selinux: fix address family in bind() and connect() to match address/port
authorAlexey Kodanev <alexey.kodanev@oracle.com>
Fri, 11 May 2018 17:15:12 +0000 (20:15 +0300)
committerPaul Moore <paul@paul-moore.com>
Mon, 14 May 2018 19:19:25 +0000 (15:19 -0400)
commit88b7d370bb4b1280717ebdacd6748456f9ba484f
treeb39eaeabeabb993ffcfffe9fb6f566a32ad4975a
parent0f8db8cc73df60b3de9a5eebd8f117b56eff5b03
selinux: fix address family in bind() and connect() to match address/port

Since sctp_bindx() and sctp_connectx() can have multiple addresses,
sk_family can differ from sa_family. Therefore, selinux_socket_bind()
and selinux_socket_connect_helper(), which process sockaddr structure
(address and port), should use the address family from that structure
too, and not from the socket one.

The initialization of the data for the audit record is moved above,
in selinux_socket_bind(), so that there is no duplicate changes and
code.

Fixes: d452930fd3b9 ("selinux: Add SCTP support")
Suggested-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/hooks.c