Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp283264ybm; Thu, 28 May 2020 23:26:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKg19uJ+Nz8P87264RWGJTCPp0d87i/fZz0FDVcgdFl7i4jPPpgQ/nWEbLS4Sdd+HcFYEL X-Received: by 2002:a17:906:e247:: with SMTP id gq7mr625028ejb.107.1590733575434; Thu, 28 May 2020 23:26:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590733575; cv=none; d=google.com; s=arc-20160816; b=UbsyPfwFTxZC2XvS3FfU3e1fRRu/a+p5QruMOfTK3Jm0TK3DGFjgD+gfndOZd75dDj 8c7JqtBWjn+H9uk0OHRa6dG5S7SaEam9aj+6M11ePMzSEg8I4VdaLe6kc10xgrhey6Jz XENct5NEOY9AZoumNXQxLuuaC8q98ErDK+O2dpNGrhxVhYgwfqsigiAWJCeLp1GU+Wd7 WQSVqHgIehYyx5KrQeDcrOEL+lf3o0t7xBqaM4PchZr1kqYJR0JywrMNhezem5hT2A4X C/xJUhoezmKPd6B/w0juECtBZKAfbGtslvsk6Ckl+EovjeEMpBN+A+nGbZ0hkbCRfGZ4 NJbA== 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=PLlzkiwXyPhTxGzF5jit/MYyFaQFHEK70UOxhdZtI5c=; b=ONWsyM2u9LFsLEiT5QrrRJ/EVrSeo7cDMn+PbZWM2dljdq4R/k5t3PpEItaP+L1iuu yVzkgd64BGKN98rlDmdoUCklHmudUqAmnsVlQ8+gLynZ3r3qLZSr9QL0Q6f1diiTq76T KPILGG0/N2OBJR3cKQ780+Em6Gd+aJZsOeU3/UCEcGJEQNfk5QWsBUbnQ0yR8NjjSbM4 iWXsaw2F2ONLss4Jvbbp0E1+ji8O0pf9GBRmgXd7BlPjd2F/uXmwWsRaf0SazlVITBfH CBPQtecl2ziGPIA/vBNG+1SOl309RvdH5xm/oxx8KLP38ZwS2hompsOHYxymlyTAbBSp RZFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Z+miJH9w; 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 l88si51394edl.376.2020.05.28.23.25.52; Thu, 28 May 2020 23:26:15 -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=Z+miJH9w; 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 S1726013AbgE2GXg (ORCPT + 99 others); Fri, 29 May 2020 02:23:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbgE2GXf (ORCPT ); Fri, 29 May 2020 02:23:35 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A90AC08C5C6 for ; Thu, 28 May 2020 23:23:35 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id m1so926978pgk.1 for ; Thu, 28 May 2020 23:23:35 -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=PLlzkiwXyPhTxGzF5jit/MYyFaQFHEK70UOxhdZtI5c=; b=Z+miJH9wcmdbU95F6BDxKYteYwdab0eN8L8nETOEWCZVZZkW/rEUMocD7CBb32c701 +tvtXMfOsTo334hqVXhONy+LvqQVhhTXZsO687J+Q9ZN5YA/JpPBLheEW1OiKccEOBAm vPkQd9q4H4UVJRPmuBCp1vYnRBwFiVgn0mC/0= 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=PLlzkiwXyPhTxGzF5jit/MYyFaQFHEK70UOxhdZtI5c=; b=KhHInm2JM+7IKxfj8pDl40MCuksQOgCi6dq/KEyKCKgF8Irh0raV5dsDiEWDJ4XXpk DUZE132HZ8NP/MuzhGowSnbEOrAmrIDSnLUx6s5EjMfvh7eLyYRE8r4OER40InU/av3Z 8qUnfIzwjOQUJ8Fgl0+Wyxp7FCCrgyVvNT7eY+oLyOooOJEx2WMssWe2pBqYvOfdpr/i kWKNdyZs3C+HOwcq9+gqYeXiDiLIFLf/dC2cHbPa16wf9XfGR/xZ3b1OzRS+VBSukvZe VVxodeYuk387SbkBJuiufOHxnzYXv5l9MLs9ec0sejIww//Gbgf+NEozhd2XJltcNJD+ GKgw== X-Gm-Message-State: AOAM5318b6IsLueYfDx0C9fFTIBzPhgN34jq8ziPFKpRF17EPY0qpawf 7XtGsHYWQLqHq0HVv5MtcmmE9Q== X-Received: by 2002:a63:ff07:: with SMTP id k7mr6136004pgi.449.1590733414728; Thu, 28 May 2020 23:23:34 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 67sm6415128pfg.9.2020.05.28.23.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2020 23:23:33 -0700 (PDT) Date: Thu, 28 May 2020 23:23:32 -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: <202005282319.2BA6AD88@keescook> References: <20200528110858.3265-1-sargun@sargun.me> <20200528110858.3265-2-sargun@sargun.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200528110858.3265-2-sargun@sargun.me> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 28, 2020 at 04:08:56AM -0700, Sargun Dhillon wrote: > This adds a helper which can iterate through a seccomp_filter to > find a notification matching an ID. It removes several replicated > chunks of code. Nice, yes. I was noticing this redundancy too while I was looking at notify locking earlier today. One note below... > +/* must be called with notif_lock held */ > +static inline struct seccomp_knotif * > +find_notification(struct seccomp_filter *filter, u64 id) > +{ > + struct seccomp_knotif *cur; While the comment is good, let's actually enforce this with: if (WARN_ON(!mutex_is_locked(&filter->notif_lock))) return NULL; > + > + list_for_each_entry(cur, &filter->notif->notifications, list) { > + if (cur->id == id) > + return cur; > + } > + > + return NULL; > +} Everything else looks good! -- Kees Cook