Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp798651ybt; Wed, 17 Jun 2020 14:26:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzt4yTA5HFIIpaLSW4/TWsLunFTnuKkSyHdDTWlJ3ZUwFzsiXJttx8sUynDehhWhbEqmFC X-Received: by 2002:a05:6402:1d84:: with SMTP id dk4mr1181362edb.22.1592429211542; Wed, 17 Jun 2020 14:26:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592429211; cv=none; d=google.com; s=arc-20160816; b=YhFAG9VcakFF9xt2C8VxJ2VPpS2x4GPNVR6umrU64ffmVCjN2ytGjmNIj/gJzCp3dT qjr6LUt1LS9WRaN5qyQob5aEw2msmTuCKYOlB1ZwN4dS0f5HnsudxjRvtfFuh3+AnOCx h0Fyi7d5eMlSJfy5pkieOzsA4xp/sh2ggrstsn6hIpOlbFc1LlFm671D9OJz4bxAuMMw pz1OqHky4Y7/2d0KZMLssQBHSZgk3a3d1B/nveXQI9tBuC28PVd0VSOjMTX3mT/7vL// N22eED3B/qWbPKdSvCpcgSWP67YDtp+LUwlFJs0qMBChfAXb4+6fXYGOis+WXxx6VA6D B9ww== 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=10p96XOHb93iqxdsMtM/iXJsZQXP+bBYNuuroRQsAf8=; b=ZayB1YWA6KMzJpvM/bTGDeTbZPdBiVZ5T1ziFqQ9E/Y9ruASidxSRbNHsXXzDR0wEH JJfb0z8lpLpjK6B8f21EeBezh1vE4JIcfhawGpmYYwHt38CRTR8KtWZXcg5jq825qwFB 9sbLm2Mv6gzW3VlBhCEuj4oeMyImDB3xo0U0ptozPu8V6CXzk5HVXYmQn8E5lakB9Jt3 gABJsAZulq6ixc/NgoSZLQREglvKN/fMRQgfIfeE2o4y4wjtfzgQ2GeIrWKk9JnrWqZI vZY1028jFW0LTA/wrwYfOwg0n8zZeNgjT/NU/xtipj5AThqWfB4mzqQfgpODgcnLw99C GC2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MWN8cZ9R; 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 ss2si625227ejb.1.2020.06.17.14.26.28; Wed, 17 Jun 2020 14:26:51 -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=MWN8cZ9R; 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 S1726920AbgFQVWT (ORCPT + 99 others); Wed, 17 Jun 2020 17:22:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726853AbgFQVWS (ORCPT ); Wed, 17 Jun 2020 17:22:18 -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 8755EC061755 for ; Wed, 17 Jun 2020 14:22:18 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id d4so1903413pgk.4 for ; Wed, 17 Jun 2020 14:22:18 -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=10p96XOHb93iqxdsMtM/iXJsZQXP+bBYNuuroRQsAf8=; b=MWN8cZ9R5il23Sphk7/cpwDrjsrTR/+kkUhvqrDrigcLgNYhYnRJGvBWABWzskO8YK +fVFuJalBPUahrMWh8uCBsyPDo8OkrkT409WrBkWm++NCgvhsa5DtrkOWHPCUY905Gwr shxLSwAth2+Jg/yZQd8sSxszCwbxMiolkIV4E= 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=10p96XOHb93iqxdsMtM/iXJsZQXP+bBYNuuroRQsAf8=; b=YllD8OME1q7pqWjcHfSNk/jGpia5t5Lh7GdlNO2DiMUasPsdkgEQYWNVTnebZUnGMw uEjiJGG6vEbk6nqUZgpiyEBtJmkU/sTqu1KjGCb+835AIa6IYLCSe/tAkMVuTXdSVPqv QxBSkJUPHAu38CQP+FXc/cgq5WLWv0a58DvgAk4BIffprXPxDYvJPhDFpOz2PHus3VL2 Ulq9mQG4pXZHbP2Y/hqrapr7/ir3ATos39+EZHLpAiNrtay7mGy88Hxwan8aGC4lVKgl fH5Xt7q3bggt4lO4wobRwJLrT3BFts25KIYmiQ014zgKunar5O/7CehtNULFcy0IyPLa sMkg== X-Gm-Message-State: AOAM530g63+ZzKBG+olluV/6tzfrF8n+hQkCIsaoIE2+MHSYHd0SNwED tH26YwZgTjK6iFBVd+Vxvwuzrw== X-Received: by 2002:a63:1617:: with SMTP id w23mr685649pgl.248.1592428938121; Wed, 17 Jun 2020 14:22:18 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id l134sm648777pga.50.2020.06.17.14.22.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 14:22:17 -0700 (PDT) Date: Wed, 17 Jun 2020 14:22:15 -0700 From: Kees Cook To: Nathan Chancellor Cc: Sargun Dhillon , containers@lists.linux-foundation.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, christian.brauner@ubuntu.com, cyphar@cyphar.com, jannh@google.com, jeffv@google.com, palmer@google.com, rsesek@google.com, tycho@tycho.ws, Matt Denton Subject: Re: [PATCH v3] seccomp: Add find_notification helper Message-ID: <202006171420.C8007EDCD8@keescook> References: <20200601112532.150158-1-sargun@sargun.me> <20200617200844.GA12976@Ryzen-9-3900X.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200617200844.GA12976@Ryzen-9-3900X.localdomain> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 17, 2020 at 01:08:44PM -0700, Nathan Chancellor wrote: > On Mon, Jun 01, 2020 at 04:25:32AM -0700, Sargun Dhillon wrote: > > [...] > > static long seccomp_notify_recv(struct seccomp_filter *filter, > > void __user *buf) > > { > > - struct seccomp_knotif *knotif = NULL, *cur; > > + struct seccomp_knotif *knotif, *cur; > > struct seccomp_notif unotif; > > ssize_t ret; > > > > I don't know that this should have been removed, clang now warns: > > kernel/seccomp.c:1063:2: warning: variable 'knotif' is used uninitialized whenever 'for' loop exits because its condition is false [-Wsometimes-uninitialized] > list_for_each_entry(cur, &filter->notif->notifications, list) { > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > include/linux/list.h:602:7: note: expanded from macro 'list_for_each_entry' > &pos->member != (head); \ > ^~~~~~~~~~~~~~~~~~~~~~ > kernel/seccomp.c:1075:7: note: uninitialized use occurs here > if (!knotif) { > ^~~~~~ > kernel/seccomp.c:1063:2: note: remove the condition if it is always true > list_for_each_entry(cur, &filter->notif->notifications, list) { > ^ > include/linux/list.h:602:7: note: expanded from macro 'list_for_each_entry' > &pos->member != (head); \ > ^ > kernel/seccomp.c:1045:31: note: initialize the variable 'knotif' to silence this warning > struct seccomp_knotif *knotif, *cur; > ^ > = NULL > 1 warning generated. Eek; yes, thank you! I've folded the fix into Sargun's patch. -- Kees Cook