Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4780656ioa; Wed, 27 Apr 2022 10:58:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvpHZvIdgkIL70IEgXhxBkP3Y38/RAHAT/4u35NDNYxJaJMRSGfhLlw//2vHVO3B7oMCJp X-Received: by 2002:a17:902:8ec2:b0:156:9d2c:9ec5 with SMTP id x2-20020a1709028ec200b001569d2c9ec5mr29236858plo.170.1651082291706; Wed, 27 Apr 2022 10:58:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651082291; cv=none; d=google.com; s=arc-20160816; b=drNc9/U0uaQ78qRM9NniWf9t5NVoaqdEkKDO/SHJG+5/TWLr3ACDzZCL+0wzAx4Pxb a9M4l6XnuJV7x+j29Q5I0lzNCblSUGA8B1MH6s9MbYeZC0XHWkHZ91zkptzqjIWtPxYe ybYkSLny6czlSxfFZYEPxwlzvcCy1dMlZ6oRZUN8hq5PaO/A5upx4xWApHdmIFpeaHzx r9VbbO/otlgknsI2HCfIGiU7E0ZuYVC8wfLyR5d1jhbT5ysLi7gp5JrI29QpOYEmh7hT moEvkTYivYNfe24MEZsL+9PAOicukgq/0F4pgKYAh/Hg8zBivKnwcPTzzjufperROI2K JKcQ== 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=N1V1cO8Wi+m2I/5bUkgpl5ktSFXMyS7uj+inmEmZwzE=; b=XXzgoCRimDkfx8hyPAWEAeuLUNIOx4bGgebGnufNO1nDwzoDYjWvCIkzZN2xlDElVr Ov65qUApAMulnbur9GSyaRznppYAXJLh3HvDxxOFFK0F7x0WmAPZYmg+ALIQA5BhsUB8 rvqKhkHpTlSQU2i2AlCy3kecSKuN8/4PY8jZyG8a1GHGCQLJHkvBBvW/xlK6fkXQ6Xnz 2pdyqL9br8dK4LJ49NLRaYU+kLKGLoTnYYs47BOWpkfTZhspDlqjZtGBy0QFxcVrd8rc p43B4V780vLxFWARGceUTyx31k1we8gQ1KUDJZtk0KffbnBD3jmOo2khMFarMluRPRJW q/Yg== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a2-20020a17090a740200b001d29583a7e1si5721404pjg.81.2022.04.27.10.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 10:58:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B5140251778; Wed, 27 Apr 2022 10:32:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244287AbiD0RfK (ORCPT + 99 others); Wed, 27 Apr 2022 13:35:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244195AbiD0Rez (ORCPT ); Wed, 27 Apr 2022 13:34:55 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3FBFC1DFE48 for ; Wed, 27 Apr 2022 10:31:41 -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 0D2001477; Wed, 27 Apr 2022 10:31:41 -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 C48B73F73B; Wed, 27 Apr 2022 10:31:39 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, alex.popov@linux.com, catalin.marinas@arm.com, keescook@chromium.org, linux-kernel@vger.kernel.org, luto@kernel.org, mark.rutland@arm.com, will@kernel.org Subject: [PATCH v2 03/13] stackleak: remove redundant check Date: Wed, 27 Apr 2022 18:31:18 +0100 Message-Id: <20220427173128.2603085-4-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220427173128.2603085-1-mark.rutland@arm.com> References: <20220427173128.2603085-1-mark.rutland@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no 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 753eab797a04d..f7a0f8cf73c37 100644 --- a/kernel/stackleak.c +++ b/kernel/stackleak.c @@ -78,10 +78,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(kstack_ptr - boundary >= THREAD_SIZE)) - kstack_ptr = boundary; - /* Search for the poison value in the kernel stack */ while (kstack_ptr > boundary && poison_count <= depth) { if (*(unsigned long *)kstack_ptr == STACKLEAK_POISON) -- 2.30.2