* [PATCH net-next v2 0/1] net: fastopen: follow-up tweaks for SipHash switch @ 2019-06-19 6:55 Ard Biesheuvel 2019-06-19 6:55 ` [PATCH net-next v2 1/1] net: fastopen: robustness and endianness fixes for SipHash Ard Biesheuvel 0 siblings, 1 reply; 6+ messages in thread From: Ard Biesheuvel @ 2019-06-19 6:55 UTC (permalink / raw) To: netdev Cc: Ard Biesheuvel, Eric Biggers, linux-crypto, herbert, edumazet, davem, kuznet, yoshfuji, jbaron, cpaasch, David.Laight, ycheng Some fixes for the fastopen code after switching to SipHash, which were spotted in review after the change had already been queued. cc: Eric Biggers <ebiggers@kernel.org> cc: linux-crypto@vger.kernel.org cc: herbert@gondor.apana.org.au cc: edumazet@google.com cc: davem@davemloft.net cc: kuznet@ms2.inr.ac.ru cc: yoshfuji@linux-ipv6.org cc: jbaron@akamai.com cc: cpaasch@apple.com cc: David.Laight@aculab.com cc: ycheng@google.com Ard Biesheuvel (1): net: fastopen: robustness and endianness fixes for SipHash include/linux/tcp.h | 2 +- include/net/tcp.h | 8 ++-- net/ipv4/sysctl_net_ipv4.c | 3 +- net/ipv4/tcp.c | 3 +- net/ipv4/tcp_fastopen.c | 39 +++++++++++--------- 5 files changed, 28 insertions(+), 27 deletions(-) -- 2.17.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next v2 1/1] net: fastopen: robustness and endianness fixes for SipHash 2019-06-19 6:55 [PATCH net-next v2 0/1] net: fastopen: follow-up tweaks for SipHash switch Ard Biesheuvel @ 2019-06-19 6:55 ` Ard Biesheuvel 2019-06-19 17:25 ` Eric Biggers ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Ard Biesheuvel @ 2019-06-19 6:55 UTC (permalink / raw) To: netdev Cc: Ard Biesheuvel, Eric Biggers, linux-crypto, herbert, edumazet, davem, kuznet, yoshfuji, jbaron, cpaasch, David.Laight, ycheng Some changes to the TCP fastopen code to make it more robust against future changes in the choice of key/cookie size, etc. - Instead of keeping the SipHash key in an untyped u8[] buffer and casting it to the right type upon use, use the correct type directly. This ensures that the key will appear at the correct alignment if we ever change the way these data structures are allocated. (Currently, they are only allocated via kmalloc so they always appear at the correct alignment) - Use DIV_ROUND_UP when sizing the u64[] array to hold the cookie, so it is always of sufficient size, even if TCP_FASTOPEN_COOKIE_MAX is no longer a multiple of 8. - Drop the 'len' parameter from the tcp_fastopen_reset_cipher() function, which is no longer used. - Add endian swabbing when setting the keys and calculating the hash, to ensure that cookie values are the same for a given key and source/destination address pair regardless of the endianness of the server. Note that none of these are functional changes wrt the current state of the code, with the exception of the swabbing, which only affects big endian systems. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- include/linux/tcp.h | 2 +- include/net/tcp.h | 8 ++-- net/ipv4/sysctl_net_ipv4.c | 3 +- net/ipv4/tcp.c | 3 +- net/ipv4/tcp_fastopen.c | 39 +++++++++++--------- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/include/linux/tcp.h b/include/linux/tcp.h index 2689b0b0b68a..f3a85a7fb4b1 100644 --- a/include/linux/tcp.h +++ b/include/linux/tcp.h @@ -58,7 +58,7 @@ static inline unsigned int tcp_optlen(const struct sk_buff *skb) /* TCP Fast Open Cookie as stored in memory */ struct tcp_fastopen_cookie { - u64 val[TCP_FASTOPEN_COOKIE_MAX / sizeof(u64)]; + __le64 val[DIV_ROUND_UP(TCP_FASTOPEN_COOKIE_MAX, sizeof(u64))]; s8 len; bool exp; /* In RFC6994 experimental option format */ }; diff --git a/include/net/tcp.h b/include/net/tcp.h index 573c9e9b0d72..9d36cc88d043 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -43,6 +43,7 @@ #include <linux/seq_file.h> #include <linux/memcontrol.h> #include <linux/bpf-cgroup.h> +#include <linux/siphash.h> extern struct inet_hashinfo tcp_hashinfo; @@ -1612,8 +1613,7 @@ void tcp_free_fastopen_req(struct tcp_sock *tp); void tcp_fastopen_destroy_cipher(struct sock *sk); void tcp_fastopen_ctx_destroy(struct net *net); int tcp_fastopen_reset_cipher(struct net *net, struct sock *sk, - void *primary_key, void *backup_key, - unsigned int len); + void *primary_key, void *backup_key); void tcp_fastopen_add_skb(struct sock *sk, struct sk_buff *skb); struct sock *tcp_try_fastopen(struct sock *sk, struct sk_buff *skb, struct request_sock *req, @@ -1623,14 +1623,14 @@ void tcp_fastopen_init_key_once(struct net *net); bool tcp_fastopen_cookie_check(struct sock *sk, u16 *mss, struct tcp_fastopen_cookie *cookie); bool tcp_fastopen_defer_connect(struct sock *sk, int *err); -#define TCP_FASTOPEN_KEY_LENGTH 16 +#define TCP_FASTOPEN_KEY_LENGTH sizeof(siphash_key_t) #define TCP_FASTOPEN_KEY_MAX 2 #define TCP_FASTOPEN_KEY_BUF_LENGTH \ (TCP_FASTOPEN_KEY_LENGTH * TCP_FASTOPEN_KEY_MAX) /* Fastopen key context */ struct tcp_fastopen_context { - __u8 key[TCP_FASTOPEN_KEY_MAX][TCP_FASTOPEN_KEY_LENGTH]; + siphash_key_t key[TCP_FASTOPEN_KEY_MAX]; int num; struct rcu_head rcu; }; diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 7d802acde040..7d66306b5f39 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -365,8 +365,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *table, int write, } } tcp_fastopen_reset_cipher(net, NULL, key, - backup_data ? key + 4 : NULL, - TCP_FASTOPEN_KEY_LENGTH); + backup_data ? key + 4 : NULL); } bad_key: diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index efd7f2b1d1f0..47c217905864 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2822,8 +2822,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, if (optlen == TCP_FASTOPEN_KEY_BUF_LENGTH) backup_key = key + TCP_FASTOPEN_KEY_LENGTH; - return tcp_fastopen_reset_cipher(net, sk, key, backup_key, - TCP_FASTOPEN_KEY_LENGTH); + return tcp_fastopen_reset_cipher(net, sk, key, backup_key); } default: /* fallthru */ diff --git a/net/ipv4/tcp_fastopen.c b/net/ipv4/tcp_fastopen.c index 46b67128e1ca..2f5e7b62ffe4 100644 --- a/net/ipv4/tcp_fastopen.c +++ b/net/ipv4/tcp_fastopen.c @@ -7,7 +7,6 @@ #include <linux/tcp.h> #include <linux/rcupdate.h> #include <linux/rculist.h> -#include <linux/siphash.h> #include <net/inetpeer.h> #include <net/tcp.h> @@ -31,7 +30,7 @@ void tcp_fastopen_init_key_once(struct net *net) * for a valid cookie, so this is an acceptable risk. */ get_random_bytes(key, sizeof(key)); - tcp_fastopen_reset_cipher(net, NULL, key, NULL, sizeof(key)); + tcp_fastopen_reset_cipher(net, NULL, key, NULL); } static void tcp_fastopen_ctx_free(struct rcu_head *head) @@ -68,8 +67,7 @@ void tcp_fastopen_ctx_destroy(struct net *net) } int tcp_fastopen_reset_cipher(struct net *net, struct sock *sk, - void *primary_key, void *backup_key, - unsigned int len) + void *primary_key, void *backup_key) { struct tcp_fastopen_context *ctx, *octx; struct fastopen_queue *q; @@ -81,9 +79,15 @@ int tcp_fastopen_reset_cipher(struct net *net, struct sock *sk, goto out; } - memcpy(ctx->key[0], primary_key, len); + ctx->key[0] = (siphash_key_t){ + get_unaligned_le64(primary_key), + get_unaligned_le64(primary_key + 8) + }; if (backup_key) { - memcpy(ctx->key[1], backup_key, len); + ctx->key[1] = (siphash_key_t){ + get_unaligned_le64(backup_key), + get_unaligned_le64(backup_key + 8) + }; ctx->num = 2; } else { ctx->num = 1; @@ -110,19 +114,18 @@ int tcp_fastopen_reset_cipher(struct net *net, struct sock *sk, static bool __tcp_fastopen_cookie_gen_cipher(struct request_sock *req, struct sk_buff *syn, - const u8 *key, + const siphash_key_t *key, struct tcp_fastopen_cookie *foc) { - BUILD_BUG_ON(TCP_FASTOPEN_KEY_LENGTH != sizeof(siphash_key_t)); BUILD_BUG_ON(TCP_FASTOPEN_COOKIE_SIZE != sizeof(u64)); if (req->rsk_ops->family == AF_INET) { const struct iphdr *iph = ip_hdr(syn); - foc->val[0] = siphash(&iph->saddr, - sizeof(iph->saddr) + - sizeof(iph->daddr), - (const siphash_key_t *)key); + foc->val[0] = cpu_to_le64(siphash(&iph->saddr, + sizeof(iph->saddr) + + sizeof(iph->daddr), + key)); foc->len = TCP_FASTOPEN_COOKIE_SIZE; return true; } @@ -130,10 +133,10 @@ static bool __tcp_fastopen_cookie_gen_cipher(struct request_sock *req, if (req->rsk_ops->family == AF_INET6) { const struct ipv6hdr *ip6h = ipv6_hdr(syn); - foc->val[0] = siphash(&ip6h->saddr, - sizeof(ip6h->saddr) + - sizeof(ip6h->daddr), - (const siphash_key_t *)key); + foc->val[0] = cpu_to_le64(siphash(&ip6h->saddr, + sizeof(ip6h->saddr) + + sizeof(ip6h->daddr), + key)); foc->len = TCP_FASTOPEN_COOKIE_SIZE; return true; } @@ -154,7 +157,7 @@ static void tcp_fastopen_cookie_gen(struct sock *sk, rcu_read_lock(); ctx = tcp_fastopen_get_ctx(sk); if (ctx) - __tcp_fastopen_cookie_gen_cipher(req, syn, ctx->key[0], foc); + __tcp_fastopen_cookie_gen_cipher(req, syn, &ctx->key[0], foc); rcu_read_unlock(); } @@ -218,7 +221,7 @@ static int tcp_fastopen_cookie_gen_check(struct sock *sk, if (!ctx) goto out; for (i = 0; i < tcp_fastopen_context_len(ctx); i++) { - __tcp_fastopen_cookie_gen_cipher(req, syn, ctx->key[i], foc); + __tcp_fastopen_cookie_gen_cipher(req, syn, &ctx->key[i], foc); if (tcp_fastopen_cookie_match(foc, orig)) { ret = i + 1; goto out; -- 2.17.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 1/1] net: fastopen: robustness and endianness fixes for SipHash 2019-06-19 6:55 ` [PATCH net-next v2 1/1] net: fastopen: robustness and endianness fixes for SipHash Ard Biesheuvel @ 2019-06-19 17:25 ` Eric Biggers 2019-06-19 21:42 ` David Miller 2019-06-20 23:03 ` kbuild test robot 2 siblings, 0 replies; 6+ messages in thread From: Eric Biggers @ 2019-06-19 17:25 UTC (permalink / raw) To: Ard Biesheuvel Cc: netdev, linux-crypto, herbert, edumazet, davem, kuznet, yoshfuji, jbaron, cpaasch, David.Laight, ycheng On Wed, Jun 19, 2019 at 08:55:10AM +0200, Ard Biesheuvel wrote: > int tcp_fastopen_reset_cipher(struct net *net, struct sock *sk, > - void *primary_key, void *backup_key, > - unsigned int len) > + void *primary_key, void *backup_key) > { > struct tcp_fastopen_context *ctx, *octx; > struct fastopen_queue *q; > @@ -81,9 +79,15 @@ int tcp_fastopen_reset_cipher(struct net *net, struct sock *sk, > goto out; > } > > - memcpy(ctx->key[0], primary_key, len); > + ctx->key[0] = (siphash_key_t){ > + get_unaligned_le64(primary_key), > + get_unaligned_le64(primary_key + 8) > + }; > if (backup_key) { > - memcpy(ctx->key[1], backup_key, len); > + ctx->key[1] = (siphash_key_t){ > + get_unaligned_le64(backup_key), > + get_unaligned_le64(backup_key + 8) > + }; > ctx->num = 2; > } else { > ctx->num = 1; These initializers are missing a level of braces. Otherwise this patch looks good to me. net/ipv4/tcp_fastopen.c: In function ‘tcp_fastopen_reset_cipher’: net/ipv4/tcp_fastopen.c:82:16: warning: missing braces around initializer [-Wmissing-braces] ctx->key[0] = (siphash_key_t){ ^ get_unaligned_le64(primary_key), { net/ipv4/tcp_fastopen.c:85:2: }; } net/ipv4/tcp_fastopen.c:87:17: warning: missing braces around initializer [-Wmissing-braces] ctx->key[1] = (siphash_key_t){ ^ get_unaligned_le64(backup_key), { net/ipv4/tcp_fastopen.c:90:3: }; } ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 1/1] net: fastopen: robustness and endianness fixes for SipHash 2019-06-19 6:55 ` [PATCH net-next v2 1/1] net: fastopen: robustness and endianness fixes for SipHash Ard Biesheuvel 2019-06-19 17:25 ` Eric Biggers @ 2019-06-19 21:42 ` David Miller 2019-06-19 21:47 ` Ard Biesheuvel 2019-06-20 23:03 ` kbuild test robot 2 siblings, 1 reply; 6+ messages in thread From: David Miller @ 2019-06-19 21:42 UTC (permalink / raw) To: ard.biesheuvel Cc: netdev, ebiggers, linux-crypto, herbert, edumazet, kuznet, yoshfuji, jbaron, cpaasch, David.Laight, ycheng From: Ard Biesheuvel <ard.biesheuvel@linaro.org> Date: Wed, 19 Jun 2019 08:55:10 +0200 > + ctx->key[0] = (siphash_key_t){ > + get_unaligned_le64(primary_key), > + get_unaligned_le64(primary_key + 8) > + }; Please just use normal assignment(s), because not only does this warn it looks not so nice. Thanks. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 1/1] net: fastopen: robustness and endianness fixes for SipHash 2019-06-19 21:42 ` David Miller @ 2019-06-19 21:47 ` Ard Biesheuvel 0 siblings, 0 replies; 6+ messages in thread From: Ard Biesheuvel @ 2019-06-19 21:47 UTC (permalink / raw) To: David Miller Cc: <netdev@vger.kernel.org>, Eric Biggers, open list:HARDWARE RANDOM NUMBER GENERATOR CORE, Herbert Xu, Eric Dumazet, Alexey Kuznetsov, Hideaki YOSHIFUJI, Jason Baron, Christoph Paasch, David Laight, Yuchung Cheng On Wed, 19 Jun 2019 at 23:42, David Miller <davem@davemloft.net> wrote: > > From: Ard Biesheuvel <ard.biesheuvel@linaro.org> > Date: Wed, 19 Jun 2019 08:55:10 +0200 > > > + ctx->key[0] = (siphash_key_t){ > > + get_unaligned_le64(primary_key), > > + get_unaligned_le64(primary_key + 8) > > + }; > > Please just use normal assignment(s), because not only does this warn > it looks not so nice. > OK Please disregard the v3 I just sent out, v4 has ordinary assignments. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v2 1/1] net: fastopen: robustness and endianness fixes for SipHash 2019-06-19 6:55 ` [PATCH net-next v2 1/1] net: fastopen: robustness and endianness fixes for SipHash Ard Biesheuvel 2019-06-19 17:25 ` Eric Biggers 2019-06-19 21:42 ` David Miller @ 2019-06-20 23:03 ` kbuild test robot 2 siblings, 0 replies; 6+ messages in thread From: kbuild test robot @ 2019-06-20 23:03 UTC (permalink / raw) To: Ard Biesheuvel Cc: kbuild-all, netdev, Ard Biesheuvel, Eric Biggers, linux-crypto, herbert, edumazet, davem, kuznet, yoshfuji, jbaron, cpaasch, David.Laight, ycheng [-- Attachment #1: Type: text/plain, Size: 8526 bytes --] Hi Ard, I love your patch! Perhaps something to improve: [auto build test WARNING on net-next/master] url: https://github.com/0day-ci/linux/commits/Ard-Biesheuvel/net-fastopen-follow-up-tweaks-for-SipHash-switch/20190621-060434 config: i386-randconfig-x009-201924 (attached as .config) compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=i386 If you fix the issue, kindly add following tag Reported-by: kbuild test robot <lkp@intel.com> All warnings (new ones prefixed by >>): net//ipv4/tcp_fastopen.c: In function 'tcp_fastopen_reset_cipher': >> net//ipv4/tcp_fastopen.c:82:16: warning: missing braces around initializer [-Wmissing-braces] ctx->key[0] = (siphash_key_t){ ^ get_unaligned_le64(primary_key), { net//ipv4/tcp_fastopen.c:85:2: }; } net//ipv4/tcp_fastopen.c:87:17: warning: missing braces around initializer [-Wmissing-braces] ctx->key[1] = (siphash_key_t){ ^ get_unaligned_le64(backup_key), { net//ipv4/tcp_fastopen.c:90:3: }; } Cyclomatic Complexity 5 include/linux/compiler.h:__read_once_size Cyclomatic Complexity 5 include/linux/compiler.h:__write_once_size Cyclomatic Complexity 1 include/linux/kasan-checks.h:kasan_check_read Cyclomatic Complexity 1 include/linux/kasan-checks.h:kasan_check_write Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:arch_atomic_read Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:arch_atomic_set Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:arch_atomic_add Cyclomatic Complexity 1 arch/x86/include/asm/atomic.h:arch_atomic_inc Cyclomatic Complexity 2 arch/x86/include/asm/atomic.h:arch_atomic_try_cmpxchg Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_read Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_set Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_add Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_inc Cyclomatic Complexity 1 include/asm-generic/atomic-instrumented.h:atomic_try_cmpxchg Cyclomatic Complexity 1 arch/x86/include/asm/bitops.h:fls Cyclomatic Complexity 1 include/uapi/linux/byteorder/little_endian.h:__le64_to_cpup Cyclomatic Complexity 1 include/uapi/linux/byteorder/little_endian.h:__le32_to_cpup Cyclomatic Complexity 1 include/linux/log2.h:__ilog2_u32 Cyclomatic Complexity 1 include/linux/percpu-defs.h:__this_cpu_preempt_check Cyclomatic Complexity 5 include/linux/string.h:memcmp Cyclomatic Complexity 1 include/asm-generic/getorder.h:__get_order Cyclomatic Complexity 6 arch/x86/include/asm/preempt.h:__preempt_count_add Cyclomatic Complexity 6 arch/x86/include/asm/preempt.h:__preempt_count_sub Cyclomatic Complexity 1 include/linux/spinlock.h:spin_lock Cyclomatic Complexity 1 include/linux/spinlock.h:spin_unlock Cyclomatic Complexity 1 include/linux/rcupdate.h:__rcu_read_lock Cyclomatic Complexity 1 include/linux/rcupdate.h:__rcu_read_unlock Cyclomatic Complexity 1 include/linux/rcutiny.h:rcu_is_watching Cyclomatic Complexity 67 include/linux/slab.h:kmalloc_large Cyclomatic Complexity 3 include/linux/slab.h:kmalloc Cyclomatic Complexity 1 include/linux/slab.h:kzalloc Cyclomatic Complexity 1 include/linux/refcount.h:refcount_set Cyclomatic Complexity 1 include/linux/refcount.h:refcount_read Cyclomatic Complexity 1 include/linux/skbuff.h:skb_end_pointer Cyclomatic Complexity 1 include/linux/skbuff.h:__skb_insert Cyclomatic Complexity 1 include/linux/skbuff.h:__skb_queue_before Cyclomatic Complexity 1 include/linux/skbuff.h:__skb_queue_tail Cyclomatic Complexity 1 include/linux/skbuff.h:skb_transport_header Cyclomatic Complexity 1 include/linux/skbuff.h:skb_network_header Cyclomatic Complexity 1 include/net/net_namespace.h:read_pnet Cyclomatic Complexity 1 include/linux/unaligned/access_ok.h:get_unaligned_le64 Cyclomatic Complexity 1 include/net/dst.h:dst_metric_raw Cyclomatic Complexity 1 include/net/sock.h:sk_has_account Cyclomatic Complexity 2 include/net/sock.h:sk_mem_charge Cyclomatic Complexity 1 include/net/sock.h:sock_net Cyclomatic Complexity 1 include/net/inet_sock.h:inet_sk Cyclomatic Complexity 1 include/net/inet_connection_sock.h:inet_csk Cyclomatic Complexity 1 include/linux/tcp.h:tcp_hdr Cyclomatic Complexity 1 include/linux/tcp.h:__tcp_hdrlen Cyclomatic Complexity 1 include/linux/tcp.h:tcp_hdrlen Cyclomatic Complexity 1 include/linux/tcp.h:tcp_rsk Cyclomatic Complexity 1 include/linux/tcp.h:tcp_sk Cyclomatic Complexity 1 include/linux/ipv6.h:ipv6_hdr Cyclomatic Complexity 1 include/linux/ip.h:ip_hdr Cyclomatic Complexity 4 include/net/tcp.h:tcp_fastopen_cookie_match Cyclomatic Complexity 1 include/net/tcp.h:tcp_fastopen_context_len Cyclomatic Complexity 3 include/net/tcp.h:tcp_segs_in Cyclomatic Complexity 8 include/net/tcp.h:tcp_fastopen_get_ctx Cyclomatic Complexity 1 include/linux/rcupdate.h:rcu_lock_acquire Cyclomatic Complexity 4 include/linux/rcupdate.h:rcu_read_lock Cyclomatic Complexity 1 include/linux/rcupdate.h:rcu_lock_release Cyclomatic Complexity 4 include/linux/rcupdate.h:rcu_read_unlock Cyclomatic Complexity 1 net//ipv4/tcp_fastopen.c:tcp_fastopen_ctx_free Cyclomatic Complexity 1 include/linux/lockdep.h:lock_is_held Cyclomatic Complexity 3 include/net/sock.h:lockdep_sock_is_held Cyclomatic Complexity 5 include/net/sock.h:__sk_dst_get Cyclomatic Complexity 2 include/net/dst.h:refdst_drop Cyclomatic Complexity 2 include/net/dst.h:skb_dst_drop Cyclomatic Complexity 5 include/net/dst.h:dst_metric Cyclomatic Complexity 5 net//ipv4/tcp_fastopen.c:tcp_fastopen_no_cookie Cyclomatic Complexity 3 include/linux/atomic-fallback.h:atomic_fetch_add_unless Cyclomatic Complexity 1 include/linux/atomic-fallback.h:atomic_add_unless Cyclomatic Complexity 1 include/linux/atomic-fallback.h:atomic_inc_not_zero Cyclomatic Complexity 6 include/net/sock.h:sk_dst_get Cyclomatic Complexity 1 include/linux/skbuff.h:__skb_pull Cyclomatic Complexity 2 include/linux/skbuff.h:skb_orphan Cyclomatic Complexity 1 include/net/sock.h:skb_set_owner_r Cyclomatic Complexity 2 include/net/sock.h:sock_put Cyclomatic Complexity 2 include/net/request_sock.h:__reqsk_free Cyclomatic Complexity 2 include/net/request_sock.h:reqsk_free Cyclomatic Complexity 2 include/net/request_sock.h:reqsk_put Cyclomatic Complexity 7 net//ipv4/tcp_fastopen.c:tcp_fastopen_queue_check Cyclomatic Complexity 11 include/linux/siphash.h:___siphash_aligned Cyclomatic Complexity 1 include/linux/siphash.h:siphash Cyclomatic Complexity 3 net//ipv4/tcp_fastopen.c:__tcp_fastopen_cookie_gen_cipher vim +82 net//ipv4/tcp_fastopen.c 68 69 int tcp_fastopen_reset_cipher(struct net *net, struct sock *sk, 70 void *primary_key, void *backup_key) 71 { 72 struct tcp_fastopen_context *ctx, *octx; 73 struct fastopen_queue *q; 74 int err = 0; 75 76 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); 77 if (!ctx) { 78 err = -ENOMEM; 79 goto out; 80 } 81 > 82 ctx->key[0] = (siphash_key_t){ 83 get_unaligned_le64(primary_key), 84 get_unaligned_le64(primary_key + 8) 85 }; 86 if (backup_key) { 87 ctx->key[1] = (siphash_key_t){ 88 get_unaligned_le64(backup_key), 89 get_unaligned_le64(backup_key + 8) 90 }; 91 ctx->num = 2; 92 } else { 93 ctx->num = 1; 94 } 95 96 spin_lock(&net->ipv4.tcp_fastopen_ctx_lock); 97 if (sk) { 98 q = &inet_csk(sk)->icsk_accept_queue.fastopenq; 99 octx = rcu_dereference_protected(q->ctx, 100 lockdep_is_held(&net->ipv4.tcp_fastopen_ctx_lock)); 101 rcu_assign_pointer(q->ctx, ctx); 102 } else { 103 octx = rcu_dereference_protected(net->ipv4.tcp_fastopen_ctx, 104 lockdep_is_held(&net->ipv4.tcp_fastopen_ctx_lock)); 105 rcu_assign_pointer(net->ipv4.tcp_fastopen_ctx, ctx); 106 } 107 spin_unlock(&net->ipv4.tcp_fastopen_ctx_lock); 108 109 if (octx) 110 call_rcu(&octx->rcu, tcp_fastopen_ctx_free); 111 out: 112 return err; 113 } 114 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation [-- Attachment #2: .config.gz --] [-- Type: application/gzip, Size: 29016 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-06-20 23:03 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-06-19 6:55 [PATCH net-next v2 0/1] net: fastopen: follow-up tweaks for SipHash switch Ard Biesheuvel 2019-06-19 6:55 ` [PATCH net-next v2 1/1] net: fastopen: robustness and endianness fixes for SipHash Ard Biesheuvel 2019-06-19 17:25 ` Eric Biggers 2019-06-19 21:42 ` David Miller 2019-06-19 21:47 ` Ard Biesheuvel 2019-06-20 23:03 ` kbuild test robot
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.