From patchwork Fri Jun 14 14:16:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 13698753 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 1146FC27C6E for ; Fri, 14 Jun 2024 14:26:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 27AE76B012D; Fri, 14 Jun 2024 10:19:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 494396B0169; Fri, 14 Jun 2024 10:19:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A952D6B0170; Fri, 14 Jun 2024 10:19:37 -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 A70DA6B0169 for ; Fri, 14 Jun 2024 10:16:53 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4B2098076F for ; Fri, 14 Jun 2024 14:16:53 +0000 (UTC) X-FDA: 82229695506.26.EABBC23 Received: from out-171.mta0.migadu.com (out-171.mta0.migadu.com [91.218.175.171]) by imf02.hostedemail.com (Postfix) with ESMTP id 0CB0F8000E for ; Fri, 14 Jun 2024 14:16:49 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="u3XAwKX/"; spf=pass (imf02.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.171 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718374607; 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=w8jKgK+1dz6W9hZOwl0Mk0auD1tYCqkT+HhvW1YvPYs=; b=R8GVPuTxsadt7+KyJYJyIjrWzx43NFuEq4MEiuih60ITRkZKEJylK5mI/Y7Iho2edk3ku9 sQPvjxf/0KA2u0geUNhHWzTvige+mVilqXdpgZpvklchN37dgi1wdM9yy+biCJdxkBOfwX mAFZvNQC3pxEVWtGFnTcPOLM68SxYPw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="u3XAwKX/"; spf=pass (imf02.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.171 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718374607; a=rsa-sha256; cv=none; b=Qo79J6+5smHIM4xYNVY9GGvtNBp+bWS1IISh9rru2T2b0Hv1zzSIbo58GkYY+XAy1HJSqc N4aE1rVLrK+ODxJU4Xxxn4zCiUaPROh/2BGbSm7DjpxOhkvTkru7LPp6wkR3Xdr4qZP4un EO5hEHO9onDNpJw/MhO/DXCX4s4Uv3U= X-Envelope-To: akpm@linux-foundation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1718374607; 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=w8jKgK+1dz6W9hZOwl0Mk0auD1tYCqkT+HhvW1YvPYs=; b=u3XAwKX/k1yalv9l/B8981lwLsSxoU4TtJpZgfX2Otb4VYYyX1hxOsRJh/L3oDSXPcZ4TR DZcGeXteZmuoatFYJvHwCHBAZlRUb5lP2bfeGQIQ+HBKDtoPhS1ZCGuRWg+1RMKPRzoPJN tvFUngscgmmwJM1LKcwM8NNXzKcP0/Q= X-Envelope-To: andreyknvl@gmail.com X-Envelope-To: elver@google.com X-Envelope-To: glider@google.com X-Envelope-To: dvyukov@google.com X-Envelope-To: ryabinin.a.a@gmail.com X-Envelope-To: kasan-dev@googlegroups.com X-Envelope-To: linux-mm@kvack.org X-Envelope-To: spender@grsecurity.net X-Envelope-To: linux-kernel@vger.kernel.org X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, Brad Spengler , linux-kernel@vger.kernel.org Subject: [PATCH] kasan: fix bad call to unpoison_slab_object Date: Fri, 14 Jun 2024 16:16:40 +0200 Message-Id: <20240614141640.59324-1-andrey.konovalov@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0CB0F8000E X-Stat-Signature: mmexbdxs8c8zba3hse5r5taig4kcszwt X-Rspam-User: X-HE-Tag: 1718374609-117080 X-HE-Meta: U2FsdGVkX1+hNIVqFpNI6+H/q/S3kHQunAh6/uNH+lN61x7hrmfU33/MvJTLbuRJ6nFvhRgKO8+DiV9fvlLKw2FvMwege6z6lED5CM8FFqI1XNgrnNgzDRIiA/JVt5IWzlC1Fr68Seycv/1rGc33BBd/Zxy8amBAOjQaZyN+601/zPwtkSIfnI9N3yofVBiVNJLwptVeroAN/3ATmuCWjHge9gii7mpyPKQ7SQ0K9NGf+DQAkmFkaA0C0NhUa0bHl4gacasPK91tCu6jhnz/xMYnA0NQ/gHB2IS+ScSWOLpdVAmKs/Re7GLVqaEXoHn1ydrrQG3gccs6ZcvdF928Sy6WeBexrG+Q2EgRVp2DuIcOmoO8E542BpAYBoPIvx/aZVLry7PiHRzAPq8GGAwT7S1C30QydLxRqXw1YeC19qzc5yIip2jnpuHeBoCJSCSpUWbqXvZXOqt00+ghupI4KNhx80PTsuE6cA1selnxA6WxtkF/wekkHCur/nn4p2PA774ymU2NHr0FqB/j8refIk1Cijr+vX9/3yQ3uOymYSlGYMArPH7dO3nt15uYGud7VokGjATZiZNInJacqBv8rhQhEH8zZoHx1ELfekpOv2Fh6bcjHpsNa5Y0Atz9+2n4e2tQxPmGSAh03Hcxbv1d7JSTRsx+Nj0uK5j19GbcKYSxhsGkKHH/WF6I0WgeVuoQIeF8bjx9PoXCT97iI9ZsUOoDKZJS4vkfLaiL8UVCIE5bc+A+zUiF94kjg8lqDQaE7IE7O7UyCyCC7zBYds3SCFj4FtqQ/AARuzfEicrQBtiMngIgl0DdiIVqZRRFzV+2I6uHBKMFbBY+8UjOWKjxOBaf43Zh5ViuE1s5rvlR9KThqqmTZwPT8WArj//xX/4eWbgXMqfCW5goVqgmAmBXkQkpRDF9lqW1yfeRwrCmyyA6qquDsKEikwAAHd3Fjs6E3gtbwcSc4KGL+gfQxHX 7vXko68z +YCNUDsQu8cwNQJTEau70LOFMo5Fpcp6wBDNcWnwsG4dLLr9cdexQlgycPrKbS1MqSxC/RdabMeJM+UiVHTLuSFoQD+pvHBuhsxRiBuqgBzFXHOnc85Thdw05pyseghk27rc0WW6ohuWv4c9M/5XGlMKiydi7HqhRb6jC4gxNLjRs68DcJiYBr9ZnyOBAeXkYbvfbK3ipSGzPOlm2yGEj++pMSi3821zRfsMhcYb4bOHyHKfitgvuhpmuGRiDVxzr/2kUO1nAqb4sV81+tvsLYNhSijMwYugVGqHNIgHgwGJc9OVtXd1GYuJ7GYvm/LXsGtTz 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: From: Andrey Konovalov Commit 29d7355a9d05 ("kasan: save alloc stack traces for mempool") messed up one of the calls to unpoison_slab_object: the last two arguments are supposed to be GFP flags and whether to init the object memory. Fix the call. Without this fix, unpoison_slab_object provides the object's size as GFP flags to unpoison_slab_object, which can cause LOCKDEP reports (and probably other issues). Fixes: 29d7355a9d05 ("kasan: save alloc stack traces for mempool") Reported-by: Brad Spengler Signed-off-by: Andrey Konovalov Acked-by: Marco Elver --- mm/kasan/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/kasan/common.c b/mm/kasan/common.c index e7c9a4dc89f8..85e7c6b4575c 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -532,7 +532,7 @@ void __kasan_mempool_unpoison_object(void *ptr, size_t size, unsigned long ip) return; /* Unpoison the object and save alloc info for non-kmalloc() allocations. */ - unpoison_slab_object(slab->slab_cache, ptr, size, flags); + unpoison_slab_object(slab->slab_cache, ptr, flags, false); /* Poison the redzone and save alloc info for kmalloc() allocations. */ if (is_kmalloc_cache(slab->slab_cache))