Skip to contentSkip to conversation

diff between name_bind,bind and node_bind

DISCUSSION Sebastian Pfaff 2 participants 4 messages Apr 7, 2009 SELinux security module

lore
Share & tools
lore
#0 lore raw

hello,

i'm working on a tutorial for selinux. in this tutorial i use nc (netcat) as simple server. but i wonder, why nc -l 5555** (nc runs in a own domain) does not need the name_bind permission to bind a port. i already asked here regarding to this, but nobody has answered.

can someone tell me how name_bind,bind and node_bind work and where the differences are?

i tried this with socat (http://www.dest-unreach.org/socat/) too. same effect. both socat and nc "never"* need name_bind.

is it possible that this pb is relying on how nc and socat work?

tnx in advance && if you need further information, please let me know ...

--
Sebastian Pfaff

* funny is, if i implement a boolean which allows nc or socat to use any port or only a speficic port, then i can see a name_bind "entry" when in permissive mode in my avc log. but i can't reproduce it. maybe this is another problem. ** same with echo "hello world" | socat - TCP-LISTEN:33331,bind=127.0.0.1

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 10 lines · Sebastian Pfaff

hello,

i'm working on a tutorial for selinux. in this tutorial i use nc (netcat) as simple server. but i wonder, why nc -l 5555** (nc runs in a own domain) does not need the name_bind permission to bind a port. i already asked here regarding to this, but nobody has answered.

can someone tell me how name_bind,bind and node_bind work and where the differences are?

Quoted 7 lines

i tried this with socat (http://www.dest-unreach.org/socat/) too. same effect. both socat and nc "never"* need name_bind.

is it possible that this pb is relying on how nc and socat work?

tnx in advance && if you need further information, please let me know ...

Hopefully my other reply clears this up for you - name_bind is not applied to ports in the auto-bind range. You can see this quite clearly from the code; look at security/selinux/hooks.c:selinux_socket_bind().

Quoted 4 lines

* funny is, if i implement a boolean which allows nc or socat to use any port or only a speficic port, then i can see a name_bind "entry" when in permissive mode in my avc log. but i can't reproduce it. maybe this is another problem.

Permissive mode only logs each unique denial once by design, as you only need one instance of each denial in order to generate policy and otherwise permissive mode is prone to flooding of the system log / audit log.

Quoted 2 lines

** same with echo "hello world" | socat - TCP-LISTEN:
33331,bind=127.0.0.1

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw

hello stephen,

tnx for your answer. it helped me a lot. i already did a "quick" check of hooks.c before but i was not sure about it. for me there are some other unknowns. i only saw, that selinux does make some differences between various port "types/classes".

is it possible to control that process cannot bind to a port which is in local port area (~32000-61000)?

so far i think it isn't possible.

--
Sebastian Pfaff

Am 07.04.2009 um 14:34 schrieb Stephen Smalley:

Quoted 28 lines · Sebastian Pfaff
Quoted 10 lines

hello,

i'm working on a tutorial for selinux. in this tutorial i use nc (netcat) as simple server. but i wonder, why nc -l 5555** (nc runs in a own domain) does not need the name_bind permission to bind a port. i already asked here regarding to this, but nobody has answered.

can someone tell me how name_bind,bind and node_bind work and where the differences are?

Quoted 7 lines

i tried this with socat (http://www.dest-unreach.org/socat/) too. same effect. both socat and nc "never"* need name_bind.

is it possible that this pb is relying on how nc and socat work?

tnx in advance && if you need further information, please let me know ...

Hopefully my other reply clears this up for you - name_bind is not applied to ports in the auto-bind range. You can see this quite clearly from the code; look at security/selinux/hooks.c:selinux_socket_bind().

Quoted 4 lines

* funny is, if i implement a boolean which allows nc or socat to use any port or only a speficic port, then i can see a name_bind "entry" when in permissive mode in my avc log. but i can't reproduce it. maybe this is another problem.

Quoted 12 lines

Permissive mode only logs each unique denial once by design, as you only need one instance of each denial in order to generate policy and otherwise permissive mode is prone to flooding of the system log / audit log.

Quoted 2 lines

** same with echo "hello world" | socat - TCP-LISTEN:
33331,bind=127.0.0.1

Signature · 2 lines
Stephen Smalley
National Security Agency

--
Sebastian Pfaff

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#3 lore raw
Quoted 11 lines · Sebastian Pfaff

hello stephen,

tnx for your answer. it helped me a lot. i already did a "quick" check of hooks.c before but i was not sure about it. for me there are some other unknowns. i only saw, that selinux does make some differences between various port "types/classes".

is it possible to control that process cannot bind to a port which is in local port area (~32000-61000)?

so far i think it isn't possible.

Not without further kernel changes. You can however prevent it from creating or binding sockets in the first place, or you can use e.g. secmark to label all packets destined to a given port as having a given type and then have policy control what sockets can receive such packets.

Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.