Repository navigation
Conversation
xattr_test_init() builds a fake super_block but never sets s_user_ns. ext4_xattr_inode_create() calls i_uid_read() and i_gid_read() on the parent inode, which map the ids through inode->i_sb->s_user_ns. With CONFIG_USER_NS=y this dereferences a NULL user namespace. Fix this by pointing s_user_ns at init_user_ns, as alloc_super() does for a normal mount. The dir, hash, inline and namei tests build their fake superblocks the same way. None of them reads an inode owner today, but do the same there so that new test cases don't run into this. Fixes: 5df08dc ("ext4: add KUnit tests for fs/ext4/xattr.c") Signed-off-by: Theodore Ts'o <tytso@mit.edu>
…linux/kernel/git/tj/cgroup Pull cgroup fixes from Tejun Heo: - A BPF program could queue a cgroup stat update with preemption enabled, tripping a lockdep assertion - When nohz_full= included the boot CPU, the tick code took the CPU back out of the nohz_full set but the housekeeping cpumask still excluded it. The fix is in the CPU isolation code. It comes through cgroup with Frederic's review as further cpuset changes build on it * tag 'cgroup-for-7.4-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup: cgroup/rstat: disable preemption in css_rstat_updated() tick/sched: Make tick_nohz_full_mask and HK_TYPE_KERNEL_NOISE cpumask consistent
…cm/linux/kernel/git/tj/sched_ext Pull sched_ext fixes from Tejun Heo: - Scheduler enable and disable could race with tasks changing class: on enable, a task could switch to sched_ext before the scheduler core started picking sched_ext tasks and be left runnable while its CPU went idle. On disable, an RT task could starve the tasks falling back to the fair class and stall the disable itself. - BPF schedulers failed to load on architectures whose BPF JIT doesn't support private stacks, such as riscv64. Only sub-schedulers need them and are now refused there instead. - The debug dump and CPU ID layout callbacks could call kfuncs that move tasks around. They are now rejected at load time. - Smaller fixes: a task's first enqueue after fork didn't tell the BPF scheduler that CPU selection had already run, and two kfuncs raised a false RCU lockdep warning in BPF timer callbacks. * tag 'sched_ext-for-7.4-rc4-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/sched_ext: sched_ext: Attach fair_server before tasks fall back to fair on disable selftests/sched_ext: Add unlocked_kfunc test sched_ext: Don't allow unlocked kfuncs from ops.dump() and ops.init_cids() sched_ext: Don't request private stacks the JIT can't provide sched_ext: Fix suspicious RCU usage in KF_RCU_PROTECTED kfuncs sched/core: Pass ENQUEUE_RQ_SELECTED on initial enqueue sched_ext: Don't route tasks to SCX before __scx_enabled is fully patched
…l/git/soc/soc
Pull SoC fixes from Arnd Bergmann:
"There are once more lots of individual device driver fixes across
several subsystems, and most of them look like they were found with
the help of LLM services looking more closely at corner cases that
had been missed before:
- Multiple SCMI firmware fixes for probing device nodes and mailboxes
- Notifications on Arm FFA firmware with hash conflicts
- Out-of-bounds access to i.MX SCMI firmware data from userspace
- Several error handling and probe fixes for reset controllers, along
with a circular locking problem and one NULL pointer dereference
- Multiple error handling fixes for memory controller drivers
- A probe order fix for Raspberry Pi firmware
For the devicetree source files, there are relatively few fixes so
far, mainly for Samsung and ST SoC based machines, and mainly covering
broken functionality:
- Suspend issues across ST SoCs
- Boot time panic on one ST based board from accessing firmware
memory
- One revert for a regression caused by enabling IOMMU for USB
on an i.MX8 based board
- Corrections for harmless mismatches to the actual boards from
Arm and ST
- Broken Bluetooth and/or Wi-Fi on older Samsung Exynos based
products"
* tag 'soc-fixes-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (40 commits)
ARM: dts: stm32: Fix STM32MP15xx DHCOM SoM PicoITX overlay application
arm64: dts: st: mark STM32MP23 timer as stopping in suspend
arm64: dts: st: add PSCI idle state to STM32MP23 CPU domains
arm64: dts: st: add PSCI idle state to STM32MP25 CPU domains
arm64: dts: st: Update gpio-line-names on STM32MP23xx DHCOS SoM
arm64: dts: st: Move Bluetooth to USART2 on STM32MP23xx DHCOS SoM
arm64: dts: st: add firmware reserved memory to Engicam MicroGEA-STM32MP257
reset: core: honour optional resets when the GPIO fallback returns -ENOENT
platform/raspberrypi: vchiq: register bus at subsys_initcall
MAINTAINERS: fix bouncing {sbranden,rjui}@broadcom.com
Revert "arm64: dts: imx8qm-ss-conn: add usbotg3 iommu information"
memory: fsl_ifc: Do not dereference the unset global pointer in probe
reset: Fix circular locking dependency in reset_controller_unregister()
reset: Fix reset_control leak when put after controller unregister
reset: spacemit: Fix the RCPU2 PWM reset registers
reset: scmi: Set the device for the reset controller
memory: fsl_ifc: Clear fsl_ifc_ctrl_dev on probe failure and removal
ARM: dts: samsung: exynos4210-trats: fix BCM4330 Bluetooth GPIOs
ARM: dts: samsung: exynos4210-universal_c210: fix BCM4330 Bluetooth GPIOs
ARM: dts: samsung: exynos4412-p4note: allow powering off the wifi card
...
The DFS referral cache stores paths and target strings in UTF-8 (cache_cp), whereas cifs_sb->prepath must be encoded in the mount's local charset (cifs_sb->local_nls). When reconnecting a DFS link in tree_connect_dfs_target(), dfs_cache_get_tgt_share() returns @Prefix in cache_cp, which was passed directly to cifs_update_super_prepath(). On mounts using a non-UTF-8 iocharset such as iso8859-1, this overwrites cifs_sb->prepath with UTF-8 bytes. Subsequent operations then re-encode cifs_sb->prepath to UTF-16LE using cifs_sb->local_nls, corrupting non-ASCII characters on the wire and causing lookups to fail with -ENOENT. Add dfs_cache_local_path() to convert a path from cache_cp to a caller-specified codepage via UTF-16, and use it in a new set_super_prepath_from_cache() helper called by tree_connect_dfs_target() so cifs_sb->prepath stays in cifs_sb->local_nls across reconnects. Tested against Samba with iocharset=utf8 and iocharset=iso8859-1 across multiple smbd restarts. Fixes: c870a8e ("cifs: handle different charsets in dfs cache") Cc: stable@vger.kernel.org Signed-off-by: Fredric Cover <fredric.cover.lkernel@gmail.com> Signed-off-by: Paulo Alcantara <pc@manguebit.org>
parse_dfs_target() converts @path_consumed to the mount charset using dfs_consumed_to_local(), but @ref->node_name from the DFS referral cache is still encoded in UTF-8 (cache_cp). In dfs_parse_target_referral(), passing @ref->node_name directly to cifs_build_devname() and smb3_parse_devname() copies UTF-8 bytes into ctx->UNC and ctx->prepath (and mixes encodings when @prepath from @full_path is also non-empty). On mounts using a non-UTF-8 iocharset such as iso8859-1, subsequent path checks re-encode these strings to UTF-16LE using local_nls, corrupting non-ASCII characters on the wire and causing initial mount to fail with -ENOENT. Convert @ref->node_name from cache_cp to ctx->local_nls with dfs_cache_local_path() before building the device name so ctx->UNC and ctx->prepath stay in the mount charset. Tested against Samba with iocharset=iso8859-1 and iocharset=utf8 for both DFS link referrals with a non-ASCII target subpath and mounts with an additional non-ASCII prepath, including reconnects. Fixes: c870a8e ("cifs: handle different charsets in dfs cache") Cc: stable@vger.kernel.org Signed-off-by: Fredric Cover <fredric.cover.lkernel@gmail.com> Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Convert to CPU byte order to avoid incorrect debug log on big-endian architectures. Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn> Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Cc: stable@vger.kernel.org Signed-off-by: Paulo Alcantara <pc@manguebit.org>
Use CPU byte order for temporary UTF-16 buffers to avoid incorrect file name conversion on big-endian architectures. Fixes: b291030 ("Fix to convert SURROGATE PAIR") Cc: stable@vger.kernel.org Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn> Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: Paulo Alcantara <pc@manguebit.org>
In smb2_reconnect_server(), when server->terminate is set, the early exit path calls cifs_put_tcp_session(server, true) while still holding pserver->reconnect_mutex and unlocks pserver->reconnect_mutex afterwards. Dropping the last session reference can free server (which equals pserver for primary channels), causing mutex_unlock() to touch freed memory; the normal done: label at the end of the same function explicitly unlocks reconnect_mutex before calling cifs_put_tcp_session(). Unlock pserver->reconnect_mutex before calling cifs_put_tcp_session() in the server->terminate branch as well. Fixes: ee1d217 ("cifs: handle when server stops supporting multichannel") Cc: stable@vger.kernel.org Signed-off-by: Elkin Cruz <elkin@google.com> Signed-off-by: Paulo Alcantara <pc@manguebit.org>
tipc_group_create() sets tsk->group_is_open to false, and tipc_poll() only reports EPOLLOUT for a socket in TIPC_OPEN state when that flag is true. Commit 1b22bca ("tipc: correct initial value for group congestion flag") made sure the flag is true for sockets that never join a group, since otherwise "SOCK_RDM/DGRAM sockets sending datagrams never receive POLLOUT". The flag is not set back when the group goes away again, though: - tipc_group_create() clears the flag and then fails when the topology subscription cannot be created, for example when TIPC_MAX_SUBSCR subscriptions exist already; - tipc_sk_join() deletes the new group when tipc_sk_publish() fails, for example when the node's publication limit is reached; - tipc_sk_leave() deletes the group while the flag may still be false, e.g. because of group congestion, or because the group has no other members yet. In all three cases the socket is back to an ordinary RDM/DGRAM socket, but poll() never reports EPOLLOUT for it again. Before commit 60c2530 ("tipc: fix race between poll() and setsockopt()"), tipc_poll() also reported EPOLLOUT when tsk->group was NULL, so deleting the group was enough; since then the flag has to be reset. Set tsk->group_is_open to true in these three places, as it is for a socket that never had a group, and call sk_write_space() so that a task already waiting for EPOLLOUT is woken up, as tipc_sk_filter_rcv() does when a group becomes open again. Found with a static analysis tool and checked by hand. Fixes: 60c2530 ("tipc: fix race between poll() and setsockopt()") Cc: stable@vger.kernel.org Co-developed-by: Kaixuan Li <kaixuan.li@ntu.edu.sg> Signed-off-by: Kaixuan Li <kaixuan.li@ntu.edu.sg> Signed-off-by: Suyuan Wang <stevewong@hust.edu.cn> Reviewed-by: Tung Nguyen <tung.quang.nguyen@est.tech> Link: https://patch.msgid.link/20261119-tipc-group-open-v1-1-cb725145da51@gmail.com Signed-off-by: Willem de Bruijn <willemb@google.com>
igmp6_group_added() and igmp6_group_dropped() build a link-layer multicast address in an on-stack buffer with ndisc_mc_map(), which fills a number of bytes depending on dev->type. dev_mc_add() and dev_mc_del() then use dev->addr_len bytes of it. Since IPv6 multicast joins and leaves no longer hold RTNL, dev->type and dev->addr_len can change between the two steps, for instance with TUNSETLINK, or when bonding or team change their type. If addr_len grows (eg ARPHRD_ETHER -> ARPHRD_IP6GRE), dev_mc_add() copies uninitialized stack bytes into a netdev_hw_addr, which can later be dumped to user space by /proc/net/dev_mcast and RTM_GETMULTICAST. Zero the buffers. Found by Sashiko AI review of a tun patch, by code inspection only. Kernels built with CONFIG_INIT_STACK_ALL_ZERO=y are not affected. Fixes: 1767bb2 ("ipv6: mcast: Don't hold RTNL for IPV6_ADD_MEMBERSHIP and MCAST_JOIN_GROUP.") Link: https://lore.kernel.org/netdev/179512665919.3136.5931555157250030152@kernel.org/ Cc: Kuniyuki Iwashima <kuniyu@google.com> Signed-off-by: Eric Dumazet <edumazet@kernel.org> Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://patch.msgid.link/20261123124458.205233-1-edumazet@kernel.org Signed-off-by: Willem de Bruijn <willemb@google.com>
The initial fix from 2017 wasn't updated for modern nouveau devinit disable paths. Fix that and just check if display exists instead. (two other people reproduced this patch, so let's commit it). Fixes: 2139cb6 ("drm/nouveau/devinit/gf100-: try to avoid double-running vbios scripts") Tested-by: Francis Laniel <laniel_francis@npnm.eu> Reviewed-by: Francesco Magazzu <postadelmaga@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com> Link: https://patch.msgid.link/20261123-nouveau-fix-disp-v1-1-ebdc525287ce@redhat.com
sock_has_rx_data() returns a positive value when receive data is available. For sockets without a peek_len() callback, however, its fallback returns skb_queue_empty(), which has the opposite meaning. An AF_PACKET SOCK_RAW socket is accepted by get_raw_socket() as a vhost-net backend, and its socket operations do not provide peek_len(). With busy polling enabled for this backend, an empty receive queue is treated as ready and a nonempty queue as not ready. This can make vhost_net_busy_poll() stop polling prematurely or fail to stop for queued receive data, and invert its receive-side scheduling decision. TUN and TAP backends provide peek_len() and are unaffected. Negate skb_queue_empty() so the fallback matches the callback and the readiness checks in vhost_net_busy_poll(). The issue was found during AI-assisted code review. The helper's incorrect result was confirmed on x86_64 running 6.6.0-amd64-desktop using a temporary diagnostic module containing the original and fixed helpers. An AF_PACKET SOCK_RAW socket, without PACKET_RX_RING, was bound to loopback in a private network namespace. Across three cycles of sending and receiving a 60-byte frame, the original helper returned 1 for an empty queue and 0 for a queued frame. The fixed helper returned 0 and 1 respectively, matching socket readability in all nine checks. This tests helper copies on real sockets, not the running vhost-net busy-poll path; the vhost-net module was not replaced. The patched drivers/vhost/net.o was also build-tested on the net tree with x86_64 GCC 12.3 and W=1 under allmodconfig and allyesconfig. No end-to-end vhost tests or kernel selftests were run. Fixes: 1576d98 ("tun: switch to use skb array for tx") Cc: stable@vger.kernel.org Signed-off-by: Xu Rao <raoxu@uniontech.com> Acked-by: Eugenio Pérez <eperezma@redhat.com> Link: https://patch.msgid.link/1B3A1B72438119BC+20261120033824.681219-1-raoxu@uniontech.com Signed-off-by: Willem de Bruijn <willemb@google.com>
When CGROUP_INET4_POST_BIND or CGROUP_INET6_POST_BIND prog fails, __inet_bind() / __inet6_bind() calls sk->sk_prot->put_port(). For TCP, __inet_put_port() calls inet_bhashfn_portaddr() to get the corresponding bhash2 bucket. inet_bhashfn_portaddr() requires saddr, but it is cleared before __inet_put_port(), leading to bhash2 lock mismatch. This triggers list corruption or use-after-free by a conccurent thread touching the same bhash2 bucket, e.g. tcp_diag_dump() with TCPF_BOUND_INACTIVE. [0] Let's clear saddr after calling sk->sk_prot->put_port(). [0]: BUG: KASAN: slab-use-after-free in tcp_diag_dump (net/ipv4/tcp_diag.c:415) Read of size 8 at addr ffff88810ae0e7a0 by task a/1007 CPU: 10 UID: 0 PID: 1007 Comm: a Not tainted 7.4.0-rc3-00456-gd5b89d55a322 #295 PREEMPT(lazy) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-debian-1.17.0-1 04/01/2014 Call Trace: <TASK> dump_stack_lvl (lib/dump_stack.c:120) print_address_description (mm/kasan/report.c:378) print_report (mm/kasan/report.c:482) kasan_report (mm/kasan/report.c:595) sock_recvmsg (net/socket.c:1154) __sys_recvfrom (net/socket.c:2333) __x64_sys_recvfrom (net/socket.c:2348 net/socket.c:2344 net/socket.c:2344) do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:89) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) RIP: 0033:0x7f2f268f8e92 Code: 08 0f 85 91 41 ff ff 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3> 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 f3 0f 1e fa 55 bf 01 00 RSP: 002b:00007f2f26874d28 EFLAGS: 00000246 ORIG_RAX: 000000000000002d RAX: ffffffffffffffda RBX: 00007f2f26879ce4 RCX: 00007f2f268f8e92 RDX: 0000000000004000 RSI: 00007f2f26874db0 RDI: 00000000000007d7 RBP: 00007f2f26874d50 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000021 R13: 00007ffcbb216e70 R14: 0000000000000000 R15: 00007ffcbb216f77 </TASK> Allocated by task 1009: kasan_save_track (mm/kasan/common.c:57 mm/kasan/common.c:79) __kasan_slab_alloc (mm/kasan/common.c:354 mm/kasan/common.c:380) kmem_cache_alloc_noprof (./include/linux/kasan.h:257 mm/slub.c:4720 mm/slub.c:5033 mm/slub.c:5047) inet_bind2_bucket_create (net/ipv4/inet_hashtables.c:162) inet_csk_get_port (net/ipv4/inet_connection_sock.c:573) __inet_bind (net/ipv4/af_inet.c:544) inet_bind_sk (net/ipv4/af_inet.c:470) __sys_bind (net/socket.c:1947 net/socket.c:1978) __x64_sys_bind (net/socket.c:1983 net/socket.c:1981 net/socket.c:1981) do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:89) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) Freed by task 1009: kasan_save_track (mm/kasan/common.c:57 mm/kasan/common.c:79) kasan_save_free_info (mm/kasan/generic.c:599) __kasan_slab_free (mm/kasan/common.c:267 mm/kasan/common.c:299) kmem_cache_free (./include/linux/kasan.h:239 mm/slub.c:2780 mm/slub.c:6637 mm/slub.c:6764) inet_put_port (net/ipv4/inet_hashtables.c:178) __inet_bind (net/ipv4/af_inet.c:554) inet_bind_sk (net/ipv4/af_inet.c:470) __sys_bind (net/socket.c:1947 net/socket.c:1978) __x64_sys_bind (net/socket.c:1983 net/socket.c:1981 net/socket.c:1981) do_syscall_64 (arch/x86/entry/syscall_64.c:61 arch/x86/entry/syscall_64.c:89) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121) The buggy address belongs to the object at ffff88810ae0e780 which belongs to the cache tcp_bind2_bucket of size 80 Fixes: 28044fc ("net: Add a bhash2 table hashed by port and address") Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Reviewed-by: Eric Dumazet <edumazet@kernel.org> Link: https://patch.msgid.link/20261121203537.341320-1-kuniyu@google.com Signed-off-by: Willem de Bruijn <willemb@google.com>
The verifier does not know how many elements a flexible array of a kernel object has. Mark pointers that are loaded from one as untrusted. Ignore the __rcu tag of such pointers. Fixes: 9c5f8a1 ("bpf: Support variable length array in tracing programs") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261125032938.670542-2-alexei.starovoitov@gmail.com
expected_attach_type of a struct_ops program is the index of the member. sock_ops, cgroup_device and cgroup_sysctl programs load with almost any value. The kernel compares it with attach types of other programs: - Members 25, 26, 27, 43 and 58 can read ctx[nr_args], as fexit does. The slot has stale stack. - The trampoline of members 58 and 61 clears that slot, as for fsession. It is the last argument when the member returns void. - Pointer arguments of member 23 get the rules of raw tracepoints. - Members 59, 60 and 61 cannot be loaded. - The release of a cgroup looks for the LSM shim of a program that says BPF_LSM_CGROUP and has no attach_btf. Look at the type of the program too. Fixes: 27ae799 ("bpf: Introduce BPF_PROG_TYPE_STRUCT_OPS") Fixes: 69fd337 ("bpf: per-cgroup lsm flavor") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261125032938.670542-3-alexei.starovoitov@gmail.com
The verifier gives the result of bpf_get_retval() the range [-4095, 0]. In timeout_init and rwnd_init of struct bpf_tcp_ops it is what the previous program returned, any int. Do not refine the range for struct_ops programs. Fixes: 5ac77ae ("bpf: tcp: Support selected sock_ops callbacks as struct_ops") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261125032938.670542-4-alexei.starovoitov@gmail.com
For a program that is attached to a program attach_btf_id is an id in the BTF of the target. bpf_d_path_allowed() looks for it in a list of kernel functions, it can match by chance. Do not look at the list when there is a target program. Fixes: 6e22ab9 ("bpf: Add d_path helper") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261125032938.670542-5-alexei.starovoitov@gmail.com
An extension runs in the hook of its target, and the checks for the hook do not see it. Tracing, LSM and struct_ops programs are checked against the BTF of their hook. An extension takes the type of its target, but it has no attach_btf and no st_ops, and attach_btf_id and the prototype are those of the function that it replaces: - tp_btf: it can read more arguments than the tracepoint has. - LSM: the range of bpf_get_retval() and bpf_set_retval(), and the helpers that only some hooks have, are looked up by a wrong id. - tp_btf and struct_ops: the load can oops. fentry, fexit, fsession and iterators cannot be extended already. Refuse the rest. freplace of global functions of tp_btf, fmod_ret and LSM programs goes away. Targets of other types load with any expected_attach_type. Do not take their extension for tp_btf or for an iterator. Some properties of a program are looked at when it is attached or run. Nobody looks at those of an extension: - bpf_get_local_storage() returns the storage of the attached program, the extension is verified against its own map. - bpf_override_return() needs a function that allows error injection. - skb->cb is saved, cleared and restored only for programs that access it. Ask for the storage map of the target, at load and at attach. Refuse the attach when the target does not call bpf_override_return() itself, or does not access skb->cb. A tail call counts as an access to skb->cb. Fixes: be8704f ("bpf: Introduce dynamic program extensions") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Anton Protopopov <a.s.protopopov@gmail.com> Link: https://patch.msgid.link/20261125032938.670542-6-alexei.starovoitov@gmail.com
A prog array compares expected_attach_type. It is 0 for an extension at the time of the check, so the extension can call programs that were checked for another attach type, and cannot share an array with its target. Take the attach type of the target. Fixes: 4540aed ("bpf: Enforce expected_attach_type for tailcall compatibility") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261125032938.670542-7-alexei.starovoitov@gmail.com
Hooks of one prototype differ in what the verifier assumes: - struct_ops: two structs can have the same index and prototype of a member. Nullable and referenced arguments, filters of kfuncs and the prologue belong to the struct. - tp_btf: which arguments can be NULL. - LSM and iterators: what is trusted, helpers, kfuncs, return values. - A tracer of a program: the context of the target. Compare that. Tracepoints that agree, and tracers of kernel functions, share a prog array as before. Two LSM hooks cannot. Fixes: 28ead3e ("bpf: Prevent tail call between progs attached to different hooks") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261125032938.670542-8-alexei.starovoitov@gmail.com
The trampoline has a session cookie and the address of the function only when the program that is attached asks for them. After a tail call bpf_get_func_ip() returns what is on the stack, and bpf_session_cookie() points to the first argument, which the trampoline passes to the function: KASAN: maybe wild-memory-access in range [0x4141414141414148-0x414141414141414f] RIP: 0010:vfs_truncate+0x32/0x450 Ask for both when the program has a tail call. Fixes: 9b99edc ("bpf: Add bpf_get_func_ip helper for tracing programs") Fixes: eeee423 ("bpf: support fsession for bpf_session_cookie") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261125032938.670542-9-alexei.starovoitov@gmail.com
A map takes a program when the id of the struct and the index of the member are the same. Ids of types are not unique among modules. Compare BTF too. BPF_PROG_ASSOC_STRUCT_OPS takes any struct_ops map, and the callers of bpf_prog_get_assoc_struct_ops() take the result for their own struct. Pass the struct_ops that the caller wants, return NULL for another one. The callers are scx_prog_sched() of sched_ext and bpf_testmod, they change with the prototype. Fixes: f6be98d ("bpf, net: switch to dynamic registration") Fixes: b5709f6 ("bpf: Support associating BPF program with struct_ops") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261125032938.670542-10-alexei.starovoitov@gmail.com
The delegate_* mount options of bpffs take names and numbers. A number overwrites the mask, the names in front of it are lost. That is the order in which /proc/mounts shows them. Fixes: 6c1752e ("bpf: Support symbolic BPF FS delegation mount options") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261125032938.670542-11-alexei.starovoitov@gmail.com
___neigh_create() calls the tracepoint before it tests the result of neigh_alloc(). It is NULL when the table is full. The verifier takes it for a trusted pointer, and a load through it oopses: BUG: kernel NULL pointer dereference, address: 000000000000013c RIP: 0010:bpf_prog_56e3384dcafb1b5b_on_create+0x61/0xc4 Mark it untrusted, loads through it are probed then. PTR_MAYBE_NULL would refuse programs like bpftune, which pass &n->parms to bpf_probe_read_kernel() without a check. The pointer cannot be passed as memory or as a trusted argument any more. Fixes: 838a10b ("bpf: Augment raw_tp arguments with PTR_MAYBE_NULL") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261125032938.670542-12-alexei.starovoitov@gmail.com
Helpers take a plain PTR_TO_BTF_ID, which can be NULL: an argument of a traced function, or a member of a struct. Some do not check it: KASAN: null-ptr-deref in range [0x0000000000000048-0x000000000000004f] RIP: 0010:sock_from_file+0x22/0x70 bpf_task_pt_regs(), bpf_get_task_stack(), bpf_copy_from_user_task(), bpf_xdp_get_buff_len(), bpf_getsockopt() and bpf_setsockopt() oops the same way. So does bpf_d_path() on the path of a unix socket that is not bound, it has no dentry. Check for NULL, as bpf_find_vma() and bpf_skc_to_*() do. Fixes: fa28dcb ("bpf: Introduce helper bpf_get_task_stack()") Fixes: 6e22ab9 ("bpf: Add d_path helper") Fixes: 4f19cab ("bpf: Add a bpf_sock_from_file helper") Fixes: 3cee6fb ("bpf: tcp: Support bpf_(get|set)sockopt in bpf tcp iter") Fixes: dd6e10f ("bpf: Add bpf_task_pt_regs() helper") Fixes: d991730 ("bpf: add frags support to xdp copy helpers") Fixes: 376040e ("bpf: Add bpf_copy_from_user_task() helper") Fixes: 9113d7e ("bpf: expose bpf_{g,s}etsockopt to lsm cgroup") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261125032938.670542-13-alexei.starovoitov@gmail.com
bpf_throw() does not return. What is kept for the return stays behind. With fexit on bpf_throw() the trampoline is never freed. With kretprobes and function_graph the next traced function up the stack takes the return address of bpf_throw() for its own. Mark it notrace and NOKPROBE_SYMBOL. kasan_unpoison_task_stack_below() takes the stack for aligned to THREAD_SIZE. The stack for interrupts of x86-64 is aligned to a page. A program that throws in softirq can leave the redzones of bpf_throw() there: BUG: KASAN: stack-out-of-bounds in stack_trace_consume_entry+0x14e/0x170 It is the only frame with redzones that is skipped. Do not instrument it. Fixes: f18b03f ("bpf: Implement BPF exceptions") Fixes: ec5290a ("bpf: Prevent KASAN false positive with bpf_throw") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261125032938.670542-14-alexei.starovoitov@gmail.com
A prog can be taken by its id and run before bpf_prog_kallsyms_add(). bpf_throw() does not find the main prog and oopses: KASAN: null-ptr-deref in range [0x0000000000000568-0x000000000000056f] RIP: 0010:bpf_throw+0x129/0x220 The exception table is found by the same symbol. Add the symbol first. bpf_prog_free() removes it when there is no id. Fixes: 3dec541 ("bpf: Add support for BTF pointers to x86 JIT") Fixes: f18b03f ("bpf: Implement BPF exceptions") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261125032938.670542-15-alexei.starovoitov@gmail.com
func_idx of the default exception callback is func_cnt, and the test for hidden subprogs is off by one. The address of the callback goes to jited_linfo[0]. libbpf and bpftool refuse the jited line info of the prog. Fixes: 335d1c5 ("bpf: Implement support for adding hidden subprogs") Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261125032938.670542-16-alexei.starovoitov@gmail.com
memstick_remove_host() removes the host ID from memstick_host_idr before device_del() removes the "memstick<N>" device. A host added in between, for example by another card reader being probed, can get the same ID, and its device_add() fails: sysfs: cannot create duplicate filename '/class/memstick_host/memstick0' Remove the ID after device_del(), as the error path of memstick_add_host() already does. Fixes: baf8532 ("memstick: initial commit for Sony MemoryStick support") Cc: stable@vger.kernel.org Signed-off-by: Changyul Lee <lcy8047@gmail.com> Signed-off-by: Ulf Hansson <ulfh@kernel.org>
r592_remove() deletes detect_timer before freeing the interrupt. A card insertion or removal interrupt can re-arm it in between, allowing r592_detect_timer() to access unmapped registers and queue media_checker work on the freed host. Use timer_shutdown_sync() to wait for the callback and prevent re-arming. Keep timer_delete_sync() in r592_suspend(), since the timer is needed again after resume. Found by a static analysis tool under development. Fixes: 6326442 ("memstick: r592: Fix UAF bug in r592_remove due to race condition") Cc: stable@vger.kernel.org Co-developed-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Myeonghun Pak <mhun512@gmail.com> Signed-off-by: Ulf Hansson <ulfh@kernel.org>
rtsx_usb_ms_drv_remove() sets host->eject and cancels poll_card, but a concurrent rtsx_usb_ms_set_param() that already read eject as false can queue the work after the cancel. Its callers, memstick_check() and ms_block error recovery, are stopped only by the later memstick_remove_host(). The delayed work can therefore run after memstick_free_host() frees the host. Use disable_delayed_work_sync() to drain the work and reject later queueing. Probe initializes fresh work on rebind. Found by a static analysis tool under development. Fixes: 4676741 ("memstick: rtsx_usb_ms: Fix slab-use-after-free in rtsx_usb_ms_drv_remove") Cc: stable@vger.kernel.org # v6.10+ Co-developed-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Myeonghun Pak <mhun512@gmail.com> Signed-off-by: Ulf Hansson <ulfh@kernel.org>
The ISSI IS22TF128G eMMC (CID manfid 0x9d, oemid 0x0101, name "IS128G") reports SECURE_REMOVAL_TYPE 0x01 (overwrite, then erase) and has a large per-command overhead for secure erase. Secure erasing a 33.5GiB partition with blkdiscard -s on an NXP i.MX8 (sdhci-esdhc-imx, HS400ES) is split into max_discard sized requests of about 3.5MiB, i.e. roughly 10000 secure erase commands, which takes 5-7 hours once ~27GiB of the partition have been written. Since the per-command overhead dominates, apply MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME so secure erase requests are no longer limited by max_discard. With the quirk, secure erasing the same partition with ~27GiB written takes about 6 minutes. Card parameters: ERASE_GROUP_DEF 0x01, HC_ERASE_GRP_SIZE 0x01 (512KiB), ERASE_TIMEOUT_MULT 0x12, SEC_ERASE_MULT 0x64, SEC_TRIM_MULT 0x64. Cc: stable@vger.kernel.org Signed-off-by: Michael Haener <michael.haener@siemens.com> Reviewed-by: Alexander Sverdlin <alexander.sverdlin@siemens.com> Signed-off-by: Ulf Hansson <ulfh@kernel.org>
With MMC_QUIRK_FIXED_SECURE_ERASE_TRIM_TIME, secure erase/trim requests are no longer limited by max_discard, so mmc_mmc_erase_timeout() can be called with a qty of several thousand erase groups. The timeout is then computed as erase_timeout * sec_erase_mult * qty in 32-bit arithmetic. With 512KiB erase groups the block layer limits a request to about 4096 groups, so the product overflows once ERASE_TIMEOUT_MULT * SEC_ERASE_MULT exceeds about 3496. The wrapped value can be much shorter than the real erase time, making the busy polling give up early with -ETIMEDOUT. No card in the quirk list is known to reach that limit today. Use check_mul_overflow() and saturate at UINT_MAX. Cc: stable@vger.kernel.org Signed-off-by: Michael Haener <michael.haener@siemens.com> Reviewed-by: Alexander Sverdlin <alexander.sverdlin@siemens.com> Signed-off-by: Ulf Hansson <ulfh@kernel.org>
With a kernel 7.3.3 we saw the following on a SoCFPGA (Cyclone 5) based board during initialization when using a high-speed SD-card: dw_mmc ff704000.mmc: DW MMC controller at irq 53,32 bit host data width,1024 deep fifo dw_mmc ff704000.mmc: Got CD GPIO dw_mmc ff704000.mmc: Got WP GPIO mmc_host mmc0: Bus speed = 50000000Hz (req 400000Hz, actual 396825HZ div = 63) mmc_host mmc0: Bus speed = 50000000Hz (req 50000000Hz, actual 50000000HZ div = 0) mmc0: error -110 whilst initialising SD card mmc_host mmc0: Bus speed = 50000000Hz (req 300000Hz, actual 297619HZ div = 84) mmc_host mmc0: Bus speed = 50000000Hz (req 50000000Hz, actual 50000000HZ div = 0) mmc0: error -110 whilst initialising SD card mmc_host mmc0: Bus speed = 50000000Hz (req 200000Hz, actual 200000HZ div = 125) mmc_host mmc0: Bus speed = 50000000Hz (req 50000000Hz, actual 50000000HZ div = 0) mmc0: error -110 whilst initialising SD card mmc_host mmc0: Bus speed = 50000000Hz (req 100000Hz, actual 100000HZ div = 250) mmc_host mmc0: Bus speed = 50000000Hz (req 50000000Hz, actual 50000000HZ div = 0) mmc0: error -110 whilst initialising SD card The SD-card was not usable in the following. Reason: Since commit 3f1628b ("mmc: dw_mmc-pltfm: Use phase_map for SoCFPGA clock phase configuration") host->phase_map is used in order to get the phase settings for MMC_TIMING_SD_HS. This is done in drv_data->init (dw_mci_socfpga_priv_init()) which is called before dw_mci_init_host(). As host->phase_map will be initialized only during dw_mci_init_host(), we'll call dw_mci_socfpga_priv_init() without the needed data. Calling mmc_of_parse_clk_phase() from dw_mci_parse_dt() instead of dw_mci_init_host() ensures that we have valid data when calling dw_mci_socfpga_priv_init() Fixes: 3f1628b ("mmc: dw_mmc-pltfm: Use phase_map for SoCFPGA clock phase configuration") Fixes: 0d94457 ("mmc: dw_mmc: Add parsing mmc_clk_phase_map support") Cc: stable@vger.kernel.org Signed-off-by: Oliver Brandt <oliver.brandt@lenze.com> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com> Signed-off-by: Ulf Hansson <ulfh@kernel.org>
Since commit c35fac6 ("mmc: mmc_test: Fix __counted_by handling after kzalloc_flex() conversion"), mmc_test_alloc_mem() bounds its fill loop with mem->cnt, relying on kzalloc_flex() to have set it to "max_segs". kzalloc_flex() only sets the __counted_by() counter when the compiler supports __builtin_counted_by_ref(). Otherwise mem->cnt is still zero after the first segment is stored. Set mem->cnt after the allocation, as that commit's description intends. Build tested ARCH=x86_64 defconfig with CONFIG_MMC_TEST=m and W=1, with GCC 16.2.0. Fixes: c35fac6 ("mmc: mmc_test: Fix __counted_by handling after kzalloc_flex() conversion") Cc: stable@vger.kernel.org Signed-off-by: Kees Cook <kees@kernel.org> Reviewed-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulfh@kernel.org>
sd_flush_cache() is called from mmc_blk_mq_issue_rq()'s REQ_OP_FLUSH
branch, which runs in the block layer dispatch path with the queue usage
counter held. Both it and sd_write_ext_reg(), which it calls, allocate
a 512-byte buffer with GFP_KERNEL. Under memory pressure that
allocation enters filesystem reclaim, and reclaim may submit I/O back to
the same request queue, closing a cycle against queue freeze:
CPU0 CPU1
---- ----
lock(&q->q_usage_counter(io));
lock(fs_reclaim);
lock(&q->q_usage_counter(io));
lock(&q->elevator_lock);
lockdep reports it on an arm64 Raspberry Pi 5 that boots from an SD
card, with the flush dispatched by blk_mq_requeue_work and the elevator
switch in another thread:
-> #2 (fs_reclaim):
fs_reclaim_acquire <- __kmalloc_cache_noprof <- sd_flush_cache
<- mmc_blk_mq_issue_rq <- mmc_mq_queue_rq
<- blk_mq_dispatch_rq_list
blk_alloc_queue() declares this ordering explicitly and teaches lockdep
about it:
/* Teach lockdep about lock ordering (reclaim WRT queue freeze lock). */
fs_reclaim_acquire(GFP_KERNEL);
rwsem_acquire_read(&q->io_lockdep_map, 0, 0, _RET_IP_);
rwsem_release(&q->io_lockdep_map, _RET_IP_);
fs_reclaim_release(GFP_KERNEL);
Taking q_usage_counter(io) and then entering reclaim is the reverse of
that contract. GFP_NOIO drops __GFP_FS and __GFP_IO, so neither the
lockdep dependency nor the writeback that could resubmit to this queue
can happen any more.
sd_write_ext_reg() is also called from sd_enable_cache() (probe) and
sd_poweroff_notify() (suspend). NOIO costs nothing on those paths: the
allocation is order-0 and 512 bytes, and reclaim without writeback is
still available. Keeping a single gfp flavour in the helper makes its
semantics independent of the caller.
Fixes: 130206a ("mmc: core: Add support for cache ctrl for SD cards")
Cc: stable@vger.kernel.org
Signed-off-by: Xiaolei Wang <wangxiaolei01@kaihong.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Ulf Hansson <ulfh@kernel.org>
This driver is the only one that uses sg_miter_next() to get a persistent mapping across interrupts, which prevents us from converting the internal kmap() to a local mapping using SG_MITER_LOCAL flag. Linus previously attempted to use atomic mappings here, which failed for the same reason. I gave it another try, with a mapping that is only active during a single sh_mmcif_mread_block()/sh_mmcif_mwrite_block() call. This is mainly a revert of the patch that fixed the command 18 timeout, but tries to solve the problem by updating and checking data->bytes_xfered to keep track of when the transfer is finished. Instead of calling sg_miter_stop() on error or completion, this now always stops the iterator after the data transfer and restarts it during the following interrupt. As sashiko-bot comments, there is an inconsistency with the size of each transfer: The mmc core expects a transfer of size data->blksz, but the actual transfer is host->blocksize, which is read from a hardware register. To keep the behavior as close as possible to what it was before, I still advance the data->bytes_xfered and sgm->consumed values by the requested transfer size for single-block read/write, but advance them by the actually copied number of bytes for the partial transfers in the multi-block requests. Cc: Geert Uytterhoeven <geert+renesas@glider.be> Fixes: 4d4a2c7 ("mmc: sh_mmcif: Advance sg_miter before reading blocks") Cc: stable@vger.kernel.org Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Linus Walleij <linusw@kernel.org> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Ulf Hansson <ulfh@kernel.org>
Among the different device id structures <linux/virtio_pci_legacy.h> only uses struct virtio_device_id. Include <linux/device-id/virtio.h> instead of <linux/mod_devicetable.h> to provide that which is more lightweight and doesn't introduce that many dependencies. The users of <linux/virtio_pci_legacy.h> also don't rely on this header to provide the full plethora of definitions. (There are only drivers/vdpa/alibaba/eni_vdpa.c and drivers/virtio/virtio_pci_common.c using pci_device_id and these include <linux/pci.h> which is enough to get it.) Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-ID: <fc69191474ffd49d50d7e39b13dfe6586f4d3f75.1783354857.git.u.kleine-koenig@baylibre.com>
The split ring indexes its avail and used rings with num - 1 as a mask, so its size must be a power of two. Commit 2a2d138 ("virtio: Add improved queue allocation API") moved that check from vring_new_virtqueue() into the new allocation path, which vring_new_virtqueue() does not use. remoteproc calls vring_new_virtqueue() with a ring size from the firmware, checked only to be non-zero. With 100 entries, for example, the driver would put buffers 4 and 8 in avail slot 0. The device would look for them at slots 4 and 8, possibly reading the wrong data. Put the check back for the split ring; the packed ring has no such restriction. Fixes: 2a2d138 ("virtio: Add improved queue allocation API") Signed-off-by: Stjepan Poljak <stjepan.poljak@gmail.com> Reviewed-by: Francesco Valla <francesco@valla.it> Tested-by: Francesco Valla <francesco@valla.it> # AM67A, rpmsg with R5F Acked-by: Eugenio Pérez <eperezma@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-ID: <20261112154927.4004184-2-stjepan.poljak@gmail.com>
… two vring_new_virtqueue() used to accept a split ring of any size, although the ring is indexed with num - 1 as a mask. Check that it now refuses one size short of RINGSIZE. Without the preceding fix, vringh_test fails with: vringh_test: vring_new_virtqueue accepted size 255 With it, vring_new_virtqueue() prints: Bad virtqueue length 255 (not a power of two) and the rest of the test runs as before. Signed-off-by: Stjepan Poljak <stjepan.poljak@gmail.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-ID: <20261112154927.4004184-3-stjepan.poljak@gmail.com>
vhost had a TODO to replace page pinning with a version of set_bit that works on userspace memory, since forever. It is really best to avoid GUP on fast path entirely. Implement set_bit_user and use it in vhost, to do just that. Should not be too hard for non-x86 too. Reported-by: Khan Zhao <zhaoguohan@kylinos.cn> Link: https://lore.kernel.org/all/20261112085631.128819-1-zhaoguohan@kylinos.cn/ Signed-off-by: Khan Zhao <zhaoguohan@kylinos.cn> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-ID: <20261117083323.89502-2-zhaoguohan@kylinos.cn>
Add vhost_log_test, which exercises used-ring dirty logging through the existing vhost_test module. It sets a log base with VHOST_SET_LOG_BASE, enables VHOST_VRING_F_LOG on the ring, submits descriptors and checks the resulting bitmap from userspace. No new kernel interface is needed. The test covers: - every bit in a byte, repeated sets, and neighbouring bytes being left untouched, including the last byte of a page followed by a PROT_NONE guard page - a used ring write that spans two log pages, with both bits in the same bitmap byte and in adjacent bytes - a log page that has not been faulted in yet, read-only, PROT_NONE and unmapped log pages, and logging after access is restored - private (COW) and shared file mappings, checking that the bit reaches the file after msync/fsync - eight vrings setting different bits of the same byte concurrently, with and without a userspace thread atomically fetching and clearing that byte - two shared mappings of one file page, one of them zapped with MADV_DONTNEED each round, so both resident and faulting pages are hit log_used() ignores errors from log_write(), so the fault cases can only check that nothing crashes, that nothing is written to an inaccessible log, and that logging works again afterwards. A --bench mode reports ns per descriptor with logging disabled and enabled. vhost_log_test.rst describes how to build and run the test. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Khan Zhao <zhaoguohan@kylinos.cn> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-ID: <20261117083323.89502-3-zhaoguohan@kylinos.cn>
vhost_workers_free() only waits for RCU readers when sync is true. Both vhost-net teardown paths pass false, relying on the assumption recorded when the sync parameter was introduced (5efd97e) that "net and scsi stop their virtqueues before the workers are freed". That assumption does not hold when a tap queue is detached while the socket is still attached. __tun_detach() runs tun_queue_purge() on the detaching thread, so skb_queue_purge() releases the zerocopy skbs and vhost_zerocopy_complete() -> vhost_poll_queue() runs there rather than on the vhost worker. The vhost_dev_flush() calls in vhost_net_flush() and vhost_dev_stop() only wait for the vhost workers, so the queueing can still be in flight when vhost_dev_cleanup() frees the worker, and vhost_worker_queue() then dereferences freed memory. Pass sync=true from vhost_net_release() and vhost_net_reset_owner() so a grace period and a flush are observed before the workers are released, matching the vsock RESET_OWNER path. Both are slow paths, and the extra grace period buys back the races described above. Testing: QEMU/KVM guest with KASAN and CONFIG_VHOST_NET, zerocopy enabled via vhost_net.experimental_zcopytx=1. A second thread detaches one of the tap queues and frees the queued skb, and vhost_worker_queue() is delayed with a fault-injection module so that the close() or the VHOST_RESET_OWNER ioctl completes in between. The delay only widens an existing window; the detach, the purge and the teardown are all unmodified upstream behaviour. Both teardown paths reproduce the use-after-free on this base, and both are clean with this change while the injection is still taken. The same injection reproduced on the earlier base where the analysis was done. Signed-off-by: Yaohan Li <shunsheng1218@gmail.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-ID: <20261117145314.1092372-1-shunsheng1218@gmail.com>
virtio_device_of_init() acquires the OF node reference once during device registration. virtio_dev_remove() currently puts it on each driver unbind, although rebinding the driver does not acquire a new reference. Repeated unbinds can therefore consume references not owned by the virtio device. Conversely, unregistering a device that never bound to a driver leaves the reference held. Move the put to unregister_virtio_device() so it is paired with device registration. Save the node pointer before device_unregister(), which can free the virtio device, and put it after unregister has completed the driver removal. Fixes: 694a111 ("virtio: Bind virtio device to device-tree node") Reported-by: sashiko-bot <sashiko-bot@kernel.org> Link: https://lore.kernel.org/all/sashiko-outbox-203883@kernel.org/ Cc: stable@vger.kernel.org Signed-off-by: Yige Jiang <yigejiang86@gmail.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Message-ID: <20261119085343.virtio-of-node-a02bd3cf522b@gmail.com>
According to the rts5139 staging driver, SD 1.x cards do not respond to SD_SEND_IF_COND. On an RTS5129, a preinserted 2 GB SD card times out on that command and the driver then rejects CMD55 and subsequent initialization requests with -ENOMEDIUM. This prevents MMC core from trying the legacy SD path. Do not suppress card detection on a timeout from a no-data CMD8. MMC SEND_EXT_CSD uses the same opcode with a data transfer, so retain the existing timeout handling for that command. Keep refreshing the physical card state and retain suppression on other discovery timeouts to stop repeated probes of an empty tray. Fixes: 7185b6d ("mmc: rtsx_usb_sdmmc: suppress false CD after init timeout") Cc: stable@vger.kernel.org Reported-by: Philipp Jonas <pjjonas@web.de> Closes: https://lore.kernel.org/r/523eb7d1cc0811df4a5e4c534538f3dd@web.de Tested-by: Philipp Jonas <pjjonas@web.de> Signed-off-by: Sean Rhodes <sean@starlabs.systems> Signed-off-by: Ulf Hansson <ulfh@kernel.org>
The DMA preparation path shortens the final scatterlist entry to reserve space for FIFO drain words. If DMA mapping or descriptor preparation fails, the request falls back to PIO, but the shortened scatterlist entry is left unchanged. As a result, the PIO transfer may omit part of the data, potentially causing corrupted or incomplete I/O. Restore the entry's original length and clear drain_words before returning to the fallback path. This issue was found while investigating a kernel panic on my Raspberry Pi server. Fixes: 660fc73 ("mmc: bcm2835: Add new driver for the sdhost controller.") Cc: stable@vger.kernel.org Signed-off-by: Artem Novak <artem122novak@gmail.com> Reviewed-by: Stefan Wahren <wahrenst@gmx.net> Signed-off-by: Ulf Hansson <ulfh@kernel.org>
Qualcomm clock fixes for v7.4 Fix Glymur GCC power domain handling for PCIe and USB. - Use collapse voting for PCIe and PCIe PHY power domains shared with other masters, including domains enabled by boot firmware. - Retain USB and USB PHY power domains to preserve configuration and fix USB host controller resume from suspend. * tag 'qcom-clk-fixes-for-7.4': clk: qcom: gcc-glymur: use collapse-voting for PCIe GDSCs clk: qcom: gcc-glymur: Use PWRSTS_RET_ON flag for USB GDSCs
…t/mst/vhost Pull virtio fixes from Michael Tsirkin: "Just a bunch of small fixes all over the place. Nothing stands out much. A new test in tools - given we had a bunch of issues around logging discovered recently, seems prudent to just include it" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: virtio: Release the OF node when unregistering the device vhost: synchronize worker freeing on vhost-net teardown tools/virtio: add a vhost dirty log test vhost: set dirty log bits without pinning pages on x86 tools/virtio: vringh_test: check that a split ring must be a power of two virtio_ring: reject a split ring size that is not a power of two again virtio-pci: Drop inclusion of <linux/mod_devicetable.h> virtio_balloon: drain update works on probe error paths virtio_console: defer HVC polling out of the virtqueue callback virtio_ring: return an error pointer from vring_create_virtqueue() tools/virtio/virtio_test: advance next_reset by reset_n, not completed tools/virtio/virtio-trace: fix swapped read/write label in path error vhost-scsi: use FOLL_PIN for DMA page pinning vhost: Run TIF_NOTIFY_RESUME work in the vhost_task loop vdpa/mlx5: Don't free QP buffers if destroying the QP fails virtio-mem: only mark the device ready in kdump mode with vmcore support
…linux/kernel/git/clk/linux
Pull clk fixes from Brian Masney:
"Qualcomm Glymur GCC:
- Use collapse voting for PCIe and PCIe PHY power domains shared with
other masters, including domains enabled by boot firmware
- Retain USB and USB PHY power domains to preserve configuration and
fix USB host controller resume from suspend
Samsung Exynos:
- Properly handle deferred probe of the AudioSubsystem clock
controller
- Fix integration of clock controller and power domains on Exynos5250
and Exynos5420: be sure device runtime resumed before proceeding
with probe and defer probe till the power domain is available"
* tag 'clk-fixes-for-linus-v7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
clk: qcom: gcc-glymur: use collapse-voting for PCIe GDSCs
clk: qcom: gcc-glymur: Use PWRSTS_RET_ON flag for USB GDSCs
clk: samsung: exynos5-subcmu: Defer probe until power domains are available
clk: samsung: exynos5-subcmu: Use pm_runtime_get_sync() during probe
clk: samsung: exynos-audss: Propagate -EPROBE_DEFER from input clocks
…/kernel/git/pcmoore/selinux Pull selinux fixes from Paul Moore: "Two SELinux fixes: one tightens a size check in SELinux's labeled IPsec code, the other ensures that the source and destination port of network related SELinux audit denial records (commonly known as "AVC" records) are properly initialized" * tag 'selinux-pr-20261130' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux: selinux: reject a 65535-byte xfrm context that ctx_len cannot hold selinux: initialize sport/dport in __ad_net_init()
…nel/git/pcmoore/lsm Pull lsm fix from Paul Moore: "A single fix for the LSM framework to ensure that the security_inode_copy_up() error handling code properly cleans up after itself" * tag 'lsm-pr-20261130' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm: lsm: put the copy up creds when an LSM hook fails
…ernel/git/ulfh/linux-pm
Pull pmdomain fixes:
"pmdomain core:
- Wait for device link removals before dropping genpd->dev
- Clear states after freeing them
pmdomain providers:
- Fix some memory leaks and reference countings during probe/remove
- cpuidle-psci: Skip SET_SUSPEND_MODE when OSI is unsupported
- mediatek:
- Fix a couple problems in the probe error path
- Fix silent audio from premature sync_state for mt8183
- qcom: Don't clamp gfx and gmxc before sync_state for rpmhpd
- rockchip:
- Fix a couple problems in the probe error path
- Manage the RK3576 GPU domain supply"
* tag 'pmdomain-v7.4-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/linux-pm:
pmdomain: samsung: fix device node leak in exynos_pd_probe()
pmdomain: renesas: rcar-sysc: Fix CPG/MSTP node reference leak
pmdomain: imx8m-blk-ctrl: Remove the power notifier on probe failure
pmdomain: imx: gpcv2: Take a reference to each PGC node
pmdomain: rockchip: Roll back power-on when leaving idle fails
pmdomain: rockchip: switch off the subdomains of a regulator domain at probe
pmdomain: mediatek: Don't power cycle domains on probe deferral
pmdomain: core: clear states after freeing them
cpuidle: psci: Skip SET_SUSPEND_MODE when OSI is unsupported
pmdomain: rockchip: Only put clocks that have been successfully obtained
pmdomain: rockchip: Manage the RK3576 GPU domain supply
pmdomain: qcom: rpmhpd: don't clamp gfx and gmxc before sync_state
pmdomain: core: Wait for device link removals before dropping genpd->dev
pmdomain: mediatek: mt8183: Fix silent audio from premature sync_state
pmdomain: mediatek: Don't power off default-off domains in probe cleanup
pmdomain: imx: gpc: remove all initialized power domains
The function kvmalloc may call vmalloc under the hood even when used with GFP_ATOMIC. However, vmalloc uses naked spin locks so it must not be called if the caller already holds spin locks that can be used in hard or soft IRQ context. Use the heuristic irqs_disabled() || in_softirq() to detect such callers and prevent them from using vmalloc. Reported-by: Liam R. Howlett (Google) <liam@infradead.org> Fixes: c630767 ("mm: kvmalloc: add non-blocking support for vmalloc") Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
…period There is a race in the vma lookup and the vma freeing that can race object close against object execbuffer vma lookups. execbuffer2 and close on two threads can be raced, so the radix tree lookup and tryget in eb_lookup_vma can be raced against a freed vma. The rcu protection in the eb lookup doesn't help because we don't use rcu around the free path. This patch adds rcu protection around the vma destruction path. We could also probably use SLAB_TYPESAFE_BY_RCU but there may be other submarined vma races in other code that this might not fix, so let's just force the rcu on free. Cc: stable@vger.kernel.org Signed-off-by: Dave Airlie <airlied@redhat.com>
…m/kernel Pull drm fix from Dave Airlie: "An out of band pull request for an i915 rcu fix that I want to get into stable, so let's just make it get there faster. i915: - use rcu to free vma" * tag 'drm-fixes-2026-12-02' of https://gitlab.freedesktop.org/drm/kernel: i915/vma: use kfree_rcu to make sure vma are freed after a rcu grace period
…/git/mchehab/linux-media
Pull media fixes from Mauro Carvalho Chehab:
- two videobuf2 core fixes related to finish prepared buffers on mmap
lock and at VIDIOC_REMOVE_BUFS ioctl
- Intel iPU6:
- fix image height calculus
- address a race contition at ipu6-isys-video
- fix a return condition and print an error at klog if frame
descriptior is not found
- Check if firmware is started before close on suspend
- AMD ISP4:
- fix API mmap dequeue of progressive-only framebuffers
- fix bad lock issues affecting stream start logic
- fix for ivsc csi driver, addressing an issue affecting camera
support on Dell XPS 13 9340 when used with libcamera
* tag 'media/v7.4-3' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
media: amd: isp4: return capture buffers with V4L2_FIELD_NONE
media: amd: isp4: hold buf_list_lock while sending buffers at stream start
media: amd: isp4: fix self-deadlock in isp4sd_start_stream() error path
media: videobuf2: finish prepared buffers in VIDIOC_REMOVE_BUFS
media: intel/ipu6: clamp crop top offset in ipu6_isys_csi2_set_sel()
media: intel/ipu6: move busy check to ipu6_isys_vidioc_s_fmt_vid_cap()
media: ipu6: Tell about not being able to obtain frame descriptor
media: ivsc: csi: Add sensor node in bound callback
media: ipu6: Check firmware is started before close
media: videobuf2: publish buffers in bufs_bitmap under mmap_lock
…l/git/jarkko/linux-tpmdd Pull key fixes from Jarkko Sakkinen: - Synchronize key_instantiate_and_link() and key_reject_and_link() with unregister_key_type() using SRCU, so that a concurrent type removal does not fail on null deref - Call rcu_barrier() at module exit so that encrypted_rcu_free() and trusted_rcu_free() callbacks queued by ->update() cannot run in freed module memory - Return user_session directly instead of installing it into the task's credentials on a lookup without KEY_LOOKUP_CREATE, as mutating struct cred, as client subsystem will then end up having a stale struct cred - Reject KEY_LOOKUP_CREATE with -EPERM when the task runs with overridden credentials, instead of triggering BUG_ON() in commit_creds() * tag 'keys-v7.4-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd: KEYS: Reject keyring creation with overridden credentials KEYS: Return user session keyring on lookup KEYS: trusted: Wait for RCU callbacks before module unload KEYS: encrypted: Wait for RCU callbacks before module unload KEYS: Protect key instantiation and rejection against type removal
…el/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson:
"MMC core:
- Saturate erase timeout instead of overflowing
- Use GFP_NOIO for SD cache flush buffers
- Fix probing of SDIO functions on ACPI systems
- Mark the end of a truncated scatterlist
- Clear MQRQ_XFER_SINGLE_BLOCK for new requests
- Add ISSI IS22TF128G eMMC to fixed secure erase time quirk
MMC host:
- bcm2835: Restore scatterlist after DMA setup failure
- dw_mmc:
- Fix support for clk-phase in DT
- Fix races at remove
- mmci:
- Fix support for tuning for stm32
- Do not count a data CRC error as a complete transfer
- Reset and restore SDMMC state on system resume for stm32
- rtsx_usb_sdmmc: Allow legacy SD init after CMD8 timeout
- sdhci-pci-gli: GL9767: Wait for UHS-II wakeup before LPM
- sunxi: Report manual stop errors correctly
- sh_mmcif: Fixes for DMA and sg_miter handling
MEMSTICK:
- Remove the host ID after device_del()
- ms_block: Fix memory leaks and double free
- mspro_block:
- Wait for running dispatches
- Don't hand a finished request back to the host
- rtsx_usb_ms/r592: Fix races at remove"
* tag 'mmc-v7.4-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (27 commits)
mmc: bcm2835: restore scatterlist after DMA setup failure
mmc: rtsx_usb_sdmmc: allow legacy SD init after CMD8 timeout
mmc: sh_mmcif: rework sg_miter handling
mmc: core: use GFP_NOIO for SD cache flush buffers
mmc: mmc_test: Set "cnt" to the allocated size explicitly
mmc: dw_mmc: Read clk-phase DT settings earlier
mmc: core: saturate erase timeout instead of overflowing
mmc: add ISSI IS22TF128G to fixed secure erase time quirk
memstick: rtsx_usb_ms: disable poll_card work on removal
memstick: r592: shut down the detect timer on removal
memstick: core: Remove the host ID after device_del()
memstick: ms_block: don't erase the old block of an unmapped LBA
memstick: mspro_block: wait for running dispatches in mspro_block_stop()
memstick: mspro_block: don't hand a finished request back to the host
mmc: sdio: Set acpi_device.power.flags.ignore_parent flag on sdio_func companion
mmc: mmci: stm32: use the delay block above 100 MHz on stm32mp25 SoC
mmc: mmci: stm32: release the delay block before enabling it
mmc: mmci: do not count a data CRC error as a complete transfer
memstick: ms_block: fix double free in msb_ftl_initialize() error path
mmc: core: Mark the end of a truncated scatterlist
...
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.