Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp582094pxb; Mon, 25 Apr 2022 17:13:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlscSeIImas4t4rC4LsTxy2L2wr1AnmM0rLsSvekA1j3Tl1uLhS4Nco40eEAYYSSAABt87 X-Received: by 2002:a50:cd8d:0:b0:416:63d7:9326 with SMTP id p13-20020a50cd8d000000b0041663d79326mr21968920edi.233.1650932029694; Mon, 25 Apr 2022 17:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650932029; cv=none; d=google.com; s=arc-20160816; b=lF2sXx/wZ2S66dAZGZMgjEA8D5mB5bjMC27QnfwSAsi7yj7ii7hLECEuomotzrO9J/ ceihyw6jRqdGiPtTcRPKa5/7nqSefqHLg1mzsArE6N2vD5oJ7p4RGCwqqFdkrvX0RJ/U /873BVRnP9kBbfo0k1y4KV+j5CxFLgLQM0d4uGWfF20gtlsR/8Os73zUbDHPQnppnKU4 kjj83aW42jUmB6Ypog8ct8Wym2wKLBVNN5UOWDMD5v1cC5Ghd7+r87Y+mWNCr5ypVphD UjDK0fCXyBHZjtzrVpbOeH6ijIMiJ0qkkq1aBhitCBueKgsJAxJguRzhYIHCXD9ciCLu ox0Q== 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; bh=OmVlKW9DoCObJis5XJ1nfQVbr7eeitk3lIDN4VFim0I=; b=rgDzM7mw6XiEWSjJfNAUC4vrkcvsD1IVEKrpgN1q1p64j/jZwFZDAStJKqQ4Pgxe5S fQ5exraPmiKwpWNdFafsoDBKZqYdilE1Hk0taS2AZRREDBJGCAcEM8UfXhgWpEi3FzAG 0v/DQwK60gYRgWHvDPovXnaCCVXR1EJh0He0/v8OdcO64fo5EPyEWkaL/QV1JYO4UAQp 1WB6g2Oe6c9mRuDQ87VKCgAhLi9iLERQILHxRb2Gc0AA8fFZXcQAhGWmodIHGNP0xEBV ZcPAI+xmpZguygjg6TIi0kM+9R62cH96/3/d74KTyTinTukU18QlR6KQRBhhvO+LgOoa Q79w== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w22-20020a1709060a1600b006e7efa5c4fbsi14263279ejf.173.2022.04.25.17.13.24; Mon, 25 Apr 2022 17:13:49 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239777AbiDYMAV (ORCPT + 99 others); Mon, 25 Apr 2022 08:00:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236991AbiDYL7c (ORCPT ); Mon, 25 Apr 2022 07:59:32 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 078E56422 for ; Mon, 25 Apr 2022 04:56:28 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C8A04113E; Mon, 25 Apr 2022 04:56:22 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7120A3F73B; Mon, 25 Apr 2022 04:56:21 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, alex.popov@linux.com, catalin.marinas@arm.com, keescook@chromium.org, linux-arm-kernel@lists.infradead.org, luto@kernel.org, mark.rutland@arm.com, will@kernel.org Subject: [PATCH 6/8] stackleak: remove redundant check Date: Mon, 25 Apr 2022 12:56:01 +0100 Message-Id: <20220425115603.781311-7-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220425115603.781311-1-mark.rutland@arm.com> References: <20220425115603.781311-1-mark.rutland@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 In __stackleak_erase() we check that the `erase_low` value derived from `current->lowest_stack` is above the lowest legitimate stack pointer value, but this is already enforced by stackleak_track_stack() when recording the lowest stack value. Remove the redundant check. There should be no functional change as a result of this patch. Signed-off-by: Mark Rutland Cc: Alexander Popov Cc: Andrew Morton Cc: Andy Lutomirski Cc: Kees Cook --- kernel/stackleak.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/kernel/stackleak.c b/kernel/stackleak.c index f597d3323729d..ba346d46218f5 100644 --- a/kernel/stackleak.c +++ b/kernel/stackleak.c @@ -79,10 +79,6 @@ static __always_inline void __stackleak_erase(void) unsigned int poison_count = 0; const unsigned int depth = STACKLEAK_SEARCH_DEPTH / sizeof(unsigned long); - /* Check that 'lowest_stack' value is sane */ - if (unlikely(erase_low - task_stack_low >= THREAD_SIZE)) - erase_low = task_stack_low; - /* Search for the poison value in the kernel stack */ while (erase_low > task_stack_low && poison_count <= depth) { if (*(unsigned long *)erase_low == STACKLEAK_POISON) -- 2.30.2