]> www.infradead.org Git - users/jedix/linux-maple.git/commit
fsnotify: Avoid data race between fsnotify_recalc_mask() and fsnotify_object_watched()
authorJan Kara <jack@suse.cz>
Wed, 17 Jul 2024 14:06:23 +0000 (16:06 +0200)
committerJan Kara <jack@suse.cz>
Wed, 2 Oct 2024 13:11:40 +0000 (15:11 +0200)
commit35ceae44742e1101f9d20adadbbbd92c05d7d659
treef34ed94b97e2467f369d26edc1eaf789aee5bf4f
parent9852d85ec9d492ebef56dc5f229416c925758edc
fsnotify: Avoid data race between fsnotify_recalc_mask() and fsnotify_object_watched()

When __fsnotify_recalc_mask() recomputes the mask on the watched object,
the compiler can "optimize" the code to perform partial updates to the
mask (including zeroing it at the beginning). Thus places checking
the object mask without conn->lock such as fsnotify_object_watched()
could see invalid states of the mask. Make sure the mask update is
performed by one memory store using WRITE_ONCE().

Reported-by: syzbot+701037856c25b143f1ad@syzkaller.appspotmail.com
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Link: https://lore.kernel.org/all/CACT4Y+Zk0ohwwwHSD63U2-PQ=UuamXczr1mKBD6xtj2dyYKBvA@mail.gmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Link: https://patch.msgid.link/20240717140623.27768-1-jack@suse.cz
fs/notify/fsnotify.c
fs/notify/inotify/inotify_user.c
fs/notify/mark.c