Re: [PATCH net] net/smc: validate the peer's CDC cursors against our own buffers
From: Piyus Kedia
Date: Sat Nov 21 2026 - 23:21:34 EST
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - How the issue was discovered, e.g. hit in production, hit during
> development, syzbot report, manual code inspection, LLM or static
> analysis tool scan.
Sorry for the omission.
How it was found
================
By AI-driven fuzzing built on top of syzkaller.
Its analysis was checked by hand against the code before we wrote anything,
and every claim in the report was reproduced on net.git main at d5b89d55a322
under KASAN:
- a 131072-byte read past a 65536-byte RMB in smc_rx_recvmsg(), reaching
userspace through _copy_to_iter();
- a 1-byte read at an attacker-chosen offset in
smc_cdc_handle_urg_data_arrival(), from the CDC tasklet;
- a NULL dereference and oops in smc_rx_splice(), where vmalloc_to_page()
returns NULL past the end of the RMB and get_page() dereferences it.
Each was run on an unpatched and a patched kernel built from the same tree in
the same scripted run: unpatched reports on all three, patched clean on all
three, with SMC_DIAG confirming SMC-R came up (mode=0, fb_reason=0x0) in
every run so that a clean result cannot be a setup failure.
What changed in v2
==================
Sending v2 separately, because it is a code change rather than only the
information above: v1 validated the SMC-R path only, while the report
acknowledged that SMC-D shares all three consumers. smcd_cdc_rx_tsklet()
reads the cursors straight out of the DMB the peer writes into, in host byte
order, with no validation of any kind - not even the length and seqno tests
the SMC-R handler applies - so v1 left the same exposure open there. v2 adds
the equivalent check on that path. The SMC-R check itself is unchanged.
We have no ISM device, so the SMC-D half is reasoned from the code and from
the shared consumers rather than reproduced; what we did verify at runtime is
that ordinary SMC-D traffic over the loopback-ISM device still works with the
check in place, so it does not reject a correct peer.
The interdiff from the posted v1:
diff --git a/net/smc/smc_cdc.c b/net/smc/smc_cdc.c
index 03ff10fef..8d24e0c83 100644
--- a/net/smc/smc_cdc.c
+++ b/net/smc/smc_cdc.c
@@ -433,6 +433,18 @@ static void smc_cdc_msg_recv(struct smc_sock *smc, struct smc_cdc_msg *cdc)
sock_put(&smc->sk); /* no free sk in softirq-context */
}
+static bool smcd_cdc_cursors_invalid(struct smc_connection *conn,
+ struct smcd_cdc_msg *cdc)
+{
+ if (!conn->rmb_desc)
+ return true;
+ if (cdc->prod.count > (u32)conn->rmb_desc->len)
+ return true;
+ if (cdc->cons.count > (u32)conn->peer_rmbe_size)
+ return true;
+ return false;
+}
+
/* Schedule a tasklet for this connection. Triggered from the ISM device IRQ
* handler to indicate update in the DMBE.
*
@@ -452,6 +464,15 @@ static void smcd_cdc_rx_tsklet(struct tasklet_struct *t)
data_cdc = (struct smcd_cdc_msg *)conn->rmb_desc->cpu_addr;
smcd_curs_copy(&cdc.prod, &data_cdc->prod, conn);
smcd_curs_copy(&cdc.cons, &data_cdc->cons, conn);
+ /* This CDC was written by the peer into the DMB we published to it, so
+ * both cursors are peer-supplied and index buffers described on this
+ * side. Nothing else checks them, and smc_cdc_msg_recv_action() uses
+ * the producer cursor as a receive length and the consumer cursor to
+ * credit sndbuf_space - which under DMB-nocopy is the memory the peer
+ * itself owns. Unlike the SMC-R path these values are host order.
+ */
+ if (smcd_cdc_cursors_invalid(conn, &cdc))
+ return;
smc = container_of(conn, struct smc_sock, conn);
smc_cdc_msg_recv(smc, (struct smc_cdc_msg *)&cdc);
}
Thanks,
Piyus Kedia