Skip to content

Commit 472de63

Browse files
James Morsewilldeacon
authored andcommitted
firmware: arm_sdei: Document the motivation behind these set_fs() calls
The SDEI handler save/restores the addr_limit using set_fs(). It isn't very clear why. The reason is to mirror the arch code's entry assembly. The arch code does this because perf may access user-space, and inheriting the addr_limit may be a problem. Add a comment explaining why this is here. Suggested-by: Christoph Hellwig <[email protected]> Signed-off-by: James Morse <[email protected]> Link: https://bugs.chromium.org/p/project-zero/issues/detail?id=822 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 82b2077 commit 472de63

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/firmware/arm_sdei.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,14 @@ int sdei_event_handler(struct pt_regs *regs,
11281128
mm_segment_t orig_addr_limit;
11291129
u32 event_num = arg->event_num;
11301130

1131+
/*
1132+
* Save restore 'fs'.
1133+
* The architecture's entry code save/restores 'fs' when taking an
1134+
* exception from the kernel. This ensures addr_limit isn't inherited
1135+
* if you interrupted something that allowed the uaccess routines to
1136+
* access kernel memory.
1137+
* Do the same here because this doesn't come via the same entry code.
1138+
*/
11311139
orig_addr_limit = get_fs();
11321140
set_fs(USER_DS);
11331141

0 commit comments

Comments
 (0)