Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp298557pxx; Thu, 29 Oct 2020 02:59:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw+wEEmF1D4eCFqEzyAH9nsLuzBWrT3H5Q+V2u6MwuPnmitIuG1EZZHuc3aQutPqmVNBul X-Received: by 2002:a17:906:ecf4:: with SMTP id qt20mr3075523ejb.131.1603965572056; Thu, 29 Oct 2020 02:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603965572; cv=none; d=google.com; s=arc-20160816; b=P3iu+LmUDu50WUsTf2dAl0NGUikwy6gL1GBZZ4+iLi7qNZRXhwWVB9nca7i0gtRR5h 6rbZZmIu9vef2QE4WJR/fVqQwv37yFbzSJEoBml0MfEHNQVKwz3N7wi2A3r2SfOhHcET XHu+/8ZtyDXHxD4cSDezh6SGxZNA7vrkHeQHy9lvbqxTkUvbj8o01H2nGg1IFqLeeJvi 350/OJpTvTng5kUaIzvytLeFclAkEMeTh3fANI0kTiUN9LA6MnmG4YqZe2DCEEXmGTq2 RtL7qXgySXW2ajv+AJYtZxFihsxokDTLlbsEePLsJTIvHCJgnmGaKnH+b/K+VB9MznjE V9zg== 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=0Xy/2zadYFsZw40LFEtdOiEBtCWDHEhIZKqPxiXGDgo=; b=RrcCR3lt1ZJnP5c9xHzHh/tgqdcUtMPw7Xi9rFCu3cfegr8R5WkLkIOphFImTkJF7/ qUKLeFvxn6t8ukKdaEfIoJnG3mSfbgvfCCTIMxVxE5h+ckQjsTS/xjD9r2VA3o4xBJlo JXvleiYTkGX1ahYdqxyBxyYxFdzUXtHPm9+CsxE4Ebs3tSLDNWTL02RdsDlKjTeRbnZx 90xGGs8y1C/zTYjAQQhhmDEwlyAz+NA2SfPEsDkPMpfMNuM5jVNpokxUPgmeHsnopfEn JelDQ/BlVioXzE72L2T+CMQDD8uOzlqUICW/iEH7Rl6A8FpfhsWCMbXDGUPQHOZyVFjQ 5ZVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=bBaojgDC; 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 e12si1439791ejr.549.2020.10.29.02.59.10; Thu, 29 Oct 2020 02:59:32 -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=bBaojgDC; 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 S2389700AbgJ1WxI (ORCPT + 99 others); Wed, 28 Oct 2020 18:53:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733228AbgJ1WxH (ORCPT ); Wed, 28 Oct 2020 18:53:07 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2829EC0613CF for ; Wed, 28 Oct 2020 15:53:07 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id e7so664917pfn.12 for ; Wed, 28 Oct 2020 15:53:07 -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=0Xy/2zadYFsZw40LFEtdOiEBtCWDHEhIZKqPxiXGDgo=; b=bBaojgDCytTeCZe09Aniv5ZCo9/1FqsTT/3OVeHNHiQoo0VRsUJwEEF+dAKR8keSyL yRWbSBM9isY011JSCr6qCTcRwh2CYocjn/3k5iQI8Ss/5A/CGKTOriZdbyXDN2ys6BHT tIbkFOOYefNeoQ0CJz/hUYR7ERPfwa7Bx6B6I= 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=0Xy/2zadYFsZw40LFEtdOiEBtCWDHEhIZKqPxiXGDgo=; b=kxb8wLbjsXKlYWQds7wAie7epWqlcR7QDVZKGk1LYTaC5zxleVHBwgZ3+XZtTGkjYf RgCN+FMqfx5rWVNPRI+5pygHWqRJhuu2gLdQLKHYogQB/Hh31aPNaLbP1nqt2nLWA/fv rEyhGJ2Me7+eC1I2LGk476kjmVqFIGBGRZHpoy2p9QQWT/o3qZSKHq6C5E/W8yo2o3s1 CkMhrJjJcRQjrFwZsJhGmiV8DXLZXCCZEp8R1AvKEpYkVyfHp9IoB14VOx8lAXMNGOuW gFhf6Ws4Fcqa2TAlvPrK3tqX8864QaP5InVJ8jMbU9zSs7W/Rrknfsf5eK/WzYpKMrwy hdEQ== X-Gm-Message-State: AOAM533sB/yXELr9aWjykxhaDtv03eHfHSKS7cafArNtLYJpw1sqnVnH FuUB2i0zOMBzETYeNasmaC2JQA== X-Received: by 2002:a17:90b:90d:: with SMTP id bo13mr1086316pjb.111.1603925586677; Wed, 28 Oct 2020 15:53:06 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id l7sm465074pja.11.2020.10.28.15.53.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2020 15:53:05 -0700 (PDT) Date: Wed, 28 Oct 2020 15:53:04 -0700 From: Kees Cook To: Jann Horn Cc: Tycho Andersen , "Michael Kerrisk (man-pages)" , Sargun Dhillon , Christian Brauner , linux-man , lkml , Aleksa Sarai , Alexei Starovoitov , Will Drewry , bpf , Song Liu , Daniel Borkmann , Andy Lutomirski , Linux Containers , Giuseppe Scrivano , Robert Sesek Subject: Re: For review: seccomp_user_notif(2) manual page Message-ID: <202010281548.CCA92731F@keescook> References: <45f07f17-18b6-d187-0914-6f341fe90857@gmail.com> <20200930150330.GC284424@cisco> <8bcd956f-58d2-d2f0-ca7c-0a30f3fcd5b8@gmail.com> <20200930230327.GA1260245@cisco> <20200930232456.GB1260245@cisco> <202010251725.2BD96926E3@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 26, 2020 at 10:51:02AM +0100, Jann Horn wrote: > The problem is the scenario where a process is interrupted while it's > waiting for the supervisor to reply. > > Consider the following scenario (with supervisor "S" and target "T"; S > wants to wait for events on two file descriptors seccomp_fd and > other_fd): > > S: starts poll() to wait for events on seccomp_fd and other_fd > T: performs a syscall that's filtered with RET_USER_NOTIF > S: poll() returns and signals readiness of seccomp_fd > T: receives signal SIGUSR1 > T: syscall aborts, enters signal handler > T: signal handler blocks on unfiltered syscall (e.g. write()) > S: starts SECCOMP_IOCTL_NOTIF_RECV > S: blocks because no syscalls are pending Oooh, yes, ew. Thanks for the illustration. Thinking about this from userspace's least-surprise view, I would expect the "recv" to stay "queued", in the sense we'd see this: S: starts poll() to wait for events on seccomp_fd and other_fd T: performs a syscall that's filtered with RET_USER_NOTIF S: poll() returns and signals readiness of seccomp_fd T: receives signal SIGUSR1 T: syscall aborts, enters signal handler T: signal handler blocks on unfiltered syscall (e.g. write()) S: starts SECCOMP_IOCTL_NOTIF_RECV S: gets (stale) seccomp_notif from seccomp_fd S: sends seccomp_notif_resp, receives ENOENT (or some better errno?) This is not at all how things are designed internally right now, but that behavior would work, yes? -- Kees Cook