Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1102801pxa; Thu, 20 Aug 2020 02:31:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFQROpdIh/JXjLmv/cpWielEnI7VBi3lbS0mfsiu7QU2GmQwlp3RxHW9GgSYW4Ctn8IMB4 X-Received: by 2002:aa7:dd94:: with SMTP id g20mr1950146edv.238.1597915901786; Thu, 20 Aug 2020 02:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597915901; cv=none; d=google.com; s=arc-20160816; b=rN0qVyQHJVeE/QzOLTBmIh7iTHhE8QwcfkM/Ig1Ymgmdz0aHHqmf2f31yDqiVsTAT7 J3NZcx7kSqgpHNhZIlY5NxLRvypylsUfe6hhxWCstX3w8QVm4WfOndKRBPwYaJ3ul3Z5 u6IVZiOM1BaSO5gdSev/SY06PG99m5ur3B7ATzXJ9EOtPfn36NNu2KkcIaPCbiZix/S0 f1iUMe2mAvSyugMxuqdPg7wlg6abvAVUSGMJLiVD4KY6Mic4oARuli2fmVcJVHpPScS/ DmKMRzKufrLsvNUksm3N0yZi3xU5scCFywO8/a0ZiZaNRCbIIPCYvaRFBKZ4BYVbGe8/ tTDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KVg1/0Rr2y7qN1ae6o0JQLt9+4rX6Ui6PDgQk5DVy/k=; b=kbWnvAj21XGPz305x/Psphu2JHhP07awci6wc7c8x2sbIQXfchkeMf0u+qQE7L9o/A cZQIadqfB+2ETpCjC2ZTyBYAbPVWViuGZMdva7EYmsv/Dz16/jfTmjhTQfdb8UNr22L1 N5PzXJGQUbgVeBoTbJN65qA6eSB4ti8KplYX3St9bfSA5AwmIxLWjYoEyYju0VO8BnFx dap7f5RSnbexFjiJtDU9hBoPqR76WjCQn/LEg4ndXU6Bl3zRJY45PYkuzarjWy8qeAAQ FamrXgXYu8lgMGVijgeuyNDF0TrPDZcIzDV+mw2SJdtC5UKdOqYL+Egnu9IsEBqE4/TW kP9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DM11x6Y8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t12si837188ejj.713.2020.08.20.02.31.18; Thu, 20 Aug 2020 02:31:41 -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=@kernel.org header.s=default header.b=DM11x6Y8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727968AbgHTJ23 (ORCPT + 99 others); Thu, 20 Aug 2020 05:28:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:33672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727841AbgHTJ1E (ORCPT ); Thu, 20 Aug 2020 05:27:04 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7609022CF6; Thu, 20 Aug 2020 09:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915624; bh=tnabjO7JEjY1lDcg7PZdz46k5I4+nn34zgqTPaqIAqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DM11x6Y8JQpXhK2Rl6i+8PKmW8odDc4Jp9X/RkjG1cIBT7D+S2/MLXPRNfEZnz19F UYw2PfywfCqN0G/T7bapyW7nfL1ir+LzOJI0TinyvB7YHZw+O6sC1KiLZG/nhl9koM XQVmgzqvZ+TYGja8XcQ7NHbNDgWhb+ucUVHGaGPA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Brauner , Christoph Hellwig , Sargun Dhillon , Jakub Kicinski , netdev@vger.kernel.org, Kees Cook Subject: [PATCH 5.8 061/232] pidfd: Add missing sock updates for pidfd_getfd() Date: Thu, 20 Aug 2020 11:18:32 +0200 Message-Id: <20200820091615.744240580@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kees Cook commit 4969f8a073977123504609d7310b42a588297aa4 upstream. The sock counting (sock_update_netprioidx() and sock_update_classid()) was missing from pidfd's implementation of received fd installation. Add a call to the new __receive_sock() helper. Cc: Christian Brauner Cc: Christoph Hellwig Cc: Sargun Dhillon Cc: Jakub Kicinski Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Fixes: 8649c322f75c ("pid: Implement pidfd_getfd syscall") Signed-off-by: Kees Cook Signed-off-by: Greg Kroah-Hartman --- kernel/pid.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/kernel/pid.c +++ b/kernel/pid.c @@ -42,6 +42,7 @@ #include #include #include +#include struct pid init_struct_pid = { .count = REFCOUNT_INIT(1), @@ -642,10 +643,12 @@ static int pidfd_getfd(struct pid *pid, } ret = get_unused_fd_flags(O_CLOEXEC); - if (ret < 0) + if (ret < 0) { fput(file); - else + } else { + __receive_sock(file); fd_install(ret, file); + } return ret; }