On 01-02-2023 16:50, Luca Vizzarro wrote:
The interface for fcntl expects the argument passed for the command F_SETSIG to be of type int. The current code wrongly treats it as a long.
This commit changes the signature of all the related and helper functions so that they treat the argument as int instead of long.
Signed-off-by: Luca Vizzarro Luca.Vizzarro@arm.com
fs/fcntl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/fcntl.c b/fs/fcntl.c index 918d0136d12b..22eb0ae23421 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -390,7 +390,7 @@ static long do_fcntl(int fd, unsigned int cmd, user_uintptr_t arg, break; case F_SETSIG: /* arg == 0 restores default behaviour. */
if (!valid_signal(arg)) {
} err = 0;if (!valid_signal((int)arg)) { break;
Hi Luca,
arg is also used here just below this line:
filp->f_owner.signum = arg;
signum is an int, so the top bytes are discarded, so it's fine, but this could easily be missed when something changes. I suggest having a local int variable, such as:
int argi = (int)arg;
and use this variable in all the cases where int is expected. This is a similar approach to argp, for the cases where a user pointer is expected. This would make the code clearer as well IMO.
Thanks, Tudor