Skip to content

af_unix: Align with upstream to avoid a potential UAF

Lee Jones lkml netdev stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest26 patches 27 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/26af_unix: Return struct unix_sock from unix_get_socket().include/net/af_unix.h net/unix/garbage.c net/unix/scm.c+15 -251 reply
2/26af_unix: Run GC on only one CPU.net/unix/garbage.c+27 -271 reply
3/26af_unix: Try to run GC async.include/net/af_unix.h include/net/scm.h net/core/scm.c +2 more+29 -51 reply
4/26af_unix: Replace BUG_ON() with WARN_ON_ONCE().net/unix/garbage.c net/unix/scm.c+8 -81 reply
5/26af_unix: Remove io_uring code for GC.include/net/af_unix.h net/unix/garbage.c net/unix/scm.c+2 -301 reply
6/26af_unix: Remove CONFIG_UNIX_SCM.include/net/af_unix.h net/Makefile net/unix/Kconfig +5 more+137 -1751 reply
7/26af_unix: Allocate struct unix_vertex for each inflight AF_UNIX fd.include/net/af_unix.h include/net/scm.h net/core/scm.c +2 more+63 -01 reply
8/26af_unix: Allocate struct unix_edge for each inflight AF_UNIX fd.include/net/af_unix.h include/net/scm.h net/core/scm.c +1 more+19 -01 reply
9/26af_unix: Link struct unix_edge when queuing skb.include/net/af_unix.h include/net/scm.h net/core/scm.c +2 more+100 -31 reply
10/26af_unix: Bulk update unix_tot_inflight/unix_inflight when queuing skb.net/unix/garbage.c+7 -111 reply
11/26af_unix: Iterate all vertices by DFS.include/net/af_unix.h net/unix/garbage.c+76 -01 reply
12/26af_unix: Detect Strongly Connected Components.include/net/af_unix.h net/unix/garbage.c+47 -21 reply
13/26af_unix: Save listener for embryo socket.include/net/af_unix.h net/unix/af_unix.c+5 -11 reply
14/26af_unix: Fix up unix_edge.successor for embryo socket.include/net/af_unix.h net/unix/af_unix.c net/unix/garbage.c+21 -21 reply
15/26af_unix: Save O(n) setup of Tarjan's algo.include/net/af_unix.h net/unix/garbage.c+15 -121 reply
16/26af_unix: Skip GC if no cycle exists.net/unix/garbage.c+47 -11 reply
17/26af_unix: Avoid Tarjan's algorithm if unnecessary.net/unix/garbage.c+27 -11 reply
18/26af_unix: Assign a unique index to SCC.include/net/af_unix.h net/unix/garbage.c+16 -151 reply
19/26af_unix: Detect dead SCC.net/unix/garbage.c+43 -11 reply
20/26af_unix: Replace garbage collection algorithm.include/net/af_unix.h net/unix/af_unix.c net/unix/garbage.c+64 -2741 reply
21/26af_unix: Remove lock dance in unix_peek_fds().include/net/af_unix.h net/unix/af_unix.c net/unix/garbage.c+1 -441 reply
22/26af_unix: Try not to hold unix_gc_lock during accept().include/net/af_unix.h net/unix/af_unix.c net/unix/garbage.c+18 -51 reply
23/26af_unix: Don't access successor in unix_del_edges() during GC.net/unix/garbage.c+12 -51 reply
24/26af_unix: Add dead flag to struct scm_fp_list.include/net/scm.h net/core/scm.c net/unix/garbage.c+12 -41 reply
25/26af_unix: Fix garbage collection of embryos carrying OOB with SCM_RIGHTSnet/unix/garbage.c+14 -91 reply
26/26af_unix: Fix uninit-value in __unix_walk_scc()net/unix/garbage.c+5 -41 reply

Reviews trailers per patch

21 of 26 patches have a Reviewed-by or Acked-by.

PatchPavel BegunkovSimon HormanJens AxboePaolo AbeniKuniyuki Iwashima
1/26A-b R-b R-b
2/26
3/26
4/26A-b A-b
5/26A-b A-b
6/26A-b A-b
7/26A-b A-b
8/26A-b
9/26A-b
10/26A-b A-b
11/26A-b A-b
12/26A-b A-b
13/26A-b A-b
14/26A-b A-b
15/26A-b A-b
16/26A-b A-b
17/26A-b A-b
18/26A-b A-b
19/26A-b A-b
20/26A-b A-b
21/26
22/26
23/26
24/26A-b A-b
25/26R-b R-b
26/26R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 5 reviewers.

Read the v1 thread

Cover letter [PATCH v6.6 00/26] af_unix: Align with upstream to avoid a potential UAF

From: Lee Jones <[email protected]>

This is the second attempt at achieving the same goal. This time, the submission avoids forking the current code base, ensuring it remains easier to maintain over time.

The set has been tested using the SCM_RIGHTS test suite [1] using QEMU and has been seen to successfully mitigate a UAF on on a top tier handset.

RESULTS:

TAP version 13
1..20
# Starting 20 tests from 5 test cases.
# RUN scm_rights.dgram.self_ref ...
# OK scm_rights.dgram.self_ref
ok 1 scm_rights.dgram.self_ref
# RUN scm_rights.dgram.triangle ...
# OK scm_rights.dgram.triangle
ok 2 scm_rights.dgram.triangle
# RUN scm_rights.dgram.cross_edge ...
# OK scm_rights.dgram.cross_edge
ok 3 scm_rights.dgram.cross_edge
# RUN scm_rights.dgram.backtrack_from_scc ...
# OK scm_rights.dgram.backtrack_from_scc
ok 4 scm_rights.dgram.backtrack_from_scc
# RUN scm_rights.stream.self_ref ...
# OK scm_rights.stream.self_ref
ok 5 scm_rights.stream.self_ref
# RUN scm_rights.stream.triangle ...
# OK scm_rights.stream.triangle
ok 6 scm_rights.stream.triangle
# RUN scm_rights.stream.cross_edge ...
# OK scm_rights.stream.cross_edge
ok 7 scm_rights.stream.cross_edge
# RUN scm_rights.stream.backtrack_from_scc ...
# OK scm_rights.stream.backtrack_from_scc
ok 8 scm_rights.stream.backtrack_from_scc
# RUN scm_rights.stream_oob.self_ref ...
# OK scm_rights.stream_oob.self_ref
ok 9 scm_rights.stream_oob.self_ref
# RUN scm_rights.stream_oob.triangle ...
# OK scm_rights.stream_oob.triangle
ok 10 scm_rights.stream_oob.triangle
# RUN scm_rights.stream_oob.cross_edge ...
# OK scm_rights.stream_oob.cross_edge
ok 11 scm_rights.stream_oob.cross_edge
# RUN scm_rights.stream_oob.backtrack_from_scc ...
# OK scm_rights.stream_oob.backtrack_from_scc
ok 12 scm_rights.stream_oob.backtrack_from_scc
# RUN scm_rights.stream_listener.self_ref ...
# OK scm_rights.stream_listener.self_ref
ok 13 scm_rights.stream_listener.self_ref
# RUN scm_rights.stream_listener.triangle ...
# OK scm_rights.stream_listener.triangle
ok 14 scm_rights.stream_listener.triangle
# RUN scm_rights.stream_listener.cross_edge ...
# OK scm_rights.stream_listener.cross_edge
ok 15 scm_rights.stream_listener.cross_edge
# RUN scm_rights.stream_listener.backtrack_from_scc ...
# OK scm_rights.stream_listener.backtrack_from_scc
ok 16 scm_rights.stream_listener.backtrack_from_scc
# RUN scm_rights.stream_listener_oob.self_ref ...
# OK scm_rights.stream_listener_oob.self_ref
ok 17 scm_rights.stream_listener_oob.self_ref
# RUN scm_rights.stream_listener_oob.triangle ...
# OK scm_rights.stream_listener_oob.triangle
ok 18 scm_rights.stream_listener_oob.triangle
# RUN scm_rights.stream_listener_oob.cross_edge ...
# OK scm_rights.stream_listener_oob.cross_edge
ok 19 scm_rights.stream_listener_oob.cross_edge
# RUN scm_rights.stream_listener_oob.backtrack_from_scc ...
# OK scm_rights.stream_listener_oob.backtrack_from_scc
ok 20 scm_rights.stream_listener_oob.backtrack_from_scc # PASSED: 20 / 20 tests passed.
# Totals: pass:20 fail:0 xfail:0 xpass:0 skip:0 error:0

[0] https://lore.kernel.org/all/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/

Kuniyuki Iwashima (24):
af_unix: Return struct unix_sock from unix_get_socket().
af_unix: Run GC on only one CPU.
af_unix: Try to run GC async.
af_unix: Replace BUG_ON() with WARN_ON_ONCE().
af_unix: Remove io_uring code for GC.
af_unix: Remove CONFIG_UNIX_SCM.
af_unix: Allocate struct unix_vertex for each inflight AF_UNIX fd.
af_unix: Allocate struct unix_edge for each inflight AF_UNIX fd.
af_unix: Link struct unix_edge when queuing skb.
af_unix: Bulk update unix_tot_inflight/unix_inflight when queuing skb.
af_unix: Iterate all vertices by DFS.
af_unix: Detect Strongly Connected Components.
af_unix: Save listener for embryo socket.
af_unix: Fix up unix_edge.successor for embryo socket.
af_unix: Save O(n) setup of Tarjan's algo.
af_unix: Skip GC if no cycle exists.
af_unix: Avoid Tarjan's algorithm if unnecessary.
af_unix: Assign a unique index to SCC.
af_unix: Detect dead SCC.
af_unix: Replace garbage collection algorithm.
af_unix: Remove lock dance in unix_peek_fds().
af_unix: Try not to hold unix_gc_lock during accept().
af_unix: Don't access successor in unix_del_edges() during GC.
af_unix: Add dead flag to struct scm_fp_list.

Michal Luczaj (1):
af_unix: Fix garbage collection of embryos carrying OOB with
SCM_RIGHTS

Shigeru Yoshida (1):
af_unix: Fix uninit-value in __unix_walk_scc()

 include/net/af_unix.h |  49 ++-
 include/net/scm.h     |  11 +
 net/Makefile          |   2 +-
 net/core/scm.c        |  17 ++
 net/unix/Kconfig      |   5 -
 net/unix/Makefile     |   2 -
 net/unix/af_unix.c    | 120 +++++---
 net/unix/garbage.c    | 691 +++++++++++++++++++++++++++++-------------
 net/unix/scm.c        | 161 ----------
 net/unix/scm.h        |  10 -
 10 files changed, 617 insertions(+), 451 deletions(-)
 delete mode 100644 net/unix/scm.c
 delete mode 100644 net/unix/scm.h
Signature · 1 line
2.49.0.1112.g889b7c5bd8-goog