@@ -518,10 +518,10 @@ static int genregs32_get(struct task_struct *target,
518
518
void * kbuf , void __user * ubuf )
519
519
{
520
520
const struct pt_regs * regs = task_pt_regs (target );
521
- compat_ulong_t __user * reg_window ;
522
521
compat_ulong_t * k = kbuf ;
523
522
compat_ulong_t __user * u = ubuf ;
524
- compat_ulong_t reg ;
523
+ u32 uregs [16 ];
524
+ u32 reg ;
525
525
526
526
if (target == current )
527
527
flushw_user ();
@@ -533,52 +533,25 @@ static int genregs32_get(struct task_struct *target,
533
533
for (; count > 0 && pos < 16 ; count -- )
534
534
* k ++ = regs -> u_regs [pos ++ ];
535
535
536
- reg_window = (compat_ulong_t __user * ) regs -> u_regs [UREG_I6 ];
537
- reg_window -= 16 ;
538
- if (target == current ) {
539
- for (; count > 0 && pos < 32 ; count -- ) {
540
- if (get_user (* k ++ , & reg_window [pos ++ ]))
541
- return - EFAULT ;
542
- }
543
- } else {
544
- for (; count > 0 && pos < 32 ; count -- ) {
545
- if (access_process_vm (target ,
546
- (unsigned long )
547
- & reg_window [pos ],
548
- k , sizeof (* k ),
549
- FOLL_FORCE )
550
- != sizeof (* k ))
551
- return - EFAULT ;
552
- k ++ ;
553
- pos ++ ;
554
- }
536
+ if (count && pos < 32 ) {
537
+ if (get_from_target (target , regs -> u_regs [UREG_I6 ],
538
+ uregs , sizeof (uregs )))
539
+ return - EFAULT ;
540
+ for (; count > 0 && pos < 32 ; count -- )
541
+ * k ++ = uregs [pos ++ - 16 ];
542
+
555
543
}
556
544
} else {
557
- for (; count > 0 && pos < 16 ; count -- ) {
545
+ for (; count > 0 && pos < 16 ; count -- )
558
546
if (put_user ((compat_ulong_t ) regs -> u_regs [pos ++ ], u ++ ))
559
547
return - EFAULT ;
560
- }
561
-
562
- reg_window = (compat_ulong_t __user * ) regs -> u_regs [UREG_I6 ];
563
- reg_window -= 16 ;
564
- if (target == current ) {
565
- for (; count > 0 && pos < 32 ; count -- ) {
566
- if (get_user (reg , & reg_window [pos ++ ]) ||
567
- put_user (reg , u ++ ))
568
- return - EFAULT ;
569
- }
570
- } else {
571
- for (; count > 0 && pos < 32 ; count -- ) {
572
- if (access_process_vm (target ,
573
- (unsigned long )
574
- & reg_window [pos ++ ],
575
- & reg , sizeof (reg ),
576
- FOLL_FORCE )
577
- != sizeof (reg ))
578
- return - EFAULT ;
579
- if (put_user (reg , u ++ ))
548
+ if (count && pos < 32 ) {
549
+ if (get_from_target (target , regs -> u_regs [UREG_I6 ],
550
+ uregs , sizeof (uregs )))
551
+ return - EFAULT ;
552
+ for (; count > 0 && pos < 32 ; count -- )
553
+ if (put_user (uregs [pos ++ - 16 ], u ++ ))
580
554
return - EFAULT ;
581
- }
582
555
}
583
556
}
584
557
while (count > 0 ) {
0 commit comments