tcp: fix use-after-free in do_tcp_getsockopt()
Status from this message: This series was applied to netdev/net.git (main)
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest2 patches 8 repliesApplied 2/2
- v22 patches 7 repliesSuperseded
- v12 patches 2 repliesSuperseded
Patches in v3 All 2 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | tcp: fix use-after-free in do_tcp_getsockopt(TCP_CONGESTION)net/ net/ net/ +2 more | +16 | 5 replies | Applied |
| 2/2 | tcp: fix use-after-free in do_tcp_getsockopt(TCP_CC_INFO)net/ net/ | +4 | 2 replies | Applied |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by.
| Patch | Eric Dumazet | Jiayuan Chen | Matthieu Baerts (NGI0) | Breno Leitao |
|---|---|---|---|---|
| 1/2 | R-b | R-b | R-b | R-b |
| 2/2 | R-b | R-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 4 reviewers.
Cover letter [PATCH net v3 0/2] tcp: fix use-after-free in do_tcp_getsockopt()
From: "Cen Zhang (Microsoft Security FORGE Labs)" <[email protected]>
do_tcp_getsockopt() has two lockless reads of icsk_ca_ops. Since BPF struct_ops congestion control made icsk_ca_ops point to dynamically allocated memory, a concurrent setsockopt(TCP_CONGESTION) can replace the pointer and free the old object while either reader is using it.
Patch 1 fixes the TCP_CONGESTION path by copying ca_ops->name to a stack buffer while holding rcu_read_lock(). It also uses READ_ONCE() for the lockless load and annotates the relevant icsk_ca_ops stores with WRITE_ONCE().
Patch 2 fixes the TCP_CC_INFO path by keeping the READ_ONCE() load, ca_ops->get_info lookup, and call inside an RCU read-side critical section.
Changes since v2 [1]:
- Fix the TCP_CONGESTION build failure by loading icsk_ca_ops inline.
- Drop the unrelated WRITE_ONCE() conversion in mptcp_ca_reset().
- Add READ_ONCE() to dctcp_get_info()'s icsk_ca_ops comparison.
Changes in v2 [2]:
- Add READ_ONCE() to both lockless icsk_ca_ops loads.
- Add WRITE_ONCE() to all six explicit icsk_ca_ops stores.
- Include the data-race annotations in the UAF series as requested by Eric Dumazet [3].
[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/
[3] https://lore.kernel.org/all/CANn89iKr1ypEFeL+7te3xWoNaK5AFyYQmr+pDh2zSZAxfgNKjw@mail.gmail.com/
Cen Zhang (Microsoft Security FORGE Labs) (2):
tcp: fix use-after-free in do_tcp_getsockopt(TCP_CONGESTION)
tcp: fix use-after-free in do_tcp_getsockopt(TCP_CC_INFO)
net/ipv4/tcp.c | 18 ++++++++++++++---- net/ipv4/tcp_cong.c | 4 ++-- net/ipv4/tcp_dctcp.c | 4 ++-- net/ipv4/tcp_minisocks.c | 2 +- net/ipv4/tcp_output.c | 2 +- 5 files changed, 20 insertions(+), 10 deletions(-)
base-commit: a3dee9bb902ee4357fa02e49b415d7724ee0140a
Signature · 1 line
2.43.0