Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1980198ybh; Tue, 14 Jul 2020 12:11:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKYzYjvOjdDZQYmpG3mCwI7JhJfQfQG1Q3HZHvImryHj0grpy8zkoFAKrBxM2pq8ZGtZvK X-Received: by 2002:a17:906:fac1:: with SMTP id lu1mr6181539ejb.427.1594753891611; Tue, 14 Jul 2020 12:11:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594753891; cv=none; d=google.com; s=arc-20160816; b=xI9KGPyjN6mxuzDzrEU+OZiV95XCsUHoi8dTkIG2Be9gOOTrnrldSOk8ZvAGKTrJHv tyUOkLMx0XkiHISUX22aMUbVlPbSKGLj1kWdooIqih6uM54pVSFPWoeUXM/yO1UHDsEV z5SG2PPYmn9irtbdTlVqngwi9lI8Bt4ejJkMw5EuohJO0xIKVODcxUPzQrn9sKk8gI77 XqXqfe97AWIWE93GItRQEAWyizkcwR/p077AirBHl6xlDTZNPdocvNMsOzEiGgkP4Z0A fHXHLUw942MMUrhlQYz9ZKuGN+oUVMfmmF2/NG/AxQZqF8jbdBpgl6nD8wkcjxl9lp3V mWVg== 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=BDxqNAyXTxzLLCgYDAkjeG7ETUtTJqGj9qruExt6hQ4=; b=ZuG3PIF8LYKkpBVtdtyg0HGBHV+0ufZU2HAWPx8IZEgr4L6p9qKi2cv9Xp7QSEMjoP 5NwdpcrEcqqVjwMMhc94YgQfLFqjyTEU+wCLsFfnG2C7S8wjaNIauMs1jeleqG8zopCd MbyjxAxCMpW5umDhrYPlyJgGVwExTCcP6kTvMqovRrmD9rHMnkjMbJEUDjn72w6rpeEB fHXjvwNuBc1nvFu/UliGCgkEHN7NUSTs9wfEjRCrSaLKqif9V7nK9DteAQLNRsdb0ZML UJ97hSIiR6b/S7WDy7wJ3DS7MExov+iiHj4IlOXflyknFyyn8T9bcZIRQzg10e4rE7Wr e4Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=jbGQngvV; 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 t14si1139120ejb.435.2020.07.14.12.11.08; Tue, 14 Jul 2020 12:11:31 -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=casper.20170209 header.b=jbGQngvV; 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 S1731056AbgGNTI5 (ORCPT + 99 others); Tue, 14 Jul 2020 15:08:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730198AbgGNTIx (ORCPT ); Tue, 14 Jul 2020 15:08:53 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A322C061794; Tue, 14 Jul 2020 12:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=BDxqNAyXTxzLLCgYDAkjeG7ETUtTJqGj9qruExt6hQ4=; b=jbGQngvVuzXKT8N+TaSzkVnsIy TIhImTs77/i/C8718Y8Qn3T8pmPJpu+4MN4uETRii8aUpey96ZZxNLecbin9T9CR4NLQG2ck/WLxR Rn5DoF3TV/mBmRF3TLHsoW24E5ZEZVGxe64zeXBxlsJJ8dHeG63cAD2o42kfhzSEwsdBIgwwUpJLM GO1cck0PorBhdHcittMmNalv9/4av3KIC0FRwi9KeIQBzk/beAKPL6c3wdbOoDLHpBffxvDvBLNq5 ATj36va3+CVflk8UOYtp7YkZED2mU/99nAUfF6TeHn7BOH22JsJXAtI2ZEcDVYPcGP0G57EXS1yje wIH0k3MA==; Received: from [2001:4bb8:188:5f50:f037:8cfe:627e:7028] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jvQIN-0005pH-9X; Tue, 14 Jul 2020 19:08:51 +0000 From: Christoph Hellwig To: linux-kernel@vger.kernel.org Cc: "H. Peter Anvin" , Song Liu , Al Viro , Linus Torvalds , linux-raid@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 02/23] fs: add a vfs_fchmod helper Date: Tue, 14 Jul 2020 21:04:06 +0200 Message-Id: <20200714190427.4332-3-hch@lst.de> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200714190427.4332-1-hch@lst.de> References: <20200714190427.4332-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.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 Add a helper for struct file based chmode operations. To be used by the initramfs code soon. Signed-off-by: Christoph Hellwig --- fs/open.c | 9 +++++++-- include/linux/fs.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/open.c b/fs/open.c index 103c66309bee67..75166f071d280a 100644 --- a/fs/open.c +++ b/fs/open.c @@ -602,14 +602,19 @@ static int chmod_common(const struct path *path, umode_t mode) return error; } +int vfs_fchmod(struct file *file, umode_t mode) +{ + audit_file(file); + return chmod_common(&file->f_path, mode); +} + int ksys_fchmod(unsigned int fd, umode_t mode) { struct fd f = fdget(fd); int err = -EBADF; if (f.file) { - audit_file(f.file); - err = chmod_common(&f.file->f_path, mode); + err = vfs_fchmod(f.file, mode); fdput(f); } return err; diff --git a/include/linux/fs.h b/include/linux/fs.h index 0ddd64ca0b45c0..635086726f2053 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1745,6 +1745,7 @@ int vfs_mkobj(struct dentry *, umode_t, void *); int vfs_fchown(struct file *file, uid_t user, gid_t group); +int vfs_fchmod(struct file *file, umode_t mode); extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg); -- 2.27.0