Skip to content

Commit 6f3946b

Browse files
Steven J. Magnanimichalsimek
authored andcommitted
microblaze: Fix /dev/zero corruption from __clear_user()
A userland read of more than PAGE_SIZE bytes from /dev/zero results in (a) not all of the bytes returned being zero, and (b) memory corruption due to zeroing of bytes beyond the user buffer. This is caused by improper constraints on the assembly __clear_user function. The constrints don't indicate to the compiler that the pointer argument is modified. Since the function is inline, this results in double-incrementing of the pointer when __clear_user() is invoked through a multi-page read() of /dev/zero. Signed-off-by: Steven J. Magnani <steve@digidescorp.com> Acked-by: Michal Simek <monstr@monstr.eu> CC: stable@kernel.org
1 parent 6f205a4 commit 6f3946b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎arch/microblaze/include/asm/uaccess.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,16 @@ static inline unsigned long __must_check __clear_user(void __user *to,
120120
{
121121
/* normal memset with two words to __ex_table */
122122
__asm__ __volatile__ ( \
123-
"1: sb r0, %2, r0;" \
123+
"1: sb r0, %1, r0;" \
124124
" addik %0, %0, -1;" \
125125
" bneid %0, 1b;" \
126-
" addik %2, %2, 1;" \
126+
" addik %1, %1, 1;" \
127127
"2: " \
128128
__EX_TABLE_SECTION \
129129
".word 1b,2b;" \
130130
".previous;" \
131-
: "=r"(n) \
132-
: "0"(n), "r"(to)
131+
: "=r"(n), "=r"(to) \
132+
: "0"(n), "1"(to)
133133
);
134134
return n;
135135
}

0 commit comments

Comments
 (0)