Linux-FSCrypt Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] ubifs: use IS_ENCRYPTED() instead of ubifs_crypt_is_encrypted()
@ 2019-12-09 21:27 Eric Biggers
  2020-01-03 17:09 ` Eric Biggers
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Biggers @ 2019-12-09 21:27 UTC (permalink / raw)
  To: linux-mtd; +Cc: linux-fscrypt, Chandan Rajendra

From: Eric Biggers <ebiggers@google.com>

There's no need for the ubifs_crypt_is_encrypted() function anymore.
Just use IS_ENCRYPTED() instead, like ext4 and f2fs do.  IS_ENCRYPTED()
checks the VFS-level flag instead of the UBIFS-specific flag, but it
shouldn't change any behavior since the flags are kept in sync.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/ubifs/dir.c     | 8 ++++----
 fs/ubifs/file.c    | 4 ++--
 fs/ubifs/journal.c | 6 +++---
 fs/ubifs/ubifs.h   | 7 -------
 4 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index acc4f942d25b6..636c3222c2308 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -81,7 +81,7 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
 	struct ubifs_inode *ui;
 	bool encrypted = false;
 
-	if (ubifs_crypt_is_encrypted(dir)) {
+	if (IS_ENCRYPTED(dir)) {
 		err = fscrypt_get_encryption_info(dir);
 		if (err) {
 			ubifs_err(c, "fscrypt_get_encryption_info failed: %i", err);
@@ -261,7 +261,7 @@ static struct dentry *ubifs_lookup(struct inode *dir, struct dentry *dentry,
 		goto done;
 	}
 
-	if (ubifs_crypt_is_encrypted(dir) &&
+	if (IS_ENCRYPTED(dir) &&
 	    (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
 	    !fscrypt_has_permitted_context(dir, inode)) {
 		ubifs_warn(c, "Inconsistent encryption contexts: %lu/%lu",
@@ -499,7 +499,7 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx)
 	struct ubifs_dent_node *dent;
 	struct inode *dir = file_inode(file);
 	struct ubifs_info *c = dir->i_sb->s_fs_info;
-	bool encrypted = ubifs_crypt_is_encrypted(dir);
+	bool encrypted = IS_ENCRYPTED(dir);
 
 	dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, ctx->pos);
 
@@ -1618,7 +1618,7 @@ int ubifs_getattr(const struct path *path, struct kstat *stat,
 
 static int ubifs_dir_open(struct inode *dir, struct file *file)
 {
-	if (ubifs_crypt_is_encrypted(dir))
+	if (IS_ENCRYPTED(dir))
 		return fscrypt_get_encryption_info(dir) ? -EACCES : 0;
 
 	return 0;
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index cd52585c8f4fe..c8e8f50c6054f 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -67,7 +67,7 @@ static int read_block(struct inode *inode, void *addr, unsigned int block,
 
 	dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
 
-	if (ubifs_crypt_is_encrypted(inode)) {
+	if (IS_ENCRYPTED(inode)) {
 		err = ubifs_decrypt(inode, dn, &dlen, block);
 		if (err)
 			goto dump;
@@ -647,7 +647,7 @@ static int populate_page(struct ubifs_info *c, struct page *page,
 			dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
 			out_len = UBIFS_BLOCK_SIZE;
 
-			if (ubifs_crypt_is_encrypted(inode)) {
+			if (IS_ENCRYPTED(inode)) {
 				err = ubifs_decrypt(inode, dn, &dlen, page_block);
 				if (err)
 					goto out_err;
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index 388fe8f5dc51d..a38e18d3ef1d7 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -727,7 +727,7 @@ int ubifs_jnl_write_data(struct ubifs_info *c, const struct inode *inode,
 	int dlen = COMPRESSED_DATA_NODE_BUF_SZ, allocated = 1;
 	int write_len;
 	struct ubifs_inode *ui = ubifs_inode(inode);
-	bool encrypted = ubifs_crypt_is_encrypted(inode);
+	bool encrypted = IS_ENCRYPTED(inode);
 	u8 hash[UBIFS_HASH_ARR_SZ];
 
 	dbg_jnlk(key, "ino %lu, blk %u, len %d, key ",
@@ -1449,7 +1449,7 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in
 	dlen = old_dlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;
 	compr_type = le16_to_cpu(dn->compr_type);
 
-	if (ubifs_crypt_is_encrypted(inode)) {
+	if (IS_ENCRYPTED(inode)) {
 		err = ubifs_decrypt(inode, dn, &dlen, block);
 		if (err)
 			goto out;
@@ -1465,7 +1465,7 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in
 		ubifs_compress(c, buf, *new_len, &dn->data, &out_len, &compr_type);
 	}
 
-	if (ubifs_crypt_is_encrypted(inode)) {
+	if (IS_ENCRYPTED(inode)) {
 		err = ubifs_encrypt(inode, dn, out_len, &old_dlen, block);
 		if (err)
 			goto out;
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index c55f212dcb759..bff682309fbef 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -2095,13 +2095,6 @@ int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn,
 
 extern const struct fscrypt_operations ubifs_crypt_operations;
 
-static inline bool ubifs_crypt_is_encrypted(const struct inode *inode)
-{
-	const struct ubifs_inode *ui = ubifs_inode(inode);
-
-	return ui->flags & UBIFS_CRYPT_FL;
-}
-
 /* Normal UBIFS messages */
 __printf(2, 3)
 void ubifs_msg(const struct ubifs_info *c, const char *fmt, ...);
-- 
2.24.0.393.g34dc348eaf-goog


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ubifs: use IS_ENCRYPTED() instead of ubifs_crypt_is_encrypted()
  2019-12-09 21:27 [PATCH] ubifs: use IS_ENCRYPTED() instead of ubifs_crypt_is_encrypted() Eric Biggers
@ 2020-01-03 17:09 ` Eric Biggers
  2020-01-09  8:01   ` Richard Weinberger
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Biggers @ 2020-01-03 17:09 UTC (permalink / raw)
  To: Richard Weinberger, linux-mtd; +Cc: linux-fscrypt, Chandan Rajendra

On Mon, Dec 09, 2019 at 01:27:21PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> There's no need for the ubifs_crypt_is_encrypted() function anymore.
> Just use IS_ENCRYPTED() instead, like ext4 and f2fs do.  IS_ENCRYPTED()
> checks the VFS-level flag instead of the UBIFS-specific flag, but it
> shouldn't change any behavior since the flags are kept in sync.
> 
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  fs/ubifs/dir.c     | 8 ++++----
>  fs/ubifs/file.c    | 4 ++--
>  fs/ubifs/journal.c | 6 +++---
>  fs/ubifs/ubifs.h   | 7 -------
>  4 files changed, 9 insertions(+), 16 deletions(-)

Richard, can you consider applying this to the UBIFS tree for 5.6?

- Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ubifs: use IS_ENCRYPTED() instead of ubifs_crypt_is_encrypted()
  2020-01-03 17:09 ` Eric Biggers
