Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/kyle/parisc-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/kyle/parisc-2.6:
parisc: use __ratelimit in unaligned.c
parisc: Convert to read/update_persistent_clock
parisc: Simplify param.h by including <asm-generic/param.h>
parisc: drop unnecessary cast in __ldcw_align() macro
parisc: add strict copy size checks (v2)
parisc: remove trailing space in messages
parisc: ditto sys_accept4
parisc: wire up sys_recvmmsg

+69 -57
+14
arch/parisc/Kconfig.debug
··· 12 portion of the kernel code won't be covered by a TLB anymore. 13 If in doubt, say "N". 14 15 endmenu
··· 12 portion of the kernel code won't be covered by a TLB anymore. 13 If in doubt, say "N". 14 15 + config DEBUG_STRICT_USER_COPY_CHECKS 16 + bool "Strict copy size checks" 17 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING 18 + ---help--- 19 + Enabling this option turns a certain set of sanity checks for user 20 + copy operations into compile time failures. 21 + 22 + The copy_from_user() etc checks are there to help test if there 23 + are sufficient security checks on the length argument of 24 + the copy operation, by having gcc prove that the argument is 25 + within bounds. 26 + 27 + If unsure, or if you run an older (pre 4.4) gcc, say N. 28 + 29 endmenu
+1 -22
arch/parisc/include/asm/param.h
··· 1 - #ifndef _ASMPARISC_PARAM_H 2 - #define _ASMPARISC_PARAM_H 3 - 4 - #ifdef __KERNEL__ 5 - #define HZ CONFIG_HZ 6 - #define USER_HZ 100 /* some user API use "ticks" */ 7 - #define CLOCKS_PER_SEC (USER_HZ) /* like times() */ 8 - #endif 9 - 10 - #ifndef HZ 11 - #define HZ 100 12 - #endif 13 - 14 - #define EXEC_PAGESIZE 4096 15 - 16 - #ifndef NOGROUP 17 - #define NOGROUP (-1) 18 - #endif 19 - 20 - #define MAXHOSTNAMELEN 64 /* max length of hostname */ 21 - 22 - #endif
··· 1 + #include <asm-generic/param.h>
+1 -1
arch/parisc/include/asm/system.h
··· 160 ldcd). */ 161 162 #define __PA_LDCW_ALIGNMENT 4 163 - #define __ldcw_align(a) ((volatile unsigned int *)a) 164 #define __LDCW "ldcw,co" 165 166 #endif /*!CONFIG_PA20*/
··· 160 ldcd). */ 161 162 #define __PA_LDCW_ALIGNMENT 4 163 + #define __ldcw_align(a) (&(a)->slock) 164 #define __LDCW "ldcw,co" 165 166 #endif /*!CONFIG_PA20*/
+25 -2
arch/parisc/include/asm/uaccess.h
··· 7 #include <asm/page.h> 8 #include <asm/system.h> 9 #include <asm/cache.h> 10 #include <asm-generic/uaccess-unaligned.h> 11 12 #define VERIFY_READ 0 ··· 235 236 unsigned long copy_to_user(void __user *dst, const void *src, unsigned long len); 237 #define __copy_to_user copy_to_user 238 - unsigned long copy_from_user(void *dst, const void __user *src, unsigned long len); 239 - #define __copy_from_user copy_from_user 240 unsigned long copy_in_user(void __user *dst, const void __user *src, unsigned long len); 241 #define __copy_in_user copy_in_user 242 #define __copy_to_user_inatomic __copy_to_user 243 #define __copy_from_user_inatomic __copy_from_user 244 245 struct pt_regs; 246 int fixup_exception(struct pt_regs *regs);
··· 7 #include <asm/page.h> 8 #include <asm/system.h> 9 #include <asm/cache.h> 10 + #include <asm/errno.h> 11 #include <asm-generic/uaccess-unaligned.h> 12 13 #define VERIFY_READ 0 ··· 234 235 unsigned long copy_to_user(void __user *dst, const void *src, unsigned long len); 236 #define __copy_to_user copy_to_user 237 + unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long len); 238 unsigned long copy_in_user(void __user *dst, const void __user *src, unsigned long len); 239 #define __copy_in_user copy_in_user 240 #define __copy_to_user_inatomic __copy_to_user 241 #define __copy_from_user_inatomic __copy_from_user 242 + 243 + extern void copy_from_user_overflow(void) 244 + #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS 245 + __compiletime_error("copy_from_user() buffer size is not provably correct") 246 + #else 247 + __compiletime_warning("copy_from_user() buffer size is not provably correct") 248 + #endif 249 + ; 250 + 251 + static inline unsigned long __must_check copy_from_user(void *to, 252 + const void __user *from, 253 + unsigned long n) 254 + { 255 + int sz = __compiletime_object_size(to); 256 + int ret = -EFAULT; 257 + 258 + if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n)) 259 + ret = __copy_from_user(to, from, n); 260 + else 261 + copy_from_user_overflow(); 262 + 263 + return ret; 264 + } 265 266 struct pt_regs; 267 int fixup_exception(struct pt_regs *regs);
+3 -1
arch/parisc/include/asm/unistd.h
··· 811 #define __NR_pwritev (__NR_Linux + 316) 812 #define __NR_rt_tgsigqueueinfo (__NR_Linux + 317) 813 #define __NR_perf_event_open (__NR_Linux + 318) 814 815 - #define __NR_Linux_syscalls (__NR_perf_event_open + 1) 816 817 818 #define __IGNORE_select /* newselect */
··· 811 #define __NR_pwritev (__NR_Linux + 316) 812 #define __NR_rt_tgsigqueueinfo (__NR_Linux + 317) 813 #define __NR_perf_event_open (__NR_Linux + 318) 814 + #define __NR_recvmmsg (__NR_Linux + 319) 815 + #define __NR_accept4 (__NR_Linux + 320) 816 817 + #define __NR_Linux_syscalls (__NR_accept4 + 1) 818 819 820 #define __IGNORE_select /* newselect */
+2 -2
arch/parisc/kernel/cache.c
··· 171 cache_info.ic_conf.cc_cst, 172 cache_info.ic_conf.cc_hv); 173 174 - printk("D-TLB conf: sh %d page %d cst %d aid %d pad1 %d \n", 175 cache_info.dt_conf.tc_sh, 176 cache_info.dt_conf.tc_page, 177 cache_info.dt_conf.tc_cst, 178 cache_info.dt_conf.tc_aid, 179 cache_info.dt_conf.tc_pad1); 180 181 - printk("I-TLB conf: sh %d page %d cst %d aid %d pad1 %d \n", 182 cache_info.it_conf.tc_sh, 183 cache_info.it_conf.tc_page, 184 cache_info.it_conf.tc_cst,
··· 171 cache_info.ic_conf.cc_cst, 172 cache_info.ic_conf.cc_hv); 173 174 + printk("D-TLB conf: sh %d page %d cst %d aid %d pad1 %d\n", 175 cache_info.dt_conf.tc_sh, 176 cache_info.dt_conf.tc_page, 177 cache_info.dt_conf.tc_cst, 178 cache_info.dt_conf.tc_aid, 179 cache_info.dt_conf.tc_pad1); 180 181 + printk("I-TLB conf: sh %d page %d cst %d aid %d pad1 %d\n", 182 cache_info.it_conf.tc_sh, 183 cache_info.it_conf.tc_page, 184 cache_info.it_conf.tc_cst,
+2
arch/parisc/kernel/syscall_table.S
··· 417 ENTRY_COMP(pwritev) 418 ENTRY_COMP(rt_tgsigqueueinfo) 419 ENTRY_SAME(perf_event_open) 420 421 /* Nothing yet */ 422
··· 417 ENTRY_COMP(pwritev) 418 ENTRY_COMP(rt_tgsigqueueinfo) 419 ENTRY_SAME(perf_event_open) 420 + ENTRY_COMP(recvmmsg) 421 + ENTRY_SAME(accept4) /* 320 */ 422 423 /* Nothing yet */ 424
+13 -16
arch/parisc/kernel/time.c
··· 250 } 251 module_init(rtc_init); 252 253 - void __init time_init(void) 254 { 255 static struct pdc_tod tod_data; 256 unsigned long current_cr16_khz; 257 258 clocktick = (100 * PAGE0->mem_10msec) / HZ; ··· 276 clocksource_cr16.mult = clocksource_khz2mult(current_cr16_khz, 277 clocksource_cr16.shift); 278 clocksource_register(&clocksource_cr16); 279 - 280 - if (pdc_tod_read(&tod_data) == 0) { 281 - unsigned long flags; 282 - 283 - write_seqlock_irqsave(&xtime_lock, flags); 284 - xtime.tv_sec = tod_data.tod_sec; 285 - xtime.tv_nsec = tod_data.tod_usec * 1000; 286 - set_normalized_timespec(&wall_to_monotonic, 287 - -xtime.tv_sec, -xtime.tv_nsec); 288 - write_sequnlock_irqrestore(&xtime_lock, flags); 289 - } else { 290 - printk(KERN_ERR "Error reading tod clock\n"); 291 - xtime.tv_sec = 0; 292 - xtime.tv_nsec = 0; 293 - } 294 }
··· 250 } 251 module_init(rtc_init); 252 253 + void read_persistent_clock(struct timespec *ts) 254 { 255 static struct pdc_tod tod_data; 256 + if (pdc_tod_read(&tod_data) == 0) { 257 + ts->tv_sec = tod_data.tod_sec; 258 + ts->tv_nsec = tod_data.tod_usec * 1000; 259 + } else { 260 + printk(KERN_ERR "Error reading tod clock\n"); 261 + ts->tv_sec = 0; 262 + ts->tv_nsec = 0; 263 + } 264 + } 265 + 266 + void __init time_init(void) 267 + { 268 unsigned long current_cr16_khz; 269 270 clocktick = (100 * PAGE0->mem_10msec) / HZ; ··· 264 clocksource_cr16.mult = clocksource_khz2mult(current_cr16_khz, 265 clocksource_cr16.shift); 266 clocksource_register(&clocksource_cr16); 267 }
+4 -10
arch/parisc/kernel/unaligned.c
··· 25 #include <linux/module.h> 26 #include <linux/sched.h> 27 #include <linux/signal.h> 28 #include <asm/uaccess.h> 29 30 /* #define DEBUG_UNALIGNED 1 */ ··· 447 448 void handle_unaligned(struct pt_regs *regs) 449 { 450 - static unsigned long unaligned_count = 0; 451 - static unsigned long last_time = 0; 452 unsigned long newbase = R1(regs->iir)?regs->gr[R1(regs->iir)]:0; 453 int modify = 0; 454 int ret = ERR_NOTHANDLED; ··· 460 goto force_sigbus; 461 } 462 463 - if (unaligned_count > 5 && 464 - time_after(jiffies, last_time + 5 * HZ)) { 465 - unaligned_count = 0; 466 - last_time = jiffies; 467 - } 468 - 469 - if (!(current->thread.flags & PARISC_UAC_NOPRINT) 470 - && ++unaligned_count < 5) { 471 char buf[256]; 472 sprintf(buf, "%s(%d): unaligned access to 0x" RFMT " at ip=0x" RFMT "\n", 473 current->comm, task_pid_nr(current), regs->ior, regs->iaoq[0]);
··· 25 #include <linux/module.h> 26 #include <linux/sched.h> 27 #include <linux/signal.h> 28 + #include <linux/ratelimit.h> 29 #include <asm/uaccess.h> 30 31 /* #define DEBUG_UNALIGNED 1 */ ··· 446 447 void handle_unaligned(struct pt_regs *regs) 448 { 449 + static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5); 450 unsigned long newbase = R1(regs->iir)?regs->gr[R1(regs->iir)]:0; 451 int modify = 0; 452 int ret = ERR_NOTHANDLED; ··· 460 goto force_sigbus; 461 } 462 463 + if (!(current->thread.flags & PARISC_UAC_NOPRINT) && 464 + __ratelimit(&ratelimit)) { 465 char buf[256]; 466 sprintf(buf, "%s(%d): unaligned access to 0x" RFMT " at ip=0x" RFMT "\n", 467 current->comm, task_pid_nr(current), regs->ior, regs->iaoq[0]);
+2 -1
arch/parisc/lib/memcpy.c
··· 475 return pa_memcpy((void __force *)dst, src, len); 476 } 477 478 - unsigned long copy_from_user(void *dst, const void __user *src, unsigned long len) 479 { 480 mtsp(get_user_space(), 1); 481 mtsp(get_kernel_space(), 2);
··· 475 return pa_memcpy((void __force *)dst, src, len); 476 } 477 478 + EXPORT_SYMBOL(__copy_from_user); 479 + unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long len) 480 { 481 mtsp(get_user_space(), 1); 482 mtsp(get_kernel_space(), 2);
+1 -1
drivers/parisc/eisa_enumerator.c
··· 460 slot, id_string); 461 462 print_eisa_id(id_string, es->eisa_slot_id); 463 - printk(" expected %s \n", id_string); 464 465 return -1; 466
··· 460 slot, id_string); 461 462 print_eisa_id(id_string, es->eisa_slot_id); 463 + printk(" expected %s\n", id_string); 464 465 return -1; 466
+1 -1
drivers/parisc/superio.c
··· 169 /* ...then properly fixup the USB to point at suckyio PIC */ 170 sio->usb_pdev->irq = superio_fixup_irq(sio->usb_pdev); 171 172 - printk(KERN_INFO PFX "Found NS87560 Legacy I/O device at %s (IRQ %i) \n", 173 pci_name(pdev), pdev->irq); 174 175 pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base);
··· 169 /* ...then properly fixup the USB to point at suckyio PIC */ 170 sio->usb_pdev->irq = superio_fixup_irq(sio->usb_pdev); 171 172 + printk(KERN_INFO PFX "Found NS87560 Legacy I/O device at %s (IRQ %i)\n", 173 pci_name(pdev), pdev->irq); 174 175 pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base);