Skip to content

Commit fa255f5

Browse files
heicarstMartin Schwidefsky
authored andcommitted
s390/uaccess: fix possible register corruption in strnlen_user_srst()
The whole point of the out-of-line strnlen_user_srst() function was to avoid corruption of register 0 due to register asm assignment. However 'somebody' :) forgot to remove the update_primary_asce() function call, which may clobber register 0 contents. So let's remove that call and also move the size check to the calling function. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent a960062 commit fa255f5

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎arch/s390/lib/uaccess.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,6 @@ static inline unsigned long strnlen_user_srst(const char __user *src,
338338
register unsigned long reg0 asm("0") = 0;
339339
unsigned long tmp1, tmp2;
340340

341-
if (unlikely(!size))
342-
return 0;
343-
update_primary_asce(current);
344341
asm volatile(
345342
" la %2,0(%1)\n"
346343
" la %3,0(%0,%1)\n"
@@ -359,6 +356,8 @@ static inline unsigned long strnlen_user_srst(const char __user *src,
359356

360357
unsigned long __strnlen_user(const char __user *src, unsigned long size)
361358
{
359+
if (unlikely(!size))
360+
return 0;
362361
update_primary_asce(current);
363362
return strnlen_user_srst(src, size);
364363
}

0 commit comments

Comments
 (0)