The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Randy Dunlap <rdunlap@infradead.org>,
	x86@kernel.org
Subject: [PATCH] x86/compat: Pull huge_encode_dev() outside of UACCESS
Date: Mon, 4 Jan 2021 16:53:47 +0100	[thread overview]
Message-ID: <20210104155347.GC3040@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20210104153127.e44uchjhlgg3hq2g@treble>

On Mon, Jan 04, 2021 at 09:31:27AM -0600, Josh Poimboeuf wrote:
> Peter, care to submit a proper patch?

Here goes..

---
Subject: x86/compat: Pull huge_encode_dev() outside of UACCESS
From: Peter Zijlstra <peterz@infradead.org>
Date: Mon, 4 Jan 2021 13:28:25 +0100

Fixes the following warning:

  arch/x86/kernel/sys_ia32.o: warning: objtool: cp_stat64()+0xd8: call to new_encode_dev() with UACCESS enabled

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 arch/x86/kernel/sys_ia32.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/arch/x86/kernel/sys_ia32.c
+++ b/arch/x86/kernel/sys_ia32.c
@@ -133,18 +133,23 @@ static int cp_stat64(struct stat64 __use
 {
 	typeof(ubuf->st_uid) uid = 0;
 	typeof(ubuf->st_gid) gid = 0;
+	u64 dev, rdev;
+
 	SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
 	SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
+	dev = huge_encode_dev(stat->dev);
+	rdev = huge_encode_dev(stat->rdev);
+
 	if (!user_write_access_begin(ubuf, sizeof(struct stat64)))
 		return -EFAULT;
-	unsafe_put_user(huge_encode_dev(stat->dev), &ubuf->st_dev, Efault);
+	unsafe_put_user(dev, &ubuf->st_dev, Efault);
 	unsafe_put_user(stat->ino, &ubuf->__st_ino, Efault);
 	unsafe_put_user(stat->ino, &ubuf->st_ino, Efault);
 	unsafe_put_user(stat->mode, &ubuf->st_mode, Efault);
 	unsafe_put_user(stat->nlink, &ubuf->st_nlink, Efault);
 	unsafe_put_user(uid, &ubuf->st_uid, Efault);
 	unsafe_put_user(gid, &ubuf->st_gid, Efault);
-	unsafe_put_user(huge_encode_dev(stat->rdev), &ubuf->st_rdev, Efault);
+	unsafe_put_user(rdev, &ubuf->st_rdev, Efault);
 	unsafe_put_user(stat->size, &ubuf->st_size, Efault);
 	unsafe_put_user(stat->atime.tv_sec, &ubuf->st_atime, Efault);
 	unsafe_put_user(stat->atime.tv_nsec, &ubuf->st_atime_nsec, Efault);

  reply	other threads:[~2021-01-04 15:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-23 15:30 [PATCH] kdev_t: Always inline major/minor helper functions Josh Poimboeuf
2020-12-23 18:06 ` Randy Dunlap
2021-01-04 12:28 ` Peter Zijlstra
2021-01-04 15:31   ` Josh Poimboeuf
2021-01-04 15:53     ` Peter Zijlstra [this message]
2021-01-04 16:19       ` [PATCH] x86/compat: Pull huge_encode_dev() outside of UACCESS Randy Dunlap
2021-01-04 17:24       ` Josh Poimboeuf
2021-01-04 23:14         ` Josh Poimboeuf
2021-01-04 23:55           ` Randy Dunlap

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=20210104155347.GC3040@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    --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