Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2975494pxa; Tue, 18 Aug 2020 03:13:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqWzBKrllNWFeT0pnTsqA6U8pWtfQzXbSqSBpueSxLfpQlmPnwzmawKZWHD2oOqGDNaXGF X-Received: by 2002:a17:906:84cf:: with SMTP id f15mr20144616ejy.259.1597745622067; Tue, 18 Aug 2020 03:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597745622; cv=none; d=google.com; s=arc-20160816; b=RbCXafNo2xelASChrN1D9hTQrAO4GekcZNn9agrI+xk7VXVzNk15+EQKNsUtgx645L rTeBURceb8kV1yHzqRzRxhFIUS8tFAuH1njREyABxXp4nBykUBgWbaB3meklfXuVru42 7ZVflQx2tGwsVYCKOKB9iOh2rGxtNjFVJnLfP8sMwkdHP0Eu1aXq6bty9DUpT4X0213z tV7l1MwOtY7NbHtsKaMvrUBsEkAOMSsyHYK9APLe4PfN+uTdnFLzNk4RTvulO2GdJvM6 1Vftml5GcU3+Sr/lVAo3KgHyzi02LdMxEt3n/hqJVWZSTbrHGjfvV+RhIvIb7H8uu4Sa mWzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=bUKkJCXHuT+GvI2o7DcLmhmhq5wlBXKo1N3vjIePVG8=; b=W+jwjueolvV0iZAk1uCASvPcYImDp69tJj7K4ZxalBaEWwbv9GG8pNZyo3AARkuexN f+kkLPv8FfZpkveIVTfVrfQHL3FKg+ZWp4IGp4rIRCJiJzQcUvP2mgIEPfB7g1un+T97 BBZu5Fsyyj8ldhScUsFtAzPWJoqj2XdgP4OId1GaFS1P0x9Mz0i59lOMpezAmY1kpE6X 0kcv+RsTlqDTSUkjkyzOqMhbOuiYdrMJb4nJ1mgQd/AW0A6xBUbZ6QV+wBQlQO/KH5wP rY3Ec29/48gb8NaDpC3OvbkmE/2PvmmuMZ7ZRVUm3oqcwMNn+S82AO89/h2waia01kmD FAyg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e6si12412970edr.328.2020.08.18.03.13.18; Tue, 18 Aug 2020 03:13:42 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726778AbgHRKMd (ORCPT + 99 others); Tue, 18 Aug 2020 06:12:33 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:38179 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726590AbgHRKMa (ORCPT ); Tue, 18 Aug 2020 06:12:30 -0400 Received: from ip5f5af70b.dynamic.kabel-deutschland.de ([95.90.247.11] helo=wittgenstein) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1k7ybT-0000x6-I9; Tue, 18 Aug 2020 10:12:27 +0000 Date: Tue, 18 Aug 2020 12:12:26 +0200 From: Christian Brauner To: "Eric W. Biederman" Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, criu@openvz.org, bpf@vger.kernel.org, Linus Torvalds , Alexander Viro , Oleg Nesterov , Cyrill Gorcunov , Jann Horn , Kees Cook , Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= , 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 Subject: Re: [PATCH 15/17] file: In f_dupfd read RLIMIT_NOFILE once. Message-ID: <20200818101226.weamow3swms6xizm@wittgenstein> References: <87ft8l6ic3.fsf@x220.int.ebiederm.org> <20200817220425.9389-15-ebiederm@xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200817220425.9389-15-ebiederm@xmission.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 17, 2020 at 05:04:23PM -0500, Eric W. Biederman wrote: > Simplify the code, and remove the chance of races by reading > RLIMIT_NOFILE only once in f_dupfd. > > Pass the read value of RLIMIT_NOFILE into alloc_fd which is the other > location the rlimit was read in f_dupfd. As f_dupfd is the only > caller of alloc_fd this changing alloc_fd is trivially safe. > > Further this causes alloc_fd to take all of the same arguments as > __alloc_fd except for the files_struct argument. > > Signed-off-by: "Eric W. Biederman" > --- Acked-by: Christian Brauner