Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2680800lqp; Mon, 25 Mar 2024 06:32:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUo5WodWdNeaYOPU+XET0qFlABBP+80UVqO0yDM+B5Bdeck0w8i7tulBu2HwuCarapbopu4q7GunsHFV7fjT1Kmhl5irBr3PCnw4AD61Q== X-Google-Smtp-Source: AGHT+IG59oi8lkInzDKwY+rs/MVjNggLvAVFbx/cuY7lRSys1LHKARWLNSJy0ieS21goVqZIblf6 X-Received: by 2002:a05:6a00:3d4e:b0:6ea:b228:912 with SMTP id lp14-20020a056a003d4e00b006eab2280912mr976300pfb.0.1711373535690; Mon, 25 Mar 2024 06:32:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711373535; cv=pass; d=google.com; s=arc-20160816; b=fiJTSgn99/s+L2LmWmyWxRJx/aAYk/4eznKJuje/NCghV86E4n6ir6qgGisfJxYENq cyyEm0jt5/H7yABrHiSadK9YLjZAmbQl60wxB7Z5exKOv8poCY+hLyLXd5XqbemT8Pcz rIkoVwcAEvPrgxcAcShdwg8T4wnUp49XS0tIHnwrs6lPBUixfscfU2bKfJCL2Nhfmq8a GY3HQ2HxFJnCxmHWngMx1OSk/9YnKM6KsXpe+f5FnZNWAsIO4qoAo74bGiptZcZPFQ2D AgFLZv8LlWr2DUb3ugzkf+0r/O655Epf2qVoo0z3+Rm2hlgs/DcE0mcjOVDsawW/GSeO 9Lkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=Q5lx1y/F22BS5LKHlDaP5KMno5R/7XUi8HuYB0JpYzw=; fh=PwSpL6OeRTZcEvskl89tB3NaLnT2/AypE8ydHIK3NcM=; b=ztn1PR+p3sPrq1DseY1wWBZMOLAWxcSvalIRaZr2QjwCfnCTSlh1cUI9HqCsuW6vyN 5ze1B//4td2HgtGoMjp0isxLUfILY9fWk8s/M9GYt3M8WOo/OnKqR2/FgcQSCqkmSnaZ XNCH5S1zMz7Yc3KwY+7ql6JH+Qte9zSPsErSDKu6sUbCfjjROhT7kSrlDdaRQttWDc5W JkooYZyMuOLazIMRsRTgLnx6aktA1ENPnARSHm3+MriTK3GVwRTljNnJ+9IwL9yxhabv 8jPhJeZliVZsaJtYGtwKEYQmrxvhy8tW2MModzVQ8qttw5212s7k41VlGdjDUNogVqik J0wA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=ghiti.fr); spf=pass (google.com: domain of linux-kernel+bounces-116657-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116657-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q22-20020a638c56000000b005dc41faf522si7586254pgn.790.2024.03.25.06.32.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 06:32:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116657-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=ghiti.fr); spf=pass (google.com: domain of linux-kernel+bounces-116657-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116657-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 43F1B2C5747 for ; Mon, 25 Mar 2024 13:32:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8198F12BEAE; Mon, 25 Mar 2024 10:21:15 +0000 (UTC) Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F44012C7F6; Mon, 25 Mar 2024 07:42:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711352542; cv=none; b=IgSWFp9LQY5JSlHKImbNnDoMe+tWR+Wavbj5OEsvtzMJYUU54VkKxDNwJ9l5RwpZwbhAxgEw0hDkjb+uCfMhb2VQZ4GRJp+vX2vtobxbVf1TZbmwmhLUjLJrA9tPCx5J8iqPwJdcnpJFNV84dnjkyG22BDbG0EiYOrrAQOTeX6c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711352542; c=relaxed/simple; bh=vdFoUSbKw87TFfNziH/t3xIKevtSzdAVn2OVLXmGMNg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=gFMjppBbjAVK5Srr2vcvH7lmUZgPyfkKTNFhWI6AJLYB6MY0XGf3ll0uECvjKagL1fuubXkTQdQWtuRpikseHfpcaCDPw/RCkOaLPdKZLnkejZk8/9T1xcSohvUle6WcyUR3OXHXOLZ5IsE8VuDnlvExjNvrIBJ0DJg2rAXy+Eo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr; spf=pass smtp.mailfrom=ghiti.fr; arc=none smtp.client-ip=217.70.183.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ghiti.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ghiti.fr Received: by mail.gandi.net (Postfix) with ESMTPSA id 5E80040002; Mon, 25 Mar 2024 07:42:17 +0000 (UTC) Message-ID: Date: Mon, 25 Mar 2024 08:42:16 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] riscv: Fix spurious errors from __get/put_kernel_nofault Content-Language: en-US To: Samuel Holland , Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20240312022030.320789-1-samuel.holland@sifive.com> From: Alexandre Ghiti In-Reply-To: <20240312022030.320789-1-samuel.holland@sifive.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-GND-Sasl: alex@ghiti.fr Hi Samuel, On 12/03/2024 03:19, Samuel Holland wrote: > These macros did not initialize __kr_err, so they could fail even if > the access did not fault. > > Cc: stable@vger.kernel.org > Fixes: d464118cdc41 ("riscv: implement __get_kernel_nofault and __put_user_nofault") > Signed-off-by: Samuel Holland > --- > Found while testing the unaligned access speed series[1]. The observed > behavior was that with RISCV_EFFICIENT_UNALIGNED_ACCESS=y, the > copy_from_kernel_nofault() in prepend_copy() failed every time when > filling out /proc/self/mounts, so all of the mount points were "xxx". > > I'm surprised this hasn't been seen before. For reference, I'm compiling > with clang 18. > > [1]: https://lore.kernel.org/linux-riscv/20240308-disable_misaligned_probe_config-v9-0-a388770ba0ce@rivosinc.com/ > > 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 ec0cab9fbddd..72ec1d9bd3f3 100644 > --- a/arch/riscv/include/asm/uaccess.h > +++ b/arch/riscv/include/asm/uaccess.h > @@ -319,7 +319,7 @@ unsigned long __must_check clear_user(void __user *to, unsigned long n) > > #define __get_kernel_nofault(dst, src, type, err_label) \ > do { \ > - long __kr_err; \ > + long __kr_err = 0; \ > \ > __get_user_nocheck(*((type *)(dst)), (type *)(src), __kr_err); \ > if (unlikely(__kr_err)) \ > @@ -328,7 +328,7 @@ do { \ > > #define __put_kernel_nofault(dst, src, type, err_label) \ > do { \ > - long __kr_err; \ > + long __kr_err = 0; \ > \ > __put_user_nocheck(*((type *)(src)), (type *)(dst), __kr_err); \ > if (unlikely(__kr_err)) \ That's a good a catch! Surprising indeed that we did not find this before, that's the second bug in the uaccess routines in the last 3 (or 4) releases, maybe we should improve our coverage here, I'll see what we can do. You can add: Reviewed-by: Alexandre Ghiti Thanks, Alex