Skip to content

net: trust-after-modification fixes for IPv4 options + netlabel

Qi Tang linux-security-module netdev stable 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest4 patches 3 repliesIn review
  2. v14 patches 7 repliesSuperseded

Changes in v2 from the cover letter

- 3/4 + 4/4 return -EINVAL on bounds-check failure instead of falling through to netlbl_unlabel_getattr() (Paul Moore).
- 3/4 commit message drops the "Smack" mention from the CALIPSO consume path; Smack does not currently consume CALIPSO (Casey Schaufler).
- 4/4 inline comment explains the literal 8: CIPSO option header (type+len+DOI = 6) plus first tag header (type+len = 2) (Paul Moore).
- All four pick up Cc: [email protected].

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4ipv4: validate ip_options length in __ip_options_echo() against skb tailnet/ipv4/ip_options.c+8 -01 reply
2/4ipv4: ipmr: clamp ip_hdrlen against skb_headlen in ipmr_cache_reportnet/ipv4/ipmr.c+1 -10 replies
3/4netlabel: validate CALIPSO option against skb tail in netlbl_skbuff_getattrnet/netlabel/netlabel_kapi.c+13 -21 reply
4/4netlabel: validate CIPSO option against skb tail in netlbl_skbuff_getattrnet/netlabel/netlabel_kapi.c+15 -21 reply

Reviews trailers per patch

1 of 4 patches has a Reviewed-by or Acked-by.

PatchPaul Moore
1/4
2/4
3/4A-b
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH net v2 0/4] net: trust-after-modification fixes for IPv4 options + netlabel

Four small bounds-check fixes for a recurring pattern in IPv4 options and CIPSO/CALIPSO consumers. The parse-time validator stores only the option offset into IPCB / skb metadata. Later consumers (cmsg echo, mrouted report, netlabel getattr) re-read the length / pointer / cat_len bytes from the skb body and use them for indexed memcpy or bitmap walk. An nftables payload mutation reachable from an unprivileged user namespace (CAP_NET_ADMIN inside the namespace) rewrites those bytes between parse and consume.

1/4 __ip_options_echo() 40-byte stack OOB write

                                         (KASAN: stack-out-of-bounds,
                                         Write of size 255).

2/4 ipmr_cache_report() Up to 40-byte OOB read of
skb head leaked into the IGMPMSG cmsg delivered to mrouted.
3/4 netlbl_skbuff_getattr() / CALIPSO ~232-byte slab OOB read
driving SELinux MLS category bitmap.
4/4 netlbl_skbuff_getattr() / CIPSO Sibling of 3/4 on the
AF_INET (CIPSO IPv4) path.

Florian Westphal's [PATCH net 05/10] netfilter: disable payload mangling in userns blocks the unprivileged-userns side of nft payload-set at the source:
https://lore.kernel.org/netdev/[email protected]/
These four consumer-side bounds checks land in the same direction as defense in depth, also covering root / CAP_NET_ADMIN nft FORWARD payload mangling in the init userns and any non-nft mutation path.

Changes v1 -> v2:
- 3/4 + 4/4 return -EINVAL on bounds-check failure instead of falling through to netlbl_unlabel_getattr() (Paul Moore).
- 3/4 commit message drops the "Smack" mention from the CALIPSO consume path; Smack does not currently consume CALIPSO (Casey Schaufler).
- 4/4 inline comment explains the literal 8: CIPSO option header (type+len+DOI = 6) plus first tag header (type+len = 2) (Paul Moore).
- All four pick up Cc: [email protected].

v1: https://lore.kernel.org/netdev/[email protected]/

Qi Tang (4):
ipv4: validate ip_options length in __ip_options_echo() against skb
tail
ipv4: ipmr: clamp ip_hdrlen against skb_headlen in ipmr_cache_report
netlabel: validate CALIPSO option against skb tail in
netlbl_skbuff_getattr
netlabel: validate CIPSO option against skb tail in
netlbl_skbuff_getattr

 net/ipv4/ip_options.c        |  8 ++++++++
 net/ipv4/ipmr.c              |  2 +-
 net/netlabel/netlabel_kapi.c | 32 ++++++++++++++++++++++++++++----
 3 files changed, 37 insertions(+), 5 deletions(-)

--
2.47.3