linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Abinash Singh <abinashlalotra@gmail.com>
To: jack@suse.cz, amir73il@gmail.com
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Abinash Singh <abinashsinghlalotra@gmail.com>,
	syzbot+aaeb1646d01d0358cb2a@syzkaller.appspotmail.com
Subject: [PATCH v3] fsnotify: initialize destroy_next to avoid KMSAN uninit-value warning
Date: Thu, 19 Jun 2025 17:46:52 +0530	[thread overview]
Message-ID: <20250619121652.126502-1-abinashsinghlalotra@gmail.com> (raw)

KMSAN reported an uninitialized value use in
fsnotify_connector_destroy_workfn(), specifically when accessing
`conn->destroy_next`:

    BUG: KMSAN: uninit-value in fsnotify_connector_destroy_workfn+0x108/0x160
    Uninit was created at:
     slab_alloc_node mm/slub.c:4197 [inline]
     kmem_cache_alloc_noprof+0x81b/0xec0 mm/slub.c:4204
     fsnotify_attach_connector_to_object fs/notify/mark.c:663

The struct fsnotify_mark_connector was allocated using
kmem_cache_alloc(), but the `destroy_next` field was never initialized,
leading to a use of uninitialized memory when the work function later
traversed the destroy list.

Fix this by explicitly initializing `destroy_next` to NULL immediately
after allocation.

Reported-by: syzbot+aaeb1646d01d0358cb2a@syzkaller.appspotmail.com
Signed-off-by: Abinash Singh <abinashsinghlalotra@gmail.com>

---
v3: Corrected the Author name
---
 fs/notify/mark.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/notify/mark.c b/fs/notify/mark.c
index 798340db69d7..28013046f732 100644
--- a/fs/notify/mark.c
+++ b/fs/notify/mark.c
@@ -665,6 +665,7 @@ static int fsnotify_attach_connector_to_object(fsnotify_connp_t *connp,
 		return -ENOMEM;
 	spin_lock_init(&conn->lock);
 	INIT_HLIST_HEAD(&conn->list);
+	conn->destroy_next = NULL;
 	conn->flags = 0;
 	conn->prio = 0;
 	conn->type = obj_type;
-- 
2.43.0


                 reply	other threads:[~2025-06-19 12:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250619121652.126502-1-abinashsinghlalotra@gmail.com \
    --to=abinashlalotra@gmail.com \
    --cc=abinashsinghlalotra@gmail.com \
    --cc=amir73il@gmail.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+aaeb1646d01d0358cb2a@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).