Received: by 10.223.176.5 with SMTP id f5csp1807458wra; Sun, 4 Feb 2018 12:36:55 -0800 (PST) X-Google-Smtp-Source: AH8x225SzNppPFHXRn7XT3mzzgn5hDEK3tF76HtVn4vUs+E62lnaUqm5vykD7CljA1Qeev4EavQ4 X-Received: by 10.99.109.70 with SMTP id i67mr9949685pgc.109.1517776615330; Sun, 04 Feb 2018 12:36:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517776615; cv=none; d=google.com; s=arc-20160816; b=forPhRFJM3x6RiCbVpgkTPl7Bhx09mKUU3S4PKqdIiN7sURIvJrzdFmOrp2YHOMTJx HFUu4Mw60LB5cgci1/a7Ybkjz6DNyP3HlOJWWdRoTH5im8XFwDaodtSok0iLI6PD0H0m AzleSU9a5GKiCTpLtkVXPn4X4288GI08ew+MqIIXJMnOi542OfCyH4LVXLlulTN0XeDq 0rpZ9R2nkBX2C2W/sAZ5FV7QkyYZNK2r7ZL29Anr/XemskcA3bUgMxT9KCTCwhe2iqJk 0fz9v0b/IYTQznRrNVSFX7fCzVMEhajvj8P/XZRWn3V/RNQPrIg1fCfQqzeJswFXVG3L MgGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dmarc-filter :arc-authentication-results; bh=x8lhoNLKWcQYlQ/uQiih1Dq6Hy7wg4Lr2gzRjdA7ntw=; b=l075Kyqq+CCFMon2MQZSBA1n6qAgbgj8kBzdEOZNBm96ZKMd6BXFVA83x8JKCO25Y5 Wx9yjKIudkj+Bb6+9TWFg0ragLLl4CV+o9O//91bexb3XiWrpKhcaCYyYTSe1HmrxQnL kA7ROoSjdcX8R1oC0MLvIRDT3VDdwUV3WH3j+JJ4aPc08dOozdXBZd1DTuxc3uPkO6h8 fic6/fVfOOYzbIdAoL8LOdWJne7pGvMY/B1dPN9F5D09pNE5quQ/vypl93DhBgtorLP/ sPLUNEaBb4VPj/IsCvngXUKFbOmmpyFwBe+AElJK3dEpHZomFHAMcC/FZO+CA4gLEcwe g0sQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z131si2934853pgz.803.2018.02.04.12.36.41; Sun, 04 Feb 2018 12:36:55 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752559AbeBDUdx (ORCPT + 99 others); Sun, 4 Feb 2018 15:33:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:55332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751797AbeBDUdq (ORCPT ); Sun, 4 Feb 2018 15:33:46 -0500 Received: from mail-io0-f169.google.com (mail-io0-f169.google.com [209.85.223.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 33813217B4 for ; Sun, 4 Feb 2018 20:33:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 33813217B4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=luto@kernel.org Received: by mail-io0-f169.google.com with SMTP id f4so28200018ioh.8 for ; Sun, 04 Feb 2018 12:33:46 -0800 (PST) X-Gm-Message-State: AKwxyte/73JNmpJsuJoJZsVMRyB1ZHY/B6XdSLR6Oatd3/BOEq7y7IMQ KlVUYKlJMt0Mxf9hfYP+4hs2WdFCaS39SAsYevSMtw== X-Received: by 10.107.138.20 with SMTP id m20mr52248474iod.192.1517776425432; Sun, 04 Feb 2018 12:33:45 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.137.84 with HTTP; Sun, 4 Feb 2018 12:33:25 -0800 (PST) In-Reply-To: <20180204200129.2bgq5yfaimg6xdg5@cisco> References: <20180204104946.25559-1-tycho@tycho.ws> <20180204104946.25559-2-tycho@tycho.ws> <20180204200129.2bgq5yfaimg6xdg5@cisco> From: Andy Lutomirski Date: Sun, 4 Feb 2018 20:33:25 +0000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC 1/3] seccomp: add a return code to trap to userspace To: Tycho Andersen Cc: LKML , Linux Containers , Kees Cook , Oleg Nesterov , "Eric W . Biederman" , "Serge E . Hallyn" , Christian Brauner , Tyler Hicks , Akihiro Suda Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 4, 2018 at 8:01 PM, Tycho Andersen wrote: > Hi Andy, > > On Sun, Feb 04, 2018 at 05:36:33PM +0000, Andy Lutomirski wrote: >> > The actual implementation of this is fairly small, although getting the >> > synchronization right was/is slightly complex. Also worth noting that there >> > is one race still present: >> > >> > 1. a task does a SECCOMP_RET_USER_NOTIF >> > 2. the userspace handler reads this notification >> > 3. the task dies >> > 4. a new task with the same pid starts >> > 5. this new task does a SECCOMP_RET_USER_NOTIF, gets the same cookie id >> > that the previous one did >> > 6. the userspace handler writes a response >> >> I'm slightly confused. I thought the id was never reused for a given >> struct seccomp_filter. (Also, shouldn't the id be u64, not u32?) > > Well, what happens when u32/64 overflows? Eventually it will wrap. I think we can safely assume that u64 won't overflow. Even if we processed one user return notification on a given seccomp_filter every nanosecond (which would be insanely fast), that's 584 years. > >> On very quick reading, I have a question. What happens if a process >> has two seccomp_filters attached, one of them returns >> SECCOMP_RET_USER_NOTIF, and the *other* one has a listener? > > Good question, in seccomp_run_filters(), the first (lowest, last > applied) filter who returns SECCOMP_RET_USER_NOTIF is the one that > gets the notification and the other receives nothing. > > I don't really have any reason to prefer this behavior, it's just what > happened without much thought. Hmm. This won't nest right. Maybe we should just disallow a user-notification-using filter from being applied if there is already one in the stack. Then, if anyone cares about making these things nest right, they can fix it.