Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1689924ybp; Wed, 9 Oct 2019 18:58:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCAK+x9HbMOGF7VXdpI+zUrwYit+7zuN4SwSjOhQ+mB56zBSkcfqP1/AjwVm40DgH2/1WS X-Received: by 2002:a17:906:c49:: with SMTP id t9mr5748988ejf.267.1570672736489; Wed, 09 Oct 2019 18:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570672736; cv=none; d=google.com; s=arc-20160816; b=ojpW5DuN0e4OYqBzLqc7RUVxN8cohyLITLeZIJvgnCCMfrd+aePgCJJS0QjGIrcOyX f4YKLRJAKAvG1Z4ZnCcxUZ23bnbE7vNhOQXYQZNilXAK6ExqH96s7TrVr3gVlFMw4DEC cjmPnKvrRM2qVEXgxcftf6vHRyaGPl0FwmMeDap9qiD26aioGrbSY97N20cFCEWocTFI CEO86LJaYi0L9SHN0pOihu+adhxbviNutN4ldjySZkFuzS3lUZFcxqKu6Pc0eXwYSu7T 8Pc85CWm8eKUG/Lz0BvYatJROzCTu9Z/Nw9SKKnukoGwn8fs9zh4+xDoHBXw3v8Bytuy Nlzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=mR9fkqi2igMVp0bF2Kt/87cwwY5FiCduUXxgQpwKv28=; b=Ejbc674Ee4zwGPjJFoOXssAFAPQXdNQ4sQ+kUYsMh8limW8i3/+wIfWZZb81ZbDRZ1 XehgIcpdg3fuHxfUiNEcvkNsTnaEMjMEVzPrFLtOkEwyI8AT4h1g2QpTnXJxL5tji8Uc W9v9vaxvN1Ny2AtBcop51gv6Djczcw9Kzh6LmXg5CV7OqVVdFUMJx42jRVo52v4NkFI2 s8jS44sBzNVbYs6qfmBpqdpWzA5G3/WtCAysNedn+jdFgES+DRGPQdvR2gOYmEKb1iBv so65Hn7gyaWgWnjvrASD4fn8jnTQcDRefr/leCBRm/kqN4i4fPPfgsTr5gxXy56ld3ly m3GA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y16si2315928ejc.34.2019.10.09.18.58.30; Wed, 09 Oct 2019 18:58:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732609AbfJJB6J (ORCPT + 99 others); Wed, 9 Oct 2019 21:58:09 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:56468 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731589AbfJJB4J (ORCPT ); Wed, 9 Oct 2019 21:56:09 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.2 #3 (Red Hat Linux)) id 1iINgU-0002UG-Tq; Thu, 10 Oct 2019 01:56:06 +0000 Date: Thu, 10 Oct 2019 02:56:06 +0100 From: Al Viro To: Max Filippov Cc: "open list:TENSILICA XTENSA PORT (xtensa)" , LKML Subject: Re: [PATCH] xtensa: fix {get,put}_user() for 64bit values Message-ID: <20191010015606.GD26530@ZenIV.linux.org.uk> References: <20191009192105.GC26530@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 09, 2019 at 06:38:12PM -0700, Max Filippov wrote: > There's also the following code in the callers of this macro, e.g. in > __get_user_nocheck: > > long __gu_err, __gu_val; \ > __get_user_size(__gu_val, (ptr), (size), __gu_err); \ > (x) = (__force __typeof__(*(ptr)))__gu_val; \ > > the last line is important for sizes 1..4, because it takes care of > sign extension of the value loaded by the assembly. > At the same time the first line doesn't make sense for the size 8 > as it will result in value truncation. Right you are... > + long __gu_err; \ > + __typeof__(*(ptr) + 0) __gu_val; \ What would __u64 __gu_val; end up with for smaller sizes? I don't have xtensa cross-toolchain at the moment, so I can't check it easily; what does =r constraint generate in such case? Another thing is, you want to zero it on failure, to avoid an uninitialized value ending up someplace interesting.... > @@ -198,7 +200,7 @@ do { > \ > case 1: __get_user_asm(x, ptr, retval, 1, "l8ui", __cb); break;\ > case 2: __get_user_asm(x, ptr, retval, 2, "l16ui", __cb); break;\ > case 4: __get_user_asm(x, ptr, retval, 4, "l32i", __cb); break;\ > - case 8: retval = __copy_from_user(&x, ptr, 8); break; \ > + case 8: retval = __copy_from_user(&x, ptr, 8) ? -EFAULT : 0; > break; \ > default: (x) = __get_user_bad(); \ > } \ > } while (0) > > Here __typeof__(*(ptr) + 0) makes enough room for all cases > in the __get_user_size and the "+0" part takes care of pointers > to const data.