Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2677141pxa; Mon, 17 Aug 2020 16:20:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7vN4dxxaOlCcKQCc3tZWk4/BZIDgwgYsqG7F1lEaLIomxbG9Dzqkgv8/cuy+M40ipa6p+ X-Received: by 2002:a05:6402:17c2:: with SMTP id s2mr16764977edy.188.1597706437530; Mon, 17 Aug 2020 16:20:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597706437; cv=none; d=google.com; s=arc-20160816; b=wxRp0r8vklQSA2r689LkxbmHr3VJYDhAwWofQr1G5vTTHQFu3Z/Hv1XMh72fs4DRGJ 61KQvpCRqZTHbKlaD8toUlhqmo6gOqOz46zyqydY7kEIOuZ+/+LcVgytd0T2hQ8pF6sj Q+cfAT8mUv/9olJpRVF42Jss6qvuJrL2TrR+1n+azGASqVwew61HH3+Wdih/H6c4ajud 3AY6nnRl9+NbSPWydydE8YHrjXcOrdC+kUmJYCN+OaiNHb7+aFAxRkca6kGnuQDREgXY pkYbnWHHmSTpTaQgPRlqn5Fs+8Y9YsdOBYzaitLAqu5gDAkmaQpJ7ogkqz/XymfBCx7G F9Ig== 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=O0e/887G+FEpAkNNjF+eauhmppfqGP9xCqSRRNv+x6s=; b=nDFKz7957t9aheGjoMAFaz3wziBU6vtQVKSz8ux++WPKN9FAphCIakLkvrChXGKCe5 x79tlI62fMTP6BMgHD+TDdPCJ4TETMHThZUYruZG2Nirdk+Q/X65mCf4UdKb9K0cFMHs kehHcUsGL8Ju6ZxzVKZTLRSwEufEog9uqTwv07OL4eLcB3K5PEnYk5r7Q2+8i5L0gMEU K6qW2M6XjfspJytAGJN+4m3I55CCxYEBas/ZtVHL+ShioU7B87bzztKInvssKYJlvs9M VA6bq8MU8mKYlz13eDM/tK9VIlo5FTsmeeWxCTfVW9EY4+9JagN8z5e0VPP4vfMvCsis LNCw== 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 v15si11712362edq.579.2020.08.17.16.20.14; Mon, 17 Aug 2020 16:20:37 -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 S1730407AbgHQWM5 (ORCPT + 99 others); Mon, 17 Aug 2020 18:12:57 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:60738 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730277AbgHQWLw (ORCPT ); Mon, 17 Aug 2020 18:11:52 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out02.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1k7nM6-001r3z-LL; Mon, 17 Aug 2020 16:11:50 -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 1k7nKu-0004PB-RU; Mon, 17 Aug 2020 16:10:37 -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:24 -0500 Message-Id: <20200817220425.9389-16-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=1k7nKu-0004PB-RU;;;mid=<20200817220425.9389-16-ebiederm@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+0S5jwtFNklOV06k8NI64kO/U96GXuYSw= 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 sa01.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-Virus: No 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 * [sa01 0; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: ; sa01 0; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: *;linux-kernel@vger.kernel.org X-Spam-Relay-Country: X-Spam-Timing: total 390 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 33 (8.3%), b_tie_ro: 2.7 (0.7%), parse: 1.29 (0.3%), extract_message_metadata: 12 (3.0%), get_uri_detail_list: 1.79 (0.5%), tests_pri_-1000: 12 (3.0%), tests_pri_-950: 1.01 (0.3%), tests_pri_-900: 0.82 (0.2%), tests_pri_-90: 89 (22.9%), check_bayes: 88 (22.5%), b_tokenize: 7 (1.8%), b_tok_get_all: 7 (1.8%), b_comp_prob: 1.75 (0.4%), b_tok_touch_all: 69 (17.6%), b_finish: 0.75 (0.2%), tests_pri_0: 230 (59.0%), check_dkim_signature: 0.40 (0.1%), check_dkim_adsp: 2.4 (0.6%), poll_dns_idle: 1.03 (0.3%), tests_pri_10: 2.5 (0.6%), tests_pri_500: 6 (1.6%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 16/17] file: Merge __alloc_fd into alloc_fd 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 The function __alloc_fd was added to support binder[1]. With binder fixed[2] there are no more users. Further with get_files_struct removed there can be no more users of __alloc_fd that pass anything except current->files. As alloc_fd just calls __alloc_fd with "files=current->files", merge them together by transforming the files parameter into a ocal variable initialized to current->files. [1] dcfadfa4ec5a ("new helper: __alloc_fd()") [2] 44d8047f1d87 ("binder: use standard functions to allocate fds") Signed-off-by: "Eric W. Biederman" --- fs/file.c | 11 +++-------- include/linux/fdtable.h | 2 -- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/fs/file.c b/fs/file.c index 505b2e81ad3e..221fc4f97f61 100644 --- a/fs/file.c +++ b/fs/file.c @@ -465,9 +465,9 @@ static unsigned int find_next_fd(struct fdtable *fdt, unsigned int start) /* * allocate a file descriptor, mark it busy. */ -int __alloc_fd(struct files_struct *files, - unsigned start, unsigned end, unsigned flags) +static int alloc_fd(unsigned start, unsigned end, unsigned flags) { + struct files_struct *files = current->files; unsigned int fd; int error; struct fdtable *fdt; @@ -523,14 +523,9 @@ int __alloc_fd(struct files_struct *files, return error; } -static int alloc_fd(unsigned start, unsigned end, unsigned flags) -{ - return __alloc_fd(current->files, start, end, flags); -} - int __get_unused_fd_flags(unsigned flags, unsigned long nofile) { - return __alloc_fd(current->files, 0, nofile, flags); + return alloc_fd(0, nofile, flags); } int get_unused_fd_flags(unsigned flags) diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h index 4da8aacc461a..d8f6c4921d85 100644 --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h @@ -116,8 +116,6 @@ int iterate_fd(struct files_struct *, unsigned, int (*)(const void *, struct file *, unsigned), const void *); -extern int __alloc_fd(struct files_struct *files, - unsigned start, unsigned end, unsigned flags); extern int __close_fd(struct files_struct *files, unsigned int fd); extern int __close_range(unsigned int fd, unsigned int max_fd, unsigned int flags); -- 2.25.0