From: Peter Zijlstra <peterz@infradead.org>
To: Randy Dunlap <rdunlap@infradead.org>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
Linux Next Mailing List <linux-next@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
linux@rasmusvillemoes.dk, cyphar@cyphar.com,
keescook@chromium.org, christian.brauner@ubuntu.com
Subject: Re: linux-next: Tree for Oct 18 (objtool)
Date: Mon, 21 Oct 2019 14:35:49 +0200 [thread overview]
Message-ID: <20191021123549.GC1817@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <40de4e26-450e-b932-3d73-e833c8aeaa2e@infradead.org>
On Fri, Oct 18, 2019 at 08:33:11AM -0700, Randy Dunlap wrote:
> On 10/18/19 12:03 AM, Stephen Rothwell wrote:
> > Hi all,
> >
> > Changes since 20191017:
> >
>
> on x86_64:
> lib/usercopy.o: warning: objtool: check_zeroed_user()+0x35f: call to __ubsan_handle_shift_out_of_bounds() with UACCESS enabled
Blergh... I suppose the below will fix that. I'm a bit conflicted on it
though, the alternative is annotating more ubsan crud.
---
lib/usercopy.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/lib/usercopy.c b/lib/usercopy.c
index cbb4d9ec00f2..9c5245778dfd 100644
--- a/lib/usercopy.c
+++ b/lib/usercopy.c
@@ -49,21 +49,28 @@ EXPORT_SYMBOL(_copy_to_user);
*/
int check_zeroed_user(const void __user *from, size_t size)
{
+ unsigned long head_mask, tail_mask;
unsigned long val;
- uintptr_t align = (uintptr_t) from % sizeof(unsigned long);
+ uintptr_t align;
if (unlikely(size == 0))
return 1;
- from -= align;
- size += align;
+ align = (uintptr_t) from % sizeof(unsigned long);
+ if (align) {
+ from -= align;
+ size += align;
+ head_mask = ~aligned_byte_mask(align);
+ }
+
+ tail_mask = aligned_byte_mask(size % sizeof(unsigned long));
if (!user_access_begin(from, size))
return -EFAULT;
unsafe_get_user(val, (unsigned long __user *) from, err_fault);
if (align)
- val &= ~aligned_byte_mask(align);
+ val &= head_mask;
while (size > sizeof(unsigned long)) {
if (unlikely(val))
@@ -76,7 +83,7 @@ int check_zeroed_user(const void __user *from, size_t size)
}
if (size < sizeof(unsigned long))
- val &= aligned_byte_mask(size);
+ val &= tail_mask;
done:
user_access_end();
next prev parent reply other threads:[~2019-10-21 12:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 7:03 linux-next: Tree for Oct 18 Stephen Rothwell
2019-10-18 15:33 ` linux-next: Tree for Oct 18 (objtool) Randy Dunlap
2019-10-21 12:35 ` Peter Zijlstra [this message]
2019-10-21 13:11 ` Peter Zijlstra
2019-10-21 13:19 ` Christian Brauner
2019-10-21 13:47 ` Peter Zijlstra
2019-10-21 19:36 ` Christian Brauner
2019-10-22 7:40 ` Peter Zijlstra
2019-10-22 8:02 ` Christian Brauner
2019-10-21 15:59 ` Randy Dunlap
2019-10-28 11:42 ` [tip: x86/asm] ubsan, x86: Annotate and allow __ubsan_handle_shift_out_of_bounds() in uaccess regions tip-bot2 for Peter Zijlstra
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=20191021123549.GC1817@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=christian.brauner@ubuntu.com \
--cc=cyphar@cyphar.com \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=rdunlap@infradead.org \
--cc=sfr@canb.auug.org.au \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.