6.6.160-rc1 review
Subsystems (12)
Greg Kroah-Hartman
maintainerPATCH 1020/1674 tools: ynl: extend netdev sample to dump xdp-rx-metadata-features
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislav Fomichev <[email protected]>
[ Upstream commit 0c6c9b105ee90d7415dc796bcf632147b3d267ce ]
The tool can be used to verify that everything works end to end.
Unrelated updates:
- include tools/include/uapi to pick the latest kernel uapi headers
- print "xdp-features" and "xdp-rx-metadata-features" so it's clear which bitmask is being dumped
Stable-dep-of: b69004f5a6ad ("net/mlx5e: xsk: Fix DMA and xdp_frame leak on XDP_TX xmit failure")
--- tools/net/ynl/generated/netdev-user.c | 19 +++++++++++++++++++ tools/net/ynl/generated/netdev-user.h | 3 +++ tools/net/ynl/samples/Makefile | 2 +- tools/net/ynl/samples/netdev.c | 8 +++++++- 4 files changed, 30 insertions(+), 2 deletions(-)
tools/net/ynl/generated/netdev-user.c +19 -0
@@ -45,12 +45,26 @@ const char *netdev_xdp_act_str(enum netdev_xdp_act value)return netdev_xdp_act_strmap[value]; } +static const char *const netdev_xdp_rx_metadata_strmap[] = { + [0 ] ="timestamp" , + [1 ] ="hash" , +}; + +const char *netdev_xdp_rx_metadata_str (enum netdev_xdp_rx_metadata value) +{ + value =ffs (value) -1 ; +if (value <0 || value >= (int )MNL_ARRAY_SIZE (netdev_xdp_rx_metadata_strmap)) +return NULL ; +return netdev_xdp_rx_metadata_strmap[value]; +} +/* Policies */ struct ynl_policy_attr netdev_dev_policy[NETDEV_A_DEV_MAX +1 ] = { [NETDEV_A_DEV_IFINDEX ] = { .name ="ifindex" , .type =YNL_PT_U32 , }, [NETDEV_A_DEV_PAD ] = { .name ="pad" , .type =YNL_PT_IGNORE , }, [NETDEV_A_DEV_XDP_FEATURES ] = { .name ="xdp-features" , .type =YNL_PT_U64 , }, [NETDEV_A_DEV_XDP_ZC_MAX_SEGS ] = { .name ="xdp-zc-max-segs" , .type =YNL_PT_U32 , }, + [NETDEV_A_DEV_XDP_RX_METADATA_FEATURES ] = { .name ="xdp-rx-metadata-features" , .type =YNL_PT_U64 , }, };struct ynl_policy_nest netdev_dev_nest = {
@@ -97,6 +111,11 @@ int netdev_dev_get_rsp_parse(const struct nlmsghdr *nlh, void *data)return MNL_CB_ERROR ; dst->_present.xdp_zc_max_segs =1 ; dst->xdp_zc_max_segs =mnl_attr_get_u32 (attr); + }else if (type ==NETDEV_A_DEV_XDP_RX_METADATA_FEATURES ) { +if (ynl_attr_validate (yarg, attr)) +return MNL_CB_ERROR ; + dst->_present.xdp_rx_metadata_features =1 ; + dst->xdp_rx_metadata_features =mnl_attr_get_u64 (attr); } }
tools/net/ynl/generated/netdev-user.h +3 -0
@@ -18,6 +18,7 @@ extern const struct ynl_family ynl_netdev_family;/* Enums */ const char *netdev_op_str (int op);const char *netdev_xdp_act_str (enum netdev_xdp_act value); +const char *netdev_xdp_rx_metadata_str (enum netdev_xdp_rx_metadata value);/* Common nested types */ /* ============== NETDEV_CMD_DEV_GET ============== */
@@ -48,11 +49,13 @@ struct netdev_dev_get_rsp { __u32 ifindex:1; __u32 xdp_features:1; __u32 xdp_zc_max_segs:1; + __u32 xdp_rx_metadata_features:1; } _present;__u32 ifindex;__u64 xdp_features;__u32 xdp_zc_max_segs; +__u64 xdp_rx_metadata_features; };void netdev_dev_get_rsp_free (struct netdev_dev_get_rsp *rsp);
tools/net/ynl/samples/Makefile +1 -1
@@ -4,7 +4,7 @@ include ../Makefile.deps CC=gcc CFLAGS=-std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \ - -I../lib/ -I../generated/ -idirafter $(UAPI_PATH) + -I../../../include/uapi -I../lib/ -I../generated/ -idirafter $(UAPI_PATH) ifeq ("$(DEBUG)","1") CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan endif
tools/net/ynl/samples/netdev.c +7 -1
@@ -32,12 +32,18 @@ static void netdev_print_device(struct netdev_dev_get_rsp *d, unsigned int op)if (!d->_present.xdp_features)return ; -printf ("%llx:" , d->xdp_features); +printf ("xdp-features (%llx):" , d->xdp_features);for (int i =0 ; d->xdp_features >1U << i; i++) {if (d->xdp_features & (1U << i))printf (" %s" ,netdev_xdp_act_str (1 << i)); } +printf (" xdp-rx-metadata-features (%llx):" , d->xdp_rx_metadata_features); +for (int i =0 ; d->xdp_rx_metadata_features >1U << i; i++) { +if (d->xdp_rx_metadata_features & (1U << i)) +printf (" %s" ,netdev_xdp_rx_metadata_str (1 << i)); + } +printf (" xdp-zc-max-segs=%u" , d->xdp_zc_max_segs); name =netdev_op_str (op);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1021/1674 net/mlx5e: xsk: Fix DMA and xdp_frame leak on XDP_TX xmit failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dragos Tatulea <[email protected]>
[ Upstream commit b69004f5a6ad32da84d8aa5b23b9c0caafe6252e ]
In the XSK branch of mlx5e_xmit_xdp_buff(), when sq->xmit_xdp_frame() returns false (e.g. XDPSQ is full), the function returns without unmapping the DMA address or freeing the xdp_frame allocated by xdp_convert_zc_to_xdp_frame(). The xdpi_fifo push only happens on success, so the completion path cannot recover these entries.
With CONFIG_DMA_API_DEBUG=y, the leak surfaces on driver unbind:
DMA-API: pci 0000:08:00.0: device driver has pending DMA allocations while released from device [count=1116]
One of leaked entries details: [device address=0x000000010ffd7028] [size=1534 bytes] [mapped with DMA_TO_DEVICE] [mapped as phy]
WARNING: kernel/dma/debug.c:881 at dma_debug_device_change+0x127/0x180 ... DMA-API: Mapped at: debug_dma_map_phys+0x4b/0xd0 dma_map_phys+0xfd/0x2d0 mlx5e_xdp_handle+0x5ae/0xac0 [mlx5_core] mlx5e_xsk_skb_from_cqe_mpwrq_linear+0xc4/0x170 [mlx5_core] mlx5e_handle_rx_cqe_mpwrq+0xc1/0x290 [mlx5_core]
Add the missing unmap + xdp_return_frame, matching the cleanup already done in mlx5e_xdp_xmit(). has_frags is rejected earlier in this branch, so no per-frag unmap is needed.
--- drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +8 -2
@@ -102,9 +102,15 @@ mlx5e_xmit_xdp_buff(struct mlx5e_xdpsq *sq, struct mlx5e_rq *rq, xdptxd->dma_addr = dma_addr; -if (unlikely (!INDIRECT_CALL_2 (sq->xmit_xdp_frame, mlx5e_xmit_xdp_frame_mpwqe, - mlx5e_xmit_xdp_frame, sq, xdptxd,0 ))) +if (unlikely (!INDIRECT_CALL_2 (sq->xmit_xdp_frame, + mlx5e_xmit_xdp_frame_mpwqe, + mlx5e_xmit_xdp_frame, + sq, xdptxd,0 ))) { +dma_unmap_single (sq->pdev, dma_addr, xdptxd->len, +DMA_TO_DEVICE ); +xdp_return_frame (xdpf);return false; + }/* xmit_mode == MLX5E_XDP_XMIT_MODE_FRAME */ mlx5e_xdpi_fifo_push(&sq->db.xdpi_fifo,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1022/1674 wifi: fix leak if split 6 GHz scanning fails
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
[ Upstream commit e8694f7cc29287e843648d1075177b9a2000d957 ]
rdev->int_scan_req is leaked if cfg80211_scan() fails. Note that it's supposed to be released at ___cfg80211_scan_done() but this doesn't happen as rdev->scan_req is NULL at that point, too, leading to the early return from the freeing function.
unreferenced object 0xffff8881161d0800 (size 512):
comm "wpa_supplicant", pid 379, jiffies 4294749765 hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 f0 81 13 16 81 88 ff ff ................
backtrace (crc c867fdb6):
kmemleak_alloc+0x89/0x90
__kmalloc_noprof+0x2fd/0x410
cfg80211_scan+0x133/0x730
nl80211_trigger_scan+0xc69/0x1cc0
genl_family_rcv_msg_doit+0x204/0x2f0
genl_rcv_msg+0x431/0x6b0
netlink_rcv_skb+0x143/0x3f0
genl_rcv+0x27/0x40
netlink_unicast+0x4f6/0x820
netlink_sendmsg+0x797/0xce0
__sock_sendmsg+0xc4/0x160
____sys_sendmsg+0x5e4/0x890
___sys_sendmsg+0xf8/0x180
__sys_sendmsg+0x136/0x1e0
__x64_sys_sendmsg+0x76/0xc0
x64_sys_call+0x13f0/0x17d0Found by Linux Verification Center (linuxtesting.org).
--- net/wireless/scan.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
net/wireless/scan.c +8 -1
@@ -1028,6 +1028,7 @@ int cfg80211_scan(struct cfg80211_registered_device *rdev)struct cfg80211_scan_request *request;struct cfg80211_scan_request *rdev_req = rdev->scan_req;u32 n_channels =0 , idx, i; +int err;if (!(rdev->wiphy.flags &WIPHY_FLAG_SPLIT_SCAN_6GHZ ))return rdev_scan (rdev, rdev_req);
@@ -1054,8 +1055,14 @@ int cfg80211_scan(struct cfg80211_registered_device *rdev) } rdev_req->scan_6ghz = false; + err =rdev_scan (rdev, request); +if (err) { +kfree (request); +return err; + } + rdev->int_scan_req = request; -return rdev_scan (rdev, request); +return 0 ; } void ___cfg80211_scan_done(struct cfg80211_registered_device *rdev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1023/1674 l2tp: pppol2tp: hold reference to session in pppol2tp_ioctl()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lee Jones <[email protected]>
[ Upstream commit a213a8950414c684999dcf03edeea6c46ede172e ]
pppol2tp_ioctl() read sock->sk->sk_user_data directly without any locks or reference counting. If a controllable sleep was induced during copy_from_user() (e.g. via a userfaultfd page fault sleep), a concurrent socket close could trigger pppol2tp_session_close() asynchronously. This frees the l2tp_session structure via the l2tp_session_del_work workqueue. Upon resuming, the ioctl thread dereferences the stale session pointer, resulting in a Use-After-Free (UAF).
Fix this by securely fetching the session reference using the RCU-safe, refcounted helper pppol2tp_sock_to_session(sk) on entry. This locks the session's refcount across the sleep. We structured the function to exit via standard err breaks, guaranteeing that l2tp_session_put() is cleanly called on all return paths to drop the reference.
To preserve existing behavior we validate the session and its magic signature only for the specific L2TP commands that require it. This ensures that generic/unknown ioctls called on an unconnected socket still return -ENOIOCTLCMD and correctly fall back to generic handlers (e.g. in sock_do_ioctl()).
--- net/l2tp/l2tp_ppp.c | 82 +++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 32 deletions(-)
net/l2tp/l2tp_ppp.c +50 -32
@@ -1056,64 +1056,76 @@ static int pppol2tp_ioctl(struct socket *sock, unsigned int cmd, {struct pppol2tp_ioc_stats stats;struct l2tp_session *session; +int err =0 ; + + session =pppol2tp_sock_to_session (sock->sk); +/* Validate session presence and magic integrity ONLY for commands +* that belong to L2TP and require a valid session. +*/ switch (cmd) {case PPPIOCGMRU :case PPPIOCGFLAGS : - session = sock->sk->sk_user_data; +case PPPIOCSMRU : +case PPPIOCSFLAGS : +case PPPIOCGL2TPSTATS :if (!session)return -ENOTCONN ; -if (WARN_ON (session->magic !=L2TP_SESSION_MAGIC )) +if (session->magic !=L2TP_SESSION_MAGIC ) { +sock_put (sock->sk);return -EBADF ; + } +break ; +default : +break ; + } +switch (cmd) { +case PPPIOCGMRU : +case PPPIOCGFLAGS :/* Not defined for tunnels */ -if (!session->session_id && !session->peer_session_id) -return -ENOSYS ; +if (!session->session_id && !session->peer_session_id) { + err = -ENOSYS ; +break ; + } -if (put_user (0 , (int __user *)arg)) -return -EFAULT ; +if (put_user (0 , (int __user *)arg)) { + err = -EFAULT ; +break ; + }break ;case PPPIOCSMRU :case PPPIOCSFLAGS : - session = sock->sk->sk_user_data; -if (!session) -return -ENOTCONN ; - -if (WARN_ON (session->magic !=L2TP_SESSION_MAGIC )) -return -EBADF ; -/* Not defined for tunnels */ -if (!session->session_id && !session->peer_session_id) -return -ENOSYS ; +if (!session->session_id && !session->peer_session_id) { + err = -ENOSYS ; +break ; + } -if (!access_ok ((int __user *)arg,sizeof (int ))) -return -EFAULT ; +if (!access_ok ((int __user *)arg,sizeof (int ))) { + err = -EFAULT ; +break ; + }break ;case PPPIOCGL2TPSTATS : - session = sock->sk->sk_user_data; -if (!session) -return -ENOTCONN ; - -if (WARN_ON (session->magic !=L2TP_SESSION_MAGIC )) -return -EBADF ; -/* Session 0 represents the parent tunnel */ if (!session->session_id && !session->peer_session_id) {u32 session_id; -int err;if (copy_from_user (&stats, (void __user *)arg, -sizeof (stats))) -return -EFAULT ; +sizeof (stats))) { + err = -EFAULT ; +break ; + } session_id = stats.session_id; err =pppol2tp_tunnel_copy_stats (&stats, session->tunnel);if (err <0 ) -return err; +break ; stats.session_id = session_id; }else {
@@ -1123,15 +1135,21 @@ static int pppol2tp_ioctl(struct socket *sock, unsigned int cmd, stats.tunnel_id = session->tunnel->tunnel_id; stats.using_ipsec =l2tp_tunnel_uses_xfrm (session->tunnel); -if (copy_to_user ((void __user *)arg, &stats,sizeof (stats))) -return -EFAULT ; +if (copy_to_user ((void __user *)arg, &stats,sizeof (stats))) { + err = -EFAULT ; +break ; + }break ;default : -return -ENOIOCTLCMD ; + err = -ENOIOCTLCMD ; +break ; } -return 0 ; +if (session) +sock_put (sock->sk); + +return err; }/*****************************************************************************
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1024/1674 btrfs: only release the dirty pages io tree after successful writes
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit 4066c55e109475a06d18a1f127c939d551211956 ]
[WARNING]
With extra warning on dirty extent buffers at umount (aka, the next patch in the series), test case generic/388 can trigger the following warning about dirty extent buffers at unmount time:
BTRFS critical (device dm-2 state E): emergency shutdown
BTRFS error (device dm-2 state E): error while writing out transaction: -30
BTRFS warning (device dm-2 state E): Skipping commit of aborted transaction.
BTRFS error (device dm-2 state EA): Transaction 9 aborted (error -30)
BTRFS: error (device dm-2 state EA) in cleanup_transaction:2068: errno=-30 Readonly filesystem BTRFS info (device dm-2 state EA): forced readonly
BTRFS info (device dm-2 state EA): last unmount of filesystem 4fbf2e15-f941-49a0-bc7c-716315d2777c
------------[ cut here ]------------ WARNING: disk-io.c:3311 at invalidate_and_check_btree_folios+0xfd/0x1ca [btrfs], CPU#8: umount/914368 CPU: 8 UID: 0 PID: 914368 Comm: umount Tainted: G OE 7.1.0-rc1-custom+ #372 PREEMPT(full) 2de38db8d1deae71fde295430a0ff3ab98ccf596 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 02/02/2022 RIP: 0010:invalidate_and_check_btree_folios+0xfd/0x1ca [btrfs] Call Trace: <TASK> close_ctree+0x52e/0x574 [btrfs d2f0b1cd330d1287e7a9919d112eadfc0e914efd] generic_shutdown_super+0x89/0x1a0 kill_anon_super+0x16/0x40 btrfs_kill_super+0x16/0x20 [btrfs d2f0b1cd330d1287e7a9919d112eadfc0e914efd] deactivate_locked_super+0x2d/0xb0 cleanup_mnt+0xdc/0x140 task_work_run+0x5a/0xa0 exit_to_user_mode_loop+0x123/0x4b0 do_syscall_64+0x243/0x7c0 entry_SYSCALL_64_after_hwframe+0x4b/0x53 </TASK> ---[ end trace 0000000000000000 ]--- BTRFS warning (device dm-2 state EA): unable to release extent buffer 30539776 owner 9 gen 9 refs 2 flags 0x7 BTRFS warning (device dm-2 state EA): unable to release extent buffer 30621696 owner 257 gen 9 refs 2 flags 0x7 BTRFS warning (device dm-2 state EA): unable to release extent buffer 30638080 owner 258 gen 9 refs 2 flags 0x7 BTRFS warning (device dm-2 state EA): unable to release extent buffer 30654464 owner 7 gen 9 refs 2 flags 0x7 BTRFS warning (device dm-2 state EA): unable to release extent buffer 30703616 owner 2 gen 9 refs 2 flags 0x7 BTRFS warning (device dm-2 state EA): unable to release extent buffer 30720000 owner 10 gen 9 refs 2 flags 0x7 BTRFS warning (device dm-2 state EA): unable to release extent buffer 30736384 owner 4 gen 9 refs 2 flags 0x7 BTRFS warning (device dm-2 state EA): unable to release extent buffer 30752768 owner 11 gen 9 refs 2 flags 0x7
I'm using a stripped down version, which seems to trigger the warning more reliably:
_fsstress_pid=""
workload()
{
dmesg -C
mkfs.btrfs -f -K $dev > /dev/null
echo 1 > /sys/kernel/debug/clear_warn_once
mount $dev $mnt
$fsstress -w -n 1024 -p 4 -d $mnt &
_fsstress_pid=$!
sleep 0
$godown $mnt
pkill --echo -PIPE fsstress > /dev/null
wait $_fsstress_pid
unset _fsstress_pid
umount $mnt if dmesg | grep -q "WARNING"; then
fail
fi
}
for (( i = 0; i < $runtime; i++ )); do
echo "=== $i/$runtime ==="
workload
done
[CAUSE]
Inside btrfs_write_and_wait_transaction(), we first try to write all dirty ebs, then wait for them to finish.
After that we call btrfs_extent_io_tree_release() to free all extent states from dirty_pages io tree.
However if we hit an error from btrfs_write_marked_extent(), then we still call btrfs_extent_io_tree_release() to clear that dirty_pages io tree, which may contain dirty records that we haven't yet submitted.
Furthermore, the later transaction cleanup path will utilize that dirty_pages io tree to properly cleanup those dirty ebs, but since it's already empty, no dirty ebs are properly cleaned up, thus will later trigger the warnings inside invalidate_btree_folios().
[FIX]
Normally such dirty ebs won't cause problems, as when the iput() is called on the btree inode, the dirty ebs will be forcibly written back, and since the fs is already in an error status, such writeback will not reach disk and finish immediately.
But it's still better to get rid of such dirty ebs, if we ended up with dirty ebs but the fs is not in an error status, then such writeback at iput() time will be too late, as all workers are already stopped but writeback will utilize workers, which will lead to NULL pointer dereferences.
Instead of unconditionally calling btrfs_extent_io_tree_release(), only call it if btrfs_write_and_wait_transaction() finished successfully, so that @dirty_pages extent io tree is kept untouched for transaction cleanup.
--- fs/btrfs/disk-io.c | 1 + fs/btrfs/transaction.c | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-)
fs/btrfs/disk-io.c +1 -0
@@ -4795,6 +4795,7 @@ static void btrfs_destroy_marked_extents(struct btrfs_fs_info *fs_info,free_extent_buffer_stale (eb); } } +extent_io_tree_release (dirty_pages); } static void btrfs_destroy_pinned_extent(struct btrfs_fs_info *fs_info,
fs/btrfs/transaction.c +4 -5
@@ -1241,14 +1241,13 @@ static int btrfs_write_and_wait_transaction(struct btrfs_trans_handle *trans)blk_finish_plug (&plug); ret2 =btrfs_wait_extents (fs_info, dirty_pages); -extent_io_tree_release (&trans->transaction->dirty_pages); -if (ret)return ret; -else if (ret2) +if (ret2)return ret2; -else -return 0 ; + +extent_io_tree_release (&trans->transaction->dirty_pages); +return 0 ; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1025/1674 net: phonet: do not BUG_ON() in pn_socket_autobind() on failed bind
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Morduan Zang <[email protected]>
[ Upstream commit 5b0c911bcdbd982f7748d11c0b39ec5808eae2de ]
syzbot reported a kernel BUG triggered from pn_socket_sendmsg() via pn_socket_autobind():
kernel BUG at net/phonet/socket.c:213!
RIP: 0010:pn_socket_autobind net/phonet/socket.c:213 [inline] RIP: 0010:pn_socket_sendmsg+0x240/0x250 net/phonet/socket.c:421 Call Trace: sock_sendmsg_nosec+0x112/0x150 net/socket.c:797 __sock_sendmsg net/socket.c:812 [inline] __sys_sendto+0x402/0x590 net/socket.c:2280 ...
pn_socket_autobind() calls pn_socket_bind() with port 0 and, on -EINVAL, assumes the socket was already bound and asserts that the port is non-zero:
err = pn_socket_bind(sock, ..., sizeof(struct sockaddr_pn));
if (err != -EINVAL)
return err;
BUG_ON(!pn_port(pn_sk(sock->sk)->sobject));
return 0; /* socket was already bound */However pn_socket_bind() also returns -EINVAL when sk->sk_state is not TCP_CLOSE, even when the socket has never been bound and pn_port() is still 0. In that case the BUG_ON() fires and panics the kernel from a user-triggerable path.
Treat the "bind returned -EINVAL but pn_port() is still 0" case as a regular error and propagate -EINVAL to the caller instead of crashing. Existing callers already translate a non-zero return from pn_socket_autobind() into -ENOBUFS/-EAGAIN, so returning -EINVAL here only changes behaviour from panic to a normal errno.
--- net/phonet/socket.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/phonet/socket.c +8 -2
@@ -208,9 +208,15 @@ static int pn_socket_autobind(struct socket *sock) sa.spn_family =AF_PHONET ; err =pn_socket_bind (sock, (struct sockaddr *)&sa,sizeof (struct sockaddr_pn )); -if (err != -EINVAL ) +/* +* pn_socket_bind() also returns -EINVAL when sk_state != TCP_CLOSE +* without a prior bind, so -EINVAL alone is not sufficient to infer +* that the socket was already bound. Only treat it as "already +* bound" when the port is non-zero; otherwise propagate the error +* instead of crashing the kernel. +*/ +if (err != -EINVAL ||unlikely (!pn_port (pn_sk (sock->sk)->sobject)))return err; -BUG_ON (!pn_port (pn_sk (sock->sk)->sobject));return 0 ;/* socket was already bound */ }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1026/1674 net: mana: Guard mana_remove against double invocation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Erni Sri Satya Vennela <[email protected]>
[ Upstream commit 50271d7ec95144d26808025b508f463780517d3c ]
If PM resume fails (e.g., mana_attach() returns an error), mana_probe() calls mana_remove(), which tears down the device and sets gd->gdma_context = NULL and gd->driver_data = NULL.
However, a failed resume callback does not automatically unbind the driver. When the device is eventually unbound, mana_remove() is invoked a second time. Without a NULL check, it dereferences gc->dev with gc == NULL, causing a kernel panic.
Add an early return if gdma_context or driver_data is NULL so the second invocation is harmless. Move the dev = gc->dev assignment after the guard so it cannot dereference NULL.
--- drivers/net/ethernet/microsoft/mana/mana_en.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/microsoft/mana/mana_en.c +6 -1
@@ -2921,11 +2921,16 @@ void mana_remove(struct gdma_dev *gd, bool suspending) {struct gdma_context *gc = gd->gdma_context;struct mana_context *ac = gd->driver_data; -struct device *dev = gc->dev; +struct device *dev;struct net_device *ndev;int err;int i; +if (!gc || !ac) +return ; + + dev = gc->dev; +/* adev currently doesn't support suspending, always remove it */ if (gd->adev)remove_adev (gd);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1027/1674 drm/amd/display: Avoid NULL dereference in dc_dmub_srv error paths
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivasan Shanmugam <[email protected]>
[ Upstream commit 4ae3e16f4b3bf64140f773629b765d605ee079a9 ]
In dc_dmub_srv_log_diagnostic_data() anddc_dmub_srv_enable_dpia_trace().
Both functions check:
if (!dc_dmub_srv || !dc_dmub_srv->dmub)
and then call DC_LOG_ERROR() inside that block.
DC_LOG_ERROR() uses dc_dmub_srv->ctx internally. So if dc_dmub_srv is NULL, the logging itself can dereference a NULL pointer and cause a crash.
Fix this by splitting the checks.
First check if dc_dmub_srv is NULL and return immediately. Then check dc_dmub_srv->dmub and log the error only when dc_dmub_srv is valid.
Fixes the below:../display/dc/dc_dmub_srv.c:962 dc_dmub_srv_log_diagnostic_data() error: we previously assumed 'dc_dmub_srv' could be null (see line 961) ../display/dc/dc_dmub_srv.c:1167 dc_dmub_srv_enable_dpia_trace() error: we previously assumed 'dc_dmub_srv' could be null (see line 1166)
--- drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c +8 -2
@@ -793,7 +793,10 @@ void dc_dmub_srv_log_diagnostic_data(struct dc_dmub_srv *dc_dmub_srv) {struct dmub_diagnostic_data diag_data = {0 }; -if (!dc_dmub_srv || !dc_dmub_srv->dmub) { +if (!dc_dmub_srv) +return ; + +if (!dc_dmub_srv->dmub) {DC_LOG_ERROR ("%s: invalid parameters." , __func__);return ; }
@@ -1034,7 +1037,10 @@ void dc_dmub_srv_enable_dpia_trace(const struct dc *dc)enum dmub_status status;static const uint32_t timeout_us =30 ; -if (!dc_dmub_srv || !dc_dmub_srv->dmub) { +if (!dc_dmub_srv) +return ; + +if (!dc_dmub_srv->dmub) {DC_LOG_ERROR ("%s: invalid parameters." , __func__);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1028/1674 wifi: mt76: mt7921: Place upper limit on station AID
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rory Little <[email protected]>
[ Upstream commit 4d0bf21e3e20619d51d06c0c36207aabab8b712c ]
Any station configured with an AID over 20 causes a firmware crash. This situation occurred in our testing using an AP interface on 7922 hardware, with a modified hostapd, sourced from Mediatek's OpenWRT feeds.
In stock hostapd, station AIDs begin counting at 1, and this configuration is prevented with an upper limit on associated stations. However, the modified hostapd began allocation at 65, which caused the firmware to crash. This fix does not allow these AIDs to work, but will prevent the firmware crash.
This crash was only seen on IFTYPE_AP interfaces, and the fix does not appear to have an effect on IFTYPE_STATION behavior.
--- drivers/net/wireless/mediatek/mt76/mt7921/main.c | 3 +++ drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h | 2 ++ 2 files changed, 5 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7921/main.c +3 -0
@@ -726,6 +726,9 @@ int mt7921_mac_sta_add(struct mt76_dev *mdev, struct ieee80211_vif *vif,struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv;int ret, idx; +if (sta->aid >MT7921_MAX_AID ) +return -ENOENT ; + idx =mt76_wcid_alloc (dev->mt76.wcid_mask, MT792x_WTBL_STA -1 );if (idx <0 )return -ENOSPC ;
drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +2 -0
@@ -7,6 +7,8 @@#include "../mt792x.h" #include "regs.h" +#define MT7921_MAX_AID 20 +#define MT7921_TX_RING_SIZE 2048#define MT7921_TX_MCU_RING_SIZE 256#define MT7921_TX_FWDL_RING_SIZE 128
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1029/1674 drm/amd/display: Fix out-of-bounds read in dp_get_eq_aux_rd_interval()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harry Wentland <[email protected]>
[ Upstream commit e8b4d37eba05141ee01794fc6b7f2da808cee83b ]
[Why & How]
The aux_rd_interval array in struct dc_lttpr_caps is declared with MAX_REPEATER_CNT - 1 (7) elements, indexed 0..6. However, the offset parameter passed to dp_get_eq_aux_rd_interval() can be as large as MAX_REPEATER_CNT (8) when a sink reports 8 LTTPR repeaters via DPCD. This leads to an out-of-bounds read of aux_rd_interval[7] when offset is 8.
Fix this by growing aux_rd_interval to MAX_REPEATER_CNT elements to accommodate the full range of valid repeater counts defined by the DP spec.
--- drivers/gpu/drm/amd/display/dc/dc_dp_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dc_dp_types.h +1 -1
@@ -1156,7 +1156,7 @@ struct dc_lttpr_caps {uint8_t max_ext_timeout;union dp_main_link_channel_coding_lttpr_cap main_link_channel_coding;union dp_128b_132b_supported_lttpr_link_rates supported_128b_132b_rates; -uint8_t aux_rd_interval[MAX_REPEATER_CNT -1 ]; +uint8_t aux_rd_interval[MAX_REPEATER_CNT ]; };struct dc_dongle_dfp_cap_ext {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1030/1674 drm/msm: always recover the gpu
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anna Maniscalco <[email protected]>
[ Upstream commit 01a0d6cd7032e9993feea19fadb03ef9d5b488f2 ]
Previously, in case there was no more work to do, recover worker wouldn't trigger recovery and would instead rely on the gpu going to sleep and then resuming when more work is submitted.
Recover_worker will first increment the fence of the hung ring so, if there's only one job submitted to a ring and that causes an hang, it will early out.
There's no guarantee that the gpu will suspend and resume before more work is submitted and if the gpu is in a hung state it will stay in that state and probably trigger a timeout again.
Just stop checking and always recover the gpu.
Patchwork: https://patchwork.freedesktop.org/patch/704066/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/msm_gpu.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-)
drivers/gpu/drm/msm/msm_gpu.c +14 -16
@@ -418,25 +418,23 @@ static void recover_worker(struct kthread_work *work)msm_update_fence (ring->fctx, fence); } -if (msm_gpu_active (gpu)) { -/* retire completed submits, plus the one that hung: */ -retire_submits (gpu); +/* retire completed submits, plus the one that hung: */ +retire_submits (gpu); - gpu->funcs->recover (gpu); + gpu->funcs->recover (gpu); -/* -* Replay all remaining submits starting with highest priority -* ring -*/ -for (i =0 ; i < gpu->nr_rings; i++) { -struct msm_ringbuffer *ring = gpu->rb[i]; -unsigned long flags; +/* +* Replay all remaining submits starting with highest priority +* ring +*/ +for (i =0 ; i < gpu->nr_rings; i++) { +struct msm_ringbuffer *ring = gpu->rb[i]; +unsigned long flags; -spin_lock_irqsave (&ring->submit_lock, flags); -list_for_each_entry (submit, &ring->submits, node) - gpu->funcs->submit (gpu, submit); -spin_unlock_irqrestore (&ring->submit_lock, flags); - } +spin_lock_irqsave (&ring->submit_lock, flags); +list_for_each_entry (submit, &ring->submits, node) + gpu->funcs->submit (gpu, submit); +spin_unlock_irqrestore (&ring->submit_lock, flags); }pm_runtime_put (&gpu->pdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1031/1674 fbdev: omap2: fix inconsistent lock returns in omapfb_mmap
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <[email protected]>
[ Upstream commit 98cf7df6e0844f7076df1db690c1ede9d69b61ff ]
Fix the warning about inconsistent returns for '&rg->lock' in omapfb_mmap() function. The warning arises because the error path uses 'ofbi->region' while the normal path uses 'rg'.
smatch warnings:drivers/video/fbdev/omap2/omapfb/omapfb-main.c:1126 omapfb_mmap()
warn: inconsistent returns '&rg->lock'.
Stable-dep-of: 7958e67375aa ("fbdev: omap2: fix use-after-free in omapfb_mmap")
--- drivers/video/fbdev/omap2/omapfb/omapfb-main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/omap2/omapfb/omapfb-main.c +1 -1
@@ -1119,7 +1119,7 @@ static int omapfb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)return 0 ; error: -omapfb_put_mem_region (ofbi->region); +omapfb_put_mem_region (rg);return r; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1032/1674 fbdev: omap2: fix use-after-free in omapfb_mmap
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <[email protected]>
[ Upstream commit 7958e67375aa111522086286bba13cfc0816ce8d ]
omapfb_mmap() has a race condition with OMAPFB_SETUP_PLANE ioctl that can lead to use-after-free:
The fb_mmap() entry point holds mm_lock but not lock (fb_info->lock), while ioctl handlers like OMAPFB_SETUP_PLANE hold lock but not mm_lock. This allows concurrent execution.
In omapfb_mmap():
1. rg = omapfb_get_mem_region(ofbi->region); // Get old region ref
2. start = omapfb_get_region_paddr(ofbi); // Read from NEW region
3. len = fix->smem_len; // Read from NEW region
4. vm_iomap_memory(vma, start, len); // Map NEW region memory
5. atomic_inc(&rg->map_count); // Increment OLD region!
Concurrently, OMAPFB_SETUP_PLANE can:
- Reassign ofbi->region = new_rg
- Update fix->smem_len
- OMAPFB_SETUP_MEM then checks NEW region's map_count (0!) and frees it
This leaves userspace with a mapping to freed physical memory.
The fix is to read all required values (start, len) from the same region reference (rg) that will have its map_count incremented, preventing the region from being freed while still mapped.
--- drivers/video/fbdev/omap2/omapfb/omapfb-main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/video/fbdev/omap2/omapfb/omapfb-main.c +8 -1
@@ -1097,7 +1097,11 @@ static int omapfb_mmap(struct fb_info *fbi, struct vm_area_struct *vma) rg =omapfb_get_mem_region (ofbi->region); - start =omapfb_get_region_paddr (ofbi); +if (ofbi->rotation_type ==OMAP_DSS_ROT_VRFB ) + start = rg->vrfb.paddr[0 ]; +else + start = rg->paddr; + len = fix->smem_len; DBG("user mmap region start %lx, len %d, off %lx\n", start, len,
@@ -1107,6 +1111,8 @@ static int omapfb_mmap(struct fb_info *fbi, struct vm_area_struct *vma) vma->vm_ops = &mmap_user_ops; vma->vm_private_data = rg; +atomic_inc (&rg->map_count); + r =vm_iomap_memory (vma, start, len);if (r) goto error;
@@ -1119,6 +1125,7 @@ static int omapfb_mmap(struct fb_info *fbi, struct vm_area_struct *vma)return 0 ; error: +atomic_dec (&rg->map_count);omapfb_put_mem_region (rg);return r;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1033/1674 f2fs: read COW data with the original inode during atomic write
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Lobanov <[email protected]>
[ Upstream commit a41075acde0124d2f8a5f563068a5d63e8ffd57b ]
When updating an atomic-write file, f2fs_write_begin() may read the previously written data back from the COW inode:prepare_atomic_write_begin() locates the block in the COW inode and sets use_cow, and the read bio is then built with the COW inode:
f2fs_submit_page_read(use_cow ? F2FS_I(inode)->cow_inode : inode, ...);
and f2fs_grab_read_bio() decides whether to schedule fs-layer decryption (STEP_DECRYPT) for the bio based on that inode via fscrypt_inode_uses_fs_layer_crypto().
However, the folio being filled belongs to the original inode (folio->mapping->host == inode), and the data stored in the COW block was encrypted (or left as plaintext) using the original inode's context, not the COW inode's -- see f2fs_encrypt_one_page(), which keys off fio->page->mapping->host. fscrypt_decrypt_pagecache_blocks() likewise operates on folio->mapping->host.
The COW inode is created as a tmpfile in the parent directory and inherits its encryption policy from there. With test_dummy_encryption the newly created COW inode gets the dummy policy and becomes encrypted, while a pre-existing regular file -- created before the policy applied, e.g. already present in the on-disk image -- stays unencrypted. The read path then sets STEP_DECRYPT based on the encrypted COW inode and calls fscrypt_decrypt_pagecache_blocks() on a folio whose host (the unencrypted original inode) has a NULL ->i_crypt_info, dereferencing it:
Oops: general protection fault, probably for non-canonical address ... KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f] RIP: 0010:fscrypt_decrypt_pagecache_blocks+0xa0/0x310 Workqueue: f2fs_post_read_wq f2fs_post_read_work Call Trace: fscrypt_decrypt_bio+0x1eb/0x340 f2fs_post_read_work+0xba/0x140 process_one_work+0x91c/0x1a40 worker_thread+0x677/0xe90 kthread+0x2bc/0x3a0
The COW inode is only needed to locate the on-disk block, and that block address is already resolved into @blkaddr by prepare_atomic_write_begin() via __find_data_block(cow_inode, ...); f2fs_submit_page_read() then reads from that physical @blkaddr directly, so the inode argument only selects the post-read crypto context, not which block is fetched. Reading with @inode therefore returns the same (latest, not-yet-committed) COW data, while making both the fs-layer decryption decision and the inline crypto path use the correct (original inode's) key.
With the COW inode no longer used at the read site, the use_cow flag has no remaining consumer; drop it from f2fs_write_begin() and prepare_atomic_write_begin().
--- fs/f2fs/data.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
fs/f2fs/data.c +16 -11
@@ -3551,7 +3551,7 @@ static int __reserve_data_block(struct inode *inode, pgoff_t index,static int prepare_atomic_write_begin (struct f2fs_sb_info *sbi,struct page *page,loff_t pos,unsigned int len, -block_t *blk_addr,bool *node_changed,bool *use_cow) +block_t *blk_addr,bool *node_changed) {struct inode *inode = page->mapping->host;struct inode *cow_inode =F2FS_I (inode)->cow_inode;
@@ -3566,14 +3566,14 @@ static int prepare_atomic_write_begin(struct f2fs_sb_info *sbi,/* Look for the block in COW inode first */ err =__find_data_block (cow_inode, index, blk_addr); -if (err) { +if (err)return err; - }else if (__is_valid_data_blkaddr (*blk_addr)) { - *use_cow = true; + +if (__is_valid_data_blkaddr (*blk_addr))return 0 ; - }else if (*blk_addr ==NEW_ADDR ) { + +if (*blk_addr ==NEW_ADDR ) cow_has_reserved_block = true; - }if (is_inode_flag_set (inode,FI_ATOMIC_REPLACE )) goto reserve_block;
@@ -3606,7 +3606,6 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,struct page *page =NULL ;pgoff_t index = ((unsigned long long ) pos) >>PAGE_SHIFT ;bool need_balance = false; -bool use_cow = false;block_t blkaddr =NULL_ADDR ;int err =0 ;
@@ -3666,7 +3665,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,if (f2fs_is_atomic_file (inode)) err =prepare_atomic_write_begin (sbi, page, pos, len, - &blkaddr, &need_balance, &use_cow); + &blkaddr, &need_balance);else err =prepare_write_begin (sbi, page, pos, len, &blkaddr, &need_balance);
@@ -3706,9 +3705,15 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,f2fs_handle_error (sbi,ERROR_INVALID_BLKADDR ); goto fail; } - err =f2fs_submit_page_read (use_cow ? -F2FS_I (inode)->cow_inode : inode, page, - blkaddr,0 , true); +/* +* Although the block may be stored in the COW inode, the folio +* belongs to @inode and its data was encrypted (or not) using +* @inode's context (see f2fs_encrypt_one_page()). Read with +* @inode so the post-read decryption decision matches the +* folio's owner; otherwise an unencrypted @inode whose COW inode +* is encrypted hits a NULL ->i_crypt_info on decryption. +*/ + err =f2fs_submit_page_read (inode, page, blkaddr,0 , true);if (err) goto fail;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1034/1674 gcov: use atomic counter updates to fix concurrent access crashes
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Khorenko <[email protected]>
[ Upstream commit 56cb9b7d96b28a1173a510ab25354b6599ad3a33 ]
GCC's GCOV instrumentation can merge global branch counters with loop induction variables as an optimization. In inflate_fast(), the inner copy loops get transformed so that the GCOV counter value is loaded multiple times to compute the loop base address, start index, and end bound. Since GCOV counters are global (not per-CPU), concurrent execution on different CPUs causes the counter to change between loads, producing inconsistent values and out-of-bounds memory writes.
The crash manifests during IPComp (IP Payload Compression) processing when inflate_fast() runs concurrently on multiple CPUs:
BUG: unable to handle page fault for address: ffffd0a3c0902ffa RIP: inflate_fast+1431 Call Trace: zlib_inflate __deflate_decompress crypto_comp_decompress ipcomp_decompress [xfrm_ipcomp] ipcomp_input [xfrm_ipcomp] xfrm_input
At the crash point, the compiler generated three loads from the same global GCOV counter (__gcov0.inflate_fast+216) to compute base, start, and end for an indexed loop. Another CPU modified the counter between loads, making the values inconsistent - the write went 3.4 MB past a 65 KB buffer.
Add -fprofile-update=prefer-atomic to CFLAGS_GCOV at the global level in the top-level Makefile, guarded by a try-run compile test. The test compiles a minimal program with and without -fprofile-update=prefer-atomic using the full KBUILD_CFLAGS, then compares undefined symbols in the resulting object files. If prefer-atomic introduces new undefined references (such as __atomic_fetch_add_8 on i386 or __aarch64_ldadd8_relax on arm64 with outline-atomics), the flag is not added -- the kernel does not link against libatomic.
On architectures where GCC inlines 64-bit atomic counter updates (x86_64, s390, ...) the test passes and the flag is enabled, preventing the compiler from merging counters with loop induction variables and fixing the observed concurrent-access crash.
On architectures where the flag would introduce libatomic dependencies, it is silently omitted and behaviour is no worse than before this patch.
Move the CFLAGS_GCOV block from its original position (before the arch Makefile include) to after the core KBUILD_CFLAGS assignments but before the scripts/Makefile.gcc-plugins include. This placement ensures the try-run test sees arch-specific flags (-m32, -march=, -mno-outline-atomics) while avoiding GCC plugin flags (-fplugin=) that would break the test on clean builds when plugin shared objects do not yet exist.
--- Makefile | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
Makefile +21 -6
@@ -754,12 +754,6 @@ endif # KBUILD_EXTMOD # Defaults to vmlinux, but the arch makefile usually adds further targets all: vmlinux -CFLAGS_GCOV := -fprofile-arcs -ftest-coverage -ifdef CONFIG_CC_IS_GCC -CFLAGS_GCOV += -fno-tree-loop-im -endif -export CFLAGS_GCOV - # The arch Makefiles can override CC_FLAGS_FTRACE. We may also append it later. ifdef CONFIG_FUNCTION_TRACER CC_FLAGS_FTRACE := -pg
@@ -1007,6 +1001,27 @@ endif # Ensure compilers do not transform certain loops into calls to wcslen() KBUILD_CFLAGS += -fno-builtin-wcslen +CFLAGS_GCOV := -fprofile-arcs -ftest-coverage +ifdef CONFIG_CC_IS_GCC +CFLAGS_GCOV += -fno-tree-loop-im +# Use atomic counter updates to avoid concurrent-access crashes in GCOV. +# Only enable if -fprofile-update=prefer-atomic does not introduce new +# undefined symbols (e.g. libatomic calls that the kernel cannot link). +CFLAGS_GCOV += $(call try-run,\ + echo 'long long x; void f(void){x++;}' | \ + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -w -fprofile-arcs \ + -ftest-coverage -x c - -c -o "$$TMP.base" && \ + echo 'long long x; void f(void){x++;}' | \ + $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -w -fprofile-arcs \ + -ftest-coverage -fprofile-update=prefer-atomic \ + -x c - -c -o "$$TMP" && \ + $(NM) "$$TMP.base" | grep ' U ' > "$$TMP.ubase" || true ; \ + $(NM) "$$TMP" | grep ' U ' > "$$TMP.utest" || true ; \ + cmp -s "$$TMP.ubase" "$$TMP.utest",\ + -fprofile-update=prefer-atomic) +endif +export CFLAGS_GCOV + # change __FILE__ to the relative path from the srctree KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1035/1674 drm/amdgpu/vcn: set no_user_fence for VCN v4.0 enc ring
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yinjie Yao <[email protected]>
[ Upstream commit 51f694221047c84fa185be98210eb2c354ffb8c6 ]
VCN encoder and decoder rings do not support 64-bit user fence writes, reject CS submissions with user fences.
--- drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c +1 -0
@@ -1827,6 +1827,7 @@ static struct amdgpu_ring_funcs vcn_v4_0_unified_ring_vm_funcs = { .type = AMDGPU_RING_TYPE_VCN_ENC, .align_mask = 0x3f, .nop = VCN_ENC_CMD_NO_OP, + .no_user_fence = true, .get_rptr = vcn_v4_0_unified_ring_get_rptr, .get_wptr = vcn_v4_0_unified_ring_get_wptr, .set_wptr = vcn_v4_0_unified_ring_set_wptr,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1036/1674 drm/amdgpu: fix amdgpu_hmm_range_get_pages
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian König <[email protected]>
[ Upstream commit 962d684b5dc0741dcd93485d41b450de402d5592 ]
The notifier sequence must only be read once or otherwise we could work with invalid pages.
While at it also fix the coding style, e.g. drop the pre-initialized return value and use the common define for 2G range.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_hmm.c +7 -8
@@ -51,8 +51,6 @@#include "amdgpu_amdkfd.h" #include "amdgpu_hmm.h" -#define MAX_WALK_BYTE (2UL << 30) -/** * amdgpu_hmm_invalidate_gfx - callback to notify about mm change *
@@ -170,12 +168,13 @@ int amdgpu_hmm_range_get_pages(struct mmu_interval_notifier *notifier, void *owner, struct page **pages, struct hmm_range **phmm_range) { + const u64 max_bytes = SZ_2G;struct hmm_range *hmm_range; -unsigned long end;unsigned long timeout; -unsigned long i;unsigned long *pfns; -int r =0 ; +unsigned long end; +unsigned long i; +int r; hmm_range =kzalloc (sizeof (*hmm_range),GFP_KERNEL );if (unlikely (!hmm_range))
@@ -196,8 +195,9 @@ int amdgpu_hmm_range_get_pages(struct mmu_interval_notifier *notifier, end = start + npages *PAGE_SIZE ; hmm_range->dev_private_owner = owner; + hmm_range->notifier_seq =mmu_interval_read_begin (notifier); do { - hmm_range->end = min(hmm_range->start + MAX_WALK_BYTE, end); + hmm_range->end = min(hmm_range->start + max_bytes, end); pr_debug("hmm range: start = 0x%lx, end = 0x%lx", hmm_range->start, hmm_range->end);
@@ -208,7 +208,6 @@ int amdgpu_hmm_range_get_pages(struct mmu_interval_notifier *notifier, timeout = jiffies +msecs_to_jiffies (timeout); retry: - hmm_range->notifier_seq =mmu_interval_read_begin (notifier); r =hmm_range_fault (hmm_range);if (unlikely (r)) {/*
@@ -222,7 +221,7 @@ int amdgpu_hmm_range_get_pages(struct mmu_interval_notifier *notifier,if (hmm_range->end == end)break ; - hmm_range->hmm_pfns +=MAX_WALK_BYTE >>PAGE_SHIFT ; + hmm_range->hmm_pfns += max_bytes >>PAGE_SHIFT ; hmm_range->start = hmm_range->end;schedule (); }while (hmm_range->end < end);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1037/1674 KVM: SEV: Ignore Port I/O requests of length 0
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 3988bd2723de407ae90fa7a6f6029b4e60238c58 ]
Explicitly ignore Port I/O requests of length '0' (or count '0'), so that setting up the software scratch area (and other code) doesn't have to worry about underflowing the length, and to allow for WARNing on trying to configure the scratch area with len==0.
Message-ID: <[email protected]>
--- arch/x86/kvm/svm/sev.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/x86/kvm/svm/sev.c +8 -0
@@ -2987,6 +2987,11 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu) control->exit_info_1, control->exit_info_2); ret = -EINVAL ;break ; +case SVM_EXIT_IOIO : +if (!((control->exit_info_1 &SVM_IOIO_SIZE_MASK ) >>SVM_IOIO_SIZE_SHIFT )) +return 1 ; + + fallthrough;default : ret =svm_invoke_exit_handler (vcpu, exit_code); }
@@ -3007,6 +3012,9 @@ int sev_es_string_io(struct vcpu_svm *svm, int size, unsigned int port, int in)if (unlikely (check_mul_overflow (count, size, &bytes)))return -EINVAL ; +if (!bytes) +return 1 ; + r =setup_vmgexit_scratch (svm, in, bytes);if (r)return r;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1038/1674 usb: typec: tcpm: bound altmode_desc[] per iteration in svdm_consume_modes()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 3389c149c68c3fea61910ad5d34f7bf3bff44e32 ]
svdm_consume_modes() checks pmdata->altmodes against the array size once before the loop over the count, but forgot to check the bound at every point in the loop.
In the well-behaved SVDM discovery flow this is harmless because each of at most SVID_DISCOVERY_MAX SVIDs contributes at most MODE_DISCOVERY_MAX modes, exactly filling altmode_desc[ALTMODE_DISCOVERY_MAX]. But the CMDT_RSP_ACK handler in tcpm_pd_svdm() does not correlate an incoming ACK with any request the port actually sent. Once port->partner is set, an unsolicited Discover Modes ACK is consumed unconditionally. A broken or malicious port partner can therefore drive altmodes to ALTMODE_DISCOVERY_MAX - 1 via the normal flow, and then send one extra Discover Modes ACK with seven VDOs. Because the pre-loop check passes, the loop could then writes up to five entries past altmode_desc[]. For mode_data_prime the next field in struct tcpm_port is the partner_altmode[] pointer array, which then receives partner-chosen SVID/VDO bytes.
Move the bound check inside the loop so the array can never be indexed past ALTMODE_DISCOVERY_MAX regardless of how many VDOs the partner supplies or how the function was reached.
--- drivers/usb/typec/tcpm/tcpm.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +4 -5
@@ -1553,17 +1553,16 @@ static void svdm_consume_modes(struct tcpm_port *port, const u32 *p, int cnt)struct typec_altmode_desc *paltmode;int i; -if (pmdata->altmodes >=ARRAY_SIZE (port->partner_altmode)) { -/* Already logged in svdm_consume_svids() */ -return ; - } -if (pmdata->svid_index <0 || pmdata->svid_index >= pmdata->nsvids) {tcpm_log (port,"Invalid SVID index %d" , pmdata->svid_index);return ; }for (i =1 ; i < cnt; i++) { +if (pmdata->altmodes >=ALTMODE_DISCOVERY_MAX ) { +/* Already logged in svdm_consume_svids() */ +return ; + } paltmode = &pmdata->altmode_desc[pmdata->altmodes];memset (paltmode,0 ,sizeof (*paltmode));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1039/1674 usb: typec: tcpm: validate VDO count in Discover Identity ACK handlers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 8fbc349e8383125dd2d8de1c1e926279d398ab17 ]
Properly validate the count passed from a device when calling svdm_consume_identity() or svdm_consume_identity_sop_prime() as the device-controlled value could index off of the static arrays, which could leak data.
--- drivers/usb/typec/tcpm/tcpm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/typec/tcpm/tcpm.c +3 -0
@@ -1485,6 +1485,9 @@ static void svdm_consume_identity(struct tcpm_port *port, const u32 *p, int cnt)u32 vdo = p[VDO_INDEX_IDH ];u32 product = p[VDO_INDEX_PRODUCT ]; +if (cnt <=VDO_INDEX_PRODUCT ) +return ; +memset (&port->mode_data,0 ,sizeof (port->mode_data)); port->partner_ident.id_header = vdo;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1040/1674 Bluetooth: hci_sync: Set HCI_CMD_DRAIN_WORKQUEUE during device close
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heitor Alves de Siqueira <[email protected]>
[ Upstream commit 525daaea459fc215f432de1b8debbd9144bf97b0 ]
Since hci_dev_close_sync() can now be called during the reset path, we should also set HCI_CMD_DRAIN_WORKQUEUE. This avoids queuing timeouts while the hdev workqueue is being drained.
--- net/bluetooth/hci_sync.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/bluetooth/hci_sync.c +8 -0
@@ -5361,6 +5361,12 @@ int hci_dev_close_sync(struct hci_dev *hdev)bt_dev_dbg (hdev,"" ); +/* Set HCI_DRAIN_WORKQUEUE flag to prevent queuing work during +* reset/close. See hci_cmd_work() and handle_cmd_cnt_and_timer(). +*/ +hci_dev_set_flag (hdev,HCI_CMD_DRAIN_WORKQUEUE ); +synchronize_rcu (); +cancel_delayed_work (&hdev->power_off);cancel_delayed_work (&hdev->ncmd_timer);cancel_delayed_work (&hdev->le_scan_disable);
@@ -5379,6 +5385,7 @@ int hci_dev_close_sync(struct hci_dev *hdev)if (!test_and_clear_bit (HCI_UP , &hdev->flags)) {cancel_delayed_work_sync (&hdev->cmd_timer); +hci_dev_clear_flag (hdev,HCI_CMD_DRAIN_WORKQUEUE );return err; }
@@ -5479,6 +5486,7 @@ int hci_dev_close_sync(struct hci_dev *hdev)/* Clear flags */ hdev->flags &=BIT (HCI_RAW );hci_dev_clear_volatile_flags (hdev); +hci_dev_clear_flag (hdev,HCI_CMD_DRAIN_WORKQUEUE );memset (hdev->eir,0 ,sizeof (hdev->eir));memset (hdev->dev_class,0 ,sizeof (hdev->dev_class));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1041/1674 net/handshake: Drain pending requests at net namespace exit
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit ea5fe6a73ca57e5150b8a38b341aef2636eb72f0 ]
The arguments to list_splice_init() in handshake_net_exit() are reversed. The call moves the local empty "requests" list onto hn->hn_requests, leaving the local list empty, so the subsequent drain loop runs zero iterations. Pending handshake requests that had not yet been accepted are not torn down when the net namespace is destroyed; each one keeps a reference on a socket file and on the handshake_req allocation.
Pass the source and destination in the documented order (list_splice_init(list, head) moves list onto head) so the pending list is transferred to the local scratch list and drained through handshake_complete().
Fixing the splice direction exposes a list-corruption race. After the splice each req->hr_list still has non-empty link pointers, threading the stack-local scratch list rather than hn_requests. A concurrent handshake_req_cancel() -- for example, from sunrpc's TLS timeout on a kernel socket whose netns reference was not taken -- finds the request through the rhashtable, calls remove_pending(), and sees !list_empty(&req->hr_list). __remove_pending_locked() then list_del_init()s an entry off the scratch list while the drain iterates, corrupting it. The same call arriving after the drain loop has run list_del() on an entry hits LIST_POISON instead.
Have remove_pending() check HANDSHAKE_F_NET_DRAINING under hn_lock and report not-found when drain is in progress. The drain has already taken ownership; handshake_complete()'s existing test_and_set on HANDSHAKE_F_REQ_COMPLETED still arbitrates between drain and cancel for who calls the consumer's hp_done. Use list_del_init() rather than list_del() in the drain so req->hr_list does not carry LIST_POISON after drain releases the entry.
The DRAINING guard in remove_pending() makes cancel return false, but cancel still falls through to test_and_set_bit on HANDSHAKE_F_REQ_COMPLETED and drops the request's hr_file reference. Without another pin, if that is the last reference, sk_destruct frees the request while it is still linked on the drain loop's local list. Pin each request's hr_file under hn_lock before releasing the list, and drop that drain pin after the loop finishes with the request.
--- net/handshake/netlink.c | 10 ++++++++-- net/handshake/request.c | 15 ++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-)
net/handshake/netlink.c +8 -2
@@ -205,12 +205,17 @@ static void __net_exit handshake_net_exit(struct net *net)*/ spin_lock (&hn->hn_lock);set_bit (HANDSHAKE_F_NET_DRAINING , &hn->hn_flags); -list_splice_init (&requests, &hn->hn_requests); +list_splice_init (&hn->hn_requests, &requests); +list_for_each_entry (req, &requests, hr_list) +sock_hold (req->hr_sk);spin_unlock (&hn->hn_lock);while (!list_empty (&requests)) { +struct sock *sk; + req = list_first_entry(&requests, struct handshake_req, hr_list); -list_del (&req->hr_list); + sk = req->hr_sk; +list_del_init (&req->hr_list);/* * Requests on this list have not yet been
@@ -218,6 +223,7 @@ static void __net_exit handshake_net_exit(struct net *net)*/ handshake_complete (req, -ETIMEDOUT ,NULL ); +sock_put (sk); } }
net/handshake/request.c +10 -5
@@ -163,13 +163,16 @@ static void __remove_pending_locked(struct handshake_net *hn,* otherwise %false. * * If @req was on a pending list, it has not yet been accepted. +* Returns %false when the net namespace is draining; the drain +* loop has taken ownership of the pending list. */ static bool remove_pending (struct handshake_net *hn,struct handshake_req *req) {bool ret = false;spin_lock (&hn->hn_lock); -if (!list_empty (&req->hr_list)) { +if (!test_bit (HANDSHAKE_F_NET_DRAINING , &hn->hn_flags) && + !list_empty (&req->hr_list)) {__remove_pending_locked (hn, req); ret = true; }
@@ -259,18 +262,20 @@ int handshake_req_submit(struct socket *sock, struct handshake_req *req, goto out_unlock;if (!__add_pending_locked (hn, req)) goto out_unlock; + +/* Prevent socket release while a handshake request is pending */ +sock_hold (req->hr_sk);spin_unlock (&hn->hn_lock); ret =handshake_genl_notify (net, req->hr_proto, flags);if (ret) {trace_handshake_notify_err (net, req, req->hr_sk, ret); -if (remove_pending (hn, req)) +if (remove_pending (hn, req)) { +sock_put (req->hr_sk); goto out_err; + } } -/* Prevent socket release while a handshake request is pending */ -sock_hold (req->hr_sk); -trace_handshake_submit (net, req, req->hr_sk);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1042/1674 ethtool: rss: fix indir_table and hkey leak on get_rxfh failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Kicinski <[email protected]>
[ Upstream commit 266297692f97008ca48bc311775c087c59bd7fe3 ]
rss_prepare_get() allocates the indirection table and hash key buffer via rss_get_data_alloc(), then calls ops->get_rxfh() to populate them. If get_rxfh() fails, the function returns an error without freeing the allocation.
--- net/ethtool/rss.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/ethtool/rss.c +3 -1
@@ -94,8 +94,10 @@ rss_prepare_data(const struct ethnl_req_info *req_base, ret = ops->get_rxfh (dev, data->indir_table, data->hkey, &dev_hfunc); -if (ret) +if (ret) { +kfree (rss_config); goto out_ops; + } data->hfunc = dev_hfunc; out_ops:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1043/1674 cgroup/rstat: validate cpu before css_rstat_cpu() access
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qing Ming <[email protected]>
[ Upstream commit 8817005efbdfdf5d4e4814cb5dc52b53d12917d7 ]
css_rstat_updated() is exposed as a BPF kfunc and accepts a caller-provided cpu argument. The function uses cpu for per-cpu rstat lookups without checking whether it refers to a valid possible CPU.
A BPF iter/cgroup program with CAP_BPF and CAP_PERFMON can pass an invalid cpu value. On an unfixed UBSCAN_BOUNDS test kernel, cpu == 0x7fffffff triggers:
UBSAN: array-index-out-of-bounds in kernel/cgroup/rstat.c:31:9
index 2147483647 is out of range for type 'long unsigned int [64]'
Call Trace:
css_rstat_updated
bpf_iter_run_prog
cgroup_iter_seq_show
bpf_seq_readAdd cpu validation to the BPF-facing css_rstat_updated() kfunc and move the common implementation to __css_rstat_updated() for in-kernel callers.
--- block/blk-cgroup.c | 2 +- include/linux/cgroup.h | 1 + kernel/cgroup/rstat.c | 19 ++++++++++++++++--- mm/memcontrol.c | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-)
block/blk-cgroup.c +1 -1
@@ -2194,7 +2194,7 @@ void blk_cgroup_bio_start(struct bio *bio) }u64_stats_update_end_irqrestore (&bis->sync, flags); -cgroup_rstat_updated (blkcg->css.cgroup, cpu); +__cgroup_rstat_updated (blkcg->css.cgroup, cpu);put_cpu (); }
include/linux/cgroup.h +1 -0
@@ -690,6 +690,7 @@ static inline void cgroup_path_from_kernfs_id(u64 id, char *buf, size_t buflen)/* * cgroup scalable recursive statistics. */ +void __cgroup_rstat_updated (struct cgroup *cgrp,int cpu);void cgroup_rstat_updated (struct cgroup *cgrp,int cpu);void cgroup_rstat_flush (struct cgroup *cgrp);void cgroup_rstat_flush_hold (struct cgroup *cgrp);
kernel/cgroup/rstat.c +16 -3
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only #include "cgroup-internal.h" +#include <linux/cpumask.h> #include <linux/sched/cputime.h> #include <linux/bpf.h>
@@ -18,7 +19,7 @@ static struct cgroup_rstat_cpu *cgroup_rstat_cpu(struct cgroup *cgrp, int cpu) }/** -* cgroup_rstat_updated - keep track of updated rstat_cpu +* __cgroup_rstat_updated - keep track of updated rstat_cpu * @cgrp: target cgroup * @cpu: cpu on which rstat_cpu was updated *
@@ -26,7 +27,7 @@ static struct cgroup_rstat_cpu *cgroup_rstat_cpu(struct cgroup *cgrp, int cpu)* rstat_cpu->updated_children list. See the comment on top of * cgroup_rstat_cpu definition for details. */ -__bpf_kfunc void cgroup_rstat_updated(struct cgroup *cgrp, int cpu) +void __cgroup_rstat_updated (struct cgroup *cgrp,int cpu) {raw_spinlock_t *cpu_lock =per_cpu_ptr (&cgroup_rstat_cpu_lock, cpu);unsigned long flags;
@@ -73,6 +74,18 @@ __bpf_kfunc void cgroup_rstat_updated(struct cgroup *cgrp, int cpu)raw_spin_unlock_irqrestore (cpu_lock, flags); } +/* +* BPF-facing wrapper for __cgroup_rstat_updated(). Validate the caller-provided +* CPU before passing it to the internal rstat updater. +*/ +__bpf_kfunc void cgroup_rstat_updated(struct cgroup *cgrp, int cpu) +{ +if (unlikely (cpu <0 || cpu >= nr_cpu_ids || !cpu_possible (cpu))) +return ; + +__cgroup_rstat_updated (cgrp, cpu); +} +/** * cgroup_rstat_cpu_pop_updated - iterate and dismantle rstat_cpu updated tree * @pos: current position
@@ -394,7 +407,7 @@ static void cgroup_base_stat_cputime_account_end(struct cgroup *cgrp, unsigned long flags) {u64_stats_update_end_irqrestore (&rstatc->bsync, flags); -cgroup_rstat_updated (cgrp,smp_processor_id ()); +__cgroup_rstat_updated (cgrp,smp_processor_id ());put_cpu_ptr (rstatc); }
mm/memcontrol.c +1 -1
@@ -715,7 +715,7 @@ static inline void memcg_rstat_updated(struct mem_cgroup *memcg, int val)if (!val)return ; -cgroup_rstat_updated (memcg->css.cgroup, cpu); +__cgroup_rstat_updated (memcg->css.cgroup, cpu); statc =this_cpu_ptr (memcg->vmstats_percpu);for (; statc; statc = statc->parent) { stats_updates =READ_ONCE (statc->stats_updates) +abs (val);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1044/1674 hwmon: (lm90) Stop work before releasing hwmon device
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit b09a45601094c7f4ec4db8090b825fa61e169d93 ]
Sashiko reports:
In lm90_probe(), the devm action to cancel the alert_work and report_work (lm90_restore_conf) is registered in lm90_init_client() before devm_hwmon_device_register_with_info() is called.
Because devm executes cleanup actions in reverse order during module unbind or probe failure, the hwmon device is unregistered and freed first.
If lm90_alert_work() or lm90_report_alarms() runs in the window between the hwmon device being freed and the delayed works being cancelled, lm90_update_alarms() will dereference the freed data->hwmon_dev here.
Fix the problem by canceling the workers separately after registering the hwmon device and before registering the interrupt handler. This ensures that the workers are canceled after interrupts are disabled and before the hwmon device is released. Add "shutdown" flag to indicate that device shutdown is in progress to prevent workers from being re-armed.
--- drivers/hwmon/lm90.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
drivers/hwmon/lm90.c +20 -4
@@ -695,6 +695,7 @@ struct lm90_data {struct mutex update_lock;struct delayed_work alert_work;struct work_struct report_work; +bool shutdown;/* true if shutting down */ bool valid;/* true if register values are valid */ bool alarms_valid;/* true if status register values are valid */ unsigned long last_updated;/* in jiffies */
@@ -1113,6 +1114,9 @@ static void lm90_report_alarms(struct work_struct *work)static int lm90_update_alarms_locked (struct lm90_data *data,bool force) { +if (data->shutdown) +return 0 ; +if (force || !data->alarms_valid ||time_after (jiffies, data->alarms_updated +msecs_to_jiffies (data->update_interval))) {struct i2c_client *client = data->client;
@@ -2558,15 +2562,23 @@ static void lm90_restore_conf(void *_data)struct lm90_data *data = _data;struct i2c_client *client = data->client; -cancel_delayed_work_sync (&data->alert_work); -cancel_work_sync (&data->report_work); -/* Restore initial configuration */ if (data->flags &LM90_HAVE_CONVRATE )lm90_write_convrate (data, data->convrate_orig);lm90_write_reg (client,LM90_REG_CONFIG1 , data->config_orig); } +static void lm90_stop_work (void *_data) +{ +struct lm90_data *data = _data; + +mutex_lock (&data->update_lock); + data->shutdown = true; +mutex_unlock (&data->update_lock); +cancel_delayed_work_sync (&data->alert_work); +cancel_work_sync (&data->report_work); +} +static int lm90_init_client (struct i2c_client *client,struct lm90_data *data) {struct device_node *np = client->dev.of_node;
@@ -2899,6 +2911,10 @@ static int lm90_probe(struct i2c_client *client) data->hwmon_dev = hwmon_dev; + err =devm_add_action_or_reset (&client->dev, lm90_stop_work, data); +if (err) +return err; +if (client->irq) {dev_dbg (dev,"IRQ: %d\n" , client->irq); err = devm_request_threaded_irq(dev, client->irq,
@@ -2927,7 +2943,7 @@ static void lm90_alert(struct i2c_client *client, enum i2c_alert_protocol type,*/ struct lm90_data *data =i2c_get_clientdata (client); -if ((data->flags &LM90_HAVE_BROKEN_ALERT ) && +if (!data->shutdown && (data->flags &LM90_HAVE_BROKEN_ALERT ) && (data->current_alarms & data->alert_alarms)) {if (!(data->config &0x80 )) {dev_dbg (&client->dev,"Disabling ALERT#\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1045/1674 netfilter: bridge: eb_tables: close module init race
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 27414ff1b287ea9a2a11675149ec28e05539f3cc ]
sashiko reports for unrelated patch:
Does the core ebtables initialization in ebtables.c suffer from a similar race? Once nf_register_sockopt() completes, the sockopts are exposed globally.
sockopt has to be registered last, just like in ip/ip6/arptables.
--- net/bridge/netfilter/ebtables.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
net/bridge/netfilter/ebtables.c +6 -5
@@ -2607,19 +2607,20 @@ static int __init ebtables_init(void) {int ret; - ret =xt_register_target (&ebt_standard_target); + ret =register_pernet_subsys (&ebt_net_ops);if (ret <0 )return ret; - ret =nf_register_sockopt (&ebt_sockopts); + + ret =xt_register_target (&ebt_standard_target);if (ret <0 ) { -xt_unregister_target (&ebt_standard_target); +unregister_pernet_subsys (&ebt_net_ops);return ret; } - ret =register_pernet_subsys (&ebt_net_ops); + ret =nf_register_sockopt (&ebt_sockopts);if (ret <0 ) { -nf_unregister_sockopt (&ebt_sockopts);xt_unregister_target (&ebt_standard_target); +unregister_pernet_subsys (&ebt_net_ops);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1046/1674 netfilter: ebtables: move to two-stage removal scheme
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit b7f0544d86d439cb946515d2ef6a0a75e8626710 ]
Like previous patches for x_tables, follow same pattern in ebtables. We can't reuse xt helpers: ebt_table struct layout is incompatible.
table->ops assignment is now done while still holding the ebt mutex to make sure we never expose partially-filled table struct.
--- net/bridge/netfilter/ebtable_broute.c | 2 +- net/bridge/netfilter/ebtable_filter.c | 2 +- net/bridge/netfilter/ebtable_nat.c | 2 +- net/bridge/netfilter/ebtables.c | 60 +++++++++++++++++---------- 4 files changed, 40 insertions(+), 26 deletions(-)
net/bridge/netfilter/ebtable_broute.c +1 -1
@@ -128,8 +128,8 @@ static int __init ebtable_broute_init(void) static void __exit ebtable_broute_fini(void) { -unregister_pernet_subsys (&broute_net_ops);ebt_unregister_template (&broute_table); +unregister_pernet_subsys (&broute_net_ops); }module_init (ebtable_broute_init);
net/bridge/netfilter/ebtable_filter.c +1 -1
@@ -109,8 +109,8 @@ static int __init ebtable_filter_init(void) static void __exit ebtable_filter_fini(void) { -unregister_pernet_subsys (&frame_filter_net_ops);ebt_unregister_template (&frame_filter); +unregister_pernet_subsys (&frame_filter_net_ops); }module_init (ebtable_filter_init);
net/bridge/netfilter/ebtable_nat.c +1 -1
@@ -109,8 +109,8 @@ static int __init ebtable_nat_init(void) static void __exit ebtable_nat_fini(void) { -unregister_pernet_subsys (&frame_nat_net_ops);ebt_unregister_template (&frame_nat); +unregister_pernet_subsys (&frame_nat_net_ops); }module_init (ebtable_nat_init);
net/bridge/netfilter/ebtables.c +37 -23
115 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1047/1674 mm/util: Introduce kmemdup_array()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kartik <[email protected]>
[ Upstream commit 7092e9b3bed1252c7d3f5812b9fb9d82375b73a6 ]
Introduce kmemdup_array() API to duplicate n number of elements from a given array. This internally uses kmemdup to allocate and duplicate the src array.
Stable-dep-of: b62eb8dcf2c4 ("netfilter: x_tables: allocate hook ops while under mutex")
--- include/linux/string.h | 1 + mm/util.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+)
include/linux/string.h +1 -0
@@ -232,6 +232,7 @@ extern char *kstrndup(const char *s, size_t len, gfp_t gfp);extern void *kmemdup (const void *src,size_t len,gfp_t gfp)__realloc_size (2 );extern void *kvmemdup (const void *src,size_t len,gfp_t gfp)__realloc_size (2 );extern char *kmemdup_nul (const char *s,size_t len,gfp_t gfp); +extern void *kmemdup_array (const void *src,size_t element_size,size_t count,gfp_t gfp);extern char **argv_split (gfp_t gfp,const char *str,int *argcp);extern void argv_free (char **argv);
mm/util.c +17 -0
@@ -135,6 +135,23 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp) }EXPORT_SYMBOL (kmemdup); +/** +* kmemdup_array - duplicate a given array. +* +* @src: array to duplicate. +* @element_size: size of each element of array. +* @count: number of elements to duplicate from array. +* @gfp: GFP mask to use. +* +* Return: duplicated array of @src or %NULL in case of error, +* result is physically contiguous. Use kfree() to free. +*/ +void *kmemdup_array (const void *src,size_t element_size,size_t count,gfp_t gfp) +{ +return kmemdup (src,size_mul (element_size, count), gfp); +} +EXPORT_SYMBOL (kmemdup_array); +/** * kvmemdup - duplicate region of memory *
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1048/1674 netfilter: Use kmemdup_array instead of kmemdup for multiple allocation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yan Zhen <[email protected]>
[ Upstream commit 20eb5e7cb78c331107fbdf2f77a30fbea9338638 ]
When we are allocating an array, using kmemdup_array() to take care about multiplication and possible overflows.
Also it makes auditing the code easier.
Stable-dep-of: b62eb8dcf2c4 ("netfilter: x_tables: allocate hook ops while under mutex")
--- net/bridge/netfilter/ebtables.c | 2 +- net/ipv4/netfilter/arp_tables.c | 2 +- net/ipv4/netfilter/ip_tables.c | 2 +- net/ipv6/netfilter/ip6_tables.c | 2 +- net/netfilter/nf_nat_core.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
net/bridge/netfilter/ebtables.c +1 -1
@@ -1254,7 +1254,7 @@ int ebt_register_table(struct net *net, const struct ebt_table *input_table, goto free_unlock; } - ops =kmemdup (template_ops,sizeof (*ops) * num_ops,GFP_KERNEL ); + ops =kmemdup_array (template_ops, num_ops,sizeof (*ops),GFP_KERNEL );if (!ops) { ret = -ENOMEM ;if (newinfo->nentries)
net/ipv4/netfilter/arp_tables.c +1 -1
@@ -1556,7 +1556,7 @@ int arpt_register_table(struct net *net, goto out_free; } - ops =kmemdup (template_ops,sizeof (*ops) * num_ops,GFP_KERNEL ); + ops =kmemdup_array (template_ops, num_ops,sizeof (*ops),GFP_KERNEL );if (!ops) { ret = -ENOMEM ; goto out_free;
net/ipv4/netfilter/ip_tables.c +1 -1
@@ -1764,7 +1764,7 @@ int ipt_register_table(struct net *net, const struct xt_table *table, goto out_free; } - ops =kmemdup (template_ops,sizeof (*ops) * num_ops,GFP_KERNEL ); + ops =kmemdup_array (template_ops, num_ops,sizeof (*ops),GFP_KERNEL );if (!ops) { ret = -ENOMEM ; goto out_free;
net/ipv6/netfilter/ip6_tables.c +1 -1
@@ -1775,7 +1775,7 @@ int ip6t_register_table(struct net *net, const struct xt_table *table, goto out_free; } - ops =kmemdup (template_ops,sizeof (*ops) * num_ops,GFP_KERNEL ); + ops =kmemdup_array (template_ops, num_ops,sizeof (*ops),GFP_KERNEL );if (!ops) { ret = -ENOMEM ; goto out_free;
net/netfilter/nf_nat_core.c +1 -1
@@ -1234,7 +1234,7 @@ int nf_nat_register_fn(struct net *net, u8 pf, const struct nf_hook_ops *ops,if (!nat_proto_net->nat_hook_ops) {WARN_ON (nat_proto_net->users !=0 ); - nat_ops =kmemdup (orig_nat_ops,sizeof (*orig_nat_ops) * ops_count,GFP_KERNEL ); + nat_ops =kmemdup_array (orig_nat_ops, ops_count,sizeof (*orig_nat_ops),GFP_KERNEL );if (!nat_ops) {mutex_unlock (&nf_nat_proto_mutex);return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1049/1674 netfilter: x_tables: allow initial table replace without emitting audit log message
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 8e72510db9fa2d41f2b06d5c01fe9020e076fee4 ]
At the moment we emit the audit log a bit too early, which makes it necessary to also emit an unregister log in case we have to unwind errors after possible hook register failure.
Followup patch will be slightly simpler if we can delay the register message until after the hooks have been wired up.
Stable-dep-of: b62eb8dcf2c4 ("netfilter: x_tables: allocate hook ops while under mutex")
--- net/netfilter/x_tables.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
net/netfilter/x_tables.c +20 -9
@@ -1403,11 +1403,9 @@ struct xt_counters *xt_counters_alloc(unsigned int counters) }EXPORT_SYMBOL (xt_counters_alloc); -struct xt_table_info * -xt_replace_table (struct xt_table *table, -unsigned int num_counters, -struct xt_table_info *newinfo, -int *error) +static struct xt_table_info * +do_replace_table (struct xt_table *table,unsigned int num_counters, +struct xt_table_info *newinfo,int *error) {struct xt_table_info *private;unsigned int cpu;
@@ -1462,10 +1460,23 @@ xt_replace_table(struct xt_table *table, } } -audit_log_nfcfg (table->name, table->af, private->number, - !private->number ?AUDIT_XT_OP_REGISTER : -AUDIT_XT_OP_REPLACE , -GFP_KERNEL ); +return private; +} + +struct xt_table_info * +xt_replace_table (struct xt_table *table,unsigned int num_counters, +struct xt_table_info *newinfo, +int *error) +{ +struct xt_table_info *private; + + private =do_replace_table (table, num_counters, newinfo, error); +if (private) +audit_log_nfcfg (table->name, table->af, private->number, + !private->number ?AUDIT_XT_OP_REGISTER : +AUDIT_XT_OP_REPLACE , +GFP_KERNEL ); +return private; }EXPORT_SYMBOL_GPL (xt_replace_table);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1050/1674 netfilter: x_tables: allocate hook ops while under mutex
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit b62eb8dcf2c47d4d676a434efbd57c4f776f7829 ]
arp/ip(6)t_register_table() add the table to the per-netns list via xt_register_table() before allocating the per-netns hook ops copy via kmemdup_array(). This leaves a window where the table is visible in the list with ops=NULL.
If the pernet exit happens runs concurrently the pre_exit callback finds the table via xt_find_table() and passes the NULL ops pointer to nf_unregister_net_hooks(), causing a NULL dereference:
general protection fault in nf_unregister_net_hooks+0xbc/0x150
RIP: nf_unregister_net_hooks (net/netfilter/core.c:613)
Call Trace:
ipt_unregister_table_pre_exit
iptable_mangle_net_pre_exit
ops_pre_exit_list
cleanup_netFix by moving the ops allocation into the xtables core so the table is never in the list without valid ops. Also ensure the table is no longer processing packets before its torn down on error unwind. nf_register_net_hooks might have published at least one hook; call synchronize_rcu() if there was an error.
audit log register message gets deferred until all operations have passed, this avoids need to emit another ureg message in case of error unwinding.
Based on earlier patch by Tristan Madani.
--- include/linux/netfilter/x_tables.h | 1 + net/ipv4/netfilter/arp_tables.c | 35 +++------------------ net/ipv4/netfilter/ip_tables.c | 41 +++--------------------- net/ipv6/netfilter/ip6_tables.c | 38 +++-------------------- net/netfilter/x_tables.c | 50 +++++++++++++++++++++++++----- 5 files changed, 55 insertions(+), 110 deletions(-)
include/linux/netfilter/x_tables.h +1 -0
@@ -307,6 +307,7 @@ struct xt_counters *xt_counters_alloc(unsigned int counters);struct xt_table *xt_register_table (struct net *net,const struct xt_table *table, +const struct nf_hook_ops *template_ops,struct xt_table_info *bootstrap,struct xt_table_info *newinfo);void *xt_unregister_table (struct xt_table *table);
net/ipv4/netfilter/arp_tables.c +4 -31
@@ -1519,13 +1519,11 @@ int arpt_register_table(struct net *net,const struct arpt_replace *repl, const struct nf_hook_ops *template_ops) { - struct nf_hook_ops *ops; -unsigned int num_ops; -int ret, i; -struct xt_table_info *newinfo; struct xt_table_info bootstrap = {0}; -void *loc_cpu_entry; +struct xt_table_info *newinfo;struct xt_table *new_table; +void *loc_cpu_entry; +int ret; newinfo =xt_alloc_table_info (repl->size);if (!newinfo)
@@ -1540,7 +1538,7 @@ int arpt_register_table(struct net *net,return ret; } - new_table =xt_register_table (net, table, &bootstrap, newinfo); + new_table =xt_register_table (net, table, template_ops, &bootstrap, newinfo);if (IS_ERR (new_table)) {struct arpt_entry *iter;
@@ -1550,31 +1548,6 @@ int arpt_register_table(struct net *net,return PTR_ERR (new_table); } - num_ops =hweight32 (table->valid_hooks); -if (num_ops ==0 ) { - ret = -EINVAL ; - goto out_free; - } - - ops =kmemdup_array (template_ops, num_ops,sizeof (*ops),GFP_KERNEL ); -if (!ops) { - ret = -ENOMEM ; - goto out_free; - } - -for (i =0 ; i < num_ops; i++) - ops[i].priv = new_table; - - new_table->ops = ops; - - ret =nf_register_net_hooks (net, ops, num_ops); -if (ret !=0 ) - goto out_free; - -return ret; - -out_free: -__arpt_unregister_table (net, new_table);return ret; }
net/ipv4/netfilter/ip_tables.c +4 -37
61 lines not on this page · raw message
net/ipv6/netfilter/ip6_tables.c +4 -34
@@ -1735,13 +1735,11 @@ int ip6t_register_table(struct net *net, const struct xt_table *table,const struct ip6t_replace *repl, const struct nf_hook_ops *template_ops) { - struct nf_hook_ops *ops; -unsigned int num_ops; -int ret, i; -struct xt_table_info *newinfo; struct xt_table_info bootstrap = {0}; -void *loc_cpu_entry; +struct xt_table_info *newinfo;struct xt_table *new_table; +void *loc_cpu_entry; +int ret; newinfo =xt_alloc_table_info (repl->size);if (!newinfo)
@@ -1756,7 +1754,7 @@ int ip6t_register_table(struct net *net, const struct xt_table *table,return ret; } - new_table =xt_register_table (net, table, &bootstrap, newinfo); + new_table =xt_register_table (net, table, template_ops, &bootstrap, newinfo);if (IS_ERR (new_table)) {struct ip6t_entry *iter;
@@ -1766,34 +1764,6 @@ int ip6t_register_table(struct net *net, const struct xt_table *table,return PTR_ERR (new_table); } -if (!template_ops) -return 0 ; - - num_ops =hweight32 (table->valid_hooks); -if (num_ops ==0 ) { - ret = -EINVAL ; - goto out_free; - } - - ops =kmemdup_array (template_ops, num_ops,sizeof (*ops),GFP_KERNEL ); -if (!ops) { - ret = -ENOMEM ; - goto out_free; - } - -for (i =0 ; i < num_ops; i++) - ops[i].priv = new_table; - - new_table->ops = ops; - - ret =nf_register_net_hooks (net, ops, num_ops); -if (ret !=0 ) - goto out_free; - -return ret; - -out_free: -__ip6t_unregister_table (net, new_table);return ret; }
net/netfilter/x_tables.c +42 -8
90 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1051/1674 wifi: mac80211: fix missing RX bitrate update for mesh forwarding path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarika Sharma <[email protected]>
[ Upstream commit cc18fffa3a51792637169872886df3407bd5bb84 ]
Currently, RX bitrate statistics are not updated for packets received on the mesh forwarding path during fast RX processing. This results in incomplete RX rate tracking in station dump outputs for mesh scenarios.
Update ieee80211_invoke_fast_rx() to record the RX rate using sta_stats_encode_rate() and store it in the last_rate field of ieee80211_sta_rx_stats when RX_QUEUED is returned from ieee80211_rx_mesh_data(). This ensures that RX bitrate is properly accounted for in both RSS and non-RSS paths.
Stable-dep-of: d71c841be5d9 ("wifi: mac80211: capture fast-RX rate before mesh reuses skb->cb")
--- net/mac80211/rx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
net/mac80211/rx.c +7 -5
@@ -4906,6 +4906,11 @@ static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx,/* after this point, don't punt to the slowpath! */ +if (fast_rx->uses_rss) + stats =this_cpu_ptr (rx->link_sta->pcpu_rx_stats); +else + stats = &rx->link_sta->rx_stats; +if (rx->key && !(status->flag &RX_FLAG_MIC_STRIPPED ) &&pskb_trim (skb, skb->len - fast_rx->icv_len)) goto drop;
@@ -4940,6 +4945,8 @@ static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx, res =ieee80211_rx_mesh_data (rx->sdata, rx->sta, rx->skb);switch (res) {case RX_QUEUED : + stats->last_rx = jiffies; + stats->last_rate =sta_stats_encode_rate (status);return true;case RX_CONTINUE :break ;
@@ -4953,11 +4960,6 @@ static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx, drop:dev_kfree_skb (skb); -if (fast_rx->uses_rss) - stats =this_cpu_ptr (rx->link_sta->pcpu_rx_stats); -else - stats = &rx->link_sta->rx_stats; - stats->dropped++;return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1052/1674 wifi: mac80211: capture fast-RX rate before mesh reuses skb->cb
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
[ Upstream commit d71c841be5d9e586ee7f36c0dc8ed4db0d9a1349 ]
ieee80211_invoke_fast_rx() reads RX status through IEEE80211_SKB_RXCB(skb), which aliases the same skb->cb storage that ieee80211_rx_mesh_data() reuses as IEEE80211_TX_INFO. In the unicast forward path, mesh_data does:
info = IEEE80211_SKB_CB(fwd_skb); memset(info, 0, sizeof(*info));
on the same skb the caller still names via rx->skb, then either queues the skb for TX (success) or kfree_skb()'s it (no-route) before returning RX_QUEUED. The caller's RX_QUEUED arm then calls sta_stats_encode_rate(status) on memory that is either zeroed (success path) or freed (no-route path). The latter is KASAN slab-use-after-free in ieee80211_prepare_and_rx_handle.
Fix by encoding the rate from status before invoking ieee80211_rx_mesh_data(), so the RX_QUEUED arm consumes a value captured while status was still backed by valid memory.
--- net/mac80211/rx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/mac80211/rx.c +5 -1
@@ -4835,6 +4835,7 @@ static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx,u8 sa[ETH_ALEN ]; } addrs__aligned(2) ;struct ieee80211_sta_rx_stats *stats; +u32 encoded_rate;/* for parallel-rx, we need to have DUP_VALIDATED, otherwise we write * to a common data structure; drivers can implement that per queue
@@ -4942,11 +4943,14 @@ static bool ieee80211_invoke_fast_rx(struct ieee80211_rx_data *rx,/* push the addresses in front */ memcpy (skb_push (skb,sizeof (addrs)), &addrs,sizeof (addrs)); +/* capture before mesh forward may memset or free skb->cb */ + encoded_rate =sta_stats_encode_rate (status); + res =ieee80211_rx_mesh_data (rx->sdata, rx->sta, rx->skb);switch (res) {case RX_QUEUED : stats->last_rx = jiffies; - stats->last_rate =sta_stats_encode_rate (status); + stats->last_rate = encoded_rate;return true;case RX_CONTINUE :break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1053/1674 ksmbd: validate SID in parent security descriptor during ACL inheritance
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junyi Liu <[email protected]>
[ Upstream commit 69f030cf95488ae1186c72ac8c66fd279664ea7f ]
Introduce smb_validate_ntsd_sid() helper to safely validate Owner SID and Group SID inside the NT Security Descriptor (smb_ntsd) retrieved from the parent directory.
--- fs/smb/server/smbacl.c | 66 ++++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 16 deletions(-)
fs/smb/server/smbacl.c +50 -16
@@ -1136,6 +1136,40 @@ static int smb_append_inherited_ace(struct smb_ace **ace, int *nt_size,return 0 ; } +static int smb_validate_ntsd_sid (struct smb_ntsd *pntsd,size_t pntsd_size, +unsigned int sid_offset,struct smb_sid **sid, +size_t *sid_size) +{ +size_t sid_end; + + *sid =NULL ; + *sid_size =0 ; + +if (!sid_offset) +return 0 ; + +if (sid_offset <sizeof (struct smb_ntsd ) || +check_add_overflow (sid_offset, (size_t )CIFS_SID_BASE_SIZE , + &sid_end) || + sid_end > pntsd_size) +return -EINVAL ; + + *sid = (struct smb_sid *)((char *)pntsd + sid_offset); +if ((*sid)->num_subauth >SID_MAX_SUB_AUTHORITIES ) +return -EINVAL ; + +if (check_add_overflow ((size_t )CIFS_SID_BASE_SIZE , +sizeof (__le32) * (size_t )(*sid)->num_subauth, + &sid_end)) +return -EINVAL ; + +if (sid_offset > pntsd_size || sid_end > pntsd_size - sid_offset) +return -EINVAL ; + + *sid_size = sid_end; +return 0 ; +} +int smb_inherit_dacl (struct ksmbd_conn *conn,const struct path *path,unsigned int uid,unsigned int gid)
@@ -1148,28 +1182,28 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,struct dentry *parent = path->dentry->d_parent;struct mnt_idmap *idmap =mnt_idmap (path->mnt);int inherited_flags =0 , flags =0 , i, nt_size =0 , pdacl_size; -int rc =0 , pntsd_type, pntsd_size, acl_len, aces_size; +int rc =0 , pntsd_type, ppntsd_size, acl_len, aces_size;unsigned int dacloffset;size_t dacl_struct_end;u16 num_aces, ace_cnt =0 ;char *aces_base;bool is_dir =S_ISDIR (d_inode (path->dentry)->i_mode); - pntsd_size =ksmbd_vfs_get_sd_xattr (conn, idmap, + ppntsd_size =ksmbd_vfs_get_sd_xattr (conn, idmap, parent, &parent_pntsd); -if (pntsd_size <=0 ) +if (ppntsd_size <=0 )return -ENOENT ; dacloffset =le32_to_cpu (parent_pntsd->dacloffset);if (!dacloffset ||check_add_overflow (dacloffset,sizeof (struct smb_acl ), &dacl_struct_end) || - dacl_struct_end > (size_t )pntsd_size) { + dacl_struct_end > (size_t )ppntsd_size) { rc = -EINVAL ; goto free_parent_pntsd; } parent_pdacl = (struct smb_acl *)((char *)parent_pntsd + dacloffset); - acl_len = pntsd_size - dacloffset; + acl_len = ppntsd_size - dacloffset; num_aces =le16_to_cpu (parent_pdacl->num_aces); pntsd_type =le16_to_cpu (parent_pntsd->type); pdacl_size =le16_to_cpu (parent_pdacl->size);
@@ -1283,19 +1317,19 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,struct smb_ntsd *pntsd;struct smb_acl *pdacl;struct smb_sid *powner_sid =NULL , *pgroup_sid =NULL ; -int powner_sid_size =0 , pgroup_sid_size =0 , pntsd_size; +size_t powner_sid_size =0 , pgroup_sid_size =0 , pntsd_size;size_t pntsd_alloc_size; -if (parent_pntsd->osidoffset) { - powner_sid = (struct smb_sid *)((char *)parent_pntsd + -le32_to_cpu (parent_pntsd->osidoffset)); - powner_sid_size =1 +1 +6 + (powner_sid->num_subauth *4 ); - } -if (parent_pntsd->gsidoffset) { - pgroup_sid = (struct smb_sid *)((char *)parent_pntsd + -le32_to_cpu (parent_pntsd->gsidoffset)); - pgroup_sid_size =1 +1 +6 + (pgroup_sid->num_subauth *4 ); - } + rc =smb_validate_ntsd_sid (parent_pntsd, ppntsd_size, +le32_to_cpu (parent_pntsd->osidoffset), + &powner_sid, &powner_sid_size); +if (rc) + goto free_aces_base; + rc =smb_validate_ntsd_sid (parent_pntsd, ppntsd_size, +le32_to_cpu (parent_pntsd->gsidoffset), + &pgroup_sid, &pgroup_sid_size); +if (rc) + goto free_aces_base; if (check_add_overflow(sizeof(struct smb_ntsd), (size_t)powner_sid_size,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1054/1674 erofs: fix metabuf leak in inode xattr initialization
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Zhu <[email protected]>
[ Upstream commit 79b09c54c6563df9846ca3094bcfd72082c3e1d7 ]
commit bb88e8da0025 ("erofs: use meta buffers for xattr operations") converted xattr operations to use on-stack erofs_buf instances. erofs_init_inode_xattrs() uses such a metabuf while reading the inline xattr header and shared xattr id array.
Some error paths after erofs_read_metabuf() leave through out_unlock without dropping the metabuf, so the folio reference can leak.
Consolidate the cleanup at out_unlock. erofs_put_metabuf() is a no-op if no folio has been acquired, and this keeps all paths after taking EROFS_I_BL_XATTR_BIT covered by a single cleanup site.
--- fs/erofs/xattr.c | 1 + 1 file changed, 1 insertion(+)
fs/erofs/xattr.c +1 -0
@@ -105,6 +105,7 @@ static int erofs_init_inode_xattrs(struct inode *inode) it.kaddr =erofs_bread (&it.buf,erofs_blknr (sb, it.pos),EROFS_KMAP );if (IS_ERR (it.kaddr)) { +erofs_put_metabuf (&it.buf);kfree (vi->xattr_shared_xattrs); vi->xattr_shared_xattrs =NULL ; ret =PTR_ERR (it.kaddr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1055/1674 drm/msm/adreno: Fix a reference leak in a6xx_gpu_init()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit e64bca63647db1d5518198d6c5ca2dbcc66b182b ]
In a6xx_gpu_init(), node is obtained via of_parse_phandle(). While there was a manual of_node_put() at the end of the common path, several early error returns would bypass this call, resulting in a reference leak.
Fix this by using the __free(device_node) cleanup handler to release the reference when the variable goes out of scope.
Patchwork: https://patchwork.freedesktop.org/patch/700661/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +2 -3
@@ -2315,7 +2315,6 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev)struct msm_drm_private *priv = dev->dev_private;struct platform_device *pdev = priv->gpu_pdev;struct adreno_platform_config *config = pdev->dev.platform_data; -struct device_node *node;struct a6xx_gpu *a6xx_gpu;struct adreno_gpu *adreno_gpu;struct msm_gpu *gpu;
@@ -2333,7 +2332,8 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) adreno_gpu->registers =NULL ;/* Check if there is a GMU phandle and set it up */ - node =of_parse_phandle (pdev->dev.of_node,"qcom,gmu" ,0 ); + struct device_node *node __free(device_node) = +of_parse_phandle (pdev->dev.of_node,"qcom,gmu" ,0 );/* FIXME: How do we gracefully handle this? */ BUG_ON (!node);
@@ -2371,7 +2371,6 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) ret =a6xx_gmu_wrapper_init (a6xx_gpu, node); else ret =a6xx_gmu_init (a6xx_gpu, node); -of_node_put (node);if (ret) {a6xx_destroy (&(a6xx_gpu->base.base));return ERR_PTR (ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1056/1674 hwmon: (lm90) Add lock protection to lm90_alert
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 873e919e3101063a7a75989510ccfc125a4391cf ]
Sashiko reports:
lm90_alert() executes in the smbus alert context and calls lm90_update_confreg() to disable the hardware alert line, without acquiring hwmon_lock.
Concurrently, sysfs write operations (such as lm90_write_convrate) hold the hwmon_lock, temporarily modify data->config, and then restore it.
If an alert interrupt occurs concurrently with a sysfs write, the sysfs path will overwrite the alert handler's modifications to data->config and the hardware register.
This unintentionally re-enables the hardware alert line while the alarm is still active, causing an interrupt storm.
Add the missing lock to lm90_alert() to solve the problem.
--- drivers/hwmon/lm90.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hwmon/lm90.c +2 -0
@@ -2943,6 +2943,7 @@ static void lm90_alert(struct i2c_client *client, enum i2c_alert_protocol type,*/ struct lm90_data *data =i2c_get_clientdata (client); +mutex_lock (&data->update_lock);if (!data->shutdown && (data->flags &LM90_HAVE_BROKEN_ALERT ) && (data->current_alarms & data->alert_alarms)) {if (!(data->config &0x80 )) {
@@ -2952,6 +2953,7 @@ static void lm90_alert(struct i2c_client *client, enum i2c_alert_protocol type,schedule_delayed_work (&data->alert_work,max_t (int,HZ ,msecs_to_jiffies (data->update_interval))); } +mutex_unlock (&data->update_lock); }else {dev_dbg (&client->dev,"Everything OK\n" ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1057/1674 crypto: qat - protect service table iterations with service_lock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahsan Atta <[email protected]>
[ Upstream commit 5c6f845e77ec35f9b7b047cc8f9789bf397cdd3e ]
The service_table list is protected by service_lock when entries are added or removed (in adf_service_add() and adf_service_remove()), but several functions iterate over the list without holding this lock.
A concurrent adf_service_register() or adf_service_unregister() call could modify the list during traversal, leading to list corruption or a use-after-free.
Fix this by holding service_lock across all list_for_each_entry() iterations of service_table in adf_dev_init(), adf_dev_start(), adf_dev_stop(), adf_dev_shutdown(), adf_dev_restarting_notify(), adf_dev_restarted_notify(), and adf_error_notifier().
The lock ordering is safe: callers of the static helpers (adf_dev_up() and adf_dev_down()) acquire state_lock before service_lock, and no event_hld callback or service_lock holder ever acquires state_lock in the reverse order.
--- drivers/crypto/intel/qat/qat_common/adf_init.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/crypto/intel/qat/qat_common/adf_init.c +14 -0
@@ -140,16 +140,19 @@ static int adf_dev_init(struct adf_accel_dev *accel_dev)* This is to facilitate any ordering dependencies between services * prior to starting any of the accelerators. */ +mutex_lock (&service_lock);list_for_each (list_itr, &service_table) { service = list_entry(list_itr, struct service_hndl, list);if (service->event_hld (accel_dev,ADF_EVENT_INIT )) {dev_err (&GET_DEV (accel_dev),"Failed to initialise service %s\n" , service->name); +mutex_unlock (&service_lock);return -EFAULT ; }set_bit (accel_dev->accel_id, service->init_status); } +mutex_unlock (&service_lock);return 0 ; }
@@ -212,16 +215,19 @@ static int adf_dev_start(struct adf_accel_dev *accel_dev)adf_heartbeat_start (accel_dev); +mutex_lock (&service_lock);list_for_each (list_itr, &service_table) { service = list_entry(list_itr, struct service_hndl, list);if (service->event_hld (accel_dev,ADF_EVENT_START )) {dev_err (&GET_DEV (accel_dev),"Failed to start service %s\n" , service->name); +mutex_unlock (&service_lock);return -EFAULT ; }set_bit (accel_dev->accel_id, service->start_status); } +mutex_unlock (&service_lock);clear_bit (ADF_STATUS_STARTING , &accel_dev->status);set_bit (ADF_STATUS_STARTED , &accel_dev->status);
@@ -289,6 +295,7 @@ static void adf_dev_stop(struct adf_accel_dev *accel_dev)qat_comp_algs_unregister ();clear_bit (ADF_STATUS_COMP_ALGS_REGISTERED , &accel_dev->status); +mutex_lock (&service_lock);list_for_each (list_itr, &service_table) { service = list_entry(list_itr, struct service_hndl, list);if (!test_bit (accel_dev->accel_id, service->start_status))
@@ -301,6 +308,7 @@ static void adf_dev_stop(struct adf_accel_dev *accel_dev)clear_bit (accel_dev->accel_id, service->start_status); } } +mutex_unlock (&service_lock);if (hw_data->stop_timer) hw_data->stop_timer (accel_dev);
@@ -349,6 +357,7 @@ static void adf_dev_shutdown(struct adf_accel_dev *accel_dev) &accel_dev->status); } +mutex_lock (&service_lock);list_for_each (list_itr, &service_table) { service = list_entry(list_itr, struct service_hndl, list);if (!test_bit (accel_dev->accel_id, service->init_status))
@@ -360,6 +369,7 @@ static void adf_dev_shutdown(struct adf_accel_dev *accel_dev)else clear_bit (accel_dev->accel_id, service->init_status); } +mutex_unlock (&service_lock);adf_heartbeat_shutdown (accel_dev);
@@ -390,6 +400,7 @@ int adf_dev_restarting_notify(struct adf_accel_dev *accel_dev)struct service_hndl *service;struct list_head *list_itr; +mutex_lock (&service_lock);list_for_each (list_itr, &service_table) { service = list_entry(list_itr, struct service_hndl, list);if (service->event_hld (accel_dev,ADF_EVENT_RESTARTING ))
@@ -397,6 +408,7 @@ int adf_dev_restarting_notify(struct adf_accel_dev *accel_dev)"Failed to restart service %s.\n" , service->name); } +mutex_unlock (&service_lock);return 0 ; }
@@ -405,6 +417,7 @@ int adf_dev_restarted_notify(struct adf_accel_dev *accel_dev)struct service_hndl *service;struct list_head *list_itr; +mutex_lock (&service_lock);list_for_each (list_itr, &service_table) { service = list_entry(list_itr, struct service_hndl, list);if (service->event_hld (accel_dev,ADF_EVENT_RESTARTED ))
@@ -412,6 +425,7 @@ int adf_dev_restarted_notify(struct adf_accel_dev *accel_dev)"Failed to restart service %s.\n" , service->name); } +mutex_unlock (&service_lock);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1058/1674 nvmet: fix pre-auth out-of-bounds heap read in Discovery Get Log Page
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryam Vargas <[email protected]>
[ Upstream commit 53cd102a7a56079b11b897835bd9b94c14e6322c ]
nvmet_execute_disc_get_log_page() validates only the dword alignment of the host-supplied Log Page Offset (lpo). The 64-bit offset is then added to a small kzalloc'd buffer that holds the discovery log page and the result is passed straight to nvmet_copy_to_sgl(), which memcpy()s data_len bytes out to the host with no source-side bound check:
u64 offset = nvmet_get_log_page_offset(req->cmd); /* 64-bit host */
size_t data_len = nvmet_get_log_page_len(req->cmd); /* 32-bit host */
...
if (offset & 0x3) { ... } /* only check */
...
alloc_len = sizeof(*hdr) + entry_size * discovery_log_entries(req);
buffer = kzalloc(alloc_len, GFP_KERNEL);
...
status = nvmet_copy_to_sgl(req, 0, buffer + offset, data_len);The Discovery controller is unauthenticated -- nvmet_host_allowed() returns true unconditionally for the discovery subsystem -- so the call is reachable pre-authentication by any TCP/RDMA/FC peer that can reach the nvmet target. With a discovery log page of ~1 KiB, an attacker requesting up to 4 KiB starting at offset == alloc_len reads the next slab page out and gets its content returned over the fabric (an empirical run on a default nvmet-tcp loopback target leaked 81 canonical kernel pointers in one Get Log Page response). Pointing the offset at unmapped kernel memory faults the in-kernel memcpy and crashes (or panics, on panic_on_oops=1) the target host instead.
The attacker-controlled source-side offset pattern "nvmet_copy_to_sgl(req, 0, buffer + ATTACKER_OFFSET, ...)" is unique to nvmet_execute_disc_get_log_page in the entire nvmet codebase: every other Get Log Page handler in admin-cmd.c either ignores lpo (and silently starts every response at offset 0) or tracks a local destination offset with a fixed source pointer.
Validate the host-supplied offset against the log page size, cap the copy length to what is actually available, and zero-fill any remainder of the host transfer buffer. The zero-fill matches the existing short-response pattern in nvmet_execute_get_log_changed_ns() (admin-cmd.c) and prevents leaking transport SGL contents when the host asks for more bytes than the log page contains.
--- drivers/nvme/target/discovery.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/nvme/target/discovery.c +22 -1
@@ -166,6 +166,7 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req)u64 offset =nvmet_get_log_page_offset (req->cmd);size_t data_len =nvmet_get_log_page_len (req->cmd);size_t alloc_len; +size_t copy_len;struct nvmet_subsys_link *p;struct nvmet_port *r;u32 numrec =0 ;
@@ -239,7 +240,27 @@ static void nvmet_execute_disc_get_log_page(struct nvmet_req *req)up_read (&nvmet_config_sem); - status =nvmet_copy_to_sgl (req,0 , buffer + offset, data_len); +/* +* Validate the host-supplied log page offset before copying out. +* Without this check, the host controls a 64-bit byte offset into +* a small kzalloc'd buffer: a value past the log page lets the +* subsequent memcpy read adjacent kernel heap, and a value aimed +* at unmapped kernel memory faults the in-kernel copy and crashes +* the target host. The Discovery controller is unauthenticated, +* so the bug is reachable from any reachable fabric peer. +*/ +if (offset > alloc_len) { + req->error_loc = + offsetof(struct nvme_get_log_page_command , lpo); + status =NVME_SC_INVALID_FIELD |NVME_STATUS_DNR ; + goto out_free_buffer; + } + + copy_len =min_t (size_t, data_len, alloc_len - offset); + status =nvmet_copy_to_sgl (req,0 , buffer + offset, copy_len); +if (!status && copy_len < data_len) + status =nvmet_zero_sgl (req, copy_len, data_len - copy_len); +out_free_buffer:kfree (buffer); out:nvmet_req_complete (req, status);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1059/1674 USB: iowarrior: fix use-after-free on disconnect race
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit c602254ba4c10f60a73cd99d147874f86a3f485c ]
mutex_unlock() may access the mutex structure after releasing the lock and therefore cannot be used to manage lifetime of objects directly (unlike spinlocks and refcounts). [1][2]
Use a kref to release the driver data to avoid use-after-free in mutex_unlock() when release() races with disconnect().
[1] a51749ab34d9 ("locking/mutex: Document that mutex_unlock() is non-atomic")
[2] 2b9d9e0a9ba0 ("locking/mutex: Clarify that mutex_unlock(), and most other sleeping locks, can still use the lock object after it's unlocked")
--- drivers/usb/misc/iowarrior.c | 57 +++++++++++++++--------------------- 1 file changed, 24 insertions(+), 33 deletions(-)
drivers/usb/misc/iowarrior.c +24 -33
@@ -71,6 +71,7 @@ static struct usb_driver iowarrior_driver;/* Structure to hold all of our device specific stuff */ struct iowarrior { +struct kref kref;struct mutex mutex;/* locks this structure */ struct usb_device *udev;/* save off the usb device pointer */ struct usb_interface *interface;/* the interface for this device */
@@ -243,8 +244,10 @@ static void iowarrior_write_callback(struct urb *urb)/* * iowarrior_delete */ -static inline void iowarrior_delete (struct iowarrior *dev) +static inline void iowarrior_delete (struct kref *kref) { + struct iowarrior *dev = container_of(kref, struct iowarrior, kref); +kfree (dev->int_in_buffer);usb_free_urb (dev->int_in_urb);kfree (dev->read_queue);
@@ -641,6 +644,9 @@ static int iowarrior_open(struct inode *inode, struct file *file) }/* increment our usage count for the driver */ ++dev->opened; + +kref_get (&dev->kref); +/* save our object in the file's private structure */ file->private_data = dev; retval =0 ;
@@ -656,7 +662,6 @@ static int iowarrior_open(struct inode *inode, struct file *file)static int iowarrior_release (struct inode *inode,struct file *file) {struct iowarrior *dev; -int retval =0 ; dev = file->private_data;if (!dev)
@@ -664,29 +669,18 @@ static int iowarrior_release(struct inode *inode, struct file *file)/* lock our device */ mutex_lock (&dev->mutex); + dev->opened =0 ;/* we're closing now */ -if (dev->opened <=0 ) { - retval = -ENODEV ;/* close called more than once */ -mutex_unlock (&dev->mutex); - }else { - dev->opened =0 ;/* we're closing now */ - retval =0 ; -if (dev->present) { -/* -The device is still connected so we only shutdown -pending read-/write-ops. -*/ -usb_kill_urb (dev->int_in_urb); -wake_up_interruptible (&dev->read_wait); -wake_up_interruptible (&dev->write_wait); -mutex_unlock (&dev->mutex); - }else { -/* The device was unplugged, cleanup resources */ -mutex_unlock (&dev->mutex); -iowarrior_delete (dev); - } +if (dev->present) { +usb_kill_urb (dev->int_in_urb); +wake_up_interruptible (&dev->read_wait); +wake_up_interruptible (&dev->write_wait); } -return retval; +mutex_unlock (&dev->mutex); + +kref_put (&dev->kref, iowarrior_delete); + +return 0 ; }static __poll_t iowarrior_poll (struct file *file,poll_table * wait)
@@ -771,6 +765,7 @@ static int iowarrior_probe(struct usb_interface *interface,if (!dev)return retval; +kref_init (&dev->kref);mutex_init (&dev->mutex);atomic_set (&dev->intr_idx,0 );
@@ -889,7 +884,8 @@ static int iowarrior_probe(struct usb_interface *interface,return retval; error: -iowarrior_delete (dev); +kref_put (&dev->kref, iowarrior_delete); +return retval; }
@@ -913,19 +909,14 @@ static void iowarrior_disconnect(struct usb_interface *interface)usb_kill_anchored_urbs (&dev->submitted);if (dev->opened) { -/* There is a process that holds a filedescriptor to the device , -so we only shutdown read-/write-ops going on. -Deleting the device is postponed until close() was called. -*/ usb_kill_urb (dev->int_in_urb);wake_up_interruptible (&dev->read_wait);wake_up_interruptible (&dev->write_wait); -mutex_unlock (&dev->mutex); - }else { -/* no process is using the device, cleanup now */ -mutex_unlock (&dev->mutex); -iowarrior_delete (dev); } + +mutex_unlock (&dev->mutex); + +kref_put (&dev->kref, iowarrior_delete); }/* usb specific object needed to register this driver with the usb subsystem */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1060/1674 cpufreq: pcc: Remove empty exit() callback
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viresh Kumar <[email protected]>
[ Upstream commit dfd3e8b90b3660b706c3031b0f746377c571b324 ]
The exit() callback is optional, remove the empty one.
Stable-dep-of: bcb8889c4981 ("cpufreq: qcom-cpufreq-hw: Fix possible double free")
--- drivers/cpufreq/pcc-cpufreq.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/cpufreq/pcc-cpufreq.c +0 -6
@@ -564,18 +564,12 @@ static int pcc_cpufreq_cpu_init(struct cpufreq_policy *policy)return result; } -static int pcc_cpufreq_cpu_exit (struct cpufreq_policy *policy) -{ -return 0 ; -} -static struct cpufreq_driver pcc_cpufreq_driver = { .flags =CPUFREQ_CONST_LOOPS , .get = pcc_get_freq, .verify = pcc_cpufreq_verify, .target = pcc_cpufreq_target, .init = pcc_cpufreq_cpu_init, - .exit = pcc_cpufreq_cpu_exit, .name ="pcc-cpufreq" , };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1061/1674 cpufreq: Make cpufreq_driver->exit() return void
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhe <[email protected]>
[ Upstream commit b4b1ddc9dfe997a5f492fa3a36487f8e7a5de30d ]
The cpufreq core doesn't check the return type of the exit() callback and there is not much the core can do on failures at that point. Just drop the returned value and make it return void.
Stable-dep-of: bcb8889c4981 ("cpufreq: qcom-cpufreq-hw: Fix possible double free")
--- drivers/cpufreq/acpi-cpufreq.c | 4 +--- drivers/cpufreq/amd-pstate.c | 7 ++----- drivers/cpufreq/apple-soc-cpufreq.c | 4 +--- drivers/cpufreq/bmips-cpufreq.c | 4 +--- drivers/cpufreq/cppc_cpufreq.c | 3 +-- drivers/cpufreq/cpufreq-dt.c | 3 +-- drivers/cpufreq/e_powersaver.c | 3 +-- drivers/cpufreq/intel_pstate.c | 8 +++----- drivers/cpufreq/mediatek-cpufreq-hw.c | 4 +--- drivers/cpufreq/mediatek-cpufreq.c | 4 +--- drivers/cpufreq/omap-cpufreq.c | 3 +-- drivers/cpufreq/pasemi-cpufreq.c | 6 ++---- drivers/cpufreq/powernow-k6.c | 5 ++--- drivers/cpufreq/powernow-k7.c | 3 +-- drivers/cpufreq/powernow-k8.c | 6 ++---- drivers/cpufreq/powernv-cpufreq.c | 4 +--- drivers/cpufreq/ppc_cbe_cpufreq.c | 3 +-- drivers/cpufreq/qcom-cpufreq-hw.c | 4 +--- drivers/cpufreq/qoriq-cpufreq.c | 4 +--- drivers/cpufreq/scmi-cpufreq.c | 4 +--- drivers/cpufreq/scpi-cpufreq.c | 4 +--- drivers/cpufreq/sh-cpufreq.c | 4 +--- drivers/cpufreq/sparc-us2e-cpufreq.c | 3 +-- drivers/cpufreq/sparc-us3-cpufreq.c | 3 +-- drivers/cpufreq/speedstep-centrino.c | 10 +++------- drivers/cpufreq/tegra194-cpufreq.c | 4 +--- drivers/cpufreq/vexpress-spc-cpufreq.c | 5 ++--- include/linux/cpufreq.h | 2 +- 28 files changed, 37 insertions(+), 84 deletions(-)
drivers/cpufreq/acpi-cpufreq.c +1 -3
@@ -926,7 +926,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)return result; } -static int acpi_cpufreq_cpu_exit (struct cpufreq_policy *policy) +static void acpi_cpufreq_cpu_exit (struct cpufreq_policy *policy) {struct acpi_cpufreq_data *data = policy->driver_data;
@@ -939,8 +939,6 @@ static int acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy)free_cpumask_var (data->freqdomain_cpus);kfree (policy->freq_table);kfree (data); - -return 0 ; }static int acpi_cpufreq_resume (struct cpufreq_policy *policy)
drivers/cpufreq/amd-pstate.c +2 -5
@@ -900,7 +900,7 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)return ret; } -static int amd_pstate_cpu_exit (struct cpufreq_policy *policy) +static void amd_pstate_cpu_exit (struct cpufreq_policy *policy) {struct amd_cpudata *cpudata = policy->driver_data;
@@ -908,8 +908,6 @@ static int amd_pstate_cpu_exit(struct cpufreq_policy *policy)freq_qos_remove_request (&cpudata->req[0 ]); policy->fast_switch_possible = false;kfree (cpudata); - -return 0 ; }static int amd_pstate_cpu_resume (struct cpufreq_policy *policy)
@@ -1353,7 +1351,7 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)return ret; } -static int amd_pstate_epp_cpu_exit (struct cpufreq_policy *policy) +static void amd_pstate_epp_cpu_exit (struct cpufreq_policy *policy) {struct amd_cpudata *cpudata = policy->driver_data;
@@ -1363,7 +1361,6 @@ static int amd_pstate_epp_cpu_exit(struct cpufreq_policy *policy) }pr_debug ("CPU %d exiting\n" , policy->cpu); -return 0 ; }static void amd_pstate_epp_update_limit (struct cpufreq_policy *policy)
drivers/cpufreq/apple-soc-cpufreq.c +1 -3
@@ -303,7 +303,7 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy)return ret; } -static int apple_soc_cpufreq_exit (struct cpufreq_policy *policy) +static void apple_soc_cpufreq_exit (struct cpufreq_policy *policy) {struct apple_cpu_priv *priv = policy->driver_data;
@@ -311,8 +311,6 @@ static int apple_soc_cpufreq_exit(struct cpufreq_policy *policy)dev_pm_opp_of_cpumask_remove_table (policy->cpus);iounmap (priv->reg_base);kfree (priv); - -return 0 ; }static struct cpufreq_driver apple_soc_cpufreq_driver = {
drivers/cpufreq/bmips-cpufreq.c +1 -3
@@ -121,11 +121,9 @@ static int bmips_cpufreq_target_index(struct cpufreq_policy *policy,return 0 ; } -static int bmips_cpufreq_exit (struct cpufreq_policy *policy) +static void bmips_cpufreq_exit (struct cpufreq_policy *policy) {kfree (policy->freq_table); - -return 0 ; }static int bmips_cpufreq_init (struct cpufreq_policy *policy)
drivers/cpufreq/cppc_cpufreq.c +1 -2
@@ -707,7 +707,7 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)return ret; } -static int cppc_cpufreq_cpu_exit (struct cpufreq_policy *policy) +static void cppc_cpufreq_cpu_exit (struct cpufreq_policy *policy) {struct cppc_cpudata *cpu_data = policy->driver_data;struct cppc_perf_caps *caps = &cpu_data->perf_caps;
@@ -724,7 +724,6 @@ static int cppc_cpufreq_cpu_exit(struct cpufreq_policy *policy) caps->lowest_perf, cpu, ret);cppc_cpufreq_put_cpu_data (policy); -return 0 ; }static inline u64 get_delta (u64 t1,u64 t0)
drivers/cpufreq/cpufreq-dt.c +1 -2
@@ -166,10 +166,9 @@ static int cpufreq_offline(struct cpufreq_policy *policy)return 0 ; } -static int cpufreq_exit (struct cpufreq_policy *policy) +static void cpufreq_exit (struct cpufreq_policy *policy) {clk_put (policy->clk); -return 0 ; }static struct cpufreq_driver dt_cpufreq_driver = {
drivers/cpufreq/e_powersaver.c +1 -2
@@ -360,14 +360,13 @@ static int eps_cpu_init(struct cpufreq_policy *policy)return 0 ; } -static int eps_cpu_exit (struct cpufreq_policy *policy) +static void eps_cpu_exit (struct cpufreq_policy *policy) {unsigned int cpu = policy->cpu;/* Bye */ kfree (eps_cpu[cpu]); eps_cpu[cpu] =NULL ; -return 0 ; }static struct cpufreq_driver eps_driver = {
drivers/cpufreq/intel_pstate.c +3 -5
@@ -2703,13 +2703,11 @@ static int intel_pstate_cpu_offline(struct cpufreq_policy *policy)return intel_cpufreq_cpu_offline (policy); } -static int intel_pstate_cpu_exit (struct cpufreq_policy *policy) +static void intel_pstate_cpu_exit (struct cpufreq_policy *policy) {pr_debug ("CPU %d exiting\n" , policy->cpu); policy->fast_switch_possible = false; - -return 0 ; }static int __intel_pstate_cpu_init (struct cpufreq_policy *policy)
@@ -3044,7 +3042,7 @@ static int intel_cpufreq_cpu_init(struct cpufreq_policy *policy)return ret; } -static int intel_cpufreq_cpu_exit (struct cpufreq_policy *policy) +static void intel_cpufreq_cpu_exit (struct cpufreq_policy *policy) {struct freq_qos_request *req;
@@ -3054,7 +3052,7 @@ static int intel_cpufreq_cpu_exit(struct cpufreq_policy *policy)freq_qos_remove_request (req);kfree (req); -return intel_pstate_cpu_exit (policy); +intel_pstate_cpu_exit (policy); }static int intel_cpufreq_suspend (struct cpufreq_policy *policy)
drivers/cpufreq/mediatek-cpufreq-hw.c +1 -3
@@ -260,7 +260,7 @@ static int mtk_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)return 0 ; } -static int mtk_cpufreq_hw_cpu_exit (struct cpufreq_policy *policy) +static void mtk_cpufreq_hw_cpu_exit (struct cpufreq_policy *policy) {struct mtk_cpufreq_data *data = policy->driver_data;struct resource *res = data->res;
@@ -270,8 +270,6 @@ static int mtk_cpufreq_hw_cpu_exit(struct cpufreq_policy *policy)writel_relaxed (0x0 , data->reg_bases[REG_FREQ_ENABLE ]);iounmap (base);release_mem_region (res->start,resource_size (res)); - -return 0 ; }static void mtk_cpufreq_register_em (struct cpufreq_policy *policy)
drivers/cpufreq/mediatek-cpufreq.c +1 -3
@@ -599,13 +599,11 @@ static int mtk_cpufreq_init(struct cpufreq_policy *policy)return 0 ; } -static int mtk_cpufreq_exit (struct cpufreq_policy *policy) +static void mtk_cpufreq_exit (struct cpufreq_policy *policy) {struct mtk_cpu_dvfs_info *info = policy->driver_data;dev_pm_opp_free_cpufreq_table (info->cpu_dev, &policy->freq_table); - -return 0 ; }static struct cpufreq_driver mtk_cpufreq_driver = {
drivers/cpufreq/omap-cpufreq.c +1 -2
@@ -135,11 +135,10 @@ static int omap_cpu_init(struct cpufreq_policy *policy)return 0 ; } -static int omap_cpu_exit (struct cpufreq_policy *policy) +static void omap_cpu_exit (struct cpufreq_policy *policy) {freq_table_free ();clk_put (policy->clk); -return 0 ; }static struct cpufreq_driver omap_driver = {
drivers/cpufreq/pasemi-cpufreq.c +2 -4
@@ -204,21 +204,19 @@ static int pas_cpufreq_cpu_init(struct cpufreq_policy *policy)return err; } -static int pas_cpufreq_cpu_exit (struct cpufreq_policy *policy) +static void pas_cpufreq_cpu_exit (struct cpufreq_policy *policy) {/* * We don't support CPU hotplug. Don't unmap after the system * has already made it to a running state. */ if (system_state >=SYSTEM_RUNNING ) -return 0 ; +return ;if (sdcasr_mapbase)iounmap (sdcasr_mapbase);if (sdcpwr_mapbase)iounmap (sdcpwr_mapbase); - -return 0 ; } static int pas_cpufreq_target(struct cpufreq_policy *policy,
drivers/cpufreq/powernow-k6.c +2 -3
@@ -219,7 +219,7 @@ static int powernow_k6_cpu_init(struct cpufreq_policy *policy) } -static int powernow_k6_cpu_exit (struct cpufreq_policy *policy) +static void powernow_k6_cpu_exit (struct cpufreq_policy *policy) {unsigned int i;
@@ -234,10 +234,9 @@ static int powernow_k6_cpu_exit(struct cpufreq_policy *policy)cpufreq_freq_transition_begin (policy, &freqs);powernow_k6_target (policy, i);cpufreq_freq_transition_end (policy, &freqs,0 ); -break ; +return ; } } -return 0 ; }static unsigned int powernow_k6_get (unsigned int cpu)
drivers/cpufreq/powernow-k7.c +1 -2
@@ -644,7 +644,7 @@ static int powernow_cpu_init(struct cpufreq_policy *policy)return 0 ; } -static int powernow_cpu_exit (struct cpufreq_policy *policy) +static void powernow_cpu_exit (struct cpufreq_policy *policy) {#ifdef CONFIG_X86_POWERNOW_K7_ACPI if (acpi_processor_perf) {
@@ -655,7 +655,6 @@ static int powernow_cpu_exit(struct cpufreq_policy *policy)#endif kfree (powernow_table); -return 0 ; }static struct cpufreq_driver powernow_driver = {
drivers/cpufreq/powernow-k8.c +2 -4
@@ -1090,13 +1090,13 @@ static int powernowk8_cpu_init(struct cpufreq_policy *pol)return -ENODEV ; } -static int powernowk8_cpu_exit (struct cpufreq_policy *pol) +static void powernowk8_cpu_exit (struct cpufreq_policy *pol) {struct powernow_k8_data *data =per_cpu (powernow_data, pol->cpu);int cpu;if (!data) -return -EINVAL ; +return ;powernow_k8_cpu_exit_acpi (data);
@@ -1105,8 +1105,6 @@ static int powernowk8_cpu_exit(struct cpufreq_policy *pol)/* pol->cpus will be empty here, use related_cpus instead. */ for_each_cpu (cpu, pol->related_cpus)per_cpu (powernow_data, cpu) =NULL ; - -return 0 ; }static void query_values_on_cpu (void *_err)
drivers/cpufreq/powernv-cpufreq.c +1 -3
@@ -874,7 +874,7 @@ static int powernv_cpufreq_cpu_init(struct cpufreq_policy *policy)return 0 ; } -static int powernv_cpufreq_cpu_exit (struct cpufreq_policy *policy) +static void powernv_cpufreq_cpu_exit (struct cpufreq_policy *policy) {struct powernv_smp_call_data freq_data;struct global_pstate_info *gpstates = policy->driver_data;
@@ -886,8 +886,6 @@ static int powernv_cpufreq_cpu_exit(struct cpufreq_policy *policy)del_timer_sync (&gpstates->timer);kfree (policy->driver_data); - -return 0 ; } static int powernv_cpufreq_reboot_notifier(struct notifier_block *nb,
drivers/cpufreq/ppc_cbe_cpufreq.c +1 -2
@@ -113,10 +113,9 @@ static int cbe_cpufreq_cpu_init(struct cpufreq_policy *policy)return 0 ; } -static int cbe_cpufreq_cpu_exit (struct cpufreq_policy *policy) +static void cbe_cpufreq_cpu_exit (struct cpufreq_policy *policy) {cbe_cpufreq_pmi_policy_exit (policy); -return 0 ; } static int cbe_cpufreq_target(struct cpufreq_policy *policy,
drivers/cpufreq/qcom-cpufreq-hw.c +1 -3
@@ -574,7 +574,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)return qcom_cpufreq_hw_lmh_init (policy, index); } -static int qcom_cpufreq_hw_cpu_exit (struct cpufreq_policy *policy) +static void qcom_cpufreq_hw_cpu_exit (struct cpufreq_policy *policy) {struct device *cpu_dev =get_cpu_device (policy->cpu);struct qcom_cpufreq_data *data = policy->driver_data;
@@ -584,8 +584,6 @@ static int qcom_cpufreq_hw_cpu_exit(struct cpufreq_policy *policy)qcom_cpufreq_hw_lmh_exit (data);kfree (policy->freq_table);kfree (data); - -return 0 ; }static void qcom_cpufreq_ready (struct cpufreq_policy *policy)
drivers/cpufreq/qoriq-cpufreq.c +1 -3
@@ -225,7 +225,7 @@ static int qoriq_cpufreq_cpu_init(struct cpufreq_policy *policy)return -ENODEV ; } -static int qoriq_cpufreq_cpu_exit (struct cpufreq_policy *policy) +static void qoriq_cpufreq_cpu_exit (struct cpufreq_policy *policy) {struct cpu_data *data = policy->driver_data;
@@ -233,8 +233,6 @@ static int qoriq_cpufreq_cpu_exit(struct cpufreq_policy *policy)kfree (data->table);kfree (data); policy->driver_data =NULL ; - -return 0 ; } static int qoriq_cpufreq_target(struct cpufreq_policy *policy,
drivers/cpufreq/scmi-cpufreq.c +1 -3
@@ -247,7 +247,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)return ret; } -static int scmi_cpufreq_exit (struct cpufreq_policy *policy) +static void scmi_cpufreq_exit (struct cpufreq_policy *policy) {struct scmi_data *priv = policy->driver_data;
@@ -255,8 +255,6 @@ static int scmi_cpufreq_exit(struct cpufreq_policy *policy)dev_pm_opp_remove_all_dynamic (priv->cpu_dev);free_cpumask_var (priv->opp_shared_cpus);kfree (priv); - -return 0 ; }static void scmi_cpufreq_register_em (struct cpufreq_policy *policy)
drivers/cpufreq/scpi-cpufreq.c +1 -3
@@ -175,7 +175,7 @@ static int scpi_cpufreq_init(struct cpufreq_policy *policy)return ret; } -static int scpi_cpufreq_exit (struct cpufreq_policy *policy) +static void scpi_cpufreq_exit (struct cpufreq_policy *policy) {struct scpi_data *priv = policy->driver_data;
@@ -183,8 +183,6 @@ static int scpi_cpufreq_exit(struct cpufreq_policy *policy)dev_pm_opp_free_cpufreq_table (priv->cpu_dev, &policy->freq_table);dev_pm_opp_remove_all_dynamic (priv->cpu_dev);kfree (priv); - -return 0 ; }static struct cpufreq_driver scpi_cpufreq_driver = {
drivers/cpufreq/sh-cpufreq.c +1 -3
@@ -135,14 +135,12 @@ static int sh_cpufreq_cpu_init(struct cpufreq_policy *policy)return 0 ; } -static int sh_cpufreq_cpu_exit (struct cpufreq_policy *policy) +static void sh_cpufreq_cpu_exit (struct cpufreq_policy *policy) {unsigned int cpu = policy->cpu;struct clk *cpuclk = &per_cpu (sh_cpuclk, cpu);clk_put (cpuclk); - -return 0 ; }static struct cpufreq_driver sh_cpufreq_driver = {
drivers/cpufreq/sparc-us2e-cpufreq.c +1 -2
@@ -296,10 +296,9 @@ static int us2e_freq_cpu_init(struct cpufreq_policy *policy)return 0 ; } -static int us2e_freq_cpu_exit (struct cpufreq_policy *policy) +static void us2e_freq_cpu_exit (struct cpufreq_policy *policy) {us2e_freq_target (policy,0 ); -return 0 ; }static struct cpufreq_driver cpufreq_us2e_driver = {
drivers/cpufreq/sparc-us3-cpufreq.c +1 -2
@@ -140,10 +140,9 @@ static int us3_freq_cpu_init(struct cpufreq_policy *policy)return 0 ; } -static int us3_freq_cpu_exit (struct cpufreq_policy *policy) +static void us3_freq_cpu_exit (struct cpufreq_policy *policy) {us3_freq_target (policy,0 ); -return 0 ; }static struct cpufreq_driver cpufreq_us3_driver = {
drivers/cpufreq/speedstep-centrino.c +3 -7
@@ -400,16 +400,12 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)return 0 ; } -static int centrino_cpu_exit (struct cpufreq_policy *policy) +static void centrino_cpu_exit (struct cpufreq_policy *policy) {unsigned int cpu = policy->cpu; -if (!per_cpu (centrino_model, cpu)) -return -ENODEV ; - -per_cpu (centrino_model, cpu) =NULL ; - -return 0 ; +if (per_cpu (centrino_model, cpu)) +per_cpu (centrino_model, cpu) =NULL ; }/**
drivers/cpufreq/tegra194-cpufreq.c +1 -3
@@ -526,14 +526,12 @@ static int tegra194_cpufreq_offline(struct cpufreq_policy *policy)return 0 ; } -static int tegra194_cpufreq_exit (struct cpufreq_policy *policy) +static void tegra194_cpufreq_exit (struct cpufreq_policy *policy) {struct device *cpu_dev =get_cpu_device (policy->cpu);dev_pm_opp_remove_all_dynamic (cpu_dev);dev_pm_opp_of_cpumask_remove_table (policy->related_cpus); - -return 0 ; } static int tegra194_cpufreq_set_target(struct cpufreq_policy *policy,
drivers/cpufreq/vexpress-spc-cpufreq.c +2 -3
@@ -447,7 +447,7 @@ static int ve_spc_cpufreq_init(struct cpufreq_policy *policy)return 0 ; } -static int ve_spc_cpufreq_exit (struct cpufreq_policy *policy) +static void ve_spc_cpufreq_exit (struct cpufreq_policy *policy) {struct device *cpu_dev;
@@ -455,11 +455,10 @@ static int ve_spc_cpufreq_exit(struct cpufreq_policy *policy)if (!cpu_dev) {pr_err ("%s: failed to get cpu%d device\n" , __func__, policy->cpu); -return -ENODEV ; +return ; }put_cluster_clk_and_freq_table (cpu_dev, policy->related_cpus); -return 0 ; }static struct cpufreq_driver ve_spc_cpufreq_driver = {
include/linux/cpufreq.h +1 -1
@@ -388,7 +388,7 @@ struct cpufreq_driver {int (*online)(struct cpufreq_policy *policy);int (*offline)(struct cpufreq_policy *policy); -int (*exit)(struct cpufreq_policy *policy); +void (*exit)(struct cpufreq_policy *policy);int (*suspend)(struct cpufreq_policy *policy);int (*resume)(struct cpufreq_policy *policy);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1062/1674 cpufreq: qcom-cpufreq-hw: Fix possible double free
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit bcb8889c4981fdde42d4fd2c29a77d510fe21da2 ]
qcom_cpufreq.data is allocated with devm_kzalloc() in probe() as an array of per-domain data. qcom_cpufreq_hw_cpu_init() stores a pointer to one element of this array in policy->driver_data.
qcom_cpufreq_hw_cpu_exit() currently calls kfree() on policy->driver_data. This is not valid because the memory is devm-managed. For the first domain, this can free the devm-managed allocation while the devres entry is still active, leading to a possible double free when the platform device is later detached. For other domains, the pointer may refer to an element inside the array rather than the allocation base.
Remove the kfree(data) call and let devres release qcom_cpufreq.data.
This issue was found by a static analysis tool I am developing.
--- drivers/cpufreq/qcom-cpufreq-hw.c | 1 - 1 file changed, 1 deletion(-)
drivers/cpufreq/qcom-cpufreq-hw.c +0 -1
@@ -583,7 +583,6 @@ static void qcom_cpufreq_hw_cpu_exit(struct cpufreq_policy *policy)dev_pm_opp_of_cpumask_remove_table (policy->related_cpus);qcom_cpufreq_hw_lmh_exit (data);kfree (policy->freq_table); -kfree (data); }static void qcom_cpufreq_ready (struct cpufreq_policy *policy)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1063/1674 smb/client: fix chown/chgrp with SMB3 POSIX Extensions
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ralph Boehme <[email protected]>
[ Upstream commit 760ef2c579c2609cf17fb1cd5392f64d42d43d33 ]
Ownership (chown) and group (chgrp) modifications were being ignored when mounting with SMB3 POSIX Extensions unless CIFS_MOUNT_CIFS_ACL or CIFS_MOUNT_MODE_FROM_SID were also explicitly set.
Fix this by checking for posix_extensions in cifs_setattr_nounix() when updating UID and GID, ensuring that id_mode_to_cifs_acl() is called to map and set the ownership/group information on the server.
--- fs/smb/client/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/smb/client/inode.c +2 -1
@@ -3242,7 +3242,8 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs) gid = attrs->ia_gid;if ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_CIFS_ACL ) || - (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MODE_FROM_SID )) { + (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MODE_FROM_SID ) || +cifs_sb_master_tcon (cifs_sb)->posix_extensions) {if (uid_valid (uid) ||gid_valid (gid)) { mode =NO_CHANGE_64 ; rc = id_mode_to_cifs_acl(inode, full_path, &mode,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1064/1674 ksmbd: validate NTLMv2 response before updating session key
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haofeng Li <[email protected]>
[ Upstream commit 954d196bebb2b50151cb96454c72dc113b2af1ac ]
ksmbd_auth_ntlmv2() derives the NTLMv2 session key into sess->sess_key before it verifies the NTLMv2 response. ksmbd_decode_ntlmssp_auth_blob() then continues into KEY_XCH even when ksmbd_auth_ntlmv2() failed.
With SMB3 multichannel binding, the failed authentication operates on an existing session and the session setup error path does not expire binding sessions. A client can send a binding session setup with a bad NT proof and KEY_XCH and still modify sess->sess_key before STATUS_LOGON_FAILURE is returned.
Relevant path:
smb2_sess_setup()
-> conn->binding = true
-> ntlm_authenticate()
-> session_user()
-> ksmbd_decode_ntlmssp_auth_blob()
-> ksmbd_auth_ntlmv2()
-> calc_ntlmv2_hash()
-> hmac_md5_usingrawkey(..., sess->sess_key)
-> crypto_memneq() returns mismatch
-> KEY_XCH arc4_crypt(..., sess->sess_key, ...)
-> out_err without expiring the binding sessionDerive the base session key into a local buffer and copy it to sess->sess_key only after the proof matches. Return immediately on authentication failure so KEY_XCH is only processed after successful authentication.
--- fs/smb/server/auth.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
fs/smb/server/auth.c +15 -6
@@ -72,13 +72,12 @@ void ksmbd_copy_gss_neg_header(void *buf)/** * ksmbd_gen_sess_key() - function to generate session key -* @sess: session of connection +* @sess_key: output buffer for the generated session key * @hash: source hash value to be used for find session key * @hmac: source hmac value to be used for finding session key * */ -static int ksmbd_gen_sess_key (struct ksmbd_session *sess,char *hash, -char *hmac) +static int ksmbd_gen_sess_key (char *sess_key,char *hash,char *hmac) {struct ksmbd_crypto_ctx *ctx;int rc;
@@ -111,7 +110,7 @@ static int ksmbd_gen_sess_key(struct ksmbd_session *sess, char *hash, goto out; } - rc =crypto_shash_final (CRYPTO_HMACMD5 (ctx), sess->sess_key); + rc =crypto_shash_final (CRYPTO_HMACMD5 (ctx), sess_key);if (rc) {ksmbd_debug (AUTH ,"Could not generate hmacmd5 hash error %d\n" , rc); goto out;
@@ -224,6 +223,7 @@ int ksmbd_auth_ntlmv2(struct ksmbd_conn *conn, struct ksmbd_session *sess, {char ntlmv2_hash[CIFS_ENCPWD_SIZE ];char ntlmv2_rsp[CIFS_HMAC_MD5_HASH_SIZE ]; +char sess_key[SMB2_NTLMV2_SESSKEY_SIZE ];struct ksmbd_crypto_ctx *ctx =NULL ;char *construct =NULL ;int rc, len;
@@ -278,19 +278,26 @@ int ksmbd_auth_ntlmv2(struct ksmbd_conn *conn, struct ksmbd_session *sess,ksmbd_release_crypto_ctx (ctx); ctx =NULL ; - rc =ksmbd_gen_sess_key (sess, ntlmv2_hash, ntlmv2_rsp); + rc =ksmbd_gen_sess_key (sess_key, ntlmv2_hash, ntlmv2_rsp);if (rc) {ksmbd_debug (AUTH ,"Could not generate sess key\n" ); goto out; }if (crypto_memneq (ntlmv2->ntlmv2_hash, ntlmv2_rsp, -CIFS_HMAC_MD5_HASH_SIZE )) +CIFS_HMAC_MD5_HASH_SIZE )) { rc = -EINVAL ; + goto out; + } + +memcpy (sess->sess_key, sess_key,sizeof (sess_key)); out:if (ctx)ksmbd_release_crypto_ctx (ctx);kfree (construct); +memzero_explicit (ntlmv2_hash,sizeof (ntlmv2_hash)); +memzero_explicit (ntlmv2_rsp,sizeof (ntlmv2_rsp)); +memzero_explicit (sess_key,sizeof (sess_key));return rc; }
@@ -348,6 +355,8 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob, nt_len -CIFS_ENCPWD_SIZE , domain_name, conn->ntlmssp.cryptkey);kfree (domain_name); +if (ret) +return ret;/* The recovered secondary session key */ if (conn->ntlmssp.client_flags &NTLMSSP_NEGOTIATE_KEY_XCH ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1065/1674 ksmbd: use opener credentials for ADS I/O
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit baa5e094886fffa7e6272edcb5e08be5ce28262c ]
Alternate data streams are stored as xattrs. Unlike regular file I/O, their read and write paths therefore call VFS xattr helpers which recheck inode permissions and LSM policy using the current task credentials.
Run ADS I/O with the credentials captured when the SMB handle was opened.
--- fs/smb/server/vfs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/smb/server/vfs.c +9 -2
@@ -288,17 +288,20 @@ static ssize_t ksmbd_vfs_getcasexattr(struct mnt_idmap *idmap,static int ksmbd_vfs_stream_read (struct ksmbd_file *fp,char *buf,loff_t *pos,size_t count) { +const struct cred *saved_cred;ssize_t v_len;char *stream_buf =NULL ;ksmbd_debug (VFS ,"read stream data pos : %llu, count : %zd\n" , *pos, count); + saved_cred =override_creds (fp->filp->f_cred); v_len =ksmbd_vfs_getcasexattr (file_mnt_idmap (fp->filp), fp->filp->f_path.dentry, fp->stream.name, fp->stream.size, &stream_buf); +revert_creds (saved_cred);if ((int )v_len <=0 )return (int )v_len;
@@ -417,6 +420,7 @@ int ksmbd_vfs_read(struct ksmbd_work *work, struct ksmbd_file *fp, size_t count,static int ksmbd_vfs_stream_write (struct ksmbd_file *fp,char *buf,loff_t *pos,size_t count) { +const struct cred *saved_cred;char *stream_buf =NULL , *wbuf;struct mnt_idmap *idmap =file_mnt_idmap (fp->filp);size_t size;
@@ -437,6 +441,7 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos, count =XATTR_SIZE_MAX - *pos; } + saved_cred =override_creds (fp->filp->f_cred); v_len = ksmbd_vfs_getcasexattr(idmap, fp->filp->f_path.dentry, fp->stream.name,
@@ -445,14 +450,14 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,if (v_len <0 ) {pr_err ("not found stream in xattr : %zd\n" , v_len); err = v_len; - goto out; + goto out_revert; }if (v_len < size) { wbuf =kvzalloc (size,GFP_KERNEL );if (!wbuf) { err = -ENOMEM ; - goto out; + goto out_revert; }if (v_len >0 )
@@ -470,6 +475,8 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos, size,0 , true); +out_revert: +revert_creds (saved_cred);if (err <0 ) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1066/1674 ksmbd: prevent path traversal bypass by restricting caseless retry
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 54bab9ba5a9f156ffa9324fcbe5a356fd0242f95 ]
ksmbd_vfs_path_lookup() enforces LOOKUP_BENEATH to restrict path resolution within the share root. When a crafted path attempts to escape the share boundary using parent-directory components ('..'), vfs_path_parent_lookup() detects this and immediately fails, returning -EXDEV.
However, a bug exists in __ksmbd_vfs_kern_path() under caseless mode. The function fails to intercept the -EXDEV error and erroneously falls through to the caseless retry logic, which is intended only for genuinely missing files. During this retry process, the path is reconstructed, leading to an unintended LOOKUP_BENEATH bypass that allows write-capable users to create zero-length files or directories outside the exported share.
Fix this by ensuring that the execution only proceeds to the caseless lookup retry when the error is specifically -ENOENT. Any other errors, such as -EXDEV from a path traversal attempt, must be returned immediately.
--- fs/smb/server/vfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/server/vfs.c +2 -2
@@ -1255,7 +1255,7 @@ int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,if (!err)return 0 ; -if (caseless) { +if (caseless && err == -ENOENT ) {char *filepath;size_t path_len, remain_len;
@@ -1286,7 +1286,7 @@ int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name, err =vfs_path_lookup (share_conf->vfs_path.dentry, share_conf->vfs_path.mnt, filepath, - flags, + flags |LOOKUP_BENEATH , path);if (!is_last) next[0 ] ='/' ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1067/1674 ALSA: hda/cs35l41: Fix firmware load work teardown
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
[ Upstream commit b65020d5398f499c09498c9786dba6d67ae57664 ]
cs35l41_hda creates ALSA controls whose private data points at the cs35l41_hda object. The firmware load control can also queue fw_load_work.
Those controls are not removed on component unbind, and device remove only cancels fw_load_work through cs35l41_remove_dsp(). That helper is skipped when halo_initialized is false. With firmware_autostart disabled, a firmware load can be requested before the DSP has been initialized. If the component or device is removed before the queued work runs, the worker can run after teardown and dereference driver state that is no longer valid.
Track the created controls and remove them on unbind so no new control callback can reach the driver data or queue more work. Then cancel fw_load_work to drain any request that was already queued. Also cancel the work unconditionally during device remove before runtime PM teardown.
--- sound/pci/hda/cs35l41_hda.c | 73 ++++++++++++++++++++++++++++++------- sound/pci/hda/cs35l41_hda.h | 5 +++ 2 files changed, 64 insertions(+), 14 deletions(-)
sound/pci/hda/cs35l41_hda.c +59 -14
@@ -1072,6 +1072,44 @@ static int cs35l41_fw_type_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctreturn snd_ctl_enum_info (uinfo,1 ,ARRAY_SIZE (hda_cs_dsp_fw_ids), hda_cs_dsp_fw_ids); } +static void cs35l41_remove_controls (struct cs35l41_hda *cs35l41) +{ +guard (mutex)(&cs35l41->ctl_lock); + +if (!cs35l41->codec) +return ; + +if (cs35l41->fw_load_ctl) +snd_ctl_remove (cs35l41->codec->card, cs35l41->fw_load_ctl); + cs35l41->fw_load_ctl =NULL ; + +if (cs35l41->fw_type_ctl) +snd_ctl_remove (cs35l41->codec->card, cs35l41->fw_type_ctl); + cs35l41->fw_type_ctl =NULL ; +} + +static int cs35l41_add_control (struct cs35l41_hda *cs35l41, +struct snd_kcontrol_new *ctl, +struct snd_kcontrol **kctl) +{ +int ret; + + *kctl =snd_ctl_new1 (ctl, cs35l41); +if (!*kctl) +return -ENOMEM ; + + ret =snd_ctl_add (cs35l41->codec->card, *kctl); +if (ret) { +dev_err (cs35l41->dev,"Failed to add KControl %s = %d\n" , ctl->name, ret); + *kctl =NULL ; +return ret; + } + +dev_dbg (cs35l41->dev,"Added Control %s\n" , ctl->name); + +return 0 ; +} +static int cs35l41_create_controls (struct cs35l41_hda *cs35l41) {char fw_type_ctl_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ];
@@ -1097,23 +1135,19 @@ static int cs35l41_create_controls(struct cs35l41_hda *cs35l41)scnprintf (fw_load_ctl_name,SNDRV_CTL_ELEM_ID_NAME_MAXLEN ,"%s DSP1 Firmware Load" , cs35l41->amp_name); - ret =snd_ctl_add (cs35l41->codec->card,snd_ctl_new1 (&fw_type_ctl, cs35l41)); -if (ret) { -dev_err (cs35l41->dev,"Failed to add KControl %s = %d\n" , fw_type_ctl.name, ret); -return ret; - } - -dev_dbg (cs35l41->dev,"Added Control %s\n" , fw_type_ctl.name); - - ret =snd_ctl_add (cs35l41->codec->card,snd_ctl_new1 (&fw_load_ctl, cs35l41)); -if (ret) { -dev_err (cs35l41->dev,"Failed to add KControl %s = %d\n" , fw_load_ctl.name, ret); -return ret; - } + ret =cs35l41_add_control (cs35l41, &fw_type_ctl, &cs35l41->fw_type_ctl); +if (ret) + goto err; -dev_dbg (cs35l41->dev,"Added Control %s\n" , fw_load_ctl.name); + ret =cs35l41_add_control (cs35l41, &fw_load_ctl, &cs35l41->fw_load_ctl); +if (ret) + goto err;return 0 ; + +err: +cs35l41_remove_controls (cs35l41); +return ret; }static int cs35l41_hda_bind (struct device *dev,struct device *master,void *master_data)
@@ -1189,6 +1223,13 @@ static void cs35l41_hda_unbind(struct device *dev, struct device *master, void * sleep_flags =lock_system_sleep ();device_link_remove (&cs35l41->codec->core.dev, cs35l41->dev);unlock_system_sleep (sleep_flags); + +cs35l41_remove_controls (cs35l41); +cancel_work_sync (&cs35l41->fw_load_work); + +mutex_lock (&cs35l41->ctl_lock); + cs35l41->codec =NULL ; +mutex_unlock (&cs35l41->ctl_lock); } }
@@ -1653,6 +1694,7 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int iINIT_WORK (&cs35l41->fw_load_work, cs35l41_fw_load_work);mutex_init (&cs35l41->fw_mutex); +mutex_init (&cs35l41->ctl_lock);pm_runtime_set_autosuspend_delay (cs35l41->dev,3000 );pm_runtime_use_autosuspend (cs35l41->dev);
@@ -1696,6 +1738,9 @@ void cs35l41_hda_remove(struct device *dev) {struct cs35l41_hda *cs35l41 =dev_get_drvdata (dev); +cs35l41_remove_controls (cs35l41); +cancel_work_sync (&cs35l41->fw_load_work); +pm_runtime_get_sync (cs35l41->dev);pm_runtime_dont_use_autosuspend (cs35l41->dev);pm_runtime_disable (cs35l41->dev);
sound/pci/hda/cs35l41_hda.h +5 -0
@@ -45,6 +45,8 @@ enum cs35l41_hda_gpio_function { CS35l41_SYNC, }; +struct snd_kcontrol ; +struct cs35l41_hda {struct device *dev;struct regmap *regmap;
@@ -61,7 +63,10 @@ struct cs35l41_hda {int firmware_type;int speaker_id;struct mutex fw_mutex; +struct mutex ctl_lock;struct work_struct fw_load_work; +struct snd_kcontrol *fw_type_ctl; +struct snd_kcontrol *fw_load_ctl;struct regmap_irq_chip_data *irq_data;bool firmware_running;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1068/1674 net/handshake: Take a long-lived file reference at submit
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 09dba37eee70d0596e26645015f1aa95a9848e9d ]
handshake_nl_accept_doit() needs the file pointer backing req->hr_sk->sk_socket to survive the window between handshake_req_next() and the subsequent FD_PREPARE() and get_file(). The submit-side sock_hold() does not provide that. sk_refcnt keeps struct sock alive, but struct socket is owned by sock->file: when the consumer fputs the last file reference, sock_release() tears the socket down regardless of any sock_hold.
Add an hr_file pointer to struct handshake_req and acquire an explicit reference on sock->file during handshake_req_submit(). handshake_complete() and handshake_req_cancel() release the reference on the completion-bit-winning path.
The submit error path must also release the file reference, but after rhashtable insertion a concurrent handshake_req_cancel() can discover the request and race the error path. Gate the error-path cleanup -- sk_destruct restoration, fput, and request destruction -- with test_and_set_bit(HANDSHAKE_F_REQ_COMPLETED), the same serialization handshake_complete() and handshake_req_cancel() already use. When cancel has already claimed ownership, the submit error path returns without touching the request; socket teardown handles final destruction.
The accept-side dereferences are not yet retargeted; that change comes in the next patch.
--- net/handshake/handshake.h | 2 ++ net/handshake/netlink.c | 5 ----- net/handshake/request.c | 42 ++++++++++++++++++++++++++++++++------- 3 files changed, 37 insertions(+), 12 deletions(-)
net/handshake/handshake.h +2 -0
@@ -24,6 +24,7 @@ enum hn_flags_bits { HANDSHAKE_F_NET_DRAINING, }; +struct file ;struct handshake_proto ;/* One handshake request */
@@ -32,6 +33,7 @@ struct handshake_req {struct rhash_head hr_rhash;unsigned long hr_flags;const struct handshake_proto *hr_proto; +struct file *hr_file;struct sock *hr_sk;void (*hr_odestruct)(struct sock *sk);
net/handshake/netlink.c +0 -5
@@ -217,11 +217,6 @@ static void __net_exit handshake_net_exit(struct net *net) sk = req->hr_sk;list_del_init (&req->hr_list); -/* -* Requests on this list have not yet been -* accepted, so they do not have an fd to put. -*/ -handshake_complete (req, -ETIMEDOUT ,NULL );sock_put (sk); }
net/handshake/request.c +35 -7
90 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1069/1674 Bluetooth: eir: Fix stack OOB write when prepending the Flags AD
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 6f5fb689fdf80bdd143f22a502f9eb1f3c85e286 ]
eir_create_adv_data() builds the advertising data into a fixed-size buffer ("size", 31 for the legacy path). It may prepend a 3-byte "Flags" AD structure (LE_AD_NO_BREDR on an LE-only controller) and then copies the per-instance data without checking that it still fits:
memcpy(ptr, adv->adv_data, adv->adv_data_len);
tlv_data_max_len() only reserves those 3 bytes when the user-supplied flags carry a managed-flags bit, so an instance added with flags == 0 is accepted with adv_data_len up to the full buffer. At advertise time the flags are still prepended, and the memcpy() writes 3 + adv_data_len bytes into the size-byte buffer:
BUG: KASAN: stack-out-of-bounds in eir_create_adv_data (net/bluetooth/eir.c:301) Write of size 31 at addr ffff88800a547bdc by task kworker/u9:0/65 Workqueue: hci0 hci_cmd_sync_work __asan_memcpy (mm/kasan/shadow.c:106) eir_create_adv_data (net/bluetooth/eir.c:301) hci_update_adv_data_sync (net/bluetooth/hci_sync.c:1310) hci_schedule_adv_instance_sync (net/bluetooth/hci_sync.c:1817) hci_cmd_sync_work (net/bluetooth/hci_sync.c:332) This frame has 1 object: [32, 64) 'cp'
The "Flags" structure is added by the kernel, not requested by userspace, so only prepend it when it fits together with the instance advertising data; when there is no room for both, drop the flags rather than the user-provided data.
Reachable by a local user with CAP_NET_ADMIN owning an LE-only controller on the legacy advertising path.
--- net/bluetooth/eir.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/bluetooth/eir.c +5 -3
@@ -283,10 +283,12 @@ u8 eir_create_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr, u8 size)if (!flags) flags |=mgmt_get_adv_discov_flags (hdev); -/* If flags would still be empty, then there is no need to -* include the "Flags" AD field". +/* Only add the "Flags" if it fits together with the instance +* advertising data; drop it rather than overflow the buffer. */ -if (flags && (ad_len +eir_precalc_len (1 ) <= size)) { +if (flags && + (ad_len +eir_precalc_len (1 ) + + (adv ? adv->adv_data_len :0 ) <= size)) { ptr[0 ] =0x02 ; ptr[1 ] =EIR_FLAGS ; ptr[2 ] = flags;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1070/1674 KVM: nVMX: Put vmcs12 pages if nested VM-Enter fails due to invalid guest state
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 2f2312c422fd2695da772cecb30c69994b795964 ]
Put all vmcs12 pages if KVM synthesizes a nested VM-Exit due to invalid guest while emulating VMLAUNCH or VMRESUME. The invalid guest state path doesn't use nested_vmx_vmexit() as that API is intended to be used if and only if L2 is active, and the open coded equivalent neglects to put the vmcs12 pages. Failure to put the vmcs12 pages leaks any pinned pages (and/or mappings) if L1 retries VMLAUNCH/VMRESUME.
Note, the !from_vmenter scenario doesn't suffer the same problem, as vmx_get_nested_state_pages() only gets/pins/maps the vmcs12 pages if L2 is active, i.e. if a "full" VM-Exit is guaranteed before KVM will retry getting vmcs12 pages.
--- arch/x86/kvm/vmx/nested.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/x86/kvm/vmx/nested.c +5 -0
@@ -3571,6 +3571,11 @@ enum nvmx_vmentry_status nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu,if (!from_vmentry)return NVMX_VMENTRY_VMEXIT ; +kvm_vcpu_unmap (vcpu, &vmx->nested.apic_access_page_map, false); +kvm_vcpu_unmap (vcpu, &vmx->nested.virtual_apic_map, true); +kvm_vcpu_unmap (vcpu, &vmx->nested.pi_desc_map, true); + vmx->nested.pi_desc =NULL ; +load_vmcs12_host_state (vcpu, vmcs12); vmcs12->vm_exit_reason = exit_reason.full;if (enable_shadow_vmcs ||evmptr_is_valid (vmx->nested.hv_evmcs_vmptr))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1071/1674 ksmbd_vfs_rename(): vfs_path_parent_lookup() accepts ERR_PTR() as name
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit ba33ac100d3feb1efb43b32e63cc0c6430936aa3 ]
no need to check in the caller
Stable-dep-of: 1c8951963d8e ("ksmbd: fix path resolution in ksmbd_vfs_kern_path_create")
--- fs/smb/server/vfs.c | 5 ----- 1 file changed, 5 deletions(-)
fs/smb/server/vfs.c +0 -5
@@ -712,10 +712,6 @@ int ksmbd_vfs_rename(struct ksmbd_work *work, const struct path *old_path,return -ENOMEM ; to =getname_kernel (newname); -if (IS_ERR (to)) { - err =PTR_ERR (to); - goto revert_fsids; - } retry: err = vfs_path_parent_lookup(to, lookup_flags | LOOKUP_BENEATH,
@@ -817,7 +813,6 @@ int ksmbd_vfs_rename(struct ksmbd_work *work, const struct path *old_path, } out1:putname (to); -revert_fsids:ksmbd_revert_fsids (work);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1072/1674 vfs: make LAST_XXX private to fs/namei.c
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jori Koolstra <[email protected]>
[ Upstream commit f2f1dddccae50f7a1d088285c53c376e26cedf67 ]
The only user of LAST_XXX outside of fs/namei.c is fs/smb/server/vfs.c; ksmbd_vfs_path_lookup() calls vfs_path_parent_lookup() and expects a LAST_NORM last type (or it will be ENOENT). ksmbd_vfs_rename() also calls vfs_path_parent_lookup() but forgets the LAST_NORM check.
It does not really make sense to have vfs_path_parent_lookup() expose the last_type because it is only needed to ensure it is LAST_NORM. So let's do this check in vfs_path_parent_lookup() instead and keep the LAST_XXX internal to fs/namei.c. This changes the ENOENT errno in ksmbd_vfs_path_lookup() to EINVAL, which matches better with how this is handled by callers of filename_parentat().
Stable-dep-of: 1c8951963d8e ("ksmbd: fix path resolution in ksmbd_vfs_kern_path_create")
--- fs/namei.c | 20 ++++++++++++++++---- fs/smb/server/vfs.c | 14 +++----------- include/linux/namei.h | 7 +------ 3 files changed, 20 insertions(+), 21 deletions(-)
fs/namei.c +16 -4
@@ -126,6 +126,11 @@#define EMBEDDED_NAME_MAX (PATH_MAX - offsetof(struct filename, iname)) +/* +* Type of the last component on LOOKUP_PARENT +*/ +enum {LAST_NORM ,LAST_ROOT ,LAST_DOT ,LAST_DOTDOT }; +struct filename *getname_flags (const char __user *filename,int flags,int *empty) {
@@ -2701,15 +2706,22 @@ EXPORT_SYMBOL(kern_path);* @flags: lookup flags * @parent: pointer to struct path to fill * @last: last component -* @type: type of the last component * @root: pointer to struct path of the base directory */ int vfs_path_parent_lookup (struct filename *filename,unsigned int flags, -struct path *parent,struct qstr *last,int *type, +struct path *parent,struct qstr *last,const struct path *root) { -return __filename_parentat (AT_FDCWD , filename, flags, parent, last, - type, root); +int type; +int err =__filename_parentat (AT_FDCWD , filename, flags, parent, last, + &type, root); +if (err) +return err; +if (unlikely (type !=LAST_NORM )) { +path_put (parent); +return -EINVAL ; + } +return 0 ; }EXPORT_SYMBOL (vfs_path_parent_lookup);
fs/smb/server/vfs.c +3 -11
@@ -73,7 +73,7 @@ static int ksmbd_vfs_path_lookup_locked(struct ksmbd_share_config *share_conf,struct qstr last;struct filename *filename;struct path *root_share_path = &share_conf->vfs_path; -int err, type; +int err;struct dentry *d;if (pathname[0 ] =='\0' ) {
@@ -88,19 +88,13 @@ static int ksmbd_vfs_path_lookup_locked(struct ksmbd_share_config *share_conf,return PTR_ERR (filename); err =vfs_path_parent_lookup (filename, flags, - parent_path, &last, &type, + parent_path, &last, root_share_path);if (err) {putname (filename);return err; } -if (unlikely (type !=LAST_NORM )) { -path_put (parent_path); -putname (filename); -return -ENOENT ; - } - err =mnt_want_write (parent_path->mnt);if (err) {path_put (parent_path);
@@ -705,7 +699,6 @@ int ksmbd_vfs_rename(struct ksmbd_work *work, const struct path *old_path,struct filename *to;struct ksmbd_share_config *share_conf = work->tcon->share_conf;struct ksmbd_file *parent_fp; -int new_type;int err, lookup_flags =LOOKUP_NO_SYMLINKS ;if (ksmbd_override_fsids (work))
@@ -715,8 +708,7 @@ int ksmbd_vfs_rename(struct ksmbd_work *work, const struct path *old_path, retry: err =vfs_path_parent_lookup (to, lookup_flags |LOOKUP_BENEATH , - &new_path, &new_last, &new_type, - &share_conf->vfs_path); + &new_path, &new_last, &share_conf->vfs_path);if (err) goto out1;
include/linux/namei.h +1 -6
@@ -12,11 +12,6 @@ enum { MAX_NESTED_LINKS = 8 };#define MAXSYMLINKS 40 -/* -* Type of the last component on LOOKUP_PARENT -*/ -enum {LAST_NORM ,LAST_ROOT ,LAST_DOT ,LAST_DOTDOT }; -/* pathwalk mode */ #define LOOKUP_FOLLOW 0x0001/* follow links at the end */ #define LOOKUP_DIRECTORY 0x0002/* require a directory */
@@ -68,7 +63,7 @@ extern struct dentry *user_path_create(int, const char __user *, struct path *,extern void done_path_create (struct path *,struct dentry *);extern struct dentry *kern_path_locked (const char *,struct path *);int vfs_path_parent_lookup (struct filename *filename,unsigned int flags, -struct path *parent,struct qstr *last,int *type, +struct path *parent,struct qstr *last,const struct path *root);int vfs_path_lookup (struct dentry *,struct vfsmount *,const char *,unsigned int ,struct path *);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1073/1674 ksmbd: fix path resolution in ksmbd_vfs_kern_path_create
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Davide Ornaghi <[email protected]>
[ Upstream commit 1c8951963d8ed357f70f59e0ad4ddce2199d2016 ]
The SMB2 open lookup is rooted at the share with LOOKUP_BENEATH, but the create/mkdir/hardlink sink is not: ksmbd_vfs_kern_path_create() builds an absolute path with convert_to_unix_name() and resolves it from AT_FDCWD via start_creating_path(), so a ".." component is walked from the real filesystem root and escapes the export.
An authenticated client races a missing path component so the rooted open lookup returns -ENOENT (taking the create branch) while the same component is present (a directory) when the create walk runs; the create then resolves ".." out of the share.
Root the create walk at the share like the lookup and rename paths already
are: resolve the parent with vfs_path_parent_lookup(..., LOOKUP_BENEATH, &share_conf->vfs_path) and create the final component with start_creating_noperm(). convert_to_unix_name() then has no callers and is removed.
--- fs/smb/server/misc.c | 33 --------------------------------- fs/smb/server/misc.h | 1 - fs/smb/server/vfs.c | 36 ++++++++++++++++++++++++++++++------ 3 files changed, 30 insertions(+), 40 deletions(-)
fs/smb/server/misc.c +0 -33
@@ -285,39 +285,6 @@ char *ksmbd_extract_sharename(struct unicode_map *um, const char *treename)return ksmbd_casefold_sharename (um, name); } -/** -* convert_to_unix_name() - convert windows name to unix format -* @share: ksmbd_share_config pointer -* @name: file name that is relative to share -* -* Return: converted name on success, otherwise NULL -*/ -char *convert_to_unix_name (struct ksmbd_share_config *share,const char *name) -{ -int no_slash =0 , name_len, path_len; -char *new_name; - -if (name[0 ] =='/' ) - name++; - - path_len = share->path_sz; - name_len =strlen (name); - new_name =kmalloc (path_len + name_len +2 ,GFP_KERNEL ); -if (!new_name) -return new_name; - -memcpy (new_name, share->path, path_len); -if (new_name[path_len -1 ] !='/' ) { - new_name[path_len] ='/' ; - no_slash =1 ; - } - -memcpy (new_name + path_len + no_slash, name, name_len); - path_len += name_len + no_slash; - new_name[path_len] =0x00 ; -return new_name; -} -char *ksmbd_convert_dir_info_name (struct ksmbd_dir_info *d_info,const struct nls_table *local_nls,int *conv_len)
fs/smb/server/misc.h +0 -1
@@ -22,7 +22,6 @@ void ksmbd_strip_last_slash(char *path);void ksmbd_conv_path_to_windows (char *path);char *ksmbd_casefold_sharename (struct unicode_map *um,const char *name);char *ksmbd_extract_sharename (struct unicode_map *um,const char *treename); -char *convert_to_unix_name (struct ksmbd_share_config *share,const char *name);#define KSMBD_DIR_INFO_ALIGNMENT 8struct ksmbd_dir_info ;
fs/smb/server/vfs.c +30 -6
@@ -1324,15 +1324,39 @@ struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,unsigned int flags, struct path *path) { - char *abs_name; + struct ksmbd_share_config *share_conf = work->tcon->share_conf; +struct filename *filename; +struct qstr last;struct dentry *dent; +int err; - abs_name =convert_to_unix_name (work->tcon->share_conf, name); -if (!abs_name) -return ERR_PTR (-ENOMEM ); +/* resolve the name beneath the share root so ".." cannot escape */ + filename =getname_kernel (name); +if (IS_ERR (filename)) +return ERR_CAST (filename); + + err =vfs_path_parent_lookup (filename, flags |LOOKUP_BENEATH , + path, &last, &share_conf->vfs_path); +if (err) { +putname (filename); +return ERR_PTR (err); + } - dent =kern_path_create (AT_FDCWD , abs_name, path, flags); -kfree (abs_name); + err =mnt_want_write (path->mnt); +if (err) { +path_put (path); +putname (filename); +return ERR_PTR (err); + } + +inode_lock_nested (path->dentry->d_inode,I_MUTEX_PARENT ); + dent =lookup_one_qstr_excl (&last, path->dentry,LOOKUP_CREATE ); +if (IS_ERR (dent)) { +inode_unlock (path->dentry->d_inode); +mnt_drop_write (path->mnt); +path_put (path); + } +putname (filename);return dent; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1074/1674 LoongArch: Move jump_label_init() before parse_early_param()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kanglong Wang <[email protected]>
[ Upstream commit ea68d444a658783234a06f05414e41cf93a18fb2 ]
When enabling both CONFIG_MEM_ALLOC_PROFILING=y and CONFIG_MEM_ALLOC_PROFILING_ENABLED_BY_DEFAULT=y, then diabling memory profiling by adding the boot parameter 'sysctl.vm.mem_profiling=0' will cause the kernel failed to boot.
After analysis, this is because jump_label_init() must be called before parse_early_param(), the early param handlers may modify static keys by static_branch_enable/disable().
Fix this by moving jump_label_init() to before parse_early_param(). The solution is similar to other architectures.
--- arch/loongarch/kernel/setup.c | 1 + 1 file changed, 1 insertion(+)
arch/loongarch/kernel/setup.c +1 -0
@@ -627,6 +627,7 @@ void __init setup_arch(char **cmdline_p)memblock_init ();pagetable_init ();bootcmdline_init (cmdline_p); +jump_label_init ();/* Initialise the static keys for early params */ parse_early_param ();reserve_initrd_mem ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1075/1674 media: vivid: fix cleanup bugs in vivid_init()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit a07c179a92e949172ca52f6d4a13202ea88cd4b7 ]
When platform_device_register() fails in vivid_init(), the embedded struct device in vivid_pdev has already been initialized by device_initialize(), but the failure path jumps to free_output_strings without dropping the device reference for the current platform device:
vivid_init()
-> platform_device_register(&vivid_pdev)
-> device_initialize(&vivid_pdev.dev)
-> setup_pdev_dma_masks(&vivid_pdev)
-> platform_device_add(&vivid_pdev)This leads to a reference leak when platform_device_register() fails. Fix this by calling platform_device_put() before jumping to the common cleanup path.
Also, the unreg_driver label incorrectly calls platform_driver_register() instead of platform_driver_unregister(), which breaks cleanup when workqueue creation fails after successful driver registration. Fix that as well.
The reference leak was identified by a static analysis tool I developed and confirmed by manual review. The incorrect cleanup call was found during code inspection.
--- drivers/media/test-drivers/vivid/vivid-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/test-drivers/vivid/vivid-core.c +3 -1
@@ -2125,8 +2125,10 @@ static int __init vivid_init(void)int ret; ret =platform_device_register (&vivid_pdev); -if (ret) +if (ret) { +platform_device_put (&vivid_pdev);return ret; + } ret =platform_driver_register (&vivid_pdrv);if (ret)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1076/1674 drm/vc4: Shut down BO cache timer before teardown
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 6273dd3ffb54ec581855b82ae77331b66028249c ]
The BO cache timer callback schedules time_work, and time_work can rearm the timer through vc4_bo_cache_free_old().
vc4_bo_cache_destroy() deletes the timer and then cancels the work, which does not break that cycle: the work being cancelled can rearm the timer, and the timer then queues work again after teardown.
Use timer_shutdown_sync() instead, so the timer cannot be rearmed and the cycle ends with cancel_work_sync().
--- drivers/gpu/drm/vc4/vc4_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_bo.c +1 -1
@@ -1050,7 +1050,7 @@ static void vc4_bo_cache_destroy(struct drm_device *dev, void *unused)struct vc4_dev *vc4 =to_vc4_dev (dev);int i; -del_timer (&vc4->bo_cache.time_timer); +timer_shutdown_sync (&vc4->bo_cache.time_timer);cancel_work_sync (&vc4->bo_cache.time_work);vc4_bo_cache_purge (dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1077/1674 drm/amdgpu: Use dbg level for VBIOS check messages
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lijo Lazar <[email protected]>
[ Upstream commit 635c659fceed82f934623188471ff604e098aab7 ]
Driver has different ways to fetch VBIOS. If one of the methods doesn't find an authentic one, it will show misleading info messages eventhough a subsequent method finds a valid VBIOS. Keep the message level at debug and add device context.
Stable-dep-of: 65bff2661760 ("drm/amdgpu: Release VFCT ACPI table reference")
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 26 +++++++++++++----------- 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +14 -12
@@ -47,35 +47,37 @@/* Check if current bios is an ATOM BIOS. * Return true if it is ATOM BIOS. Otherwise, return false. */ -static bool check_atom_bios (uint8_t *bios,size_t size) +static bool check_atom_bios (struct amdgpu_device *adev,size_t size) {uint16_t tmp, bios_header_start; +uint8_t *bios = adev->bios;if (!bios || size <0x49 ) { -DRM_INFO ("vbios mem is null or mem size is wrong\n" ); +dev_dbg (adev->dev,"VBIOS mem is null or mem size is wrong\n" );return false; }if (!AMD_IS_VALID_VBIOS (bios)) { -DRM_INFO ("BIOS signature incorrect %x %x\n" , bios[0 ], bios[1 ]); +dev_dbg (adev->dev,"VBIOS signature incorrect %x %x\n" , bios[0 ], + bios[1 ]);return false; } bios_header_start = bios[0x48 ] | (bios[0x49 ] <<8 );if (!bios_header_start) { -DRM_INFO ("Can't locate bios header\n" ); +dev_dbg (adev->dev,"Can't locate VBIOS header\n" );return false; } tmp = bios_header_start +4 ;if (size < tmp) { -DRM_INFO ("BIOS header is broken\n" ); +dev_dbg (adev->dev,"VBIOS header is broken\n" );return false; }if (!memcmp (bios + tmp,"ATOM" ,4 ) || !memcmp (bios + tmp,"MOTA" ,4 )) { -DRM_DEBUG ("ATOMBIOS detected\n" ); +dev_dbg (adev->dev,"ATOMBIOS detected\n" );return true; }
@@ -117,7 +119,7 @@ static bool igp_read_bios_from_vram(struct amdgpu_device *adev)memcpy_fromio (adev->bios, bios, size);iounmap (bios); -if (!check_atom_bios (adev->bios, size)) { +if (!check_atom_bios (adev, size)) {kfree (adev->bios);return false; }
@@ -145,7 +147,7 @@ bool amdgpu_read_bios(struct amdgpu_device *adev)memcpy_fromio (adev->bios, bios, size);pci_unmap_rom (adev->pdev, bios); -if (!check_atom_bios (adev->bios, size)) { +if (!check_atom_bios (adev, size)) {kfree (adev->bios);return false; }
@@ -185,7 +187,7 @@ static bool amdgpu_read_bios_from_rom(struct amdgpu_device *adev)/* read complete BIOS */ amdgpu_asic_read_bios_from_rom (adev, adev->bios, len); -if (!check_atom_bios (adev->bios, len)) { +if (!check_atom_bios (adev, len)) {kfree (adev->bios);return false; }
@@ -215,7 +217,7 @@ static bool amdgpu_read_platform_bios(struct amdgpu_device *adev)memcpy_fromio (adev->bios, bios, romlen);iounmap (bios); -if (!check_atom_bios (adev->bios, romlen)) +if (!check_atom_bios (adev, romlen)) goto free_bios; adev->bios_size = romlen;
@@ -337,7 +339,7 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev)break ; } -if (!check_atom_bios (adev->bios, size)) { +if (!check_atom_bios (adev, size)) {kfree (adev->bios);return false; }
@@ -440,7 +442,7 @@ static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) vhdr->ImageLength, GFP_KERNEL); -if (!check_atom_bios (adev->bios, vhdr->ImageLength)) { +if (!check_atom_bios (adev, vhdr->ImageLength)) {kfree (adev->bios);return false; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1078/1674 drm/amdgpu: Add wrapper for freeing vbios memory
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lijo Lazar <[email protected]>
[ Upstream commit e986e89659e18ba986db044df58f165042817dc3 ]
Use bios_release wrapper to release memory allocated for vbios image and reset the variables.
v2:
Use the same wrapper for clean up in sw_fini (Alex Deucher)
Stable-dep-of: 65bff2661760 ("drm/amdgpu: Release VFCT ACPI table reference")
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 20 ++++++++++++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 +-- 3 files changed, 16 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -385,6 +385,7 @@ bool amdgpu_get_bios(struct amdgpu_device *adev);bool amdgpu_read_bios (struct amdgpu_device *adev);bool amdgpu_soc15_read_bios_from_rom (struct amdgpu_device *adev,u8 *bios,u32 length_bytes); +void amdgpu_bios_release (struct amdgpu_device *adev);/* * Clocks */
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +14 -6
@@ -84,6 +84,13 @@ static bool check_atom_bios(struct amdgpu_device *adev, size_t size)return false; } +void amdgpu_bios_release (struct amdgpu_device *adev) +{ +kfree (adev->bios); + adev->bios =NULL ; + adev->bios_size =0 ; +} +/* If you boot an IGP board with a discrete card as the primary, * the IGP rom is not accessible via the rom bar as the IGP rom is * part of the system bios. On boot, the system bios puts a
@@ -120,7 +127,7 @@ static bool igp_read_bios_from_vram(struct amdgpu_device *adev)iounmap (bios);if (!check_atom_bios (adev, size)) { -kfree (adev->bios); +amdgpu_bios_release (adev);return false; }
@@ -148,7 +155,7 @@ bool amdgpu_read_bios(struct amdgpu_device *adev)pci_unmap_rom (adev->pdev, bios);if (!check_atom_bios (adev, size)) { -kfree (adev->bios); +amdgpu_bios_release (adev);return false; }
@@ -188,7 +195,7 @@ static bool amdgpu_read_bios_from_rom(struct amdgpu_device *adev)amdgpu_asic_read_bios_from_rom (adev, adev->bios, len);if (!check_atom_bios (adev, len)) { -kfree (adev->bios); +amdgpu_bios_release (adev);return false; }
@@ -224,7 +231,8 @@ static bool amdgpu_read_platform_bios(struct amdgpu_device *adev)return true; free_bios: -kfree (adev->bios); +amdgpu_bios_release (adev); +return false; }
@@ -340,7 +348,7 @@ static bool amdgpu_atrm_get_bios(struct amdgpu_device *adev) }if (!check_atom_bios (adev, size)) { -kfree (adev->bios); +amdgpu_bios_release (adev);return false; } adev->bios_size = size;
@@ -443,7 +451,7 @@ static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) GFP_KERNEL);if (!check_atom_bios (adev, vhdr->ImageLength)) { -kfree (adev->bios); +amdgpu_bios_release (adev);return false; } adev->bios_size = vhdr->ImageLength;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -2
@@ -4164,8 +4164,7 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)if (amdgpu_emu_mode !=1 )amdgpu_atombios_fini (adev); -kfree (adev->bios); - adev->bios =NULL ; +amdgpu_bios_release (adev); px =amdgpu_device_supports_px (adev_to_drm (adev));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1079/1674 drm/amdgpu: Release VFCT ACPI table reference
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
[ Upstream commit 65bff26617607c1331283232016c0e89088c5b78 ]
amdgpu_acpi_vfct_bios() fetches the VFCT table with acpi_get_table() but never releases it. acpi_get_table() takes a reference on the table (incrementing its validation_count and mapping it on the 0->1 transition); without a paired acpi_put_table() the mapping is leaked on every call, whether or not a matching VBIOS image is found.
Route all exit paths after the table is acquired through a common acpi_put_table(). The VBIOS image is copied out with kmemdup() before the table is released, so it remains valid for the caller.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +11 -6
@@ -416,13 +416,14 @@ static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)acpi_size tbl_size;UEFI_ACPI_VFCT *vfct;unsigned int offset; +bool r = false;if (!ACPI_SUCCESS (acpi_get_table ("VFCT" ,1 , &hdr)))return false; tbl_size = hdr->length;if (tbl_size <sizeof (UEFI_ACPI_VFCT )) {dev_info (adev->dev,"ACPI VFCT table present but broken (too short #1),skipping\n" ); -return false; + goto out; } vfct = (UEFI_ACPI_VFCT *)hdr;
@@ -435,13 +436,13 @@ static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev) offset +=sizeof (VFCT_IMAGE_HEADER );if (offset > tbl_size) {dev_info (adev->dev,"ACPI VFCT image header truncated,skipping\n" ); -return false; + goto out; } offset += vhdr->ImageLength;if (offset > tbl_size) {dev_info (adev->dev,"ACPI VFCT image truncated,skipping\n" ); -return false; + goto out; } if (vhdr->ImageLength &&
@@ -452,15 +453,19 @@ static bool amdgpu_acpi_vfct_bios(struct amdgpu_device *adev)if (!check_atom_bios (adev, vhdr->ImageLength)) {amdgpu_bios_release (adev); -return false; + goto out; } adev->bios_size = vhdr->ImageLength; - return true; + r = true; + goto out; } }dev_info (adev->dev,"ACPI VFCT table present but broken (too short #2),skipping\n" ); -return false; + +out: +acpi_put_table (hdr); +return r; }#else static inline bool amdgpu_acpi_vfct_bios (struct amdgpu_device *adev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1080/1674 drm/i915/mst: limit DP MST ESI service loop
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
[ Upstream commit 005771c18c5b2c98cb4e7517661aea460990fd3f ]
The loop in intel_dp_check_mst_status() keeps servicing interrupts originating from the sink without bound. Add an upper bound to the new interrupts occurring during interrupt processing to not get stuck on potentially stuck sink devices. Use arbitrary 32 tries to clear incoming interrupts in one go.
Discovered using AI-assisted static analysis confirmed by Intel Product Security.
Note: The condition likely pre-dates the commit in the Fixes: tag, but this is about as far back as a backport has any chance of succeeding. Before that, the retry had a goto.
--- drivers/gpu/drm/i915/display/intel_dp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_dp.c +7 -1
@@ -4149,10 +4149,11 @@ intel_dp_check_mst_status(struct intel_dp *intel_dp) {struct drm_i915_private *i915 =dp_to_i915 (intel_dp);bool link_ok = true; +int tries =33 ;drm_WARN_ON_ONCE (&i915->drm, intel_dp->active_mst_links <0 ); -for (;;) { +while (--tries) {u8 esi[4 ] = {};u8 ack[4 ] = {};
@@ -4185,6 +4186,11 @@ intel_dp_check_mst_status(struct intel_dp *intel_dp)drm_dp_mst_hpd_irq_send_new_request (&intel_dp->mst_mgr); } +if (!tries) { +drm_dbg_kms (&i915->drm,"DPRX ESI not clearing, device may be stuck\n" ); + link_ok = false; + } +return link_ok; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1081/1674 drm/i915/gt: Fix NULL deref on sched_engine alloc failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joonas Lahtinen <[email protected]>
[ Upstream commit 82ec992c404c3dc774c5e9f3d4aa858e97187675 ]
Avoid using intel_context_put() before intel_context_init() in execlists_create_virtual() as the kref_put() inside would lead to NULL deref on the IOCTL path when sched_engine allocation fails.
Discovered using AI-assisted static analysis confirmed by Intel Product Security.
--- .../drm/i915/gt/intel_execlists_submission.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +10 -9
@@ -3935,11 +3935,11 @@ execlists_create_virtual(struct intel_engine_cs **siblings, unsigned int count,struct drm_i915_private *i915 = siblings[0 ]->i915;struct virtual_engine *ve;unsigned int n; -int err; +int err = -ENOMEM ; ve =kzalloc (struct_size (ve, siblings, count),GFP_KERNEL );if (!ve) -return ERR_PTR (-ENOMEM ); + goto err; ve->base.i915 = i915; ve->base.gt = siblings[0 ]->gt;
@@ -3971,10 +3971,8 @@ execlists_create_virtual(struct intel_engine_cs **siblings, unsigned int count,intel_engine_init_execlists (&ve->base); ve->base.sched_engine =i915_sched_engine_create (ENGINE_VIRTUAL ); -if (!ve->base.sched_engine) { - err = -ENOMEM ; - goto err_put; - } +if (!ve->base.sched_engine) + goto err_noput; ve->base.sched_engine->private_data = &ve->base; ve->base.cops = &virtual_context_ops;
@@ -3990,10 +3988,8 @@ execlists_create_virtual(struct intel_engine_cs **siblings, unsigned int count,intel_context_init (&ve->context, &ve->base); ve->base.breadcrumbs =intel_breadcrumbs_create (NULL ); -if (!ve->base.breadcrumbs) { - err = -ENOMEM ; +if (!ve->base.breadcrumbs) goto err_put; - }for (n =0 ; n < count; n++) {struct intel_engine_cs *sibling = siblings[n];
@@ -4068,8 +4064,13 @@ execlists_create_virtual(struct intel_engine_cs **siblings, unsigned int count,virtual_engine_initial_hint (ve);return &ve->context; +err_noput: +kfree (ve); + goto err; + err_put:intel_context_put (&ve->context); +err:return ERR_PTR (err); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1082/1674 drm/i915/bios: range check LFP Data Block panel_type2
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
[ Upstream commit 2084503f2d087bf956198e7f6eb25b03a7049cb2 ]
While the panel_type from LFP Data Block is range checked, panel_type2 is not. Add a few helpers for range checking, and use them to not only check panel_type2, but also improve clarity and correctness in the panel type selection.
Discovered using AI-assisted static analysis confirmed by Intel Product Security.
v2:
- Fix commit message typo (Michał)
- Add is_panel_type_pnp() (Ville)
--- drivers/gpu/drm/i915/display/intel_bios.c | 36 ++++++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/display/intel_bios.c +28 -8
@@ -617,6 +617,21 @@ static void dump_pnp_id(struct drm_i915_private *i915, pnp_id->mfg_week, pnp_id->mfg_year + 1990); } +static bool is_panel_type_valid (int panel_type) +{ +return panel_type >=0 && panel_type <16 ; +} + +static bool is_panel_type_pnp (int panel_type) +{ +return panel_type ==0xff ; +} + +static bool is_panel_type_valid_or_pnp (int panel_type) +{ +return is_panel_type_valid (panel_type) ||is_panel_type_pnp (panel_type); +} +static int opregion_get_panel_type (struct drm_i915_private *i915,const struct intel_bios_encoder_data *devdata,const struct drm_edid *drm_edid,bool use_fallback)
@@ -634,15 +649,21 @@ static int vbt_get_panel_type(struct drm_i915_private *i915,if (!lvds_options)return -1 ; -if (lvds_options->panel_type >0xf && - lvds_options->panel_type !=0xff ) { +if (!is_panel_type_valid_or_pnp (lvds_options->panel_type)) {drm_dbg_kms (&i915->drm,"Invalid VBT panel type 0x%x\n" , lvds_options->panel_type);return -1 ; } -if (devdata && devdata->child.handle ==DEVICE_HANDLE_LFP2 ) +if (devdata && devdata->child.handle ==DEVICE_HANDLE_LFP2 ) { +if (!is_panel_type_valid_or_pnp (lvds_options->panel_type2)) { +drm_dbg_kms (&i915->drm,"Invalid VBT panel type 2 0x%x\n" , + lvds_options->panel_type2); +return -1 ; + } +return lvds_options->panel_type2; + }drm_WARN_ON (&i915->drm, devdata && devdata->child.handle !=DEVICE_HANDLE_LFP1 );
@@ -755,13 +776,12 @@ static int get_panel_type(struct drm_i915_private *i915, panel_types[i].name, panel_types[i].panel_type); } -if (panel_types[PANEL_TYPE_OPREGION ].panel_type >=0 ) +if (is_panel_type_valid (panel_types[PANEL_TYPE_OPREGION ].panel_type)) i =PANEL_TYPE_OPREGION ; -else if (panel_types[PANEL_TYPE_VBT ].panel_type ==0xff && - panel_types[PANEL_TYPE_PNPID ].panel_type >=0 ) +else if (is_panel_type_pnp (panel_types[PANEL_TYPE_VBT ].panel_type) && +is_panel_type_valid (panel_types[PANEL_TYPE_PNPID ].panel_type)) i =PANEL_TYPE_PNPID ; -else if (panel_types[PANEL_TYPE_VBT ].panel_type !=0xff && - panel_types[PANEL_TYPE_VBT ].panel_type >=0 ) +else if (is_panel_type_valid (panel_types[PANEL_TYPE_VBT ].panel_type)) i =PANEL_TYPE_VBT ;else i =PANEL_TYPE_FALLBACK ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1083/1674 drm/amdkfd: Check bounds on CRIU restore queue type and mqd size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Francis <[email protected]>
[ Upstream commit 47ea05f246bebc81c7796f56265cffd812cf0601 ]
We weren't checking whether the values provided in the private data in kfd CRIU restore were within bounds.
For queue type, add a KFD_QUEUE_TYPE_MAX and ensure the provided type is less than it.
For mqd_size, add new function mqd_size_from_queue_type and confirm that the provided mqd_size matches expectations.
--- .../drm/amd/amdkfd/kfd_device_queue_manager.c | 5 ++++ .../drm/amd/amdkfd/kfd_device_queue_manager.h | 2 ++ drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 3 ++- .../amd/amdkfd/kfd_process_queue_manager.c | 24 +++++++++++++------ 4 files changed, 26 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +5 -0
@@ -3137,6 +3137,11 @@ int debug_refresh_runlist(struct device_queue_manager *dqm)return debug_map_and_unlock (dqm); } +size_t mqd_size_from_queue_type (struct device_queue_manager *dqm,enum kfd_queue_type type) +{ +return dqm->mqd_mgrs[get_mqd_type_from_queue_type (type)]->mqd_size; +} +#if defined(CONFIG_DEBUG_FS ) static void seq_reg_dump(struct seq_file *m,
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.h +2 -0
@@ -302,6 +302,8 @@ void set_queue_snapshot_entry(struct queue *q,int debug_lock_and_unmap (struct device_queue_manager *dqm);int debug_map_and_unlock (struct device_queue_manager *dqm);int debug_refresh_runlist (struct device_queue_manager *dqm); +size_t mqd_size_from_queue_type (struct device_queue_manager *dqm, +enum kfd_queue_type type);static inline unsigned int get_sh_mem_bases_32 (struct kfd_process_device *pdd) {
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +2 -1
@@ -433,7 +433,8 @@ enum kfd_queue_type {KFD_QUEUE_TYPE_SDMA ,KFD_QUEUE_TYPE_HIQ ,KFD_QUEUE_TYPE_DIQ , -KFD_QUEUE_TYPE_SDMA_XGMI +KFD_QUEUE_TYPE_SDMA_XGMI , + KFD_QUEUE_TYPE_MAX, }; enum kfd_queue_format {
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +17 -7
@@ -946,6 +946,23 @@ int kfd_criu_restore_queue(struct kfd_process *p, goto exit; } + pdd =kfd_process_device_data_by_id (p, q_data->gpu_id); +if (!pdd) { +pr_err ("Failed to get pdd\n" ); + ret = -EINVAL ; + goto exit; + } + +if (q_data->type >=KFD_QUEUE_TYPE_MAX ) { + ret = -EINVAL ; + goto exit; + } + +if (q_data->mqd_size !=mqd_size_from_queue_type (pdd->dev->dqm, q_data->type)) { + ret = -EINVAL ; + goto exit; + } + *priv_data_offset +=sizeof (*q_data); q_extra_data_size = (uint64_t )q_data->ctl_stack_size + q_data->mqd_size;
@@ -968,13 +985,6 @@ int kfd_criu_restore_queue(struct kfd_process *p, *priv_data_offset += q_extra_data_size; - pdd =kfd_process_device_data_by_id (p, q_data->gpu_id); -if (!pdd) { -pr_err ("Failed to get pdd\n" ); - ret = -EINVAL ; - goto exit; - } -/* data stored in this order: mqd, ctl_stack */ mqd = q_extra_data; ctl_stack = mqd + q_data->mqd_size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1084/1674 drm/amdgpu: Fix context pstate override handling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tvrtko Ursulin <[email protected]>
[ Upstream commit c1dc4ccb82c9e56325d8e7514ca4c90bd1efb351 ]
There are several problems in the context pstate handling code.
The most serious ones are potential use-after-free and NULL pointer dereferences at context initialization time. Both are due amdgpu_ctx_init() not holding the adev->pm.stable_pstate_ctx_lock, which is otherwise used from both sysfs and the context code itself for modifying and clearing the stored context pointer.
Second issue is that context fini can trample over the pstate configuration set via sysfs. This is due the restore state (ctx->stable_pstate) being saved at context init time, and not if, or when the context actually changes the pstate. As the context exits it will therefore incorrectly restore to what was set before the sysfs override was requested.
The simplest fix is to drastically simplify how the state is tracked, by clearly defining the points at which pstate ownership is taken and released, and to handle all transitions under the correct lock.
Instead of at context init time, the previous state is saved only at the point the context overrides the current state, and is restored on context exit only if the context is still the owner of the current override state.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 71 +++++++++++++++---------- 1 file changed, 42 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +42 -29
@@ -320,7 +320,6 @@ static int amdgpu_ctx_init(struct amdgpu_ctx_mgr *mgr, int32_t priority, struct drm_file *filp, struct amdgpu_ctx *ctx) { struct amdgpu_fpriv *fpriv = filp->driver_priv; -u32 current_stable_pstate;int r; r =amdgpu_ctx_priority_permit (filp, priority);
@@ -338,37 +337,22 @@ static int amdgpu_ctx_init(struct amdgpu_ctx_mgr *mgr, int32_t priority, ctx->generation =amdgpu_vm_generation (mgr->adev, &fpriv->vm); ctx->init_priority = priority; ctx->override_priority =AMDGPU_CTX_PRIORITY_UNSET ; - - r =amdgpu_ctx_get_stable_pstate (ctx, ¤t_stable_pstate); -if (r) -return r; - -if (mgr->adev->pm.stable_pstate_ctx) - ctx->stable_pstate = mgr->adev->pm.stable_pstate_ctx->stable_pstate; -else - ctx->stable_pstate = current_stable_pstate; + ctx->stable_pstate =AMDGPU_CTX_STABLE_PSTATE_NONE ; ctx->ctx_mgr = &(fpriv->ctx_mgr);return 0 ; } -static int amdgpu_ctx_set_stable_pstate (struct amdgpu_ctx *ctx, -u32 stable_pstate) +static int __amdgpu_ctx_set_stable_pstate (struct amdgpu_ctx *ctx, +u32 stable_pstate) {struct amdgpu_device *adev = ctx->mgr->adev;enum amd_dpm_forced_level level; +struct amdgpu_ctx *current_ctx;u32 current_stable_pstate; -int r; +int r =0 ; -mutex_lock (&adev->pm.stable_pstate_ctx_lock); -if (adev->pm.stable_pstate_ctx && adev->pm.stable_pstate_ctx != ctx) { - r = -EBUSY ; - goto done; - } - - r =amdgpu_ctx_get_stable_pstate (ctx, ¤t_stable_pstate); -if (r || (stable_pstate == current_stable_pstate)) - goto done; +lockdep_assert_held (&adev->pm.stable_pstate_ctx_lock);switch (stable_pstate) {case AMDGPU_CTX_STABLE_PSTATE_NONE :
@@ -387,17 +371,41 @@ static int amdgpu_ctx_set_stable_pstate(struct amdgpu_ctx *ctx, level =AMD_DPM_FORCED_LEVEL_PROFILE_PEAK ;break ;default : - r = -EINVAL ; - goto done; +return -EINVAL ; } + current_ctx = adev->pm.stable_pstate_ctx; +if (current_ctx && current_ctx != ctx) +return -EBUSY ; + + r =amdgpu_ctx_get_stable_pstate (ctx, ¤t_stable_pstate); +if (r || current_stable_pstate == stable_pstate) +return r; + r =amdgpu_dpm_force_performance_level (adev, level); +if (r) +return r; -if (level ==AMD_DPM_FORCED_LEVEL_AUTO ) - adev->pm.stable_pstate_ctx =NULL ; -else +if (!current_ctx) { adev->pm.stable_pstate_ctx = ctx; -done: +/* +* Serialized by context taking ownership for the first time +* while holding adev->pm.stable_pstate_ctx_lock). +*/ +WRITE_ONCE (ctx->stable_pstate, current_stable_pstate); + } + +return 0 ; +} + +static int amdgpu_ctx_set_stable_pstate (struct amdgpu_ctx *ctx, +u32 stable_pstate) +{ +struct amdgpu_device *adev = ctx->mgr->adev; +int r; + +mutex_lock (&adev->pm.stable_pstate_ctx_lock); + r =__amdgpu_ctx_set_stable_pstate (ctx, stable_pstate);mutex_unlock (&adev->pm.stable_pstate_ctx_lock);return r;
@@ -423,7 +431,12 @@ static void amdgpu_ctx_fini(struct kref *ref) }if (drm_dev_enter (adev_to_drm (adev), &idx)) { -amdgpu_ctx_set_stable_pstate (ctx, ctx->stable_pstate); +mutex_lock (&adev->pm.stable_pstate_ctx_lock); +if (adev->pm.stable_pstate_ctx == ctx) { +__amdgpu_ctx_set_stable_pstate (ctx, ctx->stable_pstate); + adev->pm.stable_pstate_ctx =NULL ; + } +mutex_unlock (&adev->pm.stable_pstate_ctx_lock);drm_dev_exit (idx); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1085/1674 net/mlx5: Fix MCIA register buffer overflow on 32 dword reads
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gal Pressman <[email protected]>
[ Upstream commit 11c057d23465c7a5817a7284c896d19d54c0b616 ]
The MCIA register can return up to 32 dwords (128 bytes) when the device advertises the mcia_32dwords capability, but struct mlx5_ifc_mcia_reg_bits only defines dword_0..11, leaving room for just 12 dwords (48 bytes) of data.
mlx5_query_mcia() clamps the read size to mlx5_mcia_max_bytes() and then memcpy()s that many bytes out of the register, potentially reading past the end of the 'out' buffer. On kernels built with FORTIFY_SOURCE this is caught as a buffer overflow while reading the module EEPROM via ethtool:
detected buffer overflow in memcpy
kernel BUG at lib/string_helpers.c:1048!
RIP: 0010:fortify_panic+0x13/0x20 Call Trace: mlx5_query_mcia.isra.0+0x200/0x210 [mlx5_core] mlx5_query_module_eeprom_by_page+0x4a/0xa0 [mlx5_core] mlx5e_get_module_eeprom_by_page+0xbb/0x120 [mlx5_core] eeprom_prepare_data+0xf3/0x170 ethnl_default_doit+0xf1/0x3b0
Extend the mcia_reg layout to 32 dwords.
--- drivers/net/ethernet/mellanox/mlx5/core/port.c | 4 ++-- include/linux/mlx5/mlx5_ifc.h | 13 +------------ 2 files changed, 3 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/port.c +2 -2
@@ -316,7 +316,7 @@ static int mlx5_query_module_id(struct mlx5_core_dev *dev, int module_num, status);return -EIO ; } - ptr =MLX5_ADDR_OF (mcia_reg, out, dword_0); + ptr =MLX5_ADDR_OF (mcia_reg, out, dwords); *module_id = ptr[0 ];
@@ -401,7 +401,7 @@ static int mlx5_query_mcia(struct mlx5_core_dev *dev,return -EIO ; } - ptr =MLX5_ADDR_OF (mcia_reg, out, dword_0); + ptr =MLX5_ADDR_OF (mcia_reg, out, dwords);memcpy (data, ptr, size);return size;
include/linux/mlx5/mlx5_ifc.h +1 -12
@@ -11320,18 +11320,7 @@ struct mlx5_ifc_mcia_reg_bits {u8 reserved_at_60[0x20 ]; -u8 dword_0[0x20 ]; -u8 dword_1[0x20 ]; -u8 dword_2[0x20 ]; -u8 dword_3[0x20 ]; -u8 dword_4[0x20 ]; -u8 dword_5[0x20 ]; -u8 dword_6[0x20 ]; -u8 dword_7[0x20 ]; -u8 dword_8[0x20 ]; -u8 dword_9[0x20 ]; -u8 dword_10[0x20 ]; -u8 dword_11[0x20 ]; +u8 dwords[0x400 ]; };struct mlx5_ifc_dcbx_param_bits {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1086/1674 drm/vc4: hvs/v3d: Fix null dereference in unbind
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregor Herburger <[email protected]>
[ Upstream commit 7dc3680b7ffe01add3e9299fde8471d2dd53a8ae ]
The hvs and v3d drivers use dev_get_drvdata(master) in their unbind functions. Since the vc4-drm gets removed before its dependent drivers (vc4_hvs/vc4_v3d) the vc4_hvs_unbind/vc4_v3d_unbind functions try to get drvdata of its master and fails with a null dereference error.
Use the data pointer passed to the unbind functions directly instead of dev_get_drvdata(master). This avoids using potentially freed memory.
--- drivers/gpu/drm/vc4/vc4_hvs.c | 2 +- drivers/gpu/drm/vc4/vc4_v3d.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_hvs.c +1 -1
@@ -1045,7 +1045,7 @@ static int vc4_hvs_bind(struct device *dev, struct device *master, void *data)static void vc4_hvs_unbind (struct device *dev,struct device *master,void *data) { -struct drm_device *drm =dev_get_drvdata (master); +struct drm_device *drm = data;struct vc4_dev *vc4 =to_vc4_dev (drm);struct vc4_hvs *hvs = vc4->hvs;struct drm_mm_node *node, *next;
drivers/gpu/drm/vc4/vc4_v3d.c +1 -1
@@ -505,7 +505,7 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)static void vc4_v3d_unbind (struct device *dev,struct device *master,void *data) { -struct drm_device *drm =dev_get_drvdata (master); +struct drm_device *drm = data;struct vc4_dev *vc4 =to_vc4_dev (drm);/* A straggler vc4_reset() re-enables the interrupt. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1087/1674 cifs: prevent readdir from changing file size due to stale directory metadata
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Sorenson <[email protected]>
[ Upstream commit e8a8d54c2d508891c142a928fc7d298c4c8bd0dd ]
Windows Server's directory enumeration metadata lags behind the actual file size after a write+close or rename. A concurrent readdir() in the window between close() returning to userspace and stat() being called overwrites the correct cached i_size with the stale server value, causing stat() to return the wrong size.
Once _cifsFileInfo_put() removes the last writable handle from openFileList, is_size_safe_to_change() permits readdir to overwrite i_size. smb2_close_getattr() then stamps cifs_i->time = jiffies, making the corrupt cached value appear fresh to the next stat().
The existing check (see Fixes:) only blocked stale size updates while an active RW lease was held, not after the last writable handle closes.
Add cifsInodeInfo->time_last_write, written via smp_store_release() at writable close and on setattr/truncate. is_size_safe_to_change() checks is_inode_writable() first (acquiring open_file_lock), then rejects a readdir size update if time_last_write falls within acregmax jiffies. The spinlock release in _cifsFileInfo_put() forms a store-release barrier that pairs with the spin_lock() (load-acquire) in is_inode_writable(), ensuring the subsequent smp_load_acquire() on time_last_write observes any update from a concurrent close(). When a size update is rejected and the server value differs from the cached one, cifs_i->time is cleared to force a fresh QUERY_INFO on the next stat().
readdir is also blocked from changing i_size while writable handles are open or an RW lease is held, even on direct-IO mounts.
For deferred close (closetimeo > 0), time_last_write is refreshed at the actual server close in smb2_deferred_work_close() and in the cifs_close_deferred_file*() drain paths invoked by lease/oplock breaks and tcon teardown, anchoring the protection window to the real close time rather than the earlier userspace close.
time_last_write == 0 skips the time_before() check to avoid false positives near boot on 32-bit systems where jiffies starts close to INITIAL_JIFFIES.
Does not reproduce against Samba or with actimeo=0.
Stable-dep-of: c2f2e83e3bbc ("cifs: fix cifsFileInfo leak on kmalloc failure in deferred close drain paths")
--- fs/smb/client/cifsfs.c | 1 + fs/smb/client/cifsglob.h | 1 + fs/smb/client/file.c | 70 ++++++++++++++++++++++++++++++++++++---- fs/smb/client/inode.c | 6 ++++ fs/smb/client/misc.c | 27 ++++++++++++++-- 5 files changed, 96 insertions(+), 9 deletions(-)
fs/smb/client/cifsfs.c +1 -0
@@ -401,6 +401,7 @@ cifs_alloc_inode(struct super_block *sb)return NULL ; cifs_inode->cifsAttrs =0x20 ;/* default */ cifs_inode->time =0 ; + cifs_inode->time_last_write =0 ;/* * Until the file is open and we have gotten oplock info back from the * server, can not assume caching of file data or metadata.
fs/smb/client/cifsglob.h +1 -0
@@ -1575,6 +1575,7 @@ struct cifsInodeInfo {unsigned int writers;/* Number of writers on this inode */ unsigned long time;/* jiffies of last update of inode */ u64 server_eof;/* current file size on server -- protected by i_lock */ +unsigned long time_last_write;/* jiffies of last writable close or truncate */ u64 uniqueid;/* server inode number */ u64 createtime;/* creation time on server */ __u8 lease_key[SMB2_LEASE_KEY_SIZE ];/* lease key for this inode */
fs/smb/client/file.c +64 -6
104 lines not on this page · raw message
fs/smb/client/inode.c +6 -0
@@ -227,6 +227,8 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr,* calculating num blocks. */ inode->i_blocks = (512 -1 + fattr->cf_bytes) >>9 ; + }else if (from_readdir &&i_size_read (inode) != fattr->cf_eof) { + cifs_i->time =0 ; }if (S_ISLNK (fattr->cf_mode) && fattr->cf_symlink_target) {
@@ -3135,6 +3137,8 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)if ((attrs->ia_valid &ATTR_SIZE ) && attrs->ia_size !=i_size_read (inode)) { +/* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ +smp_store_release (&cifsInode->time_last_write, jiffies);truncate_setsize (inode, attrs->ia_size);fscache_resize_cookie (cifs_inode_cookie (inode), attrs->ia_size); }
@@ -3353,6 +3357,8 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)if ((attrs->ia_valid &ATTR_SIZE ) && attrs->ia_size !=i_size_read (inode)) { +/* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ +smp_store_release (&cifsInode->time_last_write, jiffies);truncate_setsize (inode, attrs->ia_size);fscache_resize_cookie (cifs_inode_cookie (inode), attrs->ia_size); }
fs/smb/client/misc.c +24 -3
@@ -799,7 +799,14 @@ cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode)spin_unlock (&cifs_inode->open_file_lock);list_for_each_entry_safe (tmp_list, tmp_next_list, &file_head, list) { -_cifsFileInfo_put (tmp_list->cfile, false, false); +struct cifsFileInfo *cfile = tmp_list->cfile; + +if (OPEN_FMODE (cfile->f_flags) &FMODE_WRITE ) { +/* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ +smp_store_release (&CIFS_I (d_inode (cfile->dentry))->time_last_write, + jiffies); + } +_cifsFileInfo_put (cfile, false, false);list_del (&tmp_list->list);kfree (tmp_list); }
@@ -832,7 +839,14 @@ cifs_close_all_deferred_files(struct cifs_tcon *tcon)spin_unlock (&tcon->open_file_lock);list_for_each_entry_safe (tmp_list, tmp_next_list, &file_head, list) { -_cifsFileInfo_put (tmp_list->cfile, true, false); +struct cifsFileInfo *cfile = tmp_list->cfile; + +if (OPEN_FMODE (cfile->f_flags) &FMODE_WRITE ) { +/* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ +smp_store_release (&CIFS_I (d_inode (cfile->dentry))->time_last_write, + jiffies); + } +_cifsFileInfo_put (cfile, true, false);list_del (&tmp_list->list);kfree (tmp_list); }
@@ -908,7 +922,14 @@ cifs_close_deferred_file_under_dentry(struct cifs_tcon *tcon, const char *path)spin_unlock (&tcon->open_file_lock);list_for_each_entry_safe (tmp_list, tmp_next_list, &file_head, list) { -_cifsFileInfo_put (tmp_list->cfile, true, false); +struct cifsFileInfo *cfile = tmp_list->cfile; + +if (OPEN_FMODE (cfile->f_flags) &FMODE_WRITE ) { +/* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ +smp_store_release (&CIFS_I (d_inode (cfile->dentry))->time_last_write, + jiffies); + } +_cifsFileInfo_put (cfile, true, false);list_del (&tmp_list->list);kfree (tmp_list); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1088/1674 cifs: fix cifsFileInfo leak on kmalloc failure in deferred close drain paths
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Sorenson <[email protected]>
[ Upstream commit c2f2e83e3bbc5483730fd4ee903182761f1ae50f ]
In cifs_close_deferred_file(), cifs_close_all_deferred_files(), and cifs_close_deferred_file_under_dentry(), when a pending deferred close is cancelled via cancel_delayed_work(), the subsequent kmalloc_obj() to add the file to the local processing list may fail under memory pressure. The loop breaks immediately, but the cancelled work is no longer pending (it would have called _cifsFileInfo_put()), and the cfile is never added to file_head for processing. The cifsFileInfo reference and the open server handle both leak.
Fix by saving the cfile that failed allocation in a local variable, breaking as before, and calling _cifsFileInfo_put() on it after releasing the lock. Any files later in the iteration are unaffected since their deferred work is still pending and will fire normally.
--- fs/smb/client/misc.c | 45 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-)
fs/smb/client/misc.c +39 -6
@@ -772,7 +772,7 @@ cifs_del_deferred_close(struct cifsFileInfo *cfile)void cifs_close_deferred_file (struct cifsInodeInfo *cifs_inode) { -struct cifsFileInfo *cfile =NULL ; +struct cifsFileInfo *cfile =NULL , *failed_cfile =NULL ;struct file_list *tmp_list, *tmp_next_list;struct list_head file_head;
@@ -789,8 +789,10 @@ cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode)spin_unlock (&cifs_inode->deferred_lock); tmp_list =kmalloc (sizeof (struct file_list ),GFP_ATOMIC ); -if (tmp_list ==NULL ) +if (tmp_list ==NULL ) { + failed_cfile = cfile;break ; + } tmp_list->cfile = cfile;list_add_tail (&tmp_list->list, &file_head); }
@@ -798,6 +800,15 @@ cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode) }spin_unlock (&cifs_inode->open_file_lock); +if (failed_cfile) { +if (OPEN_FMODE (failed_cfile->f_flags) &FMODE_WRITE ) { +/* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ +smp_store_release (&CIFS_I (d_inode (failed_cfile->dentry))->time_last_write, + jiffies); + } +_cifsFileInfo_put (failed_cfile, false, false); + } +list_for_each_entry_safe (tmp_list, tmp_next_list, &file_head, list) {struct cifsFileInfo *cfile = tmp_list->cfile;
@@ -815,7 +826,7 @@ cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode)void cifs_close_all_deferred_files (struct cifs_tcon *tcon) { -struct cifsFileInfo *cfile; +struct cifsFileInfo *cfile, *failed_cfile =NULL ;struct file_list *tmp_list, *tmp_next_list;struct list_head file_head;
@@ -829,8 +840,10 @@ cifs_close_all_deferred_files(struct cifs_tcon *tcon)spin_unlock (&CIFS_I (d_inode (cfile->dentry))->deferred_lock); tmp_list =kmalloc (sizeof (struct file_list ),GFP_ATOMIC ); -if (tmp_list ==NULL ) +if (tmp_list ==NULL ) { + failed_cfile = cfile;break ; + } tmp_list->cfile = cfile;list_add_tail (&tmp_list->list, &file_head); }
@@ -838,6 +851,15 @@ cifs_close_all_deferred_files(struct cifs_tcon *tcon) }spin_unlock (&tcon->open_file_lock); +if (failed_cfile) { +if (OPEN_FMODE (failed_cfile->f_flags) &FMODE_WRITE ) { +/* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ +smp_store_release (&CIFS_I (d_inode (failed_cfile->dentry))->time_last_write, + jiffies); + } +_cifsFileInfo_put (failed_cfile, true, false); + } +list_for_each_entry_safe (tmp_list, tmp_next_list, &file_head, list) {struct cifsFileInfo *cfile = tmp_list->cfile;
@@ -892,7 +914,7 @@ void cifs_close_all_deferred_files_sb(struct cifs_sb_info *cifs_sb)void cifs_close_deferred_file_under_dentry (struct cifs_tcon *tcon,const char *path) { -struct cifsFileInfo *cfile; +struct cifsFileInfo *cfile, *failed_cfile =NULL ;struct file_list *tmp_list, *tmp_next_list;struct list_head file_head;void *page;
@@ -911,8 +933,10 @@ cifs_close_deferred_file_under_dentry(struct cifs_tcon *tcon, const char *path)spin_unlock (&CIFS_I (d_inode (cfile->dentry))->deferred_lock); tmp_list =kmalloc (sizeof (struct file_list ),GFP_ATOMIC ); -if (tmp_list ==NULL ) +if (tmp_list ==NULL ) { + failed_cfile = cfile;break ; + } tmp_list->cfile = cfile;list_add_tail (&tmp_list->list, &file_head); }
@@ -921,6 +945,15 @@ cifs_close_deferred_file_under_dentry(struct cifs_tcon *tcon, const char *path) }spin_unlock (&tcon->open_file_lock); +if (failed_cfile) { +if (OPEN_FMODE (failed_cfile->f_flags) &FMODE_WRITE ) { +/* Pairs with smp_load_acquire() in is_size_safe_to_change(). */ +smp_store_release (&CIFS_I (d_inode (failed_cfile->dentry))->time_last_write, + jiffies); + } +_cifsFileInfo_put (failed_cfile, true, false); + } +list_for_each_entry_safe (tmp_list, tmp_next_list, &file_head, list) {struct cifsFileInfo *cfile = tmp_list->cfile;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1089/1674 pds_core: Dont assign interrupt index/bound_intr to notifyq
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brett Creeley <[email protected]>
[ Upstream commit 02daffa903e60a864b43a17f7074bb3f7b7baac7 ]
The notifyq rides on the adminq's interrupt, so there's no need to setup and/or access the notifyq's interrupt index or bound_intr. The driver sets the bound_intr using qcq->intx = -1 for the notifyq, but luckily nothing accesses that field for notifyq. Instead of expecting that remains the case, just clean up the notifyq's interrupt index and bound_intr fields.
Stable-dep-of: 0ad134881508 ("pds_core: fix use-after-free on workqueue during remove")
--- drivers/net/ethernet/amd/pds_core/core.c | 5 +---- drivers/net/ethernet/amd/pds_core/debugfs.c | 3 ++- 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/net/ethernet/amd/pds_core/core.c +1 -4
@@ -129,6 +129,7 @@ static int pdsc_qcq_intr_alloc(struct pdsc *pdsc, struct pdsc_qcq *qcq)if (index <0 )return index; qcq->intx = index; + qcq->cq.bound_intr = &pdsc->intr_info[index];return 0 ; }
@@ -227,7 +228,6 @@ int pdsc_qcq_alloc(struct pdsc *pdsc, unsigned int type, unsigned int index, goto err_out_free_irq; } - qcq->cq.bound_intr = &pdsc->intr_info[qcq->intx]; qcq->cq.num_descs = num_descs; qcq->cq.desc_size = cq_desc_size; qcq->cq.tail_idx =0 ;
@@ -432,9 +432,6 @@ int pdsc_setup(struct pdsc *pdsc, bool init)if (err) goto err_out_teardown; -/* NotifyQ rides on the AdminQ interrupt */ - pdsc->notifyqcq.intx = pdsc->adminqcq.intx; -/* Set up the Core with the AdminQ and NotifyQ info */ err =pdsc_core_init (pdsc);if (err)
drivers/net/ethernet/amd/pds_core/debugfs.c +2 -1
@@ -114,7 +114,6 @@ void pdsc_debugfs_add_qcq(struct pdsc *pdsc, struct pdsc_qcq *qcq)struct dentry *qcq_dentry, *q_dentry, *cq_dentry;struct dentry *intr_dentry;struct debugfs_regset32 *intr_ctrl_regset; -struct pdsc_intr_info *intr = &pdsc->intr_info[qcq->intx];struct pdsc_queue *q = &qcq->q;struct pdsc_cq *cq = &qcq->cq;
@@ -152,6 +151,8 @@ void pdsc_debugfs_add_qcq(struct pdsc *pdsc, struct pdsc_qcq *qcq)debugfs_create_u16 ("tail" ,0400 , cq_dentry, &cq->tail_idx);if (qcq->flags &PDS_CORE_QCQ_F_INTR ) { +struct pdsc_intr_info *intr = &pdsc->intr_info[qcq->intx]; + intr_dentry =debugfs_create_dir ("intr" , qcq->dentry);if (IS_ERR_OR_NULL (intr_dentry))return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1090/1674 pds_core: Clean up init/uninit flows to be more readable
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brett Creeley <[email protected]>
[ Upstream commit 792d36ccc163ac4aa606b3f5ec31cfd2c3a365de ]
The setup and teardown flows are somewhat hard to follow regarding pdsc_core_init()/pdsc_dev_init() and their corresponding teardown flows being in pdsc_teardown(). Improve the readability by adding new pdsc_core_uninit()/pdsc_dev_unint() functions that mirror their init counterparts. Also, move the notify and admin qcq allocations into pdsc_core_init(), so they can be freed in pdsc_core_uninit().
Stable-dep-of: 0ad134881508 ("pds_core: fix use-after-free on workqueue during remove")
--- drivers/net/ethernet/amd/pds_core/core.c | 81 ++++++++++++------------ drivers/net/ethernet/amd/pds_core/core.h | 1 + drivers/net/ethernet/amd/pds_core/dev.c | 16 +++++ 3 files changed, 58 insertions(+), 40 deletions(-)
drivers/net/ethernet/amd/pds_core/core.c +41 -40
@@ -305,6 +305,17 @@ int pdsc_qcq_alloc(struct pdsc *pdsc, unsigned int type, unsigned int index,return err; } +static void pdsc_core_uninit (struct pdsc *pdsc) +{ +pdsc_qcq_free (pdsc, &pdsc->notifyqcq); +pdsc_qcq_free (pdsc, &pdsc->adminqcq); + +if (pdsc->kern_dbpage) { +iounmap (pdsc->kern_dbpage); + pdsc->kern_dbpage =NULL ; + } +} +static int pdsc_core_init (struct pdsc *pdsc) {union pds_core_dev_comp comp = {};
@@ -315,9 +326,29 @@ static int pdsc_core_init(struct pdsc *pdsc)struct pds_core_dev_init_data_in cidi;u32 dbid_count;u32 dbpage_num; +int numdescs;size_t sz;int err; + numdescs =PDSC_ADMINQ_MAX_LENGTH ; + err =pdsc_qcq_alloc (pdsc,PDS_CORE_QTYPE_ADMINQ ,0 ,"adminq" , +PDS_CORE_QCQ_F_CORE |PDS_CORE_QCQ_F_INTR , + numdescs, +sizeof (union pds_core_adminq_cmd ), +sizeof (union pds_core_adminq_comp ), +0 , &pdsc->adminqcq); +if (err) +return err; + + err =pdsc_qcq_alloc (pdsc,PDS_CORE_QTYPE_NOTIFYQ ,0 ,"notifyq" , +PDS_CORE_QCQ_F_NOTIFYQ , +PDSC_NOTIFYQ_LENGTH , +sizeof (struct pds_core_notifyq_cmd ), +sizeof (union pds_core_notifyq_comp ), +0 , &pdsc->notifyqcq); +if (err) + goto err_out_uninit; + cidi.adminq_q_base =cpu_to_le64 (pdsc->adminqcq.q_base_pa); cidi.adminq_cq_base =cpu_to_le64 (pdsc->adminqcq.cq_base_pa); cidi.notifyq_cq_base =cpu_to_le64 (pdsc->notifyqcq.cq.base_pa);
@@ -341,7 +372,7 @@ static int pdsc_core_init(struct pdsc *pdsc)if (err) {dev_err (pdsc->dev,"Device init command failed: %pe\n" ,ERR_PTR (err)); -return err; + goto err_out_uninit; } pdsc->hw_index =le32_to_cpu (cido.core_hw_index);
@@ -351,7 +382,8 @@ static int pdsc_core_init(struct pdsc *pdsc) pdsc->kern_dbpage =pdsc_map_dbpage (pdsc, dbpage_num);if (!pdsc->kern_dbpage) {dev_err (pdsc->dev,"Cannot map dbpage, aborting\n" ); -return -ENOMEM ; + err = -ENOMEM ; + goto err_out_uninit; } pdsc->adminqcq.q.hw_type = cido.adminq_hw_type;
@@ -364,6 +396,10 @@ static int pdsc_core_init(struct pdsc *pdsc) pdsc->last_eid =0 ; +return 0 ; + +err_out_uninit: +pdsc_core_uninit (pdsc);return err; }
@@ -406,32 +442,12 @@ static int pdsc_viftypes_init(struct pdsc *pdsc)int pdsc_setup (struct pdsc *pdsc,bool init) { -int numdescs;int err; err =pdsc_dev_init (pdsc);if (err)return err; - numdescs =PDSC_ADMINQ_MAX_LENGTH ; - err =pdsc_qcq_alloc (pdsc,PDS_CORE_QTYPE_ADMINQ ,0 ,"adminq" , -PDS_CORE_QCQ_F_CORE |PDS_CORE_QCQ_F_INTR , - numdescs, -sizeof (union pds_core_adminq_cmd ), -sizeof (union pds_core_adminq_comp ), -0 , &pdsc->adminqcq); -if (err) - goto err_out_teardown; - - err =pdsc_qcq_alloc (pdsc,PDS_CORE_QTYPE_NOTIFYQ ,0 ,"notifyq" , -PDS_CORE_QCQ_F_NOTIFYQ , -PDSC_NOTIFYQ_LENGTH , -sizeof (struct pds_core_notifyq_cmd ), -sizeof (union pds_core_notifyq_comp ), -0 , &pdsc->notifyqcq); -if (err) - goto err_out_teardown; -/* Set up the Core with the AdminQ and NotifyQ info */ err =pdsc_core_init (pdsc);if (err)
@@ -456,33 +472,18 @@ int pdsc_setup(struct pdsc *pdsc, bool init)void pdsc_teardown (struct pdsc *pdsc,bool removing) { -int i; -if (!pdsc->pdev->is_virtfn)pdsc_devcmd_reset (pdsc);if (pdsc->adminqcq.work.func)cancel_work_sync (&pdsc->adminqcq.work); -pdsc_qcq_free (pdsc, &pdsc->notifyqcq); -pdsc_qcq_free (pdsc, &pdsc->adminqcq); + +pdsc_core_uninit (pdsc);kfree (pdsc->viftype_status); pdsc->viftype_status =NULL ; -if (pdsc->intr_info) { -for (i =0 ; i < pdsc->nintrs; i++) -pdsc_intr_free (pdsc, i); - -kfree (pdsc->intr_info); - pdsc->intr_info =NULL ; - pdsc->nintrs =0 ; - } - -if (pdsc->kern_dbpage) { -iounmap (pdsc->kern_dbpage); - pdsc->kern_dbpage =NULL ; - } +pdsc_dev_uninit (pdsc); -pci_free_irq_vectors (pdsc->pdev);set_bit (PDSC_S_FW_DEAD , &pdsc->state); }
drivers/net/ethernet/amd/pds_core/core.h +1 -0
@@ -282,6 +282,7 @@ int pdsc_devcmd_locked(struct pdsc *pdsc, union pds_core_dev_cmd *cmd,int pdsc_devcmd_init (struct pdsc *pdsc);int pdsc_devcmd_reset (struct pdsc *pdsc);int pdsc_dev_init (struct pdsc *pdsc); +void pdsc_dev_uninit (struct pdsc *pdsc);int pdsc_intr_alloc (struct pdsc *pdsc,char *name,irq_handler_t handler,void *data);
drivers/net/ethernet/amd/pds_core/dev.c +16 -0
@@ -323,6 +323,22 @@ static int pdsc_identify(struct pdsc *pdsc)return 0 ; } +void pdsc_dev_uninit (struct pdsc *pdsc) +{ +if (pdsc->intr_info) { +int i; + +for (i =0 ; i < pdsc->nintrs; i++) +pdsc_intr_free (pdsc, i); + +kfree (pdsc->intr_info); + pdsc->intr_info =NULL ; + pdsc->nintrs =0 ; + } + +pci_free_irq_vectors (pdsc->pdev); +} +int pdsc_dev_init (struct pdsc *pdsc) {unsigned int nintrs;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1091/1674 pds_core: fix use-after-free on workqueue during remove
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil P. Rao <[email protected]>
[ Upstream commit 0ad134881508c36b65c1a8864f8bec53adbd3327 ]
In pdsc_remove(), the workqueue is destroyed before pdsc_teardown() is called. This ordering allows two paths to queue work on the destroyed workqueue:
1. If pdsc_teardown() -> pdsc_devcmd_reset() times out, the error path in pdsc_devcmd_locked() queues health_work.
2. A NotifyQ event can trigger the ISR and queue work before free_irq() is called in pdsc_teardown().
Fix by moving destroy_workqueue() after pdsc_teardown() so the workqueue outlives every queuer; destroy_workqueue() then flushes any work still pending.
Draining the queued work also requires ordering the teardown so the resources that work touches are freed last:
- In pdsc_qcq_free(), after freeing the interrupt, cancel_work_sync()
the queue's work and only then clear qcq->intx, so
pdsc_process_adminq()'s read of qcq->intx for interrupt-credit
return cannot race with the clear.- Free adminqcq before notifyqcq: the shared adminq ISR is released when adminqcq is freed, and the adminq work accesses notifyqcq, so both must be stopped before notifyqcq is freed.
--- drivers/net/ethernet/amd/pds_core/core.c | 14 ++++++++++---- drivers/net/ethernet/amd/pds_core/main.c | 5 +++-- 2 files changed, 13 insertions(+), 6 deletions(-)
drivers/net/ethernet/amd/pds_core/core.c +10 -4
@@ -110,7 +110,6 @@ static void pdsc_qcq_intr_free(struct pdsc *pdsc, struct pdsc_qcq *qcq)return ;pdsc_intr_free (pdsc, qcq->intx); - qcq->intx =PDS_CORE_INTR_INDEX_NOT_ASSIGNED ; }static int pdsc_qcq_intr_alloc (struct pdsc *pdsc,struct pdsc_qcq *qcq)
@@ -145,6 +144,12 @@ void pdsc_qcq_free(struct pdsc *pdsc, struct pdsc_qcq *qcq)pdsc_qcq_intr_free (pdsc, qcq); +/* Drain any work queued by ISR before it was freed above */ +if (qcq->work.func) +cancel_work_sync (&qcq->work); + + qcq->intx =PDS_CORE_INTR_INDEX_NOT_ASSIGNED ; +if (qcq->q_base)dma_free_coherent (dev, qcq->q_size, qcq->q_base, qcq->q_base_pa);
@@ -307,8 +312,11 @@ int pdsc_qcq_alloc(struct pdsc *pdsc, unsigned int type, unsigned int index,static void pdsc_core_uninit (struct pdsc *pdsc) { -pdsc_qcq_free (pdsc, &pdsc->notifyqcq); +/* Free adminqcq first: its work accesses notifyqcq, so we must +* disable its IRQ and drain its work before freeing notifyqcq. +*/ pdsc_qcq_free (pdsc, &pdsc->adminqcq); +pdsc_qcq_free (pdsc, &pdsc->notifyqcq);if (pdsc->kern_dbpage) {iounmap (pdsc->kern_dbpage);
@@ -474,8 +482,6 @@ void pdsc_teardown(struct pdsc *pdsc, bool removing) {if (!pdsc->pdev->is_virtfn)pdsc_devcmd_reset (pdsc); -if (pdsc->adminqcq.work.func) -cancel_work_sync (&pdsc->adminqcq.work);pdsc_core_uninit (pdsc);
drivers/net/ethernet/amd/pds_core/main.c +3 -2
@@ -432,8 +432,6 @@ static void pdsc_remove(struct pci_dev *pdev)pdsc_sriov_configure (pdev,0 );timer_shutdown_sync (&pdsc->wdtimer); -if (pdsc->wq) -destroy_workqueue (pdsc->wq);mutex_lock (&pdsc->config_lock);set_bit (PDSC_S_STOPPING_DRIVER , &pdsc->state);
@@ -441,6 +439,9 @@ static void pdsc_remove(struct pci_dev *pdev)pdsc_stop (pdsc);pdsc_teardown (pdsc,PDSC_TEARDOWN_REMOVING );mutex_unlock (&pdsc->config_lock); + +if (pdsc->wq) +destroy_workqueue (pdsc->wq);mutex_destroy (&pdsc->config_lock);mutex_destroy (&pdsc->devcmd_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1092/1674 tipc: serialize udp bearer replicast list updates
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 350e592ff4e30e48ffb55e142d11a73e63f4869c ]
tipc_udp_rcast_add() and cleanup_bearer() both update ub->rcast.list with list_add_rcu() / list_del_rcu(), but nothing serializes them. The add runs from the encap receive softirq (via tipc_udp_rcast_disc()) without rtnl_lock(), so it can race the cleanup delete and corrupt the list:
list_del corruption. prev->next should be ffff8880298d7ab8,
but was ffff88802449ad38. (prev=ffff888027e3ec98) kernel BUG at lib/list_debug.c:62! RIP: __list_del_entry_valid_or_report+0x17a/0x200 Workqueue: events cleanup_bearer Call Trace: cleanup_bearer (net/tipc/udp_media.c:811) process_one_work (kernel/workqueue.c:3302) worker_thread (kernel/workqueue.c:3466)
The bearer can be enabled from an unprivileged user namespace, as the TIPCv2 generic-netlink ops carry no GENL_ADMIN_PERM.
Add a spinlock to struct udp_bearer and take it around the list_add_rcu() in tipc_udp_rcast_add() and the list_del_rcu() loop in cleanup_bearer() so the two writers can no longer corrupt the list.
Reject a duplicate peer under the same lock before allocating, and remove tipc_udp_is_known_peer(). The old lockless pre-check in tipc_udp_rcast_disc() was racy: two softirqs discovering the same peer could both find it absent and add it twice.
cleanup_bearer() runs from a workqueue after tipc_udp_disable() clears the bearer's up bit, so an encap softirq can still reach tipc_udp_rcast_add() and add a peer after cleanup_bearer() has already emptied the list, leaking that entry when the bearer is freed. Mark the bearer disabled under rcast_lock once the list is emptied and refuse further additions.
--- net/tipc/udp_media.c | 56 +++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 29 deletions(-)
net/tipc/udp_media.c +27 -29
@@ -94,6 +94,8 @@ struct udp_replicast {* @ifindex: local address scope * @work: used to schedule deferred work on a bearer * @rcast: associated udp_replicast container +* @rcast_lock: serialize updates to @rcast.list against concurrent updaters +* @disabled: bearer is being torn down; reject further @rcast.list additions */ struct udp_bearer {struct tipc_bearer __rcu *bearer;
@@ -101,6 +103,8 @@ struct udp_bearer {u32 ifindex;struct work_struct work;struct udp_replicast rcast; +spinlock_t rcast_lock; +bool disabled; };static int tipc_udp_is_mcast_addr (struct udp_media_addr *addr)
@@ -279,26 +283,6 @@ static int tipc_udp_send_msg(struct net *net, struct sk_buff *skb,return err; } -static bool tipc_udp_is_known_peer (struct tipc_bearer *b, -struct udp_media_addr *addr) -{ -struct udp_replicast *rcast, *tmp; -struct udp_bearer *ub; - - ub =rcu_dereference_rtnl (b->media_ptr); -if (!ub) { -pr_err_ratelimited ("UDP bearer instance not found\n" ); -return false; - } - -list_for_each_entry_safe (rcast, tmp, &ub->rcast.list, list) { -if (!memcmp (&rcast->addr, addr,sizeof (struct udp_media_addr ))) -return true; - } - -return false; -} -static int tipc_udp_rcast_add (struct tipc_bearer *b,struct udp_media_addr *addr) {
@@ -309,16 +293,34 @@ static int tipc_udp_rcast_add(struct tipc_bearer *b,if (!ub)return -ENODEV ; +spin_lock_bh (&ub->rcast_lock); +if (ub->disabled) { +spin_unlock_bh (&ub->rcast_lock); +return 0 ; + } +list_for_each_entry (rcast, &ub->rcast.list, list) { +if (!memcmp (&rcast->addr, addr,sizeof (*addr))) { +spin_unlock_bh (&ub->rcast_lock); +return 0 ; + } + } + rcast =kmalloc (sizeof (*rcast),GFP_ATOMIC ); -if (!rcast) +if (!rcast) { +spin_unlock_bh (&ub->rcast_lock);return -ENOMEM ; + }if (dst_cache_init (&rcast->dst_cache,GFP_ATOMIC )) { +spin_unlock_bh (&ub->rcast_lock);kfree (rcast);return -ENOMEM ; }memcpy (&rcast->addr, addr,sizeof (struct udp_media_addr )); +list_add_rcu (&rcast->list, &ub->rcast.list); + b->bcast_addr.broadcast =TIPC_REPLICAST_SUPPORT ; +spin_unlock_bh (&ub->rcast_lock);if (ntohs (addr->proto) ==ETH_P_IP )pr_info ("New replicast peer: %pI4\n" , &rcast->addr.ipv4);
@@ -326,8 +328,6 @@ static int tipc_udp_rcast_add(struct tipc_bearer *b, else if (ntohs(addr->proto) == ETH_P_IPV6) pr_info("New replicast peer: %pI6\n", &rcast->addr.ipv6);#endif - b->bcast_addr.broadcast =TIPC_REPLICAST_SUPPORT ; -list_add_rcu (&rcast->list, &ub->rcast.list);return 0 ; }
@@ -362,9 +362,6 @@ static int tipc_udp_rcast_disc(struct tipc_bearer *b, struct sk_buff *skb)return 0 ; } -if (likely (tipc_udp_is_known_peer (b, &src))) -return 0 ; -return tipc_udp_rcast_add (b, &src); }
@@ -646,9 +643,6 @@ int tipc_udp_nl_bearer_add(struct tipc_bearer *b, struct nlattr *attr)return -EINVAL ; } -if (tipc_udp_is_known_peer (b, &addr)) -return 0 ; -return tipc_udp_rcast_add (b, &addr); }
@@ -680,6 +674,7 @@ static int tipc_udp_enable(struct net *net, struct tipc_bearer *b,return -ENOMEM ;INIT_LIST_HEAD (&ub->rcast.list); +spin_lock_init (&ub->rcast_lock);if (!attrs[TIPC_NLA_BEARER_UDP_OPTS ]) goto err;
@@ -809,11 +804,14 @@ static void cleanup_bearer(struct work_struct *work)struct udp_replicast *rcast, *tmp;struct tipc_net *tn; +spin_lock_bh (&ub->rcast_lock);list_for_each_entry_safe (rcast, tmp, &ub->rcast.list, list) {dst_cache_destroy (&rcast->dst_cache);list_del_rcu (&rcast->list);kfree_rcu (rcast, rcu); } + ub->disabled = true; +spin_unlock_bh (&ub->rcast_lock); tn =tipc_net (sock_net (ub->ubsock->sk));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1093/1674 scsi: core: wake eh reliably when using scsi_schedule_eh
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Jeffery <[email protected]>
[ Upstream commit dccf3b1798b70f94e958b3d00b83010399e6fb05 ]
Drivers which use the scsi_schedule_eh function to run the error handler currently risk the error handler thread never waking once all commands are timed out or inactive. There is no enforced memory order between setting the host into error recovery state and counting busy commands. This can result in a race with scsi_dec_host_busy where neither CPU sees both conditions of all commands inactive and the host error state to request waking the error handler.
To fix this, run the scsi_schedule_eh's scsi_eh_wakeup from a new work item which will use rcu to ensure scsi_schedule_eh's call to scsi_host_busy will occur after the error state is globally visible and will be seen by any current scsi_dec_host_busy callers.
--- drivers/scsi/hosts.c | 2 ++ drivers/scsi/scsi_error.c | 22 +++++++++++++++++++++- drivers/scsi/scsi_priv.h | 1 + include/scsi/scsi_host.h | 3 +++ 4 files changed, 27 insertions(+), 1 deletion(-)
drivers/scsi/hosts.c +2 -0
@@ -344,6 +344,7 @@ static void scsi_host_dev_release(struct device *dev)/* Wait for functions invoked through call_rcu(&scmd->rcu, ...) */ rcu_barrier (); +cancel_work_sync (&shost->eh_work);if (shost->tmf_work_q)destroy_workqueue (shost->tmf_work_q);if (shost->ehandler)
@@ -409,6 +410,7 @@ struct Scsi_Host *scsi_host_alloc(const struct scsi_host_template *sht, int privINIT_LIST_HEAD (&shost->starved_list);init_waitqueue_head (&shost->host_wait);mutex_init (&shost->scan_mutex); +INIT_WORK (&shost->eh_work, scsi_rcu_eh_wakeup); index =ida_alloc (&host_index_ida,GFP_KERNEL );if (index <0 ) {
drivers/scsi/scsi_error.c +21 -1
@@ -73,6 +73,26 @@ void scsi_eh_wakeup(struct Scsi_Host *shost, unsigned int busy) } } +void scsi_rcu_eh_wakeup (struct work_struct *work) +{ + struct Scsi_Host *shost = container_of(work, struct Scsi_Host, eh_work); +unsigned long flags; +unsigned int busy; + +/* +* Ensure any running scsi_dec_host_busy has completed its rcu section +* so changes to host state and host_eh_scheduled are visible to all +* future calls of scsi_dec_host_busy +*/ +synchronize_rcu (); + + busy =scsi_host_busy (shost); + +spin_lock_irqsave (shost->host_lock, flags); +scsi_eh_wakeup (shost, busy); +spin_unlock_irqrestore (shost->host_lock, flags); +} +/** * scsi_schedule_eh - schedule EH for SCSI host * @shost: SCSI host to invoke error handling on.
@@ -88,7 +108,7 @@ void scsi_schedule_eh(struct Scsi_Host *shost)if (scsi_host_set_state (shost,SHOST_RECOVERY ) ==0 ||scsi_host_set_state (shost,SHOST_CANCEL_RECOVERY ) ==0 ) { shost->host_eh_scheduled++; -scsi_eh_wakeup (shost,scsi_host_busy (shost)); +queue_work (shost->tmf_work_q, &shost->eh_work); }spin_unlock_irqrestore (shost->host_lock, flags);
drivers/scsi/scsi_priv.h +1 -0
@@ -93,6 +93,7 @@ extern enum blk_eh_timer_return scsi_timeout(struct request *req);extern int scsi_error_handler (void *host);extern enum scsi_disposition scsi_decide_disposition (struct scsi_cmnd *cmd);extern void scsi_eh_wakeup (struct Scsi_Host *shost,unsigned int busy); +extern void scsi_rcu_eh_wakeup (struct work_struct *work);extern void scsi_eh_scmd_add (struct scsi_cmnd *); void scsi_eh_ready_devs(struct Scsi_Host *shost, struct list_head *work_q,
include/scsi/scsi_host.h +3 -0
@@ -710,6 +710,9 @@ struct Scsi_Host {*/ struct device *dma_dev; +/* Used for an rcu-synchronizing eh wakeup */ +struct work_struct eh_work; +/* * We should ensure that this is aligned, both for better performance * and also because some compilers (m68k) don't automatically force
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1094/1674 bpf: Disable migration when destroying sock storage
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hou Tao <[email protected]>
[ Upstream commit 7d1032d1e3031ef38d1a360380d755f75cb639b8 ]
When destroying sock storage, it invokes bpf_local_storage_destroy() to remove all storage elements saved in the sock storage. The destroy procedure will call bpf_selem_free() to free the element, and bpf_selem_free() calls bpf_obj_free_fields() to free the special fields in map value (e.g., kptr). Since kptrs may be allocated from bpf memory allocator, migrate_{disable|enable} pairs are necessary for the freeing of these kptrs.
To simplify reasoning about when migrate_disable() is needed for the freeing of these dynamically-allocated kptrs, let the caller to guarantee migration is disabled before invoking bpf_obj_free_fields(). Therefore, the patch adds migrate_{disable|enable} pair in bpf_sock_storage_free(). The migrate_{disable|enable} pairs in the underlying implementation of bpf_obj_free_fields() will be removed by The following patch.
Stable-dep-of: 7cbd0c4cebe4 ("bpf: Fix UAF in sock clone early bailouts")
--- net/core/bpf_sk_storage.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
net/core/bpf_sk_storage.c +5 -4
@@ -50,15 +50,16 @@ void bpf_sk_storage_free(struct sock *sk) {struct bpf_local_storage *sk_storage; +migrate_disable ();rcu_read_lock (); sk_storage =rcu_dereference (sk->sk_bpf_storage); -if (!sk_storage) { -rcu_read_unlock (); -return ; - } +if (!sk_storage) + goto out;bpf_local_storage_destroy (sk_storage); +out:rcu_read_unlock (); +migrate_enable (); }static void bpf_sk_storage_map_free (struct bpf_map *map)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1095/1674 bpf: Disable migration when cloning sock storage
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hou Tao <[email protected]>
[ Upstream commit dfccfc47bde53f5df5bf42486d12a8a2ecdcea60 ]
bpf_sk_storage_clone() will call bpf_selem_free() to free the clone element when the allocation of new sock storage fails. bpf_selem_free() will call check_and_free_fields() to free the special fields in the element. Since the allocated element is not visible to bpf syscall or bpf program when bpf_local_storage_alloc() fails, these special fields in the element must be all zero when invoking bpf_selem_free().
To be uniform with other callers of bpf_selem_free(), disabling migration when cloning sock storage. Adding migrate_{disable|enable} pair also benefits the potential switching from kzalloc to bpf memory allocator for sock storage.
Stable-dep-of: 7cbd0c4cebe4 ("bpf: Fix UAF in sock clone early bailouts")
--- net/core/bpf_sk_storage.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/bpf_sk_storage.c +2 -0
@@ -161,6 +161,7 @@ int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk)RCU_INIT_POINTER (newsk->sk_bpf_storage,NULL ); +migrate_disable ();rcu_read_lock (); sk_storage =rcu_dereference (sk->sk_bpf_storage);
@@ -213,6 +214,7 @@ int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk) out:rcu_read_unlock (); +migrate_enable ();/* In case of an error, don't free anything explicitly here, the * caller is responsible to call bpf_sk_storage_free.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1096/1674 rcu: add rcu_read_lock_dont_migrate()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Menglong Dong <[email protected]>
[ Upstream commit 1b93c03fb319d72a1f5f4723abd5df15ce40f4e2 ]
migrate_disable() is called to disable migration in the kernel, and it is often used together with rcu_read_lock().
However, with PREEMPT_RCU disabled, it's unnecessary, as rcu_read_lock() will always disable preemption, which will also disable migration.
Introduce rcu_read_lock_dont_migrate() and rcu_read_unlock_migrate(), which will do the migration enable and disable only when PREEMPT_RCU.
Stable-dep-of: 7cbd0c4cebe4 ("bpf: Fix UAF in sock clone early bailouts")
--- include/linux/rcupdate.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
include/linux/rcupdate.h +14 -0
@@ -908,6 +908,20 @@ static inline notrace void rcu_read_unlock_sched_notrace(void)preempt_enable_notrace (); } +static __always_inline void rcu_read_lock_dont_migrate(void) +{ +if (IS_ENABLED (CONFIG_PREEMPT_RCU )) +migrate_disable (); +rcu_read_lock (); +} + +static inline void rcu_read_unlock_migrate (void ) +{ +rcu_read_unlock (); +if (IS_ENABLED (CONFIG_PREEMPT_RCU )) +migrate_enable (); +} +/** * RCU_INIT_POINTER() - initialize an RCU protected pointer * @p: The pointer to be initialized.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1097/1674 bpf: Use rcu_read_lock_dont_migrate in bpf_sk_storage.c
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fushuai Wang <[email protected]>
[ Upstream commit 0db4941d9dae159d887e7e2eac7e54e60c3aac87 ]
Use rcu_read_lock_dont_migrate() and rcu_read_unlock_migrate() in bpf_sk_storage.c to obtain better performance when PREEMPT_RCU is not enabled.
Stable-dep-of: 7cbd0c4cebe4 ("bpf: Fix UAF in sock clone early bailouts")
--- net/core/bpf_sk_storage.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
net/core/bpf_sk_storage.c +4 -8
@@ -50,16 +50,14 @@ void bpf_sk_storage_free(struct sock *sk) {struct bpf_local_storage *sk_storage; -migrate_disable (); -rcu_read_lock (); +rcu_read_lock_dont_migrate (); sk_storage =rcu_dereference (sk->sk_bpf_storage);if (!sk_storage) goto out;bpf_local_storage_destroy (sk_storage); out: -rcu_read_unlock (); -migrate_enable (); +rcu_read_unlock_migrate (); }static void bpf_sk_storage_map_free (struct bpf_map *map)
@@ -161,8 +159,7 @@ int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk)RCU_INIT_POINTER (newsk->sk_bpf_storage,NULL ); -migrate_disable (); -rcu_read_lock (); +rcu_read_lock_dont_migrate (); sk_storage =rcu_dereference (sk->sk_bpf_storage);if (!sk_storage ||hlist_empty (&sk_storage->list))
@@ -213,8 +210,7 @@ int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk) } out: -rcu_read_unlock (); -migrate_enable (); +rcu_read_unlock_migrate ();/* In case of an error, don't free anything explicitly here, the * caller is responsible to call bpf_sk_storage_free.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1098/1674 bpf: Fix UAF in sock clone early bailouts
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Bobrowski <[email protected]>
[ Upstream commit 7cbd0c4cebe4c9f678d15e6b9ba975e1155a107f ]
Similar to recent commit 9b51a6155d14 ("bpf,fork: wipe ->bpf_storage before bailouts that access it"), sk_clone() performs an initial shallow copy of the socket field ->sk_bpf_storage via sock_copy() for the cloned socket newsk.
If sk_clone() bails out early (e.g. if sk_filter_charge() fails) prior to calling bpf_sk_storage_clone(), newsk->sk_bpf_storage still points to the parent socket's BPF local storage. When newsk is subsequently freed via sk_free(), the deallocation path (__sk_destruct() -> bpf_sk_storage_free()) destroys the parent socket's BPF local storage, leading to a use-after-free (UAF) on the parent socket.
Fix this by resetting newsk->sk_bpf_storage to NULL immediately after sock_copy() in sk_clone(), and remove the now redundant initialization from bpf_sk_storage_clone().
--- net/core/bpf_sk_storage.c | 2 -- net/core/sock.c | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-)
net/core/bpf_sk_storage.c +0 -2
@@ -157,8 +157,6 @@ int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk)struct bpf_local_storage_elem *selem;int ret =0 ; -RCU_INIT_POINTER (newsk->sk_bpf_storage,NULL ); -rcu_read_lock_dont_migrate (); sk_storage =rcu_dereference (sk->sk_bpf_storage);
net/core/sock.c +3 -0
@@ -2327,6 +2327,9 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)sock_copy (newsk, sk); newsk->sk_prot_creator = prot; +#ifdef CONFIG_BPF_SYSCALL +RCU_INIT_POINTER (newsk->sk_bpf_storage,NULL ); +#endif /* SANITY */ if (likely (newsk->sk_net_refcnt)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1099/1674 firmware: arm_ffa: Fix out-of-bound writes in ffa_setup_and_transmit()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mostafa Saleh <[email protected]>
[ Upstream commit 3383ffb7ef937317361713ffcc21921a7848511a ]
Sashiko (locally) reports multiple out-of-bound issues in ffa_setup_and_transmit:
1) Writing ep_mem_access->reserved can write out of bounds for FFA versions < 1.2 as ffa_emad_size_get() returns 16 bytes in that case while reserved has an offset of 24.
Instead of zeroing fields, memset the struct to zero first based on the FFA version.
2) Make sure there is enough size to write constituents.
While at it, convert the only sizeof() in the driver that uses a type instead of variable.
--- drivers/firmware/arm_ffa/driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/arm_ffa/driver.c +2 -2
@@ -481,7 +481,7 @@ ffa_setup_and_transmit(u32 func_id, void *buffer, u32 max_fragsize, constituents = buffer; } -if ((void *)constituents - buffer > max_fragsize) { +if ((void *)constituents +sizeof (*constituents) - buffer > max_fragsize) {pr_err ("Memory Region Fragment > Tx Buffer size\n" );return -EFAULT ; }
@@ -490,7 +490,7 @@ ffa_setup_and_transmit(u32 func_id, void *buffer, u32 max_fragsize, constituents->pg_cnt = args->sg->length /FFA_PAGE_SIZE ; constituents->reserved =0 ; constituents++; - frag_len +=sizeof (struct ffa_mem_region_addr_range ); + frag_len +=sizeof (*constituents); }while ((args->sg =sg_next (args->sg))); return ffa_transmit_fragment(func_id, addr, buf_sz, frag_len,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1100/1674 wifi: cfg80211: use wiphy work for socket owner autodisconnect
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 0c2ed186bbe14304415476d6707b747dddcd8583 ]
nl80211_netlink_notify() walks the cfg80211 wireless device list when a NETLINK_GENERIC socket is released. If the socket owns a connection, the notifier queues the embedded wdev->disconnect_wk work item.
That work is a plain work_struct today. NETDEV_GOING_DOWN cancels it, but a NETLINK_URELEASE notifier that already observed conn_owner_nlportid can queue it after that cancel returns. _cfg80211_unregister_wdev() then removes the wdev from the list and waits for RCU readers, but synchronize_net() does not drain work queued by such a reader.
Make the autodisconnect work a wiphy_work instead. The callback already needs the wiphy mutex, and wiphy_work runs under that mutex. This lets teardown cancel pending autodisconnect work while holding the mutex, without a cancel_work_sync() vs. worker locking concern.
Also cancel the wiphy work after list_del_rcu() and synchronize_net(). Any NETLINK_URELEASE notifier that had already reached the wdev list has then either queued the work and it is removed, or can no longer find the wdev.
--- include/net/cfg80211.h | 2 +- net/wireless/core.c | 7 ++++--- net/wireless/core.h | 2 +- net/wireless/nl80211.c | 3 ++- net/wireless/sme.c | 6 ++---- 5 files changed, 10 insertions(+), 10 deletions(-)
include/net/cfg80211.h +1 -1
@@ -6000,7 +6000,7 @@ struct wireless_dev {enum ieee80211_bss_type conn_bss_type;u32 conn_owner_nlportid; -struct work_struct disconnect_wk; +struct wiphy_work disconnect_wk;u8 disconnect_bssid[ETH_ALEN ];struct list_head event_list;
net/wireless/core.c +4 -3
@@ -1220,6 +1220,7 @@ static void _cfg80211_unregister_wdev(struct wireless_dev *wdev,list_del_rcu (&wdev->list);synchronize_net (); rdev->devlist_generation++; +wiphy_work_cancel (wdev->wiphy, &wdev->disconnect_wk);cfg80211_mlme_purge_registrations (wdev);
@@ -1408,7 +1409,7 @@ void cfg80211_init_wdev(struct wireless_dev *wdev) wdev->iftype == NL80211_IFTYPE_ADHOC) && !wdev->use_4addr) wdev->netdev->priv_flags |= IFF_DONT_BRIDGE; -INIT_WORK (&wdev->disconnect_wk, cfg80211_autodisconnect_wk); +wiphy_work_init (&wdev->disconnect_wk, cfg80211_autodisconnect_wk); } void cfg80211_register_wdev(struct cfg80211_registered_device *rdev,
@@ -1516,9 +1517,9 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,wiphy_lock (&rdev->wiphy);cfg80211_leave (rdev, wdev);cfg80211_remove_links (wdev); -wiphy_unlock (&rdev->wiphy);/* since we just did cfg80211_leave() nothing to do there */ -cancel_work_sync (&wdev->disconnect_wk); +wiphy_work_cancel (wdev->wiphy, &wdev->disconnect_wk); +wiphy_unlock (&rdev->wiphy);cancel_work_sync (&wdev->pmsr_free_wk);break ;case NETDEV_DOWN :
net/wireless/core.h +1 -1
@@ -427,7 +427,7 @@ void __cfg80211_port_authorized(struct wireless_dev *wdev, const u8 *bssid, const u8 *td_bitmap, u8 td_bitmap_len);int cfg80211_mgd_wext_connect (struct cfg80211_registered_device *rdev,struct wireless_dev *wdev); -void cfg80211_autodisconnect_wk (struct work_struct *work); +void cfg80211_autodisconnect_wk (struct wiphy *wiphy,struct wiphy_work *work);/* SME implementation */ void cfg80211_conn_work (struct work_struct *work);
net/wireless/nl80211.c +2 -1
@@ -20029,7 +20029,8 @@ static int nl80211_netlink_notify(struct notifier_block * nb, wdev->nl_owner_dead = true;schedule_work (&rdev->destroy_work); }else if (wdev->conn_owner_nlportid == notify->portid) { -schedule_work (&wdev->disconnect_wk); +wiphy_work_queue (wdev->wiphy, + &wdev->disconnect_wk); }cfg80211_release_pmsr (wdev, notify->portid);
net/wireless/sme.c +2 -4
@@ -1584,13 +1584,12 @@ int cfg80211_disconnect(struct cfg80211_registered_device *rdev,* Used to clean up after the connection / connection attempt owner socket * disconnects */ -void cfg80211_autodisconnect_wk (struct work_struct *work) +void cfg80211_autodisconnect_wk (struct wiphy *wiphy,struct wiphy_work *work) {struct wireless_dev *wdev = container_of(work, struct wireless_dev, disconnect_wk); -struct cfg80211_registered_device *rdev =wiphy_to_rdev (wdev->wiphy); +struct cfg80211_registered_device *rdev =wiphy_to_rdev (wiphy); -wiphy_lock (wdev->wiphy);wdev_lock (wdev);if (wdev->conn_owner_nlportid) {
@@ -1629,5 +1628,4 @@ void cfg80211_autodisconnect_wk(struct work_struct *work) }wdev_unlock (wdev); -wiphy_unlock (wdev->wiphy); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1101/1674 wifi: cfg80211: convert pmsr_free_wk to wiphy_work to fix deadlock
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peddolla Harshavardhan Reddy <[email protected]>
[ Upstream commit 2b0eab425e1f658d8fe1df7590e3b9af5959505e ]
When a netlink socket that owns a PMSR session is closed, cfg80211_release_pmsr() clears the request's nl_portid and queues pmsr_free_wk to call cfg80211_pmsr_process_abort() asynchronously.
If the interface tears down concurrently, cfg80211_pmsr_wdev_down() is called under wiphy_lock and calls cancel_work_sync(&pmsr_free_wk) to wait for any running work. The work function acquires wiphy_lock via guard(wiphy) before calling process_abort.
This is a deadlock: wdev_down holds wiphy_lock and blocks inside cancel_work_sync(); pmsr_free_wk blocks trying to acquire that same wiphy_lock. Neither thread can proceed.
The same deadlock is reachable from cfg80211_leave_locked(), which calls cfg80211_pmsr_wdev_down() for all interface types under wiphy_lock.
Fix this by converting pmsr_free_wk from a plain work_struct to a wiphy_work. The wiphy_work dispatcher holds wiphy_lock when running work items, so the explicit guard(wiphy) in the work function is no longer needed. wiphy_work_cancel() can be called safely while holding wiphy_lock - since wiphy_lock prevents the work from running concurrently, wiphy_work_cancel() never blocks, eliminating the deadlock.
Remove the cancel_work_sync() for pmsr_free_wk from the NETDEV_GOING_DOWN handler. cfg80211_leave(), called unconditionally just before it, already cancels any pending work under wiphy_lock via wiphy_work_cancel() inside cfg80211_pmsr_wdev_down().
--- include/net/cfg80211.h | 2 +- net/wireless/core.c | 3 +-- net/wireless/core.h | 2 +- net/wireless/pmsr.c | 8 +++----- 4 files changed, 6 insertions(+), 9 deletions(-)
include/net/cfg80211.h +1 -1
@@ -6042,7 +6042,7 @@ struct wireless_dev {struct list_head pmsr_list;spinlock_t pmsr_lock; -struct work_struct pmsr_free_wk; +struct wiphy_work pmsr_free_wk;unsigned long unprot_beacon_reported;
net/wireless/core.c +1 -2
@@ -1387,7 +1387,7 @@ void cfg80211_init_wdev(struct wireless_dev *wdev)INIT_LIST_HEAD (&wdev->mgmt_registrations);INIT_LIST_HEAD (&wdev->pmsr_list);spin_lock_init (&wdev->pmsr_lock); -INIT_WORK (&wdev->pmsr_free_wk, cfg80211_pmsr_free_wk); +wiphy_work_init (&wdev->pmsr_free_wk, cfg80211_pmsr_free_wk);#ifdef CONFIG_CFG80211_WEXT wdev->wext.default_key =-1 ;
@@ -1520,7 +1520,6 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb,/* since we just did cfg80211_leave() nothing to do there */ wiphy_work_cancel (wdev->wiphy, &wdev->disconnect_wk);wiphy_unlock (&rdev->wiphy); -cancel_work_sync (&wdev->pmsr_free_wk);break ;case NETDEV_DOWN :wiphy_lock (&rdev->wiphy);
net/wireless/core.h +1 -1
@@ -575,7 +575,7 @@ cfg80211_bss_update(struct cfg80211_registered_device *rdev,void cfg80211_release_pmsr (struct wireless_dev *wdev,u32 portid);void cfg80211_pmsr_wdev_down (struct wireless_dev *wdev); -void cfg80211_pmsr_free_wk (struct work_struct *work); +void cfg80211_pmsr_free_wk (struct wiphy *wiphy,struct wiphy_work *work);void cfg80211_remove_link (struct wireless_dev *wdev,unsigned int link_id);void cfg80211_remove_links (struct wireless_dev *wdev);
net/wireless/pmsr.c +3 -5
@@ -634,16 +634,14 @@ static void cfg80211_pmsr_process_abort(struct wireless_dev *wdev) } } -void cfg80211_pmsr_free_wk (struct work_struct *work) +void cfg80211_pmsr_free_wk (struct wiphy *wiphy,struct wiphy_work *work) { struct wireless_dev *wdev = container_of(work, struct wireless_dev, pmsr_free_wk); -wiphy_lock (wdev->wiphy);wdev_lock (wdev);cfg80211_pmsr_process_abort (wdev);wdev_unlock (wdev); -wiphy_unlock (wdev->wiphy); }void cfg80211_pmsr_wdev_down (struct wireless_dev *wdev)
@@ -658,7 +656,7 @@ void cfg80211_pmsr_wdev_down(struct wireless_dev *wdev) }spin_unlock_bh (&wdev->pmsr_lock); -cancel_work_sync (&wdev->pmsr_free_wk); +wiphy_work_cancel (wdev->wiphy, &wdev->pmsr_free_wk);if (found)cfg80211_pmsr_process_abort (wdev);
@@ -673,7 +671,7 @@ void cfg80211_release_pmsr(struct wireless_dev *wdev, u32 portid)list_for_each_entry (req, &wdev->pmsr_list, list) {if (req->nl_portid == portid) { req->nl_portid =0 ; -schedule_work (&wdev->pmsr_free_wk); +wiphy_work_queue (wdev->wiphy, &wdev->pmsr_free_wk); } }spin_unlock_bh (&wdev->pmsr_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1102/1674 wifi: mac80211: refactor populating mesh related fields in sinfo
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarika Sharma <[email protected]>
[ Upstream commit e5328c14590d034dc586e56aaab88e966d06efa7 ]
Introduce the sta_set_mesh_sinfo() to populate mesh related fields in sinfo structure for station statistics.
This will allow for the simplified population of other fields in the sinfo structure for link level in a subsequent patch to add support for MLO station statistics.
No functionality changes added.
Stable-dep-of: aa2eb6252518 ("wifi: mac80211: defer link RX stats percpu free to RCU")
--- net/mac80211/sta_info.c | 64 ++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 29 deletions(-)
net/mac80211/sta_info.c +35 -29
@@ -2589,6 +2589,39 @@ static inline u64 sta_get_stats_bytes(struct ieee80211_sta_rx_stats *rxstats)return value; } +#ifdef CONFIG_MAC80211_MESH +static void sta_set_mesh_sinfo (struct sta_info *sta, +struct station_info *sinfo) +{ +struct ieee80211_local *local = sta->sdata->local; + + sinfo->filled |=BIT_ULL (NL80211_STA_INFO_LLID ) | +BIT_ULL (NL80211_STA_INFO_PLID ) | +BIT_ULL (NL80211_STA_INFO_PLINK_STATE ) | +BIT_ULL (NL80211_STA_INFO_LOCAL_PM ) | +BIT_ULL (NL80211_STA_INFO_PEER_PM ) | +BIT_ULL (NL80211_STA_INFO_NONPEER_PM ) | +BIT_ULL (NL80211_STA_INFO_CONNECTED_TO_GATE ) | +BIT_ULL (NL80211_STA_INFO_CONNECTED_TO_AS ); + + sinfo->llid = sta->mesh->llid; + sinfo->plid = sta->mesh->plid; + sinfo->plink_state = sta->mesh->plink_state; +if (test_sta_flag (sta,WLAN_STA_TOFFSET_KNOWN )) { + sinfo->filled |=BIT_ULL (NL80211_STA_INFO_T_OFFSET ); + sinfo->t_offset = sta->mesh->t_offset; + } + sinfo->local_pm = sta->mesh->local_pm; + sinfo->peer_pm = sta->mesh->peer_pm; + sinfo->nonpeer_pm = sta->mesh->nonpeer_pm; + sinfo->connected_to_gate = sta->mesh->connected_to_gate; + sinfo->connected_to_as = sta->mesh->connected_to_as; + + sinfo->filled |=BIT_ULL (NL80211_STA_INFO_AIRTIME_LINK_METRIC ); + sinfo->airtime_link_metric =airtime_link_metric_get (local, sta); +} +#endif +void sta_set_sinfo (struct sta_info *sta,struct station_info *sinfo,bool tidstats) {
@@ -2772,31 +2805,10 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo,sta_set_tidstats (sta, &sinfo->pertid[i], i); } -if (ieee80211_vif_is_mesh (&sdata->vif)) {#ifdef CONFIG_MAC80211_MESH - sinfo->filled |=BIT_ULL (NL80211_STA_INFO_LLID ) | -BIT_ULL (NL80211_STA_INFO_PLID ) | -BIT_ULL (NL80211_STA_INFO_PLINK_STATE ) | -BIT_ULL (NL80211_STA_INFO_LOCAL_PM ) | -BIT_ULL (NL80211_STA_INFO_PEER_PM ) | -BIT_ULL (NL80211_STA_INFO_NONPEER_PM ) | -BIT_ULL (NL80211_STA_INFO_CONNECTED_TO_GATE ) | -BIT_ULL (NL80211_STA_INFO_CONNECTED_TO_AS ); - - sinfo->llid = sta->mesh->llid; - sinfo->plid = sta->mesh->plid; - sinfo->plink_state = sta->mesh->plink_state; -if (test_sta_flag (sta,WLAN_STA_TOFFSET_KNOWN )) { - sinfo->filled |=BIT_ULL (NL80211_STA_INFO_T_OFFSET ); - sinfo->t_offset = sta->mesh->t_offset; - } - sinfo->local_pm = sta->mesh->local_pm; - sinfo->peer_pm = sta->mesh->peer_pm; - sinfo->nonpeer_pm = sta->mesh->nonpeer_pm; - sinfo->connected_to_gate = sta->mesh->connected_to_gate; - sinfo->connected_to_as = sta->mesh->connected_to_as; +if (ieee80211_vif_is_mesh (&sdata->vif)) +sta_set_mesh_sinfo (sta, sinfo);#endif - } sinfo->bss_param.flags =0 ;if (sdata->vif.bss_conf.use_cts_prot)
@@ -2852,12 +2864,6 @@ void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo, sinfo->filled |=BIT_ULL (NL80211_STA_INFO_ACK_SIGNAL_AVG ); } - -if (ieee80211_vif_is_mesh (&sdata->vif)) { - sinfo->filled |=BIT_ULL (NL80211_STA_INFO_AIRTIME_LINK_METRIC ); - sinfo->airtime_link_metric = -airtime_link_metric_get (local, sta); - } }u32 sta_get_expected_throughput (struct sta_info *sta)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1103/1674 wifi: cfg80211: add link_station_info structure to support MLO statistics
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarika Sharma <[email protected]>
[ Upstream commit d2329fff7e527e8b350086be2e7cbf0d190177a3 ]
Current implementation of NL80211_GET_STATION does not work for multi-link operation(MLO) since in case of MLO only deflink (or one of the links) is considered and not all links.
Therefore to support for MLO, add link_station_info structure to account link level statistics for station.
Additionally, add valid_links in station_info structure to indicate bitmap of valid links for MLO. This will be helpful to check the link related statistics during MLO.
Stable-dep-of: aa2eb6252518 ("wifi: mac80211: defer link RX stats percpu free to RCU")
--- include/net/cfg80211.h | 101 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+)
include/net/cfg80211.h +101 -0
@@ -1872,6 +1872,99 @@ struct cfg80211_tid_stats {#define IEEE80211_MAX_CHAINS 4 +/** +* struct link_station_info - link station information +* +* Link station information filled by driver for get_station() and +* dump_station(). +* @filled: bit flag of flags using the bits of &enum nl80211_sta_info to +* indicate the relevant values in this struct for them +* @connected_time: time(in secs) since a link of station is last connected +* @inactive_time: time since last activity for link station(tx/rx) +* in milliseconds +* @assoc_at: bootime (ns) of the last association of link of station +* @rx_bytes: bytes (size of MPDUs) received from this link of station +* @tx_bytes: bytes (size of MPDUs) transmitted to this link of station +* @signal: The signal strength, type depends on the wiphy's signal_type. +* For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_. +* @signal_avg: Average signal strength, type depends on the wiphy's +* signal_type. For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_ +* @chains: bitmask for filled values in @chain_signal, @chain_signal_avg +* @chain_signal: per-chain signal strength of last received packet in dBm +* @chain_signal_avg: per-chain signal strength average in dBm +* @txrate: current unicast bitrate from this link of station +* @rxrate: current unicast bitrate to this link of station +* @rx_packets: packets (MSDUs & MMPDUs) received from this link of station +* @tx_packets: packets (MSDUs & MMPDUs) transmitted to this link of station +* @tx_retries: cumulative retry counts (MPDUs) for this link of station +* @tx_failed: number of failed transmissions (MPDUs) (retries exceeded, no ACK) +* @rx_dropped_misc: Dropped for un-specified reason. +* @bss_param: current BSS parameters +* @beacon_loss_count: Number of times beacon loss event has triggered. +* @expected_throughput: expected throughput in kbps (including 802.11 headers) +* towards this station. +* @rx_beacon: number of beacons received from this peer +* @rx_beacon_signal_avg: signal strength average (in dBm) for beacons received +* from this peer +* @rx_duration: aggregate PPDU duration(usecs) for all the frames from a peer +* @tx_duration: aggregate PPDU duration(usecs) for all the frames to a peer +* @airtime_weight: current airtime scheduling weight +* @pertid: per-TID statistics, see &struct cfg80211_tid_stats, using the last +* (IEEE80211_NUM_TIDS) index for MSDUs not encapsulated in QoS-MPDUs. +* Note that this doesn't use the @filled bit, but is used if non-NULL. +* @ack_signal: signal strength (in dBm) of the last ACK frame. +* @avg_ack_signal: average rssi value of ack packet for the no of msdu's has +* been sent. +* @rx_mpdu_count: number of MPDUs received from this station +* @fcs_err_count: number of packets (MPDUs) received from this station with +* an FCS error. This counter should be incremented only when TA of the +* received packet with an FCS error matches the peer MAC address. +* @addr: For MLO STA connection, filled with address of the link of station. +*/ +struct link_station_info { +u64 filled; +u32 connected_time; +u32 inactive_time; +u64 assoc_at; +u64 rx_bytes; +u64 tx_bytes; +s8 signal; +s8 signal_avg; + +u8 chains; +s8 chain_signal[IEEE80211_MAX_CHAINS ]; +s8 chain_signal_avg[IEEE80211_MAX_CHAINS ]; + +struct rate_info txrate; +struct rate_info rxrate; +u32 rx_packets; +u32 tx_packets; +u32 tx_retries; +u32 tx_failed; +u32 rx_dropped_misc; +struct sta_bss_parameters bss_param; + +u32 beacon_loss_count; + +u32 expected_throughput; + +u64 tx_duration; +u64 rx_duration; +u64 rx_beacon; +u8 rx_beacon_signal_avg; + +u16 airtime_weight; + +s8 ack_signal; +s8 avg_ack_signal; +struct cfg80211_tid_stats *pertid; + +u32 rx_mpdu_count; +u32 fcs_err_count; + +u8 addr[ETH_ALEN ]__aligned(2) ; +}; +/** * struct station_info - station information *
@@ -1956,6 +2049,11 @@ struct cfg80211_tid_stats {* dump_station() callbacks. User space needs this information to determine * the accepted and rejected affiliated links of the connected station. * @assoc_resp_ies_len: Length of @assoc_resp_ies buffer in octets. +* @valid_links: bitmap of valid links, or 0 for non-MLO. Drivers fill this +* information in cfg80211_new_sta(), cfg80211_del_sta_sinfo(), +* get_station() and dump_station() callbacks. +* @links: reference to Link sta entries for MLO STA, all link specific +* information is accessed through links[link_id]. */ struct station_info {u64 filled;
@@ -2021,6 +2119,9 @@ struct station_info {u8 mld_addr[ETH_ALEN ]__aligned(2) ;const u8 *assoc_resp_ies;size_t assoc_resp_ies_len; + +u16 valid_links; +struct link_station_info *links[IEEE80211_MLD_MAX_NUM_LINKS ]; };/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1104/1674 wifi: mac80211: defer link RX stats percpu free to RCU
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maoyi Xie <[email protected]>
[ Upstream commit aa2eb62525188269cdd402a583b9a8ed94657ff0 ]
sta_remove_link() frees a removed MLO link's RX stats percpu buffer right away, but defers only the link container to RCU:
sta_info_free_link(&alloc->info); kfree_rcu(alloc, rcu_head);
The RX fast path reads link_sta under rcu_read_lock and writes the percpu stats. A reader that resolved link_sta before the removal keeps the pointer. The container stays alive from the kfree_rcu, so the read still works. But the percpu block it points to is already freed. This needs uses_rss. That is when pcpu_rx_stats exists.
The full STA teardown frees the deflink stats only after synchronize_net(). The link removal path had no such barrier. The race is hard to win in practice, but the free should still wait for RCU.
Free the link together with its data from a single RCU callback, so the percpu block is reclaimed only after readers drain.
--- net/mac80211/sta_info.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
net/mac80211/sta_info.c +11 -4
@@ -349,6 +349,15 @@ static void sta_info_free_link(struct link_sta_info *link_sta)free_percpu (link_sta->pcpu_rx_stats); } +static void sta_link_free_rcu (struct rcu_head *head) +{ +struct sta_link_alloc *alloc = + container_of(head, struct sta_link_alloc, rcu_head); + +sta_info_free_link (&alloc->info); +kfree (alloc); +} +static void sta_remove_link (struct sta_info *sta,unsigned int link_id,bool unhash) {
@@ -374,10 +383,8 @@ static void sta_remove_link(struct sta_info *sta, unsigned int link_id, sta->sta.valid_links &= ~BIT (link_id);RCU_INIT_POINTER (sta->link[link_id],NULL );RCU_INIT_POINTER (sta->sta.link[link_id],NULL ); -if (alloc) { -sta_info_free_link (&alloc->info); -kfree_rcu (alloc, rcu_head); - } +if (alloc) +call_rcu (&alloc->rcu_head, sta_link_free_rcu);ieee80211_sta_recalc_aggregates (&sta->sta); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1105/1674 RDMA/irdma: Prevent user-triggered null deref on QP create
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Moroni <[email protected]>
[ Upstream commit b9b0889071569d43623c260074e159cd8f26adb1 ]
Previously, the user QP creation path would only attempt to populate iwqp->iwpbl if the user-provided req.user_wqe_bufs field was non-zero. The problem is that iwqp->iwpbl is unconditionally dereferenced later on in irdma_setup_virt_qp.
While there was a check for iwqp->iwpbl != NULL, this check would only occur if req.user_wqe_bufs was non-zero. The end result is that a user could send a zero user_wqe_bufs value and trigger a null ptr deref.
Fix this by unconditionally calling irdma_get_pbl and bailing if it fails, similar to the CQ and SRQ paths.
--- drivers/infiniband/hw/irdma/verbs.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/infiniband/hw/irdma/verbs.c +10 -11
@@ -602,18 +602,17 @@ static int irdma_setup_umode_qp(struct ib_udata *udata, iwqp->ctx_info.qp_compl_ctx = req.user_compl_ctx; iwqp->user_mode =1 ; -if (req.user_wqe_bufs) { - info->qp_uk_init_info.legacy_mode = ucontext->legacy_mode; -spin_lock_irqsave (&ucontext->qp_reg_mem_list_lock, flags); - iwqp->iwpbl =irdma_get_pbl ((unsigned long )req.user_wqe_bufs, - &ucontext->qp_reg_mem_list); -spin_unlock_irqrestore (&ucontext->qp_reg_mem_list_lock, flags); -if (!iwqp->iwpbl) { - ret = -ENODATA ; -ibdev_dbg (&iwdev->ibdev,"VERBS: no pbl info\n" ); -return ret; - } + info->qp_uk_init_info.legacy_mode = ucontext->legacy_mode; +spin_lock_irqsave (&ucontext->qp_reg_mem_list_lock, flags); + iwqp->iwpbl =irdma_get_pbl ((unsigned long )req.user_wqe_bufs, + &ucontext->qp_reg_mem_list); +spin_unlock_irqrestore (&ucontext->qp_reg_mem_list_lock, flags); + +if (!iwqp->iwpbl) { + ret = -ENODATA ; +ibdev_dbg (&iwdev->ibdev,"VERBS: no pbl info\n" ); +return ret; }if (!ucontext->use_raw_attrs) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1106/1674 xfrm: fix stale skb->prev after async crypto steals a GSO segment
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Petr Wozniak <[email protected]>
[ Upstream commit 3f4c3919baf0944ad96580467c302bc6c7758b00 ]
skb_gso_segment() leaves the segment list head with ->prev pointing at the last segment, an invariant validate_xmit_skb_list() relies on when it sets its tail pointer (tail = skb->prev).
When validate_xmit_xfrm() walks a GSO list and some segments are stolen by async crypto (->xmit() returns -EINPROGRESS), those segments are unlinked from the list but the head ->prev is never updated. If the last segment is the one stolen, the returned head still has ->prev pointing at it, even though it is now owned by the crypto engine and may be freed. validate_xmit_skb_list() later does tail->next = skb, writing through that stale pointer -- a use-after-free.
Repoint skb->prev at the last retained segment before returning.
--- net/xfrm/xfrm_device.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/xfrm/xfrm_device.c +8 -0
@@ -226,6 +226,14 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur pskb = skb2; } +/* skb_gso_segment() set skb->prev to the last segment, but async +* crypto may have stolen it above without updating ->prev. Repoint +* it at the last retained segment so validate_xmit_skb_list() does +* not chain onto a segment now owned by the crypto engine. +*/ +if (skb) + skb->prev = pskb; +return skb; }EXPORT_SYMBOL_GPL (validate_xmit_xfrm);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1107/1674 loongarch, kexec: change dependency of object files
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baoquan He <[email protected]>
[ Upstream commit 655fc6cd45521aba4a21c6e607533f1a21e06c2e ]
Patch series "kexec: fix the incorrect ifdeffery and dependency of CONFIG_KEXEC".
The select of KEXEC for CRASH_DUMP in kernel/Kconfig.kexec will be dropped, then compiling errors will be triggered if below config items are set:
===CONFIG_CRASH_CORE=yCONFIG_KEXEC_CORE=yCONFIG_CRASH_DUMP=y
===
E.g on mips, below link error are seen:
--------------------------------------------------------------------
mipsel-linux-ld: kernel/kexec_core.o: in function `kimage_free':
kernel/kexec_core.c:(.text+0x2200): undefined reference to `machine_kexec_cleanup'
mipsel-linux-ld: kernel/kexec_core.o: in function `__crash_kexec':
kernel/kexec_core.c:(.text+0x2480): undefined reference to `machine_crash_shutdown'
mipsel-linux-ld: kernel/kexec_core.c:(.text+0x2488): undefined reference to `machine_kexec'
mipsel-linux-ld: kernel/kexec_core.o: in function `kernel_kexec':
kernel/kexec_core.c:(.text+0x29b8): undefined reference to `machine_shutdown'
mipsel-linux-ld: kernel/kexec_core.c:(.text+0x29c0): undefined reference to `machine_kexec'
--------------------------------------------------------------------
Here, change the incorrect dependency of building kexec_core related object files, and the ifdeffery on architectures from CONFIG_KEXEC to CONFIG_KEXEC_CORE.
Testing:
========
Passed on mips and loognarch with the LKP reproducer.
This patch (of 5):
Currently, in arch/loongarch/kernel/Makefile, building machine_kexec.o relocate_kernel.o depends on CONFIG_KEXEC.
Whereas, since we will drop the select of KEXEC for CRASH_DUMP in kernel/Kconfig.kexec, compiling error will be triggered if below config items are set:
===CONFIG_CRASH_CORE=yCONFIG_KEXEC_CORE=yCONFIG_CRASH_DUMP=y
===
---------------------------------------------------------------
loongarch64-linux-ld: kernel/kexec_core.o: in function `.L209':
Quoted 1 line
Quoted 1 line
kexec_core.c:(.text+0x1660): undefined reference to `machine_kexec_cleanup'
loongarch64-linux-ld: kernel/kexec_core.o: in function `.L287':
Quoted 2 lines
Quoted 2 lines
kexec_core.c:(.text+0x1c5c): undefined reference to `machine_crash_shutdown'
loongarch64-linux-ld: kexec_core.c:(.text+0x1c64): undefined reference to `machine_kexec'
loongarch64-linux-ld: kernel/kexec_core.o: in function `.L2^B5':
Quoted 1 line
Quoted 1 line
kexec_core.c:(.text+0x2090): undefined reference to `machine_shutdown'
loongarch64-linux-ld: kexec_core.c:(.text+0x20a0): undefined reference to `machine_kexec'
---------------------------------------------------------------
Here, change the dependency of machine_kexec.o relocate_kernel.o to CONFIG_KEXEC_CORE can fix above building error.
Stable-dep-of: 485ed44db569 ("LoongArch: Fix address space mismatch in kexec command line lookup")
--- arch/loongarch/kernel/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/kernel/Makefile +1 -1
@@ -57,7 +57,7 @@ obj-$(CONFIG_MAGIC_SYSRQ) += sysrq.o obj-$(CONFIG_RELOCATABLE) += relocate.o -obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o +obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o relocate_kernel.o obj-$(CONFIG_CRASH_DUMP) += crash_dump.o obj-$(CONFIG_UNWINDER_GUESS) += unwind_guess.o
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1108/1674 LoongArch: Fix address space mismatch in kexec command line lookup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: George Guo <[email protected]>
[ Upstream commit 485ed44db5694d8d2e5027f63ad608e705286f30 ]
When searching the loaded segments for the "kexec" command line marker, the kexec_load(2) path (file_mode == 0) passes the user-space segment buffer straight to strncmp() through a bogus (char __user *) cast. This dereferences a user pointer in kernel context, which is wrong and is flagged by sparse:
arch/loongarch/kernel/machine_kexec.c:84:51: sparse: incorrect type in argument 2 (different address spaces) @@ expected char const * @@ got char [noderef] __user *
Here copy the marker-sized prefix of each segment into a small on-stack buffer with copy_from_user() before comparing, and skip segments that fault. The subsequent copy_from_user() that stages the full command line into the safe area is left unchanged.
--- arch/loongarch/kernel/machine_kexec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/loongarch/kernel/machine_kexec.c +4 -1
@@ -62,6 +62,7 @@ static void kexec_image_info(const struct kimage *kimage)int machine_kexec_prepare (struct kimage *kimage) {int i; +char head[8 ];char *bootloader ="kexec" ;void *cmdline_ptr = (void *)KEXEC_CMDLINE_ADDR ;
@@ -72,7 +73,9 @@ int machine_kexec_prepare(struct kimage *kimage)/* Find the command line */ for (i =0 ; i < kimage->nr_segments; i++) { -if (!strncmp (bootloader, (char __user *)kimage->segment[i].buf,strlen (bootloader))) { +if (copy_from_user (head, kimage->segment[i].buf,strlen (bootloader))) +continue ; +if (!strncmp (bootloader, head,strlen (bootloader))) {if (!copy_from_user (cmdline_ptr, kimage->segment[i].buf,COMMAND_LINE_SIZE )) kimage->arch.cmdline_ptr = (unsigned long )cmdline_ptr;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1109/1674 net/sched: Handle TC_ACT_REDIRECT from qdisc filter chains
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit ec48b3be2c8595dd290be883dbd4fb8b2f9f5d5e ]
When a TC filter attached to a qdisc filter chain returns TC_ACT_REDIRECT (ex: via an eBPF program calling bpf_redirect() or an act_bpf action), the redirect was silently lost i.e no qdisc classify function handled TC_ACT_REDIRECT, so the packet fell through the switch and was enqueued normally instead of being redirected.
This has been broken since bpf_redirect() was introduced for TC in commit 27b29f63058d ("bpf: add bpf_redirect() helper"). We got lucky for a long time because bpf_net_context was a per-CPU variable that was always available.
commit 401cb7dae813 ("net: Reference bpf_redirect_info via task_struct on PREEMPT_RT.") turned bpf_net_context into a task_struct member that is only set up by explicit callers. Without a caller setting it up, bpf_redirect() itself crashes with a NULL pointer dereference in bpf_net_ctx_get_ri(). However, even with bpf_net_context available, TC_ACT_REDIRECT from qdisc filter chains cannot be honored without adding skb_do_redirect() calls to every qdisc classify function, which would require changes across net/sched/. Isolate it to ebpf core where it belongs.
Instead, add a tcf_classify_qdisc() inline helper in pkt_cls.h, as a wrapper around tcf_classify() for use by qdisc classify functions and tcf_qevent_handle(). When the classify verdict is TC_ACT_REDIRECT, the wrapper converts it to TC_ACT_SHOT, dropping the packet rather than letting it continue silently. Dropping is preferred over letting the packet through because the user immediately sees packet loss. Silently passing the packet through would hide the problem and leave the user wondering why their redirect is not working.
The clsact fast path, tc_run() continues to call tcf_classify() directly and is unaffected: TC_ACT_REDIRECT is returned as-is and handled by sch_handle_egress/ingress() calling skb_do_redirect() as before.
--- include/net/pkt_cls.h | 14 +++++++++++++- net/sched/sch_cake.c | 2 +- net/sched/sch_drr.c | 2 +- net/sched/sch_ets.c | 2 +- net/sched/sch_fq_codel.c | 2 +- net/sched/sch_fq_pie.c | 2 +- net/sched/sch_hfsc.c | 2 +- net/sched/sch_htb.c | 2 +- net/sched/sch_multiq.c | 2 +- net/sched/sch_prio.c | 2 +- net/sched/sch_qfq.c | 2 +- net/sched/sch_sfb.c | 2 +- net/sched/sch_sfq.c | 2 +- 13 files changed, 25 insertions(+), 13 deletions(-)
include/net/pkt_cls.h +13 -1
@@ -154,8 +154,20 @@ static inline int tcf_classify(struct sk_buff *skb, {return TC_ACT_UNSPEC ; } -#endif +static inline int tcf_classify_qdisc (struct sk_buff *skb, +const struct tcf_proto *tp, +struct tcf_result *res,bool compat_mode) +{ +int ret =tcf_classify (skb,NULL , tp, res, compat_mode); + +/* TC_ACT_REDIRECT from qdisc filter chains is not supported. +* Use BPF via tcx or mirred redirect instead. +*/ +if (unlikely (ret ==TC_ACT_REDIRECT )) + ret =TC_ACT_SHOT ; +return ret; +}static inline unsigned long __cls_set_class (unsigned long *clp,unsigned long cl)
net/sched/sch_cake.c +1 -1
@@ -1721,7 +1721,7 @@ static u32 cake_classify(struct Qdisc *sch, struct cake_tin_data **t, goto hash; *qerr =NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; - result =tcf_classify (skb,NULL , filter, &res, false); + result =tcf_classify_qdisc (skb, filter, &res, false);if (result >=0 ) {#ifdef CONFIG_NET_CLS_ACT
net/sched/sch_drr.c +1 -1
@@ -313,7 +313,7 @@ static struct drr_class *drr_classify(struct sk_buff *skb, struct Qdisc *sch, *qerr =NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; fl =rcu_dereference_bh (q->filter_list); - result =tcf_classify (skb,NULL , fl, &res, false); + result =tcf_classify_qdisc (skb, fl, &res, false);if (result >=0 ) {#ifdef CONFIG_NET_CLS_ACT switch (result) {
net/sched/sch_ets.c +1 -1
@@ -389,7 +389,7 @@ static struct ets_class *ets_classify(struct sk_buff *skb, struct Qdisc *sch, *qerr =NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;if (TC_H_MAJ (skb->priority) != sch->handle) { fl =rcu_dereference_bh (q->filter_list); - err =tcf_classify (skb,NULL , fl, &res, false); + err =tcf_classify_qdisc (skb, fl, &res, false);#ifdef CONFIG_NET_CLS_ACT switch (err) {case TC_ACT_STOLEN :
net/sched/sch_fq_codel.c +1 -1
@@ -91,7 +91,7 @@ static unsigned int fq_codel_classify(struct sk_buff *skb, struct Qdisc *sch,return fq_codel_hash (q, skb) +1 ; *qerr =NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; - result =tcf_classify (skb,NULL , filter, &res, false); + result =tcf_classify_qdisc (skb, filter, &res, false);if (result >=0 ) {#ifdef CONFIG_NET_CLS_ACT switch (result) {
net/sched/sch_fq_pie.c +1 -1
@@ -95,7 +95,7 @@ static unsigned int fq_pie_classify(struct sk_buff *skb, struct Qdisc *sch,return fq_pie_hash (q, skb) +1 ; *qerr =NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; - result =tcf_classify (skb,NULL , filter, &res, false); + result =tcf_classify_qdisc (skb, filter, &res, false);if (result >=0 ) {#ifdef CONFIG_NET_CLS_ACT switch (result) {
net/sched/sch_hfsc.c +1 -1
@@ -1154,7 +1154,7 @@ hfsc_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr) head = &q->root; drift =HFSC_CLASSIFY_MAX_DRIFT ; tcf =rcu_dereference_bh (q->root.filter_list); -while (tcf && (result =tcf_classify (skb,NULL , tcf, &res, false)) >=0 ) { +while (tcf && (result =tcf_classify_qdisc (skb, tcf, &res, false)) >=0 ) {#ifdef CONFIG_NET_CLS_ACT switch (result) {case TC_ACT_QUEUED :
net/sched/sch_htb.c +1 -1
@@ -243,7 +243,7 @@ static struct htb_class *htb_classify(struct sk_buff *skb, struct Qdisc *sch, } *qerr =NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; -while (tcf && (result =tcf_classify (skb,NULL , tcf, &res, false)) >=0 ) { +while (tcf && (result =tcf_classify_qdisc (skb, tcf, &res, false)) >=0 ) {#ifdef CONFIG_NET_CLS_ACT switch (result) {case TC_ACT_QUEUED :
net/sched/sch_multiq.c +1 -1
@@ -36,7 +36,7 @@ multiq_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)int err; *qerr =NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; - err =tcf_classify (skb,NULL , fl, &res, false); + err =tcf_classify_qdisc (skb, fl, &res, false);#ifdef CONFIG_NET_CLS_ACT switch (err) {case TC_ACT_STOLEN :
net/sched/sch_prio.c +1 -1
@@ -39,7 +39,7 @@ prio_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr) *qerr =NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;if (TC_H_MAJ (skb->priority) != sch->handle) { fl =rcu_dereference_bh (q->filter_list); - err =tcf_classify (skb,NULL , fl, &res, false); + err =tcf_classify_qdisc (skb, fl, &res, false);#ifdef CONFIG_NET_CLS_ACT switch (err) {case TC_ACT_STOLEN :
net/sched/sch_qfq.c +1 -1
@@ -712,7 +712,7 @@ static struct qfq_class *qfq_classify(struct sk_buff *skb, struct Qdisc *sch, *qerr =NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; fl =rcu_dereference_bh (q->filter_list); - result =tcf_classify (skb,NULL , fl, &res, false); + result =tcf_classify_qdisc (skb, fl, &res, false);if (result >=0 ) {#ifdef CONFIG_NET_CLS_ACT switch (result) {
net/sched/sch_sfb.c +1 -1
@@ -260,7 +260,7 @@ static bool sfb_classify(struct sk_buff *skb, struct tcf_proto *fl,struct tcf_result res;int result; - result =tcf_classify (skb,NULL , fl, &res, false); + result =tcf_classify_qdisc (skb, fl, &res, false);if (result >=0 ) {#ifdef CONFIG_NET_CLS_ACT switch (result) {
net/sched/sch_sfq.c +1 -1
@@ -171,7 +171,7 @@ static unsigned int sfq_classify(struct sk_buff *skb, struct Qdisc *sch,return sfq_hash (q, skb) +1 ; *qerr =NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; - result =tcf_classify (skb,NULL , fl, &res, false); + result =tcf_classify_qdisc (skb, fl, &res, false);if (result >=0 ) {#ifdef CONFIG_NET_CLS_ACT switch (result) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1110/1674 ovl: check access to copy_file_range source with src mounter creds
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Goldstein <[email protected]>
[ Upstream commit a1e0eb8f55cfe09bb31a202a388babc411292656 ]
Commit 5dae222a5ff0c ("vfs: allow copy_file_range to copy across devices") allowed filesystems that implement the copy_file_range() f_op to decide if they want to access cross-sb copy from/to the same fs type.
The same commit added checks to verify same sb copy for filesystems that implement ->copy_file_range() and do not support cross-sb copy at the time, namely, to ceph, fuse and nfs.
The two remaining fs which implement ->copy_file_range(), cifs and overlayfs started to support cross-sb copy from this time.
While overlayfs does support cross-sb copy when the two underlying files are on the same base fs, the copy operation on the two real files from two different overalyfs filesystems is performed with the mounter creds of the destination overlayfs and the read permission access hook for the source file was called with the wrong creds.
This could cause either deny of access to copy which would otherwise be allowed (e.g. with splice) or allow read access to file which would otherwise be denied.
Fix the latter case by explicitly verifying read access to source file with the source overlayfs mounter creds.
The former case remains a quirk of cross-sb overlayfs copy, but userspace could fall back to regular copy so no harm done.
--- fs/overlayfs/file.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
fs/overlayfs/file.c +18 -1
@@ -615,6 +615,7 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, loff_t len, unsigned int flags, enum ovl_copyop op) { + struct inode *inode_in = file_inode(file_in);struct inode *inode_out =file_inode (file_out);struct fd real_in, real_out;const struct cred *old_cred;
@@ -639,7 +640,23 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, goto out_unlock; } - old_cred =ovl_override_creds (file_inode (file_out)->i_sb); +/* +* For cross-sb copy, vfs_copy_file_range() will verify read access with +* the mounter creds of the dest fs mounter, so we need to explicitly +* verify read access with the source mounter creds. +*/ +if (unlikely (inode_in->i_sb != inode_out->i_sb)) { + old_cred =ovl_override_creds (inode_in->i_sb); + ret =rw_verify_area (READ , real_in.file, &pos_in, len); +revert_creds (old_cred); +if (unlikely (ret)) { +fdput (real_in); +fdput (real_out); + goto out_unlock; + } + } + + old_cred =ovl_override_creds (inode_out->i_sb);switch (op) {case OVL_COPY : ret = vfs_copy_file_range(real_in.file, pos_in,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1111/1674 s390/zcrypt: Fix buffer over-read in cca_cipher2protkey
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harald Freudenberger <[email protected]>
[ Upstream commit 36b230835b8a008266aad22168ca52afacc8a58d ]
Add validation of both the actual key buffer size and token length fields in all the cca_check_sec*token() functions. Additionally check in cca_gencipherkey() for possible underflow with returned key size.
The CCA token structures contain user-controlled len fields that were used in operations without proper validation against both the actual buffer size and minimum token structure size. An attacker could set this field larger than the actual buffer size, leading to reading beyond buffer boundaries. This may result in a kernel crash or exposure of memory via sending this as part of a request down to the crypto card. Also an attacker could have used a very small len value and thus enforce a buffer under-run which may produce similar effects as a over-read.
So now a key must
- key buf length must be at least sizeof the token struct
- the key len field inside the token must fit into the range of sizeof key token struct ... key buf length
--- drivers/s390/crypto/pkey_api.c | 15 ++++--- drivers/s390/crypto/zcrypt_ccamisc.c | 64 +++++++++++++++++++++++----- drivers/s390/crypto/zcrypt_ccamisc.h | 6 +-- 3 files changed, 65 insertions(+), 20 deletions(-)
drivers/s390/crypto/pkey_api.c +8 -7
@@ -336,7 +336,8 @@ static int pkey_verifykey(const struct pkey_seckey *seckey,int rc;/* check the secure key for valid AES secure key */ - rc =cca_check_secaeskeytoken (debug_info,3 , (u8 *)seckey,0 ); + rc =cca_check_secaeskeytoken (debug_info,3 , (u8 *)seckey, +sizeof (*seckey),0 );if (rc) goto out;if (pattributes)
@@ -839,7 +840,7 @@ static int pkey_verifykey2(const u8 *key, size_t keylen, hdr->version == TOKVER_CCA_AES) {struct secaeskeytoken *t = (struct secaeskeytoken *)key; - rc =cca_check_secaeskeytoken (debug_info,3 , key,0 ); + rc =cca_check_secaeskeytoken (debug_info,3 , key, keylen,0 );if (rc) goto out;if (ktype)
@@ -869,7 +870,7 @@ static int pkey_verifykey2(const u8 *key, size_t keylen, hdr->version == TOKVER_CCA_VLSC) {struct cipherkeytoken *t = (struct cipherkeytoken *)key; - rc =cca_check_secaescipherkey (debug_info,3 , key,0 ,1 ); + rc =cca_check_secaescipherkey (debug_info,3 , key, keylen,0 ,1 );if (rc) goto out;if (ktype)
@@ -981,12 +982,12 @@ static int pkey_keyblob2pkey2(const struct pkey_apqn *apqns, size_t nr_apqns,if (hdr->version ==TOKVER_CCA_AES ) {if (keylen !=sizeof (struct secaeskeytoken ))return -EINVAL ; -if (cca_check_secaeskeytoken (debug_info,3 , key,0 )) +if (cca_check_secaeskeytoken (debug_info,3 , key, keylen,0 ))return -EINVAL ; }else if (hdr->version ==TOKVER_CCA_VLSC ) {if (keylen < hdr->len || keylen >MAXCCAVLSCTOKENSIZE )return -EINVAL ; -if (cca_check_secaescipherkey (debug_info,3 , key,0 ,1 )) +if (cca_check_secaescipherkey (debug_info,3 , key, keylen,0 ,1 ))return -EINVAL ; }else { DEBUG_ERR("%s unknown CCA internal token version %d\n",
@@ -1253,13 +1254,13 @@ static int pkey_keyblob2pkey3(const struct pkey_apqn *apqns, size_t nr_apqns,/* CCA AES data key */ if (keylen !=sizeof (struct secaeskeytoken ))return -EINVAL ; -if (cca_check_secaeskeytoken (debug_info,3 , key,0 )) +if (cca_check_secaeskeytoken (debug_info,3 , key, keylen,0 ))return -EINVAL ; }else if (hdr->version ==TOKVER_CCA_VLSC ) {/* CCA AES cipher key */ if (keylen < hdr->len || keylen >MAXCCAVLSCTOKENSIZE )return -EINVAL ; -if (cca_check_secaescipherkey (debug_info,3 , key,0 ,1 )) +if (cca_check_secaescipherkey (debug_info,3 , key, keylen,0 ,1 ))return -EINVAL ; }else { DEBUG_ERR("%s unknown CCA internal token version %d\n",
drivers/s390/crypto/zcrypt_ccamisc.c +54 -10
141 lines not on this page · raw message
drivers/s390/crypto/zcrypt_ccamisc.h +3 -3
@@ -135,7 +135,7 @@ struct eccprivkeytoken {* also checked. Returns 0 on success or errno value on failure. */ int cca_check_secaeskeytoken (debug_info_t *dbg,int dbflvl, -const u8 *token,int keybitsize); +const u8 *token,u32 keysize,int keybitsize);/* * Simple check if the token is a valid CCA secure AES cipher key
@@ -145,8 +145,8 @@ int cca_check_secaeskeytoken(debug_info_t *dbg, int dbflvl,* Returns 0 on success or errno value on failure. */ int cca_check_secaescipherkey (debug_info_t *dbg,int dbflvl, -const u8 *token,int keybitsize, -int checkcpacfexport); +const u8 *token,u32 keysize, +int keybitsize,int checkcpacfexport);/* * Simple check if the token is a valid CCA secure ECC private
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1112/1674 wifi: ieee80211: validate MLE common info length
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Li <[email protected]>
[ Upstream commit 293baeae9b2434a3e432629d7720b5603db2d77e ]
ieee80211_mle_common_size() uses the first common-info octet as the common information length for all known MLE types. However, ieee80211_mle_size_ok() only validates that octet for Basic, Probe Request, and TDLS MLEs.
Reconfiguration MLEs also skipped the length octet when calculating the minimum common size, and Priority Access MLEs skipped validation of the advertised common information length.
Account for the Reconfiguration common-info length octet and validate the advertised common information length for all known MLE types. Keep unknown-type handling unchanged.
--- include/linux/ieee80211.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
include/linux/ieee80211.h +4 -8
@@ -4945,7 +4945,7 @@ static inline bool ieee80211_mle_size_ok(const u8 *data, size_t len)const struct ieee80211_multi_link_elem *mle = (const void *)data;u8 fixed =sizeof (*mle);u8 common =0 ; -bool check_common_len = false; +u8 common_len;u16 control;if (!data || len < fixed)
@@ -4956,7 +4956,6 @@ static inline bool ieee80211_mle_size_ok(const u8 *data, size_t len)switch (u16_get_bits (control,IEEE80211_ML_CONTROL_TYPE )) {case IEEE80211_ML_CONTROL_TYPE_BASIC : common +=sizeof (struct ieee80211_mle_basic_common_info ); - check_common_len = true;if (control &IEEE80211_MLC_BASIC_PRES_LINK_ID ) common +=1 ;if (control &IEEE80211_MLC_BASIC_PRES_BSS_PARAM_CH_CNT )
@@ -4974,15 +4973,14 @@ static inline bool ieee80211_mle_size_ok(const u8 *data, size_t len) common +=sizeof (struct ieee80211_mle_preq_common_info );if (control &IEEE80211_MLC_PREQ_PRES_MLD_ID ) common +=1 ; - check_common_len = true;break ;case IEEE80211_ML_CONTROL_TYPE_RECONF : + common +=1 ;if (control &IEEE80211_MLC_RECONF_PRES_MLD_MAC_ADDR ) common +=ETH_ALEN ;break ;case IEEE80211_ML_CONTROL_TYPE_TDLS : common +=sizeof (struct ieee80211_mle_tdls_common_info ); - check_common_len = true;break ;case IEEE80211_ML_CONTROL_TYPE_PRIO_ACCESS : common =ETH_ALEN +1 ;
@@ -4995,11 +4993,9 @@ static inline bool ieee80211_mle_size_ok(const u8 *data, size_t len)if (len < fixed + common)return false; -if (!check_common_len) -return true; + common_len = mle->variable[0 ]; -/* if present, common length is the first octet there */ -return mle->variable[0 ] >= common; +return common_len >= common && common_len <= len - fixed; }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1113/1674 mmc: vub300: fix use-after-free on probe failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit a3b5f242997a3be7404112fd48784881560aea57 ]
The vub300 driver lifetime-manages its controller state using vub300->kref, with vub300_delete() freeing the mmc host when the last reference is dropped. The probe error path after the inactivity timer has been armed still bypasses that lifetime rule, however, and falls through to mmc_free_host() directly if mmc_add_host() fails.
The race window is between arming the inactivity timer and reaching the probe error unwind after mmc_add_host() fails:
probe thread timer/workqueue
------------ ---------------
kref_init(&vub300->kref) ref = 1
kref_get(&vub300->kref) ref = 2, timer ref
add_timer(inactivity_timer) fires after one second
|
| race window
|<---------------------------------------------------->
| mmc_add_host(mmc)
inactivity timer fires vub300_queue_dead_work()
kref_get() ref = 3
queue_work(deadwork)
mmc_add_host() fails
timer_delete_sync()
mmc_free_host(mmc)
frees vub300
deadwork runs
use-after-free
The inactivity timeout is one second, so this would require mmc_add_host() to both fail and take more than one second to do so. This is unlikely to happen in practice, but the error path is still wrong.
timer_delete_sync() only waits for the timer callback itself. It does not flush deadwork that the callback may already have queued. As a result, queued deadwork can still hold a kref while the probe error path directly frees the backing mmc host, including the vub300 storage.
Fix this by using the same lifetime mechanism as disconnect. Clear vub300->interface so that the timer callback and any queued deadwork return early and drop their references, then drop the initial probe reference and return without falling through to err_free_host.
--- drivers/mmc/host/vub300.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/mmc/host/vub300.c +8 -3
@@ -2343,11 +2343,16 @@ static int vub300_probe(struct usb_interface *interface, interface_to_InterfaceNumber(interface)); retval =mmc_add_host (mmc);if (retval) - goto error6; + goto err_stop_io;return 0 ; -error6: -del_timer_sync (&vub300->inactivity_timer); + +err_stop_io: + vub300->interface =NULL ; +kref_put (&vub300->kref, vub300_delete); + +return retval; + error5:mmc_free_host (mmc);/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1114/1674 dm-verity: fix buffer overflow in FEC calculation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit 31d6e6c0ba8d5a7bd59660035a089307100c5e8e ]
There's a buffer overflow in dm-verity-fec:
if (neras && *neras <= v->fec->roots)
fio->erasures[(*neras)++] = i;
This allows *neras to reach roots + 1 (the post-increment pushes it past roots). This value is then passed as no_eras to decode_rs8(). Inside the RS decoder (lib/reed_solomon/decode_rs.c:113-121), the erasure locator polynomial loop writes lambda[j] where j can reach nroots + 1 — one element past the end of lambda[] (which is sized nroots + 1, valid indices 0..nroots). The out-of-bounds write lands on syn[0], corrupting the syndrome buffer.
--- drivers/md/dm-verity-fec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-verity-fec.c +2 -2
@@ -261,7 +261,7 @@ static int fec_read_bufs(struct dm_verity *v, struct dm_verity_io *io, (unsigned long long)block, PTR_ERR(bbuf));/* assume the block is corrupted */ -if (neras && *neras <= v->fec->roots) +if (neras && *neras < v->fec->roots) fio->erasures[(*neras)++] = i;continue ;
@@ -279,7 +279,7 @@ static int fec_read_bufs(struct dm_verity *v, struct dm_verity_io *io,* skip if we have already found the theoretical * maximum number (i.e. fec->roots) of erasures */ -if (neras && *neras <= v->fec->roots && +if (neras && *neras < v->fec->roots &&fec_is_erasure (v, io, want_digest, bbuf)) fio->erasures[(*neras)++] = i; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1115/1674 nvmet: Introduce nvmet_req_transfer_len()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 43043c9b97258a008b3402cfbbf1c5d82151c77f ]
Add the new function nvmet_req_transfer_len() to parse a request command to extract the transfer length of the command. This function implementation relies on multiple helper functions for parsing I/O commands (nvmet_io_cmd_transfer_len()), admin commands (nvmet_admin_cmd_data_len()) and fabrics connect commands (nvmet_connect_cmd_data_len).
Stable-dep-of: 779575bc35c6 ("nvmet-auth: reject short AUTH_RECEIVE buffers")
--- drivers/nvme/target/admin-cmd.c | 21 +++++++++++++ drivers/nvme/target/core.c | 37 ++++++++++++++++++++++ drivers/nvme/target/discovery.c | 14 +++++++++ drivers/nvme/target/fabrics-cmd-auth.c | 14 +++++++-- drivers/nvme/target/fabrics-cmd.c | 43 ++++++++++++++++++++++++++ drivers/nvme/target/nvmet.h | 8 +++++ 6 files changed, 135 insertions(+), 2 deletions(-)
drivers/nvme/target/admin-cmd.c +21 -0
@@ -998,6 +998,27 @@ void nvmet_execute_keep_alive(struct nvmet_req *req)nvmet_req_complete (req, status); } +u32 nvmet_admin_cmd_data_len (struct nvmet_req *req) +{ +struct nvme_command *cmd = req->cmd; + +if (nvme_is_fabrics (cmd)) +return nvmet_fabrics_admin_cmd_data_len (req); +if (nvmet_is_disc_subsys (nvmet_req_subsys (req))) +return nvmet_discovery_cmd_data_len (req); + +switch (cmd->common.opcode) { +case nvme_admin_get_log_page: +return nvmet_get_log_page_len (cmd); +case nvme_admin_identify: +return NVME_IDENTIFY_DATA_SIZE ; +case nvme_admin_get_features: +return nvmet_feat_data_len (req,le32_to_cpu (cmd->common.cdw10)); +default : +return 0 ; + } +} +u16 nvmet_parse_admin_cmd (struct nvmet_req *req) {struct nvme_command *cmd = req->cmd;
drivers/nvme/target/core.c +37 -0
@@ -885,6 +885,33 @@ static inline u16 nvmet_io_cmd_check_access(struct nvmet_req *req)return 0 ; } +static u32 nvmet_io_cmd_transfer_len (struct nvmet_req *req) +{ +struct nvme_command *cmd = req->cmd; +u32 metadata_len =0 ; + +if (nvme_is_fabrics (cmd)) +return nvmet_fabrics_io_cmd_data_len (req); + +if (!req->ns) +return 0 ; + +switch (req->cmd->common.opcode) { +case nvme_cmd_read: +case nvme_cmd_write: +case nvme_cmd_zone_append: +if (req->sq->ctrl->pi_support &&nvmet_ns_has_pi (req->ns)) + metadata_len =nvmet_rw_metadata_len (req); +return nvmet_rw_data_len (req) + metadata_len; +case nvme_cmd_dsm: +return nvmet_dsm_len (req); +case nvme_cmd_zone_mgmt_recv: +return (le32_to_cpu (req->cmd->zmr.numd) +1 ) <<2 ; +default : +return 0 ; + } +} +static u16 nvmet_parse_io_cmd (struct nvmet_req *req) {struct nvme_command *cmd = req->cmd;
@@ -1009,6 +1036,16 @@ void nvmet_req_uninit(struct nvmet_req *req) }EXPORT_SYMBOL_GPL (nvmet_req_uninit); +size_t nvmet_req_transfer_len (struct nvmet_req *req) +{ +if (likely (req->sq->qid !=0 )) +return nvmet_io_cmd_transfer_len (req); +if (unlikely (!req->sq->ctrl)) +return nvmet_connect_cmd_data_len (req); +return nvmet_admin_cmd_data_len (req); +} +EXPORT_SYMBOL_GPL (nvmet_req_transfer_len); +bool nvmet_check_transfer_len (struct nvmet_req *req,size_t len) {if (unlikely (len != req->transfer_len)) {
drivers/nvme/target/discovery.c +14 -0
@@ -373,6 +373,20 @@ static void nvmet_execute_disc_get_features(struct nvmet_req *req)nvmet_req_complete (req, stat); } +u32 nvmet_discovery_cmd_data_len (struct nvmet_req *req) +{ +struct nvme_command *cmd = req->cmd; + +switch (cmd->common.opcode) { +case nvme_admin_get_log_page: +return nvmet_get_log_page_len (req->cmd); +case nvme_admin_identify: +return NVME_IDENTIFY_DATA_SIZE ; +default : +return 0 ; + } +} +u16 nvmet_parse_discovery_cmd (struct nvmet_req *req) {struct nvme_command *cmd = req->cmd;
drivers/nvme/target/fabrics-cmd-auth.c +12 -2
@@ -196,6 +196,11 @@ static u8 nvmet_auth_failure2(void *d)return data->rescode_exp; } +u32 nvmet_auth_send_data_len (struct nvmet_req *req) +{ +return le32_to_cpu (req->cmd->auth_send.tl); +} +void nvmet_execute_auth_send (struct nvmet_req *req) {struct nvmet_ctrl *ctrl = req->sq->ctrl;
@@ -223,7 +228,7 @@ void nvmet_execute_auth_send(struct nvmet_req *req) offsetof(struct nvmf_auth_send_command , spsp1); goto done; } - tl =le32_to_cpu (req->cmd->auth_send.tl); + tl =nvmet_auth_send_data_len (req);if (!tl) { status =NVME_SC_INVALID_FIELD |NVME_STATUS_DNR ; req->error_loc =
@@ -446,6 +451,11 @@ static void nvmet_auth_failure1(struct nvmet_req *req, void *d, int al) data->rescode_exp = req->sq->dhchap_status; } +u32 nvmet_auth_receive_data_len (struct nvmet_req *req) +{ +return le32_to_cpu (req->cmd->auth_receive.al); +} +void nvmet_execute_auth_receive (struct nvmet_req *req) {struct nvmet_ctrl *ctrl = req->sq->ctrl;
@@ -471,7 +481,7 @@ void nvmet_execute_auth_receive(struct nvmet_req *req) offsetof(struct nvmf_auth_receive_command , spsp1); goto done; } - al =le32_to_cpu (req->cmd->auth_receive.al); + al =nvmet_auth_receive_data_len (req);if (!al) { status =NVME_SC_INVALID_FIELD |NVME_STATUS_DNR ; req->error_loc =
drivers/nvme/target/fabrics-cmd.c +43 -0
61 lines not on this page · raw message
drivers/nvme/target/nvmet.h +8 -0
@@ -447,18 +447,24 @@ void nvmet_start_keep_alive_timer(struct nvmet_ctrl *ctrl);void nvmet_stop_keep_alive_timer (struct nvmet_ctrl *ctrl);u16 nvmet_parse_connect_cmd (struct nvmet_req *req); +u32 nvmet_connect_cmd_data_len (struct nvmet_req *req);void nvmet_bdev_set_limits (struct block_device *bdev,struct nvme_id_ns *id);u16 nvmet_bdev_parse_io_cmd (struct nvmet_req *req);u16 nvmet_file_parse_io_cmd (struct nvmet_req *req);u16 nvmet_bdev_zns_parse_io_cmd (struct nvmet_req *req); +u32 nvmet_admin_cmd_data_len (struct nvmet_req *req);u16 nvmet_parse_admin_cmd (struct nvmet_req *req); +u32 nvmet_discovery_cmd_data_len (struct nvmet_req *req);u16 nvmet_parse_discovery_cmd (struct nvmet_req *req);u16 nvmet_parse_fabrics_admin_cmd (struct nvmet_req *req); +u32 nvmet_fabrics_admin_cmd_data_len (struct nvmet_req *req);u16 nvmet_parse_fabrics_io_cmd (struct nvmet_req *req); +u32 nvmet_fabrics_io_cmd_data_len (struct nvmet_req *req);bool nvmet_req_init (struct nvmet_req *req,struct nvmet_cq *cq,struct nvmet_sq *sq,const struct nvmet_fabrics_ops *ops);void nvmet_req_uninit (struct nvmet_req *req); +size_t nvmet_req_transfer_len (struct nvmet_req *req);bool nvmet_check_transfer_len (struct nvmet_req *req,size_t len);bool nvmet_check_data_len_lte (struct nvmet_req *req,size_t data_len);void nvmet_req_complete (struct nvmet_req *req,u16 status);
@@ -696,7 +702,9 @@ static inline void nvmet_req_bio_put(struct nvmet_req *req, struct bio *bio) }#ifdef CONFIG_NVME_TARGET_AUTH +u32 nvmet_auth_send_data_len (struct nvmet_req *req);void nvmet_execute_auth_send (struct nvmet_req *req); +u32 nvmet_auth_receive_data_len (struct nvmet_req *req);void nvmet_execute_auth_receive (struct nvmet_req *req);int nvmet_auth_set_key (struct nvmet_host *host,const char *secret,bool set_ctrl);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1116/1674 nvmet-auth: reject short AUTH_RECEIVE buffers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit 779575bc35c687697ba69e904f2cd22e60112534 ]
nvmet_execute_auth_receive() trusts the AUTH_RECEIVE allocation length after checking only that it is nonzero and matches the transfer length. In the SUCCESS1 and FAILURE1/default states, that lets a remote NVMe-oF initiator reach the fixed-size DH-HMAC-CHAP response builders with a kmalloc() buffer shorter than the response, so nvmet_auth_success1() and nvmet_auth_failure1() write past the allocation; both only WARN_ON the short length and then format the message anyway.
Impact: A remote NVMe-oF initiator with access to an auth-enabled target can trigger a 16-byte heap out-of-bounds write via a one-byte AUTH_RECEIVE allocation length.
Compute the minimum response length for the current DH-HMAC-CHAP step in nvmet_auth_receive_data_len() and report a zero data length when the host-supplied allocation length is shorter, so the existing zero-length check in nvmet_execute_auth_receive() rejects the command before any builder runs. The SUCCESS1 minimum is sizeof(struct nvmf_auth_dhchap_success1_data) plus the HMAC hash length, because the response hash is written into the rval[] flexible-array tail, so the minimum is state dependent rather than a flat sizeof. CHALLENGE keeps its existing variable-length guard in nvmet_auth_challenge().
This is reachable only when in-band DH-HMAC-CHAP authentication is configured on the target.
--- drivers/nvme/target/fabrics-cmd-auth.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
drivers/nvme/target/fabrics-cmd-auth.c +25 -1
@@ -453,7 +453,31 @@ static void nvmet_auth_failure1(struct nvmet_req *req, void *d, int al)u32 nvmet_auth_receive_data_len (struct nvmet_req *req) { -return le32_to_cpu (req->cmd->auth_receive.al); +struct nvmet_ctrl *ctrl = req->sq->ctrl; +u32 al =le32_to_cpu (req->cmd->auth_receive.al); +u32 min_len; + +/* +* Reject too-short al before kmalloc(al), since the SUCCESS1 and +* FAILURE1/default builders write fixed response headers into it. +*/ +switch (req->sq->dhchap_step) { +case NVME_AUTH_DHCHAP_MESSAGE_CHALLENGE : +return al; +case NVME_AUTH_DHCHAP_MESSAGE_SUCCESS1 : + min_len =sizeof (struct nvmf_auth_dhchap_success1_data ); +if (req->sq->dhchap_c2) + min_len +=nvme_auth_hmac_hash_len (ctrl->shash_id); +break ; +default : + min_len =sizeof (struct nvmf_auth_dhchap_failure_data ); +break ; + } + +if (al < min_len) +return 0 ; + +return al; }void nvmet_execute_auth_receive (struct nvmet_req *req)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1117/1674 ocfs2: correct l_next_free_rec in online check
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Sun <[email protected]>
[ Upstream commit fdbb6cd96ed51da002bd9a5a142586a74a436784 ]
Correct the value of l_next_free_rec to l_count during the online check, as done in the check_el() function in ocfs2_tools.
Stable-dep-of: 452a8467be81 ("ocfs2: fix UBSAN array-index-out-of-bounds in ocfs2_sum_rightmost_rec")
--- fs/ocfs2/inode.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
fs/ocfs2/inode.c +24 -0
@@ -233,6 +233,20 @@ struct inode *ocfs2_iget(struct ocfs2_super *osb, u64 blkno, unsigned flags,return inode; } +static int ocfs2_dinode_has_extents (struct ocfs2_dinode *di) +{ +/* inodes flagged with other stuff in id2 */ +if (di->i_flags & (OCFS2_SUPER_BLOCK_FL |OCFS2_LOCAL_ALLOC_FL | +OCFS2_CHAIN_FL |OCFS2_DEALLOC_FL )) +return 0 ; +/* i_flags doesn't indicate when id2 is a fast symlink */ +if (S_ISLNK (di->i_mode) && di->i_size && di->i_clusters ==0 ) +return 0 ; +if (di->i_dyn_features &OCFS2_INLINE_DATA_FL ) +return 0 ; + +return 1 ; +}/* * here's how inodes get read from disk:
@@ -1728,6 +1742,16 @@ static int ocfs2_filecheck_repair_inode_block(struct super_block *sb, le32_to_cpu(di->i_fs_generation)); } +if (ocfs2_dinode_has_extents (di) && +le16_to_cpu (di->id2.i_list.l_next_free_rec) >le16_to_cpu (di->id2.i_list.l_count)) { + di->id2.i_list.l_next_free_rec = di->id2.i_list.l_count; + changed =1 ; +mlog (ML_ERROR , +"Filecheck: reset dinode #%llu: l_next_free_rec to %u\n" , + (unsigned long long )bh->b_blocknr, +le16_to_cpu (di->id2.i_list.l_next_free_rec)); + } +if (changed ||ocfs2_validate_meta_ecc (sb, bh->b_data, &di->i_check)) {ocfs2_compute_meta_ecc (sb, bh->b_data, &di->i_check);mark_buffer_dirty (bh);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1118/1674 ocfs2: add suballoc slot check in ocfs2_validate_inode_block()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Antipov <[email protected]>
[ Upstream commit fe7a283b39160153b6d1bd7f61b0a9d5d44987a8 ]
In 'ocfs2_validate_inode_block()', add suballoc slot check similar to one in 'ocfs2_get_suballoc_slot_bit()', thus preventing an out-of-bounds accesses for 'local_system_inodes' in 'get_local_system_inode()'.
Most likely this fixes
https://syzkaller.appspot.com/bug?extid=a77d690840e60bc2ddd8 as well.
Stable-dep-of: 452a8467be81 ("ocfs2: fix UBSAN array-index-out-of-bounds in ocfs2_sum_rightmost_rec")
--- fs/ocfs2/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/ocfs2/inode.c +8 -0
@@ -1577,6 +1577,14 @@ int ocfs2_validate_inode_block(struct super_block *sb, } } +if (le16_to_cpu (di->i_suballoc_slot) != (u16 )OCFS2_INVALID_SLOT && + (u32 )le16_to_cpu (di->i_suballoc_slot) >OCFS2_SB (sb)->max_slots -1 ) { + rc =ocfs2_error (sb,"Invalid dinode %llu: suballoc slot %u\n" , + (unsigned long long )bh->b_blocknr, +le16_to_cpu (di->i_suballoc_slot)); + goto bail; + } + rc =0 ; bail:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1119/1674 ocfs2: validate i_refcount_loc when refcount flag is set
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deepanshu Kartikey <[email protected]>
[ Upstream commit 688dab01c3bb14cb559878aaf7019bfba4a79275 ]
Add validation in ocfs2_validate_inode_block() to check that if an inode has OCFS2_HAS_REFCOUNT_FL set, it must also have a valid i_refcount_loc. A corrupted filesystem image can have this inconsistent state, which later triggers a BUG_ON in ocfs2_remove_refcount_tree() when the inode is being wiped during unlink.
Catch this corruption early during inode validation to fail gracefully instead of crashing the kernel.
has OCFS2_HAS_REFCOUNT_FL set, it must also have a valid i_refcount_loc. A corrupted filesystem image can have this inconsistent state, which later triggers a BUG_ON in ocfs2_remove_refcount_tree() when the inode is being wiped during unlink.
Catch this corruption early during inode validation to fail gracefully instead of crashing the kernel.
[ Dropped the context-dependent inline-data and chain-list checks that
precede this hunk upstream but are absent here; only the i_refcount_loc validation is kept. ]
Stable-dep-of: 452a8467be81 ("ocfs2: fix UBSAN array-index-out-of-bounds in ocfs2_sum_rightmost_rec")
# Conflicts:
# fs/ocfs2/inode.c
--- fs/ocfs2/inode.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/ocfs2/inode.c +7 -0
@@ -1585,6 +1585,13 @@ int ocfs2_validate_inode_block(struct super_block *sb, goto bail; } +if ((le16_to_cpu (di->i_dyn_features) &OCFS2_HAS_REFCOUNT_FL ) && + !di->i_refcount_loc) { + rc =ocfs2_error (sb,"Inode #%llu has refcount flag but no i_refcount_loc\n" , + (unsigned long long )bh->b_blocknr); + goto bail; + } + rc =0 ; bail:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1120/1674 ocfs2: fix UBSAN array-index-out-of-bounds in ocfs2_sum_rightmost_rec
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Bridges <[email protected]>
[ Upstream commit 452a8467be8143747292218212671deeb186d2ae ]
[BUG]
On-disk corruption setting l_next_free_rec to 0 in an inode's embedded extent list triggers a UBSAN panic on the next write to that file.
[CAUSE]ocfs2_sum_rightmost_rec() computes
i = le16_to_cpu(el->l_next_free_rec) - 1
and accesses el->l_recs[i] without validating i. When l_next_free_rec is 0, i becomes -1; when l_next_free_rec exceeds l_count, i falls past the end of the array. Either case violates the __counted_by_le(l_count) annotation on l_recs[] and triggers UBSAN.
[FIX]
Validate the inode's embedded extent list when the inode is read, in ocfs2_validate_inode_block(): l_count must be non-zero and no larger than the inode block can hold, and l_next_free_rec must not exceed l_count. A corrupt list is rejected at read time, before the b-tree code can index l_recs[] out of bounds.
--- fs/ocfs2/inode.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
fs/ocfs2/inode.c +32 -0
@@ -1592,6 +1592,38 @@ int ocfs2_validate_inode_block(struct super_block *sb, goto bail; } +if (ocfs2_dinode_has_extents (di)) { +struct ocfs2_extent_list *el = &di->id2.i_list; +u16 count =le16_to_cpu (el->l_count); +u16 next_free =le16_to_cpu (el->l_next_free_rec); + +if (count ==0 ) { + rc =ocfs2_error (sb, +"Invalid dinode %llu: extent list l_count is zero\n" , + (unsigned long long )bh->b_blocknr); + goto bail; + } +/* +* The exact capacity depends on i_xattr_inline_size, another +* unvalidated on-disk field. Inline xattrs only shrink the +* list, so the no-xattr maximum is a safe upper bound that a +* valid l_count never exceeds. +*/ +if (count >ocfs2_extent_recs_per_inode (sb)) { + rc =ocfs2_error (sb, +"Invalid dinode %llu: extent list l_count %u exceeds max %u\n" , + (unsigned long long )bh->b_blocknr, count, +ocfs2_extent_recs_per_inode (sb)); + goto bail; + } +if (next_free > count) { + rc =ocfs2_error (sb, +"Invalid dinode %llu: extent list l_next_free_rec %u exceeds l_count %u\n" , + (unsigned long long )bh->b_blocknr, next_free, count); + goto bail; + } + } + rc =0 ; bail:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1121/1674 mtd: maps: vmu-flash: fix fault in unaligned fixup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Fuchs <[email protected]>
[ Upstream commit 79d1661502c6e4b6f626185cef72cf2fa78116e1 ]
Use kzalloc_obj() / kzalloc_objs() to allocate the memcard structs, instead of kmalloc_obj() / kmalloc_objs() to prevent access to uninitialized data.
Fixes runtime error: Fault in unaligned fixup: 0000 [#1] at mtd_get_fact_prot_info.
--- drivers/mtd/maps/vmu-flash.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mtd/maps/vmu-flash.c +5 -5
@@ -610,7 +610,7 @@ static int vmu_connect(struct maple_device *mdev) basic_flash_data =be32_to_cpu (mdev->devinfo.function_data[c -1 ]); - card =kmalloc (sizeof (struct memcard ),GFP_KERNEL ); + card =kzalloc (sizeof (struct memcard ),GFP_KERNEL );if (!card) { error = -ENOMEM ; goto fail_nomem;
@@ -628,15 +628,15 @@ static int vmu_connect(struct maple_device *mdev)* Not sure there are actually any multi-partition devices in the * real world, but the hardware supports them, so, so will we */ - card->parts =kmalloc_array (card->partitions,sizeof (struct vmupart ), -GFP_KERNEL ); + card->parts =kcalloc (card->partitions,sizeof (struct vmupart ), +GFP_KERNEL );if (!card->parts) { error = -ENOMEM ; goto fail_partitions; } - card->mtd =kmalloc_array (card->partitions,sizeof (struct mtd_info ), -GFP_KERNEL ); + card->mtd =kcalloc (card->partitions,sizeof (struct mtd_info ), +GFP_KERNEL );if (!card->mtd) { error = -ENOMEM ; goto fail_mtd_info;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1122/1674 fs: Remove NTFS classic
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit 7ffa8f3d30236e0ab897c30bdb01224ff1fe1c89 ]
The replacement, NTFS3, was merged over two years ago. It is now time to remove the original from the tree as it is the last user of several APIs, and it is not worth changing.
--- CREDITS | 5 + Documentation/filesystems/ntfs.rst | 466 ---- MAINTAINERS | 10 - fs/Kconfig | 1 - fs/Makefile | 1 - fs/ntfs/Kconfig | 81 - fs/ntfs/Makefile | 15 - fs/ntfs/aops.c | 1761 --------------- fs/ntfs/aops.h | 88 - fs/ntfs/attrib.c | 2624 ----------------------- fs/ntfs/attrib.h | 102 - fs/ntfs/bitmap.c | 179 -- fs/ntfs/bitmap.h | 104 - fs/ntfs/collate.c | 110 - fs/ntfs/collate.h | 36 - fs/ntfs/compress.c | 950 --------- fs/ntfs/debug.c | 159 -- fs/ntfs/debug.h | 57 - fs/ntfs/dir.c | 1539 ------------- fs/ntfs/dir.h | 34 - fs/ntfs/endian.h | 79 - fs/ntfs/file.c | 2004 ----------------- fs/ntfs/index.c | 440 ---- fs/ntfs/index.h | 134 -- fs/ntfs/inode.c | 3101 --------------------------- fs/ntfs/inode.h | 310 --- fs/ntfs/layout.h | 2421 --------------------- fs/ntfs/lcnalloc.c | 1000 --------- fs/ntfs/lcnalloc.h | 131 -- fs/ntfs/logfile.c | 849 -------- fs/ntfs/logfile.h | 295 --- fs/ntfs/malloc.h | 77 - fs/ntfs/mft.c | 2907 ------------------------- fs/ntfs/mft.h | 110 - fs/ntfs/mst.c | 189 -- fs/ntfs/namei.c | 391 ---- fs/ntfs/ntfs.h | 150 -- fs/ntfs/quota.c | 103 - fs/ntfs/quota.h | 21 - fs/ntfs/runlist.c | 1893 ---------------- fs/ntfs/runlist.h | 88 - fs/ntfs/super.c | 3202 ---------------------------- fs/ntfs/sysctl.c | 59 - fs/ntfs/sysctl.h | 27 - fs/ntfs/time.h | 89 - fs/ntfs/types.h | 55 - fs/ntfs/unistr.c | 384 ---- fs/ntfs/upcase.c | 73 - fs/ntfs/usnjrnl.c | 70 - fs/ntfs/usnjrnl.h | 191 -- fs/ntfs/volume.h | 164 -- 51 files changed, 5 insertions(+), 29324 deletions(-) delete mode 100644 Documentation/filesystems/ntfs.rst delete mode 100644 fs/ntfs/Kconfig delete mode 100644 fs/ntfs/Makefile delete mode 100644 fs/ntfs/aops.c delete mode 100644 fs/ntfs/aops.h delete mode 100644 fs/ntfs/attrib.c delete mode 100644 fs/ntfs/attrib.h delete mode 100644 fs/ntfs/bitmap.c delete mode 100644 fs/ntfs/bitmap.h delete mode 100644 fs/ntfs/collate.c delete mode 100644 fs/ntfs/collate.h delete mode 100644 fs/ntfs/compress.c delete mode 100644 fs/ntfs/debug.c delete mode 100644 fs/ntfs/debug.h delete mode 100644 fs/ntfs/dir.c delete mode 100644 fs/ntfs/dir.h delete mode 100644 fs/ntfs/endian.h delete mode 100644 fs/ntfs/file.c delete mode 100644 fs/ntfs/index.c delete mode 100644 fs/ntfs/index.h delete mode 100644 fs/ntfs/inode.c delete mode 100644 fs/ntfs/inode.h delete mode 100644 fs/ntfs/layout.h delete mode 100644 fs/ntfs/lcnalloc.c delete mode 100644 fs/ntfs/lcnalloc.h delete mode 100644 fs/ntfs/logfile.c delete mode 100644 fs/ntfs/logfile.h delete mode 100644 fs/ntfs/malloc.h delete mode 100644 fs/ntfs/mft.c delete mode 100644 fs/ntfs/mft.h delete mode 100644 fs/ntfs/mst.c delete mode 100644 fs/ntfs/namei.c delete mode 100644 fs/ntfs/ntfs.h delete mode 100644 fs/ntfs/quota.c delete mode 100644 fs/ntfs/quota.h delete mode 100644 fs/ntfs/runlist.c delete mode 100644 fs/ntfs/runlist.h delete mode 100644 fs/ntfs/super.c delete mode 100644 fs/ntfs/sysctl.c delete mode 100644 fs/ntfs/sysctl.h delete mode 100644 fs/ntfs/time.h delete mode 100644 fs/ntfs/types.h delete mode 100644 fs/ntfs/unistr.c delete mode 100644 fs/ntfs/upcase.c delete mode 100644 fs/ntfs/usnjrnl.c delete mode 100644 fs/ntfs/usnjrnl.h delete mode 100644 fs/ntfs/volume.h
CREDITS +5 -0
@@ -67,6 +67,11 @@ D: dosfs, LILO, some fd features, ATM, various other hacks here and there S: Buenos Aires S: Argentina +NTFS FILESYSTEM +N: Anton Altaparmakov +E: [email protected] +D: NTFS filesystem + N: Tim Alpaerts E: [email protected] D: 802.2 class II logical link control layer,
Documentation/filesystems/ntfs.rst deleted +0 -466
466 lines not on this page · raw message
MAINTAINERS +0 -10
@@ -15202,16 +15202,6 @@ W: https://github.com/davejiang/linux/wiki T: git https://github.com/davejiang/linux.git F: drivers/ntb/hw/intel/ -NTFS FILESYSTEM -M: Anton Altaparmakov <[email protected]> -R: Namjae Jeon <[email protected]> -L: [email protected] -S: Supported -W: http://www.tuxera.com/ -T: git git://git.kernel.org/pub/scm/linux/kernel/git/aia21/ntfs.git -F: Documentation/filesystems/ntfs.rst -F: fs/ntfs/ - NTFS3 FILESYSTEM M: Konstantin Komarov <[email protected]> L: [email protected]
fs/Kconfig +0 -1
@@ -158,7 +158,6 @@ menu "DOS/FAT/EXFAT/NT Filesystems" source "fs/fat/Kconfig" source "fs/exfat/Kconfig" -source "fs/ntfs/Kconfig" source "fs/ntfs3/Kconfig" endmenu
fs/Makefile +0 -1
@@ -91,7 +91,6 @@ obj-y += unicode/ obj-$(CONFIG_SYSV_FS) += sysv/ obj-$(CONFIG_SMBFS) += smb/ obj-$(CONFIG_HPFS_FS) += hpfs/ -obj-$(CONFIG_NTFS_FS) += ntfs/ obj-$(CONFIG_NTFS3_FS) += ntfs3/ obj-$(CONFIG_UFS_FS) += ufs/ obj-$(CONFIG_EFS_FS) += efs/
fs/ntfs/Kconfig deleted +0 -81
81 lines not on this page · raw message
fs/ntfs/Makefile deleted +0 -15
@@ -1,15 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Rules for making the NTFS driver. - -obj-$(CONFIG_NTFS_FS) += ntfs.o - -ntfs-y := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \ - index.o inode.o mft.o mst.o namei.o runlist.o super.o sysctl.o \ - unistr.o upcase.o - -ntfs-$(CONFIG_NTFS_RW) += bitmap.o lcnalloc.o logfile.o quota.o usnjrnl.o - -ccflags-y := -DNTFS_VERSION=\"2.1.32\" -ccflags-$(CONFIG_NTFS_DEBUG) += -DDEBUG -ccflags-$(CONFIG_NTFS_RW) += -DNTFS_RW -
fs/ntfs/aops.c deleted +0 -1761
1,761 lines not on this page · raw message
fs/ntfs/aops.h deleted +0 -88
88 lines not on this page · raw message
fs/ntfs/attrib.c deleted +0 -2624
548 lines not on this page · raw message
fs/ntfs/attrib.h deleted +0 -102
102 lines not on this page · raw message
fs/ntfs/bitmap.c deleted +0 -179
179 lines not on this page · raw message
fs/ntfs/bitmap.h deleted +0 -104
104 lines not on this page · raw message
fs/ntfs/collate.c deleted +0 -110
110 lines not on this page · raw message
fs/ntfs/compress.c deleted +0 -950
950 lines not on this page · raw message
fs/ntfs/debug.c deleted +0 -159
159 lines not on this page · raw message
fs/ntfs/debug.h deleted +0 -57
57 lines not on this page · raw message
fs/ntfs/dir.c deleted +0 -1539
1,539 lines not on this page · raw message
fs/ntfs/endian.h deleted +0 -79
79 lines not on this page · raw message
fs/ntfs/file.c deleted +0 -2004
2,004 lines not on this page · raw message
fs/ntfs/index.c deleted +0 -440
440 lines not on this page · raw message
fs/ntfs/index.h deleted +0 -134
134 lines not on this page · raw message
fs/ntfs/inode.c deleted +0 -3101
3,101 lines not on this page · raw message
fs/ntfs/inode.h deleted +0 -310
310 lines not on this page · raw message
fs/ntfs/layout.h deleted +0 -2421
2,421 lines not on this page · raw message
fs/ntfs/lcnalloc.c deleted +0 -1000
1,000 lines not on this page · raw message
fs/ntfs/lcnalloc.h deleted +0 -131
131 lines not on this page · raw message
fs/ntfs/logfile.c deleted +0 -849
849 lines not on this page · raw message
fs/ntfs/logfile.h deleted +0 -295
295 lines not on this page · raw message
fs/ntfs/malloc.h deleted +0 -77
77 lines not on this page · raw message
fs/ntfs/mft.c deleted +0 -2907
2,907 lines not on this page · raw message
fs/ntfs/mft.h deleted +0 -110
110 lines not on this page · raw message
fs/ntfs/mst.c deleted +0 -189
189 lines not on this page · raw message
fs/ntfs/namei.c deleted +0 -391
391 lines not on this page · raw message
fs/ntfs/ntfs.h deleted +0 -150
150 lines not on this page · raw message
fs/ntfs/quota.c deleted +0 -103
103 lines not on this page · raw message
fs/ntfs/runlist.c deleted +0 -1893
1,893 lines not on this page · raw message
fs/ntfs/runlist.h deleted +0 -88
88 lines not on this page · raw message
fs/ntfs/super.c deleted +0 -3202
3,202 lines not on this page · raw message
fs/ntfs/sysctl.c deleted +0 -59
59 lines not on this page · raw message
fs/ntfs/time.h deleted +0 -89
89 lines not on this page · raw message
fs/ntfs/types.h deleted +0 -55
55 lines not on this page · raw message
fs/ntfs/unistr.c deleted +0 -384
384 lines not on this page · raw message
fs/ntfs/upcase.c deleted +0 -73
73 lines not on this page · raw message
fs/ntfs/usnjrnl.c deleted +0 -70
70 lines not on this page · raw message
fs/ntfs/usnjrnl.h deleted +0 -191
191 lines not on this page · raw message
fs/ntfs/volume.h deleted +0 -164
164 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.53.0
Part of the diff is not shown here. View the raw message.
Greg Kroah-Hartman
maintainerPATCH 1123/1674 mm/hugetlb: fix hugetlb cgroup rsvd charge/uncharge mismatch
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deepanshu Kartikey <[email protected]>
[ Upstream commit 15807d0ddde37407af72859426b654f3d1972b00 ]
In alloc_hugetlb_folio(), a single h_cg pointer is used for both the rsvd and non-rsvd hugetlb cgroup charges. When map_chg is set, hugetlb_cgroup_charge_cgroup_rsvd() stores the charged cgroup in h_cg, but the immediately following hugetlb_cgroup_charge_cgroup() overwrites h_cg with the non-rsvd cgroup pointer.
As a result, hugetlb_cgroup_commit_charge_rsvd() stores the wrong (non-rsvd) cgroup pointer into the folio's rsvd slot.
When the folio is later freed, free_huge_folio() unconditionally calls both hugetlb_cgroup_uncharge_folio() and hugetlb_cgroup_uncharge_folio_rsvd(). The rsvd uncharge reads back the wrong cgroup from the folio and decrements a counter that was never charged for that cgroup, causing a page_counter underflow:
page_counter underflow: -512 nr_pages=512
WARNING: mm/page_counter.c:61 at page_counter_cancel
Fix this by introducing a separate h_cg_rsvd pointer exclusively for the rsvd charge path, keeping the rsvd and non-rsvd charges fully independent through their charge, commit, and error uncharge paths.
--- mm/hugetlb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
mm/hugetlb.c +4 -3
@@ -3058,6 +3058,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,long gbl_chg;int ret, idx;struct hugetlb_cgroup *h_cg =NULL ; +struct hugetlb_cgroup *h_cg_rsvd =NULL ;bool deferred_reserve; idx =hstate_index (h);
@@ -3090,7 +3091,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma, deferred_reserve = map_chg || avoid_reserve;if (deferred_reserve) { ret =hugetlb_cgroup_charge_cgroup_rsvd ( - idx,pages_per_huge_page (h), &h_cg); + idx,pages_per_huge_page (h), &h_cg_rsvd);if (ret) goto out_subpool_put; }
@@ -3127,7 +3128,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,*/ if (deferred_reserve) {hugetlb_cgroup_commit_charge_rsvd (idx,pages_per_huge_page (h), - h_cg, folio); + h_cg_rsvd, folio); }spin_unlock_irq (&hugetlb_lock);
@@ -3163,7 +3164,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma, out_uncharge_cgroup_reservation:if (deferred_reserve)hugetlb_cgroup_uncharge_cgroup_rsvd (idx,pages_per_huge_page (h), - h_cg); + h_cg_rsvd); out_subpool_put:if (map_chg || avoid_reserve)hugepage_subpool_put_pages (spool,1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1124/1674 KVM: arm64: vgic: Handle race between interrupt affinity change and LPI disabling
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
[ Upstream commit 7258770e5814f15e8308ebda82ac9acf6964ba8e ]
Hyunwoo Kim reports some really bad races should the following situation occur:
- LPI-I is pending in vcpu-B's AP list
- vcpu-A writes to vcpu-B's RD to disable its LPIs
- vcpu-C moves I from B to C
If the last two race nicely enough, vgic_prune_ap_list() can drop the irq and AP list locks, reacquire them, and in the interval the irq has been freed. UAF follows.
The fix is two-fold:
- Before dropping the irq and ap_list locks, take a reference on the irq
- Do not try to handle migration of the pending bit: there is no expectation that this state is retained, as per the architecture
With that, we're sure that the interrupt is still around, and we safely remove it from the AP list as it has no target at this stage (unless another interrupt fires, but that's another story).
--- arch/arm64/kvm/vgic/vgic.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
arch/arm64/kvm/vgic/vgic.c +8 -1
@@ -160,6 +160,7 @@ void vgic_flush_pending_lpis(struct kvm_vcpu *vcpu)list_for_each_entry_safe (irq, tmp, &vgic_cpu->ap_list_head, ap_list) {if (irq->intid >=VGIC_MIN_LPI ) {raw_spin_lock (&irq->irq_lock); + irq->pending_latch = false;list_del (&irq->ap_list); irq->vcpu =NULL ;raw_spin_unlock (&irq->irq_lock);
@@ -678,7 +679,11 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu)continue ; } -/* This interrupt looks like it has to be migrated. */ +/* +* This interrupt looks like it has to be migrated, +* make sure it is kept alive while locks are dropped. +*/ +vgic_get_irq_kref (irq);raw_spin_unlock (&irq->irq_lock);raw_spin_unlock (&vgic_cpu->ap_list_lock);
@@ -723,6 +728,8 @@ static void vgic_prune_ap_list(struct kvm_vcpu *vcpu)raw_spin_unlock (&vcpuB->arch.vgic_cpu.ap_list_lock);raw_spin_unlock (&vcpuA->arch.vgic_cpu.ap_list_lock); +vgic_put_irq (vcpu->kvm, irq); +if (target_vcpu_needs_kick) {kvm_make_request (KVM_REQ_IRQ_PENDING , target_vcpu);kvm_vcpu_kick (target_vcpu);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1125/1674 netfilter: nft_lookup: fix catchall element handling with inverted lookups
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tamaki Yanagawa <[email protected]>
[ Upstream commit e6107a4c74b54cb33e3bce162a63048ae5a6b198 ]
nft_lookup_eval() decides whether a lookup matched (found) from the direct set lookup and priv->invert before falling back to the catchall element used by interval sets (e.g. nft_set_rbtree) for the open-ended default range. Since found is never recomputed after ext is replaced by the catchall lookup, inverted lookups (NFT_LOOKUP_F_INV, "!= @set") can wrongly match or wrongly skip the catchall element, producing the wrong verdict. Fold the catchall lookup into ext before computing found, matching the order already used by nft_objref_map_eval().
--- net/netfilter/nft_lookup.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
net/netfilter/nft_lookup.c +8 -6
@@ -65,14 +65,16 @@ void nft_lookup_eval(const struct nft_expr *expr,const struct net *net =nft_net (pkt);bool found; - found =nft_set_do_lookup (net, set, ®s->data[priv->sreg], &ext) ^ - priv->invert; + found =nft_set_do_lookup (net, set, ®s->data[priv->sreg], &ext);if (!found) { ext =nft_set_catchall_lookup (net, set); -if (!ext) { - regs->verdict.code =NFT_BREAK ; -return ; - } + found = !!ext; + } + + found ^= priv->invert; +if (!found) { + regs->verdict.code =NFT_BREAK ; +return ; }if (ext) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1126/1674 ipv4: igmp: Fix potential memory leaks in igmp_mod_timer() and igmp_stop_timer()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 3546deaa0c30a14c7cdb5dc8f2432cb428f0cd36 ]
When a timer is deleted and not re-armed in igmp_mod_timer(), or stopped in igmp_stop_timer(), the code currently decrements the reference counter of the multicast list entry @im using refcount_dec(&im->refcnt).
However, both functions can be called from the RCU reader path:
- igmp_mod_timer() via igmp_heard_query() -> for_each_pmc_rcu()
- igmp_stop_timer() via igmp_rcv() -> igmp_heard_report()
If the group im was concurrently removed from the list by ip_mc_dec_group(), its reference count might have already been decremented to 1.
In this case, timer_delete() succeeds, and refcount_dec() decrements the refcount from 1 to 0. Since refcount_dec() does not free the object when it hits 0 (unlike ip_ma_put()), the im structure is leaked.
Fix this by using ip_ma_put(im) instead of refcount_dec(&im->refcnt), and deferring the put until after the spinlock is released.
--- net/ipv4/igmp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/ipv4/igmp.c +12 -2
@@ -201,13 +201,18 @@ static void ip_sf_list_clear_all(struct ip_sf_list *psf)static void igmp_stop_timer (struct ip_mc_list *im) { +bool put = false; +spin_lock_bh (&im->lock);if (del_timer (&im->timer)) -refcount_dec (&im->refcnt); + put = true; im->tm_running =0 ; im->reporter =0 ; im->unsolicit_count =0 ;spin_unlock_bh (&im->lock); + +if (put) +ip_ma_put (im); }/* It must be called with locked im->lock */
@@ -250,6 +255,8 @@ static void igmp_ifc_start_timer(struct in_device *in_dev, int delay)static void igmp_mod_timer (struct ip_mc_list *im,int max_delay) { +bool put = false; +spin_lock_bh (&im->lock); im->unsolicit_count =0 ;if (del_timer (&im->timer)) {
@@ -259,10 +266,13 @@ static void igmp_mod_timer(struct ip_mc_list *im, int max_delay)spin_unlock_bh (&im->lock);return ; } -refcount_dec (&im->refcnt); + put = true; }igmp_start_timer (im, max_delay);spin_unlock_bh (&im->lock); + +if (put) +ip_ma_put (im); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1127/1674 gpio: mvebu: free generic chips on unbind
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit b11c513ad943f35cf5e8007d3a56279c79b7ed4b ]
irq_alloc_domain_generic_chips() allocates generic chip data that must be freed via irq_domain_remove_generic_chips(). The devres action mvebu_gpio_remove_irq_domain() only called irq_domain_remove(), which only frees the generic chips if IRQ_DOMAIN_FLAG_DESTROY_GC is set. Call irq_domain_remove_generic_chips() explicitly before irq_domain_remove() instead.
--- drivers/gpio/gpio-mvebu.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/gpio-mvebu.c +1 -0
@@ -1116,6 +1116,7 @@ static void mvebu_gpio_remove_irq_domain(void *data) {struct irq_domain *domain = data; +irq_domain_remove_generic_chips (domain);irq_domain_remove (domain); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1128/1674 perf/x86/amd/core: Avoid enabling BRS from the SVM reload path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sandipan Das <[email protected]>
[ Upstream commit 07c60dda9c059c09f83d42a3ebda2e7cc1cf3bc2 ]
Branch Sampling (BRS) and Last Branch Record (LBR) are mutually exclusive hardware features, and users of both are tracked via cpuc->lbr_users.
When SVM is toggled on a CPU, the host perf events are reprogrammed to update the HostOnly filter bit (set when virtualization is enabled, cleared when it is disabled). On PerfMonV2-capable processors, this reprogramming is performed by calling amd_pmu_enable_all() to rewrite the event selectors. However, amd_pmu_enable_all() also calls amd_brs_enable_all(), which enables BRS whenever cpuc->lbr_users > 0. Having active LBR events satisfies this gating on processors that have LBR but not BRS. The kernel then tries to set the BRS enable bit in DebugExtnCfg (MSR 0xc000010f). Since that bit is deprecated on such hardware, the write results in a #GP:
Call Trace: <IRQ> amd_pmu_enable_all+0x1d/0x90 amd_pmu_disable_virt+0x62/0xb0 kvm_arch_disable_virtualization_cpu+0xa/0x40 [kvm] hardware_disable_nolock+0x1a/0x30 [kvm] __flush_smp_call_function_queue+0x9b/0x410 __sysvec_call_function+0x18/0xc0 sysvec_call_function+0x69/0x90 </IRQ> <TASK> asm_sysvec_call_function+0x16/0x20 RIP: 0010:cpuidle_enter_state+0xc4/0x450 ? cpuidle_enter_state+0xb7/0x450 cpuidle_enter+0x29/0x40 cpuidle_idle_call+0xf5/0x160 do_idle+0x7b/0xe0 cpu_startup_entry+0x26/0x30 start_secondary+0x115/0x140 secondary_startup_64_no_verify+0x194/0x19b </TASK>
Fix this by ensuring that BRS is not enabled from the event selector reprogramming path even when cpuc->lbr_users > 0.
--- arch/x86/events/amd/core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/x86/events/amd/core.c +8 -4
@@ -733,13 +733,11 @@ static void amd_pmu_enable_event(struct perf_event *event)x86_pmu_enable_event (event); } -static void amd_pmu_enable_all (int added) +static void __amd_pmu_enable_all (void ) {struct cpu_hw_events *cpuc =this_cpu_ptr (&cpu_hw_events);int idx; -amd_brs_enable_all (); -for (idx =0 ; idx < x86_pmu.num_counters; idx++) {/* only activate events which are marked as active */ if (!test_bit (idx, cpuc->active_mask))
@@ -754,6 +752,12 @@ static void amd_pmu_enable_all(int added) } } +static void amd_pmu_enable_all (int added) +{ +amd_brs_enable_all (); +__amd_pmu_enable_all (); +} +static void amd_pmu_v2_enable_event (struct perf_event *event) {struct hw_perf_event *hwc = &event->hw;
@@ -1505,7 +1509,7 @@ static inline void amd_pmu_reload_virt(void)* set global enable bits once again */ amd_pmu_v2_disable_all (); -amd_pmu_enable_all (0 ); +__amd_pmu_enable_all ();amd_pmu_v2_enable_all (0 );return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1129/1674 net/liquidio: drop cached VF pci_dev LUT
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 5c0e3ba4f500fd4314ceb42f07f16bc445156431 ]
The PF SR-IOV enable path caches VF pci_dev pointers in dpiring_to_vfpcidev_lut[] by iterating with pci_get_device(). Those entries do not own a reference, because the iterator drops the previous device reference on each step. The cached pointer is then dereferenced later when handling OCTEON_VF_FLR_REQUEST.
Replace the cached VF mapping with runtime lookup on the mailbox DPI
ring: derive the VF index from q_no, resolve the VF via exported PCI IOV helpers, validate it with the PF pointer and VF ID, then issue pcie_flr() and drop the reference with pci_dev_put(). Remove the unused VF lookup table initialization and cleanup.
--- .../net/ethernet/cavium/liquidio/lio_main.c | 27 --------------- .../ethernet/cavium/liquidio/octeon_device.h | 3 -- .../ethernet/cavium/liquidio/octeon_mailbox.c | 33 ++++++++++++++++++- 3 files changed, 32 insertions(+), 31 deletions(-)
drivers/net/ethernet/cavium/liquidio/lio_main.c +0 -27
@@ -3795,9 +3795,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)static int octeon_enable_sriov (struct octeon_device *oct) {unsigned int num_vfs_alloced = oct->sriov_info.num_vfs_alloced; -struct pci_dev *vfdev;int err; -u32 u;if (OCTEON_CN23XX_PF (oct) && num_vfs_alloced) { err = pci_enable_sriov(oct->pci_dev,
@@ -3810,23 +3808,6 @@ static int octeon_enable_sriov(struct octeon_device *oct)return err; } oct->sriov_info.sriov_enabled =1 ; - -/* init lookup table that maps DPI ring number to VF pci_dev -* struct pointer -*/ - u =0 ; - vfdev =pci_get_device (PCI_VENDOR_ID_CAVIUM , -OCTEON_CN23XX_VF_VID ,NULL ); -while (vfdev) { -if (vfdev->is_virtfn && - (vfdev->physfn == oct->pci_dev)) { - oct->sriov_info.dpiring_to_vfpcidev_lut[u] = - vfdev; - u += oct->sriov_info.rings_per_vf; - } - vfdev =pci_get_device (PCI_VENDOR_ID_CAVIUM , -OCTEON_CN23XX_VF_VID , vfdev); - } }return num_vfs_alloced;
@@ -3834,8 +3815,6 @@ static int octeon_enable_sriov(struct octeon_device *oct)static int lio_pci_sriov_disable (struct octeon_device *oct) { -int u; -if (pci_vfs_assigned (oct->pci_dev)) {dev_err (&oct->pci_dev->dev,"VFs are still assigned to VMs.\n" );return -EPERM ;
@@ -3843,12 +3822,6 @@ static int lio_pci_sriov_disable(struct octeon_device *oct)pci_disable_sriov (oct->pci_dev); - u =0 ; -while (u <MAX_POSSIBLE_VFS ) { - oct->sriov_info.dpiring_to_vfpcidev_lut[u] =NULL ; - u += oct->sriov_info.rings_per_vf; - } - oct->sriov_info.num_vfs_alloced =0 ;dev_info (&oct->pci_dev->dev,"oct->pf_num:%d disabled VFs\n" , oct->pf_num);
drivers/net/ethernet/cavium/liquidio/octeon_device.h +0 -3
@@ -390,9 +390,6 @@ struct octeon_sriov_info {struct lio_trusted_vf trusted_vf; -/*lookup table that maps DPI ring number to VF pci_dev struct pointer*/ -struct pci_dev *dpiring_to_vfpcidev_lut[MAX_POSSIBLE_VFS ]; -u64 vf_macaddr[MAX_POSSIBLE_VFS ];u16 vf_vlantci[MAX_POSSIBLE_VFS ];
drivers/net/ethernet/cavium/liquidio/octeon_mailbox.c +32 -1
@@ -26,6 +26,31 @@#include "octeon_mailbox.h" #include "cn23xx_pf_device.h" +static struct pci_dev *lio_vf_pci_dev_by_qno (struct octeon_device *oct,u32 q_no) +{ +struct pci_dev *vfdev =NULL ; +int vfidx; + +if (!oct->sriov_info.rings_per_vf) +return NULL ; + +if (q_no % oct->sriov_info.rings_per_vf) +return NULL ; + + vfidx = q_no / oct->sriov_info.rings_per_vf; +if (vfidx >= oct->sriov_info.num_vfs_alloced) +return NULL ; + +while ((vfdev =pci_get_device (PCI_VENDOR_ID_CAVIUM , +OCTEON_CN23XX_VF_VID , vfdev))) { +if (pci_physfn (vfdev) &&pci_physfn (vfdev) == oct->pci_dev && +pci_iov_vf_id (vfdev) == vfidx) +return vfdev; + } + +return NULL ; +} +/** * octeon_mbox_read: * @mbox: Pointer mailbox
@@ -237,6 +262,7 @@ static int octeon_mbox_process_cmd(struct octeon_mbox *mbox, struct octeon_mbox_cmd *mbox_cmd) {struct octeon_device *oct = mbox->oct_dev; +struct pci_dev *vfdev;switch (mbox_cmd->msg.s.cmd) {case OCTEON_VF_ACTIVE :
@@ -260,7 +286,12 @@ static int octeon_mbox_process_cmd(struct octeon_mbox *mbox,dev_info (&oct->pci_dev->dev,"got a request for FLR from VF that owns DPI ring %u\n" , mbox->q_no); -pcie_flr (oct->sriov_info.dpiring_to_vfpcidev_lut[mbox->q_no]); + vfdev =lio_vf_pci_dev_by_qno (oct, mbox->q_no); +if (!vfdev) +break ; + +pcie_flr (vfdev); +pci_dev_put (vfdev);break ;case OCTEON_PF_CHANGED_VF_MACADDR :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1130/1674 Bluetooth: 6lowpan: avoid untracked enable work
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 352a59dc1f4a41314b6f827c17e16af7ca88271a ]
lowpan_enable_set() allocates a temporary work item and schedules do_enable_set() on system_wq, then returns to debugfs. The debugfs active operation has ended at that point, but the worker still executes module text and manipulates enable_6lowpan and listen_chan.
bt_6lowpan_exit() removes the debugfs files and immediately closes and puts listen_chan. It has no pointer to the queued work item, so it cannot cancel or flush it before tearing down the state that the worker uses.
The buggy scenario involves two paths, with each column showing the order within that path:
debugfs enable write module exit
1. lowpan_enable_set() allocates 1. bt_6lowpan_exit() removes
set_enable work the debugfs file
2. schedule_work() queues 2. bt_6lowpan_exit() closes
do_enable_set() and puts listen_chan
3. the write operation returns 3. module teardown can continue
4. do_enable_set() later runs
against stale state
Run the enable state transition synchronously in lowpan_enable_set() instead. The simple debugfs setter can sleep, and this file already handles the 6LoWPAN control write synchronously under the same set_lock. Once the setter returns, debugfs removal covers the whole operation and exit can no longer race with an untracked work item.
Validation reproduced this kernel report:
BUG: KASAN: slab-use-after-free in do_enable_set+0x113/0x2e0 Workqueue: events do_enable_set [bluetooth_6lowpan] The buggy address belongs to the object at ffff888109cb8000
--- net/bluetooth/6lowpan.c | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-)
net/bluetooth/6lowpan.c +4 -23
@@ -1065,23 +1065,15 @@ static void disconnect_all_peers(void) }while (nchans); } -struct set_enable { -struct work_struct work; -bool flag; -}; - -static void do_enable_set (struct work_struct *work) +static void do_enable_set (bool flag) { -struct set_enable *set_enable =container_of (work, - struct set_enable, work); - -if (!set_enable->flag || enable_6lowpan != set_enable->flag) +if (!flag || enable_6lowpan != flag)/* Disconnect existing connections if 6lowpan is * disabled */ disconnect_all_peers (); - enable_6lowpan = set_enable->flag; + enable_6lowpan = flag;mutex_lock (&set_lock);if (listen_chan) {
@@ -1091,22 +1083,11 @@ static void do_enable_set(struct work_struct *work) listen_chan =bt_6lowpan_listen ();mutex_unlock (&set_lock); - -kfree (set_enable); }static int lowpan_enable_set (void *data,u64 val) { -struct set_enable *set_enable; - - set_enable =kzalloc (sizeof (*set_enable),GFP_KERNEL ); -if (!set_enable) -return -ENOMEM ; - - set_enable->flag = !!val; -INIT_WORK (&set_enable->work, do_enable_set); - -schedule_work (&set_enable->work); +do_enable_set (!!val);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1131/1674 net/mlx5e: Fix publication race for priv->channel_stats[]
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Liu <[email protected]>
[ Upstream commit 5a799714e8ca0bce9ea40694f49914cf1adbbaa9 ]
mlx5e_channel_stats_alloc() publishes a new entry to priv->channel_stats[] and then increments priv->stats_nch as a publication token, but neither store carries any memory barrier:
priv->channel_stats[ix] = kvzalloc_node(...); if (!priv->channel_stats[ix]) return -ENOMEM; priv->stats_nch++;
Concurrent readers compute the loop bound from priv->stats_nch and then dereference priv->channel_stats[i] using plain accesses, e.g.
for (i = 0; i < priv->stats_nch; i++) {
struct mlx5e_channel_stats *cs = priv->channel_stats[i];
... cs->rq.packets ...
}On weakly-ordered architectures (ARM, PowerPC, RISC-V) the writes to channel_stats[ix] and stats_nch may become visible to other CPUs out of program order. A reader can observe stats_nch == N while still seeing channel_stats[N-1] == NULL, leading to a NULL pointer dereference in the channel_stats loop.
This has been observed in production on BlueField-3 DPUs (arm64), where ovs-vswitchd queries netdev statistics over netlink during NIC bringup, racing mlx5e_open_channel() -> mlx5e_channel_stats_alloc() on another CPU:
Unable to handle kernel NULL pointer dereference at virtual address 0x840 Hardware name: BlueField-3 DPU pc : mlx5e_fold_sw_stats64+0x30/0x180 [mlx5_core] Call trace: mlx5e_fold_sw_stats64+0x30/0x180 [mlx5_core] dev_get_stats+0x50/0xc0 ovs_vport_get_stats+0x38/0xac [openvswitch] ovs_vport_cmd_fill_info+0x194/0x290 [openvswitch] ovs_vport_cmd_get+0xbc/0x10c [openvswitch] genl_family_rcv_msg_doit+0xd0/0x160 genl_rcv_msg+0xec/0x1f0 netlink_rcv_skb+0x64/0x130 genl_rcv+0x40/0x60 netlink_unicast+0x2fc/0x370 netlink_sendmsg+0x1dc/0x454 ... __arm64_sys_sendmsg+0x2c/0x40
Add mlx5e_stats_nch_write() and mlx5e_stats_nch_read() helpers in en.h that wrap the smp_store_release()/smp_load_acquire() pair on stats_nch. The release/acquire pair establishes the contract:
stats_nch == N => channel_stats[0..N-1] are visible and non-NULL.
Publish the stats_nch increment via mlx5e_stats_nch_write() in the writer (mlx5e_channel_stats_alloc()), and read stats_nch via mlx5e_stats_nch_read() in all readers: mlx5e RX/TX queue stats, mlx5e_get_base_stats(), ethtool channels stats, IPoIB stats, the sw_stats fold and the HV VHCA stats agent.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 12 ++++++++++++ .../ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c | 10 ++++++---- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 5 +++-- drivers/net/ethernet/mellanox/mlx5/core/en_stats.c | 9 +++++---- .../net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c | 3 ++- 5 files changed, 28 insertions(+), 11 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +12 -0
@@ -944,6 +944,18 @@ struct mlx5e_priv {struct dentry *dfs_root; }; +static inline u16 mlx5e_stats_nch_read (const struct mlx5e_priv *priv) +{ +/* Pairs with smp_store_release in mlx5e_stats_nch_write(). */ +return smp_load_acquire (&priv->stats_nch); +} + +static inline void mlx5e_stats_nch_write (struct mlx5e_priv *priv,u16 n) +{ +/* Pairs with smp_load_acquire in mlx5e_stats_nch_read(). */ +smp_store_release (&priv->stats_nch, n); +} +struct mlx5e_dev {struct net_device *netdev;struct devlink_port dl_port;
drivers/net/ethernet/mellanox/mlx5/core/en/hv_vhca_stats.c +6 -4
@@ -33,9 +33,10 @@ mlx5e_hv_vhca_fill_ring_stats(struct mlx5e_priv *priv, int ch,static void mlx5e_hv_vhca_fill_stats (struct mlx5e_priv *priv,void *data,int buf_len) { +u16 nch =mlx5e_stats_nch_read (priv);int ch, i =0 ; -for (ch =0 ; ch < priv->stats_nch; ch++) { +for (ch =0 ; ch < nch; ch++) {void *buf = data + i; if (WARN_ON_ONCE(buf +
@@ -50,8 +51,9 @@ static void mlx5e_hv_vhca_fill_stats(struct mlx5e_priv *priv, void *data,static int mlx5e_hv_vhca_stats_buf_size (struct mlx5e_priv *priv) { -return (sizeof (struct mlx5e_hv_vhca_per_ring_stats ) * - priv->stats_nch); +u16 nch =mlx5e_stats_nch_read (priv); + +return sizeof (struct mlx5e_hv_vhca_per_ring_stats ) * nch; }static int mlx5e_hv_vhca_stats_buf_max_size (struct mlx5e_priv *priv)
@@ -106,7 +108,7 @@ static void mlx5e_hv_vhca_stats_control(struct mlx5_hv_vhca_agent *agent, sagent = &priv->stats_agent; block->version =MLX5_HV_VHCA_STATS_VERSION ; - block->rings = priv->stats_nch; + block->rings =mlx5e_stats_nch_read (priv);if (!block->command) {cancel_delayed_work_sync (&priv->stats_agent.work);
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +3 -2
@@ -2421,7 +2421,7 @@ static int mlx5e_channel_stats_alloc(struct mlx5e_priv *priv, int ix, int cpu) GFP_KERNEL, cpu_to_node(cpu));if (!priv->channel_stats[ix])return -ENOMEM ; - priv->stats_nch++; +mlx5e_stats_nch_write (priv, priv->stats_nch +1 );return 0 ; }
@@ -3685,9 +3685,10 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,void mlx5e_fold_sw_stats64 (struct mlx5e_priv *priv,struct rtnl_link_stats64 *s) { +u16 nch =mlx5e_stats_nch_read (priv);int i; -for (i =0 ; i < priv->stats_nch; i++) { +for (i =0 ; i < nch; i++) {struct mlx5e_channel_stats *channel_stats = priv->channel_stats[i];struct mlx5e_rq_stats *xskrq_stats = &channel_stats->xskrq;struct mlx5e_rq_stats *rq_stats = &channel_stats->rq;
drivers/net/ethernet/mellanox/mlx5/core/en_stats.c +5 -4
@@ -517,6 +517,7 @@ static void mlx5e_stats_update_stats_rq_page_pool(struct mlx5e_channel *c)static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS (sw) {struct mlx5e_sw_stats *s = &priv->stats.sw; +u16 nch =mlx5e_stats_nch_read (priv);int i;memset (s,0 ,sizeof (*s));
@@ -524,7 +525,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(sw)for (i =0 ; i < priv->channels.num; i++)/* for active channels only */ mlx5e_stats_update_stats_rq_page_pool (priv->channels.c[i]); -for (i =0 ; i < priv->stats_nch; i++) { +for (i =0 ; i < nch; i++) {struct mlx5e_channel_stats *channel_stats = priv->channel_stats[i];
@@ -2358,7 +2359,7 @@ static MLX5E_DECLARE_STATS_GRP_OP_UPDATE_STATS(ptp) { return; }static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS (channels) { -int max_nch = priv->stats_nch; +int max_nch =mlx5e_stats_nch_read (priv);return (NUM_RQ_STATS * max_nch) + (NUM_CH_STATS * max_nch) +
@@ -2371,8 +2372,8 @@ static MLX5E_DECLARE_STATS_GRP_OP_NUM_STATS(channels)static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS (channels) { +int max_nch =mlx5e_stats_nch_read (priv);bool is_xsk = priv->xsk.ever_used; -int max_nch = priv->stats_nch;int i, j, tc;for (i =0 ; i < max_nch; i++)
@@ -2413,8 +2414,8 @@ static MLX5E_DECLARE_STATS_GRP_OP_FILL_STRS(channels)static MLX5E_DECLARE_STATS_GRP_OP_FILL_STATS (channels) { +int max_nch =mlx5e_stats_nch_read (priv);bool is_xsk = priv->xsk.ever_used; -int max_nch = priv->stats_nch;int i, j, tc;for (i =0 ; i < max_nch; i++)
drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c +2 -1
@@ -114,10 +114,11 @@ void mlx5i_cleanup(struct mlx5e_priv *priv)static void mlx5i_grp_sw_update_stats (struct mlx5e_priv *priv) { +u16 nch =mlx5e_stats_nch_read (priv);struct rtnl_link_stats64 s = {};int i, j; -for (i =0 ; i < priv->stats_nch; i++) { +for (i =0 ; i < nch; i++) {struct mlx5e_channel_stats *channel_stats;struct mlx5e_rq_stats *rq_stats;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1132/1674 HID: bpf: Fix hid_bpf_get_data() range check
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yiyang Chen <[email protected]>
[ Upstream commit 2d044049421dd48212b28646a850749d4a2d57fa ]
hid_bpf_get_data() returns a pointer into the HID-BPF context data when the caller-provided offset and size fit inside ctx->allocated_size.
The current check adds rdwr_buf_size and offset before comparing the result against ctx->allocated_size. Since both values are unsigned, a very large size can wrap the sum below ctx->allocated_size and make the helper return a pointer even though the requested range is not contained in the backing buffer.
Use check_add_overflow() to reject wrapped range ends before comparing the requested range end against ctx->allocated_size.
--- drivers/hid/bpf/hid_bpf_dispatch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hid/bpf/hid_bpf_dispatch.c +4 -1
@@ -18,6 +18,7 @@#include <linux/minmax.h> #include <linux/module.h> #include <linux/workqueue.h> +#include <linux/overflow.h> #include "hid_bpf_dispatch.h" #include "entrypoints/entrypoints.lskel.h"
@@ -157,13 +158,15 @@ noinline __u8 * hid_bpf_get_data(struct hid_bpf_ctx *ctx, unsigned int offset, const size_t rdwr_buf_size) { struct hid_bpf_ctx_kern *ctx_kern; +size_t end;if (!ctx)return NULL ; ctx_kern = container_of(ctx, struct hid_bpf_ctx_kern, ctx); -if (rdwr_buf_size + offset > ctx->allocated_size) +if (check_add_overflow (rdwr_buf_size, offset, &end) || + end > ctx->allocated_size)return NULL ;return ctx_kern->data + offset;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1133/1674 afs: Fix reinitialisation of the inode, in particular ->lock_work
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
[ Upstream commit 5597fbd1e7c161914f20315a726e54025b0fdadb ]
It seems that initalising afs_vnode::lock_work a single time in the slab's init function isn't sufficient for work_structs. This results in the DEBUG_OBJECTS debugging stuff producing a warning occasionally when running the generic/131 xfstest:
ODEBUG: activate not available (active state 0) object: 0000000016d8760f object type: work_struct hint: afs_lock_work+0x0/0x220
WARNING: lib/debugobjects.c:629 at debug_print_object+0x4b/0x90, CPU#3: locktest/7695 ... CPU: 3 UID: 0 PID: 7695 Comm: locktest Tainted: G S 7.1.0-build3+ #2771 PREEMPT ... RIP: 0010:debug_print_object+0x65/0x90 ... Call Trace: <TASK> ? __pfx_afs_lock_work+0x10/0x10 debug_object_activate+0x122/0x170 insert_work+0x25/0x60 __queue_work+0x2e0/0x340 queue_delayed_work_on+0x48/0x70 afs_fl_release_private+0x57/0x70 locks_release_private+0x5c/0xa0 locks_free_lock+0xe/0x20 posix_lock_inode+0x55f/0x5b0 locks_lock_inode_wait+0x81/0x140 ? file_write_and_wait_range+0x50/0x70 afs_lock+0xcd/0x110 fcntl_setlk+0x10d/0x260 do_fcntl+0x24e/0x5b0 __do_sys_fcntl+0x6a/0x90 do_syscall_64+0x11e/0x310 entry_SYSCALL_64_after_hwframe+0x71/0x79
Fix this by reinitialising ->lock_work after allocating an inode.
Also, flush ->lock_work when the inode is being evicted to make sure it's not still running.
--- fs/afs/inode.c | 1 + fs/afs/super.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
fs/afs/inode.c +1 -0
@@ -820,6 +820,7 @@ void afs_evict_inode(struct inode *inode) ASSERTCMP(inode->i_ino, ==, vnode->fid.vnode); +flush_delayed_work (&vnode->lock_work);truncate_inode_pages_final (&inode->i_data);afs_set_cache_aux (vnode, &aux);
fs/afs/super.c +1 -1
@@ -670,7 +670,6 @@ static void afs_i_init_once(void *_vnode)INIT_LIST_HEAD (&vnode->wb_keys);INIT_LIST_HEAD (&vnode->pending_locks);INIT_LIST_HEAD (&vnode->granted_locks); -INIT_DELAYED_WORK (&vnode->lock_work, afs_lock_work);INIT_LIST_HEAD (&vnode->cb_mmap_link);seqlock_init (&vnode->cb_lock); }
@@ -702,6 +701,7 @@ static struct inode *afs_alloc_inode(struct super_block *sb)init_rwsem (&vnode->rmdir_lock);INIT_WORK (&vnode->cb_work, afs_invalidate_mmap_work); +INIT_DELAYED_WORK (&vnode->lock_work, afs_lock_work);_leave (" = %p" , &vnode->netfs.inode);return &vnode->netfs.inode;
Signature · 1 line
2.53.0