LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Huacai Chen <chenhuacai@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Davidlohr Bueso <dave@stgolabs.net>,
	Huacai Chen <chenhuacai@loongson.cn>,
	Ingo Molnar <mingo@redhat.com>,
	Darren Hart <dvhart@infradead.org>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	"open list:MIPS" <linux-mips@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Xuefeng Li <lixuefeng@loongson.cn>,
	Jiaxun Yang <jiaxun.yang@flygoat.com>,
	Hongchen Zhang <zhanghongchen@loongson.cn>
Subject: Re: [PATCH] futex: Fix fault_in_user_writeable()
Date: Tue, 17 Aug 2021 20:27:03 +0800	[thread overview]
Message-ID: <CAAhV-H4GVWw0eNYRWmGY66A6FVKcexAGr-Wh_=9VgxxEkpiKJA@mail.gmail.com> (raw)
In-Reply-To: <YRuFMbUi7ZN315dY@hirez.programming.kicks-ass.net>

Hi, all,

On Tue, Aug 17, 2021 at 5:45 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Tue, Aug 17, 2021 at 11:05:15AM +0200, Thomas Gleixner wrote:
> > Huacai,
> >
> > On Tue, Aug 17 2021 at 15:38, Huacai Chen wrote:
> > > On Tue, Aug 17, 2021 at 3:07 PM Thomas Gleixner <tglx@linutronix.de> wrote:
> > > On X86, it returns 0; on MIPS64 without patch, it hangs in kernel; on
> > > MIPS64 with this patch, it returns -1.
> >
> > As expected.
> >
> > > Then, I want to know, on "W implies R" archs (such as X86), should it
> > > return 0? Maybe return -1 is more reasonable? (because the VMA is
> > > marked as write-only). If this program should return -1, then I don't
> > > think this is a MIPS-specific problem.
> >
> > No. mmap(.., PROT_WRITE...) is simply impossible on x86 and implies
> > PROT_READ as documented in mmap(2).
> >
> > So why should this fail and only fail in the fault case, but succeed
> > when the PTE is already established?
>
> I wouldn't actually mind if it failed on fault -- it's the 'best' we can
> do on x86. Doing a RmW op on PROT_WRITE is silly and deserves all the
> wreckage it can get.
If we must fix it in arch code, there are two methods: 1, don't use
write-only map (modify protection_map as Liu Lichao did); 2, override
arch_vma_access_permitted() to do extra checks. Thomas, which is
better?

Huacai

  reply	other threads:[~2021-08-17 12:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-16  6:54 Huacai Chen
2021-08-16 18:27 ` Davidlohr Bueso
2021-08-16 19:03   ` Thomas Gleixner
2021-08-17  1:53     ` Huacai Chen
2021-08-17  7:07       ` Thomas Gleixner
2021-08-17  7:38         ` Huacai Chen
2021-08-17  9:05           ` Thomas Gleixner
2021-08-17  9:45             ` Peter Zijlstra
2021-08-17 12:27               ` Huacai Chen [this message]
2021-08-17  9:22       ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAhV-H4GVWw0eNYRWmGY66A6FVKcexAGr-Wh_=9VgxxEkpiKJA@mail.gmail.com' \
    --to=chenhuacai@gmail.com \
    --cc=chenhuacai@loongson.cn \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tsbogend@alpha.franken.de \
    --cc=zhanghongchen@loongson.cn \
    --subject='Re: [PATCH] futex: Fix fault_in_user_writeable()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).