From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7007 Path: news.gmane.org!not-for-mail From: Catalin Marinas Newsgroups: gmane.linux.kernel,gmane.linux.lib.musl.general,gmane.linux.ports.arm.kernel,gmane.comp.lib.glibc.alpha Subject: Re: [musl] Re: [PATCHv3 00/24] ILP32 support in ARM64 Date: Thu, 12 Feb 2015 17:07:15 +0000 Message-ID: <20150212170715.GB25491@e104818-lin.cambridge.arm.com> References: <20141002155217.GH32147@e104818-lin.cambridge.arm.com> <20150210181302.GA23886@brightrain.aerifal.cx> <20150211173919.GF9058@e104818-lin.cambridge.arm.com> <20150211190537.GK32724@port70.net> <20150212081234.GL32724@port70.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1423760861 6535 80.91.229.3 (12 Feb 2015 17:07:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 12 Feb 2015 17:07:41 +0000 (UTC) Cc: musl@lists.openwall.com, Rich Felker , Andrew Pinski , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "pinskia@gmail.com" , "libc-alpha@sourceware.org" , Marcus Shawcroft To: Szabolcs Nagy Original-X-From: linux-kernel-owner@vger.kernel.org Thu Feb 12 18:07:36 2015 Return-path: Envelope-to: glk-linux-kernel-3@plane.gmane.org Original-Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YLxEi-0000uS-NS for glk-linux-kernel-3@plane.gmane.org; Thu, 12 Feb 2015 18:07:33 +0100 Original-Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751279AbbBLRH1 (ORCPT ); Thu, 12 Feb 2015 12:07:27 -0500 Original-Received: from foss-mx-na.arm.com ([217.140.108.86]:43452 "EHLO foss-mx-na.foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751043AbbBLRH0 (ORCPT ); Thu, 12 Feb 2015 12:07:26 -0500 Original-Received: from foss-smtp-na-1.foss.arm.com (unknown [10.80.61.8]) by foss-mx-na.foss.arm.com (Postfix) with ESMTP id 6DA3C4E4; Thu, 12 Feb 2015 11:07:22 -0600 (CST) Original-Received: from collaborate-mta1.arm.com (highbank-bc01-b06.austin.arm.com [10.112.81.134]) by foss-smtp-na-1.foss.arm.com (Postfix) with ESMTP id E5A955FAC1; Thu, 12 Feb 2015 11:07:19 -0600 (CST) Original-Received: from e104818-lin.cambridge.arm.com (e104818-lin.cambridge.arm.com [10.1.203.148]) by collaborate-mta1.arm.com (Postfix) with ESMTPS id 488E313F638; Thu, 12 Feb 2015 11:07:18 -0600 (CST) Content-Disposition: inline In-Reply-To: <20150212081234.GL32724@port70.net> User-Agent: Mutt/1.5.23 (2014-03-12) Original-Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Xref: news.gmane.org gmane.linux.kernel:1887436 gmane.linux.lib.musl.general:7007 gmane.linux.ports.arm.kernel:393111 gmane.comp.lib.glibc.alpha:49223 Archived-At: On Thu, Feb 12, 2015 at 09:12:34AM +0100, Szabolcs Nagy wrote: > * Szabolcs Nagy [2015-02-11 20:05:37 +0100]: > > (i think this is also a problem if userspace code uses syscall(2) directly, > > libc cannot possibly know where to signextend and the kernel side does not > > do the fixup right now) > > nobody picked up this issue, is this resolved? > > ie. if userspace calls syscall(SYS_foo,...) directly with 32bit > longs does it always work out correctly on the kernel side? I think the only way to solve this is to have syscall wrappers in the kernel rather than glibc. > the sign extension is a problem for signed long arguments, > i only found these in the kernel: > > fs/buffer.c:SYSCALL_DEFINE2(bdflush, int, func, long, data) This is part of the deprecated syscalls, it is not used on new user ABIs. > fs/open.c:SYSCALL_DEFINE2(truncate, const char __user *, path, long, length) The kernel uses a long (64-bit) here and the user ABI defines this as an off_t. With x32, this should be a long long (__kernel_long_t), so not a problem. > fs/aio.c:SYSCALL_DEFINE3(io_submit, aio_context_t, ctx_id, long, nr, > fs/aio.c- struct iocb __user * __user *, iocbpp) > > fs/aio.c:SYSCALL_DEFINE5(io_getevents, aio_context_t, ctx_id, > fs/aio.c- long, min_nr, > fs/aio.c- long, nr, These would need some int->long conversion for nr, min_nr (it may be done in x32 glibc already but as you said it would not work via syscall() directly). > kernel/ptrace.c:SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr, > kernel/ptrace.c- unsigned long, data) The pid in user space would be pid_t which is 32-bit. The kernel seems to use it as pid_t afterwards, so looks safe. For addr and data, I guess it needs wrappers to zero the top part. > ipc/syscall.c:SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second, > ipc/syscall.c- unsigned long, third, void __user *, ptr, long, fifth) ipc(2) shows the first, second, third as ints. I guess some kernel wrapper is needed here as well. -- Catalin