Skip to content

Commit c1c60f9

Browse files
lxinsmb49
authored andcommitted
sctp: fix a potential overflow in sctp_ifwdtsn_skip
BugLink: https://bugs.launchpad.net/bugs/2023328 [ Upstream commit 32832a2 ] Currently, when traversing ifwdtsn skips with _sctp_walk_ifwdtsn, it only checks the pos against the end of the chunk. However, the data left for the last pos may be < sizeof(struct sctp_ifwdtsn_skip), and dereference it as struct sctp_ifwdtsn_skip may cause coverflow. This patch fixes it by checking the pos against "the end of the chunk - sizeof(struct sctp_ifwdtsn_skip)" in sctp_ifwdtsn_skip, similar to sctp_fwdtsn_skip. Fixes: 0fc2ea9 ("sctp: implement validate_ftsn for sctp_stream_interleave") Signed-off-by: Xin Long <[email protected]> Link: https://lore.kernel.org/r/2a71bffcd80b4f2c61fac6d344bb2f11c8fd74f7.1681155810.git.lucien.xin@gmail.com Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Luke Nowakowski-Krijger <[email protected]>
1 parent a901c4a commit c1c60f9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/sctp/stream_interleave.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,8 @@ static void sctp_generate_iftsn(struct sctp_outq *q, __u32 ctsn)
11621162

11631163
#define _sctp_walk_ifwdtsn(pos, chunk, end) \
11641164
for (pos = chunk->subh.ifwdtsn_hdr->skip; \
1165-
(void *)pos < (void *)chunk->subh.ifwdtsn_hdr->skip + (end); pos++)
1165+
(void *)pos <= (void *)chunk->subh.ifwdtsn_hdr->skip + (end) - \
1166+
sizeof(struct sctp_ifwdtsn_skip); pos++)
11661167

11671168
#define sctp_walk_ifwdtsn(pos, ch) \
11681169
_sctp_walk_ifwdtsn((pos), (ch), ntohs((ch)->chunk_hdr->length) - \

0 commit comments

Comments
 (0)