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=-8.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 24B49C43331 for ; Wed, 25 Mar 2020 23:20:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B52B520714 for ; Wed, 25 Mar 2020 23:20:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZM/jTUyJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B52B520714 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1F7416B000A; Wed, 25 Mar 2020 19:20:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1A76B6B000C; Wed, 25 Mar 2020 19:20:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0965A6B000D; Wed, 25 Mar 2020 19:20:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0022.hostedemail.com [216.40.44.22]) by kanga.kvack.org (Postfix) with ESMTP id E5B2B6B000A for ; Wed, 25 Mar 2020 19:20:47 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id ACB65180AD80F for ; Wed, 25 Mar 2020 23:20:47 +0000 (UTC) X-FDA: 76635456534.16.match29_4119ae084980f X-HE-Tag: match29_4119ae084980f X-Filterd-Recvd-Size: 5202 Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Wed, 25 Mar 2020 23:20:47 +0000 (UTC) Received: by mail-lj1-f193.google.com with SMTP id t17so4425579ljc.12 for ; Wed, 25 Mar 2020 16:20:47 -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=IO7eKfHi1uK1XAN0Bdci7PawjFwXyH06rPfARG6yW5SXI6AunIzZA/va/roP1w05mm H79MGbHNq4XVhpLdacnBs22TaxGcII/4mQyVBjMiEhe8Wz+sam25eUzKV/1Vcjw4YYRE RwcDiUlX0A7UhJU1GwwZQt3MFNapH3ZTj6tYrBcYN3iNBLRH1Ytch0JWUeRxWwggUxRG vMiSZoLD4Uf5ZvRpDz1g7es2dL3JysCXAl2XrZKJ0bW4FZbsclWERP8v3jlgs/Ktx+ez /VHSGDivMDidkZRUc94WBhcrJ+KnYFRNIrDmWc+zcrX0s7DshB1Dr48OB684ARrSND5K Y3SA== X-Gm-Message-State: ANhLgQ3PfgNAN//MV+IdQpYs2IRbOWBjcA9P8dm+JcK5y90JCfSi8nt2 fEk6TwW0y1CX6lRyLuZQUgkANDhex+EaMAaR6c5ILA== X-Google-Smtp-Source: APiQypKvrgnwc8js63C8N+zp0rmTpf4QKnXvTcIJYOznDtakeHU4hmQ2qW9tl4eaWWYwNL8tBGg+KWaWzxXvkE+1NWA= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.