fsnotify: Fix NULL ptr deref in fanotify_get_fsid()
Subsystems (3)
Jan Kara
maintainerPATCH 1/1 fsnotify: Fix NULL ptr deref in fanotify_get_fsid()
fanotify_get_fsid() is reading mark->connector->fsid under srcu. It can happen that it sees mark not fully initialized and thus mark->connector is still NULL leading to NULL ptr dereference. Fix the problem by setting mark->connector before adding mark to the object's list and use appropriate memory barriers to make sure proper mark->connector value is seen for any mark added to the list.
Reported-by [email protected]
Fixes 77115225acc6 ("fanotify: cache fsid in fsnotify_mark_connector")
Signed-off-by Jan Kara <[email protected]>
--- fs/notify/fanotify/fanotify.c | 2 +- fs/notify/mark.c | 43 +++++++++++++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 15 deletions(-)
fs/notify/fanotify/fanotify.c +1 -1
@@ -349,7 +349,7 @@ static __kernel_fsid_t fanotify_get_fsid(struct fsnotify_iter_info *iter_info)if (!fsnotify_iter_should_report_type (iter_info, type))continue ; - fsid = iter_info->marks[type]->connector->fsid; + fsid =READ_ONCE (iter_info->marks[type]->connector)->fsid;if (WARN_ON_ONCE (!fsid.val[0 ] && !fsid.val[1 ]))continue ;return fsid;
fs/notify/mark.c +29 -14
93 lines not on this page · raw message
Signature · 1 line
2.16.4