Skip to content

Commit 621afc6

Browse files
Julien ThierryRussell King
authored andcommitted
ARM: 8794/1: uaccess: Prevent speculative use of the current addr_limit
A mispredicted conditional call to set_fs could result in the wrong addr_limit being forwarded under speculation to a subsequent access_ok check, potentially forming part of a spectre-v1 attack using uaccess routines. This patch prevents this forwarding from taking place, but putting heavy barriers in set_fs after writing the addr_limit. Porting commit c2f0ad4 ("arm64: uaccess: Prevent speculative use of the current addr_limit"). Signed-off-by: Julien Thierry <julien.thierry@arm.com> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
1 parent 18ea66b commit 621afc6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

arch/arm/include/asm/uaccess.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ extern int __put_user_bad(void);
6969
static inline void set_fs(mm_segment_t fs)
7070
{
7171
current_thread_info()->addr_limit = fs;
72+
73+
/*
74+
* Prevent a mispredicted conditional call to set_fs from forwarding
75+
* the wrong address limit to access_ok under speculation.
76+
*/
77+
dsb(nsh);
78+
isb();
79+
7280
modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
7381
}
7482

0 commit comments

Comments
 (0)