From patchwork Mon Jun 19 18:29:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willy Tarreau X-Patchwork-Id: 105923 Delivered-To: patch@linaro.org Received: by 10.140.91.2 with SMTP id y2csp1032455qgd; Mon, 19 Jun 2017 12:37:07 -0700 (PDT) X-Received: by 10.84.174.67 with SMTP id q61mr30981063plb.60.1497901027624; Mon, 19 Jun 2017 12:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497901027; cv=none; d=google.com; s=arc-20160816; b=TXLRPe3uxnocLlhtUpq/zx7vYvySwc3dWVFD1/Ocr1vvMqDg40GsLv8zwUMTLVhZDP ciEereJpesCffxcfQ5ueUtMugV5IVkr0iT6CiSMsEOC1UTu0LEwfEEUV4KR0s+r8SMFl uT7QqrdRFFJ0m3AV9PDZ/vegD3WyTb0hZEgRo/NZKUccxlMnpc9YsxYsTU1hPtJ4+2lJ KU+vvb5QTEelT9l/k4qzUOstiQzfCTKIXaJU/KUxCq/vZlFyZq15lkA/HDqyhEZsoXDz hndwk8sNABGkiKsERgqc6iMsFy/9bSReVqsowhBacl5QG8ogDFA1K0xEqUNVqHCicYdU l0oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=cqWLyIxfMpli+7a2OTUj/f4uQb/TIu6jZJJPbjZqC14=; b=aD03Xz0rhSjWQcg1KFAunM6Z8HgKRiD0i0ZT19RUB1JEwpLLXhOgb9AqaAcZFmThMu Pr5IH/Fujuw3tLdhzMaDGkiK1WTnNbQWmOc5TyOK8TV9Jwj1UW65/rRjkEPPukzALLfJ J2pqvANYPMmCC19JHXZqJ3DbO+IT5+UFgxHZIQL7v1kD6GDrbOaUk3eR7+ZrdTDTk4gI cJqLd5WYzzPyr7yJriU2PHAdK7UDU7hj2lYrQ4XRc60XqXyJGVyXIf+TiSE5IvU5uHvs kYwpEMXPZ/ribZ/FtCiYHgDSdR2PlyS4iimniN3RKHqp1K4CRUtgZQn4216dF3U2CGkJ tt6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u195si2394058pgc.412.2017.06.19.12.37.07; Mon, 19 Jun 2017 12:37:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752776AbdFSTgz (ORCPT + 25 others); Mon, 19 Jun 2017 15:36:55 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:51891 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752487AbdFSSed (ORCPT ); Mon, 19 Jun 2017 14:34:33 -0400 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id v5JIXG9v014947; Mon, 19 Jun 2017 20:33:16 +0200 From: Willy Tarreau To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux@roeck-us.net Cc: Arnd Bergmann , David Howells , Yaowei Bai , James Morris , "Paul E. McKenney" , Andrew Morton , Linus Torvalds , Willy Tarreau Subject: [PATCH 3.10 081/268] cred/userns: define current_user_ns() as a function Date: Mon, 19 Jun 2017 20:29:40 +0200 Message-Id: <1497897167-14556-82-git-send-email-w@1wt.eu> X-Mailer: git-send-email 2.8.0.rc2.1.gbe9624a In-Reply-To: <1497897167-14556-1-git-send-email-w@1wt.eu> References: <1497897167-14556-1-git-send-email-w@1wt.eu> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann 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 Acked-by: Serge Hallyn Cc: David Howells Cc: Yaowei Bai Cc: James Morris Cc: "Paul E. McKenney" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Willy Tarreau --- include/linux/capability.h | 2 -- include/linux/cred.h | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) -- 2.8.0.rc2.1.gbe9624a diff --git a/include/linux/capability.h b/include/linux/capability.h index 9b4378a..eeb43c4 100644 --- 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; diff --git a/include/linux/cred.h b/include/linux/cred.h index 6c58dd7..cd3fb73 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h @@ -345,7 +345,10 @@ extern struct user_namespace init_user_ns; #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