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,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 4DF7EC433DF for ; Tue, 9 Jun 2020 18:39:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2EA2A20734 for ; Tue, 9 Jun 2020 18:39:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="muEdWnYf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729556AbgFISjR (ORCPT ); Tue, 9 Jun 2020 14:39:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728470AbgFISjP (ORCPT ); Tue, 9 Jun 2020 14:39:15 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7893C03E97C for ; Tue, 9 Jun 2020 11:39:14 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id ne5so1761296pjb.5 for ; Tue, 09 Jun 2020 11:39:14 -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=oUUlKxLjSlKhbNUJ+/fS04FbBkWKQBhciBLdETtik1Q=; b=muEdWnYfglQpo6mlvoIfHWOj2y/b2HPEYx/I/P/+afdRB9/f6IdVu5VnGI/3lcvXLS I9FafGnjLFcRGiW36DCgnPzai2sfXVCBdgJRXMrqAW3e7b14inpyi/jwHBpjdNDnVDY1 GBTg1KJ1wEa1aW+kWXIDPsZzAOyVi1GSGs3y4= 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=oUUlKxLjSlKhbNUJ+/fS04FbBkWKQBhciBLdETtik1Q=; b=YMAEJmS74IJwOAsA3+GOdgmW3GD6cfKtjV16t8OmgaH8DiYdYL1kSgqCTPZCH6F2cl u5gdPeHrhNxeqDBz2pvcX9mRKENWBdYxf7YcGxISezpmYj/+6VmWG2hCSfWBwAuVJSj6 GM8wFs9bT4hOboyJAI9ygsPUzgtZJyhKusPkMagfF0nyLbUyxTSI3GqysF6V1RMfntcp +2t2bxma1sSpanJABp2Qh6aqBtg/LHwo6Aj3/Aa3WPP/RxQdL/VAEVzETVzQjVTnZ0c9 nUOqe3fyDWMGTspvcxhrD0ZBseKQF7xKbtd2uLFqPGH9rVH8Uq0IoOt/wXPFdghTvD1m WnFg== X-Gm-Message-State: AOAM530GQbd0RLXOA3ndgbPPze9r/1gSoagg4H6nUmHajVsh+qsmIwjj tz40LqvLonoeCOQppM9doCxTNw== X-Google-Smtp-Source: ABdhPJwtO8ctv+axOrlGnu6BhxO/Dmuz6uhavpkS9vfR+Ml1dYIGadDqm0xyQLuzwR4BmnGnulrmGw== X-Received: by 2002:a17:90b:4d10:: with SMTP id mw16mr6182260pjb.143.1591727953613; Tue, 09 Jun 2020 11:39:13 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id u14sm11238034pfk.211.2020.06.09.11.39.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jun 2020 11:39:12 -0700 (PDT) Date: Tue, 9 Jun 2020 11:39:11 -0700 From: Kees Cook To: Alexander Popov Cc: Jann Horn , Elena Reshetova , Emese Revfy , Miguel Ojeda , Masahiro Yamada , Michal Marek , Andrew Morton , Masahiro Yamada , Thiago Jung Bauermann , Luis Chamberlain , Jessica Yu , Sven Schnelle , Iurii Zaikin , Catalin Marinas , Will Deacon , Vincenzo Frascino , Thomas Gleixner , Peter Collingbourne , Naohiro Aota , Alexander Monakov , Mathias Krause , PaX Team , Brad Spengler , Laura Abbott , Florian Weimer , Kernel Hardening , linux-kbuild@vger.kernel.org, the arch/x86 maintainers , Linux ARM , kernel list , gcc@gcc.gnu.org, notify@kernel.org Subject: Re: [PATCH 1/5] gcc-plugins/stackleak: Exclude alloca() from the instrumentation logic Message-ID: <202006091133.412F0E89@keescook> References: <20200604134957.505389-1-alex.popov@linux.com> <20200604134957.505389-2-alex.popov@linux.com> <70319f78-2c7c-8141-d751-07f28203db7c@linux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <70319f78-2c7c-8141-d751-07f28203db7c@linux.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 04, 2020 at 06:23:38PM +0300, Alexander Popov wrote: > On 04.06.2020 17:01, Jann Horn wrote: > > On Thu, Jun 4, 2020 at 3:51 PM Alexander Popov wrote: > >> Some time ago Variable Length Arrays (VLA) were removed from the kernel. > >> The kernel is built with '-Wvla'. Let's exclude alloca() from the > >> instrumentation logic and make it simpler. The build-time assertion > >> against alloca() is added instead. > > [...] > >> + /* Variable Length Arrays are forbidden in the kernel */ > >> + gcc_assert(!is_alloca(stmt)); > > > > There is a patch series from Elena and Kees on the kernel-hardening > > list that deliberately uses __builtin_alloca() in the syscall entry > > path to randomize the stack pointer per-syscall - see > > . > > Thanks, Jann. > > At first glance, leaving alloca() handling in stackleak instrumentation logic > would allow to integrate stackleak and this version of random_kstack_offset. Right, it seems there would be a need for this coverage to remain, otherwise the depth of stack erasure might be incorrect. It doesn't seem like the other patches strictly depend on alloca() support being removed, though? > Kees, Elena, did you try random_kstack_offset with upstream stackleak? I didn't try that combination yet, no. It seemed there would likely still be further discussion about the offset series first (though the thread has been silent -- I'll rebase and resend it after rc2). > It looks to me that without stackleak erasing random_kstack_offset can be > weaker. I mean, if next syscall has a bigger stack randomization gap, the data > on thread stack from the previous syscall is not overwritten and can be used. Am > I right? That's correct. I think the combination is needed, but I don't think they need to be strictly tied together. > Another aspect: CONFIG_STACKLEAK_METRICS can be used for guessing kernel stack > offset, which is bad. It should be disabled if random_kstack_offset is on. Agreed. -- Kees Cook