[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 7 Jul 2021 12:04:25 +0100
From: Robin Murphy <robin.murphy@....com>
To: David Laight <David.Laight@...LAB.COM>,
Catalin Marinas <catalin.marinas@....com>
Cc: Chen Huang <chenhuang5@...wei.com>,
Al Viro <viro@...iv.linux.org.uk>,
Matthew Wilcox <willy@...radead.org>,
Christoph Hellwig <hch@...radead.org>,
Mark Rutland <mark.rutland@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
Stephen Rothwell <sfr@...b.auug.org.au>,
Randy Dunlap <rdunlap@...radead.org>,
Will Deacon <will@...nel.org>,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
linux-mm <linux-mm@...ck.org>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [BUG] arm64: an infinite loop in generic_perform_write()
On 2021-07-07 10:55, David Laight wrote:
>>> I think it's worth doing the copy_to_user() fallback in a loop until it
>>> faults or hits the end of the buffer. This would solve the problem we
>>> currently have with writing more bytes than actually reported. The
>>> copy_from_user() is not necessary, a byte would suffice.
>>
>> The thing is, we don't really have that problem since the set_fs cleanup
>> removed IMP-DEF STP behaviour from the picture - even with the current
>> mess we could perfectly well know which of the two STTRs faulted if we
> ...
>
> There is a much more interesting case though.
> It is possible for userspace to have supplied a misaligned
> buffer that is mmapped to an IO address that doesn't support
> misaligned accesses even though normal memory does support them.
Er, yes, that's where this whole thing started - don't worry, I haven't
forgotten.
> So the 'byte retry' loop would work for the entire buffer.
Indeed it might in certain cases, but is that (unlikely) possibility
worth our while? What it boils down to is maintaining complexity in the
kernel purely to humour broken userspace doing a nonsensical thing, when
it's equally valid to just return a short read/write and let said broken
userspace take responsibility for retrying the remainder of said
nonsensical thing by itself. If userspace has managed to get its hands
on an mmap of something without Normal memory semantics, I would expect
it to know what it's doing...
Thanks,
Robin.
Powered by blists - more mailing lists