From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42932C5DF9D for ; Fri, 23 Oct 2020 17:59:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C1CB622201 for ; Fri, 23 Oct 2020 17:59:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C1CB622201 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C8DFA6B0068; Fri, 23 Oct 2020 13:59:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C16896B005D; Fri, 23 Oct 2020 13:59:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A6C416B006E; Fri, 23 Oct 2020 13:59:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0066.hostedemail.com [216.40.44.66]) by kanga.kvack.org (Postfix) with ESMTP id 6EB356B005D for ; Fri, 23 Oct 2020 13:59:21 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1B1CA1EF2 for ; Fri, 23 Oct 2020 17:59:21 +0000 (UTC) X-FDA: 77403952122.21.pest71_62001202725b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id E5653180442C0; Fri, 23 Oct 2020 17:59:20 +0000 (UTC) X-HE-Tag: pest71_62001202725b X-Filterd-Recvd-Size: 4092 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [195.92.253.2]) by imf32.hostedemail.com (Postfix) with ESMTP; Fri, 23 Oct 2020 17:59:20 +0000 (UTC) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kW1L7-00749v-U5; Fri, 23 Oct 2020 17:58:58 +0000 Date: Fri, 23 Oct 2020 18:58:57 +0100 From: Al Viro To: David Hildenbrand Cc: David Laight , 'Greg KH' , Nick Desaulniers , Christoph Hellwig , "kernel-team@android.com" , Andrew Morton , Jens Axboe , Arnd Bergmann , David Howells , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , "linux-mips@vger.kernel.org" , "linux-parisc@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-s390@vger.kernel.org" , "sparclinux@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-aio@kvack.org" , "io-uring@vger.kernel.org" , "linux-arch@vger.kernel.org" , "linux-mm@kvack.org" , "netdev@vger.kernel.org" , "keyrings@vger.kernel.org" , "linux-security-module@vger.kernel.org" Subject: Re: Buggy commit tracked to: "Re: [PATCH 2/9] iov_iter: move rw_copy_check_uvector() into lib/iov_iter.c" Message-ID: <20201023175857.GA3576660@ZenIV.linux.org.uk> References: <5fd6003b-55a6-2c3c-9a28-8fd3a575ca78@redhat.com> <20201022104805.GA1503673@kroah.com> <20201022121849.GA1664412@kroah.com> <98d9df88-b7ef-fdfb-7d90-2fa7a9d7bab5@redhat.com> <20201022125759.GA1685526@kroah.com> <20201022135036.GA1787470@kroah.com> <134f162d711d466ebbd88906fae35b33@AcuMS.aculab.com> <935f7168-c2f5-dd14-7124-412b284693a2@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <935f7168-c2f5-dd14-7124-412b284693a2@redhat.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Oct 23, 2020 at 03:09:30PM +0200, David Hildenbrand wrote: > Now, I am not a compiler expert, but as I already cited, at least on > x86-64 clang expects that the high bits were cleared by the caller - in > contrast to gcc. I suspect it's the same on arm64, but again, I am no > compiler expert. > > If what I said and cites for x86-64 is correct, if the function expects > an "unsigned int", it will happily use 64bit operations without further > checks where valid when assuming high bits are zero. That's why even > converting everything to "unsigned int" as proposed by me won't work on > clang - it assumes high bits are zero (as indicated by Nick). > > As I am neither a compiler experts (did I mention that already? ;) ) nor > an arm64 experts, I can't tell if this is a compiler BUG or not. On arm64 when callee expects a 32bit argument, the caller is *not* responsible for clearing the upper half of 64bit register used to pass the value - it only needs to store the actual value into the lower half. The callee must consider the contents of the upper half of that register as undefined. See AAPCS64 (e.g. https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#parameter-passing-rules ); AFAICS, the relevant bit is "Unlike in the 32-bit AAPCS, named integral values must be narrowed by the callee rather than the caller."