Re: [PATCH] arch: tile: kernel: signal.c: Use explicitly type case "unsigned long *" for register copy
On 11/2/14 4:23, Al Viro wrote: > On Sat, Nov 01, 2014 at 08:49:45PM +0800, Chen Gang wrote: >> setup_sigcontext() wants to copy all kernel related registers to user >> space. So let it copy explicitly instead of copying by exceeding member >> array border. So let code more clearer and avoid warning. > > Er... Perhaps it would be better to avoid that shite completely and just > use __copy_to_user() instead of bothering with loops? > OK, thanks, I shall send patch v2 for it. Also use __copy_from_user() instead of the code in restore_sigcontext(). Thanks -- Chen Gang Open, share, and attitude like air, water, and life which God blessed -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] arch: tile: kernel: signal.c: Use explicitly type case "unsigned long *" for register copy
On Sat, Nov 01, 2014 at 08:49:45PM +0800, Chen Gang wrote: > setup_sigcontext() wants to copy all kernel related registers to user > space. So let it copy explicitly instead of copying by exceeding member > array border. So let code more clearer and avoid warning. Er... Perhaps it would be better to avoid that shite completely and just use __copy_to_user() instead of bothering with loops? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] arch: tile: kernel: signal.c: Use explicitly type case "unsigned long *" for register copy
setup_sigcontext() wants to copy all kernel related registers to user space. So let it copy explicitly instead of copying by exceeding member array border. So let code more clearer and avoid warning. And for register, better use "unsigned long" instead of "long", too. The related warning (with allmodconfig under tile): CC arch/tile/kernel/signal.o In file included from include/linux/poll.h:11:0, from include/linux/ring_buffer.h:7, from include/linux/ftrace_event.h:5, from include/trace/syscall.h:6, from include/linux/syscalls.h:81, from arch/tile/kernel/signal.c:30: arch/tile/kernel/signal.c: In function 'setup_sigcontext': arch/tile/kernel/signal.c:116:31: warning: iteration 53u invokes undefined behavior [-Waggressive-loop-optimizations] err |= __put_user(regs->regs[i], >gregs[i]); ^ ./arch/tile/include/asm/uaccess.h:236:26: note: in definition of macro '__put_user_asm' : "r" (ptr), "r" (x), "i" (-EFAULT)) ^ ./arch/tile/include/asm/uaccess.h:297:10: note: in expansion of macro '__put_user_8' case 8: __put_user_8(x, ptr, __ret); break; \ ^ arch/tile/kernel/signal.c:116:10: note: in expansion of macro '__put_user' err |= __put_user(regs->regs[i], >gregs[i]); ^ arch/tile/kernel/signal.c:115:2: note: containing loop for (i = 0; i < sizeof(struct pt_regs)/sizeof(long); ++i) ^ Signed-off-by: Chen Gang --- arch/tile/kernel/signal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/tile/kernel/signal.c b/arch/tile/kernel/signal.c index 7c2fecc..a584ea1 100644 --- a/arch/tile/kernel/signal.c +++ b/arch/tile/kernel/signal.c @@ -112,8 +112,9 @@ int setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs) { int i, err = 0; - for (i = 0; i < sizeof(struct pt_regs)/sizeof(long); ++i) - err |= __put_user(regs->regs[i], >gregs[i]); + for (i = 0; i < sizeof(regs)/sizeof(unsigned long); ++i) + err |= __put_user(((unsigned long *)regs)[i], + &((unsigned long *)sc)[i]); return err; } -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] arch: tile: kernel: signal.c: Use explicitly type case unsigned long * for register copy
setup_sigcontext() wants to copy all kernel related registers to user space. So let it copy explicitly instead of copying by exceeding member array border. So let code more clearer and avoid warning. And for register, better use unsigned long instead of long, too. The related warning (with allmodconfig under tile): CC arch/tile/kernel/signal.o In file included from include/linux/poll.h:11:0, from include/linux/ring_buffer.h:7, from include/linux/ftrace_event.h:5, from include/trace/syscall.h:6, from include/linux/syscalls.h:81, from arch/tile/kernel/signal.c:30: arch/tile/kernel/signal.c: In function 'setup_sigcontext': arch/tile/kernel/signal.c:116:31: warning: iteration 53u invokes undefined behavior [-Waggressive-loop-optimizations] err |= __put_user(regs-regs[i], sc-gregs[i]); ^ ./arch/tile/include/asm/uaccess.h:236:26: note: in definition of macro '__put_user_asm' : r (ptr), r (x), i (-EFAULT)) ^ ./arch/tile/include/asm/uaccess.h:297:10: note: in expansion of macro '__put_user_8' case 8: __put_user_8(x, ptr, __ret); break; \ ^ arch/tile/kernel/signal.c:116:10: note: in expansion of macro '__put_user' err |= __put_user(regs-regs[i], sc-gregs[i]); ^ arch/tile/kernel/signal.c:115:2: note: containing loop for (i = 0; i sizeof(struct pt_regs)/sizeof(long); ++i) ^ Signed-off-by: Chen Gang gang.chen.5...@gmail.com --- arch/tile/kernel/signal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/tile/kernel/signal.c b/arch/tile/kernel/signal.c index 7c2fecc..a584ea1 100644 --- a/arch/tile/kernel/signal.c +++ b/arch/tile/kernel/signal.c @@ -112,8 +112,9 @@ int setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs) { int i, err = 0; - for (i = 0; i sizeof(struct pt_regs)/sizeof(long); ++i) - err |= __put_user(regs-regs[i], sc-gregs[i]); + for (i = 0; i sizeof(regs)/sizeof(unsigned long); ++i) + err |= __put_user(((unsigned long *)regs)[i], + ((unsigned long *)sc)[i]); return err; } -- 1.9.3 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] arch: tile: kernel: signal.c: Use explicitly type case unsigned long * for register copy
On Sat, Nov 01, 2014 at 08:49:45PM +0800, Chen Gang wrote: setup_sigcontext() wants to copy all kernel related registers to user space. So let it copy explicitly instead of copying by exceeding member array border. So let code more clearer and avoid warning. Er... Perhaps it would be better to avoid that shite completely and just use __copy_to_user() instead of bothering with loops? -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] arch: tile: kernel: signal.c: Use explicitly type case unsigned long * for register copy
On 11/2/14 4:23, Al Viro wrote: On Sat, Nov 01, 2014 at 08:49:45PM +0800, Chen Gang wrote: setup_sigcontext() wants to copy all kernel related registers to user space. So let it copy explicitly instead of copying by exceeding member array border. So let code more clearer and avoid warning. Er... Perhaps it would be better to avoid that shite completely and just use __copy_to_user() instead of bothering with loops? OK, thanks, I shall send patch v2 for it. Also use __copy_from_user() instead of the code in restore_sigcontext(). Thanks -- Chen Gang Open, share, and attitude like air, water, and life which God blessed -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/