x86/vm86/32: Remove VM86_SCREEN_BITMAP support
Subsystems (3)
Andy Lutomirski
maintainerPATCH v2 1/1 x86/vm86/32: Remove VM86_SCREEN_BITMAP support
The implementation was rather buggy. It unconditionally marked PTEs read-only, even for VM_SHARED mappings. I'm not sure whether this is actually a problem, but it certainly seems unwise. More importantly, it released the mmap lock before flushing the TLB, which could allow a racing CoW operation to falsely believe that the underlying memory was not writable.
I can't find any users at all of this mechanism, so just remove it.
---
Changes from v1:
- Get rid of the whole screen_bitmap and the fault code, too.
arch/x86/include/asm/vm86.h | 1 - arch/x86/include/uapi/asm/vm86.h | 4 +-- arch/x86/kernel/vm86_32.c | 62 ++++++++------------------------ arch/x86/mm/fault.c | 30 ---------------- 4 files changed, 16 insertions(+), 81 deletions(-)
arch/x86/include/asm/vm86.h +0 -1
@@ -36,7 +36,6 @@ struct vm86 {unsigned long saved_sp0;unsigned long flags; -unsigned long screen_bitmap;unsigned long cpu_type;struct revectored_struct int_revectored;struct revectored_struct int21_revectored;
arch/x86/include/uapi/asm/vm86.h +2 -2
@@ -97,7 +97,7 @@ struct revectored_struct {struct vm86_struct {struct vm86_regs regs;unsigned long flags; -unsigned long screen_bitmap; +unsigned long screen_bitmap;/* unused, preserved by vm86() */ unsigned long cpu_type;struct revectored_struct int_revectored;struct revectored_struct int21_revectored;
@@ -106,7 +106,7 @@ struct vm86_struct {/* * flags masks */ -#define VM86_SCREEN_BITMAP 0x0001 +#define VM86_SCREEN_BITMAP 0x0001/* no longer supported */ struct vm86plus_info_struct {unsigned long force_return_for_pic:1 ;
arch/x86/kernel/vm86_32.c +14 -48
92 lines not on this page · raw message
arch/x86/mm/fault.c +0 -30
@@ -261,25 +261,6 @@ void arch_sync_kernel_mappings(unsigned long start, unsigned long end) } } -/* -* Did it hit the DOS screen memory VA from vm86 mode? -*/ -static inline void -check_v8086_mode (struct pt_regs *regs,unsigned long address, -struct task_struct *tsk) -{ -#ifdef CONFIG_VM86 -unsigned long bit; - -if (!v8086_mode (regs) || !tsk->thread.vm86) -return ; - - bit = (address -0xA0000 ) >>PAGE_SHIFT ; -if (bit <32 ) - tsk->thread.vm86->screen_bitmap |=1 << bit; -#endif -} -static bool low_pfn (unsigned long pfn) {return pfn < max_low_pfn;
@@ -334,15 +315,6 @@ KERN_ERR"******* Disabling USB legacy in the BIOS may also help.\n" ;#endif -/* -* No vm86 mode in 64-bit mode: -*/ -static inline void -check_v8086_mode (struct pt_regs *regs,unsigned long address, -struct task_struct *tsk) -{ -} -static int bad_address (void *p) {unsigned long dummy;
@@ -1395,8 +1367,6 @@ void do_user_addr_fault(struct pt_regs *regs,mm_fault_error (regs, hw_error_code, address, fault);return ; } - -check_v8086_mode (regs, address, tsk); }NOKPROBE_SYMBOL (do_user_addr_fault);
Signature · 1 line
2.29.2
19.01.2021 20:40, Andy Lutomirski пишет:
Quoted 22 lines
The implementation was rather buggy. It unconditionally marked PTEs read-only, even for
VM_SHAREDmappings. I'm not sure whether this is actually a problem, but it certainly seems unwise. More importantly, it released the mmap lock before flushing the TLB, which could allow a racing CoW operation to falsely believe that the underlying memory was not writable.I can't find any users at all of this mechanism, so just remove it.
Cc Andrea Arcangeli <[email protected]>Cc Linux-MM <[email protected]>Cc Jason Gunthorpe <[email protected]>Cc Linus Torvalds <[email protected]>Cc Matthew Wilcox <[email protected]>Cc Jann Horn <[email protected]>Cc Jan Kara <[email protected]>Cc Yu Zhao <[email protected]>Cc Peter Xu <[email protected]>Cc Stas Sergeev <[email protected]>Cc Brian Gerst <[email protected]>Signed-off-by Andy Lutomirski <[email protected]>
Quoted 1 line
---
dosemu2 just uses mprotect().
The BIOSSEG stuff in vm86_32.c is also
unused btw.
The following commit has been merged into the x86/cleanups branch of tip:
The following commit has been merged into the x86/cleanups branch of tip:
Commit-ID: 8ece53ef7f428ee3f8eab936268b1a3fe2725e6b Gitweb: https://git.kernel.org/tip/8ece53ef7f428ee3f8eab936268b1a3fe2725e6b Author: Andy Lutomirski <[email protected]> AuthorDate: Tue, 19 Jan 2021 09:40:55 -08:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Thu, 21 Jan 2021 20:08:53 +01:00
x86/vm86/32: Remove VM86_SCREEN_BITMAP support
The implementation was rather buggy. It unconditionally marked PTEs read-only, even for VM_SHARED mappings. I'm not sure whether this is actually a problem, but it certainly seems unwise. More importantly, it released the mmap lock before flushing the TLB, which could allow a racing CoW operation to falsely believe that the underlying memory was not writable.
I can't find any users at all of this mechanism, so just remove it.
--- arch/x86/include/asm/vm86.h | 1 +- arch/x86/include/uapi/asm/vm86.h | 4 +- arch/x86/kernel/vm86_32.c | 62 +++++++------------------------ arch/x86/mm/fault.c | 30 +--------------- 4 files changed, 16 insertions(+), 81 deletions(-)
arch/x86/include/asm/vm86.h +0 -1
@@ -36,7 +36,6 @@ struct vm86 {unsigned long saved_sp0;unsigned long flags; -unsigned long screen_bitmap;unsigned long cpu_type;struct revectored_struct int_revectored;struct revectored_struct int21_revectored;
arch/x86/include/uapi/asm/vm86.h +2 -2
@@ -97,7 +97,7 @@ struct revectored_struct {struct vm86_struct {struct vm86_regs regs;unsigned long flags; -unsigned long screen_bitmap; +unsigned long screen_bitmap;/* unused, preserved by vm86() */ unsigned long cpu_type;struct revectored_struct int_revectored;struct revectored_struct int21_revectored;
@@ -106,7 +106,7 @@ struct vm86_struct {/* * flags masks */ -#define VM86_SCREEN_BITMAP 0x0001 +#define VM86_SCREEN_BITMAP 0x0001/* no longer supported */ struct vm86plus_info_struct {unsigned long force_return_for_pic:1 ;
arch/x86/kernel/vm86_32.c +14 -48
92 lines not on this page · raw message
arch/x86/mm/fault.c +0 -30
@@ -262,25 +262,6 @@ void arch_sync_kernel_mappings(unsigned long start, unsigned long end) } } -/* -* Did it hit the DOS screen memory VA from vm86 mode? -*/ -static inline void -check_v8086_mode (struct pt_regs *regs,unsigned long address, -struct task_struct *tsk) -{ -#ifdef CONFIG_VM86 -unsigned long bit; - -if (!v8086_mode (regs) || !tsk->thread.vm86) -return ; - - bit = (address -0xA0000 ) >>PAGE_SHIFT ; -if (bit <32 ) - tsk->thread.vm86->screen_bitmap |=1 << bit; -#endif -} -static bool low_pfn (unsigned long pfn) {return pfn < max_low_pfn;
@@ -335,15 +316,6 @@ KERN_ERR"******* Disabling USB legacy in the BIOS may also help.\n" ;#endif -/* -* No vm86 mode in 64-bit mode: -*/ -static inline void -check_v8086_mode (struct pt_regs *regs,unsigned long address, -struct task_struct *tsk) -{ -} -static int bad_address (void *p) {unsigned long dummy;
@@ -1416,8 +1388,6 @@ good_area:mm_fault_error (regs, hw_error_code, address, fault);return ; } - -check_v8086_mode (regs, address, tsk); }NOKPROBE_SYMBOL (do_user_addr_fault);