@ 2020-01-09  8:01   ` Richard Weinberger
  2020-01-20  6:54     ` Eric Biggers
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Weinberger @ 2020-01-09  8:01 UTC (permalink / raw)
  To: Eric Biggers
  Cc: Richard Weinberger, linux-mtd, linux-fscrypt, Chandan Rajendra

On Fri, Jan 3, 2020 at 6:09 PM Eric Biggers <ebiggers@kernel.org> wrote:
>
> On Mon, Dec 09, 2019 at 01:27:21PM -0800, Eric Biggers wrote:
> > From: Eric Biggers <ebiggers@google.com>
> >
> > There's no need for the ubifs_crypt_is_encrypted() function anymore.
> > Just use IS_ENCRYPTED() instead, like ext4 and f2fs do.  IS_ENCRYPTED()
> > checks the VFS-level flag instead of the UBIFS-specific flag, but it
> > shouldn't change any behavior since the flags are kept in sync.
> >
> > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > ---
> >  fs/ubifs/dir.c     | 8 ++++----
> >  fs/ubifs/file.c    | 4 ++--
> >  fs/ubifs/journal.c | 6 +++---
> >  fs/ubifs/ubifs.h   | 7 -------
> >  4 files changed, 9 insertions(+), 16 deletions(-)
>
> Richard, can you consider applying this to the UBIFS tree for 5.6?

