linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Serge Hallyn <serge.hallyn@canonical.com>,
	David Howells <dhowells@redhat.com>,
	Yaowei Bai <baiyaowei@cmss.chinamobile.com>,
	James Morris <james.l.morris@oracle.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 3.18 33/68] cred/userns: define current_user_ns() as a function
Date: Fri,  5 May 2017 11:32:18 -0700	[thread overview]
Message-ID: <20170505183213.918919086@linuxfoundation.org> (raw)
In-Reply-To: <20170505183212.587141964@linuxfoundation.org>

3.18-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Arnd Bergmann <arnd@arndb.de>

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>

---
 include/linux/capability.h |    2 --
 include/linux/cred.h       |    5 ++++-
 2 files changed, 4 insertions(+), 3 deletions(-)

--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -40,8 +40,6 @@ struct inode;
 struct dentry;
 struct user_namespace;
 
-struct user_namespace *current_user_ns(void);
-
 extern const kernel_cap_t __cap_empty_set;
 extern const kernel_cap_t __cap_init_eff_set;
 
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -354,7 +354,10 @@ extern struct user_namespace init_user_n
 #ifdef CONFIG_USER_NS
 #define current_user_ns()	(current_cred_xxx(user_ns))
 #else
-#define current_user_ns()	(&init_user_ns)
+static inline struct user_namespace *current_user_ns(void)
+{
+	return &init_user_ns;
+}
 #endif
 
 

  parent reply	other threads:[~2017-05-05 18:40 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-05 18:31 [PATCH 3.18 00/68] 3.18.52-stable review Greg Kroah-Hartman
2017-05-05 18:31 ` [PATCH 3.18 01/68] f2fs: do more integrity verification for superblock Greg Kroah-Hartman
2017-05-05 18:31 ` [PATCH 3.18 02/68] [media] xc2028: unlock on error in xc2028_set_config() Greg Kroah-Hartman
2017-05-05 18:31 ` [PATCH 3.18 03/68] ext4: check if in-inode xattr is corrupted in ext4_expand_extra_isize_ea() Greg Kroah-Hartman
2017-05-05 18:31 ` [PATCH 3.18 04/68] md:raid1: fix a dead loop when read from a WriteMostly disk Greg Kroah-Hartman
2017-05-05 18:31 ` [PATCH 3.18 05/68] MIPS: Fix crash registers on non-crashing CPUs Greg Kroah-Hartman
2017-05-05 18:31 ` [PATCH 3.18 06/68] RDS: Fix the atomicity for congestion map update Greg Kroah-Hartman
2017-05-05 18:31 ` [PATCH 3.18 07/68] usb: gadget: f_midi: Fixed a bug when buflen was smaller than wMaxPacketSize Greg Kroah-Hartman
2017-05-05 18:31 ` [PATCH 3.18 08/68] xen/x86: dont lose event interrupts Greg Kroah-Hartman
2017-05-05 18:31 ` [PATCH 3.18 09/68] sparc64: kern_addr_valid regression Greg Kroah-Hartman
2017-05-05 18:31 ` [PATCH 3.18 10/68] sparc64: Fix kernel panic due to erroneous #ifdef surrounding pmd_write() Greg Kroah-Hartman
2017-05-05 18:31 ` [PATCH 3.18 11/68] net: neigh: guard against NULL solicit() method Greg Kroah-Hartman
2017-05-05 18:31 ` [PATCH 3.18 12/68] net: phy: handle state correctly in phy_stop_machine Greg Kroah-Hartman
2017-05-05 18:31 ` [PATCH 3.18 13/68] l2tp: purge socket queues in the .destruct() callback Greg Kroah-Hartman
2017-05-05 18:31 ` [PATCH 3.18 14/68] net/packet: fix overflow in check for tp_frame_nr Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 15/68] net/packet: fix overflow in check for tp_reserve Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 16/68] net: ipv4: fix multipath RTM_GETROUTE behavior when iif is given Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 17/68] sctp: listen on the sock only when its state is listening or closed Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 18/68] netpoll: Check for skb->queue_mapping Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 19/68] ip6mr: fix notification device destruction Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 20/68] ALSA: seq: Dont break snd_use_lock_sync() loop by timeout Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 21/68] MIPS: KGDB: Use kernel context for sleeping threads Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 22/68] p9_client_readdir() fix Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 25/68] ftrace/x86: Fix triple fault with graph tracing and suspend-to-ram Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 26/68] powerpc/ptrace: Fix out of bounds array access warning Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 27/68] drbd: avoid redefinition of BITS_PER_PAGE Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 28/68] IB/iser: Fix sparse warnings Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 29/68] mtd: avoid stack overflow in MTD CFI code Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 30/68] mlx5: avoid build warnings on 32-bit Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 31/68] PCI: xilinx: Fix harmless format string warning Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 32/68] ALSA: ppc/awacs: shut up maybe-uninitialized warning Greg Kroah-Hartman
2017-05-05 18:32 ` Greg Kroah-Hartman [this message]
2017-05-05 18:32 ` [PATCH 3.18 34/68] net: tg3: avoid uninitialized variable warning Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 35/68] timerfd: Protect the might cancel mechanism proper Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 36/68] Handle mismatched open calls Greg Kroah-Hartman
2017-07-14 16:42   ` Ben Hutchings
2017-07-19 18:39     ` Pavel Shilovskiy
2017-07-22 12:46       ` Greg Kroah-Hartman
2017-11-15  9:08     ` Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 37/68] ALSA: pcm : Call kill_fasync() in stream lock Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 38/68] regulator: core: Fix regualtor_ena_gpio_free not to access pin after freeing Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 39/68] perf: Tighten (and fix) the grouping condition Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 40/68] posix_acl: Clear SGID bit when setting file permissions Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 41/68] l2tp: fix racy SOCK_ZAPPED flag check in l2tp_ip{,6}_bind() Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 42/68] net: avoid signed overflows for SO_{SND|RCV}BUFFORCE Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 43/68] mm: avoid setting up anonymous pages into file mapping Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 44/68] ARM: cns3xxx: shut up frame size warning Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 45/68] arm64: Provide a namespace to NCAPS Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 46/68] staging: vt6655: fix overly large stack usage Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 47/68] staging: imx-drm: fix indentation warning Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 48/68] staging: bcm: add 32-bit host dependency Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 49/68] IB/qib: rename BITS_PER_PAGE to RVT_BITS_PER_PAGE Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 50/68] IB/ehca: fix maybe-uninitialized warnings Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 51/68] tty/isicom: fix big-endian compile warning Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 52/68] infiniband: mlx5: avoid a compile-time warning Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 53/68] ips: remove pointless #warning Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 54/68] mISDN: avoid arch specific __builtin_return_address call Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 55/68] arm64: build vdso without libgcov Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 56/68] mm/cma: silence warnings due to max() usage Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 57/68] MIPS: jz4740: fix build error in irq.h Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 58/68] MIPS: elf2ecoff: Ignore PT_MIPS_ABIFLAGS program headers Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 60/68] staging: unisys: correctly handle return value from queue_delayed_work() Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 61/68] message: i2o: fix 64bit build warnings Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 62/68] scsi: advansys: remove #warning message Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 63/68] modpost: expand pattern matching to support substring matches Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 64/68] modpost: dont emit section mismatch warnings for compiler optimizations Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 65/68] cpumask_set_cpu_local_first => cpumask_local_spread, lament Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 66/68] e1000e: fix call to do_div() to use u64 arg Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 67/68] gfs2: remove IS_ERR_VALUE abuse Greg Kroah-Hartman
2017-05-05 18:32 ` [PATCH 3.18 68/68] kbuild: mergeconfig: fix "jobserver unavailable" warning Greg Kroah-Hartman
2017-05-06  1:58 ` [PATCH 3.18 00/68] 3.18.52-stable review Shuah Khan
2017-05-07 19:35 ` Guenter Roeck
     [not found] ` <590d0d30.01b9370a.e3d65.b17a@mx.google.com>
     [not found]   ` <m2tw4vdxnk.fsf@baylibre.com>
2017-05-09  7:47     ` Alexandre Belloni
2017-05-31 19:47     ` Alexandre Belloni
2017-06-06 20:52       ` Kevin Hilman

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=20170505183213.918919086@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=baiyaowei@cmss.chinamobile.com \
    --cc=dhowells@redhat.com \
    --cc=james.l.morris@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=serge.hallyn@canonical.com \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).