All of lore.kernel.org
 help / color / mirror / Atom feed
* Consolidated file encryption interface/semantics?
@ 2016-01-11 22:56 Richard Weinberger
  2016-01-11 23:36 ` Dave Chinner
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Richard Weinberger @ 2016-01-11 22:56 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-f2fs-devel, linux-ext4

Hi!

I consider adding file encryption to UBIFS.
While looking into ext4 and f2fs I realized that both
use the same data structures/concepts.

f2fs copy&pasted a lot from ext4.
Before I do the next copy&paste, I'd to ask whether it would make sense
to more parts of the ioctl() interface out to VFS?

Let's checkout the user visible interface:

ext4 offers:
EXT4_IOC_SET_ENCRYPTION_POLICY
EXT4_IOC_GET_ENCRYPTION_PWSALT
EXT4_IOC_GET_ENCRYPTION_POLICY

with:
#define EXT4_KEY_DESCRIPTOR_SIZE 8

/* Policy provided via an ioctl on the topmost directory */
struct ext4_encryption_policy {
        char version;
        char contents_encryption_mode;
        char filenames_encryption_mode;
        char flags;
        char master_key_descriptor[EXT4_KEY_DESCRIPTOR_SIZE];
} __attribute__((__packed__));


f2fs:
F2FS_IOC_SET_ENCRYPTION_POLICY
F2FS_IOC_GET_ENCRYPTION_POLICY
F2FS_IOC_GET_ENCRYPTION_PWSALT

#define F2FS_KEY_DESCRIPTOR_SIZE        8

/* Policy provided via an ioctl on the topmost directory */
struct f2fs_encryption_policy {
        char version;
        char contents_encryption_mode;
        char filenames_encryption_mode;
        char flags;
        char master_key_descriptor[F2FS_KEY_DESCRIPTOR_SIZE];
} __attribute__((__packed__));

So, the data structures are identical and AFAIK also the supported cipher modes are.
But as both use their own ioctls having a single tool to control file encryption
can be error prone in future.
Interestingly the current ioctls for ext4 and f2fs resolve to the same integers,
is this on purpose? :)

Wouldn't it be worthwhile having exactly the same ioctls such that util-linux could offer
a decent file encryption tool which can be used by all file systems with file encryption
support?

Another thing are semantics, ext4 implemented a policy which controls
under which conditions encrypted files are allowed to be unlinked, moved, etc...
f2fs adopted these from ext4. But can't we do that in VFS or at least
agree one a policy and document it? :-)

Thanks,
//richard

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

end of thread, other threads:[~2016-01-12 16:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-11 22:56 Consolidated file encryption interface/semantics? Richard Weinberger
2016-01-11 23:36 ` Dave Chinner
2016-01-12  5:30 ` Theodore Ts'o
2016-01-12  7:47 ` [f2fs-dev] " Jaegeuk Kim
2016-01-12 16:21   ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.