Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1144301pxv; Fri, 9 Jul 2021 19:24:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzBUQAef9rOZYgLo/jeyrexEcV62aQfAelP4BhuPeMDpKTPpF0NAQeWakssYsgBp1E68dKn X-Received: by 2002:a05:6402:50c6:: with SMTP id h6mr50643991edb.296.1625883892038; Fri, 09 Jul 2021 19:24:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625883892; cv=none; d=google.com; s=arc-20160816; b=paO91A906B2/SSOuPk979ARkxbWUloA1PR6lvHWdPPiK94fYVT7m1WVoPutdDFYJW9 KD7vo3SA3C3iXRBFC5/pjGiEmYQv7OPkxmMSHpJ+UKk1UqhPFP7lF/9/DLYv8BaJjjiG LuSSUIO49j7cANj9ixHODlk6eQzj6Uw7Mev6D+gLNgDmz947/v5MnLCvPv4pcx+vXzm7 ulSPR3cMbX40TYRvfv1y13HUjEIQikMO6Ltb8/sCj16s0wGEoo2tuYUGppDb4GFe6WFd idNIan2c1ngbub6njJVyrcErOaHSCUtUeWURUHJiubL4PV7prLkONOPF55uzenv4hqTf rS2w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zCYBYWlEn4O9V2Xi8wv8xKW7878FVeBXYC9nX945dis=; b=aNGtcoF6Ej+Sv4szokkk4jtLhQ+GEF0ycMkN4pARIuePrF0GVg/AeijWSBg06Cb3oE zcaTWDEyS5mWDklHZPoutgqwDxg9wFqI5Cvqz1M0+5/CZ5YnzOqFV7j/l5d5A1SVH3sk 2Ss//bHnPTIyCb6ccAUnWeJYA28DQ3eIjdo96YaIqnid8bdGTypRCIs3vNtguQCIH4fz Z8owkE0tbBcn9cLmJVYQEB2Ms8u5r0EMA6sToxCJF+xTUU/O8LYod6++vs3TPvqYiCX/ FFjSnzVxqD+85y3qohgHMcJy5biJKYt78AYkvDOviweqzjHfTsi0XWWfAT8etUHjanCx qYuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OTXAruOJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hz17si9300060ejc.210.2021.07.09.19.24.28; Fri, 09 Jul 2021 19:24: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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OTXAruOJ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233121AbhGJCXa (ORCPT + 99 others); Fri, 9 Jul 2021 22:23:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:37728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232867AbhGJCWT (ORCPT ); Fri, 9 Jul 2021 22:22:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D4C17613AF; Sat, 10 Jul 2021 02:19:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625883566; bh=0YPOTlGAevRTrCYvMVP6goKkOJ4HD5gtpQFiIRIXX6I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OTXAruOJ4APS5gHShb3eJJdgD0oRtS+GAKJmf0zILeA5+hsmQTOK4pL/3LcJDAndG NK/XPCMkQw7rxYIAExUoYYlqZxGaQpAc4X0xqkUaue+aN2wnYeQZwCa5URZ3dOu86N an3nK68JDU1uXnTXa1xBurnIbAyyQWjp2F9JStKnZfB9KHZFacoAH7cldFcyaYHkFt pm+Q7l2V99J8BfpT6DQ0S7HiC89VncusYHHSGBDuyO0mehnsNLDanyw8Ng+uMGy1UI SNRqU3BhlytNRxQiEl6jLhFM5woXswPbm/Qpms1h2t4KRrosGVcs4zfhI0R+hkMbOE Xe951GQmUOHUw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christophe Leroy , Michael Ellerman , Sasha Levin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 5.13 073/114] powerpc/inst: Fix sparse detection on get_user_instr() Date: Fri, 9 Jul 2021 22:17:07 -0400 Message-Id: <20210710021748.3167666-73-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210710021748.3167666-1-sashal@kernel.org> References: <20210710021748.3167666-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe Leroy [ Upstream commit b3a9e523237013477bea914b7fbfbe420428b988 ] 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 Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/0320e5b41a794fd456ab8c5993bbfadcf9e1d8b4.1621516826.git.christophe.leroy@csgroup.eu Signed-off-by: Sasha Levin --- 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.30.2