Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp388828rdb; Thu, 21 Dec 2023 12:05:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9bY8aPZdMDtotZnSkceLlXocxGUuyfbFb+fQqx/UZsRZslfqfnn8PEG/UqfEyQynmyVaM X-Received: by 2002:a05:6a00:b50:b0:6ce:2731:a089 with SMTP id p16-20020a056a000b5000b006ce2731a089mr232089pfo.56.1703189140479; Thu, 21 Dec 2023 12:05:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703189140; cv=none; d=google.com; s=arc-20160816; b=sT8GodZlwb94R1789DiOrVImb6pZMFqPdVCDkYLbNBNL2sR+J2G0CYNk1qqhYZv1OH 9CVBC+JmNtV7n6Ejz7h9515crHpnKIndxLe//PDfOWDEk+gt8YrkAzkbFvzmw/jMIL6s T5FI0nc7o34E6SDkMtO38FZFglH0uBmC1Q81ogdFYx34xXgKhyb1mLpVDc2YZZHSdId3 j0UGb6LYXqI82bGQPFppWUT2GLedXPGdPTTz081XmAyQhqprpMHMMVYVWOJxvHhfjn/+ 7YsWWzCPoAhi1nddizfpzLSMlfUNwKJ4gydNJnHWH3x4fVdQevh4K4R6rpnXHKvJtyrh jD0A== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9022-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x26-20020aa784da000000b006ce97669ffdsi1992124pfn.358.2023.12.21.12.05.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 12:05:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9022-linux.lists.archive=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-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9022-linux.lists.archive=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 CC716286BE3 for ; Thu, 21 Dec 2023 20:05:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B51B760BF; Thu, 21 Dec 2023 20:05:05 +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 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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; -- 2.25.1