From patchwork Fri Jun 14 14:32:38 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: 13698763 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 9841EC27C79 for ; Fri, 14 Jun 2024 14:37:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 75DDA6B012E; Fri, 14 Jun 2024 10:32:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 70D576B0175; Fri, 14 Jun 2024 10:32:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FBCF6B0176; Fri, 14 Jun 2024 10:32:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 418986B012E for ; Fri, 14 Jun 2024 10:32:52 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C34DDA1F6A for ; Fri, 14 Jun 2024 14:32:51 +0000 (UTC) X-FDA: 82229735742.26.43CAE50 Received: from out-183.mta0.migadu.com (out-183.mta0.migadu.com [91.218.175.183]) by imf30.hostedemail.com (Postfix) with ESMTP id 80B6280017 for ; Fri, 14 Jun 2024 14:32:49 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Vog70K8s; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf30.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.183 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718375567; a=rsa-sha256; cv=none; b=vVNc5FoKPepwie+XnOngGPI56S/LQ32bBnm0ccA4pGQku+JJiwdm/c9cqB4RWuMTNbUOyU ekC5cVjt4m/46I8uOYz13QdMqUyxXFYtRxuLk0Uj5zy3XGAOxX1WoRapEskAWMcvUFU8dX UMAYj2VMtbdVoj2RcpHAbpAdxLHUl+I= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Vog70K8s; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf30.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.218.175.183 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718375567; 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=oKGgulHI+TDI8kNJgxolYwa/zBW01wITWhncfioM0zI=; b=Pn29a8hKFDcbb/6aYM7VhETCTjEjbW7DPb7w7KR5oK1ti+wSywE63ZTy+3/qUcMCYgNl9Z nDlO7dCW1N+Nu1ktYsgECE1U2Lp6ZwcTA5Pq5L3vHEmgzOm+tfcCI+RXrqDQrjoiRAhOvT bYgCul/j10zVrVYHxfZloDl3+z1CsDQ= X-Envelope-To: akpm@linux-foundation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1718375567; 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=oKGgulHI+TDI8kNJgxolYwa/zBW01wITWhncfioM0zI=; b=Vog70K8se6pQCOes6SgIF2PL/qN2bK1cf5TB6JsDLVUeDtIz0ZYJD7dEo85/J7yLYLznaJ HTGZZGW3DEcq7zn/muU05dwd7FZkMQtMJ3uq92PJUaAEKp5UVCENwCYuhM0KVF838BPeId 7uO4pMlYht90PiYbs2F2VlyRkJ5YusE= 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-Envelope-To: stable@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, stable@vger.kernel.org Subject: [PATCH v2] kasan: fix bad call to unpoison_slab_object Date: Fri, 14 Jun 2024 16:32:38 +0200 Message-Id: <20240614143238.60323-1-andrey.konovalov@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 80B6280017 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ft4np7fm7a65phpttt67mixbo9tinysq X-HE-Tag: 1718375569-817048 X-HE-Meta: U2FsdGVkX1/V9u/R2igxv/GOljc5TJCouVoWQRBKgb0ZsQM3rZKE+terkilpratl99FDkDnEXivxYxFAaQx9LO3UZ2sLtqpO3czPAGFAFV0br4vQdQC+nyd+nIma0+0tECkIAUwENLTATVH5FBMtJXQdNmDTAityfoRPWAQArILDGFO3rPIqucGaduyfR0uPVadpjVMEtoTrvsy8E2mk8vgUaisrfFDT0g66JsCN2qXcnXADGlBMHT/RC5HcGvCZIhmFXQfC/W1yBwNZJyrfSlEgeElCUmyFzP8bVJWegkxMUy9TyFBAjuHEINlIV7HTAZp9ejM9d7kXo/Ka8rEQqxFxaZ0kSsibeaQuVFq+UlbKIvPAr20L/PpeObJzsSjoC9rTvkH1Or+rqG2cir1rkRPnKep9SivYdVotoXgkw2Q/u3KZDZPo5w+mJRJ5WqfUXOE3l8QvJiNCt/jQURqLr1Ww02UDotGltdBFsethzASqR2Ow2RJ99me6ZYzjHwzynvD0Be3p/fgRsJNToermR04S2RmR4K9RoZK5eJjViyuD1CrD/y5MB9LtGqBQDirduAEMVBeND+yHWA3KgABSKx9Eqngi6aq90jwh5cTu3Kwq6u5zYdEEGZSyKU2EHMjTldr9/sY24yOc1lN+XDhBcR19Ibp8nhonMien9N/AFqxzzt/ay+Bu5Qu1MIqmvHWJKzrqP3OjyOSe9WNlX6ZJoQX13JkyyrG/BafDFwNUh3QZntAcKlHKohkVegk5sPhF8b+nfoK1sahVIHY8/uvvCiT6Ugh6DYWVFb0GrClHG+0PjnSNMt3nyyy2DjWs2Xtd4+7p4w5BKbMVYwl8W8/wfP/gr0los1TxFUk8e9IDfCSo4TRUoVKqtUR8E49SGbD4T6+lj46VJL+RZMMmfSP6HrX66I+q143CQYu5TFc+fEd9wg0y2Cjih8pCHpFPYTSMjuRJwLQRv/UjKkGLrcm AR4n8BLO NRhH9irwvh/WLLXmWOAXoArPcHRz/6SmUAQSiPSMyXxdgIPQ99vCerdw9sjmm3R8hPI/0CMK1+EawjafgYuHrjJqx+pSwv0Vcd1WL52ZGIRWeSdh9BVkrsWGN1G1Ph4HdizFzCU1L/IgFyJBxOBCGG1iMkhrFEy6vN6p3v1ausGhpWMMPnrv719KUsHpmuA27yGcMXFVtliolPMPAzZQKZXtSpYRPjjffkVheKkXHAVDtgVIl8xMNLxGg4e4SRJdo04e+mEvMx67Q6Fgy1mm6g5VMqYL+XN9QPId6a1VhwJffnywJ1DLgU0mjexanrujr/ZBPfnFHxWl35UoTRoVdFeVWS5tEED78yKP31VvyFjojaLJT4d2At+D7UgKaLCV06Z3oA2fSqmMdBFE= 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, __kasan_mempool_unpoison_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 Cc: stable@vger.kernel.org Acked-by: Marco Elver Signed-off-by: Andrey Konovalov --- Changes v1->v2: - Fix typo in commit message. - CC stable. --- 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))