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 X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CE43C54FCC for ; Mon, 20 Apr 2020 22:35:05 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 36C4D20857 for ; Mon, 20 Apr 2020 22:35:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sf8qpuac"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="WaKFtBNj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 36C4D20857 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pDthWWbzc1MvIm6jFFAS5NLYPQ/1LXKpkxMUtgJpTtU=; b=sf8qpuacS29gVu fpqy3grtWZwHtvWWw5yNPn965BsatfKcvlmdOdGo501wPoqqq5aKz5qT6y0g4FGob8xXbCDDuvhZ3 +GFA7H09Ke7pDPjxnsmp1GtXu4LNz/GIKeEEjdvPH+d02riJoyRmlJoSE1mcVh+8sIVmYIC9t8gRO f7WEirO3qAUBKiRufYuVnwlIP/ePbz6Xi526GvFFqDnwhS/TslePKwykUaEvIM40uEjhmcYdgHrub 60RBGz3SYwVAi0+WRxqMlw4sTHFgTmgtiYfRCTc3Mt3pDlDc2BROG/OSo/vOjHZyYctf+I/kbGVPQ 9ln73j6pjWxCh9E+y1lg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jQf0J-0008EC-Qb; Mon, 20 Apr 2020 22:35:03 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jQf0G-0008BJ-1P for linux-arm-kernel@lists.infradead.org; Mon, 20 Apr 2020 22:35:01 +0000 Received: by mail-pg1-x542.google.com with SMTP id x26so5797135pgc.10 for ; Mon, 20 Apr 2020 15:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=gHx7qgEhMfCeRi4LwRcBINau80f3lsbADPFxDRDnQX8=; b=WaKFtBNjxAG6922c9M7PS6Sr9GtIoZi+Bab8wtI8WphnYmTcq8s4ZSzd4luipXOLU4 jf4QK74nyiAcI85rmEUYpbI/hBAhRHU50KzAVjDVdJlDL1gU+m4RHq55dCtYvfJ4lxlT nAFclQvexr0WpO9w144f4pIlUT9r5MqSnjeTI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=gHx7qgEhMfCeRi4LwRcBINau80f3lsbADPFxDRDnQX8=; b=UxoMxfT5W/xowq7Sn+WuqcqSzcdkADJlfVz3YTBuYjUgc0HUOw9VN404dNbpLbQwji vJlroFmFfMWIMkNjEbaMZlwVS9iFGVwMmJvLzERT9m8XvFZy0BJOpVc0eWR5T+537823 Q64wku4pO3us9etx8ZG8guauhOypS7jEmIbv4AQDfCWODDWRrpVJAsqel6FjK2YU+K2q QTqj77Thqtfq2tQwIeZt9U4bKK4lakvJ9+MHjDtJur4nzS8S/6dqspxzimSkjXBsehKA eoT4jbO+bSijADVjSgQzQibJM8Qgb4E0HOW0PiDy1jqMAS+xgMjJiZygTJV4wK9Kh4v3 UaDA== X-Gm-Message-State: AGi0PuZXrO7IuY1J1RV/j6WyRw0j2asBcuLRJpXIkKgPtWbrleTY7oZT ZwtwFlr57nFPHqdCxjkTlO6ZUQ== X-Google-Smtp-Source: APiQypKAcbw6yPUzbM4nMMNMJKcG2W4526Isd/VpAs6Bq80MioCbLHvZ9ufOTrlBeRJfVRW8JpiX/g== X-Received: by 2002:a63:602:: with SMTP id 2mr18621933pgg.383.1587422099130; Mon, 20 Apr 2020 15:34:59 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id x10sm373971pgq.79.2020.04.20.15.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2020 15:34:58 -0700 (PDT) Date: Mon, 20 Apr 2020 15:34:57 -0700 From: Kees Cook To: Will Deacon Subject: Re: [PATCH v2 5/5] arm64: entry: Enable random_kstack_offset support Message-ID: <202004201529.BB787BB@keescook> References: <20200324203231.64324-1-keescook@chromium.org> <20200324203231.64324-6-keescook@chromium.org> <20200420205458.GC29998@willie-the-truck> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200420205458.GC29998@willie-the-truck> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200420_153500_105126_A9F2A8F2 X-CRM114-Status: GOOD ( 14.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Jann Horn , Ard Biesheuvel , Peter Zijlstra , Catalin Marinas , x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Potapenko , linux-arm-kernel@lists.infradead.org, Andy Lutomirski , kernel-hardening@lists.openwall.com, "Perla, Enrico" , Thomas Gleixner , Elena Reshetova Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Apr 20, 2020 at 09:54:58PM +0100, Will Deacon wrote: > On Tue, Mar 24, 2020 at 01:32:31PM -0700, Kees Cook wrote: > > + /* > > + * Since the compiler chooses a 4 bit alignment for the stack, > > + * let's save one additional bit (9 total), which gets us up > > + * near 5 bits of entropy. > > + */ > > + choose_random_kstack_offset(get_random_int() & 0x1FF); > > Hmm, this comment doesn't make any sense to me. I mean, I get that 0x1ff > is 9 bits, and that is 4+5 but so what? Er, well, yes. I guess I was just trying to explain why there were 9 bits saved here and to document what I was seeing the compiler actually doing with the values. (And it serves as a comparison to the x86 comment which is explaining similar calculations in the face of x86_64 vs ia32.) Would something like this be better? /* * Since the compiler uses 4 bit alignment for the stack (1 more than * x86_64), let's try to match the 5ish-bit entropy seen in x86_64, * instead of having needlessly lower entropy. As a result, keep the * low 9 bits. */ -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel