Skip to content

RFC selinux: avoid nf hooks overhead when not needed

Paolo Abeni netdev selinux 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest2 patches 23 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2security: add hook for netlabel status change notificationinclude/linux/lsm_hooks.h include/linux/security.h net/netlabel/netlabel_cipso_v4.c +2 more+28 -30 replies
2/2selinux: implement support for dynamic net hook [de-]registrationsecurity/selinux/hooks.c security/selinux/include/security.h security/selinux/ss/services.c +1 more+68 -101 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/2] selinux: avoid nf hooks overhead when not needed

Currently, selinux always registers iptables POSTROUTING hooks regarless of the running policy needs for any action to be performed by them.

Even the socket_sock_rcv_skb() is always registered, but it can result in a no-op depending on the current policy configuration.

The above invocations in the kernel datapath are cause of measurable overhead in networking performance test.

This patch series adds explicit notification for netlabel status change (other relevant status change, like xfrm and secmark, are already notified to LSM) and use this information in selinux to register the above hooks only when the current status makes them relevant, deregistering them when no-op

Avoiding the LSM hooks overhead, in netperf UDP_STREAM test with small packets, gives about 5% performance improvement on rx and about 8% on tx.

Paolo Abeni (2):
security: add hook for netlabel status change notification
selinux: implement support for dynamic net hook [de-]registration

 include/linux/lsm_hooks.h           |  6 ++++
 include/linux/security.h            |  5 +++
 net/netlabel/netlabel_cipso_v4.c    |  8 +++--
 net/netlabel/netlabel_unlabeled.c   |  5 ++-
 security/security.c                 |  7 ++++
 security/selinux/hooks.c            | 72 +++++++++++++++++++++++++++++++------
 security/selinux/include/security.h |  1 +
 security/selinux/ss/services.c      |  1 +
 security/selinux/xfrm.c             |  4 +++
 9 files changed, 96 insertions(+), 13 deletions(-)
Signature · 1 line
1.8.3.1