Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp849634rdh; Thu, 23 Nov 2023 22:18:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IECViFjwHLCeIxgbVcEFlnu8iayaizKSamWVKk+h3G3LsHMbJvL65GIIcFhQclq3tM7lMXz X-Received: by 2002:a05:6870:a101:b0:1f9:5ce0:5984 with SMTP id m1-20020a056870a10100b001f95ce05984mr2125658oae.55.1700806704876; Thu, 23 Nov 2023 22:18:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700806704; cv=none; d=google.com; s=arc-20160816; b=fmojVOhwnDWXdBLSPeP+5L5Gds4IwAFUL+G8oW39JWlpMFGR4g0Qa1eGQGyNht1xwV ZvgFvAIdhnvI18wV0zAZlThaNpL9v3nuzOFc2T1avdqs28MVUnXkCjsjQJeuXp1GlBwd nujFQ2p4UvgG+GLinyAmyBytnTdQMv88lx4Y9cS+HhrPdACllDl+qevtFdJVmEaywSIm 5bfVTsJhFsi5We0mOq61qJY2yWTRVnp4PP9p5bPn7286O//odf20O1TuDWpd39T5I/T/ H9p8vII0BlyShEzGqb1cLqVuQ5i09kG1UESsTvw9nYeUVUUZ2O2Ou1Zf97tJqZ4wHS13 UMRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=i3N5b877wwqEXJcttr8x40Ktc1dX/olxiJWVssayIyw=; fh=pI/CbdBbHeVeQAi19zFsT2FqyVaDa8L1eIXwbDQZgaY=; b=wr3onpBE1gc5B6A800bBxAdti4T2XMUgPpJjLdN6wrIJWrCP7StFAtrMaYij/pdcM5 JY1V9zKBxghyLEpPNU72kDU7YTfnHBTbw0X/4733jE6NDY5PNfax4anNgVFg2Kf/ewNK 2+lPCTPHGb3rz86kFRKFLG7IkgeAwxF7SA3TrYq8oiVMEmfsah79+wN0JwZrDe73eECC cTUzfFiWeN+DBZnVuqgSXU6FkpkQVEelzbEjReke6v21kAMs15WB64CezBee4IA9W2eM XRg8taD9JtcJ1RVhc/c7QNf+UHSzH04q/f6PVPstW/cCva7JYF/5mrgsAppfp8kMFaNk iqRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=Sho5UVcl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bw1-20020a056a02048100b005acf4298a78si3279519pgb.149.2023.11.23.22.18.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 22:18:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=Sho5UVcl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 49B8C8189097; Thu, 23 Nov 2023 22:18:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232747AbjKXGSJ (ORCPT + 99 others); Fri, 24 Nov 2023 01:18:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjKXGSD (ORCPT ); Fri, 24 Nov 2023 01:18:03 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A2B52D66 for ; Thu, 23 Nov 2023 22:05:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=i3N5b877wwqEXJcttr8x40Ktc1dX/olxiJWVssayIyw=; b=Sho5UVclWCF9mc8IXFMKVdM4wQ CL50tQt3DDPm88wweleeVf0oPoA7dRFLPole6BIEavVFYyp6RYgTfuG0MiMQhLL/CuVvKUHbKcL6j WEynwjOBpdyUi7Q7/ChZ6XV2/K6wxBLG5BVGi8liPYppJGwM/GPU0rGxVrVOq4zxXu3lA09nNLmAi JghIAFfNmusCy32yGgd4VE9QR6cuZ1dBuN9IwOAh/ChJRLKXNTlKjokMTE/zDx1L/OtTv+TPoI4Fx Wp8WVQ5wjqZHZSoiOG0VYlekf7s/bZDknI0TNdWcZ0Kc9/MIaV+eV0ts4zGko9YeDr04wfHh0pVCz XerJv5ng==; Received: from hch by bombadil.infradead.org with local (Exim 4.96 #2 (Red Hat Linux)) id 1r6PJX-006F9E-2z; Fri, 24 Nov 2023 06:05:19 +0000 Date: Thu, 23 Nov 2023 22:05:19 -0800 From: Christoph Hellwig To: Ben Dooks Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu Subject: Re: [PATCH] riscv: fix __user annotation in traps_misaligned.c Message-ID: References: <20231123141617.259591-1-ben.dooks@codethink.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231123141617.259591-1-ben.dooks@codethink.co.uk> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 23 Nov 2023 22:18:23 -0800 (PST) On Thu, Nov 23, 2023 at 02:16:17PM +0000, Ben Dooks wrote: > @@ -319,7 +319,7 @@ static inline int get_insn(struct pt_regs *regs, ulong mepc, ulong *r_insn) > static inline int load_u8(struct pt_regs *regs, const u8 *addr, u8 *r_val) > { > if (user_mode(regs)) { > - return __get_user(*r_val, addr); > + return __get_user(*r_val, (u8 __user *)addr); > } else { > *r_val = *addr; > return 0; This is the wrong way to approach it. Pass the untype unsigned long from the caller instead and do a single round of casts from that depending on the address_space. And please also remove this horrible else after return entipattern while you're at it.