Merge tag 'parisc-for-6.2-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux

Pull parisc architecture fixes from Helge Deller:

- Fix PTRACE_GETREGS/PTRACE_SETREGS for 32-bit userspace on a 64-bit
kernel

- pdc_iodc_print() dropped chars for newline in strings

- Drop constants in favour of PRIV_USER

- use safer strscpy() function in pdc_stable driver

* tag 'parisc-for-6.2-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux:
parisc: Wire up PTRACE_GETREGS/PTRACE_SETREGS for compat case
parisc: Replace hardcoded value with PRIV_USER constant in ptrace.c
parisc: Fix return code of pdc_iodc_print()
parisc: pdc_stable: use strscpy() to instead of strncpy()

+22 -13
+3 -2
arch/parisc/kernel/firmware.c
··· 1303 */ 1304 int pdc_iodc_print(const unsigned char *str, unsigned count) 1305 { 1306 - unsigned int i; 1307 unsigned long flags; 1308 1309 count = min_t(unsigned int, count, sizeof(iodc_dbuf)); ··· 1315 iodc_dbuf[i+0] = '\r'; 1316 iodc_dbuf[i+1] = '\n'; 1317 i += 2; 1318 goto print; 1319 default: 1320 iodc_dbuf[i] = str[i]; ··· 1331 __pa(pdc_result), 0, __pa(iodc_dbuf), i, 0); 1332 spin_unlock_irqrestore(&pdc_lock, flags); 1333 1334 - return i; 1335 } 1336 1337 #if !defined(BOOTLOADER)
··· 1303 */ 1304 int pdc_iodc_print(const unsigned char *str, unsigned count) 1305 { 1306 + unsigned int i, found = 0; 1307 unsigned long flags; 1308 1309 count = min_t(unsigned int, count, sizeof(iodc_dbuf)); ··· 1315 iodc_dbuf[i+0] = '\r'; 1316 iodc_dbuf[i+1] = '\n'; 1317 i += 2; 1318 + found = 1; 1319 goto print; 1320 default: 1321 iodc_dbuf[i] = str[i]; ··· 1330 __pa(pdc_result), 0, __pa(iodc_dbuf), i, 0); 1331 spin_unlock_irqrestore(&pdc_lock, flags); 1332 1333 + return i - found; 1334 } 1335 1336 #if !defined(BOOTLOADER)
+16 -5
arch/parisc/kernel/ptrace.c
··· 126 unsigned long tmp; 127 long ret = -EIO; 128 129 switch (request) { 130 131 /* Read the word at location addr in the USER area. For ptraced ··· 172 addr >= sizeof(struct pt_regs)) 173 break; 174 if (addr == PT_IAOQ0 || addr == PT_IAOQ1) { 175 - data |= 3; /* ensure userspace privilege */ 176 } 177 if ((addr >= PT_GR1 && addr <= PT_GR31) || 178 addr == PT_IAOQ0 || addr == PT_IAOQ1 || ··· 187 return copy_regset_to_user(child, 188 task_user_regset_view(current), 189 REGSET_GENERAL, 190 - 0, sizeof(struct user_regs_struct), 191 datap); 192 193 case PTRACE_SETREGS: /* Set all gp regs in the child. */ 194 return copy_regset_from_user(child, 195 task_user_regset_view(current), 196 REGSET_GENERAL, 197 - 0, sizeof(struct user_regs_struct), 198 datap); 199 200 case PTRACE_GETFPREGS: /* Get the child FPU state. */ ··· 291 if (addr >= sizeof(struct pt_regs)) 292 break; 293 if (addr == PT_IAOQ0+4 || addr == PT_IAOQ1+4) { 294 - data |= 3; /* ensure userspace privilege */ 295 } 296 if (addr >= PT_FR0 && addr <= PT_FR31 + 4) { 297 /* Special case, fp regs are 64 bits anyway */ ··· 308 } 309 } 310 break; 311 312 default: 313 ret = compat_ptrace_request(child, request, addr, data); ··· 495 case RI(iaoq[0]): 496 case RI(iaoq[1]): 497 /* set 2 lowest bits to ensure userspace privilege: */ 498 - regs->iaoq[num - RI(iaoq[0])] = val | 3; 499 return; 500 case RI(sar): regs->sar = val; 501 return;
··· 126 unsigned long tmp; 127 long ret = -EIO; 128 129 + unsigned long user_regs_struct_size = sizeof(struct user_regs_struct); 130 + #ifdef CONFIG_64BIT 131 + if (is_compat_task()) 132 + user_regs_struct_size /= 2; 133 + #endif 134 + 135 switch (request) { 136 137 /* Read the word at location addr in the USER area. For ptraced ··· 166 addr >= sizeof(struct pt_regs)) 167 break; 168 if (addr == PT_IAOQ0 || addr == PT_IAOQ1) { 169 + data |= PRIV_USER; /* ensure userspace privilege */ 170 } 171 if ((addr >= PT_GR1 && addr <= PT_GR31) || 172 addr == PT_IAOQ0 || addr == PT_IAOQ1 || ··· 181 return copy_regset_to_user(child, 182 task_user_regset_view(current), 183 REGSET_GENERAL, 184 + 0, user_regs_struct_size, 185 datap); 186 187 case PTRACE_SETREGS: /* Set all gp regs in the child. */ 188 return copy_regset_from_user(child, 189 task_user_regset_view(current), 190 REGSET_GENERAL, 191 + 0, user_regs_struct_size, 192 datap); 193 194 case PTRACE_GETFPREGS: /* Get the child FPU state. */ ··· 285 if (addr >= sizeof(struct pt_regs)) 286 break; 287 if (addr == PT_IAOQ0+4 || addr == PT_IAOQ1+4) { 288 + data |= PRIV_USER; /* ensure userspace privilege */ 289 } 290 if (addr >= PT_FR0 && addr <= PT_FR31 + 4) { 291 /* Special case, fp regs are 64 bits anyway */ ··· 302 } 303 } 304 break; 305 + case PTRACE_GETREGS: 306 + case PTRACE_SETREGS: 307 + case PTRACE_GETFPREGS: 308 + case PTRACE_SETFPREGS: 309 + return arch_ptrace(child, request, addr, data); 310 311 default: 312 ret = compat_ptrace_request(child, request, addr, data); ··· 484 case RI(iaoq[0]): 485 case RI(iaoq[1]): 486 /* set 2 lowest bits to ensure userspace privilege: */ 487 + regs->iaoq[num - RI(iaoq[0])] = val | PRIV_USER; 488 return; 489 case RI(sar): regs->sar = val; 490 return;
+3 -6
drivers/parisc/pdc_stable.c
··· 274 275 /* We'll use a local copy of buf */ 276 count = min_t(size_t, count, sizeof(in)-1); 277 - strncpy(in, buf, count); 278 - in[count] = '\0'; 279 280 /* Let's clean up the target. 0xff is a blank pattern */ 281 memset(&hwpath, 0xff, sizeof(hwpath)); ··· 387 388 /* We'll use a local copy of buf */ 389 count = min_t(size_t, count, sizeof(in)-1); 390 - strncpy(in, buf, count); 391 - in[count] = '\0'; 392 393 /* Let's clean up the target. 0 is a blank pattern */ 394 memset(&layers, 0, sizeof(layers)); ··· 754 755 /* We'll use a local copy of buf */ 756 count = min_t(size_t, count, sizeof(in)-1); 757 - strncpy(in, buf, count); 758 - in[count] = '\0'; 759 760 /* Current flags are stored in primary boot path entry */ 761 pathentry = &pdcspath_entry_primary;
··· 274 275 /* We'll use a local copy of buf */ 276 count = min_t(size_t, count, sizeof(in)-1); 277 + strscpy(in, buf, count + 1); 278 279 /* Let's clean up the target. 0xff is a blank pattern */ 280 memset(&hwpath, 0xff, sizeof(hwpath)); ··· 388 389 /* We'll use a local copy of buf */ 390 count = min_t(size_t, count, sizeof(in)-1); 391 + strscpy(in, buf, count + 1); 392 393 /* Let's clean up the target. 0 is a blank pattern */ 394 memset(&layers, 0, sizeof(layers)); ··· 756 757 /* We'll use a local copy of buf */ 758 count = min_t(size_t, count, sizeof(in)-1); 759 + strscpy(in, buf, count + 1); 760 761 /* Current flags are stored in primary boot path entry */ 762 pathentry = &pdcspath_entry_primary;