From: Ilya Lesokhin <ilyal@mellanox.com>
To: netdev@vger.kernel.org
Cc: davejwatson@fb.com, aviadye@mellanox.com,
Ilya Lesokhin <ilyal@mellanox.com>,
Boris Pismenny <borisp@mellanox.com>
Subject: [PATCH 1/3] ipv6: Prevent unexpected sk->sk_prot changes
Date: Thu, 10 Aug 2017 13:33:14 +0300 [thread overview]
Message-ID: <1502361196-127278-2-git-send-email-ilyal@mellanox.com> (raw)
In-Reply-To: <1502361196-127278-1-git-send-email-ilyal@mellanox.com>
With this patch IPV6 code ensure that only sockets with the
expected sk->sk_prot are converted to IPV4.
Signed-off-by: Boris Pismenny <borisp@mellanox.com>
---
net/ipv6/ipv6_sockglue.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 02d795f..318cd344 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -174,6 +174,7 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
if (val == PF_INET) {
struct ipv6_txoptions *opt;
struct sk_buff *pktopt;
+ struct proto *expected_prot;
if (sk->sk_type == SOCK_RAW)
break;
@@ -199,6 +200,17 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
break;
}
+ if (sk->sk_protocol == IPPROTO_TCP &&
+ sk->sk_prot != &tcpv6_prot)
+ break;
+
+ expected_prot = &udpv6_prot;
+ if (sk->sk_protocol == IPPROTO_UDPLITE)
+ expected_prot = &udplitev6_prot;
+
+ if (sk->sk_prot != expected_prot)
+ break;
+
fl6_free_socklist(sk);
__ipv6_sock_mc_close(sk);
--
1.8.3.1
next prev parent reply other threads:[~2017-08-10 10:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-10 10:33 [PATCH 0/3] tls: Use correct sk->sk_prot for IPV6 Ilya Lesokhin
2017-08-10 10:33 ` Ilya Lesokhin [this message]
2017-08-10 10:33 ` [PATCH 2/3] net: Export tcpv6_prot Ilya Lesokhin
2017-08-11 21:34 ` David Miller
2017-08-10 10:33 ` [PATCH 3/3] tls: Use correct sk->sk_prot for IPV6 Ilya Lesokhin
2017-08-11 15:06 ` kbuild test robot
2017-08-11 21:36 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1502361196-127278-2-git-send-email-ilyal@mellanox.com \
--to=ilyal@mellanox.com \
--cc=aviadye@mellanox.com \
--cc=borisp@mellanox.com \
--cc=davejwatson@fb.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox