Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp597618rdh; Wed, 14 Feb 2024 06:19:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV2gJQ97SG1aakIJ+7mtcRJQUB9VyR6H+cCT+o8ge32dKEJPNLghrSuaHnJRGUcHgsDPViMNTjy2sGZCJMGDLa8XvtXaOn5XOzd6j4Bgw== X-Google-Smtp-Source: AGHT+IEzSK+lfiWq8kvzPErTRlzdtstT5+raXAcnqjc17f+3i3UTN7p6ej/f9Th/WZ5GPoOuOjCI X-Received: by 2002:a17:906:b752:b0:a38:5cce:1bad with SMTP id fx18-20020a170906b75200b00a385cce1badmr1945176ejb.68.1707920368674; Wed, 14 Feb 2024 06:19:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707920368; cv=pass; d=google.com; s=arc-20160816; b=FYD3P2SMYOZNPnDASFqlB3TRTeJD1Ykc0oWj+rTHsYm+bEKbCEMbkhAZonqMY74FN9 5zRufoOAofx9pcg52NnbOwG//kydoEQ+nEJguMGlbQK9vwYvYAlznSNsVgTmvTQ4q77l L8dJb2tHVjAcf2Yhy3ROGBbUoX8S7ptQB3j+jcgvjedtDx5R8u1ph33gGP9HANciDbJH xt1jH+4kQMMWMb87/Ra+FxYl/SZ5r4dSE7GErASondHuClM6Btt9rLQtEhaqwihxSLO/ fDtRMYEDopSiyU1LLqJZZi0rGbqhLDxvIikBatR3ANnOUk4WGwYPr35H+IjiH1tr6OC2 Y4iA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature:dkim-signature; bh=6RsiVidSCwBrjsulM6iUvKUYTy+Y7E6NKV1i3zA5qpU=; fh=BWY2K5chemHsL26/RBXWR9xN7TLAixUadLQYfComXDc=; b=lJdGiU8RkYSbsz/umuh52fAQYpoHt+bL3GpdFXnG7DvL5OqMwY/ED3YK/Wq8RhjV3U tczxFUKaLBxJq32RqUux+Ebh8nh4Oh9qKGdU+cuu79o5POcYnTO6HrvIfXALPKemQbOD 0vxXn9jnJxAVBbE7sfsBQZ9Y4qOl50ygqlRIhtdgF5xQGsCSTPbGuChEGRr+97pgdf3o MXDepSv5ABGnIdWnJEPTJuWVezEI5xtj5mUAAIzVd/f+MHsL0UDqKRrGptSW9N4Trt57 Owqf5oFaJgV2diUeztz4e0BeMW3sNxSSUWVpvcoGZWOGkGpBJQXuCTj4JhGn64Hz9F79 SejA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm2 header.b=jeMUyY42; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=In9lxJI2; arc=pass (i=1 spf=pass spfdomain=tycho.pizza dkim=pass dkdomain=tycho.pizza dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-65328-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65328-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCUO8jf24BiaCJkgT37aGDBRjDBIZsmAux9lpQSNxTuz3YFLLBUUibzKTkC67q7dJ1SdGJKkSCy627XYD7t28AHvHdrOUw5Ia7iBnsWv2g== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ne11-20020a1709077b8b00b00a3ce67e23fasi2122053ejc.1033.2024.02.14.06.19.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 06:19:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65328-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@tycho.pizza header.s=fm2 header.b=jeMUyY42; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=In9lxJI2; arc=pass (i=1 spf=pass spfdomain=tycho.pizza dkim=pass dkdomain=tycho.pizza dkim=pass dkdomain=messagingengine.com); spf=pass (google.com: domain of linux-kernel+bounces-65328-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65328-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3D7601F29304 for ; Wed, 14 Feb 2024 14:19:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6317855C0B; Wed, 14 Feb 2024 14:18:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tycho.pizza header.i=@tycho.pizza header.b="jeMUyY42"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="In9lxJI2" Received: from wflow8-smtp.messagingengine.com (wflow8-smtp.messagingengine.com [64.147.123.143]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDE7B29437; Wed, 14 Feb 2024 14:18:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.143 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707920338; cv=none; b=EJGlMsb/fSP6Txs8NAMb5rkSHUdCFplrU46vaFKjAQgzR8FJ36TpvXSl46FRaEk3Fmgr91yKkPVrUzTJOILSUfEmT85YaH+tiYOf8bMjafjIMxy0TxU6KnRMqesFXx1wNJMCcz86hvfF+rhvjbqcBYaxvNYcM1fpKsPehjr8sbs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707920338; c=relaxed/simple; bh=nTl1e8UEmACUyenLLW2iCRqE5C4RtIPrVYx7Rhm8IDk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SEtCKKf6DcQvut6YNr6RnKbKnIJbc/WZP/hZ7f4kMdF+uLyUuIsnbsbq6vQq+a514QEZu9RF6uOPtdUFihatddk62+I17mkQ2TSbiEjn2d+ie325TpaHojexm5cVsckBI08Qo6dlZqfH2Vco27oAnBYtn8QOT8l+D7aRcUhZOWg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tycho.pizza; spf=pass smtp.mailfrom=tycho.pizza; dkim=pass (2048-bit key) header.d=tycho.pizza header.i=@tycho.pizza header.b=jeMUyY42; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=In9lxJI2; arc=none smtp.client-ip=64.147.123.143 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=tycho.pizza Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tycho.pizza Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailflow.west.internal (Postfix) with ESMTP id 03A492CC02D0; Wed, 14 Feb 2024 09:18:52 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 14 Feb 2024 09:18:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho.pizza; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1707920332; x=1707927532; bh=6RsiVidSCw BrjsulM6iUvKUYTy+Y7E6NKV1i3zA5qpU=; b=jeMUyY42CXSJw46CT9NQVglyCM E7RLRhEzcLYi1I8QeUo183E55xwmzqBHWAv4NLTpkqHNnt65+FgnK83oq4qcxz6k q9tCfccKFZgtS5/NeIVLN6QvdeUUo5/r0ZdTWn7KZDtKJpHlq/vo+N/ObHUeLd8P 8WgWL3cwf64GiEdFu7CF/ZCKAf6vELZb8F2CbItzzqIRsO1/IylxcMnb3aI7xy/U 2aoWiUu++SvPfgrwlWr23pu8ZFEhUkmYBtS93SGtb066xY9VYgr1HqvZEPXnT7vZ N0+s2Ykx0GdRHBfceSPdQ+2LIVyEwcbe/qOjhjOJy85ic4Sh2gvFo6yyO2Pw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1707920332; x=1707927532; bh=6RsiVidSCwBrjsulM6iUvKUYTy+Y 7E6NKV1i3zA5qpU=; b=In9lxJI2/qikc/OHPx4USykX8W8PIUIKmbagu2mBdOhB 4bwb/STZdV1WcVFEaHvE8eXeK1uebqXZPyMGrvJeNAtpT592uy6MXOtqk4gEWBVL VdIdDBt0epBzO/tVVljh81LxSYUx8w8VWBFx1eqPyaarXJhGRZt9YL+qMP16VIu5 YjN/q8aPybrdpW8ZJ3KERsmf1jjH3Pq+Z7vKaorOr9uDI5r94YqamyEQBpOTCMAP VntQkstFmpps4gOR/5CnvUV3bss09HnuNFilvIEgId4CTeDN65gowCVrNm+65KUI Iu5nwSVHeudYda0tjSht/962gXyfcTdrufrsfurCww== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudejgdeifecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpefvhigthhho ucetnhguvghrshgvnhcuoehthigthhhosehthigthhhordhpihiiiigrqeenucggtffrrg htthgvrhhnpeeutedttefgjeefffehffffkeejueevieefudelgeejuddtfeffteeklefh leelteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hthigthhhosehthigthhhordhpihiiiigr X-ME-Proxy: Feedback-ID: i21f147d5:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 14 Feb 2024 09:18:50 -0500 (EST) Date: Wed, 14 Feb 2024 07:18:48 -0700 From: Tycho Andersen To: Oleg Nesterov Cc: coverity-bot , Christian Brauner , Nicholas Piggin , Sebastian Andrzej Siewior , Peng Zhang , Ard Biesheuvel , Luis Chamberlain , Heiko Carstens , Andrew Morton , Suren Baghdasaryan , Thomas Gleixner , Mateusz Guzik , Dmitry Vyukov , Tycho Andersen , Mike Christie , "Paul E. McKenney" , linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-next@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: Coverity: __do_sys_pidfd_send_signal(): UNINIT Message-ID: References: <202402131559.B76A34B@keescook> <20240214090332.GA14017@redhat.com> <20240214090640.GB14017@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240214090640.GB14017@redhat.com> On Wed, Feb 14, 2024 at 10:06:41AM +0100, Oleg Nesterov wrote: > On 02/14, Oleg Nesterov wrote: > > > > On 02/13, Tycho Andersen wrote: > > > > > > I think this is a false positive, we have: > > > > Agreed, > > > > > That said, a default case wouldn't hurt, and we should fix the first > > > comment anyways, since now we have extensions. > > > > > > I'm happy to send a patch or maybe it's better for Christian to fix it > > > in-tree. > > > > I leave this to you and Christian, whatever you prefer. But perhaps we > > can simplify these checks? Something like below. > > forgot about -EINVAL ... > > Oleg. > > --- a/kernel/signal.c > +++ b/kernel/signal.c > @@ -3876,10 +3876,6 @@ static struct pid *pidfd_to_pid(const struct file *file) > return tgid_pidfd_to_pid(file); > } > > -#define PIDFD_SEND_SIGNAL_FLAGS \ > - (PIDFD_SIGNAL_THREAD | PIDFD_SIGNAL_THREAD_GROUP | \ > - PIDFD_SIGNAL_PROCESS_GROUP) > - > /** > * sys_pidfd_send_signal - Signal a process through a pidfd > * @pidfd: file descriptor of the process > @@ -3903,13 +3899,23 @@ SYSCALL_DEFINE4(pidfd_send_signal, int, pidfd, int, sig, > kernel_siginfo_t kinfo; > enum pid_type type; > > - /* Enforce flags be set to 0 until we add an extension. */ > - if (flags & ~PIDFD_SEND_SIGNAL_FLAGS) > - return -EINVAL; > - > - /* Ensure that only a single signal scope determining flag is set. */ > - if (hweight32(flags & PIDFD_SEND_SIGNAL_FLAGS) > 1) > + switch (flags) { > + case 0: > + /* but see the PIDFD_THREAD check below */ Why not put that bit inline? But I guess the hweight and flags mask are intended to be future proofness for flags that don't fit into this switch. That said, your patch reads better than the way it is in the tree and is what I was thinking. Tycho