Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5121779rwb; Tue, 6 Sep 2022 19:33:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR5hsXnZV20bG4BOwpczNkQILiEO8kigBHYjvUq2tOLe/Emf1h6aiXoVOSZMKOph2Fgi09ti X-Received: by 2002:a05:6402:248d:b0:437:dd4c:e70e with SMTP id q13-20020a056402248d00b00437dd4ce70emr1176055eda.75.1662518023096; Tue, 06 Sep 2022 19:33:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662518023; cv=none; d=google.com; s=arc-20160816; b=I6p4Gg13hYeyH8w7oczz7p1wTVm6jUTn3/ADmWVHG8OEoAQJbLjyUmHPLSwp1JAnOs t1MBMwQpi9R/kV08Y06JxlqN86YFrfcdYzImQjCF6VAJtfSw+eJljeEFumJYD5jphp6N 8jUcRU3HvpxToc8oSLGo6F5NHyhy9t0AqHqpL/leA7N7V6cZ7uCBAEBg4g7pHJmw4x6+ 2fL2izrs/aC5jOj2D3U3r5tNSLz04Jl9jp+IHd9oTpgiPp1e3ZEdqovGEO4ZNbdnEB5t MTvHHQIwVmjzZJYCWs/5fOcHdWBK6oYIX+EnDN8WLaaQcrPKJNF/x41W+fzCTwFVhIlI 2sRQ== 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:subject:cc:to:from:date; bh=g8/iF8+F+Ex623UBFO2qS4vjeBV3dXHsFf61wMr4ldA=; b=hYMvZw4q474VnFY0DZ4DJ5MjB0k1rmC+df8VxOEa+4pE5gxfwftZYHegaO5EmFTS2s 1yLlwRcY2sPl/1TTFVa7ISibM/j2gJ/HrHe/cSYDf1mgO+LVIzPy+g6c2LOMeql/zxaw PjKdMCXMxf7NxwiTbSIqbCi1dRnPI/BDhA4g2xWnPtOhnA+MG0VrL6hcfjUqEK2ZZHIb 8sv2nZZflVOn8jLIKZe4+eY7Ig/qT57xcEwVmTXJSYtfQPUYeNiuM7zkrmFH1uDKX1Aa oxSHkpQnOSavcz+EO9O1wk3k1O2y0QsLLYoVWAiCXtYb3UmWm/9ixkKJQ6M2uEsk6X1T yciw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y18-20020a056402271200b004481da6fde3si12559443edd.520.2022.09.06.19.33.17; Tue, 06 Sep 2022 19:33:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229538AbiIGB6r (ORCPT + 99 others); Tue, 6 Sep 2022 21:58:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbiIGB6p (ORCPT ); Tue, 6 Sep 2022 21:58:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBC458C472 for ; Tue, 6 Sep 2022 18:58:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4D3D3B81ADB for ; Wed, 7 Sep 2022 01:58:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36BA1C433D6; Wed, 7 Sep 2022 01:58:39 +0000 (UTC) Date: Tue, 6 Sep 2022 21:59:18 -0400 From: Steven Rostedt To: Li Zhong Cc: linux-kernel@vger.kernel.org, peterz@infradead.org, jpoimboe@kernel.org, jbaron@akamai.com, ardb@kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com Subject: Re: [PATCH v1] arch/x86/kernel: check the return value of insn_decode_kernel() Message-ID: <20220906215918.3fe20cca@gandalf.local.home> In-Reply-To: <20220902074706.2211252-1-floridsleeves@gmail.com> References: <20220902074706.2211252-1-floridsleeves@gmail.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 On Fri, 2 Sep 2022 00:47:06 -0700 Li Zhong wrote: > @@ -20,9 +20,10 @@ > int arch_jump_entry_size(struct jump_entry *entry) > { > struct insn insn = {}; > + int ret; > > - insn_decode_kernel(&insn, (void *)jump_entry_code(entry)); > - BUG_ON(insn.length != 2 && insn.length != 5); > + ret = insn_decode_kernel(&insn, (void *)jump_entry_code(entry)); It's highly unlikely that length will be 2 or 5 if ret is not zero (as it is initialized to zero going into this function). > + BUG_ON(ret < 0 || insn.length != 2 && insn.length != 5); In any case, you need parenthesis around the && condition. -- Steve > > return insn.length;