Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp636017img; Thu, 28 Feb 2019 05:32:19 -0800 (PST) X-Google-Smtp-Source: AHgI3Iawl7eRoF7rbELHejQV/mxzeNV+ycd/Fja9NwO4iYgNRsRDhK844hHWkt4bCKl1JYnwq33p X-Received: by 2002:aa7:8c97:: with SMTP id p23mr7590145pfd.229.1551360739151; Thu, 28 Feb 2019 05:32:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551360739; cv=none; d=google.com; s=arc-20160816; b=PQIoHOJngw/ofG6TLBCHAFjx67/nUZbbdfRTuZf8SZrkaz/vukmvWMyO6nZm2qR0Sh 1hvW9tEFV7gVrb19QeHb+rTrrxYCNaeW5cKjRcb7yve/0n77Qk2LCEx9G5JRSuwIbz0L 5v2rXJk9SVz+VEv0tntXVn8tfMEWSd4w4numZigtZ/gq1DywFZBvGwEau6JQVHAPKROB 4Ux2KF0eqgq+5j0EP1LV1imgFeFK5l3nzLknZpeQuUGx+69l9mkfZCEcrpgZLeVnQtGi XDnUmPrL/RduS47O4MM7YBhbpFyVANQFIE6itluZorO6aj2N9xaEJDZho+Vz5xQeALju nPJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:cc:dkim-signature; bh=U0ez6pA4iB0pqG+CBmbvNhiiGJ1LYyk7Fn0cT+9YFOs=; b=t9vZZbX6F5Jdqv+qtRda6tneKCJ5CRhd6wufMnM7XXESgUQi5TCQ68BJ5JAmR/kJYm 2bGb4/Ti3yylReP1DV4WaeoyCuOOzogzV+lCsf7w7GXZFadwAQx/yS6VBLj0QgFg2GZO NlmpPF+B1RrFNNxj1FXDFgPgWeANEIyywlYuznKarhd5snAGFMnY4218bO9bu2O5i98u AlGNZVJy55eoaqOzANCV63CXnol9H81tFOWsumGt2dWr+2yOysn6inz7FPHnt/KX9XuZ A/luRfkZ1fq5ttfP3q5qf/GbPpur2XXmpsmtKkr4vYJ/TiGvbrFeUU+JbVmRd43JYSpT iQGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qK8WjVso; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si17430338pll.175.2019.02.28.05.32.03; Thu, 28 Feb 2019 05:32:19 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=qK8WjVso; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732967AbfB1N0D (ORCPT + 99 others); Thu, 28 Feb 2019 08:26:03 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36118 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732143AbfB1N0A (ORCPT ); Thu, 28 Feb 2019 08:26:00 -0500 Received: by mail-wr1-f67.google.com with SMTP id o17so21972322wrw.3; Thu, 28 Feb 2019 05:25:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=cc:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=U0ez6pA4iB0pqG+CBmbvNhiiGJ1LYyk7Fn0cT+9YFOs=; b=qK8WjVso3l2NLBYQIJWGmgHfSsryWyRVShB3hTrYl3iLkU3A/IUkXw4O2rZdJMl9l/ P3rpk+UJigDJqitA4JC58c5SEZsIT70dDRRnyXIK/ZGsFK1ZSEWNj4YFiIseoW85YZGx JUIhWOenKt+bbkmQyB3pF6rVE6c7kP8lzZznljqFaKA+6zftf+inhtjhKLUbNedHWyky jTULc7De2OpW+nz5jJxllxnDfRu6mpgXXDeafNPtdGiWRs1nMB894J796Elh4UQGo91A cWH/yjeMC6r8gJd6XC5iSx2wXEpnJ6io/0t4QeewEJCxYzNyADKjOkucUvlsnuxZ2Ocb owbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:cc:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=U0ez6pA4iB0pqG+CBmbvNhiiGJ1LYyk7Fn0cT+9YFOs=; b=kd1jrDAyz/9gVXrkMqR+jYuhj9QvI3MtoxQwNCPjpEtxlRwWcOFNi4+rs7vHOghVkW 4zfJAdMe2aoDRaYjcOSW2GsyIhwp2NYut3jhy8AOVJwDD1FpDq8RMkfMFr8sjdZvGTcL oAdWzg0RT5cR+tbVnoCPzknz9sQxZ6OwxU5PQCNFRWZYYiXRzf1OFqB1rk0Ed9t8OSQ9 zXKSZQsCWBcFrkldwCM+/NwO2Bg3CqUWZ1K8eGeJefuHyK2a7LvmH3vByS9x3nyjz7YX +y/npCRoUw6lpn94mUQQex5fUpQe1eZedOzP/KSKnXJnWDpFmrPkjPKTOscOAZDM2FPp tXqw== X-Gm-Message-State: APjAAAX9o0aA15DXwxgvNUaLv+NWfGI50av305L1h00ttWDu5/5++2Wz vYAMcy+Y8btU4PWDyUNSteE= X-Received: by 2002:adf:e80c:: with SMTP id o12mr6120550wrm.114.1551360357814; Thu, 28 Feb 2019 05:25:57 -0800 (PST) Received: from [10.0.21.20] ([95.157.63.22]) by smtp.gmail.com with ESMTPSA id u8sm24978737wrp.55.2019.02.28.05.25.55 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Thu, 28 Feb 2019 05:25:56 -0800 (PST) Cc: mtk.manpages@gmail.com, linux-man@vger.kernel.org, Kees Cook , Linux API , lkml , Andy Lutomirski , Jann Horn , Oleg Nesterov , Christian Brauner , "Eric W. Biederman" , Containers , Aleksa Sarai , Tyler Hicks , Akihiro Suda Subject: Re: [PATCH 2/2] seccomp.2: document userspace notification To: Tycho Andersen , "Serge E. Hallyn" References: <20181213001106.15268-1-tycho@tycho.ws> <20181213001106.15268-3-tycho@tycho.ws> <2cea5fec-e73e-5749-18af-15c35a4bd23c@gmail.com> From: "Michael Kerrisk (man-pages)" Message-ID: Date: Thu, 28 Feb 2019 14:25:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <2cea5fec-e73e-5749-18af-15c35a4bd23c@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > 7. The monitoring process can use the information in the > 'struct seccomp_notif' to make a determination about the > system call being made by the target process. This > structure includes a 'data' field that is the same > 'struct seccomp_data' that is passed to a BPF filter. > > In addition, the monitoring process may make use of other > information that is available from user space. For example, > it may inspect the memory of the target process (whose PID > is provided in the 'struct seccomp_notif') using > /proc/PID/mem, which includes inspecting the values > pointed to by system call arguments (whose location is > available 'seccomp_notif.data.args). However, when using > the target process PID in this way, one must guard against > PID re-use race conditions using the seccomp() > SECCOMP_IOCTL_NOTIF_ID_VALID operation. > > 8. Having arrived at a decision about the target process's > system call, the monitoring process can inform the kernel > of its decision using the operation > > ioctl(listenfd, SECCOMP_IOCTL_NOTIF_SEND, respptr) > > where the third argument is a pointer to a > 'struct seccomp_notif_resp'. [Some more details > needed here, but I still don't yet understand fully > the semantics of the 'error' and 'val' fields.] So clearly, I misunderstood these last two steps. (7) is something like: discover information in userspace as required; perform userspace actions if appropriate (perhaps doing the system call operation "on behalf of" the target process). (8) is something like: set 'error' and 'val' to return info to the target process: * error != 0 ==> make it look like the syscall failed, with 'errno' set to that value * error == 0 ==> make it look like the syscall succeeded and returned 'val' Right? Cheers, Michael -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/