Skip to contentSkip to conversation

selinux: error: ‘NETLINK_ROUTE_SOCKET__NLMSG’ undeclared

DISCUSSION Sebastian Andrzej Siewior 4 participants 5 messages Jan 8, 2025 – Jan 17, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi,

since commit d1d991efaf346 ("selinux: Add netlink xperm support") I can't compile a defconfig:

| $ make defconfig
| $ make security/selinux/nlmsgtab.o
…

|   CC      security/selinux/nlmsgtab.o
| security/selinux/nlmsgtab.c: In function ‘selinux_nlmsg_lookup’:
| security/selinux/nlmsgtab.c:188:33: error: ‘NETLINK_ROUTE_SOCKET__NLMSG’ undeclared (first use in this function); did you mean ‘NETLINK_ROUTE_SOCKET__LOCK’?
|   188 |                         *perm = NETLINK_ROUTE_SOCKET__NLMSG;
|       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
|       |                                 NETLINK_ROUTE_SOCKET__LOCK
| security/selinux/nlmsgtab.c:188:33: note: each undeclared identifier is reported only once for each function it appears in
| security/selinux/nlmsgtab.c:196:33: error: ‘NETLINK_TCPDIAG_SOCKET__NLMSG’ undeclared (first use in this function); did you mean ‘NETLINK_TCPDIAG_SOCKET__MAP’?
|   196 |                         *perm = NETLINK_TCPDIAG_SOCKET__NLMSG;
|       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|       |                                 NETLINK_TCPDIAG_SOCKET__MAP
| security/selinux/nlmsgtab.c:210:33: error: ‘NETLINK_XFRM_SOCKET__NLMSG’ undeclared (first use in this function); did you mean ‘NETLINK_XFRM_SOCKET__MAP’?
|   210 |                         *perm = NETLINK_XFRM_SOCKET__NLMSG;
|       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
|       |                                 NETLINK_XFRM_SOCKET__MAP
| security/selinux/nlmsgtab.c:218:33: error: ‘NETLINK_AUDIT_SOCKET__NLMSG’ undeclared (first use in this function); did you mean ‘NETLINK_AUDIT_SOCKET__LOCK’?
|   218 |                         *perm = NETLINK_AUDIT_SOCKET__NLMSG;
|       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
|       |                                 NETLINK_AUDIT_SOCKET__LOCK
| make[5]: *** [scripts/Makefile.build:194: security/selinux/nlmsgtab.o] Error 1

…

The commit introducing this is part of v6.13-rc1 and we have v6.13-rc6 and I wonder why am I the only one seeing this? The bots must have noticed it way earlier and yet I can't find any report of it. Is this a typo that everyone keeps ignoring or do I lack something that auto generates this define somewhere?

Sebastian

#1 lore raw
Quoted 29 lines · Sebastian Andrzej Siewior

Hi,

since commit d1d991efaf346 ("selinux: Add netlink xperm support") I can't compile a defconfig:

| $ make defconfig
| $ make security/selinux/nlmsgtab.o
…

|   CC      security/selinux/nlmsgtab.o
| security/selinux/nlmsgtab.c: In function ‘selinux_nlmsg_lookup’:
| security/selinux/nlmsgtab.c:188:33: error: ‘NETLINK_ROUTE_SOCKET__NLMSG’ undeclared (first use in this function); did you mean ‘NETLINK_ROUTE_SOCKET__LOCK’?
|   188 |                         *perm = NETLINK_ROUTE_SOCKET__NLMSG;
|       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
|       |                                 NETLINK_ROUTE_SOCKET__LOCK
| security/selinux/nlmsgtab.c:188:33: note: each undeclared identifier is reported only once for each function it appears in
| security/selinux/nlmsgtab.c:196:33: error: ‘NETLINK_TCPDIAG_SOCKET__NLMSG’ undeclared (first use in this function); did you mean ‘NETLINK_TCPDIAG_SOCKET__MAP’?
|   196 |                         *perm = NETLINK_TCPDIAG_SOCKET__NLMSG;
|       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|       |                                 NETLINK_TCPDIAG_SOCKET__MAP
| security/selinux/nlmsgtab.c:210:33: error: ‘NETLINK_XFRM_SOCKET__NLMSG’ undeclared (first use in this function); did you mean ‘NETLINK_XFRM_SOCKET__MAP’?
|   210 |                         *perm = NETLINK_XFRM_SOCKET__NLMSG;
|       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
|       |                                 NETLINK_XFRM_SOCKET__MAP
| security/selinux/nlmsgtab.c:218:33: error: ‘NETLINK_AUDIT_SOCKET__NLMSG’ undeclared (first use in this function); did you mean ‘NETLINK_AUDIT_SOCKET__LOCK’?
|   218 |                         *perm = NETLINK_AUDIT_SOCKET__NLMSG;
|       |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
|       |                                 NETLINK_AUDIT_SOCKET__LOCK
| make[5]: *** [scripts/Makefile.build:194: security/selinux/nlmsgtab.o] Error 1
Quoted 7 lines

