Skip to content

Commit a215032

Browse files
committed
Merge branch 'next.uaccess-2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs into x86/cleanups
Pull uaccess cleanups from Al Viro: Consolidate the user access areas and get rid of uaccess_try(), user_ex() and other warts.
2 parents 5bacdc0 + cf122cf commit a215032

File tree

17 files changed

+401
-778
lines changed

17 files changed

+401
-778
lines changed

Documentation/x86/exception-tables.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,4 @@ pointer which points to one of:
337337
entry->insn. It is used to distinguish page faults from machine
338338
check.
339339

340-
3) ``int ex_handler_ext(const struct exception_table_entry *fixup)``
341-
This case is used for uaccess_err ... we need to set a flag
342-
in the task structure. Before the handler functions existed this
343-
case was handled by adding a large offset to the fixup to tag
344-
it as special.
345-
346340
More functions can easily be added.

arch/x86/events/core.c

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2490,7 +2490,7 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *ent
24902490
/* 32-bit process in 64-bit kernel. */
24912491
unsigned long ss_base, cs_base;
24922492
struct stack_frame_ia32 frame;
2493-
const void __user *fp;
2493+
const struct stack_frame_ia32 __user *fp;
24942494

24952495
if (!test_thread_flag(TIF_IA32))
24962496
return 0;
@@ -2501,18 +2501,12 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *ent
25012501
fp = compat_ptr(ss_base + regs->bp);
25022502
pagefault_disable();
25032503
while (entry->nr < entry->max_stack) {
2504-
unsigned long bytes;
2505-
frame.next_frame = 0;
2506-
frame.return_address = 0;
2507-
25082504
if (!valid_user_frame(fp, sizeof(frame)))
25092505
break;
25102506

2511-
bytes = __copy_from_user_nmi(&frame.next_frame, fp, 4);
2512-
if (bytes != 0)
2507+
if (__get_user(frame.next_frame, &fp->next_frame))
25132508
break;
2514-
bytes = __copy_from_user_nmi(&frame.return_address, fp+4, 4);
2515-
if (bytes != 0)
2509+
if (__get_user(frame.return_address, &fp->return_address))
25162510
break;
25172511

25182512
perf_callchain_store(entry, cs_base + frame.return_address);
@@ -2533,7 +2527,7 @@ void
25332527
perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs)
25342528
{
25352529
struct stack_frame frame;
2536-
const unsigned long __user *fp;
2530+
const struct stack_frame __user *fp;
25372531

25382532
if (perf_guest_cbs && perf_guest_cbs->is_in_guest()) {
25392533
/* TODO: We don't support guest os callchain now */
@@ -2546,7 +2540,7 @@ perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs
25462540
if (regs->flags & (X86_VM_MASK | PERF_EFLAGS_VM))
25472541
return;
25482542

2549-
fp = (unsigned long __user *)regs->bp;
2543+
fp = (void __user *)regs->bp;
25502544

25512545
perf_callchain_store(entry, regs->ip);
25522546

@@ -2558,19 +2552,12 @@ perf_callchain_user(struct perf_callchain_entry_ctx *entry, struct pt_regs *regs
25582552

25592553
pagefault_disable();
25602554
while (entry->nr < entry->max_stack) {
2561-
unsigned long bytes;
2562-
2563-
frame.next_frame = NULL;
2564-
frame.return_address = 0;
2565-
25662555
if (!valid_user_frame(fp, sizeof(frame)))
25672556
break;
25682557

2569-
bytes = __copy_from_user_nmi(&frame.next_frame, fp, sizeof(*fp));
2570-
if (bytes != 0)
2558+
if (__get_user(frame.next_frame, &fp->next_frame))
25712559
break;
2572-
bytes = __copy_from_user_nmi(&frame.return_address, fp + 1, sizeof(*fp));
2573-
if (bytes != 0)
2560+
if (__get_user(frame.return_address, &fp->return_address))
25742561
break;
25752562

25762563
perf_callchain_store(entry, frame.return_address);

0 commit comments

Comments
 (0)