Skip to contentSkip to conversation

fanotify: remove unneeded sub-zero check for unsigned value

PATCH In review Nikita Kiryushin 2 participants 2 messages Mar 14, 2024 – Mar 25, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fanotify: remove unneeded sub-zero check for unsigned value

Unsigned size_t len in copy_fid_info_to_user is checked for negative value. This check is redundant as it is always false.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 5e469c830fdb ("fanotify: copy event fid info to user")
---
 fs/notify/fanotify/fanotify_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/notify/fanotify/fanotify_user.c +1 -1
index fbdc63cc10d9..4201723357cf 100644
@@ -502,7 +502,7 @@ static int copy_fid_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh,
 	}
 
 	/* Pad with 0's */
-	WARN_ON_ONCE(len < 0 || len >= FANOTIFY_EVENT_ALIGN);
+	WARN_ON_ONCE(len >= FANOTIFY_EVENT_ALIGN);
 	if (len > 0 && clear_user(buf, len))
 		return -EFAULT;
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 9 lines · Nikita Kiryushin

Unsigned size_t len in copy_fid_info_to_user is checked for negative value. This check is redundant as it is always false.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 5e469c830fdb ("fanotify: copy event fid info to user")

Looks good. Added to my tree. Thanks!

Honza

Quoted 18 lines
---
 fs/notify/fanotify/fanotify_user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/notify/fanotify/fanotify_user.c +1 -1
index fbdc63cc10d9..4201723357cf 100644
@@ -502,7 +502,7 @@ static int copy_fid_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh,
 	}
 	/* Pad with 0's */
-	WARN_ON_ONCE(len < 0 || len >= FANOTIFY_EVENT_ALIGN);
+	WARN_ON_ONCE(len >= FANOTIFY_EVENT_ALIGN);
 	if (len > 0 && clear_user(buf, len))
 		return -EFAULT;
Signature · 1 line
2.34.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR