From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yury Norov Subject: Re: [RFC6 PATCH v6 00/21] ILP32 for ARM64 Date: Thu, 12 May 2016 13:30:24 +0300 Message-ID: <20160512103024.GA7639@yury-N73SV> References: <1459894127-17698-1-git-send-email-ynorov@caviumnetworks.com> <20160512002000.GA30997@yury-N73SV> <4326765.8HKKkI07Zs@wuerfel> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <4326765.8HKKkI07Zs@wuerfel> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: Arnd Bergmann Cc: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, pinskia@gmail.com, Prasun.Kapoor@caviumnetworks.com, catalin.marinas@arm.com, linux-doc@vger.kernel.org, heiko.carstens@de.ibm.com, linux-kernel@vger.kernel.org, agraf@suse.de, klimov.linux@gmail.com, broonie@kernel.org, bamvor.zhangjian@huawei.com, joseph@codesourcery.com, schwab@suse.de, schwidefsky@de.ibm.com, Nathan_Lynch@mentor.com, linux-arm-kernel@lists.infradead.org, christoph.muellner@theobroma-systems.com List-Id: linux-arch.vger.kernel.org On Thu, May 12, 2016 at 11:19:21AM +0200, Arnd Bergmann wrote: > On Thursday 12 May 2016 03:20:00 Yury Norov wrote: > > > > I debugged preadv02 and pwritev02 failures and found very weird bug. > > Test passes {iovec_base = 0xffffffff, iovec_len = 64} as one element > > of vector, and kernel reports successful read/write. > > > > There are 2 problems: > > 1. How kernel allows such address to be passed to fs subsystem; > > 2. How fs successes to read/write at non-mapped, and in fact non-user > > address. > > > > I don't know the answer on 2'nd question, and it might be something > > generic. But I investigated first problem. > > > > The problem is that compat_rw_copy_check_uvector() uses access_ok() to > > validate user address, and on arm64 it ends up with checking buffer > > end against current_thread_info()->addr_limit. > > > > current_thread_info()->addr_limit for ilp32, and most probably for > > aarch32 is equal to aarch64 one, and so adress_ok() doesn't fail. > > It happens because on thread creation we call flush_old_exec() to set > > addr_limit, and completely ignore compat mode there. > > > > This patch fixes it. It also fixes USER_DS macro to return different > > values depending on compat. > > > > This patch is enough to handle preadv02 and pwritev02, but problem #2 > > is still there. > > > > Signed-off-by: Yury Norov > > > > Good catch! > > Can you do a version of this patch that works on the current > mainline kernel and can be backported to fix aarch32 emulation? > > For ilp32 mode, I think we can better fix arch/arm64/kernel/binfmt_ilp32.c > as it is introduced. > > Arnd > OK, will do > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-bn1on0054.outbound.protection.outlook.com ([157.56.110.54]:45056 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751395AbcELKpo (ORCPT ); Thu, 12 May 2016 06:45:44 -0400 Date: Thu, 12 May 2016 13:30:24 +0300 From: Yury Norov Subject: Re: [RFC6 PATCH v6 00/21] ILP32 for ARM64 Message-ID: <20160512103024.GA7639@yury-N73SV> References: <1459894127-17698-1-git-send-email-ynorov@caviumnetworks.com> <20160512002000.GA30997@yury-N73SV> <4326765.8HKKkI07Zs@wuerfel> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <4326765.8HKKkI07Zs@wuerfel> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Arnd Bergmann Cc: linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, pinskia@gmail.com, Prasun.Kapoor@caviumnetworks.com, catalin.marinas@arm.com, broonie@kernel.org, linux-doc@vger.kernel.org, heiko.carstens@de.ibm.com, linux-kernel@vger.kernel.org, agraf@suse.de, klimov.linux@gmail.com, bamvor.zhangjian@huawei.com, schwab@suse.de, schwidefsky@de.ibm.com, Nathan_Lynch@mentor.com, joseph@codesourcery.com, christoph.muellner@theobroma-systems.com Message-ID: <20160512103024.7HwidlJWjbzqziNVp3FaG4bukqVr8RAtPtSKlkUUNms@z> On Thu, May 12, 2016 at 11:19:21AM +0200, Arnd Bergmann wrote: > On Thursday 12 May 2016 03:20:00 Yury Norov wrote: > > > > I debugged preadv02 and pwritev02 failures and found very weird bug. > > Test passes {iovec_base = 0xffffffff, iovec_len = 64} as one element > > of vector, and kernel reports successful read/write. > > > > There are 2 problems: > > 1. How kernel allows such address to be passed to fs subsystem; > > 2. How fs successes to read/write at non-mapped, and in fact non-user > > address. > > > > I don't know the answer on 2'nd question, and it might be something > > generic. But I investigated first problem. > > > > The problem is that compat_rw_copy_check_uvector() uses access_ok() to > > validate user address, and on arm64 it ends up with checking buffer > > end against current_thread_info()->addr_limit. > > > > current_thread_info()->addr_limit for ilp32, and most probably for > > aarch32 is equal to aarch64 one, and so adress_ok() doesn't fail. > > It happens because on thread creation we call flush_old_exec() to set > > addr_limit, and completely ignore compat mode there. > > > > This patch fixes it. It also fixes USER_DS macro to return different > > values depending on compat. > > > > This patch is enough to handle preadv02 and pwritev02, but problem #2 > > is still there. > > > > Signed-off-by: Yury Norov > > > > Good catch! > > Can you do a version of this patch that works on the current > mainline kernel and can be backported to fix aarch32 emulation? > > For ilp32 mode, I think we can better fix arch/arm64/kernel/binfmt_ilp32.c > as it is introduced. > > Arnd > OK, will do > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel