net/smc: fix use-after-free in smc_rx_pipe_buf_release()
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
- v2 Latest2 patches 1 replyApplied 2/2
- v11 patch 2 repliesSuperseded
Changes in v2 from the cover letter
- Patch 1/2 is new. It is a prerequisite for 2/2.
- Patch 2/2 replaces the conn->rmb_desc = NULL approach from v1 with a conn->freed check. The NULL store exposed smc_cdc_msg_recv_action() and the sock_diag dump to NULL dereferences on paths that do not take the socket lock.
Patches in v2 All 2 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | net/smc: stop killed, freed and out_of_sync sharing a bytenet/ | +3 | 0 replies | Applied |
| 2/2 | net/smc: fix use-after-free in smc_rx_pipe_buf_release()net/ | +5 | 0 replies | Applied |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Mahanta Jambigi | Simon Horman |
|---|---|---|
| Series | R-b | |
| 1/2 | R-b | |
| 2/2 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH net v2 0/2] net/smc: fix use-after-free in smc_rx_pipe_buf_release()
smc_rx_pipe_buf_release() tests sk_state before taking the socket lock and then dereferences conn->rmb_desc and conn->lgr. A concurrent close runs smc_conn_free() in between, which releases those structures. On the is_reg_err path smcr_buf_unuse() frees the descriptor outright, so this is a use-after-free.
Patch 2/2 fixes this by taking the socket lock first and testing conn->freed instead. smc_conn_free() sets that flag before releasing anything, under the same lock, so the two paths exclude each other.
Patch 1/2 is a prerequisite. conn->freed shares a byte with killed and out_of_sync as single-bit bitfields. out_of_sync is written from the receive tasklet without the socket lock, so a concurrent store to freed from process context can be lost in the read-modify-write. Patch 1/2 gives each flag its own byte so stores do not interfere.
Hidayath Khan (2):
net/smc: stop killed, freed and out_of_sync sharing a byte net/smc: fix use-after-free in smc_rx_pipe_buf_release()
net/smc/smc.h | 6 +++--- net/smc/smc_rx.c | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-)
---
v2:
- Patch 1/2 is new. It is a prerequisite for 2/2.
- Patch 2/2 replaces the conn->rmb_desc = NULL approach from v1 with a conn->freed check. The NULL store exposed smc_cdc_msg_recv_action() and the sock_diag dump to NULL dereferences on paths that do not take the socket lock.
Signature · 1 line
2.52.0