5.15.209-rc1 review
Subsystems (5)
Greg Kroah-Hartman
maintainerPATCH 425/776 Bluetooth: fix locking in hci_conn_request_evt() with HCI_PROTO_DEFER
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pauli Virtanen <[email protected]>
[ Upstream commit 5c7209a341ff2ac338b2b0375c34a307b37c9ac2 ]
When protocol sets HCI_PROTO_DEFER, hci_conn_request_evt() calls hci_connect_cfm(conn) without hdev->lock. Generally hci_connect_cfm() assumes it is held, and if conn is deleted concurrently -> UAF.
Only SCO and ISO set HCI_PROTO_DEFER and only for defer setup listen, and HCI_EV_CONN_REQUEST is not generated for ISO. In the non-deferred listening socket code paths, hci_connect_cfm(conn) is called with hdev->lock held.
Fix by holding the lock.
--- net/bluetooth/hci_event.c | 3 --- 1 file changed, 3 deletions(-)
net/bluetooth/hci_event.c +0 -3
@@ -2882,8 +2882,6 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)memcpy (conn->dev_class, ev->dev_class,3 ); -hci_dev_unlock (hdev); -if (ev->link_type ==ACL_LINK || (!(flags &HCI_PROTO_DEFER ) && !lmp_esco_capable (hdev))) {struct hci_cp_accept_conn_req cp;
@@ -2917,7 +2915,6 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)hci_connect_cfm (conn,0 ); } -return ; unlock:hci_dev_unlock (hdev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 426/776 Bluetooth: l2cap: Add missing chan lock in l2cap_ecred_reconf_rsp
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dudu Lu <[email protected]>
[ Upstream commit 42776497cdbc9a665b384a6dcb85f0d4bd927eab ]
l2cap_ecred_reconf_rsp() calls l2cap_chan_del() without holding l2cap_chan_lock(). Every other l2cap_chan_del() caller in the file acquires the lock first. A remote BLE device can send a crafted L2CAP ECRED reconfiguration response to corrupt the channel list while another thread is iterating it.
Add l2cap_chan_hold() and l2cap_chan_lock() before l2cap_chan_del(), and l2cap_chan_unlock() and l2cap_chan_put() after, matching the pattern used in l2cap_ecred_conn_rsp() and l2cap_conn_del().
--- net/bluetooth/l2cap_core.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/bluetooth/l2cap_core.c +6 -0
@@ -6429,7 +6429,13 @@ static inline int l2cap_ecred_reconf_rsp(struct l2cap_conn *conn,if (chan->ident != cmd->ident)continue ; +l2cap_chan_hold (chan); +l2cap_chan_lock (chan); +l2cap_chan_del (chan,ECONNRESET ); + +l2cap_chan_unlock (chan); +l2cap_chan_put (chan); }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 427/776 net: phy: qcom: at803x: Use the correct bit to disable extended next page
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxime Chevallier <[email protected]>
[ Upstream commit e7a62edd34b1b4bc5f979988efc2f81c075733fd ]
As noted in the blamed commit, the AR8035 and other PHYs from this family advertise the Extended Next Page support by default, which may be understood by some partners as this PHY being multi-gig capable.
The fix is to disable XNP advertising, which is done by setting bit 12 of the Auto-Negotiation Advertisement Register (MII_ADVERTISE).
The blamed commit incorrectly uses MDIO_AN_CTRL1_XNP, which is bit 13 as per 802.3 : 45.2.7.1 AN control register (Register 7.0)
BIT 12 in MII_ADVERTISE is wrapped by ADVERTISE_RESV, used by some drivers such as the aquantia one. 802.3 Clause 28 defines bit 12 as Extended Next Page ability, at least in recent versions of the standard.
Let's add a define for it and use it in the at803x driver.
--- drivers/net/phy/at803x.c | 2 +- include/uapi/linux/mii.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/net/phy/at803x.c +1 -1
@@ -818,7 +818,7 @@ static int at803x_config_init(struct phy_device *phydev)* behaviour but we still need to accommodate it. XNP is only needed * for 10Gbps support, so disable XNP. */ -return phy_modify (phydev,MII_ADVERTISE ,MDIO_AN_CTRL1_XNP ,0 ); +return phy_modify (phydev,MII_ADVERTISE ,ADVERTISE_XNP ,0 ); }static int at803x_ack_interrupt (struct phy_device *phydev)
include/uapi/linux/mii.h +2 -1
@@ -82,7 +82,8 @@#define ADVERTISE_100BASE4 0x0200/* Try for 100mbps 4k packets */ #define ADVERTISE_PAUSE_CAP 0x0400/* Try for pause */ #define ADVERTISE_PAUSE_ASYM 0x0800/* Try for asymetric pause */ -#define ADVERTISE_RESV 0x1000/* Unused... */ +#define ADVERTISE_XNP 0x1000/* Extended Next Page */ +#define ADVERTISE_RESV ADVERTISE_XNP/* Used to be reserved */ #define ADVERTISE_RFAULT 0x2000/* Say we can detect faults */ #define ADVERTISE_LPACK 0x4000/* Ack link partners response */ #define ADVERTISE_NPAGE 0x8000/* Next page bit */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 428/776 sctp: fix missing encap_port propagation for GSO fragments
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit bf6f95ae3b8b2638c0e1d6d802d50983ce5d0f45 ]
encap_port in SCTP_INPUT_CB(skb) is used by sctp_vtag_verify() for SCTP-over-UDP processing. In the GSO case, it is only set on the head skb, while fragment skbs leave it 0.
This results in fragment skbs seeing encap_port == 0, breaking SCTP-over-UDP connections.
Fix it by propagating encap_port from the head skb cb when initializing fragment skbs in sctp_inq_pop().
--- net/sctp/inqueue.c | 1 + 1 file changed, 1 insertion(+)
net/sctp/inqueue.c +1 -0
@@ -195,6 +195,7 @@ struct sctp_chunk *sctp_inq_pop(struct sctp_inq *queue) cb->chunk = head_cb->chunk; cb->af = head_cb->af; + cb->encap_port = head_cb->encap_port; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 429/776 net, bpf: fix null-ptr-deref in xdp_master_redirect() for down master
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 1921f91298d1388a0bb9db8f83800c998b649cb3 ]
syzkaller reported a kernel panic in bond_rr_gen_slave_id() reached via xdp_master_redirect(). Full decoded trace:
https://syzkaller.appspot.com/bug?extid=80e046b8da2820b6ba73
bond_rr_gen_slave_id() dereferences bond->rr_tx_counter, a per-CPU counter that bonding only allocates in bond_open() when the mode is round-robin. If the bond device was never brought up, rr_tx_counter stays NULL.
The XDP redirect path can still reach that code on a bond that was never opened: bpf_master_redirect_enabled_key is a global static key, so as soon as any bond device has native XDP attached, the XDP_TX -> xdp_master_redirect() interception is enabled for every slave system-wide. The path xdp_master_redirect() -> bond_xdp_get_xmit_slave() -> bond_xdp_xmit_roundrobin_slave_get() -> bond_rr_gen_slave_id() then runs against a bond that has no rr_tx_counter and crashes.
Fix this in the generic xdp_master_redirect() by refusing to call into the master's ->ndo_xdp_get_xmit_slave() when the master device is not up. IFF_UP is only set after ->ndo_open() has successfully returned, so this reliably excludes masters whose XDP state has not been fully initialized. Drop the frame with XDP_ABORTED so the exception is visible via trace_xdp_exception() rather than silently falling through. This is not specific to bonding: any current or future master that defers XDP state allocation to ->ndo_open() is protected.
--- net/core/filter.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/filter.c +2 -0
@@ -4031,6 +4031,8 @@ u32 xdp_master_redirect(struct xdp_buff *xdp)struct bpf_redirect_info *ri =this_cpu_ptr (&bpf_redirect_info); master =netdev_master_upper_dev_get_rcu (xdp->rxq->dev); +if (unlikely (!(master->flags &IFF_UP ))) +return XDP_ABORTED ; slave = master->netdev_ops->ndo_xdp_get_xmit_slave (master, xdp);if (slave && slave != xdp->rxq->dev) {/* The target device is different from the receiving device, so
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 430/776 drm/komeda: fix integer overflow in AFBC framebuffer size check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Konyukhov <[email protected]>
[ Upstream commit 779ec12c85c9e4547519e3903a371a3b26a289de ]
The AFBC framebuffer size validation calculates the minimum required buffer size by adding the AFBC payload size to the framebuffer offset. This addition is performed without checking for integer overflow.
If the addition oveflows, the size check may incorrectly succed and allow userspace to provide an undersized drm_gem_object, potentially leading to out-of-bounds memory access.
Add usage of check_add_overflow() to safely compute the minimum required size and reject the framebuffer if an overflow is detected. This makes the AFBC size validation more robust against malformed.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c +5 -1
@@ -4,6 +4,8 @@* Author: James.Qian.Wang <[email protected]> * */ +#include <linux/overflow.h> +#include <drm/drm_device.h> #include <drm/drm_fb_cma_helper.h> #include <drm/drm_gem.h>
@@ -92,7 +94,9 @@ komeda_fb_afbc_size_check(struct komeda_fb *kfb, struct drm_file *file, kfb->afbc_size = kfb->offset_payload + n_blocks *ALIGN (bpp *AFBC_SUPERBLK_PIXELS /8 ,AFBC_SUPERBLK_ALIGNMENT ); - min_size = kfb->afbc_size + fb->offsets[0 ]; +if (check_add_overflow (kfb->afbc_size, fb->offsets[0 ], &min_size)) { + goto check_failed; + }if (min_size > obj->size) {DRM_DEBUG_KMS ("afbc size check failed, obj_size: 0x%zx. min_size 0x%llx.\n" , obj->size, min_size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 431/776 ASoC: sti: Return errors from regmap_field_alloc()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sander Vanheule <[email protected]>
[ Upstream commit 272aabef50bc3fe58edd26de000f4cdd41bdbe60 ]
When regmap_field_alloc() fails, it can return an error. Specifically, it will return PTR_ERR(-ENOMEM) when the allocation returns a NULL pointer. The code then uses these allocations with a simple NULL check:
if (player->clk_sel) {
// May dereference invalid pointer (-ENOMEM)
err = regmap_field_write(player->clk_sel, ...);
}Ensure initialization fails by forwarding the errors from regmap_field_alloc(), thus avoiding the use of the invalid pointers.
--- sound/soc/sti/uniperif_player.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/soc/sti/uniperif_player.c +5 -0
@@ -1029,7 +1029,12 @@ static int uni_player_parse_dt_audio_glue(struct platform_device *pdev, } player->clk_sel =regmap_field_alloc (regmap, regfield[0 ]); +if (IS_ERR (player->clk_sel)) +return PTR_ERR (player->clk_sel); + player->valid_sel =regmap_field_alloc (regmap, regfield[1 ]); +if (IS_ERR (player->valid_sel)) +return PTR_ERR (player->valid_sel);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 432/776 ASoC: sti: use managed regmap_field allocations
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sander Vanheule <[email protected]>
[ Upstream commit 1696fad8b259a2d46e51cd6e17e4bcdbe02279fa ]
The regmap_field objects allocated at player init are never freed and may leak resources if the driver is removed.
Switch to devm_regmap_field_alloc() to automatically limit the lifetime of the allocations the lifetime of the device.
--- sound/soc/sti/uniperif_player.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sti/uniperif_player.c +2 -2
@@ -1028,11 +1028,11 @@ static int uni_player_parse_dt_audio_glue(struct platform_device *pdev,return PTR_ERR (regmap); } - player->clk_sel =regmap_field_alloc (regmap, regfield[0 ]); + player->clk_sel =devm_regmap_field_alloc (&pdev->dev, regmap, regfield[0 ]);if (IS_ERR (player->clk_sel))return PTR_ERR (player->clk_sel); - player->valid_sel =regmap_field_alloc (regmap, regfield[1 ]); + player->valid_sel =devm_regmap_field_alloc (&pdev->dev, regmap, regfield[1 ]);if (IS_ERR (player->valid_sel))return PTR_ERR (player->valid_sel);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 433/776 dm cache: fix null-deref with concurrent writes in passthrough mode
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming-Hung Tsai <[email protected]>
[ Upstream commit 7d1f98d668ee34c1d15bdc0420fdd062f24a27c0 ]
In passthrough mode, when dm-cache starts to invalidate a cache entry and bio prison cell lock fails due to concurrent write to the same cached block, mg->cell remains NULL. The error path in invalidate_complete() attempts to unlock and free the cell unconditionally, causing a NULL pointer dereference:
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] CPU: 0 UID: 0 PID: 134 Comm: fio Not tainted 6.19.0-rc7 #3 PREEMPT RIP: 0010:dm_cell_unlock_v2+0x3f/0x210 <snip> Call Trace: invalidate_complete+0xef/0x430 map_bio+0x130f/0x1a10 cache_map+0x320/0x6b0 __map_bio+0x458/0x510 dm_submit_bio+0x40e/0x16d0 __submit_bio+0x419/0x870
<snip>
Reproduce steps:
1. Create a cache device
dmsetup create cmeta --table "0 8192 linear /dev/sdc 0" dmsetup create cdata --table "0 131072 linear /dev/sdc 8192" dmsetup create corig --table "0 262144 linear /dev/sdc 262144" dd if=/dev/zero of=/dev/mapper/cmeta bs=4k count=1 oflag=direct dmsetup create cache --table "0 262144 cache /dev/mapper/cmeta \/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 writethrough smq 0"
2. Promote the first data block into cache
fio --filename=/dev/mapper/cache --name=populate --rw=write --bs=4k \
--direct=1 --size=64k
3. Reload the cache into passthrough mode
dmsetup suspend cache
dmsetup reload cache --table "0 262144 cache /dev/mapper/cmeta \/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 passthrough smq 0" dmsetup resume cache
4. Write to the first cached block concurrently
fio --filename=/dev/mapper/cache --name test --rw=randwrite --bs=4k \
--randrepeat=0 --direct=1 --numjobs=2 --size 64k
Fix by checking if mg->cell is valid before attempting to unlock it.
--- drivers/md/dm-cache-target.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/md/dm-cache-target.c +4 -2
@@ -1448,8 +1448,10 @@ static void invalidate_complete(struct dm_cache_migration *mg, bool success)struct cache *cache = mg->cache;bio_list_init (&bios); -if (dm_cell_unlock_v2 (cache->prison, mg->cell, &bios)) -free_prison_cell (cache, mg->cell); +if (mg->cell) { +if (dm_cell_unlock_v2 (cache->prison, mg->cell, &bios)) +free_prison_cell (cache, mg->cell); + }if (!success && mg->overwrite_bio)bio_io_error (mg->overwrite_bio);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 434/776 dm cache: fix write path cache coherency in passthrough mode
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming-Hung Tsai <[email protected]>
[ Upstream commit 0c5eef0aad508231d8e43ff8392692925e131b68 ]
In passthrough mode, dm-cache defers write bio submission until cache invalidation completes to maintain existing coherency, requiring the target map function to return DM_MAPIO_SUBMITTED. The current map_bio() returns DM_MAPIO_REMAPPED, violating the required ordering constraint.
Reproduce steps:
1. Create a cache device
dmsetup create cmeta --table "0 8192 linear /dev/sdc 0" dmsetup create cdata --table "0 131072 linear /dev/sdc 8192" dmsetup create corig --table "0 262144 linear /dev/sdc 262144" dd if=/dev/zero of=/dev/mapper/cmeta bs=4k count=1 oflag=direct dmsetup create cache --table "0 262144 cache /dev/mapper/cmeta \/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 writethrough smq 0"
2. Promote the first data block into the cache
fio --filename=/dev/mapper/cache --name=populate --rw=write --bs=4k \
--direct=1 --size=64k
3. Reload the cache into passthrough mode
dmsetup suspend cache
dmsetup reload cache --table "0 262144 cache /dev/mapper/cmeta \/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 passthrough smq 0" dmsetup resume cache
4. Write to the first data block, and check io ordering using ftrace
echo 1 > /sys/kernel/debug/tracing/events/block/block_bio_queue/enable echo 1 > /sys/kernel/debug/tracing/events/block/block_bio_complete/enable echo 1 > /sys/kernel/debug/tracing/events/block/block_rq_complete/enable fio --filename=/dev/mapper/cache --name=test --rw=write --bs=64k \
--direct=1 --size 64k
5. ftrace logs show that write operations to the cache origin (252:2) and metadata operations (252:0) are unsynchronized: the origin write occurs before metadata commit.
<snip>
fio-146 [000] ..... 420.139562: block_bio_queue: 252,3 WS 0 + 128 [fio]
fio-146 [000] ..... 420.149395: block_bio_queue: 252,2 WS 0 + 128 [fio]
fio-146 [000] ..... 420.149763: block_bio_queue: 8,32 WS 262144 + 128 [fio]
fio-146 [000] dNh1. 420.151446: block_rq_complete: 8,32 WS () 262144 + 128 be,0,4 [0]
fio-146 [000] dNh1. 420.152731: block_bio_complete: 252,2 WS 0 + 128 [0]
fio-146 [000] dNh1. 420.154229: block_bio_complete: 252,3 WS 0 + 128 [0]
kworker/0:0-9 [000] ..... 420.160530: block_bio_queue: 252,0 W 408 + 8 [kworker/0:0]
kworker/0:0-9 [000] ..... 420.161641: block_bio_queue: 8,32 W 408 + 8 [kworker/0:0]
kworker/0:0-9 [000] ..... 420.162533: block_bio_queue: 252,0 W 416 + 8 [kworker/0:0]
kworker/0:0-9 [000] ..... 420.162821: block_bio_queue: 8,32 W 416 + 8 [kworker/0:0]<snip>
--- drivers/md/dm-cache-target.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/dm-cache-target.c +1 -0
@@ -1684,6 +1684,7 @@ static int map_bio(struct cache *cache, struct bio *bio, dm_oblock_t block,bio_drop_shared_lock (cache, bio);atomic_inc (&cache->stats.demotion);invalidate_start (cache, cblock, block, bio); +return DM_MAPIO_SUBMITTED ; }else remap_to_origin_clear_discard (cache, bio, block); }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 435/776 dm cache policy smq: fix missing locks in invalidating cache blocks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming-Hung Tsai <[email protected]>
[ Upstream commit 2d1f7b65f5deedd2e6b09fdc6ea27f8375f24b45 ]
In passthrough mode, the policy invalidate_mapping operation is called simultaneously from multiple workers, thus it should be protected by a lock. Otherwise, we might end up with data races on the allocated blocks counter, or even use-after-free issues with internal data structures when doing concurrent writes.
Note that the existing FIXME in smq_invalidate_mapping() doesn't affect passthrough mode since migration tasks don't exist there, but would need attention if supporting fast device shrinking via suspend/resume without target reloading.
Reproduce steps:
1. Create a cache device consisting of 1024 cache entries
dmsetup create cmeta --table "0 8192 linear /dev/sdc 0" dmsetup create cdata --table "0 131072 linear /dev/sdc 8192" dmsetup create corig --table "0 262144 linear /dev/sdc 262144" dd if=/dev/zero of=/dev/mapper/cmeta bs=4k count=1 oflag=direct dmsetup create cache --table "0 262144 cache /dev/mapper/cmeta \/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 writethrough smq 0"
2. Populate the cache, and record the number of cached blocks
fio --name=populate --filename=/dev/mapper/cache --rw=randwrite --bs=4k \
--size=64m --direct=1
nr_cached=$(dmsetup status cache | awk '{split($7, a, "/"); print a[1]}')
3. Reload the cache into passthrough mode
dmsetup suspend cache
dmsetup reload cache --table "0 262144 cache /dev/mapper/cmeta \/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 passthrough smq 0" dmsetup resume cache
4. Write to the passthrough cache. By setting multiple jobs with I/O size equal to the cache block size, cache blocks are invalidated concurrently from different workers.
fio --filename=/dev/mapper/cache --name=test --rw=randwrite --bs=64k \
--direct=1 --numjobs=2 --randrepeat=0 --size=64m
5. Check if demoted matches cached block count. These numbers should match but may differ due to the data race.
nr_demoted=$(dmsetup status cache | awk '{print $12}') echo "$nr_cached, $nr_demoted"
--- drivers/md/dm-cache-policy-smq.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/md/dm-cache-policy-smq.c +4 -0
@@ -1584,14 +1584,18 @@ static int smq_invalidate_mapping(struct dm_cache_policy *p, dm_cblock_t cblock) {struct smq_policy *mq =to_smq_policy (p);struct entry *e =get_entry (&mq->cache_alloc,from_cblock (cblock)); +unsigned long flags;if (!e->allocated)return -ENODATA ; +spin_lock_irqsave (&mq->lock, flags);// FIXME: what if this block has pending background work? del_queue (mq, e);h_remove (&mq->table, e);free_entry (&mq->cache_alloc, e); +spin_unlock_irqrestore (&mq->lock, flags); +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 436/776 dm cache: fix concurrent write failure in passthrough mode
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming-Hung Tsai <[email protected]>
[ Upstream commit e4f66341779d0cf4c83c74793753a84094286d9e ]
When bio prison cell lock acquisition fails due to concurrent writes to the same block in passthrough mode, dm-cache incorrectly returns an I/O error instead of properly handling the concurrency. This can occur in both process and workqueue contexts when invalidate_lock() is called for exclusive access to a data block. Fix this by deferring the write bios to ensure proper block device behavior.
Reproduce steps:
1. Create a cache device
dmsetup create cmeta --table "0 8192 linear /dev/sdc 0" dmsetup create cdata --table "0 131072 linear /dev/sdc 8192" dmsetup create corig --table "0 262144 linear /dev/sdc 262144" dd if=/dev/zero of=/dev/mapper/cmeta bs=4k count=1 oflag=direct dmsetup create cache --table "0 262144 cache /dev/mapper/cmeta \/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 writethrough smq 0"
2. Promote the first data block into cache
fio --filename=/dev/mapper/cache --name=populate --rw=write --bs=4k \
--direct=1 --size=64k
3. Reload the cache into passthrough mode
dmsetup suspend cache
dmsetup reload cache --table "0 262144 cache /dev/mapper/cmeta \/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 passthrough smq 0" dmsetup resume cache
4. Write to the first cached block concurrently. Sometimes one of the processes will receive I/O errors.
fio --filename=/dev/mapper/cache --name test --rw=randwrite --bs=4k \
--randrepeat=0 --direct=1 --numjobs=2 --size 64k
<snip>
fio-3.41
fio: io_u error on file /dev/mapper/cache: Input/output error: write offset=4096, buflen=4096
fio: pid=106, err=5/file:io_u.c:2008, func=io_u error, error=Input/output error
test: (groupid=0, jobs=1): err= 0: pid=105
test: (groupid=0, jobs=1): err= 5 (file:io_u.c:2008, func=io_u error, error=Input/output error): pid=106 <snip>
--- drivers/md/dm-cache-target.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/md/dm-cache-target.c +9 -0
@@ -1524,6 +1524,15 @@ static int invalidate_lock(struct dm_cache_migration *mg) READ_WRITE_LOCK_LEVEL, prealloc, &mg->cell);if (r <0 ) {free_prison_cell (cache, prealloc); + +/* Defer the bio for retrying the cell lock */ +if (mg->overwrite_bio) { +struct bio *bio = mg->overwrite_bio; + + mg->overwrite_bio =NULL ; +defer_bio (cache, bio); + } +invalidate_complete (mg, false);return r; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 437/776 dm cache: support shrinking the origin device
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming-Hung Tsai <[email protected]>
[ Upstream commit c2662b1544cbd8ea3181381bb899b8e681dfedc7 ]
This patch introduces formal support for shrinking the cache origin by reducing the cache target length via table reloads. Cache blocks mapped beyond the new target length must be clean and are invalidated during preresume. If any dirty blocks exist in the area being removed, the preresume operation fails without setting the NEEDS_CHECK flag in superblock, and the resume ioctl returns EFBIG. The cache device remains suspended until a table reload with target length that fits existing mappings is performed.
Without this patch, reducing the cache target length could result in io errors (RHBZ: 2134334), out-of-bounds memory access to the discard bitset, and security concerns regarding data leakage.
Verification steps:
1. create a cache metadata with some cached blocks mapped to the tail of the origin device. Here we use cache_restore v1.0 to build a metadata with one clean block mapped to the last origin block.
cat <<EOF >> cmeta.xml
<superblock uuid="" block_size="128" nr_cache_blocks="512" \
policy="smq" hint_width="4">
<mappings>
<mapping cache_block="0" origin_block="4095" dirty="false"/>
</mappings>
</superblock>
EOF
dmsetup create cmeta --table "0 8192 linear /dev/sdc 0" cache_restore -i cmeta.xml -o /dev/mapper/cmeta --metadata-version=2 dmsetup remove cmeta
2. bring up the cache whilst shrinking the cache origin by one block:
dmsetup create cmeta --table "0 8192 linear /dev/sdc 0" dmsetup create cdata --table "0 65536 linear /dev/sdc 8192" dmsetup create corig --table "0 524160 linear /dev/sdc 262144" dmsetup create cache --table "0 524160 cache /dev/mapper/cmeta \/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 writethrough smq 0"
3. check the number of cached data blocks via dmsetup status. It is expected to be zero.
dmsetup status cache | cut -d ' ' -f 7
In addition to the script above, this patch can be verified using the "cache/resize" tests in dmtest-python:
./dmtest run --rx cache/resize/shrink_origin --result-set default
Stable-dep-of: 322586745bd1 ("dm cache: fix dirty mapping checking in passthrough mode switching")
--- drivers/md/dm-cache-target.c | 72 ++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 3 deletions(-)
drivers/md/dm-cache-target.c +69 -3
@@ -405,6 +405,12 @@ struct cache {mempool_t migration_pool;struct bio_set bs; + +/* +* Cache_size entries. Set bits indicate blocks mapped beyond the +* target length, which are marked for invalidation. +*/ +unsigned long *invalid_bitset; };struct per_bio_data {
@@ -1918,6 +1924,9 @@ static void __destroy(struct cache *cache)if (cache->discard_bitset)free_bitset (cache->discard_bitset); +if (cache->invalid_bitset) +free_bitset (cache->invalid_bitset); +if (cache->copier)dm_kcopyd_client_destroy (cache->copier);
@@ -2506,6 +2515,13 @@ static int cache_create(struct cache_args *ca, struct cache **result) }clear_bitset (cache->discard_bitset,from_dblock (cache->discard_nr_blocks)); + cache->invalid_bitset =alloc_bitset (from_cblock (cache->cache_size)); +if (!cache->invalid_bitset) { + *error ="could not allocate bitset for invalid blocks" ; + goto bad; + } +clear_bitset (cache->invalid_bitset,from_cblock (cache->cache_size)); + cache->copier =dm_kcopyd_client_create (&dm_kcopyd_throttle);if (IS_ERR (cache->copier)) { *error ="could not create kcopyd client" ;
@@ -2804,6 +2820,24 @@ static int load_mapping(void *context, dm_oblock_t oblock, dm_cblock_t cblock,return policy_load_mapping (cache->policy, oblock, cblock, dirty, hint, hint_valid); } +static int load_filtered_mapping (void *context,dm_oblock_t oblock,dm_cblock_t cblock, +bool dirty,uint32_t hint,bool hint_valid) +{ +struct cache *cache = context; + +if (from_oblock (oblock) >=from_oblock (cache->origin_blocks)) { +if (dirty) { +DMERR ("%s: unable to shrink origin; cache block %u is dirty" , +cache_device_name (cache),from_cblock (cblock)); +return -EFBIG ; + } +set_bit (from_cblock (cblock), cache->invalid_bitset); +return 0 ; + } + +return load_mapping (context, oblock, cblock, dirty, hint, hint_valid); +} +/* * The discard block size in the on disk metadata is not * neccessarily the same as we're currently using. So we have to
@@ -2958,6 +2992,24 @@ static int resize_cache_dev(struct cache *cache, dm_cblock_t new_size)return 0 ; } +static int truncate_oblocks (struct cache *cache) +{ +uint32_t nr_blocks =from_cblock (cache->cache_size); +uint32_t i; +int r; + +for_each_set_bit (i, cache->invalid_bitset, nr_blocks) { + r =dm_cache_remove_mapping (cache->cmd,to_cblock (i)); +if (r) { +DMERR_LIMIT ("%s: invalidation failed; couldn't update on disk metadata" , +cache_device_name (cache)); +return r; + } + } + +return 0 ; +} +static int cache_preresume (struct dm_target *ti) {int r =0 ;
@@ -2982,11 +3034,25 @@ static int cache_preresume(struct dm_target *ti) }if (!cache->loaded_mappings) { +/* +* The fast device could have been resized since the last +* failed preresume attempt. To be safe we start by a blank +* bitset for cache blocks. +*/ +clear_bitset (cache->invalid_bitset,from_cblock (cache->cache_size)); + r =dm_cache_load_mappings (cache->cmd, cache->policy, - load_mapping, cache); + load_filtered_mapping, cache);if (r) {DMERR ("%s: could not load cache mappings" ,cache_device_name (cache)); -metadata_operation_failed (cache,"dm_cache_load_mappings" , r); +if (r != -EFBIG ) +metadata_operation_failed (cache,"dm_cache_load_mappings" , r); +return r; + } + + r =truncate_oblocks (cache); +if (r) { +metadata_operation_failed (cache,"dm_cache_remove_mapping" , r);return r; }
@@ -3460,7 +3526,7 @@ static void cache_io_hints(struct dm_target *ti, struct queue_limits *limits)static struct target_type cache_target = { .name ="cache" , - .version = {2 ,2 ,0 }, + .version = {2 ,3 ,0 }, .module =THIS_MODULE , .ctr = cache_ctr, .dtr = cache_dtr,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 438/776 dm cache: fix dirty mapping checking in passthrough mode switching
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming-Hung Tsai <[email protected]>
[ Upstream commit 322586745bd1a0e5f3559fd1635fdeb4dbd1d6b8 ]
As mentioned in commit 9b1cc9f251af ("dm cache: share cache-metadata object across inactive and active DM tables"), dm-cache assumed table reload occurs after suspension, while LVM's table preload breaks this assumption. The dirty mapping check for passthrough mode was designed around this assumption and is performed during table creation, causing the check to fail with preload while metadata updates are ongoing. This risks loading dirty mappings into passthrough mode, resulting in data loss.
Reproduce steps:
1. Create a writeback cache with zero migration_threshold to produce dirty mappings
dmsetup create cmeta --table "0 8192 linear /dev/sdc 0" dmsetup create cdata --table "0 131072 linear /dev/sdc 8192" dmsetup create corig --table "0 262144 linear /dev/sdc 262144" dd if=/dev/zero of=/dev/mapper/cmeta bs=4k count=1 oflag=direct dmsetup create cache --table "0 262144 cache /dev/mapper/cmeta \/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 writeback smq \
2 migration_threshold 0"
2. Preload a table in passthrough mode
dmsetup reload cache --table "0 262144 cache /dev/mapper/cmeta \/dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 passthrough smq 0"
3. Write to the first cache block to make it dirty
fio --filename=/dev/mapper/cache --name=populate --rw=write --bs=4k \
--direct=1 --size=64k
4. Resume the inactive table. Now it's possible to load the dirty block into passthrough mode.
dmsetup resume cache
Fix by moving the checks to the preresume phase to support table preloading. Also remove the unused function dm_cache_metadata_all_clean.
--- drivers/md/dm-cache-metadata.c | 11 ----------- drivers/md/dm-cache-metadata.h | 5 ----- drivers/md/dm-cache-target.c | 25 ++++++++----------------- 3 files changed, 8 insertions(+), 33 deletions(-)
drivers/md/dm-cache-metadata.c +0 -11
@@ -1749,17 +1749,6 @@ int dm_cache_write_hints(struct dm_cache_metadata *cmd, struct dm_cache_policy *return r; } -int dm_cache_metadata_all_clean (struct dm_cache_metadata *cmd,bool *result) -{ -int r; - -READ_LOCK (cmd); - r =blocks_are_unmapped_or_clean (cmd,0 , cmd->cache_blocks, result); -READ_UNLOCK (cmd); - -return r; -} -void dm_cache_metadata_set_read_only (struct dm_cache_metadata *cmd) {WRITE_LOCK_VOID (cmd);
drivers/md/dm-cache-metadata.h +0 -5
@@ -137,11 +137,6 @@ void dm_cache_dump(struct dm_cache_metadata *cmd);*/ int dm_cache_write_hints (struct dm_cache_metadata *cmd,struct dm_cache_policy *p); -/* -* Query method. Are all the blocks in the cache clean? -*/ -int dm_cache_metadata_all_clean (struct dm_cache_metadata *cmd,bool *result); -int dm_cache_metadata_needs_check (struct dm_cache_metadata *cmd,bool *result);int dm_cache_metadata_set_needs_check (struct dm_cache_metadata *cmd);void dm_cache_metadata_set_read_only (struct dm_cache_metadata *cmd);
drivers/md/dm-cache-target.c +8 -17
@@ -2470,23 +2470,8 @@ static int cache_create(struct cache_args *ca, struct cache **result) goto bad; } -if (passthrough_mode (cache)) { -bool all_clean; - - r =dm_cache_metadata_all_clean (cache->cmd, &all_clean); -if (r) { - *error ="dm_cache_metadata_all_clean() failed" ; - goto bad; - } - -if (!all_clean) { - *error ="Cannot enter passthrough mode unless all blocks are clean" ; - r = -EINVAL ; - goto bad; - } - +if (passthrough_mode (cache))policy_allow_migrations (cache->policy, false); - }spin_lock_init (&cache->lock);bio_list_init (&cache->deferred_bios);
@@ -2812,6 +2797,12 @@ static int load_mapping(void *context, dm_oblock_t oblock, dm_cblock_t cblock,struct cache *cache = context;if (dirty) { +if (passthrough_mode (cache)) { +DMERR ("%s: cannot enter passthrough mode unless all blocks are clean" , +cache_device_name (cache)); +return -EBUSY ; + } +set_bit (from_cblock (cblock), cache->dirty_bitset);atomic_inc (&cache->nr_dirty); }else
@@ -3045,7 +3036,7 @@ static int cache_preresume(struct dm_target *ti) load_filtered_mapping, cache);if (r) {DMERR ("%s: could not load cache mappings" ,cache_device_name (cache)); -if (r != -EFBIG ) +if (r != -EFBIG && r != -EBUSY )metadata_operation_failed (cache,"dm_cache_load_mappings" , r);return r; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 439/776 dm cache metadata: fix memory leak on metadata abort retry
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming-Hung Tsai <[email protected]>
[ Upstream commit 044ca491d4086dc5bf233e9fcb71db52df32f633 ]
When failing to acquire the root_lock in dm_cache_metadata_abort because the block_manager is read-only, the temporary block_manager created outside the root_lock is not properly released, causing a memory leak.
Reproduce steps:
This can be reproduced by reloading a new table while the metadata is read-only. While the second call to dm_cache_metadata_abort is caused by lack of support for table preload in dm-cache, mentioned in commit 9b1cc9f251af ("dm cache: share cache-metadata object across inactive and active DM tables"), it exposes the memory leak in dm_cache_metadata_abort when the function is called multiple times. Specifically, dm-cache fails to sync the new cache object's mode during preresume, creating the reproducer condition.
This issue could also occur through concurrent metadata_operation_failed calls due to races in cache mode updates, but the table preload scenario below provides a reliable reproducer.
1. Create a cache device with some faulty trailing metadata blocks
dmsetup create cmeta <<EOF
0 200 linear /dev/sdc 0
200 7992 error
EOF
dmsetup create cdata --table "0 131072 linear /dev/sdc 8192" dmsetup create corig --table "0 262144 linear /dev/sdc 262144" dd if=/dev/zero of=/dev/mapper/cmeta bs=4k count=1 oflag=direct dmsetup create cache --table "0 131072 cache /dev/mapper/cmeta \/dev/mapper/cdata /dev/mapper/corig 128 1 writethrough smq 0"
2. Suspend and resume the cache to start a new metadata transaction and trigger metadata io errors on the next metadata commit.
dmsetup suspend cache
dmsetup resume cache
3. Write to the cache device to update metadata
fio --filename=/dev/mapper/cache --name test --rw=randwrite --bs=4k \
--randrepeat=0 --direct=1 --size 64k
4. Preload the same table
dmsetup reload cache --table "$(dmsetup table cache)"
5. Resume the new table. This triggers the memory leak.
dmsetup suspend cache
dmsetup resume cache
kmemleak logs:
<snip>
unreferenced object 0xffff8880080c2010 (size 16):
comm "dmsetup", pid 132, jiffies 4294982580
hex dump (first 16 bytes):
00 38 b9 07 80 88 ff ff 6a 6b 6b 6b 6b 6b 6b a5 ...
backtrace (crc 3118f31c):
kmemleak_alloc+0x28/0x40
__kmalloc_cache_noprof+0x3d9/0x510
dm_block_manager_create+0x51/0x140
dm_cache_metadata_abort+0x85/0x320
metadata_operation_failed+0x103/0x1e0
cache_preresume+0xacd/0xe70
dm_table_resume_targets+0xd3/0x320
__dm_resume+0x1b/0xf0
dm_resume+0x127/0x170<snip>
--- drivers/md/dm-cache-metadata.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/md/dm-cache-metadata.c +8 -5
@@ -1017,6 +1017,12 @@ static bool cmd_write_lock(struct dm_cache_metadata *cmd)return ; \ } while(0) +#define WRITE_LOCK_OR_GOTO (cmd, label) \ + do { \ + if (!cmd_write_lock((cmd))) \ + goto label; \ + } while (0) +#define WRITE_UNLOCK (cmd) \ up_write(&(cmd)->root_lock)
@@ -1815,11 +1821,8 @@ int dm_cache_metadata_abort(struct dm_cache_metadata *cmd) new_bm =dm_block_manager_create (cmd->bdev,DM_CACHE_METADATA_BLOCK_SIZE <<SECTOR_SHIFT ,CACHE_MAX_CONCURRENT_LOCKS ); -WRITE_LOCK (cmd); -if (cmd->fail_io) { -WRITE_UNLOCK (cmd); - goto out; - } +/* cmd_write_lock() already checks fail_io with cmd->root_lock held */ +WRITE_LOCK_OR_GOTO (cmd, out);__destroy_persistent_data_objects (cmd, false); old_bm = cmd->bm;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 440/776 dm log: fix out-of-bounds write due to region_count overflow
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
[ Upstream commit c20e36b7631d83e7535877f08af8b0af72c44b1a ]
The local variable region_count in create_log_context() is declared as unsigned int (32-bit), but dm_sector_div_up() returns sector_t (64-bit). When a device-mapper target has a sufficiently large ti->len with a small region_size, the division result can exceed UINT_MAX. The truncated value is then used to calculate bitset_size, causing clean_bits, sync_bits, and recovering_bits to be allocated far smaller than needed for the actual number of regions.
Subsequent log operations (log_set_bit, log_clear_bit, log_test_bit) use region indices derived from the full untruncated region space, causing out-of-bounds writes to kernel heap memory allocated by vmalloc.
This can be reproduced by creating a mirror target whose region_count overflows 32 bits:
dmsetup create bigzero --table '0 8589934594 zero'
dmsetup create mymirror --table '0 8589934594 mirror \
core 2 2 nosync 2 /dev/mapper/bigzero 0 \
/dev/mapper/bigzero 0'The status output confirms the truncation (sync_count=1 instead of 4294967297, because 0x100000001 was truncated to 1):
$ dmsetup status mymirror 0 8589934594 mirror 2 254:1 254:1 1/4294967297 ...
This leads to a kernel crash in core_in_sync:
BUG: scheduling while atomic: (udev-worker)/9150/0x00000000 RIP: 0010:core_in_sync+0x14/0x30 [dm_log] CR2: 0000000000000008 Fixing recursive fault but reboot is needed!
Fix by widening the local region_count to sector_t and adding an explicit overflow check before the value is assigned to lc->region_count.
--- drivers/md/dm-log.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/md/dm-log.c +5 -1
@@ -368,7 +368,7 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,struct log_c *lc;uint32_t region_size; -unsigned int region_count; +sector_t region_count;size_t bitset_size, buf_size;int r;char dummy;
@@ -397,6 +397,10 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti, } region_count =dm_sector_div_up (ti->len, region_size); +if (region_count >UINT_MAX ) { +DMWARN ("region count exceeds limit of %u" ,UINT_MAX ); +return -EINVAL ; + } lc =kmalloc (sizeof (*lc),GFP_KERNEL );if (!lc) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 441/776 spi: fsl-qspi: Use reinit_completion() for repeated operations
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 981b080a79724738882b0af1c5bb7ade30d94f24 ]
The driver currently calls init_completion() during every spi_mem_op. Tchnically it may work, but it's not the recommended pattern.
According to the kernel documentation: Calling init_completion() on the same completion object twice is most likely a bug as it re-initializes the queue to an empty queue and enqueued tasks could get "lost" - use reinit_completion() in that case, but be aware of other races.
So moves the initial initialization to probe function and uses reinit_completion() for subsequent operations.
--- drivers/spi/spi-fsl-qspi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spi/spi-fsl-qspi.c +2 -1
@@ -607,7 +607,7 @@ static int fsl_qspi_do_op(struct fsl_qspi *q, const struct spi_mem_op *op)void __iomem *base = q->iobase;int err =0 ; -init_completion (&q->c); +reinit_completion (&q->c);/* * Always start the sequence at the same index since we update
@@ -913,6 +913,7 @@ static int fsl_qspi_probe(struct platform_device *pdev)if (ret <0 ) goto err_disable_clk; +init_completion (&q->c); ret =devm_request_irq (dev, ret, fsl_qspi_irq_handler,0 , pdev->name, q);if (ret) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 442/776 drm/sun4i: Fix resource leaks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ethan Tidmore <[email protected]>
[ Upstream commit 127367ad2e0f4870de60c6d719ae82ecf68d674c ]
Three clocks are not being released in devm_regmap_init_mmio() error path.
Add proper goto and set ret to the error code.
--- drivers/gpu/drm/sun4i/sun4i_backend.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/sun4i/sun4i_backend.c +2 -1
@@ -879,7 +879,8 @@ static int sun4i_backend_bind(struct device *dev, struct device *master, &sun4i_backend_regmap_config);if (IS_ERR (backend->engine.regs)) {dev_err (dev,"Couldn't create the backend regmap\n" ); -return PTR_ERR (backend->engine.regs); + ret =PTR_ERR (backend->engine.regs); + goto err_disable_ram_clk; }list_add_tail (&backend->engine.list, &drv->engine_list);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 443/776 dm init: ensure device probing has finished in dm-mod.waitfor=
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guillaume Gonnet <[email protected]>
[ Upstream commit 99a2312f69805f4ba92d98a757625e0300a747ab ]
The early_lookup_bdev() function returns successfully when the disk device is present but not necessarily its partitions. In this situation, dm_early_create() fails as the partition block device does not exist yet.
In my case, this phenomenon occurs quite often because the device is an SD card with slow reading times, on which kernel takes time to enumerate available partitions.
Fortunately, the underlying device is back to "probing" state while enumerating partitions. Waiting for all probing to end is enough to fix this issue.
That's also the reason why this problem never occurs with rootwait=
parameter: the while loop inside wait_for_root() explicitly waits for probing to be done and then the function calls async_synchronize_full(). These lines were omitted in 035641b, even though the commit says it's based on the rootwait logic...
Anyway, calling wait_for_device_probe() after our while loop does the job (it both waits for probing and calls async_synchronize_full).
--- drivers/md/dm-init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/dm-init.c +3 -1
@@ -302,8 +302,10 @@ static int __init dm_init_init(void) } } -if (waitfor[0 ]) +if (waitfor[0 ]) { +wait_for_device_probe ();DMINFO ("all devices available" ); + }list_for_each_entry (dev, &devices, list) { if (dm_early_create(&dev->dmi, dev->table,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 444/776 fbdev: matroxfb: Mark variable with __maybe_unused to avoid W=1 build break
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit caf6144053b4e1c815aa56afb54745a176f999df ]
Clang is not happy about set but unused variable:
drivers/video/fbdev/matrox/g450_pll.c:412:18: error: variable 'mnp' set but not used
412 | unsigned int mnp;
| ^
1 error generated.
Since the commit 7b987887f97b ("video: fbdev: matroxfb: remove dead code and set but not used variable") the 'mnp' became unused, but eliminating that code might have side-effects. The question here is what should we do with 'mnp'? The easiest way out is just mark it with __maybe_unused which will shut the compiler up and won't change any possible IO flow. So does this change.
A dive into the history of the driver:
The problem was revealed when the #if 0 guarded code along with unused pixel_vco variable was removed. That code was introduced in the original commit 213d22146d1f ("[PATCH] (1/3) matroxfb for 2.5.3"). And then guarded in the commit 705e41f82988 ("matroxfb DVI updates: Handle DVI output on G450/G550. Powerdown unused portions of G450/G550 DAC. Split G450/G550 DAC from older DAC1064 handling. Modify PLL setting when both CRTCs use same pixel clocks.").
NOTE: The two commits mentioned above pre-date Git era and available in history.git repository for archaeological purposes.
Even without that guard the modern compilers may see that the pixel_vco wasn't ever used and seems a leftover after some debug or review made 25 years ago.
The g450_mnp2vco() doesn't have any IO and as Jason said doesn't seem to have any side effects either than some unneeded CPU processing during runtime. I agree that's unlikely that timeout (or heating up the CPU) has any effect on the HW (GPU/display) functionality.
--- drivers/video/fbdev/matrox/g450_pll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/matrox/g450_pll.c +1 -1
@@ -407,7 +407,7 @@ static int __g450_setclk(struct matrox_fb_info *minfo, unsigned int fout,case M_VIDEO_PLL : {u_int8_t tmp; -unsigned int mnp; +unsigned int mnp__maybe_unused ;unsigned long flags;matroxfb_DAC_lock_irqsave (flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 445/776 spi: hisi-kunpeng: prevent infinite while() loop in hisi_spi_flush_fifo
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit 9f61daf2c2debe9f5cf4e1a4471e56a89a6fe45a ]
The hisi_spi_flush_fifo()'s inner while loop that lacks any timeout mechanism. Maybe the hardware never becomes empty, the loop will spin forever, causing the CPU to hang.
Fix this by adding a inner_limit based on loops_per_jiffy. The inner loop now exits after approximately one jiffy if the FIFO remains non-empty, logs a ratelimited warning, and breaks out of the outer loop. Additionally, add a cpu_relax() inside the busy loop to improve power efficiency.
--- drivers/spi/spi-hisi-kunpeng.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/spi/spi-hisi-kunpeng.c +11 -1
@@ -198,8 +198,18 @@ static void hisi_spi_flush_fifo(struct hisi_spi *hs)unsigned long limit = loops_per_jiffy <<1 ;do { -while (hisi_spi_rx_not_empty (hs)) +unsigned long inner_limit = loops_per_jiffy; + +while (hisi_spi_rx_not_empty (hs) && --inner_limit) {readl (hs->regs +HISI_SPI_DOUT ); +cpu_relax (); + } + +if (!inner_limit) { +dev_warn_ratelimited (hs->dev,"RX FIFO flush timeout\n" ); +break ; + } + }while (hisi_spi_busy (hs) && limit--); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 446/776 drm/msm/dsi: rename MSM8998 DSI version from V2_2_0 to V2_0_0
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Koskovich <[email protected]>
[ Upstream commit 913a709dea0eff9c7b2e9470f8c8594b9a0114ab ]
The MSM8998 DSI controller is v2.0.0 as stated in commit 7b8c9e203039 ("drm/msm/dsi: Add support for MSM8998 DSI controller"). The value was always correct just the name was wrong.
Rename and reorder to maintain version sorting.
Patchwork: https://patchwork.freedesktop.org/patch/713717/
--- drivers/gpu/drm/msm/dsi/dsi_cfg.c | 4 ++-- drivers/gpu/drm/msm/dsi/dsi_cfg.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/dsi/dsi_cfg.c +2 -2
@@ -268,10 +268,10 @@ static const struct msm_dsi_cfg_handler dsi_cfg_handlers[] = { &msm8996_dsi_cfg, &msm_dsi_6g_host_ops}, {MSM_DSI_VER_MAJOR_6G ,MSM_DSI_6G_VER_MINOR_V1_4_2 , &msm8976_dsi_cfg, &msm_dsi_6g_host_ops}, + {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_0_0, + &msm8998_dsi_cfg, &msm_dsi_6g_v2_host_ops}, {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_1_0, &sdm660_dsi_cfg, &msm_dsi_6g_v2_host_ops}, - {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_2_0, - &msm8998_dsi_cfg, &msm_dsi_6g_v2_host_ops}, {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_2_1, &sdm845_dsi_cfg, &msm_dsi_6g_v2_host_ops}, {MSM_DSI_VER_MAJOR_6G, MSM_DSI_6G_VER_MINOR_V2_3_0,
drivers/gpu/drm/msm/dsi/dsi_cfg.h +1 -1
@@ -18,8 +18,8 @@#define MSM_DSI_6G_VER_MINOR_V1_3_1 0x10030001#define MSM_DSI_6G_VER_MINOR_V1_4_1 0x10040001#define MSM_DSI_6G_VER_MINOR_V1_4_2 0x10040002 +#define MSM_DSI_6G_VER_MINOR_V2_0_0 0x20000000#define MSM_DSI_6G_VER_MINOR_V2_1_0 0x20010000 -#define MSM_DSI_6G_VER_MINOR_V2_2_0 0x20000000#define MSM_DSI_6G_VER_MINOR_V2_2_1 0x20020001#define MSM_DSI_6G_VER_MINOR_V2_3_0 0x20030000#define MSM_DSI_6G_VER_MINOR_V2_4_0 0x20040000
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 447/776 drm/panel: simple: Correct G190EAN01 prepare timing
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Reichel <[email protected]>
[ Upstream commit f1080f82570b797598c1ba7e9c800ae9e94aafc6 ]
The prepare timing specified by the G190EAN01 datasheet should be between 30 and 50 ms. Considering it might take some time for the LVDS encoder to enable the signal, we should only wait the min. required time in the panel driver and not the max. allowed time.
--- drivers/gpu/drm/panel/panel-simple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panel/panel-simple.c +1 -1
@@ -1388,7 +1388,7 @@ static const struct panel_desc auo_g190ean01 = { .height = 301, }, .delay = { - .prepare = 50, + .prepare = 30, .enable = 200, .disable = 110, .unprepare = 1000,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 448/776 ALSA: core: Validate compress device numbers without dynamic minors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
[ Upstream commit 796e119e9b14763be905ad0d023c71a14bc2e931 ]
Without CONFIG_SND_DYNAMIC_MINORS, ALSA reserves only two fixed minors for compress devices on each card: comprD0 and comprD1.
snd_find_free_minor() currently computes the compress minor as type + dev without validating dev first, so device numbers greater than 1 spill into the HWDEP minor range instead of failing registration.
ASoC passes rtd->id to snd_compress_new(), so this can happen on real non-dynamic-minor builds.
Add a dedicated fixed-minor check for SNDRV_DEVICE_TYPE_COMPRESS in snd_find_free_minor() and reject out-of-range device numbers with -EINVAL before constructing the minor.
Also remove the stale TODO in compress_offload.c that still claims multiple compress nodes are missing.
--- sound/core/compress_offload.c | 7 ------- sound/core/sound.c | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-)
sound/core/compress_offload.c +0 -7
@@ -40,13 +40,6 @@#define COMPR_CODEC_CAPS_OVERFLOW #endif -/* TODO: -* - add substream support for multiple devices in case of -* SND_DYNAMIC_MINORS is not used -* - Multiple node representation -* driver should be able to register multiple nodes -*/ -struct snd_compr_file {unsigned long caps;struct snd_compr_stream stream;
sound/core/sound.c +7 -0
@@ -219,9 +219,16 @@ static int snd_find_free_minor(int type, struct snd_card *card, int dev)case SNDRV_DEVICE_TYPE_RAWMIDI :case SNDRV_DEVICE_TYPE_PCM_PLAYBACK :case SNDRV_DEVICE_TYPE_PCM_CAPTURE : +if (snd_BUG_ON (!card)) +return -EINVAL ; + minor =SNDRV_MINOR (card->number, type + dev); +break ;case SNDRV_DEVICE_TYPE_COMPRESS :if (snd_BUG_ON (!card))return -EINVAL ; +if (dev <0 || + dev >=SNDRV_MINOR_HWDEP -SNDRV_MINOR_COMPRESS ) +return -EINVAL ; minor =SNDRV_MINOR (card->number, type + dev);break ;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 449/776 drm/amd/pm/ci: Use highest MCLK on CI when MCLK DPM is disabled
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 894f0d34d66cb47fe718fe2ae5c18729d22c5218 ]
When MCLK DPM is disabled for any reason, populate the MCLK table with the highest MCLK DPM level, so that the ASIC can use the highest possible memory clock to get good performance even when MCLK DPM is disabled.
--- drivers/gpu/drm/amd/pm/powerplay/smumgr/ci_smumgr.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/pm/powerplay/smumgr/ci_smumgr.c +8 -0
@@ -1321,6 +1321,14 @@ static int ci_populate_all_memory_levels(struct pp_hwmgr *hwmgr)return result; } +if (data->mclk_dpm_key_disabled && dpm_table->mclk_table.count) { +/* Populate the table with the highest MCLK level when MCLK DPM is disabled */ +for (i =0 ; i < dpm_table->mclk_table.count -1 ; i++) { + levels[i] = levels[dpm_table->mclk_table.count -1 ]; + levels[i].DisplayWatermark =PPSMC_DISPLAY_WATERMARK_HIGH ; + } + } + smu_data->smc_state_table.MemoryLevel[0 ].EnabledForActivity =1 ; dev_id = adev->pdev->device;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 450/776 drm/amd/pm/ci: Disable MCLK DPM on problematic CI ASICs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 9851f29cb06c09f7dad3867d8b0feec3fc71b6c8 ]
There are two known cases where MCLK DPM can causes issues:
Radeon R9 M380 found in iMac computers from 2015. The SMU in this GPU just hangs as soon as we send it the PPSMC_MSG_MCLKDPM_Enable command, even when MCLK switching is disabled, and even when we only populate one MCLK DPM level. Apply workaround to all devices with the same subsystem ID.
Radeon R7 260X due to old memory controller microcode. We only flash the MC ucode when it isn't set up by the VBIOS, therefore there is no way to make sure that it has the correct ucode version.
I verified that this patch fixes the SMU hang on the R9 M380 which would previously fail to boot. This also fixes the UVD initialization error on that GPU which happened because the SMU couldn't ungate the UVD after it hung.
--- drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/hwmgr.c +15 -0
@@ -104,6 +104,21 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr) PP_GFXOFF_MASK); hwmgr->pp_table_version =PP_TABLE_V0 ; hwmgr->od_enabled = false; +switch (hwmgr->chip_id) { +case CHIP_BONAIRE : +/* R9 M380 in iMac 2015: SMU hangs when enabling MCLK DPM +* R7 260X cards with old MC ucode: MCLK DPM is unstable +*/ +if (adev->pdev->subsystem_vendor ==0x106B || + adev->pdev->device ==0x6658 ) { +dev_info (adev->dev,"disabling MCLK DPM on quirky ASIC" ); + adev->pm.pp_feature &= ~PP_MCLK_DPM_MASK ; + hwmgr->feature_mask &= ~PP_MCLK_DPM_MASK ; + } +break ; +default : +break ; + }smu7_init_function_pointers (hwmgr);break ;case AMDGPU_FAMILY_CZ :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 451/776 drm/amd/pm/smu7: Fix SMU7 voltage dependency on display clock
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 0138610c14130425be53423b35336561829965e0 ]
The DCE (display controller engine) requires a minimum voltage in order to function correctly, depending on which clock level it currently uses.
Add a new table that contains display clock frequency levels and the corresponding required voltages. The clock frequency levels are taken from DC (and the old radeon driver's voltage dependency table for CI in cases where its values were lower). The voltage levels are taken from the following function:phm_initializa_dynamic_state_adjustment_rule_settings(). Furthermore, in case of CI, call smu7_patch_vddc() on the new table to account for leakage voltage (like in radeon).
Use the display clock value from amd_pp_display_configuration to look up the voltage level needed by the DCE. Send the voltage to the SMU via the PPSMC_MSG_VddC_Request command.
The previous implementation of this feature was non-functional because it relied on a "dal_power_level" field which was never assigned; and it was not at all implemented for CI ASICs.
I verified this on a Radeon R9 M380 which previously booted to a black screen with DC enabled (default since Linux 6.19), but now works correctly.
--- drivers/gpu/drm/amd/pm/inc/hwmgr.h | 1 + .../drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c | 88 ++++++++++++++++++- 2 files changed, 86 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/pm/inc/hwmgr.h +1 -0
@@ -635,6 +635,7 @@ struct phm_dynamic_state_info {struct phm_clock_voltage_dependency_table *vddci_dependency_on_mclk;struct phm_clock_voltage_dependency_table *vddc_dependency_on_mclk;struct phm_clock_voltage_dependency_table *mvdd_dependency_on_mclk; +struct phm_clock_voltage_dependency_table *vddc_dependency_on_display_clock;struct phm_clock_voltage_dependency_table *vddc_dep_on_dal_pwrl;struct phm_clock_array *valid_sclk_values;struct phm_clock_array *valid_mclk_values;
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c +85 -3
122 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 452/776 drm/amd/pm/ci: Fix powertune defaults for Hawaii 0x67B0
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit d784759c07924280f3c313f205fc48eb62d7cb71 ]
There is no AMD GPU with the ID 0x66B0, this looks like a typo. It should be 0x67B0 which is actually part of the PCI ID list, and should use the Hawaii XT powertune defaults according to the old radeon driver.
--- drivers/gpu/drm/amd/pm/powerplay/smumgr/ci_smumgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/powerplay/smumgr/ci_smumgr.c +1 -1
@@ -244,7 +244,7 @@ static void ci_initialize_power_tune_defaults(struct pp_hwmgr *hwmgr) smu_data->power_tune_defaults = &defaults_hawaii_pro;break ;case 0x67B8 : -case 0x66B0 : +case 0x67B0 : smu_data->power_tune_defaults = &defaults_hawaii_xt;break ;case 0x6640 :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 453/776 drm/amd/pm/ci: Clear EnabledForActivity field for memory levels
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 5facfd4c4c67e8500116ffec0d9da35d92b9c787 ]
Follow what radeon did and what amdgpu does for other GPUs with SMU7.
--- drivers/gpu/drm/amd/pm/powerplay/smumgr/ci_smumgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/powerplay/smumgr/ci_smumgr.c +1 -1
@@ -1216,7 +1216,7 @@ static int ci_populate_single_memory_level( } memory_level->EnabledForThrottle =1 ; - memory_level->EnabledForActivity =1 ; + memory_level->EnabledForActivity =0 ; memory_level->UpH = data->current_profile_setting.mclk_up_hyst; memory_level->DownH = data->current_profile_setting.mclk_down_hyst; memory_level->VoltageDownH =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 454/776 drm/amd/pm/ci: Fill DW8 fields from SMC
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit baf28ec5795c077406d6f52b8ad39e614153bce6 ]
In ci_populate_dw8() we currently just read a value from the SMU and then throw it away. Instead of throwing away the value, we should use it to fill other fields in DW8 (like radeon).
Otherwise the value of the other fiels is just cleared when we copy this data to the SMU later.
--- drivers/gpu/drm/amd/pm/powerplay/smumgr/ci_smumgr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/smumgr/ci_smumgr.c +1 -2
@@ -542,12 +542,11 @@ static int ci_populate_dw8(struct pp_hwmgr *hwmgr, uint32_t fuse_table_offset) {struct ci_smumgr *smu_data = (struct ci_smumgr *)(hwmgr->smu_backend);const struct ci_pt_defaults *defaults = smu_data->power_tune_defaults; -uint32_t temp;if (ci_read_smc_sram_dword (hwmgr, fuse_table_offset + offsetof(SMU7_Discrete_PmFuses , TdcWaterfallCtl), - (uint32_t *)&temp,SMC_RAM_END )) + (uint32_t *)&smu_data->power_tune_table.TdcWaterfallCtl,SMC_RAM_END ))PP_ASSERT_WITH_CODE (false,"Attempt to read PmFuses.DW6 (SviLoadLineEn) from SMC Failed!" , return -EINVAL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 455/776 drm/amd/pm/smu7: Add SCLK cap for quirky Hawaii board
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Timur Kristóf <[email protected]>
[ Upstream commit 4724bc5b8d78c34b993594f9406135408ccb312a ]
On a specific Radeon R9 390X board, the GPU can "randomly" hang while gaming. Initially I thought this was a RADV bug and tried to work around this in Mesa:
commit 8ea08747b86b ("radv: Mitigate GPU hang on Hawaii in Dota 2 and RotTR")
However, I got some feedback from other users who are reporting that the above mitigation causes a significant performance regression for them, and they didn't experience the hang on their GPU in the first place.
After some further investigation, it turns out that the problem is that the highest SCLK DPM level on this board isn't stable. Lowering SCLK to 1040 MHz (from 1070 MHz) works around the issue, and has a negligible impact on performance compared to the Mesa patch. (Note that increasing the voltage can also work around it, but we felt that lowering the SCLK is the safer option.)
To solve the above issue, add an "sclk_cap" field to smu7_hwmgr and set this field for the affected board. The capped SCLK value correctly appears on the sysfs interface and shows up in GUI tools such as LACT.
--- .../drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c | 30 ++++++++++++++++--- .../drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.h | 1 + 2 files changed, 27 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c +26 -4
@@ -788,7 +788,7 @@ static int smu7_setup_dpm_tables_v0(struct pp_hwmgr *hwmgr) hwmgr->dyn_state.vddc_dependency_on_mclk;struct phm_cac_leakage_table *std_voltage_table = hwmgr->dyn_state.cac_leakage_table; -uint32_t i; +uint32_t i, clk;PP_ASSERT_WITH_CODE (allowed_vdd_sclk_table !=NULL ,"SCLK dependency table is missing. This table is mandatory" , return -EINVAL );
@@ -805,10 +805,12 @@ static int smu7_setup_dpm_tables_v0(struct pp_hwmgr *hwmgr) data->dpm_table.sclk_table.count =0 ;for (i =0 ; i < allowed_vdd_sclk_table->count; i++) { + clk =min (allowed_vdd_sclk_table->entries[i].clk, data->sclk_cap); +if (i ==0 || data->dpm_table.sclk_table.dpm_levels[data->dpm_table.sclk_table.count-1 ].value != - allowed_vdd_sclk_table->entries[i].clk) { + clk) { data->dpm_table.sclk_table.dpm_levels[data->dpm_table.sclk_table.count].value = - allowed_vdd_sclk_table->entries[i].clk; + clk; data->dpm_table.sclk_table.dpm_levels[data->dpm_table.sclk_table.count].enabled = (i ==0 ) ?1 :0 ; data->dpm_table.sclk_table.count++; }
@@ -2956,6 +2958,25 @@ static int smu7_init_voltage_dependency_on_display_clock_table(struct pp_hwmgr *return 0 ; } +static void smu7_set_sclk_cap (struct pp_hwmgr *hwmgr) +{ +struct amdgpu_device *adev = hwmgr->adev; +struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend); + + data->sclk_cap =0xffffffff ; + +if (hwmgr->od_enabled) +return ; + +/* R9 390X board: last sclk dpm level is unstable, use lower sclk */ +if (adev->pdev->device ==0x67B0 && + adev->pdev->subsystem_vendor ==0x1043 ) + data->sclk_cap =104000 ;/* 1040 MHz */ + +if (data->sclk_cap !=0xffffffff ) +dev_info (adev->dev,"sclk cap: %u kHz on quirky ASIC\n" , data->sclk_cap *10 ); +} +static int smu7_hwmgr_backend_init (struct pp_hwmgr *hwmgr) {struct amdgpu_device *adev = hwmgr->adev;
@@ -2967,6 +2988,7 @@ static int smu7_hwmgr_backend_init(struct pp_hwmgr *hwmgr)return -ENOMEM ; hwmgr->backend = data; +smu7_set_sclk_cap (hwmgr);smu7_patch_voltage_workaround (hwmgr);smu7_init_dpm_defaults (hwmgr);
@@ -3868,7 +3890,7 @@ static int smu7_get_pp_table_entry_callback_func_v0(struct pp_hwmgr *hwmgr,/* Performance levels are arranged from low to high. */ performance_level->memory_clock = memory_clock; - performance_level->engine_clock = engine_clock; + performance_level->engine_clock =min (engine_clock, data->sclk_cap); pcie_gen_from_bios = visland_clk_info->ucPCIEGen;
drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.h +1 -0
@@ -234,6 +234,7 @@ struct smu7_hwmgr {uint32_t pcie_gen_cap;uint32_t pcie_lane_cap;uint32_t pcie_spc_cap; +uint32_t sclk_cap;struct smu7_leakage_voltage vddc_leakage;struct smu7_leakage_voltage vddci_leakage;struct smu7_leakage_voltage vddcgfx_leakage;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 456/776 ALSA: hda/realtek: Whitespace fix
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luke D. Jones <[email protected]>
[ Upstream commit 72cea3a3175b50a4875b3c112fb13df20c6218a5 ]
Remove an erroneous whitespace.
Stable-dep-of: d1888bf848ad ("ALSA: hda/realtek: fix code style (ERROR: else should follow close brace '}')")
--- sound/pci/hda/patch_realtek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/hda/patch_realtek.c +1 -1
@@ -6011,7 +6011,7 @@ static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,struct alc_spec *spec = codec->spec; spec->parse_flags |=HDA_PINCFG_HEADSET_MIC ;alc255_set_default_jack_type (codec); - } + }else alc_fixup_headset_mode (codec, fix, action); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 457/776 ALSA: hda/realtek: fix code style (ERROR: else should follow close brace })
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lei Huang <[email protected]>
[ Upstream commit d1888bf848ade6a9e71c7ba516fd215aa1bd8d65 ]
Fix checkpatch code style errors:
ERROR: else should follow close brace '}' #2300: FILE: sound/hda/codecs/realtek/alc269.c:2300:
+ }
+ else
--- sound/pci/hda/patch_realtek.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/pci/hda/patch_realtek.c +2 -2
@@ -6011,9 +6011,9 @@ static void alc_fixup_headset_mode_alc255_no_hp_mic(struct hda_codec *codec,struct alc_spec *spec = codec->spec; spec->parse_flags |=HDA_PINCFG_HEADSET_MIC ;alc255_set_default_jack_type (codec); - } -else + }else {alc_fixup_headset_mode (codec, fix, action); + } } static void alc288_update_headset_jack_cb(struct hda_codec *codec,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 458/776 drm/msm/a6xx: Fix HLSQ register dumping
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Clark <[email protected]>
[ Upstream commit c289a6db9ba6cb974f0317da142e4f665d589566 ]
Fix the bitfield offset of HLSQ_READ_SEL state-type bitfield. Otherwise we are always reading TP state when we wanted SP or HLSQ state.
Patchwork: https://patchwork.freedesktop.org/patch/714236/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c +1 -1
@@ -642,7 +642,7 @@ static void a6xx_get_crashdumper_hlsq_registers(struct msm_gpu *gpu,u64 out = dumper->iova +A6XX_CD_DATA_OFFSET ;int i, regcount =0 ; - in +=CRASHDUMP_WRITE (in,REG_A6XX_HLSQ_DBG_READ_SEL , regs->val1); + in +=CRASHDUMP_WRITE (in,REG_A6XX_HLSQ_DBG_READ_SEL , (regs->val1 &0xff ) <<8 );for (i =0 ; i < regs->count; i +=2 ) {u32 count =RANGE (regs->registers, i);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 459/776 drm/msm/a6xx: Use barriers while updating HFI Q headers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Akhil P Oommen <[email protected]>
[ Upstream commit dc78b35d5ec09d1b0b8a937e6e640d2c5a030915 ]
To avoid harmful compiler optimizations and IO reordering in the HW, use barriers and READ/WRITE_ONCE helpers as necessary while accessing the HFI queue index variables.
Patchwork: https://patchwork.freedesktop.org/patch/714653/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a6xx_hfi.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_hfi.c +10 -4
@@ -29,7 +29,7 @@ static int a6xx_hfi_queue_read(struct a6xx_gmu *gmu,struct a6xx_hfi_queue_header *header = queue->header;u32 i, hdr, index = header->read_index; -if (header->read_index == header->write_index) { +if (header->read_index ==READ_ONCE (header->write_index)) { header->rx_request =1 ;return 0 ; }
@@ -55,7 +55,10 @@ static int a6xx_hfi_queue_read(struct a6xx_gmu *gmu,if (!gmu->legacy) index =ALIGN (index,4 ) % header->size; - header->read_index = index; +/* Ensure all memory operations are complete before updating the read index */ +dma_mb (); + +WRITE_ONCE (header->read_index, index);return HFI_HEADER_SIZE (hdr); }
@@ -67,7 +70,7 @@ static int a6xx_hfi_queue_write(struct a6xx_gmu *gmu,spin_lock (&queue->lock); - space =CIRC_SPACE (header->write_index, header->read_index, + space =CIRC_SPACE (header->write_index,READ_ONCE (header->read_index), header->size);if (space < dwords) { header->dropped++;
@@ -86,7 +89,10 @@ static int a6xx_hfi_queue_write(struct a6xx_gmu *gmu, queue->data[index] =0xfafafafa ; } - header->write_index = index; +/* Ensure all memory operations are complete before updating the write index */ +dma_mb (); + +WRITE_ONCE (header->write_index, index);spin_unlock (&queue->lock);gmu_write (gmu,REG_A6XX_GMU_HOST2GMU_INTR_SET ,0x01 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 460/776 pmdomain: ti: omap_prm: Fix a reference leak on device node
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 44c28e1c52764fef6dd1c1ada3a248728812e67f ]
When calling of_parse_phandle_with_args(), the caller is responsible to call of_node_put() to release the reference of device node. In omap_prm_domain_attach_dev, it does not release the reference.
--- drivers/soc/ti/omap_prm.c | 1 + 1 file changed, 1 insertion(+)
drivers/soc/ti/omap_prm.c +1 -0
@@ -656,6 +656,7 @@ static int omap_prm_domain_attach_dev(struct generic_pm_domain *domain,if (pd_args.args_count !=0 )dev_warn (dev,"%s: unusupported #power-domain-cells: %i\n" , prmd->pd.name, pd_args.args_count); +of_node_put (pd_args.np); genpd_data =dev_gpd_data (dev); genpd_data->data =NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 461/776 pmdomain: imx: scu-pd: Fix device_node reference leak during ->probe()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit c8e9b6a55702be6c6d034e973d519c52c3848415 ]
When calling of_parse_phandle_with_args(), the caller is responsible to call of_node_put() to release the reference of device node. In imx_sc_pd_get_console_rsrc(), it does not release the reference.
--- drivers/firmware/imx/scu-pd.c | 1 + 1 file changed, 1 insertion(+)
drivers/firmware/imx/scu-pd.c +1 -0
@@ -231,6 +231,7 @@ static void imx_sc_pd_get_console_rsrc(void)return ; imx_con_rsrc = specs.args[0 ]; +of_node_put (specs.np); }static int imx_sc_pd_power (struct generic_pm_domain *domain,bool power_on)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 462/776 ASoC: fsl_xcvr: Fix event generation in fsl_xcvr_arc_mode_put()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengjiu Wang <[email protected]>
[ Upstream commit 1b61c8103c9317a9c37fe544c2d83cee1c281149 ]
ALSA controls should return 1 if the value in the control changed but the control put operation fsl_xcvr_arc_mode_put() only returns 0 or a negative error code, causing ALSA to not generate any change events.
Add a suitable check in the function before updating the arc_mode variable.
--- sound/soc/fsl/fsl_xcvr.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
sound/soc/fsl/fsl_xcvr.c +9 -2
@@ -97,10 +97,17 @@ static int fsl_xcvr_arc_mode_put(struct snd_kcontrol *kcontrol,struct fsl_xcvr *xcvr =snd_soc_dai_get_drvdata (dai);struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;unsigned int *item = ucontrol->value.enumerated.item; +int val =snd_soc_enum_item_to_val (e, item[0 ]); +int ret; - xcvr->arc_mode =snd_soc_enum_item_to_val (e, item[0 ]); +if (val <0 || val >1 ) +return -EINVAL ; -return 0 ; + ret = (xcvr->arc_mode != val); + + xcvr->arc_mode = val; + +return ret; } static int fsl_xcvr_arc_mode_get(struct snd_kcontrol *kcontrol,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 463/776 ASoC: fsl_xcvr: Fix event generation in fsl_xcvr_mode_put()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengjiu Wang <[email protected]>
[ Upstream commit 64a496ba976324615b845d60739dfcdae3d57434 ]
ALSA controls should return 1 if the value in the control changed but the control put operation fsl_xcvr_mode_put() only returns 0 or a negative error code, causing ALSA to not generate any change events.
Add a suitable check in the function before updating the mode variable.
--- sound/soc/fsl/fsl_xcvr.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
sound/soc/fsl/fsl_xcvr.c +9 -2
@@ -205,10 +205,17 @@ static int fsl_xcvr_mode_put(struct snd_kcontrol *kcontrol,struct fsl_xcvr *xcvr =snd_soc_dai_get_drvdata (dai);struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;unsigned int *item = ucontrol->value.enumerated.item; +int val =snd_soc_enum_item_to_val (e, item[0 ]);struct snd_soc_card *card = dai->component->card;struct snd_soc_pcm_runtime *rtd; +int ret; + +if (val <FSL_XCVR_MODE_SPDIF || val >FSL_XCVR_MODE_EARC ) +return -EINVAL ; - xcvr->mode =snd_soc_enum_item_to_val (e, item[0 ]); + ret = (xcvr->mode != val); + + xcvr->mode = val;fsl_xcvr_activate_ctl (dai, fsl_xcvr_arc_mode_kctl.name, (xcvr->mode ==FSL_XCVR_MODE_ARC ));
@@ -218,7 +225,7 @@ static int fsl_xcvr_mode_put(struct snd_kcontrol *kcontrol, rtd =snd_soc_get_pcm_runtime (card, card->dai_link); rtd->pcm->streams[SNDRV_PCM_STREAM_PLAYBACK ].substream_count = (xcvr->mode ==FSL_XCVR_MODE_SPDIF ?1 :0 ); -return 0 ; +return ret; } static int fsl_xcvr_mode_get(struct snd_kcontrol *kcontrol,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 464/776 ASoC: fsl_easrc: Check the variable range in fsl_easrc_iec958_put_bits()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengjiu Wang <[email protected]>
[ Upstream commit 00541b86fb578d4949cfdd6aff1f82d43fcf07af ]
Add check of input value's range in fsl_easrc_iec958_put_bits(), otherwise the wrong value may be written from user space.
--- sound/soc/fsl/fsl_easrc.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/fsl/fsl_easrc.c +3 -0
@@ -54,6 +54,9 @@ static int fsl_easrc_iec958_put_bits(struct snd_kcontrol *kcontrol,unsigned int regval = ucontrol->value.integer.value[0 ];int ret; +if (regval <EASRC_WIDTH_16_BIT || regval >EASRC_WIDTH_24_BIT ) +return -EINVAL ; + ret = (easrc_priv->bps_iec958[mc->regbase] != regval); easrc_priv->bps_iec958[mc->regbase] = regval;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 465/776 ASoC: fsl_easrc: Fix value type in fsl_easrc_iec958_get_bits()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengjiu Wang <[email protected]>
[ Upstream commit aa21fe4a81458cf469c2615b08cbde5997dde25a ]
The value type of controls "Context 0 IEC958 Bits Per Sample" should be integer, not enumerated, the issue is found by the mixer-test.
--- sound/soc/fsl/fsl_easrc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/fsl/fsl_easrc.c +1 -1
@@ -73,7 +73,7 @@ static int fsl_easrc_iec958_get_bits(struct snd_kcontrol *kcontrol,struct soc_mreg_control *mc = (struct soc_mreg_control *)kcontrol->private_value; - ucontrol->value.enumerated.item[0 ] = easrc_priv->bps_iec958[mc->regbase]; + ucontrol->value.integer.value[0 ] = easrc_priv->bps_iec958[mc->regbase];return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 466/776 ASoC: fsl_easrc: Change the type for iec958 channel status controls
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengjiu Wang <[email protected]>
[ Upstream commit 47f28a5bd154a95d5aa563dde02a801bd32ddb81 ]
Use the type SNDRV_CTL_ELEM_TYPE_IEC958 for iec958 channel status controls, the original type will cause mixer-test to iterate all 32bit values, which costs a lot of time. And using IEC958 type can reduce the control numbers.
Also enable pm runtime before updating registers to make the regmap cache data align with the value in hardware.
--- sound/soc/fsl/fsl_easrc.c | 118 +++++++++++++++++++++++++++----------- 1 file changed, 84 insertions(+), 34 deletions(-)
sound/soc/fsl/fsl_easrc.c +84 -34
@@ -78,17 +78,47 @@ static int fsl_easrc_iec958_get_bits(struct snd_kcontrol *kcontrol,return 0 ; } +static int fsl_easrc_iec958_info (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_info *uinfo) +{ + uinfo->type =SNDRV_CTL_ELEM_TYPE_IEC958 ; + uinfo->count =1 ; +return 0 ; +} +static int fsl_easrc_get_reg (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) {struct snd_soc_component *component =snd_kcontrol_chip (kcontrol);struct soc_mreg_control *mc = (struct soc_mreg_control *)kcontrol->private_value; -unsigned int regval; +struct fsl_asrc *easrc =snd_soc_component_get_drvdata (component); +unsigned int *regval = (unsigned int *)ucontrol->value.iec958.status; +int ret; + + ret =regmap_read (easrc->regmap,REG_EASRC_CS0 (mc->regbase), ®val[0 ]); +if (ret) +return ret; + + ret =regmap_read (easrc->regmap,REG_EASRC_CS1 (mc->regbase), ®val[1 ]); +if (ret) +return ret; + + ret =regmap_read (easrc->regmap,REG_EASRC_CS2 (mc->regbase), ®val[2 ]); +if (ret) +return ret; - regval =snd_soc_component_read (component, mc->regbase); + ret =regmap_read (easrc->regmap,REG_EASRC_CS3 (mc->regbase), ®val[3 ]); +if (ret) +return ret; + + ret =regmap_read (easrc->regmap,REG_EASRC_CS4 (mc->regbase), ®val[4 ]); +if (ret) +return ret; - ucontrol->value.integer.value[0 ] = regval; + ret =regmap_read (easrc->regmap,REG_EASRC_CS5 (mc->regbase), ®val[5 ]); +if (ret) +return ret;return 0 ; }
@@ -100,22 +130,62 @@ static int fsl_easrc_set_reg(struct snd_kcontrol *kcontrol,struct soc_mreg_control *mc = (struct soc_mreg_control *)kcontrol->private_value;struct fsl_asrc *easrc =snd_soc_component_get_drvdata (component); -unsigned int regval = ucontrol->value.integer.value[0 ]; -bool changed; +unsigned int *regval = (unsigned int *)ucontrol->value.iec958.status; +bool changed, changed_all = false;int ret; - ret =regmap_update_bits_check (easrc->regmap, mc->regbase, -GENMASK (31 ,0 ), regval, &changed); -if (ret !=0 ) + ret =pm_runtime_resume_and_get (component->dev); +if (ret)return ret; -return changed; + ret =regmap_update_bits_check (easrc->regmap,REG_EASRC_CS0 (mc->regbase), +GENMASK (31 ,0 ), regval[0 ], &changed); +if (ret !=0 ) + goto err; + changed_all |= changed; + + ret =regmap_update_bits_check (easrc->regmap,REG_EASRC_CS1 (mc->regbase), +GENMASK (31 ,0 ), regval[1 ], &changed); +if (ret !=0 ) + goto err; + changed_all |= changed; + + ret =regmap_update_bits_check (easrc->regmap,REG_EASRC_CS2 (mc->regbase), +GENMASK (31 ,0 ), regval[2 ], &changed); +if (ret !=0 ) + goto err; + changed_all |= changed; + + ret =regmap_update_bits_check (easrc->regmap,REG_EASRC_CS3 (mc->regbase), +GENMASK (31 ,0 ), regval[3 ], &changed); +if (ret !=0 ) + goto err; + changed_all |= changed; + + ret =regmap_update_bits_check (easrc->regmap,REG_EASRC_CS4 (mc->regbase), +GENMASK (31 ,0 ), regval[4 ], &changed); +if (ret !=0 ) + goto err; + changed_all |= changed; + + ret =regmap_update_bits_check (easrc->regmap,REG_EASRC_CS5 (mc->regbase), +GENMASK (31 ,0 ), regval[5 ], &changed); +if (ret !=0 ) + goto err; + changed_all |= changed; +err: +pm_runtime_put_autosuspend (component->dev); + +if (ret !=0 ) +return ret; +else +return changed_all; }#define SOC_SINGLE_REG_RW (xname, xreg) \ { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .name = (xname), \ .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \ - .info = snd_soc_info_xr_sx, .get = fsl_easrc_get_reg, \ + .info = fsl_easrc_iec958_info, .get = fsl_easrc_get_reg, \ .put = fsl_easrc_set_reg, \ .private_value = (unsigned long)&(struct soc_mreg_control) \ { .regbase = xreg, .regcount = 1, .nbits = 32, \
@@ -146,30 +216,10 @@ static const struct snd_kcontrol_new fsl_easrc_snd_controls[] = {SOC_SINGLE_VAL_RW ("Context 2 IEC958 Bits Per Sample" ,2 ),SOC_SINGLE_VAL_RW ("Context 3 IEC958 Bits Per Sample" ,3 ), -SOC_SINGLE_REG_RW ("Context 0 IEC958 CS0" ,REG_EASRC_CS0 (0 )), -SOC_SINGLE_REG_RW ("Context 1 IEC958 CS0" ,REG_EASRC_CS0 (1 )), -SOC_SINGLE_REG_RW ("Context 2 IEC958 CS0" ,REG_EASRC_CS0 (2 )), -SOC_SINGLE_REG_RW ("Context 3 IEC958 CS0" ,REG_EASRC_CS0 (3 )), -SOC_SINGLE_REG_RW ("Context 0 IEC958 CS1" ,REG_EASRC_CS1 (0 )), -SOC_SINGLE_REG_RW ("Context 1 IEC958 CS1" ,REG_EASRC_CS1 (1 )), -SOC_SINGLE_REG_RW ("Context 2 IEC958 CS1" ,REG_EASRC_CS1 (2 )), -SOC_SINGLE_REG_RW ("Context 3 IEC958 CS1" ,REG_EASRC_CS1 (3 )), -SOC_SINGLE_REG_RW ("Context 0 IEC958 CS2" ,REG_EASRC_CS2 (0 )), -SOC_SINGLE_REG_RW ("Context 1 IEC958 CS2" ,REG_EASRC_CS2 (1 )), -SOC_SINGLE_REG_RW ("Context 2 IEC958 CS2" ,REG_EASRC_CS2 (2 )), -SOC_SINGLE_REG_RW ("Context 3 IEC958 CS2" ,REG_EASRC_CS2 (3 )), -SOC_SINGLE_REG_RW ("Context 0 IEC958 CS3" ,REG_EASRC_CS3 (0 )), -SOC_SINGLE_REG_RW ("Context 1 IEC958 CS3" ,REG_EASRC_CS3 (1 )), -SOC_SINGLE_REG_RW ("Context 2 IEC958 CS3" ,REG_EASRC_CS3 (2 )), -SOC_SINGLE_REG_RW ("Context 3 IEC958 CS3" ,REG_EASRC_CS3 (3 )), -SOC_SINGLE_REG_RW ("Context 0 IEC958 CS4" ,REG_EASRC_CS4 (0 )), -SOC_SINGLE_REG_RW ("Context 1 IEC958 CS4" ,REG_EASRC_CS4 (1 )), -SOC_SINGLE_REG_RW ("Context 2 IEC958 CS4" ,REG_EASRC_CS4 (2 )), -SOC_SINGLE_REG_RW ("Context 3 IEC958 CS4" ,REG_EASRC_CS4 (3 )), -SOC_SINGLE_REG_RW ("Context 0 IEC958 CS5" ,REG_EASRC_CS5 (0 )), -SOC_SINGLE_REG_RW ("Context 1 IEC958 CS5" ,REG_EASRC_CS5 (1 )), -SOC_SINGLE_REG_RW ("Context 2 IEC958 CS5" ,REG_EASRC_CS5 (2 )), - SOC_SINGLE_REG_RW("Context 3 IEC958 CS5", REG_EASRC_CS5(3)), +SOC_SINGLE_REG_RW ("Context 0 IEC958 CS" ,0 ), +SOC_SINGLE_REG_RW ("Context 1 IEC958 CS" ,1 ), +SOC_SINGLE_REG_RW ("Context 2 IEC958 CS" ,2 ), + SOC_SINGLE_REG_RW("Context 3 IEC958 CS", 3), };/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 467/776 PCI: Enable AtomicOps only if Root Port supports them
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gerd Bayer <[email protected]>
[ Upstream commit 1ae8c4ce157037e266184064a182af9ef9af278b ]
When inspecting the config space of a Connect-X physical function in an s390 system after it was initialized by the mlx5_core device driver, we found the function to be enabled to request AtomicOps despite the Root Port lacking support for completing them:
00:00.1 Ethernet controller: Mellanox Technologies MT2894 Family [ConnectX-6 Lx]
Subsystem: Mellanox Technologies Device 0002
DevCtl2: Completion Timeout: 50us to 50ms, TimeoutDis-
AtomicOpsCtl: ReqEn+
On s390 and many virtualized guests, the Endpoint is visible but the Root Port is not. In this case, pci_enable_atomic_ops_to_root() previously enabled AtomicOps in the Endpoint even though it can't tell whether the Root Port supports them as a completer.
Change pci_enable_atomic_ops_to_root() to fail if there's no Root Port or the Root Port doesn't support AtomicOps.
--- drivers/pci/pci.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-)
drivers/pci/pci.c +20 -21
@@ -3742,8 +3742,7 @@ int pci_rebar_set_size(struct pci_dev *pdev, int bar, int size)*/ int pci_enable_atomic_ops_to_root (struct pci_dev *dev,u32 cap_mask) { -struct pci_bus *bus = dev->bus; -struct pci_dev *bridge; +struct pci_dev *root, *bridge;u32 cap, ctl2;/*
@@ -3773,35 +3772,35 @@ int pci_enable_atomic_ops_to_root(struct pci_dev *dev, u32 cap_mask)return -EINVAL ; } -while (bus->parent) { - bridge = bus->self; + root =pcie_find_root_port (dev); +if (!root) +return -EINVAL ; -pcie_capability_read_dword (bridge,PCI_EXP_DEVCAP2 , &cap); +pcie_capability_read_dword (root,PCI_EXP_DEVCAP2 , &cap); +if ((cap & cap_mask) != cap_mask) +return -EINVAL ; + bridge =pci_upstream_bridge (dev); +while (bridge != root) {switch (pci_pcie_type (bridge)) { -/* Ensure switch ports support AtomicOp routing */ case PCI_EXP_TYPE_UPSTREAM : -case PCI_EXP_TYPE_DOWNSTREAM : -if (!(cap &PCI_EXP_DEVCAP2_ATOMIC_ROUTE )) -return -EINVAL ; -break ; - -/* Ensure root port supports all the sizes we care about */ -case PCI_EXP_TYPE_ROOT_PORT : -if ((cap & cap_mask) != cap_mask) -return -EINVAL ; -break ; - } - -/* Ensure upstream ports don't block AtomicOps on egress */ -if (pci_pcie_type (bridge) ==PCI_EXP_TYPE_UPSTREAM ) { +/* Upstream ports must not block AtomicOps on egress */ pcie_capability_read_dword (bridge,PCI_EXP_DEVCTL2 , &ctl2);if (ctl2 &PCI_EXP_DEVCTL2_ATOMIC_EGRESS_BLOCK )return -EINVAL ; + fallthrough; + +/* All switch ports need to route AtomicOps */ +case PCI_EXP_TYPE_DOWNSTREAM : +pcie_capability_read_dword (bridge,PCI_EXP_DEVCAP2 , + &cap); +if (!(cap &PCI_EXP_DEVCAP2_ATOMIC_ROUTE )) +return -EINVAL ; +break ; } - bus = bus->parent; + bridge =pci_upstream_bridge (bridge); } pcie_capability_set_word(dev, PCI_EXP_DEVCTL2,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 468/776 Documentation: fix a hugetlbfs reservation statement
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jane Chu <[email protected]>
[ Upstream commit 7a197d346a44384a1a858a98ef03766840e561d4 ]
Documentation/mm/hugetlbfs_reserv.rst has
if (resv_needed <= (resv_huge_pages - free_huge_pages))
resv_huge_pages += resv_needed;
which describes this code in gather_surplus_pages()
needed = (h->resv_huge_pages + delta) - h->free_huge_pages;
if (needed <= 0) {
h->resv_huge_pages += delta;
return 0;
}which means if there are enough free hugepages to account for the new reservation, simply update the global reservation count without further action.
But the description is backwards, it should be
if (resv_needed <= (free_huge_pages - resv_huge_pages))
instead.
--- Documentation/vm/hugetlbfs_reserv.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/vm/hugetlbfs_reserv.rst +1 -1
@@ -157,7 +157,7 @@ are enough free huge pages to accommodate the reservation. If there are, the global reservation count resv_huge_pages is adjusted something like the following:: - if (resv_needed <= (resv_huge_pages - free_huge_pages)) + if (resv_needed <= (free_huge_pages - resv_huge_pages) resv_huge_pages += resv_needed; Note that the global lock hugetlb_lock is held when checking and adjusting
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 469/776 selftest: memcg: skip memcg_sock test if address family not supported
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waiman Long <[email protected]>
[ Upstream commit 2d028f3e4bbbfd448928a8d3d2814b0b04c214f4 ]
The test_memcg_sock test in memcontrol.c sets up an IPv6 socket and send data over it to consume memory and verify that memory.stat.sock and memory.current values are close.
On systems where IPv6 isn't enabled or not configured to support SOCK_STREAM, the test_memcg_sock test always fails. When the socket() call fails, there is no way we can test the memory consumption and verify the above claim. I believe it is better to just skip the test in this case instead of reporting a test failure hinting that there may be something wrong with the memcg code.
--- tools/testing/selftests/cgroup/test_memcontrol.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
tools/testing/selftests/cgroup/test_memcontrol.c +10 -1
@@ -833,8 +833,11 @@ static int tcp_server(const char *cgroup, void *arg) saddr.sin6_port =htons (srv_args->port); sk =socket (AF_INET6 ,SOCK_STREAM ,0 ); -if (sk <0 ) +if (sk <0 ) { +/* Pass back errno to the ctl_fd */ +write (ctl_fd, &errno,sizeof (errno));return ret; + }if (setsockopt (sk,SOL_SOCKET ,SO_REUSEADDR , &yes,sizeof (yes)) <0 ) goto cleanup;
@@ -964,6 +967,12 @@ static int test_memcg_sock(const char *root) goto cleanup;close (args.ctl[0 ]); +/* Skip if address family not supported by protocol */ +if (err ==EAFNOSUPPORT ) { + ret =KSFT_SKIP ; + goto cleanup; + } +if (!err)break ;if (err !=EADDRINUSE )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 470/776 PCI: Add PCIE_PME_TO_L2_TIMEOUT_US L2 ready timeout value
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
[ Upstream commit e78bd50b4078b3b2d9f85d97796b7c271e7860ca ]
Add the PCIE_PME_TO_L2_TIMEOUT_US macro to define the L2 ready timeout as described in the PCI specifications.
Stable-dep-of: adaffed907f1 ("PCI: tegra194: Fix polling delay for L2 state")
--- drivers/pci/pci.h | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/pci/pci.h +6 -0
@@ -14,6 +14,12 @@#define PCI_EXP_AER_FLAGS (PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | \ PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE) +/* +* PCIe r6.0, sec 5.3.3.2.1 <PME Synchronization> +* Recommends 1ms to 10ms timeout to check L2 ready. +*/ +#define PCIE_PME_TO_L2_TIMEOUT_US 10000 +extern const unsigned char pcie_link_speed[];extern bool pci_early_dump;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 471/776 PCI: tegra194: Fix polling delay for L2 state
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vidya Sagar <[email protected]>
[ Upstream commit adaffed907f14f954096555665ad6af2ae724d83 ]
As per PCIe r7.0, sec 5.3.3.2.1, after sending PME_Turn_Off message, Root Port should wait for 1-10 msec for PME_TO_Ack message. Currently, driver is polling for 10 msec with 1 usec delay which is aggressive. Use existing macro PCIE_PME_TO_L2_TIMEOUT_US to poll for 10 msec with 1 msec delay. Since this function is used in non-atomic context only, use non-atomic poll function.
--- drivers/pci/controller/dwc/pcie-tegra194.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +4 -5
@@ -221,8 +221,6 @@#define CAP_SPCIE_CAP_OFF_USP_TX_PRESET0_MASK GENMASK(11, 8)#define CAP_SPCIE_CAP_OFF_USP_TX_PRESET0_SHIFT 8 -#define PME_ACK_TIMEOUT 10000 -#define LTSSM_TIMEOUT 50000/* 50ms */ #define GEN3_GEN4_EQ_PRESET_INIT 5
@@ -1498,9 +1496,10 @@ static int tegra_pcie_try_link_l2(struct tegra_pcie_dw *pcie) val |=APPL_PM_XMT_TURNOFF_STATE ;appl_writel (pcie, val,APPL_RADM_STATUS ); -return readl_poll_timeout_atomic (pcie->appl_base +APPL_DEBUG , val, - val &APPL_DEBUG_PM_LINKST_IN_L2_LAT , -1 ,PME_ACK_TIMEOUT ); +return readl_poll_timeout (pcie->appl_base +APPL_DEBUG , val, + val &APPL_DEBUG_PM_LINKST_IN_L2_LAT , +PCIE_PME_TO_L2_TIMEOUT_US /10 , +PCIE_PME_TO_L2_TIMEOUT_US ); }static void tegra_pcie_dw_pme_turnoff (struct tegra_pcie_dw *pcie)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 472/776 PCI: tegra194: Increase LTSSM poll time on surprise link down
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manikanta Maddireddy <[email protected]>
[ Upstream commit 74dd8efe4d6cead433162147333af989a568aac7 ]
On surprise link down, LTSSM state transits from L0 -> Recovery.RcvrLock -> Recovery.RcvrSpeed -> Gen1 Recovery.RcvrLock -> Detect. Recovery.RcvrLock and Recovery.RcvrSpeed transit times are 24 ms and 48 ms respectively, so the total time from L0 to Detect is ~96 ms. Increase the poll timeout to 120 ms to account for this.
While at it, add LTSSM state defines for Detect-related states and use them in the poll condition. Use readl_poll_timeout() instead of readl_poll_timeout_atomic() in tegra_pcie_dw_pme_turnoff() since that path runs in non-atomic context.
--- drivers/pci/controller/dwc/pcie-tegra194.c | 36 +++++++++++++--------- 1 file changed, 21 insertions(+), 15 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +21 -15
@@ -134,7 +134,11 @@#define APPL_DEBUG_PM_LINKST_IN_L0 0x11#define APPL_DEBUG_LTSSM_STATE_MASK GENMASK(8, 3)#define APPL_DEBUG_LTSSM_STATE_SHIFT 3 -#define LTSSM_STATE_PRE_DETECT 5 +#define LTSSM_STATE_DETECT_QUIET 0x00 +#define LTSSM_STATE_DETECT_ACT 0x08 +#define LTSSM_STATE_PRE_DETECT_QUIET 0x28 +#define LTSSM_STATE_DETECT_WAIT 0x30 +#define LTSSM_STATE_L2_IDLE 0xa8#define APPL_RADM_STATUS 0xE4#define APPL_PM_XMT_TURNOFF_STATE BIT(0)
@@ -221,7 +225,8 @@#define CAP_SPCIE_CAP_OFF_USP_TX_PRESET0_MASK GENMASK(11, 8)#define CAP_SPCIE_CAP_OFF_USP_TX_PRESET0_SHIFT 8 -#define LTSSM_TIMEOUT 50000/* 50ms */ +#define LTSSM_DELAY_US 10000/* 10 ms */ +#define LTSSM_TIMEOUT_US 120000/* 120 ms */ #define GEN3_GEN4_EQ_PRESET_INIT 5
@@ -1542,15 +1547,14 @@ static void tegra_pcie_dw_pme_turnoff(struct tegra_pcie_dw *pcie) data &= ~APPL_CTRL_LTSSM_EN ;writel (data, pcie->appl_base +APPL_CTRL ); - err =readl_poll_timeout_atomic (pcie->appl_base +APPL_DEBUG , - data, - ((data & -APPL_DEBUG_LTSSM_STATE_MASK ) >> -APPL_DEBUG_LTSSM_STATE_SHIFT ) == -LTSSM_STATE_PRE_DETECT , -1 ,LTSSM_TIMEOUT ); + err =readl_poll_timeout (pcie->appl_base +APPL_DEBUG , data, + ((data &APPL_DEBUG_LTSSM_STATE_MASK ) ==LTSSM_STATE_DETECT_QUIET ) || + ((data &APPL_DEBUG_LTSSM_STATE_MASK ) ==LTSSM_STATE_DETECT_ACT ) || + ((data &APPL_DEBUG_LTSSM_STATE_MASK ) ==LTSSM_STATE_PRE_DETECT_QUIET ) || + ((data &APPL_DEBUG_LTSSM_STATE_MASK ) ==LTSSM_STATE_DETECT_WAIT ), +LTSSM_DELAY_US ,LTSSM_TIMEOUT_US );if (err) -dev_info (pcie->dev,"Link didn't go to detect state\n" ); +dev_info (pcie->dev,"LTSSM state: 0x%x detect timeout: %d\n" , data, err); }/* * DBI registers may not be accessible after this as PLL-E would be
@@ -1638,12 +1642,14 @@ static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie)appl_writel (pcie, val,APPL_CTRL ); ret =readl_poll_timeout (pcie->appl_base +APPL_DEBUG , val, - ((val &APPL_DEBUG_LTSSM_STATE_MASK ) >> -APPL_DEBUG_LTSSM_STATE_SHIFT ) == -LTSSM_STATE_PRE_DETECT , -1 ,LTSSM_TIMEOUT ); + ((val &APPL_DEBUG_LTSSM_STATE_MASK ) ==LTSSM_STATE_DETECT_QUIET ) || + ((val &APPL_DEBUG_LTSSM_STATE_MASK ) ==LTSSM_STATE_DETECT_ACT ) || + ((val &APPL_DEBUG_LTSSM_STATE_MASK ) ==LTSSM_STATE_PRE_DETECT_QUIET ) || + ((val &APPL_DEBUG_LTSSM_STATE_MASK ) ==LTSSM_STATE_DETECT_WAIT ) || + ((val &APPL_DEBUG_LTSSM_STATE_MASK ) ==LTSSM_STATE_L2_IDLE ), +LTSSM_DELAY_US ,LTSSM_TIMEOUT_US );if (ret) -dev_err (pcie->dev,"Failed to go Detect state: %d\n" , ret); +dev_info (pcie->dev,"LTSSM state: 0x%x detect timeout: %d\n" , val, ret);reset_control_assert (pcie->core_rst);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 473/776 PCI: tegra194: Disable LTSSM after transition to Detect on surprise link down
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manikanta Maddireddy <[email protected]>
[ Upstream commit 9fa0c242f8d7acf1b124d4462d18f4023573ac1c ]
After the link reaches a Detect-related LTSSM state, disable LTSSM so it does not keep toggling between Polling and Detect. Do this by polling for the Detect state first, then clearing APPL_CTRL_LTSSM_EN in both tegra_pcie_dw_pme_turnoff() and pex_ep_event_pex_rst_assert().
--- drivers/pci/controller/dwc/pcie-tegra194.c | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +16 -13
@@ -1539,14 +1539,6 @@ static void tegra_pcie_dw_pme_turnoff(struct tegra_pcie_dw *pcie) data &= ~APPL_PINMUX_PEX_RST ;appl_writel (pcie, data,APPL_PINMUX ); -/* -* Some cards do not go to detect state even after de-asserting -* PERST#. So, de-assert LTSSM to bring link to detect state. -*/ - data =readl (pcie->appl_base +APPL_CTRL ); - data &= ~APPL_CTRL_LTSSM_EN ; -writel (data, pcie->appl_base +APPL_CTRL ); - err = readl_poll_timeout(pcie->appl_base + APPL_DEBUG, data, ((data & APPL_DEBUG_LTSSM_STATE_MASK) == LTSSM_STATE_DETECT_QUIET) || ((data & APPL_DEBUG_LTSSM_STATE_MASK) == LTSSM_STATE_DETECT_ACT) ||
@@ -1555,6 +1547,14 @@ static void tegra_pcie_dw_pme_turnoff(struct tegra_pcie_dw *pcie) LTSSM_DELAY_US, LTSSM_TIMEOUT_US);if (err)dev_info (pcie->dev,"LTSSM state: 0x%x detect timeout: %d\n" , data, err); + +/* +* Deassert LTSSM state to stop the state toggling between +* Polling and Detect. +*/ + data =readl (pcie->appl_base +APPL_CTRL ); + data &= ~APPL_CTRL_LTSSM_EN ; +writel (data, pcie->appl_base +APPL_CTRL ); }/* * DBI registers may not be accessible after this as PLL-E would be
@@ -1636,11 +1636,6 @@ static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie)if (pcie->ep_state ==EP_STATE_DISABLED )return ; -/* Disable LTSSM */ - val =appl_readl (pcie,APPL_CTRL ); - val &= ~APPL_CTRL_LTSSM_EN ; -appl_writel (pcie, val,APPL_CTRL ); - ret = readl_poll_timeout(pcie->appl_base + APPL_DEBUG, val, ((val & APPL_DEBUG_LTSSM_STATE_MASK) == LTSSM_STATE_DETECT_QUIET) || ((val & APPL_DEBUG_LTSSM_STATE_MASK) == LTSSM_STATE_DETECT_ACT) ||
@@ -1651,6 +1646,14 @@ static void pex_ep_event_pex_rst_assert(struct tegra_pcie_dw *pcie)if (ret)dev_info (pcie->dev,"LTSSM state: 0x%x detect timeout: %d\n" , val, ret); +/* +* Deassert LTSSM state to stop the state toggling between +* Polling and Detect. +*/ + val =appl_readl (pcie,APPL_CTRL ); + val &= ~APPL_CTRL_LTSSM_EN ; +appl_writel (pcie, val,APPL_CTRL ); +reset_control_assert (pcie->core_rst);tegra_pcie_disable_phy (pcie);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 474/776 PCI: tegra194: Use devm_gpiod_get_optional() to parse "nvidia,refclk-select"
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vidya Sagar <[email protected]>
[ Upstream commit f62bc7917de1374dce86a852ffba8baf9cb7a56a ]
The GPIO DT property "nvidia,refclk-select", to select the PCIe reference clock is optional. Use devm_gpiod_get_optional() to get it.
--- drivers/pci/controller/dwc/pcie-tegra194.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +3 -3
@@ -1146,9 +1146,9 @@ static int tegra_pcie_dw_parse_dt(struct tegra_pcie_dw *pcie)return err; } - pcie->pex_refclk_sel_gpiod =devm_gpiod_get (pcie->dev, -"nvidia,refclk-select" , -GPIOD_OUT_HIGH ); + pcie->pex_refclk_sel_gpiod =devm_gpiod_get_optional (pcie->dev, +"nvidia,refclk-select" , +GPIOD_OUT_HIGH );if (IS_ERR (pcie->pex_refclk_sel_gpiod)) {int err =PTR_ERR (pcie->pex_refclk_sel_gpiod);const char *level =KERN_ERR ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 475/776 PCI: tegra194: Disable direct speed change for Endpoint mode
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vidya Sagar <[email protected]>
[ Upstream commit 976f6763f57970388bcd7118931f33f447916927 ]
Pre-silicon simulation showed the controller operating in Endpoint mode initiating link speed change after completing Secondary Bus Reset. Ideally, the Root Port or the Switch Downstream Port should initiate the link speed change post SBR, not the Endpoint.
So, as per the hardware team recommendation, disable direct speed change for the Endpoint mode to prevent it from initiating speed change after the physical layer link is up at Gen1, leaving speed change ownership with the host.
--- drivers/pci/controller/dwc/pcie-tegra194.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/pci/controller/dwc/pcie-tegra194.c +4 -0
@@ -1774,6 +1774,10 @@ static void pex_ep_event_pex_rst_deassert(struct tegra_pcie_dw *pcie)reset_control_deassert (pcie->core_rst); + val =dw_pcie_readl_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL ); + val &= ~PORT_LOGIC_SPEED_CHANGE ; +dw_pcie_writel_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL , val); +if (pcie->update_fc_fixup) { val =dw_pcie_readl_dbi (pci,CFG_TIMER_CTRL_MAX_FUNC_NUM_OFF ); val |=0x1 <<CFG_TIMER_CTRL_ACK_NAK_SHIFT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 476/776 ALSA: sc6000: Use standard print API
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit e7c475b92043c02c3e6cd0c20e308fbb6f03ebde ]
Use the standard print API with dev_*() instead of the old house-baked one. It gives better information and allows dynamically control of debug prints.
Some functions are changed to receive a device pointer to be passed to dev_*() calls.
Stable-dep-of: fb79bf127ac2 ("ALSA: sc6000: Keep the programmed board state in card-private data")
--- sound/isa/sc6000.c | 177 +++++++++++++++++++++++---------------------- 1 file changed, 90 insertions(+), 87 deletions(-)
sound/isa/sc6000.c +90 -87
@@ -204,7 +204,7 @@ static int sc6000_read(char __iomem *vport) } -static int sc6000_write (char __iomem *vport,int cmd) +static int sc6000_write (struct device *devptr,char __iomem *vport,int cmd) {unsigned char val;int loop =500000 ;
@@ -221,18 +221,19 @@ static int sc6000_write(char __iomem *vport, int cmd)cpu_relax (); }while (loop--); -snd_printk (KERN_ERR "DSP Command (0x%x) timeout.\n" , cmd); +dev_err (devptr,"DSP Command (0x%x) timeout.\n" , cmd);return -EIO ; } -static int sc6000_dsp_get_answer (char __iomem *vport,int command, +static int sc6000_dsp_get_answer (struct device *devptr, +char __iomem *vport,int command,char *data,int data_len) {int len =0 ; -if (sc6000_write (vport, command)) { -snd_printk (KERN_ERR "CMD 0x%x: failed!\n" , command); +if (sc6000_write (devptr, vport, command)) { +dev_err (devptr,"CMD 0x%x: failed!\n" , command);return -EIO ; }
@@ -265,82 +266,86 @@ static int sc6000_dsp_reset(char __iomem *vport) }/* detection and initialization */ -static int sc6000_hw_cfg_write (char __iomem *vport,const int *cfg) +static int sc6000_hw_cfg_write (struct device *devptr, +char __iomem *vport,const int *cfg) { -if (sc6000_write (vport,COMMAND_6C ) <0 ) { -snd_printk (KERN_WARNING "CMD 0x%x: failed!\n" ,COMMAND_6C ); +if (sc6000_write (devptr, vport,COMMAND_6C ) <0 ) { +dev_warn (devptr,"CMD 0x%x: failed!\n" ,COMMAND_6C );return -EIO ; } -if (sc6000_write (vport,COMMAND_5C ) <0 ) { -snd_printk (KERN_ERR "CMD 0x%x: failed!\n" ,COMMAND_5C ); +if (sc6000_write (devptr, vport,COMMAND_5C ) <0 ) { +dev_err (devptr,"CMD 0x%x: failed!\n" ,COMMAND_5C );return -EIO ; } -if (sc6000_write (vport, cfg[0 ]) <0 ) { -snd_printk (KERN_ERR "DATA 0x%x: failed!\n" , cfg[0 ]); +if (sc6000_write (devptr, vport, cfg[0 ]) <0 ) { +dev_err (devptr,"DATA 0x%x: failed!\n" , cfg[0 ]);return -EIO ; } -if (sc6000_write (vport, cfg[1 ]) <0 ) { -snd_printk (KERN_ERR "DATA 0x%x: failed!\n" , cfg[1 ]); +if (sc6000_write (devptr, vport, cfg[1 ]) <0 ) { +dev_err (devptr,"DATA 0x%x: failed!\n" , cfg[1 ]);return -EIO ; } -if (sc6000_write (vport,COMMAND_C5 ) <0 ) { -snd_printk (KERN_ERR "CMD 0x%x: failed!\n" ,COMMAND_C5 ); +if (sc6000_write (devptr, vport,COMMAND_C5 ) <0 ) { +dev_err (devptr,"CMD 0x%x: failed!\n" ,COMMAND_C5 );return -EIO ; }return 0 ; } -static int sc6000_cfg_write (char __iomem *vport,unsigned char softcfg) +static int sc6000_cfg_write (struct device *devptr, +char __iomem *vport,unsigned char softcfg) { -if (sc6000_write (vport,WRITE_MDIRQ_CFG )) { -snd_printk (KERN_ERR "CMD 0x%x: failed!\n" ,WRITE_MDIRQ_CFG ); +if (sc6000_write (devptr, vport,WRITE_MDIRQ_CFG )) { +dev_err (devptr,"CMD 0x%x: failed!\n" ,WRITE_MDIRQ_CFG );return -EIO ; } -if (sc6000_write (vport, softcfg)) { -snd_printk (KERN_ERR "sc6000_cfg_write: failed!\n" ); +if (sc6000_write (devptr, vport, softcfg)) { +dev_err (devptr,"%s: failed!\n" , __func__);return -EIO ; }return 0 ; } -static int sc6000_setup_board (char __iomem *vport,int config) +static int sc6000_setup_board (struct device *devptr, +char __iomem *vport,int config) {int loop =10 ;do { -if (sc6000_write (vport,COMMAND_88 )) { -snd_printk (KERN_ERR "CMD 0x%x: failed!\n" , -COMMAND_88 ); +if (sc6000_write (devptr, vport,COMMAND_88 )) { +dev_err (devptr,"CMD 0x%x: failed!\n" , +COMMAND_88 );return -EIO ; } }while ((sc6000_wait_data (vport) <0 ) && loop--);if (sc6000_read (vport) <0 ) { -snd_printk (KERN_ERR "sc6000_read after CMD 0x%x: failed\n" , -COMMAND_88 ); +dev_err (devptr,"sc6000_read after CMD 0x%x: failed\n" , +COMMAND_88 );return -EIO ; } -if (sc6000_cfg_write (vport, config)) +if (sc6000_cfg_write (devptr, vport, config))return -ENODEV ;return 0 ; } -static int sc6000_init_mss (char __iomem *vport,int config, +static int sc6000_init_mss (struct device *devptr, +char __iomem *vport,int config,char __iomem *vmss_port,int mss_config) { -if (sc6000_write (vport,DSP_INIT_MSS )) { -snd_printk (KERN_ERR "sc6000_init_mss [0x%x]: failed!\n" , -DSP_INIT_MSS ); +if (sc6000_write (devptr, vport,DSP_INIT_MSS )) { +dev_err (devptr,"%s [0x%x]: failed!\n" , __func__, +DSP_INIT_MSS );return -EIO ; }msleep (10 ); -if (sc6000_cfg_write (vport, config)) +if (sc6000_cfg_write (devptr, vport, config))return -EIO ;iowrite8 (mss_config, vmss_port);
@@ -348,7 +353,8 @@ static int sc6000_init_mss(char __iomem *vport, int config,return 0 ; } -static void sc6000_hw_cfg_encode (char __iomem *vport,int *cfg, +static void sc6000_hw_cfg_encode (struct device *devptr, +char __iomem *vport,int *cfg,long xport,long xmpu,long xmss_port,int joystick) {
@@ -367,10 +373,11 @@ static void sc6000_hw_cfg_encode(char __iomem *vport, int *cfg, cfg[0 ] |=0x02 ; cfg[1 ] |=0x80 ;/* enable WSS system */ cfg[1 ] &= ~0x40 ;/* disable IDE */ -snd_printd ("hw cfg %x, %x\n" , cfg[0 ], cfg[1 ]); +dev_dbg (devptr,"hw cfg %x, %x\n" , cfg[0 ], cfg[1 ]); } -static int sc6000_init_board (char __iomem *vport, +static int sc6000_init_board (struct device *devptr, +char __iomem *vport,char __iomem *vmss_port,int dev) {char answer[15 ];
@@ -384,14 +391,14 @@ static int sc6000_init_board(char __iomem *vport, err =sc6000_dsp_reset (vport);if (err <0 ) { -snd_printk (KERN_ERR "sc6000_dsp_reset: failed!\n" ); +dev_err (devptr,"sc6000_dsp_reset: failed!\n" );return err; }memset (answer,0 ,sizeof (answer)); - err =sc6000_dsp_get_answer (vport,GET_DSP_COPYRIGHT , answer,15 ); + err =sc6000_dsp_get_answer (devptr, vport,GET_DSP_COPYRIGHT , answer,15 );if (err <=0 ) { -snd_printk (KERN_ERR "sc6000_dsp_copyright: failed!\n" ); +dev_err (devptr,"sc6000_dsp_copyright: failed!\n" );return -ENODEV ; }/*
@@ -399,52 +406,52 @@ static int sc6000_init_board(char __iomem *vport,* if we have something different, we have to be warned. */ if (strncmp ("SC-6000" , answer,7 )) -snd_printk (KERN_WARNING "Warning: non SC-6000 audio card!\n" ); +dev_warn (devptr,"Warning: non SC-6000 audio card!\n" ); -if (sc6000_dsp_get_answer (vport,GET_DSP_VERSION , version,2 ) <2 ) { -snd_printk (KERN_ERR "sc6000_dsp_version: failed!\n" ); +if (sc6000_dsp_get_answer (devptr, vport,GET_DSP_VERSION , version,2 ) <2 ) { +dev_err (devptr,"sc6000_dsp_version: failed!\n" );return -ENODEV ; } - printk(KERN_INFO PFX "Detected model: %s, DSP version %d.%d\n", +dev_info (devptr,"Detected model: %s, DSP version %d.%d\n" , answer, version[0 ], version[1 ]);/* set configuration */ -sc6000_write (vport,COMMAND_5C ); +sc6000_write (devptr, vport,COMMAND_5C );if (sc6000_read (vport) <0 ) old =1 ;if (!old) {int cfg[2 ]; -sc6000_hw_cfg_encode (vport, &cfg[0 ], port[dev], mpu_port[dev], +sc6000_hw_cfg_encode (devptr, + vport, &cfg[0 ], port[dev], mpu_port[dev], mss_port[dev], joystick[dev]); -if (sc6000_hw_cfg_write (vport, cfg) <0 ) { -snd_printk (KERN_ERR "sc6000_hw_cfg_write: failed!\n" ); +if (sc6000_hw_cfg_write (devptr, vport, cfg) <0 ) { +dev_err (devptr,"sc6000_hw_cfg_write: failed!\n" );return -EIO ; } } - err =sc6000_setup_board (vport, config); + err =sc6000_setup_board (devptr, vport, config);if (err <0 ) { -snd_printk (KERN_ERR "sc6000_setup_board: failed!\n" ); +dev_err (devptr,"sc6000_setup_board: failed!\n" );return -ENODEV ; }sc6000_dsp_reset (vport);if (!old) { -sc6000_write (vport,COMMAND_60 ); -sc6000_write (vport,0x02 ); +sc6000_write (devptr, vport,COMMAND_60 ); +sc6000_write (devptr, vport,0x02 );sc6000_dsp_reset (vport); } - err =sc6000_setup_board (vport, config); + err =sc6000_setup_board (devptr, vport, config);if (err <0 ) { -snd_printk (KERN_ERR "sc6000_setup_board: failed!\n" ); +dev_err (devptr,"sc6000_setup_board: failed!\n" );return -ENODEV ; } - err =sc6000_init_mss (vport, config, vmss_port, mss_config); + err =sc6000_init_mss (devptr, vport, config, vmss_port, mss_config);if (err <0 ) { -snd_printk (KERN_ERR "Cannot initialize " -"Microsoft Sound System mode.\n" ); +dev_err (devptr,"Cannot initialize Microsoft Sound System mode.\n" );return -ENODEV ; }
@@ -491,39 +498,39 @@ static int snd_sc6000_match(struct device *devptr, unsigned int dev)if (!enable[dev])return 0 ;if (port[dev] ==SNDRV_AUTO_PORT ) { - printk(KERN_ERR PFX "specify IO port\n"); +dev_err (devptr,"specify IO port\n" );return 0 ; }if (mss_port[dev] ==SNDRV_AUTO_PORT ) { - printk(KERN_ERR PFX "specify MSS port\n"); +dev_err (devptr,"specify MSS port\n" );return 0 ; }if (port[dev] !=0x220 && port[dev] !=0x240 ) { - printk(KERN_ERR PFX "Port must be 0x220 or 0x240\n"); +dev_err (devptr,"Port must be 0x220 or 0x240\n" );return 0 ; }if (mss_port[dev] !=0x530 && mss_port[dev] !=0xe80 ) { - printk(KERN_ERR PFX "MSS port must be 0x530 or 0xe80\n"); +dev_err (devptr,"MSS port must be 0x530 or 0xe80\n" );return 0 ; }if (irq[dev] !=SNDRV_AUTO_IRQ && !sc6000_irq_to_softcfg (irq[dev])) { - printk(KERN_ERR PFX "invalid IRQ %d\n", irq[dev]); +dev_err (devptr,"invalid IRQ %d\n" , irq[dev]);return 0 ; }if (dma[dev] !=SNDRV_AUTO_DMA && !sc6000_dma_to_softcfg (dma[dev])) { - printk(KERN_ERR PFX "invalid DMA %d\n", dma[dev]); +dev_err (devptr,"invalid DMA %d\n" , dma[dev]);return 0 ; }if (mpu_port[dev] !=SNDRV_AUTO_PORT && (mpu_port[dev] & ~0x30L ) !=0x300 ) { - printk(KERN_ERR PFX "invalid MPU-401 port %lx\n", +dev_err (devptr,"invalid MPU-401 port %lx\n" , mpu_port[dev]);return 0 ; }if (mpu_port[dev] !=SNDRV_AUTO_PORT && mpu_irq[dev] !=SNDRV_AUTO_IRQ && mpu_irq[dev] !=0 && !sc6000_mpu_irq_to_softcfg (mpu_irq[dev])) { - printk(KERN_ERR PFX "invalid MPU-401 IRQ %d\n", mpu_irq[dev]); +dev_err (devptr,"invalid MPU-401 IRQ %d\n" , mpu_irq[dev]);return 0 ; }return 1 ;
@@ -534,7 +541,7 @@ static void snd_sc6000_free(struct snd_card *card)char __iomem *vport = (char __force __iomem *)card->private_data;if (vport) -sc6000_setup_board (vport,0 ); +sc6000_setup_board (card->dev, vport,0 ); }static int __snd_sc6000_probe (struct device *devptr,unsigned int dev)
@@ -558,7 +565,7 @@ static int __snd_sc6000_probe(struct device *devptr, unsigned int dev)if (xirq ==SNDRV_AUTO_IRQ ) { xirq =snd_legacy_find_free_irq (possible_irqs);if (xirq <0 ) { - snd_printk(KERN_ERR PFX "unable to find a free IRQ\n"); +dev_err (devptr,"unable to find a free IRQ\n" );return -EBUSY ; } }
@@ -566,42 +573,39 @@ static int __snd_sc6000_probe(struct device *devptr, unsigned int dev)if (xdma ==SNDRV_AUTO_DMA ) { xdma =snd_legacy_find_free_dma (possible_dmas);if (xdma <0 ) { - snd_printk(KERN_ERR PFX "unable to find a free DMA\n"); +dev_err (devptr,"unable to find a free DMA\n" );return -EBUSY ; } }if (!devm_request_region (devptr, port[dev],0x10 ,DRV_NAME )) { - snd_printk(KERN_ERR PFX - "I/O port region is already in use.\n"); +dev_err (devptr,"I/O port region is already in use.\n" );return -EBUSY ; } vport =devm_ioport_map (devptr, port[dev],0x10 );if (!vport) { - snd_printk(KERN_ERR PFX - "I/O port cannot be iomapped.\n"); +dev_err (devptr,"I/O port cannot be iomapped.\n" );return -EBUSY ; } card->private_data = (void __force *)vport;/* to make it marked as used */ if (!devm_request_region (devptr, mss_port[dev],4 ,DRV_NAME )) { - snd_printk(KERN_ERR PFX - "SC-6000 port I/O port region is already in use.\n"); +dev_err (devptr, +"SC-6000 port I/O port region is already in use.\n" );return -EBUSY ; } vmss_port =devm_ioport_map (devptr, mss_port[dev],4 );if (!vmss_port) { - snd_printk(KERN_ERR PFX - "MSS port I/O cannot be iomapped.\n"); +dev_err (devptr,"MSS port I/O cannot be iomapped.\n" );return -EBUSY ; } -snd_printd ("Initializing BASE[0x%lx] IRQ[%d] DMA[%d] MIRQ[%d]\n" , - port[dev], xirq, xdma, - mpu_irq[dev] ==SNDRV_AUTO_IRQ ?0 : mpu_irq[dev]); +dev_dbg (devptr,"Initializing BASE[0x%lx] IRQ[%d] DMA[%d] MIRQ[%d]\n" , + port[dev], xirq, xdma, + mpu_irq[dev] ==SNDRV_AUTO_IRQ ?0 : mpu_irq[dev]); - err =sc6000_init_board (vport, vmss_port, dev); + err =sc6000_init_board (devptr, vport, vmss_port, dev);if (err <0 )return err; card->private_free = snd_sc6000_free;
@@ -613,25 +617,24 @@ static int __snd_sc6000_probe(struct device *devptr, unsigned int dev) err =snd_wss_pcm (chip,0 );if (err <0 ) { - snd_printk(KERN_ERR PFX - "error creating new WSS PCM device\n"); +dev_err (devptr,"error creating new WSS PCM device\n" );return err; } err =snd_wss_mixer (chip);if (err <0 ) { - snd_printk(KERN_ERR PFX "error creating new WSS mixer\n"); +dev_err (devptr,"error creating new WSS mixer\n" );return err; } err =snd_sc6000_mixer (chip);if (err <0 ) { - snd_printk(KERN_ERR PFX "the mixer rewrite failed\n"); +dev_err (devptr,"the mixer rewrite failed\n" );return err; }if (snd_opl3_create (card,0x388 ,0x388 +2 ,OPL3_HW_AUTO ,0 , &opl3) <0 ) { - snd_printk(KERN_ERR PFX "no OPL device at 0x%x-0x%x ?\n", - 0x388, 0x388 + 2); +dev_err (devptr,"no OPL device at 0x%x-0x%x ?\n" , +0x388 ,0x388 +2 ); }else { err =snd_opl3_hwdep_new (opl3,0 ,1 ,NULL );if (err <0 )
@@ -645,8 +648,8 @@ static int __snd_sc6000_probe(struct device *devptr, unsigned int dev) MPU401_HW_MPU401, mpu_port[dev], 0, mpu_irq[dev], NULL) < 0) -snd_printk (KERN_ERR "no MPU-401 device at 0x%lx ?\n" , - mpu_port[dev]); +dev_err (devptr,"no MPU-401 device at 0x%lx ?\n" , + mpu_port[dev]); }strcpy (card->driver,DRV_NAME );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 477/776 ALSA: sc6000: Keep the programmed board state in card-private data
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
[ Upstream commit fb79bf127ac2577b4876132da6dba768018aad4c ]
The driver may auto-select IRQ and DMA resources at probe time, but sc6000_init_board() still derives the SC-6000 soft configuration from the module parameter arrays. When irq=auto or dma=auto is used, the codec is created with the selected resources while the board is programmed with the unresolved values.
Store the mapped ports and generated SC-6000 board configuration in card-private data, build that configuration from the live probe results instead of the raw module parameters, and keep the probe-time board programming in a shared helper.
This fixes the resource-programming mismatch and leaves the driver with a stable board-state block that can be reused by suspend/resume.
--- sound/isa/sc6000.c | 152 +++++++++++++++++++++++++++------------------ 1 file changed, 92 insertions(+), 60 deletions(-)
sound/isa/sc6000.c +92 -60
@@ -100,6 +100,15 @@ MODULE_PARM_DESC(joystick, "Enable gameport.");#define PFX "sc6000: "#define DRV_NAME "SC-6000" +struct snd_sc6000 { +char __iomem *vport; +char __iomem *vmss_port; +u8 mss_config; +u8 config; +u8 hw_cfg[2 ]; +bool old_dsp; +}; +/* hardware dependent functions */ /*
@@ -267,7 +276,7 @@ static int sc6000_dsp_reset(char __iomem *vport)/* detection and initialization */ static int sc6000_hw_cfg_write (struct device *devptr, -char __iomem *vport,const int *cfg) +char __iomem *vport,const u8 *cfg) {if (sc6000_write (devptr, vport,COMMAND_6C ) <0 ) {dev_warn (devptr,"CMD 0x%x: failed!\n" ,COMMAND_6C );
@@ -353,8 +362,7 @@ static int sc6000_init_mss(struct device *devptr,return 0 ; } -static void sc6000_hw_cfg_encode (struct device *devptr, -char __iomem *vport,int *cfg, +static void sc6000_hw_cfg_encode (struct device *devptr,u8 *cfg,long xport,long xmpu,long xmss_port,int joystick) {
@@ -376,27 +384,83 @@ static void sc6000_hw_cfg_encode(struct device *devptr,dev_dbg (devptr,"hw cfg %x, %x\n" , cfg[0 ], cfg[1 ]); } -static int sc6000_init_board (struct device *devptr, -char __iomem *vport, -char __iomem *vmss_port,int dev) +static void sc6000_prepare_board (struct device *devptr, +struct snd_sc6000 *sc6000, +unsigned int dev,int xirq,int xdma) +{ + sc6000->mss_config =sc6000_irq_to_softcfg (xirq) | +sc6000_dma_to_softcfg (xdma); + sc6000->config = sc6000->mss_config | +sc6000_mpu_irq_to_softcfg (mpu_irq[dev]); +sc6000_hw_cfg_encode (devptr, sc6000->hw_cfg, port[dev], mpu_port[dev], + mss_port[dev], joystick[dev]); +} + +static void sc6000_detect_old_dsp (struct device *devptr, +struct snd_sc6000 *sc6000) +{ +sc6000_write (devptr, sc6000->vport,COMMAND_5C ); + sc6000->old_dsp =sc6000_read (sc6000->vport) <0 ; +} + +static int sc6000_program_board (struct device *devptr, +struct snd_sc6000 *sc6000) +{ +int err; + +if (!sc6000->old_dsp) { +if (sc6000_hw_cfg_write (devptr, sc6000->vport, + sc6000->hw_cfg) <0 ) { +dev_err (devptr,"sc6000_hw_cfg_write: failed!\n" ); +return -EIO ; + } + } + + err =sc6000_setup_board (devptr, sc6000->vport, sc6000->config); +if (err <0 ) { +dev_err (devptr,"sc6000_setup_board: failed!\n" ); +return -ENODEV ; + } + +sc6000_dsp_reset (sc6000->vport); + +if (!sc6000->old_dsp) { +sc6000_write (devptr, sc6000->vport,COMMAND_60 ); +sc6000_write (devptr, sc6000->vport,0x02 ); +sc6000_dsp_reset (sc6000->vport); + } + + err =sc6000_setup_board (devptr, sc6000->vport, sc6000->config); +if (err <0 ) { +dev_err (devptr,"sc6000_setup_board: failed!\n" ); +return -ENODEV ; + } + + err =sc6000_init_mss (devptr, sc6000->vport, sc6000->config, + sc6000->vmss_port, sc6000->mss_config); +if (err <0 ) { +dev_err (devptr,"Cannot initialize Microsoft Sound System mode.\n" ); +return -ENODEV ; + } + +return 0 ; +} + +static int sc6000_init_board (struct device *devptr,struct snd_sc6000 *sc6000) {char answer[15 ];char version[2 ]; -int mss_config =sc6000_irq_to_softcfg (irq[dev]) | -sc6000_dma_to_softcfg (dma[dev]); -int config = mss_config | -sc6000_mpu_irq_to_softcfg (mpu_irq[dev]);int err; -int old =0 ; - err =sc6000_dsp_reset (vport); + err =sc6000_dsp_reset (sc6000->vport);if (err <0 ) {dev_err (devptr,"sc6000_dsp_reset: failed!\n" );return err; }memset (answer,0 ,sizeof (answer)); - err =sc6000_dsp_get_answer (devptr, vport,GET_DSP_COPYRIGHT , answer,15 ); + err =sc6000_dsp_get_answer (devptr, sc6000->vport,GET_DSP_COPYRIGHT , + answer,15 );if (err <=0 ) {dev_err (devptr,"sc6000_dsp_copyright: failed!\n" );return -ENODEV ;
@@ -408,54 +472,17 @@ static int sc6000_init_board(struct device *devptr,if (strncmp ("SC-6000" , answer,7 ))dev_warn (devptr,"Warning: non SC-6000 audio card!\n" ); -if (sc6000_dsp_get_answer (devptr, vport,GET_DSP_VERSION , version,2 ) <2 ) { +if (sc6000_dsp_get_answer (devptr, sc6000->vport, +GET_DSP_VERSION , version,2 ) <2 ) {dev_err (devptr,"sc6000_dsp_version: failed!\n" );return -ENODEV ; }dev_info (devptr,"Detected model: %s, DSP version %d.%d\n" , answer, version[0 ], version[1 ]); -/* set configuration */ -sc6000_write (devptr, vport,COMMAND_5C ); -if (sc6000_read (vport) <0 ) - old =1 ; - -if (!old) { -int cfg[2 ]; -sc6000_hw_cfg_encode (devptr, - vport, &cfg[0 ], port[dev], mpu_port[dev], - mss_port[dev], joystick[dev]); -if (sc6000_hw_cfg_write (devptr, vport, cfg) <0 ) { -dev_err (devptr,"sc6000_hw_cfg_write: failed!\n" ); -return -EIO ; - } - } - err =sc6000_setup_board (devptr, vport, config); -if (err <0 ) { -dev_err (devptr,"sc6000_setup_board: failed!\n" ); -return -ENODEV ; - } - -sc6000_dsp_reset (vport); - -if (!old) { -sc6000_write (devptr, vport,COMMAND_60 ); -sc6000_write (devptr, vport,0x02 ); -sc6000_dsp_reset (vport); - } +sc6000_detect_old_dsp (devptr, sc6000); - err =sc6000_setup_board (devptr, vport, config); -if (err <0 ) { -dev_err (devptr,"sc6000_setup_board: failed!\n" ); -return -ENODEV ; - } - err =sc6000_init_mss (devptr, vport, config, vmss_port, mss_config); -if (err <0 ) { -dev_err (devptr,"Cannot initialize Microsoft Sound System mode.\n" ); -return -ENODEV ; - } - -return 0 ; +return sc6000_program_board (devptr, sc6000); }static int snd_sc6000_mixer (struct snd_wss *chip)
@@ -538,10 +565,10 @@ static int snd_sc6000_match(struct device *devptr, unsigned int dev)static void snd_sc6000_free (struct snd_card *card) { -char __iomem *vport = (char __force __iomem *)card->private_data; +struct snd_sc6000 *sc6000 = card->private_data; -if (vport) -sc6000_setup_board (card->dev, vport,0 ); +if (sc6000->vport) +sc6000_setup_board (card->dev, sc6000->vport,0 ); }static int __snd_sc6000_probe (struct device *devptr,unsigned int dev)
@@ -552,15 +579,17 @@ static int __snd_sc6000_probe(struct device *devptr, unsigned int dev)int xirq = irq[dev];int xdma = dma[dev];struct snd_card *card; +struct snd_sc6000 *sc6000;struct snd_wss *chip;struct snd_opl3 *opl3;char __iomem *vport;char __iomem *vmss_port; err =snd_devm_card_new (devptr, index[dev], id[dev],THIS_MODULE , -0 , &card); +sizeof (*sc6000), &card);if (err <0 )return err; + sc6000 = card->private_data;if (xirq ==SNDRV_AUTO_IRQ ) { xirq =snd_legacy_find_free_irq (possible_irqs);
@@ -587,7 +616,7 @@ static int __snd_sc6000_probe(struct device *devptr, unsigned int dev)dev_err (devptr,"I/O port cannot be iomapped.\n" );return -EBUSY ; } - card->private_data = (void __force *)vport; + sc6000->vport = vport;/* to make it marked as used */ if (!devm_request_region (devptr, mss_port[dev],4 ,DRV_NAME )) {
@@ -600,12 +629,15 @@ static int __snd_sc6000_probe(struct device *devptr, unsigned int dev)dev_err (devptr,"MSS port I/O cannot be iomapped.\n" );return -EBUSY ; } + sc6000->vmss_port = vmss_port;dev_dbg (devptr,"Initializing BASE[0x%lx] IRQ[%d] DMA[%d] MIRQ[%d]\n" , port[dev], xirq, xdma, mpu_irq[dev] ==SNDRV_AUTO_IRQ ?0 : mpu_irq[dev]); - err =sc6000_init_board (devptr, vport, vmss_port, dev); +sc6000_prepare_board (devptr, sc6000, dev, xirq, xdma); + + err =sc6000_init_board (devptr, sc6000);if (err <0 )return err; card->private_free = snd_sc6000_free;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 478/776 ktest: Avoid undef warning when WARNINGS_FILE is unset
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo B. Marlière <[email protected]>
[ Upstream commit 057854f8a595160656fe77ed7bf0d2403724b915 ]
check_buildlog() probes $warnings_file with -f even when WARNINGS_FILE is not configured. Perl warns about the uninitialized value and adds noise to the test log, which can hide the output we actually care about.
Check that WARNINGS_FILE is defined before testing whether the file exists.
--- tools/testing/ktest/ktest.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/ktest/ktest.pl +1 -1
@@ -2465,7 +2465,7 @@ sub check_buildlog { my $save_no_reboot = $no_reboot; $no_reboot = 1; - if (-f $warnings_file) { + if (defined($warnings_file) && -f $warnings_file) { open(IN, $warnings_file) or dodie "Error opening $warnings_file";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 479/776 ktest: Honor empty per-test option overrides
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo B. Marlière <[email protected]>
[ Upstream commit a2de57a3c8192dcd67cccaff6c341b93748d799b ]
A per-test override can clear an inherited default option by assigning an empty value, but __set_test_option() still used option_defined() to decide whether a per-test key existed. That turned an empty per-test assignment back into "fall back to the default", so tests still could not clear inherited settings.
For example:
DEFAULTS
(...)
LOG_FILE = /tmp/ktest-empty-override.log
CLEAR_LOG = 1
ADD_CONFIG = /tmp/.config
TEST_START
TEST_TYPE = build
BUILD_TYPE = nobuild
ADD_CONFIG =
This would run the test with ADD_CONFIG[1] = /tmp/.config
Fix by checking whether the per-test key exists before falling back. If it does exist but is empty, treat it as unset for that test and stop the fallback chain there.
--- tools/testing/ktest/ktest.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
tools/testing/ktest/ktest.pl +4 -2
@@ -4106,7 +4106,8 @@ sub __set_test_option { my $option = "$name\[$i\]"; - if (option_defined($option)) { + if (exists($opt{$option})) { + return undef if (!option_defined($option)); return $opt{$option}; }
@@ -4114,7 +4115,8 @@ sub __set_test_option { if ($i >= $test && $i < $test + $repeat_tests{$test}) { $option = "$name\[$test\]"; - if (option_defined($option)) { + if (exists($opt{$option})) { + return undef if (!option_defined($option)); return $opt{$option}; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 480/776 ktest: Run POST_KTEST hooks on failure and cancellation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo B. Marlière <[email protected]>
[ Upstream commit bc6e165a452da909cef0efbc286e6695624db372 ]
PRE_KTEST can be useful for setting up the environment and POST_KTEST to tear it down, however POST_KTEST only runs on the normal end-of-run path. It is skipped when ktest exits through dodie() or cancel_test(). Final cleanup hooks are skipped.
Factor the final hook execution into run_post_ktest(), call it from the normal exit path and from the early exit paths, and guard it so the hook runs at most once.
--- tools/testing/ktest/ktest.pl | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-)
tools/testing/ktest/ktest.pl +22 -5
@@ -98,6 +98,7 @@ my $test_type; my $build_type; my $build_options; my $final_post_ktest; +my $post_ktest_done = 0; my $pre_ktest; my $post_ktest; my $pre_test;
@@ -1530,6 +1531,24 @@ sub get_test_name() { return $name; } +sub run_post_ktest { + my $cmd; + + return if ($post_ktest_done); + + if (defined($final_post_ktest)) { + $cmd = $final_post_ktest; + } elsif (defined($post_ktest)) { + $cmd = $post_ktest; + } else { + return; + } + + my $cp_post_ktest = eval_kernel_version($cmd); + run_command $cp_post_ktest; + $post_ktest_done = 1; +} + sub dodie { # avoid recursion return if ($in_die);
@@ -1589,6 +1608,7 @@ sub dodie { if (defined($post_test)) { run_command $post_test; } + run_post_ktest; die @_, "\n"; }
@@ -4223,6 +4243,7 @@ sub cancel_test { send_email("KTEST: Your [$name] test was cancelled", "Your test started at $script_start_time was cancelled: sig int"); } + run_post_ktest; die "\nCaught Sig Int, test interrupted: $!\n" }
@@ -4533,11 +4554,7 @@ for (my $i = 1; $i <= $opt{"NUM_TESTS"}; $i++) { success $i; } -if (defined($final_post_ktest)) { - - my $cp_final_post_ktest = eval_kernel_version $final_post_ktest; - run_command $cp_final_post_ktest; -} +run_post_ktest; if ($opt{"POWEROFF_ON_SUCCESS"}) { halt;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 481/776 quota: Fix race of dquot_scan_active() with quota deactivation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
[ Upstream commit e93ab401da4b2e2c1b8ef2424de2f238d51c8b2d ]
dquot_scan_active() can race with quota deactivation in quota_release_workfn() like:
CPU0 (quota_release_workfn) CPU1 (dquot_scan_active)
============================== ==============================
spin_lock(&dq_list_lock);
list_replace_init(
&releasing_dquots, &rls_head);
/* dquot X on rls_head,
dq_count == 0,
DQ_ACTIVE_B still set */
spin_unlock(&dq_list_lock);
synchronize_srcu(&dquot_srcu);
spin_lock(&dq_list_lock);
list_for_each_entry(dquot,
&inuse_list, dq_inuse) {
/* finds dquot X */
dquot_active(X) -> true
atomic_inc(&X->dq_count);
}
spin_unlock(&dq_list_lock);
spin_lock(&dq_list_lock);
dquot = list_first_entry(&rls_head);
WARN_ON_ONCE(atomic_read(&dquot->dq_count));The problem is not only a cosmetic one as under memory pressure the caller of dquot_scan_active() can end up working on freed dquot.
Fix the problem by making sure the dquot is removed from releasing list when we acquire a reference to it.
--- fs/quota/dquot.c | 38 ++++++++++++++++++++++++++++++-------- include/linux/quotaops.h | 9 +-------- 2 files changed, 31 insertions(+), 16 deletions(-)
fs/quota/dquot.c +30 -8
@@ -362,6 +362,31 @@ static inline int dquot_active(struct dquot *dquot)return test_bit (DQ_ACTIVE_B , &dquot->dq_flags); } +static struct dquot *__dqgrab (struct dquot *dquot) +{ +lockdep_assert_held (&dq_list_lock); +if (!atomic_read (&dquot->dq_count)) +remove_free_dquot (dquot); +atomic_inc (&dquot->dq_count); +return dquot; +} + +/* +* Get reference to dquot when we got pointer to it by some other means. The +* dquot has to be active and the caller has to make sure it cannot get +* deactivated under our hands. +*/ +struct dquot *dqgrab (struct dquot *dquot) +{ +spin_lock (&dq_list_lock); +WARN_ON_ONCE (!dquot_active (dquot)); + dquot =__dqgrab (dquot); +spin_unlock (&dq_list_lock); + +return dquot; +} +EXPORT_SYMBOL_GPL (dqgrab); +static inline int dquot_dirty (struct dquot *dquot) {return test_bit (DQ_MOD_B , &dquot->dq_flags);
@@ -640,15 +665,14 @@ int dquot_scan_active(struct super_block *sb,continue ;if (dquot->dq_sb != sb)continue ; -/* Now we have active dquot so we can just increase use count */ -atomic_inc (&dquot->dq_count); +__dqgrab (dquot);spin_unlock (&dq_list_lock);dqput (old_dquot); old_dquot = dquot;/* * ->release_dquot() can be racing with us. Our reference -* protects us from new calls to it so just wait for any -* outstanding call and recheck the DQ_ACTIVE_B after that. +* protects us from dquot_release() proceeding so just wait for +* any outstanding call and recheck the DQ_ACTIVE_B after that. */ wait_on_dquot (dquot);if (dquot_active (dquot)) {
@@ -716,7 +740,7 @@ int dquot_writeback_dquots(struct super_block *sb, int type)/* Now we have active dquot from which someone is * holding reference so we can safely just increase * use count */ -dqgrab (dquot); +__dqgrab (dquot);spin_unlock (&dq_list_lock); err =dquot_write_dquot (dquot);if (err && !ret)
@@ -971,9 +995,7 @@ struct dquot *dqget(struct super_block *sb, struct kqid qid)spin_unlock (&dq_list_lock);dqstats_inc (DQST_LOOKUPS ); }else { -if (!atomic_read (&dquot->dq_count)) -remove_free_dquot (dquot); -atomic_inc (&dquot->dq_count); +__dqgrab (dquot);spin_unlock (&dq_list_lock);dqstats_inc (DQST_CACHE_HITS );dqstats_inc (DQST_LOOKUPS );
include/linux/quotaops.h +1 -8
@@ -43,14 +43,7 @@ int dquot_initialize(struct inode *inode);bool dquot_initialize_needed (struct inode *inode);void dquot_drop (struct inode *inode);struct dquot *dqget (struct super_block *sb,struct kqid qid); -static inline struct dquot *dqgrab (struct dquot *dquot) -{ -/* Make sure someone else has active reference to dquot */ -WARN_ON_ONCE (!atomic_read (&dquot->dq_count)); -WARN_ON_ONCE (!test_bit (DQ_ACTIVE_B , &dquot->dq_flags)); -atomic_inc (&dquot->dq_count); -return dquot; -} +struct dquot *dqgrab (struct dquot *dquot);static inline bool dquot_is_busy (struct dquot *dquot) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 482/776 gfs2: add some missing log locking
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Gruenbacher <[email protected]>
[ Upstream commit fe2c8d051150b90b3ccb85f89e3b1d636cb88ec8 ]
Function gfs2_logd() calls the log flushing functions gfs2_ail1_start(), gfs2_ail1_wait(), and gfs2_ail1_empty() without holding sdp->sd_log_flush_lock, but these functions require exclusion against concurrent transactions.
To fix that, add a non-locking __gfs2_log_flush() function. Then, in gfs2_logd(), take sdp->sd_log_flush_lock before calling the above mentioned log flushing functions and __gfs2_log_flush().
--- fs/gfs2/log.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)
fs/gfs2/log.c +20 -8
@@ -1017,14 +1017,15 @@ static void trans_drain(struct gfs2_trans *tr) }/** -* gfs2_log_flush - flush incore transaction(s) +* __gfs2_log_flush - flush incore transaction(s) * @sdp: The filesystem * @gl: The glock structure to flush. If NULL, flush the whole incore log * @flags: The log header flags: GFS2_LOG_HEAD_FLUSH_* and debug flags * */ -void gfs2_log_flush (struct gfs2_sbd *sdp,struct gfs2_glock *gl,u32 flags) +static void __gfs2_log_flush (struct gfs2_sbd *sdp,struct gfs2_glock *gl, +u32 flags) {struct gfs2_trans *tr =NULL ;unsigned int reserved_blocks =0 , used_blocks =0 ;
@@ -1032,7 +1033,6 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)unsigned int first_log_head;unsigned int reserved_revokes =0 ; -down_write (&sdp->sd_log_flush_lock);trace_gfs2_log_flush (sdp,1 , flags); repeat:
@@ -1145,7 +1145,6 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags)gfs2_assert_withdraw_delayed (sdp, used_blocks < reserved_blocks);gfs2_log_release (sdp, reserved_blocks - used_blocks); } -up_write (&sdp->sd_log_flush_lock);gfs2_trans_free (sdp, tr);if (gfs2_withdrawing (sdp))gfs2_withdraw (sdp);
@@ -1168,6 +1167,13 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl, u32 flags) goto out_end; } +void gfs2_log_flush (struct gfs2_sbd *sdp,struct gfs2_glock *gl,u32 flags) +{ +down_write (&sdp->sd_log_flush_lock); +__gfs2_log_flush (sdp, gl, flags); +up_write (&sdp->sd_log_flush_lock); +} +/** * gfs2_merge_trans - Merge a new transaction into a cached transaction * @sdp: the filesystem
@@ -1313,19 +1319,25 @@ int gfs2_logd(void *data) }if (gfs2_jrnl_flush_reqd (sdp) || t ==0 ) { +down_write (&sdp->sd_log_flush_lock);gfs2_ail1_empty (sdp,0 ); -gfs2_log_flush (sdp,NULL ,GFS2_LOG_HEAD_FLUSH_NORMAL | -GFS2_LFC_LOGD_JFLUSH_REQD ); +__gfs2_log_flush (sdp,NULL , +GFS2_LOG_HEAD_FLUSH_NORMAL | +GFS2_LFC_LOGD_JFLUSH_REQD ); +up_write (&sdp->sd_log_flush_lock); }if (test_bit (SDF_FORCE_AIL_FLUSH , &sdp->sd_flags) ||gfs2_ail_flush_reqd (sdp)) {clear_bit (SDF_FORCE_AIL_FLUSH , &sdp->sd_flags); +down_write (&sdp->sd_log_flush_lock);gfs2_ail1_start (sdp);gfs2_ail1_wait (sdp);gfs2_ail1_empty (sdp,0 ); -gfs2_log_flush (sdp,NULL ,GFS2_LOG_HEAD_FLUSH_NORMAL | -GFS2_LFC_LOGD_AIL_FLUSH_REQD ); +__gfs2_log_flush (sdp,NULL , +GFS2_LOG_HEAD_FLUSH_NORMAL | +GFS2_LFC_LOGD_AIL_FLUSH_REQD ); +up_write (&sdp->sd_log_flush_lock); } t =gfs2_tune_get (sdp, gt_logd_secs) *HZ ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 483/776 gfs2: prevent NULL pointer dereference during unmount
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Gruenbacher <[email protected]>
[ Upstream commit 74b4dbb946060a3233604d91859a9abd3708141d ]
When flushing out outstanding glock work during an unmount, gfs2_log_flush() can be called when sdp->sd_jdesc has already been deallocated and sdp->sd_jdesc is NULL. Commit 35264909e9d1 ("gfs2: Fix NULL pointer dereference in gfs2_log_flush") added a check for that to gfs2_log_flush() itself, but it missed the sdp->sd_jdesc dereference in gfs2_log_release(). Fix that.
--- fs/gfs2/log.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/gfs2/log.c +3 -2
@@ -470,8 +470,9 @@ void gfs2_log_release(struct gfs2_sbd *sdp, unsigned int blks) {atomic_add (blks, &sdp->sd_log_blks_free);trace_gfs2_log_blocks (sdp, blks); -gfs2_assert_withdraw (sdp,atomic_read (&sdp->sd_log_blks_free) <= - sdp->sd_jdesc->jd_blocks); +gfs2_assert_withdraw (sdp, !sdp->sd_jdesc || +atomic_read (&sdp->sd_log_blks_free) <= + sdp->sd_jdesc->jd_blocks);if (atomic_read (&sdp->sd_log_blks_needed))wake_up (&sdp->sd_log_waitq); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 484/776 efi/capsule-loader: fix incorrect sizeof in phys array reallocation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Huth <[email protected]>
[ Upstream commit 48a428215782321b56956974f23593e40ce84b7a ]
The krealloc() call for cap_info->phys in __efi_capsule_setup_info() uses sizeof(phys_addr_t *) instead of sizeof(phys_addr_t), which might be causing an undersized allocation.
The allocation is also inconsistent with the initial array allocation in efi_capsule_open() that allocates one entry with sizeof(phys_addr_t), and the efi_capsule_write() function that stores phys_addr_t values (not pointers) via page_to_phys().
On 64-bit systems where sizeof(phys_addr_t) == sizeof(phys_addr_t *), this goes unnoticed. On 32-bit systems with PAE where phys_addr_t is 64-bit but pointers are 32-bit, this allocates half the required space, which might lead to a heap buffer overflow when storing physical addresses.
This is similar to the bug fixed in commit fccfa646ef36 ("efi/capsule-loader:
fix incorrect allocation size") which fixed the same issue at the initial allocation site.
--- drivers/firmware/efi/capsule-loader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/capsule-loader.c +1 -1
@@ -67,7 +67,7 @@ int __efi_capsule_setup_info(struct capsule_info *cap_info) cap_info->pages = temp_page; temp_page =krealloc (cap_info->phys, - pages_needed *sizeof (phys_addr_t *), + pages_needed *sizeof (phys_addr_t),GFP_KERNEL | __GFP_ZERO);if (!temp_page)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 485/776 ksmbd: fix use-after-free from async crypto on Qualcomm crypto engine
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joshua Klinesmith <[email protected]>
[ Upstream commit 3e298897f41c61450c2e7a4f457e8b2485eb35b3 ]
ksmbd_crypt_message() sets a NULL completion callback on AEAD requests and does not handle the -EINPROGRESS return code from async hardware crypto engines like the Qualcomm Crypto Engine (QCE). When QCE returns -EINPROGRESS, ksmbd treats it as an error and immediately frees the request while the hardware DMA operation is still in flight. The DMA completion callback then dereferences freed memory, causing a NULL pointer crash:
pc : qce_skcipher_done+0x24/0x174 lr : vchan_complete+0x230/0x27c ... el1h_64_irq+0x68/0x6c ksmbd_free_work_struct+0x20/0x118 [ksmbd] ksmbd_exit_file_cache+0x694/0xa4c [ksmbd]
Use the standard crypto_wait_req() pattern with crypto_req_done() as the completion callback, matching the approach used by the SMB client in fs/smb/client/smb2ops.c. This properly handles both synchronous engines (immediate return) and async engines (-EINPROGRESS followed by callback notification).
--- fs/ksmbd/auth.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/ksmbd/auth.c +6 -5
@@ -1108,6 +1108,7 @@ int ksmbd_crypt_message(struct ksmbd_work *work, struct kvec *iov,struct smb2_transform_hdr *tr_hdr =smb2_get_msg (iov[0 ].iov_base);unsigned int assoc_data_len =sizeof (struct smb2_transform_hdr ) -20 ;int rc; +DECLARE_CRYPTO_WAIT (wait);struct scatterlist *sg;u8 sign[SMB2_SIGNATURE_SIZE ] = {};u8 key[SMB3_ENC_DEC_KEY_SIZE ];
@@ -1194,12 +1195,12 @@ int ksmbd_crypt_message(struct ksmbd_work *work, struct kvec *iov,aead_request_set_crypt (req, sg, sg, crypt_len, iv);aead_request_set_ad (req, assoc_data_len); -aead_request_set_callback (req,CRYPTO_TFM_REQ_MAY_SLEEP ,NULL ,NULL ); +aead_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG | +CRYPTO_TFM_REQ_MAY_SLEEP , + crypto_req_done, &wait); -if (enc) - rc =crypto_aead_encrypt (req); -else - rc =crypto_aead_decrypt (req); + rc =crypto_wait_req (enc ?crypto_aead_encrypt (req) : +crypto_aead_decrypt (req), &wait);if (rc) goto free_iv;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 486/776 ARM: dts: mediatek: mt7623: fix efuse fallback compatible
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafał Miłecki <[email protected]>
[ Upstream commit 5978ff33cc6f0988388a2830dc5cd2ea4e81f36a ]
Fix following validation error:arch/arm/boot/dts/mediatek/mt7623a-rfb-emmc.dtb: efuse@10206000: compatible: 'oneOf' conditional failed, one must be fixed:
['mediatek,mt7623-efuse', 'mediatek,mt8173-efuse'] is too long
'mediatek,mt8173-efuse' was expected
'mediatek,efuse' was expected
from schema $id: http://devicetree.org/schemas/nvmem/mediatek,efuse.yaml#arch/arm/boot/dts/mediatek/mt7623a-rfb-emmc.dtb: efuse@10206000: Unevaluated properties are not allowed ('compatible' was unexpected)
from schema $id: http://devicetree.org/schemas/nvmem/mediatek,efuse.yaml#
--- arch/arm/boot/dts/mt7623.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/mt7623.dtsi +1 -1
@@ -329,7 +329,7 @@ sysirq: interrupt-controller@10200100 { efuse: efuse@10206000 { compatible = "mediatek,mt7623-efuse", - "mediatek,mt8173-efuse"; + "mediatek,efuse"; reg = <0 0x10206000 0 0x1000>; #address-cells = <1>; #size-cells = <1>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 487/776 memory: tegra124-emc: Fix dll_change check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Perttunen <[email protected]>
[ Upstream commit 9597ab9a8296ab337e6820f8a717ff621078b632 ]
The code checking whether the specified memory timing enables DLL in the EMRS register was reversed. DLL is enabled if bit A0 is low. Fix the check.
--- drivers/memory/tegra/tegra124-emc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/memory/tegra/tegra124-emc.c +1 -1
@@ -608,7 +608,7 @@ static int tegra_emc_prepare_timing_change(struct tegra_emc *emc,if ((last->emc_mode_1 &0x1 ) == (timing->emc_mode_1 &0x1 )) dll_change =DLL_CHANGE_NONE ; -else if (timing->emc_mode_1 &0x1 ) +else if (!(timing->emc_mode_1 &0x1 )) dll_change =DLL_CHANGE_ON ;else dll_change =DLL_CHANGE_OFF ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 488/776 memory: tegra30-emc: Fix dll_change check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Perttunen <[email protected]>
[ Upstream commit 0a93f2355cf4922ad2399dbef5ea1049fef116d4 ]
The code checking whether the specified memory timing enables DLL in the EMRS register was reversed. DLL is enabled if bit A0 is low. Fix the check.
--- drivers/memory/tegra/tegra30-emc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/memory/tegra/tegra30-emc.c +3 -3
@@ -539,14 +539,14 @@ static int emc_prepare_timing_change(struct tegra_emc *emc, unsigned long rate) emc->emc_cfg =readl_relaxed (emc->regs +EMC_CFG ); emc_dbg =readl_relaxed (emc->regs +EMC_DBG ); -if (emc->dll_on == !!(timing->emc_mode_1 &0x1 )) +if (emc->dll_on == !(timing->emc_mode_1 &0x1 )) dll_change =DLL_CHANGE_NONE ; -else if (timing->emc_mode_1 &0x1 ) +else if (!(timing->emc_mode_1 &0x1 )) dll_change =DLL_CHANGE_ON ;else dll_change =DLL_CHANGE_OFF ; - emc->dll_on = !!(timing->emc_mode_1 &0x1 ); + emc->dll_on = !(timing->emc_mode_1 &0x1 );if (timing->data[80 ] && !readl_relaxed (emc->regs +EMC_ZCAL_INTERVAL )) emc->zcal_long = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 489/776 soc: qcom: ocmem: use scoped device node handling to simplify error paths
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit f4c1c19f5c0e5cf2870df91dedc6b40400fd9c8a ]
Obtain the device node reference with scoped/cleanup.h to reduce error handling and make the code a bit simpler.
Stable-dep-of: 9dfd69cd89cd ("soc: qcom: ocmem: register reasons for probe deferrals")
--- drivers/soc/qcom/ocmem.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/soc/qcom/ocmem.c +2 -5
@@ -192,23 +192,20 @@ static void update_range(struct ocmem *ocmem, struct ocmem_buf *buf,struct ocmem *of_get_ocmem (struct device *dev) {struct platform_device *pdev; -struct device_node *devnode;struct ocmem *ocmem; - devnode =of_parse_phandle (dev->of_node,"sram" ,0 ); + struct device_node *devnode __free(device_node) = of_parse_phandle(dev->of_node, +"sram" ,0 );if (!devnode || !devnode->parent) {dev_err (dev,"Cannot look up sram phandle\n" ); -of_node_put (devnode);return ERR_PTR (-ENODEV ); } pdev =of_find_device_by_node (devnode->parent);if (!pdev) {dev_err (dev,"Cannot find device node %s\n" , devnode->name); -of_node_put (devnode);return ERR_PTR (-EPROBE_DEFER ); } -of_node_put (devnode); ocmem =platform_get_drvdata (pdev);put_device (&pdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 490/776 soc: qcom: ocmem: register reasons for probe deferrals
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 9dfd69cd89cd6afa4723be9098979abeef3bb8c6 ]
Instead of printing messages to the dmesg, let the message be recorded as a reason for the OCMEM client deferral.
[bjorn: s/ERR_PTR(dev_err_probe)/dev_err_ptr_probe/
--- drivers/soc/qcom/ocmem.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/soc/qcom/ocmem.c +4 -4
@@ -202,10 +202,10 @@ struct ocmem *of_get_ocmem(struct device *dev) } pdev =of_find_device_by_node (devnode->parent); -if (!pdev) { -dev_err (dev,"Cannot find device node %s\n" , devnode->name); -return ERR_PTR (-EPROBE_DEFER ); - } +if (!pdev) +return dev_err_ptr_probe (dev, -EPROBE_DEFER , +"Cannot find device node %s\n" , + devnode->name); ocmem =platform_get_drvdata (pdev);put_device (&pdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 491/776 soc: qcom: ocmem: return -EPROBE_DEFER is ocmem is not available
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 91b59009c7d48b58dbc50fecb27f2ad20749a05a ]
If OCMEM is declared in DT, it is expected that it is present and handled by the driver. The GPU driver will ignore -ENODEV error, which typically means that OCMEM isn't defined in DT. Let ocmem return -EPROBE_DEFER if it supposed to be used, but it is not probed (yet).
[bjorn: s/ERR_PTR(dev_err_probe)/dev_err_ptr_probe/
--- drivers/soc/qcom/ocmem.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/soc/qcom/ocmem.c +3 -4
@@ -209,10 +209,9 @@ struct ocmem *of_get_ocmem(struct device *dev) ocmem =platform_get_drvdata (pdev);put_device (&pdev->dev); -if (!ocmem) { -dev_err (dev,"Cannot get ocmem\n" ); -return ERR_PTR (-ENODEV ); - } +if (!ocmem) +return dev_err_ptr_probe (dev, -EPROBE_DEFER ,"Cannot get ocmem\n" ); +return ocmem; }EXPORT_SYMBOL (of_get_ocmem);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 492/776 arm64: dts: qcom: sdm845-xiaomi-beryllium: Mark l1a regulator as powered during boot
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Heidelberg <[email protected]>
[ Upstream commit 3b0dd81eea6b7a239fce456ce4545af76f1a9715 ]
The regulator must be on, since it provides the display subsystem and therefore the bootloader had turned it on before Linux booted.
--- arch/arm64/boot/dts/qcom/sdm845-xiaomi-beryllium.dts | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/qcom/sdm845-xiaomi-beryllium.dts +1 -0
@@ -133,6 +133,7 @@ vreg_l1a_0p875: ldo1 { regulator-min-microvolt = <880000>; regulator-max-microvolt = <880000>; regulator-initial-mode = <RPMH_REGULATOR_MODE_HPM>; + regulator-boot-on; }; vreg_l5a_0p8: ldo5 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 493/776 unshare: fix nsproxy leak in ksys_unshare() on set_cred_ucounts() failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Grzedzicki <[email protected]>
[ Upstream commit a98621a0f187a934c115dcfe79a49520ae892111 ]
When set_cred_ucounts() fails in ksys_unshare() new_nsproxy is leaked.
Let's call put_nsproxy() if that happens.
--- kernel/fork.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
kernel/fork.c +7 -4
@@ -3176,11 +3176,10 @@ int ksys_unshare(unsigned long unshare_flags) new_cred, new_fs);if (err) goto bad_unshare_cleanup_cred; -if (new_cred) { err =set_cred_ucounts (new_cred);if (err) - goto bad_unshare_cleanup_cred; + goto bad_unshare_cleanup_nsproxy; }if (new_fs || new_fd || do_sysvsem || new_cred || new_nsproxy) {
@@ -3196,8 +3195,10 @@ int ksys_unshare(unsigned long unshare_flags)shm_init_task (current); } -if (new_nsproxy) +if (new_nsproxy) {switch_task_namespaces (current, new_nsproxy); + new_nsproxy =NULL ; + }task_lock (current);
@@ -3229,13 +3230,15 @@ int ksys_unshare(unsigned long unshare_flags)perf_event_namespaces (current); +bad_unshare_cleanup_nsproxy: +if (new_nsproxy) +put_nsproxy (new_nsproxy); bad_unshare_cleanup_cred:if (new_cred)put_cred (new_cred); bad_unshare_cleanup_fd:if (new_fd)put_files_struct (new_fd); - bad_unshare_cleanup_fs:if (new_fs)free_fs_struct (new_fs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 494/776 ocfs2/dlm: validate qr_numregions in dlm_match_regions()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
[ Upstream commit 7ab3fbb01bc6d79091bc375e5235d360cd9b78be ]
Patch series "ocfs2/dlm: fix two bugs in dlm_match_regions()".
In dlm_match_regions(), the qr_numregions field from a DLM_QUERY_REGION network message is used to drive loops over the qr_regions buffer without sufficient validation. This series fixes two issues:
- Patch 1 adds a bounds check to reject messages where qr_numregions exceeds O2NM_MAX_REGIONS. The o2net layer only validates message byte length; it does not constrain field values, so a crafted message can set qr_numregions up to 255 and trigger out-of-bounds reads past the 1024-byte qr_regions buffer.
- Patch 2 fixes an off-by-one in the local-vs-remote comparison loop, which uses '<=' instead of '<', reading one entry past the valid range even when qr_numregions is within bounds.
This patch (of 2):
The qr_numregions field from a DLM_QUERY_REGION network message is used directly as loop bounds in dlm_match_regions() without checking against O2NM_MAX_REGIONS. Since qr_regions is sized for at most O2NM_MAX_REGIONS
(32) entries, a crafted message with qr_numregions > 32 causes out-of-bounds reads past the qr_regions buffer.
Add a bounds check for qr_numregions before entering the loops.
--- fs/ocfs2/dlm/dlmdomain.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/ocfs2/dlm/dlmdomain.c +8 -0
@@ -980,6 +980,14 @@ static int dlm_match_regions(struct dlm_ctxt *dlm, goto bail; } +if (qr->qr_numregions >O2NM_MAX_REGIONS ) { +mlog (ML_ERROR ,"Domain %s: Joining node %d has invalid " +"number of heartbeat regions %u\n" , + qr->qr_domain, qr->qr_node, qr->qr_numregions); + status = -EINVAL ; + goto bail; + } + r = remote;for (i =0 ; i < qr->qr_numregions; ++i) {mlog (0 ,"Region %.*s\n" ,O2HB_MAX_REGION_NAME_LEN , r);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 495/776 ocfs2/dlm: fix off-by-one in dlm_match_regions() region comparison
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
[ Upstream commit 01b61e8dda9b0fdb0d4cda43de25f4e390554d7b ]
The local-vs-remote region comparison loop uses '<=' instead of '<', causing it to read one entry past the valid range of qr_regions. The other loops in the same function correctly use '<'.
Fix the loop condition to use '<' for consistency and correctness.
--- fs/ocfs2/dlm/dlmdomain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ocfs2/dlm/dlmdomain.c +1 -1
@@ -1002,7 +1002,7 @@ static int dlm_match_regions(struct dlm_ctxt *dlm,for (i =0 ; i < localnr; ++i) { foundit =0 ; r = remote; -for (j =0 ; j <= qr->qr_numregions; ++j) { +for (j =0 ; j < qr->qr_numregions; ++j) {if (!memcmp (l, r,O2HB_MAX_REGION_NAME_LEN )) { foundit =1 ;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 496/776 soc: qcom: aoss: compare against normalized cooling state
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alok Tiwari <[email protected]>
[ Upstream commit cd3c4670db3ffe997be9548c7a9db3952563cf14 ]
qmp_cdev_set_cur_state() normalizes the requested state to a boolean (cdev_state = !!state). The existing early-return check compares qmp_cdev->state == state, which can be wrong if state is non-boolean (any non-zero value). Compare qmp_cdev->state against cdev_state instead, so the check matches the effective state and avoids redundant updates.
--- drivers/soc/qcom/qcom_aoss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/qcom/qcom_aoss.c +1 -1
@@ -436,7 +436,7 @@ static int qmp_cdev_set_cur_state(struct thermal_cooling_device *cdev,/* Normalize state */ cdev_state = !!state; -if (qmp_cdev->state == state) +if (qmp_cdev->state == cdev_state)return 0 ; snprintf(buf, sizeof(buf),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 497/776 ocfs2: fix listxattr handling when the buffer is full
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: ZhengYuan Huang <[email protected]>
[ Upstream commit d12f558e6200b3f47dbef9331ed6d115d2410e59 ]
[BUG]
If an OCFS2 inode has both inline and block-based xattrs, listxattr() can return a size larger than the caller's buffer when the inline names consume that buffer exactly.
kernel BUG at mm/usercopy.c:102!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI RIP: 0010:usercopy_abort+0xb7/0xd0 mm/usercopy.c:102 Call Trace: __check_heap_object+0xe3/0x120 mm/slub.c:8243 check_heap_object mm/usercopy.c:196 [inline] __check_object_size mm/usercopy.c:250 [inline] __check_object_size+0x5c5/0x780 mm/usercopy.c:215 check_object_size include/linux/ucopysize.h:22 [inline] check_copy_size include/linux/ucopysize.h:59 [inline] copy_to_user include/linux/uaccess.h:219 [inline] listxattr+0xb0/0x170 fs/xattr.c:926 filename_listxattr fs/xattr.c:958 [inline] path_listxattrat+0x137/0x320 fs/xattr.c:988 __do_sys_listxattr fs/xattr.c:1001 [inline] __se_sys_listxattr fs/xattr.c:998 [inline] __x64_sys_listxattr+0x7f/0xd0 fs/xattr.c:998 ...
[CAUSE]
Commit 936b8834366e ("ocfs2: Refactor xattr list and remove ocfs2_xattr_handler().") replaced the old per-handler list accounting with ocfs2_xattr_list_entry(), but it kept using size == 0 to detect probe mode.
That assumption stops being true once ocfs2_listxattr() finishes the inline-xattr pass. If the inline names fill the caller buffer exactly, the block-xattr pass runs with a non-NULL buffer and a remaining size of zero. ocfs2_xattr_list_entry() then skips the bounds check, keeps counting block names, and returns a positive size larger than the supplied buffer.
[FIX]
Detect probe mode by testing whether the destination buffer pointer is NULL instead of whether the remaining size is zero.
That restores the pre-refactor behavior and matches the OCFS2 getxattr helpers. Once the remaining buffer reaches zero while more names are left, the block-xattr pass now returns -ERANGE instead of reporting a size larger than the allocated list buffer.
--- fs/ocfs2/xattr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ocfs2/xattr.c +2 -2
@@ -911,8 +911,8 @@ static int ocfs2_xattr_list_entry(struct super_block *sb, total_len = prefix_len + name_len +1 ; *result += total_len; -/* we are just looking for how big our buffer needs to be */ -if (!size) +/* No buffer means we are only looking for the required size. */ +if (!buffer)return 0 ;if (*result > size)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 498/776 ocfs2: validate bg_bits during freefrag scan
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: ZhengYuan Huang <[email protected]>
[ Upstream commit 8f687eeed3da3012152b0f9473f578869de0cd7b ]
[BUG]
A crafted filesystem can trigger an out-of-bounds bitmap walk when OCFS2_IOC_INFO is issued with OCFS2_INFO_FL_NON_COHERENT.
BUG: KASAN: use-after-free in instrument_atomic_read include/linux/instrumented.h:68 [inline] BUG: KASAN: use-after-free in _test_bit include/asm-generic/bitops/instrumented-non-atomic.h:141 [inline] BUG: KASAN: use-after-free in test_bit_le include/asm-generic/bitops/le.h:21 [inline] BUG: KASAN: use-after-free in ocfs2_info_freefrag_scan_chain fs/ocfs2/ioctl.c:495 [inline] BUG: KASAN: use-after-free in ocfs2_info_freefrag_scan_bitmap fs/ocfs2/ioctl.c:588 [inline] BUG: KASAN: use-after-free in ocfs2_info_handle_freefrag fs/ocfs2/ioctl.c:662 [inline] BUG: KASAN: use-after-free in ocfs2_info_handle_request+0x1c66/0x3370 fs/ocfs2/ioctl.c:754 Read of size 8 at addr ffff888031bce000 by task syz.0.636/1435 Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0xbe/0x130 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xd1/0x650 mm/kasan/report.c:482 kasan_report+0xfb/0x140 mm/kasan/report.c:595 check_region_inline mm/kasan/generic.c:186 [inline] kasan_check_range+0x11c/0x200 mm/kasan/generic.c:200 __kasan_check_read+0x11/0x20 mm/kasan/shadow.c:31 instrument_atomic_read include/linux/instrumented.h:68 [inline] _test_bit include/asm-generic/bitops/instrumented-non-atomic.h:141 [inline] test_bit_le include/asm-generic/bitops/le.h:21 [inline] ocfs2_info_freefrag_scan_chain fs/ocfs2/ioctl.c:495 [inline] ocfs2_info_freefrag_scan_bitmap fs/ocfs2/ioctl.c:588 [inline] ocfs2_info_handle_freefrag fs/ocfs2/ioctl.c:662 [inline] ocfs2_info_handle_request+0x1c66/0x3370 fs/ocfs2/ioctl.c:754 ocfs2_info_handle+0x18d/0x2a0 fs/ocfs2/ioctl.c:828 ocfs2_ioctl+0x632/0x6e0 fs/ocfs2/ioctl.c:913 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:597 [inline] __se_sys_ioctl fs/ioctl.c:583 [inline] __x64_sys_ioctl+0x197/0x1e0 fs/ioctl.c:583 ...
[CAUSE]ocfs2_info_freefrag_scan_chain() uses on-disk bg_bits directly as the bitmap scan limit. The coherent path reads group descriptors through ocfs2_read_group_descriptor(), which validates the descriptor before use. The non-coherent path uses ocfs2_read_blocks_sync() instead and skips that validation, so an impossible bg_bits value can drive the bitmap walk past the end of the block.
[FIX]
Compute the bitmap capacity from the filesystem format with ocfs2_group_bitmap_size(), report descriptors whose bg_bits exceeds that limit, and clamp the scan to the computed capacity. This keeps the freefrag report going while avoiding reads beyond the buffer.
--- fs/ocfs2/ioctl.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
fs/ocfs2/ioctl.c +17 -1
@@ -442,13 +442,16 @@ static int ocfs2_info_freefrag_scan_chain(struct ocfs2_super *osb,struct buffer_head *bh =NULL ;struct ocfs2_group_desc *bg =NULL ; -unsigned int max_bits, num_clusters; +unsigned int max_bits, max_bitmap_bits, num_clusters;unsigned int offset =0 , cluster, chunk;unsigned int chunk_free, last_chunksize =0 ;if (!le32_to_cpu (rec->c_free)) goto bail; + max_bitmap_bits =8 *ocfs2_group_bitmap_size (osb->sb,0 , + osb->s_feature_incompat); + do { if (!bg) blkno = le64_to_cpu(rec->c_blkno);
@@ -480,6 +483,19 @@ static int ocfs2_info_freefrag_scan_chain(struct ocfs2_super *osb,continue ; max_bits =le16_to_cpu (bg->bg_bits); + +/* +* Non-coherent scans read raw blocks and do not get the +* bg_bits validation from +* ocfs2_read_group_descriptor(). +*/ +if (max_bits > max_bitmap_bits) { +mlog (ML_ERROR , +"Group desc #%llu has %u bits, max bitmap bits %u\n" , + (unsigned long long )blkno, max_bits, max_bitmap_bits); + max_bits = max_bitmap_bits; + } + offset =0 ;for (chunk =0 ; chunk < chunks_in_group; chunk++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 499/776 ocfs2: validate group add input before caching
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: ZhengYuan Huang <[email protected]>
[ Upstream commit 70b672833f4025341c11b22c7f83778a5cd611bc ]
[BUG]OCFS2_IOC_GROUP_ADD can trigger a BUG_ON inocfs2_set_new_buffer_uptodate():
kernel BUG at fs/ocfs2/uptodate.c:509!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI RIP: 0010:ocfs2_set_new_buffer_uptodate+0x194/0x1e0 fs/ocfs2/uptodate.c:509 Code: ffffe88f 42b9fe4c 89e64889 dfe8b4df Call Trace: ocfs2_group_add+0x3f1/0x1510 fs/ocfs2/resize.c:507 ocfs2_ioctl+0x309/0x6e0 fs/ocfs2/ioctl.c:887 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:597 [inline] __se_sys_ioctl fs/ioctl.c:583 [inline] __x64_sys_ioctl+0x197/0x1e0 fs/ioctl.c:583 x64_sys_call+0x1144/0x26a0 arch/x86/include/generated/asm/syscalls_64.h:17 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x93/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7bbfb55a966d
[CAUSE]ocfs2_group_add() calls ocfs2_set_new_buffer_uptodate() on a user-controlled group block before ocfs2_verify_group_and_input() validates that block number. That helper is only valid for newly allocated metadata and asserts that the block is not already present in the chosen metadata cache. The code also uses INODE_CACHE(inode) even though the group descriptor belongs to main_bm_inode and later journal accesses use that cache context instead.
[FIX]
Validate the on-disk group descriptor before caching it, then add it to the metadata cache tracked by INODE_CACHE(main_bm_inode). Keep the validation failure path separate from the later cleanup path so we only remove the buffer from that cache after it has actually been inserted. This keeps the group buffer lifetime consistent across validation, journaling, and cleanup.
--- fs/ocfs2/resize.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
fs/ocfs2/resize.c +7 -5
@@ -500,14 +500,14 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input) goto out_unlock; } -ocfs2_set_new_buffer_uptodate (INODE_CACHE (inode), group_bh); - ret =ocfs2_verify_group_and_input (main_bm_inode, fe, input, group_bh);if (ret) {mlog_errno (ret); goto out_free_group_bh; } +ocfs2_set_new_buffer_uptodate (INODE_CACHE (main_bm_inode), group_bh); +trace_ocfs2_group_add ((unsigned long long )input->group, input->chain, input->clusters, input->frees);
@@ -515,7 +515,7 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input)if (IS_ERR (handle)) {mlog_errno (PTR_ERR (handle)); ret = -EINVAL ; - goto out_free_group_bh; + goto out_remove_cache; } cl_bpc =le16_to_cpu (fe->id2.i_chain.cl_bpc);
@@ -569,9 +569,11 @@ int ocfs2_group_add(struct inode *inode, struct ocfs2_new_group_input *input) out_commit:ocfs2_commit_trans (osb, handle); -out_free_group_bh: +out_remove_cache:if (ret <0 ) -ocfs2_remove_from_cache (INODE_CACHE (inode), group_bh); +ocfs2_remove_from_cache (INODE_CACHE (main_bm_inode), group_bh); + +out_free_group_bh:brelse (group_bh); out_unlock:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 500/776 dmaengine: dw-axi-dmac: Remove unnecessary return statement from void function
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Khairul Anuar Romli <[email protected]>
[ Upstream commit 48278a72fce8a8d30efaedeb206c9c3f05c1eb3f ]
checkpatch.pl --strict reports a WARNING in dw-axi-dmac-platform.c:
WARNING: void function return statements are not generally useful
FILE: drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
According to Linux kernel coding style [Documentation/process/ coding-style.rst], explicit "return;" statements at the end of void functions are redundant and should be omitted. The function will automatically return upon reaching the closing brace, so the extra statement adds unnecessary clutter without functional benefit.
This patch removes the superfluous "return;" statement in dw_axi_dma_set_hw_channel() to comply with kernel coding standards and eliminate the checkpatch warning.
--- drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 2 -- 1 file changed, 2 deletions(-)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +0 -2
@@ -502,8 +502,6 @@ static void dw_axi_dma_set_hw_channel(struct axi_dma_chan *chan, bool set) (chan->id * DMA_APB_HS_SEL_BIT_SIZE)); reg_value |= (val << (chan->id *DMA_APB_HS_SEL_BIT_SIZE ));lo_hi_writeq (reg_value, chip->apb_regs +DMAC_APB_HW_HS_SEL_0 ); - -return ; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 501/776 dmaengine: mxs-dma: Fix missing return value from of_dma_controller_register()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Li <[email protected]>
[ Upstream commit ab2bf6d4c0a0152907b18d25c1b118ea5ea779df ]
Propagate the return value of of_dma_controller_register() in probe() instead of ignoring it.
--- drivers/dma/mxs-dma.c | 1 + 1 file changed, 1 insertion(+)
drivers/dma/mxs-dma.c +1 -0
@@ -827,6 +827,7 @@ static int mxs_dma_probe(struct platform_device *pdev)if (ret) {dev_err (mxs_dma->dma_device.dev,"failed to register controller\n" ); +return ret; }dev_info (mxs_dma->dma_device.dev,"initialized\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 502/776 tracing: Rebuild full_name on each hist_field_name() call
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 5ec1d1e97de134beed3a5b08235a60fc1c51af96 ]
hist_field_name() uses a static MAX_FILTER_STR_VAL buffer for fully qualified variable-reference names, but it currently appends into that buffer with strcat() without rebuilding it first. As a result, repeated calls append a new "system.event.field" name onto the previous one, which can eventually run past the end of full_name.
Build the name with snprintf() on each call and return NULL if the fully qualified name does not fit in MAX_FILTER_STR_VAL.
--- kernel/trace/trace_events_hist.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
kernel/trace/trace_events_hist.c +7 -5
@@ -1141,12 +1141,14 @@ static const char *hist_field_name(struct hist_field *field, field->flags & HIST_FIELD_FL_VAR_REF) {if (field->system) {static char full_name[MAX_FILTER_STR_VAL ]; +int len; + + len =snprintf (full_name,sizeof (full_name),"%s.%s.%s" , + field->system, field->event_name, + field->name); +if (len >=sizeof (full_name)) +return NULL ; -strcat (full_name, field->system); -strcat (full_name,"." ); -strcat (full_name, field->event_name); -strcat (full_name,"." ); -strcat (full_name, field->name); field_name = full_name; }else field_name = field->name;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 503/776 ima: check return value of crypto_shash_final() in boot aggregate
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Hodges <[email protected]>
[ Upstream commit 870819434c8dfcc3158033b66e7851b81bb17e21 ]
The return value of crypto_shash_final() is not checked in ima_calc_boot_aggregate_tfm(). If the hash finalization fails, the function returns success and a corrupted boot aggregate digest could be used for IMA measurements.
Capture the return value and propagate any error to the caller.
--- security/integrity/ima/ima_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/integrity/ima/ima_crypto.c +1 -1
@@ -837,7 +837,7 @@ static int ima_calc_boot_aggregate_tfm(char *digest, u16 alg_id, } }if (!rc) -crypto_shash_final (shash, digest); + rc =crypto_shash_final (shash, digest);return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 504/776 HID: asus: make asus_resume adhere to linux kernel coding standards
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Benato <[email protected]>
[ Upstream commit 51d33b42b8ae23da92819d28439fdd5636c45186 ]
Linux kernel coding standars requires functions opening brackets to be in a newline: move the opening bracket of asus_resume in its own line.
--- drivers/hid/hid-asus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/hid/hid-asus.c +2 -1
@@ -1014,7 +1014,8 @@ static int asus_start_multitouch(struct hid_device *hdev)return 0 ; } -static int __maybe_unused asus_resume (struct hid_device *hdev) { +static int __maybe_unused asus_resume (struct hid_device *hdev) +{struct asus_drvdata *drvdata =hid_get_drvdata (hdev);int ret =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 505/776 HID: asus: do not abort probe when not necessary
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Benato <[email protected]>
[ Upstream commit 7253091766ded0fd81fe8d8be9b8b835495b06e8 ]
In order to avoid dereferencing a NULL pointer asus_probe is aborted early and control of some asus devices is transferred over hid-generic after erroring out even when such NULL dereference cannot happen: only early abort when the NULL dereference can happen.
Also make the code shorter and more adherent to coding standards removing square brackets enclosing single-line if-else statements.
--- drivers/hid/hid-asus.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-)
drivers/hid/hid-asus.c +10 -15
@@ -1142,22 +1142,17 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)* were freed during registration due to no usages being mapped, * leaving drvdata->input pointing to freed memory. */ -if (!drvdata->input || !(hdev->claimed &HID_CLAIMED_INPUT )) { -hid_err (hdev,"Asus input not registered\n" ); - ret = -ENOMEM ; - goto err_stop_hw; - } - -if (drvdata->tp) { - drvdata->input->name ="Asus TouchPad" ; - }else { - drvdata->input->name ="Asus Keyboard" ; - } +if (drvdata->input && (hdev->claimed &HID_CLAIMED_INPUT )) { +if (drvdata->tp) + drvdata->input->name ="Asus TouchPad" ; +else + drvdata->input->name ="Asus Keyboard" ; -if (drvdata->tp) { - ret =asus_start_multitouch (hdev); -if (ret) - goto err_stop_hw; +if (drvdata->tp) { + ret =asus_start_multitouch (hdev); +if (ret) + goto err_stop_hw; + } }return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 506/776 mtd: physmap_of_gemini: Fix disabled pinctrl state check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Ni <[email protected]>
[ Upstream commit b7c0982184b0661f5b1b805f3a56f1bd3757b63e ]
The condition for checking the disabled pinctrl state incorrectly checks gf->enabled_state instead of gf->disabled_state. This causes misleading error messages and could lead to incorrect behavior when only one of the pinctrl states is defined.
Fix the condition to properly check gf->disabled_state.
--- drivers/mtd/maps/physmap-gemini.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/maps/physmap-gemini.c +1 -1
@@ -181,7 +181,7 @@ int of_flash_probe_gemini(struct platform_device *pdev,dev_err (dev,"no enabled pin control state\n" ); gf->disabled_state =pinctrl_lookup_state (gf->p,"disabled" ); -if (IS_ERR (gf->enabled_state)) { +if (IS_ERR (gf->disabled_state)) {dev_err (dev,"no disabled pin control state\n" ); }else { ret =pinctrl_select_state (gf->p, gf->disabled_state);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 507/776 mtd: spi-nor: core: correct the op.dummy.nbytes when check read operations
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haibo Chen <[email protected]>
[ Upstream commit 756564a536ecd8c9d33edd89f0647a91a0b03587 ]
When check read operation, need to setting the op.dummy.nbytes based on current read operation rather than the nor->read_proto.
--- drivers/mtd/spi-nor/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/spi-nor/core.c +1 -1
@@ -2160,7 +2160,7 @@ static int spi_nor_spimem_check_readop(struct spi_nor *nor,/* convert the dummy cycles to the number of bytes */ op.dummy.nbytes = (read->num_mode_clocks + read->num_wait_states) * op.dummy.buswidth /8 ; -if (spi_nor_protocol_is_dtr (nor->read_proto)) +if (spi_nor_protocol_is_dtr (read->proto)) op.dummy.nbytes *=2 ;return spi_nor_spimem_check_op (nor, &op);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 508/776 mtd: spi-nor: swp: check SR_TB flag when getting tb_mask
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shiji Yang <[email protected]>
[ Upstream commit 94645aa41bf9ecb87c2ce78b1c3405bfb6074a37 ]
When the chip does not support top/bottom block protect, the tb_mask must be set to 0, otherwise SR1 bit5 will be unexpectedly modified.
--- drivers/mtd/spi-nor/swp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/spi-nor/swp.c +3 -1
@@ -27,8 +27,10 @@ static u8 spi_nor_get_sr_tb_mask(struct spi_nor *nor) {if (nor->flags &SNOR_F_HAS_SR_TB_BIT6 )return SR_TB_BIT6 ; -else +else if (nor->flags &SNOR_F_HAS_SR_TB )return SR_TB_BIT5 ; +else +return 0 ; }static u64 spi_nor_get_min_prot_length_sr (struct spi_nor *nor)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 509/776 mtd: parsers: ofpart: call of_node_put() only in ofpart_fail path
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cosmin Tanislav <[email protected]>
[ Upstream commit 0c87dea1aab86116211cb37387c404c9e9231c39 ]
ofpart_none can only be reached after the for_each_child_of_node() loop finishes. for_each_child_of_node() correctly calls of_node_put() for all device nodes it iterates over as long as we don't break or jump out of the loop.
Calling of_node_put() inside the ofpart_none path will wrongly decrement the ref count of the last node in the for_each_child_of_node() loop.
Move the call to of_node_put() under the ofpart_fail label to fix this.
--- drivers/mtd/parsers/ofpart_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/parsers/ofpart_core.c +1 -1
@@ -172,11 +172,11 @@ static int parse_fixed_partitions(struct mtd_info *master, ofpart_fail:pr_err ("%s: error parsing ofpart partition %pOF (%pOF)\n" , master->name, pp, mtd_node); +of_node_put (pp); ret = -EINVAL ; ofpart_none:if (dedicated)of_node_put (ofpart_node); -of_node_put (pp);kfree (parts);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 510/776 mtd: parsers: ofpart: call of_node_get() for dedicated subpartitions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cosmin Tanislav <[email protected]>
[ Upstream commit e882626c1747653f1f01ea9d12e278e613b11d0f ]
In order to parse sub-partitions, add_mtd_partitions() calls parse_mtd_partitions() for all previously found partitions.
Each partition will end up being passed to parse_fixed_partitions(), and its of_node will be treated as the ofpart_node.
Commit 7cce81df7d26 ("mtd: parsers: ofpart: fix OF node refcount leak in parse_fixed_partitions()") added of_node_put() calls for ofpart_node on all exit paths.
In the case where the partition passed to parse_fixed_partitions() has a parent, it is treated as a dedicated partitions node, and of_node_put() is wrongly called for it, even if of_node_get() was not called explicitly.
On repeated bind / unbinds of the MTD, the extra of_node_put() ends up decrementing the refcount down to 0, which should never happen, resulting in the following error:
OF: ERROR: of_node_release() detected bad of_node_put() on /soc/spi@80007000/flash@0/partitions/partition@0
Call of_node_get() to balance the call to of_node_put() done for dedicated partitions nodes.
--- drivers/mtd/parsers/ofpart_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/parsers/ofpart_core.c +1 -1
@@ -71,7 +71,7 @@ static int parse_fixed_partitions(struct mtd_info *master, dedicated = false; } }else {/* Partition */ - ofpart_node = mtd_node; + ofpart_node =of_node_get (mtd_node); } of_id =of_match_node (parse_ofpart_match_table, ofpart_node);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 511/776 mtd: rawnand: sunxi: fix sunxi_nfc_hw_ecc_read_extra_oob
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Genoud <[email protected]>
[ Upstream commit 848c13996c55fe4ea6bf5acc3ce6c8c5c944b5f6 ]
When dumping the OOB, the bytes at the end where actually copied from the beginning of the OOB instead of current_offset.
That leads to something like:
OOB: ff ff ff ff ff ff ff ff ea 19 00 3a 83 db aa 8d
OOB: 99 09 c8 9a 90 36 35 7d aa 15 13 07 3d 97 b2 a4
OOB: a8 bb 19 b3 07 e9 f6 25 52 d7 1a 23 e2 7e 0a e4
OOB: 52 8a 09 d2 1a 86 3d cf b4 99 43 13 d3 90 33 0b
OOB: ff ff ff ff ff ff ff ff ea 19 00 3a 83 db aa 8d
OOB: 99 09 c8 9a 90 36 35 7d aa 15 13 07 3d 97 b2 a4
OOB: a8 bb 19 b3 07 e9 f6 25 52 d7 1a 23 e2 7e 0a e4
OOB: 52 8a 09 d2 1a 86 3d cf b4 99 43 13 d3 90 33 0b instead of:
OOB: ff ff ff ff ff ff ff ff ea 19 00 3a 83 db aa 8d
OOB: 99 09 c8 9a 90 36 35 7d aa 15 13 07 3d 97 b2 a4
OOB: a8 bb 19 b3 07 e9 f6 25 52 d7 1a 23 e2 7e 0a e4
OOB: 52 8a 09 d2 1a 86 3d cf b4 99 43 13 d3 90 33 0b
OOB: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
OOB: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
OOB: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
OOB: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff (example with BCH16, user data [8,0], no scrambling)
*cur_off (offset from the beginning of the page) was compared to offset (offset from the beginning of the OOB), and then, the nand_change_read_column_op() sets the current position to the beginning of the OOB instead of OOB+offset
--- drivers/mtd/nand/raw/sunxi_nand.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/sunxi_nand.c +3 -3
@@ -898,9 +898,9 @@ static void sunxi_nfc_hw_ecc_read_extra_oob(struct nand_chip *nand,if (len <=0 )return ; -if (!cur_off || *cur_off != offset) -nand_change_read_column_op (nand, mtd->writesize,NULL ,0 , - false); +if (!cur_off || *cur_off != (offset + mtd->writesize)) +nand_change_read_column_op (nand, mtd->writesize + offset, +NULL ,0 , false);if (!randomize)sunxi_nfc_read_buf (nand, oob + offset, len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 512/776 HID: usbhid: fix deadlock in hid_post_reset()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Neukum <[email protected]>
[ Upstream commit 8df2c1b47ee3cd50fd454f75c7a7e2ae8a6adf72 ]
You can build a USB device that includes a HID component and a storage or UAS component. The components can be reset only together. That means that hid_pre_reset() and hid_post_reset() are in the block IO error handling. Hence no memory allocation used in them may do block IO because the IO can deadlock on the mutex held while resetting a device and calling the interface drivers.
Use GFP_NOIO for all allocations in them.
--- drivers/hid/usbhid/hid-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/usbhid/hid-core.c +1 -1
@@ -1544,7 +1544,7 @@ static int hid_post_reset(struct usb_interface *intf)* configuration descriptors passed, we already know that * the size of the HID report descriptor has not changed. */ - rdesc =kmalloc (hid->dev_rsize,GFP_KERNEL ); + rdesc =kmalloc (hid->dev_rsize,GFP_NOIO );if (!rdesc)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 513/776 pinctrl: pinctrl-pic32: Fix resource leak
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ethan Tidmore <[email protected]>
[ Upstream commit fe5560688f3ba98364c7de7b4f8dc240ffd1ff75 ]
Fix three possible resource leaks by using the devres version of clk_prepare_enable(). Also, update error message accordingly.
Detected by Smatch:drivers/pinctrl/pinctrl-pic32.c:2211 pic32_pinctrl_probe() warn:
'pctl->clk' from clk_prepare_enable() not released on lines: 2208.
drivers/pinctrl/pinctrl-pic32.c:2274 pic32_gpio_probe() warn:
'bank->clk' from clk_prepare_enable() not released on lines: 2264,2272.
--- drivers/pinctrl/pinctrl-pic32.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
drivers/pinctrl/pinctrl-pic32.c +4 -16
@@ -2162,16 +2162,10 @@ static int pic32_pinctrl_probe(struct platform_device *pdev)if (IS_ERR (pctl->reg_base))return PTR_ERR (pctl->reg_base); - pctl->clk =devm_clk_get (&pdev->dev,NULL ); + pctl->clk =devm_clk_get_enabled (&pdev->dev,NULL );if (IS_ERR (pctl->clk)) { ret =PTR_ERR (pctl->clk); -dev_err (&pdev->dev,"clk get failed\n" ); -return ret; - } - - ret =clk_prepare_enable (pctl->clk); -if (ret) { -dev_err (&pdev->dev,"clk enable failed\n" ); +dev_err (&pdev->dev,"Failed to get and enable clock\n" );return ret; }
@@ -2227,16 +2221,10 @@ static int pic32_gpio_probe(struct platform_device *pdev)if (irq <0 )return irq; - bank->clk =devm_clk_get (&pdev->dev,NULL ); + bank->clk =devm_clk_get_enabled (&pdev->dev,NULL );if (IS_ERR (bank->clk)) { ret =PTR_ERR (bank->clk); -dev_err (&pdev->dev,"clk get failed\n" ); -return ret; - } - - ret =clk_prepare_enable (bank->clk); -if (ret) { -dev_err (&pdev->dev,"clk enable failed\n" ); +dev_err (&pdev->dev,"Failed to get and enable clock\n" );return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 514/776 perf branch: Avoid incrementing NULL
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit c969a9d7bbf46f983c4a48566b3b2f7340b02296 ]
If the entry is NULL the value is meaningless so early return NULL to avoid an increment of NULL. This was happening in calls from has_stitched_lbr when running the "perf record LBR tests". The return value isn't used in that case, so returning NULL as no effect.
--- tools/perf/util/branch.h | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/branch.h +3 -0
@@ -63,6 +63,9 @@ static inline struct branch_entry *perf_sample__branch_entries(struct perf_sampl {u64 *entry = (u64 *)sample->branch_stack; +if (entry ==NULL ) +return NULL ; + entry++;if (sample->no_hw_idx)return (struct branch_entry *)entry;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 515/776 perf: tools: cs-etm: Fix print issue for Coresight debug in ETE/TRBE trace
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Leach <[email protected]>
[ Upstream commit 6c478e7b3eba3f387a2d6c749e3e3ee0f8ad1c53 ]
Building perf with CORESIGHT=1 and the optional CSTRACE_RAW=1 enables additional debug printing of raw trace data when using command:- perf report --dump.
This raw trace prints the CoreSight formatted trace frames, which may be used to investigate suspected issues with trace quality / corruption / decode.
These frames are not present in ETE + TRBE trace. This fix removes the unnecessary call to print these frames.
This fix also rationalises implementation - original code had helper function that unnecessarily repeated initialisation calls that had already been made.
Due to an addtional fault with the OpenCSD library, this call when ETE/TRBE are being decoded will cause a segfault in perf. This fix also prevents that problem for perf using older (<= 1.8.0 version) OpenCSD libraries.
--- .../perf/util/cs-etm-decoder/cs-etm-decoder.c | 51 +++++-------------- 1 file changed, 13 insertions(+), 38 deletions(-)
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +13 -38
@@ -214,46 +214,24 @@ cs_etm_decoder__init_def_logger_printing(struct cs_etm_decoder_params *d_params, (void *)decoder, cs_etm_decoder__print_str_cb);if (ret !=0 ) - ret =-1 ; - -return 0 ; -} +return -1 ;#ifdef CS_LOG_RAW_FRAMES -static void -cs_etm_decoder__init_raw_frame_logging (struct cs_etm_decoder_params *d_params, -struct cs_etm_decoder *decoder) -{ -/* Only log these during a --dump operation */ -if (d_params->operation ==CS_ETM_OPERATION_PRINT ) { -/* set up a library default logger to process the -* raw frame printer we add later -*/ -ocsd_def_errlog_init (OCSD_ERR_SEV_ERROR ,1 ); - -/* no stdout / err / file output */ -ocsd_def_errlog_config_output (C_API_MSGLOGOUT_FLG_NONE ,NULL ); - -/* set the string CB for the default logger, -* passes strings to perf print logger. -*/ -ocsd_def_errlog_set_strprint_cb (decoder->dcd_tree, - (void *)decoder, - cs_etm_decoder__print_str_cb); - +/* +* Only log raw frames if --dump operation and hardware is actually +* generating formatted CoreSight trace frames +*/ +if ((d_params->operation ==CS_ETM_OPERATION_PRINT ) && + (d_params->formatted == true)) {/* use the built in library printer for the raw frames */ -ocsd_dt_set_raw_frame_printer (decoder->dcd_tree, -CS_RAW_DEBUG_FLAGS ); + ret =ocsd_dt_set_raw_frame_printer (decoder->dcd_tree, +CS_RAW_DEBUG_FLAGS ); +if (ret !=0 ) +return -1 ; } -} -#else -static void -cs_etm_decoder__init_raw_frame_logging ( -struct cs_etm_decoder_params *d_params__maybe_unused , -struct cs_etm_decoder *decoder__maybe_unused ) -{ -}#endif +return 0 ; +} static ocsd_datapath_resp_t cs_etm_decoder__do_soft_timestamp(struct cs_etm_queue *etmq,
@@ -716,9 +694,6 @@ cs_etm_decoder__new(int decoders, struct cs_etm_decoder_params *d_params,if (ret !=0 ) goto err_free_decoder; -/* init raw frame logging if required */ -cs_etm_decoder__init_raw_frame_logging (d_params, decoder); -for (i =0 ; i < decoders; i++) { ret = cs_etm_decoder__create_etm_decoder(d_params, &t_params[i],
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 516/776 pinctrl: abx500: Fix type of argument variable
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu-Chun Lin <[email protected]>
[ Upstream commit 34006f77890d050e6d80cbee365b5d703c1140b4 ]
The argument variable is assigned the return value of pinconf_to_config_argument(), which returns a u32. Change its type from enum pin_config_param to unsigned int to correctly store the configuration argument.
--- drivers/pinctrl/nomadik/pinctrl-abx500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/nomadik/pinctrl-abx500.c +1 -1
@@ -850,7 +850,7 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev,int ret = -EINVAL ;int i;enum pin_config_param param; -enum pin_config_param argument; +unsigned int argument;for (i =0 ; i < num_configs; i++) { param =pinconf_to_config_param (configs[i]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 517/776 perf expr: Return -EINVAL for syntax error in expr__find_ids()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit 3a61fd866ef9aaa1d3158b460f852b74a2df07f4 ]
expr__find_ids() propagates the parser return value directly. For syntax errors, the parser can return a positive value, but callers treat it as success, e.g., for below case on Arm64 platform:
metric expr 100 * (STALL_SLOT_BACKEND / (CPU_CYCLES * #slots) - BR_MIS_PRED * 3 / CPU_CYCLES) for backend_bound parsing metric: 100 * (STALL_SLOT_BACKEND / (CPU_CYCLES * #slots) - BR_MIS_PRED * 3 / CPU_CYCLES) Failure to read '#slots' literal: #slots = nan
syntax error
Convert positive parser returns in expr__find_ids() to -EINVAL, as a result, the error value will be respected by callers.
Before:
perf stat -C 5
Failure to read '#slots'Failure to read '#slots'Failure to read '#slots'Failure to read '#slots'Segmentation fault
After:
perf stat -C 5
Failure to read '#slots'Cannot find metric or group `Default'
--- tools/perf/util/expr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/expr.c +2 -1
@@ -275,7 +275,8 @@ int expr__find_other(const char *expr, const char *one,if (one)expr__del_id (ctx, one); -return ret; +/* A positive value means syntax error, convert to -EINVAL */ +return ret >0 ? -EINVAL : ret; }double expr_id_data__value (const struct expr_id_data *data)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 518/776 perf util: Kill die() prototype, dead for a long time
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit e5cce1b9c82fbd48e2f1f7a25a9fad8ee228176f ]
In fef2a735167a827a ("perf tools: Kill die()") the die() function was removed, but not the prototype in util.h, now when building with LIBPERL=1, during a 'make -C tools/perf build-test' routine test, it is failing as perl likes die() calls and then this clashes with this remnant, remove it.
--- tools/perf/util/util.h | 1 - 1 file changed, 1 deletion(-)
tools/perf/util/util.h +0 -1
@@ -14,7 +14,6 @@/* General helper functions */ void usage (const char *err)__noreturn ; -void die(const char *err, ...) __noreturn __printf(1, 2);struct dirent ;struct strlist ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 519/776 i3c: mipi-i3c-hci: fix IBI payload length calculation for final status
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Billy Tsai <[email protected]>
[ Upstream commit d35a6db887eeae7c57b719521e39d64f929c6dc3 ]
In DMA mode, the IBI status descriptor encodes the payload using CHUNKS (number of chunks) and DATA_LENGTH (valid bytes in the last chunk). All preceding chunks are implicitly full-sized.
The current code accumulates full chunk sizes for non-final status descriptors, but for the final status descriptor it only adds DATA_LENGTH. This ignores the contribution of the preceding full chunks described by the same final status entry.
As a result, the computed IBI payload length is truncated whenever the final status spans multiple chunks. For example, with a chunk size of 4 bytes, CHUNKS=2 and DATA_LENGTH=1 should result in a total payload size of 5 bytes, but the current code reports only 1 byte.
Fix the calculation by adding the size of (CHUNKS - 1) full chunks plus DATA_LENGTH for the last chunk.
--- drivers/i3c/master/mipi-i3c-hci/dma.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/i3c/master/mipi-i3c-hci/dma.c +4 -1
@@ -636,7 +636,10 @@ static void hci_dma_process_ibi(struct i3c_hci *hci, struct hci_rh_data *rh)if (!(ibi_status &IBI_LAST_STATUS )) { ibi_size += chunks * rh->ibi_chunk_sz; }else { - ibi_size +=FIELD_GET (IBI_DATA_LENGTH , ibi_status); +if (chunks) { + ibi_size += (chunks -1 ) * rh->ibi_chunk_sz; + ibi_size +=FIELD_GET (IBI_DATA_LENGTH , ibi_status); + } last_ptr = ptr;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 520/776 driver core: device.h: remove extern from function prototypes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit f43243c66e5e9ad839d235f82a58e73a7e7612af ]
The kernel coding style does not require 'extern' in function prototypes in .h files, so remove them from include/linux/device.h as they are not needed.
Stable-dep-of: 797cc011ae02 ("backlight: sky81452-backlight: Check return value of devm_gpiod_get_optional() in sky81452_bl_parse_dt()")
--- include/linux/device.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/linux/device.h +1 -2
@@ -1030,8 +1030,7 @@ void device_links_supplier_sync_state_pause(void);void device_links_supplier_sync_state_resume (void );void device_link_wait_removal (void ); -extern __printf(3, 4) -int dev_err_probe(const struct device *dev, int err, const char *fmt, ...); +__printf(3, 4) int dev_err_probe(const struct device *dev, int err, const char *fmt, ...);/* Create alias, so I can be autoloaded. */ #define MODULE_ALIAS_CHARDEV (major,minor) \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 521/776 driver core: Move dev_err_probe() to where it belogs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit 9e0cace7a6254070159ebd86497eadc29ea307ca ]
dev_err_probe() belongs to the printing API, hence move the definition from device.h to dev_printk.h.
There is no change to the callers at all, since:
1) implementation is located in the same core.c;
2) dev_printk.h is guaranteed to be included by device.h.
Stable-dep-of: 797cc011ae02 ("backlight: sky81452-backlight: Check return value of devm_gpiod_get_optional() in sky81452_bl_parse_dt()")
--- include/linux/dev_printk.h | 2 ++ include/linux/device.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/dev_printk.h +2 -0
@@ -275,4 +275,6 @@ do { \ WARN_ONCE(condition, "%s %s: " format, \ dev_driver_string(dev), dev_name(dev), ## arg) +__printf(3, 4) int dev_err_probe(const struct device *dev, int err, const char *fmt, ...); +#endif /* _DEVICE_PRINTK_H_ */
include/linux/device.h +0 -2
@@ -1030,8 +1030,6 @@ void device_links_supplier_sync_state_pause(void);void device_links_supplier_sync_state_resume (void );void device_link_wait_removal (void ); -__printf(3, 4) int dev_err_probe(const struct device *dev, int err, const char *fmt, ...); -/* Create alias, so I can be autoloaded. */ #define MODULE_ALIAS_CHARDEV (major,minor) \ MODULE_ALIAS("char-major-" __stringify(major) "-" __stringify(minor))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 522/776 dev_printk: add new dev_err_probe() helpers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nuno Sa <[email protected]>
[ Upstream commit dbbe7eaf0e4795bf003ac06872aaf52b6b6b1310 ]
This is similar to dev_err_probe() but for cases where an ERR_PTR() or ERR_CAST() is to be returned simplifying patterns like:
dev_err_probe(dev, ret, ...); return ERR_PTR(ret) or dev_err_probe(dev, PTR_ERR(ptr), ...); return ERR_CAST(ptr)
Stable-dep-of: 797cc011ae02 ("backlight: sky81452-backlight: Check return value of devm_gpiod_get_optional() in sky81452_bl_parse_dt()")
--- include/linux/dev_printk.h | 8 ++++++++ 1 file changed, 8 insertions(+)
include/linux/dev_printk.h +8 -0
@@ -277,4 +277,12 @@ do { \ __printf(3, 4) int dev_err_probe(const struct device *dev, int err, const char *fmt, ...); +/* Simple helper for dev_err_probe() when ERR_PTR() is to be returned. */ +#define dev_err_ptr_probe (dev, ___err, fmt, ...) \ + ERR_PTR(dev_err_probe(dev, ___err, fmt, ##__VA_ARGS__)) + +/* Simple helper for dev_err_probe() when ERR_CAST() is to be returned. */ +#define dev_err_cast_probe (dev, ___err_ptr, fmt, ...) \ + ERR_PTR(dev_err_probe(dev, PTR_ERR(___err_ptr), fmt, ##__VA_ARGS__)) +#endif /* _DEVICE_PRINTK_H_ */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 523/776 backlight: sky81452-backlight: Check return value of devm_gpiod_get_optional() in sky81452_bl_parse_dt()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Ni <[email protected]>
[ Upstream commit 797cc011ae02bda26f93d25a4442d7a1a77d84df ]
The devm_gpiod_get_optional() function may return an ERR_PTR in case of genuine GPIO acquisition errors, not just NULL which indicates the legitimate absence of an optional GPIO.
Add an IS_ERR() check after the call in sky81452_bl_parse_dt(). On error, return the error code to ensure proper failure handling rather than proceeding with invalid pointers.
--- drivers/video/backlight/sky81452-backlight.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/video/backlight/sky81452-backlight.c +3 -0
@@ -204,6 +204,9 @@ static struct sky81452_bl_platform_data *sky81452_bl_parse_dt( pdata->dpwm_mode =of_property_read_bool (np,"skyworks,dpwm-mode" ); pdata->phase_shift =of_property_read_bool (np,"skyworks,phase-shift" ); pdata->gpiod_enable =devm_gpiod_get_optional (dev,NULL ,GPIOD_OUT_HIGH ); +if (IS_ERR (pdata->gpiod_enable)) +return dev_err_cast_probe (dev, pdata->gpiod_enable, +"failed to get gpio\n" ); ret =of_property_count_u32_elems (np,"led-sources" );if (ret <0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 524/776 platform/surface: surfacepro3_button: Drop wakeup source on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 1410a228ab2d36fe2b383415a632ae12048d4f3a ]
The wakeup source added by device_init_wakeup() in surface_button_add() needs to be dropped during driver removal, so update the driver to do that.
--- drivers/platform/surface/surfacepro3_button.c | 1 + 1 file changed, 1 insertion(+)
drivers/platform/surface/surfacepro3_button.c +1 -0
@@ -243,6 +243,7 @@ static int surface_button_remove(struct acpi_device *device) {struct surface_button *button =acpi_driver_data (device); +device_init_wakeup (&device->dev, false);input_unregister_device (button->input);kfree (button);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 525/776 leds: lgm-sso: Remove duplicate assignments for priv->mmap
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Ni <[email protected]>
[ Upstream commit 7186d0330c3f3e86de577687a82f4ebd96dcb5ac ]
Remove duplicate assignment of priv->mmap in intel_sso_led_probe().
--- drivers/leds/blink/leds-lgm-sso.c | 2 -- 1 file changed, 2 deletions(-)
drivers/leds/blink/leds-lgm-sso.c +0 -2
@@ -808,8 +808,6 @@ static int intel_sso_led_probe(struct platform_device *pdev) priv->fpid_clkrate =clk_get_rate (priv->clocks[1 ].clk); - priv->mmap =syscon_node_to_regmap (dev->of_node); - priv->mmap =syscon_node_to_regmap (dev->of_node);if (IS_ERR (priv->mmap)) {dev_err (dev,"Failed to map iomem!\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 526/776 tty: hvc: remove HVC_IUCV_MAGIC
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: наб <[email protected]>
[ Upstream commit eef7381d8134f249dc17138bb1794c249aff7f5a ]
According to Greg, in the context of magic numbers as defined in magic-number.rst, "the tty layer should not need this and I'll gladly take patches"
This stretches that definition slightly, since it multiplexes it with the terminal number as a constant offset, but is equivalent
Ref: https://lore.kernel.org/linux-doc/[email protected]/
Stable-dep-of: f2a880e802ad ("tty: hvc_iucv: fix off-by-one in number of supported devices")
--- drivers/tty/hvc/hvc_iucv.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/tty/hvc/hvc_iucv.c +5 -6
@@ -29,7 +29,6 @@/* General device driver settings */ -#define HVC_IUCV_MAGIC 0xc9e4c3e5#define MAX_HVC_IUCV_LINES HVC_ALLOC_TTY_ADAPTERS#define MEMPOOL_MIN_NR (PAGE_SIZE / sizeof(struct iucv_tty_buffer)/4)
@@ -131,9 +130,9 @@ static struct iucv_handler hvc_iucv_handler = {*/ static struct hvc_iucv_private *hvc_iucv_get_private (uint32_t num) { -if ((num <HVC_IUCV_MAGIC ) || (num -HVC_IUCV_MAGIC > hvc_iucv_devices)) +if (num > hvc_iucv_devices)return NULL ; -return hvc_iucv_table[num -HVC_IUCV_MAGIC ]; +return hvc_iucv_table[num]; }/**
@@ -1072,8 +1071,8 @@ static int __init hvc_iucv_alloc(int id, unsigned int is_console) priv->is_console = is_console;/* allocate hvc device */ - priv->hvc =hvc_alloc (HVC_IUCV_MAGIC + id,/* PAGE_SIZE */ -HVC_IUCV_MAGIC + id, &hvc_iucv_ops,256 ); + priv->hvc =hvc_alloc (id,/* PAGE_SIZE */ + id, &hvc_iucv_ops,256 );if (IS_ERR (priv->hvc)) { rc =PTR_ERR (priv->hvc); goto out_error_hvc;
@@ -1371,7 +1370,7 @@ static int __init hvc_iucv_init(void)/* register the first terminal device as console * (must be done before allocating hvc terminal devices) */ - rc =hvc_instantiate (HVC_IUCV_MAGIC ,IUCV_HVC_CON_IDX , &hvc_iucv_ops); + rc =hvc_instantiate (0 ,IUCV_HVC_CON_IDX , &hvc_iucv_ops);if (rc) {pr_err ("Registering HVC terminal device as " "Linux console failed\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 527/776 tty: hvc_iucv: fix off-by-one in number of supported devices
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit f2a880e802ad12d1e38039d1334fb1475d0f5241 ]
MAX_HVC_IUCV_LINES == HVC_ALLOC_TTY_ADAPTERS == 8.
This is the number of entries in:
static struct hvc_iucv_private *hvc_iucv_table[MAX_HVC_IUCV_LINES];
Sometimes hvc_iucv_table[] is limited by:
(a) if (num > hvc_iucv_devices) // for error detection
or
(b) for (i = 0; i < hvc_iucv_devices; i++) // in 2 places
(so these 2 don't agree; second one appears to be correct to me.)
hvc_iucv_devices can be 0..8. This is a counter.
(c) if (hvc_iucv_devices > MAX_HVC_IUCV_LINES)
If hvc_iucv_devices == 8, (a) allows the code to access hvc_iucv_table[8]. Oops.
--- drivers/tty/hvc/hvc_iucv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/hvc/hvc_iucv.c +1 -1
@@ -130,7 +130,7 @@ static struct iucv_handler hvc_iucv_handler = {*/ static struct hvc_iucv_private *hvc_iucv_get_private (uint32_t num) { -if (num > hvc_iucv_devices) +if (num >= hvc_iucv_devices)return NULL ;return hvc_iucv_table[num]; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 528/776 platform/x86: panasonic-laptop: Fix OPTD notifier registration and cleanup
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 8baeff2c1d33dad8572216c6ad3a7425852507d4 ]
An ACPI notify handler is leaked if device_create_file() returns an error in acpi_pcc_hotkey_add().
Also, it is pointless to call pcc_unregister_optd_notifier() in acpi_pcc_hotkey_remove() if pcc->platform is NULL and it is better to arrange the cleanup code in that function in the same order as the rollback code in acpi_pcc_hotkey_add().
Address the above by placing the pcc_register_optd_notifier() call in acpi_pcc_hotkey_add() after the device_create_file() return value check and placing the pcc_unregister_optd_notifier() call in acpi_pcc_hotkey_remove() right before the device_remove_file() call.
--- drivers/platform/x86/panasonic-laptop.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/platform/x86/panasonic-laptop.c +3 -2
@@ -1077,9 +1077,10 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device) } result =device_create_file (&pcc->platform->dev, &dev_attr_cdpower); -pcc_register_optd_notifier (pcc,"\\_SB.PCI0.EHCI.ERHB.OPTD" );if (result) goto out_platform; + +pcc_register_optd_notifier (pcc,"\\_SB.PCI0.EHCI.ERHB.OPTD" ); }else { pcc->platform =NULL ; }
@@ -1113,10 +1114,10 @@ static int acpi_pcc_hotkey_remove(struct acpi_device *device)i8042_remove_filter (panasonic_i8042_filter);if (pcc->platform) { +pcc_unregister_optd_notifier (pcc,"\\_SB.PCI0.EHCI.ERHB.OPTD" );device_remove_file (&pcc->platform->dev, &dev_attr_cdpower);platform_device_unregister (pcc->platform); } -pcc_unregister_optd_notifier (pcc,"\\_SB.PCI0.EHCI.ERHB.OPTD" );sysfs_remove_group (&device->dev.kobj, &pcc_attr_group);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 529/776 mfd: mc13xxx-core: Fix memory leak in mc13xxx_add_subdevice_pdata()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdun Nihaal <[email protected]>
[ Upstream commit a5a65a7fb2f7796bbe492cd6be59c92cb64377d1 ]
The memory allocated for cell.name using kmemdup() is not freed when mfd_add_devices() fails. Fix that by using devm_kmemdup().
--- drivers/mfd/mc13xxx-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/mc13xxx-core.c +1 -1
@@ -377,7 +377,7 @@ static int mc13xxx_add_subdevice_pdata(struct mc13xxx *mc13xxx,if (snprintf (buf,sizeof (buf), format, name) >sizeof (buf))return -E2BIG ; - cell.name =kmemdup (buf,strlen (buf) +1 ,GFP_KERNEL ); + cell.name =devm_kmemdup (mc13xxx->dev, buf,strlen (buf) +1 ,GFP_KERNEL );if (!cell.name)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 530/776 nfs/blocklayout: Fix compilation error (`make W=1`) in bl_write_pagelist()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit f83c8dda456ce4863f346aa26d88efa276eda35d ]
Clang compiler is not happy about set but unused variable (when dprintk() is no-op):
.../blocklayout/blocklayout.c:384:9: error: variable 'count' set but not used [-Werror,-Wunused-but-set-variable]
Remove a leftover from the previous cleanup.
--- fs/nfs/blocklayout/blocklayout.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/nfs/blocklayout/blocklayout.c +1 -3
@@ -399,14 +399,13 @@ bl_write_pagelist(struct nfs_pgio_header *header, int sync)sector_t isect, extent_length =0 ;struct parallel_io *par =NULL ;loff_t offset = header->args.offset; -size_t count = header->args.count;struct page **pages = header->args.pages;int pg_index = header->args.pgbase >>PAGE_SHIFT ;unsigned int pg_len;struct blk_plug plug;int i; -dprintk ("%s enter, %zu@%lld\n" , __func__, count, offset); +dprintk ("%s enter, %u@%lld\n" , __func__, header->args.count, offset);/* At this point, header->page_aray is a (sequential) list of nfs_pages. * We want to write each, and if there is an error set pnfs_error
@@ -448,7 +447,6 @@ bl_write_pagelist(struct nfs_pgio_header *header, int sync) } offset += pg_len; - count -= pg_len; isect += (pg_len >>SECTOR_SHIFT ); extent_length -= (pg_len >>SECTOR_SHIFT ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 531/776 fs/ntfs3: terminate the cached volume label after UTF-8 conversion
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit a6cd43fe9b083fa23fe1595666d5738856cb261a ]
ntfs_fill_super() loads the on-disk volume label with utf16s_to_utf8s() and stores the result in sbi->volume.label. The converted label is later exposed through ntfs3_label_show() using %s, but utf16s_to_utf8s() only returns the number of bytes written and does not add a trailing NUL.
If the converted label fills the entire fixed buffer, ntfs3_label_show() can read past the end of sbi->volume.label while looking for a terminator.
Terminate the cached label explicitly after a successful conversion and clamp the exact-full case to the last byte of the buffer.
--- fs/ntfs3/super.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/ntfs3/super.c +6 -1
@@ -958,8 +958,13 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)le32_to_cpu (attr->res.data_size) >>1 ,UTF16_LITTLE_ENDIAN , sbi->volume.label, sizeof(sbi->volume.label)); -if (err <0 ) +if (err <0 ) { sbi->volume.label[0 ] =0 ; + }else if (err >=sizeof (sbi->volume.label)) { + sbi->volume.label[sizeof (sbi->volume.label) -1 ] =0 ; + }else { + sbi->volume.label[err] =0 ; + } }else {/* Should we break mounting here? */ //err = -EINVAL;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 532/776 platform/x86: dell_rbu: avoid uninit value usage in packet_size_write()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
[ Upstream commit f8fd138c2363c0e2d3235c32bfb4fb5c6474e4ae ]
Ensure the temp value has been properly parsed from the user-provided buffer and initialized to be used in later operations. While at it, prefer a convenient kstrtoul() helper.
Found by Linux Verification Center (linuxtesting.org) with Svace static analysis tool.
--- drivers/platform/x86/dell/dell_rbu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/platform/x86/dell/dell_rbu.c +5 -1
@@ -30,6 +30,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/init.h> +#include <linux/kstrtox.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/string.h>
@@ -617,9 +618,12 @@ static ssize_t packet_size_write(struct file *filp, struct kobject *kobj, char *buffer, loff_t pos, size_t count) { unsigned long temp; + +if (kstrtoul (buffer,10 , &temp)) +return -EINVAL ; +spin_lock (&rbu_data.lock);packet_empty_list (); -sscanf (buffer,"%lu" , &temp);if (temp <0xffffffff ) rbu_data.packetsize = temp;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 533/776 platform/x86: dell-wmi-sysman: bound enumeration string aggregation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 3c34471c26abc52a37f5ad90949e2e4b8027eb14 ]
populate_enum_data() aggregates firmware-provided value-modifier and possible-value strings into fixed 512-byte struct members. The current code bounds each individual source string but then appends every string and separator with raw strcat() and no remaining-space check.
Switch the aggregation loops to a bounded append helper and reject enumeration packages whose combined strings do not fit in the destination buffers.
--- .../dell/dell-wmi-sysman/enum-attributes.c | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-)
drivers/platform/x86/dell/dell-wmi-sysman/enum-attributes.c +28 -6
@@ -6,10 +6,32 @@* Copyright (c) 2020 Dell Inc. */ +#include <linux/bug.h> +#include "dell-wmi-sysman.h" get_instance_id (enumeration); +static int append_enum_string (char *dest,const char *src) +{ +size_t dest_len =strlen (dest); +ssize_t copied; + +if (WARN_ON_ONCE (dest_len >=MAX_BUFF )) +return -EINVAL ; + + copied =strscpy (dest + dest_len, src,MAX_BUFF - dest_len); +if (copied <0 ) +return -EINVAL ; + + dest_len += copied; + copied =strscpy (dest + dest_len,";" ,MAX_BUFF - dest_len); +if (copied <0 ) +return -EINVAL ; + +return 0 ; +} +static ssize_t current_value_show (struct kobject *kobj,struct kobj_attribute *attr,char *buf) {int instance_id =get_enumeration_instance_id (kobj);
@@ -176,9 +198,9 @@ int populate_enum_data(union acpi_object *enumeration_obj, int instance_id,return -EINVAL ;if (check_property_type (enumeration, next_obj,ACPI_TYPE_STRING ))return -EINVAL ; -strcat (wmi_priv.enumeration_data[instance_id].dell_value_modifier, - enumeration_obj[next_obj++].string.pointer); -strcat (wmi_priv.enumeration_data[instance_id].dell_value_modifier,";" ); +if (append_enum_string (wmi_priv.enumeration_data[instance_id].dell_value_modifier, + enumeration_obj[next_obj++].string.pointer)) +return -EINVAL ; }if (next_obj >= enum_property_count)
@@ -193,9 +215,9 @@ int populate_enum_data(union acpi_object *enumeration_obj, int instance_id,return -EINVAL ;if (check_property_type (enumeration, next_obj,ACPI_TYPE_STRING ))return -EINVAL ; -strcat (wmi_priv.enumeration_data[instance_id].possible_values, - enumeration_obj[next_obj++].string.pointer); -strcat (wmi_priv.enumeration_data[instance_id].possible_values,";" ); +if (append_enum_string (wmi_priv.enumeration_data[instance_id].possible_values, + enumeration_obj[next_obj++].string.pointer)) +return -EINVAL ; }return sysfs_create_group (attr_name_kobj, &enumeration_attr_group);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 534/776 RDMA/core: Prefer NLA_NUL_STRING
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 6ed3d14fc45d3da6025e7fe4a6a09066856698e2 ]
These attributes are evaluated as c-string (passed to strcmp), but NLA_STRING doesn't check for the presence of a \0 terminator.
Either this needs to switch to nla_strcmp() and needs to adjust printf fmt specifier to not use plain %s, or this needs to use NLA_NUL_STRING.
As the code has been this way for long time, it seems to me that userspace does include the terminating nul, even tough its not enforced so far, and thus NLA_NUL_STRING use is the simpler solution.
--- drivers/infiniband/core/iwpm_msg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/infiniband/core/iwpm_msg.c +3 -3
@@ -365,9 +365,9 @@ int iwpm_remove_mapping(struct sockaddr_storage *local_addr, u8 nl_client)/* netlink attribute policy for the received response to register pid request */ static const struct nla_policy resp_reg_policy[IWPM_NLA_RREG_PID_MAX ] = { [IWPM_NLA_RREG_PID_SEQ ] = { .type =NLA_U32 }, - [IWPM_NLA_RREG_IBDEV_NAME ] = { .type =NLA_STRING , + [IWPM_NLA_RREG_IBDEV_NAME ] = { .type =NLA_NUL_STRING , .len =IWPM_DEVNAME_SIZE -1 }, - [IWPM_NLA_RREG_ULIB_NAME ] = { .type =NLA_STRING , + [IWPM_NLA_RREG_ULIB_NAME ] = { .type =NLA_NUL_STRING , .len =IWPM_ULIBNAME_SIZE -1 }, [IWPM_NLA_RREG_ULIB_VER ] = { .type =NLA_U16 }, [IWPM_NLA_RREG_PID_ERR ] = { .type =NLA_U16 }
@@ -677,7 +677,7 @@ int iwpm_remote_info_cb(struct sk_buff *skb, struct netlink_callback *cb)/* netlink attribute policy for the received request for mapping info */ static const struct nla_policy resp_mapinfo_policy[IWPM_NLA_MAPINFO_REQ_MAX ] = { - [IWPM_NLA_MAPINFO_ULIB_NAME ] = { .type =NLA_STRING , + [IWPM_NLA_MAPINFO_ULIB_NAME ] = { .type =NLA_NUL_STRING , .len =IWPM_ULIBNAME_SIZE -1 }, [IWPM_NLA_MAPINFO_ULIB_VER ] = { .type =NLA_U16 } };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 535/776 scsi: sg: Resolve soft lockup issue when opening /dev/sgX
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Erkun <[email protected]>
[ Upstream commit d06a310b45e153872033dd0cf19d5a2279121099 ]
The parameter def_reserved_size defines the default buffer size reserved for each Sg_fd and should be restricted to a range between 0 and 1,048,576 (see https://tldp.org/HOWTO/SCSI-Generic-HOWTO/proc.html). Although the function sg_proc_write_dressz enforces this limit, it is possible to bypass it by directly modifying the module parameter as shown below, which then causes a soft lockup:
echo -1 > /sys/module/sg/parameters/def_reserved_size exec 4<> /dev/sg0
watchdog: BUG: soft lockup - CPU#5 stuck for 26 seconds! [bash:537] Modules loaded: CPU: 5 UID: 0 PID: 537 Command: bash, kernel version 6.19.0-rc3+ #134,
PREEMPT disabled
Hardware: QEMU Standard PC (i440FX + PIIX, 1996), BIOS version 1.16.1-2.fc37 dated 04/01/2014
...
Call Trace: sg_build_reserve+0x5c/0xa0 sg_add_sfp+0x168/0x270 sg_open+0x16e/0x340 chrdev_open+0xbe/0x230 do_dentry_open+0x175/0x480 vfs_open+0x34/0xf0 do_open+0x265/0x3d0 path_openat+0x110/0x290 do_filp_open+0xc3/0x170 do_sys_openat2+0x71/0xe0 __x64_sys_openat+0x6d/0xa0 do_syscall_64+0x62/0x310 entry_SYSCALL_64_after_hwframe+0x76/0x7e
The fix is to use module_param_cb to validate and reject invalid values assigned to def_reserved_size.
--- drivers/scsi/sg.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)
drivers/scsi/sg.c +27 -2
@@ -1615,10 +1615,35 @@ sg_remove_device(struct device *cl_dev, struct class_interface *cl_intf) }module_param_named (scatter_elem_sz, scatter_elem_sz, int,S_IRUGO |S_IWUSR ); -module_param_named (def_reserved_size, def_reserved_size, int, -S_IRUGO |S_IWUSR );module_param_named (allow_dio, sg_allow_dio, int,S_IRUGO |S_IWUSR ); +static int def_reserved_size_set (const char *val,const struct kernel_param *kp) +{ +int size, ret; + +if (!val) +return -EINVAL ; + + ret =kstrtoint (val,0 , &size); +if (ret) +return ret; + +/* limit to 1 MB */ +if (size <0 || size >1048576 ) +return -ERANGE ; + + def_reserved_size = size; +return 0 ; +} + +static const struct kernel_param_ops def_reserved_size_ops = { + .set = def_reserved_size_set, + .get = param_get_int, +}; + +module_param_cb (def_reserved_size, &def_reserved_size_ops, &def_reserved_size, +S_IRUGO |S_IWUSR ); +MODULE_AUTHOR ("Douglas Gilbert" );MODULE_DESCRIPTION ("SCSI generic (sg) driver" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 536/776 scsi: target: core: Fix integer overflow in UNMAP bounds check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
[ Upstream commit 2bf2d65f76697820dbc4227d13866293576dd90a ]
sbc_execute_unmap() checks LBA + range does not exceed the device capacity, but does not guard against LBA + range wrapping around on 64-bit overflow.
Add an overflow check matching the pattern already used for WRITE_SAME in the same file.
--- drivers/target/target_core_sbc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/target/target_core_sbc.c +2 -1
@@ -1232,7 +1232,8 @@ sbc_execute_unmap(struct se_cmd *cmd) goto err; } -if (lba + range > dev->transport->get_blocks (dev) +1 ) { +if (lba + range < lba || + lba + range > dev->transport->get_blocks (dev) +1 ) { ret =TCM_ADDRESS_OUT_OF_RANGE ; goto err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 537/776 dt-bindings: clock: qcom,gcc-sc8180x: Add missing GDSCs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Val Packett <[email protected]>
[ Upstream commit 76404ffbf07f28a5ec04748e18fce3dac2e78ef6 ]
There are 5 more GDSCs that we were ignoring and not putting to sleep, which are listed in downstream DTS. Add them.
Stable-dep-of: 3565741eb985 ("clk: qcom: gcc-sc8180x: Add missing GDSCs")
--- include/dt-bindings/clock/qcom,gcc-sc8180x.h | 5 +++++ 1 file changed, 5 insertions(+)
include/dt-bindings/clock/qcom,gcc-sc8180x.h +5 -0
@@ -308,5 +308,10 @@#define USB30_MP_GDSC 8#define USB30_PRIM_GDSC 9#define USB30_SEC_GDSC 10 +#define HLOS1_VOTE_MMNOC_MMU_TBU_HF0_GDSC 11 +#define HLOS1_VOTE_MMNOC_MMU_TBU_HF1_GDSC 12 +#define HLOS1_VOTE_MMNOC_MMU_TBU_SF_GDSC 13 +#define HLOS1_VOTE_TURING_MMU_TBU0_GDSC 14 +#define HLOS1_VOTE_TURING_MMU_TBU1_GDSC 15#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 538/776 clk: qcom: gcc-sc8180x: Add missing GDSCs
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Val Packett <[email protected]>
[ Upstream commit 3565741eb985a8a7cc6656eb33496195468cb99e ]
There are 5 more GDSCs that we were ignoring and not putting to sleep, which are listed in downstream DTS. Add them.
--- drivers/clk/qcom/gcc-sc8180x.c | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+)
drivers/clk/qcom/gcc-sc8180x.c +50 -0
@@ -4200,6 +4200,51 @@ static struct gdsc usb30_mp_gdsc = { .flags = POLL_CFG_GDSCR, }; +static struct gdsc hlos1_vote_mmnoc_mmu_tbu_hf0_gdsc = { + .gdscr =0x7d050 , + .pd = { + .name ="hlos1_vote_mmnoc_mmu_tbu_hf0_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =VOTABLE , +}; + +static struct gdsc hlos1_vote_mmnoc_mmu_tbu_hf1_gdsc = { + .gdscr =0x7d058 , + .pd = { + .name ="hlos1_vote_mmnoc_mmu_tbu_hf1_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =VOTABLE , +}; + +static struct gdsc hlos1_vote_mmnoc_mmu_tbu_sf_gdsc = { + .gdscr =0x7d054 , + .pd = { + .name ="hlos1_vote_mmnoc_mmu_tbu_sf_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =VOTABLE , +}; + +static struct gdsc hlos1_vote_turing_mmu_tbu0_gdsc = { + .gdscr =0x7d05c , + .pd = { + .name ="hlos1_vote_turing_mmu_tbu0_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =VOTABLE , +}; + +static struct gdsc hlos1_vote_turing_mmu_tbu1_gdsc = { + .gdscr =0x7d060 , + .pd = { + .name ="hlos1_vote_turing_mmu_tbu1_gdsc" , + }, + .pwrsts =PWRSTS_OFF_ON , + .flags =VOTABLE , +}; +static struct clk_regmap *gcc_sc8180x_clocks[] = { [GCC_AGGRE_NOC_PCIE_TBU_CLK ] = &gcc_aggre_noc_pcie_tbu_clk.clkr, [GCC_AGGRE_UFS_CARD_AXI_CLK ] = &gcc_aggre_ufs_card_axi_clk.clkr,
@@ -4500,6 +4545,11 @@ static struct gdsc *gcc_sc8180x_gdscs[] = { [USB30_MP_GDSC] = &usb30_mp_gdsc, [USB30_PRIM_GDSC] = &usb30_prim_gdsc, [USB30_SEC_GDSC] = &usb30_sec_gdsc, + [HLOS1_VOTE_MMNOC_MMU_TBU_HF0_GDSC] = &hlos1_vote_mmnoc_mmu_tbu_hf0_gdsc, + [HLOS1_VOTE_MMNOC_MMU_TBU_HF1_GDSC] = &hlos1_vote_mmnoc_mmu_tbu_hf1_gdsc, + [HLOS1_VOTE_MMNOC_MMU_TBU_SF_GDSC] = &hlos1_vote_mmnoc_mmu_tbu_sf_gdsc, + [HLOS1_VOTE_TURING_MMU_TBU0_GDSC] = &hlos1_vote_turing_mmu_tbu0_gdsc, + [HLOS1_VOTE_TURING_MMU_TBU1_GDSC] = &hlos1_vote_turing_mmu_tbu1_gdsc, };static const struct regmap_config gcc_sc8180x_regmap_config = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 539/776 clk: qcom: gcc-sc8180x: Use retention for USB power domains
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Val Packett <[email protected]>
[ Upstream commit 25bc96f26cd6c19dde13a0b9859183e531d6fbfc ]
The USB subsystem does not expect to lose its state on suspend:
xhci-hcd xhci-hcd.0.auto: xHC error in resume, USBSTS 0x401, Reinit usb usb1: root hub lost power or was reset
(The reinitialization usually succeeds, but it does slow down resume.)
To maintain state during suspend, the relevant GDSCs need to stay in retention mode, like they do on other similar SoCs. Change the mode to PWRSTS_RET_ON to fix.
--- drivers/clk/qcom/gcc-sc8180x.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clk/qcom/gcc-sc8180x.c +3 -3
@@ -4106,7 +4106,7 @@ static struct gdsc usb30_sec_gdsc = { .pd = { .name = "usb30_sec_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, .flags = POLL_CFG_GDSCR, };
@@ -4124,7 +4124,7 @@ static struct gdsc usb30_prim_gdsc = { .pd = { .name = "usb30_prim_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, .flags = POLL_CFG_GDSCR, };
@@ -4196,7 +4196,7 @@ static struct gdsc usb30_mp_gdsc = { .pd = { .name = "usb30_mp_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, .flags = POLL_CFG_GDSCR, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 540/776 clk: qcom: gcc-sc8180x: Use retention for PCIe power domains
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Val Packett <[email protected]>
[ Upstream commit ccb92c78b42edd26225b4d5920847dfee3e1b093 ]
As the PCIe host controller driver does not yet support dealing with the loss of state during suspend, use retention for relevant GDSCs.
This fixes the link not surviving upon resume:
nvme 0002:01:00.0: Unable to change power state from D3cold to D0, device inaccessible nvme nvme0: controller is down; will reset: CSTS=0xffffffff, PCI_STATUS read failed (134) nvme 0002:01:00.0: Unable to change power state from D3cold to D0, device inaccessible nvme nvme0: Disabling device after reset failure: -19
--- drivers/clk/qcom/gcc-sc8180x.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clk/qcom/gcc-sc8180x.c +4 -4
@@ -4133,7 +4133,7 @@ static struct gdsc pcie_0_gdsc = { .pd = { .name = "pcie_0_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, .flags = POLL_CFG_GDSCR, };
@@ -4160,7 +4160,7 @@ static struct gdsc pcie_1_gdsc = { .pd = { .name = "pcie_1_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, .flags = POLL_CFG_GDSCR, };
@@ -4169,7 +4169,7 @@ static struct gdsc pcie_2_gdsc = { .pd = { .name = "pcie_2_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, .flags = POLL_CFG_GDSCR, };
@@ -4187,7 +4187,7 @@ static struct gdsc pcie_3_gdsc = { .pd = { .name = "pcie_3_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, .flags = POLL_CFG_GDSCR, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 541/776 clk: qcom: dispcc-sm8250: Use shared ops on the mdss vsync clk
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Val Packett <[email protected]>
[ Upstream commit 8c522da70f0c2e5148c4c13ccb1c64cca57a6fdb ]
mdss_gdsc can get stuck on boot due to RCGs being left on from last boot. As a fix, commit 01a0a6cc8cfd ("clk: qcom: Park shared RCGs upon registration") introduced a callback to ensure the RCG is off upon init. However, the fix depends on all shared RCGs being marked as such in code.
For SM8150/SC8180X/SM8250 the MDSS vsync clock was using regular ops, unlike the same clock in the SC7180 code. This was causing display to frequently fail to initialize after rebooting on the Surface Pro X. Fix by using shared ops for this clock.
--- drivers/clk/qcom/dispcc-sm8250.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/dispcc-sm8250.c +1 -1
@@ -613,7 +613,7 @@ static struct clk_rcg2 disp_cc_mdss_vsync_clk_src = { .parent_data = disp_cc_parent_data_1, .num_parents = ARRAY_SIZE(disp_cc_parent_data_1), .flags = CLK_SET_RATE_PARENT, - .ops = &clk_rcg2_ops, + .ops = &clk_rcg2_shared_ops, }, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 542/776 clk: qcom: dispcc-sm8250: Enable parents for pixel clocks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Val Packett <[email protected]>
[ Upstream commit acf7a91d0b0e9e3ef374944021de62062125b7e4 ]
Add CLK_OPS_PARENT_ENABLE to MDSS pixel clock sources to ensure parent clocks are enabled during clock operations, preventing potential stability issues during display configuration.
--- drivers/clk/qcom/dispcc-sm8250.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/dispcc-sm8250.c +2 -2
@@ -559,7 +559,7 @@ static struct clk_rcg2 disp_cc_mdss_pclk0_clk_src = { .name = "disp_cc_mdss_pclk0_clk_src", .parent_data = disp_cc_parent_data_6, .num_parents = ARRAY_SIZE(disp_cc_parent_data_6), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, .ops = &clk_pixel_ops, }, };
@@ -573,7 +573,7 @@ static struct clk_rcg2 disp_cc_mdss_pclk1_clk_src = { .name = "disp_cc_mdss_pclk1_clk_src", .parent_data = disp_cc_parent_data_6, .num_parents = ARRAY_SIZE(disp_cc_parent_data_6), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, .ops = &clk_pixel_ops, }, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 543/776 clk: imx: imx6q: Fix device node reference leak in pll6_bypassed()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 4b84d496c804b470124cd3a08e928df6801d8eae ]
The function pll6_bypassed() calls of_parse_phandle_with_args() but never calls of_node_put() to release the reference, causing a memory leak.
Fix this by adding proper cleanup calls on all exit paths.
--- drivers/clk/imx/clk-imx6q.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/clk/imx/clk-imx6q.c +7 -1
@@ -233,8 +233,11 @@ static bool pll6_bypassed(struct device_node *node)return false;if (clkspec.np == node && - clkspec.args[0 ] ==IMX6QDL_PLL6_BYPASS ) + clkspec.args[0 ] ==IMX6QDL_PLL6_BYPASS ) { +of_node_put (clkspec.np);break ; + } +of_node_put (clkspec.np); }/* PLL6 bypass is not part of the assigned clock list */
@@ -244,6 +247,9 @@ static bool pll6_bypassed(struct device_node *node) ret =of_parse_phandle_with_args (node,"assigned-clock-parents" ,"#clock-cells" , index, &clkspec); +if (!ret) +of_node_put (clkspec.np); +if (clkspec.args[0 ] !=IMX6QDL_CLK_PLL6 )return true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 544/776 clk: imx: imx6q: Fix device node reference leak in of_assigned_ldb_sels()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 9faf207208951460f3f7eefbc112246c8d28ff1b ]
The function of_assigned_ldb_sels() calls of_parse_phandle_with_args() but never calls of_node_put() to release the reference, causing a memory leak.
Fix this by adding proper cleanup calls on all exit paths.
--- drivers/clk/imx/clk-imx6q.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/clk/imx/clk-imx6q.c +4 -0
@@ -183,9 +183,11 @@ static void of_assigned_ldb_sels(struct device_node *node, }if (clkspec.np != node || clkspec.args[0 ] >=IMX6QDL_CLK_END ) {pr_err ("ccm: parent clock %d not in ccm\n" , index); +of_node_put (clkspec.np);return ; } parent = clkspec.args[0 ]; +of_node_put (clkspec.np); rc =of_parse_phandle_with_args (node,"assigned-clocks" ,"#clock-cells" , index, &clkspec);
@@ -193,9 +195,11 @@ static void of_assigned_ldb_sels(struct device_node *node,return ;if (clkspec.np != node || clkspec.args[0 ] >=IMX6QDL_CLK_END ) {pr_err ("ccm: child clock %d not in ccm\n" , index); +of_node_put (clkspec.np);return ; } child = clkspec.args[0 ]; +of_node_put (clkspec.np);if (child !=IMX6QDL_CLK_LDB_DI0_SEL && child !=IMX6QDL_CLK_LDB_DI1_SEL )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 545/776 clk: imx8mq: Correct the CSI PHY sels
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Krzyszkowiak <[email protected]>
[ Upstream commit d16f57caa78776e6e8a88b96cb2597797b376138 ]
According to i.MX 8M Quad Reference Manual (Section 5.1.2 Table 5-1) MIPI_CSI1_PHY_REF_CLK_ROOT and MIPI_CSI2_PHY_REF_CLK_ROOT have SYSTEM_PLL2_DIV3 available as their second source, which corresponds to sys2_pll_333m rather than sys2_pll_125m.
--- drivers/clk/imx/clk-imx8mq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/imx/clk-imx8mq.c +2 -2
@@ -237,7 +237,7 @@ static const char * const imx8mq_dsi_esc_sels[] = {"osc_25m", "sys2_pll_100m", "static const char *const imx8mq_csi1_core_sels[] = {"osc_25m" ,"sys1_pll_266m" ,"sys2_pll_250m" ,"sys1_pll_800m" ,"sys2_pll_1000m" ,"sys3_pll_out" ,"audio_pll2_out" ,"video_pll1_out" , }; -static const char *const imx8mq_csi1_phy_sels[] = {"osc_25m" ,"sys2_pll_125m" ,"sys2_pll_100m" ,"sys1_pll_800m" , +static const char *const imx8mq_csi1_phy_sels[] = {"osc_25m" ,"sys2_pll_333m" ,"sys2_pll_100m" ,"sys1_pll_800m" ,"sys2_pll_1000m" ,"clk_ext2" ,"audio_pll2_out" ,"video_pll1_out" , };static const char *const imx8mq_csi1_esc_sels[] = {"osc_25m" ,"sys2_pll_100m" ,"sys1_pll_80m" ,"sys1_pll_800m" ,
@@ -246,7 +246,7 @@ static const char * const imx8mq_csi1_esc_sels[] = {"osc_25m", "sys2_pll_100m",static const char *const imx8mq_csi2_core_sels[] = {"osc_25m" ,"sys1_pll_266m" ,"sys2_pll_250m" ,"sys1_pll_800m" ,"sys2_pll_1000m" ,"sys3_pll_out" ,"audio_pll2_out" ,"video_pll1_out" , }; -static const char *const imx8mq_csi2_phy_sels[] = {"osc_25m" ,"sys2_pll_125m" ,"sys2_pll_100m" ,"sys1_pll_800m" , +static const char *const imx8mq_csi2_phy_sels[] = {"osc_25m" ,"sys2_pll_333m" ,"sys2_pll_100m" ,"sys1_pll_800m" ,"sys2_pll_1000m" ,"clk_ext2" ,"audio_pll2_out" ,"video_pll1_out" , };static const char *const imx8mq_csi2_esc_sels[] = {"osc_25m" ,"sys2_pll_100m" ,"sys1_pll_80m" ,"sys1_pll_800m" ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 546/776 clk: qoriq: avoid format string warning
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 096abbb6682ee031a0f5ce9f4c71ead9fa63d31e ]
clang-22 warns about the use of non-variadic format arguments passed into snprintf():
drivers/clk/clk-qoriq.c:925:39: error: diagnostic behavior may be improved by adding the
'format(printf, 7, 8)' attribute to the declaration of 'create_mux_common' [-Werror,-Wmissing-format-attribute]
910 | static struct clk * __init create_mux_common(struct clockgen *cg,
| __attribute__((format(printf, 7, 8)))
911 | struct mux_hwclock *hwc,
912 | const struct clk_ops *ops,
913 | unsigned long min_rate,
914 | unsigned long max_rate,
915 | unsigned long pct80_rate,
916 | const char *fmt, int idx)
917 | {
918 | struct clk_init_data init = {};
919 | struct clk *clk;
920 | const struct clockgen_pll_div *div;
921 | const char *parent_names[NUM_MUX_PARENTS];
922 | char name[32];
923 | int i, j;
924 |
925 | snprintf(name, sizeof(name), fmt, idx);
| ^drivers/clk/clk-qoriq.c:910:28: note: 'create_mux_common' declared here
910 | static struct clk * __init create_mux_common(struct clockgen *cg,
Rework this to pass the 'int idx' as a varargs argument, allowing the format string to be verified at the caller location.
--- drivers/clk/clk-qoriq.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/clk/clk-qoriq.c +9 -8
@@ -905,13 +905,11 @@ static const struct clockgen_pll_div *get_pll_div(struct clockgen *cg,return &cg->pll[pll].div[div]; } -static struct clk *__init create_mux_common (struct clockgen *cg, -struct mux_hwclock *hwc, -const struct clk_ops *ops, -unsigned long min_rate, -unsigned long max_rate, -unsigned long pct80_rate, -const char *fmt,int idx) +static struct clk * __init __printf(7, 8) +create_mux_common(struct clockgen *cg, struct mux_hwclock *hwc, + const struct clk_ops *ops, unsigned long min_rate, + unsigned long max_rate, unsigned long pct80_rate, + const char *fmt, ...) { struct clk_init_data init = {};struct clk *clk;
@@ -919,8 +917,11 @@ static struct clk * __init create_mux_common(struct clockgen *cg,const char *parent_names[NUM_MUX_PARENTS ];char name[32 ];int i, j; +va_list args; -snprintf (name,sizeof (name), fmt, idx); +va_start (args, fmt); +vsnprintf (name,sizeof (name), fmt, args); +va_end (args);for (i =0 , j =0 ; i <NUM_MUX_PARENTS ; i++) {unsigned long rate;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 547/776 clk: xgene: Fix mapping leak in xgene_pllclk_init()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit f520a492e07bc6718e26cfb7543ab4cadd8bb0e2 ]
If xgene_register_clk_pll() fails, the mapped register block is never unmapped.
--- drivers/clk/clk-xgene.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clk/clk-xgene.c +2 -0
@@ -187,6 +187,8 @@ static void xgene_pllclk_init(struct device_node *np, enum xgene_pll_type pll_tyof_clk_add_provider (np, of_clk_src_simple_get, clk);clk_register_clkdev (clk, clk_name,NULL );pr_debug ("Add %s clock PLL\n" , clk_name); + }else { +iounmap (reg); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 548/776 dt-bindings: clock: qcom,dispcc-sc7180: Define MDSS resets
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit fc6e29d42872680dca017f2e5169eefe971f8d89 ]
The MDSS resets have so far been left undescribed. Fix that.
Stable-dep-of: b0bc6011c549 ("clk: qcom: dispcc-sc7180: Add missing MDSS resets")
--- include/dt-bindings/clock/qcom,dispcc-sc7180.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
include/dt-bindings/clock/qcom,dispcc-sc7180.h +6 -1
@@ -6,6 +6,7 @@#ifndef _DT_BINDINGS_CLK_QCOM_DISP_CC_SC7180_H#define _DT_BINDINGS_CLK_QCOM_DISP_CC_SC7180_H +/* Clocks */ #define DISP_CC_PLL0 0#define DISP_CC_PLL0_OUT_EVEN 1#define DISP_CC_MDSS_AHB_CLK 2
@@ -40,7 +41,11 @@#define DISP_CC_MDSS_VSYNC_CLK_SRC 31#define DISP_CC_XO_CLK 32 -/* DISP_CC GDSCR */ +/* Resets */ +#define DISP_CC_MDSS_CORE_BCR 0 +#define DISP_CC_MDSS_RSCC_BCR 1 + +/* GDSCs */ #define MDSS_GDSC 0#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 549/776 clk: qcom: dispcc-sc7180: Add missing MDSS resets
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit b0bc6011c5499bdfddd0390262bfa13dce1eff74 ]
The MDSS resets have so far been left undescribed. Fix that.
--- drivers/clk/qcom/dispcc-sc7180.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/clk/qcom/dispcc-sc7180.c +8 -0
@@ -16,6 +16,7 @@#include "clk-regmap-divider.h" #include "common.h" #include "gdsc.h" +#include "reset.h" enum {P_BI_TCXO ,
@@ -635,6 +636,11 @@ static struct gdsc mdss_gdsc = { .flags = HW_CTRL, }; +static const struct qcom_reset_map disp_cc_sc7180_resets[] = { + [DISP_CC_MDSS_CORE_BCR ] = {0x2000 }, + [DISP_CC_MDSS_RSCC_BCR ] = {0x4000 }, +}; +static struct gdsc *disp_cc_sc7180_gdscs[] = { [MDSS_GDSC ] = &mdss_gdsc, };
@@ -686,6 +692,8 @@ static const struct qcom_cc_desc disp_cc_sc7180_desc = { .config = &disp_cc_sc7180_regmap_config, .clks = disp_cc_sc7180_clocks, .num_clks = ARRAY_SIZE(disp_cc_sc7180_clocks), + .resets = disp_cc_sc7180_resets, + .num_resets = ARRAY_SIZE(disp_cc_sc7180_resets), .gdscs = disp_cc_sc7180_gdscs, .num_gdscs = ARRAY_SIZE(disp_cc_sc7180_gdscs), };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 550/776 lib/hexdump: print_hex_dump_bytes() calls print_hex_dump_debug()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 36776b7f8a8955b4e75b5d490a75fee0c7a2a7ef ]
print_hex_dump_bytes() claims to be a simple wrapper around print_hex_dump(), but it actally calls print_hex_dump_debug(), which means no output is printed if (dynamic) DEBUG is disabled.
Update the documentation to match the implementation.
--- include/linux/printk.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/linux/printk.h +3 -2
@@ -741,7 +741,8 @@ static inline void print_hex_dump_debug(const char *prefix_str, int prefix_type,#endif /** -* print_hex_dump_bytes - shorthand form of print_hex_dump() with default params +* print_hex_dump_bytes - shorthand form of print_hex_dump_debug() with default +* params * @prefix_str: string to prefix each line with; * caller supplies trailing spaces for alignment if desired * @prefix_type: controls whether prefix of an offset, address, or none
@@ -749,7 +750,7 @@ static inline void print_hex_dump_debug(const char *prefix_str, int prefix_type,* @buf: data blob to dump * @len: number of bytes in the @buf * -* Calls print_hex_dump(), with log level of KERN_DEBUG, +* Calls print_hex_dump_debug(), with log level of KERN_DEBUG, * rowsize of 16, groupsize of 1, and ASCII output included. */ #define print_hex_dump_bytes (prefix_str, prefix_type, buf, len) \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 551/776 crypto: sa2ul - Fix AEAD fallback algorithm names
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: T Pratham <[email protected]>
[ Upstream commit 8451ab6ad686ffdcdf9ddadaa446a79ab48e5590 ]
For authenc AEAD algorithms, sa2ul is trying to register very specific -ce version as a fallback. This causes registration failure on SoCs which do not have ARMv8-CE enabled/available. Change the fallback algorithm from the specific driver name to generic algorithm name so that the kernel can allocate any available fallback.
--- drivers/crypto/sa2ul.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/sa2ul.c +2 -2
@@ -1774,13 +1774,13 @@ static int sa_cra_init_aead(struct crypto_aead *tfm, const char *hash,static int sa_cra_init_aead_sha1 (struct crypto_aead *tfm) {return sa_cra_init_aead (tfm,"sha1" , -"authenc(hmac(sha1-ce),cbc(aes-ce))" ); +"authenc(hmac(sha1),cbc(aes))" ); }static int sa_cra_init_aead_sha256 (struct crypto_aead *tfm) {return sa_cra_init_aead (tfm,"sha256" , -"authenc(hmac(sha256-ce),cbc(aes-ce))" ); +"authenc(hmac(sha256),cbc(aes))" ); }static void sa_exit_tfm_aead (struct crypto_aead *tfm)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 552/776 crypto: ccp - copy IV using skcipher ivsize
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Moses <[email protected]>
[ Upstream commit a7a1f3cdd64d8a165d9b8c9e9ad7fb46ac19dfc4 ]
AF_ALG rfc3686-ctr-aes-ccp requests pass an 8-byte IV to the driver.
ccp_aes_complete() restores AES_BLOCK_SIZE bytes into the caller's IV buffer while RFC3686 skciphers expose an 8-byte IV, so the restore overruns the provided buffer.
Use crypto_skcipher_ivsize() to copy only the algorithm's IV length.
--- drivers/crypto/ccp/ccp-crypto-aes.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/crypto/ccp/ccp-crypto-aes.c +5 -2
@@ -28,8 +28,11 @@ static int ccp_aes_complete(struct crypto_async_request *async_req, int ret)if (ret)return ret; -if (ctx->u.aes.mode !=CCP_AES_MODE_ECB ) -memcpy (req->iv, rctx->iv,AES_BLOCK_SIZE ); +if (ctx->u.aes.mode !=CCP_AES_MODE_ECB ) { +size_t ivsize =crypto_skcipher_ivsize (crypto_skcipher_reqtfm (req)); + +memcpy (req->iv, rctx->iv, ivsize); + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 553/776 PCMCIA: Fix garbled log messages for KERN_CONT
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: René Rebe <[email protected]>
[ Upstream commit bfeaa6814bd3f9a1f6d525b3b35a03b9a0368961 ]
For years the PCMCIA info messages are messed up by superfluous newlines. While f2e6cf76751d ("pcmcia: Convert dev_printk to dev_<level>") converted the code to pr_cont(), dev_info enforces a \n via vprintk_store setting LOG_NEWLINE, breaking subsequent pr_cont.
Fix by logging the device name manually to allow pr_cont to work for more readable and not \n distorted logs.
--- drivers/pcmcia/rsrc_nonstatic.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pcmcia/rsrc_nonstatic.c +3 -3
@@ -188,7 +188,7 @@ static void do_io_probe(struct pcmcia_socket *s, unsigned int base,int any;u_char *b, hole, most; -dev_info (&s->dev,"cs: IO port probe %#x-%#x:" , base, base+num-1 ); +pr_info ("%s: cs: IO port probe %#x-%#x:" ,dev_name (&s->dev), base, base+num-1 );/* First, what does a floating port look like? */ b =kzalloc (256 ,GFP_KERNEL );
@@ -410,8 +410,8 @@ static int do_mem_probe(struct pcmcia_socket *s, u_long base, u_long num,struct socket_data *s_data = s->resource_data;u_long i, j, bad, fail, step; -dev_info (&s->dev,"cs: memory probe 0x%06lx-0x%06lx:" , - base, base+num-1 ); +pr_info ("%s: cs: memory probe 0x%06lx-0x%06lx:" , +dev_name (&s->dev), base, base+num-1 ); bad = fail =0 ; step = (num <0x20000 ) ?0x2000 : ((num>>4 ) & ~0x1fff );/* don't allow too large steps */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 554/776 net/sched: sch_cake: fix NAT destination port not being updated in cake_update_flowkeys
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dudu Lu <[email protected]>
[ Upstream commit f9e40664706927d7ae22a448a3383e23c38a4c0b ]
cake_update_flowkeys() is supposed to update the flow dissector keys with the NAT-translated addresses and ports from conntrack, so that CAKE's per-flow fairness correctly identifies post-NAT flows as belonging to the same connection.
For the source port, this works correctly:
keys->ports.src = port;
But for the destination port, the assignment is reversed:
port = keys->ports.dst;
This means the NAT destination port is never updated in the flow keys. As a result, when multiple connections are NATed to the same destination, CAKE treats them as separate flows because the original (pre-NAT) destination ports differ. This breaks CAKE's NAT-aware flow isolation when using the "nat" mode.
The bug was introduced in commit b0c19ed6088a ("sch_cake: Take advantage of skb->hash where appropriate") which refactored the original direct assignment into a compare-and-conditionally-update pattern, but wrote the destination port update backwards.
Fix by reversing the assignment direction to match the source port pattern.
--- net/sched/sch_cake.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_cake.c +1 -1
@@ -619,7 +619,7 @@ static bool cake_update_flowkeys(struct flow_keys *keys, } port = rev ? tuple.src.u.all : tuple.dst.u.all;if (port != keys->ports.dst) { - port = keys->ports.dst; + keys->ports.dst = port; upd = true; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 555/776 nexthop: fix IPv6 route referencing IPv4 nexthop
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 29c95185ba32b621fbc3800fb86e7dc3edf5c2be ]
syzbot reported a panic [1] [2].
When an IPv6 nexthop is replaced with an IPv4 nexthop, the has_v4 flag of all groups containing this nexthop is not updated. This is because nh_group_v4_update is only called when replacing AF_INET to AF_INET6, but the reverse direction (AF_INET6 to AF_INET) is missed.
This allows a stale has_v4=false to bypass fib6_check_nexthop, causing IPv6 routes to be attached to groups that effectively contain only AF_INET members. Subsequent route lookups then call nexthop_fib6_nh() which returns NULL for the AF_INET member, leading to a NULL pointer dereference.
Fix by calling nh_group_v4_update whenever the family changes, not just AF_INET to AF_INET6.
Reproducer:
# AF_INET6 blackhole
ip -6 nexthop add id 1 blackhole
# group with has_v4=false
ip nexthop add id 100 group 1
# replace with AF_INET (no -6), has_v4 stays false ip nexthop replace id 1 blackhole
# pass stale has_v4 check
ip -6 route add 2001:db8::/64 nhid 100
# panic
ping -6 2001:db8::1
[1] https://syzkaller.appspot.com/bug?id=e17283eb2f8dcf3dd9b47fe6f67a95f71faadad0
[2] https://syzkaller.appspot.com/bug?id=8699b6ae54c9f35837d925686208402949e12ef3
--- net/ipv4/nexthop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv4/nexthop.c +2 -2
@@ -2161,10 +2161,10 @@ static int replace_nexthop_single(struct net *net, struct nexthop *old, goto err_notify; } -/* When replacing an IPv4 nexthop with an IPv6 nexthop, potentially +/* When replacing a nexthop with one of a different family, potentially * update IPv4 indication in all the groups using the nexthop. */ -if (oldi->family ==AF_INET && newi->family ==AF_INET6 ) { +if (oldi->family != newi->family) {list_for_each_entry (nhge, &old->grp_list, nh_list) {struct nexthop *nhp = nhge->nh_parent;struct nh_group *nhg;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 556/776 net/sched: taprio: stop going through private ops for dequeue and peek
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Oltean <[email protected]>
[ Upstream commit 25becba6290bc34e369a0e1a76db9ca88bad87aa ]
Since commit 13511704f8d7 ("net: taprio offload: enforce qdisc to netdev queue mapping"), taprio_dequeue_soft() and taprio_peek_soft() are de facto the only implementations for Qdisc_ops :: dequeue and Qdisc_ops ::
peek that taprio provides.
This is because in full offload mode, __dev_queue_xmit() will select a txq->qdisc which is never root taprio qdisc. So if nothing is enqueued in the root qdisc, it will never be run and nothing will get dequeued from it.
Therefore, we can remove the private indirection from taprio, and always point Qdisc_ops :: dequeue to taprio_dequeue_soft (now simply named taprio_dequeue) and Qdisc_ops :: peek to taprio_peek_soft (now simply named taprio_peek).
Stable-dep-of: 105425b1969c ("net/sched: taprio: fix use-after-free in advance_sched() on schedule switch")
--- net/sched/sch_taprio.c | 58 +++++++++--------------------------------- 1 file changed, 12 insertions(+), 46 deletions(-)
net/sched/sch_taprio.c +12 -46
@@ -78,8 +78,6 @@ struct taprio_sched {struct sched_gate_list __rcu *admin_sched;struct hrtimer advance_timer;struct list_head taprio_list; -struct sk_buff *(*dequeue)(struct Qdisc *sch); -struct sk_buff *(*peek)(struct Qdisc *sch);u32 txtime_delay; };
@@ -491,7 +489,7 @@ static int taprio_enqueue(struct sk_buff *skb, struct Qdisc *sch,return taprio_enqueue_one (skb, sch, child, to_free); } -static struct sk_buff *taprio_peek_soft (struct Qdisc *sch) +static struct sk_buff *taprio_peek (struct Qdisc *sch) {struct taprio_sched *q =qdisc_priv (sch);struct net_device *dev =qdisc_dev (sch);
@@ -500,6 +498,11 @@ static struct sk_buff *taprio_peek_soft(struct Qdisc *sch)u32 gate_mask;int i; +if (unlikely (FULL_OFFLOAD_IS_ENABLED (q->flags))) { +WARN_ONCE (1 ,"Trying to peek into the root of a taprio qdisc configured with full offload\n" ); +return NULL ; + } +rcu_read_lock (); entry =rcu_dereference (q->current_entry); gate_mask = entry ? entry->gate_mask :TAPRIO_ALL_GATES_OPEN ;
@@ -535,20 +538,6 @@ static struct sk_buff *taprio_peek_soft(struct Qdisc *sch)return NULL ; } -static struct sk_buff *taprio_peek_offload (struct Qdisc *sch) -{ -WARN_ONCE (1 ,"Trying to peek into the root of a taprio qdisc configured with full offload\n" ); - -return NULL ; -} - -static struct sk_buff *taprio_peek (struct Qdisc *sch) -{ -struct taprio_sched *q =qdisc_priv (sch); - -return q->peek (sch); -} -static void taprio_set_budget (struct taprio_sched *q,struct sched_entry *entry) { atomic_set(&entry->budget,
@@ -556,7 +545,7 @@ static void taprio_set_budget(struct taprio_sched *q, struct sched_entry *entry) atomic64_read(&q->picos_per_byte))); } -static struct sk_buff *taprio_dequeue_soft (struct Qdisc *sch) +static struct sk_buff *taprio_dequeue (struct Qdisc *sch) {struct taprio_sched *q =qdisc_priv (sch);struct net_device *dev =qdisc_dev (sch);
@@ -565,6 +554,11 @@ static struct sk_buff *taprio_dequeue_soft(struct Qdisc *sch)u32 gate_mask;int i; +if (unlikely (FULL_OFFLOAD_IS_ENABLED (q->flags))) { +WARN_ONCE (1 ,"Trying to dequeue from the root of a taprio qdisc configured with full offload\n" ); +return NULL ; + } +rcu_read_lock (); entry =rcu_dereference (q->current_entry);/* if there's no entry, it means that the schedule didn't
@@ -644,20 +638,6 @@ static struct sk_buff *taprio_dequeue_soft(struct Qdisc *sch)return skb; } -static struct sk_buff *taprio_dequeue_offload (struct Qdisc *sch) -{ -WARN_ONCE (1 ,"Trying to dequeue from the root of a taprio qdisc configured with full offload\n" ); - -return NULL ; -} - -static struct sk_buff *taprio_dequeue (struct Qdisc *sch) -{ -struct taprio_sched *q =qdisc_priv (sch); - -return q->dequeue (sch); -} -static bool should_restart_cycle (const struct sched_gate_list *oper,const struct sched_entry *entry) {
@@ -1572,17 +1552,6 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, q->advance_timer.function = advance_sched; } -if (FULL_OFFLOAD_IS_ENABLED (q->flags)) { - q->dequeue = taprio_dequeue_offload; - q->peek = taprio_peek_offload; - }else { -/* Be sure to always keep the function pointers -* in a consistent state. -*/ - q->dequeue = taprio_dequeue_soft; - q->peek = taprio_peek_soft; - } - err =taprio_get_start_time (sch, new_admin, &start);if (err <0 ) {NL_SET_ERR_MSG (extack,"Internal error: failed get start time" );
@@ -1698,9 +1667,6 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt,hrtimer_init (&q->advance_timer,CLOCK_TAI ,HRTIMER_MODE_ABS ); q->advance_timer.function = advance_sched; - q->dequeue = taprio_dequeue_soft; - q->peek = taprio_peek_soft; - q->root = sch;/* We only support static clockids. Use an invalid value as default
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 557/776 net/sched: taprio: replace safety precautions with comments
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Oltean <[email protected]>
[ Upstream commit 2c08a4f898d0a8e08f431709a1ae728a6fddaabd ]
The WARN_ON_ONCE() checks introduced in commit 13511704f8d7 ("net:
taprio offload: enforce qdisc to netdev queue mapping") take a small toll on performance, but otherwise, the conditions are never expected to happen. Replace them with comments, such that the information is still conveyed to developers.
Stable-dep-of: 105425b1969c ("net/sched: taprio: fix use-after-free in advance_sched() on schedule switch")
--- net/sched/sch_taprio.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-)
net/sched/sch_taprio.c +9 -15
@@ -432,6 +432,9 @@ static int taprio_enqueue_one(struct sk_buff *skb, struct Qdisc *sch,return qdisc_enqueue (skb, child, to_free); } +/* Will not be called in the full offload case, since the TX queues are +* attached to the Qdisc created using qdisc_create_dflt() +*/ static int taprio_enqueue (struct sk_buff *skb,struct Qdisc *sch,struct sk_buff **to_free) {
@@ -439,11 +442,6 @@ static int taprio_enqueue(struct sk_buff *skb, struct Qdisc *sch,struct Qdisc *child;int queue; -if (unlikely (FULL_OFFLOAD_IS_ENABLED (q->flags))) { -WARN_ONCE (1 ,"Trying to enqueue skb into the root of a taprio qdisc configured with full offload\n" ); -return qdisc_drop (skb, sch, to_free); - } - queue =skb_get_queue_mapping (skb); child = q->qdiscs[queue];
@@ -489,6 +487,9 @@ static int taprio_enqueue(struct sk_buff *skb, struct Qdisc *sch,return taprio_enqueue_one (skb, sch, child, to_free); } +/* Will not be called in the full offload case, since the TX queues are +* attached to the Qdisc created using qdisc_create_dflt() +*/ static struct sk_buff *taprio_peek (struct Qdisc *sch) {struct taprio_sched *q =qdisc_priv (sch);
@@ -498,11 +499,6 @@ static struct sk_buff *taprio_peek(struct Qdisc *sch)u32 gate_mask;int i; -if (unlikely (FULL_OFFLOAD_IS_ENABLED (q->flags))) { -WARN_ONCE (1 ,"Trying to peek into the root of a taprio qdisc configured with full offload\n" ); -return NULL ; - } -rcu_read_lock (); entry =rcu_dereference (q->current_entry); gate_mask = entry ? entry->gate_mask :TAPRIO_ALL_GATES_OPEN ;
@@ -545,6 +541,9 @@ static void taprio_set_budget(struct taprio_sched *q, struct sched_entry *entry) atomic64_read(&q->picos_per_byte))); } +/* Will not be called in the full offload case, since the TX queues are +* attached to the Qdisc created using qdisc_create_dflt() +*/ static struct sk_buff *taprio_dequeue (struct Qdisc *sch) {struct taprio_sched *q =qdisc_priv (sch);
@@ -554,11 +553,6 @@ static struct sk_buff *taprio_dequeue(struct Qdisc *sch)u32 gate_mask;int i; -if (unlikely (FULL_OFFLOAD_IS_ENABLED (q->flags))) { -WARN_ONCE (1 ,"Trying to dequeue from the root of a taprio qdisc configured with full offload\n" ); -return NULL ; - } -rcu_read_lock (); entry =rcu_dereference (q->current_entry);/* if there's no entry, it means that the schedule didn't
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 558/776 net/sched: taprio: continue with other TXQs if one dequeue() failed
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Oltean <[email protected]>
[ Upstream commit 1638bbbe4ececa615b273497d347d59ad71060a2 ]
This changes the handling of an unlikely condition to not stop dequeuing if taprio failed to dequeue the peeked skb in taprio_dequeue().
I've no idea when this can happen, but the only side effect seems to be that the atomic_sub_return() call right above will have consumed some budget. This isn't a big deal, since either that made us remain without any budget (and therefore, we'd exit on the next peeked skb anyway), or we could send some packets from other TXQs.
I'm making this change because in a future patch I'll be refactoring the dequeue procedure to simplify it, and this corner case will have to go away.
Stable-dep-of: 105425b1969c ("net/sched: taprio: fix use-after-free in advance_sched() on schedule switch")
--- net/sched/sch_taprio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_taprio.c +1 -1
@@ -616,7 +616,7 @@ static struct sk_buff *taprio_dequeue(struct Qdisc *sch) skb = child->ops->dequeue (child);if (unlikely (!skb)) - goto done; +continue ; skb_found:qdisc_bstats_update (sch, skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 559/776 net/sched: taprio: refactor one skb dequeue from TXQ to separate function
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Oltean <[email protected]>
[ Upstream commit 92f966674f6a257eddfa60a85f9b6741d6087ccb ]
Future changes will refactor the TXQ selection procedure, and a lot of stuff will become messy, the indentation of the bulk of the dequeue procedure would increase, etc.
Break out the bulk of the function into a new one, which knows the TXQ (child qdisc) we should perform a dequeue from.
Stable-dep-of: 105425b1969c ("net/sched: taprio: fix use-after-free in advance_sched() on schedule switch")
--- net/sched/sch_taprio.c | 121 +++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 58 deletions(-)
net/sched/sch_taprio.c +63 -58
@@ -541,6 +541,66 @@ static void taprio_set_budget(struct taprio_sched *q, struct sched_entry *entry) atomic64_read(&q->picos_per_byte))); } +static struct sk_buff *taprio_dequeue_from_txq (struct Qdisc *sch,int txq, +struct sched_entry *entry, +u32 gate_mask) +{ +struct taprio_sched *q =qdisc_priv (sch); +struct net_device *dev =qdisc_dev (sch); +struct Qdisc *child = q->qdiscs[txq]; +struct sk_buff *skb; +ktime_t guard; +int prio; +int len; +u8 tc; + +if (unlikely (!child)) +return NULL ; + +if (TXTIME_ASSIST_IS_ENABLED (q->flags)) { + skb = child->ops->dequeue (child); +if (!skb) +return NULL ; + goto skb_found; + } + + skb = child->ops->peek (child); +if (!skb) +return NULL ; + + prio = skb->priority; + tc =netdev_get_prio_tc_map (dev, prio); + +if (!(gate_mask &BIT (tc))) +return NULL ; + + len =qdisc_pkt_len (skb); + guard =ktime_add_ns (taprio_get_time (q),length_to_duration (q, len)); + +/* In the case that there's no gate entry, there's no +* guard band ... +*/ +if (gate_mask !=TAPRIO_ALL_GATES_OPEN && +ktime_after (guard, entry->close_time)) +return NULL ; + +/* ... and no budget. */ +if (gate_mask !=TAPRIO_ALL_GATES_OPEN && +atomic_sub_return (len, &entry->budget) <0 ) +return NULL ; + + skb = child->ops->dequeue (child); +if (unlikely (!skb)) +return NULL ; + +skb_found: +qdisc_bstats_update (sch, skb); +qdisc_qstats_backlog_dec (sch, skb); + sch->q.qlen--; + +return skb; +} +/* Will not be called in the full offload case, since the TX queues are * attached to the Qdisc created using qdisc_create_dflt() */
@@ -566,64 +626,9 @@ static struct sk_buff *taprio_dequeue(struct Qdisc *sch) goto done;for (i =0 ; i < dev->num_tx_queues; i++) { -struct Qdisc *child = q->qdiscs[i]; -ktime_t guard; -int prio; -int len; -u8 tc; - -if (unlikely (!child)) -continue ; - -if (TXTIME_ASSIST_IS_ENABLED (q->flags)) { - skb = child->ops->dequeue (child); -if (!skb) -continue ; - goto skb_found; - } - - skb = child->ops->peek (child); -if (!skb) -continue ; - - prio = skb->priority; - tc =netdev_get_prio_tc_map (dev, prio); - -if (!(gate_mask &BIT (tc))) { - skb =NULL ; -continue ; - } - - len =qdisc_pkt_len (skb); - guard =ktime_add_ns (taprio_get_time (q), -length_to_duration (q, len)); - -/* In the case that there's no gate entry, there's no -* guard band ... -*/ -if (gate_mask !=TAPRIO_ALL_GATES_OPEN && -ktime_after (guard, entry->close_time)) { - skb =NULL ; -continue ; - } - -/* ... and no budget. */ -if (gate_mask !=TAPRIO_ALL_GATES_OPEN && -atomic_sub_return (len, &entry->budget) <0 ) { - skb =NULL ; -continue ; - } - - skb = child->ops->dequeue (child); -if (unlikely (!skb)) -continue ; - -skb_found: -qdisc_bstats_update (sch, skb); -qdisc_qstats_backlog_dec (sch, skb); - sch->q.qlen--; - - goto done; + skb =taprio_dequeue_from_txq (sch, i, entry, gate_mask); +if (skb) + goto done; } done:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 560/776 net/sched: taprio: rename close_time to end_time
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Oltean <[email protected]>
[ Upstream commit e5517551112ff2395611e552443932152f83672d ]
There is a confusion in terms in taprio which makes what is called "close_time" to be actually used for 2 things:
1. determining when an entry "closes" such that transmitted skbs are never allowed to overrun that time (?!)
2. an aid for determining when to advance and/or restart the schedule using the hrtimer
It makes more sense to call this so-called "close_time" "end_time", because it's not clear at all to me what "closes". Future patches will hopefully make better use of the term "to close".
This is an absolutely mechanical change.
Stable-dep-of: 105425b1969c ("net/sched: taprio: fix use-after-free in advance_sched() on schedule switch")
--- net/sched/sch_taprio.c | 52 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-)
net/sched/sch_taprio.c +26 -26
@@ -37,11 +37,11 @@ static DEFINE_SPINLOCK(taprio_list_lock);struct sched_entry {struct list_head list; -/* The instant that this entry "closes" and the next one +/* The instant that this entry ends and the next one * should open, the qdisc will make some effort so that no * packet leaves after this time. */ -ktime_t close_time; +ktime_t end_time;ktime_t next_txtime;atomic_t budget;int index;
@@ -54,7 +54,7 @@ struct sched_gate_list {struct rcu_head rcu;struct list_head entries;size_t num_entries; -ktime_t cycle_close_time; +ktime_t cycle_end_time;s64 cycle_time;s64 cycle_time_extension;s64 base_time;
@@ -581,7 +581,7 @@ static struct sk_buff *taprio_dequeue_from_txq(struct Qdisc *sch, int txq,* guard band ... */ if (gate_mask !=TAPRIO_ALL_GATES_OPEN && -ktime_after (guard, entry->close_time)) +ktime_after (guard, entry->end_time))return NULL ;/* ... and no budget. */
@@ -643,7 +643,7 @@ static bool should_restart_cycle(const struct sched_gate_list *oper,if (list_is_last (&entry->list, &oper->entries))return true; -if (ktime_compare (entry->close_time, oper->cycle_close_time) ==0 ) +if (ktime_compare (entry->end_time, oper->cycle_end_time) ==0 )return true;return false;
@@ -651,7 +651,7 @@ static bool should_restart_cycle(const struct sched_gate_list *oper,static bool should_change_schedules (const struct sched_gate_list *admin,const struct sched_gate_list *oper, -ktime_t close_time) +ktime_t end_time) {ktime_t next_base_time, extension_time;
@@ -660,18 +660,18 @@ static bool should_change_schedules(const struct sched_gate_list *admin, next_base_time =sched_base_time (admin); -/* This is the simple case, the close_time would fall after +/* This is the simple case, the end_time would fall after * the next schedule base_time. */ -if (ktime_compare (next_base_time, close_time) <=0 ) +if (ktime_compare (next_base_time, end_time) <=0 )return true; -/* This is the cycle_time_extension case, if the close_time +/* This is the cycle_time_extension case, if the end_time * plus the amount that can be extended would fall after the * next schedule base_time, we can extend the current schedule * for that amount. */ - extension_time =ktime_add_ns (close_time, oper->cycle_time_extension); + extension_time =ktime_add_ns (end_time, oper->cycle_time_extension);/* FIXME: the IEEE 802.1Q-2018 Specification isn't clear about * how precisely the extension should be made. So after
@@ -690,7 +690,7 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer)struct sched_gate_list *oper, *admin;struct sched_entry *entry, *next;struct Qdisc *sch = q->root; -ktime_t close_time; +ktime_t end_time;spin_lock (&q->current_entry_lock); entry = rcu_dereference_protected(q->current_entry,
@@ -709,41 +709,41 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer)* entry of all schedules are pre-calculated during the * schedule initialization. */ -if (unlikely (!entry || entry->close_time == oper->base_time)) { +if (unlikely (!entry || entry->end_time == oper->base_time)) { next = list_first_entry(&oper->entries, struct sched_entry, list); - close_time = next->close_time; + end_time = next->end_time; goto first_run; }if (should_restart_cycle (oper, entry)) { next = list_first_entry(&oper->entries, struct sched_entry, list); - oper->cycle_close_time =ktime_add_ns (oper->cycle_close_time, - oper->cycle_time); + oper->cycle_end_time =ktime_add_ns (oper->cycle_end_time, + oper->cycle_time); }else { next =list_next_entry (entry, list); } - close_time =ktime_add_ns (entry->close_time, next->interval); - close_time =min_t (ktime_t, close_time, oper->cycle_close_time); + end_time =ktime_add_ns (entry->end_time, next->interval); + end_time =min_t (ktime_t, end_time, oper->cycle_end_time); -if (should_change_schedules (admin, oper, close_time)) { +if (should_change_schedules (admin, oper, end_time)) {/* Set things so the next time this runs, the new * schedule runs. */ - close_time =sched_base_time (admin); + end_time =sched_base_time (admin);switch_schedules (q, &admin, &oper); } - next->close_time = close_time; + next->end_time = end_time;taprio_set_budget (q, next); first_run:rcu_assign_pointer (q->current_entry, next);spin_unlock (&q->current_entry_lock); -hrtimer_set_expires (&q->advance_timer, close_time); +hrtimer_set_expires (&q->advance_timer, end_time);rcu_read_lock ();__netif_schedule (sch);
@@ -1016,8 +1016,8 @@ static int taprio_get_start_time(struct Qdisc *sch,return 0 ; } -static void setup_first_close_time (struct taprio_sched *q, -struct sched_gate_list *sched,ktime_t base) +static void setup_first_end_time (struct taprio_sched *q, +struct sched_gate_list *sched,ktime_t base) {struct sched_entry *first;ktime_t cycle;
@@ -1028,9 +1028,9 @@ static void setup_first_close_time(struct taprio_sched *q, cycle = sched->cycle_time;/* FIXME: find a better place to do this */ - sched->cycle_close_time =ktime_add_ns (base, cycle); + sched->cycle_end_time =ktime_add_ns (base, cycle); - first->close_time =ktime_add_ns (base, first->interval); + first->end_time =ktime_add_ns (base, first->interval);taprio_set_budget (q, first);rcu_assign_pointer (q->current_entry,NULL ); }
@@ -1573,7 +1573,7 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt,if (admin)call_rcu (&admin->rcu, taprio_free_sched_cb); }else { -setup_first_close_time (q, new_admin, start); +setup_first_end_time (q, new_admin, start);/* Protects against advance_sched() */ spin_lock_irqsave (&q->current_entry_lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 561/776 net/sched: taprio: fix use-after-free in advance_sched() on schedule switch
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vinicius Costa Gomes <[email protected]>
[ Upstream commit 105425b1969c5affe532713cfac1c0b320d7ac2b ]
In advance_sched(), when should_change_schedules() returns true, switch_schedules() is called to promote the admin schedule to oper. switch_schedules() queues the old oper schedule for RCU freeing via call_rcu(), but 'next' still points into an entry of the old oper schedule. The subsequent 'next->end_time = end_time' and rcu_assign_pointer(q->current_entry, next) are use-after-free.
Fix this by selecting 'next' from the new oper schedule immediately after switch_schedules(), and using its pre-calculated end_time. setup_first_end_time() sets the first entry's end_time to base_time + interval when the schedule is installed, so the value is already correct.
The deleted 'end_time = sched_base_time(admin)' assignment was also harmful independently: it would overwrite the new first entry's pre-calculated end_time with just base_time.
--- net/sched/sch_taprio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
net/sched/sch_taprio.c +5 -4
@@ -729,11 +729,12 @@ static enum hrtimer_restart advance_sched(struct hrtimer *timer) end_time =min_t (ktime_t, end_time, oper->cycle_end_time);if (should_change_schedules (admin, oper, end_time)) { -/* Set things so the next time this runs, the new -* schedule runs. -*/ - end_time =sched_base_time (admin);switch_schedules (q, &admin, &oper); +/* After changing schedules, the next entry is the first one +* in the new schedule, with a pre-calculated end_time. +*/ + next = list_first_entry(&oper->entries, struct sched_entry, list); + end_time = next->end_time; } next->end_time = end_time;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 562/776 tcp: annotate data-races around (tp->write_seq - tp->snd_nxt)
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 3a63b3d160560ef51e43fb4c880a5cde8078053c ]
tcp_get_timestamping_opt_stats() intentionally runs lockless, we must add READ_ONCE() annotations to keep KCSAN happy.
WRITE_ONCE() annotations are already present.
--- net/ipv4/tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/tcp.c +2 -1
@@ -3961,7 +3961,8 @@ struct sk_buff *tcp_get_timestamping_opt_stats(const struct sock *sk,nla_put_u32 (stats,TCP_NLA_SRTT , tp->srtt_us >>3 );nla_put_u16 (stats,TCP_NLA_TIMEOUT_REHASH , tp->timeout_rehash);nla_put_u32 (stats,TCP_NLA_BYTES_NOTSENT , -max_t (int,0 , tp->write_seq - tp->snd_nxt)); +max_t (int,0 , +READ_ONCE (tp->write_seq) -READ_ONCE (tp->snd_nxt)));nla_put_u64_64bit (stats,TCP_NLA_EDT , orig_skb->skb_mstamp_ns,TCP_NLA_PAD );if (ack_skb)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 563/776 i40e: dont advertise IFF_SUPP_NOFCS
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kohei Enju <[email protected]>
[ Upstream commit a24162f18825684ad04e3a5d0531f8a50d679347 ]
i40e advertises IFF_SUPP_NOFCS, allowing users to use the SO_NOFCS socket option. However, this option is silently ignored, as the driver does not check skb->no_fcs, and always enables FCS insertion offload.
Fix this by removing the advertisement of IFF_SUPP_NOFCS.
This behavior can be reproduced with a simple AF_PACKET socket:
import socket
s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW) s.setsockopt(socket.SOL_SOCKET, 43, 1) # SO_NOFCS s.bind(("eth0", 0))
s.send(b'\xff' * 64)
Previously, send() succeeds but the driver ignores SO_NOFCS. With this change, send() fails with -EPROTONOSUPPORT, as expected.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +0 -1
@@ -13817,7 +13817,6 @@ static int i40e_config_netdev(struct i40e_vsi *vsi) netdev->neigh_priv_len =sizeof (u32) *4 ; netdev->priv_flags |=IFF_UNICAST_FLT ; - netdev->priv_flags |=IFF_SUPP_NOFCS ;/* Setup netdev TC information */ i40e_vsi_config_netdev_tc (vsi, vsi->tc_config.enabled_tc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 564/776 e1000e: Unroll PTP in probe error handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Vollrath <[email protected]>
[ Upstream commit aa3f7fe409350857c25d050482a2eef2cfd69b58 ]
If probe fails after registering the PTP clock and its delayed work, these resources must be released.
This was not an issue until a 2016 fix moved the e1000e_ptp_init() call before the jump to err_register.
--- drivers/net/ethernet/intel/e1000e/netdev.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/e1000e/netdev.c +1 -0
@@ -7708,6 +7708,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_register:if (!(adapter->flags &FLAG_HAS_AMT ))e1000e_release_hw_control (adapter); +e1000e_ptp_remove (adapter); err_eeprom:if (hw->phy.ops.check_reset_block && !hw->phy.ops.check_reset_block (hw))e1000_phy_hw_reset (&adapter->hw);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 565/776 ipv6: fix possible UAF in icmpv6_rcv()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit f996edd7615e686ada141b7f3395025729ff8ccb ]
Caching saddr and daddr before pskb_pull() is problematic since skb->head can change.
Remove these temporary variables:
- We only access &ipv6_hdr(skb)->saddr and &ipv6_hdr(skb)->daddr when net_dbg_ratelimited() is called in the slow path.
- Avoid potential future misuse after pskb_pull() call.
--- net/ipv6/icmp.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
net/ipv6/icmp.c +4 -6
@@ -883,7 +883,6 @@ static int icmpv6_rcv(struct sk_buff *skb)struct net *net =dev_net (skb->dev);struct net_device *dev =icmp6_dev (skb);struct inet6_dev *idev =__in6_dev_get (dev); -const struct in6_addr *saddr, *daddr;struct icmp6hdr *hdr;u8 type;bool success = false;
@@ -910,12 +909,10 @@ static int icmpv6_rcv(struct sk_buff *skb)__ICMP6_INC_STATS (dev_net (dev), idev,ICMP6_MIB_INMSGS ); - saddr = &ipv6_hdr (skb)->saddr; - daddr = &ipv6_hdr (skb)->daddr; -if (skb_checksum_validate (skb,IPPROTO_ICMPV6 , ip6_compute_pseudo)) {net_dbg_ratelimited ("ICMPv6 checksum failed [%pI6c > %pI6c]\n" , - saddr, daddr); + &ipv6_hdr (skb)->saddr, + &ipv6_hdr (skb)->daddr); goto csum_error; }
@@ -997,7 +994,8 @@ static int icmpv6_rcv(struct sk_buff *skb)break ;net_dbg_ratelimited ("icmpv6: msg of unknown type [%pI6c > %pI6c]\n" , - saddr, daddr); + &ipv6_hdr (skb)->saddr, + &ipv6_hdr (skb)->daddr);/* * error of unknown type.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 566/776 sctp: fix OOB write to userspace in sctp_getsockopt_peer_auth_chunks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit 0cf004ffb61cd32d140531c3a84afe975f9fc7ea ]
sctp_getsockopt_peer_auth_chunks() checks that the caller's optval buffer is large enough for the peer AUTH chunk list with
if (len < num_chunks)
return -EINVAL;
but then writes num_chunks bytes to p->gauth_chunks, which lives at offset offsetof(struct sctp_authchunks, gauth_chunks) == 8 inside optval. The check is missing the sizeof(struct sctp_authchunks) = 8-byte header. When the caller supplies len == num_chunks (for any num_chunks > 0) the test passes but copy_to_user() writes sizeof(struct sctp_authchunks) = 8 bytes past the declared buffer.
The sibling function sctp_getsockopt_local_auth_chunks() at the next line already has the correct check:
if (len < sizeof(struct sctp_authchunks) + num_chunks)
return -EINVAL;
Align the peer variant with its sibling.
Reproducer confirms on v7.0-13-generic: an unprivileged userspace caller that opens a loopback SCTP association with AUTH enabled, queries num_chunks with a short optval, then issues the real getsockopt with len == num_chunks and sentinel bytes painted past the buffer observes those sentinel bytes overwritten with the peer's AUTH chunk type. The bytes written are under the peer's control but land in the caller's own userspace; this is not a kernel memory corruption, but it is a kernel-side contract violation that can silently corrupt adjacent userspace data.
--- net/sctp/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/socket.c +1 -1
@@ -6991,7 +6991,7 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len,/* See if the user provided enough room for all the data */ num_chunks =ntohs (ch->param_hdr.length) -sizeof (struct sctp_paramhdr ); -if (len < num_chunks) +if (len <sizeof (struct sctp_authchunks ) + num_chunks)return -EINVAL ;if (copy_to_user (to, ch->chunks, num_chunks))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 567/776 dissector: do not set invalid PPP protocol
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Sukholitko <[email protected]>
[ Upstream commit 2e861e5e97175dfa7b7bc055c45acdc06d2301d3 ]
The following flower filter fails to match non-PPP_IP{V6} packets wrapped in PPP_SES protocol:
tc filter add dev eth0 ingress protocol ppp_ses flower \
action simple sdata hi64
The reason is that proto local variable is being set even when FLOW_DISSECT_RET_OUT_BAD status is returned.
The fix is to avoid setting proto variable if the PPP protocol is unknown.
Stable-dep-of: cc1ff87bce1c ("pppoe: drop PFC frames")
--- net/core/flow_dissector.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/core/flow_dissector.c +1 -2
@@ -1207,9 +1207,8 @@ bool __skb_flow_dissect(const struct net *net,break ; } - proto = hdr->proto; nhoff +=PPPOE_SES_HLEN ; -switch (proto) { +switch (hdr->proto) {case htons (PPP_IP ): proto =htons (ETH_P_IP ); fdret =FLOW_DISSECT_RET_PROTO_AGAIN ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 568/776 flow_dissector: Add number of vlan tags dissector
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Sukholitko <[email protected]>
[ Upstream commit 34951fcf26c59e78ae430fba1fce7c08b1871249 ]
Our customers in the fiber telecom world have network configurations where they would like to control their traffic according to the number of tags appearing in the packet.
For example, TR247 GPON conformance test suite specification mostly talks about untagged, single, double tagged packets and gives lax guidelines on the vlan protocol vs. number of vlan tags.
This is different from the common IT networks where 802.1Q and 802.1ad protocols are usually describe single and double tagged packet. GPON configurations that we work with have arbitrary mix the above protocols and number of vlan tags in the packet.
The goal is to make the following TC commands possible:
tc filter add dev eth1 ingress flower \
num_of_vlans 1 vlan_prio 5 action drop
Quoted 1 line
From our logs, we have redirect rules such that:
tc filter add dev $GPON ingress flower num_of_vlans $N \
action mirred egress redirect dev $DEV
where N can range from 0 to 3 and $DEV is the function of $N.
Also there are rules setting skb mark based on the number of vlans:
tc filter add dev $GPON ingress flower num_of_vlans $N vlan_prio \
$P action skbedit mark $M
This new dissector allows extracting the number of vlan tags existing in the packet.
Stable-dep-of: cc1ff87bce1c ("pppoe: drop PFC frames")
--- include/net/flow_dissector.h | 9 +++++++++ net/core/flow_dissector.c | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+)
include/net/flow_dissector.h +9 -0
@@ -269,6 +269,14 @@ struct flow_dissector_key_hash {u32 hash; }; +/** +* struct flow_dissector_key_num_of_vlans: +* @num_of_vlans: num_of_vlans value +*/ +struct flow_dissector_key_num_of_vlans { +u8 num_of_vlans; +}; +enum flow_dissector_key_id {FLOW_DISSECTOR_KEY_CONTROL ,/* struct flow_dissector_key_control */ FLOW_DISSECTOR_KEY_BASIC ,/* struct flow_dissector_key_basic */
@@ -298,6 +306,7 @@ enum flow_dissector_key_id {FLOW_DISSECTOR_KEY_META ,/* struct flow_dissector_key_meta */ FLOW_DISSECTOR_KEY_CT ,/* struct flow_dissector_key_ct */ FLOW_DISSECTOR_KEY_HASH ,/* struct flow_dissector_key_hash */ +FLOW_DISSECTOR_KEY_NUM_OF_VLANS ,/* struct flow_dissector_key_num_of_vlans */ FLOW_DISSECTOR_KEY_MAX, };
net/core/flow_dissector.c +20 -0
@@ -1042,6 +1042,16 @@ bool __skb_flow_dissect(const struct net *net,memcpy (key_eth_addrs, ð->h_dest,sizeof (*key_eth_addrs)); } +if (dissector_uses_key (flow_dissector, +FLOW_DISSECTOR_KEY_NUM_OF_VLANS )) { +struct flow_dissector_key_num_of_vlans *key_num_of_vlans; + + key_num_of_vlans =skb_flow_dissector_target (flow_dissector, +FLOW_DISSECTOR_KEY_NUM_OF_VLANS , + target_container); + key_num_of_vlans->num_of_vlans =0 ; + } + proto_again: fdret =FLOW_DISSECT_RET_CONTINUE ;
@@ -1165,6 +1175,16 @@ bool __skb_flow_dissect(const struct net *net, nhoff +=sizeof (*vlan); } +if (dissector_uses_key (flow_dissector, +FLOW_DISSECTOR_KEY_NUM_OF_VLANS )) { +struct flow_dissector_key_num_of_vlans *key_nvs; + + key_nvs =skb_flow_dissector_target (flow_dissector, +FLOW_DISSECTOR_KEY_NUM_OF_VLANS , + target_container); + key_nvs->num_of_vlans++; + } +if (dissector_vlan ==FLOW_DISSECTOR_KEY_MAX ) { dissector_vlan =FLOW_DISSECTOR_KEY_VLAN ; }else if (dissector_vlan ==FLOW_DISSECTOR_KEY_VLAN ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 569/776 flow_dissector: Add PPPoE dissectors
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wojciech Drewek <[email protected]>
[ Upstream commit 46126db9c86110e5fc1e369b9bb89735ddefdae4 ]
Allow to dissect PPPoE specific fields which are:
- session ID (16 bits)
- ppp protocol (16 bits)
- type (16 bits) - this is PPPoE ethertype, for now only ETH_P_PPP_SES is supported, possible ETH_P_PPP_DISC in the future
The goal is to make the following TC command possible:
# tc filter add dev ens6f0 ingress prio 1 protocol ppp_ses \
flower \
pppoe_sid 12 \
ppp_proto ip \
action dropNote that only PPPoE Session is supported.
Stable-dep-of: cc1ff87bce1c ("pppoe: drop PFC frames")
--- include/linux/ppp_defs.h | 14 ++++++++++ include/net/flow_dissector.h | 13 +++++++++ net/core/flow_dissector.c | 53 +++++++++++++++++++++++++++++++----- 3 files changed, 73 insertions(+), 7 deletions(-)
include/linux/ppp_defs.h +14 -0
@@ -11,4 +11,18 @@#include <uapi/linux/ppp_defs.h> #define PPP_FCS (fcs, c) crc_ccitt_byte(fcs, c) + +/** +* ppp_proto_is_valid - checks if PPP protocol is valid +* @proto: PPP protocol +* +* Assumes proto is not compressed. +* Protocol is valid if the value is odd and the least significant bit of the +* most significant octet is 0 (see RFC 1661, section 2). +*/ +static inline bool ppp_proto_is_valid (u16 proto) +{ +return !!((proto &0x0101 ) ==0x0001 ); +} +#endif /* _PPP_DEFS_H_ */
include/net/flow_dissector.h +13 -0
@@ -277,6 +277,18 @@ struct flow_dissector_key_num_of_vlans {u8 num_of_vlans; }; +/** +* struct flow_dissector_key_pppoe: +* @session_id: pppoe session id +* @ppp_proto: ppp protocol +* @type: pppoe eth type +*/ +struct flow_dissector_key_pppoe { +__be16 session_id; +__be16 ppp_proto; +__be16 type; +}; +enum flow_dissector_key_id {FLOW_DISSECTOR_KEY_CONTROL ,/* struct flow_dissector_key_control */ FLOW_DISSECTOR_KEY_BASIC ,/* struct flow_dissector_key_basic */
@@ -307,6 +319,7 @@ enum flow_dissector_key_id {FLOW_DISSECTOR_KEY_CT ,/* struct flow_dissector_key_ct */ FLOW_DISSECTOR_KEY_HASH ,/* struct flow_dissector_key_hash */ FLOW_DISSECTOR_KEY_NUM_OF_VLANS ,/* struct flow_dissector_key_num_of_vlans */ +FLOW_DISSECTOR_KEY_PPPOE ,/* struct flow_dissector_key_pppoe */ FLOW_DISSECTOR_KEY_MAX, };
net/core/flow_dissector.c +46 -7
78 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 570/776 pppoe: drop PFC frames
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit cc1ff87bce1ccd38410ab10960f576dcd17db679 ]
RFC 2516 Section 7 states that Protocol Field Compression (PFC) is NOT RECOMMENDED for PPPoE. In practice, pppd does not support negotiating PFC for PPPoE sessions, and the current PPPoE driver assumes an uncompressed (2-byte) protocol field. However, the generic PPP layer function ppp_input() is not aware of the negotiation result, and still accepts PFC frames.
If a peer with a broken implementation or an attacker sends a frame with a compressed (1-byte) protocol field, the subsequent PPP payload is shifted by one byte. This causes the network header to be 4-byte misaligned, which may trigger unaligned access exceptions on some architectures.
To reduce the attack surface, drop PPPoE PFC frames. Introduce ppp_skb_is_compressed_proto() helper function to be used in both ppp_generic.c and pppoe.c to avoid open-coding.
--- drivers/net/ppp/ppp_generic.c | 2 +- drivers/net/ppp/pppoe.c | 8 +++++++- include/linux/ppp_defs.h | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-)
drivers/net/ppp/ppp_generic.c +1 -1
@@ -2244,7 +2244,7 @@ ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)*/ static void __ppp_decompress_proto (struct sk_buff *skb) { -if (skb->data[0 ] &0x01 ) +if (ppp_skb_is_compressed_proto (skb)) *(u8 *)skb_push (skb,1 ) =0x00 ; }
drivers/net/ppp/pppoe.c +7 -1
@@ -425,7 +425,7 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,if (skb_mac_header_len (skb) <ETH_HLEN ) goto drop; -if (!pskb_may_pull (skb,sizeof (struct pppoe_hdr ))) +if (!pskb_may_pull (skb,PPPOE_SES_HLEN )) goto drop; ph =pppoe_hdr (skb);
@@ -435,6 +435,12 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,if (skb->len < len) goto drop; +/* skb->data points to the PPP protocol header after skb_pull_rcsum. +* Drop PFC frames. +*/ +if (ppp_skb_is_compressed_proto (skb)) + goto drop; +if (pskb_trim_rcsum (skb, len)) goto drop;
include/linux/ppp_defs.h +16 -0
@@ -8,6 +8,7 @@#define _PPP_DEFS_H_#include <linux/crc-ccitt.h> +#include <linux/skbuff.h> #include <uapi/linux/ppp_defs.h> #define PPP_FCS (fcs, c) crc_ccitt_byte(fcs, c)
@@ -25,4 +26,19 @@ static inline bool ppp_proto_is_valid(u16 proto) return !!((proto & 0x0101) == 0x0001); } +/** +* ppp_skb_is_compressed_proto - checks if PPP protocol in a skb is compressed +* @skb: skb to check +* +* Check if the PPP protocol field is compressed (the least significant +* bit of the most significant octet is 1). skb->data must point to the PPP +* protocol header. +* +* Return: Whether the PPP protocol field is compressed. +*/ +static inline bool ppp_skb_is_compressed_proto (const struct sk_buff *skb) +{ +return unlikely (skb->data[0 ] &0x01 ); +} +#endif /* _PPP_DEFS_H_ */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 571/776 openvswitch: cap upcall PID array size and pre-size vport replies
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 2091c6aa0df6aba47deb5c8ab232b1cb60af3519 ]
The vport netlink reply helpers allocate a fixed-size skb with nlmsg_new(NLMSG_DEFAULT_SIZE, ...) but serialize the full upcall PID array via ovs_vport_get_upcall_portids(). Since ovs_vport_set_upcall_portids() accepts any non-zero multiple of sizeof(u32) with no upper bound, a CAP_NET_ADMIN user can install a PID array large enough to overflow the reply buffer, causing nla_put() to fail with -EMSGSIZE and hitting BUG_ON(err < 0). On systems with unprivileged user namespaces enabled (e.g., Ubuntu default), this is reachable via unshare -Urn since OVS vport mutation operations use GENL_UNS_ADMIN_PERM.
kernel BUG at net/openvswitch/datapath.c:2414!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI CPU: 1 UID: 0 PID: 65 Comm: poc Not tainted 7.0.0-rc7-00195-geb216e422044 #1 RIP: 0010:ovs_vport_cmd_set+0x34c/0x400 Call Trace: <TASK> genl_family_rcv_msg_doit (net/netlink/genetlink.c:1116) genl_rcv_msg (net/netlink/genetlink.c:1194) netlink_rcv_skb (net/netlink/af_netlink.c:2550) genl_rcv (net/netlink/genetlink.c:1219) netlink_unicast (net/netlink/af_netlink.c:1344) netlink_sendmsg (net/netlink/af_netlink.c:1894) __sys_sendto (net/socket.c:2206) __x64_sys_sendto (net/socket.c:2209) do_syscall_64 (arch/x86/entry/syscall_64.c:63) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) </TASK> Kernel panic - not syncing: Fatal exception
Reject attempts to set more PIDs than nr_cpu_ids in ovs_vport_set_upcall_portids(), and pre-compute the worst-case reply size in ovs_vport_cmd_msg_size() based on that bound, similar to the existing ovs_dp_cmd_msg_size(). nr_cpu_ids matches the cap already used by the per-CPU dispatch configuration on the datapath side (ovs_dp_cmd_fill_info() serialises at most nr_cpu_ids PIDs), so the two sides stay consistent.
--- net/openvswitch/datapath.c | 35 +++++++++++++++++++++++++++++++++-- net/openvswitch/vport.c | 3 +++ 2 files changed, 36 insertions(+), 2 deletions(-)
net/openvswitch/datapath.c +33 -2
@@ -2110,9 +2110,40 @@ static int ovs_vport_cmd_fill_info(struct vport *vport, struct sk_buff *skb,return err; } +static size_t ovs_vport_cmd_msg_size (void ) +{ +size_t msgsize =NLMSG_ALIGN (sizeof (struct ovs_header )); + + msgsize +=nla_total_size (sizeof (u32));/* OVS_VPORT_ATTR_PORT_NO */ + msgsize +=nla_total_size (sizeof (u32));/* OVS_VPORT_ATTR_TYPE */ + msgsize +=nla_total_size (IFNAMSIZ );/* OVS_VPORT_ATTR_NAME */ + msgsize +=nla_total_size (sizeof (u32));/* OVS_VPORT_ATTR_IFINDEX */ + msgsize +=nla_total_size (sizeof (s32));/* OVS_VPORT_ATTR_NETNSID */ + +/* OVS_VPORT_ATTR_STATS */ + msgsize +=nla_total_size_64bit (sizeof (struct ovs_vport_stats )); + +/* OVS_VPORT_ATTR_UPCALL_STATS(OVS_VPORT_UPCALL_ATTR_SUCCESS + +* OVS_VPORT_UPCALL_ATTR_FAIL) +*/ + msgsize +=nla_total_size (nla_total_size_64bit (sizeof (u64)) + +nla_total_size_64bit (sizeof (u64))); + +/* OVS_VPORT_ATTR_UPCALL_PID */ + msgsize +=nla_total_size (nr_cpu_ids *sizeof (u32)); + +/* OVS_VPORT_ATTR_OPTIONS(OVS_TUNNEL_ATTR_DST_PORT + +* OVS_TUNNEL_ATTR_EXTENSION(OVS_VXLAN_EXT_GBP)) +*/ + msgsize +=nla_total_size (nla_total_size (sizeof (u16)) + +nla_total_size (nla_total_size (0 ))); + +return msgsize; +} +static struct sk_buff *ovs_vport_cmd_alloc_info (void ) { -return nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); +return genlmsg_new (ovs_vport_cmd_msg_size (),GFP_KERNEL ); }/* Called with ovs_mutex, only via ovs_dp_notify_wq(). */
@@ -2122,7 +2153,7 @@ struct sk_buff *ovs_vport_cmd_build_info(struct vport *vport, struct net *net,struct sk_buff *skb;int retval; - skb =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_KERNEL ); + skb =ovs_vport_cmd_alloc_info ();if (!skb)return ERR_PTR (-ENOMEM );
net/openvswitch/vport.c +3 -0
@@ -342,6 +342,9 @@ int ovs_vport_set_upcall_portids(struct vport *vport, const struct nlattr *ids)if (!nla_len (ids) ||nla_len (ids) %sizeof (u32))return -EINVAL ; +if (nla_len (ids) /sizeof (u32) > nr_cpu_ids) +return -EINVAL ; + old =ovsl_dereference (vport->upcall_portids); vport_portids = kmalloc(sizeof(*vport_portids) + nla_len(ids),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 572/776 netfilter: nft_osf: restrict it to ipv4
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
[ Upstream commit b336fdbb7103fb1484e1dcb6741151d4b5a41e35 ]
This expression only supports for ipv4, restrict it.
--- net/netfilter/nft_osf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/netfilter/nft_osf.c +5 -1
@@ -28,6 +28,11 @@ static void nft_osf_eval(const struct nft_expr *expr, struct nft_regs *regs,struct nf_osf_data data;struct tcphdr _tcph; +if (nft_pf (pkt) !=NFPROTO_IPV4 ) { + regs->verdict.code =NFT_BREAK ; +return ; + } +if (pkt->tprot !=IPPROTO_TCP ) { regs->verdict.code =NFT_BREAK ;return ;
@@ -119,7 +124,6 @@ static int nft_osf_validate(const struct nft_ctx *ctx,switch (ctx->family) {case NFPROTO_IPV4 : -case NFPROTO_IPV6 :case NFPROTO_INET : hooks = (1 <<NF_INET_LOCAL_IN ) | (1 << NF_INET_PRE_ROUTING) |
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 573/776 netfilter: nfnetlink_osf: fix divide-by-zero in OSF_WSS_MODULO
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit 2195574dc6d9017d32ac346987e12659f931d932 ]
nf_osf_match_one() computes ctx->window % f->wss.val in the OSF_WSS_MODULO branch with no guard for f->wss.val == 0. A CAP_NET_ADMIN user can add such a fingerprint via nfnetlink; a subsequent matching TCP SYN divides by zero and panics the kernel.
Reject the bogus fingerprint in nfnl_osf_add_callback() above the per-option for-loop. f->wss is per-fingerprint, not per-option, so the check must run regardless of f->opt_num (including 0). Also reject wss.wc >= OSF_WSS_MAX; nf_osf_match_one() already treats that as "should not happen".
Crash:
Oops: divide error: 0000 [#1] SMP KASAN NOPTI RIP: 0010:nf_osf_match_one (net/netfilter/nfnetlink_osf.c:98) Call Trace: <IRQ> nf_osf_match (net/netfilter/nfnetlink_osf.c:220) xt_osf_match_packet (net/netfilter/xt_osf.c:32) ipt_do_table (net/ipv4/netfilter/ip_tables.c:348) nf_hook_slow (net/netfilter/core.c:622) ip_local_deliver (net/ipv4/ip_input.c:265) ip_rcv (include/linux/skbuff.h:1162) __netif_receive_skb_one_core (net/core/dev.c:6181) process_backlog (net/core/dev.c:6642) __napi_poll (net/core/dev.c:7710) net_rx_action (net/core/dev.c:7945) handle_softirqs (kernel/softirq.c:622)
--- net/netfilter/nfnetlink_osf.c | 4 ++++ 1 file changed, 4 insertions(+)
net/netfilter/nfnetlink_osf.c +4 -0
@@ -320,6 +320,10 @@ static int nfnl_osf_add_callback(struct sk_buff *skb,if (f->opt_num >ARRAY_SIZE (f->opt))return -EINVAL ; +if (f->wss.wc >=OSF_WSS_MAX || + (f->wss.wc ==OSF_WSS_MODULO && f->wss.val ==0 )) +return -EINVAL ; +for (i =0 ; i < f->opt_num; i++) {if (!f->opt[i].length || f->opt[i].length >MAX_IPOPTLEN )return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 574/776 netfilter: conntrack: remove sprintf usage
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 6e7066bdb481a87fe88c4fa563e348c03b2d373d ]
Replace it with scnprintf, the buffer sizes are expected to be large enough to hold the result, no need for snprintf+overflow check.
Increase buffer size in mangle_content_len() while at it.
BUG: KASAN: stack-out-of-bounds in vsnprintf+0xea5/0x1270 Write of size 1 at addr [..] vsnprintf+0xea5/0x1270 sprintf+0xb1/0xe0 mangle_content_len+0x1ac/0x280 nf_nat_sdp_session+0x1cc/0x240 process_sdp+0x8f8/0xb80 process_invite_request+0x108/0x2b0 process_sip_msg+0x5da/0xf50 sip_help_tcp+0x45e/0x780 nf_confirm+0x34d/0x990 [..]
--- net/netfilter/nf_nat_amanda.c | 2 +- net/netfilter/nf_nat_sip.c | 33 ++++++++++++++++++--------------- 2 files changed, 19 insertions(+), 16 deletions(-)
net/netfilter/nf_nat_amanda.c +1 -1
@@ -62,7 +62,7 @@ static unsigned int help(struct sk_buff *skb,return NF_DROP ; } -sprintf (buffer,"%u" , port); +snprintf (buffer,sizeof (buffer),"%u" , port);if (!nf_nat_mangle_udp_packet (skb, exp->master, ctinfo, protoff, matchoff, matchlen, buffer,strlen (buffer))) {
net/netfilter/nf_nat_sip.c +18 -15
@@ -68,25 +68,27 @@ static unsigned int mangle_packet(struct sk_buff *skb, unsigned int protoff, }static int sip_sprintf_addr (const struct nf_conn *ct,char *buffer, +size_t size,const union nf_inet_addr *addr,bool delim) {if (nf_ct_l3num (ct) ==NFPROTO_IPV4 ) -return sprintf (buffer,"%pI4" , &addr->ip); +return scnprintf (buffer, size,"%pI4" , &addr->ip);else {if (delim) -return sprintf (buffer,"[%pI6c]" , &addr->ip6); +return scnprintf (buffer, size,"[%pI6c]" , &addr->ip6);else -return sprintf (buffer,"%pI6c" , &addr->ip6); +return scnprintf (buffer, size,"%pI6c" , &addr->ip6); } }static int sip_sprintf_addr_port (const struct nf_conn *ct,char *buffer, +size_t size,const union nf_inet_addr *addr,u16 port) {if (nf_ct_l3num (ct) ==NFPROTO_IPV4 ) -return sprintf (buffer,"%pI4:%u" , &addr->ip, port); +return scnprintf (buffer, size,"%pI4:%u" , &addr->ip, port);else -return sprintf (buffer,"[%pI6c]:%u" , &addr->ip6, port); +return scnprintf (buffer, size,"[%pI6c]:%u" , &addr->ip6, port); } static int map_addr(struct sk_buff *skb, unsigned int protoff,
@@ -119,7 +121,7 @@ static int map_addr(struct sk_buff *skb, unsigned int protoff,if (nf_inet_addr_cmp (&newaddr, addr) && newport == port)return 1 ; - buflen =sip_sprintf_addr_port (ct, buffer, &newaddr,ntohs (newport)); + buflen =sip_sprintf_addr_port (ct, buffer,sizeof (buffer), &newaddr,ntohs (newport));return mangle_packet (skb, protoff, dataoff, dptr, datalen, matchoff, matchlen, buffer, buflen); }
@@ -212,7 +214,7 @@ static unsigned int nf_nat_sip(struct sk_buff *skb, unsigned int protoff, &addr, true) > 0 && nf_inet_addr_cmp(&addr, &ct->tuplehash[dir].tuple.src.u3) && !nf_inet_addr_cmp(&addr, &ct->tuplehash[!dir].tuple.dst.u3)) { - buflen = sip_sprintf_addr(ct, buffer, + buflen = sip_sprintf_addr(ct, buffer, sizeof(buffer), &ct->tuplehash[!dir].tuple.dst.u3, true); if (!mangle_packet(skb, protoff, dataoff, dptr, datalen,
@@ -229,7 +231,7 @@ static unsigned int nf_nat_sip(struct sk_buff *skb, unsigned int protoff, &addr, false) > 0 && nf_inet_addr_cmp(&addr, &ct->tuplehash[dir].tuple.dst.u3) && !nf_inet_addr_cmp(&addr, &ct->tuplehash[!dir].tuple.src.u3)) { - buflen = sip_sprintf_addr(ct, buffer, + buflen = sip_sprintf_addr(ct, buffer, sizeof(buffer), &ct->tuplehash[!dir].tuple.src.u3, false); if (!mangle_packet(skb, protoff, dataoff, dptr, datalen,
@@ -247,7 +249,7 @@ static unsigned int nf_nat_sip(struct sk_buff *skb, unsigned int protoff, htons(n) == ct->tuplehash[dir].tuple.dst.u.udp.port && htons(n) != ct->tuplehash[!dir].tuple.src.u.udp.port) {__be16 p = ct->tuplehash[!dir].tuple.src.u.udp.port; - buflen =sprintf (buffer,"%u" ,ntohs (p)); + buflen =scnprintf (buffer,sizeof (buffer),"%u" ,ntohs (p));if (!mangle_packet (skb, protoff, dataoff, dptr, datalen, poff, plen, buffer, buflen)) {nf_ct_helper_log (skb, ct,"cannot mangle rport" );
@@ -430,7 +432,8 @@ static unsigned int nf_nat_sip_expect(struct sk_buff *skb, unsigned int protoff,if (!nf_inet_addr_cmp (&exp->tuple.dst.u3, &exp->saved_addr) || exp->tuple.dst.u.udp.port != exp->saved_proto.udp.port) { - buflen =sip_sprintf_addr_port (ct, buffer, &newaddr, port); + buflen =sip_sprintf_addr_port (ct, buffer,sizeof (buffer), + &newaddr, port);if (!mangle_packet (skb, protoff, dataoff, dptr, datalen, matchoff, matchlen, buffer, buflen)) {nf_ct_helper_log (skb, ct,"cannot mangle packet" );
@@ -450,8 +453,8 @@ static int mangle_content_len(struct sk_buff *skb, unsigned int protoff, {enum ip_conntrack_info ctinfo;struct nf_conn *ct =nf_ct_get (skb, &ctinfo); +char buffer[sizeof ("4294967295" )];unsigned int matchoff, matchlen; -char buffer[sizeof ("65536" )];int buflen, c_len;/* Get actual SDP length */
@@ -466,7 +469,7 @@ static int mangle_content_len(struct sk_buff *skb, unsigned int protoff, &matchoff, &matchlen) <= 0)return 0 ; - buflen =sprintf (buffer,"%u" , c_len); + buflen =scnprintf (buffer,sizeof (buffer),"%u" , c_len);return mangle_packet (skb, protoff, dataoff, dptr, datalen, matchoff, matchlen, buffer, buflen); }
@@ -503,7 +506,7 @@ static unsigned int nf_nat_sdp_addr(struct sk_buff *skb, unsigned int protoff,char buffer[INET6_ADDRSTRLEN ];unsigned int buflen; - buflen =sip_sprintf_addr (ct, buffer, addr, false); + buflen =sip_sprintf_addr (ct, buffer,sizeof (buffer), addr, false);if (mangle_sdp_packet (skb, protoff, dataoff, dptr, datalen, sdpoff, type, term, buffer, buflen))return 0 ;
@@ -521,7 +524,7 @@ static unsigned int nf_nat_sdp_port(struct sk_buff *skb, unsigned int protoff,char buffer[sizeof ("nnnnn" )];unsigned int buflen; - buflen =sprintf (buffer,"%u" , port); + buflen =scnprintf (buffer,sizeof (buffer),"%u" , port);if (!mangle_packet (skb, protoff, dataoff, dptr, datalen, matchoff, matchlen, buffer, buflen))return 0 ;
@@ -541,7 +544,7 @@ static unsigned int nf_nat_sdp_session(struct sk_buff *skb, unsigned int protoffunsigned int buflen;/* Mangle session description owner and contact addresses */ - buflen =sip_sprintf_addr (ct, buffer, addr, false); + buflen =sip_sprintf_addr (ct, buffer,sizeof (buffer), addr, false);if (mangle_sdp_packet (skb, protoff, dataoff, dptr, datalen, sdpoff,SDP_HDR_OWNER ,SDP_HDR_MEDIA , buffer, buflen))return 0 ;
Signature · 1 line
2.53.0