summaryrefslogtreecommitdiffstats
path: root/net/compat.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-01-03 21:57:57 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-01-03 21:57:57 -0500
commit96d4f267e40f9509e8a66e2b39e8b95655617693 (patch)
treedf03d142d405652392707b1b80c284d68d6ea6ab /net/compat.c
parent135143b2cac43d2a1ec73b53033b9473fbbcce6d (diff)
Remove 'type' argument from access_ok() function
Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument of the user address range verification function since we got rid of the old racy i386-only code to walk page tables by hand. It existed because the original 80386 would not honor the write protect bit when in kernel mode, so you had to do COW by hand before doing any user access. But we haven't supported that in a long time, and these days the 'type' argument is a purely historical artifact. A discussion about extending 'user_access_begin()' to do the range checking resulted this patch, because there is no way we're going to move the old VERIFY_xyz interface to that model. And it's best done at the end of the merge window when I've done most of my merges, so let's just get this done once and for all. This patch was mostly done with a sed-script, with manual fix-ups for the cases that weren't of the trivial 'access_ok(VERIFY_xyz' form. There were a couple of notable cases: - csky still had the old "verify_area()" name as an alias. - the iter_iov code had magical hardcoded knowledge of the actual values of VERIFY_{READ,WRITE} (not that they mattered, since nothing really used it) - microblaze used the type argument for a debug printout but other than those oddities this should be a total no-op patch. I tried to fix up all architectures, did fairly extensive grepping for access_ok() uses, and the changes are trivial, but I may have missed something. Any missed conversion should be trivially fixable, though. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'net/compat.c')
-rw-r--r--net/compat.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/net/compat.c b/net/compat.c
index c3a2f868e8af..959d1c51826d 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -358,7 +358,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
358 358
359 if (optlen < sizeof(*up)) 359 if (optlen < sizeof(*up))
360 return -EINVAL; 360 return -EINVAL;
361 if (!access_ok(VERIFY_READ, up, sizeof(*up)) || 361 if (!access_ok(up, sizeof(*up)) ||
362 __get_user(ktime.tv_sec, &up->tv_sec) || 362 __get_user(ktime.tv_sec, &up->tv_sec) ||
363 __get_user(ktime.tv_usec, &up->tv_usec)) 363 __get_user(ktime.tv_usec, &up->tv_usec))
364 return -EFAULT; 364 return -EFAULT;
@@ -438,7 +438,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
438 438
439 if (!err) { 439 if (!err) {
440 if (put_user(sizeof(*up), optlen) || 440 if (put_user(sizeof(*up), optlen) ||
441 !access_ok(VERIFY_WRITE, up, sizeof(*up)) || 441 !access_ok(up, sizeof(*up)) ||
442 __put_user(ktime.tv_sec, &up->tv_sec) || 442 __put_user(ktime.tv_sec, &up->tv_sec) ||
443 __put_user(ktime.tv_usec, &up->tv_usec)) 443 __put_user(ktime.tv_usec, &up->tv_usec))
444 err = -EFAULT; 444 err = -EFAULT;
@@ -590,8 +590,8 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
590 compat_alloc_user_space(sizeof(struct group_req)); 590 compat_alloc_user_space(sizeof(struct group_req));
591 u32 interface; 591 u32 interface;
592 592
593 if (!access_ok(VERIFY_READ, gr32, sizeof(*gr32)) || 593 if (!access_ok(gr32, sizeof(*gr32)) ||
594 !access_ok(VERIFY_WRITE, kgr, sizeof(struct group_req)) || 594 !access_ok(kgr, sizeof(struct group_req)) ||
595 __get_user(interface, &gr32->gr_interface) || 595 __get_user(interface, &gr32->gr_interface) ||
596 __put_user(interface, &kgr->gr_interface) || 596 __put_user(interface, &kgr->gr_interface) ||
597 copy_in_user(&kgr->gr_group, &gr32->gr_group, 597 copy_in_user(&kgr->gr_group, &gr32->gr_group,
@@ -611,8 +611,8 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
611 sizeof(struct group_source_req)); 611 sizeof(struct group_source_req));
612 u32 interface; 612 u32 interface;
613 613
614 if (!access_ok(VERIFY_READ, gsr32, sizeof(*gsr32)) || 614 if (!access_ok(gsr32, sizeof(*gsr32)) ||
615 !access_ok(VERIFY_WRITE, kgsr, 615 !access_ok(kgsr,
616 sizeof(struct group_source_req)) || 616 sizeof(struct group_source_req)) ||
617 __get_user(interface, &gsr32->gsr_interface) || 617 __get_user(interface, &gsr32->gsr_interface) ||
618 __put_user(interface, &kgsr->gsr_interface) || 618 __put_user(interface, &kgsr->gsr_interface) ||
@@ -631,7 +631,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
631 struct group_filter __user *kgf; 631 struct group_filter __user *kgf;
632 u32 interface, fmode, numsrc; 632 u32 interface, fmode, numsrc;
633 633
634 if (!access_ok(VERIFY_READ, gf32, __COMPAT_GF0_SIZE) || 634 if (!access_ok(gf32, __COMPAT_GF0_SIZE) ||
635 __get_user(interface, &gf32->gf_interface) || 635 __get_user(interface, &gf32->gf_interface) ||
636 __get_user(fmode, &gf32->gf_fmode) || 636 __get_user(fmode, &gf32->gf_fmode) ||
637 __get_user(numsrc, &gf32->gf_numsrc)) 637 __get_user(numsrc, &gf32->gf_numsrc))
@@ -641,7 +641,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
641 if (koptlen < GROUP_FILTER_SIZE(numsrc)) 641 if (koptlen < GROUP_FILTER_SIZE(numsrc))
642 return -EINVAL; 642 return -EINVAL;
643 kgf = compat_alloc_user_space(koptlen); 643 kgf = compat_alloc_user_space(koptlen);
644 if (!access_ok(VERIFY_WRITE, kgf, koptlen) || 644 if (!access_ok(kgf, koptlen) ||
645 __put_user(interface, &kgf->gf_interface) || 645 __put_user(interface, &kgf->gf_interface) ||
646 __put_user(fmode, &kgf->gf_fmode) || 646 __put_user(fmode, &kgf->gf_fmode) ||
647 __put_user(numsrc, &kgf->gf_numsrc) || 647 __put_user(numsrc, &kgf->gf_numsrc) ||
@@ -675,7 +675,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
675 return getsockopt(sock, level, optname, optval, optlen); 675 return getsockopt(sock, level, optname, optval, optlen);
676 676
677 koptlen = compat_alloc_user_space(sizeof(*koptlen)); 677 koptlen = compat_alloc_user_space(sizeof(*koptlen));
678 if (!access_ok(VERIFY_READ, optlen, sizeof(*optlen)) || 678 if (!access_ok(optlen, sizeof(*optlen)) ||
679 __get_user(ulen, optlen)) 679 __get_user(ulen, optlen))
680 return -EFAULT; 680 return -EFAULT;
681 681
@@ -685,14 +685,14 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
685 if (klen < GROUP_FILTER_SIZE(0)) 685 if (klen < GROUP_FILTER_SIZE(0))
686 return -EINVAL; 686 return -EINVAL;
687 687
688 if (!access_ok(VERIFY_WRITE, koptlen, sizeof(*koptlen)) || 688 if (!access_ok(koptlen, sizeof(*koptlen)) ||
689 __put_user(klen, koptlen)) 689 __put_user(klen, koptlen))
690 return -EFAULT; 690 return -EFAULT;
691 691
692 /* have to allow space for previous compat_alloc_user_space, too */ 692 /* have to allow space for previous compat_alloc_user_space, too */
693 kgf = compat_alloc_user_space(klen+sizeof(*optlen)); 693 kgf = compat_alloc_user_space(klen+sizeof(*optlen));
694 694
695 if (!access_ok(VERIFY_READ, gf32, __COMPAT_GF0_SIZE) || 695 if (!access_ok(gf32, __COMPAT_GF0_SIZE) ||
696 __get_user(interface, &gf32->gf_interface) || 696 __get_user(interface, &gf32->gf_interface) ||
697 __get_user(fmode, &gf32->gf_fmode) || 697 __get_user(fmode, &gf32->gf_fmode) ||
698 __get_user(numsrc, &gf32->gf_numsrc) || 698 __get_user(numsrc, &gf32->gf_numsrc) ||
@@ -706,18 +706,18 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
706 if (err) 706 if (err)
707 return err; 707 return err;
708 708
709 if (!access_ok(VERIFY_READ, koptlen, sizeof(*koptlen)) || 709 if (!access_ok(koptlen, sizeof(*koptlen)) ||
710 __get_user(klen, koptlen)) 710 __get_user(klen, koptlen))
711 return -EFAULT; 711 return -EFAULT;
712 712
713 ulen = klen - (sizeof(*kgf)-sizeof(*gf32)); 713 ulen = klen - (sizeof(*kgf)-sizeof(*gf32));
714 714
715 if (!access_ok(VERIFY_WRITE, optlen, sizeof(*optlen)) || 715 if (!access_ok(optlen, sizeof(*optlen)) ||
716 __put_user(ulen, optlen)) 716 __put_user(ulen, optlen))
717 return -EFAULT; 717 return -EFAULT;
718 718
719 if (!access_ok(VERIFY_READ, kgf, klen) || 719 if (!access_ok(kgf, klen) ||
720 !access_ok(VERIFY_WRITE, gf32, ulen) || 720 !access_ok(gf32, ulen) ||
721 __get_user(interface, &kgf->gf_interface) || 721 __get_user(interface, &kgf->gf_interface) ||
722 __get_user(fmode, &kgf->gf_fmode) || 722 __get_user(fmode, &kgf->gf_fmode) ||
723 __get_user(numsrc, &kgf->gf_numsrc) || 723 __get_user(numsrc, &kgf->gf_numsrc) ||