Skip to content

Commit 987af76

Browse files
mashirochenkernelgregkh
authored andcommitted
net: hamradio: 6pack: fix uninit-value in sixpack_receive_buf
[ Upstream commit bf9a388 ] sixpack_receive_buf() does not properly skip bytes with TTY error flags. The while loop iterates through the flags buffer but never advances the data pointer (cp), and passes the original count (including error bytes) to sixpack_decode(). This causes sixpack_decode() to process bytes that should have been skipped due to TTY errors. The TTY layer does not guarantee that cp[i] holds a meaningful value when fp[i] is set, so passing those positions to sixpack_decode() results in KMSAN reporting an uninit-value read. Fix this by processing bytes one at a time, advancing cp on each iteration, and only passing valid (non-error) bytes to sixpack_decode(). This matches the pattern used by slip_receive_buf() and mkiss_receive_buf() for the same purpose. Reported-by: syzbot+ecdb8c9878a81eb21e54@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=ecdb8c9878a81eb21e54 Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: Mashiro Chen <mashiro.chen@mailbox.org> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260407173101.107352-1-mashiro.chen@mailbox.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent e1ed678 commit 987af76

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

drivers/net/hamradio/6pack.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ static void sixpack_receive_buf(struct tty_struct *tty, const u8 *cp,
391391
const u8 *fp, size_t count)
392392
{
393393
struct sixpack *sp;
394-
size_t count1;
395394

396395
if (!count)
397396
return;
@@ -401,16 +400,16 @@ static void sixpack_receive_buf(struct tty_struct *tty, const u8 *cp,
401400
return;
402401

403402
/* Read the characters out of the buffer */
404-
count1 = count;
405-
while (count) {
406-
count--;
403+
while (count--) {
407404
if (fp && *fp++) {
408405
if (!test_and_set_bit(SIXPF_ERROR, &sp->flags))
409406
sp->dev->stats.rx_errors++;
407+
cp++;
410408
continue;
411409
}
410+
sixpack_decode(sp, cp, 1);
411+
cp++;
412412
}
413-
sixpack_decode(sp, cp, count1);
414413

415414
tty_unthrottle(tty);
416415
}

0 commit comments

Comments
 (0)