Sure. I'm back from the x-mas break and start collecting patches.

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ubifs: use IS_ENCRYPTED() instead of ubifs_crypt_is_encrypted()
  2020-01-09  8:01   ` Richard Weinberger
@ 2020-01-20  6:54     ` Eric Biggers
  2020-01-20  9:44       ` Richard Weinberger
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Biggers @ 2020-01-20  6:54 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: Richard Weinberger, linux-mtd, linux-fscrypt, Chandan Rajendra

On Thu, Jan 09, 2020 at 09:01:09AM +0100, Richard Weinberger wrote:
> On Fri, Jan 3, 2020 at 6:09 PM Eric Biggers <ebiggers@kernel.org> wrote:
> >
> > On Mon, Dec 09, 2019 at 01:27:21PM -0800, Eric Biggers wrote:
> > > From: Eric Biggers <ebiggers@google.com>
> > >
> > > There's no need for the ubifs_crypt_is_encrypted() function anymore.
> > > Just use IS_ENCRYPTED() instead, like ext4 and f2fs do.  IS_ENCRYPTED()
> > > checks the VFS-level flag instead of the UBIFS-specific flag, but it
> > > shouldn't change any behavior since the flags are kept in sync.
> > >
> > > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > > ---
> > >  fs/ubifs/dir.c     | 8 ++++----
> > >  fs/ubifs/file.c    | 4 ++--
> > >  fs/ubifs/journal.c | 6 +++---
> > >  fs/ubifs/ubifs.h   | 7 -------
> > >  4 files changed, 9 insertions(+), 16 deletions(-)
> >
> > Richard, can you consider applying this to the UBIFS tree for 5.6?
> 
> Sure. I'm back from the x-mas break and start collecting patches.
> 

Ping?  I see the other UBIFS patches I sent in linux-ubifs.git#linux-next,
but not this one.

- Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ubifs: use IS_ENCRYPTED() instead of ubifs_crypt_is_encrypted()
  2020-01-20  6:54     ` Eric Biggers
@ 2020-01-20  9:44       ` Richard Weinberger
  2020-01-20 18:47         ` Eric Biggers
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Weinberger @ 2020-01-20  9:44 UTC (permalink / raw)
  To: Eric Biggers; +Cc: linux-mtd, linux-fscrypt, Chandan Rajendra, Miquel Raynal


----- Ursprüngliche Mail -----
> Von: "Eric Biggers" <ebiggers@kernel.org>
> An: "Richard Weinberger" <richard.weinberger@gmail.com>
> CC: "richard" <richard@nod.at>, "linux-mtd" <linux-mtd@lists.infradead.org>, "linux-fscrypt"
> <linux-fscrypt@vger.kernel.org>, "Chandan Rajendra" <chandan@linux.vnet.ibm.com>
> Gesendet: Montag, 20. Januar 2020 07:54:22
> Betreff: Re: [PATCH] ubifs: use IS_ENCRYPTED() instead of ubifs_crypt_is_encrypted()

> On Thu, Jan 09, 2020 at 09:01:09AM +0100, Richard Weinberger wrote:
>> On Fri, Jan 3, 2020 at 6:09 PM Eric Biggers <ebiggers@kernel.org> wrote:
>> >
>> > On Mon, Dec 09, 2019 at 01:27:21PM -0800, Eric Biggers wrote:
>> > > From: Eric Biggers <ebiggers@google.com>
>> > >
>> > > There's no need for the ubifs_crypt_is_encrypted() function anymore.
>> > > Just use IS_ENCRYPTED() instead, like ext4 and f2fs do.  IS_ENCRYPTED()
>> > > checks the VFS-level flag instead of the UBIFS-specific flag, but it
>> > > shouldn't change any behavior since the flags are kept in sync.
>> > >
>> > > Signed-off-by: Eric Biggers <ebiggers@google.com>
>> > > ---
>> > >  fs/ubifs/dir.c     | 8 ++++----
>> > >  fs/ubifs/file.c    | 4 ++--
>> > >  fs/ubifs/journal.c | 6 +++---
>> > >  fs/ubifs/ubifs.h   | 7 -------
>> > >  4 files changed, 9 insertions(+), 16 deletions(-)
>> >
>> > Richard, can you consider applying this to the UBIFS tree for 5.6?
>> 
>> Sure. I'm back from the x-mas break and start collecting patches.
>> 
> 
> Ping?  I see the other UBIFS patches I sent in linux-ubifs.git#linux-next,
> but not this one.

Oh dear, I reviewed but forgot to apply it. Now I'm already traveling without my
kernel.org PGP keys.

