vmgfx gcc-7.1.1 warning..

Daniel Vetter daniel at ffwll.ch
Thu Jul 13 20:28:48 UTC 2017


On Thu, Jul 13, 2017 at 10:11 PM, Linus Torvalds
<torvalds at linux-foundation.org> wrote:
> This one actually seems to imply that vmw_cmd_invalid() is broken:
>
> drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c:522:34: warning: the omitted
> middle operand in ?: will always be ‘true’, suggest explicit middle
> operand [-Wparentheses]
>   return capable(CAP_SYS_ADMIN) ? : -EINVAL;
>                                   ^
>
> gcc is very right. I think the *intent* of that function is to return
> 0 if CAP_SYS_ADMIN, but it always returns nonzero.
>
> If CAP_SYS_ADMIN is true, it returns 1, and if it's false it returns -EINVAL.
>
> Since nobody has noticed in many many years, maybe it should just
> always return -EINVAL unconditionally?

Fun one. It's the security parser afaict, and it looks like no one
wrote a testcase to make sure it actually catches the bad guys. Or
it's not needed, since there's 3 more security checks above it in
vmw_cmd_check.

Worst case it's become uapi and we can't fix it :-)

Anyway, not my area, I'll leave this to Sinclair to figure out.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the dri-devel mailing list