net: rose: fix OOB read in CCITT facility parsing
Subsystems (3)
PATCH 1/1 net: rose: fix OOB read in CCITT facility parsing
In rose_parse_ccitt(), the 0xC0 (variable-length) case validates that len >= 2 and that the length field l is in range [10, 20], but does not check that the remaining buffer can actually hold l + 2 bytes before performing memcpy operations at offsets p+7 and p+12.
With a short facilities field (e.g. 2 bytes) and l=10, the memcpy calls read up to 15 bytes past the buffer, leaking adjacent heap data into the facilities struct. This data is then copied to the socket and can be read by userspace via getsockname()/getpeername().
Add the same bounds check that rose_parse_national() already uses for its own 0xC0 case: if (len < 2 + l) return -1.
This code was removed from mainline by commit dd8d4bc28ad72 but remains in the 6.12 LTS branch and all prior LTS branches.
--- net/rose/rose_subr.c | 2 ++ 1 file changed, 2 insertions(+)
net/rose/rose_subr.c +2 -0
@@ -369,6 +369,8 @@ static int rose_parse_ccitt(unsigned char *p,/* Prevent overflows*/ if (l <10 || l >20 )return -1 ; +if (len <2 + l) +return -1 ;if (*p ==FAC_CCITT_DEST_NSAP ) {memcpy (&facilities->source_addr, p +7 ,ROSE_ADDR_LEN );
--
2.43.0
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
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.
- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.
Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Greg KH
maintainerQuoted 16 lines · Tanuj Sharma
In
rose_parse_ccitt(), the0xC0(variable-length) case validates that len >= 2 and that the length field l is in range [10, 20], but does not check that the remaining buffer can actually hold l + 2 bytes before performing memcpy operations at offsets p+7 and p+12.With a short facilities field (e.g. 2 bytes) and l=10, the memcpy calls read up to 15 bytes past the buffer, leaking adjacent heap data into the facilities struct. This data is then copied to the socket and can be read by userspace via getsockname()/getpeername().
Add the same bounds check that
rose_parse_national()already uses for its own0xC0case: if (len < 2 + l) return -1.This code was removed from mainline by commit
dd8d4bc28ad72but remains in the 6.12 LTS branch and all prior LTS branches.
Quoted 6 lines
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Signed-off-by Tanuj Sharma <[email protected]>--- net/rose/rose_subr.c | 2 ++ 1 file changed, 2 insertions(+)
This file is no longer in the tree, please submit this to the out-of-tree repo that is keeping this codebase alive as it does send patches back to the stable kernel trees quite often.
thanks,
greg k-h