Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp831337ybm; Fri, 29 May 2020 13:18:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkRMqVyaxdg6MlzTBtPUVQR1pBhrDDnj/nDheeoy013RZuSiGwW32yPiy6ck5pYM7tBTsX X-Received: by 2002:a50:9b0f:: with SMTP id o15mr10393602edi.325.1590783483049; Fri, 29 May 2020 13:18:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590783483; cv=none; d=google.com; s=arc-20160816; b=NIp5SaIm69xtINLaapQ4Rx6hykMkKIKBjpOfYQTYK1PAdCMZZXI14ZsYtiJBnbQo9Q nrRulDj4KhEA6JtMpPhpDK9W76KkEi3Sn6sxO4jF2PlRbQrIWN36zaDNmmXChDiyM3rt kvVhU8RJyRt5WfZKMmLnSa0sS9wQEw8EEEwJ6YFsZ58AlwSh6o6RREPjTP2Z3W59v02m 2xvvVFPHxoa3IYtLGKa1LJcKrd9CyCDJGpeIEEuoT9jD6nQEDd1D/y6aais8qhYMgLNr 3/Skcuh++lSY+bH0EOSYSzprLWqC+88Iq7MwtpuG5p56MeSInY2syB5WOAY1HxlSWWV3 /GUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=43C+pRXNPgAMVhwiYz5UucFsjABxpoowLodbLHMi21k=; b=ta5QxYy4nkpQHkV6LDT9pLibdWn5DIZ1U8jb7wZtpK6f6uW3qLhSPyX41zBb7AeY8x qjyzczRnejtBD1+yo7lLOQ8ZagnRAD1pKOdzFbubI/idpDmuIzpIE7e7Qc5pkE6pOBv5 P+l38N1Np2rw3WLLnG+JvTv+zsQfFJ9svQrRO/5X1t9GfGS0v3tskNJf/f8w5SVW1FR/ RVV9F3cYAtECAQm5ecVLWzFOd0JgXuzt9M5+igmtweBb/Zk1eZmN+yu1Yota/FF2OlOi fq79l4uefXaGowJ4Ihm5iliyW6drYLMWG9ty3hch5YBSWOOPeenFC/MbWgrb7VwfwAVD SRJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aTOw0dCA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f25si366860ejf.743.2020.05.29.13.17.38; Fri, 29 May 2020 13:18:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aTOw0dCA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728227AbgE2UPD (ORCPT + 99 others); Fri, 29 May 2020 16:15:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728188AbgE2UPA (ORCPT ); Fri, 29 May 2020 16:15:00 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BF65C08C5C8 for ; Fri, 29 May 2020 13:14:59 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id m7so1686817plt.5 for ; Fri, 29 May 2020 13:14:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=43C+pRXNPgAMVhwiYz5UucFsjABxpoowLodbLHMi21k=; b=aTOw0dCAP9TME+W+TRoQL9YN6hlr+OudY32PgYQij21goUWVujpoJSdGyYQ2kyfXS+ K+q0YyKlvL/XkAkGMI5cr510tpa9WL2c1mUlF9MDv92RyRJHQEiSa56RQ7GDzwUt0rQ1 Uy8zXnbc6tLhqq80hAPAhNq8pY/LCfCFYH8yA= 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; bh=43C+pRXNPgAMVhwiYz5UucFsjABxpoowLodbLHMi21k=; b=XaMcIa9qXXHPONt2M6JL6GqVk9m1V9jcZlHS+PlaNDG18gK23RkZoz19n8+7uvsLui KIx3dCDwt+VcljtwOyk6hclV+PqMW5qnBwJie4ocq4BxFqcaHguBkxxKsOjHxJ89zTg4 yA8ZdADR+ZACtNS6lCbvo47XrJrPhqJhSMAm33Ix+MA3B8Uzgn/UJWVlL8LqX9VS8qzg gykXvksTc2RJpW1ijOC6C3ez79/NZ3QqgW1lwjIicQM0KRbH6ywdHQKqLUPLRvwIVCx2 fgDPAaqBqab7h3C6sc85/bp+sZeURoDrtfOm6DCVIPI0MY09sWNxNDwv7KbZfJQuorIG OQjw== X-Gm-Message-State: AOAM531aEw3DWRP1f7ZHCXd7riXo4iyTVGvm/oi35BBeALaOPJ1brRPa pIx7kFPRUmC1JVONID2Mr+ZRoWrh/4Htwg== X-Received: by 2002:a17:902:aa88:: with SMTP id d8mr10342437plr.257.1590783298799; Fri, 29 May 2020 13:14:58 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id bu7sm261872pjb.41.2020.05.29.13.14.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 13:14:57 -0700 (PDT) Date: Fri, 29 May 2020 13:14:56 -0700 From: Kees Cook To: Sargun Dhillon Cc: christian.brauner@ubuntu.com, containers@lists.linux-foundation.org, cyphar@cyphar.com, jannh@google.com, jeffv@google.com, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, palmer@google.com, rsesek@google.com, tycho@tycho.ws, Matt Denton Subject: Re: [PATCH v2 1/3] seccomp: Add find_notification helper Message-ID: <202005291309.6183EC0604@keescook> References: <20200528110858.3265-1-sargun@sargun.me> <20200528110858.3265-2-sargun@sargun.me> <202005282319.2BA6AD88@keescook> <20200529174037.GA11153@ircssh-2.c.rugged-nimbus-611.internal> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200529174037.GA11153@ircssh-2.c.rugged-nimbus-611.internal> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 29, 2020 at 05:40:38PM +0000, Sargun Dhillon wrote: > > > > While the comment is good, let's actually enforce this with: > > > > if (WARN_ON(!mutex_is_locked(&filter->notif_lock))) > > return NULL; > > > I don't see much use of lockdep in seccomp (well, any), but > wouldn't a stronger statement be to use lockdep, and just have: > > lockdep_assert_held(&filter->notify_lock); > > As that checks that the lock is held by the current task. /me slaps his forehead Yes. I need more coffee or something. Yes, I meant lockdep_assert_held(), and now I need to go fix my pstore series since I confused myself into the wrong function and using it so many times in pstore overwrote the correct function in my head. Thank you! > Although, that does put this check behind lockdep, which means > that running in "normal" circumstances is less safe (but faster?). Now, that's fine. The check needs to be "am *I* holding this mutex?" and I don't think anything except lockdep can do that. -- Kees Cook