Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp923769pxb; Wed, 29 Sep 2021 12:37:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzseBrrK+mLvq+ZUBMYjMWy8c3Hsahtn06MQZa6w30F1Pwf7aaVw/091fKjKbV4x11q3xFp X-Received: by 2002:aa7:c78f:: with SMTP id n15mr2137483eds.338.1632944225960; Wed, 29 Sep 2021 12:37:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632944225; cv=none; d=google.com; s=arc-20160816; b=vdnu6pXWuBO+GOdjvdhZUtVllHgOc+iunjqvUBkLCC7sftZN1mNn96H+cPJ9TKGFW+ zDDAhs1hKCULhsV4DVXZpMtZIt1LltnHCHvjTfnDdyusEHr4wL64Y4vK1WkoaG4IFEgF bsX40Wy5WB2jCW3rOdlzRRP3aruEFfXrf0o0CP+/Y8llH8XEbs0TfxMGginGoFmf87XM YYH468WBHQnB3bGO+etJ/+0+Vy6Uy9Bbic+bYpzHQUiUdLYyTlmmRXFjPQh5quNTtesh 0iEs2UNf/OBFnCk4wCtjjmAQrJm409E2J3adq/s8tP/RiEWewNT4imMMz+YZQI8YBeMS IySg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8+uJcBBc/PF7ems2z5fw4m588jWE79HAklefzm/UZpA=; b=wA/QBkyU1GOuBhvX93OSizsOST/g/qq1UBQSxY8WUxD/BTN7UIIAq5lNjgqlGezqPQ jmxSDEXX8Z52ae8Z9/cKAKhMr4ECZmzL1e1R1MuuUMxOUWQq9v6AHXrFAicUOanTTLVz vraptL6hKdA59Zj0ZRxBXhPC07vb5ien70QfjoFxy4nkTTrG/TQhsh8N7oefTBrQ4pfg PGgrggC4dGbM73yor2JZoHLTtKFxeWJau27zYDPSEGAHHmT2iyKVPrGjCKdpqLVfm8gK QfJHXiNtevawbT3chdcPm06q/pnEJRlr2AyI55+x6GEcu1WIpx5M9BsUh6N04Q4M/6bA y7LQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jUKnSXoA; 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 y5si932208edu.73.2021.09.29.12.36.41; Wed, 29 Sep 2021 12:37:05 -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=jUKnSXoA; 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 S1346366AbhI2S4j (ORCPT + 99 others); Wed, 29 Sep 2021 14:56:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346078AbhI2S4i (ORCPT ); Wed, 29 Sep 2021 14:56:38 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8648BC06161C for ; Wed, 29 Sep 2021 11:54:57 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id k23-20020a17090a591700b001976d2db364so2777080pji.2 for ; Wed, 29 Sep 2021 11:54:57 -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=8+uJcBBc/PF7ems2z5fw4m588jWE79HAklefzm/UZpA=; b=jUKnSXoA0hVODkS6t3osdG2XYk+v1gSULRVbnIZ9NcZh4ZpOliivKVPuRpp/UlzKhh AbAGzhdYgAFxFcXd7rtQC4jDpvDc26ThZ27hDgqIxJg/E3s6vOblrrvcj45Gi0/6cPpw q2WLquH9eoGvFWwMXjEu5YoLIYzPRTV+vvS4w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8+uJcBBc/PF7ems2z5fw4m588jWE79HAklefzm/UZpA=; b=hEL3NKbJC2OzNe/mQykvpjWKLoRLCESstqv5i3uyD/kWFCOCKsG0tcyFNltNFP9wA9 tf1MIOZJ6I41z6CaF5Kf5PR7mTZE0d1IqA5++Eq0qUU048k2em2ZcJzgr+35KcdnovBb FgZ44k5WK39UhvHHO7HvLGfQIBHBki08poxSVvqhtGN1/9YjaJ4G4VuEPRDhEa29DfSs RbhC2LjpxpNTMxDBAva6DpR641QseDWRcBoYo9eu44Dk4mK50lx6EmJPvDDtYlpD4V76 E8UUIRYp8kr+09gK72ZbsYafuZgalNSy8qgedMu7zj79rJbjZm+da8YLT8r75qItuQ61 1qXw== X-Gm-Message-State: AOAM531kvBoTXTLK2wZ/z8grwR/J9Lz6lcDnAdnNqHn5rr2d6thJqyEe 54R/UeMqQGBFzGJOtmmQvA6mhw== X-Received: by 2002:a17:90a:304:: with SMTP id 4mr8095556pje.124.1632941697076; Wed, 29 Sep 2021 11:54:57 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c206sm480031pfc.220.2021.09.29.11.54.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Sep 2021 11:54:56 -0700 (PDT) Date: Wed, 29 Sep 2021 11:54:55 -0700 From: Kees Cook To: Josh Poimboeuf Cc: Mark Rutland , Vito Caputo , Jann Horn , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jens Axboe , Peter Zijlstra , Stefan Metzmacher , Andy Lutomirski , Lai Jiangshan , Christian Brauner , Andrew Morton , "Kenta.Tada@sony.com" , Daniel Bristot de Oliveira , Michael =?iso-8859-1?Q?Wei=DF?= , Anand K Mistry , Alexey Gladkov , Michal Hocko , Helge Deller , Dave Hansen , Andrea Righi , Ohhoon Kwon , Kalesh Singh , YiFei Zhu , "Eric W. Biederman" , Qi Zheng , linux-kernel@vger.kernel.org, x86@kernel.org, linux-fsdevel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] proc: Disable /proc/$pid/wchan Message-ID: <202109291152.681444A135@keescook> References: <20210923233105.4045080-1-keescook@chromium.org> <20210923234917.pqrxwoq7yqnvfpwu@shells.gnugeneration.com> <20210924002230.sijoedia65hf5bj7@shells.gnugeneration.com> <202109231814.FD09DBAD3@keescook> <20210924135424.GA33573@C02TD0UTHF1T.local> <202109240716.A0792BE46@keescook> <20210927090337.GB1131@C02TD0UTHF1T.local> <202109271103.4E15FC0@keescook> <20210927205056.jjdlkof5w6fs5wzw@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210927205056.jjdlkof5w6fs5wzw@treble> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 27, 2021 at 01:50:56PM -0700, Josh Poimboeuf wrote: > On Mon, Sep 27, 2021 at 11:07:27AM -0700, Kees Cook wrote: > > On Mon, Sep 27, 2021 at 10:03:51AM +0100, Mark Rutland wrote: > > > On Fri, Sep 24, 2021 at 07:26:22AM -0700, Kees Cook wrote: > > > > On Fri, Sep 24, 2021 at 02:54:24PM +0100, Mark Rutland wrote: > > > > > On Thu, Sep 23, 2021 at 06:16:16PM -0700, Kees Cook wrote: > > > > > > On Thu, Sep 23, 2021 at 05:22:30PM -0700, Vito Caputo wrote: > > > > > > > Instead of unwinding stacks maybe the kernel should be sticking an > > > > > > > entrypoint address in the current task struct for get_wchan() to > > > > > > > access, whenever userspace enters the kernel? > > > > > > > > > > > > wchan is supposed to show where the kernel is at the instant the > > > > > > get_wchan() happens. (i.e. recording it at syscall entry would just > > > > > > always show syscall entry.) > > > > > > > > > > It's supposed to show where a blocked task is blocked; the "wait > > > > > channel". > > > > > > > > > > I'd wanted to remove get_wchan since it requires cross-task stack > > > > > walking, which is generally painful. > > > > > > > > Right -- this is the "fragile" part I'm worried about. > > > > I'd like to clarify this concern first -- is the proposed fix actually > > fragile? Because I think we'd be better off just restoring behavior than > > trying to invent new behavior... > > > > i.e. Josh, Jann, do you see any issues with Qi Zheng's fix here: > > https://lore.kernel.org/all/20210924062006.231699-4-keescook@chromium.org/ > > Even with that patch, it doesn't lock the task's runqueue before reading > the stack, so there's still the possibility of the task running on > another CPU and the unwinder going off the rails a bit, which might be > used by an attacker in creative ways similar to the /proc//stack > vulnerability Jann mentioned earlier. Since I think we're considering get_wchan() to be slow-path, can we just lock the runqueue and use arch_stack_walk_reliable()? -- Kees Cook