提交 6f3946b4 编写于 作者: S Steven J. Magnani 提交者: Michal Simek

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: NSteven J. Magnani <steve@digidescorp.com>
Acked-by: NMichal Simek <monstr@monstr.eu>
CC: stable@kernel.org
上级 6f205a4c
...@@ -120,16 +120,16 @@ static inline unsigned long __must_check __clear_user(void __user *to, ...@@ -120,16 +120,16 @@ static inline unsigned long __must_check __clear_user(void __user *to,
{ {
/* normal memset with two words to __ex_table */ /* normal memset with two words to __ex_table */
__asm__ __volatile__ ( \ __asm__ __volatile__ ( \
"1: sb r0, %2, r0;" \ "1: sb r0, %1, r0;" \
" addik %0, %0, -1;" \ " addik %0, %0, -1;" \
" bneid %0, 1b;" \ " bneid %0, 1b;" \
" addik %2, %2, 1;" \ " addik %1, %1, 1;" \
"2: " \ "2: " \
__EX_TABLE_SECTION \ __EX_TABLE_SECTION \
".word 1b,2b;" \ ".word 1b,2b;" \
".previous;" \ ".previous;" \
: "=r"(n) \ : "=r"(n), "=r"(to) \
: "0"(n), "r"(to) : "0"(n), "1"(to)
); );
return n; return n;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册