Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2675513pxa; Mon, 17 Aug 2020 16:17:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAmhcwDX9JQGkmGoaMT59AD0Lsy1skJvRpwvjTzFJFfQVTjJGjBHVP2v7aaVGir2i9nk5T X-Received: by 2002:a05:6402:44e:: with SMTP id p14mr17618012edw.1.1597706244756; Mon, 17 Aug 2020 16:17:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597706244; cv=none; d=google.com; s=arc-20160816; b=UMDDVIyks3MyewN97jeNzrulsFqRr7yKekSsYgKpY5p0kQxpT4G8jzj+la5ofoxuLA bNHxhGucMA2GNSwpvGRMt96MSf+Ol/3D0NfkMAgFp2m2e4xU+0VhD+C3RnbU8ks/U881 eCCYWRiWz49armeZqcajpkgI1atOiovcFfcEZP1wFJiBx1VPmHYivo/z6b/s+6N+xNNd /j7Pv+ZnHcWkX60I5MEQ+4gJ1BYR6mY1yfinGsca232aPXhwPHl2WxrjAayP+IMedAjI y0sghreuMaH7JUDz/4nC3wx//k5V6wShXBxbORCbikFHDLxmHBpiyeBa8BS417cZfSiZ /sAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:cc:to:from; bh=pXqEGf9vWo/Qn1gPwiGWgICmVbHmu3MOSibs/P62KTY=; b=Gsx2eFQiSRJdiOoMEZEJ5PHvlavCrGfBjF6IXheuoHIeRm7CMyRdiMIEQj+GvNfPyc MwvPFoMRxCGMKMsCerU7pSxvIpGeiXi+gYHjBwfVKjRKQ8TNUsuqkV8bo0+VoLxTFwl6 yPqtdFWnbjMlbn80vPv3+tuKvU/LHTFSSbPwPWWyaCH4Aq3T7RLySkUNky2V0prXseN4 pnPpeqyhEs04V8djZH0ti4HyKhfsTbQidcgkIpu6mWEiJr5n5qjDh5gdE8WX0X/HQJQ4 /eXPnmNfOy9mSbFcUXJ8tHr2VfZuI+rIPjXTtWjKkF3mx1Y9rg8kLLP8U0wSgt5vR+Kt D8uw== ARC-Authentication-Results: i=1; mx.google.com; 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=xmission.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x8si12475130ejs.414.2020.08.17.16.17.01; Mon, 17 Aug 2020 16:17:24 -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; 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=xmission.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730156AbgHQWKF (ORCPT + 99 others); Mon, 17 Aug 2020 18:10:05 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:32968 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730094AbgHQWJ5 (ORCPT ); Mon, 17 Aug 2020 18:09:57 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out03.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1k7nKF-001Gya-MY; Mon, 17 Aug 2020 16:09:55 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.int.ebiederm.org) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1k7nKE-0004PB-TN; Mon, 17 Aug 2020 16:09:55 -0600 From: "Eric W. Biederman" To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, criu@openvz.org, bpf@vger.kernel.org, Linus Torvalds , Alexander Viro , Christian Brauner , Oleg Nesterov , Cyrill Gorcunov , Jann Horn , Kees Cook , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Jeff Layton , Miklos Szeredi , Matthew Wilcox , "J. Bruce Fields" , Matthew Wilcox , Trond Myklebust , Chris Wright , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , "Eric W. Biederman" Date: Mon, 17 Aug 2020 17:04:14 -0500 Message-Id: <20200817220425.9389-6-ebiederm@xmission.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <87ft8l6ic3.fsf@x220.int.ebiederm.org> References: <87ft8l6ic3.fsf@x220.int.ebiederm.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-XM-SPF: eid=1k7nKE-0004PB-TN;;;mid=<20200817220425.9389-6-ebiederm@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18+FAvHqoU00EuPv+eIsuw9qOJOke3CL9M= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa07.xmission.com X-Spam-Level: * X-Spam-Status: No, score=1.3 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TooManySym_01,XMNoVowels autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.5 XMNoVowels Alpha-numberic number with no vowels * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 0; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: ; sa07 0; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 366 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 12 (3.4%), b_tie_ro: 11 (3.0%), parse: 1.42 (0.4%), extract_message_metadata: 13 (3.6%), get_uri_detail_list: 1.29 (0.4%), tests_pri_-1000: 15 (4.1%), tests_pri_-950: 1.19 (0.3%), tests_pri_-900: 1.05 (0.3%), tests_pri_-90: 120 (32.8%), check_bayes: 118 (32.3%), b_tokenize: 8 (2.3%), b_tok_get_all: 7 (1.8%), b_comp_prob: 2.3 (0.6%), b_tok_touch_all: 97 (26.5%), b_finish: 1.04 (0.3%), tests_pri_0: 188 (51.3%), check_dkim_signature: 0.87 (0.2%), check_dkim_adsp: 2.0 (0.6%), poll_dns_idle: 0.42 (0.1%), tests_pri_10: 2.9 (0.8%), tests_pri_500: 8 (2.3%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 06/17] file: Implement fcheck_task X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As a companion to fget_task implement fcheck_task for use for querying a process about a specific file. Signed-off-by: "Eric W. Biederman" --- fs/file.c | 13 +++++++++++++ include/linux/fdtable.h | 1 + 2 files changed, 14 insertions(+) diff --git a/fs/file.c b/fs/file.c index c585dbaf31a3..8d4b385055e9 100644 --- a/fs/file.c +++ b/fs/file.c @@ -863,6 +863,19 @@ struct file *fget_task(struct task_struct *task, unsigned int fd) return file; } +struct file *fcheck_task(struct task_struct *task, unsigned int fd) +{ + /* Must be called with rcu_read_lock held */ + struct file *file = NULL; + + task_lock(task); + if (task->files) + file = fcheck_files(task->files, fd); + task_unlock(task); + + return file; +} + /* * Lightweight file lookup - no refcnt increment if fd table isn't shared. * diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h index 7cc9885044d9..def9debd2ce2 100644 --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h @@ -103,6 +103,7 @@ static inline struct file *fcheck_files(struct files_struct *files, unsigned int * Check whether the specified fd has an open file. */ #define fcheck(fd) fcheck_files(current->files, fd) +struct file *fcheck_task(struct task_struct *task, unsigned int fd); struct task_struct; -- 2.25.0