linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Jann Horn <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
	keescook@chromium.org, jannh@google.com, bp@suse.de,
	tglx@linutronix.de, hpa@zytor.com, x86@kernel.org,
	avagin@openvz.org, akpm@linux-foundation.org,
	dan.carpenter@oracle.com, mojha@codeaurora.org, neilb@suse.com,
	yamada.masahiro@socionext.com, peterz@infradead.org,
	qiaowei.ren@intel.com, mingo@kernel.org, jani.nikula@intel.com
Subject: [tip:core/urgent] linux/kernel.h: Use parentheses around argument in u64_to_user_ptr()
Date: Wed, 3 Apr 2019 04:10:12 -0700	[thread overview]
Message-ID: <tip-a0fe2c6479aab5723239b315ef1b552673f434a3@git.kernel.org> (raw)
In-Reply-To: <20190329214652.258477-1-jannh@google.com>

Commit-ID:  a0fe2c6479aab5723239b315ef1b552673f434a3
Gitweb:     https://git.kernel.org/tip/a0fe2c6479aab5723239b315ef1b552673f434a3
Author:     Jann Horn <jannh@google.com>
AuthorDate: Fri, 29 Mar 2019 22:46:49 +0100
Committer:  Borislav Petkov <bp@suse.de>
CommitDate: Wed, 3 Apr 2019 11:43:49 +0200

linux/kernel.h: Use parentheses around argument in u64_to_user_ptr()

Use parentheses around uses of the argument in u64_to_user_ptr() to
ensure that the cast doesn't apply to part of the argument.

There are existing uses of the macro of the form

  u64_to_user_ptr(A + B)

which expands to

  (void __user *)(uintptr_t)A + B

(the cast applies to the first operand of the addition, the addition
is a pointer addition). This happens to still work as intended, the
semantic difference doesn't cause a difference in behavior.

But I want to use u64_to_user_ptr() with a ternary operator in the
argument, like so:

  u64_to_user_ptr(A ? B : C)

This currently doesn't work as intended.

Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Cc: Andrei Vagin <avagin@openvz.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: NeilBrown <neilb@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Qiaowei Ren <qiaowei.ren@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: x86-ml <x86@kernel.org>
Link: https://lkml.kernel.org/r/20190329214652.258477-1-jannh@google.com
---
 include/linux/kernel.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 34a5036debd3..2d14e21c16c0 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -47,8 +47,8 @@
 
 #define u64_to_user_ptr(x) (		\
 {					\
-	typecheck(u64, x);		\
-	(void __user *)(uintptr_t)x;	\
+	typecheck(u64, (x));		\
+	(void __user *)(uintptr_t)(x);	\
 }					\
 )
 

      parent reply	other threads:[~2019-04-03 11:11 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 ` [PATCH v3 4/4] x86/uaccess: Fix implicit cast of __user pointer Jann Horn
2019-04-03 15:10   ` [tip:x86/asm] " tip-bot for Jann Horn
2019-04-03 11:10 ` tip-bot for Jann Horn [this message]

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=tip-a0fe2c6479aab5723239b315ef1b552673f434a3@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=akpm@linux-foundation.org \
    --cc=avagin@openvz.org \
    --cc=bp@suse.de \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=jani.nikula@intel.com \
    --cc=jannh@google.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mojha@codeaurora.org \
    --cc=neilb@suse.com \
    --cc=peterz@infradead.org \
    --cc=qiaowei.ren@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=yamada.masahiro@socionext.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;
as well as URLs for NNTP newsgroup(s).