6.12.118-rc1 review
Greg Kroah-Hartman
maintainerPATCH 474/670 crypto: ecc - Handle exceptional points in Shamir multiplication
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 6fd70bc8bc01a578c7728b7bd1cb5689c62cc5b7 ]
Shamir multiplication mishandles equal points, opposite points and the point at infinity. This rejects valid ECDSA signatures and can accept invalid digest/signature tuples when the public key is G or -G. The kernel incorrectly rejects 16 valid signatures from Wycheproof.
Handle doubling, cancellation and the point at infinity in precomputation and accumulation. Add regression tests for P-256 ECDSA and 256/512-bit EC-RDSA. The valid vectors are Wycheproof P1363 secp256r1/SHA-256 cases 60 and 210 converted to X9.62, two constructed ECDSA signatures for Q = +/-G with k = 2, and six constructed EC-RDSA signatures for Q = G, -G and -2G. Also add two invalid P-256 digest/signature tuples for Q = +/-G that must return -EKEYREJECTED.
--- crypto/ecc.c | 33 ++++- crypto/testmgr.c | 10 +- crypto/testmgr.h | 339 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 375 insertions(+), 7 deletions(-)
crypto/ecc.c +31 -2
@@ -1410,9 +1410,22 @@ static void ecc_point_add(const struct ecc_point *result,vli_set (result->x, q->x, ndigits);vli_set (result->y, q->y, ndigits);vli_mod_sub (z, result->x, p->x, curve->p, ndigits); +if (vli_is_zero (z, ndigits)) { +if (vli_cmp (p->y, q->y, ndigits)) { +/* P + (-P) is the point at infinity. */ +vli_clear (result->x, ndigits); +vli_clear (result->y, ndigits); +return ; + } +/* The co-Z addition formula does not handle P == Q. */ + z[0 ] =1 ; +ecc_point_double_jacobian (result->x, result->y, z, curve); + goto out; + }vli_set (px, p->x, ndigits);vli_set (py, p->y, ndigits);xycz_add (px, py, result->x, result->y, curve); +out:vli_mod_inv (z, z, curve->p, ndigits);apply_z (result->x, result->y, z, curve); }
@@ -1452,22 +1465,38 @@ void ecc_point_mult_shamir(const struct ecc_point *result,vli_set (rx, point->x, ndigits);vli_set (ry, point->y, ndigits);vli_clear (z +1 , ndigits -1 ); - z[0 ] =1 ; + z[0 ] = !ecc_point_is_zero (point);for (--i; i >=0 ; i--) {ecc_point_double_jacobian (rx, ry, z, curve); idx = !!vli_test_bit (u1, i); idx |= (!!vli_test_bit (u2, i)) <<1 ; point = points[idx]; -if (point) { +if (point && !ecc_point_is_zero (point)) {u64 tx[ECC_MAX_DIGITS ];u64 ty[ECC_MAX_DIGITS ];u64 tz[ECC_MAX_DIGITS ]; +if (vli_is_zero (z, ndigits)) { +/* Adding to infinity starts a new accumulator. */ +vli_set (rx, point->x, ndigits); +vli_set (ry, point->y, ndigits); + z[0 ] =1 ; +continue ; + }vli_set (tx, point->x, ndigits);vli_set (ty, point->y, ndigits);apply_z (tx, ty, z, curve);vli_mod_sub (tz, rx, tx, curve->p, ndigits); +if (vli_is_zero (tz, ndigits)) { +if (!vli_cmp (ry, ty, ndigits)) +ecc_point_double_jacobian (rx, ry, z, + curve); +else +/* Adding opposite points yields infinity. */ +vli_clear (z, ndigits); +continue ; + }xycz_add (tx, ty, rx, ry, curve);vli_mod_mult_fast (z, z, tz, curve); }
crypto/testmgr.c +6 -4
@@ -4209,8 +4209,10 @@ static int test_akcipher_one(struct crypto_akcipher *tfm, crypto_akcipher_verify(req) :/* Run asymmetric encrypt */ crypto_akcipher_encrypt(req), &wait); -if (err) { -pr_err ("alg: akcipher: %s test failed. err %d\n" , op, err); +if (err != vecs->verify_error) { +pr_err ("alg: akcipher: %s test failed: expected %d, got %d\n" , + op, vecs->verify_error, err); + err = err ?: -EINVAL ; goto free_all; }if (!vecs->siggen_sigver_test && c) {
@@ -4232,9 +4234,9 @@ static int test_akcipher_one(struct crypto_akcipher *tfm,/* * Don't invoke (decrypt or sign) test which require a private key -* for vectors with only a public key. +* for vectors with only a public key or an invalid signature. */ -if (vecs->public_key_vec) { +if (vecs->public_key_vec || vecs->verify_error) { err =0 ; goto free_all; }
crypto/testmgr.h +338 -1
363 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 475/670 usb: typec: ucsi: ccg: Validate altmode index in GET_CURRENT_CAM response
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seungjin Bae <[email protected]>
[ Upstream commit 02ee864e8d2142c5648998944c3306ea6a763c26 ]
When the PPM reports more than one DisplayPort alternate mode for a connector, ucsi_ccg_update_altmodes() merges them into a single entry in uc->updated[] and sets uc->has_multiple_dp. In that case, ucsi_ccg_update_get_current_cam_cmd() rewrites the response of the GET_CURRENT_CAM command. The response is a single byte holding the index of the currently active alternate mode, and it is provided by the PPM firmware.
The function uses this byte directly as an index into uc->orig[], and then uses the linked_idx read from that entry as the translated index into uc->updated[]. Both arrays have UCSI_MAX_ALTMODES entries, but neither index is checked against that size.
If a malicious or buggy PPM reports a value of UCSI_MAX_ALTMODES or larger, e.g. 0xFF, uc->orig[cam].linked_idx reads over the end of uc->orig[]. The byte read from there is then used as the index for writing cam into uc->updated[new_cam].active_idx, so the out-of-bounds read is followed by an out-of-bounds write. This happens without any userspace action, since the UCSI core issues GET_CURRENT_CAM on its own when handling connector changes.
Fix this by rejecting responses whose index is out of range, printing an error and returning -EPROTO, so that the caller cannot accept this. Also check linked_idx before using it as an index, so that the write into uc->updated[] is always within bounds.
The response is now only processed when the command completed without an error. ucsi_sync_control_common() only reads the response when the CCI reports command completion, so otherwise the buffer is not filled and must not be mistaken for an invalid index.
This bug was found with a Python script that traces where firmware input is used.
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/usb/typec/ucsi/ucsi_ccg.c +18 -3
@@ -397,14 +397,28 @@ static int ucsi_ccg_init(struct ucsi_ccg *uc)return -ETIMEDOUT ; } -static void ucsi_ccg_update_get_current_cam_cmd (struct ucsi_ccg *uc,u8 *data) +static int ucsi_ccg_update_get_current_cam_cmd (struct ucsi_ccg *uc,u8 *data) {u8 cam, new_cam; cam = data[0 ]; +if (cam >=UCSI_MAX_ALTMODES ) { +dev_err (uc->dev,"PPM returned invalid alternate mode index %u\n" , + cam); +return -EPROTO ; + } + new_cam = uc->orig[cam].linked_idx; +if (new_cam >=UCSI_MAX_ALTMODES ) { +dev_err (uc->dev,"invalid linked alternate mode index %u for %u\n" , + new_cam, cam); +return -EPROTO ; + } + uc->updated[new_cam].active_idx = cam; data[0 ] = new_cam; + +return 0 ; } static bool ucsi_ccg_update_altmodes(struct ucsi *ucsi,
@@ -593,6 +607,7 @@ static int ucsi_ccg_read_message_in(struct ucsi *ucsi, void *val, size_t val_lenstruct ucsi_ccg *uc =ucsi_get_drvdata (ucsi);struct ucsi_capability *cap;struct ucsi_altmode *alt; +int ret =0 ;spin_lock (&uc->op_lock);memcpy (val, uc->op_data.message_in, val_len);
@@ -601,7 +616,7 @@ static int ucsi_ccg_read_message_in(struct ucsi *ucsi, void *val, size_t val_lenswitch (UCSI_COMMAND (uc->last_cmd_sent)) {case UCSI_GET_CURRENT_CAM :if (uc->has_multiple_dp) -ucsi_ccg_update_get_current_cam_cmd (uc, (u8 *)val); + ret =ucsi_ccg_update_get_current_cam_cmd (uc, (u8 *)val);break ;case UCSI_GET_ALTERNATE_MODES : if (UCSI_ALTMODE_RECIPIENT(uc->last_cmd_sent) ==
@@ -622,7 +637,7 @@ static int ucsi_ccg_read_message_in(struct ucsi *ucsi, void *val, size_t val_len } uc->last_cmd_sent =0 ; -return 0 ; +return ret; }static int ucsi_ccg_async_control (struct ucsi *ucsi,u64 command)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 476/670 sctp: hold shkey across socket migration
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lee <[email protected]>
[ Upstream commit ad1320865b1826ffa2e81e37c49535751e81335c ]
sctp_sock_migrate() transfers queued DATA skbs from the old socket to the new one. skb_orphan() invokes sctp_wfree() during that transfer and drops the skb-owned shared-key reference.
If userspace has removed that key from the association, this can be the final reference. The following sctp_set_owner_w() then dereferences the freed chunk->shkey while trying to take the new owner reference.
Take a temporary shared-key reference before orphaning the skb and release it after the new owner has taken its reference. This preserves the selected authentication key throughout the ownership transfer.
Bug found and triaged by OpenAI Security Research and validated by Trail of Bits.
Stable-dep-of: 52ffeaa358d1 ("sctp: re-point retained control chunks on association migration")
--- net/sctp/socket.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
net/sctp/socket.c +11 -1
@@ -149,9 +149,19 @@ static inline void sctp_set_owner_w(struct sctp_chunk *chunk)static void sctp_clear_owner_w (struct sctp_chunk *chunk) { +/* Keep the shkey alive until the new owner takes its reference. */ +if (chunk->shkey) +sctp_auth_shkey_hold (chunk->shkey);skb_orphan (chunk->skb); } +static void sctp_set_owner_w_migrate (struct sctp_chunk *chunk) +{ +sctp_set_owner_w (chunk); +if (chunk->shkey) +sctp_auth_shkey_release (chunk->shkey); +} +#define traverse_and_process () \ do { \ msg = chunk->msg; \
@@ -9707,7 +9717,7 @@ static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,lock_sock_nested (newsk,SINGLE_DEPTH_NESTING );sctp_for_each_tx_datachunk (assoc, true, sctp_clear_owner_w);sctp_assoc_migrate (assoc, newsk); -sctp_for_each_tx_datachunk (assoc, false, sctp_set_owner_w); +sctp_for_each_tx_datachunk (assoc, false, sctp_set_owner_w_migrate);/* If the association on the newsk is already closed before accept() * is called, set RCV_SHUTDOWN flag.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 477/670 sctp: re-point retained control chunks on association migration
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jun Yang <[email protected]>
[ Upstream commit 52ffeaa358d1f3d91aa87a26ad90d77769cff74b ]
sctp_sock_migrate() transfers DATA chunk ownership but leaves retained control chunks pointing at the old socket. A later retransmission can therefore access the socket after it has been freed.
Extend the migration walk to cover retained control chunks and use sctp_control_set_owner_w() to assign their new owner. Reuse the DATA ownership check so each chunk is processed once per pass, even when it is reachable through multiple lists or retained pointers.
Preserve a control chunk's existing authentication key across migration so its final release can still generate SCTP_AUTH_FREE_KEY when needed.
--- include/net/sctp/sm.h | 1 + net/sctp/sm_make_chunk.c | 5 ++-- net/sctp/socket.c | 53 ++++++++++++++++++++++++++++++---------- 3 files changed, 44 insertions(+), 15 deletions(-)
include/net/sctp/sm.h +1 -0
@@ -253,6 +253,7 @@ struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc, struct sctp_fwdtsn_skip *skiplist);struct sctp_chunk *sctp_make_auth (const struct sctp_association *asoc,__u16 key_id); +void sctp_control_set_owner_w (struct sctp_chunk *chunk);struct sctp_chunk *sctp_make_strreset_req (const struct sctp_association *asoc,__u16 stream_num,__be16 *stream_list,bool out,bool in);
net/sctp/sm_make_chunk.c +3 -2
@@ -95,7 +95,7 @@ static void sctp_control_release_owner(struct sk_buff *skb) } } -static void sctp_control_set_owner_w (struct sctp_chunk *chunk) +void sctp_control_set_owner_w (struct sctp_chunk *chunk) {struct sctp_association *asoc = chunk->asoc;struct sk_buff *skb = chunk->skb;
@@ -108,7 +108,8 @@ static void sctp_control_set_owner_w(struct sctp_chunk *chunk)* For now don't do anything for now. */ if (chunk->auth) { - chunk->shkey = asoc->shkey; +if (!chunk->shkey) + chunk->shkey = asoc->shkey;sctp_auth_shkey_hold (chunk->shkey); } skb->sk = asoc ? asoc->base.sk :NULL ;
net/sctp/socket.c +40 -13
81 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 478/670 userfaultfd: fix UFFDIO_MOVE livelock on large folio with extra references
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang (Microsoft) <[email protected]>
[ Upstream commit 454143aeb4c6c85ca7d50df36d1a66a64d88283e ]
To move one page out of a large folio, move_pages_ptes() first has to split the folio. __folio_split() refuses if the folio has any reference beyond its page table mappings and the caller's own, and it reports the refusal as -EAGAIN. move_pages() treats returned -EAGAIN as a transient race and keeps retrying the same address, holding the VMA read locks the whole time. This is incorrect since in some cases userspace can hold such a reference indefinitely, such as by registering the page as an io_uring buffer.
An unprivileged user can trigger this with three threads: first holds such a reference on a page of a THP, second calls UFFDIO_MOVE on another page of the same THP and spins in the kernel forever holding the VMA read locks, and third calls fork() or mprotect(), which takes mmap_lock for writing and then waits forever for those read locks. From then on every mmap_lock user of that mm hangs, including other processes inspecting it through /proc/<pid>/, until the process is SIGKILLed. The hung task detector reports the blocked tasks (third one), and with kernel.hung_task_panic=1 the machine panics:
INFO: task wedge:95 blocked for more than 122 seconds. task:wedge state:D stack:12528 pid:95 tgid:95 ppid:94 Call Trace: __schedule+0x596/0x1110 schedule+0x36/0xf0 __vma_start_exclude_readers+0x100/0x170 __vma_start_write+0x51/0xd0 __split_vma+0x208/0x3d0 vma_modify+0x6a8/0x840 vma_modify_flags+0xce/0x110 mprotect_fixup+0xbe/0x480 do_mprotect_pkey+0x2d9/0x580 __x64_sys_mprotect+0x1a/0x30
Fix by returning -EBUSY instead of -EAGAIN in move_pages_ptes(), the caller of split_folio(), when the split fails. Thus, move_pages() does not retry -EBUSY and the ioctl drops its locks and returns to userspace instead of spinning.
--- mm/userfaultfd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
mm/userfaultfd.c +5 -1
@@ -1323,8 +1323,12 @@ static int move_pages_pte(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd,pte_unmap (dst_pte); src_pte = dst_pte =NULL ; err =split_folio (src_folio); -if (err) +if (err) { +/* do not retry, extra refs may be held forever */ +if (err == -EAGAIN ) + err = -EBUSY ; goto out; + }/* have to reacquire the folio after it got split */ folio_unlock (src_folio);folio_put (src_folio);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 479/670 bnxt_en: dont leave an XDP program installed when the open fails
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vaibhav Nagare <[email protected]>
[ Upstream commit 78731b46967e3e7102b5cd5062bef185f3404b5c ]
bnxt_xdp_set() stores the new program and drops the reference on the old one before reopening the NIC. If bnxt_open_nic() then fails, ndo_bpf() returns an error with the new program still in bp->xdp_prog. The caller treats the error as "nothing was installed" and drops its own reference, so bp->xdp_prog is left pointing at a freed program and the next XDP update dereferences it:
BUG: unable to handle page fault for address: ff78ecc80ddd1038 RIP: 0010:__bpf_prog_put+0x5/0x80 Call Trace: bnxt_xdp_set+0xad/0x1b0 [bnxt_en] dev_xdp_propagate+0x36/0xa0 bond_xdp_set+0xeb/0x2d0 [bonding] dev_xdp_install+0x1b1/0x350 bpf_xdp_link_update+0xc5/0x1b0 link_update+0x104/0x1e0 __sys_bpf+0x662/0xcf0
Seen on a 6.12 based kernel after bnxt_alloc_mem() failed an order-4 allocation on a fragmented host:
bnxt_en 0000:a0:00.1 ens4f1np1: nic open fail (rc: fffffff4)
bond1: (slave ens4f1np1): Error -12 calling ndo_bpf
Bonding is not required to hit this; a plain XDP attach on a bnxt interface takes the same path.
Restore the previous program when an attach or a replace fails, and recompute the page-mode and XDP TX ring configuration from it. The configuration matters because bnxt_init_one_rx_ring() only assigns rxr->xdp_prog in page mode, and __bnxt_set_rx_skb_mode() derives dev->max_mtu from the installed program. Release the old program only once the change has been committed.
A detach is not undone. dev_xdp_detach_link() clears the core's record of the program even when the driver returns an error, so putting the program back would leave the driver running a program the core has already dropped. If the reopen fails during a detach, bnxt_xdp_set() therefore returns 0 with the device closed; bnxt_open_nic() has already logged the failure.
Found in a crash dump; the change was not tested on hardware.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 54 ++++++++++++------- 1 file changed, 36 insertions(+), 18 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +36 -18
@@ -380,12 +380,34 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frames,return nxmit; } +static void bnxt_xdp_apply_cfg (struct bnxt *bp,int tx_xdp) +{ +struct net_device *dev = bp->dev; +int tc = bp->num_tc ? :1 ; +int tx_cp; + +if (bp->xdp_prog) { +bnxt_set_rx_skb_mode (bp, true); +xdp_features_set_redirect_target (dev, true); + }else { +xdp_features_clear_redirect_target (dev); +bnxt_set_rx_skb_mode (bp, false); + } + bp->tx_nr_rings_xdp = tx_xdp; + bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc + tx_xdp; + tx_cp =bnxt_num_tx_to_cp (bp, bp->tx_nr_rings); + bp->cp_nr_rings =max_t (int, tx_cp, bp->rx_nr_rings); +bnxt_set_tpa_flags (bp); +bnxt_set_ring_params (bp); +} +/* Under rtnl_lock */ static int bnxt_xdp_set (struct bnxt *bp,struct bpf_prog *prog) {struct net_device *dev = bp->dev; -int tx_xdp =0 , tx_cp, rc, tc; +int tx_xdp =0 , rc, tc;struct bpf_prog *old; +int old_tx_xdp;if (prog && !prog->aux->xdp_has_frags && bp->dev->mtu >BNXT_MAX_PAGE_MODE_MTU ) {
@@ -412,26 +434,22 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)if (netif_running (dev))bnxt_close_nic (bp, true, false); + old_tx_xdp = bp->tx_nr_rings_xdp; old =xchg (&bp->xdp_prog, prog); -if (old) -bpf_prog_put (old); - -if (prog) { -bnxt_set_rx_skb_mode (bp, true); -xdp_features_set_redirect_target (dev, true); - }else { -xdp_features_clear_redirect_target (dev); -bnxt_set_rx_skb_mode (bp, false); +bnxt_xdp_apply_cfg (bp, tx_xdp); + +if (netif_running (dev)) { + rc =bnxt_open_nic (bp, true, false); +/* a detach cannot be undone, only an attach */ +if (rc && prog) { +WRITE_ONCE (bp->xdp_prog, old); +bnxt_xdp_apply_cfg (bp, old_tx_xdp); +return rc; + } } - bp->tx_nr_rings_xdp = tx_xdp; - bp->tx_nr_rings = bp->tx_nr_rings_per_tc * tc + tx_xdp; - tx_cp =bnxt_num_tx_to_cp (bp, bp->tx_nr_rings); - bp->cp_nr_rings =max_t (int, tx_cp, bp->rx_nr_rings); -bnxt_set_tpa_flags (bp); -bnxt_set_ring_params (bp); -if (netif_running (dev)) -return bnxt_open_nic (bp, true, false); +if (old) +bpf_prog_put (old);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 480/670 fs/ntfs3: validate the EA value length in ntfs_read_ea()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuejie Shi <[email protected]>
[ Upstream commit 351817226fbf0031c4c63d1f5d7f15c3172312eb ]
ntfs_read_ea() checks the $EA list for consistency, but it only recomputes the packed size of an entry when the entry's own size field is zero:
for (off = 0; off < size; off += ea_size) {
const struct EA_FULL *ef = Add2Ptr(ea_p, off);
u32 bytes = size - off;
...
if (ef->size) {
ea_size = le32_to_cpu(ef->size);
if (ea_size > bytes)
goto out1;
continue; /* <- elength never checked */
}
...
ea_size = ALIGN(struct_size(ef, name,
1 + ef->name_len +
le16_to_cpu(ef->elength)),
4);
if (ea_size > bytes)
goto out1;
}ef->size is non-zero for every entry except the last one, and it is what ntfs3 itself writes (ntfs_set_ea() stores exactly that aligned packed size), so in practice elength is not validated at all. find_ea() then uses unpacked_ea_size(), which also prefers ea->size when it is set, so it agrees and hands the entry back.
ntfs_get_ea() copies elength bytes with no further bound of its own:
len = le16_to_cpu(ea->elength);
...
if (len > size) { /* size is the *caller's* buffer */
err = -ERANGE;
...
}
memcpy(buffer, ea->name + ea->name_len + 1, len);so a caller that supplies a large enough buffer receives up to 64 KiB of whatever follows the small $EA allocation -- straight to userspace via getxattr(2).
Compute the packed size unconditionally and require it to fit in the entry. Hoist the "bytes < offsetof(struct EA_FULL, name)" test above the ef->size branch as well: name_len and elength were being read there without it, which is itself a small over-read of the kmalloc'd buffer when fewer than 8 bytes are left. The old "bytes < sizeof(ef->size)" test is subsumed by it.
# mkntfs image; create /mnt/ntfs/poc with user.ntfs6 set, then rewrite
# that EA_FULL's elength from 0xf to 0xff00 on the raw device
mount -t ntfs3 -o ro /dev/vda /mnt/ntfs
getxattr("/mnt/ntfs/poc", "user.ntfs6", buf, 128 * 1024);BUG: KASAN: slab-out-of-bounds in ntfs_get_ea+0x294/0x3e0 Read of size 65280 at addr ffff0000cca53acf by task xattr_probe/142 __asan_memcpy+0x3c/0xa0 ntfs_get_ea+0x294/0x3e0 ntfs_getxattr+0x284/0x318 __vfs_getxattr+0x104/0x160 vfs_getxattr+0x1b4/0x1e0 do_getxattr+0xcc/0x230 path_getxattrat+0x184/0x270 __arm64_sys_getxattr+0x64/0x80 Allocated by task 142: __kmalloc_noprof+0x294/0x668 ntfs_read_ea+0x1e4/0x420 ntfs_get_ea+0x2c8/0x3e0 The buggy address belongs to the object at ffff0000cca53a80 which belongs to the cache kmalloc-96 of size 96
The object being over-read is the one ntfs_read_ea() just allocated, and it is 96 bytes.
Entries written by ntfs3 and by Windows set size to the aligned packed size, so the new test does not reject anything a working filesystem produces.
--- fs/ntfs3/xattr.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
fs/ntfs3/xattr.c +14 -11
@@ -146,29 +146,32 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,for (off =0 ; off < size; off += ea_size) {const struct EA_FULL *ef =Add2Ptr (ea_p, off);u32 bytes = size - off; -size_t need; - -/* Check if we can use field ea->size. */ -if (bytes <sizeof (ef->size)) - goto out1; +u32 packed_size;/* Check if we can use fields ef->name_len and ef->elength. */ if (bytes < offsetof(struct EA_FULL , name)) goto out1; -/* Size needed to hold this record's name and value. */ - need =struct_size (ef, name, -1 + ef->name_len +le16_to_cpu (ef->elength)); +/* +* The name and the value have to fit in the entry whether or +* not ef->size is set, because ntfs_get_ea() copies elength +* bytes out of this buffer and checks them only against the +* caller supplied buffer size. +*/ + packed_size = +ALIGN (struct_size (ef, name, +1 + ef->name_len + +le16_to_cpu (ef->elength)), +4 );if (ef->size) { ea_size =le32_to_cpu (ef->size); -/* ef->size must fit the list and cover the record. */ -if (ea_size > bytes || ea_size < need) +if (ea_size > bytes || packed_size > ea_size) goto out1;continue ; } - ea_size =ALIGN (need,4 ); + ea_size = packed_size;if (ea_size > bytes) goto out1; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 481/670 usb: xhci: Fix bounce buffer overflow
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Pecio <[email protected]>
[ Upstream commit 68c5cb7574c567e83ba95258cb146db95e069a87 ]
High-speed devices with out of spec 1024 byte bulk endpoints exist and are allowed by USB core, but xhci-hcd always sets packet size to 512. The exact nature of these devices isn't documented, commit fb5ee84ea72c ("USB: Accept bulk endpoints with 1024-byte maxpacket") only states that they "don't work with xHCI host controllers", whatever it means.
But somebody (or a malicious device) can try, and then the driver will allocate a 512 byte bounce buffer for this endpoint and may write up to 1024 bytes into it if particular scatter-gather URBs are used, because xhci_align_td() obtains packet size from the descriptor. Fix this.
As a side effect, TRBs will be aligned to the packet size chosen by the driver on all endpoints of all speeds. Alignment serves the xHC, not device, so this is fine. Only out of spec devices are affected anyway.
--- drivers/usb/host/xhci-ring.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/usb/host/xhci-ring.c +3 -6
@@ -3583,15 +3583,13 @@ static u32 xhci_td_remainder(struct xhci_hcd *xhci, int transferred,static int xhci_align_td (struct xhci_hcd *xhci,struct urb *urb,u32 enqd_len, -u32 *trb_buff_len,struct xhci_segment *seg) +u32 *trb_buff_len,struct xhci_segment *seg,u32 max_pkt) {struct device *dev =xhci_to_hcd (xhci)->self.sysdev;unsigned int unalign; -unsigned int max_pkt;u32 new_buff_len;size_t len; - max_pkt =usb_endpoint_maxp (&urb->ep->desc); unalign = (enqd_len + *trb_buff_len) % max_pkt;/* we got lucky, last normal TRB data on segment is packet aligned */
@@ -3736,9 +3734,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,if (enqd_len + trb_buff_len < full_len) { field |=TRB_CHAIN ;if (trb_is_link (ring->enqueue +1 )) { -if (xhci_align_td (xhci, urb, enqd_len, - &trb_buff_len, - ring->enq_seg)) { +if (xhci_align_td (xhci, urb, enqd_len, &trb_buff_len, + ring->enq_seg, ring->bounce_buf_len)) { send_addr = ring->enq_seg->bounce_dma;/* TD bounced at least, and last on this seg */ td->bounce_seg = ring->enq_seg;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 482/670 KVM: arm64: Validate the host vCPUs VM before reading it under pKVM
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit cf533b4d3630b229d78ad55567c5db2f365052a2 ]
On an MTE-capable host under pKVM, enter_exception64() reads the VM's MTE flag through vcpu->kvm, which for a host vCPU is a host-writable pointer nothing validates. The host can point it at any address in the hyp linear map and read back bit 1 of that word through PSR_TCO in the vCPU's CPSR, or panic the hypervisor with an unmapped one.
Get the VM through a get/put pair around the read: a loaded vCPU's is the hyp VM, an unloaded host vCPU's is read once and pinned, and a pointer the host never shared leaves TCO clear.
--- arch/arm64/kvm/hyp/exception.c | 5 ++- arch/arm64/kvm/hyp/include/hyp/adjust_pc.h | 28 +++++++++++++++ arch/arm64/kvm/hyp/include/nvhe/pkvm.h | 2 ++ arch/arm64/kvm/hyp/nvhe/pkvm.c | 42 ++++++++++++++++++++++ 4 files changed, 76 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/exception.c +4 -1
@@ -92,6 +92,7 @@ static void enter_exception64(struct kvm_vcpu *vcpu, unsigned long target_mode, enum exception_type type) {unsigned long sctlr, vbar, old, new, mode; +struct kvm *kvm;u64 exc_offset; mode = *vcpu_cpsr (vcpu) & (PSR_MODE_MASK |PSR_MODE32_BIT );
@@ -131,8 +132,10 @@ static void enter_exception64(struct kvm_vcpu *vcpu, unsigned long target_mode, new |= (old &PSR_C_BIT ); new |= (old &PSR_V_BIT ); -if (kvm_has_mte (kern_hyp_va (vcpu->kvm))) + kvm =vcpu_get_kvm (vcpu); +if (kvm &&kvm_has_mte (kvm)) new |=PSR_TCO_BIT ; +vcpu_put_kvm (vcpu, kvm); new |= (old &PSR_DIT_BIT );
arch/arm64/kvm/hyp/include/hyp/adjust_pc.h +28 -0
@@ -13,6 +13,34 @@#include <asm/kvm_emulate.h> #include <asm/kvm_host.h> +#ifdef __KVM_NVHE_HYPERVISOR__ +#include <nvhe/pkvm.h> + +/* Under pKVM a host vCPU's ->kvm is host-writable. */ +static inline struct kvm *vcpu_get_kvm (struct kvm_vcpu *vcpu) +{ +if (is_protected_kvm_enabled ()) +return pkvm_vcpu_get_kvm (vcpu); + +return kern_hyp_va (vcpu->kvm); +} + +static inline void vcpu_put_kvm (struct kvm_vcpu *vcpu,struct kvm *kvm) +{ +if (is_protected_kvm_enabled ()) +pkvm_vcpu_put_kvm (vcpu, kvm); +} +#else +static inline struct kvm *vcpu_get_kvm (struct kvm_vcpu *vcpu) +{ +return vcpu->kvm; +} + +static inline void vcpu_put_kvm (struct kvm_vcpu *vcpu,struct kvm *kvm) +{ +} +#endif +static inline void kvm_skip_instr (struct kvm_vcpu *vcpu) {if (vcpu_mode_is_32bit (vcpu)) {
arch/arm64/kvm/hyp/include/nvhe/pkvm.h +2 -0
@@ -69,5 +69,7 @@ int __pkvm_teardown_vm(pkvm_handle_t handle);struct pkvm_hyp_vcpu *pkvm_load_hyp_vcpu (pkvm_handle_t handle,unsigned int vcpu_idx);void pkvm_put_hyp_vcpu (struct pkvm_hyp_vcpu *hyp_vcpu); +struct kvm *pkvm_vcpu_get_kvm (struct kvm_vcpu *vcpu); +void pkvm_vcpu_put_kvm (struct kvm_vcpu *vcpu,struct kvm *kvm);#endif /* __ARM64_KVM_NVHE_PKVM_H__ */
arch/arm64/kvm/hyp/nvhe/pkvm.c +42 -0
48 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 483/670 ALSA: usb-audio: Bound packet copies by the PCM buffer size
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sinan Turunc <[email protected]>
[ Upstream commit 06be918062adc1a5a76dc346803b136b20bdb5ae ]
retire_capture_urb() and prepare_playback_urb() assume that one USB packet never carries more data than the whole ALSA ring buffer. Nothing enforces that: the packet size comes from the device (wMaxPacketSize, and curpacksize == maxpacksize when the class-specific endpoint descriptor sets MaxPacketsOnly), while the PCM hardware constraints only require 64-byte periods, two periods and a period time of one data interval. An 8 kHz mono U8 stream on a 128-byte buffer is legal, and a full-speed device can send 1023-byte packets into it.
On the first oversized packet hwptr_done is wrapped once and stays beyond buffer_bytes (895 for 1023 bytes into 128). On the next packet the wrap arithmetic in the copy path computes
bytes1 = subs->buffer_bytes - oldptr
with oldptr > buffer_bytes, so bytes1 wraps to about 4 GB and memcpy() runs off the end of the URB buffer and of the vmalloc'd DMA buffer:
BUG: KASAN: slab-out-of-bounds in retire_capture_urb+0x251/0x870 Read of size 4294966529 at addr ffff88800c1e2800 by task vhci_rx/82
and for playback, where copy_to_urb() has the same shape:
BUG: KASAN: vmalloc-out-of-bounds in copy_to_urb.isra.0+0x188/0x430 Read of size 4294966529 at addr ffffc9000004537f by task vhci_rx/79 prepare_playback_urb+0x98a/0x1fc0
Truncate an oversized capture packet to the buffer size, and stop filling a playback URB once it holds a whole buffer. With bytes <= buffer_bytes the single wrap of hwptr_done and the two-part memcpy() in both copy paths stay inside the buffer. A device whose packets do not fit the buffer at all was never going to play correctly anyway.
Reproduced on 7.3-rc7 with a USB/IP device (dummy_hcd cannot carry isochronous data) advertising a UAC1 endpoint with MaxPacketsOnly and wMaxPacketSize 1023, and a PCM client using period_size 64, periods 2.
--- sound/usb/pcm.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
sound/usb/pcm.c +19 -1
@@ -1292,6 +1292,18 @@ static void retire_capture_urb(struct snd_usb_substream *subs, bytes -= adj; subs->stream_offset_adj -= adj; } +/* +* A packet can be as large as the endpoint's maxpacksize, which +* the device chooses, while the ring buffer can be as small as +* two 64-byte periods. The hwptr_done wrap below handles one +* wrap only, so never take more than one buffer from a packet. +*/ +if (unlikely (bytes > subs->buffer_bytes)) { +dev_warn_ratelimited (&subs->dev->dev, +"%u-byte packet exceeds %u-byte buffer, truncating\n" , + bytes, subs->buffer_bytes); + bytes = subs->buffer_bytes; + } frames = bytes / stride;if (!subs->txfr_quirk) bytes = frames * stride;
@@ -1505,8 +1517,14 @@ static int prepare_playback_urb(struct snd_usb_substream *subs,for (i =0 ; i < ctx->packets; i++) { counts =snd_usb_endpoint_next_packet_size (ep, ctx, i, avail); +/* +* Bound by the ring buffer as well as by the URB: +* copy_to_urb() wraps hwptr_done once, so one URB must +* never carry more than the whole buffer. +*/ if (counts <0 || - (frames + counts) * stride > ctx->buffer_size) + (frames + counts) * stride > ctx->buffer_size || + (frames + counts) * stride > subs->buffer_bytes)break ;/* set up descriptor */ urb->iso_frame_desc[i].offset = frames * stride;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 484/670 mm/hugetlb: unmap the page where the other VMA maps it
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit ae99c503eb362b42cd5d24d80bc6cba669acc4c2 ]
If the owner of a MAP_PRIVATE hugetlb mapping fails to allocate a page for CoW, unmap_ref_private() unmaps the old page from all other private VMAs that have no reservation of their own. It finds them by the offset in the file, but then zaps each of them at the address of the faulting VMA. Nothing says that another VMA maps the offset at that address: a child can have moved its copy of the VMA with mremap(), and a second mapping of the file is wherever mmap() has put it.
So __unmap_hugepage_range() walks the page tables of the other mm at an address outside of iter_vma, where i_mmap_rwsem of this file protects nothing and where anything can be mapped, and the page stays mapped where it really is.
All of the following was seen on v7.3-rc6+ (g6c377d19d4a5) in KVM guests, as a user without any privilege. It takes a pool of 2 MiB pages with no free page that is not reserved, so that the allocation fails: the user can take or reserve what is free itself.
- The child moves its VMA away. The page is never unmapped, the mapcount stays 2, and the owner goes round retry_avoidcopy in hugetlb_wp() until the child is gone or a page becomes free. SIGKILL to the owner does not end it. 5 of 5 runs.
- The owner's mm has a second private mapping of the offset, made with MAP_NORESERVE. The owner zaps its own entry and reads zeroes where its data was. 5 of 5 runs.
- The child moves its VMA away and maps a 1 GiB hugetlb page at the old address, so this one takes a pool with a 1 GiB page as well. huge_pte_offset() for the 2 MiB size steps through the PUD leaf, so the "PMD table" is the 1 GiB page itself and its "page table lock" is folio->private of that page, which holds 2. Kernels with lock debugging oops in __unmap_hugepage_range(), 7 of 7 runs. Others spin on that word for ever with preemption disabled, 5 of 5 runs:
watchdog: BUG: soft lockup - CPU#0 stuck for 26s! [u_det3:130]
RIP: 0010:queued_spin_lock_slowpath+0x8a/0x290
RAX: 0000000000000002 RBX: ffffea0001000028
Call Trace:
__unmap_hugepage_range+0x154/0x6d0
unmap_hugepage_range+0xc1/0x140
hugetlb_wp+0x55c/0x700
hugetlb_fault+0x5f3/0x8f0RCU stalls follow, and killing all tasks of the user changes nothing. Four such owners, whose children share a single 1 GiB page, took down the whole guest with its four CPUs, 2 of 2 runs: one reported soft lockups on all four, the other gave no sign of life any more.
i_mmap_rwsem stays write locked. With a MAP_PRIVATE mapping of a hugetlbfs file that belongs to another user, and that the attacker can only read, the next mmap() of that file by its owner sleeps uninterruptibly in __mmap_region(), 4 of 4 runs.
Compute the address from the offset for each VMA. The tree walk returns only VMAs that cover pgoff, and vm_start, vm_end and vm_pgoff of a hugetlb VMA are aligned to the huge page size, as pgoff is, so the whole range lies inside iter_vma. Its page tables can not go away there, since the VMA is unlinked from the file under i_mmap_rwsem first.
With the right address the page is unmapped from all VMAs but the owner's, so the retry in hugetlb_wp() finds a mapcount of 1 and reuses the page.
A child that has moved its copy of the VMA now loses the page, and gets SIGBUS when it faults on a missing page of that VMA. That is what the comment above the function has always promised to those who do not own the reservation, and what already happens to a child that has left the VMA in place.
The address has been wrong from the start, and the second case needs only mmap() and fork(). mremap() of hugetlb VMAs, which the other cases use, came with commit 550a7d60bd5e ("mm, hugepages: add mremap() support for hugepage backed vma") in v5.16.
Original fix generated by an LLM and sent in private by Josef.
--- mm/hugetlb.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
mm/hugetlb.c +13 -3
@@ -5805,6 +5805,8 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,struct address_space *mapping;pgoff_t pgoff; +VM_WARN_ON_ONCE (!folio_test_anon (page_folio (page))); +/* * vm_pgoff is in PAGE_SIZE units, hence the different calculation * from page cache lookup which is in HPAGE_SIZE units.
@@ -5840,9 +5842,17 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,* could insert a zeroed page instead of the data existing * from the time of fork. This would look like data corruption */ -if (!is_vma_resv_set (iter_vma,HPAGE_RESV_OWNER )) -unmap_hugepage_range (iter_vma, address, - address +huge_page_size (h), page,0 ); +if (is_vma_resv_set (iter_vma,HPAGE_RESV_OWNER )) +continue ; + +/* +* The address in other VMAs can differ. Even though our old +* folio is anon, we always operate on the underlying hugetlb +* file. +*/ + address =vma_address (iter_vma, pgoff,1 ); +unmap_hugepage_range (iter_vma, address, + address +huge_page_size (h), page,0 ); }i_mmap_unlock_write (mapping); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 485/670 mm/userfaultfd: only allocate anon_vma in CoW mappings
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <[email protected]>
[ Upstream commit 514c9247db305922591d806ec65d3c3fe420538d ]
find_vma_and_prepare_anon() can end up allocating an anon_vma in VMAs that are not CoW mappings, which is wrong.
If we have a MAP_SHARED R/O file mapped, we lack VM_SHARED (but do have VM_MAYSHARE) and lack VM_MAYWRITE.
While uffd later rejects such mappings (uffd registration requires VM_MAYWRITE, see comment in validate_dst_vma) find_vma_and_prepare_anon() still wrongly allocates an anon vma before it validates the vma.
This in turn later confuses copy_page_range()->vma_needs_copy() such that we end up calling copy_hugetlb_page_range() with ranges that actually do not contain *any* per-pagetable information that would require copying, which is the basis for PMD-table sharing in the first place.
copy_hugetlb_page_range() should not have to worry about shared PMD tables at all: it doesn't make any sense to copy page tables that are shared, as they can be fully recreated later. Ending up in the function with shareable page tables is the real issue.
If a destination PMD table is shared in copy_hugetlb_page_range(), it might get concurrently unshared as we are not holding relevant locks, resulting in us using a page table that is no longer mapped and possibly freed after calling:
dst_pte = huge_pte_alloc(dst, dst_vma, addr, sz);
To fix it, do not allocate an anon_vma in non-CoW mappings and add a safety guard to copy_hugetlb_page_range(), making sure that we never end up messing with shared PMD tables in there.
Before commit 867a43a34ff8a ("userfaultfd: use per-vma locks in userfaultfd operations") we would always validate the VMA before allocating an anon_vma, and consequently never wrongly allocate an anon_vma.
As uffd_lock_vma() is part of the same lookup machinery and also contains a misleading VM_SHARED check, change that one as well directly for consistency.
A follow-up cleanup will stop taking the hugetlb_vma_lock_read(src_vma) lock in copy_hugetlb_page_range() entirely. Further, the usage of VM_SHARED in userfaultfd code should be cleaned up later to focus on CoW vs. non-CoW mappings.
--- mm/hugetlb.c | 24 ++++++++++++------------ mm/userfaultfd.c | 5 ++--- 2 files changed, 14 insertions(+), 15 deletions(-)
mm/hugetlb.c +12 -12
@@ -5305,10 +5305,11 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,raw_write_seqcount_begin (&src->write_protect_seq); }else {/* -* For shared mappings the vma lock must be held before -* calling hugetlb_walk() in the src vma. Otherwise, the -* returned ptep could go away if part of a shared pmd and -* another thread calls huge_pmd_unshare. +* Shared mappings only need copying when we could have +* information stored in page tables (e.g., userfaultfd PTE +* bits or markers), which is incompatible with PMD sharing. +* Still take the hugetlb VMA lock for now to satisfy +* hugetlb_walk()'s locking requirements. */ hugetlb_vma_lock_read (src_vma); }
@@ -5316,6 +5317,13 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, last_addr_mask =hugetlb_mask_last_page (h);for (addr = src_vma->vm_start; addr < src_vma->vm_end; addr += sz) {spinlock_t *src_ptl, *dst_ptl; + +if (WARN_ON_ONCE (want_pmd_share (src_vma, addr) || +want_pmd_share (dst_vma, addr))) { + ret = -EINVAL ; +break ; + } + src_pte =hugetlb_walk (src_vma, addr, sz);if (!src_pte) { addr |= last_addr_mask;
@@ -5327,14 +5335,6 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,break ; } -#ifdef CONFIG_HUGETLB_PMD_PAGE_TABLE_SHARING -/* If the pagetables are shared, there is nothing to do */ -if (ptdesc_pmd_is_shared (virt_to_ptdesc (dst_pte))) { - addr |= last_addr_mask; -continue ; - } -#endif - dst_ptl =huge_pte_lock (h, dst, dst_pte); src_ptl =huge_pte_lockptr (h, src, src_pte);spin_lock_nested (src_ptl,SINGLE_DEPTH_NESTING );
mm/userfaultfd.c +2 -3
@@ -48,8 +48,7 @@ struct vm_area_struct *find_vma_and_prepare_anon(struct mm_struct *mm, vma =vma_lookup (mm, addr);if (!vma) vma =ERR_PTR (-ENOENT ); -else if (!(vma->vm_flags &VM_SHARED ) && -unlikely (anon_vma_prepare (vma))) +else if (is_cow_mapping (vma->vm_flags) &&unlikely (anon_vma_prepare (vma))) vma =ERR_PTR (-ENOMEM );return vma;
@@ -77,7 +76,7 @@ static struct vm_area_struct *uffd_lock_vma(struct mm_struct *mm,* We know we're going to need to use anon_vma, so check * that early. */ -if (!(vma->vm_flags &VM_SHARED ) &&unlikely (!vma->anon_vma)) +if (is_cow_mapping (vma->vm_flags) &&unlikely (!vma->anon_vma))vma_end_read (vma);else return vma;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 486/670 ipmr: Call ipmr_fib_lookup() under RCU.
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 019c892e46544af0ae94ec833f79aa903c837666 ]
Yi Lai reported RCU splat in reg_vif_xmit() below. [0]
When CONFIG_IP_MROUTE_MULTIPLE_TABLES=n, ipmr_fib_lookup() uses rcu_dereference() without explicit rcu_read_lock().
Although rcu_read_lock_bh() is already held by the caller __dev_queue_xmit(), lockdep requires explicit rcu_read_lock() for rcu_dereference().
Let's move up rcu_read_lock() in reg_vif_xmit() to cover ipmr_fib_lookup().
[0]:
WARNING: suspicious RCU usage 7.1.0-rc2-next-20260504-9d0d467c3572 #1 Not tainted
-----------------------------net/ipv4/ipmr.c:329 suspicious rcu_dereference_check() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
2 locks held by syz.2.17/1779:
#0: ffffffff87896440 (rcu_read_lock_bh){....}-{1:3}, at: local_bh_disable include/linux/bottom_half.h:20 [inline] #0: ffffffff87896440 (rcu_read_lock_bh){....}-{1:3}, at: rcu_read_lock_bh include/linux/rcupdate.h:891 [inline] #0: ffffffff87896440 (rcu_read_lock_bh){....}-{1:3}, at: __dev_queue_xmit+0x239/0x4140 net/core/dev.c:4792 #1: ffff88801a199d18 (_xmit_PIMREG#2){+...}-{3:3}, at: spin_lock include/linux/spinlock.h:342 [inline] #1: ffff88801a199d18 (_xmit_PIMREG#2){+...}-{3:3}, at: __netif_tx_lock include/linux/netdevice.h:4795 [inline] #1: ffff88801a199d18 (_xmit_PIMREG#2){+...}-{3:3}, at: __dev_queue_xmit+0x1d5d/0x4140 net/core/dev.c:4865
stack backtrace: CPU: 1 UID: 0 PID: 1779 Comm: syz.2.17 Not tainted 7.1.0-rc2-next-20260504-9d0d467c3572 #1 PREEMPT(lazy) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x121/0x150 lib/dump_stack.c:120 dump_stack+0x19/0x20 lib/dump_stack.c:129 lockdep_rcu_suspicious+0x15b/0x1f0 kernel/locking/lockdep.c:6878 ipmr_fib_lookup net/ipv4/ipmr.c:329 [inline] reg_vif_xmit+0x2ee/0x3c0 net/ipv4/ipmr.c:540 __netdev_start_xmit include/linux/netdevice.h:5382 [inline] netdev_start_xmit include/linux/netdevice.h:5391 [inline] xmit_one net/core/dev.c:3889 [inline] dev_hard_start_xmit+0x170/0x700 net/core/dev.c:3905 __dev_queue_xmit+0x1df1/0x4140 net/core/dev.c:4871 dev_queue_xmit include/linux/netdevice.h:3423 [inline] packet_xmit+0x252/0x370 net/packet/af_packet.c:276 packet_snd net/packet/af_packet.c:3082 [inline] packet_sendmsg+0x39ad/0x5650 net/packet/af_packet.c:3114 sock_sendmsg_nosec net/socket.c:797 [inline] __sock_sendmsg net/socket.c:812 [inline] ____sys_sendmsg+0xa21/0xba0 net/socket.c:2716 ___sys_sendmsg+0x121/0x1c0 net/socket.c:2770 __sys_sendmsg+0x177/0x220 net/socket.c:2802 __do_sys_sendmsg net/socket.c:2807 [inline] __se_sys_sendmsg net/socket.c:2805 [inline] __x64_sys_sendmsg+0x80/0xc0 net/socket.c:2805 x64_sys_call+0x1d9c/0x21c0 arch/x86/include/generated/asm/syscalls_64.h:47 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xc1/0x1020 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7f37e563ee5d Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 93 af 1b 00 f7 d8 64 89 01 48 RSP: 002b:00007ffe5caa7fa8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00000000005c5fa0 RCX: 00007f37e563ee5d RDX: 0000000000000000 RSI: 00002000000012c0 RDI: 0000000000000004 RBP: 00000000005c5fa0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00000000005c5fac R15: 00000000005c5fa0 </TASK>
Stable-dep-of: aa1799e93f5e ("ipmr, ip6mr: validate packets injected into the register vif on xmit")
--- net/ipv4/ipmr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/ipmr.c +2 -1
@@ -513,15 +513,16 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, struct net_device *dev) };int err; +rcu_read_lock (); err =ipmr_fib_lookup (net, &fl4, &mrt);if (err <0 ) { +rcu_read_unlock ();kfree_skb (skb);return err; }DEV_STATS_ADD (dev, tx_bytes, skb->len);DEV_STATS_INC (dev, tx_packets); -rcu_read_lock ();/* Pairs with WRITE_ONCE() in vif_add() and vif_delete() */ ipmr_cache_report(mrt, skb, READ_ONCE(mrt->mroute_reg_vif_num),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 487/670 ipmr, ip6mr: validate packets injected into the register vif on xmit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit aa1799e93f5ebb973252aec649d84d12d9c7fd1c ]
reg_vif_xmit() passes the packet to ipmr_cache_report() which copies its IP header into the IGMPMSG_WHOLEPKT report that is queued to the mroute socket. Nothing guarantees that the packet contains a full IP header, so when a short packet is injected on the register device (e.g., using AF_PACKET), the copy reads past the end of the packet and a recvmsg() on the mroute socket leaks the uninitialized bytes to user space [1].
IPv6 has the same problem [2]. Its reg_vif_xmit() does call pskb_inet_may_pull(), but the helper keys off skb->protocol and does not pull anything when the protocol is neither IPv4 nor IPv6.
Fix by dropping packets whose protocol does not match the address family of the register device or that do not contain a full network header.
[1]
BUG: KMSAN: kernel-infoleak in _copy_to_iter raw_recvmsg
Uninit was stored to memory at:
ipmr_cache_report
reg_vif_xmit
packet_sendmsg
Uninit was created at:
__alloc_skb
sock_alloc_send_pskb
packet_sendmsg
Bytes 1-3 of 21 are uninitialized
[2]
BUG: KMSAN: kernel-infoleak in _copy_to_iter rawv6_recvmsg
Uninit was stored to memory at:
ip6mr_cache_report
reg_vif_xmit
packet_sendmsg
Uninit was created at:
__alloc_skb
sock_alloc_send_pskb
packet_sendmsg
Bytes 8-23 of 41 are uninitialized
--- net/ipv4/ipmr.c | 6 ++++++ net/ipv6/ip6mr.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)
net/ipv4/ipmr.c +6 -0
@@ -513,6 +513,12 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, struct net_device *dev) };int err; +if (skb->protocol !=htons (ETH_P_IP ) || !pskb_inet_may_pull (skb)) { +DEV_STATS_INC (dev, tx_errors); +kfree_skb (skb); +return NETDEV_TX_OK ; + } +rcu_read_lock (); err =ipmr_fib_lookup (net, &fl4, &mrt);if (err <0 ) {
net/ipv6/ip6mr.c +1 -1
@@ -616,7 +616,7 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, .flowi6_mark = skb->mark, }; -if (!pskb_inet_may_pull (skb)) +if (skb->protocol !=htons (ETH_P_IPV6 ) || !pskb_inet_may_pull (skb)) goto tx_err;if (ip6mr_fib_lookup (net, &fl6, &mrt) <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 488/670 ceph: fix longname buffer overflow in ceph_fname_to_usr()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiangshan Yi <[email protected]>
[ Upstream commit 71975d6e0db17646102488cf54480fda9de0f7a7 ]
Snapshot longname reconstruction formats "_<name>_<inode>" via snprintf() and memcpy()s the result into oname->name. Checking the length against NAME_MAX only protects the LOOKUPNAME/export callers, whose buffer is allocated with fscrypt_fname_alloc_buffer(NAME_MAX). The readdir path points oname->name straight at the altname in the MDS reply, whose capacity is altname_len; the reconstructed name can exceed that while still fitting under NAME_MAX, overflowing the in-place destination.
Save the actual oname->len before the decryption overwrites it, and fail with -ENAMETOOLONG when the reconstructed name would not fit.
--- fs/ceph/crypto.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/ceph/crypto.c +8 -0
@@ -389,6 +389,7 @@ int ceph_fname_to_usr(const struct ceph_fname *fname, struct fscrypt_str *tname,struct fscrypt_str iname;char *name = fname->name;int name_len = fname->name_len; +int dst_len;int ret;if (WARN_ON_ONCE (tname &&is_vmalloc_addr (tname->name)))
@@ -464,6 +465,9 @@ int ceph_fname_to_usr(const struct ceph_fname *fname, struct fscrypt_str *tname, iname.len = fname->ctext_len; } +/* oname->len is overwritten by the decryption below */ + dst_len = oname->len; + _oname.name =unlikely (is_vmalloc_addr (oname->name)) ? tname->name : oname->name; _oname.len = oname->len;
@@ -481,6 +485,10 @@ int ceph_fname_to_usr(const struct ceph_fname *fname, struct fscrypt_str *tname, name_len =snprintf (tmp_buf,sizeof (tmp_buf),"_%.*s_%ld" , oname->len, oname->name, dir->i_ino); +if (name_len > dst_len) { + ret = -ENAMETOOLONG ; + goto out; + }memcpy (oname->name, tmp_buf, name_len); oname->len = name_len; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 489/670 mm/page_vma_mapped: continue past nonmatching huge PMDs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit 1a2993227e8a27fc4cdea305bbdae82d290bc885 ]
A PTE-mapped large folio can straddle PMD boundaries after an unaligned mremap(). If the first part is discarded and replaced with an unrelated huge PMD, page_vma_mapped_walk() stops instead of looking for the rest of the folio in subsequent PMDs.
This also affects migration entries. A walk that stops at an unrelated huge PMD can leave migration PTEs behind when migration or an anonymous folio split restores the mappings. Those entries do not hold mapping references and can outlive the source folio.
This issue can lead to memory corruption and I have a reproducer for it.
Skip the current PMD rather than ending the walk on a flag or PFN mismatch. Do the same if the PMD became nonpresent before the locked recheck. Release the PMD lock, clear the per-PMD state and advance with step_forward(), so the existing range limit controls termination. This covers present, migration and device-private huge PMDs while preserving the matching-PMD and split-to-PTE paths.
--- mm/page_vma_mapped.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
mm/page_vma_mapped.c +16 -6
@@ -255,18 +255,18 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)if (!thp_migration_supported () || !(pvmw->flags &PVMW_MIGRATION )) -return not_found (pvmw); + goto next_pmd; entry =pmd_to_swp_entry (pmde);if (!is_migration_entry (entry) || !check_pmd (swp_offset_pfn (entry), pvmw)) -return not_found (pvmw); + goto next_pmd;return true; }if (likely (pmd_trans_huge (pmde) ||pmd_devmap (pmde))) {if (pvmw->flags &PVMW_MIGRATION ) -return not_found (pvmw); + goto next_pmd;if (!check_pmd (pmd_pfn (pmde), pvmw)) -return not_found (pvmw); + goto next_pmd;return true; }/* THP pmd was split under us: handle on pte level */
@@ -286,8 +286,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)spin_unlock (ptl); } -step_forward (pvmw,PMD_SIZE ); -continue ; + goto next_pmd; }if (!map_pte (pvmw, &ptl)) {if (!pvmw->pte)
@@ -320,6 +319,17 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)spin_lock (pvmw->ptl); } goto this_pte; +next_pmd: +/* +* A large folio can be PTE-mapped across PMDs, so a +* nonmatching PMD does not end the walk. +*/ +if (pvmw->ptl) { +spin_unlock (pvmw->ptl); + pvmw->ptl =NULL ; + } + pvmw->pmd =NULL ; +step_forward (pvmw,PMD_SIZE ); }while (pvmw->address < end);return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 490/670 mm/shmem: honour F_SEAL_EXEC when an ACL is set
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
[ Upstream commit 0237c47ca17005ea41b510c6116f0257dbf84eab ]
The owner of a memfd sealed with F_SEAL_EXEC can still change its execute bits by setting a POSIX access ACL. With CONFIG_TMPFS_POSIX_ACL, this lets an unprivileged owner make a non-executable memfd executable, bypassing vm.memfd_noexec=2.
simple_set_acl() updates i_mode directly, bypassing the seal check in shmem_setattr(). Add shmem_set_acl() to check the resulting mode. Share the F_SEAL_EXEC check with shmem_setattr() using memfd_check_seals_mode() in include/linux/memfd.h.
Fix generated by an LLM and sent by Chris Mason in private.
--- include/linux/memfd.h | 9 +++++++++ mm/shmem.c | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-)
include/linux/memfd.h +9 -0
@@ -2,8 +2,17 @@#ifndef __LINUX_MEMFD_H#define __LINUX_MEMFD_H +#include <linux/fcntl.h> #include <linux/file.h> +static inline int memfd_check_seals_mode (unsigned int seals,umode_t old_mode, +umode_t new_mode) +{ +if ((seals &F_SEAL_EXEC ) && ((old_mode ^ new_mode) &0111 )) +return -EPERM ; +return 0 ; +} +#ifdef CONFIG_MEMFD_CREATE extern long memfd_fcntl (struct file *file,unsigned int cmd,unsigned int arg);struct folio *memfd_alloc_folio (struct file *memfd,pgoff_t idx);
mm/shmem.c +30 -5
@@ -75,6 +75,7 @@ static struct vfsmount *shm_mnt __ro_after_init;#include <linux/magic.h> #include <linux/syscalls.h> #include <linux/fcntl.h> +#include <linux/memfd.h> #include <uapi/linux/memfd.h> #include <linux/rmap.h> #include <linux/uuid.h>
@@ -1255,10 +1256,11 @@ static int shmem_setattr(struct mnt_idmap *idmap,if (error)return error; -if ((info->seals &F_SEAL_EXEC ) && (attr->ia_valid &ATTR_MODE )) { -if ((inode->i_mode ^ attr->ia_mode) &0111 ) { -return -EPERM ; - } +if (attr->ia_valid &ATTR_MODE ) { + error =memfd_check_seals_mode (info->seals, inode->i_mode, + attr->ia_mode); +if (error) +return error; }if (S_ISREG (inode->i_mode) && (attr->ia_valid &ATTR_SIZE )) {
@@ -4939,12 +4941,35 @@ static const struct file_operations shmem_file_operations = {#endif }; +#ifdef CONFIG_TMPFS_POSIX_ACL +static int shmem_set_acl (struct mnt_idmap *idmap,struct dentry *dentry, +struct posix_acl *acl,int type) +{ +struct inode *inode =d_inode (dentry); +umode_t mode = inode->i_mode; +int error; + +if (type ==ACL_TYPE_ACCESS ) { + error =posix_acl_equiv_mode (acl, &mode); +if (error <0 ) +return error; + error =memfd_check_seals_mode (SHMEM_I (inode)->seals, + inode->i_mode, mode); +if (error) +return error; + } +return simple_set_acl (idmap, dentry, acl, type); +} +#else +#define shmem_set_acl simple_set_acl +#endif +static const struct inode_operations shmem_inode_operations = { .getattr = shmem_getattr, .setattr = shmem_setattr, #ifdef CONFIG_TMPFS_XATTR .listxattr = shmem_listxattr, - .set_acl = simple_set_acl, + .set_acl = shmem_set_acl, .fileattr_get = shmem_fileattr_get, .fileattr_set = shmem_fileattr_set, #endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 491/670 bitfield: Add FIELD_MODIFY() helper
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luo Jie <[email protected]>
[ Upstream commit a256ae22570ee4c3427fdc703a58a89afee6a332 ]
Add a helper for replacing the contents of bitfield in memory with the specified value.
Even though a helper xxx_replace_bits() is available, it is not well documented, and only reports errors at the run time, which will not be helpful to catch possible overflow errors due to incorrect parameter types used.
FIELD_MODIFY(REG_FIELD_C, ®, c) is the wrapper to the code below.
reg &= ~REG_FIELD_C; reg |= FIELD_PREP(REG_FIELD_C, c);
Yury: trim commit message, align backslashes.
Stable-dep-of: ea9854a169e9 ("spi: cadence-xspi: reject SDMA transfers larger than the requested length")
--- include/linux/bitfield.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
include/linux/bitfield.h +19 -2
@@ -8,6 +8,7 @@#define _LINUX_BITFIELD_H#include <linux/build_bug.h> +#include <linux/typecheck.h> #include <asm/byteorder.h> /*
@@ -38,8 +39,7 @@* FIELD_PREP(REG_FIELD_D, 0x40); * * Modify: -* reg &= ~REG_FIELD_C; -* reg |= FIELD_PREP(REG_FIELD_C, c); +* FIELD_MODIFY(REG_FIELD_C, ®, c); */ #define __bf_shf __builtin_ctzll
@@ -156,6 +156,23 @@ (typeof (_mask))(((_reg) & (_mask)) >>__bf_shf (_mask)); \ }) +/** +* FIELD_MODIFY() - modify a bitfield element +* @_mask: shifted mask defining the field's length and position +* @_reg_p: pointer to the memory that should be updated +* @_val: value to store in the bitfield +* +* FIELD_MODIFY() modifies the set of bits in @_reg_p specified by @_mask, +* by replacing them with the bitfield value passed in as @_val. +*/ +#define FIELD_MODIFY (_mask, _reg_p, _val) \ + ({ \ + typecheck_pointer(_reg_p); \ + __BF_FIELD_CHECK(_mask, *(_reg_p), _val, "FIELD_MODIFY: "); \ + *(_reg_p) &= ~(_mask); \ + *(_reg_p) |= (((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask)); \ + }) + extern void __compiletime_error("value doesn't fit into mask") __field_overflow(void); extern void __compiletime_error("bad bitfield mask")
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 492/670 spi: cadence-xspi: Replace ACPI specifics by agnostic APIs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit 6f9e4740e8591176eb90bb1dae95bbbb5c7d789e ]
Replace ACPI specific calls to get device property with the agnostic one. The code looses the direct dependency to the ACPI APIs and get cleaner. This doesn't change functionality.
While at it, drop now unneeded acpi.h.
Stable-dep-of: ea9854a169e9 ("spi: cadence-xspi: reject SDMA transfers larger than the requested length")
--- drivers/spi/spi-cadence-xspi.c | 36 +++++++++++----------------------- 1 file changed, 11 insertions(+), 25 deletions(-)
drivers/spi/spi-cadence-xspi.c +11 -25
@@ -2,7 +2,6 @@// Cadence XSPI flash controller driver // Copyright (C) 2020-21 Cadence -#include <linux/acpi.h> #include <linux/completion.h> #include <linux/delay.h> #include <linux/err.h>
@@ -21,6 +20,7 @@#include <linux/limits.h> #include <linux/log2.h> #include <linux/bitrev.h> +#include <linux/util_macros.h> #define CDNS_XSPI_MAGIC_NUM_VALUE 0x6522#define CDNS_XSPI_MAX_BANKS 8
@@ -775,19 +775,15 @@ static int marvell_xspi_mem_op_execute(struct spi_mem *mem,return ret; } -#ifdef CONFIG_ACPI static bool cdns_xspi_supports_op (struct spi_mem *mem,const struct spi_mem_op *op) {struct spi_device *spi = mem->spi; -const union acpi_object *obj; -struct acpi_device *adev; +struct device *dev = &spi->dev; +u32 value; - adev =ACPI_COMPANION (&spi->dev); - -if (!acpi_dev_get_property (adev,"spi-tx-bus-width" ,ACPI_TYPE_INTEGER , - &obj)) { -switch (obj->integer.value) { +if (!device_property_read_u32 (dev,"spi-tx-bus-width" , &value)) { +switch (value) {case 1 :break ;case 2 :
@@ -800,16 +796,13 @@ static bool cdns_xspi_supports_op(struct spi_mem *mem, spi->mode |=SPI_TX_OCTAL ;break ;default : -dev_warn (&spi->dev, -"spi-tx-bus-width %lld not supported\n" , - obj->integer.value); +dev_warn (dev,"spi-tx-bus-width %u not supported\n" , value);break ; } } -if (!acpi_dev_get_property (adev,"spi-rx-bus-width" ,ACPI_TYPE_INTEGER , - &obj)) { -switch (obj->integer.value) { +if (!device_property_read_u32 (dev,"spi-rx-bus-width" , &value)) { +switch (value) {case 1 :break ;case 2 :
@@ -822,9 +815,7 @@ static bool cdns_xspi_supports_op(struct spi_mem *mem, spi->mode |=SPI_RX_OCTAL ;break ;default : -dev_warn (&spi->dev, -"spi-rx-bus-width %lld not supported\n" , - obj->integer.value); +dev_warn (dev,"spi-rx-bus-width %u not supported\n" , value);break ; } }
@@ -834,7 +825,6 @@ static bool cdns_xspi_supports_op(struct spi_mem *mem,return true; } -#endif static int cdns_xspi_adjust_mem_op_size (struct spi_mem *mem,struct spi_mem_op *op) {
@@ -847,17 +837,13 @@ static int cdns_xspi_adjust_mem_op_size(struct spi_mem *mem, struct spi_mem_op * }static const struct spi_controller_mem_ops cadence_xspi_mem_ops = { -#ifdef CONFIG_ACPI - .supports_op = cdns_xspi_supports_op, -#endif + .supports_op =PTR_IF (IS_ENABLED (CONFIG_ACPI ), cdns_xspi_supports_op), .exec_op = cdns_xspi_mem_op_execute, .adjust_op_size = cdns_xspi_adjust_mem_op_size, };static const struct spi_controller_mem_ops marvell_xspi_mem_ops = { -#ifdef CONFIG_ACPI - .supports_op = cdns_xspi_supports_op, -#endif + .supports_op =PTR_IF (IS_ENABLED (CONFIG_ACPI ), cdns_xspi_supports_op), .exec_op = marvell_xspi_mem_op_execute, .adjust_op_size = cdns_xspi_adjust_mem_op_size, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 493/670 spi: cadence-xspi: Use FIELD_MODIFY()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Zhang <[email protected]>
[ Upstream commit 6fa473f4c5dcc20db9799f90da48b977730e05f1 ]
Use FIELD_MODIFY() to remove open-coded bit manipulation. No functional change intended.
Stable-dep-of: ea9854a169e9 ("spi: cadence-xspi: reject SDMA transfers larger than the requested length")
--- drivers/spi/spi-cadence-xspi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/spi/spi-cadence-xspi.c +1 -2
@@ -453,8 +453,7 @@ static bool cdns_mrvl_xspi_setup_clock(struct cdns_xspi_dev *cdns_xspi,writel (clk_reg, cdns_xspi->auxbase +MRVL_XSPI_CLK_CTRL_AUX_REG ); clk_reg =FIELD_PREP (MRVL_XSPI_CLK_DIV , i); - clk_reg &= ~MRVL_XSPI_CLK_DIV ; - clk_reg |=FIELD_PREP (MRVL_XSPI_CLK_DIV , i); +FIELD_MODIFY (MRVL_XSPI_CLK_DIV , &clk_reg, i); clk_reg |=MRVL_XSPI_CLK_ENABLE ; clk_reg |=MRVL_XSPI_IRQ_ENABLE ; update_clk = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 494/670 spi: cadence-xspi: group marvell support code together
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jisheng Zhang <[email protected]>
[ Upstream commit 94d031d26168560e951f8c88cbfb7aa53a57092a ]
We will remove the 64BIT dependency from cadence-xspi for non marvell platform soon. No functionality change.
Stable-dep-of: ea9854a169e9 ("spi: cadence-xspi: reject SDMA transfers larger than the requested length")
--- drivers/spi/spi-cadence-xspi.c | 455 ++++++++++++++++----------------- 1 file changed, 227 insertions(+), 228 deletions(-)
drivers/spi/spi-cadence-xspi.c +227 -228
@@ -316,39 +316,10 @@ struct cdns_xspi_driver_data {u32 rfile_phy_dll_slave_ctrl; }; -static struct cdns_xspi_driver_data marvell_driver_data = { - .mrvl_hw_overlay = true, - .dll_phy_ctrl =MARVELL_REGS_DLL_PHY_CTRL , - .ctb_rfile_phy_ctrl =MARVELL_CTB_RFILE_PHY_CTRL , - .rfile_phy_tsel =MARVELL_RFILE_PHY_TSEL , - .rfile_phy_dq_timing =MARVELL_RFILE_PHY_DQ_TIMING , - .rfile_phy_dqs_timing =MARVELL_RFILE_PHY_DQS_TIMING , - .rfile_phy_gate_lpbk_ctrl =MARVELL_RFILE_PHY_GATE_LPBK_CTRL , - .rfile_phy_dll_master_ctrl =MARVELL_RFILE_PHY_DLL_MASTER_CTRL , - .rfile_phy_dll_slave_ctrl =MARVELL_RFILE_PHY_DLL_SLAVE_CTRL , -}; -static struct cdns_xspi_driver_data cdns_driver_data = { .mrvl_hw_overlay = false, }; -static const int cdns_mrvl_xspi_clk_div_list[] = { -4 ,//0x0 = Divide by 4. SPI clock is 200 MHz. -6 ,//0x1 = Divide by 6. SPI clock is 133.33 MHz. -8 ,//0x2 = Divide by 8. SPI clock is 100 MHz. -10 ,//0x3 = Divide by 10. SPI clock is 80 MHz. -12 ,//0x4 = Divide by 12. SPI clock is 66.666 MHz. -16 ,//0x5 = Divide by 16. SPI clock is 50 MHz. -18 ,//0x6 = Divide by 18. SPI clock is 44.44 MHz. -20 ,//0x7 = Divide by 20. SPI clock is 40 MHz. -24 ,//0x8 = Divide by 24. SPI clock is 33.33 MHz. -32 ,//0x9 = Divide by 32. SPI clock is 25 MHz. -40 ,//0xA = Divide by 40. SPI clock is 20 MHz. -50 ,//0xB = Divide by 50. SPI clock is 16 MHz. -64 ,//0xC = Divide by 64. SPI clock is 12.5 MHz. -128 //0xD = Divide by 128. SPI clock is 6.25 MHz. -}; -struct cdns_xspi_dev {struct platform_device *pdev;struct device *dev;
@@ -380,92 +351,6 @@ struct cdns_xspi_dev {int current_xfer_qword; }; -static void cdns_xspi_reset_dll (struct cdns_xspi_dev *cdns_xspi) -{ -u32 dll_cntrl =readl (cdns_xspi->iobase + -CDNS_XSPI_RF_MINICTRL_REGS_DLL_PHY_CTRL ); - -/* Reset DLL */ - dll_cntrl |=CDNS_XSPI_DLL_RST_N ; -writel (dll_cntrl, cdns_xspi->iobase + -CDNS_XSPI_RF_MINICTRL_REGS_DLL_PHY_CTRL ); -} - -static bool cdns_xspi_is_dll_locked (struct cdns_xspi_dev *cdns_xspi) -{ -u32 dll_lock; - -return !readl_relaxed_poll_timeout (cdns_xspi->iobase + -CDNS_XSPI_INTR_STATUS_REG , - dll_lock, ((dll_lock &CDNS_XSPI_DLL_LOCK ) ==1 ),10 ,10000 ); -} - -/* Static configuration of PHY */ -static bool cdns_xspi_configure_phy (struct cdns_xspi_dev *cdns_xspi) -{ -writel (cdns_xspi->driver_data->dll_phy_ctrl, - cdns_xspi->iobase +CDNS_XSPI_RF_MINICTRL_REGS_DLL_PHY_CTRL ); -writel (cdns_xspi->driver_data->ctb_rfile_phy_ctrl, - cdns_xspi->auxbase +CDNS_XSPI_PHY_CTB_RFILE_PHY_CTRL ); -writel (cdns_xspi->driver_data->rfile_phy_tsel, - cdns_xspi->auxbase +CDNS_XSPI_PHY_CTB_RFILE_PHY_TSEL ); -writel (cdns_xspi->driver_data->rfile_phy_dq_timing, - cdns_xspi->auxbase +CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_DQ_TIMING ); -writel (cdns_xspi->driver_data->rfile_phy_dqs_timing, - cdns_xspi->auxbase +CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_DQS_TIMING ); -writel (cdns_xspi->driver_data->rfile_phy_gate_lpbk_ctrl, - cdns_xspi->auxbase +CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_GATE_LPBK_CTRL ); -writel (cdns_xspi->driver_data->rfile_phy_dll_master_ctrl, - cdns_xspi->auxbase +CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_DLL_MASTER_CTRL ); -writel (cdns_xspi->driver_data->rfile_phy_dll_slave_ctrl, - cdns_xspi->auxbase +CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_DLL_SLAVE_CTRL ); - -cdns_xspi_reset_dll (cdns_xspi); - -return cdns_xspi_is_dll_locked (cdns_xspi); -} - -static bool cdns_mrvl_xspi_setup_clock (struct cdns_xspi_dev *cdns_xspi, -int requested_clk) -{ -int i =0 ; -int clk_val; -u32 clk_reg; -bool update_clk = false; - -while (i < (ARRAY_SIZE (cdns_mrvl_xspi_clk_div_list) -1 )) { - clk_val =MRVL_XSPI_CLOCK_DIVIDED ( - cdns_mrvl_xspi_clk_div_list[i]); -if (clk_val <= requested_clk) -break ; - i++; - } - -dev_dbg (cdns_xspi->dev,"Found clk div: %d, clk val: %d\n" , - cdns_mrvl_xspi_clk_div_list[i], -MRVL_XSPI_CLOCK_DIVIDED ( - cdns_mrvl_xspi_clk_div_list[i])); - - clk_reg =readl (cdns_xspi->auxbase +MRVL_XSPI_CLK_CTRL_AUX_REG ); - -if (FIELD_GET (MRVL_XSPI_CLK_DIV , clk_reg) != i) { - clk_reg &= ~MRVL_XSPI_CLK_ENABLE ; -writel (clk_reg, - cdns_xspi->auxbase +MRVL_XSPI_CLK_CTRL_AUX_REG ); - clk_reg =FIELD_PREP (MRVL_XSPI_CLK_DIV , i); -FIELD_MODIFY (MRVL_XSPI_CLK_DIV , &clk_reg, i); - clk_reg |=MRVL_XSPI_CLK_ENABLE ; - clk_reg |=MRVL_XSPI_IRQ_ENABLE ; - update_clk = true; - } - -if (update_clk) -writel (clk_reg, - cdns_xspi->auxbase +MRVL_XSPI_CLK_CTRL_AUX_REG ); - -return update_clk; -} -static int cdns_xspi_wait_for_controller_idle (struct cdns_xspi_dev *cdns_xspi) {u32 ctrl_stat;
@@ -538,23 +423,6 @@ static void cdns_xspi_set_interrupts(struct cdns_xspi_dev *cdns_xspi,writel (intr_enable, cdns_xspi->iobase +CDNS_XSPI_INTR_ENABLE_REG ); } -static void marvell_xspi_set_interrupts (struct cdns_xspi_dev *cdns_xspi, -bool enabled) -{ -u32 intr_enable; -u32 irq_status; - - irq_status =readl (cdns_xspi->iobase +CDNS_XSPI_INTR_STATUS_REG ); -writel (irq_status, cdns_xspi->iobase +CDNS_XSPI_INTR_STATUS_REG ); - - intr_enable =readl (cdns_xspi->iobase +CDNS_XSPI_INTR_ENABLE_REG ); -if (enabled) - intr_enable |=CDNS_XSPI_INTR_MASK ; -else - intr_enable &= ~CDNS_XSPI_INTR_MASK ; -writel (intr_enable, cdns_xspi->iobase +CDNS_XSPI_INTR_ENABLE_REG ); -} -static int cdns_xspi_controller_init (struct cdns_xspi_dev *cdns_xspi) {u32 ctrl_ver;
@@ -599,78 +467,6 @@ static void cdns_xspi_sdma_handle(struct cdns_xspi_dev *cdns_xspi) } } -static void m_ioreadq (void __iomem *addr,void *buf,int len) -{ -if (IS_ALIGNED ((long )buf,8 ) && len >=8 ) { -u64 full_ops = len /8 ; -u64 *buffer = buf; - - len -= full_ops *8 ; - buf += full_ops *8 ; - -do { -u64 b =readq (addr); - *buffer++ = b; - }while (--full_ops); - } - - -while (len) { -u64 tmp_buf; - - tmp_buf =readq (addr); -memcpy (buf, &tmp_buf,min (len,8 )); - len = len >8 ? len -8 :0 ; - buf +=8 ; - } -} - -static void m_iowriteq (void __iomem *addr,const void *buf,int len) -{ -if (IS_ALIGNED ((long )buf,8 ) && len >=8 ) { -u64 full_ops = len /8 ; -const u64 *buffer = buf; - - len -= full_ops *8 ; - buf += full_ops *8 ; - -do { -writeq (*buffer++, addr); - }while (--full_ops); - } - -while (len) { -u64 tmp_buf; - -memcpy (&tmp_buf, buf,min (len,8 )); -writeq (tmp_buf, addr); - len = len >8 ? len -8 :0 ; - buf +=8 ; - } -} - -static void marvell_xspi_sdma_handle (struct cdns_xspi_dev *cdns_xspi) -{ -u32 sdma_size, sdma_trd_info; -u8 sdma_dir; - - sdma_size =readl (cdns_xspi->iobase +CDNS_XSPI_SDMA_SIZE_REG ); - sdma_trd_info =readl (cdns_xspi->iobase +CDNS_XSPI_SDMA_TRD_INFO_REG ); - sdma_dir =FIELD_GET (CDNS_XSPI_SDMA_DIR , sdma_trd_info); - -switch (sdma_dir) { -case CDNS_XSPI_SDMA_DIR_READ : -m_ioreadq (cdns_xspi->sdmabase, - cdns_xspi->in_buffer, sdma_size); -break ; - -case CDNS_XSPI_SDMA_DIR_WRITE : -m_iowriteq (cdns_xspi->sdmabase, - cdns_xspi->out_buffer, sdma_size); -break ; - } -} -static int cdns_xspi_send_stig_command (struct cdns_xspi_dev *cdns_xspi,const struct spi_mem_op *op,bool data_phase)
@@ -760,20 +556,6 @@ static int cdns_xspi_mem_op_execute(struct spi_mem *mem,return ret; } -static int marvell_xspi_mem_op_execute (struct spi_mem *mem, -const struct spi_mem_op *op) -{ -struct cdns_xspi_dev *cdns_xspi = -spi_controller_get_devdata (mem->spi->controller); -int ret =0 ; - -cdns_mrvl_xspi_setup_clock (cdns_xspi, mem->spi->max_speed_hz); - - ret =cdns_xspi_mem_op (cdns_xspi, mem, op); - -return ret; -} -static bool cdns_xspi_supports_op (struct spi_mem *mem,const struct spi_mem_op *op) {
@@ -841,12 +623,6 @@ static const struct spi_controller_mem_ops cadence_xspi_mem_ops = { .adjust_op_size = cdns_xspi_adjust_mem_op_size, }; -static const struct spi_controller_mem_ops marvell_xspi_mem_ops = { - .supports_op =PTR_IF (IS_ENABLED (CONFIG_ACPI ), cdns_xspi_supports_op), - .exec_op = marvell_xspi_mem_op_execute, - .adjust_op_size = cdns_xspi_adjust_mem_op_size, -}; -static irqreturn_t cdns_xspi_irq_handler (int this_irq,void *dev) {struct cdns_xspi_dev *cdns_xspi = dev;
@@ -928,6 +704,230 @@ static void cdns_xspi_print_phy_config(struct cdns_xspi_dev *cdns_xspi) readl(cdns_xspi->auxbase + CDNS_XSPI_CCP_PHY_DLL_SLAVE_CTRL)); } +static struct cdns_xspi_driver_data marvell_driver_data = { + .mrvl_hw_overlay = true, + .dll_phy_ctrl =MARVELL_REGS_DLL_PHY_CTRL , + .ctb_rfile_phy_ctrl =MARVELL_CTB_RFILE_PHY_CTRL , + .rfile_phy_tsel =MARVELL_RFILE_PHY_TSEL , + .rfile_phy_dq_timing =MARVELL_RFILE_PHY_DQ_TIMING , + .rfile_phy_dqs_timing =MARVELL_RFILE_PHY_DQS_TIMING , + .rfile_phy_gate_lpbk_ctrl =MARVELL_RFILE_PHY_GATE_LPBK_CTRL , + .rfile_phy_dll_master_ctrl =MARVELL_RFILE_PHY_DLL_MASTER_CTRL , + .rfile_phy_dll_slave_ctrl =MARVELL_RFILE_PHY_DLL_SLAVE_CTRL , +}; + +static const int cdns_mrvl_xspi_clk_div_list[] = { +4 ,//0x0 = Divide by 4. SPI clock is 200 MHz. +6 ,//0x1 = Divide by 6. SPI clock is 133.33 MHz. +8 ,//0x2 = Divide by 8. SPI clock is 100 MHz. +10 ,//0x3 = Divide by 10. SPI clock is 80 MHz. +12 ,//0x4 = Divide by 12. SPI clock is 66.666 MHz. +16 ,//0x5 = Divide by 16. SPI clock is 50 MHz. +18 ,//0x6 = Divide by 18. SPI clock is 44.44 MHz. +20 ,//0x7 = Divide by 20. SPI clock is 40 MHz. +24 ,//0x8 = Divide by 24. SPI clock is 33.33 MHz. +32 ,//0x9 = Divide by 32. SPI clock is 25 MHz. +40 ,//0xA = Divide by 40. SPI clock is 20 MHz. +50 ,//0xB = Divide by 50. SPI clock is 16 MHz. +64 ,//0xC = Divide by 64. SPI clock is 12.5 MHz. +128 //0xD = Divide by 128. SPI clock is 6.25 MHz. +}; + +static void cdns_xspi_reset_dll (struct cdns_xspi_dev *cdns_xspi) +{ +u32 dll_cntrl =readl (cdns_xspi->iobase + +CDNS_XSPI_RF_MINICTRL_REGS_DLL_PHY_CTRL ); + +/* Reset DLL */ + dll_cntrl |=CDNS_XSPI_DLL_RST_N ; +writel (dll_cntrl, cdns_xspi->iobase + +CDNS_XSPI_RF_MINICTRL_REGS_DLL_PHY_CTRL ); +} + +static bool cdns_xspi_is_dll_locked (struct cdns_xspi_dev *cdns_xspi) +{ +u32 dll_lock; + +return !readl_relaxed_poll_timeout (cdns_xspi->iobase + +CDNS_XSPI_INTR_STATUS_REG , + dll_lock, ((dll_lock &CDNS_XSPI_DLL_LOCK ) ==1 ),10 ,10000 ); +} + +/* Static configuration of PHY */ +static bool cdns_xspi_configure_phy (struct cdns_xspi_dev *cdns_xspi) +{ +writel (cdns_xspi->driver_data->dll_phy_ctrl, + cdns_xspi->iobase +CDNS_XSPI_RF_MINICTRL_REGS_DLL_PHY_CTRL ); +writel (cdns_xspi->driver_data->ctb_rfile_phy_ctrl, + cdns_xspi->auxbase +CDNS_XSPI_PHY_CTB_RFILE_PHY_CTRL ); +writel (cdns_xspi->driver_data->rfile_phy_tsel, + cdns_xspi->auxbase +CDNS_XSPI_PHY_CTB_RFILE_PHY_TSEL ); +writel (cdns_xspi->driver_data->rfile_phy_dq_timing, + cdns_xspi->auxbase +CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_DQ_TIMING ); +writel (cdns_xspi->driver_data->rfile_phy_dqs_timing, + cdns_xspi->auxbase +CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_DQS_TIMING ); +writel (cdns_xspi->driver_data->rfile_phy_gate_lpbk_ctrl, + cdns_xspi->auxbase +CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_GATE_LPBK_CTRL ); +writel (cdns_xspi->driver_data->rfile_phy_dll_master_ctrl, + cdns_xspi->auxbase +CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_DLL_MASTER_CTRL ); +writel (cdns_xspi->driver_data->rfile_phy_dll_slave_ctrl, + cdns_xspi->auxbase +CDNS_XSPI_PHY_DATASLICE_RFILE_PHY_DLL_SLAVE_CTRL ); + +cdns_xspi_reset_dll (cdns_xspi); + +return cdns_xspi_is_dll_locked (cdns_xspi); +} + +static bool cdns_mrvl_xspi_setup_clock (struct cdns_xspi_dev *cdns_xspi, +int requested_clk) +{ +int i =0 ; +int clk_val; +u32 clk_reg; +bool update_clk = false; + +while (i < (ARRAY_SIZE (cdns_mrvl_xspi_clk_div_list) -1 )) { + clk_val =MRVL_XSPI_CLOCK_DIVIDED ( + cdns_mrvl_xspi_clk_div_list[i]); +if (clk_val <= requested_clk) +break ; + i++; + } + +dev_dbg (cdns_xspi->dev,"Found clk div: %d, clk val: %d\n" , + cdns_mrvl_xspi_clk_div_list[i], +MRVL_XSPI_CLOCK_DIVIDED ( + cdns_mrvl_xspi_clk_div_list[i])); + + clk_reg =readl (cdns_xspi->auxbase +MRVL_XSPI_CLK_CTRL_AUX_REG ); + +if (FIELD_GET (MRVL_XSPI_CLK_DIV , clk_reg) != i) { + clk_reg &= ~MRVL_XSPI_CLK_ENABLE ; +writel (clk_reg, + cdns_xspi->auxbase +MRVL_XSPI_CLK_CTRL_AUX_REG ); + clk_reg =FIELD_PREP (MRVL_XSPI_CLK_DIV , i); +FIELD_MODIFY (MRVL_XSPI_CLK_DIV , &clk_reg, i); + clk_reg |=MRVL_XSPI_CLK_ENABLE ; + clk_reg |=MRVL_XSPI_IRQ_ENABLE ; + update_clk = true; + } + +if (update_clk) +writel (clk_reg, + cdns_xspi->auxbase +MRVL_XSPI_CLK_CTRL_AUX_REG ); + +return update_clk; +} + +static void marvell_xspi_set_interrupts (struct cdns_xspi_dev *cdns_xspi, +bool enabled) +{ +u32 intr_enable; +u32 irq_status; + + irq_status =readl (cdns_xspi->iobase +CDNS_XSPI_INTR_STATUS_REG ); +writel (irq_status, cdns_xspi->iobase +CDNS_XSPI_INTR_STATUS_REG ); + + intr_enable =readl (cdns_xspi->iobase +CDNS_XSPI_INTR_ENABLE_REG ); +if (enabled) + intr_enable |=CDNS_XSPI_INTR_MASK ; +else + intr_enable &= ~CDNS_XSPI_INTR_MASK ; +writel (intr_enable, cdns_xspi->iobase +CDNS_XSPI_INTR_ENABLE_REG ); +} + +static int marvell_xspi_mem_op_execute (struct spi_mem *mem, +const struct spi_mem_op *op) +{ +struct cdns_xspi_dev *cdns_xspi = +spi_controller_get_devdata (mem->spi->controller); +int ret =0 ; + +cdns_mrvl_xspi_setup_clock (cdns_xspi, mem->spi->max_speed_hz); + + ret =cdns_xspi_mem_op (cdns_xspi, mem, op); + +return ret; +} + +static void m_ioreadq (void __iomem *addr,void *buf,int len) +{ +if (IS_ALIGNED ((long )buf,8 ) && len >=8 ) { +u64 full_ops = len /8 ; +u64 *buffer = buf; + + len -= full_ops *8 ; + buf += full_ops *8 ; + +do { +u64 b =readq (addr); + *buffer++ = b; + }while (--full_ops); + } + + +while (len) { +u64 tmp_buf; + + tmp_buf =readq (addr); +memcpy (buf, &tmp_buf,min (len,8 )); + len = len >8 ? len -8 :0 ; + buf +=8 ; + } +} + +static void m_iowriteq (void __iomem *addr,const void *buf,int len) +{ +if (IS_ALIGNED ((long )buf,8 ) && len >=8 ) { +u64 full_ops = len /8 ; +const u64 *buffer = buf; + + len -= full_ops *8 ; + buf += full_ops *8 ; + +do { +writeq (*buffer++, addr); + }while (--full_ops); + } + +while (len) { +u64 tmp_buf; + +memcpy (&tmp_buf, buf,min (len,8 )); +writeq (tmp_buf, addr); + len = len >8 ? len -8 :0 ; + buf +=8 ; + } +} + +static void marvell_xspi_sdma_handle (struct cdns_xspi_dev *cdns_xspi) +{ +u32 sdma_size, sdma_trd_info; +u8 sdma_dir; + + sdma_size =readl (cdns_xspi->iobase +CDNS_XSPI_SDMA_SIZE_REG ); + sdma_trd_info =readl (cdns_xspi->iobase +CDNS_XSPI_SDMA_TRD_INFO_REG ); + sdma_dir =FIELD_GET (CDNS_XSPI_SDMA_DIR , sdma_trd_info); + +switch (sdma_dir) { +case CDNS_XSPI_SDMA_DIR_READ : +m_ioreadq (cdns_xspi->sdmabase, + cdns_xspi->in_buffer, sdma_size); +break ; + +case CDNS_XSPI_SDMA_DIR_WRITE : +m_iowriteq (cdns_xspi->sdmabase, + cdns_xspi->out_buffer, sdma_size); +break ; + } +} + +static const struct spi_controller_mem_ops marvell_xspi_mem_ops = { + .supports_op =PTR_IF (IS_ENABLED (CONFIG_ACPI ), cdns_xspi_supports_op), + .exec_op = marvell_xspi_mem_op_execute, + .adjust_op_size = cdns_xspi_adjust_mem_op_size, +}; +static int cdns_xspi_prepare_generic (int cs,const void *dout,int len,int glue,u32 *cmd_regs) {u8 *data = (u8 *)dout;
@@ -1155,15 +1155,14 @@ static int cdns_xspi_probe(struct platform_device *pdev)return -ENODEV ; } + host->mem_ops = &cadence_xspi_mem_ops; + cdns_xspi->sdma_handler = &cdns_xspi_sdma_handle; + cdns_xspi->set_interrupts_handler = &cdns_xspi_set_interrupts;if (cdns_xspi->driver_data->mrvl_hw_overlay) { host->mem_ops = &marvell_xspi_mem_ops; host->transfer_one_message = cdns_xspi_transfer_one_message_b0; cdns_xspi->sdma_handler = &marvell_xspi_sdma_handle; cdns_xspi->set_interrupts_handler = &marvell_xspi_set_interrupts; - }else { - host->mem_ops = &cadence_xspi_mem_ops; - cdns_xspi->sdma_handler = &cdns_xspi_sdma_handle; - cdns_xspi->set_interrupts_handler = &cdns_xspi_set_interrupts; } host->dev.of_node = pdev->dev.of_node; host->bus_num =-1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 495/670 spi: cadence-xspi: reject SDMA transfers larger than the requested length
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weibin Liu <[email protected]>
[ Upstream commit ea9854a169e9c1437df8829bea21c2f2e80b137c ]
The XSPI controller reports the size of the slave-DMA transaction through SDMA_SIZE_REG. Both SDMA handlers take this register at face value and copy the reported number of bytes between the SDMA FIFO and the transfer buffers, without checking it against the length of the transfer that was actually requested.
While cdns_xspi_adjust_mem_op_size() clamps the size of the operations issued by the SPI core, the device can still report a bigger SDMA size than what was programmed, which makes the handlers read from or write to memory beyond the end of the transfer buffers.
Track the number of bytes requested for the current data phase in a new sdma_xfer_len field, set by cdns_xspi_send_stig_command() and by the Marvell b0 transfer path, and reject any SDMA size that exceeds it.
--- drivers/spi/spi-cadence-xspi.c | 36 +++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-)
drivers/spi/spi-cadence-xspi.c +31 -5
@@ -332,6 +332,7 @@ struct cdns_xspi_dev {int irq;int cur_cs;unsigned int sdmasize; +unsigned int sdma_xfer_len;struct completion cmd_complete;struct completion auto_cmd_complete;
@@ -344,7 +345,7 @@ struct cdns_xspi_dev {u8 hw_num_banks;const struct cdns_xspi_driver_data *driver_data; -void (*sdma_handler)(struct cdns_xspi_dev *cdns_xspi); +int (*sdma_handler)(struct cdns_xspi_dev *cdns_xspi);void (*set_interrupts_handler)(struct cdns_xspi_dev *cdns_xspi,bool enabled);bool xfer_in_progress;
@@ -445,7 +446,7 @@ static int cdns_xspi_controller_init(struct cdns_xspi_dev *cdns_xspi)return 0 ; } -static void cdns_xspi_sdma_handle (struct cdns_xspi_dev *cdns_xspi) +static int cdns_xspi_sdma_handle (struct cdns_xspi_dev *cdns_xspi) {u32 sdma_size, sdma_trd_info;u8 sdma_dir;
@@ -454,6 +455,13 @@ static void cdns_xspi_sdma_handle(struct cdns_xspi_dev *cdns_xspi) sdma_trd_info =readl (cdns_xspi->iobase +CDNS_XSPI_SDMA_TRD_INFO_REG ); sdma_dir =FIELD_GET (CDNS_XSPI_SDMA_DIR , sdma_trd_info); +if (sdma_size > cdns_xspi->sdma_xfer_len) { +dev_err (cdns_xspi->dev, +"SDMA size %u exceeds the requested length %u\n" , + sdma_size, cdns_xspi->sdma_xfer_len); +return -EINVAL ; + } +switch (sdma_dir) {case CDNS_XSPI_SDMA_DIR_READ : ioread8_rep(cdns_xspi->sdmabase,
@@ -465,6 +473,8 @@ static void cdns_xspi_sdma_handle(struct cdns_xspi_dev *cdns_xspi) cdns_xspi->out_buffer, sdma_size);break ; } + +return 0 ; } static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi,
@@ -510,6 +520,7 @@ static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi, cdns_xspi->in_buffer = op->data.buf.in; cdns_xspi->out_buffer = op->data.buf.out; + cdns_xspi->sdma_xfer_len = op->data.nbytes;cdns_xspi_trigger_command (cdns_xspi, cmd_regs);
@@ -518,7 +529,11 @@ static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi, cdns_xspi->set_interrupts_handler (cdns_xspi, false);return -EIO ; } - cdns_xspi->sdma_handler (cdns_xspi); + ret = cdns_xspi->sdma_handler (cdns_xspi); +if (ret) { + cdns_xspi->set_interrupts_handler (cdns_xspi, false); +return ret; + } }wait_for_completion (&cdns_xspi->cmd_complete);
@@ -900,7 +915,7 @@ static void m_iowriteq(void __iomem *addr, const void *buf, int len) } } -static void marvell_xspi_sdma_handle (struct cdns_xspi_dev *cdns_xspi) +static int marvell_xspi_sdma_handle (struct cdns_xspi_dev *cdns_xspi) {u32 sdma_size, sdma_trd_info;u8 sdma_dir;
@@ -909,6 +924,13 @@ static void marvell_xspi_sdma_handle(struct cdns_xspi_dev *cdns_xspi) sdma_trd_info =readl (cdns_xspi->iobase +CDNS_XSPI_SDMA_TRD_INFO_REG ); sdma_dir =FIELD_GET (CDNS_XSPI_SDMA_DIR , sdma_trd_info); +if (sdma_size > cdns_xspi->sdma_xfer_len) { +dev_err (cdns_xspi->dev, +"SDMA size %u exceeds the requested length %u\n" , + sdma_size, cdns_xspi->sdma_xfer_len); +return -EINVAL ; + } +switch (sdma_dir) {case CDNS_XSPI_SDMA_DIR_READ : m_ioreadq(cdns_xspi->sdmabase,
@@ -920,6 +942,8 @@ static void marvell_xspi_sdma_handle(struct cdns_xspi_dev *cdns_xspi) cdns_xspi->out_buffer, sdma_size);break ; } + +return 0 ; }static const struct spi_controller_mem_ops marvell_xspi_mem_ops = {
@@ -1084,9 +1108,11 @@ static int cdns_xspi_transfer_one_message_b0(struct spi_controller *controller,cdns_xspi_prepare_transfer (cs,1 , current_transfer_len -1 , cmd_regs);cdns_xspi_trigger_command (cdns_xspi, cmd_regs); + cdns_xspi->sdma_xfer_len = current_transfer_len -1 ;if (!cdns_xspi_is_sdma_ready (cdns_xspi, true))return -EIO ; - cdns_xspi->sdma_handler (cdns_xspi); +if (cdns_xspi->sdma_handler (cdns_xspi)) +return -EIO ;if (!cdns_xspi_is_stig_ready (cdns_xspi, true))return -EIO ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 496/670 ipmr: prevent info-leak in pmr_cache_report()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 4f34002e2e37639133693c13a2a9977fab86880d ]
Yiming Qian reported:
<quote>
ipmr_cache_report() allocates a report skb with alloc_skb(128, GFP_ATOMIC) and appends a struct igmphdr using skb_put(). In the non-IGMPMSG_WHOLEPKT` path it initializes only:
- igmp->type
- igmp->code
but does not initialize:
- igmp->csum
- igmp->group
Later, igmpmsg_netlink_event() copies the bytes after sizeof(struct igmpmsg) into the IPMRA_CREPORT_PKT netlink attribute and emits RTM_NEWCACHEREPORT on RTNLGRP_IPV4_MROUTE_R.
As a result, 6 bytes of stale heap data from the skb head are disclosed to userspace.
</quote>
Let's use skb_put_zero() instead of skb_put() to fix this bug.
Stable-dep-of: 94a6736bb5ab ("ipmr: only copy pktinfo to cache reports")
--- net/ipv4/ipmr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/ipv4/ipmr.c +4 -3
@@ -1095,11 +1095,12 @@ static int ipmr_cache_report(const struct mr_table *mrt, msg->im_vif_hi = vifi >>8 ;ipv4_pktinfo_prepare (mroute_sk, pkt, false);memcpy (skb->cb, pkt->cb,sizeof (skb->cb)); -/* Add our header */ - igmp =skb_put (skb,sizeof (struct igmphdr )); +/* Add our header. +* Note that code, csum and group fields are cleared. +*/ + igmp =skb_put_zero (skb,sizeof (struct igmphdr )); igmp->type = assert; msg->im_msgtype = assert; - igmp->code =0 ;ip_hdr (skb)->tot_len =htons (skb->len);/* Fix the length */ skb->transport_header = skb->network_header; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 497/670 ipmr: only copy pktinfo to cache reports
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
[ Upstream commit 94a6736bb5abe6b2ef38490d0cab19c1c6a7c71f ]
ipmr_cache_report() prepares IP_PKTINFO on the original skb. The ipv4_pktinfo_prepare() helper updates skb->cb and clears the pktinfo fields when packet info is disabled. Since the skb can continue through the data path, preserve and restore its original control block around the helper.
The original implementation copies the entire control block to the report skb. For synthetic RTM_GETROUTE packets, NETLINK_CB data is interpreted as IPCB by the raw IPv4 receive path. With IP_RECVOPTS or IP_RETOPTS enabled, corrupted option offsets cause out-of-bounds reads or a stack buffer overflow. WHOLEPKT and WRVIFWHOLE reports also inherit stale IP option offsets when their header is prepended.
Clear the report skb control block. Only prepare and copy pktinfo when the input skb has an IPv4 header. Synthetic route-query skbs use NETLINK_CB, not IPCB, so leave their report control block zeroed. Restore pkt->cb after preparing pktinfo for regular IPv4 packets.
--- net/ipv4/ipmr.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
net/ipv4/ipmr.c +10 -2
@@ -1038,6 +1038,7 @@ static void ipmr_cache_resolve(struct net *net, struct mr_table *mrt,static int ipmr_cache_report (const struct mr_table *mrt,struct sk_buff *pkt,vifi_t vifi,int assert) { +unsigned char pkt_cb[sizeof (pkt->cb)];const int ihl =ip_hdrlen (pkt);struct sock *mroute_sk;struct igmphdr *igmp;
@@ -1093,8 +1094,6 @@ static int ipmr_cache_report(const struct mr_table *mrt, msg = (struct igmpmsg *)skb_network_header (skb); msg->im_vif = vifi; msg->im_vif_hi = vifi >>8 ; -ipv4_pktinfo_prepare (mroute_sk, pkt, false); -memcpy (skb->cb, pkt->cb,sizeof (skb->cb));/* Add our header. * Note that code, csum and group fields are cleared. */
@@ -1105,6 +1104,15 @@ static int ipmr_cache_report(const struct mr_table *mrt, skb->transport_header = skb->network_header; } +memset (skb->cb,0 ,sizeof (skb->cb)); +/* Route queries from ipmr_get_route() carry NETLINK_CB, not IPCB. */ +if (ip_hdr (pkt)->version) { +memcpy (pkt_cb, pkt->cb,sizeof (pkt_cb)); +ipv4_pktinfo_prepare (mroute_sk, pkt, false); + *PKTINFO_SKB_CB (skb) = *PKTINFO_SKB_CB (pkt); +memcpy (pkt->cb, pkt_cb,sizeof (pkt_cb)); + } +igmpmsg_netlink_event (mrt, skb);/* Deliver to mrouted */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 498/670 coresight/etm4: fix missing disable active config
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yeoreum Yun <[email protected]>
commit 895b12b7d7b8c651f73f57a1ea040d35aa7048cb upstream.
When etm4 device is disabled via sysfs, it should disable its active count.
--- drivers/hwtracing/coresight/coresight-etm4x-core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwtracing/coresight/coresight-etm4x-core.c +3 -0
@@ -1082,6 +1082,9 @@ static void etm4_disable_sysfs(struct coresight_device *csdev)smp_call_function_single (drvdata->cpu, etm4_disable_hw, drvdata,1 );spin_unlock (&drvdata->spinlock); + +cscfg_csdev_disable_active_config (csdev); +cpus_read_unlock ();/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 499/670 apparmor: check accept index + 1 is in bounds
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guanglei Zhu <[email protected]>
[ Upstream commit afe5d5a747393cb3d00795db31d7fce5108a766a ]
aa_lookup_fperms() returns perms[index + 1] when the current fsuid does not match cond->uid, so such an entry consumes two slots in the perms table. But verify_dfa_accept_index() only checks that index is within the perms table, so a policy whose last accept entry is reached with a non-matching fsuid reads perms[index + 1] one entry past the end of the table.
The perms table is allocated by unpack_perms_table() with a u16 size read from the policy blob, so a crafted policy can place an accept entry at index size - 1 to reach the out-of-bounds read.
Check that index + 1 is also in bounds.
--- security/apparmor/policy_unpack.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
security/apparmor/policy_unpack.c +15 -4
@@ -1202,13 +1202,22 @@ static int verify_header(struct aa_ext *e, int required, const char **ns)* verify_dfa_accept_index - verify accept indexes are in range of perms table * @dfa: the dfa to check accept indexes are in range * @table_size: the permission table size the indexes should be within +* @pair: the accept indexes reference two slots, index and index + 1 */ -static bool verify_dfa_accept_index (struct aa_dfa *dfa,int table_size) +static bool verify_dfa_accept_index (struct aa_dfa *dfa,int table_size, +bool pair) {int i;for (i =0 ; i < dfa->tables[YYTD_ID_ACCEPT ]->td_lolen; i++) {if (ACCEPT_TABLE (dfa)[i] >= table_size)return false; +/* +* Accept indexes for owner-conditional permissions come +* in pairs, so the non-owner entry at index + 1 must also +* be in bounds. +*/ +if (pair &&ACCEPT_TABLE (dfa)[i] +1 >= table_size) +return false; }return true; }
@@ -1272,15 +1281,17 @@ static int verify_profile(struct aa_profile *profile)if (!rules)return 0 ; -if (rules->file->dfa && !verify_dfa_accept_index (rules->file->dfa, - rules->file->size)) { +if (rules->file->dfa && + !verify_dfa_accept_index (rules->file->dfa, rules->file->size, + rules->file != rules->policy)) {audit_iface (profile,NULL ,NULL ,"Unpack: file Invalid named transition" ,NULL , -EPROTO );return -EPROTO ; }if (rules->policy->dfa && - !verify_dfa_accept_index (rules->policy->dfa, rules->policy->size)) { + !verify_dfa_accept_index (rules->policy->dfa, rules->policy->size, + false)) {audit_iface (profile,NULL ,NULL ,"Unpack: policy Invalid named transition" ,NULL , -EPROTO );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 500/670 nvme-tcp: skip TLS control records while waiting for the ICResp
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Belanger <[email protected]>
commit 12c20e2903563acfb949342967adb900310a24d4 upstream.
A peer may send a NewSessionTicket as soon as the handshake completes, ahead of the ICResp. nvme_tcp_init_connection() fails the connection on any record that is not application data, so such a target cannot be reached at all. An OpenSSL-based target does this by default.
RFC 9846 section 4.7.1 requires a client that does not support session resumption to ignore a NewSessionTicket. Discard such a record and read again, up to a fixed number of records. Report an alert, and fail the connection for any other record type.
The record type is now checked before the length. A control record shorter than the ICResp was reported as -ECONNRESET, which hid the real cause.
--- drivers/nvme/host/tcp.c | 162 ++++++++++++++++++++++++++++++++++------ 1 file changed, 140 insertions(+), 22 deletions(-)
drivers/nvme/host/tcp.c +140 -22
@@ -54,6 +54,12 @@ MODULE_PARM_DESC(tls_handshake_timeout, "nvme TLS handshake timeout in seconds (default 10)");#endif +/* read a TLS control record in chunks of this size */ +#define NVME_TCP_TLS_REC_CHUNK 256 + +/* TLS records read while waiting for the ICResp, the ICResp included */ +#define NVME_TCP_ICRESP_MAX_RECORDS 8 +static atomic_t nvme_tcp_cpu_queues[NR_CPUS ];#ifdef CONFIG_DEBUG_LOCK_ALLOC
@@ -1569,12 +1575,143 @@ static void nvme_tcp_free_queue(struct nvme_ctrl *nctrl, int qid)mutex_destroy (&queue->pf_cache_lock); } +static int nvme_tcp_recv_tls_alert (struct nvme_tcp_queue *queue, +struct msghdr *msg,int len) +{ +struct sock *sk = queue->sock->sk; +u8 level, description; + +if (len <2 ) { +dev_err (queue->ctrl->ctrl.device, +"queue %d: truncated TLS alert\n" , +nvme_tcp_queue_id (queue)); +return -ENOTCONN ; + } + +/* tls_alert_recv() reads through the iterator */ +iov_iter_revert (&msg->msg_iter, len); +tls_alert_recv (sk, msg, &level, &description); + +if (level ==TLS_ALERT_LEVEL_FATAL ) { +dev_err (queue->ctrl->ctrl.device, +"queue %d: fatal TLS alert %u\n" , +nvme_tcp_queue_id (queue), description); +return -ENOTCONN ; + } + +/* a peer shutting down normally is not worth a warning */ +if (description ==TLS_ALERT_DESC_CLOSE_NOTIFY ) +dev_dbg (queue->ctrl->ctrl.device, +"queue %d: TLS close_notify\n" , +nvme_tcp_queue_id (queue)); +else +dev_warn (queue->ctrl->ctrl.device, +"queue %d: TLS alert %u\n" , +nvme_tcp_queue_id (queue), description); + +return 0 ; +} + +/* +* Discard a TLS record that arrived in place of the ICResp. A peer may send +* a NewSessionTicket as soon as the handshake completes. +* +* Returns 0 when the record was discarded and the ICResp can be read, or a +* negative errno if the connection cannot continue. +*/ +static int nvme_tcp_skip_tls_record (struct nvme_tcp_queue *queue, +struct msghdr *msg,u8 ctype,int len) +{ +u8 buf[NVME_TCP_TLS_REC_CHUNK ]; +int ret; + +switch (ctype) { +case TLS_RECORD_TYPE_HANDSHAKE : +break ; +case TLS_RECORD_TYPE_ALERT : + ret =nvme_tcp_recv_tls_alert (queue, msg, len); +return ret ? : -ENOTCONN ; +default : +pr_err ("queue %d: unhandled TLS record %u\n" , +nvme_tcp_queue_id (queue), ctype); +return -ENOTCONN ; + } + +/* the ICResp is in a later record, drain this one first */ +while (!(msg->msg_flags &MSG_EOR )) { +struct kvec iov = { + .iov_base = buf, + .iov_len =sizeof (buf), + }; +char cbuf[CMSG_LEN (sizeof (char ))] = {}; +/* kTLS fails a control record read without a cmsg buffer */ +struct msghdr drain = { + .msg_control = cbuf, + .msg_controllen =sizeof (cbuf), + }; + + ret =kernel_recvmsg (queue->sock, &drain, &iov,1 ,sizeof (buf), +0 ); +if (ret <=0 ) { +pr_warn ("queue %d: failed to drain TLS record: %d\n" , +nvme_tcp_queue_id (queue), ret); +return ret ? : -ECONNRESET ; + } + msg->msg_flags = drain.msg_flags; + } + +return 0 ; +} + +/* +* Receive the ICResp. Over TLS, skip the records that a peer may send +* ahead of it. +* +* Returns the length received, or a negative errno. +*/ +static int nvme_tcp_recv_icresp (struct nvme_tcp_queue *queue, +struct nvme_tcp_icresp_pdu *icresp) +{ +char cbuf[CMSG_LEN (sizeof (char ))]; +struct msghdr msg; +struct kvec iov; +u8 ctype; +int i, ret; + +for (i =0 ; i <NVME_TCP_ICRESP_MAX_RECORDS ; i++) { +memset (&msg,0 ,sizeof (msg)); +memset (cbuf,0 ,sizeof (cbuf)); + iov.iov_base = icresp; + iov.iov_len =sizeof (*icresp); +if (nvme_tcp_queue_tls (queue)) { + msg.msg_control = cbuf; + msg.msg_controllen =sizeof (cbuf); + } + msg.msg_flags =MSG_WAITALL ; + ret =kernel_recvmsg (queue->sock, &msg, &iov,1 , + iov.iov_len, msg.msg_flags); +if (ret <=0 || !nvme_tcp_queue_tls (queue)) +return ret; + + ctype =tls_get_record_type (queue->sock->sk, + (struct cmsghdr *)cbuf); +if (ctype ==TLS_RECORD_TYPE_DATA ) +return ret; + + ret =nvme_tcp_skip_tls_record (queue, &msg, ctype, ret); +if (ret <0 ) +return ret; + } + +pr_err ("queue %d: too many TLS records before the ICResp\n" , +nvme_tcp_queue_id (queue)); +return -EPROTO ; +} +static int nvme_tcp_init_connection (struct nvme_tcp_queue *queue) {struct nvme_tcp_icreq_pdu *icreq;struct nvme_tcp_icresp_pdu *icresp; -char cbuf[CMSG_LEN (sizeof (char ))] = {}; -u8 ctype;struct msghdr msg = {};struct kvec iov;bool ctrl_hdgst, ctrl_ddgst;
@@ -1612,16 +1749,7 @@ static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue) goto free_icresp; } -memset (&msg,0 ,sizeof (msg)); - iov.iov_base = icresp; - iov.iov_len =sizeof (*icresp); -if (nvme_tcp_queue_tls (queue)) { - msg.msg_control = cbuf; - msg.msg_controllen =sizeof (cbuf); - } - msg.msg_flags =MSG_WAITALL ; - ret =kernel_recvmsg (queue->sock, &msg, &iov,1 , - iov.iov_len, msg.msg_flags); + ret =nvme_tcp_recv_icresp (queue, icresp);if (ret >=0 && ret <sizeof (*icresp)) ret = -ECONNRESET ;if (ret <0 ) {
@@ -1629,16 +1757,6 @@ static int nvme_tcp_init_connection(struct nvme_tcp_queue *queue) nvme_tcp_queue_id(queue), ret); goto free_icresp; } - ret = -ENOTCONN ; -if (nvme_tcp_queue_tls (queue)) { - ctype =tls_get_record_type (queue->sock->sk, - (struct cmsghdr *)cbuf); -if (ctype !=TLS_RECORD_TYPE_DATA ) { -pr_err ("queue %d: unhandled TLS record %d\n" , -nvme_tcp_queue_id (queue), ctype); - goto free_icresp; - } - } ret = -EINVAL ;if (icresp->hdr.type != nvme_tcp_icresp) { pr_err("queue %d: bad type returned %d\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 501/670 wifi: rtw88: usb: route bmc frames via the high queue only for DTIM delivery
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mehmet Fide <[email protected]>
[ Upstream commit c710c7c2e0380d7c0eeb33b686262edcaef7cb07 ]
In AP mode every broadcast and multicast data frame is routed to TX_DESC_QSEL_HIGH, the after-DTIM queue, whether or not anybody is asleep. The firmware drains that queue at beacon pace, a dozen or so frames per second measured on RTL8822BU, while one associated client's mDNS/SSDP chatter alone exceeds that. The excess accumulates inside the chip until the shared TX page pool is exhausted (measured: 14 of 1803 pages left). From that point every host-sourced frame queues behind the backlog: authentication responses reach the air seconds after the client has given up, so no station can associate anymore, and the beacon reserved-page download fails the BCN_VALID poll ("error beacon valid") because it needs pages from the same pool. The AP keeps beaconing, so the failure looks like a silent RX stall and only a reboot recovers.
mac80211 already decides when after-DTIM delivery is needed: it sets IEEE80211_TX_CTL_SEND_AFTER_DTIM on bmc frames only while at least one station is actually dozing. Honor that instead of routing
unconditionally: flagged frames keep going through the high queue with the MORE_DATA and HGQMD handling introduced by commit 076f786a0ae1 ("wifi: rtw88: Fix AP mode incorrect DTIM behavior"), everything else leaves at line rate through the AC queues. This partially reverts the usb.c hunk of that commit, whose unconditional routing is what lets the backlog build up.
On a bench AP (USB2, 20 MHz, WPA2, hostapd, a Windows client driven through disconnect/reconnect cycles): reconnects fail 0/5 on RTL8822BU and 0/3 on RTL8821CU before this change, and pass 10/10 and 5/5 with it, with the page pool staying healthy and no beacon errors logged.
--- drivers/net/wireless/realtek/rtw88/usb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/usb.c +3 -1
@@ -558,6 +558,7 @@ static int rtw_usb_write_data_h2c(struct rtw_dev *rtwdev, u8 *buf, u32 size)static u8 rtw_usb_tx_queue_mapping_to_qsel (struct sk_buff *skb) {struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; +struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb);__le16 fc = hdr->frame_control;u8 qsel;
@@ -565,7 +566,8 @@ static u8 rtw_usb_tx_queue_mapping_to_qsel(struct sk_buff *skb) qsel =TX_DESC_QSEL_MGMT ; else if (is_broadcast_ether_addr(hdr->addr1) || is_multicast_ether_addr(hdr->addr1)) - qsel =TX_DESC_QSEL_HIGH ; + qsel = (info->flags &IEEE80211_TX_CTL_SEND_AFTER_DTIM ) ? +TX_DESC_QSEL_HIGH : skb->priority; else if (skb_get_queue_mapping(skb) <= IEEE80211_AC_BK) qsel = skb->priority; else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 502/670 wifi: rtw88: usb: bound what the driver feeds the after-DTIM queue
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mehmet Fide <[email protected]>
[ Upstream commit 04cc8c59a3d79ef7ec2341f1c7aef1d40a0ce7df ]
Frames routed to the high queue are transmitted right after DTIM beacons only, inside the ATIM window, while they wait in the shared TX page pool. The driver puts no limit on how many it hands over, so as long as one station dozes, any sustained broadcast or multicast traffic outruns the drain and empties the pool: measured on an RTL8822BU AP with a single client in power save and ~40 frames/s of mDNS chatter, the free page count at 0x240 goes from 1803 to 16 in about 100 seconds and stays there for as long as the traffic lasts. From that point every other transmit queues behind the backlog, authentication responses arrive too late for anyone to join, and the reserved page download fails ("error beacon valid"). The AP keeps beaconing and only a reboot recovers.
Feed the high queue through a small budget that refills below the measured drain rate (about 3 frames per DTIM, ~15/s at dtim_period 2 on the default 2 TU ATIM window); whatever exceeds the budget leaves on its access category queue right away. The high queue backlog is now bounded by the burst size under any load, so the page pool cannot run dry, at the price that a dozing station may miss part of a broadcast storm.
--- drivers/net/wireless/realtek/rtw88/usb.c | 41 ++++++++++++++++++++++-- drivers/net/wireless/realtek/rtw88/usb.h | 5 +++ 2 files changed, 43 insertions(+), 3 deletions(-)
drivers/net/wireless/realtek/rtw88/usb.c +38 -3
@@ -555,7 +555,37 @@ static int rtw_usb_write_data_h2c(struct rtw_dev *rtwdev, u8 *buf, u32 size)return rtw_usb_write_data (rtwdev, &pkt_info, buf); } -static u8 rtw_usb_tx_queue_mapping_to_qsel (struct sk_buff *skb) +#define RTW_USB_HIQ_REFILL_INTERVAL (HZ / 10)/* one unit of budget per 100 ms */ +#define RTW_USB_HIQ_BUDGET_MAX 16 + +static bool rtw_usb_hiq_take_budget (struct rtw_usb *rtwusb) +{ +unsigned long flags, elapsed, add; +bool ok; + +spin_lock_irqsave (&rtwusb->hiq_lock, flags); + + elapsed = jiffies - rtwusb->hiq_refill; + add = elapsed /RTW_USB_HIQ_REFILL_INTERVAL ; +if (add) { + rtwusb->hiq_budget = min_t(unsigned long, rtwusb->hiq_budget + add, +RTW_USB_HIQ_BUDGET_MAX ); + +/* keep the unfinished part of the interval for the next unit */ + rtwusb->hiq_refill = jiffies - elapsed %RTW_USB_HIQ_REFILL_INTERVAL ; + } + + ok = rtwusb->hiq_budget >0 ; +if (ok) + rtwusb->hiq_budget--; + +spin_unlock_irqrestore (&rtwusb->hiq_lock, flags); + +return ok; +} + +static u8 rtw_usb_tx_queue_mapping_to_qsel (struct rtw_usb *rtwusb, +struct sk_buff *skb) {struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb);
@@ -566,7 +596,8 @@ static u8 rtw_usb_tx_queue_mapping_to_qsel(struct sk_buff *skb) qsel =TX_DESC_QSEL_MGMT ; else if (is_broadcast_ether_addr(hdr->addr1) || is_multicast_ether_addr(hdr->addr1)) - qsel = (info->flags &IEEE80211_TX_CTL_SEND_AFTER_DTIM ) ? + qsel = (info->flags &IEEE80211_TX_CTL_SEND_AFTER_DTIM ) && +rtw_usb_hiq_take_budget (rtwusb) ?TX_DESC_QSEL_HIGH : skb->priority; else if (skb_get_queue_mapping(skb) <= IEEE80211_AC_BK) qsel = skb->priority;
@@ -586,7 +617,7 @@ static int rtw_usb_tx_write(struct rtw_dev *rtwdev,u8 *pkt_desc;int ep; - pkt_info->qsel =rtw_usb_tx_queue_mapping_to_qsel (skb); + pkt_info->qsel =rtw_usb_tx_queue_mapping_to_qsel (rtwusb, skb); pkt_desc =skb_push (skb, chip->tx_pkt_desc_sz);memset (pkt_desc,0 , chip->tx_pkt_desc_sz); ep =qsel_to_ep (rtwusb, pkt_info->qsel);
@@ -937,6 +968,10 @@ static int rtw_usb_init_tx(struct rtw_dev *rtwdev)struct rtw_usb *rtwusb =rtw_get_usb_priv (rtwdev);int i; +spin_lock_init (&rtwusb->hiq_lock); + rtwusb->hiq_budget =RTW_USB_HIQ_BUDGET_MAX ; + rtwusb->hiq_refill = jiffies; + rtwusb->txwq =create_singlethread_workqueue ("rtw88_usb: tx wq" );if (!rtwusb->txwq) {rtw_err (rtwdev,"failed to create TX work queue\n" );
drivers/net/wireless/realtek/rtw88/usb.h +5 -0
@@ -74,6 +74,11 @@ struct rtw_usb {u8 out_ep[RTW_USB_EP_MAX ];int qsel_to_ep[TX_DESC_QSEL_MAX ]; +/* protects hiq_budget and hiq_refill */ +spinlock_t hiq_lock; +u32 hiq_budget; +unsigned long hiq_refill; +struct workqueue_struct *txwq, *rxwq;struct sk_buff_head tx_queue[RTW_USB_EP_MAX ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 503/670 wifi: rtw88: usb: only let the frames a dozing station needs use the after-DTIM queue
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mehmet Fide <[email protected]>
[ Upstream commit 185971f1b4eb4ea9059d76cf1a18f992eef998c1 ]
With the budget in place the high queue can no longer take the chip down, but ordinary chatter still competes with the frames a sleeping station actually needs. mac80211 marks every broadcast and multicast frame with IEEE80211_TX_CTL_SEND_AFTER_DTIM while a station dozes, mDNS and SSDP included, so under normal traffic the budget is spent on frames nobody waits for.
Do what the vendor driver does with its default "allow special" high queue filter: admit only ARP, EAPOL and DHCP to the after-DTIM path, the frames a station coming out of power save has to see; everything else goes out on its access category queue at line rate. The frames are classified the way rtw89_core_tx_btc_spec_pkt_notify() does it, from skb->protocol and the network and transport header offsets that mac80211 keeps from the netdev path; EAPOL is the control port flag. Frames the AP relays between its own stations arrive as ETH_P_802_3 and are not inspected, they leave on the access category queue.
With the filter in place the page pool stays at 1803 through the same 180 second storm, a DHCP flood still takes the after-DTIM path (and is then held by the budget), and join/ping cycling without power save is unchanged (10/10).
--- drivers/net/wireless/realtek/rtw88/usb.c | 27 ++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw88/usb.c +25 -2
@@ -2,9 +2,11 @@/* Copyright(c) 2018-2019 Realtek Corporation */ +#include <linux/ip.h> #include <linux/module.h> -#include <linux/usb.h> #include <linux/mutex.h> +#include <linux/udp.h> +#include <linux/usb.h> #include "main.h" #include "debug.h" #include "reg.h"
@@ -555,6 +557,27 @@ static int rtw_usb_write_data_h2c(struct rtw_dev *rtwdev, u8 *buf, u32 size)return rtw_usb_write_data (rtwdev, &pkt_info, buf); } +static bool rtw_usb_bmc_needs_dtim (struct sk_buff *skb) +{ +struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb); +struct udphdr *udphdr; + +if (info->control.flags &IEEE80211_TX_CTRL_PORT_CTRL_PROTO ) +return true; + +if (skb->protocol ==htons (ETH_P_ARP )) +return true; + +if (skb->protocol ==htons (ETH_P_IP ) && +ip_hdr (skb)->protocol ==IPPROTO_UDP ) { + udphdr =udp_hdr (skb); + +return udphdr->dest ==htons (67 ) || udphdr->dest ==htons (68 ); + } + +return false; +} +#define RTW_USB_HIQ_REFILL_INTERVAL (HZ / 10)/* one unit of budget per 100 ms */ #define RTW_USB_HIQ_BUDGET_MAX 16
@@ -597,7 +620,7 @@ static u8 rtw_usb_tx_queue_mapping_to_qsel(struct rtw_usb *rtwusb,else if (is_broadcast_ether_addr (hdr->addr1) ||is_multicast_ether_addr (hdr->addr1)) qsel = (info->flags &IEEE80211_TX_CTL_SEND_AFTER_DTIM ) && -rtw_usb_hiq_take_budget (rtwusb) ? +rtw_usb_bmc_needs_dtim (skb) &&rtw_usb_hiq_take_budget (rtwusb) ?TX_DESC_QSEL_HIGH : skb->priority;else if (skb_get_queue_mapping (skb) <=IEEE80211_AC_BK ) qsel = skb->priority;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 504/670 wifi: rtw88: widen the ATIM window while an AP interface is up
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mehmet Fide <[email protected]>
[ Upstream commit cf8b516f67652f550e040951b88a2040b375afcf ]
The frames held for dozing stations go out right after the DTIM beacon and only for the duration of the ATIM window. The chips come up with a 2 TU window (the two that program it set 0x2 at init), which drains about three frames per DTIM; the vendor driver sets 0xa or 0xc in AP mode instead. With the 2 TU window the measured page pool exhaustion takes ~100 s of ordinary multicast chatter; at 0x4 the same storm already drains, so 0xa leaves comfortable headroom.
Program 0xa when an AP interface starts and put the default back when it stops, since most chips never initialize the register themselves. The bound and the filter of the previous patches still apply: the window adds drain capacity, the budget protects the pool when that is not enough, the filter keeps chatter off the beacon-paced path.
--- drivers/net/wireless/realtek/rtw88/mac80211.c | 2 ++ drivers/net/wireless/realtek/rtw88/reg.h | 2 ++ 2 files changed, 4 insertions(+)
drivers/net/wireless/realtek/rtw88/mac80211.c +2 -0
@@ -466,6 +466,7 @@ static int rtw_ops_start_ap(struct ieee80211_hw *hw,mutex_lock (&rtwdev->mutex);rtw_write32_set (rtwdev,REG_TCR ,BIT_TCR_UPDATE_HGQMD ); +rtw_write16 (rtwdev,REG_ATIMWND ,ATIMWND_AP ); rtwdev->ap_active = true;rtw_store_op_chan (rtwdev, true); chip->ops->phy_calibration (rtwdev);
@@ -482,6 +483,7 @@ static void rtw_ops_stop_ap(struct ieee80211_hw *hw,mutex_lock (&rtwdev->mutex);rtw_write32_clr (rtwdev,REG_TCR ,BIT_TCR_UPDATE_HGQMD ); +rtw_write16 (rtwdev,REG_ATIMWND ,ATIMWND_DEFAULT ); rtwdev->ap_active = false;if (!rtw_core_check_sta_active (rtwdev))rtw_clear_op_chan (rtwdev);
drivers/net/wireless/realtek/rtw88/reg.h +2 -0
@@ -431,6 +431,8 @@#define REG_DRVERLYINT 0x0558#define REG_BCNDMATIM 0x0559#define REG_ATIMWND 0x055A +#define ATIMWND_DEFAULT 0x2 +#define ATIMWND_AP 0xa#define REG_USTIME_TSF 0x055C#define REG_BCN_MAX_ERR 0x055D#define REG_RXTSF_OFFSET_CCK 0x055E
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 505/670 drm/nouveau/pci: use config-space MSI rearm on MCP79/MCP7A (NVAC)
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Czernohous <[email protected]>
commit 354d47fb3f35461b7f942831c1b2a7105e92b57f upstream.
NVAC (MCP79/MCP7A) uses g94_pci_func, whose .msi_rearm is nv40_pci_msi_rearm(): a re-arm write through the MMIO mirror of PCI config space. On this IGP that path is unreliable; when a re-arm is missed the interrupt line stays dead, command submission times out and the GPU appears hung until reboot. On an Apple Mac mini (early 2009, MCP79, boot0 0x0ac080b1) this showed as sporadic fifo timeouts and GPU hangs under load unless MSI was disabled via config=NvMSI=0.
Give NVAC its own pci func that re-arms through real PCI config space (nv46_pci_msi_rearm) instead. This follows existing precedent: nv46.c documents the MMIO-mirror re-arm as broken on several related parts, and commit 5112abc6a433 ("drm/nouveau/pci/g92: Fix rearm") fixed g92 the same way while moving the remaining chipsets, NVAC included, into the newly added shared g94 table, where NVAC stayed on the MMIO path. This change completes that fix for NVAC. The sibling IGP NVAA (MCP77/MCP78) has MSI disabled entirely as "reported broken" in nvkm_pci_new_(); NVAC works correctly once the re-arm goes through config space, so disabling MSI is not necessary.
Only NVAC is switched: that is the hardware this has been validated on. The other users of g94_pci_func (G94/G96/G98/GT2xx and the MCP77/MCP89 IGPs) keep their current behavior; MCP77 and MCP89 plausibly want the same treatment but were not tested.
Tested on the Mac mini as a daily driver for two months with MSI enabled and zero fifo timeouts. Independently confirmed stable on an iMac9,1 (MCP79) running 6.12.90 with the v1 form of this change (the same one-line functional switch, applied to that kernel's g94 implementation).
[ Backport note: linux-6.12.y predates commit 2f89bb3264af
("drm/nouveau/pci: add PRI address of config space mirror to nvkm_pci_func"), so struct nvkm_pci_func has no .cfg member here. mcp79_pci_func uses the nv40 .rd32/.wr08/.wr32 accessors instead, exactly as g94_pci_func does in this tree, and still differs from g94_pci_func only in .msi_rearm. ]
--- .../gpu/drm/nouveau/include/nvkm/subdev/pci.h | 1 + .../gpu/drm/nouveau/nvkm/engine/device/base.c | 2 +- .../gpu/drm/nouveau/nvkm/subdev/pci/Kbuild | 1 + .../gpu/drm/nouveau/nvkm/subdev/pci/mcp79.c | 36 +++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/nouveau/nvkm/subdev/pci/mcp79.c
drivers/gpu/drm/nouveau/include/nvkm/subdev/pci.h +1 -0
@@ -46,6 +46,7 @@ int nv4c_pci_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nint g84_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int g92_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int g94_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **); +int mcp79_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int gf100_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int gf106_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int gk104_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +1 -1
@@ -1237,7 +1237,7 @@ nvac_chipset = { .mc = { 0x00000001, g98_mc_new }, .mmu = { 0x00000001, mcp77_mmu_new }, .mxm = { 0x00000001, nv50_mxm_new }, - .pci = { 0x00000001, g94_pci_new }, + .pci = { 0x00000001, mcp79_pci_new }, .therm = { 0x00000001, g84_therm_new }, .timer = { 0x00000001, nv41_timer_new }, .volt = { 0x00000001, nv40_volt_new },
drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild +1 -0
@@ -9,6 +9,7 @@ nvkm-y += nvkm/subdev/pci/nv4c.o nvkm-y += nvkm/subdev/pci/g84.o nvkm-y += nvkm/subdev/pci/g92.o nvkm-y += nvkm/subdev/pci/g94.o +nvkm-y += nvkm/subdev/pci/mcp79.o nvkm-y += nvkm/subdev/pci/gf100.o nvkm-y += nvkm/subdev/pci/gf106.o nvkm-y += nvkm/subdev/pci/gk104.o
drivers/gpu/drm/nouveau/nvkm/subdev/pci/mcp79.c new file +36 -0
@@ -0,0 +1,36 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright 2026 Marek Czernohous +* +* MCP79/MCP7A (NVAC): like g94, but MSI re-arm goes through real PCI +* config space. The MMIO-mirror re-arm is unreliable on this IGP and a +* missed re-arm kills the interrupt line (see the nv46 comment; g92 +* already re-arms through config space for the same reason). +*/ +#include "priv.h" + +static const struct nvkm_pci_func +mcp79_pci_func = { + .init = g84_pci_init, + .rd32 = nv40_pci_rd32, + .wr08 = nv40_pci_wr08, + .wr32 = nv40_pci_wr32, + .msi_rearm = nv46_pci_msi_rearm, + + .pcie.init = g84_pcie_init, + .pcie.set_link = g84_pcie_set_link, + + .pcie.max_speed = g84_pcie_max_speed, + .pcie.cur_speed = g84_pcie_cur_speed, + + .pcie.set_version = g84_pcie_set_version, + .pcie.version = g84_pcie_version, + .pcie.version_supported = g92_pcie_version_supported, +}; + +int +mcp79_pci_new (struct nvkm_device *device,enum nvkm_subdev_type type,int inst, +struct nvkm_pci **ppci) +{ +return nvkm_pci_new_ (&mcp79_pci_func, device, type, inst, ppci); +}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 506/670 mm/page-writeback: avoid 32-bit overflow in dirty threshold shares
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hungyu Lin <[email protected]>
[ Upstream commit 9597c2056e05bd79df9d343a9b42e84a54de1c52 ]
The ratios used by __wb_calc_thresh() are scaled to parts per million, but the threshold and ratio operands are unsigned long. On 32-bit kernels, their multiplication can wrap before the result is assigned to u64.
For example, with a threshold of 25600 pages and the default maximum ratio of 1000000, wb_max_thresh becomes 4125 pages instead of 25600. The shared threshold and minimum share calculations can overflow in the same way, producing incorrect per-writeback dirty limits.
Use a u64 threshold for the three ratio multiplications and div_u64() to retain the existing division order and rounding.
In 6.12, __wb_calc_thresh() has no freerun adjustment here. Widen the threshold for the ratio calculations and compute the maximum share once for the existing clamp.
--- mm/page-writeback.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
mm/page-writeback.c +8 -4
@@ -917,7 +917,9 @@ static unsigned long __wb_calc_thresh(struct dirty_throttle_control *dtc, unsigned long thresh) {struct wb_domain *dom =dtc_dom (dtc); +u64 threshold = thresh;u64 wb_thresh; +u64 wb_max_thresh;unsigned long numerator, denominator;unsigned long wb_min_ratio, wb_max_ratio;
@@ -927,15 +929,17 @@ static unsigned long __wb_calc_thresh(struct dirty_throttle_control *dtc,fprop_fraction_percpu (&dom->completions, dtc->wb_completions, &numerator, &denominator); - wb_thresh = (thresh * (100 *BDI_RATIO_SCALE - bdi_min_ratio)) / (100 *BDI_RATIO_SCALE ); + wb_thresh =div_u64 (threshold * (100 *BDI_RATIO_SCALE - bdi_min_ratio), +100 *BDI_RATIO_SCALE ); wb_thresh *= numerator; wb_thresh =div64_ul (wb_thresh, denominator);wb_min_max_ratio (dtc->wb, &wb_min_ratio, &wb_max_ratio); - wb_thresh += (thresh * wb_min_ratio) / (100 *BDI_RATIO_SCALE ); -if (wb_thresh > (thresh * wb_max_ratio) / (100 *BDI_RATIO_SCALE )) - wb_thresh = thresh * wb_max_ratio / (100 *BDI_RATIO_SCALE ); + wb_thresh +=div_u64 (threshold * wb_min_ratio,100 *BDI_RATIO_SCALE ); + wb_max_thresh =div_u64 (threshold * wb_max_ratio,100 *BDI_RATIO_SCALE ); +if (wb_thresh > wb_max_thresh) + wb_thresh = wb_max_thresh;return wb_thresh; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 507/670 udf: validate the device specification EA before using it
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yunpeng Tian <[email protected]>
[ Upstream commit 9a2390959685ac35a58c80c8016120849a2babf6 ]
udf_get_extendedattr() bounds an extended attribute only against struct genericFormat, which is 12 bytes. A type-12 device specification is struct deviceSpec, which is 24 bytes plus a flexible impUse array. Thus a corrupted filesystem can contain extended attribute that is accepted by udf_get_extendedattr() but udf_write_inode() or udf_read_inode() may access beyond the end of provided buffer.
Provide a udf_device_spec_valid() check to validate correctness of extended attribute that is a deviceSpec. While here, check the result of udf_add_extendedattr() before dereferencing it as it can return NULL in case of error.
[JK: Removed duplicated validity checks]
--- fs/udf/inode.c | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-)
fs/udf/inode.c +37 -5
@@ -1339,6 +1339,26 @@ int udf_setsize(struct inode *inode, loff_t newsize)return err; } +/* +* Verify validity of struct deviceSpec on disk. udf_get_extendedattr() has +* already verified the generic header and made sure attribute fits in the +* inode so we just have to make sure attribute space is large enough for +* deviceSpec struct and required impUse information. +*/ +static bool udf_device_spec_valid (struct deviceSpec *dsea) +{ +u32 attr_length, imp_use_length; + + attr_length =le32_to_cpu (dsea->attrLength); + imp_use_length =le32_to_cpu (dsea->impUseLength); +if (attr_length <sizeof (struct deviceSpec ) || + imp_use_length <sizeof (struct regid ) || + imp_use_length > attr_length -sizeof (struct deviceSpec )) +return false; + +return true; +} +/* * Maximum length of linked list formed by ICB hierarchy. The chosen number is * arbitrary - just that we hopefully don't limit any real use of rewritten
@@ -1657,13 +1677,12 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)if (S_ISCHR (inode->i_mode) ||S_ISBLK (inode->i_mode)) {struct deviceSpec *dsea = (struct deviceSpec *)udf_get_extendedattr (inode,12 ,1 ); -if (dsea) { -init_special_inode (inode, inode->i_mode, + +if (!dsea || !udf_device_spec_valid (dsea)) + goto out; +init_special_inode (inode, inode->i_mode,MKDEV (le32_to_cpu (dsea->majorDeviceIdent),le32_to_cpu (dsea->minorDeviceIdent))); -/* Developer ID ??? */ - }else - goto out; } ret =0 ; out:
@@ -1811,6 +1830,10 @@ static int udf_update_inode(struct inode *inode, int do_sync)udf_add_extendedattr (inode,sizeof (struct deviceSpec ) +sizeof (struct regid ),12 ,0x3 ); +if (!dsea) { + err = -ENOSPC ; + goto out_unlock; + } dsea->attrType =cpu_to_le32 (12 ); dsea->attrSubtype =1 ; dsea->attrLength = cpu_to_le32(
@@ -1818,6 +1841,10 @@ static int udf_update_inode(struct inode *inode, int do_sync) sizeof(struct regid)); dsea->impUseLength =cpu_to_le32 (sizeof (struct regid )); } +if (!udf_device_spec_valid (dsea)) { + err = -EFSCORRUPTED ; + goto out_unlock; + } eid = (struct regid *)dsea->impUse;memset (eid,0 ,sizeof (*eid));strcpy (eid->ident,UDF_ID_DEVELOPER );
@@ -1959,6 +1986,11 @@ static int udf_update_inode(struct inode *inode, int do_sync)brelse (bh);return err; + +out_unlock: +unlock_buffer (bh); +brelse (bh); +return err; } struct inode *__udf_iget(struct super_block *sb, struct kernel_lb_addr *ino,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 508/670 hwmon: (tmp108) Fix jiffies wraparound in conversion-ready check
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Verdonck <[email protected]>
[ Upstream commit 6b8b1d1d7bc7e579b53fc7c3293b787d68de702a ]
tmp108 records a one-shot deadline in ->ready_time at probe (and resume) and, on every temperature read, refuses the read with -EAGAIN while time_before(jiffies, ready_time) is true, in order to skip the initial conversion.
->ready_time is an unsigned long compared with time_before(), whose signed difference is only meaningful while the two values are within LONG_MAX jiffies of each other. Because ->ready_time is set once and never refreshed, jiffies keeps advancing away from it, and after 2^31 jiffies the difference flips sign. On a 32-bit HZ=100 kernel that happens ~248.5 days after boot: time_before() then permanently reports "not ready" and the driver returns -EAGAIN on every read, without ever touching the sensor, until the next reboot. The continuous-mode path, which sets ->ready_time to jiffies with no added conversion delay, wraps the same way.
Store the deadline as a 64-bit jiffies value and compare it with get_jiffies_64()/time_before64(), which does not wrap in any practical uptime.
--- drivers/hwmon/tmp108.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/tmp108.c +4 -4
@@ -73,7 +73,7 @@struct tmp108 {struct regmap *regmap;u16 orig_config; -unsigned long ready_time; +u64 ready_time; };/* convert 12-bit TMP108 register value to milliCelsius */
@@ -124,7 +124,7 @@ static int tmp108_read(struct device *dev, enum hwmon_sensor_types type,switch (attr) {case hwmon_temp_input:/* Is it too early to return a conversion ? */ -if (time_before (jiffies, tmp108->ready_time)) { +if (time_before64 (get_jiffies_64 (), tmp108->ready_time)) {dev_dbg (dev,"%s: Conversion not ready yet..\n" , __func__);return -EAGAIN ;
@@ -371,7 +371,7 @@ static int tmp108_probe(struct i2c_client *client)return err; } - tmp108->ready_time = jiffies; + tmp108->ready_time =get_jiffies_64 ();if ((tmp108->orig_config &TMP108_CONF_MODE_MASK ) ==TMP108_MODE_SHUTDOWN ) tmp108->ready_time +=
@@ -405,7 +405,7 @@ static int tmp108_resume(struct device *dev) err =regmap_update_bits (tmp108->regmap,TMP108_REG_CONF ,TMP108_CONF_MODE_MASK ,TMP108_MODE_CONTINUOUS ); - tmp108->ready_time = jiffies + + tmp108->ready_time =get_jiffies_64 () +msecs_to_jiffies (TMP108_CONVERSION_TIME_MS );return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 509/670 dmaengine: qcom: bam_dma: Defer IRQ trigger type to device tree
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishnu Santhosh <[email protected]>
[ Upstream commit 3cee6f79553202d7d3954555560ac38d719344b8 ]
The driver hardcodes IRQF_TRIGGER_HIGH when registering the BAM interrupt, which overrides the trigger type specified in the device tree. On Qualcomm Shikra SoC, the A2 BAM signals an edge interrupt to the apps processor; registering it as level-high causes the interrupt to not fire, resulting in missed DMA completions.
Use IRQF_TRIGGER_NONE instead, which causes the kernel to use the trigger type already configured by platform_get_irq() when it parsed the device tree interrupts property. This makes the driver platform-agnostic.
Stable-dep-of: 82eed160cfa7 ("dmaengine: qcom: bam_dma: free interrupt before the clock in error path")
--- drivers/dma/qcom/bam_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/qcom/bam_dma.c +1 -1
@@ -1323,7 +1323,7 @@ static int bam_dma_probe(struct platform_device *pdev)bam_channel_init (bdev, &bdev->channels[i], i); ret =devm_request_irq (bdev->dev, bdev->irq, bam_dma_irq, -IRQF_TRIGGER_HIGH ,"bam_dma" , bdev); +IRQF_TRIGGER_NONE ,"bam_dma" , bdev);if (ret) goto err_bam_channel_exit;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 510/670 dmaengine: qcom: bam_dma: free interrupt before the clock in error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
[ Upstream commit 82eed160cfa7a296ae4eb5acb8dd8f493323eea7 ]
The BAM interrupt is requested with a devres helper and so on error it's freed after probe() returns. We disable the clock before freeing or masking it so it may still fire and we may end up reading BAM registers with clock disabled.
Stop using devres for interrupts as we free it in remove() manually anyway. Add an appropriate label and free the interrupt before disabling the clock in error path and in remove().
--- drivers/dma/qcom/bam_dma.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/dma/qcom/bam_dma.c +6 -4
@@ -1322,8 +1322,8 @@ static int bam_dma_probe(struct platform_device *pdev)for (i =0 ; i < bdev->num_channels; i++)bam_channel_init (bdev, &bdev->channels[i], i); - ret =devm_request_irq (bdev->dev, bdev->irq, bam_dma_irq, -IRQF_TRIGGER_NONE ,"bam_dma" , bdev); + ret =request_irq (bdev->irq, bam_dma_irq,IRQF_TRIGGER_NONE , +"bam_dma" , bdev);if (ret) goto err_bam_channel_exit;
@@ -1356,7 +1356,7 @@ static int bam_dma_probe(struct platform_device *pdev) ret =dma_async_device_register (&bdev->common);if (ret) {dev_err (bdev->dev,"failed to register dma async device\n" ); - goto err_bam_channel_exit; + goto err_free_irq; } ret = of_dma_controller_register(pdev->dev.of_node, bam_dma_xlate,
@@ -1375,6 +1375,8 @@ static int bam_dma_probe(struct platform_device *pdev) err_unregister_dma:dma_async_device_unregister (&bdev->common); +err_free_irq: +free_irq (bdev->irq, bdev); err_bam_channel_exit:for (i =0 ; i < bdev->num_channels; i++)tasklet_kill (&bdev->channels[i].vc.task);
@@ -1400,7 +1402,7 @@ static void bam_dma_remove(struct platform_device *pdev)/* mask all interrupts for this execution environment */ writel_relaxed (0 ,bam_addr (bdev,0 ,BAM_IRQ_SRCS_MSK_EE )); -devm_free_irq (bdev->dev, bdev->irq, bdev); +free_irq (bdev->irq, bdev);for (i =0 ; i < bdev->num_channels; i++) {bam_dma_terminate_all (&bdev->channels[i].vc.chan);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 511/670 nilfs2: correct return value kernel-doc descriptions for the rest
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 343d4a33f26d048fde4b02cfc3681f766b3f1b12 ]
Similar to the previous changes to fix return value descriptions, this fixes the format of the return value descriptions of functions for the rest.
Stable-dep-of: 7131aaa74bcc ("nilfs2: ignore non-fatal signals during synchronous log write wait")
--- fs/nilfs2/gcinode.c | 24 +++++++++------------- fs/nilfs2/inode.c | 12 +++-------- fs/nilfs2/recovery.c | 32 +++++++++++------------------ fs/nilfs2/segbuf.c | 12 ++--------- fs/nilfs2/segment.c | 48 ++++++++++++++++--------------------------- fs/nilfs2/the_nilfs.c | 12 +++++------ 6 files changed, 50 insertions(+), 90 deletions(-)
fs/nilfs2/gcinode.c +10 -14
@@ -46,14 +46,11 @@* specified by @pbn to the GC pagecache with the key @blkoff. * This function sets @vbn (@pbn if @vbn is zero) in b_blocknr of the buffer. * -* Return Value: On success, 0 is returned. On Error, one of the following -* negative error code is returned. -* -* %-EIO - I/O error. -* -* %-ENOMEM - Insufficient amount of memory available. -* -* %-ENOENT - The block specified with @pbn does not exist. +* Return: 0 on success, or one of the following negative error codes on +* failure: +* * %-EIO - I/O error (including metadata corruption). +* * %-ENOENT - The block specified with @pbn does not exist. +* * %-ENOMEM - Insufficient memory available. */ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff, sector_t pbn, __u64 vbn,
@@ -114,12 +111,11 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff,* specified by @vbn to the GC pagecache. @pbn can be supplied by the * caller to avoid translation of the disk block address. * -* Return Value: On success, 0 is returned. On Error, one of the following -* negative error code is returned. -* -* %-EIO - I/O error. -* -* %-ENOMEM - Insufficient amount of memory available. +* Return: 0 on success, or one of the following negative error codes on +* failure: +* * %-EIO - I/O error (including metadata corruption). +* * %-ENOENT - Invalid virtual block address. +* * %-ENOMEM - Insufficient memory available. */ int nilfs_gccache_submit_read_node (struct inode *inode,sector_t pbn,__u64 vbn,struct buffer_head **out_bh)
fs/nilfs2/inode.c +3 -9
@@ -636,10 +636,7 @@ struct inode *nilfs_iget_for_gc(struct super_block *sb, unsigned long ino,* or does nothing if the inode already has it. This function allocates * an additional inode to maintain page cache of B-tree nodes one-on-one. * -* Return Value: On success, 0 is returned. On errors, one of the following -* negative error code is returned. -* -* %-ENOMEM - Insufficient memory available. +* Return: 0 on success, or %-ENOMEM if memory is insufficient. */ int nilfs_attach_btree_node_cache (struct inode *inode) {
@@ -698,11 +695,8 @@ void nilfs_detach_btree_node_cache(struct inode *inode)* in one inode and the one for b-tree node pages is set up in the * other inode, which is attached to the former inode. * -* Return Value: On success, a pointer to the inode for data pages is -* returned. On errors, one of the following negative error code is returned -* in a pointer type. -* -* %-ENOMEM - Insufficient memory available. +* Return: a pointer to the inode for data pages on success, or %-ENOMEM +* if memory is insufficient. */ struct inode *nilfs_iget_for_shadow (struct inode *inode) {
fs/nilfs2/recovery.c +12 -20
@@ -757,18 +757,13 @@ static void nilfs_abort_roll_forward(struct the_nilfs *nilfs)* @sb: super block instance * @ri: pointer to a nilfs_recovery_info struct to store search results. * -* Return Value: On success, 0 is returned. On error, one of the following -* negative error code is returned. -* -* %-EINVAL - Inconsistent filesystem state. -* -* %-EIO - I/O error -* -* %-ENOSPC - No space left on device (only in a panic state). -* -* %-ERESTARTSYS - Interrupted. -* -* %-ENOMEM - Insufficient memory available. +* Return: 0 on success, or one of the following negative error codes on +* failure: +* * %-EINVAL - Inconsistent filesystem state. +* * %-EIO - I/O error. +* * %-ENOMEM - Insufficient memory available. +* * %-ENOSPC - No space left on device (only in a panic state). +* * %-ERESTARTSYS - Interrupted. */ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs, struct super_block *sb,
@@ -833,14 +828,11 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,* segment pointed by the superblock. It sets up struct the_nilfs through * this search. It fills nilfs_recovery_info (ri) required for recovery. * -* Return Value: On success, 0 is returned. On error, one of the following -* negative error code is returned. -* -* %-EINVAL - No valid segment found -* -* %-EIO - I/O error -* -* %-ENOMEM - Insufficient memory available. +* Return: 0 on success, or one of the following negative error codes on +* failure: +* * %-EINVAL - No valid segment found. +* * %-EIO - I/O error. +* * %-ENOMEM - Insufficient memory available. */ int nilfs_search_super_root (struct the_nilfs *nilfs,struct nilfs_recovery_info *ri)
fs/nilfs2/segbuf.c +2 -10
@@ -403,12 +403,7 @@ static int nilfs_segbuf_submit_bh(struct nilfs_segment_buffer *segbuf,* @segbuf: buffer storing a log to be written * @nilfs: nilfs object * -* Return Value: On Success, 0 is returned. On Error, one of the following -* negative error code is returned. -* -* %-EIO - I/O error -* -* %-ENOMEM - Insufficient memory available. +* Return: Always 0. */ static int nilfs_segbuf_write (struct nilfs_segment_buffer *segbuf,struct the_nilfs *nilfs)
@@ -449,10 +444,7 @@ static int nilfs_segbuf_write(struct nilfs_segment_buffer *segbuf,* nilfs_segbuf_wait - wait for completion of requested BIOs * @segbuf: segment buffer * -* Return Value: On Success, 0 is returned. On Error, one of the following -* negative error code is returned. -* -* %-EIO - I/O error +* Return: 0 on success, or %-EIO if I/O error is detected. */ static int nilfs_segbuf_wait (struct nilfs_segment_buffer *segbuf) {
fs/nilfs2/segment.c +18 -30
66 lines not on this page · raw message
fs/nilfs2/the_nilfs.c +5 -7
@@ -49,8 +49,8 @@ void nilfs_set_last_segment(struct the_nilfs *nilfs,* alloc_nilfs - allocate a nilfs object * @sb: super block instance * -* Return Value: On success, pointer to the_nilfs is returned. -* On error, NULL is returned. +* Return: a pointer to the allocated nilfs object on success, or NULL on +* failure. */ struct the_nilfs *alloc_nilfs (struct super_block *sb) {
@@ -200,8 +200,7 @@ static int nilfs_store_log_cursor(struct the_nilfs *nilfs,* exponent information written in @sbp and stores it in @blocksize, * or aborts with an error message if it's too large. * -* Return Value: On success, 0 is returned. If the block size is too -* large, -EINVAL is returned. +* Return: 0 on success, or %-EINVAL if the block size is too large. */ static int nilfs_get_blocksize (struct super_block *sb,struct nilfs_super_block *sbp,int *blocksize)
@@ -544,7 +543,7 @@ static int nilfs_valid_sb(struct nilfs_super_block *sbp)* area, or if the parameters themselves are not normal, it is * determined to be invalid. * -* Return Value: true if invalid, false if valid. +* Return: true if invalid, false if valid. */ static bool nilfs_sb2_bad_offset (struct nilfs_super_block *sbp,u64 offset) {
@@ -690,8 +689,7 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs,* reading the super block, getting disk layout information, initializing * shared fields in the_nilfs). * -* Return Value: On success, 0 is returned. On error, a negative error -* code is returned. +* Return: 0 on success, or a negative error code on failure. */ int init_nilfs (struct the_nilfs *nilfs,struct super_block *sb) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 512/670 nilfs2: ignore non-fatal signals during synchronous log write wait
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 7131aaa74bcc7c9da1f1d1c8724da75c775557a0 ]
Based on a syzbot report, Wang Jianjian pointed out that following a successful directory operation in nilfs_rename(), a synchronous write requested within nilfs_transaction_commit(), triggered by a sync flag set by nilfs_commit_chunk(), could be interrupted by a user signal. This interruption leaves in-memory metadata updates intact while returning an error, causing inconsistency with the VFS dentry cache and ultimately triggering a kernel warning.
According to "signal(7)", local disks are not classified as "slow devices" (such as terminals, FIFOs, or pipes) and their I/O operations on disk devices are not interrupted by signals. In kernel space, waiting for such disk I/O should therefore not be aborted by ordinary (non-fatal) signals.
Suppress this issue by modifying nilfs_segctor_sync(), which waits for the log writer thread to complete synchronous writes, to catch only fatal signals via fatal_signal_pending() and return -EINTR rather than -ERESTARTSYS. To complement this change and prevent the wait loop from busy-looping when schedule() returns immediately due to a pending non-fatal signal, switch the wait state from TASK_INTERRUPTIBLE to TASK_KILLABLE.
This serves as an effective interim stabilization measure without structural changes until a comprehensive fix for metadata consistency is implemented.
--- fs/nilfs2/ioctl.c | 2 +- fs/nilfs2/recovery.c | 2 +- fs/nilfs2/segment.c | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-)
fs/nilfs2/ioctl.c +1 -1
@@ -972,10 +972,10 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,* Return: 0 on success, or one of the following negative error codes on * failure: * * %-EFAULT - Failure during execution of requested operation. +* * %-EINTR - Interrupted. * * %-EIO - I/O error. * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. * * %-EROFS - Read only filesystem. */ static int nilfs_ioctl_sync(struct inode *inode, struct file *filp,
fs/nilfs2/recovery.c +1 -1
@@ -759,11 +759,11 @@ static void nilfs_abort_roll_forward(struct the_nilfs *nilfs)* * Return: 0 on success, or one of the following negative error codes on * failure: +* * %-EINTR - Interrupted. * * %-EINVAL - Inconsistent filesystem state. * * %-EIO - I/O error. * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. */ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs, struct super_block *sb,
fs/nilfs2/segment.c +5 -5
@@ -2264,7 +2264,7 @@ static int nilfs_segctor_sync(struct nilfs_sc_info *sci)wake_up (&sci->sc_wait_daemon);for (;;) { -set_current_state (TASK_INTERRUPTIBLE ); +set_current_state (TASK_KILLABLE );/* * Synchronize only while the log writer thread is alive.
@@ -2278,11 +2278,11 @@ static int nilfs_segctor_sync(struct nilfs_sc_info *sci) err = wait_req.err;break ; } -if (!signal_pending (current)) { +if (!fatal_signal_pending (current)) {schedule ();continue ; } - err = -ERESTARTSYS ; + err = -EINTR ;break ; }finish_wait (&sci->sc_wait_request, &wait_req.wq);
@@ -2316,10 +2316,10 @@ static void nilfs_segctor_wakeup(struct nilfs_sc_info *sci, int err, bool force)* * Return: 0 on success, or one of the following negative error codes on * failure: +* * %-EINTR - Interrupted. * * %-EIO - I/O error (including metadata corruption). * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. * * %-EROFS - Read only filesystem. */ int nilfs_construct_segment (struct super_block *sb)
@@ -2346,10 +2346,10 @@ int nilfs_construct_segment(struct super_block *sb)* * Return: 0 on success, or one of the following negative error codes on * failure: +* * %-EINTR - Interrupted. * * %-EIO - I/O error (including metadata corruption). * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. * * %-EROFS - Read only filesystem. */ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 513/670 media: chips-media: wave5: Handle polling IRQ thread failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 1d563e3d718a1c7c16355843374fbdd4c798ac66 ]
When falling back to polling mode, wave5_vpu_probe() does not check the return value of kthread_run(). On failure, dev->irq_thread holds an error pointer instead of a valid task pointer.
Both the probe error path and the remove path only check dev->irq_thread against NULL before calling kthread_stop() on it, so an error pointer passes the check and kthread_stop() crashes on it.
Check the kthread_run() result, clear dev->irq_thread and unwind the probe on failure.
--- drivers/media/platform/chips-media/wave5/wave5-vpu.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/media/platform/chips-media/wave5/wave5-vpu.c +7 -0
@@ -300,6 +300,13 @@ static int wave5_vpu_probe(struct platform_device *pdev)dev_err (&pdev->dev,"failed to get irq resource, falling back to polling\n" );sema_init (&dev->irq_sem,1 ); dev->irq_thread =kthread_run (irq_thread, dev,"irq thread" ); +if (IS_ERR (dev->irq_thread)) { + ret =PTR_ERR (dev->irq_thread); +dev_err (&pdev->dev,"failed to create irq thread\n" ); + dev->irq_thread =NULL ; + goto err_vdi_release; + } +hrtimer_init (&dev->hrtimer,CLOCK_MONOTONIC ,HRTIMER_MODE_REL_PINNED ); dev->hrtimer.function = &wave5_vpu_timer_callback; dev->worker =kthread_create_worker (0 ,"vpu_irq_thread" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 514/670 ASoC: stm: stm32_i2s: Drop redundant error messages
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit a6cdfb6230944082e7be64f9166eed64656b1162 ]
Both devm_request_irq() and snd_dmaengine_pcm_register() already log failures internally. Drop the redundant error messages and return the original errors directly.
Stable-dep-of: 1b207c85551f ("ASoC: stm: stm32_i2s: request IRQ after regmap initialization")
--- sound/soc/stm/stm32_i2s.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/stm/stm32_i2s.c +2 -4
@@ -1076,10 +1076,8 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev, ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,0 ,dev_name (&pdev->dev), i2s); -if (ret) { -dev_err (&pdev->dev,"irq request returned %d\n" , ret); +if (ret)return ret; - }/* Reset */ rst =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL );
@@ -1133,7 +1131,7 @@ static int stm32_i2s_probe(struct platform_device *pdev) ret =snd_dmaengine_pcm_register (&pdev->dev, &stm32_i2s_pcm_config,0 );if (ret) -return dev_err_probe (&pdev->dev, ret,"PCM DMA register error\n" ); +return ret; ret =snd_soc_register_component (&pdev->dev, &stm32_i2s_component, i2s->dai_drv,1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 515/670 ASoC: stm: stm32_i2s: request IRQ after regmap initialization
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 1b207c85551fd74854d632116849295b2305245f ]
The ISR accesses the managed regmap, but probe requests the IRQ before creating it. An early interrupt can reach an uninitialized regmap. Reverse-order cleanup can free the regmap while the IRQ remains active.
Request the IRQ after regmap initialization so probe unwind and removal free and synchronize it before releasing the regmap.
The teardown ordering issue was found by static analysis.
--- sound/soc/stm/stm32_i2s.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
sound/soc/stm/stm32_i2s.c +11 -12
@@ -1026,7 +1026,7 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev,struct device_node *np = pdev->dev.of_node;struct reset_control *rst;struct resource *res; -int irq, ret; +int ret;if (!np)return -ENODEV ;
@@ -1069,16 +1069,6 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev,return ret; } -/* Get irqs */ - irq =platform_get_irq (pdev,0 ); -if (irq <0 ) -return irq; - - ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,0 , -dev_name (&pdev->dev), i2s); -if (ret) -return ret; -/* Reset */ rst =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL );if (IS_ERR (rst))
@@ -1103,7 +1093,7 @@ static int stm32_i2s_probe(struct platform_device *pdev) {struct stm32_i2s_data *i2s;u32 val; -int ret; +int irq, ret; i2s =devm_kzalloc (&pdev->dev,sizeof (*i2s),GFP_KERNEL );if (!i2s)
@@ -1129,6 +1119,15 @@ static int stm32_i2s_probe(struct platform_device *pdev)return dev_err_probe (&pdev->dev,PTR_ERR (i2s->regmap),"Regmap init error\n" ); + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) +return irq; + + ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,0 , +dev_name (&pdev->dev), i2s); +if (ret) +return ret; + ret =snd_dmaengine_pcm_register (&pdev->dev, &stm32_i2s_pcm_config,0 );if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 516/670 iio: dac: mcp4821: reject devices without match data
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 6ac1faf4de61dcf27ffe8f2c25d96fe5f4b2886d ]
A device bound through driver_override need not match an entry in the driver tables. In that case spi_get_device_match_data() returns NULL, but mcp4821_probe() dereferences the result while configuring the IIO device.
Reject devices without match data before using the chip information.
--- drivers/iio/dac/mcp4821.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/iio/dac/mcp4821.c +5 -2
@@ -172,9 +172,13 @@ static const struct iio_info mcp4821_info = {static int mcp4821_probe (struct spi_device *spi) { +const struct mcp4821_chip_info *info;struct iio_dev *indio_dev;struct mcp4821_state *state; -const struct mcp4821_chip_info *info; + + info =spi_get_device_match_data (spi); +if (!info) +return -ENODATA ; indio_dev =devm_iio_device_alloc (&spi->dev,sizeof (*state));if (indio_dev ==NULL )
@@ -183,7 +187,6 @@ static int mcp4821_probe(struct spi_device *spi) state =iio_priv (indio_dev); state->spi = spi; - info =spi_get_device_match_data (spi); indio_dev->name = info->name; indio_dev->info = &mcp4821_info; indio_dev->modes =INDIO_DIRECT_MODE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 517/670 drm/msm/dsi: Fix VM leak in dsi_tx_buf_alloc_6g()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit ab91ba61871a896ca2ecc6e048d80a152136da44 ]
dsi_tx_buf_alloc_6g() takes a reference to the kms VM with drm_gpuvm_get() and stores it in msm_host->vm. If msm_gem_kernel_new() fails, the function returns early without dropping that reference. Since msm_host->tx_gem_obj is cleared on the error path, msm_dsi_tx_buf_free() will never see a non-NULL tx_gem_obj and thus never calls drm_gpuvm_put(), leaking the VM reference.
Drop the VM reference and clear msm_host->vm on the error path.
Patchwork: https://patchwork.freedesktop.org/patch/754332/
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/dsi/dsi_host.c +2 -0
@@ -1205,6 +1205,8 @@ int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size)if (IS_ERR (data)) { msm_host->tx_gem_obj =NULL ; +msm_gem_address_space_put (msm_host->aspace); + msm_host->aspace =NULL ;return PTR_ERR (data); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 518/670 KVM: arm64: Fix MMFR0 TGRAN advertisement for pVMs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <[email protected]>
[ Upstream commit 6c29285e78b5e4811145ebda382ac0ba732ce56a ]
Protected VM ID register emulation leaves unlisted fields at 0. This creates two issues for TGRAN:
* TGRAN16: 0 means non-implemented. It prevents 16KB protected VMs from booting even when the hardware supports it.
* TGRAN4|TGRAN64: 0 means implemented. This may falsely advertise the feature even when the hardware does not support it.
Advertise all the TGRAN fields in pvmid_aa64mmfr0 so that the hardware support is properly propagated.
--- arch/arm64/kvm/hyp/include/nvhe/fixed_config.h | 3 ++- arch/arm64/kvm/hyp/nvhe/sys_regs.c | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/include/nvhe/fixed_config.h +2 -1
@@ -92,7 +92,8 @@*/ #define PVM_ID_AA64MMFR0_RESTRICT_UNSIGNED (\ FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64MMFR0_EL1_PARANGE), ID_AA64MMFR0_EL1_PARANGE_40) | \ - FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64MMFR0_EL1_ASIDBITS), ID_AA64MMFR0_EL1_ASIDBITS_16) \ + FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64MMFR0_EL1_ASIDBITS), ID_AA64MMFR0_EL1_ASIDBITS_16) | \ + SYS_FIELD_PREP_ENUM(ID_AA64MMFR0_EL1, TGRAN16, IMP) \ )/*
arch/arm64/kvm/hyp/nvhe/sys_regs.c +9 -0
@@ -191,6 +191,15 @@ static u64 get_pvm_id_aa64mmfr0(const struct kvm_vcpu *vcpu) set_mask =get_restricted_features_unsigned (id_aa64mmfr0_el1_sys_val,PVM_ID_AA64MMFR0_RESTRICT_UNSIGNED ); + set_mask |=SYS_FIELD_PREP (ID_AA64MMFR0_EL1 ,TGRAN4 , +min_t (int,cpuid_feature_extract_signed_field (id_aa64mmfr0_el1_sys_val, +ID_AA64MMFR0_EL1_TGRAN4_SHIFT ), +ID_AA64MMFR0_EL1_TGRAN4_IMP )); + set_mask |=SYS_FIELD_PREP (ID_AA64MMFR0_EL1 ,TGRAN64 , +min_t (int,cpuid_feature_extract_signed_field (id_aa64mmfr0_el1_sys_val, +ID_AA64MMFR0_EL1_TGRAN64_SHIFT ), +ID_AA64MMFR0_EL1_TGRAN64_IMP )); +return (id_aa64mmfr0_el1_sys_val &PVM_ID_AA64MMFR0_ALLOW ) | set_mask; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 519/670 ata: libata-eh: Rename and make ata_set_mode() static
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit 6ba4d05c1425fe220d95395b4485443ce895bb95 ]
The function ata_set_mode() is defined and used only in libata-eh.c. Make this function static and rename it ata_eh_set_mode() to make it clear where its definition is.
No functional changes.
Stable-dep-of: 96fdeb7e3fd8 ("ata: sata_inic162x: remove dangerous broken driver")
--- drivers/ata/libata-eh.c | 9 +++++---- drivers/ata/libata.h | 1 - 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/ata/libata-eh.c +5 -4
@@ -3248,12 +3248,12 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link, }/** -* ata_set_mode - Program timings and issue SET FEATURES - XFER +* ata_eh_set_mode - Program timings and issue SET FEATURES - XFER * @link: link on which timings will be programmed * @r_failed_dev: out parameter for failed device * * Set ATA device disk transfer mode (PIO3, UDMA6, etc.). If -* ata_set_mode() fails, pointer to the failing device is +* ata_eh_set_mode() fails, pointer to the failing device is * returned in @r_failed_dev. * * LOCKING:
@@ -3262,7 +3262,8 @@ static int ata_eh_revalidate_and_attach(struct ata_link *link,* RETURNS: * 0 on success, negative errno otherwise */ -int ata_set_mode (struct ata_link *link,struct ata_device **r_failed_dev) +static int ata_eh_set_mode (struct ata_link *link, +struct ata_device **r_failed_dev) {struct ata_port *ap = link->ap;struct ata_device *dev;
@@ -3900,7 +3901,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,/* configure transfer mode if necessary */ if (ehc->i.flags &ATA_EHI_SETMODE ) { - rc =ata_set_mode (link, &dev); + rc =ata_eh_set_mode (link, &dev);if (rc) goto rest_fail; ehc->i.flags &= ~ATA_EHI_SETMODE ;
drivers/ata/libata.h +0 -1
@@ -199,7 +199,6 @@ extern void ata_eh_report(struct ata_port *ap);extern int ata_eh_reset (struct ata_link *link,int classify,ata_prereset_fn_t prereset,ata_reset_fn_t softreset,ata_reset_fn_t hardreset,ata_postreset_fn_t postreset); -extern int ata_set_mode (struct ata_link *link,struct ata_device **r_failed_dev); extern int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset, ata_reset_fn_t softreset, ata_reset_fn_t hardreset, ata_postreset_fn_t postreset,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 520/670 ata: libata-eh: Remove ata_do_eh()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit df6f9a918ea856fc288b9001b0414c5be136d7d0 ]
The only reason for ata_do_eh() to exist is that the two caller sites, ata_std_error_handler() and ata_sff_error_handler() may pass it a NULL hardreset operation so that the built-in (generic) hardreset operation for a driver is ignored if the adapter SCR access is not available.
However, ata_std_error_handler() and ata_sff_error_handler() modifications of the hardreset port operation can easily be combined as they are mutually exclusive. That is, a driver using sata_std_hardreset() as its hardreset operation cannot use sata_sff_hardreset() and vice-versa.
With this observation, ata_do_eh() can be removed and its code moved to ata_std_error_handler(). The condition used to ignore the built-in hardreset port operation is modified to be the one that was used in ata_sff_error_handler(). This requires defining a stub for the function sata_sff_hardreset() to avoid compilation errors when CONFIG_ATA_SFF is not enabled. Furthermore, instead of modifying the local hardreset operation definition, set the ATA_LFLAG_NO_HRST link flag to prevent the use of built-in hardreset methods for ports without a valid scr_read function. This flag is checked in ata_eh_reset() and if set, the hardreset method is ignored.
This change simplifies ata_sff_error_handler() as this function now only needs to call ata_std_error_handler().
No functional changes.
Stable-dep-of: 96fdeb7e3fd8 ("ata: sata_inic162x: remove dangerous broken driver")
--- drivers/ata/libata-eh.c | 48 ++++++++++++---------------------------- drivers/ata/libata-sff.c | 10 +-------- include/linux/libata.h | 9 +++++--- 3 files changed, 21 insertions(+), 46 deletions(-)
drivers/ata/libata-eh.c +14 -34
@@ -4040,59 +4040,39 @@ void ata_eh_finish(struct ata_port *ap) }/** -* ata_do_eh - do standard error handling +* ata_std_error_handler - standard error handler * @ap: host port to handle error for * -* @prereset: prereset method (can be NULL) -* @softreset: softreset method (can be NULL) -* @hardreset: hardreset method (can be NULL) -* @postreset: postreset method (can be NULL) -* * Perform standard error handling sequence. * * LOCKING: * Kernel thread context (may sleep). */ -void ata_do_eh (struct ata_port *ap,ata_prereset_fn_t prereset, -ata_reset_fn_t softreset,ata_reset_fn_t hardreset, -ata_postreset_fn_t postreset) +void ata_std_error_handler (struct ata_port *ap) { -struct ata_device *dev; +struct ata_port_operations *ops = ap->ops; +struct ata_link *link = &ap->link;int rc; +/* Ignore built-in hardresets if SCR access is not available */ +if ((ops->hardreset == sata_std_hardreset || + ops->hardreset == sata_sff_hardreset) && !sata_scr_valid (link)) + link->flags |=ATA_LFLAG_NO_HRST ; +ata_eh_autopsy (ap);ata_eh_report (ap); - rc =ata_eh_recover (ap, prereset, softreset, hardreset, postreset, -NULL ); + rc =ata_eh_recover (ap, ops->prereset, ops->softreset, + ops->hardreset, ops->postreset,NULL );if (rc) { -ata_for_each_dev (dev, &ap->link,ALL ) +struct ata_device *dev; + +ata_for_each_dev (dev, link,ALL )ata_dev_disable (dev); }ata_eh_finish (ap); } - -/** -* ata_std_error_handler - standard error handler -* @ap: host port to handle error for -* -* Standard error handler -* -* LOCKING: -* Kernel thread context (may sleep). -*/ -void ata_std_error_handler (struct ata_port *ap) -{ -struct ata_port_operations *ops = ap->ops; -ata_reset_fn_t hardreset = ops->hardreset; - -/* ignore built-in hardreset if SCR access is not available */ -if (hardreset == sata_std_hardreset && !sata_scr_valid (&ap->link)) - hardreset =NULL ; - -ata_do_eh (ap, ops->prereset, ops->softreset, hardreset, ops->postreset); -}EXPORT_SYMBOL_GPL (ata_std_error_handler);#ifdef CONFIG_PM
drivers/ata/libata-sff.c +1 -9
@@ -2054,8 +2054,6 @@ EXPORT_SYMBOL_GPL(ata_sff_drain_fifo);*/ void ata_sff_error_handler (struct ata_port *ap) { -ata_reset_fn_t softreset = ap->ops->softreset; -ata_reset_fn_t hardreset = ap->ops->hardreset;struct ata_queued_cmd *qc;unsigned long flags;
@@ -2077,13 +2075,7 @@ void ata_sff_error_handler(struct ata_port *ap)spin_unlock_irqrestore (ap->lock, flags); -/* ignore built-in hardresets if SCR access is not available */ -if ((hardreset == sata_std_hardreset || - hardreset == sata_sff_hardreset) && !sata_scr_valid (&ap->link)) - hardreset =NULL ; - -ata_do_eh (ap, ap->ops->prereset, softreset, hardreset, - ap->ops->postreset); +ata_std_error_handler (ap); }EXPORT_SYMBOL_GPL (ata_sff_error_handler);
include/linux/libata.h +6 -3
@@ -1418,9 +1418,6 @@ extern void ata_eh_thaw_port(struct ata_port *ap);extern void ata_eh_qc_complete (struct ata_queued_cmd *qc);extern void ata_eh_qc_retry (struct ata_queued_cmd *qc); -extern void ata_do_eh (struct ata_port *ap,ata_prereset_fn_t prereset, -ata_reset_fn_t softreset,ata_reset_fn_t hardreset, -ata_postreset_fn_t postreset);extern void ata_std_error_handler (struct ata_port *ap);extern void ata_std_sched_eh (struct ata_port *ap);extern void ata_std_end_eh (struct ata_port *ap);
@@ -2153,6 +2150,12 @@ static inline u8 ata_wait_idle(struct ata_port *ap)return status; } +#else /* CONFIG_ATA_SFF */ +static inline int sata_sff_hardreset (struct ata_link *link,unsigned int *class, +unsigned long deadline) +{ +return -EOPNOTSUPP ; +}#endif /* CONFIG_ATA_SFF */ #endif /* __LINUX_LIBATA_H__ */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 521/670 ata: libata-eh: Simplify reset operation management
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
[ Upstream commit a4daf088a77323154514eb1f8626bbdf9329cfd4 ]
Introduce struct ata_reset_operations to aggregate in a single structure the definitions of the 4 reset methods (prereset, softreset, hardreset and postreset) for a port. This new structure is used in struct ata_port to define the reset methods for a regular port (reset field) and for a port-multiplier port (pmp_reset field). A pointer to either of these fields replaces the 4 reset method arguments passed to ata_eh_recover() and ata_eh_reset().
The definition of the reset methods for all drivers is changed to use the reset and pmp_reset fields in struct ata_port_operations.
A large number of files is modifed, but no functional changes are introduced.
Stable-dep-of: 96fdeb7e3fd8 ("ata: sata_inic162x: remove dangerous broken driver")
--- drivers/ata/ahci.c | 6 ++--- drivers/ata/ahci_da850.c | 6 ++--- drivers/ata/ahci_dm816.c | 2 +- drivers/ata/ahci_imx.c | 13 ++++++----- drivers/ata/ahci_qoriq.c | 4 ++-- drivers/ata/ahci_xgene.c | 8 +++---- drivers/ata/ata_piix.c | 4 ++-- drivers/ata/libahci.c | 10 ++++----- drivers/ata/libata-core.c | 4 ++-- drivers/ata/libata-eh.c | 29 +++++++++++-------------- drivers/ata/libata-pmp.c | 26 ++++++++-------------- drivers/ata/libata-sata.c | 2 +- drivers/ata/libata-sff.c | 8 +++---- drivers/ata/libata.h | 8 +++---- drivers/ata/pata_acpi.c | 2 +- drivers/ata/pata_ali.c | 10 ++++----- drivers/ata/pata_amd.c | 4 ++-- drivers/ata/pata_artop.c | 4 ++-- drivers/ata/pata_atiixp.c | 2 +- drivers/ata/pata_efar.c | 2 +- drivers/ata/pata_ep93xx.c | 4 ++-- drivers/ata/pata_hpt366.c | 2 +- drivers/ata/pata_hpt37x.c | 4 ++-- drivers/ata/pata_hpt3x2n.c | 2 +- drivers/ata/pata_icside.c | 2 +- drivers/ata/pata_it8213.c | 2 +- drivers/ata/pata_jmicron.c | 2 +- drivers/ata/pata_marvell.c | 2 +- drivers/ata/pata_mpiix.c | 2 +- drivers/ata/pata_ns87410.c | 2 +- drivers/ata/pata_octeon_cf.c | 2 +- drivers/ata/pata_oldpiix.c | 2 +- drivers/ata/pata_opti.c | 2 +- drivers/ata/pata_optidma.c | 2 +- drivers/ata/pata_parport/pata_parport.c | 4 ++-- drivers/ata/pata_pdc2027x.c | 2 +- drivers/ata/pata_rdc.c | 2 +- drivers/ata/pata_sis.c | 2 +- drivers/ata/pata_sl82c105.c | 2 +- drivers/ata/pata_triflex.c | 2 +- drivers/ata/pata_via.c | 2 +- drivers/ata/pdc_adma.c | 2 +- drivers/ata/sata_dwc_460ex.c | 2 +- drivers/ata/sata_fsl.c | 6 ++--- drivers/ata/sata_highbank.c | 2 +- drivers/ata/sata_inic162x.c | 2 +- drivers/ata/sata_mv.c | 10 ++++----- drivers/ata/sata_nv.c | 2 +- drivers/ata/sata_promise.c | 4 ++-- drivers/ata/sata_qstor.c | 4 ++-- drivers/ata/sata_rcar.c | 2 +- drivers/ata/sata_sil24.c | 8 +++---- drivers/ata/sata_svw.c | 4 ++-- drivers/ata/sata_sx4.c | 2 +- drivers/ata/sata_uli.c | 2 +- drivers/ata/sata_via.c | 4 ++-- drivers/scsi/libsas/sas_ata.c | 4 ++-- include/linux/libata.h | 17 ++++++++------- 58 files changed, 134 insertions(+), 145 deletions(-)
drivers/ata/ahci.c +3 -3
@@ -111,17 +111,17 @@ static const struct scsi_host_template ahci_sht = {static struct ata_port_operations ahci_vt8251_ops = { .inherits = &ahci_ops, - .hardreset = ahci_vt8251_hardreset, + .reset.hardreset = ahci_vt8251_hardreset, };static struct ata_port_operations ahci_p5wdh_ops = { .inherits = &ahci_ops, - .hardreset = ahci_p5wdh_hardreset, + .reset.hardreset = ahci_p5wdh_hardreset, };static struct ata_port_operations ahci_avn_ops = { .inherits = &ahci_ops, - .hardreset = ahci_avn_hardreset, + .reset.hardreset = ahci_avn_hardreset, };static const struct ata_port_info ahci_port_info[] = {
drivers/ata/ahci_da850.c +3 -3
@@ -137,13 +137,13 @@ static int ahci_da850_hardreset(struct ata_link *link,static struct ata_port_operations ahci_da850_port_ops = { .inherits = &ahci_platform_ops, - .softreset = ahci_da850_softreset, + .reset.softreset = ahci_da850_softreset,/* * No need to override .pmp_softreset - it's only used for actual * PMP-enabled ports. */ - .hardreset = ahci_da850_hardreset, - .pmp_hardreset = ahci_da850_hardreset, + .reset.hardreset = ahci_da850_hardreset, + .pmp_reset.hardreset = ahci_da850_hardreset, };static const struct ata_port_info ahci_da850_port_info = {
drivers/ata/ahci_dm816.c +1 -1
@@ -124,7 +124,7 @@ static int ahci_dm816_softreset(struct ata_link *link,static struct ata_port_operations ahci_dm816_port_ops = { .inherits = &ahci_platform_ops, - .softreset = ahci_dm816_softreset, + .reset.softreset = ahci_dm816_softreset, };static const struct ata_port_info ahci_dm816_port_info = {
drivers/ata/ahci_imx.c +7 -6
@@ -642,18 +642,19 @@ static int ahci_imx_softreset(struct ata_link *link, unsigned int *class,int ret;if (imxpriv->type ==AHCI_IMX53 ) - ret = ahci_pmp_retry_srst_ops.softreset (link, class, deadline); + ret = ahci_pmp_retry_srst_ops.reset.softreset (link, class, + deadline);else - ret = ahci_ops.softreset (link, class, deadline); + ret = ahci_ops.reset.softreset (link, class, deadline);return ret; }static struct ata_port_operations ahci_imx_ops = { - .inherits = &ahci_ops, - .host_stop = ahci_imx_host_stop, - .error_handler = ahci_imx_error_handler, - .softreset = ahci_imx_softreset, + .inherits = &ahci_ops, + .host_stop = ahci_imx_host_stop, + .error_handler = ahci_imx_error_handler, + .reset.softreset = ahci_imx_softreset, };static const struct ata_port_info ahci_imx_port_info = {
drivers/ata/ahci_qoriq.c +2 -2
@@ -146,8 +146,8 @@ static int ahci_qoriq_hardreset(struct ata_link *link, unsigned int *class, }static struct ata_port_operations ahci_qoriq_ops = { - .inherits = &ahci_ops, - .hardreset = ahci_qoriq_hardreset, + .inherits = &ahci_ops, + .reset.hardreset = ahci_qoriq_hardreset, };static const struct ata_port_info ahci_qoriq_port_info = {
drivers/ata/ahci_xgene.c +4 -4
@@ -613,11 +613,11 @@ static irqreturn_t xgene_ahci_irq_intr(int irq, void *dev_instance)static struct ata_port_operations xgene_ahci_v1_ops = { .inherits = &ahci_ops, .host_stop = xgene_ahci_host_stop, - .hardreset = xgene_ahci_hardreset, + .reset.hardreset = xgene_ahci_hardreset, + .reset.softreset = xgene_ahci_softreset, + .pmp_reset.softreset = xgene_ahci_pmp_softreset, .read_id = xgene_ahci_read_id, .qc_issue = xgene_ahci_qc_issue, - .softreset = xgene_ahci_softreset, - .pmp_softreset = xgene_ahci_pmp_softreset };static const struct ata_port_info xgene_ahci_v1_port_info = {
@@ -630,7 +630,7 @@ static const struct ata_port_info xgene_ahci_v1_port_info = {static struct ata_port_operations xgene_ahci_v2_ops = { .inherits = &ahci_ops, .host_stop = xgene_ahci_host_stop, - .hardreset = xgene_ahci_hardreset, + .reset.hardreset = xgene_ahci_hardreset, .read_id = xgene_ahci_read_id, };
drivers/ata/ata_piix.c +2 -2
@@ -1074,7 +1074,7 @@ static struct ata_port_operations piix_pata_ops = { .cable_detect = ata_cable_40wire, .set_piomode = piix_set_piomode, .set_dmamode = piix_set_dmamode, - .prereset = piix_pata_prereset, + .reset.prereset = piix_pata_prereset, };static struct ata_port_operations piix_vmw_ops = {
@@ -1103,7 +1103,7 @@ static const struct scsi_host_template piix_sidpr_sht = {static struct ata_port_operations piix_sidpr_sata_ops = { .inherits = &piix_sata_ops, - .hardreset = sata_std_hardreset, + .reset.hardreset = sata_std_hardreset, .scr_read = piix_sidpr_scr_read, .scr_write = piix_sidpr_scr_write, .set_lpm = piix_sidpr_set_lpm,
drivers/ata/libahci.c +5 -5
@@ -163,10 +163,10 @@ struct ata_port_operations ahci_ops = { .freeze = ahci_freeze, .thaw = ahci_thaw, - .softreset = ahci_softreset, - .hardreset = ahci_hardreset, - .postreset = ahci_postreset, - .pmp_softreset = ahci_softreset, + .reset.softreset = ahci_softreset, + .reset.hardreset = ahci_hardreset, + .reset.postreset = ahci_postreset, + .pmp_reset.softreset = ahci_softreset, .error_handler = ahci_error_handler, .post_internal_cmd = ahci_post_internal_cmd, .dev_config = ahci_dev_config,
@@ -193,7 +193,7 @@ EXPORT_SYMBOL_GPL(ahci_ops);struct ata_port_operations ahci_pmp_retry_srst_ops = { .inherits = &ahci_ops, - .softreset = ahci_pmp_retry_softreset, + .reset.softreset = ahci_pmp_retry_softreset, };EXPORT_SYMBOL_GPL (ahci_pmp_retry_srst_ops);
drivers/ata/libata-core.c +2 -2
@@ -65,8 +65,8 @@#include "libata-transport.h" const struct ata_port_operations ata_base_port_ops = { - .prereset = ata_std_prereset, - .postreset = ata_std_postreset, + .reset.prereset = ata_std_prereset, + .reset.postreset = ata_std_postreset, .error_handler = ata_std_error_handler, .sched_eh = ata_std_sched_eh, .end_eh = ata_std_end_eh,
drivers/ata/libata-eh.c +13 -16
@@ -2633,13 +2633,16 @@ static int ata_eh_followup_srst_needed(struct ata_link *link, int rc) }int ata_eh_reset (struct ata_link *link,int classify, -ata_prereset_fn_t prereset,ata_reset_fn_t softreset, -ata_reset_fn_t hardreset,ata_postreset_fn_t postreset) +struct ata_reset_operations *reset_ops) {struct ata_port *ap = link->ap;struct ata_link *slave = ap->slave_link;struct ata_eh_context *ehc = &link->eh_context;struct ata_eh_context *sehc = slave ? &slave->eh_context :NULL ; +ata_reset_fn_t hardreset = reset_ops->hardreset; +ata_reset_fn_t softreset = reset_ops->softreset; +ata_prereset_fn_t prereset = reset_ops->prereset; +ata_postreset_fn_t postreset = reset_ops->postreset;unsigned int *classes = ehc->classes;unsigned int lflags = link->flags;int verbose = !(ehc->i.flags &ATA_EHI_QUIET );
@@ -3730,10 +3733,7 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)/** * ata_eh_recover - recover host port after error * @ap: host port to recover -* @prereset: prereset method (can be NULL) -* @softreset: softreset method (can be NULL) -* @hardreset: hardreset method (can be NULL) -* @postreset: postreset method (can be NULL) +* @reset_ops: The set of reset operations to use * @r_failed_link: out parameter for failed link * * This is the alpha and omega, eum and yang, heart and soul of
@@ -3749,9 +3749,7 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)* RETURNS: * 0 on success, -errno on failure. */ -int ata_eh_recover (struct ata_port *ap,ata_prereset_fn_t prereset, -ata_reset_fn_t softreset,ata_reset_fn_t hardreset, -ata_postreset_fn_t postreset, +int ata_eh_recover (struct ata_port *ap,struct ata_reset_operations *reset_ops,struct ata_link **r_failed_link) {struct ata_link *link;
@@ -3819,8 +3817,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,if (!(ehc->i.action &ATA_EH_RESET ))continue ; - rc =ata_eh_reset (link,ata_link_nr_vacant (link), - prereset, softreset, hardreset, postreset); + rc =ata_eh_reset (link,ata_link_nr_vacant (link), reset_ops);if (rc) {ata_link_err (link,"reset failed, giving up\n" ); goto out;
@@ -4050,20 +4047,20 @@ void ata_eh_finish(struct ata_port *ap)*/ void ata_std_error_handler (struct ata_port *ap) { -struct ata_port_operations *ops = ap->ops; +struct ata_reset_operations *reset_ops = &ap->ops->reset;struct ata_link *link = &ap->link;int rc;/* Ignore built-in hardresets if SCR access is not available */ -if ((ops->hardreset == sata_std_hardreset || - ops->hardreset == sata_sff_hardreset) && !sata_scr_valid (link)) +if ((reset_ops->hardreset == sata_std_hardreset || + reset_ops->hardreset == sata_sff_hardreset) && + !sata_scr_valid (link)) link->flags |=ATA_LFLAG_NO_HRST ;ata_eh_autopsy (ap);ata_eh_report (ap); - rc =ata_eh_recover (ap, ops->prereset, ops->softreset, - ops->hardreset, ops->postreset,NULL ); + rc =ata_eh_recover (ap, reset_ops,NULL );if (rc) {struct ata_device *dev;
drivers/ata/libata-pmp.c +9 -17
@@ -15,9 +15,9 @@const struct ata_port_operations sata_pmp_port_ops = { .inherits = &sata_port_ops, - .pmp_prereset = ata_std_prereset, - .pmp_hardreset = sata_std_hardreset, - .pmp_postreset = ata_std_postreset, + .pmp_reset.prereset = ata_std_prereset, + .pmp_reset.hardreset = sata_std_hardreset, + .pmp_reset.postreset = ata_std_postreset, .error_handler = sata_pmp_error_handler, };
@@ -760,10 +760,7 @@ static int sata_pmp_revalidate_quick(struct ata_device *dev)/** * sata_pmp_eh_recover_pmp - recover PMP * @ap: ATA port PMP is attached to -* @prereset: prereset method (can be NULL) -* @softreset: softreset method -* @hardreset: hardreset method -* @postreset: postreset method (can be NULL) +* @reset_ops: The set of reset operations to use * * Recover PMP attached to @ap. Recovery procedure is somewhat * similar to that of ata_eh_recover() except that reset should
@@ -777,8 +774,7 @@ static int sata_pmp_revalidate_quick(struct ata_device *dev)* 0 on success, -errno on failure. */ static int sata_pmp_eh_recover_pmp (struct ata_port *ap, -ata_prereset_fn_t prereset,ata_reset_fn_t softreset, -ata_reset_fn_t hardreset,ata_postreset_fn_t postreset) +struct ata_reset_operations *reset_ops) {struct ata_link *link = &ap->link;struct ata_eh_context *ehc = &link->eh_context;
@@ -800,8 +796,7 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,struct ata_link *tlink;/* reset */ - rc =ata_eh_reset (link,0 , prereset, softreset, hardreset, - postreset); + rc =ata_eh_reset (link,0 , reset_ops);if (rc) {ata_link_err (link,"failed to reset PMP, giving up\n" ); goto fail;
@@ -965,8 +960,7 @@ static int sata_pmp_eh_recover(struct ata_port *ap) retry:/* PMP attached? */ if (!sata_pmp_attached (ap)) { - rc =ata_eh_recover (ap, ops->prereset, ops->softreset, - ops->hardreset, ops->postreset,NULL ); + rc =ata_eh_recover (ap, &ops->reset,NULL );if (rc) {ata_for_each_dev (dev, &ap->link,ALL )ata_dev_disable (dev);
@@ -984,8 +978,7 @@ static int sata_pmp_eh_recover(struct ata_port *ap) }/* recover pmp */ - rc =sata_pmp_eh_recover_pmp (ap, ops->prereset, ops->softreset, - ops->hardreset, ops->postreset); + rc =sata_pmp_eh_recover_pmp (ap, &ops->reset);if (rc) goto pmp_fail;
@@ -1011,8 +1004,7 @@ static int sata_pmp_eh_recover(struct ata_port *ap) goto pmp_fail;/* recover links */ - rc =ata_eh_recover (ap, ops->pmp_prereset, ops->pmp_softreset, - ops->pmp_hardreset, ops->pmp_postreset, &link); + rc =ata_eh_recover (ap, &ops->pmp_reset, &link);if (rc) goto link_fail;
drivers/ata/libata-sata.c +1 -1
@@ -1735,6 +1735,6 @@ const struct ata_port_operations sata_port_ops = { .inherits = &ata_base_port_ops, .qc_defer = ata_std_qc_defer, - .hardreset = sata_std_hardreset, + .reset.hardreset = sata_std_hardreset, };EXPORT_SYMBOL_GPL (sata_port_ops);
drivers/ata/libata-sff.c +4 -4
@@ -31,10 +31,10 @@ const struct ata_port_operations ata_sff_port_ops = { .freeze = ata_sff_freeze, .thaw = ata_sff_thaw, - .prereset = ata_sff_prereset, - .softreset = ata_sff_softreset, - .hardreset = sata_sff_hardreset, - .postreset = ata_sff_postreset, + .reset.prereset = ata_sff_prereset, + .reset.softreset = ata_sff_softreset, + .reset.hardreset = sata_sff_hardreset, + .reset.postreset = ata_sff_postreset, .error_handler = ata_sff_error_handler, .sff_dev_select = ata_sff_dev_select,
drivers/ata/libata.h +3 -5
@@ -197,11 +197,9 @@ extern void ata_eh_autopsy(struct ata_port *ap);const char *ata_get_cmd_name (u8 command);extern void ata_eh_report (struct ata_port *ap);extern int ata_eh_reset (struct ata_link *link,int classify, -ata_prereset_fn_t prereset,ata_reset_fn_t softreset, -ata_reset_fn_t hardreset,ata_postreset_fn_t postreset); -extern int ata_eh_recover (struct ata_port *ap,ata_prereset_fn_t prereset, -ata_reset_fn_t softreset,ata_reset_fn_t hardreset, -ata_postreset_fn_t postreset, +struct ata_reset_operations *reset_ops); +extern int ata_eh_recover (struct ata_port *ap, +struct ata_reset_operations *reset_ops,struct ata_link **r_failed_disk);extern void ata_eh_finish (struct ata_port *ap); extern int ata_ering_map(struct ata_ering *ering,
drivers/ata/pata_acpi.c +1 -1
@@ -216,7 +216,7 @@ static struct ata_port_operations pacpi_ops = { .mode_filter = pacpi_mode_filter, .set_piomode = pacpi_set_piomode, .set_dmamode = pacpi_set_dmamode, - .prereset = pacpi_pre_reset, + .reset.prereset = pacpi_pre_reset, .port_start = pacpi_port_start, };
drivers/ata/pata_ali.c +5 -5
@@ -392,11 +392,11 @@ static struct ata_port_operations ali_20_port_ops = {* Port operations for DMA capable ALi with cable detect */ static struct ata_port_operations ali_c2_port_ops = { - .inherits = &ali_dma_base_ops, - .check_atapi_dma = ali_check_atapi_dma, - .cable_detect = ali_c2_cable_detect, - .dev_config = ali_lock_sectors, - .postreset = ali_c2_c3_postreset, + .inherits = &ali_dma_base_ops, + .check_atapi_dma = ali_check_atapi_dma, + .cable_detect = ali_c2_cable_detect, + .dev_config = ali_lock_sectors, + .reset.postreset = ali_c2_c3_postreset, };/*
drivers/ata/pata_amd.c +2 -2
@@ -394,7 +394,7 @@ static const struct scsi_host_template amd_sht = {static const struct ata_port_operations amd_base_port_ops = { .inherits = &ata_bmdma32_port_ops, - .prereset = amd_pre_reset, + .reset.prereset = amd_pre_reset, };static struct ata_port_operations amd33_port_ops = {
@@ -429,7 +429,7 @@ static const struct ata_port_operations nv_base_port_ops = { .inherits = &ata_bmdma_port_ops, .cable_detect = ata_cable_ignore, .mode_filter = nv_mode_filter, - .prereset = nv_pre_reset, + .reset.prereset = nv_pre_reset, .host_stop = nv_host_stop, };
drivers/ata/pata_artop.c +2 -2
@@ -301,7 +301,7 @@ static struct ata_port_operations artop6210_ops = { .cable_detect = ata_cable_40wire, .set_piomode = artop6210_set_piomode, .set_dmamode = artop6210_set_dmamode, - .prereset = artop62x0_pre_reset, + .reset.prereset = artop62x0_pre_reset, .qc_defer = artop6210_qc_defer, };
@@ -310,7 +310,7 @@ static struct ata_port_operations artop6260_ops = { .cable_detect = artop6260_cable_detect, .set_piomode = artop6260_set_piomode, .set_dmamode = artop6260_set_dmamode, - .prereset = artop62x0_pre_reset, + .reset.prereset = artop62x0_pre_reset, };static void atp8xx_fixup (struct pci_dev *pdev)
drivers/ata/pata_atiixp.c +1 -1
@@ -264,7 +264,7 @@ static struct ata_port_operations atiixp_port_ops = { .bmdma_start = atiixp_bmdma_start, .bmdma_stop = atiixp_bmdma_stop, - .prereset = atiixp_prereset, + .reset.prereset = atiixp_prereset, .cable_detect = atiixp_cable_detect, .set_piomode = atiixp_set_piomode, .set_dmamode = atiixp_set_dmamode,
drivers/ata/pata_efar.c +1 -1
@@ -243,7 +243,7 @@ static struct ata_port_operations efar_ops = { .cable_detect = efar_cable_detect, .set_piomode = efar_set_piomode, .set_dmamode = efar_set_dmamode, - .prereset = efar_pre_reset, + .reset.prereset = efar_pre_reset, };
drivers/ata/pata_ep93xx.c +2 -2
@@ -891,8 +891,8 @@ static const struct scsi_host_template ep93xx_pata_sht = {static struct ata_port_operations ep93xx_pata_port_ops = { .inherits = &ata_bmdma_port_ops, - .softreset = ep93xx_pata_softreset, - .hardreset =ATA_OP_NULL , + .reset.softreset = ep93xx_pata_softreset, + .reset.hardreset =ATA_OP_NULL , .sff_dev_select = ep93xx_pata_dev_select, .sff_set_devctl = ep93xx_pata_set_devctl,
drivers/ata/pata_hpt366.c +1 -1
@@ -322,7 +322,7 @@ static const struct scsi_host_template hpt36x_sht = {static struct ata_port_operations hpt366_port_ops = { .inherits = &ata_bmdma_port_ops, - .prereset = hpt366_prereset, + .reset.prereset = hpt366_prereset, .cable_detect = hpt36x_cable_detect, .mode_filter = hpt366_filter, .set_piomode = hpt366_set_piomode,
drivers/ata/pata_hpt37x.c +2 -2
@@ -543,7 +543,7 @@ static struct ata_port_operations hpt370_port_ops = { .cable_detect = hpt37x_cable_detect, .set_piomode = hpt37x_set_piomode, .set_dmamode = hpt37x_set_dmamode, - .prereset = hpt37x_pre_reset, + .reset.prereset = hpt37x_pre_reset, };/*
@@ -567,7 +567,7 @@ static struct ata_port_operations hpt302_port_ops = { .cable_detect = hpt37x_cable_detect, .set_piomode = hpt37x_set_piomode, .set_dmamode = hpt37x_set_dmamode, - .prereset = hpt37x_pre_reset, + .reset.prereset = hpt37x_pre_reset, };/*
drivers/ata/pata_hpt3x2n.c +1 -1
@@ -356,7 +356,7 @@ static struct ata_port_operations hpt3xxn_port_ops = { .cable_detect = hpt3x2n_cable_detect, .set_piomode = hpt3x2n_set_piomode, .set_dmamode = hpt3x2n_set_dmamode, - .prereset = hpt3x2n_pre_reset, + .reset.prereset = hpt3x2n_pre_reset, };/*
drivers/ata/pata_icside.c +1 -1
@@ -336,7 +336,7 @@ static struct ata_port_operations pata_icside_port_ops = { .cable_detect = ata_cable_40wire, .set_dmamode = pata_icside_set_dmamode, - .postreset = pata_icside_postreset, + .reset.postreset = pata_icside_postreset, .port_start = ATA_OP_NULL, /* don't need PRD table */ };
drivers/ata/pata_it8213.c +1 -1
@@ -238,7 +238,7 @@ static struct ata_port_operations it8213_ops = { .cable_detect = it8213_cable_detect, .set_piomode = it8213_set_piomode, .set_dmamode = it8213_set_dmamode, - .prereset = it8213_pre_reset, + .reset.prereset = it8213_pre_reset, };
drivers/ata/pata_jmicron.c +1 -1
@@ -113,7 +113,7 @@ static const struct scsi_host_template jmicron_sht = {static struct ata_port_operations jmicron_ops = { .inherits = &ata_bmdma_port_ops, - .prereset = jmicron_pre_reset, + .reset.prereset = jmicron_pre_reset, };
drivers/ata/pata_marvell.c +1 -1
@@ -99,7 +99,7 @@ static const struct scsi_host_template marvell_sht = {static struct ata_port_operations marvell_ops = { .inherits = &ata_bmdma_port_ops, .cable_detect = marvell_cable_detect, - .prereset = marvell_pre_reset, + .reset.prereset = marvell_pre_reset, };
drivers/ata/pata_mpiix.c +1 -1
@@ -145,7 +145,7 @@ static struct ata_port_operations mpiix_port_ops = { .qc_issue = mpiix_qc_issue, .cable_detect = ata_cable_40wire, .set_piomode = mpiix_set_piomode, - .prereset = mpiix_pre_reset, + .reset.prereset = mpiix_pre_reset, .sff_data_xfer = ata_sff_data_xfer32, };
drivers/ata/pata_ns87410.c +1 -1
@@ -123,7 +123,7 @@ static struct ata_port_operations ns87410_port_ops = { .qc_issue = ns87410_qc_issue, .cable_detect = ata_cable_40wire, .set_piomode = ns87410_set_piomode, - .prereset = ns87410_pre_reset, + .reset.prereset = ns87410_pre_reset, };static int ns87410_init_one (struct pci_dev *dev,const struct pci_device_id *id)
drivers/ata/pata_octeon_cf.c +1 -1
@@ -942,7 +942,7 @@ static int octeon_cf_probe(struct platform_device *pdev)/* 16 bit but not True IDE */ base = cs0 +0x800 ; octeon_cf_ops.sff_data_xfer = octeon_cf_data_xfer16; - octeon_cf_ops.softreset = octeon_cf_softreset16; + octeon_cf_ops.reset.softreset = octeon_cf_softreset16; octeon_cf_ops.sff_check_status = octeon_cf_check_status16; octeon_cf_ops.sff_tf_read = octeon_cf_tf_read16; octeon_cf_ops.sff_tf_load = octeon_cf_tf_load16;
drivers/ata/pata_oldpiix.c +1 -1
@@ -214,7 +214,7 @@ static struct ata_port_operations oldpiix_pata_ops = { .cable_detect = ata_cable_40wire, .set_piomode = oldpiix_set_piomode, .set_dmamode = oldpiix_set_dmamode, - .prereset = oldpiix_pre_reset, + .reset.prereset = oldpiix_pre_reset, };
drivers/ata/pata_opti.c +1 -1
@@ -156,7 +156,7 @@ static struct ata_port_operations opti_port_ops = { .inherits = &ata_sff_port_ops, .cable_detect = ata_cable_40wire, .set_piomode = opti_set_piomode, - .prereset = opti_pre_reset, + .reset.prereset = opti_pre_reset, };static int opti_init_one (struct pci_dev *dev,const struct pci_device_id *id)
drivers/ata/pata_optidma.c +1 -1
@@ -344,7 +344,7 @@ static struct ata_port_operations optidma_port_ops = { .set_piomode = optidma_set_pio_mode, .set_dmamode = optidma_set_dma_mode, .set_mode = optidma_set_mode, - .prereset = optidma_pre_reset, + .reset.prereset = optidma_pre_reset, };static struct ata_port_operations optiplus_port_ops = {
drivers/ata/pata_parport/pata_parport.c +2 -2
@@ -321,8 +321,8 @@ static void pata_parport_drain_fifo(struct ata_queued_cmd *qc)static struct ata_port_operations pata_parport_port_ops = { .inherits = &ata_sff_port_ops, - .softreset = pata_parport_softreset, - .hardreset =NULL , + .reset.softreset = pata_parport_softreset, + .reset.hardreset =NULL , .sff_dev_select = pata_parport_dev_select, .sff_set_devctl = pata_parport_set_devctl,
drivers/ata/pata_pdc2027x.c +1 -1
@@ -130,7 +130,7 @@ static struct ata_port_operations pdc2027x_pata100_ops = { .inherits = &ata_bmdma_port_ops, .check_atapi_dma = pdc2027x_check_atapi_dma, .cable_detect = pdc2027x_cable_detect, - .prereset = pdc2027x_prereset, + .reset.prereset = pdc2027x_prereset, };static struct ata_port_operations pdc2027x_pata133_ops = {
drivers/ata/pata_rdc.c +1 -1
@@ -276,7 +276,7 @@ static struct ata_port_operations rdc_pata_ops = { .cable_detect = rdc_pata_cable_detect, .set_piomode = rdc_set_piomode, .set_dmamode = rdc_set_dmamode, - .prereset = rdc_pata_prereset, + .reset.prereset = rdc_pata_prereset, };static const struct ata_port_info rdc_port_info = {
drivers/ata/pata_sis.c +1 -1
@@ -552,7 +552,7 @@ static struct ata_port_operations sis_133_for_sata_ops = {static struct ata_port_operations sis_base_ops = { .inherits = &ata_bmdma_port_ops, - .prereset = sis_pre_reset, + .reset.prereset = sis_pre_reset, };static struct ata_port_operations sis_133_ops = {
drivers/ata/pata_sl82c105.c +1 -1
@@ -248,7 +248,7 @@ static struct ata_port_operations sl82c105_port_ops = { .bmdma_stop = sl82c105_bmdma_stop, .cable_detect = ata_cable_40wire, .set_piomode = sl82c105_set_piomode, - .prereset = sl82c105_pre_reset, + .reset.prereset = sl82c105_pre_reset, .sff_irq_check = sl82c105_sff_irq_check, };
drivers/ata/pata_triflex.c +1 -1
@@ -170,7 +170,7 @@ static struct ata_port_operations triflex_port_ops = { .bmdma_stop = triflex_bmdma_stop, .cable_detect = ata_cable_40wire, .set_piomode = triflex_set_piomode, - .prereset = triflex_prereset, + .reset.prereset = triflex_prereset, };static int triflex_init_one (struct pci_dev *dev,const struct pci_device_id *id)
drivers/ata/pata_via.c +1 -1
@@ -451,7 +451,7 @@ static struct ata_port_operations via_port_ops = { .cable_detect = via_cable_detect, .set_piomode = via_set_piomode, .set_dmamode = via_set_dmamode, - .prereset = via_pre_reset, + .reset.prereset = via_pre_reset, .sff_tf_load = via_tf_load, .port_start = via_port_start, .mode_filter = via_mode_filter,
drivers/ata/pdc_adma.c +1 -1
@@ -140,7 +140,7 @@ static struct ata_port_operations adma_ata_ops = { .freeze = adma_freeze, .thaw = adma_thaw, - .prereset = adma_prereset, + .reset.prereset = adma_prereset, .port_start = adma_port_start, .port_stop = adma_port_stop,
drivers/ata/sata_dwc_460ex.c +1 -1
@@ -1087,7 +1087,7 @@ static struct ata_port_operations sata_dwc_ops = { .inherits = &ata_sff_port_ops, .error_handler = sata_dwc_error_handler, - .hardreset = sata_dwc_hardreset, + .reset.hardreset = sata_dwc_hardreset, .qc_issue = sata_dwc_qc_issue,
drivers/ata/sata_fsl.c +3 -3
@@ -1395,9 +1395,9 @@ static struct ata_port_operations sata_fsl_ops = { .freeze = sata_fsl_freeze, .thaw = sata_fsl_thaw, - .softreset = sata_fsl_softreset, - .hardreset = sata_fsl_hardreset, - .pmp_softreset = sata_fsl_softreset, + .reset.softreset = sata_fsl_softreset, + .reset.hardreset = sata_fsl_hardreset, + .pmp_reset.softreset = sata_fsl_softreset, .error_handler = sata_fsl_error_handler, .post_internal_cmd = sata_fsl_post_internal_cmd,
drivers/ata/sata_highbank.c +1 -1
@@ -428,7 +428,7 @@ static int ahci_highbank_hardreset(struct ata_link *link, unsigned int *class,static struct ata_port_operations ahci_highbank_ops = { .inherits = &ahci_ops, - .hardreset = ahci_highbank_hardreset, + .reset.hardreset = ahci_highbank_hardreset, .transmit_led_message = ecx_transmit_led_message, };
drivers/ata/sata_inic162x.c +1 -1
@@ -730,7 +730,7 @@ static struct ata_port_operations inic_port_ops = { .freeze = inic_freeze, .thaw = inic_thaw, - .hardreset = inic_hardreset, + .reset.hardreset = inic_hardreset, .error_handler = inic_error_handler, .post_internal_cmd = inic_post_internal_cmd,
drivers/ata/sata_mv.c +5 -5
@@ -687,7 +687,7 @@ static struct ata_port_operations mv5_ops = { .freeze = mv_eh_freeze, .thaw = mv_eh_thaw, - .hardreset = mv_hardreset, + .reset.hardreset = mv_hardreset, .scr_read = mv5_scr_read, .scr_write = mv5_scr_write,
@@ -709,10 +709,10 @@ static struct ata_port_operations mv6_ops = { .freeze = mv_eh_freeze, .thaw = mv_eh_thaw, - .hardreset = mv_hardreset, - .softreset = mv_softreset, - .pmp_hardreset = mv_pmp_hardreset, - .pmp_softreset = mv_softreset, + .reset.hardreset = mv_hardreset, + .reset.softreset = mv_softreset, + .pmp_reset.hardreset = mv_pmp_hardreset, + .pmp_reset.softreset = mv_softreset, .error_handler = mv_pmp_error_handler, .scr_read = mv_scr_read,
drivers/ata/sata_nv.c +1 -1
@@ -462,7 +462,7 @@ static struct ata_port_operations nv_generic_ops = { .lost_interrupt = ATA_OP_NULL, .scr_read = nv_scr_read, .scr_write = nv_scr_write, - .hardreset = nv_hardreset, + .reset.hardreset = nv_hardreset, };static struct ata_port_operations nv_nf2_ops = {
drivers/ata/sata_promise.c +2 -2
@@ -188,7 +188,7 @@ static struct ata_port_operations pdc_sata_ops = { .scr_read = pdc_sata_scr_read, .scr_write = pdc_sata_scr_write, .port_start = pdc_sata_port_start, - .hardreset = pdc_sata_hardreset, + .reset.hardreset = pdc_sata_hardreset, };/* First-generation chips need a more restrictive ->check_atapi_dma op,
@@ -206,7 +206,7 @@ static struct ata_port_operations pdc_pata_ops = { .freeze = pdc_freeze, .thaw = pdc_thaw, .port_start = pdc_common_port_start, - .softreset = pdc_pata_softreset, + .reset.softreset = pdc_pata_softreset, };static const struct ata_port_info pdc_port_info[] = {
drivers/ata/sata_qstor.c +2 -2
@@ -123,8 +123,8 @@ static struct ata_port_operations qs_ata_ops = { .freeze = qs_freeze, .thaw = qs_thaw, - .prereset = qs_prereset, - .softreset = ATA_OP_NULL, + .reset.prereset = qs_prereset, + .reset.softreset = ATA_OP_NULL, .error_handler = qs_error_handler, .lost_interrupt = ATA_OP_NULL,
drivers/ata/sata_rcar.c +1 -1
@@ -624,7 +624,7 @@ static struct ata_port_operations sata_rcar_port_ops = { .freeze = sata_rcar_freeze, .thaw = sata_rcar_thaw, - .softreset = sata_rcar_softreset, + .reset.softreset = sata_rcar_softreset, .scr_read = sata_rcar_scr_read, .scr_write = sata_rcar_scr_write,
drivers/ata/sata_sil24.c +4 -4
@@ -394,10 +394,10 @@ static struct ata_port_operations sil24_ops = { .freeze = sil24_freeze, .thaw = sil24_thaw, - .softreset = sil24_softreset, - .hardreset = sil24_hardreset, - .pmp_softreset = sil24_softreset, - .pmp_hardreset = sil24_pmp_hardreset, + .reset.softreset = sil24_softreset, + .reset.hardreset = sil24_hardreset, + .pmp_reset.softreset = sil24_softreset, + .pmp_reset.hardreset = sil24_pmp_hardreset, .error_handler = sil24_error_handler, .post_internal_cmd = sil24_post_internal_cmd, .dev_config = sil24_dev_config,
drivers/ata/sata_svw.c +2 -2
@@ -340,8 +340,8 @@ static const struct scsi_host_template k2_sata_sht = {static struct ata_port_operations k2_sata_ops = { .inherits = &ata_bmdma_port_ops, - .softreset = k2_sata_softreset, - .hardreset = k2_sata_hardreset, + .reset.softreset = k2_sata_softreset, + .reset.hardreset = k2_sata_hardreset, .sff_tf_load = k2_sata_tf_load, .sff_tf_read = k2_sata_tf_read, .sff_check_status = k2_stat_check_status,
drivers/ata/sata_sx4.c +1 -1
@@ -241,7 +241,7 @@ static struct ata_port_operations pdc_20621_ops = { .freeze = pdc_freeze, .thaw = pdc_thaw, - .softreset = pdc_softreset, + .reset.softreset = pdc_softreset, .error_handler = pdc_error_handler, .lost_interrupt = ATA_OP_NULL, .post_internal_cmd = pdc_post_internal_cmd,
drivers/ata/sata_uli.c +1 -1
@@ -67,7 +67,7 @@ static struct ata_port_operations uli_ops = { .inherits = &ata_bmdma_port_ops, .scr_read = uli_scr_read, .scr_write = uli_scr_write, - .hardreset = ATA_OP_NULL, + .reset.hardreset = ATA_OP_NULL, };static const struct ata_port_info uli_port_info = {
drivers/ata/sata_via.c +2 -2
@@ -119,7 +119,7 @@ static struct ata_port_operations svia_base_ops = {static struct ata_port_operations vt6420_sata_ops = { .inherits = &svia_base_ops, .freeze = svia_noop_freeze, - .prereset = vt6420_prereset, + .reset.prereset = vt6420_prereset, .bmdma_start = vt6420_bmdma_start, };
@@ -139,7 +139,7 @@ static struct ata_port_operations vt6421_sata_ops = {static struct ata_port_operations vt8251_ops = { .inherits = &svia_base_ops, - .hardreset = sata_std_hardreset, + .reset.hardreset = sata_std_hardreset, .scr_read = vt8251_scr_read, .scr_write = vt8251_scr_write, };
drivers/scsi/libsas/sas_ata.c +2 -2
@@ -559,8 +559,8 @@ static int sas_ata_prereset(struct ata_link *link, unsigned long deadline) }static struct ata_port_operations sas_sata_ops = { - .prereset = sas_ata_prereset, - .hardreset = sas_ata_hard_reset, + .reset.prereset = sas_ata_prereset, + .reset.hardreset = sas_ata_hard_reset, .error_handler = ata_std_error_handler, .post_internal_cmd = sas_ata_post_internal, .qc_defer = ata_std_qc_defer,
include/linux/libata.h +9 -8
@@ -947,6 +947,13 @@ struct ata_port {*/ #define ATA_OP_NULL (void *)(unsigned long)(-ENOENT) +struct ata_reset_operations { +ata_prereset_fn_t prereset; +ata_reset_fn_t softreset; +ata_reset_fn_t hardreset; +ata_postreset_fn_t postreset; +}; +struct ata_port_operations {/* * Command execution
@@ -973,14 +980,8 @@ struct ata_port_operations {void (*freeze)(struct ata_port *ap);void (*thaw)(struct ata_port *ap); -ata_prereset_fn_t prereset; -ata_reset_fn_t softreset; -ata_reset_fn_t hardreset; -ata_postreset_fn_t postreset; -ata_prereset_fn_t pmp_prereset; -ata_reset_fn_t pmp_softreset; -ata_reset_fn_t pmp_hardreset; -ata_postreset_fn_t pmp_postreset; +struct ata_reset_operations reset; +struct ata_reset_operations pmp_reset;void (*error_handler)(struct ata_port *ap);void (*lost_interrupt)(struct ata_port *ap);void (*post_internal_cmd)(struct ata_queued_cmd *qc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 522/670 ata: libata: Add an argument to ata_eh_reset()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 4b3c2ca268b0a66093793466e02d8566d642f19c ]
Pass the ATA port pointer as first argument to ata_eh_reset(). No functionality has been changed. This patch prepares for enabling lock context analysis. Without this patch, lockdep_assert_held() statements would have to be added before each ata_eh_reset() call because the compiler doesn't know that ap->link.p == ap. See also ata_link_init().
Stable-dep-of: 96fdeb7e3fd8 ("ata: sata_inic162x: remove dangerous broken driver")
--- drivers/ata/libata-eh.c | 6 +++--- drivers/ata/libata-pmp.c | 2 +- drivers/ata/libata.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-)
drivers/ata/libata-eh.c +3 -3
@@ -2632,10 +2632,9 @@ static int ata_eh_followup_srst_needed(struct ata_link *link, int rc)return 0 ; } -int ata_eh_reset (struct ata_link *link,int classify, +int ata_eh_reset (struct ata_port *ap,struct ata_link *link,int classify,struct ata_reset_operations *reset_ops) { -struct ata_port *ap = link->ap;struct ata_link *slave = ap->slave_link;struct ata_eh_context *ehc = &link->eh_context;struct ata_eh_context *sehc = slave ? &slave->eh_context :NULL ;
@@ -3817,7 +3816,8 @@ int ata_eh_recover(struct ata_port *ap, struct ata_reset_operations *reset_ops,if (!(ehc->i.action &ATA_EH_RESET ))continue ; - rc =ata_eh_reset (link,ata_link_nr_vacant (link), reset_ops); + rc =ata_eh_reset (ap, link,ata_link_nr_vacant (link), + reset_ops);if (rc) {ata_link_err (link,"reset failed, giving up\n" ); goto out;
drivers/ata/libata-pmp.c +1 -1
@@ -796,7 +796,7 @@ static int sata_pmp_eh_recover_pmp(struct ata_port *ap,struct ata_link *tlink;/* reset */ - rc =ata_eh_reset (link,0 , reset_ops); + rc =ata_eh_reset (ap, link,0 , reset_ops);if (rc) {ata_link_err (link,"failed to reset PMP, giving up\n" ); goto fail;
drivers/ata/libata.h +2 -2
@@ -196,8 +196,8 @@ extern void ata_eh_done(struct ata_link *link, struct ata_device *dev,extern void ata_eh_autopsy (struct ata_port *ap);const char *ata_get_cmd_name (u8 command);extern void ata_eh_report (struct ata_port *ap); -extern int ata_eh_reset (struct ata_link *link,int classify, -struct ata_reset_operations *reset_ops); +extern int ata_eh_reset (struct ata_port *ap,struct ata_link *link, +int classify,struct ata_reset_operations *reset_ops);extern int ata_eh_recover (struct ata_port *ap,struct ata_reset_operations *reset_ops,struct ata_link **r_failed_disk);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 523/670 ata: sata_inic162x: remove dangerous broken driver
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ethan Nelson-Moore <[email protected]>
[ Upstream commit 96fdeb7e3fd8d937f8351ed90824c9d904e590a1 ]
The sata_inic162x driver was labeled as "very experimental" in commit bb9696192826 ("libata: make it clear that sata_inic162x is experimental") due to data corruption issues, but not marked as broken. Since then, no changes have been made to it that could fix these issues. Since the driver was not marked as broken, and the message about potential data corruption is only visible in the code and dmesg, it is possible that someone could enable the driver without realizing its potential for data corruption. Remove the driver to protect users' data.
--- drivers/ata/Kconfig | 7 - drivers/ata/Makefile | 1 - drivers/ata/sata_inic162x.c | 902 ------------------------------------ 3 files changed, 910 deletions(-) delete mode 100644 drivers/ata/sata_inic162x.c
drivers/ata/Kconfig +0 -7
@@ -329,13 +329,6 @@ config SATA_AHCI_SEATTLE If unsure, say N -config SATA_INIC162X - tristate "Initio 162x SATA support (Very Experimental)" - depends on PCI - select SATA_HOST - help - This option enables support for Initio 162x Serial ATA. - config SATA_ACARD_AHCI tristate "ACard AHCI variant (ATP 8620)" depends on PCI
drivers/ata/Makefile +0 -1
@@ -9,7 +9,6 @@ obj-$(CONFIG_SATA_AHCI_SEATTLE) += ahci_seattle.o libahci.o libahci_platform.o obj-$(CONFIG_SATA_AHCI_PLATFORM) += ahci_platform.o libahci.o libahci_platform.o obj-$(CONFIG_SATA_FSL) += sata_fsl.o obj-$(CONFIG_SATA_GEMINI) += sata_gemini.o -obj-$(CONFIG_SATA_INIC162X) += sata_inic162x.o obj-$(CONFIG_SATA_SIL24) += sata_sil24.o obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o obj-$(CONFIG_SATA_HIGHBANK) += sata_highbank.o libahci.o
drivers/ata/sata_inic162x.c deleted +0 -902
902 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 524/670 ALSA: line6: Use guard() for spin locks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit bdcdb4e7aa410122baa3496b93e7850dc20a90fa ]
Clean up the code using guard() for spin locks.
Merely code refactoring, and no behavior change.
Stable-dep-of: 443ed4edc267 ("ALSA: line6: Handle period elapsed calls outside the locks")
--- sound/usb/line6/capture.c | 6 +----- sound/usb/line6/driver.c | 31 +++++++++++++++---------------- sound/usb/line6/midi.c | 10 ++-------- sound/usb/line6/pcm.c | 27 ++++++++++++--------------- 4 files changed, 30 insertions(+), 44 deletions(-)
sound/usb/line6/capture.c +1 -5
@@ -157,8 +157,6 @@ void line6_capture_check_period(struct snd_line6_pcm *line6pcm, int length)static void audio_in_callback (struct urb *urb) {int i, index, length =0 , shutdown =0 ; -unsigned long flags; -struct snd_line6_pcm *line6pcm = (struct snd_line6_pcm *)urb->context; line6pcm->in.last_frame = urb->start_frame;
@@ -168,7 +166,7 @@ static void audio_in_callback(struct urb *urb)if (urb == line6pcm->in.urbs[index])break ; -spin_lock_irqsave (&line6pcm->in.lock, flags); +guard (spinlock_irqsave)(&line6pcm->in.lock);for (i =0 ; i <LINE6_ISO_PACKETS ; ++i) {char *fbuf;
@@ -223,8 +221,6 @@ static void audio_in_callback(struct urb *urb) test_bit(LINE6_STREAM_PCM, &line6pcm->in.running))line6_capture_check_period (line6pcm, length); } - -spin_unlock_irqrestore (&line6pcm->in.lock, flags); }/* open capture callback */
sound/usb/line6/driver.c +15 -16
@@ -286,31 +286,30 @@ static void line6_data_received(struct urb *urb) {struct usb_line6 *line6 = (struct usb_line6 *)urb->context;struct midi_buffer *mb = &line6->line6midi->midibuf_in; -unsigned long flags;int done;if (urb->status == -ESHUTDOWN )return ;if (line6->properties->capabilities &LINE6_CAP_CONTROL_MIDI ) { -spin_lock_irqsave (&line6->line6midi->lock, flags); - done = -line6_midibuf_write (mb, urb->transfer_buffer, urb->actual_length); - -if (done < urb->actual_length) { -line6_midibuf_ignore (mb, done); -dev_dbg (line6->ifcdev,"%d %d buffer overflow - message skipped\n" , - done, urb->actual_length); + scoped_guard(spinlock_irqsave, &line6->line6midi->lock) { + done = +line6_midibuf_write (mb, urb->transfer_buffer, urb->actual_length); + +if (done < urb->actual_length) { +line6_midibuf_ignore (mb, done); +dev_dbg (line6->ifcdev,"%d %d buffer overflow - message skipped\n" , + done, urb->actual_length); + } } -spin_unlock_irqrestore (&line6->line6midi->lock, flags);for (;;) { -spin_lock_irqsave (&line6->line6midi->lock, flags); - done = -line6_midibuf_read (mb, line6->buffer_message, -LINE6_MIDI_MESSAGE_MAXLEN , -LINE6_MIDIBUF_READ_RX ); -spin_unlock_irqrestore (&line6->line6midi->lock, flags); + scoped_guard(spinlock_irqsave, &line6->line6midi->lock) { + done = +line6_midibuf_read (mb, line6->buffer_message, +LINE6_MIDI_MESSAGE_MAXLEN , +LINE6_MIDIBUF_READ_RX ); + }if (done <=0 )break ;
sound/usb/line6/midi.c +2 -8
@@ -72,7 +72,6 @@ static void line6_midi_transmit(struct snd_rawmidi_substream *substream)*/ static void midi_sent (struct urb *urb) { -unsigned long flags;int status;int num;struct usb_line6 *line6 = (struct usb_line6 *)urb->context;
@@ -84,7 +83,7 @@ static void midi_sent(struct urb *urb)if (status == -ESHUTDOWN )return ; -spin_lock_irqsave (&line6->line6midi->lock, flags); +guard (spinlock_irqsave)(&line6->line6midi->lock); num = --line6->line6midi->num_active_send_urbs;if (num ==0 ) {
@@ -94,8 +93,6 @@ static void midi_sent(struct urb *urb)if (num ==0 )wake_up (&line6->line6midi->send_wait); - -spin_unlock_irqrestore (&line6->line6midi->lock, flags); }/*
@@ -158,17 +155,14 @@ static int line6_midi_output_close(struct snd_rawmidi_substream *substream)static void line6_midi_output_trigger (struct snd_rawmidi_substream *substream,int up) { -unsigned long flags;struct usb_line6 *line6 =line6_rawmidi_substream_midi (substream)->line6; line6->line6midi->substream_transmit = substream; -spin_lock_irqsave (&line6->line6midi->lock, flags); +guard (spinlock_irqsave)(&line6->line6midi->lock);if (line6->line6midi->num_active_send_urbs ==0 )line6_midi_transmit (substream); - -spin_unlock_irqrestore (&line6->line6midi->lock, flags); }static void line6_midi_output_drain (struct snd_rawmidi_substream *substream)
sound/usb/line6/pcm.c +12 -15
@@ -190,11 +190,10 @@ static void line6_buffer_release(struct snd_line6_pcm *line6pcm,static int line6_stream_start (struct snd_line6_pcm *line6pcm,int direction,int type) { -unsigned long flags;struct line6_pcm_stream *pstr =get_stream (line6pcm, direction);int ret =0 ; -spin_lock_irqsave (&pstr->lock, flags); +guard (spinlock_irqsave)(&pstr->lock);if (!test_and_set_bit (type, &pstr->running) && !(pstr->active_urbs || pstr->unlink_urbs)) { pstr->count =0 ;
@@ -207,7 +206,6 @@ static int line6_stream_start(struct snd_line6_pcm *line6pcm, int direction,if (ret <0 )clear_bit (type, &pstr->running); -spin_unlock_irqrestore (&pstr->lock, flags);return ret; }
@@ -215,21 +213,20 @@ static int line6_stream_start(struct snd_line6_pcm *line6pcm, int direction,static void line6_stream_stop (struct snd_line6_pcm *line6pcm,int direction,int type) { -unsigned long flags;struct line6_pcm_stream *pstr =get_stream (line6pcm, direction); -spin_lock_irqsave (&pstr->lock, flags); -clear_bit (type, &pstr->running); -if (!pstr->running) { -spin_unlock_irqrestore (&pstr->lock, flags); -line6_unlink_audio_urbs (line6pcm, pstr); -spin_lock_irqsave (&pstr->lock, flags); -if (direction ==SNDRV_PCM_STREAM_CAPTURE ) { - line6pcm->prev_fbuf =NULL ; - line6pcm->prev_fsize =0 ; - } + scoped_guard(spinlock_irqsave, &pstr->lock) { +clear_bit (type, &pstr->running); +if (pstr->running) +return ; + } + +line6_unlink_audio_urbs (line6pcm, pstr); +if (direction ==SNDRV_PCM_STREAM_CAPTURE ) { +guard (spinlock_irqsave)(&pstr->lock); + line6pcm->prev_fbuf =NULL ; + line6pcm->prev_fsize =0 ; } -spin_unlock_irqrestore (&pstr->lock, flags); }/* common PCM trigger callback */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 525/670 ALSA: line6: Handle period elapsed calls outside the locks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 443ed4edc2678cc51c5a01e7dffc4c890be40051 ]
LINE6 driver may call snd_pcm_period_elapsed() for both playback and capture substreams at processing the playback substream, and this may lead to a ABBA deadlock.
Move the actual calls of snd_pcm_period_elapsed() outside the locks for avoiding it. The capture period notification at submitting the initial playback URBs (only with the impulse mode) is simply skipped, as it's done in the lock context; it'll be caught up at the next period.
--- sound/usb/line6/capture.c | 25 ++++++++++++++++--------- sound/usb/line6/capture.h | 2 +- sound/usb/line6/playback.c | 31 +++++++++++++++++++++---------- 3 files changed, 38 insertions(+), 20 deletions(-)
sound/usb/line6/capture.c +16 -9
@@ -137,24 +137,21 @@ void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize) line6pcm->in.pos_done -= runtime->buffer_size; } -void line6_capture_check_period (struct snd_line6_pcm *line6pcm,int length) +/* update the capture position and check whether we need period_elapsed call */ +bool line6_capture_check_period (struct snd_line6_pcm *line6pcm,int length) { -struct snd_pcm_substream *substream = -get_substream (line6pcm,SNDRV_PCM_STREAM_CAPTURE ); - line6pcm->in.bytes += length;if (line6pcm->in.bytes >= line6pcm->in.period) { line6pcm->in.bytes %= line6pcm->in.period; -spin_unlock (&line6pcm->in.lock); -snd_pcm_period_elapsed (substream); -spin_lock (&line6pcm->in.lock); +return true; } +return false; }/* * Callback for completed capture URB. */ -static void audio_in_callback (struct urb *urb) +static bool handle_audio_in (struct urb *urb) {int i, index, length =0 , shutdown =0 ;struct snd_line6_pcm *line6pcm = (struct snd_line6_pcm *)urb->context;
@@ -219,8 +216,18 @@ static void audio_in_callback(struct urb *urb)if (!test_bit (LINE6_STREAM_IMPULSE , &line6pcm->in.running) &&test_bit (LINE6_STREAM_PCM , &line6pcm->in.running)) -line6_capture_check_period (line6pcm, length); +return line6_capture_check_period (line6pcm, length); } + +return false; +} + +static void audio_in_callback (struct urb *urb) +{ +struct snd_line6_pcm *line6pcm = (struct snd_line6_pcm *)urb->context; + +if (handle_audio_in (urb)) +snd_pcm_period_elapsed (get_substream (line6pcm,SNDRV_PCM_STREAM_CAPTURE )); }/* open capture callback */
sound/usb/line6/capture.h +1 -1
@@ -17,7 +17,7 @@ extern const struct snd_pcm_ops snd_line6_capture_ops;extern void line6_capture_copy (struct snd_line6_pcm *line6pcm,char *fbuf,int fsize); -extern void line6_capture_check_period (struct snd_line6_pcm *line6pcm, +extern bool line6_capture_check_period (struct snd_line6_pcm *line6pcm,int length);extern int line6_create_audio_in_urbs (struct snd_line6_pcm *line6pcm);extern int line6_submit_audio_in_all_urbs (struct snd_line6_pcm *line6pcm);
sound/usb/line6/playback.c +21 -10
@@ -136,6 +136,8 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal,/* Find a free URB, prepare audio data, and submit URB. must be called in line6pcm->out.lock context +Returns 1 if snd_pcm_period_elapsed() needs to be called for the +capture stream after releasing the lock, 0 if not, or a negative error */ static int submit_audio_out_urb (struct snd_line6_pcm *line6pcm) {
@@ -151,6 +153,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) line6pcm->properties->rates.rats[0 ].den * (line6pcm->line6->intervals_per_second /LINE6_ISO_INTERVAL );struct urb *urb_out; +bool capture_period_elapsed = false; index =find_first_zero_bit (&line6pcm->out.active_urbs, line6pcm->line6->iso_buffers);
@@ -260,8 +263,9 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) urb_out->transfer_buffer, urb_out-> transfer_buffer_length); -line6_capture_check_period (line6pcm, - urb_out->transfer_buffer_length); + capture_period_elapsed = +line6_capture_check_period (line6pcm, + urb_out->transfer_buffer_length); } }else { if (!(line6pcm->line6->properties->capabilities & LINE6_CAP_HWMON)
@@ -283,24 +287,26 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)dev_err (line6pcm->line6->ifcdev,"URB out #%d submission failed (%d)\n" , index, ret); -return 0 ; +return capture_period_elapsed; }/* Submit all currently available playback URBs. must be called in line6pcm->out.lock context +The capture period notification is skipped here since we can't call +snd_pcm_period_elapsed() in the lock; it'll be caught up at the next one. */ int line6_submit_audio_out_all_urbs (struct snd_line6_pcm *line6pcm) { -int ret =0 , i; +int ret, i;for (i =0 ; i < line6pcm->line6->iso_buffers; ++i) { ret =submit_audio_out_urb (line6pcm);if (ret <0 ) -break ; +return ret; } -return ret; +return 0 ; }/*
@@ -316,6 +322,8 @@ static void audio_out_callback(struct urb *urb)const int bytes_per_frame = line6pcm->properties->bytes_per_channel * line6pcm->properties->playback_hw.channels_max; +bool capture_period_elapsed = false; +bool playback_period_elapsed = false;#if USE_CLEAR_BUFFER_WORKAROUND memset (urb->transfer_buffer,0 , urb->transfer_buffer_length);
@@ -358,19 +366,22 @@ static void audio_out_callback(struct urb *urb) shutdown =1 ;if (!shutdown) { -submit_audio_out_urb (line6pcm); + capture_period_elapsed =submit_audio_out_urb (line6pcm) >0 ;if (test_bit (LINE6_STREAM_PCM , &line6pcm->out.running)) { line6pcm->out.bytes += length;if (line6pcm->out.bytes >= line6pcm->out.period) { line6pcm->out.bytes %= line6pcm->out.period; -spin_unlock (&line6pcm->out.lock); -snd_pcm_period_elapsed (substream); -spin_lock (&line6pcm->out.lock); + playback_period_elapsed = true; } } }spin_unlock_irqrestore (&line6pcm->out.lock, flags); + +if (capture_period_elapsed) +snd_pcm_period_elapsed (get_substream (line6pcm,SNDRV_PCM_STREAM_CAPTURE )); +if (playback_period_elapsed) +snd_pcm_period_elapsed (substream); }/* open playback callback */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 526/670 f2fs: zone: fix to avoid bio split on sequential zone
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit b9b036bd1e2cfbc189d5811d62d8711e216c40b3 ]
In the block layer, bio_split_to_limits() splits a bio if it exceeds any underlying queue limits:
1. queue_max_sectors: Splits bios larger than the transfer limit. This limit is set by the device driver/DMA controller (max_hw_sectors) and device-mapper targets. When flushing dirty pages (governed by VFS writeback_chunk_size() and f2fs nr_pages_to_skip()), f2fs merges contiguous pages into bios up to 512KB (1024 sectors) or more without checking queue_max_sectors, which will be split if the device or DM target enforces a smaller limit.
2. queue_max_segments: Splits bios exceeding scatter-gather segment limits. f2fs allocates bios with up to 256 pages, exceeding the 128-segment limit of DM targets (dm-default-key/dm-crypt) if pages are discontiguous.
3. chunk_sectors: Splits bios crossing chunk/zone boundaries. In f2fs, section_size strictly matches zone_size, and block allocation never spans across section boundaries, so bios never cross chunk_sectors.
Crucially, when bio_split_to_limits() splits a bio, bio_submit_split() submits the tail half via submit_bio_noacct() before returning the head half to the caller. On a sequential zoned device, this causes the tail bio to arrive at the zone write plug before the head:
dm-3: zone 7: prepare_bio wp mismatch: bio sector 30720 offset 2048 != wp_offset 248, len 248
The write plug rejects the out-of-order tail with BLK_STS_IOERR, causing f2fs_stop_checkpoint() and remounting the filesystem read-only:
2026-09-30T22:09:23.725678+08:00 localhost kernel: CPU: 9 UID: 0 PID: 243 Comm: kworker/9:1H Not tainted 6.12.81-gb3ef518fb26d #5 2026-09-30T22:09:23.725750+08:00 localhost kernel: Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-debian-1.17.0-1 04/01/2014 2026-09-30T22:09:23.725753+08:00 localhost kernel: Workqueue: dm-3_zwplugs blk_zone_wplug_bio_work 2026-09-30T22:09:23.725756+08:00 localhost kernel: Call Trace: 2026-09-30T22:09:23.725758+08:00 localhost kernel: <TASK> 2026-09-30T22:09:23.725758+08:00 localhost kernel: dump_stack_lvl+0x4d/0x70 2026-09-30T22:09:23.725759+08:00 localhost kernel: f2fs_stop_checkpoint+0x1df/0x5d0 2026-09-30T22:09:23.725759+08:00 localhost kernel: ? blk_zone_wplug_bio_work+0x4eb/0x740 2026-09-30T22:09:23.725760+08:00 localhost kernel: f2fs_cache_write_end_io+0x545/0x6e0 2026-09-30T22:09:23.725761+08:00 localhost kernel: blk_zone_wplug_bio_work+0x4eb/0x740 2026-09-30T22:09:23.725762+08:00 localhost kernel: process_one_work+0x5c6/0xde0 2026-09-30T22:09:23.725764+08:00 localhost kernel: ? assign_work+0x124/0x4e0 2026-09-30T22:09:23.725765+08:00 localhost kernel: worker_thread+0x403/0xb70 2026-09-30T22:09:23.725765+08:00 localhost kernel: ? __kthread_parkme+0x82/0x140 2026-09-30T22:09:23.725766+08:00 localhost kernel: ? __pfx_worker_thread+0x10/0x10 2026-09-30T22:09:23.725766+08:00 localhost kernel: kthread+0x235/0x2e0 2026-09-30T22:09:23.725767+08:00 localhost kernel: ? recalc_sigpending+0x128/0x1d0 2026-09-30T22:09:23.725767+08:00 localhost kernel: ? __pfx_kthread+0x10/0x10 2026-09-30T22:09:23.725769+08:00 localhost kernel: ret_from_fork+0x2f/0x70 2026-09-30T22:09:23.725769+08:00 localhost kernel: ? __pfx_kthread+0x10/0x10 2026-09-30T22:09:23.725770+08:00 localhost kernel: ret_from_fork_asm+0x1a/0x30 2026-09-30T22:09:23.725771+08:00 localhost kernel: </TASK> 2026-09-30T22:09:23.725771+08:00 localhost kernel: F2FS-fs (dm-0): Stopped filesystem due to reason: 3
To prevent write bios destined for sequential zones from being split:
1. In __bio_alloc(), bound npages to bdev_max_segments(bdev) for writes to sequential zone areas.
2. In page_is_mergeable(), check queue_max_segments() and queue_max_sectors() for sequential zone areas, so f2fs will not merge beyond the queue limits.
--- fs/f2fs/data.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
fs/f2fs/data.c +17 -1
@@ -460,6 +460,10 @@ static struct bio *__bio_alloc(struct f2fs_io_info *fio, int npages)struct bio *bio; bdev =f2fs_target_device (sbi, fio->new_blkaddr, §or); +/* avoid reversed IO if bio is split due to exceeding max_segments */ +if (npages >1 && !is_read_io (fio->op) && +f2fs_is_sequential_zone_area (sbi, fio->new_blkaddr)) + npages =min_t (int, npages,bdev_max_segments (bdev)); bio =bio_alloc_bioset (bdev, npages, fio->op | fio->op_flags |f2fs_io_flags (fio),GFP_NOIO , &f2fs_bioset);
@@ -738,7 +742,19 @@ static bool page_is_mergeable(struct f2fs_sb_info *sbi, struct bio *bio,return false;if (last_blkaddr +1 != cur_blkaddr)return false; -return bio->bi_bdev ==f2fs_target_device (sbi, cur_blkaddr,NULL ); +if (bio->bi_bdev !=f2fs_target_device (sbi, cur_blkaddr,NULL )) +return false; +/* avoid reversed IO if bio is split due to exceeding max_segments/sectors */ +if (f2fs_is_sequential_zone_area (sbi, cur_blkaddr)) { +struct request_queue *q =bdev_get_queue (bio->bi_bdev); + +if (bio->bi_vcnt >=queue_max_segments (q)) +return false; +if (bio_sectors (bio) + (F2FS_BLKSIZE >>SECTOR_SHIFT ) > +queue_max_sectors (q)) +return false; + } +return true; } static bool io_type_is_mergeable(struct f2fs_bio_info *io,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 527/670 mm/mglru: fix ineffective memory protection for non-kswapd reclaim
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ridong Chen <[email protected]>
[ Upstream commit 15da1e4978dd4ea8f5faa6e15ee967ba4ad9a30a ]
For MGLRU, memory.min/low is not honored during global proactive reclaim (writing to the root memory.reclaim) and global direct reclaim, because these paths shrink memcgs using stale protection (emin/elow). It can be reproduced as follows:
# echo 7 > /sys/kernel/mm/lru_gen/enabled # cd /sys/fs/cgroup # mkdir -p a/b # echo 100M > a/memory.min # echo +memory > a/cgroup.subtree_control # echo 100M > a/b/memory.min # echo $$ > a/b/cgroup.procs # dd if=/dev/zero of=/tmp/testfile bs=1M count=200 # cat a/b/memory.current 222650368 # echo 500M > memory.reclaim -bash: echo: write error: Resource temporarily unavailable # cat a/b/memory.current 6070272
memory.min is 100M, yet reclaim drops a/b down to 6M, breaking the protection. The traditional LRU path is not affected because shrink_node() calls mem_cgroup_calculate_protection() for each memcg it visits during a top-down tree walk.
Commit 30d77b7eef01 ("mm/mglru: fix ineffective protection calculation") moved the protection computation into lru_gen_age_node(), which only runs for kswapd. Non-kswapd global reclaim reaches shrink_one() through lru_gen_shrink_node() -> shrink_many() without any protection computation, so emin/elow are whatever a previous kswapd run left behind - or zero if kswapd never ran on this node. Relying on a prior kswapd pass is not correct either: a memcg's emin/elow are derived from its ancestors' memory.min/low settings and from children_min_usage, both of which change over time, so emin/elow go stale even after kswapd has run and must be recomputed at the point of reclaim.
Introduce mem_cgroup_calculate_protection_path() which computes emin/elow along the root-to-target path only, by iterating through the cgroup ancestors array top-down. This avoids the full tree traversal that would be needed with mem_cgroup_calculate_protection(), limiting the cost to O(depth) per memcg - typically 3-5 levels.
Call it from shrink_one() for the non-kswapd path so that each memcg about to be shrunk has correct protection values.
--- include/linux/memcontrol.h | 10 +++++++++ mm/memcontrol.c | 45 ++++++++++++++++++++++++++++++++++++++ mm/vmscan.c | 8 ++++++- 3 files changed, 62 insertions(+), 1 deletion(-)
include/linux/memcontrol.h +10 -0
@@ -1884,6 +1884,16 @@ static inline void count_objcg_events(struct obj_cgroup *objcg,#endif /* CONFIG_MEMCG */ +#if defined(CONFIG_MEMCG ) && defined(CONFIG_LRU_GEN ) +void mem_cgroup_calculate_protection_path (struct mem_cgroup *root, +struct mem_cgroup *memcg); +#else +static inline void mem_cgroup_calculate_protection_path (struct mem_cgroup *root, +struct mem_cgroup *memcg) +{ +} +#endif +#if defined(CONFIG_MEMCG ) && defined(CONFIG_ZSWAP )bool obj_cgroup_may_zswap (struct obj_cgroup *objcg);void obj_cgroup_charge_zswap (struct obj_cgroup *objcg,size_t size);
mm/memcontrol.c +45 -0
51 lines not on this page · raw message
mm/vmscan.c +7 -1
@@ -4835,7 +4835,13 @@ static int shrink_one(struct lruvec *lruvec, struct scan_control *sc)struct mem_cgroup *memcg =lruvec_memcg (lruvec);struct pglist_data *pgdat =lruvec_pgdat (lruvec); -/* lru_gen_age_node() called mem_cgroup_calculate_protection() */ +/* +* For kswapd, mem_cgroup_calculate_protection() has already +* been called during the top-down cgroup traversal. +*/ +if (!current_is_kswapd ()) +mem_cgroup_calculate_protection_path (NULL , memcg); +if (mem_cgroup_below_min (NULL , memcg))return MEMCG_LRU_YOUNG ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 528/670 f2fs: return -EIO for a lost inode block after cp_error
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daeho Jeong <[email protected]>
[ Upstream commit 53b12b63304b34a3850a901c4de3cc6ad08e0aee ]
After cp_error, dirty node caches are dropped without being written. If such an inode was never written, its NAT entry is still NEW_ADDR, and reading its inode block returns -ENOENT.
f2fs_get_dnode_of_data() passes that -ENOENT up, and callers take it as a hole. Since the inode block is missing, the next offset can only advance one block, so fiemap walks block by block up to maxbytes, about 2^30 blocks, while holding the inode lock. It took hours in a power-off recovery test after shutdown and blocked unlink and umount on the file.
Return -EIO instead of -ENOENT when the inode block itself is missing after cp_error or shutdown. A missing direct or indirect node is still reported as -ENOENT.
--- fs/f2fs/node.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
fs/f2fs/node.c +14 -2
@@ -785,8 +785,20 @@ int f2fs_get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode)if (!npage[0 ]) { npage[0 ] =f2fs_get_node_page (sbi, nids[0 ]); -if (IS_ERR (npage[0 ])) -return PTR_ERR (npage[0 ]); +if (IS_ERR (npage[0 ])) { + err =PTR_ERR (npage[0 ]); +/* +* cp_error drops dirty node caches, so the inode block +* of an inode that was never written reads as NEW_ADDR +* and returns -ENOENT. It is not a hole; the inode is +* gone. Callers treat -ENOENT as a hole and keep +* looking block by block (e.g. fiemap up to maxbytes). +*/ +if (err == -ENOENT && (f2fs_cp_error (sbi) || +is_sbi_flag_set (sbi,SBI_IS_SHUTDOWN ))) + err = -EIO ; +return err; + } }/* if inline_data is set, should not report any block indices */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 529/670 drm/amd/pm:restate all customized OD features on every table upload for smu 13.0.0/smu 14.0.2
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kenneth Feng <[email protected]>
[ Upstream commit 44d0d3031e47973ed65fd327669d5e2eaaf6c565 ]
PMFW interprets OverDriveTable.FeatureCtrlMask as the complete set of overdrive features that are currently overridden, not as a delta describing the operation at hand. On import it resets every feature whose bit is clear back to its default value - for the VF curve that means zeroing VoltageOffsetPerZoneBoundary[] outright.
The driver assumed the opposite. smu_v14_0_2_od_edit_dpm_table() clears the mask after a successful commit, so a subsequent above-default power1_cap write goes through smu_v14_0_2_set_ppt_limit() and uploads a table carrying only PP_OD_FEATURE_PPT_BIT. PMFW then drops the user's voltage offset and reverts to the stock V/F curve, while the driver's cached user table still reports the offset through pp_od_clk_voltage.
--- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 2 + .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 34 +++++++---------- .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 31 +++++++-------- .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 38 +++++++++++-------- 4 files changed, 52 insertions(+), 53 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +2 -0
@@ -358,6 +358,8 @@ struct smu_table_context {void *boot_overdrive_table;void *user_overdrive_table; +uint32_t user_od_feature_mask; +uint32_t gpu_metrics_table_size;void *gpu_metrics_table; };
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +14 -20
@@ -1610,7 +1610,6 @@ static int smu_v13_0_0_od_edit_dpm_table(struct smu_context *smu,struct amdgpu_device *adev = smu->adev;uint32_t offset_of_voltageoffset;int32_t minimum, maximum; -uint32_t feature_ctrlmask;int i, ret =0 ;switch (type) {
@@ -1890,21 +1889,16 @@ static int smu_v13_0_0_od_edit_dpm_table(struct smu_context *smu,if (ret)return ret; }else { - feature_ctrlmask = od_table->OverDriveTable.FeatureCtrlMask;memcpy (od_table, table_context->boot_overdrive_table,sizeof (OverDriveTableExternal_t)); - od_table->OverDriveTable.FeatureCtrlMask = feature_ctrlmask; + od_table->OverDriveTable.FeatureCtrlMask =0 ; + table_context->user_od_feature_mask =0 ; } fallthrough;case PP_OD_COMMIT_DPM_TABLE : -/* -* The member below instructs PMFW the settings focused in -* this single operation. -* `uint32_t FeatureCtrlMask;` -* It does not contain actual informations about user's custom -* settings. Thus we do not cache it. -*/ + table_context->user_od_feature_mask = + od_table->OverDriveTable.FeatureCtrlMask; offset_of_voltageoffset = offsetof(OverDriveTable_t , VoltageOffsetPerZoneBoundary); if (memcmp((u8 *)od_table + offset_of_voltageoffset, table_context->user_overdrive_table + offset_of_voltageoffset,
@@ -1917,7 +1911,6 @@ static int smu_v13_0_0_od_edit_dpm_table(struct smu_context *smu,return ret; } - od_table->OverDriveTable.FeatureCtrlMask =0 ;memcpy (table_context->user_overdrive_table + offset_of_voltageoffset, (u8 *)od_table + offset_of_voltageoffset,sizeof (OverDriveTableExternal_t) - offset_of_voltageoffset);
@@ -2191,6 +2184,7 @@ static int smu_v13_0_0_set_default_od_settings(struct smu_context *smu) boot_od_table, sizeof(OverDriveTableExternal_t)); smu->user_dpm_profile.user_od = false; + smu->smu_table.user_od_feature_mask =0 ; }else if (smu->user_dpm_profile.user_od) { memcpy(&user_od_table_bak, user_od_table,
@@ -2236,11 +2230,8 @@ static int smu_v13_0_0_restore_user_od_settings(struct smu_context *smu)OverDriveTableExternal_t *od_table = table_context->overdrive_table;OverDriveTableExternal_t *user_od_table = table_context->user_overdrive_table;int res; - - user_od_table->OverDriveTable.FeatureCtrlMask =BIT (PP_OD_FEATURE_GFXCLK_BIT ) | -BIT (PP_OD_FEATURE_UCLK_BIT ) | -BIT (PP_OD_FEATURE_GFX_VF_CURVE_BIT ) | -BIT (PP_OD_FEATURE_FAN_CURVE_BIT ); + user_od_table->OverDriveTable.FeatureCtrlMask = + table_context->user_od_feature_mask; res =smu_v13_0_0_upload_overdrive_table (smu, user_od_table); user_od_table->OverDriveTable.FeatureCtrlMask =0 ;if (res ==0 )
@@ -3060,8 +3051,10 @@ static int smu_v13_0_0_set_power_limit(struct smu_context *smu,if (limit <= msg_limit) {if (smu->current_power_limit > msg_limit) { od_table->OverDriveTable.Ppt =0 ; - od_table->OverDriveTable.FeatureCtrlMask |=1U <<PP_OD_FEATURE_PPT_BIT ; - + table_context->user_od_feature_mask &= + ~(1U <<PP_OD_FEATURE_PPT_BIT ); + od_table->OverDriveTable.FeatureCtrlMask = + table_context->user_od_feature_mask; ret =smu_v13_0_0_upload_overdrive_table (smu, od_table);if (ret) {dev_err (smu->adev->dev,"Failed to upload overdrive table!\n" );
@@ -3075,8 +3068,9 @@ static int smu_v13_0_0_set_power_limit(struct smu_context *smu,return ret; od_table->OverDriveTable.Ppt = (limit *100 ) / msg_limit -100 ; - od_table->OverDriveTable.FeatureCtrlMask |=1U <<PP_OD_FEATURE_PPT_BIT ; - + table_context->user_od_feature_mask |=1U <<PP_OD_FEATURE_PPT_BIT ; + od_table->OverDriveTable.FeatureCtrlMask = + table_context->user_od_feature_mask; ret =smu_v13_0_0_upload_overdrive_table (smu, od_table);if (ret) {dev_err (smu->adev->dev,"Failed to upload overdrive table!\n" );
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +14 -17
@@ -1598,7 +1598,6 @@ static int smu_v13_0_7_od_edit_dpm_table(struct smu_context *smu,struct amdgpu_device *adev = smu->adev;uint32_t offset_of_voltageoffset;int32_t minimum, maximum; -uint32_t feature_ctrlmask;int i, ret =0 ;switch (type) {
@@ -1878,22 +1877,17 @@ static int smu_v13_0_7_od_edit_dpm_table(struct smu_context *smu,if (ret)return ret; }else { - feature_ctrlmask = od_table->OverDriveTable.FeatureCtrlMask;memcpy (od_table, table_context->boot_overdrive_table,sizeof (OverDriveTableExternal_t)); - od_table->OverDriveTable.FeatureCtrlMask = feature_ctrlmask; + od_table->OverDriveTable.FeatureCtrlMask =0 ; + table_context->user_od_feature_mask =0 ; } fallthrough;case PP_OD_COMMIT_DPM_TABLE : -/* -* The member below instructs PMFW the settings focused in -* this single operation. -* `uint32_t FeatureCtrlMask;` -* It does not contain actual informations about user's custom -* settings. Thus we do not cache it. -*/ + table_context->user_od_feature_mask = + od_table->OverDriveTable.FeatureCtrlMask; offset_of_voltageoffset = offsetof(OverDriveTable_t , VoltageOffsetPerZoneBoundary); if (memcmp((u8 *)od_table + offset_of_voltageoffset, table_context->user_overdrive_table + offset_of_voltageoffset,
@@ -1906,7 +1900,6 @@ static int smu_v13_0_7_od_edit_dpm_table(struct smu_context *smu,return ret; } - od_table->OverDriveTable.FeatureCtrlMask =0 ;memcpy (table_context->user_overdrive_table + offset_of_voltageoffset, (u8 *)od_table + offset_of_voltageoffset,sizeof (OverDriveTableExternal_t) - offset_of_voltageoffset);
@@ -2174,6 +2167,7 @@ static int smu_v13_0_7_set_default_od_settings(struct smu_context *smu) boot_od_table, sizeof(OverDriveTableExternal_t)); smu->user_dpm_profile.user_od = false; + smu->smu_table.user_od_feature_mask =0 ; }else if (smu->user_dpm_profile.user_od) { memcpy(&user_od_table_bak, user_od_table,
@@ -2220,10 +2214,8 @@ static int smu_v13_0_7_restore_user_od_settings(struct smu_context *smu)OverDriveTableExternal_t *user_od_table = table_context->user_overdrive_table;int res; - user_od_table->OverDriveTable.FeatureCtrlMask =BIT (PP_OD_FEATURE_GFXCLK_BIT ) | -BIT (PP_OD_FEATURE_UCLK_BIT ) | -BIT (PP_OD_FEATURE_GFX_VF_CURVE_BIT ) | -BIT (PP_OD_FEATURE_FAN_CURVE_BIT ); + user_od_table->OverDriveTable.FeatureCtrlMask = + table_context->user_od_feature_mask; res =smu_v13_0_7_upload_overdrive_table (smu, user_od_table); user_od_table->OverDriveTable.FeatureCtrlMask =0 ;if (res ==0 )
@@ -2641,7 +2633,10 @@ static int smu_v13_0_7_set_power_limit(struct smu_context *smu,if (limit <= msg_limit) {if (smu->current_power_limit > msg_limit) { od_table->OverDriveTable.Ppt =0 ; - od_table->OverDriveTable.FeatureCtrlMask |=1U <<PP_OD_FEATURE_PPT_BIT ; + table_context->user_od_feature_mask &= + ~(1U <<PP_OD_FEATURE_PPT_BIT ); + od_table->OverDriveTable.FeatureCtrlMask = + table_context->user_od_feature_mask; ret =smu_v13_0_7_upload_overdrive_table (smu, od_table);if (ret) {
@@ -2656,7 +2651,9 @@ static int smu_v13_0_7_set_power_limit(struct smu_context *smu,return ret; od_table->OverDriveTable.Ppt = (limit *100 ) / msg_limit -100 ; - od_table->OverDriveTable.FeatureCtrlMask |=1U <<PP_OD_FEATURE_PPT_BIT ; + table_context->user_od_feature_mask |=1U <<PP_OD_FEATURE_PPT_BIT ; + od_table->OverDriveTable.FeatureCtrlMask = + table_context->user_od_feature_mask; ret =smu_v13_0_7_upload_overdrive_table (smu, od_table);if (ret) {
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c +22 -16
@@ -2350,6 +2350,7 @@ static int smu_v14_0_2_set_default_od_settings(struct smu_context *smu) boot_od_table, sizeof(OverDriveTableExternal_t)); smu->user_dpm_profile.user_od = false; + smu->smu_table.user_od_feature_mask =0 ; }else if (smu->user_dpm_profile.user_od) { memcpy(&user_od_table_bak, user_od_table,
@@ -2394,11 +2395,8 @@ static int smu_v14_0_2_restore_user_od_settings(struct smu_context *smu)OverDriveTableExternal_t *user_od_table = table_context->user_overdrive_table;int res; - user_od_table->OverDriveTable.FeatureCtrlMask =BIT (PP_OD_FEATURE_GFXCLK_BIT ) | -BIT (PP_OD_FEATURE_UCLK_BIT ) | -BIT (PP_OD_FEATURE_GFX_VF_CURVE_BIT ) | -BIT (PP_OD_FEATURE_FAN_CURVE_BIT ) | -BIT (PP_OD_FEATURE_ZERO_FAN_BIT ); + user_od_table->OverDriveTable.FeatureCtrlMask = + table_context->user_od_feature_mask; res =smu_v14_0_2_upload_overdrive_table (smu, user_od_table); user_od_table->OverDriveTable.FeatureCtrlMask =0 ;if (res ==0 )
@@ -2473,7 +2471,6 @@ static int smu_v14_0_2_od_edit_dpm_table(struct smu_context *smu,struct amdgpu_device *adev = smu->adev;uint32_t offset_of_voltageoffset;int32_t minimum, maximum; -uint32_t feature_ctrlmask;int i, ret =0 ;switch (type) {
@@ -2720,21 +2717,26 @@ static int smu_v14_0_2_od_edit_dpm_table(struct smu_context *smu,if (ret)return ret; }else { - feature_ctrlmask = od_table->OverDriveTable.FeatureCtrlMask;memcpy (od_table, table_context->boot_overdrive_table,sizeof (OverDriveTableExternal_t)); - od_table->OverDriveTable.FeatureCtrlMask = feature_ctrlmask; + od_table->OverDriveTable.FeatureCtrlMask =0 ; + table_context->user_od_feature_mask =0 ; } fallthrough;case PP_OD_COMMIT_DPM_TABLE :/* -* The member below instructs PMFW the settings focused in -* this single operation. -* `uint32_t FeatureCtrlMask;` -* It does not contain actual informations about user's custom -* settings. Thus we do not cache it. +* PMFW interprets FeatureCtrlMask as the complete set of OD +* features that are currently overridden, not as a delta +* describing this single operation. Any feature whose bit is +* clear gets reset to its default on import. od_table's mask +* has accumulated every feature the user touched since the +* last full restore, so record it and keep restating it on +* subsequent uploads. */ + table_context->user_od_feature_mask = + od_table->OverDriveTable.FeatureCtrlMask; + offset_of_voltageoffset = offsetof(OverDriveTable_t , VoltageOffsetPerZoneBoundary); if (memcmp((u8 *)od_table + offset_of_voltageoffset, table_context->user_overdrive_table + offset_of_voltageoffset,
@@ -2747,7 +2749,6 @@ static int smu_v14_0_2_od_edit_dpm_table(struct smu_context *smu,return ret; } - od_table->OverDriveTable.FeatureCtrlMask =0 ;memcpy (table_context->user_overdrive_table + offset_of_voltageoffset, (u8 *)od_table + offset_of_voltageoffset,sizeof (OverDriveTableExternal_t) - offset_of_voltageoffset);
@@ -2785,7 +2786,10 @@ static int smu_v14_0_2_set_power_limit(struct smu_context *smu,if (limit <= msg_limit) {if (smu->current_power_limit > msg_limit) { od_table->OverDriveTable.Ppt =0 ; - od_table->OverDriveTable.FeatureCtrlMask |=1U <<PP_OD_FEATURE_PPT_BIT ; + table_context->user_od_feature_mask &= + ~(1U <<PP_OD_FEATURE_PPT_BIT ); + od_table->OverDriveTable.FeatureCtrlMask = + table_context->user_od_feature_mask; ret =smu_v14_0_2_upload_overdrive_table (smu, od_table);if (ret) {
@@ -2800,7 +2804,9 @@ static int smu_v14_0_2_set_power_limit(struct smu_context *smu,return ret; od_table->OverDriveTable.Ppt = (limit *100 ) / msg_limit -100 ; - od_table->OverDriveTable.FeatureCtrlMask |=1U <<PP_OD_FEATURE_PPT_BIT ; + table_context->user_od_feature_mask |=1U <<PP_OD_FEATURE_PPT_BIT ; + od_table->OverDriveTable.FeatureCtrlMask = + table_context->user_od_feature_mask; ret =smu_v14_0_2_upload_overdrive_table (smu, od_table);if (ret) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 530/670 mfd: twl-core: Use i2c_check_functionality as boolean value
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 7ee4fa2674e51a0d100b9240cd8a50355141362f ]
i2c_check_functionality() returns a boolean status rather than an error code - directly use it as a boolean value.
Stable-dep-of: 3c5c55d979dd ("mfd: twl-core: Unregister the auxiliary platform device on unbind")
--- drivers/mfd/twl-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/twl-core.c +1 -1
@@ -750,7 +750,7 @@ twl_probe(struct i2c_client *client)return status; } -if (i2c_check_functionality (client->adapter,I2C_FUNC_I2C ) ==0 ) { +if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) {dev_dbg (&client->dev,"can't talk I2C?\n" ); status = -EIO ; goto free;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 531/670 mfd: twl-core: Unregister the auxiliary platform device on unbind
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 3c5c55d979ddcb0765ce531bc7ba173c87c8712a ]
twl_probe() registers a standalone platform device named "twl", but keeps its pointer only in a local variable. Probe errors unregister the device, while successful probe leaves no way for twl_remove() to release it. The platform device therefore remains registered after the I2C driver unbinds.
Register a managed action on the I2C device immediately after adding the platform device. This unregisters it on probe failure and driver unbind, and also handles failure to register the action itself. Remove the manual error-path unregister to avoid releasing the device twice.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/mfd/twl-core.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
drivers/mfd/twl-core.c +15 -8
@@ -715,6 +715,11 @@ static const struct mfd_cell twl6032_cells[] = { { .name = "twl6032-clk" }, }; +static void twl_unregister_device (void *data) +{ +platform_device_unregister (data); +} +/* NOTE: This driver only handles a single twl4030/tps659x0 chip */ static int twl_probe (struct i2c_client *client)
@@ -750,17 +755,22 @@ twl_probe(struct i2c_client *client)return status; } + status =devm_add_action_or_reset (&client->dev, twl_unregister_device, + pdev); +if (status) +return status; +if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) {dev_dbg (&client->dev,"can't talk I2C?\n" ); status = -EIO ; - goto free; + goto out; } twl_priv =devm_kzalloc (&client->dev,sizeof (struct twl_private ),GFP_KERNEL );if (!twl_priv) { status = -ENOMEM ; - goto free; + goto out; }if ((id->driver_data) &TWL6030_CLASS ) {
@@ -780,7 +790,7 @@ twl_probe(struct i2c_client *client) GFP_KERNEL);if (!twl_priv->twl_modules) { status = -ENOMEM ; - goto free; + goto out; }for (i =0 ; i < num_slaves; i++) {
@@ -868,7 +878,7 @@ twl_probe(struct i2c_client *client)ARRAY_SIZE (twl6032_cells), NULL, 0, NULL);if (status <0 ) - goto free; + goto out; }if (twl_class_is_6030 ()) {
@@ -886,10 +896,7 @@ twl_probe(struct i2c_client *client) fail:if (status <0 )twl_remove (client); -free: -if (status <0 ) -platform_device_unregister (pdev); - +out:return status; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 532/670 ALSA: hda/hdmi: clamp sad_count in ELD proc write handler
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
[ Upstream commit b3e7ddd694f8429217ba509b55b910a0e4361dfb ]
snd_hdmi_write_eld_info() parses a "sad_count N" line from the root-writable ELD proc interface and assigns N directly to e->sad_count with no upper bound, unlike the per-index "sadN_*" lines a few lines below which are already bounded to ELD_MAX_SAD.
snd_hdmi_eld_update_pcm_info() later iterates
"for (i = 0; i < e->sad_count; i++)" over the fixed e->sad[ELD_MAX_SAD] array, so an oversized sad_count read from the proc file causes it to walk past the array.
Reject sad_count values above ELD_MAX_SAD, matching the existing per-index guard.
--- sound/pci/hda/hda_eld.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/pci/hda/hda_eld.c +4 -2
@@ -525,9 +525,11 @@ void snd_hdmi_write_eld_info(struct hdmi_eld *eld, e->aud_synch_delay = val; else if (!strcmp(name, "speakers")) e->spk_alloc = val; - else if (!strcmp(name, "sad_count")) + else if (!strcmp(name, "sad_count")) { +if (val >ELD_MAX_SAD ) +continue ; e->sad_count = val; - else if (!strncmp(name, "sad", 3)) { + } else if (!strncmp(name, "sad", 3)) { sname = name +4 ; n = name[3 ] -'0' ;if (name[4 ] >='0' && name[4 ] <='9' ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 533/670 mailbox: altera: shut down RX polling timer on channel teardown
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 0cf10e65639cba32d05994f85e6a8f08dd0ffe08 ]
The RX polling callback unconditionally rearms the timer after it processes mailbox data. altera_mbox_shutdown() uses timer_delete_sync(), which waits for a running callback but does not prevent that callback from rearming the timer after the deletion.
Use timer_shutdown_sync() for the final polling teardown so the timer cannot be queued again while the mailbox channel is being released. The timer is reinitialized with timer_setup() on a later channel startup, so polling mode remains reusable.
--- drivers/mailbox/mailbox-altera.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mailbox/mailbox-altera.c +1 -1
@@ -270,7 +270,7 @@ static void altera_mbox_shutdown(struct mbox_chan *chan)writel_relaxed (~0 , mbox->mbox_base +MAILBOX_INTMASK_REG );free_irq (mbox->irq, chan); }else if (!mbox->is_sender) { -del_timer_sync (&mbox->rxpoll_timer); +timer_shutdown_sync (&mbox->rxpoll_timer); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 534/670 ALSA: hda: cs35l41: Use auto-cleanup for put_device()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit c437a83cc69645edab8e0bfc450a3b706abe759e ]
A temporary refcount management of a struct device can be done gracefully with __clean(put_device) for avoiding potential leaks.
No functional change but just a code cleanup.
Stable-dep-of: 8d70e364e866 ("ALSA: hda: cs35l41: Fix ACPI device reference leak on probe failure")
--- sound/pci/hda/cs35l41_hda.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
sound/pci/hda/cs35l41_hda.c +3 -7
@@ -1895,7 +1895,6 @@ int cs35l41_hda_parse_acpi(struct cs35l41_hda *cs35l41, struct device *physdev,static int cs35l41_hda_read_acpi (struct cs35l41_hda *cs35l41,const char *hid,int id) {struct acpi_device *adev; -struct device *physdev;struct spi_device *spi;const char *sub;int ret;
@@ -1907,7 +1906,8 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i } cs35l41->dacpi = adev; - physdev =get_device (acpi_get_first_physical_node (adev)); + struct device *physdev __free(put_device) = +get_device (acpi_get_first_physical_node (adev));if (!physdev) {acpi_dev_put (adev);return -ENODEV ;
@@ -1925,13 +1925,9 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i } ret =cs35l41_hda_parse_acpi (cs35l41, physdev, id); -if (ret) { -put_device (physdev); +if (ret)return ret; - } out: -put_device (physdev); - cs35l41->bypass_fw = false;if (cs35l41->control_bus ==SPI ) { spi =to_spi_device (cs35l41->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 535/670 ALSA: hda: cs35l41: Fix ACPI device reference leak on probe failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
[ Upstream commit 8d70e364e866bdfca81eee24d0688fac9472cfb9 ]
cs35l41_hda_probe() takes an acpi_device through cs35l41_hda_read_acpi() and stores it in cs35l41->dacpi. Only the failures that happen later reach the err: label, which is where that reference and cs35l41->acpi_subsystem_id are released, so the early return taken when cs35l41_hda_read_acpi() fails leaves both behind.
Keep the ownership in the caller instead of dropping the reference inside cs35l41_hda_read_acpi(). That removes the need to work out whether a given failure path has already released it, and with it the double put that cs35l41_hda_parse_acpi() would otherwise cause when it fails after having released the device itself.
cs35l41_hda_parse_acpi() and the !physdev path no longer put the reference, and the early failure enters the existing err: cleanup tail through a new err_acpi label.
The label sits between the reset of the codec and the gpio cleanup, so an early failure also releases the reset and chip-select descriptors that cs35l41_hda_parse_acpi() may already have taken, while still skipping cs35l41_safe_reset() on a codec that was never brought up.
cs35l41->dacpi comes from devm_kzalloc() and is only assigned once the ACPI device has been found, so the put is a no-op when the lookup itself failed.
Found by code review.
--- sound/pci/hda/cs35l41_hda.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
sound/pci/hda/cs35l41_hda.c +6 -6
@@ -1887,7 +1887,6 @@ int cs35l41_hda_parse_acpi(struct cs35l41_hda *cs35l41, struct device *physdev, hw_cfg->valid = false; hw_cfg->gpio1.valid = false; hw_cfg->gpio2.valid = false; -acpi_dev_put (cs35l41->dacpi);return ret; }
@@ -1908,10 +1907,8 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i cs35l41->dacpi = adev; struct device *physdev __free(put_device) =get_device (acpi_get_first_physical_node (adev)); -if (!physdev) { -acpi_dev_put (adev); +if (!physdev)return -ENODEV ; - } sub =acpi_get_subsystem_id (ACPI_HANDLE (physdev));if (IS_ERR (sub))
@@ -1966,8 +1963,10 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int idev_set_drvdata (dev, cs35l41); ret =cs35l41_hda_read_acpi (cs35l41, device_name, id); -if (ret) -return dev_err_probe (cs35l41->dev, ret,"Platform not supported\n" ); +if (ret) { +dev_err_probe (cs35l41->dev, ret,"Platform not supported\n" ); + goto err_acpi; + }if (IS_ERR (cs35l41->reset_gpio)) { ret =PTR_ERR (cs35l41->reset_gpio);
@@ -2055,6 +2054,7 @@ int cs35l41_hda_probe(struct device *dev, const char *device_name, int id, int i err:if (cs35l41_safe_reset (cs35l41->regmap, cs35l41->hw_cfg.bst_type))gpiod_set_value_cansleep (cs35l41->reset_gpio,0 ); +err_acpi:gpiod_put (cs35l41->reset_gpio);gpiod_put (cs35l41->cs_gpio);acpi_dev_put (cs35l41->dacpi);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 536/670 platform/x86: asus-wmi: Serialize WMI method evaluations with a mutex
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Scardovi <[email protected]>
[ Upstream commit b9428edaf4109e86a97254228d831767d0acc1f8 ]
Concurrent evaluations of ASUS WMI management methods (from ACPI notify, HID, userspace daemons, and debugfs) enter the BIOS ACPI/SMM interface simultaneously, triggering re-entrant SMIs or EC mailbox buffer corruption.
Fix this at the root by introducing a centralized evaluation helper (asus_wmi_evaluate_method_locked()) protected by a global mutex (asus_wmi_eval_lock) using guard(mutex). Route all evaluations of ASUS_WMI_MGMT_GUID (method3, method5, method_buf, and show_call) through this helper.
A static mutex is required because asus_wmi_evaluate_method() is an exported symbol used by external modules (such as hid-asus and asus-armoury) that lack access to struct asus_wmi drvdata, and the underlying ASUS ACPI/EC management method is a single physical platform resource.
The mutex is non-recursive: nested ACPI/WMI notify handlers must not call back into evaluate on the same task (defer via workqueue, as asus_rfkill_notify already does).
The sysfs-versus-notify race predates the later export of asus_wmi_evaluate_method(), so Fixes points at the original shared evaluate helper rather than that export.
--- drivers/platform/x86/asus-wmi.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
drivers/platform/x86/asus-wmi.c +21 -9
@@ -15,6 +15,7 @@#include <linux/acpi.h> #include <linux/backlight.h> +#include <linux/cleanup.h> #include <linux/debugfs.h> #include <linux/delay.h> #include <linux/dmi.h>
@@ -27,6 +28,7 @@#include <linux/leds.h> #include <linux/minmax.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/pci.h> #include <linux/pci_hotplug.h> #include <linux/platform_data/x86/asus-wmi.h>
@@ -337,6 +339,20 @@ struct asus_wmi {/* WMI ************************************************************************/ +/* +* Concurrent evaluations of ASUS WMI methods can re-enter firmware +* SMI/EC mailbox handling and corrupt the mailbox. +*/ +static DEFINE_MUTEX (asus_wmi_eval_lock); + +static acpi_status asus_wmi_evaluate_method_locked (u32 method_id, +struct acpi_buffer *input, +struct acpi_buffer *output) +{ +guard (mutex)(&asus_wmi_eval_lock); +return wmi_evaluate_method (ASUS_WMI_MGMT_GUID ,0 , method_id, input, output); +} +static int asus_wmi_evaluate_method3 (u32 method_id,u32 arg0,u32 arg1,u32 arg2,u32 *retval) {
@@ -351,8 +367,7 @@ static int asus_wmi_evaluate_method3(u32 method_id,union acpi_object *obj;u32 tmp =0 ; - status =wmi_evaluate_method (ASUS_WMI_MGMT_GUID ,0 , method_id, - &input, &output); + status =asus_wmi_evaluate_method_locked (method_id, &input, &output);pr_debug ("%s called (0x%08x) with args: 0x%08x, 0x%08x, 0x%08x\n" , __func__, method_id, arg0, arg1, arg2);
@@ -403,8 +418,7 @@ static int asus_wmi_evaluate_method5(u32 method_id,union acpi_object *obj;u32 tmp =0 ; - status =wmi_evaluate_method (ASUS_WMI_MGMT_GUID ,0 , method_id, - &input, &output); + status =asus_wmi_evaluate_method_locked (method_id, &input, &output);pr_debug ("%s called (0x%08x) with args: 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x\n" , __func__, method_id, arg0, arg1, arg2, arg3, arg4);
@@ -451,8 +465,7 @@ static int asus_wmi_evaluate_method_buf(u32 method_id,union acpi_object *obj;int err =0 ; - status =wmi_evaluate_method (ASUS_WMI_MGMT_GUID ,0 , method_id, - &input, &output); + status =asus_wmi_evaluate_method_locked (method_id, &input, &output);pr_debug ("%s called (0x%08x) with args: 0x%08x, 0x%08x\n" , __func__, method_id, arg0, arg1);
@@ -4632,9 +4645,8 @@ static int show_call(struct seq_file *m, void *data)union acpi_object *obj;acpi_status status; - status =wmi_evaluate_method (ASUS_WMI_MGMT_GUID , -0 , asus->debug.method_id, - &input, &output); + status =asus_wmi_evaluate_method_locked (asus->debug.method_id, + &input, &output);if (ACPI_FAILURE (status))return -EIO ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 537/670 mm: disallow ioremaping ordinary RAM in generic_access_phys()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <[email protected]>
[ Upstream commit 4590752e20aa393cc0d4fe538c0747d14a98c97a ]
generic_access_phys() can end up getting called on CoW PFNMAP mappings, resulting in it trying to ioremap anonymous folios, which especially the x86 code doesn't enjoy, and which is in general just odd/wrong.
E.g., with a CoW mapping of a PCI BAR:
ioremap on RAM at 0x0000000045623000 - 0x0000000045623fff
WARNING: arch/x86/mm/ioremap.c:216 at __ioremap_caller.isra.0+0x4c2/0x5f0 Call Trace: generic_access_phys+0x130/0x4d0 mm/memory.c:7178 kernfs_vma_access+0x1ce/0x280 fs/kernfs/file.c:437 __access_remote_vm+0x58f/0x890 mm/memory.c:7256 mem_rw+0x2a1/0x670 fs/proc/base.c:912
But more generically, we should disallow access to anything that looks like ordinary RAM in the system: including allocating memory (e.g., alloc_pages) and mapping them in a VM_PFNMAP.
For pages with an online memmap, allow only pages marked as reserved (PageReserved). This also includes memblock allocations, however, distinguishing them from other MMIO is tricky, and nobody should really be mapping them in a PFNMAP (except someone abusing /dev/mem, which we do not care about).
So only allow access if there is no online memmap, or if the pages are marked reserved. Reject other pages with -EINVAL.
Note that, just like other pfn_to_online_page() users, we won't care about concurrent memory offlining; mapping memory that can concurrently get offlined is highly dubious.
--- mm/memory.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
mm/memory.c +14 -0
@@ -6567,6 +6567,7 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,resource_size_t phys_addr;unsigned long prot =0 ;void __iomem *maddr; +struct page *page;int offset =offset_in_page (addr);int ret = -EINVAL ;bool writable;
@@ -6575,6 +6576,19 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr, retry:if (follow_pfnmap_start (&args))return -EINVAL ; + +/* +* Reject anything that looks like ordinary RAM, including anonymous +* folios in CoW mappings or allocated kernel memory. Note that we +* cannot distinguish memblock allocations from non-RAM reliably, so +* we cannot easily reject them here. +*/ + page =pfn_to_online_page (args.pfn); +if (page && !PageReserved (page)) { +follow_pfnmap_end (&args); +return -EINVAL ; + } + prot =pgprot_val (args.pgprot); phys_addr = (resource_size_t )args.pfn <<PAGE_SHIFT ; writable = args.writable;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 538/670 KVM: arm64: Move IN_GUEST_MODE ahead of state being loaded
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
[ Upstream commit 22b6557ad05bf05c73246f62c19af3e04017270e ]
IN_GUEST_MODE is advertised too late, when state has already been moved onto CPU registers and cannot be observed by another CPU anymore.
Move the IN_GUEST_MODE publication ahead of the state being loaded, and immediately check for pending request. This ensures that there is no window of opportunity for another CPU to observe OUTSIDE_GUEST_MODE and yet for state to be loaded.
This also simplifies the "state rollback", which solely amounts to synchronising the timer when no irqchip is present.
--- arch/arm64/kvm/arm.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
arch/arm64/kvm/arm.c +10 -7
@@ -1189,30 +1189,33 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)local_irq_disable (); -kvm_vgic_flush_hwstate (vcpu); - -kvm_pmu_update_vcpu_events (vcpu); -/* * Ensure we set mode to IN_GUEST_MODE after we disable * interrupts and before the final VCPU requests check. * See the comment in kvm_vcpu_exiting_guest_mode() and * Documentation/virt/kvm/vcpu-requests.rst +* +* Requests to self must be posted before this point, or +* won't be taken into account until the next exit. No state +* loading other than what happens at vcpu_load() time can +* be done before we have checked for pending requests. */ smp_store_mb (vcpu->mode,IN_GUEST_MODE );if (ret <=0 ||kvm_vcpu_exit_request (vcpu, &ret)) { -isb ();/* Ensure work in x_flush_hwstate is committed */ -kvm_pmu_sync_hwstate (vcpu);if (unlikely (!irqchip_in_kernel (vcpu->kvm)))kvm_timer_sync_user (vcpu); -kvm_vgic_sync_hwstate (vcpu);smp_store_release (&vcpu->mode,OUTSIDE_GUEST_MODE );local_irq_enable ();preempt_enable ();continue ; } +/* From here onwards, we are commited to entering the guest */ +kvm_vgic_flush_hwstate (vcpu); + +kvm_pmu_update_vcpu_events (vcpu); +kvm_arm_setup_debug (vcpu);kvm_arch_vcpu_ctxflush_fp (vcpu);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 539/670 media: rockchip: rga: use clk_bulk api
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Püschel <[email protected]>
[ Upstream commit a2a4f69fd2e333bacd17d1788eb5211cb6f373cc ]
Use the clk_bulk API to avoid code duplication for each of the three clocks.
Stable-dep-of: a875c43dd95e ("media: rockchip: rga: quiesce IRQ before releasing m2m state")
--- drivers/media/platform/rockchip/rga/rga.c | 65 +++-------------------- drivers/media/platform/rockchip/rga/rga.h | 6 +-- 2 files changed, 11 insertions(+), 60 deletions(-)
drivers/media/platform/rockchip/rga/rga.c +8 -57
@@ -704,48 +704,10 @@ static const struct video_device rga_videodev = { .device_caps = V4L2_CAP_VIDEO_M2M_MPLANE | V4L2_CAP_STREAMING, }; -static int rga_enable_clocks (struct rockchip_rga *rga) -{ -int ret; - - ret =clk_prepare_enable (rga->sclk); -if (ret) { -dev_err (rga->dev,"Cannot enable rga sclk: %d\n" , ret); -return ret; - } - - ret =clk_prepare_enable (rga->aclk); -if (ret) { -dev_err (rga->dev,"Cannot enable rga aclk: %d\n" , ret); - goto err_disable_sclk; - } - - ret =clk_prepare_enable (rga->hclk); -if (ret) { -dev_err (rga->dev,"Cannot enable rga hclk: %d\n" , ret); - goto err_disable_aclk; - } - -return 0 ; - -err_disable_aclk: -clk_disable_unprepare (rga->aclk); -err_disable_sclk: -clk_disable_unprepare (rga->sclk); - -return ret; -} - -static void rga_disable_clocks (struct rockchip_rga *rga) -{ -clk_disable_unprepare (rga->sclk); -clk_disable_unprepare (rga->hclk); -clk_disable_unprepare (rga->aclk); -} -static int rga_parse_dt (struct rockchip_rga *rga) {struct reset_control *core_rst, *axi_rst, *ahb_rst; +int ret; core_rst =devm_reset_control_get (rga->dev,"core" );if (IS_ERR (core_rst)) {
@@ -777,23 +739,12 @@ static int rga_parse_dt(struct rockchip_rga *rga)udelay (1 );reset_control_deassert (ahb_rst); - rga->sclk =devm_clk_get (rga->dev,"sclk" ); -if (IS_ERR (rga->sclk)) { -dev_err (rga->dev,"failed to get sclk clock\n" ); -return PTR_ERR (rga->sclk); - } - - rga->aclk =devm_clk_get (rga->dev,"aclk" ); -if (IS_ERR (rga->aclk)) { -dev_err (rga->dev,"failed to get aclk clock\n" ); -return PTR_ERR (rga->aclk); - } - - rga->hclk =devm_clk_get (rga->dev,"hclk" ); -if (IS_ERR (rga->hclk)) { -dev_err (rga->dev,"failed to get hclk clock\n" ); -return PTR_ERR (rga->hclk); + ret =devm_clk_bulk_get_all (rga->dev, &rga->clks); +if (ret <0 ) { +dev_err (rga->dev,"failed to get clocks\n" ); +return ret; } + rga->num_clks = ret;return 0 ; }
@@ -941,7 +892,7 @@ static int __maybe_unused rga_runtime_suspend(struct device *dev) {struct rockchip_rga *rga =dev_get_drvdata (dev); -rga_disable_clocks (rga); +clk_bulk_disable_unprepare (rga->num_clks, rga->clks);return 0 ; }
@@ -950,7 +901,7 @@ static int __maybe_unused rga_runtime_resume(struct device *dev) {struct rockchip_rga *rga =dev_get_drvdata (dev); -return rga_enable_clocks (rga); +return clk_bulk_prepare_enable (rga->num_clks, rga->clks); }static const struct dev_pm_ops rga_pm = {
drivers/media/platform/rockchip/rga/rga.h +3 -3
@@ -6,6 +6,7 @@#ifndef __RGA_H__#define __RGA_H__ +#include <linux/clk.h> #include <linux/platform_device.h> #include <media/videobuf2-v4l2.h> #include <media/v4l2-ctrls.h>
@@ -76,9 +77,8 @@ struct rockchip_rga {struct device *dev;struct regmap *grf;void __iomem *regs; -struct clk *sclk; -struct clk *aclk; -struct clk *hclk; +struct clk_bulk_data *clks; +int num_clks;struct rockchip_rga_version version;/* vfd lock */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 540/670 media: rockchip: rga: quiesce IRQ before releasing m2m state
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit a875c43dd95ee4f9c4e3e5ae1cb8362cc6d7817d ]
rga_remove() releases the m2m state before the IRQ is freed. The IRQ is devm-managed and is only released once rga_remove() returns, so rga_isr() can still run while the m2m device state is being torn down.
Store the IRQ number in struct rockchip_rga, unregister the video device first, and free the IRQ before releasing the m2m state so the handler cannot run against the freed state.
--- drivers/media/platform/rockchip/rga/rga.c | 4 +++- drivers/media/platform/rockchip/rga/rga.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/rockchip/rga/rga.c +3 -1
@@ -784,6 +784,7 @@ static int rga_probe(struct platform_device *pdev) ret = irq; goto err_put_clk; } + rga->irq = irq; ret =devm_request_irq (rga->dev, irq, rga_isr,0 ,dev_name (rga->dev), rga);
@@ -881,8 +882,9 @@ static void rga_remove(struct platform_device *pdev)v4l2_info (&rga->v4l2_dev,"Removing\n" ); -v4l2_m2m_release (rga->m2m_dev);video_unregister_device (rga->vfd); +devm_free_irq (rga->dev, rga->irq, rga); +v4l2_m2m_release (rga->m2m_dev);v4l2_device_unregister (&rga->v4l2_dev);pm_runtime_disable (rga->dev);
drivers/media/platform/rockchip/rga/rga.h +1 -0
@@ -77,6 +77,7 @@ struct rockchip_rga {struct device *dev;struct regmap *grf;void __iomem *regs; +int irq;struct clk_bulk_data *clks;int num_clks;struct rockchip_rga_version version;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 541/670 xfarray: dont crash when sorting if array element crosses a folio
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darrick J. Wong <[email protected]>
[ Upstream commit 329750292e9dfbb594b375d7b30cf5ddb58b7bb9 ]
LOLLM points out that if an array element crosses a folio boundary, xfile_get_folio returns a NULL folio pointer. If this happens, si->folio is also set to NULL, and calling folio_pos/folio_address will just crash the kernel. Teach this function to handle this condition by falling back to reading the array element into scratchpad memory.
--- fs/xfs/scrub/xfarray.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
fs/xfs/scrub/xfarray.c +18 -4
@@ -819,7 +819,7 @@ xfarray_sort_scan( (idx < si->first_folio_idx || idx > si->last_folio_idx))xfarray_sort_scan_done (si); -/* Grab the first folio that backs this array element. */ +/* Grab the folio that backs this array element. */ if (!si->folio) {struct folio *folio;loff_t next_pos;
@@ -830,6 +830,10 @@ xfarray_sort_scan(return PTR_ERR (folio); si->folio = folio; +/* No folio? Read into the scratchpad. */ +if (!si->folio) + goto read_scratchpad; + si->first_folio_idx =xfarray_idx (si->array,folio_pos (si->folio) + si->array->obj_size -1 );
@@ -838,14 +842,24 @@ xfarray_sort_scan(if (xfarray_pos (si->array, si->last_folio_idx +1 ) > next_pos) si->last_folio_idx--; +/* +* If this folio still doesn't cover the desired element, it must +* cross a folio boundary. Read into the scratchpad. +*/ +if (idx < si->first_folio_idx || idx > si->last_folio_idx) { +xfarray_sort_scan_done (si); + goto read_scratchpad; + } +trace_xfarray_sort_scan (si, idx); } +read_scratchpad:/* -* If this folio still doesn't cover the desired element, it must cross -* a folio boundary. Read into the scratchpad and we're done. +* If we don't have a folio mapping the entire array element, read into +* the scratchpad and we're done. */ -if (idx < si->first_folio_idx || idx > si->last_folio_idx) { +if (!si->folio) {void *temp =xfarray_scratch (si->array); error = xfile_load(si->array->xfile, temp, si->array->obj_size,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 542/670 fbdev: core: Initialize modelist in framebuffer_alloc()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Misiurov <[email protected]>
[ Upstream commit 0c9cb9321cb3863b52bdea4b8ae5a27705762c9e ]
framebuffer_alloc() returns zeroed memory, so info->modelist starts out with NULL next and prev pointers. The list head is initialized only later, by fb_videomode_to_modelist() or by do_register_framebuffer().
The "fix potential memory leak" commits listed below added fb_destroy_modelist(&info->modelist) to the probe error paths of s3fb, tdfxfb, tridentfb, i740fb and carminefb. These paths can run before the list head is initialized:
- s3fb, tdfxfb, tridentfb and i740fb call fb_videomode_to_modelist() only after a successful EDID read, and tridentfb can also hit the error path on an ioremap() or kmalloc() failure before that;
- carminefb jumps to the error path when fb_find_mode() fails, before its fb_videomode_to_modelist() call.
fb_destroy_modelist() then dereferences the NULL head. Reproduced on Debian 12 (6.1.180) by binding s3fb to a VGA device without EDID and forcing fb_alloc_cmap() to fail:
s3fb 0000:00:03.0: cannot allocate colormap
BUG: kernel NULL pointer dereference, address: 0000000000000000 RIP: 0010:fb_destroy_modelist+0x10/0x80 Call Trace: s3_pci_probe.cold+0x12b/0x2bf [s3fb] local_pci_probe+0x41/0x80 pci_device_probe+0xc3/0x240 really_probe+0xde/0x380 __driver_probe_device+0x84/0x150 driver_probe_device+0x1f/0x90 __driver_attach+0xce/0x1c0 bus_for_each_dev+0x87/0xd0 bus_add_driver+0x1ae/0x200 driver_register+0x89/0xe0 do_one_initcall+0x59/0x220 do_init_module+0x4a/0x1f0
Initialize the list head in framebuffer_alloc(), so info->modelist is always a valid, possibly empty, list and fb_destroy_modelist() is safe on every error path. Keep the lazy initialization in do_register_framebuffer(), as drivers that embed struct fb_info rather than calling framebuffer_alloc() still depend on it.
--- drivers/video/fbdev/core/fb_info.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/core/fb_info.c +1 -0
@@ -42,6 +42,7 @@ struct fb_info *framebuffer_alloc(size_t size, struct device *dev) info->device = dev; info->fbcon_rotate_hint =-1 ; +INIT_LIST_HEAD (&info->modelist);#if IS_ENABLED (CONFIG_FB_BACKLIGHT )mutex_init (&info->bl_curve_mutex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 543/670 s390/pci: Add error cleanup in zpci_directed_irq_init()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tobias Schumacher <[email protected]>
[ Upstream commit 769f66f595c11185c66913ea5d96420504bfebc3 ]
If per-CPU airq_iv allocation fails in the loop, previously allocated vectors and arrays leak. Add proper error path to release all resources on failure.
The error path frees zpci_sbv, but SIC_IRQ_MODE_DIRECT has already programmed its address into the hardware. Set the directed interrupt mode only after all allocations have succeeded, so a failed init leaves no freed memory registered with the hardware.
--- arch/s390/pci/pci_irq.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
arch/s390/pci/pci_irq.c +19 -7
@@ -450,15 +450,10 @@ static int __init zpci_directed_irq_init(void)if (!zpci_sbv)return -ENOMEM ; - iib.diib.isc =PCI_ISC ; - iib.diib.nr_cpus =num_possible_cpus (); - iib.diib.disb_addr =virt_to_phys (zpci_sbv->vector); -zpci_set_irq_ctrl (SIC_IRQ_MODE_DIRECT ,0 , &iib); - zpci_ibv =kcalloc (num_possible_cpus (),sizeof (*zpci_ibv),GFP_KERNEL );if (!zpci_ibv) -return -ENOMEM ; + goto out_free_sbv;for_each_possible_cpu (cpu) {/*
@@ -470,13 +465,30 @@ static int __init zpci_directed_irq_init(void)AIRQ_IV_CACHELINE | (!cpu ? AIRQ_IV_ALLOC : 0), NULL);if (!zpci_ibv[cpu]) -return -ENOMEM ; + goto out_free_dibv; } + + iib.diib.isc =PCI_ISC ; + iib.diib.nr_cpus =num_possible_cpus (); + iib.diib.disb_addr =virt_to_phys (zpci_sbv->vector); +zpci_set_irq_ctrl (SIC_IRQ_MODE_DIRECT ,0 , &iib);on_each_cpu (cpu_enable_directed_irq,NULL ,1 ); zpci_irq_chip.irq_set_affinity = zpci_set_irq_affinity;return 0 ; + +out_free_dibv: +for_each_possible_cpu (cpu) { +if (zpci_ibv[cpu]) +airq_iv_release (zpci_ibv[cpu]); + } +kfree (zpci_ibv); + zpci_ibv =NULL ; +out_free_sbv: +airq_iv_release (zpci_sbv); + zpci_sbv =NULL ; +return -ENOMEM ; }static int __init zpci_floating_irq_init (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 544/670 ALSA: mpu401: shut down timer before freeing MPU
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 9332af5220d42341bb1446a62c545c0518e990ef ]
When an MPU401 interface has no usable IRQ, the driver polls raw-MIDI input and output with a timer. During raw-MIDI teardown, the timer callback can already be running when snd_mpu401_uart_remove_timer() clears the last mode bit and calls timer_delete(). That API neither waits for a running callback nor prevents it from rearming the timer, and free_irq() does not synchronize timer callbacks. snd_mpu401_uart_free() can therefore release mpu while the timer callback still uses it.
Initialize the timer once when the MPU object is created and only rearm it while a timer mode is active. Shut it down synchronously after freeing the IRQ so an in-flight callback completes before mpu and its resources are released.
--- sound/drivers/mpu401/mpu401_uart.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/drivers/mpu401/mpu401_uart.c +5 -3
@@ -162,14 +162,15 @@ static void snd_mpu401_uart_timer(struct timer_list *t)spin_lock_irqsave (&mpu->timer_lock, flags);/*mpu->mode |= MPU401_MODE_TIMER;*/ -mod_timer (&mpu->timer,1 + jiffies); +if (mpu->timer_invoked) +mod_timer (&mpu->timer,1 + jiffies);spin_unlock_irqrestore (&mpu->timer_lock, flags);if (mpu->rmidi)_snd_mpu401_uart_interrupt (mpu); }/* -* initialize the timer callback if not programmed yet +* arm the timer if it is not already active */ static void snd_mpu401_uart_add_timer (struct snd_mpu401 *mpu,int input) {
@@ -177,7 +178,6 @@ static void snd_mpu401_uart_add_timer (struct snd_mpu401 *mpu, int input)spin_lock_irqsave (&mpu->timer_lock, flags);if (mpu->timer_invoked ==0 ) { -timer_setup (&mpu->timer, snd_mpu401_uart_timer,0 );mod_timer (&mpu->timer,1 + jiffies); } mpu->timer_invoked |= input ? MPU401_MODE_INPUT_TIMER :
@@ -493,6 +493,7 @@ static void snd_mpu401_uart_free(struct snd_rawmidi *rmidi)struct snd_mpu401 *mpu = rmidi->private_data;if (mpu->irq >=0 )free_irq (mpu->irq, (void *) mpu); +timer_shutdown_sync (&mpu->timer);release_and_free_resource (mpu->res);kfree (mpu); }
@@ -547,6 +548,7 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,spin_lock_init (&mpu->input_lock);spin_lock_init (&mpu->output_lock);spin_lock_init (&mpu->timer_lock); +timer_setup (&mpu->timer, snd_mpu401_uart_timer,0 ); mpu->hardware = hardware; mpu->irq =-1 ; mpu->rmidi = rmidi;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 545/670 mm: memcontrol: raise MEMCG_MAX for charges that fail without reclaiming
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Damato <[email protected]>
[ Upstream commit 374f65b1481992eb6b9c6bffd53f3afa5c2e94cf ]
Charges that exceed memory.max and return through the nomem label can raise no event and simply return -ENOMEM.
A non-blocking charge can hit the limit, get rejected, but is not visible in memory.events.
This was noticed in a production setting where bpf_mem_alloc() attempted to refill its per-cpu freelists, which triggered a non-blocking charge while at the limit.
Commit d6e103a757fa ("mm: memcontrol: do not miss MEMCG_MAX events for enforced allocations") added raised_max_event to cover charges that are force charged without ever reaching reclaim, but charges that are rejected outright were left out. Getting an allocation failure without the corresponding MEMCG_MAX event is unexpected and makes debugging and monitoring harder.
Raise the event on the way out for rejected charges as well, by routing the -ENOMEM return through the same exit path that already covers forced charges. The existing behavior of raising a MEMCG_MAX event on every charge/reclaim/retry iteration is left unchanged.
Tested with a module that performs accounted GFP_NOWAIT page allocations from a task in a cgroup at its memory.max, and measures the resulting memory.events:max delta. Without this patch the rejected charges raise no event at all; with it the delta matches the number of rejected charges exactly. A GFP_KERNEL|__GFP_NORETRY control, which reaches reclaim, raises the same two events per failed charge before and after, confirming the existing charge/reclaim/retry accounting is unchanged.
--- mm/memcontrol.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
mm/memcontrol.c +16 -12
@@ -2182,10 +2182,11 @@ int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,bool drained = false;bool raised_max_event = false;unsigned long pflags; +int ret =0 ; retry:if (consume_stock (memcg, nr_pages)) -return 0 ; +return ret;if (!do_memsw_account () ||page_counter_try_charge (&memcg->memsw, batch, &counter)) {
@@ -2297,16 +2298,11 @@ int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,* put the burden of reclaim on regular allocation requests * and let these go through as privileged allocations. */ -if (!(gfp_mask & (__GFP_NOFAIL | __GFP_HIGH))) -return -ENOMEM ; +if (!(gfp_mask & (__GFP_NOFAIL | __GFP_HIGH))) { + ret = -ENOMEM ; + goto out; + } force: -/* -* If the allocation has to be enforced, don't forget to raise -* a MEMCG_MAX event. -*/ -if (!raised_max_event) -memcg_memory_event (mem_over_limit,MEMCG_MAX ); -/* * The allocation either can't fail or will lead to more memory * being freed very soon. Allow memory usage go over the limit
@@ -2316,7 +2312,15 @@ int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,if (do_memsw_account ())page_counter_charge (&memcg->memsw, nr_pages); -return 0 ; +out: +/* +* Don't forget to raise a MEMCG_MAX event for forced or rejected +* requests. +*/ +if (!raised_max_event) +memcg_memory_event (mem_over_limit,MEMCG_MAX ); + +return ret; done_restock:if (batch > nr_pages)
@@ -2375,7 +2379,7 @@ int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask, !(current->flags & PF_MEMALLOC) && gfpflags_allow_blocking(gfp_mask))mem_cgroup_handle_over_high (gfp_mask); -return 0 ; +return ret; }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 546/670 serial: sc16is7xx: declare SPR/TLR/XOFF2 register as volatile
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 983f91e5f13149ade6dbd9568053ecd0ab5e9265 ]
SPR shares the same address space as TLR and XOFF2. If SPR or TLR were to be used eventually, this could lead to incorrect read value from the cache.
Prevent this potential bug by declaring SPR/TLR/XOFF2 as volatile.
Stable-dep-of: 1c41d09dcd07 ("serial: sc16is7xx: declare MCR and IER as volatile registers")
--- drivers/tty/serial/sc16is7xx.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/sc16is7xx.c +1 -0
@@ -539,6 +539,7 @@ static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg)case SC16IS7XX_IIR_REG :case SC16IS7XX_LSR_REG :case SC16IS7XX_MSR_REG : +case SC16IS7XX_SPR_REG :/* Shared address space with TLR & XOFF2 */ case SC16IS7XX_TXLVL_REG :case SC16IS7XX_RXLVL_REG :case SC16IS7XX_IOSTATE_REG :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 547/670 serial: sc16is7xx: add comments for lock requirements
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 42405cb77fd35b5acc0e5a11d74eef68c2afa484 ]
Indicate why lock needs to be asserted when accessing
MSR register, as this is not immediately obvious when looking at this register in the device datasheet.
Stable-dep-of: 1c41d09dcd07 ("serial: sc16is7xx: declare MCR and IER as volatile registers")
--- drivers/tty/serial/sc16is7xx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/tty/serial/sc16is7xx.c +5 -4
@@ -535,10 +535,10 @@ EXPORT_SYMBOL_GPL(sc16is762_devtype);static bool sc16is7xx_regmap_volatile (struct device *dev,unsigned int reg) {switch (reg) { -case SC16IS7XX_RHR_REG : -case SC16IS7XX_IIR_REG : -case SC16IS7XX_LSR_REG : -case SC16IS7XX_MSR_REG : +case SC16IS7XX_RHR_REG :/* Shared address space with THR & DLL */ +case SC16IS7XX_IIR_REG :/* Shared address space with FCR & EFR */ +case SC16IS7XX_LSR_REG :/* Shared address space with XON2 */ +case SC16IS7XX_MSR_REG :/* Shared address space with TCR & XOFF1 */ case SC16IS7XX_SPR_REG :/* Shared address space with TLR & XOFF2 */ case SC16IS7XX_TXLVL_REG :case SC16IS7XX_RXLVL_REG :
@@ -782,6 +782,7 @@ static void sc16is7xx_update_mlines(struct sc16is7xx_one *one)unsigned long flags;unsigned int status, changed; +/* Lock required as MSR address is shared with TCR and XOFF1. */ lockdep_assert_held_once (&one->lock); status =sc16is7xx_get_hwmctrl (port);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 548/670 serial: sc16is7xx: declare MCR and IER as volatile registers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 1c41d09dcd07ee9648e20aa8238e404c2e6a12fb ]
MCR register has the same address as XON1 register. IER register has the same address as DLH register.
Which register is accessed depends on bits configuration in some other registers.
To prevent potential access errors, declare MCR and IER as volatile registers.
--- drivers/tty/serial/sc16is7xx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/sc16is7xx.c +2 -0
@@ -536,7 +536,9 @@ static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg) {switch (reg) {case SC16IS7XX_RHR_REG :/* Shared address space with THR & DLL */ +case SC16IS7XX_IER_REG :/* Shared address space with DLH */ case SC16IS7XX_IIR_REG :/* Shared address space with FCR & EFR */ +case SC16IS7XX_MCR_REG :/* Shared address space with XON1 */ case SC16IS7XX_LSR_REG :/* Shared address space with XON2 */ case SC16IS7XX_MSR_REG :/* Shared address space with TCR & XOFF1 */ case SC16IS7XX_SPR_REG :/* Shared address space with TLR & XOFF2 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 549/670 virtiofs: add FUSE protocol validation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuto Ohnuki <[email protected]>
[ Upstream commit 68b69fa0edb241a946cd4c850110990f30705164 ]
Add virtio_fs_verify_response() to validate that the server properly follows the FUSE protocol by checking:
- Response length is at least sizeof(struct fuse_out_header).
- oh.len matches the actual response length.
- oh.unique matches the request's unique identifier.
On validation failure, set error to -EIO and normalize oh.len to prevent underflow in copy_args_from_argbuf().
Addresses the TODO comment in virtio_fs_request_complete().
Stable-dep-of: 5364d081125a ("virtiofs: validate fixed-output response length")
--- fs/fuse/virtio_fs.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)
fs/fuse/virtio_fs.c +25 -4
@@ -749,6 +749,27 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req) req->argbuf =NULL ; } +/* Verify that the server properly follows the FUSE protocol */ +static bool virtio_fs_verify_response (struct fuse_req *req,unsigned int len) +{ +struct fuse_out_header *oh = &req->out.h; + +if (len <sizeof (*oh)) { +pr_warn ("virtio-fs: response too short (%u)\n" , len); +return false; + } +if (oh->len != len) { +pr_warn ("virtio-fs: oh.len mismatch (%u != %u)\n" , oh->len, len); +return false; + } +if (oh->unique != req->in.h.unique) { +pr_warn ("virtio-fs: oh.unique mismatch (%llu != %llu)\n" , + oh->unique, req->in.h.unique); +return false; + } +return true; +} +/* Work function for request completion */ static void virtio_fs_request_complete (struct fuse_req *req,struct virtio_fs_vq *fsvq)
@@ -759,10 +780,6 @@ static void virtio_fs_request_complete(struct fuse_req *req,unsigned int len, i, thislen;struct page *page; -/* -* TODO verify that server properly follows FUSE protocol -* (oh.uniq, oh.len) -*/ args = req->args;copy_args_from_argbuf (args, req);
@@ -818,6 +835,10 @@ static void virtio_fs_requests_done_work(struct work_struct *work)virtqueue_disable_cb (vq);while ((req =virtqueue_get_buf (vq, &len)) !=NULL ) { +if (!virtio_fs_verify_response (req, len)) { + req->out.h.error = -EIO ; + req->out.h.len =sizeof (struct fuse_out_header ); + }spin_lock (&fpq->lock);list_move_tail (&req->list, &reqs);spin_unlock (&fpq->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 550/670 virtiofs: validate fixed-output response length
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sung Byeongchan <[email protected]>
[ Upstream commit 5364d081125a34e90851fbb46ecc93f79339ce78 ]
A short successful virtiofs response can leave the fixed-output portion of the request argument buffer unwritten. The completion path nevertheless copies the full declared output to the request destination, allowing stale allocator contents to reach callers such as fuse_statfs().
Require successful fixed-output responses to contain their complete declared output. Continue to permit a shorter final argument only for out_argvar requests. Reject positive and internal restart error values and require valid error replies to be header-only. The error already stored in the FUSE output header is returned by fuse_request_end(), so do not copy output arguments from an error reply.
This was found by source review with AI assistance. A header-only successful FUSE_STATFS reply returned stale fields in nine of nine calls across three boots. The fixed kernel rejected the short response and preserved complete replies, valid negative-error replies, and variable-output replies.
--- fs/fuse/virtio_fs.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
fs/fuse/virtio_fs.c +30 -0
@@ -720,6 +720,10 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)unsigned int num_out;unsigned int i; +/* fuse_request_end() returns this error; there are no args to copy. */ +if (req->out.h.error) + goto out; + remaining = req->out.h.len -sizeof (req->out.h); num_in = args->in_numargs - args->in_pages; num_out = args->out_numargs - args->out_pages;
@@ -745,6 +749,7 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)if (args->out_argvar) args->out_args[args->out_numargs -1 ].size = remaining; +out:kfree (req->argbuf); req->argbuf =NULL ; }
@@ -752,7 +757,9 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)/* Verify that the server properly follows the FUSE protocol */ static bool virtio_fs_verify_response (struct fuse_req *req,unsigned int len) { +struct fuse_args *args = req->args;struct fuse_out_header *oh = &req->out.h; +unsigned int expected;if (len <sizeof (*oh)) {pr_warn ("virtio-fs: response too short (%u)\n" , len);
@@ -767,6 +774,29 @@ static bool virtio_fs_verify_response(struct fuse_req *req, unsigned int len) oh->unique, req->in.h.unique);return false; } +if (oh->error <= -ERESTARTSYS || oh->error >0 ) { +pr_warn ("virtio-fs: invalid error value (%d)\n" , oh->error); +return false; + } + +if (oh->error) { +if (len !=sizeof (*oh)) { +pr_warn ("virtio-fs: error response too long (%u)\n" , len); +return false; + } +return true; + } + + expected =sizeof (*oh) + +fuse_len_args (args->out_numargs, args->out_args); +if (len > expected || + (len < expected && + (!args->out_argvar || + expected - len > args->out_args[args->out_numargs -1 ].size))) { +pr_warn ("virtio-fs: invalid response length (%u, expected %u)\n" , + len, expected); +return false; + }return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 551/670 mm/page_table_check: skip zero pages
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
[ Upstream commit 33afd07412a1efe5b750a3fd5eb0272ebdd12761 ]
page_table_check_set() accounts pages by whether they are PageAnon(). The shared zero page is a special page, not an ordinary file-backed page. Read faults on private anonymous mappings can install many read-only PTEs that point at the zero page, but page_table_check currently accounts them in file_map_count.
That lets an unprivileged process populate enough zero-page mappings to overflow file_map_count and trip the BUG_ON() in page_table_check_set().
Skip zero pages in page_table_check accounting. They do not need the anonymous/file mapping conflict checks that page_table_check performs for ordinary pages, and this keeps the existing counter size and page_ext layout unchanged.
--- mm/page_table_check.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
mm/page_table_check.c +4 -2
@@ -67,7 +67,8 @@ static void page_table_check_clear(unsigned long pfn, unsigned long pgcnt)unsigned long i;bool anon; -if (!pfn_valid (pfn)) +if (!pfn_valid (pfn) ||is_zero_pfn (pfn) || +is_huge_zero_folio (pfn_folio (pfn)))return ; page =pfn_to_page (pfn);
@@ -107,7 +108,8 @@ static void page_table_check_set(unsigned long pfn, unsigned long pgcnt,unsigned long i;bool anon; -if (!pfn_valid (pfn)) +if (!pfn_valid (pfn) ||is_zero_pfn (pfn) || +is_huge_zero_folio (pfn_folio (pfn)))return ; page =pfn_to_page (pfn);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 552/670 mm/memory: constrain generic_access_phys() to page boundary
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luxiao Xu <[email protected]>
[ Upstream commit ae0298a5fbeff32951c0d31398ccec97ec6aa0ea ]
This patch addresses an issue in generic_access_phys() where accessing memory across page boundaries in PFNMAP VMAs assumes physical pages are contiguous, which can lead to accessing unintended physical memory or exceeding VMA boundaries.
generic_access_phys() improperly validates the memory access range: it only validates the start address using follow_pfnmap_start() and passes PAGE_ALIGN(len + offset) to ioremap_prot().
This poses two problems:
1. In PFNMAP VMAs, consecutive virtual pages are not guaranteed to be physically contiguous, and individual PTEs may have different access permissions or writability.
2. The mapping may cross VMA boundaries if len extends beyond vma->vm_end.
Constrain the access in generic_access_phys() to at most the current page boundary (PAGE_SIZE - offset) and map only a single PAGE_SIZE via ioremap_prot(). Since the caller __access_remote_vm() already loops over the requested length and handles partial transfers, it will naturally iterate over the remaining pages.
Also add a missing (resource_size_t) cast during PFN re-validation to avoid truncation on 32-bit PAE systems.
--- mm/memory.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
mm/memory.c +8 -2
@@ -6573,6 +6573,12 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,bool writable;struct follow_pfnmap_args args = { .vma = vma, .address = addr }; +/* +* Limit access to one page at a time, as that's what follow_pfnmap_start() +* guarantees; expect the caller to retry to read larger ranges. +*/ + len =min_t (int, len,PAGE_SIZE - offset); + retry:if (follow_pfnmap_start (&args))return -EINVAL ;
@@ -6597,7 +6603,7 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,if ((write &FOLL_WRITE ) && !writable)return -EINVAL ; - maddr =ioremap_prot (phys_addr,PAGE_ALIGN (len + offset), prot); + maddr =ioremap_prot (phys_addr,PAGE_SIZE , prot);if (!maddr)return -ENOMEM ;
@@ -6605,7 +6611,7 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr, goto out_unmap;if ((prot !=pgprot_val (args.pgprot)) || - (phys_addr != (args.pfn <<PAGE_SHIFT )) || + (phys_addr != ((resource_size_t )args.pfn <<PAGE_SHIFT )) || (writable != args.writable)) {follow_pfnmap_end (&args);iounmap (maddr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 553/670 irqchip/atmel-aic[5]: Disable interrupts in the irq_pm_shutdown() callbacks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 0ca21fe111457c843624a835641bb490e704bb2f ]
irq_gc_shutdown() calls the irq_pm_shutdown() callbacks from syscore_shutdown() with interrupts enabled. aic_pm_shutdown() and aic5_pm_shutdown() take the generic chip lock with raw_spin_lock(), and irq_gc_eoi() takes the same lock from the interrupt handler. An interrupt from the chip while the lock is held spins in irq_gc_eoi() and hangs the reboot.
Lockdep reports this on every reboot of a SAM9X75 Curiosity board:
WARNING: inconsistent lock state
inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. busybox/101 [HC0[0]:SC0[0]:HE1:SE1] takes:
c1c2b434 (&gc->lock){?.-.}-{2:2}, at: aic5_pm_shutdown+0x34/0xd8 {IN-HARDIRQ-W} state was registered at:
...
irq_gc_eoi+0x28/0x60
handle_fasteoi_irq+0x120/0x214 ...
aic5_pm_shutdown from irq_gc_shutdown+0x4c/0x58 irq_gc_shutdown from syscore_shutdown+0x5c/0x9c syscore_shutdown from kernel_restart+0x34/0x78 kernel_restart from sys_reboot+0x180/0x25c
Use the irqsave guard, as
commit 33517881ede7 ("irqchip/brcmstb-l2: Use _irqsave locking variants in non-interrupt code") did for brcmstb-l2.
--- drivers/irqchip/irq-atmel-aic.c | 5 +++-- drivers/irqchip/irq-atmel-aic5.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/irqchip/irq-atmel-aic.c +3 -2
@@ -125,11 +125,12 @@ static void aic_resume(struct irq_data *d)static void aic_pm_shutdown (struct irq_data *d) {struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +unsigned long flags; -irq_gc_lock (gc); +irq_gc_lock_irqsave (gc, flags);irq_reg_writel (gc,0xffffffff ,AT91_AIC_IDCR );irq_reg_writel (gc,0xffffffff ,AT91_AIC_ICCR ); -irq_gc_unlock (gc); +irq_gc_unlock_irqrestore (gc, flags); }#else #define aic_suspend NULL
drivers/irqchip/irq-atmel-aic5.c +3 -2
@@ -223,15 +223,16 @@ static void aic5_pm_shutdown(struct irq_data *d)struct irq_domain_chip_generic *dgc = domain->gc;struct irq_chip_generic *bgc =irq_get_domain_generic_chip (domain,0 );struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +unsigned long flags;int i; -irq_gc_lock (bgc); +irq_gc_lock_irqsave (bgc, flags);for (i =0 ; i < dgc->irqs_per_chip; i++) {irq_reg_writel (bgc, i + gc->irq_base,AT91_AIC5_SSR );irq_reg_writel (bgc,1 ,AT91_AIC5_IDCR );irq_reg_writel (bgc,1 ,AT91_AIC5_ICCR ); } - irq_gc_unlock(bgc); + irq_gc_unlock_irqrestore(bgc, flags); }#else #define aic5_suspend NULL
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 554/670 serial: sc16is7xx: fix data corruption due to unexpected xon/xoff
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Fuzzey <[email protected]>
[ Upstream commit 8bb50e95c0abd44607bc60a43032c1dbf7470d5a ]
The hardware supports automatically sending XON/OFF based on the FIFO status and that is already implemented by the driver. However that capability was not announced with the UPF_SOFT_FLOW bit.
When the port is opened with the default of XON enabled the driver configures that in the hardware.
If userspace does not want XON/OFF (which is normally the case) it will use TCSETS to disactivate it. However the serial core optimises this to only notify the driver if someting imporant has changed, and for XON/XOFF thit is only if the driver declares UPF_SOFT_FLOW.
So we end up with unwanted XON/XOFF in the data stream.
The problem only occurs if nothing else needed to be set by termios, ie if the user space requested values are the same as the default values, except for XON/XOFF.
Since the default speed is 9600 this means that the problem only occurs when requesting 9600, otherwise the call to the driver will be made to change the speed, and that will also clear the XON/XOFF.
As 9600 is quite rare these days that probably explains why this hasn't already been seen.
It also only occurs on the first port open after boot since the subsequent opens will use the "logical state" set by TCSETS but not communicated to the driver the first time.
--- drivers/tty/serial/sc16is7xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/sc16is7xx.c +1 -1
@@ -1619,7 +1619,7 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype, s->p[i].port.irq = irq; s->p[i].port.type =PORT_SC16IS7XX ; s->p[i].port.fifosize =SC16IS7XX_FIFO_SIZE ; - s->p[i].port.flags =UPF_FIXED_TYPE |UPF_LOW_LATENCY ; + s->p[i].port.flags =UPF_FIXED_TYPE |UPF_LOW_LATENCY |UPF_SOFT_FLOW ; s->p[i].port.iobase = i;/* * Use all ones as membase to make sure uart_configure_port() in
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 555/670 PCI: rockchip: Drive at 2.5 GT/s, error other speeds
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geraldo Nascimento <[email protected]>
[ Upstream commit 84d08ff902f1ec01177fef1a21a38934927f5aee ]
Configure the core to be driven at 2.5 GT/s Link Speed and ignore any other speed with a warning. Also drop the 5.0 GT/s Link Speed defines from Rockchip PCIe header.
The reason is that Shawn Lin from Rockchip has reiterated that there may be danger of "catastrophic failure" in using their PCIe with 5.0 GT/s speeds.
While Rockchip has done so informally without issuing a proper errata, and the particulars are thus unknown, this may cause data loss or worse.
This change is corroborated by RK3399 official datasheet [1], which states maximum link speed for this platform is 2.5 GT/s.
[1] https://opensource.rock-chips.com/images/d/d7/Rockchip_RK3399_Datasheet_V2.1-20200323.pdf
--- drivers/pci/controller/pcie-rockchip.c | 14 ++++++-------- drivers/pci/controller/pcie-rockchip.h | 3 --- 2 files changed, 6 insertions(+), 11 deletions(-)
drivers/pci/controller/pcie-rockchip.c +6 -8
@@ -66,8 +66,10 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip) } rockchip->link_gen =of_pci_get_max_link_speed (node); -if (rockchip->link_gen <0 || rockchip->link_gen >2 ) - rockchip->link_gen =2 ; +if (rockchip->link_gen <0 || rockchip->link_gen >=2 ) { + rockchip->link_gen =1 ; +dev_warn (dev,"invalid max-link-speed, limited to 2.5 GT/s\n" ); + } rockchip->core_rst =devm_reset_control_get_exclusive (dev,"core" );if (IS_ERR (rockchip->core_rst)) {
@@ -237,12 +239,8 @@ int rockchip_pcie_init_port(struct rockchip_pcie *rockchip) goto err_exit_phy; } -if (rockchip->link_gen ==2 ) -rockchip_pcie_write (rockchip,PCIE_CLIENT_GEN_SEL_2 , -PCIE_CLIENT_CONFIG ); -else -rockchip_pcie_write (rockchip,PCIE_CLIENT_GEN_SEL_1 , -PCIE_CLIENT_CONFIG ); +rockchip_pcie_write (rockchip,PCIE_CLIENT_GEN_SEL_1 , +PCIE_CLIENT_CONFIG ); regs =PCIE_CLIENT_LINK_TRAIN_ENABLE |PCIE_CLIENT_ARI_ENABLE |PCIE_CLIENT_CONF_LANE_NUM (rockchip->lanes);
drivers/pci/controller/pcie-rockchip.h +0 -3
@@ -37,7 +37,6 @@#define PCIE_CLIENT_MODE_RC HIWORD_UPDATE_BIT(0x0040)#define PCIE_CLIENT_MODE_EP HIWORD_UPDATE(0x0040, 0)#define PCIE_CLIENT_GEN_SEL_1 HIWORD_UPDATE(0x0080, 0) -#define PCIE_CLIENT_GEN_SEL_2 HIWORD_UPDATE_BIT(0x0080)#define PCIE_CLIENT_LEGACY_INT_CTRL (PCIE_CLIENT_BASE + 0x0c)#define PCIE_CLIENT_INT_IN_ASSERT HIWORD_UPDATE_BIT(0x0002)#define PCIE_CLIENT_INT_IN_DEASSERT HIWORD_UPDATE(0x0002, 0)
@@ -183,8 +182,6 @@ (((x) & PCIE_CLIENT_DEBUG_LTSSM_MASK) == PCIE_CLIENT_DEBUG_LTSSM_L2)#define PCIE_LINK_UP (x) \ (((x) & PCIE_CLIENT_LINK_STATUS_MASK) == PCIE_CLIENT_LINK_STATUS_UP) -#define PCIE_LINK_IS_GEN2 (x) \ - (((x) & PCIE_CORE_PL_CONF_SPEED_MASK) == PCIE_CORE_PL_CONF_SPEED_5G)#define RC_REGION_0_ADDR_TRANS_H 0x00000000#define RC_REGION_0_ADDR_TRANS_L 0x00000000
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 556/670 dm-bufio: fix non-working memory limit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit 1190dbeaeaa026a4879e675b8556a150c36a7ced ]
The function evict_old is supposed to loop and evict buffers while the allocated size is above the threshold. However if it hits one bufio client that is empty, it stops and doesn't attempt to scan other clients.
This commit fixes it, so that it skips empty clients and retries up to dm_bufio_client_count times.
--- drivers/md/dm-bufio.c | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-)
drivers/md/dm-bufio.c +37 -4
@@ -2526,6 +2526,13 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsigninit_waitqueue_head (&c->free_buffer_wait); c->async_write_error =0 ; +/* +* A client with no buffers yet is not holding the oldest buffer in +* the system; leaving this zeroed would claim exactly that and keep +* the client pinned at the front of dm_bufio_all_clients. +*/ + c->oldest_buffer = jiffies; + c->dm_io =dm_io_client_create ();if (IS_ERR (c->dm_io)) { r =PTR_ERR (c->dm_io);
@@ -2861,9 +2868,23 @@ static unsigned long __evict_a_few(unsigned long nr_buffers) count =__evict_many (c, ¶ms,LIST_CLEAN , nr_buffers);dm_bufio_unlock (c); -if (count) +if (count) { c->oldest_buffer = params.last_accessed; -__insert_client (c); +__insert_client (c); + }else { +/* +* We evicted nothing, so 'oldest_buffer' tells us nothing new +* and the client keeps its old, possibly very stale, value. +* Requeue it at the back rather than by that value, otherwise +* __insert_client() would put it straight back at the front +* and every subsequent call would pop this same client again, +* never reaching any of the others. +* +* This leaves the list slightly out of order, which is fine - +* it is only ever an approximation. +*/ +list_add_tail (&c->client_list, &dm_bufio_all_clients); + }return count; }
@@ -2888,11 +2909,23 @@ static void evict_old(void) {unsigned long threshold = dm_bufio_cache_size - dm_bufio_cache_size /DM_BUFIO_LOW_WATERMARK_RATIO ; +int unproductive =0 ;mutex_lock (&dm_bufio_clients_lock);while (dm_bufio_current_allocated > threshold) { -if (!__evict_a_few (64 )) -break ; +if (__evict_a_few (64 )) { + unproductive =0 ; + }else { +/* +* This client had nothing to give. Try the others +* before giving up: one idle client, or one whose +* buffers are all held, must not stop us evicting +* from everybody else. Stop once a whole sweep of +* the client list has freed nothing. +*/ +if (++unproductive >= dm_bufio_client_count) +break ; + }cond_resched (); }mutex_unlock (&dm_bufio_clients_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 557/670 ASoC: qcom: q6apm-dai: wrap the position of a full ring to 0
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladyslav Tymoshchuk <[email protected]>
[ Upstream commit 0ea3e0b196f9dcc17b40ac881a6efef06459975b ]
q6apm_dai_pointer() turns the number of period buffers the DSP has returned in the current lap, 1..periods, into a position and reports one frame less than that. Commit a93dad6f4e6a ("ASoC: q6apm-dai: make use of q6apm_get_hw_pointer") added the "- 1" so that the end of the ring is not reported as a position equal to the buffer size.
One frame short has a cost once the application stops feeding the stream. The DSP returns the last queued buffer and the position stops at appl_ptr - 1, so avail stays at buffer_size - 1, below the default stop_threshold. The DSP sends nothing more as its queue is empty, so no period interrupt comes either: ALSA never detects the underrun and the stream stays RUNNING. A poll-driven application that missed its last wakeup waits forever, and drain only ends on its timeout, with -EIO. On capture, the last frame of each period is held back until the next one.
Before that commit the position wrapped to 0 at the end of the ring. Do that again. A full lap is the start of the ring, and snd_pcm_update_hw_ptr0() accounts for the wrap: the position cannot move by more than one lap between two updates, as each returned buffer calls snd_pcm_period_elapsed() and the DSP holds at most periods buffers.
Seen on a OnePlus Pad 3 (SM8750) with PipeWire in interrupt-driven
scheduling: after a stall the PCM sat at hw_ptr 78239, appl_ptr 78240 (avail 3839 of 3840) for two hours.
--- sound/soc/qcom/qdsp6/q6apm-dai.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
sound/soc/qcom/qdsp6/q6apm-dai.c +8 -4
@@ -441,11 +441,15 @@ static snd_pcm_uframes_t q6apm_dai_pointer(struct snd_soc_component *component,struct q6apm_dai_rtd *prtd = runtime->private_data;snd_pcm_uframes_t ptr; - ptr =q6apm_get_hw_pointer (prtd->graph, substream->stream) * runtime->period_size; -if (ptr) -return ptr -1 ; +/* +* The hw pointer counts the period buffers the DSP has returned in +* this lap, 1..periods. A full lap is the start of the ring again: +* report 0 rather than one frame less, so that the position of a +* drained buffer reaches appl_ptr and ALSA sees the underrun. +*/ + ptr =q6apm_get_hw_pointer (prtd->graph, substream->stream) % runtime->periods; -return 0 ; +return ptr * runtime->period_size; } static int q6apm_dai_hw_params(struct snd_soc_component *component,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 558/670 nilfs2: remove nilfs_writepage
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit 310293201ed242e466b0e9f10f53b4a4abccffec ]
Since nilfs2 has a ->writepages operation already, ->writepage is only called by the migration code. If we add a ->migrate_folio operation, it won't even be used for that and so it can be deleted.
Stable-dep-of: cb6702e63e0a ("nilfs2: force clear dirty state when restoring from the shadow map")
--- fs/nilfs2/inode.c | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-)
fs/nilfs2/inode.c +1 -32
@@ -170,37 +170,6 @@ static int nilfs_writepages(struct address_space *mapping,return err; } -static int nilfs_writepage (struct page *page,struct writeback_control *wbc) -{ -struct folio *folio =page_folio (page); -struct inode *inode = folio->mapping->host; -int err; - -if (sb_rdonly (inode->i_sb)) { -/* -* It means that filesystem was remounted in read-only -* mode because of error or metadata corruption. But we -* have dirty pages that try to be flushed in background. -* So, here we simply discard this dirty page. -*/ -nilfs_clear_folio_dirty (folio); -folio_unlock (folio); -return -EROFS ; - } - -folio_redirty_for_writepage (wbc, folio); -folio_unlock (folio); - -if (wbc->sync_mode ==WB_SYNC_ALL ) { - err =nilfs_construct_segment (inode->i_sb); -if (unlikely (err)) -return err; - }else if (wbc->for_reclaim) -nilfs_flush_segment (inode->i_sb, inode->i_ino); - -return 0 ; -} -static bool nilfs_dirty_folio (struct address_space *mapping,struct folio *folio) {
@@ -295,7 +264,6 @@ nilfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter) }const struct address_space_operations nilfs_aops = { - .writepage = nilfs_writepage, .read_folio = nilfs_read_folio, .writepages = nilfs_writepages, .dirty_folio = nilfs_dirty_folio,
@@ -304,6 +272,7 @@ const struct address_space_operations nilfs_aops = { .write_end = nilfs_write_end, .invalidate_folio = block_invalidate_folio, .direct_IO = nilfs_direct_IO, + .migrate_folio = buffer_migrate_folio_norefs, .is_partially_uptodate = block_is_partially_uptodate, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 559/670 nilfs2: convert nilfs_page_count_clean_buffers() to take a folio
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit c1d73eb8d06003e7714cd3ce1d0d79832e59b1e9 ]
Both callers have a folio, so pass it in and use it directly.
Stable-dep-of: cb6702e63e0a ("nilfs2: force clear dirty state when restoring from the shadow map")
--- fs/nilfs2/dir.c | 2 +- fs/nilfs2/inode.c | 2 +- fs/nilfs2/page.c | 4 ++-- fs/nilfs2/page.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-)
fs/nilfs2/dir.c +1 -1
@@ -95,7 +95,7 @@ static void nilfs_commit_chunk(struct folio *folio,unsigned int nr_dirty;int err; - nr_dirty =nilfs_page_count_clean_buffers (&folio->page, from, to); + nr_dirty =nilfs_page_count_clean_buffers (folio, from, to); copied =block_write_end (NULL , mapping, pos, len, len, folio,NULL );if (pos + copied > dir->i_size)i_size_write (dir, pos + copied);
fs/nilfs2/inode.c +1 -1
@@ -242,7 +242,7 @@ static int nilfs_write_end(struct file *file, struct address_space *mapping,unsigned int nr_dirty;int err; - nr_dirty =nilfs_page_count_clean_buffers (&folio->page, start, + nr_dirty =nilfs_page_count_clean_buffers (folio, start, start + copied); copied =generic_write_end (file, mapping, pos, len, copied, folio, fsdata);
fs/nilfs2/page.c +2 -2
@@ -458,14 +458,14 @@ void nilfs_clear_folio_dirty(struct folio *folio)__nilfs_clear_folio_dirty (folio); } -unsigned int nilfs_page_count_clean_buffers (struct page *page, +unsigned int nilfs_page_count_clean_buffers (struct folio *folio,unsigned int from,unsigned int to) {unsigned int block_start, block_end;struct buffer_head *bh, *head;unsigned int nc =0 ; -for (bh = head =page_buffers (page), block_start =0 ; +for (bh = head =folio_buffers (folio), block_start =0 ; bh != head || !block_start; block_start = block_end, bh = bh->b_this_page) { block_end = block_start + bh->b_size;
fs/nilfs2/page.h +2 -2
@@ -43,8 +43,8 @@ int nilfs_copy_dirty_pages(struct address_space *, struct address_space *);void nilfs_copy_back_pages (struct address_space *,struct address_space *);void nilfs_clear_folio_dirty (struct folio *folio);void nilfs_clear_dirty_pages (struct address_space *mapping); -unsigned int nilfs_page_count_clean_buffers (struct page *,unsigned int , -unsigned int ); +unsigned int nilfs_page_count_clean_buffers (struct folio *folio, +unsigned int from,unsigned int to);unsigned long nilfs_find_uncommitted_extent (struct inode *inode,sector_t start_blk,sector_t *blkoff);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 560/670 nilfs2: force clear dirty state when restoring from the shadow map
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaming Zhang <[email protected]>
[ Upstream commit cb6702e63e0a16afd83875294e5ce53becdd1b1f ]
When garbage collection fails, nilfs2 rolls the DAT metadata file's page cache back to a shadow copy taken before GC started. nilfs_clear_dirty_pages() drops the dirty state of the folios in the DAT cache, then nilfs_copy_back_pages() overwrites them with the saved contents and warns if one is still dirty:
/* overwrite existing folio in the destination cache */ WARN_ON(folio_test_dirty(dfolio));
nilfs_clear_dirty_pages() used to clear the dirty state unconditionally, which is safe here because the rollback runs with the log writer stopped, so nothing else can dirty the cache while it runs. The same helper is also used when writeback finds dirty folios after the filesystem has degraded to read-only, where it does run concurrently with the log writer, so commit ca76bb226bf4 ("nilfs2: do not force clear folio if buffer is referenced") made nilfs_clear_folio_dirty() skip a folio if any of its buffer heads is busy. The rollback caller shares that helper, so its clearing step can now return with a folio still dirty.
A DAT folio can hold a busy buffer head without anyone modifying the
folio: nilfs_mdt_read_block() submits read-ahead for the blocks following the one it was asked for and waits only for the first, so the read-ahead buffers are still locked when it returns. With a block size smaller than the page size, a locked read-ahead buffer can share a folio with a block that GC dirtied and keep the whole folio dirty past the clearing step.
Add a force flag to nilfs_clear_dirty_pages() and nilfs_clear_folio_dirty() that skips the busy buffer check, and set it in the two calls from nilfs_mdt_restore_from_shadow_map(). The read-only fallback callers keep passing false, so that commit still protects them and the WARN_ON() is left alone.
--- fs/nilfs2/inode.c | 2 +- fs/nilfs2/mdt.c | 6 +++--- fs/nilfs2/page.c | 50 +++++++++++++++++++++++++++-------------------- fs/nilfs2/page.h | 4 ++-- 4 files changed, 35 insertions(+), 27 deletions(-)
fs/nilfs2/inode.c +1 -1
@@ -159,7 +159,7 @@ static int nilfs_writepages(struct address_space *mapping,int err =0 ;if (sb_rdonly (inode->i_sb)) { -nilfs_clear_dirty_pages (mapping); +nilfs_clear_dirty_pages (mapping, false);return -EROFS ; }
fs/nilfs2/mdt.c +3 -3
@@ -410,7 +410,7 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc)* have dirty folios that try to be flushed in background. * So, here we simply discard this dirty folio. */ -nilfs_clear_folio_dirty (folio); +nilfs_clear_folio_dirty (folio, false);folio_unlock (folio);return -EROFS ; }
@@ -637,10 +637,10 @@ void nilfs_mdt_restore_from_shadow_map(struct inode *inode)if (mi->mi_palloc_cache)nilfs_palloc_clear_cache (inode); -nilfs_clear_dirty_pages (inode->i_mapping); +nilfs_clear_dirty_pages (inode->i_mapping, true);nilfs_copy_back_pages (inode->i_mapping, shadow->inode->i_mapping); -nilfs_clear_dirty_pages (ii->i_assoc_inode->i_mapping); +nilfs_clear_dirty_pages (ii->i_assoc_inode->i_mapping, true);nilfs_copy_back_pages (ii->i_assoc_inode->i_mapping,NILFS_I (shadow->inode)->i_assoc_inode->i_mapping);
fs/nilfs2/page.c +29 -21
81 lines not on this page · raw message
fs/nilfs2/page.h +2 -2
@@ -41,8 +41,8 @@ void nilfs_folio_bug(struct folio *);int nilfs_copy_dirty_pages (struct address_space *,struct address_space *);void nilfs_copy_back_pages (struct address_space *,struct address_space *); -void nilfs_clear_folio_dirty (struct folio *folio); -void nilfs_clear_dirty_pages (struct address_space *mapping); +void nilfs_clear_folio_dirty (struct folio *folio,bool force); +void nilfs_clear_dirty_pages (struct address_space *mapping,bool force);unsigned int nilfs_page_count_clean_buffers (struct folio *folio,unsigned int from,unsigned int to); unsigned long nilfs_find_uncommitted_extent(struct inode *inode,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 561/670 IB/hfi1: Shutdown self-rearming timers before freeing
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 9d3259e41ccd5016cd2c6d013232b89df6d73011 ]
The HFI1 receive error and synthetic counter timers rearm themselves from their callbacks. Their cleanup paths use timer_delete_sync(), which only waits for a running callback and does not prevent a concurrent or subsequent rearm.
Use timer_shutdown_sync() when releasing these timers. This prevents a callback from enqueueing either timer after cleanup begins, before the containing hfi1_devdata is freed.
Preserve the existing work cancellation and workqueue destruction ordering for synthetic counters.
--- drivers/infiniband/hw/hfi1/chip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +2 -2
@@ -5576,7 +5576,7 @@ static int init_rcverr(struct hfi1_devdata *dd)static void free_rcverr (struct hfi1_devdata *dd) {if (dd->rcverr_timer.function) -del_timer_sync (&dd->rcverr_timer); +timer_shutdown_sync (&dd->rcverr_timer); }static void handle_rxe_err (struct hfi1_devdata *dd,u32 unused,u64 reg)
@@ -12308,7 +12308,7 @@ static void free_cntrs(struct hfi1_devdata *dd)int i;if (dd->synth_stats_timer.function) -del_timer_sync (&dd->synth_stats_timer); +timer_shutdown_sync (&dd->synth_stats_timer);cancel_work_sync (&dd->update_cntr_work); ppd = (struct hfi1_pportdata *)(dd +1 );for (i =0 ; i < dd->num_pports; i++, ppd++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 562/670 wifi: brcmfmac: cfg80211: Report port_authorized for 4-way HS offload
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Janne Grunau <[email protected]>
[ Upstream commit 6fff9de5c5b425817588eeed42bd56d665751c13 ]
Since commit 416386060 ("Mark authorization completed on driver indication during 4-way HS offload") [0] wpa_supplicant expects NL80211_CMD_PORT_AUTHORIZED to complete the authentication when the driver supports 4-way handshake offload.
This was apparently never tested with the upstream brcmfmac driver as it does not report this. This broke authentication on Apple silicon devices (BRCM4378, BRMC4387, BRMC4388) and other devices when wpa_supplicant 2.11 was released [1]. This was initially dealt with by reverting the commit in Fedora [2] and other Linux distributions.
Instead of carrying the revert over to wpa_supplicant 2.12 add the expected NL80211_CMD_PORT_AUTHORIZED when the connection is established.
The "Fixes:" tag is not fully accurate as this has only became an issue after userspace changes years after the change. Since the change is expected to be required in all active stable branches for wpa_supplicant 2.11 / 2.12 compatibility it is helpful even though BRCMF_PROFILE_FWSUP_SAE did not exists then.
--- .../net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +7 -0
@@ -6424,6 +6424,7 @@ brcmf_bss_connect_done(struct brcmf_cfg80211_info *cfg,struct brcmf_cfg80211_profile *profile = &ifp->vif->profile;struct brcmf_cfg80211_connect_info *conn_info =cfg_to_conn (cfg);struct cfg80211_connect_resp_params conn_params; +bool authorized;brcmf_dbg (TRACE ,"Enter\n" );
@@ -6448,7 +6449,13 @@ brcmf_bss_connect_done(struct brcmf_cfg80211_info *cfg, conn_params.req_ie_len = conn_info->req_ie_len; conn_params.resp_ie = conn_info->resp_ie; conn_params.resp_ie_len = conn_info->resp_ie_len; + authorized = completed && + (profile->use_fwsup ==BRCMF_PROFILE_FWSUP_SAE || + profile->use_fwsup ==BRCMF_PROFILE_FWSUP_PSK );cfg80211_connect_done (ndev, &conn_params,GFP_KERNEL ); +if (authorized) +cfg80211_port_authorized (ndev, profile->bssid,NULL ,0 , +GFP_KERNEL );brcmf_dbg (CONN ,"Report connect result - connection %s\n" , completed ?"succeeded" :"failed" ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 563/670 iomap: dont lose a failed direct I/O bios error when zeroing the tail
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrea Parri <[email protected]>
[ Upstream commit a9fd24bcbe690ed4a5b8ea6a7516fa297fae9360 ]
iomap_dio_bio_iter() falls through to the sub-block tail zeroing when the data bio submission fails, so that the rest of the block is still zeroed and stale data is not exposed. The zeroing result was assigned to ret, which overwrote the submission error with the successful zeroing result (zero) and the failed write was reported as success.
iomap_dio_zero() can only return an error from a can't-happen WARN_ON_ONCE() (nr_vecs exceeding BIO_MAX_VECS, which the existing comment there says "shall never be reached" for any in-tree filesystem), so it isn't a real runtime failure worth reporting to userspace, let alone one worth losing the actual submission error for. Make iomap_dio_zero() return void and drop the error handling at both call sites instead of threading the result through a separate variable.
--- fs/iomap/direct-io.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
fs/iomap/direct-io.c +5 -10
@@ -250,19 +250,19 @@ void iomap_dio_bio_end_io(struct bio *bio) }EXPORT_SYMBOL_GPL (iomap_dio_bio_end_io); -static int iomap_dio_zero (const struct iomap_iter *iter,struct iomap_dio *dio, +static void iomap_dio_zero (const struct iomap_iter *iter,struct iomap_dio *dio,loff_t pos,unsigned len) {struct inode *inode =file_inode (dio->iocb->ki_filp);struct bio *bio;if (!len) -return 0 ; +return ;/* * Max block size supported is 64k */ if (WARN_ON_ONCE (len >IOMAP_ZERO_PAGE_SIZE )) -return -EINVAL ; +return ; bio =iomap_dio_alloc_bio (iter, dio,1 ,REQ_OP_WRITE |REQ_SYNC |REQ_IDLE ); fscrypt_set_bio_crypt_ctx(bio, inode, pos >> inode->i_blkbits,
@@ -273,7 +273,6 @@ static int iomap_dio_zero(const struct iomap_iter *iter, struct iomap_dio *dio,__bio_add_page (bio, zero_page, len,0 );iomap_dio_submit_bio (iter, dio, bio, pos); -return 0 ; }/*
@@ -382,10 +381,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter,if (need_zeroout) {/* zero out from the start of the block to the write offset */ pad = pos & (fs_block_size -1 ); - - ret =iomap_dio_zero (iter, dio, pos - pad, pad); -if (ret) - goto out; +iomap_dio_zero (iter, dio, pos - pad, pad); }/*
@@ -463,8 +459,7 @@ static loff_t iomap_dio_bio_iter(const struct iomap_iter *iter,/* zero out from the end of the write to the end of the block */ pad = pos & (fs_block_size -1 );if (pad) - ret =iomap_dio_zero (iter, dio, pos, - fs_block_size - pad); +iomap_dio_zero (iter, dio, pos, fs_block_size - pad); } out:/* Undo iter limitation to current extent */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 564/670 drm/amd: define gc ip version local variable
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Sierra <[email protected]>
[ Upstream commit 9bfe4caa4e57ba343d81e837911242f058688200 ]
For better readability. Also leftover orphaned code.
Stable-dep-of: 232213c9bd7f ("drm/amdgpu/gmc9: add extra type-2 TLB flush for gfx942/gfx950")
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 8 +++----- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 5 +++-- 2 files changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3 -5
@@ -1139,12 +1139,13 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,bool uncached = bo->flags &AMDGPU_GEM_CREATE_UNCACHED ;struct amdgpu_vm *vm = mapping->bo_va->base.vm;unsigned int mtype_local, mtype; +uint32_t gc_ip_version =amdgpu_ip_version (adev,GC_HWIP ,0 );bool snoop = false;bool is_local;dma_resv_assert_held (bo->tbo.base.resv); -switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { +switch (gc_ip_version) {case IP_VERSION (9 ,4 ,1 ):case IP_VERSION (9 ,4 ,2 ):if (is_vram) {
@@ -1158,10 +1159,7 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,/* FIXME: is this still needed? Or does * amdgpu_ttm_tt_pde_flags already handle this? */ -if ((amdgpu_ip_version (adev,GC_HWIP ,0 ) == -IP_VERSION (9 ,4 ,2 ) || -amdgpu_ip_version (adev,GC_HWIP ,0 ) == -IP_VERSION (9 ,4 ,3 )) && +if (gc_ip_version ==IP_VERSION (9 ,4 ,2 ) && adev->gmc.xgmi.connected_to_cpu) snoop = true; }else {
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +3 -2
@@ -1224,6 +1224,7 @@ svm_range_get_pte_flags(struct kfd_node *node,struct kfd_node *bo_node;uint32_t flags = prange->flags;uint32_t mapping_flags =0 ; +uint32_t gc_ip_version =KFD_GC_VERSION (node);uint64_t pte_flags;bool snoop = (domain !=SVM_RANGE_VRAM_DOMAIN );bool coherent = flags & (KFD_IOCTL_SVM_FLAG_COHERENT |KFD_IOCTL_SVM_FLAG_EXT_COHERENT );
@@ -1233,7 +1234,7 @@ svm_range_get_pte_flags(struct kfd_node *node,if (domain ==SVM_RANGE_VRAM_DOMAIN ) bo_node = prange->svm_bo->node; -switch (amdgpu_ip_version (node->adev,GC_HWIP ,0 )) { +switch (gc_ip_version) {case IP_VERSION (9 ,4 ,1 ):if (domain ==SVM_RANGE_VRAM_DOMAIN ) {if (bo_node == node) {
@@ -1322,7 +1323,7 @@ svm_range_get_pte_flags(struct kfd_node *node, pte_flags =AMDGPU_PTE_VALID ; pte_flags |= (domain ==SVM_RANGE_VRAM_DOMAIN ) ?0 :AMDGPU_PTE_SYSTEM ; pte_flags |= snoop ?AMDGPU_PTE_SNOOPED :0 ; -if (KFD_GC_VERSION (node) >=IP_VERSION (12 ,0 ,0 )) +if (gc_ip_version >=IP_VERSION (12 ,0 ,0 )) pte_flags |=AMDGPU_PTE_IS_PTE ; pte_flags |=amdgpu_gem_va_map_flags (node->adev, mapping_flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 565/670 drm/amd: update mtype flags for gfx 9.5.0
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Sierra <[email protected]>
[ Upstream commit dad0c70507a834ac12e9286401d90536a3c4cea2 ]
Update mtype flags to meet gfx 9.5.0 requirements for remote GPU memory and system memory.
Stable-dep-of: 232213c9bd7f ("drm/amdgpu/gmc9: add extra type-2 TLB flush for gfx942/gfx950")
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 8 ++++---- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +4 -4
@@ -1207,7 +1207,7 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,if (uncached) { mtype =MTYPE_UC ; }else if (ext_coherent) { -if (adev->rev_id) +if (gc_ip_version ==IP_VERSION (9 ,5 ,0 ) || adev->rev_id) mtype = is_local ?MTYPE_CC :MTYPE_UC ;else mtype =MTYPE_UC ;
@@ -1217,10 +1217,10 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,/* dGPU */ if (is_local) mtype = mtype_local; -else if (is_vram) - mtype =MTYPE_NC ; -else +else if (gc_ip_version <IP_VERSION (9 ,5 ,0 ) && !is_vram) mtype =MTYPE_UC ; +else + mtype =MTYPE_NC ; }break ;
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +12 -4
@@ -1272,7 +1272,8 @@ svm_range_get_pte_flags(struct kfd_node *node,case IP_VERSION (9 ,4 ,3 ):case IP_VERSION (9 ,4 ,4 ):if (ext_coherent) - mtype_local = node->adev->rev_id ?AMDGPU_VM_MTYPE_CC :AMDGPU_VM_MTYPE_UC ; + mtype_local = (gc_ip_version <IP_VERSION (9 ,5 ,0 ) && !node->adev->rev_id) ? +AMDGPU_VM_MTYPE_UC :AMDGPU_VM_MTYPE_CC ;else mtype_local = amdgpu_mtype_local ==1 ?AMDGPU_VM_MTYPE_NC : amdgpu_mtype_local ==2 ?AMDGPU_VM_MTYPE_CC :AMDGPU_VM_MTYPE_RW ;
@@ -1287,9 +1288,13 @@ svm_range_get_pte_flags(struct kfd_node *node,*/ else if (svm_nodes_in_same_hive(bo_node, node) && !ext_coherent) mapping_flags |= AMDGPU_VM_MTYPE_NC; -/* PCIe P2P or extended system scope coherence */ - else +/* PCIe P2P on GPUs pre-9.5.0 */ + else if (gc_ip_version < IP_VERSION(9, 5, 0) && + !svm_nodes_in_same_hive(bo_node, node)) mapping_flags |= AMDGPU_VM_MTYPE_UC; +/* Other remote memory */ + else + mapping_flags |= ext_coherent ? AMDGPU_VM_MTYPE_UC : AMDGPU_VM_MTYPE_NC;/* system memory accessed by the APU */ }else if (node->adev->flags &AMD_IS_APU ) {/* On NUMA systems, locality is determined per-page
@@ -1301,7 +1306,10 @@ svm_range_get_pte_flags(struct kfd_node *node, mapping_flags |= ext_coherent ?AMDGPU_VM_MTYPE_UC :AMDGPU_VM_MTYPE_NC ;/* system memory accessed by the dGPU */ }else { - mapping_flags |=AMDGPU_VM_MTYPE_UC ; +if (gc_ip_version <IP_VERSION (9 ,5 ,0 )) + mapping_flags |=AMDGPU_VM_MTYPE_UC ; +else + mapping_flags |=AMDGPU_VM_MTYPE_NC ; }break ;case IP_VERSION (12 ,0 ,0 ):
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 566/670 drm/amdkfd: Drop workaround for GC v9.4.3 revID 0
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Apurv Mishra <[email protected]>
[ Upstream commit daafa303d19f5522e4c24fbf5c1c981a16df2c2f ]
Remove workaround code for the early engineering
samples GC v9.4.3 SOCs with revID 0
Stable-dep-of: 232213c9bd7f ("drm/amdgpu/gmc9: add extra type-2 TLB flush for gfx942/gfx950")
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 8 +++++++- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 14 ++------------ drivers/gpu/drm/amd/amdkfd/kfd_device.c | 5 ----- drivers/gpu/drm/amd/amdkfd/kfd_queue.c | 4 ++-- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 3 +-- 5 files changed, 12 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +7 -1
@@ -2680,6 +2680,13 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)break ; } +/* Check for IP version 9.4.3 with A0 hardware */ +if (amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) && + !amdgpu_device_get_rev_id (adev)) { +dev_err (adev->dev,"Unsupported A0 hardware\n" ); +return -ENODEV ;/* device unsupported - no device error */ + } + if (amdgpu_has_atpx() && (amdgpu_is_atpx_hybrid() || amdgpu_has_atpx_dgpu_power_cntl()) &&
@@ -2692,7 +2699,6 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) adev->has_pr3 = parent ?pci_pr3_present (parent) : false; } - adev->pm.pp_feature = amdgpu_pp_feature_mask;if (amdgpu_sriov_vf (adev) || sched_policy ==KFD_SCHED_POLICY_NO_HWS ) adev->pm.pp_feature &= ~PP_GFXOFF_MASK ;
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -12
@@ -1207,10 +1207,7 @@ static void gmc_v9_0_get_coherence_flags(struct amdgpu_device *adev,if (uncached) { mtype =MTYPE_UC ; }else if (ext_coherent) { -if (gc_ip_version ==IP_VERSION (9 ,5 ,0 ) || adev->rev_id) - mtype = is_local ?MTYPE_CC :MTYPE_UC ; -else - mtype =MTYPE_UC ; + mtype = is_local ?MTYPE_CC :MTYPE_UC ; }else if (adev->flags &AMD_IS_APU ) { mtype = is_local ? mtype_local :MTYPE_NC ; }else {
@@ -1330,7 +1327,7 @@ static void gmc_v9_0_override_vm_pte_flags(struct amdgpu_device *adev, mtype_local =MTYPE_CC ; *flags =AMDGPU_PTE_MTYPE_VG10 (*flags, mtype_local); - }else if (adev->rev_id) { + }else {/* MTYPE_UC case */ *flags =AMDGPU_PTE_MTYPE_VG10 (*flags,MTYPE_CC ); }
@@ -2331,13 +2328,6 @@ static int gmc_v9_0_hw_init(void *handle) adev->gmc.flush_tlb_needs_extra_type_2 =amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,0 ) && adev->gmc.xgmi.num_physical_nodes; -/* -* TODO: This workaround is badly documented and had a buggy -* implementation. We should probably verify what we do here. -*/ - adev->gmc.flush_tlb_needs_extra_type_0 = -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,3 ) && - adev->rev_id ==0 ;/* The sequence of these two function calls matters.*/ gmc_v9_0_init_golden_registers (adev);
drivers/gpu/drm/amd/amdkfd/kfd_device.c +0 -5
@@ -347,11 +347,6 @@ struct kfd_dev *kgd2kfd_probe(struct amdgpu_device *adev, bool vf) f2g = &aldebaran_kfd2kgd;break ;case IP_VERSION (9 ,4 ,3 ): - gfx_target_version = adev->rev_id >=1 ?90402 - : adev->flags &AMD_IS_APU ?90400 - :90401 ; - f2g = &gc_9_4_3_kfd2kgd; -break ;case IP_VERSION (9 ,4 ,4 ): gfx_target_version =90402 ; f2g = &gc_9_4_3_kfd2kgd;
drivers/gpu/drm/amd/amdkfd/kfd_queue.c +2 -2
@@ -424,7 +424,7 @@ static u32 kfd_get_vgpr_size_per_cu(u32 gfxv) {u32 vgpr_size =0x40000 ; -if ((gfxv /100 *100 ) ==90400 ||/* GFX_VERSION_AQUA_VANJARAM */ +if (gfxv ==90402 ||/* GFX_VERSION_AQUA_VANJARAM */ gfxv ==90010 ||/* GFX_VERSION_ALDEBARAN */ gfxv ==90008 )/* GFX_VERSION_ARCTURUS */ vgpr_size =0x80000 ;
@@ -483,7 +483,7 @@ void kfd_queue_ctx_save_restore_size(struct kfd_topology_device *dev)if (gfxv ==80002 )/* GFX_VERSION_TONGA */ props->eop_buffer_size =0x8000 ; -else if ((gfxv /100 *100 ) ==90400 )/* GFX_VERSION_AQUA_VANJARAM */ +else if (gfxv ==90402 )/* GFX_VERSION_AQUA_VANJARAM */ props->eop_buffer_size =4096 ;else if (gfxv >=80000 ) props->eop_buffer_size =4096 ;
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +1 -2
@@ -1272,8 +1272,7 @@ svm_range_get_pte_flags(struct kfd_node *node,case IP_VERSION (9 ,4 ,3 ):case IP_VERSION (9 ,4 ,4 ):if (ext_coherent) - mtype_local = (gc_ip_version <IP_VERSION (9 ,5 ,0 ) && !node->adev->rev_id) ? -AMDGPU_VM_MTYPE_UC :AMDGPU_VM_MTYPE_CC ; + mtype_local =AMDGPU_VM_MTYPE_CC ;else mtype_local = amdgpu_mtype_local ==1 ?AMDGPU_VM_MTYPE_NC : amdgpu_mtype_local ==2 ?AMDGPU_VM_MTYPE_CC :AMDGPU_VM_MTYPE_RW ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 567/670 drm/amdgpu/gmc9: add extra type-2 TLB flush for gfx942/gfx950
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Elena Sakhnovitch <[email protected]>
[ Upstream commit 232213c9bd7f703836164f23160b76657094a7db ]
Add extra type-2 TLB flush for GC 9.5.0, similar race condition was observed as Vega20+XGMI. Add to GC 9.4.3 and 9.4.4 too, as they share the same multi-XCD TLB topology.
--- drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +15 -3
@@ -2324,10 +2324,22 @@ static int gmc_v9_0_hw_init(void *handle)* (type 2), which flushes both. Due to a race condition with * concurrent memory accesses using the same TLB cache line, we still * need a second TLB flush after this. +* +* GC 9.4.3, 9.4.4 and 9.5.0 hit a similar race. */ - adev->gmc.flush_tlb_needs_extra_type_2 = -amdgpu_ip_version (adev,GC_HWIP ,0 ) ==IP_VERSION (9 ,4 ,0 ) && - adev->gmc.xgmi.num_physical_nodes; +switch (amdgpu_ip_version (adev,GC_HWIP ,0 )) { +case IP_VERSION (9 ,4 ,0 ): + adev->gmc.flush_tlb_needs_extra_type_2 = + adev->gmc.xgmi.num_physical_nodes; +break ; +case IP_VERSION (9 ,4 ,3 ): +case IP_VERSION (9 ,4 ,4 ): +case IP_VERSION (9 ,5 ,0 ): + adev->gmc.flush_tlb_needs_extra_type_2 = true; +break ; +default : +break ; + }/* The sequence of these two function calls matters.*/ gmc_v9_0_init_golden_registers (adev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 568/670 exfat: advance valid_size to EOF for append writes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chi Zhiling <[email protected]>
[ Upstream commit b70ab407503706289163dd59f1ac3e942bacc37d ]
For an append write, the write position is recalculated by generic_write_checks(). Therefore, the write position must be obtained after generic_write_checks() returns.
Using the original write position to advance valid_size may cause the valid_size update to be skipped, potentially exposing stale data.
Also move the truncate_pagecache() check below the recalculated position, so that pos is never read before it is assigned.
--- fs/exfat/file.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
fs/exfat/file.c +8 -10
@@ -581,23 +581,18 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)struct file *file = iocb->ki_filp;struct inode *inode =file_inode (file);struct exfat_inode_info *ei =EXFAT_I (inode); -loff_t pos = iocb->ki_pos; -loff_t valid_size; +loff_t pos, valid_size;if (unlikely (exfat_forced_shutdown (inode->i_sb)))return -EIO ;inode_lock (inode); -if (pos >i_size_read (inode)) -truncate_pagecache (inode,i_size_read (inode)); - - valid_size = ei->valid_size; - ret =generic_write_checks (iocb, iter);if (ret <=0 ) goto unlock; + pos = iocb->ki_pos;if (iocb->ki_flags &IOCB_DIRECT ) {unsigned long align = pos |iov_iter_alignment (iter);
@@ -608,6 +603,10 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter) } } +if (pos >i_size_read (inode)) +truncate_pagecache (inode,i_size_read (inode)); + + valid_size = ei->valid_size;if (pos > valid_size) { ret =exfat_extend_valid_size (file, pos);if (ret <0 && ret != -ENOSPC ) {
@@ -617,6 +616,8 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter) }if (ret <0 ) goto unlock; + + pos = valid_size; } ret =__generic_file_write_iter (iocb, iter);
@@ -625,9 +626,6 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)inode_unlock (inode); -if (pos > valid_size) - pos = valid_size; -if (iocb->ki_pos > pos) {ssize_t err =generic_write_sync (iocb, iocb->ki_pos - pos);if (err <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 569/670 mptcp: fix subflow bitfield misuse
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit 7538fa33bb2f66b8b809ff39d58308be48e197a0 ]
The subflow status bitfield is protected by the subflow socket lock, with one notable exception: the close_event_done bit is actually under the msk socket lock protection.
As reported by Clashiko [1], flipping the latter bit may corrupt other entries in the same bitfield.
Move the close_event_done outside the bitfield, in a 32bit hole.
--- net/mptcp/protocol.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/mptcp/protocol.h +4 -2
@@ -544,14 +544,16 @@ struct mptcp_subflow_context { stale : 1, /* unable to snd/rcv data, do not use for xmit */ valid_csum_seen : 1, /* at least one csum validated */ is_mptfo : 1, /* subflow is doing TFO */ - close_event_done : 1, /* has done the post-closed part */ mpc_drop : 1, /* the MPC option has been dropped in a rtx */ resetting : 1, /* subflow is resetting */ - __unused : 7; + __unused : 8;bool data_avail;bool scheduled;bool pm_listener;/* a listener managed by the kernel PM? */ bool fully_established;/* path validated */ +bool close_event_done;/* has done the post-closed part, +* protected by msk socket lock +*/ u32 remote_nonce;u64 thmac;u32 local_nonce;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 570/670 f2fs: bound the SIT/NAT bitmaps by the checkpoint pack
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kaixuan Li <[email protected]>
[ Upstream commit 080833a32fd5dc10b3acf2fa9af9b3213e6cb617 ]
sit_ver_bitmap_bytesize and nat_ver_bitmap_bytesize are used as memcpy lengths into and out of sbi->ckpt, which is sized from cp_payload alone, and nothing compares either length against that allocation.
sanity_check_ckpt() has checked these two fields since c77ec61ca0a4, which added them after a crafted image overran build_sit_info(). That check ties each length to a segment count; it never compares either against the allocation, which is the half this adds.
Mounting over-reads in build_sit_info() and build_node_manager(), and the first checkpoint writes the same lengths back through the same pointers, so the over-read's contents reach the on-disk checkpoint. An unmount is enough; the filesystem does not have to be used.
Bound both ends the way __bitmap_ptr() lays them out. The three branches differ, so a single sum of the two lengths would still admit a small overflow when cp_payload is non-zero.
--- fs/f2fs/super.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
fs/f2fs/super.c +24 -0
@@ -3773,6 +3773,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)block_t avail_node_count, valid_node_count;unsigned int nat_blocks, nat_bits_bytes, nat_bits_blocks;unsigned int sit_blk_cnt; +unsigned long long ckpt_size, sit_end, nat_end;int i, j; total =le32_to_cpu (raw_super->segment_count);
@@ -3904,6 +3905,29 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)return 1 ; } +/* +* Nothing above ties the bitmap lengths to sbi->ckpt, which is +* (1 + cp_payload) blocks. Bound both ends the way __bitmap_ptr() +* lays them out. +*/ + ckpt_size = (unsigned long long )(cp_payload +1 ) *F2FS_BLKSIZE ; +if (__is_set_ckpt_flags (ckpt,CP_LARGE_NAT_BITMAP_FLAG )) { + nat_end =CP_MIN_CHKSUM_OFFSET +sizeof (__le32) + nat_bitmap_size; + sit_end = nat_end + sit_bitmap_size; + }else if (cp_payload >0 ) { + nat_end =CP_MIN_CHKSUM_OFFSET + nat_bitmap_size; + sit_end =F2FS_BLKSIZE + sit_bitmap_size; + }else { + sit_end =CP_MIN_CHKSUM_OFFSET + sit_bitmap_size; + nat_end = sit_end + nat_bitmap_size; + } + +if (sit_end > ckpt_size || nat_end > ckpt_size) { +f2fs_err (sbi,"Bitmaps do not fit the checkpoint pack: sit ends at %llu, nat at %llu, pack is %llu bytes" , + sit_end, nat_end, ckpt_size); +return 1 ; + } +if (__is_set_ckpt_flags (ckpt,CP_LARGE_NAT_BITMAP_FLAG ) &&le32_to_cpu (ckpt->checksum_offset) !=CP_MIN_CHKSUM_OFFSET ) { f2fs_warn(sbi, "using deprecated layout of large_nat_bitmap, "
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 571/670 block: introduce bio_in_atomic()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tal Zussman <[email protected]>
[ Upstream commit 8ed0831b5263e1aa48d99063795a1f20e4e69b50 ]
Move the atomic context detection logic from erofs's z_erofs_in_atomic() into the block layer as bio_in_atomic(). This helper returns true when the current context is unsafe for sleeping bio completion handlers (e.g., hard/soft IRQ, preempt-disabled).
The logic was originally added to erofs in commit c99fab6e80b7 ("erofs:
fix atomic context detection when !CONFIG_DEBUG_LOCK_ALLOC"). A subsequent patch will use it in the block layer's bio completion infrastructure, so move it to include/linux/bio.h where both subsystems can share it.
Convert erofs to call the new bio_in_atomic() directly.
Stable-dep-of: a605d5d71a6d ("f2fs: fix to use bio_in_atomic() in f2fs_read_end_io()")
--- fs/erofs/zdata.c | 11 +---------- include/linux/bio.h | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 10 deletions(-)
fs/erofs/zdata.c +1 -10
@@ -1386,15 +1386,6 @@ static void z_erofs_decompressqueue_kthread_work(struct kthread_work *work) }#endif -/* Use (kthread_)work in atomic contexts to minimize scheduling overhead */ -static inline bool z_erofs_in_atomic (void ) -{ -if (IS_ENABLED (CONFIG_PREEMPTION ) &&rcu_preempt_depth ()) -return true; -if (!IS_ENABLED (CONFIG_PREEMPT_COUNT )) -return true; -return !preemptible (); -}static void z_erofs_decompress_kickoff (struct z_erofs_decompressqueue *io,int bios)
@@ -1411,7 +1402,7 @@ static void z_erofs_decompress_kickoff(struct z_erofs_decompressqueue *io,if (atomic_add_return (bios, &io->pending_bios))return ; -if (z_erofs_in_atomic ()) { +if (bio_in_atomic ()) {/* See `sync_decompress` in sysfs-fs-erofs for more details */ if (sbi->sync_decompress ==EROFS_SYNC_DECOMPRESS_AUTO ) sbi->sync_decompress =EROFS_SYNC_DECOMPRESS_FORCE_ON ;
include/linux/bio.h +15 -0
@@ -377,6 +377,21 @@ static inline struct bio *bio_alloc(struct block_device *bdev,void submit_bio (struct bio *bio); +/** +* bio_in_atomic - check if the current context is unsafe for bio completion +* +* Return: %true in atomic contexts (e.g. hard/soft IRQ, preempt-disabled); +* %false when a bio can be safely completed in the current context. +*/ +static inline bool bio_in_atomic (void ) +{ +if (IS_ENABLED (CONFIG_PREEMPTION ) &&rcu_preempt_depth ()) +return true; +if (!IS_ENABLED (CONFIG_PREEMPT_COUNT )) +return true; +return !preemptible (); +} +extern void bio_endio (struct bio *);static inline void bio_io_error (struct bio *bio)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 572/670 f2fs: fix to use bio_in_atomic() in f2fs_read_end_io()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit a605d5d71a6d280c43c7ede9778dda63fb5c3f22 ]
f2fs_read_end_io() uses "in_task() && !irqs_disabled()" to decide whether it is safe to sleep, the result is passed down as @in_task to:
- f2fs_put_dic() -> f2fs_free_dic() -> f2fs_release_decomp_mem() -> vm_unmap_ram(), which may sleep.
- f2fs_end_read_compressed_page() -> f2fs_cache_compressed_page() -> f2fs_grab_cache() -> f2fs_lock_cache(), which may sleep in wait_on_bit_lock().
However, the check still treats below task contexts as sleepable:
- with spinlock held via spin_lock(), i.e. preempt count != 0 while irqs are enabled.
- with BH disabled via local_bh_disable().
- inside an RCU read lock on kernels with CONFIG_PREEMPTION.
- with any spinlock held on kernels without CONFIG_PREEMPT_COUNT.
So the "sleeping function called from invalid context" issue fixed by commit 08a7efc5b02a ("f2fs: vm_unmap_ram() may be called from an invalid context") can still be triggered.
The block layer provides bio_in_atomic() for exactly this purpose, it checks rcu_preempt_depth() and preemptible(), and conservatively returns true if CONFIG_PREEMPT_COUNT is disabled, let's use it instead. The difference is as below:
old: intask = in_task() && !irqs_disabled()
new: intask = !bio_in_atomic()
Context | old intask | new intask
-------------------------------------+----------------+----------------
Hard IRQ / softirq | false | false IRQs disabled | false | false spin_lock() held, IRQs enabled | true (wrong) | false BH disabled by local_bh_disable() | true (wrong) | false RCU read lock (CONFIG_PREEMPTION) | true (wrong) | false Spinlock held, w/o PREEMPT_COUNT | true (wrong) | false
Note that on kernels without CONFIG_PREEMPT_COUNT, bio_in_atomic() always returns true, so dic freeing will always be offloaded to sbi->wq, and compressed pages will not be cached in f2fs_read_end_io(); this is the price of correctness, since there is no way to tell whether the current context can sleep.
--- fs/f2fs/data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/data.c +1 -1
@@ -287,7 +287,7 @@ static void f2fs_read_end_io(struct bio *bio) {struct f2fs_sb_info *sbi =F2FS_P_SB (bio_first_page_all (bio));struct bio_post_read_ctx *ctx; -bool intask =in_task () && !irqs_disabled (); +bool intask = !bio_in_atomic ();iostat_update_and_unbind_ctx (bio); ctx = bio->bi_private;
Signature · 1 line
2.53.0