Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
authorJakub Kicinski <kuba@kernel.org>
Thu, 14 Jul 2022 21:19:42 +0000 (14:19 -0700)
committerJakub Kicinski <kuba@kernel.org>
Thu, 14 Jul 2022 22:27:35 +0000 (15:27 -0700)
include/net/sock.h
  310731e2f161 ("net: Fix data-races around sysctl_mem.")
  e70f3c701276 ("Revert "net: set SK_MEM_QUANTUM to 4096"")
https://lore.kernel.org/all/20220711120211.7c8b7cba@canb.auug.org.au/

net/ipv4/fib_semantics.c
  747c14307214 ("ip: fix dflt addr selection for connected nexthop")
  d62607c3fe45 ("net: rename reference+tracking helpers")

net/tls/tls.h
include/net/tls.h
  3d8c51b25a23 ("net/tls: Check for errors in tls_device_init")
  587903142308 ("tls: create an internal header")

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
47 files changed:
1  2 
Documentation/networking/ip-sysctl.rst
MAINTAINERS
arch/x86/net/bpf_jit_comp.c
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
drivers/net/ethernet/netronome/nfp/nfdk/dp.c
drivers/net/ethernet/sfc/ef10.c
drivers/net/wireless/ath/ath11k/wmi.c
drivers/net/wireless/mac80211_hwsim.c
drivers/net/wireless/realtek/rtw88/rtw8821c.c
drivers/net/xen-netback/rx.c
include/net/cfg80211.h
include/net/mac80211.h
include/net/raw.h
include/net/sock.h
include/uapi/linux/bpf.h
kernel/bpf/core.c
kernel/bpf/helpers.c
kernel/sysctl.c
net/core/dev.c
net/core/filter.c
net/ipv4/af_inet.c
net/ipv4/fib_semantics.c
net/ipv4/tcp.c
net/ipv4/tcp_input.c
net/ipv4/tcp_output.c
net/ipv6/route.c
net/mac80211/cfg.c
net/mac80211/iface.c
net/mac80211/rx.c
net/mac80211/tx.c
net/mac80211/util.c
net/mac80211/wme.c
net/mptcp/protocol.c
net/tls/tls.h
net/tls/tls_device.c
net/tls/tls_main.c
net/wireless/sme.c
tools/include/uapi/linux/bpf.h
tools/testing/selftests/net/.gitignore
tools/testing/selftests/net/forwarding/Makefile

diff --cc MAINTAINERS
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
index 0dd43c3df49b93698cb9a63f0624e839560cdc65,9fa54762e07752313a181fec44df21794cdfc982..f7ad1a7705e915b3829efb8951c50d5e194d75f9
@@@ -1541,10 -1521,22 +1541,10 @@@ void __sk_mem_reclaim(struct sock *sk, 
  #define SK_MEM_SEND   0
  #define SK_MEM_RECV   1
  
 -/* sysctl_mem values are in pages, we convert them in SK_MEM_QUANTUM units */
 +/* sysctl_mem values are in pages */
  static inline long sk_prot_mem_limits(const struct sock *sk, int index)
  {
-       return sk->sk_prot->sysctl_mem[index];
 -      long val = READ_ONCE(sk->sk_prot->sysctl_mem[index]);
 -
 -#if PAGE_SIZE > SK_MEM_QUANTUM
 -      val <<= PAGE_SHIFT - SK_MEM_QUANTUM_SHIFT;
 -#elif PAGE_SIZE < SK_MEM_QUANTUM
 -      val >>= SK_MEM_QUANTUM_SHIFT - PAGE_SHIFT;
 -#endif
 -      return val;
++      return READ_ONCE(sk->sk_prot->sysctl_mem[index]);
  }
  
  static inline int sk_mem_pages(int amt)
Simple merge
Simple merge
Simple merge
diff --cc kernel/sysctl.c
Simple merge
diff --cc net/core/dev.c
Simple merge
Simple merge
Simple merge
index a5439a8414d4da88611ea679894acecc3fd802eb,d9fdcbae16ee388249f35b51747b222e091af667..14f037e8ac55de490216165e9768dd3171950bcd
@@@ -1230,8 -1229,8 +1230,8 @@@ static int fib_check_nh_nongw(struct ne
        }
  
        nh->fib_nh_dev = in_dev->dev;
 -      dev_hold_track(nh->fib_nh_dev, &nh->fib_nh_dev_tracker, GFP_ATOMIC);
 +      netdev_hold(nh->fib_nh_dev, &nh->fib_nh_dev_tracker, GFP_ATOMIC);
-       nh->fib_nh_scope = RT_SCOPE_HOST;
+       nh->fib_nh_scope = RT_SCOPE_LINK;
        if (!netif_carrier_ok(nh->fib_nh_dev))
                nh->fib_nh_flags |= RTNH_F_LINKDOWN;
        err = 0;
diff --cc net/ipv4/tcp.c
Simple merge
Simple merge
Simple merge
Simple merge
index fd6c4291c9715c1f7c50b4a22ddbcf812004d6c4,4ddf297f40f2e6520a8445d828e0c9888656d0d0..64801ab545c1627982ff50f38187b89bd455d701
@@@ -4467,10 -4472,10 +4467,10 @@@ ieeee80211_obss_color_collision_notify(
  {
        struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
  
 -      if (sdata->vif.color_change_active || sdata->vif.csa_active)
 +      if (sdata->vif.bss_conf.color_change_active || sdata->vif.bss_conf.csa_active)
                return;
  
-       cfg80211_obss_color_collision_notify(sdata->dev, color_bitmap);
+       cfg80211_obss_color_collision_notify(sdata->dev, color_bitmap, gfp);
  }
  EXPORT_SYMBOL_GPL(ieeee80211_obss_color_collision_notify);
  
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc net/tls/tls.h
index 8005ee25157d37dd0bed2612bb64d0b97e68d00f,0000000000000000000000000000000000000000..e0ccc96a0850dbdc38b12f0e16edda6238d22ecc
mode 100644,000000..100644
--- /dev/null
@@@ -1,290 -1,0 +1,290 @@@
- void tls_device_init(void);
 +/*
 + * Copyright (c) 2016-2017, Mellanox Technologies. All rights reserved.
 + * Copyright (c) 2016-2017, Dave Watson <davejwatson@fb.com>. All rights reserved.
 + *
 + * This software is available to you under a choice of one of two
 + * licenses.  You may choose to be licensed under the terms of the GNU
 + * General Public License (GPL) Version 2, available from the file
 + * COPYING in the main directory of this source tree, or the
 + * OpenIB.org BSD license below:
 + *
 + *     Redistribution and use in source and binary forms, with or
 + *     without modification, are permitted provided that the following
 + *     conditions are met:
 + *
 + *      - Redistributions of source code must retain the above
 + *        copyright notice, this list of conditions and the following
 + *        disclaimer.
 + *
 + *      - Redistributions in binary form must reproduce the above
 + *        copyright notice, this list of conditions and the following
 + *        disclaimer in the documentation and/or other materials
 + *        provided with the distribution.
 + *
 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 + * SOFTWARE.
 + */
 +
 +#ifndef _TLS_INT_H
 +#define _TLS_INT_H
 +
 +#include <asm/byteorder.h>
 +#include <linux/types.h>
 +#include <linux/skmsg.h>
 +#include <net/tls.h>
 +
 +#define __TLS_INC_STATS(net, field)                           \
 +      __SNMP_INC_STATS((net)->mib.tls_statistics, field)
 +#define TLS_INC_STATS(net, field)                             \
 +      SNMP_INC_STATS((net)->mib.tls_statistics, field)
 +#define TLS_DEC_STATS(net, field)                             \
 +      SNMP_DEC_STATS((net)->mib.tls_statistics, field)
 +
 +/* TLS records are maintained in 'struct tls_rec'. It stores the memory pages
 + * allocated or mapped for each TLS record. After encryption, the records are
 + * stores in a linked list.
 + */
 +struct tls_rec {
 +      struct list_head list;
 +      int tx_ready;
 +      int tx_flags;
 +
 +      struct sk_msg msg_plaintext;
 +      struct sk_msg msg_encrypted;
 +
 +      /* AAD | msg_plaintext.sg.data | sg_tag */
 +      struct scatterlist sg_aead_in[2];
 +      /* AAD | msg_encrypted.sg.data (data contains overhead for hdr & iv & tag) */
 +      struct scatterlist sg_aead_out[2];
 +
 +      char content_type;
 +      struct scatterlist sg_content_type;
 +
 +      char aad_space[TLS_AAD_SPACE_SIZE];
 +      u8 iv_data[MAX_IV_SIZE];
 +      struct aead_request aead_req;
 +      u8 aead_req_ctx[];
 +};
 +
 +int __net_init tls_proc_init(struct net *net);
 +void __net_exit tls_proc_fini(struct net *net);
 +
 +struct tls_context *tls_ctx_create(struct sock *sk);
 +void tls_ctx_free(struct sock *sk, struct tls_context *ctx);
 +void update_sk_prot(struct sock *sk, struct tls_context *ctx);
 +
 +int wait_on_pending_writer(struct sock *sk, long *timeo);
 +int tls_sk_query(struct sock *sk, int optname, char __user *optval,
 +               int __user *optlen);
 +int tls_sk_attach(struct sock *sk, int optname, char __user *optval,
 +                unsigned int optlen);
 +void tls_err_abort(struct sock *sk, int err);
 +
 +int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx);
 +void tls_update_rx_zc_capable(struct tls_context *tls_ctx);
 +void tls_sw_strparser_arm(struct sock *sk, struct tls_context *ctx);
 +void tls_sw_strparser_done(struct tls_context *tls_ctx);
 +int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size);
 +int tls_sw_sendpage_locked(struct sock *sk, struct page *page,
 +                         int offset, size_t size, int flags);
 +int tls_sw_sendpage(struct sock *sk, struct page *page,
 +                  int offset, size_t size, int flags);
 +void tls_sw_cancel_work_tx(struct tls_context *tls_ctx);
 +void tls_sw_release_resources_tx(struct sock *sk);
 +void tls_sw_free_ctx_tx(struct tls_context *tls_ctx);
 +void tls_sw_free_resources_rx(struct sock *sk);
 +void tls_sw_release_resources_rx(struct sock *sk);
 +void tls_sw_free_ctx_rx(struct tls_context *tls_ctx);
 +int tls_sw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
 +                 int flags, int *addr_len);
 +bool tls_sw_sock_is_readable(struct sock *sk);
 +ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
 +                         struct pipe_inode_info *pipe,
 +                         size_t len, unsigned int flags);
 +
 +int tls_device_sendmsg(struct sock *sk, struct msghdr *msg, size_t size);
 +int tls_device_sendpage(struct sock *sk, struct page *page,
 +                      int offset, size_t size, int flags);
 +int tls_tx_records(struct sock *sk, int flags);
 +
 +void tls_sw_write_space(struct sock *sk, struct tls_context *ctx);
 +void tls_device_write_space(struct sock *sk, struct tls_context *ctx);
 +
 +int tls_process_cmsg(struct sock *sk, struct msghdr *msg,
 +                   unsigned char *record_type);
 +int decrypt_skb(struct sock *sk, struct sk_buff *skb,
 +              struct scatterlist *sgout);
 +
 +int tls_sw_fallback_init(struct sock *sk,
 +                       struct tls_offload_context_tx *offload_ctx,
 +                       struct tls_crypto_info *crypto_info);
 +
 +static inline struct tls_msg *tls_msg(struct sk_buff *skb)
 +{
 +      struct sk_skb_cb *scb = (struct sk_skb_cb *)skb->cb;
 +
 +      return &scb->tls;
 +}
 +
 +#ifdef CONFIG_TLS_DEVICE
