Skip to content

Commit 96d4f26

Browse files
committed
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 <[email protected]>
1 parent 135143b commit 96d4f26

File tree

221 files changed

+610
-679
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+610
-679
lines changed

arch/alpha/include/asm/futex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
6868
int ret = 0, cmp;
6969
u32 prev;
7070

71-
if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
71+
if (!access_ok(uaddr, sizeof(u32)))
7272
return -EFAULT;
7373

7474
__asm__ __volatile__ (

arch/alpha/include/asm/uaccess.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#define __access_ok(addr, size) \
3737
((get_fs().seg & (addr | size | (addr+size))) == 0)
3838

39-
#define access_ok(type, addr, size) \
39+
#define access_ok(addr, size) \
4040
({ \
4141
__chk_user_ptr(addr); \
4242
__access_ok(((unsigned long)(addr)), (size)); \

arch/alpha/kernel/signal.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ SYSCALL_DEFINE3(osf_sigaction, int, sig,
6565

6666
if (act) {
6767
old_sigset_t mask;
68-
if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
68+
if (!access_ok(act, sizeof(*act)) ||
6969
__get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
7070
__get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
7171
__get_user(mask, &act->sa_mask))
@@ -77,7 +77,7 @@ SYSCALL_DEFINE3(osf_sigaction, int, sig,
7777
ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
7878

7979
if (!ret && oact) {
80-
if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
80+
if (!access_ok(oact, sizeof(*oact)) ||
8181
__put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
8282
__put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
8383
__put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
@@ -207,7 +207,7 @@ do_sigreturn(struct sigcontext __user *sc)
207207
sigset_t set;
208208

209209
/* Verify that it's a good sigcontext before using it */
210-
if (!access_ok(VERIFY_READ, sc, sizeof(*sc)))
210+
if (!access_ok(sc, sizeof(*sc)))
211211
goto give_sigsegv;
212212
if (__get_user(set.sig[0], &sc->sc_mask))
213213
goto give_sigsegv;
@@ -235,7 +235,7 @@ do_rt_sigreturn(struct rt_sigframe __user *frame)
235235
sigset_t set;
236236

237237
/* Verify that it's a good ucontext_t before using it */
238-
if (!access_ok(VERIFY_READ, &frame->uc, sizeof(frame->uc)))
238+
if (!access_ok(&frame->uc, sizeof(frame->uc)))
239239
goto give_sigsegv;
240240
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
241241
goto give_sigsegv;
@@ -332,7 +332,7 @@ setup_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs)
332332

333333
oldsp = rdusp();
334334
frame = get_sigframe(ksig, oldsp, sizeof(*frame));
335-
if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
335+
if (!access_ok(frame, sizeof(*frame)))
336336
return -EFAULT;
337337

338338
err |= setup_sigcontext(&frame->sc, regs, set->sig[0], oldsp);
@@ -377,7 +377,7 @@ setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs)
377377

378378
oldsp = rdusp();
379379
frame = get_sigframe(ksig, oldsp, sizeof(*frame));
380-
if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
380+
if (!access_ok(frame, sizeof(*frame)))
381381
return -EFAULT;
382382

383383
err |= copy_siginfo_to_user(&frame->info, &ksig->info);

arch/alpha/lib/csum_partial_copy.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst, int len,
333333
unsigned long doff = 7 & (unsigned long) dst;
334334

335335
if (len) {
336-
if (!access_ok(VERIFY_READ, src, len)) {
336+
if (!access_ok(src, len)) {
337337
if (errp) *errp = -EFAULT;
338338
memset(dst, 0, len);
339339
return sum;

arch/arc/include/asm/futex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, u32 expval,
126126
int ret = 0;
127127
u32 existval;
128128

129-
if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
129+
if (!access_ok(uaddr, sizeof(u32)))
130130
return -EFAULT;
131131

132132
#ifndef CONFIG_ARC_HAS_LLSC

arch/arc/kernel/process.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
6161
/* Z indicates to userspace if operation succeded */
6262
regs->status32 &= ~STATUS_Z_MASK;
6363

64-
ret = access_ok(VERIFY_WRITE, uaddr, sizeof(*uaddr));
64+
ret = access_ok(uaddr, sizeof(*uaddr));
6565
if (!ret)
6666
goto fail;
6767

arch/arc/kernel/signal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ SYSCALL_DEFINE0(rt_sigreturn)
169169

170170
sf = (struct rt_sigframe __force __user *)(regs->sp);
171171

172-
if (!access_ok(VERIFY_READ, sf, sizeof(*sf)))
172+
if (!access_ok(sf, sizeof(*sf)))
173173
goto badframe;
174174

175175
if (__get_user(magic, &sf->sigret_magic))
@@ -219,7 +219,7 @@ static inline void __user *get_sigframe(struct ksignal *ksig,
219219
frame = (void __user *)((sp - framesize) & ~7);
220220

221221
/* Check that we can actually write to the signal frame */
222-
if (!access_ok(VERIFY_WRITE, frame, framesize))
222+
if (!access_ok(frame, framesize))
223223
frame = NULL;
224224

225225
return frame;

arch/arm/include/asm/futex.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
5050
int ret;
5151
u32 val;
5252

53-
if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
53+
if (!access_ok(uaddr, sizeof(u32)))
5454
return -EFAULT;
5555

5656
smp_mb();
@@ -104,7 +104,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
104104
int ret = 0;
105105
u32 val;
106106

107-
if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
107+
if (!access_ok(uaddr, sizeof(u32)))
108108
return -EFAULT;
109109

110110
preempt_disable();

arch/arm/include/asm/uaccess.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ static inline void set_fs(mm_segment_t fs)
279279

280280
#endif /* CONFIG_MMU */
281281

282-
#define access_ok(type, addr, size) (__range_ok(addr, size) == 0)
282+
#define access_ok(addr, size) (__range_ok(addr, size) == 0)
283283

284284
#define user_addr_max() \
285285
(uaccess_kernel() ? ~0UL : get_fs())
@@ -560,7 +560,7 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
560560

561561
static inline unsigned long __must_check clear_user(void __user *to, unsigned long n)
562562
{
563-
if (access_ok(VERIFY_WRITE, to, n))
563+
if (access_ok(to, n))
564564
n = __clear_user(to, n);
565565
return n;
566566
}

arch/arm/kernel/perf_callchain.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ user_backtrace(struct frame_tail __user *tail,
3737
struct frame_tail buftail;
3838
unsigned long err;
3939

40-
if (!access_ok(VERIFY_READ, tail, sizeof(buftail)))
40+
if (!access_ok(tail, sizeof(buftail)))
4141
return NULL;
4242

4343
pagefault_disable();

0 commit comments

Comments
 (0)