* [PATCH v2 0/5] f2fs: switch to new fscrypt helper functions
@ 2017-11-29 20:35 Eric Biggers
2017-11-29 20:35 ` [PATCH v2 1/5] f2fs: switch to fscrypt_file_open() Eric Biggers
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Eric Biggers @ 2017-11-29 20:35 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim, linux-fscrypt, Eric Biggers
From: Eric Biggers <ebiggers@google.com>
This series switches f2fs to use the fscrypt helper functions for
open/link/rename/lookup/setattr introduced in v4.15.
These patches were originally sent in "[PATCH 00/25] fscrypt: add some
higher-level helper functions". I've rebased them onto v4.15-rc1.
Eric Biggers (5):
f2fs: switch to fscrypt_file_open()
f2fs: switch to fscrypt_prepare_link()
f2fs: switch to fscrypt_prepare_rename()
f2fs: switch to fscrypt_prepare_lookup()
f2fs: switch to fscrypt_prepare_setattr()
fs/f2fs/file.c | 30 +++++++-----------------------
fs/f2fs/namei.c | 54 +++++++++++++-----------------------------------------
2 files changed, 20 insertions(+), 64 deletions(-)
--
2.15.0.531.g2ccb3012c9-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/5] f2fs: switch to fscrypt_file_open()
2017-11-29 20:35 [PATCH v2 0/5] f2fs: switch to new fscrypt helper functions Eric Biggers
@ 2017-11-29 20:35 ` Eric Biggers
2017-11-29 20:35 ` [PATCH v2 2/5] f2fs: switch to fscrypt_prepare_link() Eric Biggers
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2017-11-29 20:35 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim, linux-fscrypt, Eric Biggers
From: Eric Biggers <ebiggers@google.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
fs/f2fs/file.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 7874bbd7311d..ae2cf96190e4 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -472,22 +472,10 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
static int f2fs_file_open(struct inode *inode, struct file *filp)
{
- struct dentry *dir;
+ int err = fscrypt_file_open(inode, filp);
- if (f2fs_encrypted_inode(inode)) {
- int ret = fscrypt_get_encryption_info(inode);
- if (ret)
- return -EACCES;
- if (!fscrypt_has_encryption_key(inode))
- return -ENOKEY;
- }
- dir = dget_parent(file_dentry(filp));
- if (f2fs_encrypted_inode(d_inode(dir)) &&
- !fscrypt_has_permitted_context(d_inode(dir), inode)) {
- dput(dir);
- return -EPERM;
- }
- dput(dir);
+ if (err)
+ return err;
return dquot_file_open(inode, filp);
}
--
2.15.0.531.g2ccb3012c9-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/5] f2fs: switch to fscrypt_prepare_link()
2017-11-29 20:35 [PATCH v2 0/5] f2fs: switch to new fscrypt helper functions Eric Biggers
2017-11-29 20:35 ` [PATCH v2 1/5] f2fs: switch to fscrypt_file_open() Eric Biggers
@ 2017-11-29 20:35 ` Eric Biggers
2017-11-29 20:35 ` [PATCH v2 3/5] f2fs: switch to fscrypt_prepare_rename() Eric Biggers
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2017-11-29 20:35 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim, linux-fscrypt, Eric Biggers
From: Eric Biggers <ebiggers@google.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
fs/f2fs/namei.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 28bdf8828e73..dcf5c3a97059 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -240,9 +240,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
if (unlikely(f2fs_cp_error(sbi)))
return -EIO;
- if (f2fs_encrypted_inode(dir) &&
- !fscrypt_has_permitted_context(dir, inode))
- return -EPERM;
+ err = fscrypt_prepare_link(old_dentry, dir, dentry);
+ if (err)
+ return err;
if (is_inode_flag_set(dir, FI_PROJ_INHERIT) &&
(!projid_eq(F2FS_I(dir)->i_projid,
--
2.15.0.531.g2ccb3012c9-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/5] f2fs: switch to fscrypt_prepare_rename()
2017-11-29 20:35 [PATCH v2 0/5] f2fs: switch to new fscrypt helper functions Eric Biggers
2017-11-29 20:35 ` [PATCH v2 1/5] f2fs: switch to fscrypt_file_open() Eric Biggers
2017-11-29 20:35 ` [PATCH v2 2/5] f2fs: switch to fscrypt_prepare_link() Eric Biggers
@ 2017-11-29 20:35 ` Eric Biggers
2017-11-29 20:35 ` [PATCH v2 4/5] f2fs: switch to fscrypt_prepare_lookup() Eric Biggers
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2017-11-29 20:35 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim, linux-fscrypt, Eric Biggers
From: Eric Biggers <ebiggers@google.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
fs/f2fs/namei.c | 31 +++++++------------------------
1 file changed, 7 insertions(+), 24 deletions(-)
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index dcf5c3a97059..e910d2ebe0c6 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -800,18 +800,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
if (unlikely(f2fs_cp_error(sbi)))
return -EIO;
- if ((f2fs_encrypted_inode(old_dir) &&
- !fscrypt_has_encryption_key(old_dir)) ||
- (f2fs_encrypted_inode(new_dir) &&
- !fscrypt_has_encryption_key(new_dir)))
- return -ENOKEY;
-
- if ((old_dir != new_dir) && f2fs_encrypted_inode(new_dir) &&
- !fscrypt_has_permitted_context(new_dir, old_inode)) {
- err = -EPERM;
- goto out;
- }
-
if (is_inode_flag_set(new_dir, FI_PROJ_INHERIT) &&
(!projid_eq(F2FS_I(new_dir)->i_projid,
F2FS_I(old_dentry->d_inode)->i_projid)))
@@ -1002,18 +990,6 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
if (unlikely(f2fs_cp_error(sbi)))
return -EIO;
- if ((f2fs_encrypted_inode(old_dir) &&
- !fscrypt_has_encryption_key(old_dir)) ||
- (f2fs_encrypted_inode(new_dir) &&
- !fscrypt_has_encryption_key(new_dir)))
- return -ENOKEY;
-
- if ((f2fs_encrypted_inode(old_dir) || f2fs_encrypted_inode(new_dir)) &&
- (old_dir != new_dir) &&
- (!fscrypt_has_permitted_context(new_dir, old_inode) ||
- !fscrypt_has_permitted_context(old_dir, new_inode)))
- return -EPERM;
-
if ((is_inode_flag_set(new_dir, FI_PROJ_INHERIT) &&
!projid_eq(F2FS_I(new_dir)->i_projid,
F2FS_I(old_dentry->d_inode)->i_projid)) ||
@@ -1153,9 +1129,16 @@ static int f2fs_rename2(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
{
+ int err;
+
if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT))
return -EINVAL;
+ err = fscrypt_prepare_rename(old_dir, old_dentry, new_dir, new_dentry,
+ flags);
+ if (err)
+ return err;
+
if (flags & RENAME_EXCHANGE) {
return f2fs_cross_rename(old_dir, old_dentry,
new_dir, new_dentry);
--
2.15.0.531.g2ccb3012c9-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 4/5] f2fs: switch to fscrypt_prepare_lookup()
2017-11-29 20:35 [PATCH v2 0/5] f2fs: switch to new fscrypt helper functions Eric Biggers
` (2 preceding siblings ...)
2017-11-29 20:35 ` [PATCH v2 3/5] f2fs: switch to fscrypt_prepare_rename() Eric Biggers
@ 2017-11-29 20:35 ` Eric Biggers
2017-11-29 20:35 ` [PATCH v2 5/5] f2fs: switch to fscrypt_prepare_setattr() Eric Biggers
2017-12-01 7:12 ` [PATCH v2 0/5] f2fs: switch to new fscrypt helper functions Jaegeuk Kim
5 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2017-11-29 20:35 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim, linux-fscrypt, Eric Biggers
From: Eric Biggers <ebiggers@google.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
fs/f2fs/namei.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index e910d2ebe0c6..bbb3fc1e2bef 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -357,20 +357,9 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,
trace_f2fs_lookup_start(dir, dentry, flags);
- if (f2fs_encrypted_inode(dir)) {
- err = fscrypt_get_encryption_info(dir);
-
- /*
- * DCACHE_ENCRYPTED_WITH_KEY is set if the dentry is
- * created while the directory was encrypted and we
- * don't have access to the key.
- */
- if (fscrypt_has_encryption_key(dir))
- fscrypt_set_encrypted_dentry(dentry);
- fscrypt_set_d_op(dentry);
- if (err && err != -ENOKEY)
- goto out;
- }
+ err = fscrypt_prepare_lookup(dir, dentry, flags);
+ if (err)
+ goto out;
if (dentry->d_name.len > F2FS_NAME_LEN) {
err = -ENAMETOOLONG;
--
2.15.0.531.g2ccb3012c9-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 5/5] f2fs: switch to fscrypt_prepare_setattr()
2017-11-29 20:35 [PATCH v2 0/5] f2fs: switch to new fscrypt helper functions Eric Biggers
` (3 preceding siblings ...)
2017-11-29 20:35 ` [PATCH v2 4/5] f2fs: switch to fscrypt_prepare_lookup() Eric Biggers
@ 2017-11-29 20:35 ` Eric Biggers
2017-12-01 7:12 ` [PATCH v2 0/5] f2fs: switch to new fscrypt helper functions Jaegeuk Kim
5 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2017-11-29 20:35 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: Jaegeuk Kim, linux-fscrypt, Eric Biggers
From: Eric Biggers <ebiggers@google.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
fs/f2fs/file.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index ae2cf96190e4..52b8f95b9bee 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -743,6 +743,10 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
if (err)
return err;
+ err = fscrypt_prepare_setattr(dentry, attr);
+ if (err)
+ return err;
+
if (is_quota_modification(inode, attr)) {
err = dquot_initialize(inode);
if (err)
@@ -758,14 +762,6 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
}
if (attr->ia_valid & ATTR_SIZE) {
- if (f2fs_encrypted_inode(inode)) {
- err = fscrypt_get_encryption_info(inode);
- if (err)
- return err;
- if (!fscrypt_has_encryption_key(inode))
- return -ENOKEY;
- }
-
if (attr->ia_size <= i_size_read(inode)) {
down_write(&F2FS_I(inode)->i_mmap_sem);
truncate_setsize(inode, attr->ia_size);
--
2.15.0.531.g2ccb3012c9-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/5] f2fs: switch to new fscrypt helper functions
2017-11-29 20:35 [PATCH v2 0/5] f2fs: switch to new fscrypt helper functions Eric Biggers
` (4 preceding siblings ...)
2017-11-29 20:35 ` [PATCH v2 5/5] f2fs: switch to fscrypt_prepare_setattr() Eric Biggers
@ 2017-12-01 7:12 ` Jaegeuk Kim
5 siblings, 0 replies; 7+ messages in thread
From: Jaegeuk Kim @ 2017-12-01 7:12 UTC (permalink / raw)
To: Eric Biggers; +Cc: linux-fscrypt, Eric Biggers, linux-f2fs-devel
Thanks, merged.
On 11/29, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> This series switches f2fs to use the fscrypt helper functions for
> open/link/rename/lookup/setattr introduced in v4.15.
>
> These patches were originally sent in "[PATCH 00/25] fscrypt: add some
> higher-level helper functions". I've rebased them onto v4.15-rc1.
>
> Eric Biggers (5):
> f2fs: switch to fscrypt_file_open()
> f2fs: switch to fscrypt_prepare_link()
> f2fs: switch to fscrypt_prepare_rename()
> f2fs: switch to fscrypt_prepare_lookup()
> f2fs: switch to fscrypt_prepare_setattr()
>
> fs/f2fs/file.c | 30 +++++++-----------------------
> fs/f2fs/namei.c | 54 +++++++++++++-----------------------------------------
> 2 files changed, 20 insertions(+), 64 deletions(-)
>
> --
> 2.15.0.531.g2ccb3012c9-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-12-01 7:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-29 20:35 [PATCH v2 0/5] f2fs: switch to new fscrypt helper functions Eric Biggers
2017-11-29 20:35 ` [PATCH v2 1/5] f2fs: switch to fscrypt_file_open() Eric Biggers
2017-11-29 20:35 ` [PATCH v2 2/5] f2fs: switch to fscrypt_prepare_link() Eric Biggers
2017-11-29 20:35 ` [PATCH v2 3/5] f2fs: switch to fscrypt_prepare_rename() Eric Biggers
2017-11-29 20:35 ` [PATCH v2 4/5] f2fs: switch to fscrypt_prepare_lookup() Eric Biggers
2017-11-29 20:35 ` [PATCH v2 5/5] f2fs: switch to fscrypt_prepare_setattr() Eric Biggers
2017-12-01 7:12 ` [PATCH v2 0/5] f2fs: switch to new fscrypt helper functions Jaegeuk Kim
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).