Skip to content

Commit

Permalink
mm: return EBADF if pidfd is invalid
Browse files Browse the repository at this point in the history
This patch makes returning of EBADF when the fd passed as argument is
invalid. The implementaion relies on pidfd_get_pid's error return.

This patch also fixes syscall declare part since we removed pid support.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Minchan Kim <[email protected]>
Cc: Suren Baghdasaryan <[email protected]>
Cc: Christian Brauner <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Stephen Rothwell <[email protected]>
  • Loading branch information
minchank authored and sfrothwell committed Jun 5, 2020
1 parent d8d78ae commit fa6c19e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
6 changes: 3 additions & 3 deletions include/linux/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -827,10 +827,10 @@ asmlinkage long compat_sys_pwritev64v2(unsigned long fd,
unsigned long vlen, loff_t pos, rwf_t flags);
#endif

asmlinkage ssize_t compat_sys_process_madvise(compat_int_t which,
compat_pid_t upid, const struct compat_iovec __user *vec,
asmlinkage ssize_t compat_sys_process_madvise(compat_int_t pidfd,
const struct compat_iovec __user *vec,
compat_ulong_t vlen, compat_int_t behavior,
compat_ulong_t flags);
compat_int_t flags);

/*
* Deprecated system calls which are still defined in
Expand Down
5 changes: 2 additions & 3 deletions include/linux/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -879,9 +879,8 @@ asmlinkage long sys_munlockall(void);
asmlinkage long sys_mincore(unsigned long start, size_t len,
unsigned char __user * vec);
asmlinkage long sys_madvise(unsigned long start, size_t len, int behavior);
asmlinkage long sys_process_madvise(int which, pid_t upid,
const struct iovec __user *vec, unsigned long vlen,
int behavior, unsigned long flags);
asmlinkage long sys_process_madvise(int pidfd, const struct iovec __user *vec,
unsigned long vlen, int behavior, unsigned int flags);
asmlinkage long sys_remap_file_pages(unsigned long start, unsigned long size,
unsigned long prot, unsigned long pgoff,
unsigned long flags);
Expand Down
3 changes: 0 additions & 3 deletions mm/madvise.c
Original file line number Diff line number Diff line change
Expand Up @@ -1242,9 +1242,6 @@ static ssize_t do_process_madvise(int pidfd, struct iov_iter *iter,
if (flags != 0)
return -EINVAL;

if (pidfd < 0)
return -EINVAL;

pid = pidfd_get_pid(pidfd);
if (IS_ERR(pid))
return PTR_ERR(pid);
Expand Down

0 comments on commit fa6c19e

Please sign in to comment.