net/tls: prevent bad memory access in tls_is_sk_tx_device_offloaded()
authorJakub Kicinski <jakub.kicinski@netronome.com>
Tue, 9 Apr 2019 00:59:50 +0000 (17:59 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 11 Apr 2019 05:42:28 +0000 (22:42 -0700)
Unlike '&&' operator, the '&' does not have short-circuit
evaluation semantics.  IOW both sides of the operator always
get evaluated.  Fix the wrong operator in
tls_is_sk_tx_device_offloaded(), which would lead to
out-of-bounds access for for non-full sockets.

Fixes: 4799ac81e52a ("tls: Add rx inline crypto offload")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/tls.h

index c7f7dc344e738c678adabb2e301391cffa7f52dc..5934246b2c6f4bafbe318fdddfacb328a2b9bf5c 100644 (file)
@@ -381,7 +381,7 @@ tls_validate_xmit_skb(struct sock *sk, struct net_device *dev,
 static inline bool tls_is_sk_tx_device_offloaded(struct sock *sk)
 {
 #ifdef CONFIG_SOCK_VALIDATE_XMIT
-       return sk_fullsock(sk) &
+       return sk_fullsock(sk) &&
               (smp_load_acquire(&sk->sk_validate_xmit_skb) ==
               &tls_validate_xmit_skb);
 #else