From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,URIBL_RED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6404BC433E0 for ; Sat, 9 Jan 2021 20:43:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AE23523B02 for ; Sat, 9 Jan 2021 20:43:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE23523B02 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=amacapital.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id EFD878D000E; Sat, 9 Jan 2021 15:43:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EADEF8D0002; Sat, 9 Jan 2021 15:43:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D4DF68D000E; Sat, 9 Jan 2021 15:43:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0208.hostedemail.com [216.40.44.208]) by kanga.kvack.org (Postfix) with ESMTP id BFAEB8D0002 for ; Sat, 9 Jan 2021 15:43:02 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 86473364C for ; Sat, 9 Jan 2021 20:43:02 +0000 (UTC) X-FDA: 77687411004.12.road61_250668b274fe Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id 639CA18012B40 for ; Sat, 9 Jan 2021 20:43:02 +0000 (UTC) X-HE-Tag: road61_250668b274fe X-Filterd-Recvd-Size: 8401 Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Sat, 9 Jan 2021 20:43:01 +0000 (UTC) Received: by mail-pg1-f181.google.com with SMTP id c22so9903563pgg.13 for ; Sat, 09 Jan 2021 12:43:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=iDC8zu1DnkHayfNIvehs/kpoM8d8bZ4+CgqaiflpHGo=; b=DjbCOGe9WIyDX24Jo8PAIImBM0mrum3QfT+hTtSRZt9/9kAUBg10owQ7/XURwWvORw BfnjCnFUEkBiEsPEPZiutaMMfA+XbBdkD3MKd80mQHdz88C37OcnYIu83HMU4AyTYE0K BJOF3xJn9qzr6bUaghVmW8QIS8CncIGplVvVORNZksx3eEYMLynwKXplw0f73c11LAm7 PfkMwagmjNVLlixc5tWnWCelSbtFmwjWYjIQwn4hCEoaOOLwhlLroxrKBUgF/cM0rtcA cXcW/zBCczJUwndN1Kz2TtUPsO06oxywsJqYCQ98AfxGjphk7rzrDsLf33dNnxHtpv2M 0+GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=iDC8zu1DnkHayfNIvehs/kpoM8d8bZ4+CgqaiflpHGo=; b=ZHRkxShvPfxgOUd9rHUdauQMd7tpZRZeTymV+Ul7HesbszXGbHJu7tSv1Qrz/MGw94 OF9nS2od6RLyn55M2XYByLTbXOlTBri7i4PmXUOmQybb+xy1vHh1DoF2FS4r0PX2V7si 9JhAMR9cx/zQThVT/V5ejCD2S5g1xEUISZiZrk+LXXxtFsEiVpK7QAjByhIE7QGF8m4k /R3AkwBQJGpqNoE1ve4s6S0iCgRiqaEbaUuSCjJiCqRTwFQ9a+/or6DFARuvvXH04QTN oAVRgStHfUq+zCzbsyLKjQYXuHk0k+gksrbHhzT/nWWo66u4ZF7udP9oElqcmI/0vTgG kNTA== X-Gm-Message-State: AOAM530OBFJzm5xThHpseD7NuCY5FZ3/YAlT4JHxWTfCDNVkPo5ZbOUe saCDiLwvIp5Q+m+Vj6uzFcNJ0w== X-Google-Smtp-Source: ABdhPJw2glJ1RJ6LkYDXffm3GGsIit0j65/2pHvNzTsMsL4wCNfz5snM6XVu/ivVy5nTWLwje6g+cA== X-Received: by 2002:a62:a502:0:b029:1ae:6d07:b10f with SMTP id v2-20020a62a5020000b02901ae6d07b10fmr9698738pfm.12.1610224980710; Sat, 09 Jan 2021 12:43:00 -0800 (PST) Received: from ?IPv6:2600:1010:b057:c69:2465:1316:86ee:af99? ([2600:1010:b057:c69:2465:1316:86ee:af99]) by smtp.gmail.com with ESMTPSA id t206sm13334338pgb.84.2021.01.09.12.42.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 09 Jan 2021 12:42:59 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] x86/vm86/32: Remove VM86_SCREEN_BITMAP support Date: Sat, 9 Jan 2021 12:42:57 -0800 Message-Id: References: <87wnwl27dp.fsf@x220.int.ebiederm.org> Cc: Andy Lutomirski , x86@kernel.org, LKML , Andrea Arcangeli , Linux-MM , Jason Gunthorpe , Linus Torvalds , Matthew Wilcox , Jann Horn , Jan Kara , Yu Zhao , Peter Xu In-Reply-To: <87wnwl27dp.fsf@x220.int.ebiederm.org> To: ebiederm@xmission.com X-Mailer: iPhone Mail (18B121) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: > On Jan 9, 2021, at 12:17 PM, ebiederm@xmission.com wrote: >=20 > =EF=BB=BFAndy Lutomirski writes: >=20 >> 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 racin= g >> CoW operation to falsely believe that the underlying memory was not >> writable. >>=20 >> I can't find any users at all of this mechanism, so just remove it. >=20 > In another age this was used by dosemu. Have you looked at dosemu to > see if it still uses this support (on 32bit where dosemu can use vm86)? >=20 > It may still be a valid removal target I just wanted to point out what > the original user was. I=E2=80=99m pretty sure that dosemu2 does not use this support. I think the= original dosemu doesn=E2=80=99t either, but I=E2=80=99m also not convinced i= t has any users at all. I meant to cc Stas, and I will for v2. >=20 > Eric >=20 >> Cc: Andrea Arcangeli >> Cc: Linux-MM >> Cc: Jason Gunthorpe >> Cc: x86@kernel.org >> Cc: Linus Torvalds >> Cc: Matthew Wilcox >> Cc: Jann Horn >> Cc: Jan Kara >> Cc: Yu Zhao >> Cc: Peter Xu >> Signed-off-by: Andy Lutomirski >> --- >> arch/x86/include/uapi/asm/vm86.h | 2 +- >> arch/x86/kernel/vm86_32.c | 55 ++++++-------------------------- >> 2 files changed, 10 insertions(+), 47 deletions(-) >>=20 >> diff --git a/arch/x86/include/uapi/asm/vm86.h b/arch/x86/include/uapi/asm= /vm86.h >> index d2ee4e307ef8..50004fb4590d 100644 >> --- a/arch/x86/include/uapi/asm/vm86.h >> +++ b/arch/x86/include/uapi/asm/vm86.h >> @@ -106,7 +106,7 @@ struct vm86_struct { >> /* >> * flags masks >> */ >> -#define VM86_SCREEN_BITMAP 0x0001 >> +#define VM86_SCREEN_BITMAP 0x0001 /* no longer supported */ >>=20 >> struct vm86plus_info_struct { >> unsigned long force_return_for_pic:1; >> diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c >> index 764573de3996..28b9e8d511e1 100644 >> --- a/arch/x86/kernel/vm86_32.c >> +++ b/arch/x86/kernel/vm86_32.c >> @@ -160,49 +160,6 @@ void save_v86_state(struct kernel_vm86_regs *regs, i= nt retval) >> do_exit(SIGSEGV); >> } >>=20 >> -static void mark_screen_rdonly(struct mm_struct *mm) >> -{ >> - struct vm_area_struct *vma; >> - spinlock_t *ptl; >> - pgd_t *pgd; >> - p4d_t *p4d; >> - pud_t *pud; >> - pmd_t *pmd; >> - pte_t *pte; >> - int i; >> - >> - mmap_write_lock(mm); >> - pgd =3D pgd_offset(mm, 0xA0000); >> - if (pgd_none_or_clear_bad(pgd)) >> - goto out; >> - p4d =3D p4d_offset(pgd, 0xA0000); >> - if (p4d_none_or_clear_bad(p4d)) >> - goto out; >> - pud =3D pud_offset(p4d, 0xA0000); >> - if (pud_none_or_clear_bad(pud)) >> - goto out; >> - pmd =3D pmd_offset(pud, 0xA0000); >> - >> - if (pmd_trans_huge(*pmd)) { >> - vma =3D find_vma(mm, 0xA0000); >> - split_huge_pmd(vma, pmd, 0xA0000); >> - } >> - if (pmd_none_or_clear_bad(pmd)) >> - goto out; >> - pte =3D pte_offset_map_lock(mm, pmd, 0xA0000, &ptl); >> - for (i =3D 0; i < 32; i++) { >> - if (pte_present(*pte)) >> - set_pte(pte, pte_wrprotect(*pte)); >> - pte++; >> - } >> - pte_unmap_unlock(pte, ptl); >> -out: >> - mmap_write_unlock(mm); >> - flush_tlb_mm_range(mm, 0xA0000, 0xA0000 + 32*PAGE_SIZE, PAGE_SHIFT, f= alse); >> -} >> - >> - >> - >> static int do_vm86_irq_handling(int subfunction, int irqnumber); >> static long do_sys_vm86(struct vm86plus_struct __user *user_vm86, bool pl= us); >>=20 >> @@ -282,6 +239,15 @@ static long do_sys_vm86(struct vm86plus_struct __use= r *user_vm86, bool plus) >> offsetof(struct vm86_struct, int_revectored))) >> return -EFAULT; >>=20 >> + >> + /* VM86_SCREEN_BITMAP had numerous bugs and appears to have no users= . */ >> + if (v.flags & VM86_SCREEN_BITMAP) { >> + char comm[TASK_COMM_LEN]; >> + >> + pr_info_once("vm86: '%s' uses VM86_SCREEN_BITMAP, which is no lo= nger supported\n", get_task_comm(comm, current); >> + return -EINVAL; >> + } >> + >> memset(&vm86regs, 0, sizeof(vm86regs)); >>=20 >> vm86regs.pt.bx =3D v.regs.ebx; >> @@ -370,9 +336,6 @@ static long do_sys_vm86(struct vm86plus_struct __user= *user_vm86, bool plus) >> update_task_stack(tsk); >> preempt_enable(); >>=20 >> - if (vm86->flags & VM86_SCREEN_BITMAP) >> - mark_screen_rdonly(tsk->mm); >> - >> memcpy((struct kernel_vm86_regs *)regs, &vm86regs, sizeof(vm86regs)); >> return regs->ax; >> }