linux-stable/net/core
Jakub Sitnicki 058ec4a7d9 bpf: Treat bpf_sk_lookup remote_port as a 2-byte field
In commit 9a69e2b385 ("bpf: Make remote_port field in struct
bpf_sk_lookup 16-bit wide") the remote_port field has been split up and
re-declared from u32 to be16.

However, the accompanying changes to the context access converter have not
been well thought through when it comes big-endian platforms.

Today 2-byte wide loads from offsetof(struct bpf_sk_lookup, remote_port)
are handled as narrow loads from a 4-byte wide field.

This by itself is not enough to create a problem, but when we combine

 1. 32-bit wide access to ->remote_port backed by a 16-wide wide load, with
 2. inherent difference between litte- and big-endian in how narrow loads
    need have to be handled (see bpf_ctx_narrow_access_offset),

we get inconsistent results for a 2-byte loads from &ctx->remote_port on LE
and BE architectures. This in turn makes BPF C code for the common case of
2-byte load from ctx->remote_port not portable.

To rectify it, inform the context access converter that remote_port is
2-byte wide field, and only 1-byte loads need to be treated as narrow
loads.

At the same time, we special-case the 4-byte load from &ctx->remote_port to
continue handling it the same way as do today, in order to keep the
existing BPF programs working.

Fixes: 9a69e2b385 ("bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide")
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20220319183356.233666-2-jakub@cloudflare.com
2022-03-20 18:58:59 -07:00
..
bpf_sk_storage.c bpf: Enable non-atomic allocations in local storage 2022-03-20 18:55:05 -07:00
datagram.c net: avoid double accounting for pure zerocopy skbs 2021-11-03 11:19:49 +00:00
datagram.h
dev.c net: dev: use kfree_skb_reason() for __netif_receive_skb_core() 2022-03-04 12:17:11 +00:00
dev_addr_lists.c dev_addr_list: put the first addr on the tree 2021-11-20 12:25:57 +00:00
dev_addr_lists_test.c net: kunit: add a test for dev_addr_lists 2021-11-20 12:25:57 +00:00
dev_ioctl.c net_tstamp: add new flag HWTSTAMP_FLAG_BONDED_PHC_INDEX 2021-12-14 12:28:24 +00:00
devlink.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2021-12-31 14:35:40 +00:00
drop_monitor.c drop_monitor: remove quadratic behavior 2022-02-23 12:39:58 +00:00
dst.c net: dst: add net device refcount tracking to dst_entry 2021-12-06 16:05:10 -08:00
dst_cache.c wireguard: device: reset peer src endpoint when netns exits 2021-11-29 19:50:45 -08:00
failover.c net: failover: add net device refcount tracker 2021-12-06 16:06:02 -08:00
fib_notifier.c
fib_rules.c fib: expand fib_rule_policy 2021-12-16 07:18:35 -08:00
filter.c bpf: Treat bpf_sk_lookup remote_port as a 2-byte field 2022-03-20 18:58:59 -07:00
flow_dissector.c flow_dissector: Add support for HSR 2022-03-02 22:44:49 -08:00
flow_offload.c flow_offload: add reoffload process to update hw_count 2021-12-19 14:08:48 +00:00
gen_estimator.c net: sched: Remove Qdisc::running sequence counter 2021-10-18 12:54:41 +01:00
gen_stats.c net: stats: Read the statistics in ___gnet_stats_copy_basic() instead of adding. 2021-10-21 12:47:56 +01:00
gro.c net: gro: minor optimization for dev_gro_receive() 2022-02-05 15:13:52 +00:00
gro_cells.c gro_cells: avoid using synchronize_rcu() in gro_cells_destroy() 2022-02-22 11:25:40 -08:00
hwbm.c
link_watch.c net: refine dev_put()/dev_hold() debugging 2022-02-05 15:22:45 +00:00
lwt_bpf.c net: Don't include filter.h from net/sock.h 2021-12-29 08:48:14 -08:00
lwtunnel.c lwtunnel: Validate RTA_ENCAP_TYPE attribute length 2021-12-31 14:31:59 +00:00
Makefile net: kunit: add a test for dev_addr_lists 2021-11-20 12:25:57 +00:00
neighbour.c net: neigh: use kfree_skb_reason() for __neigh_event_send() 2022-02-26 12:53:59 +00:00
net-procfs.c net-procfs: show net devices bound packet types 2022-01-24 11:58:46 +00:00
net-sysfs.c net-sysfs: add check for netdevice being present to speed_show 2022-02-18 10:59:11 +00:00
net-sysfs.h
net-traces.c tcp: add tracepoint for checksum errors 2021-05-14 15:26:03 -07:00
net_namespace.c net: initialize init_net earlier 2022-02-06 11:04:29 +00:00
netclassid_cgroup.c bpf, cgroups: Fix cgroup v2 fallback on v1/v2 mixed mode 2021-09-13 16:35:58 -07:00
netevent.c net: core: Correct function name netevent_unregister_notifier() in the kerneldoc 2021-03-28 17:56:56 -07:00
netpoll.c netpoll: add net device refcount tracker to struct netpoll 2021-12-06 16:06:02 -08:00
netprio_cgroup.c bpf, cgroups: Fix cgroup v2 fallback on v1/v2 mixed mode 2021-09-13 16:35:58 -07:00
of_net.c Revert "of: net: support NVMEM cells with MAC in text format" 2022-01-12 14:14:36 +00:00
page_pool.c page_pool: Add function to batch and return stats 2022-03-03 09:55:28 +00:00
pktgen.c proc: remove PDE_DATA() completely 2022-01-22 08:33:37 +02:00
ptp_classifier.c bpf: Refactor BPF_PROG_RUN into a function 2021-08-17 00:45:07 +02:00
request_sock.c
rtnetlink.c net: rtnetlink: Add UAPI toggle for IFLA_OFFLOAD_XSTATS_L3_STATS 2022-03-03 10:37:23 +00:00
scm.c memcg: enable accounting for scm_fp_list objects 2021-07-20 06:00:38 -07:00
secure_seq.c net: align static siphash keys 2021-11-16 19:07:54 -08:00
selftests.c net: core: constify mac addrs in selftests 2021-10-24 13:59:44 +01:00
skbuff.c net: skb: introduce the function kfree_skb_list_reason() 2022-03-04 12:17:11 +00:00
skmsg.c bpf, sockmap: Fix memleak in tcp_bpf_sendmsg while sk msg is full 2022-03-15 16:43:31 +01:00
sock.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-02-24 17:54:25 -08:00
sock_destructor.h skb_expand_head() adjust skb->truesize incorrectly 2021-10-22 12:35:51 -07:00
sock_diag.c net: Don't include filter.h from net/sock.h 2021-12-29 08:48:14 -08:00
sock_map.c bpf: support BPF_PROG_QUERY for progs attached to sockmap 2022-01-20 21:30:58 -08:00
sock_reuseport.c tcp: Add stats for socket migration. 2021-06-23 12:56:08 -07:00
stream.c net: stream: don't purge sk_error_queue in sk_stream_kill_queues() 2021-10-16 09:06:09 +01:00
sysctl_net_core.c net/sysctl: avoid two synchronize_rcu() calls 2022-02-28 11:40:47 +00:00
timestamping.c
tso.c
utils.c net: core: Use csum_replace_by_diff() and csum_sub() instead of opencoding 2022-02-21 11:40:44 +00:00
xdp.c veth: Rework veth_xdp_rcv_skb in order to accept non-linear skb 2022-03-17 20:33:52 +01:00