[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <27fbb8c1-2a65-738f-6bec-13f450395ab7@arm.com>
Date: Thu, 24 Jun 2021 14:22:27 +0100
From: Robin Murphy <robin.murphy@....com>
To: Matthew Wilcox <willy@...radead.org>,
Christoph Hellwig <hch@...radead.org>
Cc: Chen Huang <chenhuang5@...wei.com>,
Mark Rutland <mark.rutland@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
Stephen Rothwell <sfr@...b.auug.org.au>,
Al Viro <viro@...iv.linux.org.uk>,
Randy Dunlap <rdunlap@...radead.org>,
Catalin Marinas <catalin.marinas@....com>,
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-06-24 12:15, Matthew Wilcox wrote:
> On Thu, Jun 24, 2021 at 08:04:07AM +0100, Christoph Hellwig wrote:
>> On Thu, Jun 24, 2021 at 04:24:46AM +0100, Matthew Wilcox wrote:
>>> On Thu, Jun 24, 2021 at 11:10:41AM +0800, Chen Huang wrote:
>>>> In userspace, I perform such operation:
>>>>
>>>> fd = open("/tmp/test", O_RDWR | O_SYNC);
>>>> access_address = (char *)mmap(NULL, uio_size, PROT_READ, MAP_SHARED, uio_fd, 0);
>>>> ret = write(fd, access_address + 2, sizeof(long));
>>>
>>> ... you know that accessing this at unaligned offsets isn't going to
>>> work. It's completely meaningless. Why are you trying to do it?
>>
>> We still should not cause an infinite loop in kernel space due to a
>> a userspace programmer error.
>
> They're running as root and they've mapped some device memory. We can't
> save them from themself. Imagine if they'd done this to the NVMe BAR.
FWIW I think the only way to make the kernel behaviour any more robust
here would be to make the whole uaccess API more expressive, such that
rather than simply saying "I only got this far" it could actually
differentiate between stopping due to a fault which may be recoverable
and worth retrying, and one which definitely isn't.
Unless maybe there's the possibility to abandon a syscall and SIGBUS the
process directly from the uaccess fixup path, but even to my limited
knowledge that seems unlikely.
(I'm not counting "cap the number of retries to a very large value to
guarantee *eventual* failure" as robust, but I suppose it's a potential
option too)
Robin.
Powered by blists - more mailing lists