fs/fcntl: return -ESRCH in f_setown when pid/pgid can't be found
authorJeff Layton <jlayton@redhat.com>
Wed, 14 Jun 2017 13:11:54 +0000 (09:11 -0400)
committerJeff Layton <jlayton@redhat.com>
Wed, 14 Jun 2017 13:11:54 +0000 (09:11 -0400)
commitf73127356f344483c82632accda2e72b7e0e5f25
treea28efd5ab23bd502147d4267590ea1c79dc74b64
parentfc3dc67471461c0efcb1ed22fb7595121d65fad9
fs/fcntl: return -ESRCH in f_setown when pid/pgid can't be found

The current implementation of F_SETOWN doesn't properly vet the argument
passed in and only returns an error if INT_MIN is passed in. If the
argument doesn't specify a valid pid/pgid, then we just end up cleaning
out the file->f_owner structure.

What we really want is to only clean that out only in the case where
userland passed in an argument of 0. For anything else, we want to
return ESRCH if it doesn't refer to a valid pid.

The relevant POSIX spec page is here:

    http://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html

Cc: Jiri Slaby <jslaby@suse.cz>
Cc: zhong jiang <zhongjiang@huawei.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
fs/fcntl.c