Patch "padata: Fix list iterator in padata_do_serial()" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    padata: Fix list iterator in padata_do_serial()

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     padata-fix-list-iterator-in-padata_do_serial.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 2ffb5970f09a59f17224a64bb18e64e9296e8bd0
Author: Daniel Jordan <daniel.m.jordan@xxxxxxxxxx>
Date:   Wed Nov 16 20:28:04 2022 -0500

    padata: Fix list iterator in padata_do_serial()
    
    [ Upstream commit 57ddfecc72a6c9941d159543e1c0c0a74fe9afdd ]
    
    list_for_each_entry_reverse() assumes that the iterated list is nonempty
    and that every list_head is embedded in the same type, but its use in
    padata_do_serial() breaks both rules.
    
    This doesn't cause any issues now because padata_priv and padata_list
    happen to have their list fields at the same offset, but we really
    shouldn't be relying on that.
    
    Fixes: bfde23ce200e ("padata: unbind parallel jobs from specific CPUs")
    Signed-off-by: Daniel Jordan <daniel.m.jordan@xxxxxxxxxx>
    Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/padata.c b/kernel/padata.c
index 4d31a69a9b38..11ca3ebd8b12 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -403,13 +403,16 @@ void padata_do_serial(struct padata_priv *padata)
 	int hashed_cpu = padata_cpu_hash(pd, padata->seq_nr);
 	struct padata_list *reorder = per_cpu_ptr(pd->reorder_list, hashed_cpu);
 	struct padata_priv *cur;
+	struct list_head *pos;
 
 	spin_lock(&reorder->lock);
 	/* Sort in ascending order of sequence number. */
-	list_for_each_entry_reverse(cur, &reorder->list, list)
+	list_for_each_prev(pos, &reorder->list) {
+		cur = list_entry(pos, struct padata_priv, list);
 		if (cur->seq_nr < padata->seq_nr)
 			break;
-	list_add(&padata->list, &cur->list);
+	}
+	list_add(&padata->list, pos);
 	spin_unlock(&reorder->lock);
 
 	/*



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux