Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
* [PATCH net v2 0/2] net/smc: fix use-after-free in smc_rx_pipe_buf_release()
@ 2026-08-20  7:46 Hidayath Khan
  2026-08-20  7:46 ` [PATCH net v2 1/2] net/smc: stop killed, freed and out_of_sync sharing a byte Hidayath Khan
  2026-08-20  7:46 ` [PATCH net v2 2/2] net/smc: fix use-after-free in smc_rx_pipe_buf_release() Hidayath Khan
  0 siblings, 2 replies; 3+ messages in thread
From: Hidayath Khan @ 2026-08-20  7:46 UTC (permalink / raw)
  To: alibuda, dust.li, sidraya, mjambigi, andrew+netdev
  Cc: tonylu, guwen, davem, edumazet, kuba, pabeni, horms, pasic,
	hidayath, linux-s390, netdev, linux-rdma

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.

-- 
2.52.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-20  7:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-20  7:46 [PATCH net v2 0/2] net/smc: fix use-after-free in smc_rx_pipe_buf_release() Hidayath Khan
2026-08-20  7:46 ` [PATCH net v2 1/2] net/smc: stop killed, freed and out_of_sync sharing a byte Hidayath Khan
2026-08-20  7:46 ` [PATCH net v2 2/2] net/smc: fix use-after-free in smc_rx_pipe_buf_release() Hidayath Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox