From mboxrd@z Thu Jan 1 00:00:00 1970 From: Balbir Singh Subject: Re: [PATCH v2 02/11] mm: Hardened usercopy Date: Fri, 15 Jul 2016 11:41:51 +1000 Message-ID: <20160715014151.GA13944@balbir.ozlabs.ibm.com> References: <1468446964-22213-1-git-send-email-keescook@chromium.org> <1468446964-22213-3-git-send-email-keescook@chromium.org> <20160714232019.GA28254@350D> <1468544658.30053.26.camel@redhat.com> Reply-To: bsingharora@gmail.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline In-Reply-To: <1468544658.30053.26.camel@redhat.com> Sender: owner-linux-mm@kvack.org To: Rik van Riel Cc: bsingharora@gmail.com, Kees Cook , linux-kernel@vger.kernel.org, Casey Schaufler , PaX Team , Brad Spengler , Russell King , Catalin Marinas , Will Deacon , Ard Biesheuvel , Benjamin Herrenschmidt , Michael Ellerman , Tony Luck , Fenghua Yu , "David S. Miller" , x86@kernel.org, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Andy Lutomirski , Borislav Petkov , Mathias Krause , Jan List-Id: linux-arch.vger.kernel.org On Thu, Jul 14, 2016 at 09:04:18PM -0400, Rik van Riel wrote: > On Fri, 2016-07-15 at 09:20 +1000, Balbir Singh wrote: >=20 > > > =3D=3D > > > + =A0=A0=A0((unsigned long)end & (unsigned > > > long)PAGE_MASK))) > > > + return NULL; > > > + > > > + /* Allow if start and end are inside the same compound > > > page. */ > > > + endpage =3D virt_to_head_page(end); > > > + if (likely(endpage =3D=3D page)) > > > + return NULL; > > > + > > > + /* Allow special areas, device memory, and sometimes > > > kernel data. */ > > > + if (PageReserved(page) && PageReserved(endpage)) > > > + return NULL; > >=20 > > If we came here, it's likely that endpage > page, do we need to check > > that only the first and last pages are reserved? What about the ones > > in > > the middle? >=20 > I think this will be so rare, we can get away with just > checking the beginning and the end. > But do we want to leave a hole where an aware user space can try a longer copy_* to avoid this check? If it is unlikely should we just bite the bullet and do the check for the entire range? Balbir Singh.=20 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f193.google.com ([209.85.192.193]:35442 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751279AbcGOBmN (ORCPT ); Thu, 14 Jul 2016 21:42:13 -0400 Date: Fri, 15 Jul 2016 11:41:51 +1000 From: Balbir Singh Subject: Re: [PATCH v2 02/11] mm: Hardened usercopy Message-ID: <20160715014151.GA13944@balbir.ozlabs.ibm.com> Reply-To: bsingharora@gmail.com References: <1468446964-22213-1-git-send-email-keescook@chromium.org> <1468446964-22213-3-git-send-email-keescook@chromium.org> <20160714232019.GA28254@350D> <1468544658.30053.26.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1468544658.30053.26.camel@redhat.com> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Rik van Riel Cc: bsingharora@gmail.com, Kees Cook , linux-kernel@vger.kernel.org, Casey Schaufler , PaX Team , Brad Spengler , Russell King , Catalin Marinas , Will Deacon , Ard Biesheuvel , Benjamin Herrenschmidt , Michael Ellerman , Tony Luck , Fenghua Yu , "David S. Miller" , x86@kernel.org, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Andy Lutomirski , Borislav Petkov , Mathias Krause , Jan Kara , Vitaly Wool , Andrea Arcangeli , Dmitry Vyukov , Laura Abbott , linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, kernel-hardening@lists.openwall.com Message-ID: <20160715014151.Adgzuw-8b8amM40CIQ6wiOR-67bq0ILXhTplCrEaT4U@z> On Thu, Jul 14, 2016 at 09:04:18PM -0400, Rik van Riel wrote: > On Fri, 2016-07-15 at 09:20 +1000, Balbir Singh wrote: > > > > == > > > +    ((unsigned long)end & (unsigned > > > long)PAGE_MASK))) > > > + return NULL; > > > + > > > + /* Allow if start and end are inside the same compound > > > page. */ > > > + endpage = virt_to_head_page(end); > > > + if (likely(endpage == page)) > > > + return NULL; > > > + > > > + /* Allow special areas, device memory, and sometimes > > > kernel data. */ > > > + if (PageReserved(page) && PageReserved(endpage)) > > > + return NULL; > > > > If we came here, it's likely that endpage > page, do we need to check > > that only the first and last pages are reserved? What about the ones > > in > > the middle? > > I think this will be so rare, we can get away with just > checking the beginning and the end. > But do we want to leave a hole where an aware user space can try a longer copy_* to avoid this check? If it is unlikely should we just bite the bullet and do the check for the entire range? Balbir Singh.