From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9E650C433F5 for ; Sun, 8 May 2022 18:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:Reply-To:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DB/OQ8mq8mDdOjLCRBZaMk2v4FWivxyuQdirpjqWvGo=; b=5GWetBvj1wL8cv OQ+gmSen6y/3xEF1kMTa2KvN/Jfr3Su/e5rM6yhqkh3y5VgUkJ4RmS8Il9EYPkwmu0LcCwY8Sx878 BxCZMbMzQDeR8xTP2jZOPuvzWCWVOE1e9xMxiVxe0azg5pLa1GtuZYIjUP9Puesm7v3wjJd6nYfdV bD5TclYHtB23H3wtqMwpLToniso8ihkQQ7vUc/VgCW/PKYr55IjW6lga6FIczYOAqCygazfw2/GPY nFKg+k2I1sTMupwgGfuhEOLS/5imKwe/bfdy5yKNDK9qA3Z1og8ss/AuzYWDtrvx8Vv60P6rIxaq2 bdRHvXrwa9tmYwoFq3AQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnlSu-00AqN3-Kw; Sun, 08 May 2022 18:17:08 +0000 Received: from mail-ed1-f42.google.com ([209.85.208.42]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nnlSr-00AqMf-RF for linux-arm-kernel@lists.infradead.org; Sun, 08 May 2022 18:17:07 +0000 Received: by mail-ed1-f42.google.com with SMTP id w24so6171718edx.3 for ; Sun, 08 May 2022 11:17:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:reply-to :subject:content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=loFIheiMu2Crc+DoRZaJl6AeMAJVov39dGaYt5KOZD4=; b=UR4oOiSe63IalQo/8/9kjKyrhx6GNGlzDpUtV7vGbFP4mdL/HK3krFdOUX3yV/rAle rdw2SvQrTd7DbF4WYqvPtMG7MBJLDiDG7jD/tlE7tVOQ1DfWvmlua55FbkeNGbWPHHv5 xp2Zq/R3enkQUHV8CTCFEb+JbXkXd9/KVDvOTqDM3ZRRdHgfxS1vNqdqm1wXgIwI7+ka 0c/7LXPCyqYTxnbjlhCcxkKht9wmhhcc9e3k3ZpE/sTsE6RgcqRzHal/rQ4J2v4bZZ7Y xbW72JMuBCnrEZuE6499NrKc8VB9TCI88mYfttZGmOj7TDkhywfTjhE6PMaG5/PnIUXt HZyQ== X-Gm-Message-State: AOAM531tK+Dz6WI1YhgdTI5yBza+7UKx2vk/oWhvBm5hVlfpohvfE7fQ CFuK/eC6Jt+y5Vgch+4iKLY= X-Google-Smtp-Source: ABdhPJxCax2ujg6yC/0BtAh7dxpYxYj313fZjEN1v5f+vWY76URaZLSGwan6iSjmfMZX4xI9ypE65g== X-Received: by 2002:a05:6402:268f:b0:427:d90e:86a1 with SMTP id w15-20020a056402268f00b00427d90e86a1mr13768964edd.143.1652033824560; Sun, 08 May 2022 11:17:04 -0700 (PDT) Received: from [10.9.0.34] ([46.166.128.205]) by smtp.gmail.com with ESMTPSA id zd20-20020a17090698d400b006f3ef214e31sm4270009ejb.151.2022.05.08.11.17.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 May 2022 11:17:03 -0700 (PDT) Message-ID: Date: Sun, 8 May 2022 21:17:01 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH v2 03/13] stackleak: remove redundant check Content-Language: en-US To: Mark Rutland , linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, catalin.marinas@arm.com, keescook@chromium.org, linux-kernel@vger.kernel.org, luto@kernel.org, will@kernel.org References: <20220427173128.2603085-1-mark.rutland@arm.com> <20220427173128.2603085-4-mark.rutland@arm.com> From: Alexander Popov In-Reply-To: <20220427173128.2603085-4-mark.rutland@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220508_111705_931338_4D7508BB X-CRM114-Status: GOOD ( 20.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: alex.popov@linux.com Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 27.04.2022 20:31, Mark Rutland wrote: > 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. Mark, I can't agree here. I think this check is important. The performance profit from dropping it is less than the confidence decrease :) With this check, if the 'lowest_stack' value is corrupted, stackleak doesn't overwrite some wrong kernel memory, but simply clears the whole thread stack, which is safe behavior. > 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) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel