From: Jann Horn <jannh@google.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
jannh@google.com
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
Qiaowei Ren <qiaowei.ren@intel.com>,
Mukesh Ojha <mojha@codeaurora.org>
Subject: [PATCH v3 4/4] x86/uaccess: Fix implicit cast of __user pointer
Date: Fri, 29 Mar 2019 22:46:52 +0100 [thread overview]
Message-ID: <20190329214652.258477-4-jannh@google.com> (raw)
In-Reply-To: <20190329214652.258477-1-jannh@google.com>
The first two arguments of __user_atomic_cmpxchg_inatomic() are:
- `uval` is a kernel pointer into which the old value should be stored
- `ptr` is the user pointer on which the cmpxchg should operate
This means that casting `uval` to `__typeof__(ptr)` is wrong. Since `uval`
is only used once inside the macro, just get rid of __uval and use `(uval)`
directly.
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Signed-off-by: Jann Horn <jannh@google.com>
---
arch/x86/include/asm/uaccess.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
index 1954dd5552a2..a21f2a2f17bf 100644
--- a/arch/x86/include/asm/uaccess.h
+++ b/arch/x86/include/asm/uaccess.h
@@ -585,7 +585,6 @@ extern void __cmpxchg_wrong_size(void)
#define __user_atomic_cmpxchg_inatomic(uval, ptr, old, new, size) \
({ \
int __ret = 0; \
- __typeof__(ptr) __uval = (uval); \
__typeof__(*(ptr)) __old = (old); \
__typeof__(*(ptr)) __new = (new); \
__uaccess_begin_nospec(); \
@@ -661,7 +660,7 @@ extern void __cmpxchg_wrong_size(void)
__cmpxchg_wrong_size(); \
} \
__uaccess_end(); \
- *__uval = __old; \
+ *(uval) = __old; \
__ret; \
})
--
2.21.0.392.gf8f6787159e-goog
next prev parent reply other threads:[~2019-03-29 21:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-29 21:46 [PATCH v3 1/4] kernel.h: use parentheses around argument in u64_to_user_ptr() Jann Horn
2019-03-29 21:46 ` [PATCH v3 2/4] x86/microcode: Fix __user annotations around generic_load_microcode() Jann Horn
2019-04-01 17:30 ` Borislav Petkov
2019-04-01 17:53 ` Jann Horn
2019-04-02 9:55 ` David Laight
2019-04-02 10:01 ` Borislav Petkov
2019-04-02 10:26 ` David Laight
2019-03-29 21:46 ` [PATCH v3 3/4] x86/fpu: Fix __user annotations Jann Horn
2019-04-03 12:43 ` [tip:x86/fpu] " tip-bot for Jann Horn
2019-03-29 21:46 ` Jann Horn [this message]
2019-04-03 15:10 ` [tip:x86/asm] x86/uaccess: Fix implicit cast of __user pointer tip-bot for Jann Horn
2019-04-03 11:10 ` [tip:core/urgent] linux/kernel.h: Use parentheses around argument in u64_to_user_ptr() tip-bot for Jann Horn
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=20190329214652.258477-4-jannh@google.com \
--to=jannh@google.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mojha@codeaurora.org \
--cc=qiaowei.ren@intel.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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®