The patch is simple and sane, so I'm totally fine if you carry it via fscrypt.
Another option is that Miquel carries it via MTD this time.

In any case:

Acked-by: Richard Weinberger <richard@nod.at>

Sorry for messing this up. :-(

Thanks,
//richard

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ubifs: use IS_ENCRYPTED() instead of ubifs_crypt_is_encrypted()
  2020-01-20  9:44       ` Richard Weinberger
@ 2020-01-20 18:47         ` Eric Biggers
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Biggers @ 2020-01-20 18:47 UTC (permalink / raw)
  To: Richard Weinberger
  Cc: linux-mtd, linux-fscrypt, Chandan Rajendra, Miquel Raynal

On Mon, Jan 20, 2020 at 10:44:29AM +0100, Richard Weinberger wrote:
> 
> ----- Ursprüngliche Mail -----
> > Von: "Eric Biggers" <ebiggers@kernel.org>
> > An: "Richard Weinberger" <richard.weinberger@gmail.com>
> > CC: "richard" <richard@nod.at>, "linux-mtd" <linux-mtd@lists.infradead.org>, "linux-fscrypt"
> > <linux-fscrypt@vger.kernel.org>, "Chandan Rajendra" <chandan@linux.vnet.ibm.com>
> > Gesendet: Montag, 20. Januar 2020 07:54:22
> > Betreff: Re: [PATCH] ubifs: use IS_ENCRYPTED() instead of ubifs_crypt_is_encrypted()
> 
> > On Thu, Jan 09, 2020 at 09:01:09AM +0100, Richard Weinberger wrote:
> >> On Fri, Jan 3, 2020 at 6:09 PM Eric Biggers <ebiggers@kernel.org> wrote:
> >> >
> >> > On Mon, Dec 09, 2019 at 01:27:21PM -0800, Eric Biggers wrote:
> >> > > From: Eric Biggers <ebiggers@google.com>
> >> > >
> >> > > There's no need for the ubifs_crypt_is_encrypted() function anymore.
> >> > > Just use IS_ENCRYPTED() instead, like ext4 and f2fs do.  IS_ENCRYPTED()
> >> > > checks the VFS-level flag instead of the UBIFS-specific flag, but it
> >> > > shouldn't change any behavior since the flags are kept in sync.
> >> > >
> >> > > Signed-off-by: Eric Biggers <ebiggers@google.com>
> >> > > ---
> >> > >  fs/ubifs/dir.c     | 8 ++++----
> >> > >  fs/ubifs/file.c    | 4 ++--
> >> > >  fs/ubifs/journal.c | 6 +++---
> >> > >  fs/ubifs/ubifs.h   | 7 -------
> >> > >  4 files changed, 9 insertions(+), 16 deletions(-)
> >> >
> >> > Richard, can you consider applying this to the UBIFS tree for 5.6?
> >> 
> >> Sure. I'm back from the x-mas break and start collecting patches.
> >> 
> > 
> > Ping?  I see the other UBIFS patches I sent in linux-ubifs.git#linux-next,
> > but not this one.
> 
> Oh dear, I reviewed but forgot to apply it. Now I'm already traveling without my
> kernel.org PGP keys.
> 
> The patch is simple and sane, so I'm totally fine if you carry it via fscrypt.
> Another option is that Miquel carries it via MTD this time.
> 
> In any case:
> 
> Acked-by: Richard Weinberger <richard@nod.at>
> 
> Sorry for messing this up. :-(
> 

I just went ahead and applied it to the fscrypt tree with your Acked-by, since
it doesn't conflict with anything in the UBIFS tree.  Thanks,

- Eric

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-09 21:27 [PATCH] ubifs: use IS_ENCRYPTED() instead of ubifs_crypt_is_encrypted() Eric Biggers
2020-01-03 17:09 ` Eric Biggers
2020-01-09  8:01   ` Richard Weinberger
2020-01-20  6:54     ` Eric Biggers
2020-01-20  9:44       ` Richard Weinberger
2020-01-20 18:47         ` Eric Biggers

Linux-FSCrypt Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-fscrypt/0 linux-fscrypt/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-fscrypt linux-fscrypt/ https://lore.kernel.org/linux-fscrypt \
		linux-fscrypt@vger.kernel.org
	public-inbox-index linux-fscrypt

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-fscrypt


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git