From patchwork Thu Dec 21 20:04:46 2023 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: 13502600 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 B4E36C35274 for ; Thu, 21 Dec 2023 20:05:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DBBE66B0085; Thu, 21 Dec 2023 15:05:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CCC106B0088; Thu, 21 Dec 2023 15:05:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AD04C6B0089; Thu, 21 Dec 2023 15:05:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9BB546B0085 for ; Thu, 21 Dec 2023 15:05:04 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 62B64120CDB for ; Thu, 21 Dec 2023 20:05:04 +0000 (UTC) X-FDA: 81591904128.19.3E5BDE3 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) by imf08.hostedemail.com (Postfix) with ESMTP id 8F577160024 for ; Thu, 21 Dec 2023 20:05:02 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=T3Q2NIda; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf08.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.173 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703189102; a=rsa-sha256; cv=none; b=tXNs0zMmReKzWLmxNftf5eF1UFNU7CyrEg8mZuIGiLu81U++NtreKZ7oMTSZUJ8Qwk8mwx 7OPTJ0LFV3/2IrjlssB2PVjo/Nrw0mbNZMkKTI/vf6gXJglyvgNpyjf1T+G1uqLh13b47k gXeZirIujFJItVqM9jcJ3UtGXWhfVX4= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=T3Q2NIda; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf08.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.173 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=1703189102; 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:in-reply-to:references:references:dkim-signature; bh=02IeghrfT0ytg5MuYoXhCbr9XM7hY33pPyxRWGvQP4Y=; b=8JH159qFYm5XjnOPhFqFP0aAl90qkJq3OWnWPn4gK5/c6y+Tlf2nCmSsJpP5xLBbH43j97 KhH+S7zdifu7q4ovINhVF0Tm2kZ1DtLzoIPGLOtDJecu3nR1Pa4NBQWC6ez1tgf6L2xrkw b+VQdlh/WcZshc7VvsH4aBQ1vsTok1c= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1703189101; 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: in-reply-to:in-reply-to:references:references; bh=02IeghrfT0ytg5MuYoXhCbr9XM7hY33pPyxRWGvQP4Y=; b=T3Q2NIdanun939NScwaTG7WLvoYmfTTFiLEYJ3J+HNG2IsD+W9B/KY5/3GWHlronvX+HVx UO/qV9RzLo7I2y0mo6AY2SLB81+1FFxAYBxngYWc6AIhArd5EEHVGN3+RLEDZyXA+UgF4y 2f6iUwmX7QGqhFZ2rrVU/A585fQMbwc= From: andrey.konovalov@linux.dev To: Marco Elver Cc: Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 04/11] kasan: clean up kasan_requires_meta Date: Thu, 21 Dec 2023 21:04:46 +0100 Message-Id: <8086623407095ac1c82377a2107dcc5845f99cfa.1703188911.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8F577160024 X-Stat-Signature: xonxrk7au67w6nd89r476edt7tcigq11 X-HE-Tag: 1703189102-234254 X-HE-Meta: U2FsdGVkX18e+pxw8uPM48xhfsKJsXuRy8eFfoYhijNT/eu3XXGAd5ysU75I6HaaBFC11/E1zWmYHulMi2mru0jice+Zs9WvWc7SKnHxS3aXD/vPdlmH7lg2joYkXdR9ia4RWNK0DWsFjxF63KkC6FFTwusV094fftAYE3nr/HiyTtg+Ge2JfKvh3zb1vEPcESC7J8jpiWOAV362aFDYr/KCfOwhKXuxmHQbQ0QfTPwvJcM3M7GYoJcXesNhdDboXxSW0k2S86l852fsi3rjJDOC46XjUIGdHhlNoZzeE8nMptnjXzpBk9ib6eo+uI0zpEEZXWenXHGp3/BRbm/BPsq5rmPFP1ZxWasicZaaYklMTv80YF/VjYHmnI5lOdte0zT3ZcWXx0ivB1QQQYLd7nv5lTIJtB/ehvK2F0M9veZgpp696ucY1YFWnJoS26wOvsRmWqDASRkkPd3AauW9PMfRKxdhAnnxnbI4EAHeVxpLIGuSpzpbeR7LGYbDqPHVad5XCg3N9LMowL7dGacnFg8Sesjh6tXqmDwNd+jHmR2Q6wAYQCZR5LbfrJEItrdzrhKxuIt8LulMxaWYek2zwjyOw6WLCVO7DQDS0zz4gXmmvnmLziEv/yhwzkE64Cib8VgYajIgpPuzFRd04YEoY7qNXA39YD9D+GIiI8EU8yVYhcerisMLbAto3b9rRZToMYpCNv3o+6MDzsh4qXyUbCxJdiVm6bHzKwp4LS1UNVnEmHuDW7XVwZlM9cjWi+277vUEHwTrraOrGX3kEJZzUosL7WIsuzsGJ8hoWlv+o2vgIKDKTiMIUkGzetZz1sVF95pqRaRMmLeMfqlGaw3rRY/WBXh8KErAvUS0Nn8LSY/ItM973RAaLuBZuCFEv8N4Q2F3EdeqlDti3hLF+mGJ7qB7BwENV+DBGon8ktl6jl0LcFsGaIaafv6nu4YniEF75PKTuyGlleR5AZAQR5u lxRvHVYo k2tIT1JemRfzyVAtWa02i9S/JLy79GzLf3+T0Hsevq+FuJkFiQ5kqpJSQfdVjaVFsIAIQ7aAr8H4nwZuYyjtOaXDnPY6CxNd98pKYHMSETi9g8liq9D0Es3+l6H68xxekZsqnqGBut9pCJ3FCyCkx7wk+ppg9ebq4GPxp0y4B2XR+b+DmGTDLEHzHD0HGVEuuQDv/sXI/wnT1efuEXrld+t9Dsg== 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 Currently, for Generic KASAN mode, kasan_requires_meta is defined to return kasan_stack_collection_enabled. Even though the Generic mode does not support disabling stack trace collection, kasan_requires_meta was implemented in this way to make it easier to implement the disabling for the Generic mode in the future. However, for the Generic mode, the per-object metadata also stores the quarantine link. So even if disabling stack collection is implemented, the per-object metadata will still be required. Fix kasan_requires_meta to return true for the Generic mode and update the related comments. This change does not fix any observable bugs but rather just brings the code to a cleaner state. Signed-off-by: Andrey Konovalov --- mm/kasan/kasan.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index 0e209b823b2c..38af25b9c89c 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -101,21 +101,21 @@ static inline bool kasan_sample_page_alloc(unsigned int order) #ifdef CONFIG_KASAN_GENERIC -/* Generic KASAN uses per-object metadata to store stack traces. */ +/* + * Generic KASAN uses per-object metadata to store alloc and free stack traces + * and the quarantine link. + */ static inline bool kasan_requires_meta(void) { - /* - * Technically, Generic KASAN always collects stack traces right now. - * However, let's use kasan_stack_collection_enabled() in case the - * kasan.stacktrace command-line argument is changed to affect - * Generic KASAN. - */ - return kasan_stack_collection_enabled(); + return true; } #else /* CONFIG_KASAN_GENERIC */ -/* Tag-based KASAN modes do not use per-object metadata. */ +/* + * Tag-based KASAN modes do not use per-object metadata: they use the stack + * ring to store alloc and free stack traces and do not use qurantine. + */ static inline bool kasan_requires_meta(void) { return false;