Re: [PATCH net v2] net/smc: validate the peer's CDC cursors against our own buffers
From: Piyus Kedia
Date: Sun Nov 22 2026 - 09:06:57 EST
Hi Dust,
Thanks for pointing this out. I checked that Bryam's patch indeed
fixes the same issue. Please drop this patch.
Best,
Piyus
On Sun, Nov 22, 2026 at 7:09 PM Dust Li <dust.li@xxxxxxxxxxxxxxxxx> wrote:
>
> On 2026-11-22 09:51:20, Piyus Kedia wrote:
> >A peer's CDC message carries two cursors that are offsets into buffers
> >described on this side: the producer cursor counts the bytes the peer has
> >written into the RMB we published to it, and the consumer cursor the bytes
> >it has taken from the RMB it published to us. Neither is checked, on either
> >transport.
> >
> >smcr_cdc_msg_to_host() and smcd_cdc_msg_to_host() copy both into the
> >connection as they arrive, and every later user treats them as trustworthy:
> >
> > - smc_cdc_msg_recv_action() adds the producer difference to
> > conn->bytes_to_rcv under a comment asserting
> > "guarantee 0 <= bytes_to_rcv <= rmb_desc->len", which nothing enforces;
> > - smc_cdc_handle_urg_data_arrival() reads
> > *(base + conn->urg_curs.count - 1), an unbounded index into the RMB;
> > - smc_rx_recvmsg() clamps only the first of its two ring chunks
> > (rmb_desc->len - cons.count) and uses the remainder unclamped for the
> > second, so bytes_to_rcv becomes a copy length;
> > - smc_rx_splice() walks PAGE_ALIGN(len + offset) / PAGE_SIZE pages calling
> > vmalloc_to_page() without checking the result, and get_page() then
> > dereferences NULL once the walk passes the end of the RMB.
>
> I think Bryam's patch is solving the same problem here:
> https://lore.kernel.org/netdev/20261112-b4-disp-0287c16e-v9-0-e5e8fa688177@xxxxxxxxx
>
> Best regards,
> Dust
>