Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8493762imu; Thu, 15 Nov 2018 12:29:44 -0800 (PST) X-Google-Smtp-Source: AJdET5dImce0xlkHYpkzpZ1piTqvb9XN9eSgsMUzKv6lvNGlsRi8TS8f5TdyWaqpnrKunwoqtKlk X-Received: by 2002:a17:902:7e44:: with SMTP id a4mr7776873pln.338.1542313784736; Thu, 15 Nov 2018 12:29:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542313784; cv=none; d=google.com; s=arc-20160816; b=bt9mNvmrGTI7nLUBctosCx25Q3zkjFhi3WjjprhaWlMnzDoDnMCxdHkBflBsnSehOO LEfEQPgtlY6ZbepgiSzYPjSnogr9m89hJdxLR4C4fH+mZys4LZ+ypvd6lNcJZssyfmc3 sRZQs0eB51fL2guMZgsy4dDMIqTUTJpXDPXwc0rV6yANIBuQwsawocdggCkbkXHMmfCs 1LzCe1rqAt+zs3Ezi19CsDqiWl+yha7ZRLwlleFAXDQhV6W2wfNbLgBri+l0nUcOScEJ S1hh+f+X4raz0LNgLo03R9QT0WuqscXgJvk/pSCYQa44q5pLcDYBcjNdvSni6rTsfgRt mtBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=cafcOmuLYw/QUgVJslWZRnzNm+HBqhgujYm2tJCmbX4=; b=GI9IP6psMB9wiOSNM2JaBB6tCW4xLPxCbC4SqDWRCRTPqFf2JaTjS8h3KB21cycyFZ TDurS2oos+8MODXao2Ge1INWIqkaTNApQUybc8Ulcz6djtgw/uE+KRedv82ztsBKyLmL NbZNvP7SokKuIl1f7BzcU112f/lw0mCp7yt1X4I10m+/Z1u79xvYQ2OSc0tubfgaJg8O E6kjEruS6cuzhabsTg8AU+HLlFtW1AjK1yH90IEBtyJYE7Q3Tlv76umCNbSPMh7U4SDT tuXiZXpqbEHSqVZNBeLGUtKmaAbiT6rNLYqgS+j4P2qCFxNbMa4x29ac2NT/zkjCBZw/ 31aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lixom-net.20150623.gappssmtp.com header.s=20150623 header.b=XEthsVL8; 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 p9si25068440pgc.448.2018.11.15.12.29.29; Thu, 15 Nov 2018 12:29:44 -0800 (PST) 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; dkim=pass header.i=@lixom-net.20150623.gappssmtp.com header.s=20150623 header.b=XEthsVL8; 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 S1729586AbeKPGhN (ORCPT + 99 others); Fri, 16 Nov 2018 01:37:13 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:38065 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725869AbeKPGhN (ORCPT ); Fri, 16 Nov 2018 01:37:13 -0500 Received: by mail-it1-f195.google.com with SMTP id k141-v6so31217243itk.3 for ; Thu, 15 Nov 2018 12:27:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lixom-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cafcOmuLYw/QUgVJslWZRnzNm+HBqhgujYm2tJCmbX4=; b=XEthsVL8wm6O5L+a6JpBLmCNep8SfInq6yj1zz3eh1XbRQ43NWG56YH96KXtp0TPCN 4BR6EYlCGzDWrnHoMfUD/7nryFIZWiFI7PKm5P33WH12TyB7E0/OegXjGjyZD96sFU/8 J1rpAA2KlyJbCtAodl4CeG7Q+lH/IjzYWhU72+EUZRX3onToBlu/uVSwTxg0y0YAcxG1 aQFrTuyuurxFIK5iZPmN4fPAp7rh2CmONXpUh5Yx44EKTGGYVwpdksm5U9PpP+eoDRpL eFSwkE3NcDGoH2F5leI8jywPKmVgdbfbfDfyBTY6GwfPDq9VpRLLXZXMk+0EW+tOKlSN 5Ong== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cafcOmuLYw/QUgVJslWZRnzNm+HBqhgujYm2tJCmbX4=; b=HbSsOLTkd55wBBbLahBzBizEvEqXciUqpG1f1F6jzSgAtO9FA7o3sh3pd9cQ1DmKGh UvuVJQ01zKUbzLXxROSwVCI9Mwn/fWySZpu+iWRawEF9k6Ot0QhrKFiFO+E+cIhhUvLT /DXgOWOA2Snun5D5Bn+gOqkp5gVXixrXwJNmffTtbMKlGUqsM2AbSvGAVnR2vI7c9WQz qLsO9B0Tek67USKM+4VJzVl4Ou5Wvr6BJJYjOU69oFaiAOQeoDE6RU8gktXHrzl1+WDo yqR5zQLivhp3aXHnogyLaBptwjLFbKvPk/qZtSJifxA1Agex9KlL5viHVkXNpjJP9+vH /kJg== X-Gm-Message-State: AGRZ1gKlKqEA8RVId7ef3rAOWA0bB7GZcsVP2xgdQGlZVM5qd827pHz8 HNZsaWA78Mct2tD6G+cFrx3x1rG1ok0zM03wA3noEw== X-Received: by 2002:a02:88cf:: with SMTP id b15mr7008396jak.10.1542313673351; Thu, 15 Nov 2018 12:27:53 -0800 (PST) MIME-Version: 1.0 References: <20181115002755.24195-1-olof@lixom.net> In-Reply-To: From: Olof Johansson Date: Thu, 15 Nov 2018 12:27:42 -0800 Message-ID: Subject: Re: [PATCH] RISC-V: Fix raw_copy_{to,from}_user() To: Palmer Dabbelt Cc: Albert Ou , linux-riscv@lists.infradead.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 15, 2018 at 6:59 AM Palmer Dabbelt wrote: > > On Wed, 14 Nov 2018 16:27:55 PST (-0800), Olof Johansson wrote: > > Sparse highlighted it, and appears to be a pure bug (from vs to). > > > > ./arch/riscv/include/asm/uaccess.h:403:35: warning: incorrect type in argument 1 (different address spaces) > > ./arch/riscv/include/asm/uaccess.h:403:39: warning: incorrect type in argument 2 (different address spaces) > > ./arch/riscv/include/asm/uaccess.h:409:37: warning: incorrect type in argument 1 (different address spaces) > > ./arch/riscv/include/asm/uaccess.h:409:41: warning: incorrect type in argument 2 (different address spaces) > > > > Signed-off-by: Olof Johansson > > --- > > arch/riscv/include/asm/uaccess.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h > > index 473cfc84e412f..8c3e3e3c8be12 100644 > > --- a/arch/riscv/include/asm/uaccess.h > > +++ b/arch/riscv/include/asm/uaccess.h > > @@ -400,13 +400,13 @@ extern unsigned long __must_check __asm_copy_from_user(void *to, > > static inline unsigned long > > raw_copy_from_user(void *to, const void __user *from, unsigned long n) > > { > > - return __asm_copy_to_user(to, from, n); > > + return __asm_copy_from_user(to, from, n); > > } > > > > static inline unsigned long > > raw_copy_to_user(void __user *to, const void *from, unsigned long n) > > { > > - return __asm_copy_from_user(to, from, n); > > + return __asm_copy_to_user(to, from, n); > > } > > > > extern long strncpy_from_user(char *dest, const char __user *src, long count); > > Oh, no idea how I missed that one. This looks like it's been in for a long > time, so I'm surprised anything works at all! Actually, it boils down to a memcpy either way, it's just that exceptions and access control isn't handled right. So as long as you always do valid copying you'll luck out. > I'm going to add a stable CC and PR this to Linus this week, assuming I get > some time to at least give it a minimal test. > > Thanks for catching this! Cool, sounds good. -Olof