mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrey Ryabinin <a.ryabinin@samsung.com>
To: linux@arm.linux.org.uk
Cc: Andrey Ryabinin <a.ryabinin@samsung.com>,
	stable@vger.kernel.org, Nicolas Pitre <nicolas.pitre@linaro.org>,
	Will Deacon <will.deacon@arm.com>,
	linux-arm-kernel@lists.infradead.org (moderated list:ARM PORT),
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCHv2] arm: put_user: fix possible data corruption in put_user
Date: Tue, 06 May 2014 11:11:51 +0400	[thread overview]
Message-ID: <1399360312-13843-1-git-send-email-a.ryabinin@samsung.com> (raw)
In-Reply-To: <alpine.LFD.2.11.1405050950410.980@knanqh.ubzr>

According to arm procedure call standart r2 register is call-cloberred.
So after the result of x expression was put into r2 any following
function call in p may overwrite r2. To fix this, the result of p
expression must be saved to the temporary variable before the
assigment x expression to __r2.

Signed-off-by: Andrey Ryabinin <a.ryabinin@samsung.com>
Reviewed-by: Nicolas Pitre <nico@linaro.org>
Cc: stable@vger.kernel.org
---
Since v1:
 - tmp_p variable renamed to __tmp_p
 - added Reviewed-by tag
 - added Cc: stable@vger.kernel.org

 arch/arm/include/asm/uaccess.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index 12c3a5d..75d9579 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -171,8 +171,9 @@ extern int __put_user_8(void *, unsigned long long);
 #define __put_user_check(x,p)							\
 	({								\
 		unsigned long __limit = current_thread_info()->addr_limit - 1; \
+		const typeof(*(p)) __user *__tmp_p = (p);		\
 		register const typeof(*(p)) __r2 asm("r2") = (x);	\
-		register const typeof(*(p)) __user *__p asm("r0") = (p);\
+		register const typeof(*(p)) __user *__p asm("r0") = __tmp_p; \
 		register unsigned long __l asm("r1") = __limit;		\
 		register int __e asm("r0");				\
 		switch (sizeof(*(__p))) {				\
-- 
1.8.5.5


  reply	other threads:[~2014-05-06  7:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-05  6:13 [PATCH] " Andrey Ryabinin
2014-05-05  9:01 ` Russell King - ARM Linux
2014-05-05 10:50   ` Andrey Ryabinin
2014-05-05 13:45     ` Nicolas Pitre
2014-05-05 14:15 ` Nicolas Pitre
2014-05-06  7:11   ` Andrey Ryabinin [this message]
2014-05-06 20:13     ` [PATCHv2] " Nicolas Pitre
2014-05-07 13:19       ` Andrey Ryabinin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399360312-13843-1-git-send-email-a.ryabinin@samsung.com \
    --to=a.ryabinin@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=nicolas.pitre@linaro.org \
    --cc=stable@vger.kernel.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®