Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp44060ybb; Tue, 24 Mar 2020 16:09:02 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtY6k3ZUcfnxd1A29xT40EEn6GzEVn4YqjsemFYVi0ykdCh/tSrDE+ebIHqMHQxoQkRnN42 X-Received: by 2002:aca:da8b:: with SMTP id r133mr477688oig.81.1585091342765; Tue, 24 Mar 2020 16:09:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585091342; cv=none; d=google.com; s=arc-20160816; b=L2ltOFZa4/dYJBv5zPrE2zDRWzWwGlCOOP/Ntu+BiACeW22xsclsvabjacc+4OAPRQ e07r8lGANphI2DRTs9djIWHYRcAht0bJGI9hqulrfppfGxnJt8SG3kOG9sjHoLaCowA9 VADpLe+YM+DdCNouxqfAyUOVH4tJPKBOCmr/gtWFUcA2VuxtbXFmjq1ZEFZNx0seguNs ancsieA/F+yeEnFOcwxLtwMonOaZrWPJuIIBULMZeSU/9wsgt0ORUc/9F+SE1YkDr+6t wwnMxdxo9z5OdkfX2Iufs82SJYx/KOrC67GsWvO/+NlvUssXFfSAJ+PavTP3PJWdBRCT lIqw== 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=hZYGrrYHl0NkyIgc2uGWToFLNVXOPMpm5ALW355x8l8=; b=yW0gTGrsWSSyAbuvOKrX5W9rRTtaKBg0GF/rrJ/iSwBDWon57NPp/Lhq2BQRtwf2Bx Q1PPeqJ7VwKUTnBsTlBo6nRPv6987/oDzdOAwybc9a/s/LI+O7tiAtKCIu8MpuZ1Ik+1 ruGwB3JItZA3TgGqSCUkH2eZ5ZTwRgVOE1TMiQw5VRs8zN59ZPZwIWxEySJSrBqd77rN sfjorNIG9SxTJcjZ/mu/qCpGkrf7pHcGPfEH/mb/kxgfw8FfYchrdB0vAOYXQRIN71Gg aEQiFspj/jLrbvwPmQIh1XqxeutF1U5TIuVu5MpWAKVoUIxYPmljN8qCfqi7YjMZTTbX Qw1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BD55ubdc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id x33si9581808otb.48.2020.03.24.16.08.50; Tue, 24 Mar 2020 16:09:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BD55ubdc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727420AbgCXXH5 (ORCPT + 99 others); Tue, 24 Mar 2020 19:07:57 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43758 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727070AbgCXXH5 (ORCPT ); Tue, 24 Mar 2020 19:07:57 -0400 Received: by mail-pg1-f193.google.com with SMTP id u12so190260pgb.10 for ; Tue, 24 Mar 2020 16:07:56 -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=hZYGrrYHl0NkyIgc2uGWToFLNVXOPMpm5ALW355x8l8=; b=BD55ubdcQFGlrkHGIItP7aQDYlQQqN7BWHznAV/BjGLMmkbrJluW3YXOG3HL/kyDw3 42/9FZDOe8ljg+1CRL8AXZrMCy3hHzGKeh/6wZnm1iCU/d6Aup3GFDglcGpiGZQja3QM Urwx0W7yYX5sK3oS2wzmYSIY/u5xoQbapUf/A= 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=hZYGrrYHl0NkyIgc2uGWToFLNVXOPMpm5ALW355x8l8=; b=deMXV7kJb47gQnHv3r22en6InlxzGwpe9d7M2shui3o2fJMK+UwO553PZIMPzZBvx6 zo+lIdjIo9SMVdVOQZk3Rvq/UicCPyTu2pNUhoztz9hhnYuj3AbFJ2iF81LINHNYcSdD VW5wSq7mLwXaBcH9f0TpC8PrtQsgN00i9eEgFCa+eoqFtYZOaed7nwm5qOavMh9zmITe zYimsk629TT6iKrPVa9dSG+7DHAUEioO8xf0wT+KSaoFaWjjWKa4XAoNeEBZItEeKAur Cp9nz4tDXB6OQTKgN7FANdNcviZlIPSuCJqExoeFdb9eopah2TFCqNbdn3QOhECnojN5 1imw== X-Gm-Message-State: ANhLgQ2TvylJyzHxXIWBCflJRTCJXyy89zD1gFOfrE6VJzRVu9cU4EJQ 4MUIf7wmvMBEiMsoe2WXKEQkZg== X-Received: by 2002:a62:1894:: with SMTP id 142mr151739pfy.27.1585091275699; Tue, 24 Mar 2020 16:07:55 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 11sm16908017pfz.91.2020.03.24.16.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 16:07:54 -0700 (PDT) Date: Tue, 24 Mar 2020 16:07:53 -0700 From: Kees Cook To: Jann Horn Cc: Thomas Gleixner , Elena Reshetova , the arch/x86 maintainers , Andy Lutomirski , Peter Zijlstra , Catalin Marinas , Will Deacon , Mark Rutland , Alexander Potapenko , Ard Biesheuvel , Kernel Hardening , linux-arm-kernel@lists.infradead.org, Linux-MM , kernel list Subject: Re: [PATCH v2 0/5] Optionally randomize kernel stack offset each syscall Message-ID: <202003241604.7269C810B@keescook> References: <20200324203231.64324-1-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [-enrico, who is bouncing] On Tue, Mar 24, 2020 at 10:28:35PM +0100, Jann Horn wrote: > On Tue, Mar 24, 2020 at 9:32 PM Kees Cook wrote: > > This is a continuation and refactoring of Elena's earlier effort to add > > kernel stack base offset randomization. In the time since the previous > > discussions, two attacks[1][2] were made public that depended on stack > > determinism, so we're no longer in the position of "this is a good idea > > but we have no examples of attacks". :) > [...] > > [1] https://a13xp0p0v.github.io/2020/02/15/CVE-2019-18683.html > > This one only starts using the stack's location after having parsed > it out of dmesg (which in any environment that wants to provide a > reasonable level of security really ought to be restricted to root), > right? If you give people read access to dmesg, they can leak all > sorts of pointers; not just the stack pointer, but also whatever else > happens to be in the registers at that point - which is likely to give > the attacker more ways to place controlled data at a known location. > See e.g. , > which leaks the pointer to a BPF map out of dmesg. It was mentioned that it would re-use the base across syscalls, so this defense would have frustrated it. More to my point was that there still are attacks using a deterministic stack as part of the exploit chain. We have a low-cost way to make that go away. > Also, are you sure that it isn't possible to make the syscall that > leaked its stack pointer never return to userspace (via ptrace or > SIGSTOP or something like that), and therefore never realign its > stack, while keeping some controlled data present on the syscall's > stack? > > > [2] https://repositorio-aberto.up.pt/bitstream/10216/125357/2/374717.pdf > > That's a moderately large document; which specific part are you referencing? IIRC, section 3.3 discusses using the stack for CFI bypass, though thinking about it again, it may have been targeting pt_regs. I'll double check and remove this reference if that's the case. But, as I mention, this is proactive and I'd like to stop yet more things from being able to depend on the stack location. -- Kees Cook