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: 182437 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp659453dyi; Thu, 21 Dec 2023 12:06:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IH0MQtJqfhcF2Hs0C3+aoEwo04spimwdpuE6mFfLxzX8C4hI9Url8f4h/PEc9YnrsXUemMS X-Received: by 2002:a05:6a20:da:b0:18b:d207:d857 with SMTP id 26-20020a056a2000da00b0018bd207d857mr246457pzh.11.1703189187751; Thu, 21 Dec 2023 12:06:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703189187; cv=none; d=google.com; s=arc-20160816; b=nqMbpi7FmpFW+kfukVf9MfGFLi4MYGrZHCZMATYwkirt9akcU/GYL/H6r5j0A742Id UlQpkvpT8qS30Z2ZPJfV863DQ956fBWNB00IQBWO/KTqIKFxJQxm3Wm3Rad9+k9wyQRc K15Kl1d7wpwZrGvazBgwfATwO4ZiMPhciFK7RhqsIknPD2xNdNqHdA/4dzmvNUBnJ1gY AS3k9zsvcHv68q2ST7snCnZ1VoJdFulFf2M0ONcBbl5O4bLHqvZv9iViw2oLYJR2XP9g 20sFSWIO01grfcNbKxNLMJaDNKqQTnXMpqEveXvTGIkVOk3xt/w1GyCFkeN07MieK3yy Y1jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=02IeghrfT0ytg5MuYoXhCbr9XM7hY33pPyxRWGvQP4Y=; fh=GyTEpUCUNPwsl1pqA0jDPXgvja+iZTM9USlQd9sQtQg=; b=uGZ7udGgRq33tvZwLMj6hVs0gIijD4MD8ou8b5d9V7Zuv1nUlBBm4+w4Mvh6Pb3o1w 2MBJVsH2zseb0bzBQDji0OW4vb4mO4jNA5RYMbiBaN/AMBHW/MBDTZqpb7lGZfAL7zjU QSxx1aS2ANyIYIe9xM6BFk5EOTBv4mDkNJtMHR4tBZHsOMnQkNN+PwTJ0LA7K8sfKPyL Q6Rg6POWj9szrGtYuvEx4TgrLn0zbhXMqK/OUrPEGDn+XXaYzPgOadb2NwbSYkVO0gTp jBX8uEqn8eIgMQjppKy/tjocCNTAoioxR8A5PLwaqxFBcgSVVcAlTg10pbQGn9AjkJ1N 8TPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=T3Q2NIda; spf=pass (google.com: domain of linux-kernel+bounces-9022-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9022-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z10-20020a056a001d8a00b006ce7f143603si2082769pfw.184.2023.12.21.12.06.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 12:06:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9022-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=T3Q2NIda; spf=pass (google.com: domain of linux-kernel+bounces-9022-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9022-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 0B60C288FB1 for ; Thu, 21 Dec 2023 20:06:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2006B77629; Thu, 21 Dec 2023 20:05:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="T3Q2NIda" X-Original-To: linux-kernel@vger.kernel.org Received: from out-185.mta1.migadu.com (out-185.mta1.migadu.com [95.215.58.185]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E565355E6C for ; Thu, 21 Dec 2023 20:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785923305609934520 X-GMAIL-MSGID: 1785923305609934520 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;