···3636 unsigned long ip;3737 unsigned long sp;3838 unsigned long fp;3939+ unsigned int ws;3940 enum unwind_user_type current_type;4041 unsigned int available_types;4142 bool done;
+29-11
kernel/unwind/user.c
···88#include <linux/unwind_user.h>99#include <linux/uaccess.h>10101111-static const struct unwind_user_frame fp_frame = {1212- ARCH_INIT_USER_FP_FRAME1313-};1414-1511#define for_each_user_frame(state) \1612 for (unwind_user_start(state); !(state)->done; unwind_user_next(state))17131414+static inline int1515+get_user_word(unsigned long *word, unsigned long base, int off, unsigned int ws)1616+{1717+ unsigned long __user *addr = (void __user *)base + off;1818+#ifdef CONFIG_COMPAT1919+ if (ws == sizeof(int)) {2020+ unsigned int data;2121+ int ret = get_user(data, (unsigned int __user *)addr);2222+ *word = data;2323+ return ret;2424+ }2525+#endif2626+ return get_user(*word, addr);2727+}2828+1829static int unwind_user_next_fp(struct unwind_user_state *state)1930{2020- const struct unwind_user_frame *frame = &fp_frame;3131+ const struct unwind_user_frame frame = {3232+ ARCH_INIT_USER_FP_FRAME(state->ws)3333+ };2134 unsigned long cfa, fp, ra;22352323- if (frame->use_fp) {3636+ if (frame.use_fp) {2437 if (state->fp < state->sp)2538 return -EINVAL;2639 cfa = state->fp;···4229 }43304431 /* Get the Canonical Frame Address (CFA) */4545- cfa += frame->cfa_off;3232+ cfa += frame.cfa_off;46334734 /* stack going in wrong direction? */4835 if (cfa <= state->sp)4936 return -EINVAL;50375138 /* Make sure that the address is word aligned */5252- if (cfa & (sizeof(long) - 1))3939+ if (cfa & (state->ws - 1))5340 return -EINVAL;54415542 /* Find the Return Address (RA) */5656- if (get_user(ra, (unsigned long *)(cfa + frame->ra_off)))4343+ if (get_user_word(&ra, cfa, frame.ra_off, state->ws))5744 return -EINVAL;58455959- if (frame->fp_off && get_user(fp, (unsigned long __user *)(cfa + frame->fp_off)))4646+ if (frame.fp_off && get_user_word(&fp, cfa, frame.fp_off, state->ws))6047 return -EINVAL;61486249 state->ip = ra;6350 state->sp = cfa;6464- if (frame->fp_off)5151+ if (frame.fp_off)6552 state->fp = fp;6653 return 0;6754}···113100 state->ip = instruction_pointer(regs);114101 state->sp = user_stack_pointer(regs);115102 state->fp = frame_pointer(regs);103103+ state->ws = unwind_user_word_size(regs);104104+ if (!state->ws) {105105+ state->done = true;106106+ return -EINVAL;107107+ }116108117109 return 0;118110}