From: Christoph Hellwig <hch@infradead.org>
To: Max Kellermann <mk@cm4all.com>
Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org,
trond.myklebust@hammerspace.com, bfields@redhat.com,
tytso@mit.edu, viro@zeniv.linux.org.uk, agruenba@redhat.com,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v3 2/4] fs/ext4/acl: apply umask if ACL support is disabled
Date: Fri, 17 Apr 2020 00:50:02 -0700 [thread overview]
Message-ID: <20200417075002.GB598@infradead.org> (raw)
In-Reply-To: <20200407142243.2032-2-mk@cm4all.com>
This looks correct (modulo some minor coding style derivations),
but I think the better fix is to reuse the poix_acl_create
functionality rather than duplicating it. Something like this:
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index 8c7bbf3e566d..6cff7cc31866 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -268,33 +268,17 @@ ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type)
/*
* Initialize the ACLs of a new inode. Called from ext4_new_inode.
*
- * dir->i_mutex: down
* inode->i_mutex: up (access to inode is still exclusive)
*/
int
-ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
+ext4_init_acl(handle_t *handle, struct inode *inode, int type,
+ struct posix_acl *acl)
{
- struct posix_acl *default_acl, *acl;
- int error;
+ int error = 0;
- error = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
- if (error)
- return error;
-
- if (default_acl) {
- error = __ext4_set_acl(handle, inode, ACL_TYPE_DEFAULT,
- default_acl, XATTR_CREATE);
- posix_acl_release(default_acl);
- } else {
- inode->i_default_acl = NULL;
- }
if (acl) {
- if (!error)
- error = __ext4_set_acl(handle, inode, ACL_TYPE_ACCESS,
- acl, XATTR_CREATE);
+ error = __ext4_set_acl(handle, inode, type, acl, XATTR_CREATE);
posix_acl_release(acl);
- } else {
- inode->i_acl = NULL;
}
return error;
}
diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h
index 9b63f5416a2f..1e2927d14238 100644
--- a/fs/ext4/acl.h
+++ b/fs/ext4/acl.h
@@ -57,15 +57,16 @@ static inline int ext4_acl_count(size_t size)
/* acl.c */
struct posix_acl *ext4_get_acl(struct inode *inode, int type);
int ext4_set_acl(struct inode *inode, struct posix_acl *acl, int type);
-extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
+int ext4_init_acl(handle_t *handle, struct inode *inode, int type,
+ struct posix_acl *acl);
#else /* CONFIG_EXT4_FS_POSIX_ACL */
#include <linux/sched.h>
#define ext4_get_acl NULL
#define ext4_set_acl NULL
-static inline int
-ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
+static inline int ext4_init_acl(handle_t *handle, struct inode *inode, int type,
+ struct posix_acl *acl)
{
return 0;
}
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index b420c9dc444d..32b03f6277c1 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -1168,7 +1168,17 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
}
if (!(ei->i_flags & EXT4_EA_INODE_FL)) {
- err = ext4_init_acl(handle, inode, dir);
+ struct posix_acl *default_acl, *acl;
+
+ cache_no_acl(inode);
+ err = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl);
+ if (err)
+ goto fail_free_drop;
+ err = ext4_init_acl(handle, inode, ACL_TYPE_DEFAULT,
+ default_acl);
+ if (err)
+ goto fail_free_drop;
+ err = ext4_init_acl(handle, inode, ACL_TYPE_ACCESS, acl);
if (err)
goto fail_free_drop;
next prev parent reply other threads:[~2020-04-17 7:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-07 14:22 [PATCH v3 1/4] fs/posix_acl: apply umask if superblock disables ACL support Max Kellermann
2020-04-07 14:22 ` [PATCH v3 2/4] fs/ext4/acl: apply umask if ACL support is disabled Max Kellermann
2020-04-17 7:50 ` Christoph Hellwig [this message]
2020-04-07 14:22 ` [PATCH v3 3/4] linux/fs.h: fix umask on NFS with CONFIG_FS_POSIX_ACL=n Max Kellermann
2020-04-17 7:51 ` Christoph Hellwig
2020-04-07 14:22 ` [PATCH v3 4/4] nfs/super: check NFS_CAP_ACLS instead of the NFS version Max Kellermann
2020-04-17 7:53 ` Christoph Hellwig
2020-04-17 7:35 ` [PATCH v3 1/4] fs/posix_acl: apply umask if superblock disables ACL support Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200417075002.GB598@infradead.org \
--to=hch@infradead.org \
--cc=agruenba@redhat.com \
--cc=bfields@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=mk@cm4all.com \
--cc=stable@vger.kernel.org \
--cc=trond.myklebust@hammerspace.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).