]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
cred/userns: define current_user_ns() as a function
authorArnd Bergmann <arnd@arndb.de>
Tue, 22 Mar 2016 21:27:11 +0000 (14:27 -0700)
committerLuis Henriques <luis.henriques@canonical.com>
Fri, 20 Jan 2017 11:27:06 +0000 (11:27 +0000)
commit26e23f594e23e0c67c33e4db46a7219cc400fe34
tree323e8dac913b43db57bb8060d02871b4cc9f54d2
parentc8d627bcebd6506dd5b1c2a37734840b83258b7e
cred/userns: define current_user_ns() as a function

BugLink: http://bugs.launchpad.net/bugs/1655969
commit 0335695dfa4df01edff5bb102b9a82a0668ee51e upstream.

The current_user_ns() macro currently returns &init_user_ns when user
namespaces are disabled, and that causes several warnings when building
with gcc-6.0 in code that compares the result of the macro to
&init_user_ns itself:

  fs/xfs/xfs_ioctl.c: In function 'xfs_ioctl_setattr_check_projid':
  fs/xfs/xfs_ioctl.c:1249:22: error: self-comparison always evaluates to true [-Werror=tautological-compare]
    if (current_user_ns() == &init_user_ns)

This is a legitimate warning in principle, but here it isn't really
helpful, so I'm reprasing the definition in a way that shuts up the
warning.  Apparently gcc only warns when comparing identical literals,
but it can figure out that the result of an inline function can be
identical to a constant expression in order to optimize a condition yet
not warn about the fact that the condition is known at compile time.
This is exactly what we want here, and it looks reasonable because we
generally prefer inline functions over macros anyway.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Yaowei Bai <baiyaowei@cmss.chinamobile.com>
Cc: James Morris <james.l.morris@oracle.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
include/linux/capability.h
include/linux/cred.h