]> git.baikalelectronics.ru Git - kernel.git/commit
sctp: fix possibly using a bad saddr with a given dst
authorMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Thu, 26 Mar 2020 23:47:46 +0000 (20:47 -0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 30 Mar 2020 05:01:43 +0000 (22:01 -0700)
commit3efa32ee0bb271cb137431d01a9de9034bc3e48d
treee4ee774bfb8cbcd87d3e58c969ad0d86a68d6678
parent240f357b23a2094b3f7ac9bbf9b0ea5ca25c5e3b
sctp: fix possibly using a bad saddr with a given dst

Under certain circumstances, depending on the order of addresses on the
interfaces, it could be that sctp_v[46]_get_dst() would return a dst
with a mismatched struct flowi.

For example, if when walking through the bind addresses and the first
one is not a match, it saves the dst as a fallback (added in
2a22cc7dc01b), but not the flowi. Then if the next one is also not a
match, the previous dst will be returned but with the flowi information
for the 2nd address, which is wrong.

The fix is to use a locally stored flowi that can be used for such
attempts, and copy it to the parameter only in case it is a possible
match, together with the corresponding dst entry.

The patch updates IPv6 code mostly just to be in sync. Even though the issue
is also present there, it fallback is not expected to work with IPv6.

Fixes: 2a22cc7dc01b ("sctp: add routing output fallback")
Reported-by: Jin Meng <meng.a.jin@nokia-sbell.com>
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Tested-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/ipv6.c
net/sctp/protocol.c