Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp796319lql; Mon, 11 Mar 2024 19:20:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+YlgvIv3+xVgiz4NFZ1QrtadtYlzbwfhQvaWsP06DzMxl4VWQ2YCy6xFgCp+f+VplGHPgVdrKkhQkz9oK8uo4gTVLKSo285EIdbQhXg== X-Google-Smtp-Source: AGHT+IEIo7QDzDorHaaTMTmyMpIM9dHSJh17J3RlPvAkkZopUYCv1e0lhw0W9M/ZYAcVuLLBOFrS X-Received: by 2002:ac8:5bd5:0:b0:42f:208a:9ab7 with SMTP id b21-20020ac85bd5000000b0042f208a9ab7mr804908qtb.16.1710210040939; Mon, 11 Mar 2024 19:20:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710210040; cv=pass; d=google.com; s=arc-20160816; b=q6/5xF1/8QuxQKEPo3ulbbOL78hmh99ScSctaunCMsP+MvX2mZQOBlUoG7zIvrahiN Cmab14xPpkf3SDMFqUbNZ6FuCDrnAMGw2699YMn8l7G1iqKU6OirEfrdw5IRn7vDsqHJ tdrQjrEzsZQ5vrUB7CXVXws6eSCA650j5qUHQouWK2fPqco9oVMUxiEl+U1UifKRf5fD ZNS5nUlVH5OVebL5IWRG6+lc6Xgaiw0F7ffJbwyuyavj5QREvwl2l18DGClu1pHlNvAm bN+egbyTUQ/EdRTowpbIf/Ndpz1FQ9S647+fh87xAoixCDhtLi3bJIyRPqBdO5qUTyBF ct6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=MRqA0g05W48N7EVchL2+ZCRtUYEZmKtpe/WU4nz0oWY=; fh=8nODF4iwT2hpsC5hOMn7hW6wHEhlLe6jOjR1G5JYm3o=; b=YbEsJ6il8CgCZh0Uk/bABJM3Ts5DrUJg/f3nQDsjXaeJVNGRDwM5sb94JnfXMzYPnq 3KiYn2KiMC6OXPKBECiq8Aig+YFmv+8h3T8FB1tTYAe1gZSguBbG4HVQpVpSNxi4X4jU i7L8/wqZl9qKjlZCSORizZCp9a4NMpeoWVvfNYwayjF4Cw6S7gkoGsUyOWJ0NLqh17OP GAT9t3nUgl1XPQPhjEbEExvxLqcPvpcCcVA/UdnGrLkOJoJIK+7iEt4W49qDOpo1U77e Tt/3HyIhBrwlS7NKyjJurRUx7jaRZWJ3+XycKrKQS47Z7tsljknqBUtUU2RYKegUtY3f YQdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=bJEXJ4r6; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-99763-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99763-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 10-20020ac8570a000000b0042f515210besi1515280qtw.414.2024.03.11.19.20.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 19:20:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-99763-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=bJEXJ4r6; arc=pass (i=1 spf=pass spfdomain=sifive.com dkim=pass dkdomain=sifive.com dmarc=pass fromdomain=sifive.com); spf=pass (google.com: domain of linux-kernel+bounces-99763-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-99763-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=sifive.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A7F151C210E7 for ; Tue, 12 Mar 2024 02:20:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A46B76FC5; Tue, 12 Mar 2024 02:20:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="bJEXJ4r6" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6526F6FB6 for ; Tue, 12 Mar 2024 02:20:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710210033; cv=none; b=ZIZkM68xocalrq9SLIumnu0R5uZn5s11UZFWmfeMS8r7P+7BfMvtWB9xFZ3MKAIvs+hxXZEZ+qUkzYLbutoax6c9+Zh7gTF7cmZj6szDQJJ4S62xV5dMvTwY3+sHur+hWf4o0H/NxTsHiKcYjkNdzGBxiRPJHYd/mTF86YlHYGg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710210033; c=relaxed/simple; bh=PMk/rTFNC8v/WZbxXaUIU5/HY2l7wQbZqSq8PeM/KF8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=AkMy6KPQZ6vS0gLza0ZezU9ijQoYOAiVsALyqghClhdxgquH7cYi0xTB2OU29kh1LoxbPdhQmTRPux4h/OvbhrJAgTigaEA+5RPp7FKA/ho8T1K2x5/TsXggs9slpAGuM8//CENTNuPLCWB/1kG5dAYALI8pylIVw4CE85bz1QY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com; spf=pass smtp.mailfrom=sifive.com; dkim=pass (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b=bJEXJ4r6; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=sifive.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1dda51bb52eso9252055ad.3 for ; Mon, 11 Mar 2024 19:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1710210031; x=1710814831; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=MRqA0g05W48N7EVchL2+ZCRtUYEZmKtpe/WU4nz0oWY=; b=bJEXJ4r6ziqnTWVMjaZd0sLhoVIkDh/U2WLBHclMcEUXAXFg/UPbMpFRYErHba9X5f aCaKY931bz0g7s4wOuXs974gBqwC6C4/nVfV5QVNvsVLqqVvKCZyoG/XcKsHZGZbJVyb sY+rXXl1yjw02OfyZiXgrVZelx31KReiGKhWpoWBIW7G5dMrW0WFlG21j+qWSKkK+qQz VxdzQTLsMerZznUKKAKUrfrPsbmJHm6dkANC+ztTmP06qYhKDeoiPN2iYGveG2JUzahH wv2vQigVU44rtguIlKg7rV0oisltxhla7kpGO1IsN67u+5InSrxaBnWc4OMJ4zZFjUce 0YBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710210031; x=1710814831; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=MRqA0g05W48N7EVchL2+ZCRtUYEZmKtpe/WU4nz0oWY=; b=LwiZd0FYcFJi3Fumk0f0a8fNe9Ckh3a4Vz5DVTOLcqIztZCUILEyCDa2M9G2rHfqje H48C+p2xcATNOoB5imQSnSjQxt+P1lKp6L58F371cb5WvCI2qf8+4B0Vb3tojVwSUpCV N6bryozlZFYWqj/azZ0KuSk81J2CL7qLHaIG1rdR7dNuCyVYhXJPGp5zN/LwcD8N8I/x kHFnVLEOTsNQvQnzvY7/jx4/ZXYS8zGuIiPpbOGd+GaOFobBSI8FiPMQNRPe7e7KeIUZ TQFMLv2CODqXpBEO7XTiUvgGA3hclHBM3ep9VI2B0aGERZOAqWSDbMRnoAzB0aidjfRP GU3g== X-Gm-Message-State: AOJu0YxXVX/VAbuNn+golTYzIq5OfXGpzVKGZ6Jx25FJ3zhyeZlYvtgd WJ74X7TvyOor+bItiXOC3byWIyTtKmfuDeb8DwTRAfFqZRckti7ihTvmt/wQh54= X-Received: by 2002:a17:902:d58b:b0:1dd:b6b8:a689 with SMTP id k11-20020a170902d58b00b001ddb6b8a689mr572370plh.6.1710210031582; Mon, 11 Mar 2024 19:20:31 -0700 (PDT) Received: from sw06.internal.sifive.com ([4.53.31.132]) by smtp.gmail.com with ESMTPSA id a6-20020a170902ecc600b001db5bdd5e33sm5394175plh.48.2024.03.11.19.20.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Mar 2024 19:20:31 -0700 (PDT) From: Samuel Holland To: Palmer Dabbelt , linux-riscv@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Samuel Holland , stable@vger.kernel.org Subject: [PATCH] riscv: Fix spurious errors from __get/put_kernel_nofault Date: Mon, 11 Mar 2024 19:19:13 -0700 Message-ID: <20240312022030.320789-1-samuel.holland@sifive.com> X-Mailer: git-send-email 2.43.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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)) \ -- 2.43.1