Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp813010ybg; Tue, 9 Jun 2020 13:34:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoGv4JVHl4T6FCigFZ4mMQxRBECXqLRY2I4oQFfKUHBu/0oQ3i3hH0IXFfRRZ3wtKOG8Ii X-Received: by 2002:a17:906:3e5a:: with SMTP id t26mr150312eji.165.1591734867887; Tue, 09 Jun 2020 13:34:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591734867; cv=none; d=google.com; s=arc-20160816; b=MH5KCWV7rCm4H5FJJcuDa22cPGZ1rgwJ7H5d0ZLOdfxdM59LOlC88CziJzid0bjOFv Y9MhEooLxHOCb9CWKiSVwAcEqCHB+ToPmtUl8YTqpqzk7iUp9zf5DoJl2o+heTGKPQlV vF9+vKHxmJ8bVTQy4645PqpgNeR1w512lCtgBZGMqlnvgbvp5wlh6yUeEJDT+AoqDQcv mAGIhPWT+BaGhHF2D8Epo5YxC6v7LdDNO+82fFZNMl8ZlkwkpxoBzpiyk5v3ivWAbSUf LQGDN0N/om21JrRKa3iqOAHeVhWtlLg3EiHa4gRQENkP7zjPKCHYmjtb2J5PAxiVbTC2 jGWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=oUUlKxLjSlKhbNUJ+/fS04FbBkWKQBhciBLdETtik1Q=; b=d8zDsIO9yU1bkU8+EfC5UPpvp7Xz65NuEzvMfP8kJG4w/BxYBepKd4k7qEOzGaLQIE S4ID7GqFzTUf7Tke0L5kW617j7k3jG6CFzM7C6S/Ar+C+4hegcnSCVrri6LvsP0btvId AS9sjeFvUtCWQztDYM7fSw/x9J8qw3vylyUqmWt9TKSha6JJxwL8oBvkCXz31yI5oeJj uHdheEmcNigyEOQzmzAwwvLpg6aWOeHbqKcHXCKVkHxt1S/xsbsHepnruuXD6BNbK/3Q LI+15hNxSIVuosR9yPz4Q+9pAv6G1Y93ci1KtLgNkCg3xEkhkmZ443kGzl/9nkxki6Vh szVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=muEdWnYf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ar22si11795555ejc.434.2020.06.09.13.34.05; Tue, 09 Jun 2020 13:34:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=muEdWnYf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729181AbgFISjQ (ORCPT + 99 others); Tue, 9 Jun 2020 14:39:16 -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-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