Skip to content

Commit 30fe3f5

Browse files
neosys007Paolo Abeni
authored andcommitted
NFC: pn533: bound the UART receive buffer
pn532_receive_buf() appends every incoming byte to dev->recv_skb and only resets the buffer after pn532_uart_rx_is_frame() recognizes a complete frame. A continuous stream of bytes without a valid PN532 frame header therefore keeps growing the skb until skb_put_u8() hits the tail limit. Drop the accumulated partial frame once the fixed receive buffer is full so malformed UART traffic cannot grow the skb past PN532_UART_SKB_BUFF_LEN. Fixes: c656aa4 ("nfc: pn533: add UART phy driver") Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn> Link: https://patch.msgid.link/20260326142033.82297-1-pengpeng@iscas.ac.cn Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 2884bf7 commit 30fe3f5

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/nfc/pn533/uart.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,9 @@ static size_t pn532_receive_buf(struct serdev_device *serdev,
211211

212212
timer_delete(&dev->cmd_timeout);
213213
for (i = 0; i < count; i++) {
214+
if (unlikely(!skb_tailroom(dev->recv_skb)))
215+
skb_trim(dev->recv_skb, 0);
216+
214217
skb_put_u8(dev->recv_skb, *data++);
215218
if (!pn532_uart_rx_is_frame(dev->recv_skb))
216219
continue;

0 commit comments

Comments
 (0)