Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull misc fixes from Al Viro:
 "A couple of regression fixes, one for this merge window, one for the
  previous cycle"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  ipc/shm: Fix order of parameters when calling copy_compat_shmid_to_user
  iov_iter: fix page_copy_sane for compound pages
This commit is contained in:
Linus Torvalds 2017-09-21 05:57:50 -10:00
commit 449cd5d2a0
2 changed files with 5 additions and 3 deletions

View File

@ -1237,7 +1237,7 @@ COMPAT_SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, void __user *, uptr)
err = shmctl_stat(ns, shmid, cmd, &sem64); err = shmctl_stat(ns, shmid, cmd, &sem64);
if (err < 0) if (err < 0)
return err; return err;
if (copy_compat_shmid_to_user(&sem64, uptr, version)) if (copy_compat_shmid_to_user(uptr, &sem64, version))
err = -EFAULT; err = -EFAULT;
return err; return err;

View File

@ -687,8 +687,10 @@ EXPORT_SYMBOL(_copy_from_iter_full_nocache);
static inline bool page_copy_sane(struct page *page, size_t offset, size_t n) static inline bool page_copy_sane(struct page *page, size_t offset, size_t n)
{ {
size_t v = n + offset; struct page *head = compound_head(page);
if (likely(n <= v && v <= (PAGE_SIZE << compound_order(page)))) size_t v = n + offset + page_address(page) - page_address(head);
if (likely(n <= v && v <= (PAGE_SIZE << compound_order(head))))
return true; return true;
WARN_ON(1); WARN_ON(1);
return false; return false;