From patchwork Tue Jun 18 21:34:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shakeel Butt X-Patchwork-Id: 13703071 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24BB5C27C4F for ; Tue, 18 Jun 2024 21:34:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A82FB8D0065; Tue, 18 Jun 2024 17:34:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A31B58D005C; Tue, 18 Jun 2024 17:34:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F97C8D0065; Tue, 18 Jun 2024 17:34:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 720CD8D005C for ; Tue, 18 Jun 2024 17:34:49 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 188BE40B17 for ; Tue, 18 Jun 2024 21:34:49 +0000 (UTC) X-FDA: 82245314298.08.BEDAFB3 Received: from out-170.mta0.migadu.com (out-170.mta0.migadu.com [91.218.175.170]) by imf08.hostedemail.com (Postfix) with ESMTP id EDEEA160015 for ; Tue, 18 Jun 2024 21:34:46 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=l+gW5eaS; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf08.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.170 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718746481; a=rsa-sha256; cv=none; b=fDrKuqzHuotcrUPiapfQeKFo7B90/SY6D1uaV7lSmTjhSYttgaojWH/NXMeXU/S/lSaocH XEAtq1eQptrFUEKQpnvqLz08R15YPlXnIFp4seBi4jpu3lieX4a7luerk0qK+ASZwGkJhR sPP2JmQsQ4LBSFOkDe1G+Tt0YTo6xaI= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=l+gW5eaS; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf08.hostedemail.com: domain of shakeel.butt@linux.dev designates 91.218.175.170 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718746481; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=uCcgPhMT9v27bOz9O3+n1SaaJwS+iEnfXv26dRb41IU=; b=6wPlNNPbMprRqD7107GqA05g8aSL9s8iLCL4HnzktrA9Yv5ovDRo8JoKm/LQL4AYIvM5Ba dQi3qOaimnCBNZ1NGO7ZQdqfFg83Mey/Iwz31qMCUqzHdbjz+Lhe7g51qGYyZt1seH7jZh 6/znXVC3xu8lsSTf/DH6mxqQW4/JZ0U= X-Envelope-To: akpm@linux-foundation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1718746484; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=uCcgPhMT9v27bOz9O3+n1SaaJwS+iEnfXv26dRb41IU=; b=l+gW5eaSmKpsFqkM+8k3godaPJNaYfHtWPYvol12kbqM3FF1A/bsxydW9jA6tpASWGg3eT 9kn5eZKLHFLEDpPHMQZzfE6aS55s/SS/suUNa5lqwAinKpuzc+zEx+r/16oYaOXVfiZPcn me3P3x9MStpUft3FdisWgWEjj7hAQrs= X-Envelope-To: mhocko@kernel.org X-Envelope-To: torvalds@linux-foundation.org X-Envelope-To: kernel-team@meta.com X-Envelope-To: linux-mm@kvack.org X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: kyle@infradead.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Andrew Morton , Michal Hocko Cc: Linus Torvalds , kernel-team@meta.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Kyle McMartin Subject: [PATCH] mm: ratelimit oversized kvmalloc warnings instead of once Date: Tue, 18 Jun 2024 14:34:21 -0700 Message-ID: <20240618213421.282381-1-shakeel.butt@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: EDEEA160015 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: t3m513judnj86g1i7qdg4c464rkhdan4 X-HE-Tag: 1718746486-827788 X-HE-Meta: U2FsdGVkX1/6AD7g6Ryt0xagaP9NMk+uRDvkGK74w+q4dnB/KIzfQMqC/DoVszorphOdwiuC5ULE5MsnoMErTswsgR4j0QpzTUcUQPb309tECfZiV4M6StnU/amjytGhonpQTYL0ocUBUEDiGC2s8pZQZgSBvwl7OWy0m6cVmVjawMBQU/gbb+W/flfClsV1/mwwV5NEXcZgp837OjflH4sQg9WJkwsot1o/EDHj6dJSgxYO2gQ+oXZ5t3HMSmPfMBPQTvGfKF3CGjeAAWHIDQ0uW2V6h+QEIwbiEcGg6ZC2+NnS2KXgrfGvsZq8omONGOLqSOnAx1ZZqNJyYStpHclL7xi0rGjd+OWc8FxP5EQ/aRGN71PGwzyrIJYwK4yRrDufuXTL458OxROeOddLva1u8OUfceDvoYwCC3VyY4daGXVTTftGpX/acKDdaTw4OvErYimlIIMKsUh19EIcd2HG+iILY28sHHvQCXLIkurDuB1laIii17l75IAp90rbgy/CALYQiCJl1lGJM4M63m80O4Eb3j5KuWWsTOJhsc/YaZLdvCvZfaVZ1gdLkR575cZPDsTvHeZ5tzVKe3c0J6F9wOIf+O0kmiDzE0+OLX5VUBqHz+J75DTxBZuOutZJkJKADzNeKS6kAM3jLniiscJ/44VBImaTyERnhdCUmnRoCiq2HrB7Xno+kPlqli3hqV4d6oo/V69YsTuh47Leb2ry16B1OnLvcH6dX55kQCyxyUjnl5eRKc+wqvA6ftZY3N9O9AlqHq+neG3kk+MKHfab7IRWCvoTe/JmPVqjGYb75+UvIps5ZNnsTNt20hQ+obB2sZr+4z+9pDaXweoQ7V1bqywM5z1Oy+HQXGiOTpR1toD5CyoBwLUSwrBrjOY0ZfIJiwujQNtiv148sMdWqJ7cpkLWlIuROcmnwwfhQTS8ISEbBtGX1ZnVs4vN33ZqWlyhZLOr2nBSWb7WIRr acby9JT0 5LqqhzlvnSLoxNRIT9GE18TKHZhEjaMK4AqBZglZwAsfRs8ZBYVmIijh9YUFbqE4ct8UW/SXFdGhTtEzmXnu3ZDLwY/LJ/7KAPg6hB2Xu7AbPflBfePDxKx9QyQ3EgBh4QBy26cpLUPEuNFSwVJV3JZFc9To7dzADnt9+oJR2o8wJSiI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: At the moment oversize kvmalloc warnings are triggered once using WARN_ON_ONCE() macro. One issue with this approach is that it only detects the first abuser and then ignores the remaining abusers which complicates detecting all such abusers in a timely manner. The situation becomes worse when the repro has low probability and requires production traffic and thus require large set of machines to find such abusers. In Mera production, this warn once is slowing down the detection of these abusers. Simply replace WARN_ON_ONCE with WARN_RATELIMIT. Reported-by: Kyle McMartin Signed-off-by: Shakeel Butt --- mm/util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/util.c b/mm/util.c index 10f215985fe5..de36344e8d53 100644 --- a/mm/util.c +++ b/mm/util.c @@ -649,7 +649,8 @@ void *kvmalloc_node_noprof(size_t size, gfp_t flags, int node) /* Don't even allow crazy sizes */ if (unlikely(size > INT_MAX)) { - WARN_ON_ONCE(!(flags & __GFP_NOWARN)); + WARN_RATELIMIT(!(flags & __GFP_NOWARN), "size = %zu > INT_MAX", + size); return NULL; }