Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7614785imu; Mon, 3 Dec 2018 16:11:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/XggseYtvjYroN98GEuxRL+wTAEKKNgrUhLPMg0Z9gO6YyOGmeSFdoBRBF5UQ7+VY1tjXH/ X-Received: by 2002:a17:902:2f03:: with SMTP id s3mr17541950plb.277.1543882266321; Mon, 03 Dec 2018 16:11:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543882266; cv=none; d=google.com; s=arc-20160816; b=McQkWqbSHhT5C2TSrcK7Q+k4gYmbKHUW1BY16+S4ApdN25f1AmX+ft2Qdw499Yp//n b2TDhY+4re9CXRiaaSOhviMhavqBq9JQ77KTG0Rkap2GBwNrqWGzCWP5NZqZsmViPs22 JzqOytekrvF+H8CRbLU2M8tWbaBrERJOEWTyMODoN/vO/m4ZVQiI/QpsD5ZIFgL6nDc6 uXiTqgLlKheKKZIG3pkcMFeYk+6mmbOqKpMSIL3qvH3ml8yV7cmwsQTUYYAQ8ckMdevB NtoYCXeAo6ByGpFriVZ5OEDCvxlwwh90rJFvGYCeGP21qDw+M+qvkeJEz+6sF+bGnPmV oqeg== 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; bh=1U9m6CPIsevtqAJhUV0/6xKvVLDOf292xf2UN64dhIw=; b=FrdVpQwyY2DC6boEH8+u74VN38gbg0NM9Rvnn0FYar5rpp1F+nOm2iPuCwgBF2Af+O hbTtGF/pzNn8k44ld1YnBhLfMC/YAUhgmtcLG1fo0nMByS7+G0m2fEjvwW7OTlpZ6CxO 6rHr8LcUBHy8rXkCMic6sRLooLMLxXmyrybY0Ntsq9FIu51uTEgYw1LHqWCdLPci5Abo arvS/HnxrqAqt74pnRskk/qKpudIyES5UP+rZ7sh/gv4btm21ypSdRJpxraxqB6UO9Bn LUP+IexycnnXdYLHUgwLoOWDF1brnSwgzxcvK8O3/VkGVUpsPHBaIdDbBZ0C31Zke1i6 n4dg== 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 ca19si17609000plb.238.2018.12.03.16.10.51; Mon, 03 Dec 2018 16:11:06 -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 S1726073AbeLDAKM (ORCPT + 99 others); Mon, 3 Dec 2018 19:10:12 -0500 Received: from mail.hallyn.com ([178.63.66.53]:40792 "EHLO mail.hallyn.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725903AbeLDAKM (ORCPT ); Mon, 3 Dec 2018 19:10:12 -0500 Received: by mail.hallyn.com (Postfix, from userid 1001) id 06F7B964; Mon, 3 Dec 2018 18:10:09 -0600 (CST) Date: Mon, 3 Dec 2018 18:10:09 -0600 From: "Serge E. Hallyn" To: Tycho Andersen Cc: "Serge E. Hallyn" , Kees Cook , Andy Lutomirski , Oleg Nesterov , "Eric W . Biederman" , Christian Brauner , Tyler Hicks , Akihiro Suda , Aleksa Sarai , Jann Horn , linux-kernel@vger.kernel.org, containers@lists.linux-foundation.org, linux-api@vger.kernel.org Subject: Re: [PATCH v9 3/4] seccomp: add a return code to trap to userspace Message-ID: <20181204001009.GA8796@mail.hallyn.com> References: <20181203032827.27978-1-tycho@tycho.ws> <20181203032827.27978-4-tycho@tycho.ws> <20181203052650.GC31406@mail.hallyn.com> <20181203155211.GB3504@cisco> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181203155211.GB3504@cisco> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 03, 2018 at 08:52:11AM -0700, Tycho Andersen wrote: > On Sun, Dec 02, 2018 at 11:26:50PM -0600, Serge E. Hallyn wrote: > > On Sun, Dec 02, 2018 at 08:28:26PM -0700, Tycho Andersen wrote: > > > +struct seccomp_knotif { > > > + /* The struct pid of the task whose filter triggered the notification */ > > > + struct task_struct *task; > > > + > > > + /* The "cookie" for this request; this is unique for this filter. */ > > > + u64 id; > > > + > > > + /* > > > + * The seccomp data. This pointer is valid the entire time this > > > + * notification is active, since it comes from __seccomp_filter which > > > > define 'active' - is a notification in state REPLIED still active? > > Yes, > > > Actually while looking at that, I came to wondering - when are knotifs > > freed? Seems like only during seccomp_notify_release(), i.e. when the > > tracing task stops polling for events? Is that going to be a problem? > > Or am I misreading this? > > they're stack allocated in do_user_notification(). So "active" in this > sense really means "somewhere in do_user_notification()". D'oh! I see, thanks :) > > > + if (ret == 0 && copy_to_user(buf, &unotif, sizeof(unotif))) { > > > + ret = -EFAULT; > > > + > > > + /* > > > + * Userspace screwed up. To make sure that we keep this > > > + * notification alive, let's reset it back to INIT. It > > > > Is keeping the notification alive the right thing to do? > > > > If userspace has messed up in something this touchy, it seems unlikely > > that it'll to better if we give it a do-over... I'm not sure whether > > killing the whole thing (victim and tracer) is the right thing or not. > > I suppose we could do that too. I just didn't want to get into a > situation where the notification is lost and the task is stuck because > userspace screwed up here. Yeah, that's probably best - I'm just trying to see whether there is any way that this could be abused. My underactive imagination hasn't come up with anything yet. -serge