Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1299pxb; Mon, 2 Nov 2020 12:13:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJyyoNgME8E2/Df9iLqdTt314VsdhaVwHFnL+DEwX6vwguoVL80sO+q6e8XhsxX5UcGIP8rD X-Received: by 2002:a05:6402:1cb2:: with SMTP id cz18mr2793542edb.388.1604348028599; Mon, 02 Nov 2020 12:13:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604348028; cv=none; d=google.com; s=arc-20160816; b=MJ+m67bUes1so26COBrJ719euwueQXedsgKrZw6vfWLhwZ54GMwXN2gX0Gru2FGNyu baWgefBd6V+LD07XEB2tSStsJ6wYkimfAOgNbFXMW1AkPjrnbNFITD45doe5Qs5ZZ9Kq CSCLTBGI8Z1ZmJSe6v2SmGtP1LQqcR6a1nw2WmLjyDI6t+8gRiLsrUHi+nhBtC9MRCza RhIWMf8NaUmxnmTSH4TXO6SpTc9apnLVH1tCc2fLPh289evA9SoIg5MIYXioOjbBhIcz HsUBM/7pSpNM28lTrmaPjBPwTQlTjnz370i0PelZSjgA77DKEU5VDh///82n2RcOyY5o Plsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SygJ0YMRNg3kRA+P+/o9DS9VAcEeWET+xfXo18MSK8w=; b=M8WObhddqjA02UuJGo8Qe/8Ju1Zw9wpbvKSeBbd90tL+RK01bU1HN4wk5OThlS6K+t HGTGMcFdFpFZWteXKs39MefnTsoIIV9QrLmXGeAiIBSvlXjyCrWUSfbwQU/QfpivV+9Z 5IzFdcQ8kXslWxZlQY0vdKthPKYy9f8CnnNAZoZnCjtTyJ333usVAqd8KxRGqKYp8aVd oA1KamanC/G85U+utmpzK0zHQGEOhe6n7AWT6g7kFwKdPlUxbY2SdgHqWdfKgbMJlnj4 YZ7j6b+ySg2M4Y+j47JRfsWBvNAIxH/QBzjSm08V6PdA43V+pO2D4QD3zvMZymRbjh51 W9yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=IenDEOwc; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bq7si10762637ejb.212.2020.11.02.12.13.25; Mon, 02 Nov 2020 12:13:48 -0800 (PST) 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=@google.com header.s=20161025 header.b=IenDEOwc; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726020AbgKBUEv (ORCPT + 99 others); Mon, 2 Nov 2020 15:04:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725806AbgKBUEv (ORCPT ); Mon, 2 Nov 2020 15:04:51 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E187C061A04 for ; Mon, 2 Nov 2020 12:04:50 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id b1so18993596lfp.11 for ; Mon, 02 Nov 2020 12:04:50 -0800 (PST) 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=SygJ0YMRNg3kRA+P+/o9DS9VAcEeWET+xfXo18MSK8w=; b=IenDEOwcE7acdWlt3upinLTTJLqi4UdRIK+PzIcZHwuf5PctnsoAcu0L8yOZf6HI57 vlaLdkuBhc5qdDVb0YDoMMcI+rHBUzP1McRaXIovcqGA3X5wyw0sq1O9rJjQTyvAFkj4 861P7yLhcvBsg8AEdFaV57Edi1EdHZvsLJOIhT0vSnbaUEmhGJo+AL4jNz0rqo8af+d7 cYAj0ZM/aUC4Y3Lce948K0l4awqBXzXiDZrI1AgyGl4zivZne7XLXGpiLRjzEdn9aDzo 98Kq0yEKIoz8niqnACP7ZZTeuT7fEmNkLrHA5ATKyJZvfX9PycBSL5wJNWljhEo8JtAX fcFA== 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=SygJ0YMRNg3kRA+P+/o9DS9VAcEeWET+xfXo18MSK8w=; b=lu6y3WRKf5w6JDCjsaQi2uCjpqAFWiiwDWvkBav9ulS8LjXk8O+qeT0yUxaCeUD/kc TE76HDdofO1ipf+VsqULuDAKMIJRjdlX+aukUDCXo1nAWd9f4v9DDR2ZpZRjhjyBiN6X 79HlBurz5lKDeyv8Fkftf3PjGsWLkk1hSE2dUw1m4tudwHFDhZyMUgaKYMUH7XUbw4HB NNhQEpUmLrTWo7eRVXmJLivBZb26JesyYFt3L9VjDGAZ6wrsXpbVh37W0Cts/oN5JKUU ZKC/qf3hg3XOf0TTm17YFABx3iolf0zFx/Mn1BSgkruhEzReZ06y4AibN6AdFyTqmEvR ECkw== X-Gm-Message-State: AOAM530b2jNUNW9KkPwzdNj/YJl+MN04usW96ctC/N/iBuab53lQlqcS EohaHtoLYEGgQyMcTIWG0nk34FkzURIjE7Mszw211A== X-Received: by 2002:a19:c357:: with SMTP id t84mr5844550lff.34.1604347488712; Mon, 02 Nov 2020 12:04:48 -0800 (PST) MIME-Version: 1.0 References: <63598b4f-6ce3-5a11-4552-cdfe308f68e4@gmail.com> <20201029085312.GC29881@ircssh-2.c.rugged-nimbus-611.internal> <48e5937b-80f5-c48b-1c67-e8c9db263ca5@gmail.com> <20201030202720.GA4088@ircssh-2.c.rugged-nimbus-611.internal> <606199d6-b48c-fee2-6e79-1e52bd7f429f@gmail.com> <964c2191-db78-ff4d-5664-1d80dc382df4@gmail.com> In-Reply-To: From: Jann Horn Date: Mon, 2 Nov 2020 21:04:22 +0100 Message-ID: Subject: Re: For review: seccomp_user_notif(2) manual page [v2] To: Sargun Dhillon Cc: "Michael Kerrisk (man-pages)" , Tycho Andersen , Christian Brauner , Kees Cook , Daniel Borkmann , Giuseppe Scrivano , Song Liu , Robert Sesek , Containers , linux-man , lkml , Aleksa Sarai , Alexei Starovoitov , Will Drewry , bpf , Andy Lutomirski Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 2, 2020 at 8:50 PM Sargun Dhillon wrote: > On Mon, Nov 2, 2020 at 11:45 AM Michael Kerrisk (man-pages) > wrote: > > Caveats regarding blocking system calls > > Suppose that the target performs a blocking system call (e.g., > > accept(2)) that the supervisor should handle. The supervisor > > might then in turn execute the same blocking system call. > > > > In this scenario, it is important to note that if the target's > > system call is now interrupted by a signal, the supervisor is not > > informed of this. If the supervisor does not take suitable steps > > to actively discover that the target's system call has been > > canceled, various difficulties can occur. Taking the example of > > accept(2), the supervisor might remain blocked in its accept(2) > > holding a port number that the target (which, after the > > interruption by the signal handler, perhaps closed its listening > > socket) might expect to be able to reuse in a bind(2) call. > > > > Therefore, when the supervisor wishes to emulate a blocking system > > call, it must do so in such a way that it gets informed if the > > target's system call is interrupted by a signal handler. For > > example, if the supervisor itself executes the same blocking > > system call, then it could employ a separate thread that uses the > > SECCOMP_IOCTL_NOTIF_ID_VALID operation to check if the target is > > still blocked in its system call. Alternatively, in the accept(2) > > example, the supervisor might use poll(2) to monitor both the > > notification file descriptor (so as as to discover when the > > target's accept(2) call has been interrupted) and the listening > > file descriptor (so as to know when a connection is available). > > > > If the target's system call is interrupted, the supervisor must > > take care to release resources (e.g., file descriptors) that it > > acquired on behalf of the target. > > > > Does that seem okay? > > > This is far clearer than my explanation. The one thing is that *just* > poll is not good enough, you would poll, with some timeout, and when > that timeout is hit, check if all the current notifications are valid, > as poll isn't woken up when an in progress notification goes off > AFAIK. Arguably that's so terrible that it qualifies for being in the BUGS section of the manpage. If you want this to be fixed properly, I recommend that someone implements my proposal from , unless you can come up with something better.