aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/tcp_ipv4.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 992a1f926009..dceff5fe8e66 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1167,7 +1167,8 @@ clear_hash_noput:
1167} 1167}
1168EXPORT_SYMBOL(tcp_v4_md5_hash_skb); 1168EXPORT_SYMBOL(tcp_v4_md5_hash_skb);
1169 1169
1170static bool tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb) 1170static bool __tcp_v4_inbound_md5_hash(struct sock *sk,
1171 const struct sk_buff *skb)
1171{ 1172{
1172 /* 1173 /*
1173 * This gets called for each TCP segment that arrives 1174 * This gets called for each TCP segment that arrives
@@ -1220,6 +1221,17 @@ static bool tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
1220 return false; 1221 return false;
1221} 1222}
1222 1223
1224static bool tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb)
1225{
1226 bool ret;
1227
1228 rcu_read_lock();
1229 ret = __tcp_v4_inbound_md5_hash(sk, skb);
1230 rcu_read_unlock();
1231
1232 return ret;
1233}
1234
1223#endif 1235#endif
1224 1236
1225static void tcp_v4_init_req(struct request_sock *req, struct sock *sk, 1237static void tcp_v4_init_req(struct request_sock *req, struct sock *sk,
@@ -1432,16 +1444,6 @@ static struct sock *tcp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
1432int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) 1444int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
1433{ 1445{
1434 struct sock *rsk; 1446 struct sock *rsk;
1435#ifdef CONFIG_TCP_MD5SIG
1436 /*
1437 * We really want to reject the packet as early as possible
1438 * if:
1439 * o We're expecting an MD5'd packet and this is no MD5 tcp option
1440 * o There is an MD5 option and we're not expecting one
1441 */
1442 if (tcp_v4_inbound_md5_hash(sk, skb))
1443 goto discard;
1444#endif
1445 1447
1446 if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */ 1448 if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */
1447 struct dst_entry *dst = sk->sk_rx_dst; 1449 struct dst_entry *dst = sk->sk_rx_dst;
@@ -1644,6 +1646,18 @@ process:
1644 1646
1645 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) 1647 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
1646 goto discard_and_relse; 1648 goto discard_and_relse;
1649
1650#ifdef CONFIG_TCP_MD5SIG
1651 /*
1652 * We really want to reject the packet as early as possible
1653 * if:
1654 * o We're expecting an MD5'd packet and this is no MD5 tcp option
1655 * o There is an MD5 option and we're not expecting one
1656 */
1657 if (tcp_v4_inbound_md5_hash(sk, skb))
1658 goto discard_and_relse;
1659#endif
1660
1647 nf_reset(skb); 1661 nf_reset(skb);
1648 1662
1649 if (sk_filter(sk, skb)) 1663 if (sk_filter(sk, skb))