Skip to content

af_unix: Align with upstream to avoid a potential UAF

Lee Jones linux-arch lkml netdev stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest27 patches 30 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/27af_unix: Kconfig: make CONFIG_UNIX boolnet/unix/Kconfig+1 -51 reply
2/27af_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
3/27af_unix: Run GC on only one CPU.net/unix/garbage.c+27 -271 reply
4/27af_unix: Try to run GC async.include/net/af_unix.h include/net/scm.h net/core/scm.c +2 more+29 -51 reply
5/27af_unix: Replace BUG_ON() with WARN_ON_ONCE().net/unix/garbage.c net/unix/scm.c+8 -84 replies
6/27af_unix: Remove io_uring code for GC.net/unix/garbage.c+2 -231 reply
7/27af_unix: Remove CONFIG_UNIX_SCM.include/net/af_unix.h net/Makefile net/unix/Kconfig +5 more+137 -1741 reply
8/27af_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
9/27af_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
10/27af_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
11/27af_unix: Bulk update unix_tot_inflight/unix_inflight when queuing skb.net/unix/garbage.c+7 -111 reply
12/27af_unix: Iterate all vertices by DFS.include/net/af_unix.h net/unix/garbage.c+76 -01 reply
13/27af_unix: Detect Strongly Connected Components.include/net/af_unix.h net/unix/garbage.c+47 -21 reply
14/27af_unix: Save listener for embryo socket.include/net/af_unix.h net/unix/af_unix.c+5 -11 reply
15/27af_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
16/27af_unix: Save O(n) setup of Tarjan's algo.include/net/af_unix.h net/unix/garbage.c+15 -121 reply
17/27af_unix: Skip GC if no cycle exists.net/unix/garbage.c+47 -11 reply
18/27af_unix: Avoid Tarjan's algorithm if unnecessary.net/unix/garbage.c+27 -11 reply
19/27af_unix: Assign a unique index to SCC.include/net/af_unix.h net/unix/garbage.c+16 -151 reply
20/27af_unix: Detect dead SCC.net/unix/garbage.c+43 -11 reply
21/27af_unix: Replace garbage collection algorithm.include/net/af_unix.h net/unix/af_unix.c net/unix/garbage.c+64 -2741 reply
22/27af_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
23/27af_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
24/27af_unix: Don't access successor in unix_del_edges() during GC.net/unix/garbage.c+12 -51 reply
25/27af_unix: Add dead flag to struct scm_fp_list.include/net/scm.h net/core/scm.c net/unix/garbage.c+12 -41 reply
26/27af_unix: Fix garbage collection of embryos carrying OOB with SCM_RIGHTSnet/unix/garbage.c+14 -91 reply
27/27af_unix: Fix uninit-value in __unix_walk_scc()net/unix/garbage.c+5 -41 reply

Reviews trailers per patch

22 of 27 patches have a Reviewed-by or Acked-by.

PatchChristian BraunerEric DumazetPavel BegunkovSimon HormanJens AxboePaolo AbeniKuniyuki Iwashima
1/27A-b A-b R-b R-b
2/27A-b R-b R-b
3/27
4/27
5/27A-b A-b
6/27A-b A-b
7/27A-b
8/27A-b
9/27A-b
10/27A-b A-b
11/27A-b A-b
12/27A-b A-b
13/27A-b A-b
14/27A-b A-b
15/27A-b A-b
16/27A-b A-b
17/27A-b A-b
18/27A-b A-b
19/27A-b A-b
20/27A-b A-b
21/27A-b A-b
22/27
23/27
24/27
25/27A-b A-b
26/27R-b R-b
27/27R-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 7 reviewers.

Read the v1 thread

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

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]/

Alexander Mikhalitsyn (1):
af_unix: Kconfig: make CONFIG_UNIX bool

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 |  48 ++-
 include/net/scm.h     |  11 +
 net/Makefile          |   2 +-
 net/core/scm.c        |  17 ++
 net/unix/Kconfig      |  11 +-
 net/unix/Makefile     |   2 -
 net/unix/af_unix.c    | 120 +++++---
 net/unix/garbage.c    | 691 +++++++++++++++++++++++++++++-------------
 net/unix/scm.c        | 154 ----------
 net/unix/scm.h        |  10 -
 10 files changed, 618 insertions(+), 448 deletions(-)
 delete mode 100644 net/unix/scm.c
 delete mode 100644 net/unix/scm.h
Signature · 1 line
2.49.0.1143.g0be31eac6b-goog