kernfs: annotate different lockdep class for of->mutex of writable files
authorAmir Goldstein <amir73il@gmail.com>
Fri, 5 Apr 2024 14:56:35 +0000 (17:56 +0300)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 14 Apr 2024 10:55:46 +0000 (06:55 -0400)
commit16b52bbee4823b01ab7fe3919373c981a38f3797
treece7a54dd66475297874f9a14c370bb8a6aabb9c6
parentfec50db7033ea478773b159e0e2efb135270e3b7
kernfs: annotate different lockdep class for of->mutex of writable files

The writable file /sys/power/resume may call vfs lookup helpers for
arbitrary paths and readonly files can be read by overlayfs from vfs
helpers when sysfs is a lower layer of overalyfs.

To avoid a lockdep warning of circular dependency between overlayfs
inode lock and kernfs of->mutex, use a different lockdep class for
writable and readonly kernfs files.

Reported-by: syzbot+9a5b0ced8b1bfb238b56@syzkaller.appspotmail.com
Fixes: 0fedefd4c4e3 ("kernfs: sysfs: support custom llseek method for sysfs entries")
Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/kernfs/file.c