[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200227223542.GE23230@ZenIV.linux.org.uk>
Date: Thu, 27 Feb 2020 22:35:42 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Josh Poimboeuf <jpoimboe@...hat.com>
Cc: Chris Wilson <chris@...is-wilson.co.uk>,
linux-kernel@...r.kernel.org, Randy Dunlap <rdunlap@...radead.org>,
Peter Zijlstra <peterz@...radead.org>,
intel-gfx@...ts.freedesktop.org
Subject: Re: [PATCH] drm/i915: Minimize uaccess exposure in
i915_gem_execbuffer2_ioctl()
On Thu, Feb 27, 2020 at 04:08:26PM -0600, Josh Poimboeuf wrote:
> With CONFIG_CC_OPTIMIZE_FOR_SIZE, objtool reports:
>
> drivers/gpu/drm/i915/gem/i915_gem_execbuffer.o: warning: objtool: i915_gem_execbuffer2_ioctl()+0x5b7: call to gen8_canonical_addr() with UACCESS enabled
>
> This means i915_gem_execbuffer2_ioctl() is calling gen8_canonical_addr()
> -- and indirectly, sign_extend64() -- from the user_access_begin/end
> critical region (i.e, with SMAP disabled).
>
> While it's probably harmless in this case, in general we like to avoid
> extra function calls in SMAP-disabled regions because it can open up
> inadvertent security holes.
>
> Fix it by moving the gen8_canonical_addr() conversion to a separate loop
> before user_access_begin() is called.
>
> Note that gen8_canonical_addr() is now called *before* masking off the
> PIN_OFFSET_MASK bits. That should be ok because it just does a sign
> extension and ignores the masked lower bits anyway.
How painful would it be to inline the damn thing?
<looks>
static inline u64 gen8_canonical_addr(u64 address)
{
return sign_extend64(address, GEN8_HIGH_ADDRESS_BIT);
}
static inline __s64 sign_extend64(__u64 value, int index)
{
__u8 shift = 63 - index;
return (__s64)(value << shift) >> shift;
}
What the hell? Josh, what kind of .config do you have that these are
_not_ inlined? And why not mark gen8_canonical_addr() __always_inline?
Powered by blists - more mailing lists