diff mbox series

mtd-utils: mkfs.ubifs with fscrypt does not crypt hardlink files

Message ID 333067545.1988194.1592904950183.JavaMail.zimbra@robart.cc
State Changes Requested
Headers show
Series mtd-utils: mkfs.ubifs with fscrypt does not crypt hardlink files | expand

Commit Message

Manuel Dipolt June 23, 2020, 9:35 a.m. UTC
hi, 

Hardlink files gets not crypted per default via mkfs.ubifs with fscrypt (missing fctx parameter for the add_multi_linked_files function) 

Is http://git.infradead.org/mtd-utils.git currently down? 

yours, 
Manuel 

Patch to crypt also hardlinks:

Comments

David Oberhollenzer June 23, 2020, 10:25 a.m. UTC | #1
Hi,

> Is http://git.infradead.org/mtd-utils.git currently down? > Yes, due to a complete disk failure that occoured over the weekend.

In addition to git.infradead.org, I also push the mtd-utils git tree
to the following locations and try to keep them in sync:

https://git.infraroot.at/mtd-utils.git
https://github.com/sigma-star/mtd-utils.git

> Patch to crypt also hardlinks: 
> 
Besides being pasted into the mail, that patch seems to have its
indentation mangled up pretty badly.

Could you please resend this patch as a proper signed-off commit with
something like git-send-email, so I can simply apply the e-mail and
keep authorship, explanation, etc... in tact?

Thanks,

David
Manuel Dipolt June 23, 2020, 11:43 a.m. UTC | #2
hi,

patch is now in attachment, hope it fits now

yours,
Manuel

----- Original Message -----
From: "David Oberhollenzer" <david.oberhollenzer@sigma-star.at>
To: "Manuel Dipolt" <mdipolt@robart.cc>, "linux-mtd" <linux-mtd@lists.infradead.org>
Sent: Tuesday, June 23, 2020 12:25:45 PM
Subject: Re: mtd-utils: mkfs.ubifs with fscrypt does not crypt hardlink files

Hi,

> Is http://git.infradead.org/mtd-utils.git currently down? > Yes, due to a complete disk failure that occoured over the weekend.

In addition to git.infradead.org, I also push the mtd-utils git tree
to the following locations and try to keep them in sync:

https://git.infraroot.at/mtd-utils.git
https://github.com/sigma-star/mtd-utils.git

> Patch to crypt also hardlinks: 
> 
Besides being pasted into the mail, that patch seems to have its
indentation mangled up pretty badly.

Could you please resend this patch as a proper signed-off commit with
something like git-send-email, so I can simply apply the e-mail and
keep authorship, explanation, etc... in tact?

Thanks,

David
Manuel Dipolt June 23, 2020, 12:24 p.m. UTC | #3
hi,

sorry i overlooked that already posted similar patch: (searched only for hardlink)

https://www.spinics.net/lists/linux-mtd/msg10556.html

question is how to handle the inherit for fscrypt correctly cause hardlink files have two parents or?
with using root context only it worked in my case (opening file on both places was possible)

yours,
Manuel

----- Original Message -----
From: "Manuel Dipolt" <mdipolt@robart.cc>
To: "David Oberhollenzer" <david.oberhollenzer@sigma-star.at>
Cc: "linux-mtd" <linux-mtd@lists.infradead.org>
Sent: Tuesday, June 23, 2020 1:43:24 PM
Subject: Re: mtd-utils: mkfs.ubifs with fscrypt does not crypt hardlink files

hi,

patch is now in attachment, hope it fits now

yours,
Manuel

----- Original Message -----
From: "David Oberhollenzer" <david.oberhollenzer@sigma-star.at>
To: "Manuel Dipolt" <mdipolt@robart.cc>, "linux-mtd" <linux-mtd@lists.infradead.org>
Sent: Tuesday, June 23, 2020 12:25:45 PM
Subject: Re: mtd-utils: mkfs.ubifs with fscrypt does not crypt hardlink files

Hi,

> Is http://git.infradead.org/mtd-utils.git currently down? > Yes, due to a complete disk failure that occoured over the weekend.

In addition to git.infradead.org, I also push the mtd-utils git tree
to the following locations and try to keep them in sync:

https://git.infraroot.at/mtd-utils.git
https://github.com/sigma-star/mtd-utils.git

> Patch to crypt also hardlinks: 
> 
Besides being pasted into the mail, that patch seems to have its
indentation mangled up pretty badly.

Could you please resend this patch as a proper signed-off commit with
something like git-send-email, so I can simply apply the e-mail and
keep authorship, explanation, etc... in tact?

Thanks,

David
Richard Weinberger June 23, 2020, 1:20 p.m. UTC | #4
On Tue, Jun 23, 2020 at 2:31 PM Manuel Dipolt <mdipolt@robart.cc> wrote:
>
> hi,
>
> sorry i overlooked that already posted similar patch: (searched only for hardlink)
>
> https://www.spinics.net/lists/linux-mtd/msg10556.html
>
> question is how to handle the inherit for fscrypt correctly cause hardlink files have two parents or?
> with using root context only it worked in my case (opening file on both places was possible)

The inode will always have just one parent, it has just more than one name.
Right now fscrypt seems to have a simple inheritance model where
always from the root context is inherited.
This is why the patch you mentioned works. But this can change in
future fscrypt modes.
See fscrypt_inherit_context().

So I suggest implementing it properly in mkfs.ubifs.

Anyway, thanks a lot for bringing this issue up again! I completely
forgot about it.
If you have further questions, don't hesitate to ask.
diff mbox series

Patch

diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c 
index 0b5e2e0..c32ebc3 100644 
--- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c 
+++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c 
@@ -2202,7 +2200,7 @@  out_free: 
/** 
* add_multi_linked_files - write all the files for which we counted links. 
*/ 
-static int add_multi_linked_files(void) 
+static int add_multi_linked_files(struct fscrypt_context *fctx) 
{ 
int i, err; 

@@ -2213,7 +2211,7 @@  static int add_multi_linked_files(void) 
for (im = hash_table[i]; im; im = im->next) { 
dbg_msg(2, "%s", im->path_name); 
err = add_non_dir(im->path_name, &im->use_inum, 
- im->use_nlink, &type, &im->st, NULL); 
+ im->use_nlink, &type, &im->st, fctx); 
if (err) 
return err; 
} 
@@ -2264,7 +2262,7 @@  static int write_data(void) 
err = add_directory(root, UBIFS_ROOT_INO, &root_st, !!root, root_fctx); 
if (err) 
return err; 
- err = add_multi_linked_files(); 
+ err = add_multi_linked_files(root_fctx); 
if (err) 
return err; 
return flush_nodes();