From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796381038; b=wfwyRhbwoNgxVwt+e6AFxVRfcV5XuVcxN5v8RJklOz16PK2VjtFyAJx4k/3mss8KF63i Ky4bnJQ1U4gVx9bUuTCTacZnRiuh6H6ADwVoQl+HeQGiIDwbeybYAxKGSP8uHMbRDmx2I LrmPZlF9wVU8XSqd/tEOuP/Bm64loL40zvyINaVBdMBGVx48skcv9lH71vuTXj++icAKN 0uzHtsYiJ6VHqQNZjU+Hhd7HvT2dQGqdiDzpIiedb5qCGx7tw0dsCuT512wOP6tPn7f+w YJ54iIwmvB8219Rf5S3WePNs5j1kuvqGPEDPL1rkdfDG8eslrNYp4Djo+wTkVwbqXDg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381038; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=oRYupeu8Kw84amO+FS3je/n5b7tY4E4I7QzyJ2yoHlY=; b=ulq0jCvW6dEbYfXG04XkoiO32gcoxwM4Gvmhnq+wkRDikHkKoN/dbw/jPHt9RY/16zaL GxTQ60z6vNwy1IsnmbtZR/r6am6wtfLUsT5kAh9XYkAsdZXoOJ1398INZ2dsbe3znZvnu 5+YnTTd/BHiKwibMamya2hR2xdSdMwX8eMksFuiGael+QCrEZzQkW4WgpyDjUNSgVTMaX ezGoom9Q4ibABrnpTR6LNXS3/S+QXPoqiYY1pqsrstgeQxHmxAQuWOB6sNQT8ng3OvtgS fWCfUi+ibe0MyYT1wJrf+z90QZhcImwOZc3H8VcdIECISl4kkgrJQUmDBh9KiY1ltSQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=vkbpyFJF; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BE9F606A330; Fri, 4 Dec 2026 10:43:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=vkbpyFJF Received: by smtp.kernel.org (Postfix) with ESMTPSA id B1F271F00933; Fri, 4 Dec 2026 10:43:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381038; bh=oRYupeu8Kw84amO+FS3je/n5b7tY4E4I7QzyJ2yoHlY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vkbpyFJFws5v5u6su2xLYYC8heYmPwu0IZ6EzSjDT5KA9GHgC+JI15M3VnJwL9zPA m/XHOd7YgVS7ADcDccT69ir4fmKDO2XR2fVv0qL1pJJhQ7Wxy6Fi5HCXB/fUMy1itQ MgCesr61v2Mi29yv3V3Z5AU46p73GL2yqqAn7OR0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joas Antonio dos Santos , Andrew Morton , syzbot+91e1fc35f51774c479b2@syzkaller.appspotmail.com, David Hildenbrand , Muchun Song , Oscar Salvador , Hongbo Li Subject: [PATCH 7.3 490/742] hugetlbfs: move hugetlbfs_free_inode tracepoint to ->destroy_inode() Date: Fri, 4 Dec 2026 19:05:54 +0900 Message-ID: <20261204100648.153534757@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Joas Antonio dos Santos commit ccf8bda05b19dc144bc7051936b08573476499ee upstream. hugetlbfs_free_inode() calls trace_hugetlbfs_free_inode(), and the hugetlbfs__inode event class records inode->i_sb->s_dev. ->free_inode() runs from an RCU callback (destroy_inode() queues i_callback() with call_rcu()), and Documentation/filesystems/porting.rst says that this callback "is *NOT* ordered wrt superblock destruction; as the matter of fact, the superblock and all associated structures might be already gone". put_super() frees the superblock with call_rcu() followed by a workqueue item (destroy_super_rcu() -> destroy_super_work()). syzbot hit this with the event enabled: BUG: KASAN: slab-use-after-free in trace_event_raw_event_hugetlbfs__inode+0x45b/0x4c0 include/trace/events/hugetlbfs.h:36 Read of size 4 at addr ffff888038850010 by task syz-executor952/6134 hugetlbfs_free_inode+0x15e/0x1f0 fs/hugetlbfs/inode.c:1182 i_callback+0x46/0x80 fs/inode.c:317 rcu_do_batch kernel/rcu/tree.c:2650 [inline] rcu_core+0x5f0/0x1220 kernel/rcu/tree.c:2919 Allocated by task 6134: alloc_super fs/super.c:326 [inline] sget_fc+0x1ba/0x1f60 fs/super.c:874 hugetlbfs_get_tree+0x1e7/0x2b0 fs/hugetlbfs/inode.c:1431 Freed by task 855: kfree+0x22b/0x6d0 mm/slub.c:6923 process_one_work+0xac7/0x1b10 kernel/workqueue.c:3495 Emit the event from hugetlbfs_destroy_inode() instead. destroy_inode() calls ->destroy_inode() synchronously, before it queues the RCU callback, while the superblock is still alive; hugetlbfs_destroy_inode() already dereferences inode->i_sb there. ->free_inode() is left with only the kmem_cache_free(). Since the event no longer fires from ->free_inode(), rename it to hugetlbfs_destroy_inode so that its name matches where it is emitted, as suggested by David and Muchun. Found by syzbot; analysed and tested with the syzbot C reproducer on an arm64 KASAN kernel. Link: https://lore.kernel.org/20261102-b4-hugetlbfs-trace-v4-1-72371825bb5e@gmail.com Fixes: 014ad7c42a69 ("hugetlbfs: use tracepoints in hugetlbfs functions.") Signed-off-by: Joas Antonio dos Santos Signed-off-by: Andrew Morton Reported-by: Closes: https://lore.kernel.org/all/6ae27525.5451848c.f7707.0001.GAE@google.com/ Suggested-by: David Hildenbrand Suggested-by: Muchun Song Reviewed-by: Muchun Song Acked-by: David Hildenbrand (Arm) Cc: Oscar Salvador Cc: Hongbo Li Cc: Signed-off-by: Greg Kroah-Hartman --- fs/hugetlbfs/inode.c | 2 +- include/trace/events/hugetlbfs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -1184,12 +1184,12 @@ static struct inode *hugetlbfs_alloc_ino static void hugetlbfs_free_inode(struct inode *inode) { - trace_hugetlbfs_free_inode(inode); kmem_cache_free(hugetlbfs_inode_cachep, HUGETLBFS_I(inode)); } static void hugetlbfs_destroy_inode(struct inode *inode) { + trace_hugetlbfs_destroy_inode(inode); hugetlbfs_inc_free_inodes(HUGETLBFS_SB(inode->i_sb)); } --- a/include/trace/events/hugetlbfs.h +++ b/include/trace/events/hugetlbfs.h @@ -72,7 +72,7 @@ DEFINE_EVENT(hugetlbfs__inode, hugetlbfs TP_ARGS(inode) ); -DEFINE_EVENT(hugetlbfs__inode, hugetlbfs_free_inode, +DEFINE_EVENT(hugetlbfs__inode, hugetlbfs_destroy_inode, TP_PROTO(struct inode *inode),