Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752493AbdCEOIg (ORCPT ); Sun, 5 Mar 2017 09:08:36 -0500 Received: from mx1.polytechnique.org ([129.104.30.34]:40015 "EHLO mx1.polytechnique.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752162AbdCEOIe (ORCPT ); Sun, 5 Mar 2017 09:08:34 -0500 X-Greylist: delayed 305 seconds by postgrey-1.27 at vger.kernel.org; Sun, 05 Mar 2017 09:08:34 EST From: Nicolas Iooss To: Paul Moore , Stephen Smalley , Eric Paris , selinux@tycho.nsa.gov Cc: linux-kernel@vger.kernel.org Subject: [PATCH 1/1] selinux: include sys/socket.h in host programs to have PF_MAX Date: Sun, 5 Mar 2017 15:01:52 +0100 Message-Id: <20170305140152.12728-1-nicolas.iooss@m4x.org> X-Mailer: git-send-email 2.11.1 X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Sun Mar 5 15:03:26 2017 +0100 (CET)) X-Spam-Flag: No, tests=bogofilter, spamicity=0.000000, queueID=308765649F6 X-Org-Mail: nicolas.iooss.2010@polytechnique.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2358 Lines: 65 Compiling with clang and -Wundef makes the compiler report a usage of undefined PF_MAX macro in security/selinux/include/classmap.h: In file included from scripts/selinux/mdp/mdp.c:48: security/selinux/include/classmap.h:37:31: warning: no previous extern declaration for non-static variable 'secclass_map' [-Wmissing-variable-declarations] struct security_class_mapping secclass_map[] = { ^ security/selinux/include/classmap.h:235:5: error: 'PF_MAX' is not defined, evaluates to 0 [-Werror,-Wundef] #if PF_MAX > 43 ^ In file included from scripts/selinux/genheaders/genheaders.c:17: security/selinux/include/classmap.h:37:31: warning: no previous extern declaration for non-static variable 'secclass_map' [-Wmissing-variable-declarations] struct security_class_mapping secclass_map[] = { ^ security/selinux/include/classmap.h:235:5: error: 'PF_MAX' is not defined, evaluates to 0 [-Werror,-Wundef] #if PF_MAX > 43 ^ PF_MAX is defined in include/linux/socket.h but not in include/uapi/linux/socket.h. Therefore host programs have to rely on the definition from libc's /usr/include/bits/socket.h, included by . Fix the issue by using sys/socket.h in mdp and genheaders. When classmap.h is included by security/selinux/avc.c, it uses the kernel definition of PF_MAX, which makes the test consistent. Signed-off-by: Nicolas Iooss --- scripts/selinux/genheaders/genheaders.c | 1 + scripts/selinux/mdp/mdp.c | 1 + 2 files changed, 2 insertions(+) diff --git a/scripts/selinux/genheaders/genheaders.c b/scripts/selinux/genheaders/genheaders.c index f4dd41f900d5..6a24569c3578 100644 --- a/scripts/selinux/genheaders/genheaders.c +++ b/scripts/selinux/genheaders/genheaders.c @@ -8,6 +8,7 @@ #include #include #include +#include struct security_class_mapping { const char *name; diff --git a/scripts/selinux/mdp/mdp.c b/scripts/selinux/mdp/mdp.c index c29fa4a6228d..ffe8179f5d41 100644 --- a/scripts/selinux/mdp/mdp.c +++ b/scripts/selinux/mdp/mdp.c @@ -32,6 +32,7 @@ #include #include #include +#include static void usage(char *name) { -- 2.11.1