Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6293783rwl; Thu, 29 Dec 2022 10:16:11 -0800 (PST) X-Google-Smtp-Source: AMrXdXttcD1RhQHnT7+ndYU3+B3+lQnAJTId14HuPkqgpHEaWAT5zvN0aQgpOvr43XJn0Gh7BSya X-Received: by 2002:a17:90a:130d:b0:219:89c2:b70b with SMTP id h13-20020a17090a130d00b0021989c2b70bmr37179615pja.16.1672337771681; Thu, 29 Dec 2022 10:16:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672337771; cv=none; d=google.com; s=arc-20160816; b=fz07f2ymIIpBwBvlqrBLIg2MuWvfsvEcueXVCuRwhdPWSreHvuddxxdzWdFGMux3IA mfLkaXKQIrGKlbPGWD7Pd/s6GRkKTZ1D5tTsM29vbx+XBeul6NddkpCxC60ihdDkWEaI JPU98fomvKDSxmh3pzwUKGlbhvc8b6J2G2A8cea88ASESdIhtnWWvNl0fJn/B2M+QD5r 6eSxMRDbyGpIgH+OoHAoM1zgTxYIJHKyyS455an6owQn+5J9l0SrrUI2i7eW/yuc0crA 48r8EislrNv10m4/T1rsQrx0cmhNrxZy06Y1vQZMqiTDMYCBnsaKBuwjalDkoy4uIWd2 DlfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=sVJacmndrR3SXF4pgI7oq7jigbBGB7nMmK3ZJ4uErFg=; b=sY3dqetJNVIq9FoLHGDJcItMWFQQ3i0lGmW+itXr5WsX+Z/BpWfrNgJ0qlvcmsJ+FH MLPz3P1s+6knUn9eABRAW9btt+8CHj0zXk7EQqE+50aV+wfhn3E1GMnXooeJTexRboa5 8QB1HveC53FOWFPMMX4zs7ZwQm7jzGqA65h2S5+2PlYmIriATBuBiOUWIcrRVr7ow4x1 vWz6fcxrys+zkcXmV5yFxibBXjlbQS2CrIZaNYWe9VcPJmdlpkAlprmSBRvDQ0HvBYEW hYzGmRJlxbVDEOeRdPaJ0lwWjJVmYbzlGLUQ7CxopnBiLWJsdIKAp7jvydqFmdDg/Db4 cMrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=sLDUvYVA; 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 h2-20020a636c02000000b0047883ec165esi18830157pgc.544.2022.12.29.10.16.03; Thu, 29 Dec 2022 10:16:11 -0800 (PST) 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=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=sLDUvYVA; 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 S233847AbiL2RcS (ORCPT + 61 others); Thu, 29 Dec 2022 12:32:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234006AbiL2Rbk (ORCPT ); Thu, 29 Dec 2022 12:31:40 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5120F15FCD for ; Thu, 29 Dec 2022 09:31:28 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id n4so19559925plp.1 for ; Thu, 29 Dec 2022 09:31:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date:message-id :reply-to; bh=sVJacmndrR3SXF4pgI7oq7jigbBGB7nMmK3ZJ4uErFg=; b=sLDUvYVARgK48hM4ztw89h3d9Pa2+0WTyT7T5Ud9zRoin3WUKukse7kiiDZK/VqpLy TTV8avCc4fhG2Q4R4ek5ySBKdx9iZ9VUoBkgSVttyKy+QT7h6f7rsNNr5APjsuJ036QY bvRIrXiGnJ4encNQ85H3NcxikMAaZgZXmx+2WbHUfO4YvZJc8cQK3u7CGNMAKkvMgviE qPg4A5cB8ZgArCQSwb4L9pFxEBj/rBwNe3P9/d2Klt0PAKvxbQaXXnxCkAkxni2bxWnZ 4ph22vu4DS5S7CwJenUcWlx2fGHqIA3NHkf6DcE46OxlcnThLbDf6M7u0v8qLZuaaBvy B+kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=sVJacmndrR3SXF4pgI7oq7jigbBGB7nMmK3ZJ4uErFg=; b=N06AY8k7cqXTbIPoQBvY1T57iIjW9g1xnZEEOgPOYx6T3lQy6tcLxnLerP3leTSSEv 7R4u4W/AC3sgtd7FrF8HrSCtsjS+oPoEIt07DK/vne1QD1T4+nEO0OAi7ruq5xsP2DT3 E6yLgn4LfhgndRItFxAMi0BH+bmSPw59xkCFq1tswMuLiLR4HCAgL6IdCxGfBhE4UbdT ExNzlP1M/aqlPCStLvu3En7T2dSvDo+vMUvYI9oWD36P5vXXAmntVkpYlbg4UlI4+ZHO EPXCZVo4x5ZktI12wMV/KczqHMRW4cjGMD1Urqml439q6x+Krtr9X2K9AeTpHzTHgA1g BMlA== X-Gm-Message-State: AFqh2kqmATKHosUsN7Yau9EswKKSlixZn4a5jGRinH8R2gMWH/KxGeQt 4gb2ROLd+OpKbNcNTUTNJn0oCOqT/4eZeS5SIU8= X-Received: by 2002:a05:6a20:c78d:b0:a3:878d:c126 with SMTP id hk13-20020a056a20c78d00b000a3878dc126mr39597273pzb.42.1672335087597; Thu, 29 Dec 2022 09:31:27 -0800 (PST) Received: from localhost ([135.180.226.51]) by smtp.gmail.com with ESMTPSA id 27-20020a63115b000000b00477bdc1d5d5sm11199985pgr.6.2022.12.29.09.31.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Dec 2022 09:31:27 -0800 (PST) Date: Thu, 29 Dec 2022 09:31:27 -0800 (PST) X-Google-Original-Date: Thu, 29 Dec 2022 09:31:18 PST (-0800) Subject: Re: [PATCH] riscv: uaccess: fix type of 0 variable on error in get_user() In-Reply-To: <20221229170545.718264-1-ben-linux@fluff.org> CC: linux-riscv@lists.infradead.org, Paul Walmsley , linux-kernel@vger.kernel.org, aou@eecs.berkeley.edu, ben-linux@fluff.org From: Palmer Dabbelt To: ben-linux@fluff.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On Thu, 29 Dec 2022 09:05:45 PST (-0800), ben-linux@fluff.org wrote: > If the get_user(x, ptr) has x as a pointer, then the setting > of (x) = 0 is going to produce the following sparse warning, > so fix this by forcing the type of 'x' when access_ok() fails. > > fs/aio.c:2073:21: warning: Using plain integer as NULL pointer > > Signed-off-by: Ben Dooks > --- > arch/riscv/include/asm/uaccess.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h > index 855450bed9f5..ec0cab9fbddd 100644 > --- a/arch/riscv/include/asm/uaccess.h > +++ b/arch/riscv/include/asm/uaccess.h > @@ -165,7 +165,7 @@ do { \ > might_fault(); \ > access_ok(__p, sizeof(*__p)) ? \ > __get_user((x), __p) : \ > - ((x) = 0, -EFAULT); \ > + ((x) = (__force __typeof__(x))0, -EFAULT); \ > }) > > #define __put_user_asm(insn, x, ptr, err) \ Looks like arm64 has a pretty similar pattern. They've got the __force __typeof__ already, but given the similarity it might be worth refactoring these to share the error checking code. Reviewed-by: Palmer Dabbelt I'll give this a bit of time like usual, unless anyone's opposed I'll put it on fixes. I wasn't planning on sending a PR this week anyway due to the holidays. Thanks!