…

The commit introducing this is part of v6.13-rc1 and we have v6.13-rc6 and I wonder why am I the only one seeing this? The bots must have noticed it way earlier and yet I can't find any report of it. Is this a typo that everyone keeps ignoring or do I lack something that auto generates this define somewhere?

Thanks for the report. This is a known issue where the generated header is not cleaned properly:
https://lore.kernel.org/selinux/[email protected]/

Could you try to remove security/selinux/av_permissions.h manually from your build directory and build again?

#2 lore raw
Quoted 6 lines · Thiébaud Weksteen

Thanks for the report. This is a known issue where the generated header is not cleaned properly:
https://lore.kernel.org/selinux/[email protected]/

Could you try to remove security/selinux/av_permissions.h manually from your build directory and build again?

I used a "clean" build directory for this: as in

| make O=/dev/shm/build defconfig
| make O=/dev/shm/build security/selinux/nlmsgtab.o

and it occurred. But since you gave me the pointer, I had av_permissions.h in my source directory which did not pop in "git status" as it was ignored. Now that this is gone, it builds again. I have no idea who this ended up in my source tree since I build out of tree.

Anyway, thank you!

Sebastian

#3 lore raw
Quoted 19 lines · Sebastian Andrzej Siewior
Quoted 6 lines · Thiébaud Weksteen

Thanks for the report. This is a known issue where the generated header is not cleaned properly:
https://lore.kernel.org/selinux/[email protected]/

Could you try to remove security/selinux/av_permissions.h manually from your build directory and build again?

I used a "clean" build directory for this: as in

| make O=/dev/shm/build defconfig
| make O=/dev/shm/build security/selinux/nlmsgtab.o

and it occurred. But since you gave me the pointer, I had av_permissions.h in my source directory which did not pop in "git status" as it was ignored. Now that this is gone, it builds again. I have no idea who this ended up in my source tree since I build out of tree.

Quoted 3 lines

Anyway, thank you!

Sebastian

[email protected]

I was seeing a similar issue. I was trying builds against multiple ARCH settings. Based upon the prior comments I first removed the instances of av_permissions.h from my build directories, but still had the "undeclared" issue. I then noticed I had an instance of av_permissions.h in my source directory, so I removed it, but then got:

../security/selinux/nlmsgtab.c:20:10: fatal error: 'av_permissions.h' file not found
20 | #include "av_permissions.h"

      |          ^~~~~~~~~~~~~~~~~~

1 error generated.
make[5]: *** [../scripts/Makefile.build:194: security/selinux/nlmsgtab.o] Error 1 make[5]: Target 'security/selinux/' not remade because of errors. make[4]: *** [../scripts/Makefile.build:440: security/selinux] Error 2

So I dug into the selinux Makefile and discovered there isn't a specific rule to make av_permissions.h, but instead it is built as a side-effect of creating flask.h. So I removed all versions of flask.h from my source and build directories, and now my selinux build issues are gone.

Is someone going to followup on the comments in selinux/Makefile about replacing the dependency rules?

# NOTE: There are a number of improvements that can be made to this Makefile

# once the kernel requires make v4.3 or greater; the most important feature
# lacking in older versions of make is support for grouped targets.  These
# improvements are noted inline in the Makefile below ...
...
# see the note above, replace the dependency rule with the one below:
#  $(addprefix $(obj)/,$(selinux-y)): $(addprefix $(obj)/,$(genhdrs))
$(addprefix $(obj)/,$(selinux-y)): $(obj)/flask.h
...
# see the note above, replace the $targets and 'flask.h' rule with the lines
# below:
#  targets += $(genhdrs)
#  $(addprefix $(obj)/,$(genhdrs)) &: $(obj)/genheaders FORCE
targets += flask.h
$(obj)/flask.h: $(obj)/genheaders FORCE
	$(call if_changed,genhdrs)

/jeff
/jeff

maintainer
#4 lore raw
Quoted 3 lines · Jeff Johnson

Is someone going to followup on the comments in selinux/Makefile about replacing the dependency rules?

As stated in the Makefile comments that you referenced, the suggested fixes for the selinux Makefile require make v4.3 or greater and unfortunately the kernel still supports make versions going back to make v4.0. Once that changes we can look at implementing the suggestions in the selinux Makefile.

In the meantime, if someone wants to propose changes to the Makefile, patches are welcome on the selinux mailing list.

Signature · 1 line
paul-moore.com