Skip to content

Commit 6e150b7

Browse files
H. Peter Anvinhansendc
authored andcommitted
x86/entry/vdso32: Don't rely on int80_landing_pad for adjusting ip
There is no fundamental reason to use the int80_landing_pad symbol to adjust ip when moving the vdso. If ip falls within the vdso, and the vdso is moved, we should change the ip accordingly, regardless of mode or location within the vdso. This *currently* can only happen on 32 bits, but there isn't any reason not to do so generically. Note that if this is ever possible from a vdso-internal call, then the user space stack will also needed to be adjusted (as well as the shadow stack, if enabled.) Fortunately this is not currently the case. At the moment, we don't even consider other threads when moving the vdso. The assumption is that it is only used by process freeze/thaw for migration, where this is not an issue. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Link: https://patch.msgid.link/20251216212606.1325678-5-hpa@zytor.com
1 parent 693c819 commit 6e150b7

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

arch/x86/entry/vdso/vma.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,12 @@ static vm_fault_t vdso_fault(const struct vm_special_mapping *sm,
6565
static void vdso_fix_landing(const struct vdso_image *image,
6666
struct vm_area_struct *new_vma)
6767
{
68-
if (in_ia32_syscall() && image == &vdso32_image) {
69-
struct pt_regs *regs = current_pt_regs();
70-
unsigned long vdso_land = image->sym_int80_landing_pad;
71-
unsigned long old_land_addr = vdso_land +
72-
(unsigned long)current->mm->context.vdso;
73-
74-
/* Fixing userspace landing - look at do_fast_syscall_32 */
75-
if (regs->ip == old_land_addr)
76-
regs->ip = new_vma->vm_start + vdso_land;
77-
}
68+
struct pt_regs *regs = current_pt_regs();
69+
unsigned long ipoffset = regs->ip -
70+
(unsigned long)current->mm->context.vdso;
71+
72+
if (ipoffset < image->size)
73+
regs->ip = new_vma->vm_start + ipoffset;
7874
}
7975

8076
static int vdso_mremap(const struct vm_special_mapping *sm,

0 commit comments

Comments
 (0)