This series addresses two OOB skb handling bugs in AF_UNIX stream sockets:
1. Decrement u->inq_len by 1 when manage_oob() unlinks an unread OOB skb,
preventing u->inq_len from remaining permanently inflated and causing
SIOCINQ / FIONREAD to report a stale positive byte count on an empty
socket.
2. Skip zero-length consumed OOB skbs (after releasing SCM rights via
unix_orphan_scm()) and pull UNIXCB(skb).consumed bytes via pskb_pull()
in unix_stream_read_skb(), preventing BPF sockmap from re-delivering
already consumed OOB bytes or partially consumed skb prefixes.
Changes in v2:
- Split into a 2-patch series as requested by Kuniyuki Iwashima.
- Update Fixes: tag to f4e1fb04c123 ("af_unix: Use cached value for
SOCK_STREAM in unix_inq_len().").
- Call unix_orphan_scm(sk, skb) before consume_skb(skb) and use
pskb_pull() instead of skb_pull() to safely handle non-linear paged skbs
as noted by Sashiko.
Hui Peng (2):
af_unix: decrement u->inq_len when skipping unread OOB skb in manage_oob()
af_unix: skip consumed OOB skb and pull consumed bytes in unix_stream_read_skb()
net/unix/af_unix.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)