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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE365C433EF for ; Thu, 9 Dec 2021 20:33:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231177AbhLIUgr (ORCPT ); Thu, 9 Dec 2021 15:36:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230484AbhLIUgr (ORCPT ); Thu, 9 Dec 2021 15:36:47 -0500 Received: from mail-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC481C061746 for ; Thu, 9 Dec 2021 12:33:13 -0800 (PST) Received: by mail-oi1-x231.google.com with SMTP id n66so10314971oia.9 for ; Thu, 09 Dec 2021 12:33:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kkfMK5PB8QI1XOoT83uXuffhKjgO17IGbJlqxB7Wwjw=; b=GvTTIDuouZQMVVXAnpmcyU3Gx53MZYuELZzUGCQqpaCUDzPEn3riEDFzRpwKQdMFZb nfl/1sGVtEAdgILK3aYLue6HOJUbPwu+QAUSi+hTSRja7ul8GzpWv4NMi7dYhpJhB4/z iwOVw/IqHOAdoP7Uk53PQKv2whQaj31Ed+LI+mbLQ8D1nzjU9fwymLhZKdqObEwM7VnY 9BWc8tmCfg0B/swTogcVoToAzGTAXyhoYVdtEoI6oJOSSS/qLjbsDIpDL/IVwUXqC7vV 3QxrF2COmUd6jmV06TbzH87thULXjLQwXsSsibrYss2+xM2ydBzBieDrGjMVhMOLtvZF pIHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kkfMK5PB8QI1XOoT83uXuffhKjgO17IGbJlqxB7Wwjw=; b=ZjnIZ9F//J4aioBVs7GEwbvkQZBZFwIupMDAobU1zGtnOWuJzT7sbLRPirSMlEjyRH 7IInH27+yyf0X6hHIyNKziImq8+cik4kSXJMrmIIVXQXheFloY8IIpduihR6bAdsCoxB wqoS74ZUIrw5rhxmcVqYVNUYMUT36OaX0loV6a9AQzrI23oeYnGOqkMKOZavZHto1EC+ fdy7SJmfhLAP+nU344Dzzjx/IWjbYz8JkM79pxVb3H0zE6gw1PxG/pQW2qhpqrD6fxHd xr/+JUyTKIsUeheNkvL9FBbM71TVJAgumwM1NP9tSWkMPDdIReew4jO5D7+X1tkoWllV sgHA== X-Gm-Message-State: AOAM532a4ipazmPbZlMevDvLd6+RxZ2EWJ/atnxsu3v7HStaBRmyLSF3 y8WYppog7AksmeHpI38oGNXLrWXQmXsyjtu1I38bnQ== X-Google-Smtp-Source: ABdhPJzORI+4/1cecMt2bxtxnQkSHfNLFChARuXfNE1C35htwXuJdGA5pt88aLuZATfaLyL88OsMelcreW+SKZQzifY= X-Received: by 2002:a05:6808:1903:: with SMTP id bf3mr8384470oib.7.1639081992787; Thu, 09 Dec 2021 12:33:12 -0800 (PST) MIME-Version: 1.0 References: <20211209201616.GU614@gate.crashing.org> In-Reply-To: <20211209201616.GU614@gate.crashing.org> From: Marco Elver Date: Thu, 9 Dec 2021 21:33:01 +0100 Message-ID: Subject: Re: randomize_kstack: To init or not to init? To: Segher Boessenkool Cc: Kees Cook , Thomas Gleixner , Nathan Chancellor , Nick Desaulniers , Elena Reshetova , Mark Rutland , Peter Zijlstra , Alexander Potapenko , Jann Horn , Peter Collingbourne , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-toolchains@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Thu, 9 Dec 2021 at 21:19, Segher Boessenkool wrote: > > On Thu, Dec 09, 2021 at 10:58:01AM +0100, Marco Elver wrote: > > Clang supports CONFIG_INIT_STACK_ALL_ZERO, which appears to be the > > default since dcb7c0b9461c2, which is why this came on my radar. And > > Clang also performs auto-init of allocas when auto-init is on > > (https://reviews.llvm.org/D60548), with no way to skip. As far as I'm > > aware, GCC 12's upcoming -ftrivial-auto-var-init= doesn't yet auto-init > > allocas. > > The space allocated by alloca is not an automatic variable, so of course > it is not affected by this compiler flag. And it should not, this flag > is explicitly for *small fixed-size* stack variables (initialising > others can be much too expensive). > > > C. Introduce a new __builtin_alloca_uninitialized(). > > That is completely backwards. That is the normal behaviour of alloca > already. Also you can get __builtin_alloca inserted by the compiler > (for a variable length array for example), and you typically do not want > those initialised either, for the same reasons. You're right, if we're strict about it, initializing allocas is technically out-of-scope of that feature. So, option D: Add a param to control this, and probably it shouldn't do it by default. Let's see how far that gets then.