- static inline void tls_device_init(void) {}
++int tls_device_init(void);
 +void tls_device_cleanup(void);
 +int tls_set_device_offload(struct sock *sk, struct tls_context *ctx);
 +void tls_device_free_resources_tx(struct sock *sk);
 +int tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx);
 +void tls_device_offload_cleanup_rx(struct sock *sk);
 +void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq);
 +int tls_device_decrypted(struct sock *sk, struct tls_context *tls_ctx,
 +                       struct sk_buff *skb, struct strp_msg *rxm);
 +#else
++static inline int tls_device_init(void) { return 0; }
 +static inline void tls_device_cleanup(void) {}
 +
 +static inline int
 +tls_set_device_offload(struct sock *sk, struct tls_context *ctx)
 +{
 +      return -EOPNOTSUPP;
 +}
 +
 +static inline void tls_device_free_resources_tx(struct sock *sk) {}
 +
 +static inline int
 +tls_set_device_offload_rx(struct sock *sk, struct tls_context *ctx)
 +{
 +      return -EOPNOTSUPP;
 +}
 +
 +static inline void tls_device_offload_cleanup_rx(struct sock *sk) {}
 +static inline void
 +tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq) {}
 +
 +static inline int
 +tls_device_decrypted(struct sock *sk, struct tls_context *tls_ctx,
 +                   struct sk_buff *skb, struct strp_msg *rxm)
 +{
 +      return 0;
 +}
 +#endif
 +
 +int tls_push_sg(struct sock *sk, struct tls_context *ctx,
 +              struct scatterlist *sg, u16 first_offset,
 +              int flags);
 +int tls_push_partial_record(struct sock *sk, struct tls_context *ctx,
 +                          int flags);
 +void tls_free_partial_record(struct sock *sk, struct tls_context *ctx);
 +
 +static inline bool tls_is_partially_sent_record(struct tls_context *ctx)
 +{
 +      return !!ctx->partially_sent_record;
 +}
 +
 +static inline bool tls_is_pending_open_record(struct tls_context *tls_ctx)
 +{
 +      return tls_ctx->pending_open_record_frags;
 +}
 +
 +static inline bool tls_bigint_increment(unsigned char *seq, int len)
 +{
 +      int i;
 +
 +      for (i = len - 1; i >= 0; i--) {
 +              ++seq[i];
 +              if (seq[i] != 0)
 +                      break;
 +      }
 +
 +      return (i == -1);
 +}
 +
 +static inline void tls_bigint_subtract(unsigned char *seq, int  n)
 +{
 +      u64 rcd_sn;
 +      __be64 *p;
 +
 +      BUILD_BUG_ON(TLS_MAX_REC_SEQ_SIZE != 8);
 +
 +      p = (__be64 *)seq;
 +      rcd_sn = be64_to_cpu(*p);
 +      *p = cpu_to_be64(rcd_sn - n);
 +}
 +
 +static inline void
 +tls_advance_record_sn(struct sock *sk, struct tls_prot_info *prot,
 +                    struct cipher_context *ctx)
 +{
 +      if (tls_bigint_increment(ctx->rec_seq, prot->rec_seq_size))
 +              tls_err_abort(sk, -EBADMSG);
 +
 +      if (prot->version != TLS_1_3_VERSION &&
 +          prot->cipher_type != TLS_CIPHER_CHACHA20_POLY1305)
 +              tls_bigint_increment(ctx->iv + prot->salt_size,
 +                                   prot->iv_size);
 +}
 +
 +static inline void
 +tls_xor_iv_with_seq(struct tls_prot_info *prot, char *iv, char *seq)
 +{
 +      int i;
 +
 +      if (prot->version == TLS_1_3_VERSION ||
 +          prot->cipher_type == TLS_CIPHER_CHACHA20_POLY1305) {
 +              for (i = 0; i < 8; i++)
 +                      iv[i + 4] ^= seq[i];
 +      }
 +}
 +
 +static inline void
 +tls_fill_prepend(struct tls_context *ctx, char *buf, size_t plaintext_len,
 +               unsigned char record_type)
 +{
 +      struct tls_prot_info *prot = &ctx->prot_info;
 +      size_t pkt_len, iv_size = prot->iv_size;
 +
 +      pkt_len = plaintext_len + prot->tag_size;
 +      if (prot->version != TLS_1_3_VERSION &&
 +          prot->cipher_type != TLS_CIPHER_CHACHA20_POLY1305) {
 +              pkt_len += iv_size;
 +
 +              memcpy(buf + TLS_NONCE_OFFSET,
 +                     ctx->tx.iv + prot->salt_size, iv_size);
 +      }
 +
 +      /* we cover nonce explicit here as well, so buf should be of
 +       * size KTLS_DTLS_HEADER_SIZE + KTLS_DTLS_NONCE_EXPLICIT_SIZE
 +       */
 +      buf[0] = prot->version == TLS_1_3_VERSION ?
 +                 TLS_RECORD_TYPE_DATA : record_type;
 +      /* Note that VERSION must be TLS_1_2 for both TLS1.2 and TLS1.3 */
 +      buf[1] = TLS_1_2_VERSION_MINOR;
 +      buf[2] = TLS_1_2_VERSION_MAJOR;
 +      /* we can use IV for nonce explicit according to spec */
 +      buf[3] = pkt_len >> 8;
 +      buf[4] = pkt_len & 0xFF;
 +}
 +
 +static inline
 +void tls_make_aad(char *buf, size_t size, char *record_sequence,
 +                unsigned char record_type, struct tls_prot_info *prot)
 +{
 +      if (prot->version != TLS_1_3_VERSION) {
 +              memcpy(buf, record_sequence, prot->rec_seq_size);
 +              buf += 8;
 +      } else {
 +              size += prot->tag_size;
 +      }
 +
 +      buf[0] = prot->version == TLS_1_3_VERSION ?
 +                TLS_RECORD_TYPE_DATA : record_type;
 +      buf[1] = TLS_1_2_VERSION_MAJOR;
 +      buf[2] = TLS_1_2_VERSION_MINOR;
 +      buf[3] = size >> 8;
 +      buf[4] = size & 0xFF;
 +}
 +
 +#endif
