mptcp: Avoid NULL dereference in mptcp_getsockopt_subflow_addrs()
Subsystems (2)
PATCH 1/1 mptcp: Avoid NULL dereference in mptcp_getsockopt_subflow_addrs()
From: Tim Gardner <[email protected]>
Coverity complains of a possible NULL dereference in mptcp_getsockopt_subflow_addrs():
861 } else if (sk->sk_family == AF_INET6) {
3. returned_null: inet6_sk returns NULL. [show details]
4. var_assigned: Assigning: np = NULL return value from inet6_sk.
862 const struct ipv6_pinfo *np = inet6_sk(sk);
Fix this by checking for NULL.
---
This is a slight revision to Tim's patch submitted to netdev a few weeks ago:
https://lore.kernel.org/netdev/[email protected]/
I added the WARN_ON_ONCE() as Paolo suggested and added Closes:/Fixes:.
-Mat
--- net/mptcp/sockopt.c | 3 +++ 1 file changed, 3 insertions(+)
net/mptcp/sockopt.c +3 -0
@@ -861,6 +861,9 @@ static void mptcp_get_sub_addrs(const struct sock *sk, struct mptcp_subflow_addr }else if (sk->sk_family ==AF_INET6 ) {const struct ipv6_pinfo *np =inet6_sk (sk); +if (WARN_ON_ONCE (!np)) +return ; + a->sin6_local.sin6_family =AF_INET6 ; a->sin6_local.sin6_port = inet->inet_sport;
Signature · 1 line
2.33.0
Hi Mat, Tim,
Quoted 10 lines · Mat Martineau
From: Tim Gardner <[email protected]>
Coverity complains of a possible NULL dereference in
mptcp_getsockopt_subflow_addrs():861 } else if (
sk->sk_family==AF_INET6) {
3.returned_null:inet6_skreturns NULL. [show details]
4.var_assigned: Assigning: np = NULL return value frominet6_sk.
862 const structipv6_pinfo*np =inet6_sk(sk);
Quoted 8 lines
Fix this by checking for NULL.
Fixes c11c5906bc0a ("mptcp: add MPTCP_SUBFLOW_ADDRS getsockopt support")Cc Florian Westphal <[email protected]>Signed-off-by Tim Gardner <[email protected]>[mjm: Added WARN_ON_ONCE() to the unexpected case]Signed-off-by Mat Martineau <[email protected]>
Thank you for this patch, the review and the modifications!
Now in our tree: in "fixes for net", I guess that's what you wanted, right?
- 08dbe56922c1: mptcp: Avoid NULL dereference in mptcp_getsockopt_s(...)
- Results: 0c525f1e0da1..7d0aef192d20
Builds and tests are now in progress:
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20211014T121646
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net