Received: by 10.223.176.5 with SMTP id f5csp2265995wra; Mon, 5 Feb 2018 00:48:35 -0800 (PST) X-Google-Smtp-Source: AH8x226vlLDaYxd7rn/6WEvr9iYSm8aqvn91bH126P+MpTLQ+Y0uCnYjhPLX6Ee208Vy7lf56pBn X-Received: by 10.99.167.15 with SMTP id d15mr38134601pgf.408.1517820515468; Mon, 05 Feb 2018 00:48:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517820515; cv=none; d=google.com; s=arc-20160816; b=ciNtAKq7qQutF8WLw2TdhunCVSDWHkYDZzIY9woQbTu0eojWCkGBDezytAcd53oJDB uHeW5Ge1fMPH8eo3xR++J7/6I5XC0a07HDPAfAGEE2yS/VJ6ZfM+mmxEgsT9S0R2/5n8 DItCZjQqEkEL0XrK48wmOGXquvV7YCv/JDsZBLTq1bhENwHoXwKeE365P+kKYClVfvmX VoNSzG9XNRO+eMjCW9zHajL4hG27RSOffY0kgj0xldAWnjAIfuxY5IivDy1eGWno7CeO 38P8eg381nJSA5go7avttODa7ISQMClLk0m2/r4hOeaA6fsOI0djiuTLCt6LnLRrDAMa LuSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=q64tR7ySEWrluJpSqRv+UzV1q/OArTqw1VZhMGbP/sc=; b=EgEO4G71ifbYUSZGkHK2dPQgA2nW0mbkhY/wZxARMMMcPyT38hjOYjgq81LoyRoNU0 DmO39rk/qLhNvnGH3NCK7nnC1Rl+Xi1vKUiQJXWiSyx5UeNX2w+QrcpzqizULLKbE2Lt FKBO3FK+6utz58NzAy5cuUWZQcEPJ8EsqJjwUMxDOMmA5BPTPnF+ANCjAn76x5Y+HHvI xroRszliNSVE8WfkaG/5LYSV9gH4niALyapxRarNv/v4a6EpyDXVJHRRxRxqkW3XoVEm pWmBVZepNxDafLDXLsohB9Xhl2sFmvMeFWVFy+6tr3CRHD92ShsKx9OVzYuvee2I5TnN 6yzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=m2x4AzJy; 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 c24-v6si4328059plo.608.2018.02.05.00.48.20; Mon, 05 Feb 2018 00:48:35 -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=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=m2x4AzJy; 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 S1752654AbeBEIrs (ORCPT + 99 others); Mon, 5 Feb 2018 03:47:48 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:55069 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752195AbeBEIrk (ORCPT ); Mon, 5 Feb 2018 03:47:40 -0500 Received: by mail-wm0-f68.google.com with SMTP id i186so24359506wmi.4 for ; Mon, 05 Feb 2018 00:47:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho-ws.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=q64tR7ySEWrluJpSqRv+UzV1q/OArTqw1VZhMGbP/sc=; b=m2x4AzJyHAi1+/vb7+2ZLhzzqATwzdsayrZd/BBINDcdLO05X1/zSJH0xzCVzXXdQB ssTQE6R6b4n/+NkEa3mCNBzF+kFTYbWE140mHbi6iBWw5bpSdTmENBLgQ/Dxpp0JKQg0 MYV8hFyGVkhDnvLMR/Fr81ibvImIruUOLXF/oNuzA0tkUR8aJr+K32zGyJNVI8jepM50 sFvOvAHMt7UUTe41m0hokyiiQHne2bDqH9/s1229B3nstQiLU9GuTMRWt0/WMYAFVMYZ +zBPMZorEu6Dw5wrotvqFC0JEv/F5O4boeRbNRuOsc6PjShLwggO0c1E6FbVnhy+aKGp J2sg== 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:user-agent; bh=q64tR7ySEWrluJpSqRv+UzV1q/OArTqw1VZhMGbP/sc=; b=Wmw6Y3ZvGLPhayVWIHzMqM3dIC896VMp010m8P2XMy4zkzAP/0hXAbJBA0oqeWpQmv 6qxkADwBzM4MRgoK2VGHOysTYNLBRm2yWWLn9vUwjgYxcZpZ/qNV36shbX2nDdyxWuuG jqXgcmrKo0tOetxFShyIqL1mwOKJSHf0BNItQQUDukMsLEY49G8Eayqz8jxUIQuMOHeM eEOjwz9Z9dPNtOtTk0FBeeIjSD5JA5ISl6xzQYi+RINvdOkVUgbUDG4ieA1XAuttwAJM wowETGvAIBjAeP0UnFxMaV0ZsVVLAxojpTKQTMVYm6/NwylQ3ytEwOfnOyy6X5BK8Uy0 y12A== X-Gm-Message-State: AKwxytf4j5Ixum0uPECsh1JwrW3PGeEDZ3G/TR88SYyvN03X+khVsCxE ATs8TUOcWD9KzfvYdS6gmPxeyg== X-Received: by 10.80.146.134 with SMTP id k6mr30884649eda.107.1517820459571; Mon, 05 Feb 2018 00:47:39 -0800 (PST) Received: from cisco ([88.128.82.163]) by smtp.gmail.com with ESMTPSA id g7sm6057504edf.76.2018.02.05.00.47.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Feb 2018 00:47:38 -0800 (PST) Date: Mon, 5 Feb 2018 09:47:36 +0100 From: Tycho Andersen To: Andy Lutomirski Cc: LKML , Linux Containers , Kees Cook , Oleg Nesterov , "Eric W . Biederman" , "Serge E . Hallyn" , Christian Brauner , Tyler Hicks , Akihiro Suda Subject: Re: [RFC 1/3] seccomp: add a return code to trap to userspace Message-ID: <20180205084736.biqc4mflczsix6wm@cisco> References: <20180204104946.25559-1-tycho@tycho.ws> <20180204104946.25559-2-tycho@tycho.ws> <20180204200129.2bgq5yfaimg6xdg5@cisco> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 04, 2018 at 08:33:25PM +0000, Andy Lutomirski wrote: > 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. Yes, fair point r.e. u64. I'll make the change. > > > >> 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. Sounds fine to me, I'll add a check. Cheers, Tycho