From nobody Mon Apr 6 12:39:38 2026 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 96624C54EE9 for ; Wed, 7 Sep 2022 08:54:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230284AbiIGIyv (ORCPT ); Wed, 7 Sep 2022 04:54:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230373AbiIGIye (ORCPT ); Wed, 7 Sep 2022 04:54:34 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA5B8AF48F for ; Wed, 7 Sep 2022 01:54:17 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id b144so9160959pfb.7 for ; Wed, 07 Sep 2022 01:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=U5qUfa4Lgm6hhBC3Ke1utiFg4URrAIPI6E9fvOAWsXI=; b=MQ7NMUEslV3VIUJ66hoDMHQfDuJkUnpJAen7HiFiuTbputRUKwX5L1Fr3edDOGbpEI cxVcIECleckQZrSfvSXBeNKt3h8k99H66GK7CKXor2fgzeN7/YBWqbkIt3V2UsBGiayD e3D1vJTCbJwbANC1J7MU7n9bYxymCraeGsH531e0C5gNjSJHEAz7cuulbQUD7IL/Xt7w cAl/vX8uQZGDXRnUQ/bFYLhBCFc85/OCjUfGU0PI6pTSHmoQK4N0VD1nBfkprneose3Q OzapL9pGLhrmzMNWJTzM3iS9nyltjmVg+woULdMCa39YNBcI7bfq+WUmcckJpEtK3bKb y7zA== 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:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=U5qUfa4Lgm6hhBC3Ke1utiFg4URrAIPI6E9fvOAWsXI=; b=DhFmnhqLZh5pVm3+Jo0l6wzMjhvxmwkZtmD01FE4AAiKvQpEbF9kiP2THUz7Xuc6ep h8LR/uCus2ckyLBikxLNrZ70Nf0/61VVmy2UT56/BlgwzGtfChwvg6OshNyDQH7h2eva fCV3XBuJR7nnSy17Zy/4gTWtn1y0L6wBHPMVxMDVem8lz1a9rOnME/zSsL2UWYpdIo5k L3bnzPXa8xYn3BOs6Ds1dZlFgNWFOKECN/c3P4rsBlbEl4VFd7ibiTQXZzTxMwHJPdhy J06tL11d3KoWiljbXyUlwiSLVDTVJ/CN0uiiMLunWVSIQPuVkPM4k/9ZXX+rv+uVvVMk uYAA== X-Gm-Message-State: ACgBeo0s0X1FooXrLhf/pAJHVsPOV03j02GYN6heDOgzpbUbUHs9cOVZ McXgQ+HFKqllJKMyG/KZoL3RWEoeCoBxpA== X-Google-Smtp-Source: AA6agR5M11WYJL19TlZ6W51AfRZ+JLgFXH5YZxaS5byi54LlBPFRpOa3rzFRzPc2d3Y4LNg59x6HnQ== X-Received: by 2002:a05:6a00:15ce:b0:537:24ee:cbcf with SMTP id o14-20020a056a0015ce00b0053724eecbcfmr2651312pfu.30.1662540856481; Wed, 07 Sep 2022 01:54:16 -0700 (PDT) Received: from localhost.localdomain (lily-optiplex-3070.dynamic.ucsd.edu. [2607:f720:1300:3033::1:4dd]) by smtp.googlemail.com with ESMTPSA id k5-20020a63d845000000b0042a713dd68csm10106384pgj.53.2022.09.07.01.54.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Sep 2022 01:54:16 -0700 (PDT) From: Li Zhong To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, jpoimboe@kernel.org, jbaron@akamai.com, rostedt@goodmis.org, ardb@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, Li Zhong Subject: [PATCH v2] arch/x86/kernel: check the return value of insn_decode_kernel() Date: Wed, 7 Sep 2022 01:54:05 -0700 Message-Id: <20220907085405.2317461-1-floridsleeves@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" insn_decode() could fail and the insn.length could be invalid. So we need to check the return value first. Signed-off-by: Li Zhong --- arch/x86/kernel/jump_label.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c index f5b8ef02d172..59385700f579 100644 --- a/arch/x86/kernel/jump_label.c +++ b/arch/x86/kernel/jump_label.c @@ -20,9 +20,10 @@ int arch_jump_entry_size(struct jump_entry *entry) { struct insn insn =3D {}; + int ret; =20 - insn_decode_kernel(&insn, (void *)jump_entry_code(entry)); - BUG_ON(insn.length !=3D 2 && insn.length !=3D 5); + ret =3D insn_decode_kernel(&insn, (void *)jump_entry_code(entry)); + BUG_ON(ret < 0 || (insn.length !=3D 2 && insn.length !=3D 5)); =20 return insn.length; } --=20 2.25.1