Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1592768 > unrolled thread
| Started by | Nicolas Iooss <nicolas.iooss@m4x.org> |
|---|---|
| First post | 2017-03-05 15:10 +0100 |
| Last post | 2017-03-10 21:20 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 1/1] selinux: include sys/socket.h in host programs to have PF_MAX Nicolas Iooss <nicolas.iooss@m4x.org> - 2017-03-05 15:10 +0100
Re: [PATCH 1/1] selinux: include sys/socket.h in host programs to have PF_MAX Paul Moore <paul@paul-moore.com> - 2017-03-10 21:20 +0100
| From | Nicolas Iooss <nicolas.iooss@m4x.org> |
|---|---|
| Date | 2017-03-05 15:10 +0100 |
| Subject | [PATCH 1/1] selinux: include sys/socket.h in host programs to have PF_MAX |
| Message-ID | <thF1f-1s1-5@gated-at.bofh.it> |
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
<sys/socket.h>.
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 <nicolas.iooss@m4x.org>
---
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 <string.h>
#include <errno.h>
#include <ctype.h>
+#include <sys/socket.h>
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 <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <sys/socket.h>
static void usage(char *name)
{
--
2.11.1
[toc] | [next] | [standalone]
| From | Paul Moore <paul@paul-moore.com> |
|---|---|
| Date | 2017-03-10 21:20 +0100 |
| Subject | Re: [PATCH 1/1] selinux: include sys/socket.h in host programs to have PF_MAX |
| Message-ID | <tjzb3-yL-9@gated-at.bofh.it> |
| In reply to | #1592768 |
On Sun, Mar 5, 2017 at 9:01 AM, Nicolas Iooss <nicolas.iooss@m4x.org> wrote:
> 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
> <sys/socket.h>.
>
> 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 <nicolas.iooss@m4x.org>
> ---
> scripts/selinux/genheaders/genheaders.c | 1 +
> scripts/selinux/mdp/mdp.c | 1 +
> 2 files changed, 2 insertions(+)
Merged into selinux/next, thank you.
> 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 <string.h>
> #include <errno.h>
> #include <ctype.h>
> +#include <sys/socket.h>
>
> 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 <stdlib.h>
> #include <unistd.h>
> #include <string.h>
> +#include <sys/socket.h>
>
> static void usage(char *name)
> {
> --
> 2.11.1
>
--
paul moore
www.paul-moore.com
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web