Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dnotify: Pass argument of fcntl_dirnotify as int

The interface for fcntl expects the argument passed for the command
F_DIRNOTIFY to be of type int. The current code wrongly treats it as
a long. In order to avoid access to undefined bits, we should explicitly
cast the argument to int.

Cc: Jan Kara <jack@suse.cz>
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jeff Layton <jlayton@kernel.org>
Cc: Chuck Lever <chuck.lever@oracle.com>
Cc: Kevin Brodsky <Kevin.Brodsky@arm.com>
Cc: Vincenzo Frascino <Vincenzo.Frascino@arm.com>
Cc: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: David Laight <David.Laight@ACULAB.com>
Cc: Mark Rutland <Mark.Rutland@arm.com>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-morello@op-lists.linaro.org
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: Luca Vizzarro <Luca.Vizzarro@arm.com>
Message-Id: <20230414152459.816046-6-Luca.Vizzarro@arm.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Luca Vizzarro and committed by
Christian Brauner
f4ae4081 515c5046

+4 -4
+2 -2
fs/notify/dnotify/dnotify.c
··· 199 199 } 200 200 201 201 /* this conversion is done only at watch creation */ 202 - static __u32 convert_arg(unsigned long arg) 202 + static __u32 convert_arg(unsigned int arg) 203 203 { 204 204 __u32 new_mask = FS_EVENT_ON_CHILD; 205 205 ··· 258 258 * up here. Allocate both a mark for fsnotify to add and a dnotify_struct to be 259 259 * attached to the fsnotify_mark. 260 260 */ 261 - int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg) 261 + int fcntl_dirnotify(int fd, struct file *filp, unsigned int arg) 262 262 { 263 263 struct dnotify_mark *new_dn_mark, *dn_mark; 264 264 struct fsnotify_mark *new_fsn_mark, *fsn_mark;
+2 -2
include/linux/dnotify.h
··· 30 30 FS_MOVED_FROM | FS_MOVED_TO) 31 31 32 32 extern void dnotify_flush(struct file *, fl_owner_t); 33 - extern int fcntl_dirnotify(int, struct file *, unsigned long); 33 + extern int fcntl_dirnotify(int, struct file *, unsigned int); 34 34 35 35 #else 36 36 ··· 38 38 { 39 39 } 40 40 41 - static inline int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg) 41 + static inline int fcntl_dirnotify(int fd, struct file *filp, unsigned int arg) 42 42 { 43 43 return -EINVAL; 44 44 }