Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1121862ybb; Wed, 25 Mar 2020 16:21:46 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtqHwBq3oqyKYjB1e03SozdoUHEOhK59wUmd6GznDJXNPcH6tro3xCxgPCjYPGkM+EwMp9Q X-Received: by 2002:aca:3302:: with SMTP id z2mr4363246oiz.3.1585178506127; Wed, 25 Mar 2020 16:21:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585178506; cv=none; d=google.com; s=arc-20160816; b=ykLbG1QB8tkWfQmBGMvSmHwaV5ATohRe+2J5DcgzQKhjKY1g75t+vjo3KI264dEIDV 0pyV9yslkYcX+XA+jvcoGhU1S17a89EUCrS9iyHfjPeEDX+q99/Q8R6GLgh1iAGAYrYa 03xD+rjfEsKZjq9IyHL1fWuyNrkXZM8wn5DEhQrSMNwWmYdZwkU7BJBRslQ5qaVxb+Ts dvTIG4n0yBV8g6QnPDjsHPlD6JIdhh5u8fywyRt4Ac2scwfixWjotANkKaVfS0XhcXUa EcV1LZucgcbZdJ8lSns7W3yRqtWViYRIffVD1mCVbYUbFq/4LNtNOqOqq7T/721+O0yW nTAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=h3mXdOIBxbqqeyxP+0PXoxoXMdv9AQuRrD+qyz/H71o=; b=QRSpz1wnI22elTxATTegDzWcD8kz6/ynE0lJ9JN8N7dL36NHRLXGxdCjED3SiKW2ad t6Fmw7wN59iTBDyTMKL8Dz63rZAbTeHoFBZXjFUBfous1Mk3tGW0tYU0L26CunuIU57p aq/7U6YQb+dpm51M82U98A5sWofJUAc2LjFCihz/ZIeIE/Ns21L864vkRh7Qbc87cH3F GK/m2Iw0HyXjsYDfHv2xfYwI/N8xWluRyg4b2cpnnOgS1+fdDMUvMCtsvtdOwVzLdp2J xU4AqQy7VbdS9xmd2iVUQZP/VQHNMxXMbeTA9/ao4copTN1UzSbdJOfdFmBjprgYEh8H Ua7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="ZM/jTUyJ"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 79si263442oty.232.2020.03.25.16.21.33; Wed, 25 Mar 2020 16:21:46 -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=@google.com header.s=20161025 header.b="ZM/jTUyJ"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727451AbgCYXUt (ORCPT + 99 others); Wed, 25 Mar 2020 19:20:49 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:43682 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727389AbgCYXUt (ORCPT ); Wed, 25 Mar 2020 19:20:49 -0400 Received: by mail-lj1-f195.google.com with SMTP id g27so4412363ljn.10 for ; Wed, 25 Mar 2020 16:20:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=h3mXdOIBxbqqeyxP+0PXoxoXMdv9AQuRrD+qyz/H71o=; b=ZM/jTUyJNrHVVxOxf+9oynRmIW13ku5twP/1npQnFCofNysPZwbL5csUYzSS3+Qonv AuyoCrSZgF9tMzDWcjH4Ayri4cfQUejUxUTkxyf7HhJ85VjFzQAFmcoKFqqeo+1rgLxY r17QyqhpDtYkkDVeBMM0CubiCaAf4Hf+EILg4VmbjWVnQy/TJ6rVYwYESi+/n2fsnDdF xq9WsWLpvdxZGXTru6VrL8sZ0YJ+lliBAv5w6ErmlYsdgQ93PE2Kax7fAjlQHehHFmGZ lbBwJi0eXjXn/OKyNZenxUPLA9V8S40cduQ49rIEHZdvgdvScOcOp6242BXAOfMfk5dn /4Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=h3mXdOIBxbqqeyxP+0PXoxoXMdv9AQuRrD+qyz/H71o=; b=jyit61JjmP0jBewtNaccjQg6Z+Oplrk+EJ3iRSe+0P9/gMox+IcUB/SD5wFrjUBMUa IYJ944ubtKEpSs8zvhTxpmO9CawWcsA98P9Mwi6f1EqXtFbiY8dULyZIU5xzMvoJlFEw UKVYDdWkYzBbqulJJxX3FovCaBFXI/EfeeTKffd+rbm0LcSH1hMSYon65YE3NPw2YSbc XCVAqa+RrG0dAwrOOFKvjoT/YLKDQ2rXkNp7SgRLY0xgRSHE8D2YVEeYVbNu8E2+dxUi dipi4oGSDILOaEam6mfq9OvbOq5E1KeyFb9zEQpPAVive6DR9elIEF7b9jI2FCq6MQb8 Sl9w== X-Gm-Message-State: ANhLgQ2GY6UZrhqIwtnjkmHS6tJdWQ3P7ADcDq0wqne5bGwNcIGUe/Wk xuWZQcM1wqeJ+1UufaSZVbChsSKhBrhyL6W3VenCrA== X-Received: by 2002:a2e:b5d1:: with SMTP id g17mr3279884ljn.139.1585178445467; Wed, 25 Mar 2020 16:20:45 -0700 (PDT) MIME-Version: 1.0 References: <20200324203231.64324-1-keescook@chromium.org> <202003241604.7269C810B@keescook> <202003251322.180F2536E@keescook> In-Reply-To: <202003251322.180F2536E@keescook> From: Jann Horn Date: Thu, 26 Mar 2020 00:20:19 +0100 Message-ID: Subject: Re: [PATCH v2 0/5] Optionally randomize kernel stack offset each syscall To: Kees Cook Cc: "Reshetova, Elena" , Thomas Gleixner , "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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 25, 2020 at 9:27 PM Kees Cook wrote: > On Wed, Mar 25, 2020 at 12:15:12PM +0000, Reshetova, Elena wrote: > > > > 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? > > > > How would you reliably detect that a stack pointer has been leaked > > to userspace while it has been in a syscall? Does not seem to be a trivial > > task to me. > > Well, my expectation is that folks using this defense are also using > panic_on_warn sysctl, etc, so attackers don't get a chance to actually > _use_ register values spilled to dmesg. Uh... I thought that thing was exclusively for stuff like syzkaller, because nuking the entire system because of a WARN is far too excessive? WARNs should be safe to add almost anywhere in the kernel, so that developers can put their assumptions about system behavior into code without having to worry about bringing down the entire system if that assumption turns out to have been false in some harmless edgecase. Also, there are other places that dump register state. In particular the soft lockup detection, which you can IIRC easily trip even accidentally if you play around with stuff like FUSE filesystems, or if a disk becomes unresponsive. Sure, *theoretically* you can also set the "panic on soft lockup" flag, but that seems like a really terrible idea to me. As far as I can tell, the only clean way to fix this is to tell distros that give non-root users access to dmesg (Ubuntu in particular) that they have to stop doing that. E.g. Debian seems to get by just fine with root-restricted dmesg.