Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp156881ybj; Fri, 8 May 2020 08:39:09 -0700 (PDT) X-Google-Smtp-Source: APiQypK4KoT10Wd+va9duoGEdL/E1NxY2vlkhUKRLqr4D7OB1DrU/hIMyUJmQVfLaSPnO3l9raAW X-Received: by 2002:a17:906:355b:: with SMTP id s27mr2388491eja.184.1588952349069; Fri, 08 May 2020 08:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588952349; cv=none; d=google.com; s=arc-20160816; b=qYHMCl+NKswbUJE2lELnl5G1YJdOoRlBmwVhFTA5doVJb5EWW/vID9y93ZWa308WO7 9LlNuX8yv0EmIr704gv/FqUWyxnt+gZHmzRAV8p2V8BeDJaOyJhEgHnJ57VGDd97uN7N Inuf20ddslW39puUGnC6hr+FerY0rG9+T3C7Sj7yPfi0S/+k5Lg9BpzYdoiU8US1L5VG VdaeEfABrTSILi/ou0y+jTCazv72s/RkHuz524Su4m3vRxjAheIGB5nD45XMOsmAGtcv Wl34R4ROI1tNoSavobuBGiMTEzM8kE+CKheoN4uIMdbZ9E+o/inG93+T5W8DFMN6Hm5B WDYg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gdo1CI68NGJpSv9H2lBuA2msCSuabwKNVFFgXf1S+fQ=; b=F/LJRlQ18d+0R73IeoIKGwgcf/9imfbY732Cq2M5AhaetQ53q+Lg1WHbZwJz7ZF9s1 YcoYA1rfn2+pvqBOrNb0aXgXFZOf3iQqMZ3yyvv6Z6EBL940kgCrP85BCduH8f/8ww+Q gnn8qBVP6MqD5CBwzY6ifRYBTeN78iSiVNgE4n68mZ9OGV42lcndkhKZVIvur3vPINTN IPINs6WSOq6hQWbkn8iKGF4Ac9DCfIv+0d3Q1THwSFaiJHNB71xWeVVlM156DuFAD88y iPThnVGpZzaRMVshynw++MnCRMEaTFzMhW8gOMj9E0IrFM3FE1oxYgfQawZ12s0AFC6h D3yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=kXvLegnP; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r23si543142eji.340.2020.05.08.08.38.45; Fri, 08 May 2020 08:39:09 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=kXvLegnP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728201AbgEHPgu (ORCPT + 99 others); Fri, 8 May 2020 11:36:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728050AbgEHPgq (ORCPT ); Fri, 8 May 2020 11:36:46 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AC95C061A0C; Fri, 8 May 2020 08:36:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=gdo1CI68NGJpSv9H2lBuA2msCSuabwKNVFFgXf1S+fQ=; b=kXvLegnPNvMN1Xbz6imxQGM4XM Z8HFAC7hxbTwBWprI5Zanbre5K5ZwnCBBb4002EVizfDHTsu7wogMSR3nHOL7Ph1/16Aya6Jhb4dJ Eux8v6F6qPyHNsXqCoATHO+bgojB6GwUxNrouxkwQPZklS6F4DXUwsKb7vxpKNcraqET5L2x04Rqu nEUOVezhcTYa4Zw/6XTkgLDACTmIpGAZ1rX0Rl5VqNFyF/wKFnxjiNP/rhXXEmYd753MOqRvCuUvS OO7jQSd/2NZJu8y8Qss0YVUQz5fsROiTd5y+++Ve6eHFR2VVNhw2NSaRKJVviaOwWCwlhMrw3OLBv eNQEao8g==; Received: from [2001:4bb8:180:9d3f:90d7:9df8:7cd:3504] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jX53N-00048d-Lx; Fri, 08 May 2020 15:36:46 +0000 From: Christoph Hellwig To: Alexander Viro Cc: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, io-uring@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 03/12] pidfd: use __anon_inode_getfd Date: Fri, 8 May 2020 17:36:25 +0200 Message-Id: <20200508153634.249933-4-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200508153634.249933-1-hch@lst.de> References: <20200508153634.249933-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use __anon_inode_getfd instead of opencoding the logic using get_unused_fd_flags + anon_inode_getfile. Signed-off-by: Christoph Hellwig --- kernel/fork.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 4385f3d639f23..31e0face01072 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2113,19 +2113,11 @@ static __latent_entropy struct task_struct *copy_process( * if the fd table isn't shared). */ if (clone_flags & CLONE_PIDFD) { - retval = get_unused_fd_flags(O_RDWR | O_CLOEXEC); + retval = __anon_inode_getfd("[pidfd]", &pidfd_fops, pid, + O_RDWR | O_CLOEXEC, &pidfile); if (retval < 0) goto bad_fork_free_pid; - pidfd = retval; - - pidfile = anon_inode_getfile("[pidfd]", &pidfd_fops, pid, - O_RDWR | O_CLOEXEC); - if (IS_ERR(pidfile)) { - put_unused_fd(pidfd); - retval = PTR_ERR(pidfile); - goto bad_fork_free_pid; - } get_pid(pid); /* held by pidfile now */ retval = put_user(pidfd, args->pidfd); -- 2.26.2