Return-Path: Received: from mail-ot0-f193.google.com ([74.125.82.193]:33795 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751818AbdBMVky (ORCPT ); Mon, 13 Feb 2017 16:40:54 -0500 MIME-Version: 1.0 In-Reply-To: <20170213095616.GA18053@linaro.org> References: <20170124212327.14517-1-jlayton@redhat.com> <20170125133205.21704-1-jlayton@redhat.com> <20170202095125.GF27291@ZenIV.linux.org.uk> <20170202105651.GA32111@infradead.org> <20170202111625.GG27291@ZenIV.linux.org.uk> <1486040452.2812.6.camel@redhat.com> <20170203072952.GI27291@ZenIV.linux.org.uk> <20170203190816.GK27291@ZenIV.linux.org.uk> <20170213095616.GA18053@linaro.org> From: Linus Torvalds Date: Mon, 13 Feb 2017 13:40:52 -0800 Message-ID: Subject: Re: [PATCH v3 0/2] iov_iter: allow iov_iter_get_pages_alloc to allocate more pages per call To: Steve Capper Cc: Al Viro , Catalin Marinas , Hugh Dickins , Peter Zijlstra , Ingo Molnar , Jeff Layton , Christoph Hellwig , linux-fsdevel , Linux Kernel Mailing List , Linux NFS Mailing List , ceph-devel , lustre-devel@lists.lustre.org, V9FS Developers , Jan Kara , Chris Wilson , "Kirill A. Shutemov" Content-Type: text/plain; charset=UTF-8 Sender: linux-nfs-owner@vger.kernel.org List-ID: On Mon, Feb 13, 2017 at 1:56 AM, Steve Capper wrote: > > Okay so looking at what we have for access_ok(.) on arm64, my > understanding is that we perform a 65-bit add/compare (in assembler) to > see whether or not the range is below the current_thread_info->addr_limit. > So I think this is a roundabout way of checking for no-wrap around and <= TASK_SIZE. No, that's the problem. It's *not* testing against TASK_SIZE. Because add_limit is not always TASK_SIZE. When you do set_fs(KERNEL_DS), you set addr_limit to infinity. And yes, the kernel does read and write calls too. Seldom, but it happens. And walking the page tables with kernel addresses is not supposed to work (sometimes it happens to work by mistake). So if somebody finds a path that gets from that kind of situation into the get_user_pages() interface, bad things happen. Linus