From patchwork Tue Dec 12 00:14:00 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: 13488207 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 7FC1EC4332F for ; Tue, 12 Dec 2023 00:14:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F186F6B0259; Mon, 11 Dec 2023 19:14:12 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EC8E46B025A; Mon, 11 Dec 2023 19:14:12 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D90386B025B; Mon, 11 Dec 2023 19:14:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C8C316B0259 for ; Mon, 11 Dec 2023 19:14:12 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A2A4DC08CF for ; Tue, 12 Dec 2023 00:14:12 +0000 (UTC) X-FDA: 81556243944.11.D944569 Received: from out-179.mta1.migadu.com (out-179.mta1.migadu.com [95.215.58.179]) by imf08.hostedemail.com (Postfix) with ESMTP id C028D160014 for ; Tue, 12 Dec 2023 00:14:10 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=ZFY0MXvU; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf08.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.179 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=1702340051; 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=vOaXJmSZ4mgcOuCRTmHs9viCNJ5mspLX8zhenk2W1qY=; b=HTvy3Ozw4PUfprfRS3p8wsLn0RCxH/IKBXObnFssHND4zqfH5X3wxmiuNnKb2h8mxGTJ52 iINzNMJ3aCYdpLf7gV2orVBj0T0KYYQz0xt2AEm9+j/I2FpvVGA4WlrVhrOedMN028swav neQ3cl8cOi8JwFTqOfqjIQWq32YiVmc= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=ZFY0MXvU; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf08.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.179 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702340051; a=rsa-sha256; cv=none; b=es3N3b7Lyb3buSIBADDKNMgJWYVETxwxiURsoX0NNeiMjx9HMB2HWegnNI4EA8BAI4BYEd e/GDjkvHOq+ipApVItWHFCa6r0YXj4sc1oAicWxKfpcp6Xo2sitIGifFUVXQQ+hP4Dglck XA02kQ3xsAKxXJxSOqzKKJWuo7EvVTg= 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=1702340049; 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=vOaXJmSZ4mgcOuCRTmHs9viCNJ5mspLX8zhenk2W1qY=; b=ZFY0MXvUwTln62U1tHBt6KK8Dqg+6tfH+i/GfcUa4eujPC2CC53JaDXpaZhT1eWOt98GO5 rQ36NXtwX/bnZpsUbbyhXz3bTvVFqA6FvpYHeqX+qP0YEUP3BL6KN8k/7Q6TNtfpTILzXF HbnIpR5duzaXmjUbV13x2oH9iQ3NxmE= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Tetsuo Handa , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 1/4] lib/stackdepot: add printk_deferred_enter/exit guards Date: Tue, 12 Dec 2023 01:14:00 +0100 Message-Id: <6c38c31e304a55449f76f60b6f72e35f992cad99.1702339432.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: C028D160014 X-Stat-Signature: 7t9etemgps1i9kzzc7xhmfhag74ks7h4 X-HE-Tag: 1702340050-338247 X-HE-Meta: U2FsdGVkX1/NO4XaoIiTV3CNXMXeJD6xikIBb2IGEx0Foob9VWAYtxZgBZG5Q2WVsyhkoRWPYvEyc5vHcvYriT5qHDue9w+YqxrWV3ctaJo6te1ftdyCSiZn9n2vss+JVCLuB02Z/nt03OUiqV2FtEIDiV34ZEFBKCbFP+DNqhzk1H1lkxxpDCcTBzmQ1GndWwI7iiJP3dwcz2d255YSygXX5HZhFB7+YOWD3CpP1mpr1nxIlF6FNtZjBeslGS5hYWMRbuMOhWCsKom1O94auBtjdOJMwkTC1Q4w+NDbvzlfDWMncs7YsmsSb2LnllXfiIIP5eqx2TAxCb7unlkgjZLz1hnyTu19zmMS/qvQ3tyWPMXijpf2TLC/7uIbaZ+3RM2ZJMrlr6vy3SVTZziNf1k2XBZxGdfVAtTBmt79GVsbmfMKto/iSyVun+g9sy6qYgSTvAIIXXX8XV1w+xQZuerHJUBnY70dYdNn6+z40Tl/tLk+wkSjV43L81GuZzcHQpFG7g/TzCzPD9gzuokucCVXY2WKJMeORZWhnVv7W+wHeI346hEhSXzNNwxtVf/iubbeyKjSHDe6a1hKLEZY+fGStMl+Ob1J/A4Q/nsDSR9bSQjZD81jy6LtQLHHpzus3WJbvJFDp235LaVevftWuPRBv/Ar6boINleQ7WsSNdFLvYHvyvN0G5+UAzImMR+sB1ow2HfgnvVJOSKoQCWrPnD0DDfr5Fy5DQ0fqwhYVfp2LTZExN+0DMbzE2SmU5FgBVxY9yLaCGHXx5x/L7sZQxNSMhKpFdV8l+aIdv6TF2g0f4MVG06TYp3TewsFF1mXJaUu7s4blO0zagcjWXgtFVtrwY5KPdZBn87mUC/rJwrPqIsoDlkEMhELv0UdiG4BIqf6hnmWWZv7eFIlnQAJPirltTM0raBuMAp8/+YxXrGb6MVRaYHnrii2WX6RUQLCkfpY4ZmIfB4QjXON3k9 XfxGWbxW /2YLj4ASotOqhrU9FdDG67Z/GrykTdY1OrmnLMPhsQ2ICkipcxGXDyZzU41s9vLdHMPfn6mBWEhyXdA7KHIfvm8k4mikO1HiL6mjIBuJAvQqrn2boxbzZeZH0KiHaTPCJL/1DJTv0rrBd1dCuu8EdKYnIxuX5oNU7qYCunKNJ/L4OflY= 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 Stack depot functions can be called from various contexts that do allocations, including with console locks taken. At the same time, stack depot functions might print WARNING's or refcount-related failures. This can cause a deadlock on console locks. Add printk_deferred_enter/exit guards to stack depot to avoid this. Reported-by: Tetsuo Handa Closes: https://lore.kernel.org/all/000000000000f56750060b9ad216@google.com/ Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver --- lib/stackdepot.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 870cce2f4cbd..a0be5d05c7f0 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -506,12 +506,14 @@ depot_stack_handle_t stack_depot_save_flags(unsigned long *entries, bucket = &stack_table[hash & stack_hash_mask]; read_lock_irqsave(&pool_rwlock, flags); + printk_deferred_enter(); /* Fast path: look the stack trace up without full locking. */ found = find_stack(bucket, entries, nr_entries, hash); if (found) { if (depot_flags & STACK_DEPOT_FLAG_GET) refcount_inc(&found->count); + printk_deferred_exit(); read_unlock_irqrestore(&pool_rwlock, flags); goto exit; } @@ -520,6 +522,7 @@ depot_stack_handle_t stack_depot_save_flags(unsigned long *entries, if (new_pool_required) need_alloc = true; + printk_deferred_exit(); read_unlock_irqrestore(&pool_rwlock, flags); /* @@ -541,6 +544,7 @@ depot_stack_handle_t stack_depot_save_flags(unsigned long *entries, } write_lock_irqsave(&pool_rwlock, flags); + printk_deferred_enter(); found = find_stack(bucket, entries, nr_entries, hash); if (!found) { @@ -562,6 +566,7 @@ depot_stack_handle_t stack_depot_save_flags(unsigned long *entries, depot_keep_new_pool(&prealloc); } + printk_deferred_exit(); write_unlock_irqrestore(&pool_rwlock, flags); exit: if (prealloc) { @@ -600,9 +605,11 @@ unsigned int stack_depot_fetch(depot_stack_handle_t handle, return 0; read_lock_irqsave(&pool_rwlock, flags); + printk_deferred_enter(); stack = depot_fetch_stack(handle); + printk_deferred_exit(); read_unlock_irqrestore(&pool_rwlock, flags); *entries = stack->entries; @@ -619,6 +626,7 @@ void stack_depot_put(depot_stack_handle_t handle) return; write_lock_irqsave(&pool_rwlock, flags); + printk_deferred_enter(); stack = depot_fetch_stack(handle); if (WARN_ON(!stack)) @@ -633,6 +641,7 @@ void stack_depot_put(depot_stack_handle_t handle) } out: + printk_deferred_exit(); write_unlock_irqrestore(&pool_rwlock, flags); } EXPORT_SYMBOL_GPL(stack_depot_put); From patchwork Tue Dec 12 00:14:01 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: 13488210 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 355A8C4332F for ; Tue, 12 Dec 2023 00:14:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0C346B025F; Mon, 11 Dec 2023 19:14:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BBE386B0260; Mon, 11 Dec 2023 19:14:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E8486B0266; Mon, 11 Dec 2023 19:14:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 841566B0260 for ; Mon, 11 Dec 2023 19:14:14 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 58245A089D for ; Tue, 12 Dec 2023 00:14:14 +0000 (UTC) X-FDA: 81556244028.25.C02591F Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) by imf02.hostedemail.com (Postfix) with ESMTP id A2F9780002 for ; Tue, 12 Dec 2023 00:14:11 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="UvkDjF/5"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf02.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.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=1702340051; 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=x4Cn8Rdft153TNfaMCqmpUoRbUij/xgpu9Ka1HxHDYI=; b=5HDkt0c9KCZGICqSubMLEGlmah+H7YyolZloUbdLd95xwGwSe3xdNvdAUAcwSP0/psGzc0 HsWUyH5W5ltFuuOP2w/WozVccBK/HrpPdIJKvlP8pugEnq7oT229r5wXC8BVUi/QGQI3/1 IJW6Q0Sn5kLftRXglDTZkdBlEuiZsiw= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="UvkDjF/5"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf02.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.183 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702340051; a=rsa-sha256; cv=none; b=nz88ixOJwL5unT+lzL7Q8+TpkQflkJQYWb7wxbOcsxMIqeEJmHxw3wMtFue+uaSp4fTgBb rpHxTj+cQR/5vhXR6eRtVKro2d0o8f+kC56JjtBbK2+1czBOkE6BXXZm+IKqQbZkzqLGuH 0KXHTCsqZu86djB8BAjnp8CwqZR7cdM= 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=1702340049; 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=x4Cn8Rdft153TNfaMCqmpUoRbUij/xgpu9Ka1HxHDYI=; b=UvkDjF/5ctTo0nGnQabktnmBPXGfus3/X3idORYN6B4D44rXq0KJToDsQKy9BeHFX8qw7b qQCY+W0sZZweOoacCTj/1cWItkpd82s9p4KPKbjHROXaD7+UwOj6FNmJAKaJ2G1O+XKX3R d6piyZ++vR5FIz/37yANY5B0lerp6zk= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Tetsuo Handa , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov , syzbot+186b55175d8360728234@syzkaller.appspotmail.com Subject: [PATCH mm 2/4] kasan: handle concurrent kasan_record_aux_stack calls Date: Tue, 12 Dec 2023 01:14:01 +0100 Message-Id: <432a89fafce11244287c8af757e73a2eb22a5354.1702339432.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: A2F9780002 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: h8kj3kftqu3zd34ixzt33n7xgkxe58tz X-HE-Tag: 1702340051-416519 X-HE-Meta: U2FsdGVkX19l503M12lCamZV1Y2ydUrXlWfRFDIhlcoyV3I5dKhvjw7DURiVaQ6i4+Z8WHvziQhLqP2me+D0Z18Iy5sT+AvsHRuSUBkWYJADoQLVVvC55i5+ROM/pyae9v4E7/yDgH3BF/CjE524DqFrlBLKkwJM/5bYysNxO/wCrjCwkTNM5ZQIpKqgcAXH/rui9os2fXW4+JjowzNK2w4WOJaouL0Q+VudYfKNO5oaiyXZVaG0/t1RrnnEEGbIGVMSf3WthpBqspACaoVYBvgn7v9UB973suIZo+zzw0aribj0yrxu1zb8BBORv+EO92jFQWm+oz2CQy1pFRffObE0YFOFrYZyYmr7AV97Mxi1OnS5B6jPLP2Tpea5U8IUhC/WQtmffi1hvz2ZhJCMtozMJhaQlgFjGHn1FXOSjAK6ZrzLByQuoPfdpIb9SHKHzDrDi/rLhjiL35c38ivRBAXx/d29AS9w15bnJUnuFBGq0oqmYw/4lXcWb0GOnrKI9caQUdi27i1VimcPh5QfzH9Q9rLzbkDfnbkN0nzuXtlZO5L1ddHX/gXp8+6edCqKjAOTQvkSRUGBVGWiwojOwR+Spknir95EVtOZFAslutH1pU+DQFqbdD4k4OUEu+la7Nx0K697DjBaEPe4Lb6TAwuMrwhCEFdttLH9XzZdeTsETPj9igk58bPfjjVqWsxXe4PV8SR1ukPVjX96weRn9UFRXqJDOBt6MBgW19a9BjxYTpRzvyOVwRbChqmBfoW1hP5Uyihrg3Sooj9SHSRtz74IxUk167gpNdObVE18FgNCdy+20uzYL2IlL4gLr9hJfU9RhyO/MEwUk/R41d+n8FnDteVG5eq+TsZxEzR8PdVX3jTJEOUBnOnha3iOu+T8ekHzjw2Ca1i5DPPLc/kA0+Fk7bsy/mx9JzqrmzpFdMg4sX9VFbaIQ++KEgwPFirNcdt6XRcQJrSWg0Qh0RK W4yp7smD isglCELzeciNwCLZtSnkJP8cYU3Ti7vZa0OueqW1gxRPruPfBFesNssGD6Jy9n9tcoszbdi70sYgKzud4apiq+kwQsZGznqgKsAiI0o/ym4iuCgPWm9B9l0F2EKXvv6gg4+qDelNFgdTit3qTR/90HzPgTS7Bg7yAXXs9bLzKskNzmTAnjRpdM2ls+UVEEzUVqkRvkEVnCtXJlQZcXZalJA4qjTx7igMmaUbsDKbtfBQAm/NFgqRtU+wj+8m7l3C7MNX3xkANZc8MtNgNqfYORHsYToNJVQdZ2837HPx3INQocO0G/JhBCd/Yo7Sl80tiDeBz 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 kasan_record_aux_stack can be called concurrently on the same object. This might lead to a race condition when rotating the saved aux stack trace handles. Fix by introducing a spinlock to protect the aux stack trace handles in kasan_record_aux_stack. Reported-by: Tetsuo Handa Reported-by: syzbot+186b55175d8360728234@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/000000000000784b1c060b0074a2@google.com/ Signed-off-by: Andrey Konovalov --- This can be squashed into "kasan: use stack_depot_put for Generic mode" or left standalone. --- mm/kasan/generic.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c index 54e20b2bc3e1..ca5c75a1866c 100644 --- a/mm/kasan/generic.c +++ b/mm/kasan/generic.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -35,6 +36,8 @@ #include "kasan.h" #include "../slab.h" +DEFINE_SPINLOCK(aux_lock); + /* * All functions below always inlined so compiler could * perform better optimizations in each of __asan_loadX/__assn_storeX @@ -502,6 +505,8 @@ static void __kasan_record_aux_stack(void *addr, depot_flags_t depot_flags) struct kmem_cache *cache; struct kasan_alloc_meta *alloc_meta; void *object; + depot_stack_handle_t new_handle, old_handle; + unsigned long flags; if (is_kfence_address(addr) || !slab) return; @@ -512,9 +517,15 @@ static void __kasan_record_aux_stack(void *addr, depot_flags_t depot_flags) if (!alloc_meta) return; - stack_depot_put(alloc_meta->aux_stack[1]); + new_handle = kasan_save_stack(0, depot_flags); + + spin_lock_irqsave(&aux_lock, flags); + old_handle = alloc_meta->aux_stack[1]; alloc_meta->aux_stack[1] = alloc_meta->aux_stack[0]; - alloc_meta->aux_stack[0] = kasan_save_stack(0, depot_flags); + alloc_meta->aux_stack[0] = new_handle; + spin_unlock_irqrestore(&aux_lock, flags); + + stack_depot_put(old_handle); } void kasan_record_aux_stack(void *addr) From patchwork Tue Dec 12 00:14:02 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: 13488209 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 BCBCAC4332F for ; Tue, 12 Dec 2023 00:14:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 618D96B025C; Mon, 11 Dec 2023 19:14:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A31D6B025F; Mon, 11 Dec 2023 19:14:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3CF706B0260; Mon, 11 Dec 2023 19:14:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 258C26B025C for ; Mon, 11 Dec 2023 19:14:14 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id DC1F0A1CA9 for ; Tue, 12 Dec 2023 00:14:13 +0000 (UTC) X-FDA: 81556243986.30.7A4BFDD Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) by imf29.hostedemail.com (Postfix) with ESMTP id 2B4FF120019 for ; Tue, 12 Dec 2023 00:14:11 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=AhuNEvWc; spf=pass (imf29.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.183 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=1702340052; 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=OwbAGppKL3WPs8Dt+2mYc7aec7Z15bPqx/lY8lY4n/4=; b=JpOJy0rENMpofmsQw8EBsLqx501CLQG+E8O4/SYN0XH26qG+5fwPu20f5ki2K+hvceFq90 iy8Y3hv/zagzwBGrh2DP7SGzu8b6g5Zj+7L8irRIWeOylfJE4+Ba4WwJpMa1T2EaorSRg8 wLTgnQ0kyF35bdbK7Boei7a5/Rolu9c= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702340052; a=rsa-sha256; cv=none; b=Chr81hA/S58NDpvnh6JWkELagvdwEEfhsayJ1KaAvwz79gWcnt94jOpfoYRSgq7Ts1kaPg 84bq6T/oTKxz1JNVM1qxRpDWUxLH90Pd7JG0XDyobxtpy4ECYVhEHrpvaznEdIj3K/Xwma BaEqF9uw0a1MXQEDp0yuvkS7vy3sA0w= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=AhuNEvWc; spf=pass (imf29.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.183 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=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=1702340050; 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=OwbAGppKL3WPs8Dt+2mYc7aec7Z15bPqx/lY8lY4n/4=; b=AhuNEvWc+xId+ebmaR6PLfGdXFqw+Wg1SNRrPQ1ZlK1Sc1etaByaW4J7PAGKThBVnj447n j8TePKCfHAMCJ1KwilljkT2LUfiq2L5u0pH0HA7XJfeRd1JbF++UGx/w+zfsttHD227a+f IZQYQmT7JGekNhMS5pIy488rlfoaazI= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Tetsuo Handa , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 3/4] kasan: memset free track in qlink_free Date: Tue, 12 Dec 2023 01:14:02 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: 2B4FF120019 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: iity8qeg3ob98c8z68mrppakkjyajc76 X-HE-Tag: 1702340051-855339 X-HE-Meta: U2FsdGVkX1/j6/yOm119qlEvToIkebPCawC08H16I6etIm98KNVmeXPK2edHRM8xnevRxLriCTpySfK6R40tmpFqI1uYSHWfNVzX26wqUkr20RpsJid7iTyGHns/X7ZC4cI87tBMesVb4mGPegv0yR1nSr9muPBWJh8YBGDsX2gsIA/C5lQyymM9uWSrWYzXs0gAhclTB8J3LRHLLijTjykQuugzfXEcpkAYp4lw44VVR3KLYVrd9pueFwt9zn3rdys8ABDMeEteJosht7kIOoVJLLJxejQu6P4ChPiphxRJFg0mf0T8VvteCJGVEz/UhwaHPT+fMjWFPoDmWsRBJTZnWOFJ+JUTiDBfbca7H35V0hvU61CEXuVSPBMqJh4tcMjw4DVudqZ9G4emh91CVxrQz1EfeI6c32oePTxuaJoAsaXtw2HZS7f2zwxduNoGutl41ajUaSdgmYUpJfP3pkF52CDFF73zoLjC4t20URbFTVq4zi+NGvvslQfxRL3DSdbZwITSkb63d6mr7cRkxV/x42jRZUwy/HCEBIJ1Q9jv5vQVRyS3BzlBHypSVDLZfqUKyWw72xrl8I3/RvBwW12t3qoNI5MKPOyYcpHMT7skABYm1MZD1t9cAMIDdutZ53TMOlctFv/3W2wGRKOrgJBRH9eewYXwGqvdJv46Q/Oeex4bFSPuSwTllbImIz4qCsxzp5CIAvCZPkkSEZ8zJOFshowA6mRsmeaHRR2Exud0yhunir1xx29GTFOmv5ohx+qBmhs+GFaxXJPpBgNW94cDBhdusOweKRx8nOWLN0F5TU7tLrX6+cTB4XOXb3jHZ8G/QM8pP6Mr5ftC0khL1WPUfmPPY4UaCrp+1kQ4QXOsFJ7ziPXF6TNJVTCyQzMT1HP4DoduhSBR0l7tsS0S9PvukICYQGb9UnqImkZLhoa7L9z1p2TRQnBEHn8ERRFvYefOZ+/usuoDTmIpSHt Zco92dTm I2v9HtmAxm0MdxkIcmWfgywGObdcA6GHilPH8b4S8eUm5biNSAkcFjanXSSIeLSfiS7X6jxvVi7Oz+GCRlVIrbVXQYGhF8ihPojg/vsla4YDeMrA= 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 Instead of only zeroing out the stack depot handle when evicting the free stack trace in qlink_free, zero out the whole track. Do this just to produce a similar effect for alloc and free meta. The other fields of the free track besides the stack trace handle are considered invalid at this point anyway, so no harm in zeroing them out. Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver --- This can be squashed into "kasan: use stack_depot_put for Generic mode" or left standalone. --- mm/kasan/quarantine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c index 265ca2bbe2dd..782e045da911 100644 --- a/mm/kasan/quarantine.c +++ b/mm/kasan/quarantine.c @@ -157,7 +157,7 @@ static void qlink_free(struct qlist_node *qlink, struct kmem_cache *cache) if (free_meta && *(u8 *)kasan_mem_to_shadow(object) == KASAN_SLAB_FREETRACK) { stack_depot_put(free_meta->free_track.stack); - free_meta->free_track.stack = 0; + __memset(&free_meta->free_track, 0, sizeof(free_meta->free_track)); } /* From patchwork Tue Dec 12 00:14:03 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: 13488211 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 E6A54C4332F for ; Tue, 12 Dec 2023 00:14:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 94EB26B0260; Mon, 11 Dec 2023 19:14:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D61B6B0269; Mon, 11 Dec 2023 19:14:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79E4E6B026A; Mon, 11 Dec 2023 19:14:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 6A8D46B0260 for ; Mon, 11 Dec 2023 19:14:15 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4A6C112085C for ; Tue, 12 Dec 2023 00:14:15 +0000 (UTC) X-FDA: 81556244070.17.12F8C37 Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) by imf23.hostedemail.com (Postfix) with ESMTP id 975FF140015 for ; Tue, 12 Dec 2023 00:14:12 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=pkglrqnI; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf23.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.178 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702340052; a=rsa-sha256; cv=none; b=UvBXyCGj7o8rb3JMnKz9s9h1E8VBAZi2K2e812akxIikaQzuucHMaYicmpP4PSilLZ9enI dYxKUTXbAa64jFOrP1nwwN5ENG1bXyoYbGBvwgfhx8TULAuJZzSlnd1bEbJRZPSZWWcfdf q72lhTpjR7v7vmZURNUDn1gipfhJHOo= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=pkglrqnI; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf23.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.178 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=1702340052; 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=4v2xeqlY3bmUQ3FXCYD1mACtOfLEO5nvek1y1ZiQa0s=; b=oXxlfo9PmoYqskhGBzWvKs97J6JqduGBX8kWhcPMrL9Q7mkd3R0vBR4QdY16U/QGZkV/BE IU+eJwJmafF2/Y5MUPjbWkRPkY7XqIQYAW/mx3nNCt9/WchPHDBcWFibXvMcR/A2xdPuP0 BZIBZ7udb7Ft3tOhwpHYq6iwwDyokZQ= 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=1702340051; 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=4v2xeqlY3bmUQ3FXCYD1mACtOfLEO5nvek1y1ZiQa0s=; b=pkglrqnIvLL1i2TrN6B8oPzonG4Tx1w7mQXL6y13N9tGc5e12sY7eb+AJFYGp9qNNRA6C8 fsFj5WhSBPxuf9OzL/2ucnnjhPh0g/dy12UZ2lGf3lPYNFaJYLPQY3wu39tWi6RGT9VYZk uDz7QstHoOYA5j+8ntWl6s9I7C6+Dv4= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Vlastimil Babka , kasan-dev@googlegroups.com, Evgenii Stepanov , Tetsuo Handa , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 4/4] lib/stackdepot: fix comment in include/linux/stackdepot.h Date: Tue, 12 Dec 2023 01:14:03 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 975FF140015 X-Stat-Signature: azy5y4ck9s9x8ttbe95ka7akojhr1qg9 X-HE-Tag: 1702340052-355768 X-HE-Meta: U2FsdGVkX1/a5R1BPwpKjXb0UVCUa2UlYZtBbY7Mb8iRmvx3YZ4oaWVrcyzGrzVFXfszF2AzrxuCqcQ5ScMgHrSoWc2PFz4pgOix2y0DBNQ7Wh03+K0bBeue3beH0xE7BMY4WJ8LYOeYFsRjd8A1UP1PJ/avrCA2bUKHuOrXvYuUYic5Z7WOsn/I34+o28hWrz29r9RE1HXlbUvaFP/muU2Csl49qrnJD96S1HDrljKRRKe920RodExqK04xbMq4gyGMjDDnMmk4ncGF13pbfcMaQUaf3FxK/Gp5f+mcJ3ESHmf38kpiuNQybZ+bXI8qtPgXyGmaSyMi8k4BD6Y5qnRUnsIglPWydSROJffT/aQaqCdRszrEgdubEmqWGugA4AezYewHsISj2UCpTAEXhtbv33yxW03NOzumZYzfcjr9WdC9k2NE6Z2DGK+YIzKLOq8ffefVdQFWzHqRIC9WiDvy3AoLKtcYkZtTuGtDUcHJQacyB3QPq2IiMHOKUzIm7ICzca8rDJx7mXkmH1J74X3mD41o4Ge1TAcV21rd4MgY27/fo74A/zb8jJr4gUwfA8sxa4Sgg8mQ2anAXJTqZ6jZxK2D9AqnDfYtOGJ0+T+uGwlDB37jMrmM/gcHo4pcrm8aIveOyAKN5p81g9NQ9hBncflUnzSjMWLyyfJBPBgFS1Q8tpIJp6PFaqFHgAGvV7TVQd4leVtknfbSKG4rfYuAs54SH8fwsVaIzkn6VEx1aip1CjkVs2hUDW8afFA/GiNGtkjTJPEC9h3qJ6HtSEM5IcO14Wi8fFvuQtZrwZcuEk+kPH8wrw0pV4yIw9K0+6NRMprEt/Vy2ONiLOPwrOBHViYVYrjTu4eWhhMgaDTGUyQMaHyn8CIHB2wBHAR/2YSKM2jTu1/Bu54WnzMjjy76B601R+uYCJvWBdEU9tFsLCCJnLJBUSz59xGr0KWS13hrFptMbO3agUt7bpq nge8fyLJ 1F7l3SZMKPDloBfSTYGNk7tV7lNQ8vGhZgrVZuvpLtAsjwPz8DVYZPsUZLF3WpVG/OY80 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 As stack traces can now be evicted from the stack depot, remove the comment saying that they are never removed. Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver --- Can be squashed into "lib/stackdepot: allow users to evict stack traces" or left standalone. --- include/linux/stackdepot.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/linux/stackdepot.h b/include/linux/stackdepot.h index a6796f178913..adcbb8f23600 100644 --- a/include/linux/stackdepot.h +++ b/include/linux/stackdepot.h @@ -11,8 +11,6 @@ * SLUB_DEBUG needs 256 bytes per object for that). Since allocation and free * stack traces often repeat, using stack depot allows to save about 100x space. * - * Stack traces are never removed from the stack depot. - * * Author: Alexander Potapenko * Copyright (C) 2016 Google, Inc. *