Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp166821pxj; Thu, 20 May 2021 06:52:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhpNX5yj6O4OHSd1VDYqzgM2k1KTC9C7s0cD+2DCOfV3VKh481ampNHb4uG1r5m7BpsNe1 X-Received: by 2002:a05:6402:40d6:: with SMTP id z22mr5208127edb.125.1621518772382; Thu, 20 May 2021 06:52:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621518772; cv=none; d=google.com; s=arc-20160816; b=dz4AhPZfFh2Ti0RixYudF8gj503FsZhPZ+txhTAELLBJqi+igubnv9yGDt2F0Jm2xO SM7sa24oCyQuOtY1/FjS6Y59DAvGyp9fthFW1ub52pek03VosMlqE5EfGaQyBiU3k0/j P4c5fwL34Fv1YimauTCPIkmpN1EPFA0DidfTsODAsWnEdQcydWrZs7Dye/L2N0ioKZhc DMYgfPvLIRVPNvFWYW5U6Pem8MkSqUcXgQnDpgryhPEq6Ffzzd4CKL9hTWWjHZ4NQm2a xBjutBM/zA0hpjpuPawhsoN0uo5MZQ09kgxq354iEDZfxU+Fs7GkzqYXIYLFb1m/e0xq ci+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:references:in-reply-to :message-id; bh=rr1/cHKAMqPhsNJroHiQOd4gqYGHxEhnAN/71k9HsGQ=; b=g1kDuVQt0c6X5OrfhDBcf8dz2lShLcZr6cHS2pOOGk2D6hM1KbMwY76SsUbGzH5/yl yMCB/XRGHFx5RYGNfzz6VBghHve7ycVUyk28OiaFD7IS4zPfACbJrvkv8o7Z39umjXOi 04CnJgfifkFQzJ5NSd9fB7rc4npLAWYgG9WeaTwqkTBTYdgc8hgY+hENj5/uGEw5yVYa tZ8rUlBySZxx+caWIsNBNEhN5wX+D9mJAJULPUr2B5VutWTyer35Y4N1m+dqi1kadBJh 896lWRTYpxCm0FIrBevp8VTLXWYqzq85sE/MdkQJc8uA4cXWGtxjx0Ohv2X0rMI4c8IY GdXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v20si2481115ejq.133.2021.05.20.06.52.26; Thu, 20 May 2021 06:52:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241086AbhETNwE (ORCPT + 99 others); Thu, 20 May 2021 09:52:04 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:46505 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240474AbhETNwD (ORCPT ); Thu, 20 May 2021 09:52:03 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4FmB2m4c4lz9sTP; Thu, 20 May 2021 15:50:40 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SKVrAdrGOrIs; Thu, 20 May 2021 15:50:40 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4FmB2k3VmTz9sT8; Thu, 20 May 2021 15:50:38 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 47EE98B815; Thu, 20 May 2021 15:50:38 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 41r-VQm3G30B; Thu, 20 May 2021 15:50:38 +0200 (CEST) Received: from po15610vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.105]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 29B7E8B814; Thu, 20 May 2021 15:50:38 +0200 (CEST) Received: by po15610vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 1F15264C40; Thu, 20 May 2021 13:50:38 +0000 (UTC) Message-Id: <0320e5b41a794fd456ab8c5993bbfadcf9e1d8b4.1621516826.git.christophe.leroy@csgroup.eu> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v2 01/12] powerpc/inst: Fix sparse detection on get_user_instr() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , naveen.n.rao@linux.vnet.ibm.com, jniethe5@gmail.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Thu, 20 May 2021 13:50:38 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org get_user_instr() lacks sparse detection for the __user tag. This is because __gui_ptr is assigned with a cast. Fix that by adding a __chk_user_ptr() Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/inst.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/inst.h b/arch/powerpc/include/asm/inst.h index 268d3bd073c8..887ef150fdda 100644 --- a/arch/powerpc/include/asm/inst.h +++ b/arch/powerpc/include/asm/inst.h @@ -12,6 +12,8 @@ unsigned long __gui_ptr = (unsigned long)ptr; \ struct ppc_inst __gui_inst; \ unsigned int __prefix, __suffix; \ + \ + __chk_user_ptr(ptr); \ __gui_ret = gu_op(__prefix, (unsigned int __user *)__gui_ptr); \ if (__gui_ret == 0) { \ if ((__prefix >> 26) == OP_PREFIX) { \ @@ -29,7 +31,10 @@ }) #else /* !CONFIG_PPC64 */ #define ___get_user_instr(gu_op, dest, ptr) \ - gu_op((dest).val, (u32 __user *)(ptr)) +({ \ + __chk_user_ptr(ptr); \ + gu_op((dest).val, (u32 __user *)(ptr)); \ +}) #endif /* CONFIG_PPC64 */ #define get_user_instr(x, ptr) \ -- 2.25.0