Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1270627imd; Thu, 1 Nov 2018 12:57:42 -0700 (PDT) X-Google-Smtp-Source: AJdET5dGlM4liRa5uZdZYWib2F+KzNa9NTbdduMEQbWHiOnLsN1GwXFHvvTRbLI7CaiK127PKpbY X-Received: by 2002:a17:902:6901:: with SMTP id j1-v6mr8979098plk.26.1541102262266; Thu, 01 Nov 2018 12:57:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541102262; cv=none; d=google.com; s=arc-20160816; b=my8OebmnyTb8gkUZRUQRZuqCEmK6QRhhnsC4lq82Rchjn8D292yiisXCC8yGFiIla8 Gt2TRM29saA+53mK3f81syBybGHaT1KebrqjijySXZIPO1NQn593amEH5JZy+7M8y50z MoQ3cw2xp2GVU6WsA2MWSIiRDN+xwEz3z2zNSe7rbFnOq3szk98SIo24daZwYvH1Mu9V q3JHAjFm0Pqc7mSa0V3vW0mhYqYbFCK7jxLWPvLa8ScFrCe4HlEssSg96mYRp4A6duP9 vEgsUt+NaixKtT9p0r8hEhlc+n9eIV9AA5Cq5Og63fmOzl2LLv6rsmuKN3/o9hsC5Lyb jtoA== 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; bh=w8EX9DyP27t+5ZTQBjl2uq3Kd+oOoLjCwILy/qKcEyM=; b=uUK7juwYpJyPCILirMgnFkHqDWEhENCSkFECG3Z8BqF/queACAuW5wwX189jgE769l vIiUn+w29BnLBaFjbBZLFmP7PrpO4y/ZJhyhbN4Ow1NSwd01LsVqjdKPlbqxQtUcu2KF v/L3P5KB6Gs7C/ZbQDmZKQluXu7cKi/MuaJh8LKGL7ZOJ8M1RfaikOv0uBSAJ16Xx2UC lx1B1XruuBGOVUTS1am9lRJ+fDkiqYVOtHVMYNbzEwKMmtuE8MGkRfH9+2S2E8j7yRHg teQJ5MPWG86iIeZHNcZzC53T6iJrwu0noZCsojPCKqF5jXzDhHyn8mOse5Tw3W3SjhP5 tu+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b=Irc4MEGr; 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 t21-v6si31550218pgg.123.2018.11.01.12.57.14; Thu, 01 Nov 2018 12:57:42 -0700 (PDT) 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=Irc4MEGr; 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 S1727001AbeKBFBE (ORCPT + 99 others); Fri, 2 Nov 2018 01:01:04 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:37898 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726602AbeKBFBE (ORCPT ); Fri, 2 Nov 2018 01:01:04 -0400 Received: by mail-qk1-f193.google.com with SMTP id d19so2733471qkg.5 for ; Thu, 01 Nov 2018 12:56:40 -0700 (PDT) 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=w8EX9DyP27t+5ZTQBjl2uq3Kd+oOoLjCwILy/qKcEyM=; b=Irc4MEGrFFGw28hQ9UE41MsDyB5UdtJkEEu9r4l5sJJxYMxrAZ956EXsEhNFHDq+qF fo4YOm1NM0ckkS2HI5gyd209ULwZaAvFhoIMz3i/eW1ycZTtkcporOzbM5SW3DhFsoTQ dIDGBkSMPIJpcjfMG0mK0D2gxZRsKDBPXllQKYzWDTqkGjYeMBGEvtg16fIdoXOeVsCC 80f66AgkXTWw7h07zXdavq4oK3wbNI5aZOLpDQBOotER5UupDR4ao8WdD4kMFn/iAlon fdCVejtA8dNklgP2eZWt7+boajTdlcJX2FDO3MlyZ6RU5q1MS3uyb7S9WlwOKE4PyRQK MvzQ== 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=w8EX9DyP27t+5ZTQBjl2uq3Kd+oOoLjCwILy/qKcEyM=; b=gbnqcoDFe39RsPnDXN5Vy9o8fKqjDiFJuKcoN2L/Blce4QaU+kcPOw/6C71I5P62O0 yCOUYp/xTFgfgZ9uSeXdeQ1/met9piVuniwMejzgLikD299SxE6I1BDzohKE60LtXTbq DhTujwmA3qfo4CyBwOZ4tVvPIygvHH++yaQHTXmM1RUVevxaMWTtGqBTB/9vkqmjilcw kebxUp/efXlUyo1KAxd9rOmgl8M4EGJ+dfxxiDPrFQTDEh859i2/KnY5QaU41JGDx90O lRpxtBvSw8Y8u/+9vh5EYZygywzMJhDwMCsZOQ8286V4c4hWwhBEQQSnnLJ4Heltp7pJ ZrWg== X-Gm-Message-State: AGRZ1gIP6jWCN4C/PoFGD8KLy6j4ICtEizVeAjbjtQZHjWFtyJsByXKc Znsq4FebfuIUYZNrZNLrPPue0g== X-Received: by 2002:ae9:e901:: with SMTP id x1mr7278669qkf.332.1541102199398; Thu, 01 Nov 2018 12:56:39 -0700 (PDT) Received: from cisco ([173.38.117.87]) by smtp.gmail.com with ESMTPSA id g2-v6sm19145365qkf.91.2018.11.01.12.56.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Nov 2018 12:56:38 -0700 (PDT) Date: Thu, 1 Nov 2018 13:56:35 -0600 From: Tycho Andersen To: Oleg Nesterov Cc: Kees Cook , Andy Lutomirski , "Eric W . Biederman" , "Serge E . Hallyn" , Christian Brauner , Tyler Hicks , Akihiro Suda , Aleksa Sarai , linux-kernel@vger.kernel.org, containers@lists.linux-foundation.org, linux-api@vger.kernel.org Subject: Re: [PATCH v8 1/2] seccomp: add a return code to trap to userspace Message-ID: <20181101195635.GG2180@cisco> References: <20181029224031.29809-1-tycho@tycho.ws> <20181029224031.29809-2-tycho@tycho.ws> <20181101134001.GA23232@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181101134001.GA23232@redhat.com> 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 Thu, Nov 01, 2018 at 02:40:02PM +0100, Oleg Nesterov wrote: > On 10/29, Tycho Andersen wrote: > > > > +static struct file *init_listener(struct seccomp_filter *filter) > > +{ > > + struct file *ret = ERR_PTR(-EBUSY); > > + struct seccomp_filter *cur, *last_locked = NULL; > > + int filter_nesting = 0; > > + > > + for (cur = current->seccomp.filter; cur; cur = cur->prev) { > > + mutex_lock_nested(&cur->notify_lock, filter_nesting); > > + filter_nesting++; > > + last_locked = cur; > > + if (cur->notif) > > + goto out; > > + } > > Somehow I no longer understand why do you need to take all locks. Isn't > the first filter's notify_lock enough? IOW, > > for (cur = current->seccomp.filter; cur; cur = cur->prev) { > if (cur->notif) > return ERR_PTR(-EBUSY); > first = cur; > } > > if (first) > mutex_lock(&first->notify_lock); > > ... initialize filter->notif ... > > out: > if (first) > mutex_unlock(&first->notify_lock); > > return ret; The idea here is to prevent people from "nesting" notify filters. So if any filter in the chain has a listener attached, it refuses to install another filter with a listener. But it just occurred to me that we don't handle the TSYNC case correctly by doing it this way, and it's not necessarily obvious to me how we can :). So let me look into that. Tycho