[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <176347611805.498.14857756863113145675.tip-bot2@tip-bot2>
Date: Tue, 18 Nov 2025 14:28:38 -0000
From: "tip-bot2 for Christophe Leroy" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Christophe Leroy <christophe.leroy@...roup.eu>,
Thomas Gleixner <tglx@...utronix.de>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: core/uaccess] iov_iter: Add missing speculation barrier to
copy_from_user_iter()
The following commit has been merged into the core/uaccess branch of tip:
Commit-ID: 803abedbd540617f136a2c4d7066ff2e304f016d
Gitweb: https://git.kernel.org/tip/803abedbd540617f136a2c4d7066ff2e304f016d
Author: Christophe Leroy <christophe.leroy@...roup.eu>
AuthorDate: Mon, 17 Nov 2025 17:43:42 +01:00
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitterDate: Tue, 18 Nov 2025 15:27:34 +01:00
iov_iter: Add missing speculation barrier to copy_from_user_iter()
The results of "access_ok()" can be mis-speculated. The result is that
the CPU can end speculatively:
if (access_ok(from, size))
// Right here
For the same reason as done in copy_from_user() in commit 74e19ef0ff80
("uaccess: Add speculation barrier to copy_from_user()"), add a speculation
barrier to copy_from_user_iter().
Signed-off-by: Christophe Leroy <christophe.leroy@...roup.eu>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Link: https://patch.msgid.link/6b73e69cc7168c89df4eab0a216e3ed4cca36b0a.1763396724.git.christophe.leroy@csgroup.eu
---
lib/iov_iter.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index a589935..896760b 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -49,11 +49,19 @@ size_t copy_from_user_iter(void __user *iter_from, size_t progress,
if (should_fail_usercopy())
return len;
- if (can_do_masked_user_access())
+ if (can_do_masked_user_access()) {
iter_from = mask_user_address(iter_from);
- else if (!access_ok(iter_from, len))
- return res;
+ } else {
+ if (!access_ok(iter_from, len))
+ return res;
+ /*
+ * Ensure that bad access_ok() speculation will not
+ * lead to nasty side effects *after* the copy is
+ * finished:
+ */
+ barrier_nospec();
+ }
to += progress;
instrument_copy_from_user_before(to, iter_from, len);
res = raw_copy_from_user(to, iter_from, len);
Powered by blists - more mailing lists