diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2026-11-20 17:41:06 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2026-11-20 17:41:06 -0800 |
| commit | 84afebd853437e44cb71f718be11d90e4c1a59dd (patch) | |
| tree | 09dc2b20cfa9303bc824b928eb6c9a322ecb318a /include | |
| parent | 05718d5c2907cb46fb27bb6580edb89769ea430a (diff) | |
| parent | d5ba86298b45e1a81c578c499e9a222a3b734d5d (diff) | |
Merge tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf
Pull bpf fixes from Alexei Starovoitov:
"Mostly sockmap fixes as promised, plus uprobe ctx rewrite via bpf and
cgroup-bpf fixes.
- Reject writable map iterators on read-only maps (Adethya
Srinivasan)
- Various sockmap fixes (Alexei Starovoitov):
- Clear the redirect target before the sk_msg prog runs
- Check that the redirected message is the cork
- Leave sk_stream_wait_memory() once the socket is dead
- Keep the rest of the cork after a redirect
- Don't let an SK_PASS verdict cover the next message
- Subtract all dropped bytes from the return value of sendmsg()
- Clear the end mark of elements added by bpf_msg_push_data() and
bpf_msg_pop_data()
- Fix ring capacity invariant break in bpf_msg_push_data() (Bo Cao)
- Report RCU-tasks quiescent states in do_check() to fix rcu_tasks
stalls during a long verification (Breno Leitao)
- Various sockmap fixes (Chris Mason):
- Give no progs to a TCP listener
- Check the target of an egress redirect before each send
- Check the TCP state in recvmsg()
- Reset the copy position when corking
- Don't copy 0 bytes into a full cork
- Use a dedicated workqueue for freeing BPF programs to fix a
deadlock between pack_mutex waiters and the vmalloc purge work
(Emil Tsalapatis)
- Fix verifier model mismatch on a narrow read of
__sk_buff.remote_port (Henry Martin)
- Fix bpf-gcc CO-RE relocation in verifier_sockmap_mutate selftest
(Jiayuan Chen)
- Restrict uprobe ctx writes to the registers that ptrace can set
(Jiri Olsa)
- Various sockmap fixes (Josef Bacik):
- Write sg.start when recvmsg() faults
- Don't let an SK_DROP verdict stick
- Clear the resume state of a stopped psock
- Various fixes (Michal Luczaj):
- Fix "unresolved symbol tcp_request_sock" build error with
CONFIG_INET=n
- Restrict iter-context sockmap updates to iter/sockmap
- Restrict bpf_sock_destroy() to iter/{tcp,udp}
- Mark bpf_iter__sockmap::sk as PTR_TRUSTED
- Mark backing_file_alloc/free LSM hooks as untrusted (Sergei
Nizovtsev)
- Various cgroup-bpf fixes (Shakeel Butt):
- Don't read freed effective arrays in BPF_PROG_QUERY
- Don't attach to a removed cgroup
- Protect cgroup_bpf state with its own mutex, so that queries
and the release work don't wait for cgroup_mutex
- Don't lose errors in effective BPF_LSM_CGROUP queries
- Check variable-offset accesses against special fields (Shihuang
Liu)"
* tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf: (38 commits)
selftests/bpf: Test which ctx registers a uprobe prog can write
bpf: Restrict uprobe ctx writes to the registers ptrace can set
selftests/bpf: Fix bpf-gcc CO-RE relocation in verifier_sockmap_mutate
bpf, cgroup: Don't lose errors in effective BPF_LSM_CGROUP queries
bpf, cgroup: Protect cgroup_bpf state with its own mutex
bpf, cgroup: Don't attach to a removed cgroup
bpf, cgroup: Don't read freed effective arrays in BPF_PROG_QUERY
bpf: Fix verifier model mismatch on __sk_buff.remote_port narrow read
bpf: Fix "unresolved symbol tcp_request_sock" build error
selftests/bpf: Add iter/sockmap bpf_sock_destroy() negative test
bpf: Mark bpf_iter__sockmap::sk as PTR_TRUSTED
bpf: Restrict bpf_sock_destroy() to iter/{tcp,udp}
bpf, docs: Document BPF_ITER_NOSLEEP
selftests/bpf: Add negative test for sockmap update from non-sockmap iter
bpf, sockmap: Restrict iter-context sockmap updates to iter/sockmap
selftests/bpf: Remove sockmap update from bpf_iter_unix
bpf, lsm: Mark backing_file_alloc/free LSM hooks as untrusted
bpf: Report RCU-tasks quiescent states in do_check()
bpf: Check variable-offset accesses against special fields
bpf: Use dedicated workqueue for freeing BPF programs
...
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/bpf-cgroup-defs.h | 1 | ||||
| -rw-r--r-- | include/linux/bpf-cgroup.h | 3 | ||||
| -rw-r--r-- | include/linux/bpf.h | 1 | ||||
| -rw-r--r-- | include/linux/skmsg.h | 19 | ||||
| -rw-r--r-- | include/linux/uprobes.h | 5 | ||||
| -rw-r--r-- | include/net/tcp.h | 6 |
6 files changed, 35 insertions, 0 deletions
diff --git a/include/linux/bpf-cgroup-defs.h b/include/linux/bpf-cgroup-defs.h index 0147b8bec973..671f27ba6a62 100644 --- a/include/linux/bpf-cgroup-defs.h +++ b/include/linux/bpf-cgroup-defs.h @@ -53,6 +53,7 @@ enum cgroup_bpf_attach_type { MAX_CGROUP_BPF_ATTACH_TYPE }; +/* Locking: see cgroup_bpf_mutex in kernel/bpf/cgroup.c */ struct cgroup_bpf { /* array of effective progs in this cgroup */ struct bpf_prog_array __rcu *effective[MAX_CGROUP_BPF_ATTACH_TYPE]; diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h index 02ef7f899b3d..dfa7a75507c9 100644 --- a/include/linux/bpf-cgroup.h +++ b/include/linux/bpf-cgroup.h @@ -421,6 +421,9 @@ static inline bool cgroup_bpf_sock_enabled(struct sock *sk, __ret; \ }) +/* Take cgroup_mutex first if you need both. See kernel/bpf/cgroup.c. */ +void cgroup_bpf_lock(void); +void cgroup_bpf_unlock(void); int cgroup_bpf_prog_attach(const union bpf_attr *attr, enum bpf_prog_type ptype, struct bpf_prog *prog); int cgroup_bpf_prog_detach(const union bpf_attr *attr, diff --git a/include/linux/bpf.h b/include/linux/bpf.h index fdbf638300fc..1dd9db16f324 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -70,6 +70,7 @@ extern spinlock_t btf_idr_lock; extern struct kobject *btf_kobj; extern struct bpf_mem_alloc bpf_global_ma, bpf_global_percpu_ma; extern bool bpf_global_ma_set; +extern struct workqueue_struct *bpf_prog_free_wq __ro_after_init; typedef u64 (*bpf_callback_t)(u64, u64, u64, u64, u64); typedef int (*bpf_iter_init_seq_priv_t)(void *private_data, diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h index d5e35f24738d..f0e27b4b929f 100644 --- a/include/linux/skmsg.h +++ b/include/linux/skmsg.h @@ -196,6 +196,25 @@ static inline void sk_msg_init(struct sk_msg *msg) sg_init_marker(msg->sg.data, NR_MSG_FRAG_IDS); } +/* + * sk_msg_memcopy_from_iter() writes to byte sg.copybreak of element sg.curr, + * counted from the offset of that element. Point both past the last byte of + * the message, after something other than a copy has changed its elements. + */ +static inline void sk_msg_reset_curr(struct sk_msg *msg) +{ + if (!msg->sg.size) { + msg->sg.curr = msg->sg.start; + msg->sg.copybreak = 0; + } else { + u32 i = msg->sg.end; + + sk_msg_iter_var_prev(i); + msg->sg.curr = i; + msg->sg.copybreak = msg->sg.data[i].length; + } +} + static inline void sk_msg_xfer(struct sk_msg *dst, struct sk_msg *src, int which, u32 size) { diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h index d34dbc0fbbfe..43b250bff162 100644 --- a/include/linux/uprobes.h +++ b/include/linux/uprobes.h @@ -239,6 +239,7 @@ extern void uprobe_copy_from_page(struct page *page, unsigned long vaddr, void * extern void handle_syscall_uprobe(struct pt_regs *regs, unsigned long bp_vaddr); extern void arch_uprobe_optimize(struct arch_uprobe *auprobe, unsigned long vaddr); extern unsigned long arch_uprobe_get_xol_area(void); +extern bool arch_uprobe_regs_writable(int off, int size); #else /* !CONFIG_UPROBES */ struct uprobes_state { }; @@ -300,5 +301,9 @@ static inline void uprobe_copy_process(struct task_struct *t, u64 flags) static inline void uprobe_clear_state(struct mm_struct *mm) { } +static inline bool arch_uprobe_regs_writable(int off, int size) +{ + return false; +} #endif /* !CONFIG_UPROBES */ #endif /* _LINUX_UPROBES_H */ diff --git a/include/net/tcp.h b/include/net/tcp.h index 27de546dc802..bb84b7f64be5 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -1864,6 +1864,12 @@ static inline void tcp_adjust_rcv_ssthresh(struct sock *sk) void tcp_cleanup_rbuf(struct sock *sk, int copied); void __tcp_cleanup_rbuf(struct sock *sk, int copied); +/* Is the socket in a state in which TCP may send an ACK? */ +static inline bool tcp_can_send_ack(const struct sock *sk) +{ + return !((1 << inet_sk_state_load(sk)) & + (TCPF_SYN_SENT | TCPF_SYN_RECV | TCPF_TIME_WAIT | TCPF_CLOSE | TCPF_LISTEN)); +} /* We provision sk_rcvbuf around 200% of sk_rcvlowat. * If 87.5 % (7/8) of the space has been consumed, we want to override |
