Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1060666rdg; Fri, 11 Aug 2023 08:30:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGfJSF+jbPo2lZ4Ztx5cvNstlL85yosvj+Efmu9Jdq+ZH9pvBuVMzwgPNdMAD1HYtSLFaip X-Received: by 2002:a17:907:a062:b0:99b:bf82:75fc with SMTP id ia2-20020a170907a06200b0099bbf8275fcmr1835315ejc.32.1691767858623; Fri, 11 Aug 2023 08:30:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691767858; cv=none; d=google.com; s=arc-20160816; b=wDqLua3eYVhdhkOi1Q+DDcKEaCQhWZnBooCLSnwvYvsrMJ/ynV88KOGEjiTC7hAvtI slp8MQkvvY2cnLGl4mu1JhFkXCsWiXIU3T183NFT9YBNtWvlGdEm3MyOfQw2DA7/mr9b Vb3CqixwSGxwc59N7xRwTRZFO4WbAaryrX7tjt2LDsG0mWBsa66nqX9NZYkbHXaiaWmU RSSmoucShmDDpyK4/LISvt8/luY9ARqOBMipic+Ccoxk78PGa219QcLAFLybDuGeG3TL x3UA7sNZnP0/rLFjG8T/1caASsjimTFdY/tamLFnoyKCp3wHq4o6D9z80RUTWjm0bO9C HvmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:dkim-signature; bh=Xd+TgXFtpWK8JUp/buH0ZdNAaimnoDNIO7zEmS6bZ9c=; fh=gc2h2ZEEdzGRttvPWA+NAkV8FmgNX1HpJgQffTlHnOU=; b=o8CukUXw2ZHiOIf1EfHyjaqzO7KKXWFgw0ULoqu0QVdGPCAAwtMbzOUojOh8gBUD1X lqj0IGyXXMS1ft4XGy1wgmRhLYeXDS4E4sin3u+2W7a2XT4aLRA7NougqabKIb+c2ovi S34Q1n5xjUrtGt544nBIeWRenFaavMC25ZfYHm53MMXLSal5jfSEDlaM6KDiO+QwtuU5 RIOtrFOc3enErX2s0Gcl78WlvOeAC89qSgCoJyRTj3Xym5afy8gRlk0cxEZh7YRea40O p9oKe6FQ0Cfk15bsoYqtq8hVi8MqYlzSQKfsbhzRgfBNY620IVjlm8fvXxyThx9q8QoD 8tsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aurel32.net header.s=202004.hall header.b=Qh6Yinvx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qc23-20020a170906d8b700b00997e1a43c28si3743210ejb.381.2023.08.11.08.30.31; Fri, 11 Aug 2023 08:30:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@aurel32.net header.s=202004.hall header.b=Qh6Yinvx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235390AbjHKOfc (ORCPT + 99 others); Fri, 11 Aug 2023 10:35:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232228AbjHKOfb (ORCPT ); Fri, 11 Aug 2023 10:35:31 -0400 Received: from hall.aurel32.net (hall.aurel32.net [IPv6:2001:bc8:30d7:100::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7DE4130 for ; Fri, 11 Aug 2023 07:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aurel32.net ; s=202004.hall; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Content-Transfer-Encoding:From:Reply-To: Subject:Content-ID:Content-Description:X-Debbugs-Cc; bh=Xd+TgXFtpWK8JUp/buH0ZdNAaimnoDNIO7zEmS6bZ9c=; b=Qh6Yinvx23/8VlytZgJZE4vMcY zpVO0I0SturxAaHA9CzDIvKg33IMiBOTu4odRO0ragaHMU7cWSxAjmWKSuDRlyq4P9uEYmEmkLTUr BmHpgrl8lu21Be+jkMKAcQDtl6ehhdaEkIYzQhG3zK6sdjiSDnAnd/+cPnPzsTlOsIZ+7DqJ/vnCZ Hf/FtpsUHjJ416aYMFX6O4Mnh7CUeNxDeXuhaQQK1aw+3JNL136K1hPH5WyN8mJi1XtIWdWNWWmCR GQ5rc1F3UIpL7TImvHhyu1zeYLE1hcFcTF4aSoEKXWdkoWZ4DkNUMXPfRsyFdm+HmYyoGzG8XPuEc rJEiZyiA==; Received: from ohm.aurel32.net ([2001:bc8:30d7:111::2]) by hall.aurel32.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qUTEV-008IKO-JZ; Fri, 11 Aug 2023 16:35:19 +0200 Received: from aurel32 by ohm.aurel32.net with local (Exim 4.96) (envelope-from ) id 1qUTER-00HJuM-1m; Fri, 11 Aug 2023 16:35:15 +0200 Date: Fri, 11 Aug 2023 16:35:15 +0200 From: Aurelien Jarno To: Alexandre Ghiti Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alan Kao , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Bo YU Subject: Re: [PATCH -fixes] riscv: uaccess: Return the number of bytes effectively copied Message-ID: Mail-Followup-To: Alexandre Ghiti , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alan Kao , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Bo YU References: <20230811110304.1613032-1-alexghiti@rivosinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230811110304.1613032-1-alexghiti@rivosinc.com> User-Agent: Mutt/2.2.9 (2022-11-12) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_PASS, SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alexandre, On 2023-08-11 13:03, Alexandre Ghiti wrote: > It was reported that the riscv kernel hangs while executing the test > in [1]. > > Indeed, the test hangs when trying to write a buffer to a file. The > problem is that the riscv implementation of raw_copy_from_user() does not > return the number of bytes written when an exception happens and is fixed > up. > > generic_perform_write() pre-faults the user pages and bails out if nothing > can be written, otherwise it will access the userspace buffer: here the > riscv implementation keeps returning it was not able to copy any byte > though the pre-faulting indicates otherwise. So generic_perform_write() > keeps retrying to access the user memory and ends up in an infinite > loop. > > Note that before the commit mentioned in [1] that introduced this > regression, it worked because generic_perform_write() would bail out if > only one byte could not be written. > > So fix this by returning the number of bytes effectively written in > __asm_copy_[to|from]_user() and __clear_user(), as it is expected. > > [1] https://lore.kernel.org/linux-riscv/20230309151841.bomov6hq3ybyp42a@debian/ > > Fixes: ebcbd75e3962 ("riscv: Fix the bug in memory access fixup code") > Reported-by: Bo YU > Closes: https://lore.kernel.org/linux-riscv/20230309151841.bomov6hq3ybyp42a@debian/#t > Reported-by: Aurelien Jarno > Closes: https://lore.kernel.org/linux-riscv/ZNOnCakhwIeue3yr@aurel32.net/ > Signed-off-by: Alexandre Ghiti > --- > arch/riscv/lib/uaccess.S | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) Thanks for providing a patch so fast. I confirm that the issue I reported is fixed, but also that the full strace testsuite now passes successfully. The code looks all good to me, so: Tested-by: Aurelien Jarno Reviewed-by: Aurelien Jarno -- Aurelien Jarno GPG: 4096R/1DDD8C9B aurelien@aurel32.net http://aurel32.net