All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH LSM v2 0/2] security: SELinux/LSM label with MPTCP and accept
@ 2023-04-20 17:17 Matthieu Baerts
  2023-04-20 17:17 ` [PATCH LSM v2 1/2] security, lsm: Introduce security_mptcp_add_subflow() Matthieu Baerts
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Matthieu Baerts @ 2023-04-20 17:17 UTC (permalink / raw)
  To: Paul Moore, James Morris, Serge E. Hallyn, Stephen Smalley, Eric Paris
  Cc: Paolo Abeni, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Ondrej Mosnacek, mptcp, linux-kernel, netdev,
	linux-security-module, selinux, Matthieu Baerts

In [1], Ondrej Mosnacek explained they discovered the (userspace-facing)
sockets returned by accept(2) when using MPTCP always end up with the
label representing the kernel (typically system_u:system_r:kernel_t:s0),
while it would make more sense to inherit the context from the parent
socket (the one that is passed to accept(2)). Thanks to the
participation of Paul Moore in the discussions, modifications on MPTCP
side have started and the result is available here.

Paolo Abeni worked hard to refactor the initialisation of the first
subflow of a listen socket. The first subflow allocation is no longer
done at the initialisation of the socket but later, when the connection
request is received or when requested by the userspace. This was a
prerequisite to proper support of SELinux/LSM labels with MPTCP and
accept. The last batch containing the commit ddb1a072f858 ("mptcp: move
first subflow allocation at mpc access time") [2] has been recently
accepted and applied in netdev/net-next repo [3].

This series of 2 patches is based on top of the lsm/next branch. Despite
the fact they depend on commits that are in netdev/net-next repo to
support the new feature, they can be applied in lsm/next without
creating conflicts with net-next or causing build issues. These two
patches on top of lsm/next still passes all the MPTCP-specific tests.
The only thing is that the new feature only works properly with the
patches that are on netdev/net-next. The tests with the new labels have
been done on top of them.

Regarding the two patches, the first one introduces a new LSM hook
called from MPTCP side when creating a new subflow socket. This hook
allows the security module to relabel the subflow according to the owing
process. The second one implements this new hook on the SELinux side.

Link: https://lore.kernel.org/netdev/CAFqZXNs2LF-OoQBUiiSEyranJUXkPLcCfBkMkwFeM6qEwMKCTw@mail.gmail.com/ [1]
Link: https://git.kernel.org/netdev/net-next/c/ddb1a072f858 [2]
Link: https://lore.kernel.org/netdev/20230414-upstream-net-next-20230414-mptcp-refactor-first-subflow-init-v1-0-04d177057eb9@tessares.net/ [3]
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
Changes in v2:
- Address Paul's comments, see the notes on each patch
- Link to v1: https://lore.kernel.org/r/20230419-upstream-lsm-next-20230419-mptcp-sublows-user-ctx-v1-0-9d4064cb0075@tessares.net

---
Paolo Abeni (2):
      security, lsm: Introduce security_mptcp_add_subflow()
      selinux: Implement mptcp_add_subflow hook

 include/linux/lsm_hook_defs.h |  1 +
 include/linux/security.h      |  6 ++++++
 net/mptcp/subflow.c           |  6 ++++++
 security/security.c           | 17 +++++++++++++++++
 security/selinux/hooks.c      | 16 ++++++++++++++++
 security/selinux/netlabel.c   |  8 ++++++--
 6 files changed, 52 insertions(+), 2 deletions(-)
---
base-commit: d82dcd9e21b77d338dc4875f3d4111f0db314a7c
change-id: 20230419-upstream-lsm-next-20230419-mptcp-sublows-user-ctx-eee658fafcba

Best regards,
-- 
Matthieu Baerts <matthieu.baerts@tessares.net>


^ permalink raw reply	[flat|nested] 16+ messages in thread
* [PATCH v2 0/2] lsm: introduce and use security_mptcp_add_subflow()
@ 2022-12-19 17:33 Paolo Abeni
  2022-12-19 17:33 ` [PATCH v2 2/2] selinux: Implement mptcp_add_subflow hook Paolo Abeni
  0 siblings, 1 reply; 16+ messages in thread
From: Paolo Abeni @ 2022-12-19 17:33 UTC (permalink / raw)
  To: linux-security-module; +Cc: Paul Moore, selinux, mptcp

This series is an attempt to solve the LSM labeling breakage
reported here:

https://lore.kernel.org/linux-security-module/CAHC9VhSQnhH3UL4gqzu+YiA1Q3YyLLCv88gLJOvw-0+uw5Lvkw@mail.gmail.com/

As per previous discussion, a new LSM hook is introduced and
invoked by the mptcp code to let LSMs set the appropriate label
for the newly created subflow.

I'm not sure the chosen hook name is a perfect fit, any suggestion
more then welcome.
The new hook requires both the mptcp socket reference and the
subflow socket reference, even if the provided LSM implementation
for selinux ends-up accessing only the subflow socket. Possibly
other LSM implementation could need or use the addtional parameter.

Tested vs the issue reproducer and mptcp self-tests.

v1 -> v2:
 - fix a few build issues with unusual configurations reported
   by bots

Paolo Abeni (2):
  security, lsm: Introduce security_mptcp_add_subflow()
  selinux: Implement mptcp_add_subflow hook

 include/linux/lsm_hook_defs.h |  1 +
 include/linux/lsm_hooks.h     |  9 +++++++++
 include/linux/security.h      |  6 ++++++
 net/mptcp/subflow.c           |  6 ++++++
 security/security.c           |  5 +++++
 security/selinux/hooks.c      | 27 +++++++++++++++++++++++++++
 security/selinux/netlabel.c   |  4 +++-
 7 files changed, 57 insertions(+), 1 deletion(-)

-- 
2.38.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2023-05-18 17:12 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-20 17:17 [PATCH LSM v2 0/2] security: SELinux/LSM label with MPTCP and accept Matthieu Baerts
2023-04-20 17:17 ` [PATCH LSM v2 1/2] security, lsm: Introduce security_mptcp_add_subflow() Matthieu Baerts
2023-05-18 17:11   ` [PATCH " Paul Moore
2023-04-20 17:17 ` [PATCH LSM v2 2/2] selinux: Implement mptcp_add_subflow hook Matthieu Baerts
2023-05-18 17:12   ` [PATCH " Paul Moore
2023-05-04 14:14 ` [PATCH LSM v2 0/2] security: SELinux/LSM label with MPTCP and accept Ondrej Mosnacek
2023-05-04 16:13   ` Paolo Abeni
2023-05-05 14:16     ` Ondrej Mosnacek
  -- strict thread matches above, loose matches on Subject: below --
2022-12-19 17:33 [PATCH v2 0/2] lsm: introduce and use security_mptcp_add_subflow() Paolo Abeni
2022-12-19 17:33 ` [PATCH v2 2/2] selinux: Implement mptcp_add_subflow hook Paolo Abeni
2022-12-20 22:07   ` Paul Moore
2022-12-21 19:23     ` Paolo Abeni
2022-12-22  1:21       ` Paul Moore
2022-12-22 15:57         ` Paolo Abeni
2022-12-23 17:11           ` Paul Moore
2023-01-09 10:31             ` Paolo Abeni
2023-01-11 23:17               ` Paul Moore

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.