Simple merge
Simple merge
index 00be498aab2e5f8c54c7eb42ecf6ccc5e6405f9e,607a689110471e7ff7ecf2c9dce33bbc2963ed8f..22996d63c15fa3e88b685693306a990ffb671610
@@@ -1236,11 -1031,12 +1236,12 @@@ void __cfg80211_port_authorized(struct 
  {
        ASSERT_WDEV_LOCK(wdev);
  
-       if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION))
+       if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION &&
+                   wdev->iftype != NL80211_IFTYPE_P2P_CLIENT))
                return;
  
 -      if (WARN_ON(!wdev->current_bss) ||
 -          WARN_ON(!ether_addr_equal(wdev->current_bss->pub.bssid, bssid)))
 +      if (WARN_ON(!wdev->connected) ||
 +          WARN_ON(!ether_addr_equal(wdev->u.client.connected_addr, bssid)))
                return;
  
        nl80211_send_port_authorized(wiphy_to_rdev(wdev->wiphy), wdev->netdev,
Simple merge
index 1257baa79286e9db9fb392d4782a68fe3aff8867,ffc35a22e9143eeaca6b7234464f31ec9e0e75b5..892306bdb47dbf294f67b3db050b171857ee8bf7
@@@ -36,5 -36,5 +36,6 @@@ test_unix_oo
  gro
  ioam6_parser
  toeplitz
+ tun
  cmsg_sender
 +unix_connect