Pull networking fixes from Jakub Kicinski: "Including fixes from bpf, can and netfilter. Current release - regressions: - bpf: do not reject when the stack read size is different from the tracked scalar size - net: fix premature exit from NAPI state polling in napi_disable() - riscv, bpf: fix RV32 broken build, and silence RV64 warning Current release - new code bugs: - net: fix possible NULL deref in sock_reserve_memory - amt: fix error return code in amt_init(); fix stopping the workqueue - ax88796c: use the correct ioctl callback Previous releases - always broken: - bpf: stop caching subprog index in the bpf_pseudo_func insn - security: fixups for the security hooks in sctp - nfc: add necessary privilege flags in netlink layer, limit operations to admin only - vsock: prevent unnecessary refcnt inc for non-blocking connect - net/smc: fix sk_refcnt underflow on link down and fallback - nfnetlink_queue: fix OOB when mac header was cleared - can: j1939: ignore invalid messages per standard - bpf, sockmap: - fix race in ingress receive verdict with redirect to self - fix incorrect sk_skb data_end access when src_reg = dst_reg - strparser, and tls are reusing qdisc_skb_cb and colliding - ethtool: fix ethtool msg len calculation for pause stats - vlan: fix a UAF in vlan_dev_real_dev() when ref-holder tries to access an unregistering real_dev - udp6: make encap_rcv() bump the v6 not v4 stats - drv: prestera: add explicit padding to fix m68k build - drv: felix: fix broken VLAN-tagged PTP under VLAN-aware bridge - drv: mvpp2: fix wrong SerDes reconfiguration order Misc & small latecomers: - ipvs: auto-load ipvs on genl access - mctp: sanity check the struct sockaddr_mctp padding fields - libfs: support RENAME_EXCHANGE in simple_rename() - avoid double accounting for pure zerocopy skbs" * tag 'net-5.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (123 commits) selftests/net: udpgso_bench_rx: fix port argument net: wwan: iosm: fix compilation warning cxgb4: fix eeprom len when diagnostics not implemented net: fix premature exit from NAPI state polling in napi_disable() net/smc: fix sk_refcnt underflow on linkdown and fallback net/mlx5: Lag, fix a potential Oops with mlx5_lag_create_definer() gve: fix unmatched u64_stats_update_end() net: ethernet: lantiq_etop: Fix compilation error selftests: forwarding: Fix packet matching in mirroring selftests vsock: prevent unnecessary refcnt inc for nonblocking connect net: marvell: mvpp2: Fix wrong SerDes reconfiguration order net: ethernet: ti: cpsw_ale: Fix access to un-initialized memory net: stmmac: allow a tc-taprio base-time of zero selftests: net: test_vxlan_under_vrf: fix HV connectivity test net: hns3: allow configure ETS bandwidth of all TCs net: hns3: remove check VF uc mac exist when set by PF net: hns3: fix some mac statistics is always 0 in device version V2 net: hns3: fix kernel crash when unload VF while it is being reset net: hns3: sync rx ring head in echo common pull net: hns3: fix pfc packet number incorrect after querying pfc parameters ...
Showing the changes to include (14 of 134 files). Show all
Unified · Split
| @@ -484,6 +484,12 @@ bpf_ctx_record_field_size(struct bpf_insn_access_aux *aux, u32 size) · 483 unmodified lines | ||
| 484 | 484 | aux->ctx_field_size = size; |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | +static inline bool bpf_pseudo_func(const struct bpf_insn *insn) | |
| 488 | +{ | |
| 489 | + return insn->code == (BPF_LD | BPF_IMM | BPF_DW) && | |
| 490 | + insn->src_reg == BPF_PSEUDO_FUNC; | |
| 491 | +} | |
| 492 | + | |
| 487 | 493 | struct bpf_prog_ops { |
| 488 | 494 | int (*test_run)(struct bpf_prog *prog, const union bpf_attr *kattr, |
| 489 | 495 | union bpf_attr __user *uattr); |
| @@ -12,6 +12,7 @@ · 11 unmodified lines | ||
| 12 | 12 | struct ocelot_skb_cb { |
| 13 | 13 | struct sk_buff *clone; |
| 14 | 14 | unsigned int ptp_class; /* valid only for clones */ |
| 15 | + u32 tstamp_lo; | |
| 15 | 16 | u8 ptp_cmd; |
| 16 | 17 | u8 ts_id; |
| 17 | 18 | }; |
| @@ -10,6 +10,9 @@ · 9 unmodified lines | ||
| 10 | 10 | #define __ETHTOOL_LINK_MODE_MASK_NWORDS \ |
| 11 | 11 | DIV_ROUND_UP(__ETHTOOL_LINK_MODE_MASK_NBITS, 32) |
| 12 | 12 | |
| 13 | +#define ETHTOOL_PAUSE_STAT_CNT (__ETHTOOL_A_PAUSE_STAT_CNT - \ | |
| 14 | + ETHTOOL_A_PAUSE_STAT_TX_FRAMES) | |
| 15 | + | |
| 13 | 16 | enum ethtool_multicast_groups { |
| 14 | 17 | ETHNL_MCGRP_MONITOR, |
| 15 | 18 | }; |
| @@ -3385,6 +3385,8 @@ extern int simple_open(struct inode *inode, struct file *file); · 3384 unmodified lines | ||
| 3385 | 3385 | extern int simple_link(struct dentry *, struct inode *, struct dentry *); |
| 3386 | 3386 | extern int simple_unlink(struct inode *, struct dentry *); |
| 3387 | 3387 | extern int simple_rmdir(struct inode *, struct dentry *); |
| 3388 | +extern int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry, | |
| 3389 | + struct inode *new_dir, struct dentry *new_dentry); | |
| 3388 | 3390 | extern int simple_rename(struct user_namespace *, struct inode *, |
| 3389 | 3391 | struct dentry *, struct inode *, struct dentry *, |
| 3390 | 3392 | unsigned int); |
| @@ -329,12 +329,14 @@ LSM_HOOK(int, 0, tun_dev_create, void) · 328 unmodified lines | ||
| 329 | 329 | LSM_HOOK(int, 0, tun_dev_attach_queue, void *security) |
| 330 | 330 | LSM_HOOK(int, 0, tun_dev_attach, struct sock *sk, void *security) |
| 331 | 331 | LSM_HOOK(int, 0, tun_dev_open, void *security) |
| 332 | −LSM_HOOK(int, 0, sctp_assoc_request, struct sctp_endpoint *ep, | |
| 332 | +LSM_HOOK(int, 0, sctp_assoc_request, struct sctp_association *asoc, | |
| 333 | 333 | struct sk_buff *skb) |
| 334 | 334 | LSM_HOOK(int, 0, sctp_bind_connect, struct sock *sk, int optname, |
| 335 | 335 | struct sockaddr *address, int addrlen) |
| 336 | −LSM_HOOK(void, LSM_RET_VOID, sctp_sk_clone, struct sctp_endpoint *ep, | |
| 336 | +LSM_HOOK(void, LSM_RET_VOID, sctp_sk_clone, struct sctp_association *asoc, | |
| 337 | 337 | struct sock *sk, struct sock *newsk) |
| 338 | +LSM_HOOK(void, LSM_RET_VOID, sctp_assoc_established, struct sctp_association *asoc, | |
| 339 | + struct sk_buff *skb) | |
| 338 | 340 | #endif /* CONFIG_SECURITY_NETWORK */ |
| 339 | 341 | |
| 340 | 342 | #ifdef CONFIG_SECURITY_INFINIBAND |
| @@ -1027,9 +1027,9 @@ · 1026 unmodified lines | ||
| 1027 | 1027 | * Security hooks for SCTP |
| 1028 | 1028 | * |
| 1029 | 1029 | * @sctp_assoc_request: |
| 1030 | − * Passes the @ep and @chunk->skb of the association INIT packet to | |
| 1030 | + * Passes the @asoc and @chunk->skb of the association INIT packet to | |
| 1031 | 1031 | * the security module. |
| 1032 | − * @ep pointer to sctp endpoint structure. | |
| 1032 | + * @asoc pointer to sctp association structure. | |
| 1033 | 1033 | * @skb pointer to skbuff of association packet. |
| 1034 | 1034 | * Return 0 on success, error on failure. |
| 1035 | 1035 | * @sctp_bind_connect: |
| @@ -1047,9 +1047,14 @@ · 11 unmodified lines | ||
| 1047 | 1047 | * Called whenever a new socket is created by accept(2) (i.e. a TCP |
| 1048 | 1048 | * style socket) or when a socket is 'peeled off' e.g userspace |
| 1049 | 1049 | * calls sctp_peeloff(3). |
| 1050 | − * @ep pointer to current sctp endpoint structure. | |
| 1050 | + * @asoc pointer to current sctp association structure. | |
| 1051 | 1051 | * @sk pointer to current sock structure. |
| 1052 | − * @sk pointer to new sock structure. | |
| 1052 | + * @newsk pointer to new sock structure. | |
| 1053 | + * @sctp_assoc_established: | |
| 1054 | + * Passes the @asoc and @chunk->skb of the association COOKIE_ACK packet | |
| 1055 | + * to the security module. | |
| 1056 | + * @asoc pointer to sctp association structure. | |
| 1057 | + * @skb pointer to skbuff of association packet. | |
| 1053 | 1058 | * |
| 1054 | 1059 | * Security hooks for Infiniband |
| 1055 | 1060 | * |
| @@ -179,7 +179,7 @@ struct xfrm_policy; · 178 unmodified lines | ||
| 179 | 179 | struct xfrm_state; |
| 180 | 180 | struct xfrm_user_sec_ctx; |
| 181 | 181 | struct seq_file; |
| 182 | −struct sctp_endpoint; | |
| 182 | +struct sctp_association; | |
| 183 | 183 | |
| 184 | 184 | #ifdef CONFIG_MMU |
| 185 | 185 | extern unsigned long mmap_min_addr; |
| @@ -1425,11 +1425,13 @@ int security_tun_dev_create(void); · 1239 unmodified lines | ||
| 1425 | 1425 | int security_tun_dev_attach_queue(void *security); |
| 1426 | 1426 | int security_tun_dev_attach(struct sock *sk, void *security); |
| 1427 | 1427 | int security_tun_dev_open(void *security); |
| 1428 | −int security_sctp_assoc_request(struct sctp_endpoint *ep, struct sk_buff *skb); | |
| 1428 | +int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb); | |
| 1429 | 1429 | int security_sctp_bind_connect(struct sock *sk, int optname, |
| 1430 | 1430 | struct sockaddr *address, int addrlen); |
| 1431 | −void security_sctp_sk_clone(struct sctp_endpoint *ep, struct sock *sk, | |
| 1431 | +void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk, | |
| 1432 | 1432 | struct sock *newsk); |
| 1433 | +void security_sctp_assoc_established(struct sctp_association *asoc, | |
| 1434 | + struct sk_buff *skb); | |
| 1433 | 1435 | |
| 1434 | 1436 | #else /* CONFIG_SECURITY_NETWORK */ |
| 1435 | 1437 | static inline int security_unix_stream_connect(struct sock *sock, |
| @@ -1631,7 +1633,7 @@ static inline int security_tun_dev_open(void *security) · 195 unmodified lines | ||
| 1631 | 1633 | return 0; |
| 1632 | 1634 | } |
| 1633 | 1635 | |
| 1634 | −static inline int security_sctp_assoc_request(struct sctp_endpoint *ep, | |
| 1636 | +static inline int security_sctp_assoc_request(struct sctp_association *asoc, | |
| 1635 | 1637 | struct sk_buff *skb) |
| 1636 | 1638 | { |
| 1637 | 1639 | return 0; |
| @@ -1644,11 +1646,16 @@ static inline int security_sctp_bind_connect(struct sock *sk, int optname, · 6 unmodified lines | ||
| 1644 | 1646 | return 0; |
| 1645 | 1647 | } |
| 1646 | 1648 | |
| 1647 | −static inline void security_sctp_sk_clone(struct sctp_endpoint *ep, | |
| 1649 | +static inline void security_sctp_sk_clone(struct sctp_association *asoc, | |
| 1648 | 1650 | struct sock *sk, |
| 1649 | 1651 | struct sock *newsk) |
| 1650 | 1652 | { |
| 1651 | 1653 | } |
| 1654 | + | |
| 1655 | +static inline void security_sctp_assoc_established(struct sctp_association *asoc, | |
| 1656 | + struct sk_buff *skb) | |
| 1657 | +{ | |
| 1658 | +} | |
| 1652 | 1659 | #endif /* CONFIG_SECURITY_NETWORK */ |
| 1653 | 1660 | |
| 1654 | 1661 | #ifdef CONFIG_SECURITY_INFINIBAND |
| @@ -454,9 +454,15 @@ enum { · 453 unmodified lines | ||
| 454 | 454 | * all frags to avoid possible bad checksum |
| 455 | 455 | */ |
| 456 | 456 | SKBFL_SHARED_FRAG = BIT(1), |
| 457 | + | |
| 458 | + /* segment contains only zerocopy data and should not be | |
| 459 | + * charged to the kernel memory. | |
| 460 | + */ | |
| 461 | + SKBFL_PURE_ZEROCOPY = BIT(2), | |
| 457 | 462 | }; |
| 458 | 463 | |
| 459 | 464 | #define SKBFL_ZEROCOPY_FRAG (SKBFL_ZEROCOPY_ENABLE | SKBFL_SHARED_FRAG) |
| 465 | +#define SKBFL_ALL_ZEROCOPY (SKBFL_ZEROCOPY_FRAG | SKBFL_PURE_ZEROCOPY) | |
| 460 | 466 | |
| 461 | 467 | /* |
| 462 | 468 | * The callback notifies userspace to release buffers when skb DMA is done in |
| @@ -1464,6 +1470,17 @@ static inline struct ubuf_info *skb_zcopy(struct sk_buff *skb) · 1001 unmodified lines | ||
| 1464 | 1470 | return is_zcopy ? skb_uarg(skb) : NULL; |
| 1465 | 1471 | } |
| 1466 | 1472 | |
| 1473 | +static inline bool skb_zcopy_pure(const struct sk_buff *skb) | |
| 1474 | +{ | |
| 1475 | + return skb_shinfo(skb)->flags & SKBFL_PURE_ZEROCOPY; | |
| 1476 | +} | |
| 1477 | + | |
| 1478 | +static inline bool skb_pure_zcopy_same(const struct sk_buff *skb1, | |
| 1479 | + const struct sk_buff *skb2) | |
| 1480 | +{ | |
| 1481 | + return skb_zcopy_pure(skb1) == skb_zcopy_pure(skb2); | |
| 1482 | +} | |
| 1483 | + | |
| 1467 | 1484 | static inline void net_zcopy_get(struct ubuf_info *uarg) |
| 1468 | 1485 | { |
| 1469 | 1486 | refcount_inc(&uarg->refcnt); |
| @@ -1528,7 +1545,7 @@ static inline void skb_zcopy_clear(struct sk_buff *skb, bool zerocopy_success) · 58 unmodified lines | ||
| 1528 | 1545 | if (!skb_zcopy_is_nouarg(skb)) |
| 1529 | 1546 | uarg->callback(skb, uarg, zerocopy_success); |
| 1530 | 1547 | |
| 1531 | − skb_shinfo(skb)->flags &= ~SKBFL_ZEROCOPY_FRAG; | |
| 1548 | + skb_shinfo(skb)->flags &= ~SKBFL_ALL_ZEROCOPY; | |
| 1532 | 1549 | } |
| 1533 | 1550 | } |
| 1534 | 1551 | |
| @@ -1675,6 +1692,22 @@ static inline int skb_unclone(struct sk_buff *skb, gfp_t pri) · 140 unmodified lines | ||
| 1675 | 1692 | return 0; |
| 1676 | 1693 | } |
| 1677 | 1694 | |
| 1695 | +/* This variant of skb_unclone() makes sure skb->truesize is not changed */ | |
| 1696 | +static inline int skb_unclone_keeptruesize(struct sk_buff *skb, gfp_t pri) | |
| 1697 | +{ | |
| 1698 | + might_sleep_if(gfpflags_allow_blocking(pri)); | |
| 1699 | + | |
| 1700 | + if (skb_cloned(skb)) { | |
| 1701 | + unsigned int save = skb->truesize; | |
| 1702 | + int res; | |
| 1703 | + | |
| 1704 | + res = pskb_expand_head(skb, 0, 0, pri); | |
| 1705 | + skb->truesize = save; | |
| 1706 | + return res; | |
| 1707 | + } | |
| 1708 | + return 0; | |
| 1709 | +} | |
| 1710 | + | |
| 1678 | 1711 | /** |
| 1679 | 1712 | * skb_header_cloned - is the header a clone |
| 1680 | 1713 | * @skb: buffer to check |
| @@ -507,6 +507,18 @@ static inline bool sk_psock_strp_enabled(struct sk_psock *psock) · 506 unmodified lines | ||
| 507 | 507 | return !!psock->saved_data_ready; |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | +static inline bool sk_is_tcp(const struct sock *sk) | |
| 511 | +{ | |
| 512 | + return sk->sk_type == SOCK_STREAM && | |
| 513 | + sk->sk_protocol == IPPROTO_TCP; | |
| 514 | +} | |
| 515 | + | |
| 516 | +static inline bool sk_is_udp(const struct sock *sk) | |
| 517 | +{ | |
| 518 | + return sk->sk_type == SOCK_DGRAM && | |
| 519 | + sk->sk_protocol == IPPROTO_UDP; | |
| 520 | +} | |
| 521 | + | |
| 510 | 522 | #if IS_ENABLED(CONFIG_NET_SOCK_MSG) |
| 511 | 523 | |
| 512 | 524 | #define BPF_F_STRPARSER (1UL << 1) |
| @@ -72,7 +72,9 @@ struct llc_sap { · 71 unmodified lines | ||
| 72 | 72 | static inline |
| 73 | 73 | struct hlist_head *llc_sk_dev_hash(struct llc_sap *sap, int ifindex) |
| 74 | 74 | { |
| 75 | − return &sap->sk_dev_hash[ifindex % LLC_SK_DEV_HASH_ENTRIES]; | |
| 75 | + u32 bucket = hash_32(ifindex, LLC_SK_DEV_HASH_BITS); | |
| 76 | + | |
| 77 | + return &sap->sk_dev_hash[bucket]; | |
| 76 | 78 | } |
| 77 | 79 | |
| 78 | 80 | static inline |
| @@ -1355,16 +1355,6 @@ struct sctp_endpoint { · 1354 unmodified lines | ||
| 1355 | 1355 | reconf_enable:1; |
| 1356 | 1356 | |
| 1357 | 1357 | __u8 strreset_enable; |
| 1358 | − | |
| 1359 | − /* Security identifiers from incoming (INIT). These are set by | |
| 1360 | − * security_sctp_assoc_request(). These will only be used by | |
| 1361 | − * SCTP TCP type sockets and peeled off connections as they | |
| 1362 | − * cause a new socket to be generated. security_sctp_sk_clone() | |
| 1363 | − * will then plug these into the new socket. | |
| 1364 | − */ | |
| 1365 | − | |
| 1366 | − u32 secid; | |
| 1367 | − u32 peer_secid; | |
| 1368 | 1358 | }; |
| 1369 | 1359 | |
| 1370 | 1360 | /* Recover the outter endpoint structure. */ |
| @@ -2104,6 +2094,16 @@ struct sctp_association { · 733 unmodified lines | ||
| 2104 | 2094 | __u64 abandoned_unsent[SCTP_PR_INDEX(MAX) + 1]; |
| 2105 | 2095 | __u64 abandoned_sent[SCTP_PR_INDEX(MAX) + 1]; |
| 2106 | 2096 | |
| 2097 | + /* Security identifiers from incoming (INIT). These are set by | |
| 2098 | + * security_sctp_assoc_request(). These will only be used by | |
| 2099 | + * SCTP TCP type sockets and peeled off connections as they | |
| 2100 | + * cause a new socket to be generated. security_sctp_sk_clone() | |
| 2101 | + * will then plug these into the new socket. | |
| 2102 | + */ | |
| 2103 | + | |
| 2104 | + u32 secid; | |
| 2105 | + u32 peer_secid; | |
| 2106 | + | |
| 2107 | 2107 | struct rcu_head rcu; |
| 2108 | 2108 | }; |
| 2109 | 2109 | |
| @@ -54,10 +54,28 @@ struct strp_msg { · 53 unmodified lines | ||
| 54 | 54 | int offset; |
| 55 | 55 | }; |
| 56 | 56 | |
| 57 | +struct _strp_msg { | |
| 58 | + /* Internal cb structure. struct strp_msg must be first for passing | |
| 59 | + * to upper layer. | |
| 60 | + */ | |
| 61 | + struct strp_msg strp; | |
| 62 | + int accum_len; | |
| 63 | +}; | |
| 64 | + | |
| 65 | +struct sk_skb_cb { | |
| 66 | +#define SK_SKB_CB_PRIV_LEN 20 | |
| 67 | + unsigned char data[SK_SKB_CB_PRIV_LEN]; | |
| 68 | + struct _strp_msg strp; | |
| 69 | + /* temp_reg is a temporary register used for bpf_convert_data_end_access | |
| 70 | + * when dst_reg == src_reg. | |
| 71 | + */ | |
| 72 | + u64 temp_reg; | |
| 73 | +}; | |
| 74 | + | |
| 57 | 75 | static inline struct strp_msg *strp_msg(struct sk_buff *skb) |
| 58 | 76 | { |
| 59 | 77 | return (struct strp_msg *)((void *)skb->cb + |
| 60 | − offsetof(struct qdisc_skb_cb, data)); | |
| 78 | + offsetof(struct sk_skb_cb, strp)); | |
| 61 | 79 | } |
| 62 | 80 | |
| 63 | 81 | /* Structure for an attached lower socket */ |
| @@ -293,7 +293,10 @@ static inline bool tcp_out_of_memory(struct sock *sk) · 292 unmodified lines | ||
| 293 | 293 | static inline void tcp_wmem_free_skb(struct sock *sk, struct sk_buff *skb) |
| 294 | 294 | { |
| 295 | 295 | sk_wmem_queued_add(sk, -skb->truesize); |
| 296 | − sk_mem_uncharge(sk, skb->truesize); | |
| 296 | + if (!skb_zcopy_pure(skb)) | |
| 297 | + sk_mem_uncharge(sk, skb->truesize); | |
| 298 | + else | |
| 299 | + sk_mem_uncharge(sk, SKB_TRUESIZE(skb_end_offset(skb))); | |
| 297 | 300 | __kfree_skb(skb); |
| 298 | 301 | } |
| 299 | 302 | |
| @@ -974,7 +977,8 @@ static inline bool tcp_skb_can_collapse(const struct sk_buff *to, · 674 unmodified lines | ||
| 974 | 977 | const struct sk_buff *from) |
| 975 | 978 | { |
| 976 | 979 | return likely(tcp_skb_can_collapse_to(to) && |
| 977 | − mptcp_skb_can_collapse(to, from)); | |
| 980 | + mptcp_skb_can_collapse(to, from) && | |
| 981 | + skb_pure_zcopy_same(to, from)); | |
| 978 | 982 | } |
| 979 | 983 | |
| 980 | 984 | /* Events passed to congestion control interface */ |
| @@ -411,7 +411,9 @@ enum { · 410 unmodified lines | ||
| 411 | 411 | ETHTOOL_A_PAUSE_STAT_TX_FRAMES, |
| 412 | 412 | ETHTOOL_A_PAUSE_STAT_RX_FRAMES, |
| 413 | 413 | |
| 414 | − /* add new constants above here */ | |
| 414 | + /* add new constants above here | |
| 415 | + * adjust ETHTOOL_PAUSE_STAT_CNT if adding non-stats! | |
| 416 | + */ | |
| 415 | 417 | __ETHTOOL_A_PAUSE_STAT_CNT, |
| 416 | 418 | ETHTOOL_A_PAUSE_STAT_MAX = (__ETHTOOL_A_PAUSE_STAT_CNT - 1) |
| 417 | 419 | }; |