ubifs: switch to new fscrypt helper functions
Subsystems (3)
v2 cover ubifs: switch to new fscrypt helper functions
From: Eric Biggers <[email protected]>
This series switches ubifs 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):
ubifs: switch to fscrypt_file_open()
ubifs: switch to fscrypt_prepare_link()
ubifs: switch to fscrypt_prepare_rename()
ubifs: switch to fscrypt_prepare_lookup()
ubifs: switch to fscrypt_prepare_setattr()
fs/ubifs/dir.c | 43 +++++++++++++------------------------------ fs/ubifs/file.c | 41 ++++------------------------------------- 2 files changed, 17 insertions(+), 67 deletions(-)
Signature · 1 line
2.15.0.531.g2ccb3012c9-goog
PATCH v2 1/5 ubifs: switch to fscrypt_file_open()
From: Eric Biggers <[email protected]>
--- fs/ubifs/file.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-)
fs/ubifs/file.c +1 -30
@@ -1629,35 +1629,6 @@ static int ubifs_file_mmap(struct file *file, struct vm_area_struct *vma)return 0 ; } -static int ubifs_file_open (struct inode *inode,struct file *filp) -{ -int ret; -struct dentry *dir; -struct ubifs_info *c = inode->i_sb->s_fs_info; - -if (ubifs_crypt_is_encrypted (inode)) { - 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 (ubifs_crypt_is_encrypted (d_inode (dir)) && - !fscrypt_has_permitted_context (d_inode (dir), inode)) { -ubifs_err (c,"Inconsistent encryption contexts: %lu/%lu" , - (unsigned long )d_inode (dir)->i_ino, - (unsigned long ) inode->i_ino); -dput (dir); -ubifs_ro_mode (c, -EPERM ); -return -EPERM ; - } -dput (dir); - -return 0 ; -} -static const char *ubifs_get_link (struct dentry *dentry,struct inode *inode,struct delayed_call *done)
@@ -1746,7 +1717,7 @@ const struct file_operations ubifs_file_operations = { .unlocked_ioctl = ubifs_ioctl, .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, - .open = ubifs_file_open, + .open = fscrypt_file_open,#ifdef CONFIG_COMPAT .compat_ioctl = ubifs_compat_ioctl,#endif
Signature · 1 line
2.15.0.531.g2ccb3012c9-goog
PATCH v2 2/5 ubifs: switch to fscrypt_prepare_link()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
--- fs/ubifs/dir.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/ubifs/dir.c +3 -3
@@ -743,9 +743,9 @@ static int ubifs_link(struct dentry *old_dentry, struct inode *dir,ubifs_assert (inode_is_locked (dir));ubifs_assert (inode_is_locked (inode)); -if (ubifs_crypt_is_encrypted (dir) && - !fscrypt_has_permitted_context (dir, inode)) -return -EPERM ; + err =fscrypt_prepare_link (old_dentry, dir, dentry); +if (err) +return err; err =fscrypt_setup_filename (dir, &dentry->d_name,0 , &nm);if (err)
Signature · 1 line
2.15.0.531.g2ccb3012c9-goog
PATCH v2 3/5 ubifs: switch to fscrypt_prepare_rename()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
--- fs/ubifs/dir.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
fs/ubifs/dir.c +7 -13
@@ -1353,12 +1353,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,if (unlink)ubifs_assert (inode_is_locked (new_inode)); -if (old_dir != new_dir) { -if (ubifs_crypt_is_encrypted (new_dir) && - !fscrypt_has_permitted_context (new_dir, old_inode)) -return -EPERM ; - } -if (unlink && is_dir) { err =ubifs_check_dir_empty (new_inode);if (err)
@@ -1573,13 +1567,6 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,ubifs_assert (fst_inode && snd_inode); -if ((ubifs_crypt_is_encrypted (old_dir) || -ubifs_crypt_is_encrypted (new_dir)) && - (old_dir != new_dir) && - (!fscrypt_has_permitted_context (new_dir, fst_inode) || - !fscrypt_has_permitted_context (old_dir, snd_inode))) -return -EPERM ; - err =fscrypt_setup_filename (old_dir, &old_dentry->d_name,0 , &fst_nm);if (err)return err;
@@ -1624,12 +1611,19 @@ static int ubifs_rename(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_WHITEOUT |RENAME_EXCHANGE ))return -EINVAL ;ubifs_assert (inode_is_locked (old_dir));ubifs_assert (inode_is_locked (new_dir)); + err =fscrypt_prepare_rename (old_dir, old_dentry, new_dir, new_dentry, + flags); +if (err) +return err; +if (flags &RENAME_EXCHANGE )return ubifs_xrename (old_dir, old_dentry, new_dir, new_dentry);
Signature · 1 line
2.15.0.531.g2ccb3012c9-goog
PATCH v2 4/5 ubifs: switch to fscrypt_prepare_lookup()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
--- fs/ubifs/dir.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
fs/ubifs/dir.c +3 -14
@@ -220,20 +220,9 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,dbg_gen ("'%pd' in dir ino %lu" , dentry, dir->i_ino); -if (ubifs_crypt_is_encrypted (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 -* 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 ) -return ERR_PTR (err); - } + err =fscrypt_prepare_lookup (dir, dentry, flags); +if (err) +return ERR_PTR (err); err =fscrypt_setup_filename (dir, &dentry->d_name,1 , &nm);if (err)
Signature · 1 line
2.15.0.531.g2ccb3012c9-goog
PATCH v2 5/5 ubifs: switch to fscrypt_prepare_setattr()
In reply to Eric BiggersFrom: Eric Biggers <[email protected]>
--- fs/ubifs/file.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
fs/ubifs/file.c +3 -7
@@ -1284,13 +1284,9 @@ int ubifs_setattr(struct dentry *dentry, struct iattr *attr)if (err)return err; -if (ubifs_crypt_is_encrypted (inode) && (attr->ia_valid &ATTR_SIZE )) { - err =fscrypt_get_encryption_info (inode); -if (err) -return err; -if (!fscrypt_has_encryption_key (inode)) -return -ENOKEY ; - } + err =fscrypt_prepare_setattr (dentry, attr); +if (err) +return err;if ((attr->ia_valid &ATTR_SIZE ) && attr->ia_size < inode->i_size)/* Truncation to a smaller size */
Signature · 1 line
2.15.0.531.g2ccb3012c9-goog
Quoted 15 lines · Eric Biggers
From: Eric Biggers <[email protected]>
This series switches ubifs 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):
ubifs: switch tofscrypt_file_open()
ubifs: switch tofscrypt_prepare_link()
ubifs: switch tofscrypt_prepare_rename()
ubifs: switch tofscrypt_prepare_lookup()
ubifs: switch tofscrypt_prepare_setattr()
Quoted 7 lines
fs/ubifs/dir.c | 43 +++++++++++++------------------------------ fs/ubifs/file.c | 41 ++++------------------------------------- 2 files changed, 17 insertions(+), 67 deletions(-)Signature · 1 line
2.15.0.531.g2ccb3012c9-goog
Richard, can you take these for UBIFS for v4.16?
Eric
Richard Weinberger
maintainerEric,
Am Freitag, 5. Januar 2018, 19:37:44 CET schrieb Eric Biggers:
Quoted 16 lines · Eric Biggers
Quoted 15 lines
From: Eric Biggers <[email protected]>
This series switches ubifs 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):
ubifs: switch tofscrypt_file_open()
ubifs: switch tofscrypt_prepare_link()
ubifs: switch tofscrypt_prepare_rename()
ubifs: switch tofscrypt_prepare_lookup()
ubifs: switch tofscrypt_prepare_setattr()
Quoted 5 lines
Quoted 3 lines
fs/ubifs/dir.c | 43 +++++++++++++------------------------------ fs/ubifs/file.c | 41 ++++------------------------------------- 2 files changed, 17 insertions(+), 67 deletions(-)Richard, can you take these for UBIFS for v4.16?
Yes. Thanks a lot for cleaning this up.
Thanks,
//richard
Quoted 19 lines · Richard Weinberger
Eric,
Am Freitag, 5. Januar 2018, 19:37:44 CET schrieb Eric Biggers:
Quoted 16 lines · Eric Biggers
Quoted 15 lines
From: Eric Biggers <[email protected]>
This series switches ubifs 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):
ubifs: switch tofscrypt_file_open()
ubifs: switch tofscrypt_prepare_link()
ubifs: switch tofscrypt_prepare_rename()
ubifs: switch tofscrypt_prepare_lookup()
ubifs: switch tofscrypt_prepare_setattr()
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
fs/ubifs/dir.c | 43 +++++++++++++------------------------------ fs/ubifs/file.c | 41 ++++------------------------------------- 2 files changed, 17 insertions(+), 67 deletions(-)Richard, can you take these for UBIFS for v4.16?
Yes. Thanks a lot for cleaning this up.
FYI, this series has merge conflicts with other fscrypt related changes that went via Ted into fs/ubifs.
Signature · 2 lines
Thanks, //richard
Quoted 24 lines · Richard Weinberger
Quoted 23 lines · Richard Weinberger
Eric,
Am Freitag, 5. Januar 2018, 19:37:44 CET schrieb Eric Biggers:
Quoted 20 lines · Eric Biggers
Quoted 18 lines
From: Eric Biggers <[email protected]>
This series switches ubifs 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):
ubifs: switch tofscrypt_file_open()
ubifs: switch tofscrypt_prepare_link()
ubifs: switch tofscrypt_prepare_rename()
ubifs: switch tofscrypt_prepare_lookup()
ubifs: switch tofscrypt_prepare_setattr()fs/ubifs/dir.c | 43 +++++++++++++------------------------------ fs/ubifs/file.c | 41 ++++------------------------------------- 2 files changed, 17 insertions(+), 67 deletions(-)
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Richard, can you take these for UBIFS for v4.16?
Yes. Thanks a lot for cleaning this up.
FYI, this series has merge conflicts with other fscrypt related changes that went via Ted into fs/ubifs.
How so? These apply cleanly to both Linus' tree and to fscrypt/master currently.
Richard Weinberger
maintainerAm Mittwoch, 17. Januar 2018, 22:23:54 CET schrieb Eric Biggers:
Quoted 2 lines · Richard Weinberger
Quoted 1 line
On Fri, Jan 5, 2018 at 11:11 PM, Richard Weinberger <[email protected]>
Quoted 26 lines · wrote:
Quoted 26 lines
Quoted 26 lines
Eric,
Am Freitag, 5. Januar 2018, 19:37:44 CET schrieb Eric Biggers:
Quoted 22 lines · Eric Biggers
Quoted 16 lines
From: Eric Biggers <[email protected]>
This series switches ubifs 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):
ubifs: switch tofscrypt_file_open()
ubifs: switch tofscrypt_prepare_link()
ubifs: switch tofscrypt_prepare_rename()
ubifs: switch tofscrypt_prepare_lookup()
ubifs: switch tofscrypt_prepare_setattr()Quoted 3 lines
fs/ubifs/dir.c | 43 +++++++++++++------------------------------ fs/ubifs/file.c | 41 ++++------------------------------------- 2 files changed, 17 insertions(+), 67 deletions(-)Richard, can you take these for UBIFS for v4.16?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Yes. Thanks a lot for cleaning this up.
FYI, this series has merge conflicts with other fscrypt related changes that went via Ted into fs/ubifs.
How so? These apply cleanly to both Linus' tree and to fscrypt/master currently.
Just checked, the problem is this commit:
commit 9a2cebc6e2368072490a574eafe0f0747d330bbd
Author: Eric Biggers <[email protected]> Date: Fri Jan 5 11:30:03 2018 -0800
ubifs: free the encrypted symlink target
It exists also in my tree. I'll drop it and force push. Sorry for messing up, next time I try hard to be more responsive.
Thanks,
//richard
Quoted 44 lines · Richard Weinberger
Am Mittwoch, 17. Januar 2018, 22:23:54 CET schrieb Eric Biggers:
Quoted 2 lines · Richard Weinberger
Quoted 1 line
On Fri, Jan 5, 2018 at 11:11 PM, Richard Weinberger <[email protected]>
Quoted 26 lines · wrote:
Quoted 26 lines
Quoted 26 lines
Eric,
Am Freitag, 5. Januar 2018, 19:37:44 CET schrieb Eric Biggers:
Quoted 22 lines · Eric Biggers
Quoted 16 lines
From: Eric Biggers <[email protected]>
This series switches ubifs 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):
ubifs: switch tofscrypt_file_open()
ubifs: switch tofscrypt_prepare_link()
ubifs: switch tofscrypt_prepare_rename()
ubifs: switch tofscrypt_prepare_lookup()
ubifs: switch tofscrypt_prepare_setattr()Quoted 3 lines
fs/ubifs/dir.c | 43 +++++++++++++------------------------------ fs/ubifs/file.c | 41 ++++------------------------------------- 2 files changed, 17 insertions(+), 67 deletions(-)Richard, can you take these for UBIFS for v4.16?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Yes. Thanks a lot for cleaning this up.
FYI, this series has merge conflicts with other fscrypt related changes that went via Ted into fs/ubifs.
How so? These apply cleanly to both Linus' tree and to fscrypt/master currently.
Just checked, the problem is this commit:
commit
9a2cebc6e2368072490a574eafe0f0747d330bbdAuthor: Eric Biggers <[email protected]> Date: Fri Jan 5 11:30:03 2018 -0800
Quoted 8 lines
ubifs: free the encrypted symlink target
It exists also in my tree. I'll drop it and force push. Sorry for messing up, next time I try hard to be more responsive.
Thanks,
//richard
Ah yes, sorry for the confusion. The original plan was to just take the initial patches in the "fscrypt: symlink helpers and fscrypt.h cleanup" series, but we decided to take the fs-specific patches through the fscrypt tree too, since the only merge conflict was a "trivial" one in f2fs_symlink(), and it otherwise would have taken a long time to get all those patches as well as the follow-on fscrypt patches applied.
Eric