From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9D82C61D97 for ; Fri, 24 Nov 2023 06:18:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232041AbjKXGSL (ORCPT ); Fri, 24 Nov 2023 01:18:11 -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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.