Split fsverity-utils into a shared library
Subsystems (2)
cover Split fsverity-utils into a shared library
From: Jes Sorensen <[email protected]>
Hi,
I am looking at what it will take to add support for fsverity signatures to rpm, similar to how rpm supports IMA signatures.
In order to do so, it makes sense to split the fsverity util into a shared library and the command line tool, so the core functions can be used from other applciations. Alternatively I will have to copy over a good chunk of the code into rpm, which makes it nasty to support long term.
This is a first stab at doing that, and I'd like to get some feedback on the approach.
I basically split it into four functions:
fsverity_cmd_gen_digest(): Build the digest, but do not sign it fsverity_cmd_sign(): Sign the digest structure fsverity_cmd_measure(): Measure a file, basically 'fsverity measure' fsverity_cmd_enable(): Enable verity on a file, basically 'fsverity enable'
If we can agree on the approach, then I am happy to deal with the full libtoolification etc.
Jes
Jes Sorensen (7):
Build basic shared library
Restructure fsverity_cmd_sign for shared libraries Make fsverity_cmd_measure() a library function Make fsverity_cmd_enable a library call() Rename commands.h to fsverity.h
Move cmdline helper functions to fsverity.c
cmd_sign: fsverity_cmd_sign() into two functions
Makefile | 18 ++- cmd_enable.c | 133 +------------------ cmd_measure.c | 51 ++------ cmd_sign.c | 168 ++++++------------------ commands.h | 24 ---- fsverity.c | 345 +++++++++++++++++++++++++++++++++++++++++++++++--- fsverity.h | 38 ++++++ util.c | 13 ++ 8 files changed, 446 insertions(+), 344 deletions(-) delete mode 100644 commands.h create mode 100644 fsverity.h
Signature · 1 line
2.24.1
PATCH 1/7 Build basic shared library
From: Jes Sorensen <[email protected]>
--- Makefile | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
Makefile +15 -3
@@ -1,20 +1,32 @@ EXE := fsverity +LIB := libfsverity.so CFLAGS := -O2 -Wall CPPFLAGS := -D_FILE_OFFSET_BITS=64 LDLIBS := -lcrypto DESTDIR := /usr/local +LIBDIR := /usr/lib64 SRC := $(wildcard *.c) -OBJ := $(SRC:.c=.o) +OBJ := fsverity.o +SSRC := hash_algs.c cmd_sign.c cmd_enable.c cmd_measure.c util.c +SOBJ := hash_algs.so cmd_sign.so cmd_enable.so cmd_measure.so util.so HDRS := $(wildcard *.h) all:$(EXE) -$(EXE):$(OBJ) +$(EXE):$(OBJ) $(LIB) + $(CC) -o $@ $< -L . -l fsverity $(OBJ): %.o: %.c $(HDRS) + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ + +$(SOBJ): %.so: %.c $(HDRS) + $(CC) -c -fPIC $(CFLAGS) $(CPPFLAGS) $< -o $@ + +libfsverity.so: $(SOBJ) + $(CC) $(LDLIBS) -shared -o libfsverity.so $(SOBJ) clean: - rm -f $(EXE) $(OBJ) + rm -f $(EXE) $(OBJ) $(SOBJ) $(LIB) install:all install -Dm755 -t $(DESTDIR)/bin $(EXE)
Signature · 1 line
2.24.1
PATCH 2/7 Restructure fsverity_cmd_sign for shared libraries
In reply to Jes SorensenFrom: Jes Sorensen <[email protected]>
This moves the command line parsing, error reporting etc. to the command line tool, and turns fsverity_cmd_sign() into a call returning the digest and the signature.
It is the responsibility of the caller to decide what to do with the returned objects.
--- cmd_sign.c | 132 ++++++----------------------------------------------- commands.h | 23 +++++++++- fsverity.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 163 insertions(+), 121 deletions(-)
cmd_sign.c +14 -118
@@ -8,7 +8,6 @@*/ #include <fcntl.h> -#include <getopt.h> #include <limits.h> #include <openssl/bio.h> #include <openssl/err.h>
@@ -38,19 +37,6 @@ struct fsverity_descriptor {__u8 signature[];/* optional PKCS#7 signature */ }; -/* -* Format in which verity file measurements are signed. This is the same as -* 'struct fsverity_digest', except here some magic bytes are prepended to -* provide some context about what is being signed in case the same key is used -* for non-fsverity purposes, and here the fields have fixed endianness. -*/ -struct fsverity_signed_digest { -char magic[8 ];/* must be "FSVerity" */ -__le16 digest_algorithm; -__le16 digest_size; -__u8 digest[]; -}; - static void __printf(1, 2) __cold error_msg_openssl(const char *format, ...) {
@@ -340,18 +326,6 @@ out:return ok; } -static bool write_signature (const char *filename,const u8 *sig,u32 sig_size) -{ -struct filedes file; -bool ok; - -if (!open_file (&file, filename,O_WRONLY |O_CREAT |O_TRUNC ,0644 )) -return false; - ok =full_write (&file, sig, sig_size); - ok &=filedes_close (&file); -return ok; -} -#define FS_VERITY_MAX_LEVELS 64struct block_buffer {
@@ -507,93 +481,27 @@ out:return ok; } -enum { -OPT_HASH_ALG , -OPT_BLOCK_SIZE , -OPT_SALT , -OPT_KEY , -OPT_CERT , -}; - -static const struct option longopts[] = { - {"hash-alg" , required_argument,NULL ,OPT_HASH_ALG }, - {"block-size" , required_argument,NULL ,OPT_BLOCK_SIZE }, - {"salt" , required_argument,NULL ,OPT_SALT }, - {"key" , required_argument,NULL ,OPT_KEY }, - {"cert" , required_argument,NULL ,OPT_CERT }, - {NULL ,0 ,NULL ,0 } -}; -/* Sign a file for fs-verity by computing its measurement, then signing it. */ -int fsverity_cmd_sign (const struct fsverity_command *cmd, -int argc,char *argv[]) +int fsverity_cmd_sign (char *filename,const struct fsverity_hash_alg *hash_alg, +u32 block_size,u8 *salt,u32 salt_size, +const char *keyfile,const char *certfile, +struct fsverity_signed_digest **retdigest, +u8 **sig,u32 *sig_size) { -const struct fsverity_hash_alg *hash_alg =NULL ; -u32 block_size =0 ; -u8 *salt =NULL ; -u32 salt_size =0 ; -const char *keyfile =NULL ; -const char *certfile =NULL ;struct fsverity_signed_digest *digest =NULL ; -char digest_hex[FS_VERITY_MAX_DIGEST_SIZE *2 +1 ]; -u8 *sig =NULL ; -u32 sig_size;int status; -int c; - -while ((c =getopt_long (argc, argv,"" , longopts,NULL )) !=-1 ) { -switch (c) { -case OPT_HASH_ALG : -if (hash_alg !=NULL ) { -error_msg ("--hash-alg can only be specified once" ); - goto out_usage; - } - hash_alg =find_hash_alg_by_name (optarg); -if (hash_alg ==NULL ) - goto out_usage; -break ; -case OPT_BLOCK_SIZE : -if (!parse_block_size_option (optarg, &block_size)) - goto out_usage; -break ; -case OPT_SALT : -if (!parse_salt_option (optarg, &salt, &salt_size)) - goto out_usage; -break ; -case OPT_KEY : -if (keyfile !=NULL ) { -error_msg ("--key can only be specified once" ); - goto out_usage; - } - keyfile = optarg; -break ; -case OPT_CERT : -if (certfile !=NULL ) { -error_msg ("--cert can only be specified once" ); - goto out_usage; - } - certfile = optarg; -break ; -default : - goto out_usage; - } - } - argv += optind; - argc -= optind; - -if (argc !=2 ) - goto out_usage; - -if (hash_alg ==NULL ) - hash_alg = &fsverity_hash_algs[FS_VERITY_HASH_ALG_DEFAULT ]; +if (hash_alg ==NULL ) { + status = -EINVAL ; + goto out; + }if (block_size ==0 ) block_size =get_default_block_size ();if (keyfile ==NULL ) { -error_msg ("Missing --key argument" ); - goto out_usage; + status = -EINVAL ; + goto out; }if (certfile ==NULL ) certfile = keyfile;
@@ -603,33 +511,21 @@ int fsverity_cmd_sign(const struct fsverity_command *cmd, digest->digest_algorithm =cpu_to_le16 (hash_alg - fsverity_hash_algs); digest->digest_size =cpu_to_le16 (hash_alg->digest_size); -if (!compute_file_measurement (argv[0 ], hash_alg, block_size, +if (!compute_file_measurement (filename, hash_alg, block_size, salt, salt_size, digest->digest)) goto out_err;if (!sign_data (digest,sizeof (*digest) + hash_alg->digest_size, - keyfile, certfile, hash_alg, &sig, &sig_size)) - goto out_err; - -if (!write_signature (argv[1 ], sig, sig_size)) + keyfile, certfile, hash_alg, sig, sig_size)) goto out_err; -bin2hex (digest->digest, hash_alg->digest_size, digest_hex); -printf ("Signed file '%s' (%s:%s)\n" , argv[0 ], hash_alg->name, - digest_hex); + *retdigest = digest; status =0 ; out: -free (salt); -free (digest); -free (sig);return status; out_err: status =1 ; goto out; -out_usage: -usage (cmd, stderr); - status =2 ; - goto out; }
commands.h +21 -2
@@ -5,17 +5,36 @@#include <stdio.h> #include "util.h" +#include "hash_algs.h" +#include "fsverity_uapi.h" struct fsverity_command ; +/* +* Format in which verity file measurements are signed. This is the same as +* 'struct fsverity_digest', except here some magic bytes are prepended to +* provide some context about what is being signed in case the same key is used +* for non-fsverity purposes, and here the fields have fixed endianness. +*/ +struct fsverity_signed_digest { +char magic[8 ];/* must be "FSVerity" */ +__le16 digest_algorithm; +__le16 digest_size; +__u8 digest[]; +}; + +void usage (const struct fsverity_command *cmd,FILE *fp);int fsverity_cmd_enable (const struct fsverity_command *cmd,int argc,char *argv[]);int fsverity_cmd_measure (const struct fsverity_command *cmd,int argc,char *argv[]); -int fsverity_cmd_sign (const struct fsverity_command *cmd, -int argc,char *argv[]); +int fsverity_cmd_sign (char *filename,const struct fsverity_hash_alg *hash_alg, +u32 block_size,u8 *salt,u32 salt_size, +const char *keyfile,const char *certfile, +struct fsverity_signed_digest **retdigest, +u8 **sig,u32 *sig_size);bool parse_block_size_option (const char *arg,u32 *size_ptr);u32 get_default_block_size (void );
fsverity.c +128 -1
149 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH 3/7 Make fsverity_cmd_measure() a library function
In reply to Jes SorensenFrom: Jes Sorensen <[email protected]>
This splits the cmdline option parsing into wrap_cmd_measure() and fsverity_cmd_measure() is just the basic call to the ioctl.
--- cmd_measure.c | 49 +++++++++---------------------------------------- commands.h | 3 +-- fsverity.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 43 deletions(-)
cmd_measure.c +9 -40
@@ -13,50 +13,24 @@#include "commands.h" #include "fsverity_uapi.h" -#include "hash_algs.h" /* Display the measurement of the given verity file(s). */ -int fsverity_cmd_measure (const struct fsverity_command *cmd, -int argc,char *argv[]) +int fsverity_cmd_measure (char *filename,struct fsverity_digest *d) { -struct fsverity_digest *d =NULL ;struct filedes file; -char digest_hex[FS_VERITY_MAX_DIGEST_SIZE *2 +1 ]; -const struct fsverity_hash_alg *hash_alg; -char _hash_alg_name[32 ]; -const char *hash_alg_name;int status; -int i; -if (argc <2 ) - goto out_usage; +if (!open_file (&file, filename,O_RDONLY ,0 )) + goto out_err; - d =xzalloc (sizeof (*d) +FS_VERITY_MAX_DIGEST_SIZE ); - -for (i =1 ; i < argc; i++) { - d->digest_size =FS_VERITY_MAX_DIGEST_SIZE ; - -if (!open_file (&file, argv[i],O_RDONLY ,0 )) - goto out_err; -if (ioctl (file.fd,FS_IOC_MEASURE_VERITY , d) !=0 ) { -error_msg_errno ("FS_IOC_MEASURE_VERITY failed on '%s'" , - file.name); -filedes_close (&file); - goto out_err; - } +if (ioctl (file.fd,FS_IOC_MEASURE_VERITY , d) !=0 ) { +error_msg_errno ("FS_IOC_MEASURE_VERITY failed on '%s'" , + file.name);filedes_close (&file); - -ASSERT (d->digest_size <=FS_VERITY_MAX_DIGEST_SIZE ); -bin2hex (d->digest, d->digest_size, digest_hex); - hash_alg =find_hash_alg_by_num (d->digest_algorithm); -if (hash_alg) { - hash_alg_name = hash_alg->name; - }else { -sprintf (_hash_alg_name,"ALG_%u" , d->digest_algorithm); - hash_alg_name = _hash_alg_name; - } -printf ("%s:%s %s\n" , hash_alg_name, digest_hex, argv[i]); + goto out_err; } +filedes_close (&file); + status =0 ; out:free (d);
@@ -65,9 +39,4 @@ out: out_err: status =1 ; goto out; - -out_usage: -usage (cmd, stderr); - status =2 ; - goto out; }
commands.h +1 -2
@@ -28,8 +28,7 @@ void usage(const struct fsverity_command *cmd, FILE *fp);int fsverity_cmd_enable (const struct fsverity_command *cmd,int argc,char *argv[]); -int fsverity_cmd_measure (const struct fsverity_command *cmd, -int argc,char *argv[]); +int fsverity_cmd_measure (char *filename,struct fsverity_digest *d); int fsverity_cmd_sign(char *filename, const struct fsverity_hash_alg *hash_alg, u32 block_size, u8 *salt, u32 salt_size, const char *keyfile, const char *certfile,
fsverity.c +49 -1
62 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH 4/7 Make fsverity_cmd_enable a library call()
In reply to Jes SorensenFrom: Jes Sorensen <[email protected]>
Split the parsing of command line arguments from the actual cmd call, which allows this to be called by other users.
--- cmd_enable.c | 131 ++---------------------------------------------- commands.h | 3 +- fsverity.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 140 insertions(+), 131 deletions(-)
cmd_enable.c +3 -128
@@ -18,137 +18,17 @@#include "fsverity_uapi.h" #include "hash_algs.h" -static bool parse_hash_alg_option (const char *arg,u32 *alg_ptr) -{ -char *end; -unsigned long n =strtoul (arg, &end,10 ); -const struct fsverity_hash_alg *alg; - -if (*alg_ptr !=0 ) { -error_msg ("--hash-alg can only be specified once" ); -return false; - } - -/* Specified by number? */ -if (n >0 && n <INT32_MAX && *end =='\0' ) { - *alg_ptr = n; -return true; - } - -/* Specified by name? */ - alg =find_hash_alg_by_name (arg); -if (alg !=NULL ) { - *alg_ptr = alg - fsverity_hash_algs; -return true; - } -return false; -} - -static bool read_signature (const char *filename,u8 **sig_ret, -u32 *sig_size_ret) -{ -struct filedes file = { .fd =-1 }; -u64 file_size; -u8 *sig =NULL ; -bool ok = false; - -if (!open_file (&file, filename,O_RDONLY ,0 )) - goto out; -if (!get_file_size (&file, &file_size)) - goto out; -if (file_size <=0 ) { -error_msg ("signature file '%s' is empty" , filename); - goto out; - } -if (file_size >1000000 ) { -error_msg ("signature file '%s' is too large" , filename); - goto out; - } - sig =xmalloc (file_size); -if (!full_read (&file, sig, file_size)) - goto out; - *sig_ret = sig; - *sig_size_ret = file_size; - sig =NULL ; - ok = true; -out: -filedes_close (&file); -free (sig); -return ok; -} - -enum { -OPT_HASH_ALG , -OPT_BLOCK_SIZE , -OPT_SALT , -OPT_SIGNATURE , -}; - -static const struct option longopts[] = { - {"hash-alg" , required_argument,NULL ,OPT_HASH_ALG }, - {"block-size" , required_argument,NULL ,OPT_BLOCK_SIZE }, - {"salt" , required_argument,NULL ,OPT_SALT }, - {"signature" , required_argument,NULL ,OPT_SIGNATURE }, - {NULL ,0 ,NULL ,0 } -}; -/* Enable fs-verity on a file. */ -int fsverity_cmd_enable (const struct fsverity_command *cmd, -int argc,char *argv[]) +int fsverity_cmd_enable (char *filename,struct fsverity_enable_arg *arg) { -struct fsverity_enable_arg arg = { .version =1 };u8 *salt =NULL ;u8 *sig =NULL ;struct filedes file;int status; -int c; - -while ((c =getopt_long (argc, argv,"" , longopts,NULL )) !=-1 ) { -switch (c) { -case OPT_HASH_ALG : -if (!parse_hash_alg_option (optarg, &arg.hash_algorithm)) - goto out_usage; -break ; -case OPT_BLOCK_SIZE : -if (!parse_block_size_option (optarg, &arg.block_size)) - goto out_usage; -break ; -case OPT_SALT : -if (!parse_salt_option (optarg, &salt, &arg.salt_size)) - goto out_usage; - arg.salt_ptr = (uintptr_t )salt; -break ; -case OPT_SIGNATURE : -if (sig !=NULL ) { -error_msg ("--signature can only be specified once" ); - goto out_usage; - } -if (!read_signature (optarg, &sig, &arg.sig_size)) - goto out_err; - arg.sig_ptr = (uintptr_t )sig; -break ; -default : - goto out_usage; - } - } - argv += optind; - argc -= optind; - -if (argc !=1 ) - goto out_usage; - -if (arg.hash_algorithm ==0 ) - arg.hash_algorithm =FS_VERITY_HASH_ALG_DEFAULT ; - -if (arg.block_size ==0 ) - arg.block_size =get_default_block_size (); - -if (!open_file (&file, argv[0 ],O_RDONLY ,0 )) +if (!open_file (&file, filename,O_RDONLY ,0 )) goto out_err; -if (ioctl (file.fd,FS_IOC_ENABLE_VERITY , &arg) !=0 ) { -error_msg_errno ("FS_IOC_ENABLE_VERITY failed on '%s'" , - file.name); +if (ioctl (file.fd,FS_IOC_ENABLE_VERITY , arg) !=0 ) {filedes_close (&file); goto out_err; }
@@ -164,9 +44,4 @@ out: out_err: status =1 ; goto out; - -out_usage: -usage (cmd, stderr); - status =2 ; - goto out; }
commands.h +1 -2
@@ -26,8 +26,7 @@ struct fsverity_signed_digest {void usage (const struct fsverity_command *cmd,FILE *fp); -int fsverity_cmd_enable (const struct fsverity_command *cmd, -int argc,char *argv[]); +int fsverity_cmd_enable (char *filename,struct fsverity_enable_arg *arg);int fsverity_cmd_measure (char *filename,struct fsverity_digest *d); int fsverity_cmd_sign(char *filename, const struct fsverity_hash_alg *hash_alg, u32 block_size, u8 *salt, u32 salt_size,
fsverity.c +136 -1
167 lines not on this page · raw message
Signature · 1 line
2.24.1
PATCH 5/7 Rename commands.h to fsverity.h
In reply to Jes SorensenFrom: Jes Sorensen <[email protected]>
This is a more appropriate name to provide the API for the shared library
--- cmd_enable.c | 2 +- cmd_measure.c | 2 +- cmd_sign.c | 2 +- fsverity.c | 2 +- commands.h => fsverity.h | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename commands.h => fsverity.h (100%)
cmd_enable.c +1 -1
@@ -14,7 +14,7 @@#include <string.h> #include <sys/ioctl.h> -#include "commands.h" +#include "fsverity.h" #include "fsverity_uapi.h" #include "hash_algs.h"
cmd_measure.c +1 -1
@@ -11,7 +11,7 @@#include <stdlib.h> #include <sys/ioctl.h> -#include "commands.h" +#include "fsverity.h" #include "fsverity_uapi.h" /* Display the measurement of the given verity file(s). */
cmd_sign.c +1 -1
@@ -16,7 +16,7 @@#include <stdlib.h> #include <string.h> -#include "commands.h" +#include "fsverity.h" #include "fsverity_uapi.h" #include "hash_algs.h"
fsverity.c +1 -1
@@ -15,7 +15,7 @@#include <getopt.h> #include <errno.h> -#include "commands.h" +#include "fsverity.h" #include "hash_algs.h" enum {
fsverity.h renamed from commands.h +0 -0
Signature · 1 line
2.24.1
PATCH 6/7 Move cmdline helper functions to fsverity.c
In reply to Jes SorensenFrom: Jes Sorensen <[email protected]>
There is no need for these to live in the shared library. In addition move get_default_block_size() to the library and rename it appropriately.
--- cmd_sign.c | 2 +- fsverity.c | 25 +++++++++---------------- fsverity.h | 8 +------- util.c | 13 +++++++++++++ 4 files changed, 24 insertions(+), 24 deletions(-)
cmd_sign.c +1 -1
@@ -497,7 +497,7 @@ int fsverity_cmd_sign(char *filename, const struct fsverity_hash_alg *hash_alg, }if (block_size ==0 ) - block_size =get_default_block_size (); + block_size =fsverity_get_default_block_size ();if (keyfile ==NULL ) { status = -EINVAL ;
fsverity.c +9 -16
@@ -18,6 +18,12 @@#include "fsverity.h" #include "hash_algs.h" +struct fsverity_command ; + +static bool parse_block_size_option (const char *arg,u32 *size_ptr); +static bool parse_salt_option (const char *arg,u8 **salt_ptr,u32 *salt_size_ptr); +static void usage (const struct fsverity_command *cmd,FILE *fp); +enum {OPT_HASH_ALG ,OPT_BLOCK_SIZE ,
@@ -310,7 +316,7 @@ int wrap_cmd_enable(const struct fsverity_command *cmd, arg.hash_algorithm =FS_VERITY_HASH_ALG_DEFAULT ;if (arg.block_size ==0 ) - arg.block_size =get_default_block_size (); + arg.block_size =fsverity_get_default_block_size (); status =fsverity_cmd_enable (argv[0 ], &arg);
@@ -437,7 +443,7 @@ static const struct fsverity_command *find_command(const char *name)return NULL ; } -bool parse_block_size_option (const char *arg,u32 *size_ptr) +static bool parse_block_size_option (const char *arg,u32 *size_ptr) {char *end;unsigned long n =strtoul (arg, &end,10 );
@@ -455,7 +461,7 @@ bool parse_block_size_option(const char *arg, u32 *size_ptr)return true; } -bool parse_salt_option (const char *arg,u8 **salt_ptr,u32 *salt_size_ptr) +static bool parse_salt_option (const char *arg,u8 **salt_ptr,u32 *salt_size_ptr) {if (*salt_ptr !=NULL ) {error_msg ("--salt can only be specified once" );
@@ -470,19 +476,6 @@ bool parse_salt_option(const char *arg, u8 **salt_ptr, u32 *salt_size_ptr)return true; } -u32 get_default_block_size (void ) -{ -long n =sysconf (_SC_PAGESIZE); - -if (n <=0 || n >=INT_MAX || !is_power_of_2 (n)) { -fprintf (stderr, -"Warning: invalid _SC_PAGESIZE (%ld). Assuming 4K blocks.\n" , - n); -return 4096 ; - } -return n; -} -int main (int argc,char *argv[]) {const struct fsverity_command *cmd;
fsverity.h +1 -7
@@ -8,8 +8,6 @@#include "hash_algs.h" #include "fsverity_uapi.h" -struct fsverity_command ; -/* * Format in which verity file measurements are signed. This is the same as * 'struct fsverity_digest', except here some magic bytes are prepended to
@@ -24,7 +22,7 @@ struct fsverity_signed_digest { }; -void usage (const struct fsverity_command *cmd,FILE *fp); +u32 fsverity_get_default_block_size (void );int fsverity_cmd_enable (char *filename,struct fsverity_enable_arg *arg);int fsverity_cmd_measure (char *filename,struct fsverity_digest *d);
@@ -34,8 +32,4 @@ int fsverity_cmd_sign(char *filename, const struct fsverity_hash_alg *hash_alg,struct fsverity_signed_digest **retdigest, u8 **sig, u32 *sig_size); -bool parse_block_size_option (const char *arg,u32 *size_ptr); -u32 get_default_block_size (void ); -bool parse_salt_option (const char *arg,u8 **salt_ptr,u32 *salt_size_ptr); -#endif /* COMMANDS_H */
util.c +13 -0
@@ -213,3 +213,16 @@ void bin2hex(const u8 *bin, size_t bin_len, char *hex) } *hex ='\0' ; } + +u32 fsverity_get_default_block_size (void ) +{ +long n =sysconf (_SC_PAGESIZE); + +if (n <=0 || n >=INT_MAX || !is_power_of_2 (n)) { +fprintf (stderr, +"Warning: invalid _SC_PAGESIZE (%ld). Assuming 4K blocks.\n" , + n); +return 4096 ; + } +return n; +}
Signature · 1 line
2.24.1
PATCH 7/7 cmd_sign: fsverity_cmd_sign() into two functions
In reply to Jes SorensenFrom: Jes Sorensen <[email protected]>
This splits cmd_sign() into a gen_digest() and a sign_digest() function, and fixes fsverity.c to use them appropriately.
--- cmd_sign.c | 50 +++++++++++++++++++++++++++++++++----------------- fsverity.c | 8 ++++++-- fsverity.h | 13 ++++++++----- 3 files changed, 47 insertions(+), 24 deletions(-)
cmd_sign.c +33 -17
@@ -481,12 +481,11 @@ out:return ok; } -/* Sign a file for fs-verity by computing its measurement, then signing it. */ -int fsverity_cmd_sign (char *filename,const struct fsverity_hash_alg *hash_alg, -u32 block_size,u8 *salt,u32 salt_size, -const char *keyfile,const char *certfile, -struct fsverity_signed_digest **retdigest, -u8 **sig,u32 *sig_size) +/* Generate the fsverity digest computing its measurement. */ +int fsverity_cmd_gen_digest (char *filename, +const struct fsverity_hash_alg *hash_alg, +u32 block_size,u8 *salt,u32 salt_size, +struct fsverity_signed_digest **retdigest) {struct fsverity_signed_digest *digest =NULL ;int status;
@@ -499,13 +498,6 @@ int fsverity_cmd_sign(char *filename, const struct fsverity_hash_alg *hash_alg,if (block_size ==0 ) block_size =fsverity_get_default_block_size (); -if (keyfile ==NULL ) { - status = -EINVAL ; - goto out; - } -if (certfile ==NULL ) - certfile = keyfile; - digest =xzalloc (sizeof (*digest) + hash_alg->digest_size);memcpy (digest->magic,"FSVerity" ,8 ); digest->digest_algorithm =cpu_to_le16 (hash_alg - fsverity_hash_algs);
@@ -515,10 +507,6 @@ int fsverity_cmd_sign(char *filename, const struct fsverity_hash_alg *hash_alg, salt, salt_size, digest->digest)) goto out_err; -if (!sign_data (digest,sizeof (*digest) + hash_alg->digest_size, - keyfile, certfile, hash_alg, sig, sig_size)) - goto out_err; - *retdigest = digest; status =0 ; out:
@@ -529,3 +517,31 @@ out_err: goto out; } + +/* Sign a pre-generated fsverity_signed_digest structure */ +int fsverity_cmd_sign_digest (struct fsverity_signed_digest *digest, +const struct fsverity_hash_alg *hash_alg, +const char *keyfile,const char *certfile, +u8 **sig,u32 *sig_size) +{ +int status; + +if (keyfile ==NULL ) { + status = -EINVAL ; + goto out; + } +if (certfile ==NULL ) + certfile = keyfile; + +if (!sign_data (digest,sizeof (*digest) + hash_alg->digest_size, + keyfile, certfile, hash_alg, sig, sig_size)) + goto out_err; + + status =0 ; + out: +return status; + + out_err: + status =1 ; + goto out; +}
fsverity.c +6 -2
@@ -188,8 +188,12 @@ int wrap_cmd_sign(const struct fsverity_command *cmd, int argc, char *argv[])if (argc !=2 ) goto out_usage; - status =fsverity_cmd_sign (argv[0 ], hash_alg, block_size, salt, salt_size, - keyfile, certfile, &digest, &sig, &sig_size); + status =fsverity_cmd_gen_digest (argv[0 ], hash_alg, block_size, + salt, salt_size, &digest); +if (status) + goto out_usage; + status =fsverity_cmd_sign_digest (digest, hash_alg, keyfile, certfile, + &sig, &sig_size);if (status == -EINVAL ) goto out_usage;if (status !=0 )
fsverity.h +8 -5
@@ -26,10 +26,13 @@ u32 fsverity_get_default_block_size(void);int fsverity_cmd_enable (char *filename,struct fsverity_enable_arg *arg);int fsverity_cmd_measure (char *filename,struct fsverity_digest *d); -int fsverity_cmd_sign (char *filename,const struct fsverity_hash_alg *hash_alg, -u32 block_size,u8 *salt,u32 salt_size, -const char *keyfile,const char *certfile, -struct fsverity_signed_digest **retdigest, -u8 **sig,u32 *sig_size); +int fsverity_cmd_gen_digest (char *filename, +const struct fsverity_hash_alg *hash_alg, +u32 block_size,u8 *salt,u32 salt_size, +struct fsverity_signed_digest **retdigest); +int fsverity_cmd_sign_digest (struct fsverity_signed_digest *digest, +const struct fsverity_hash_alg *hash_alg, +const char *keyfile,const char *certfile, +u8 **sig,u32 *sig_size);#endif /* COMMANDS_H */
Signature · 1 line
2.24.1
Eric Biggers
maintainerHi Jes,
Quoted 18 lines · Jes Sorensen
From: Jes Sorensen <[email protected]>
Hi,
I am looking at what it will take to add support for fsverity signatures to rpm, similar to how rpm supports IMA signatures.
In order to do so, it makes sense to split the fsverity util into a shared library and the command line tool, so the core functions can be used from other applciations. Alternatively I will have to copy over a good chunk of the code into rpm, which makes it nasty to support long term.
This is a first stab at doing that, and I'd like to get some feedback on the approach.
I basically split it into four functions:
Quoted 8 lines
fsverity_cmd_gen_digest(): Build the digest, but do not sign it fsverity_cmd_sign(): Sign the digest structure fsverity_cmd_measure(): Measure a file, basically 'fsverity measure' fsverity_cmd_enable(): Enable verity on a file, basically 'fsverity enable'If we can agree on the approach, then I am happy to deal with the full libtoolification etc.
Before we do all this work, can you take a step back and explain the use case so that we can be sure it's really worthwhile?
fsverity_cmd_enable() and fsverity_cmd_measure() would just be trivial wrappers around the FS_IOC_ENABLE_VERITY and FS_IOC_MEASURE_VERITY ioctls, so they don't need a library. [Aside: I'd suggest calling these fsverity_enable() and fsverity_measure(), and leaving "cmd" for the command-line wrappers.]
That leaves signing as the only real point of the library. But do you actually need to be able to *sign* the files via the rpm binary, or do you just need to be able to install already-created signatures? I.e., can the signatures instead just be created with 'fsverity sign' when building the RPMs?
Separately, before you start building something around fs-verity's builtin signature verification support, have you also considered adding support for fs-verity to IMA? I.e., using the fs-verity hashing mechanism with the IMA signature mechanism. The IMA maintainer has been expressed interested in that. If rpm already supports IMA signatures, maybe that way would be a better fit?
- Eric
Quoted 15 lines · Eric Biggers
Hi Jes,
Quoted 3 lines · Jes Sorensen
From: Jes Sorensen <[email protected]>
If we can agree on the approach, then I am happy to deal with the full libtoolification etc.Before we do all this work, can you take a step back and explain the use case so that we can be sure it's really worthwhile?
fsverity_cmd_enable()andfsverity_cmd_measure()would just be trivial wrappers around theFS_IOC_ENABLE_VERITYandFS_IOC_MEASURE_VERITYioctls, so they don't need a library. [Aside: I'd suggest calling thesefsverity_enable()andfsverity_measure(), and leaving "cmd" for the command-line wrappers.]
Quoted 4 lines
That leaves signing as the only real point of the library. But do you actually need to be able to *sign* the files via the rpm binary, or do you just need to be able to install already-created signatures? I.e., can the signatures instead just be created with 'fsverity sign' when building the RPMs?
So I basically want to be able to carry verity signatures in RPM as RPM internal data, similar to how it supports IMA signatures. I want to be able to install those without relying on post-install scripts and signature files being distributed as actual files that gets installed, just to have to remove them. This is how IMA support is integrated into RPM as well.
Right now the RPM approach for signatures involves two steps, a build digest phase, and a sign the digest phase.
The reason I included enable and measure was for completeness. I don't care wildly about those.
Quoted 5 lines
Separately, before you start building something around fs-verity's builtin signature verification support, have you also considered adding support for fs-verity to IMA? I.e., using the fs-verity hashing mechanism with the IMA signature mechanism. The IMA maintainer has been expressed interested in that. If rpm already supports IMA signatures, maybe that way would be a better fit?
I looked at IMA and it is overly complex. It is not obvious to me how you would get around that without the full complexity of IMA? The beauty of fsverity's approach is the simplicity of relying on just the kernel keyring for validation of the signature. If you have explicit suggestions, I am certainly happy to look at it.
Thanks,
Jes
Eric Biggers
maintainerQuoted 28 lines · Jes Sorensen
Quoted 15 lines · Eric Biggers
Hi Jes,
Quoted 3 lines · Jes Sorensen
From: Jes Sorensen <[email protected]>
If we can agree on the approach, then I am happy to deal with the full libtoolification etc.Before we do all this work, can you take a step back and explain the use case so that we can be sure it's really worthwhile?
fsverity_cmd_enable()andfsverity_cmd_measure()would just be trivial wrappers around theFS_IOC_ENABLE_VERITYandFS_IOC_MEASURE_VERITYioctls, so they don't need a library. [Aside: I'd suggest calling thesefsverity_enable()andfsverity_measure(), and leaving "cmd" for the command-line wrappers.]Quoted 4 lines
That leaves signing as the only real point of the library. But do you actually need to be able to *sign* the files via the rpm binary, or do you just need to be able to install already-created signatures? I.e., can the signatures instead just be created with 'fsverity sign' when building the RPMs?
So I basically want to be able to carry verity signatures in RPM as RPM internal data, similar to how it supports IMA signatures. I want to be able to install those without relying on post-install scripts and signature files being distributed as actual files that gets installed, just to have to remove them. This is how IMA support is integrated into RPM as well.
Quoted 5 lines
Right now the RPM approach for signatures involves two steps, a build digest phase, and a sign the digest phase.
The reason I included enable and measure was for completeness. I don't care wildly about those.
So the signing happens when the RPM is built, not when it's installed? Are you sure you actually need a library and not just 'fsverity sign' called from a build script?
Quoted 7 lines
Quoted 6 lines
Separately, before you start building something around fs-verity's builtin signature verification support, have you also considered adding support for fs-verity to IMA? I.e., using the fs-verity hashing mechanism with the IMA signature mechanism. The IMA maintainer has been expressed interested in that. If rpm already supports IMA signatures, maybe that way would be a better fit?
Quoted 5 lines
I looked at IMA and it is overly complex. It is not obvious to me how you would get around that without the full complexity of IMA? The beauty of fsverity's approach is the simplicity of relying on just the kernel keyring for validation of the signature. If you have explicit suggestions, I am certainly happy to look at it.
fs-verity's builtin signature verification feature is simple, but does it actually do what you need? Note that unlike IMA, it doesn't provide an in-kernel policy about which files have to have signatures and which don't. I.e., to get any authenticity guarantee, before using any files that are supposed to be protected by fs-verity, userspace has to manually check whether the fs-verity bit is actually set. Is that part of your design?
- Eric
Quoted 13 lines · Eric Biggers
Quoted 12 lines · Jes Sorensen
Quoted 1 line · Eric Biggers
Hi Jes,
So I basically want to be able to carry verity signatures in RPM as RPM internal data, similar to how it supports IMA signatures. I want to be able to install those without relying on post-install scripts and signature files being distributed as actual files that gets installed, just to have to remove them. This is how IMA support is integrated into RPM as well.
Right now the RPM approach for signatures involves two steps, a build digest phase, and a sign the digest phase.
Quoted 6 lines
Quoted 2 lines
The reason I included enable and measure was for completeness. I don't care wildly about those.
So the signing happens when the RPM is built, not when it's installed? Are you sure you actually need a library and not just 'fsverity sign' called from a build script?
So the way RPM is handling these is to calculate the digest in one place, and sign it in another. Basically the signing is a second step, post build, using the rpmsign command. Shelling out is not a good fit for this model.
Quoted 12 lines
Quoted 11 lines
Quoted 5 lines
Separately, before you start building something around fs-verity's builtin signature verification support, have you also considered adding support for fs-verity to IMA? I.e., using the fs-verity hashing mechanism with the IMA signature mechanism. The IMA maintainer has been expressed interested in that. If rpm already supports IMA signatures, maybe that way would be a better fit?
I looked at IMA and it is overly complex. It is not obvious to me how you would get around that without the full complexity of IMA? The beauty of fsverity's approach is the simplicity of relying on just the kernel keyring for validation of the signature. If you have explicit suggestions, I am certainly happy to look at it.
Quoted 6 lines
fs-verity's builtin signature verification feature is simple, but does it actually do what you need? Note that unlike IMA, it doesn't provide an in-kernel policy about which files have to have signatures and which don't. I.e., to get any authenticity guarantee, before using any files that are supposed to be protected by fs-verity, userspace has to manually check whether the fs-verity bit is actually set. Is that part of your design?
Totally aware of this, and it fits the model I am looking at.
Jes
Eric Biggers
maintainerHi Jes,
Quoted 38 lines · Jes Sorensen
Quoted 13 lines · Eric Biggers
Quoted 12 lines · Jes Sorensen
Quoted 1 line · Eric Biggers
Hi Jes,
So I basically want to be able to carry verity signatures in RPM as RPM internal data, similar to how it supports IMA signatures. I want to be able to install those without relying on post-install scripts and signature files being distributed as actual files that gets installed, just to have to remove them. This is how IMA support is integrated into RPM as well.
Right now the RPM approach for signatures involves two steps, a build digest phase, and a sign the digest phase.
Quoted 6 lines
Quoted 2 lines
The reason I included enable and measure was for completeness. I don't care wildly about those.
So the signing happens when the RPM is built, not when it's installed? Are you sure you actually need a library and not just 'fsverity sign' called from a build script?
So the way RPM is handling these is to calculate the digest in one place, and sign it in another. Basically the signing is a second step, post build, using the rpmsign command. Shelling out is not a good fit for this model.
Quoted 12 lines
Quoted 11 lines
Quoted 5 lines
Separately, before you start building something around fs-verity's builtin signature verification support, have you also considered adding support for fs-verity to IMA? I.e., using the fs-verity hashing mechanism with the IMA signature mechanism. The IMA maintainer has been expressed interested in that. If rpm already supports IMA signatures, maybe that way would be a better fit?
I looked at IMA and it is overly complex. It is not obvious to me how you would get around that without the full complexity of IMA? The beauty of fsverity's approach is the simplicity of relying on just the kernel keyring for validation of the signature. If you have explicit suggestions, I am certainly happy to look at it.
Quoted 9 lines
Quoted 6 lines
fs-verity's builtin signature verification feature is simple, but does it actually do what you need? Note that unlike IMA, it doesn't provide an in-kernel policy about which files have to have signatures and which don't. I.e., to get any authenticity guarantee, before using any files that are supposed to be protected by fs-verity, userspace has to manually check whether the fs-verity bit is actually set. Is that part of your design?
Totally aware of this, and it fits the model I am looking at.
Well, this might be a legitimate use case then. We need to define the library interface as simply as possible, though, so that we can maintain this code in the future without breaking users. I suggest starting with something along the lines of:
#ifndef _LIBFSVERITY_H
#define _LIBFSVERITY_H
#include <stddef.h>
#include <stdint.h>
#define FS_VERITY_HASH_ALG_SHA256 1
#define FS_VERITY_HASH_ALG_SHA512 2
struct libfsverity_merkle_tree_params {
uint32_t version;
uint32_t hash_algorithm;
uint32_t block_size;
uint32_t salt_size;
const uint8_t *salt;
size_t reserved[11];
};struct libfsverity_digest {
uint16_t digest_algorithm;
uint16_t digest_size;
uint8_t digest[];
};struct libfsverity_signature_params {
const char *keyfile;
const char *certfile;
size_t reserved[11];
};int libfsverity_compute_digest(int fd,
const struct libfsverity_merkle_tree_params *params, struct libfsverity_digest **digest_ret);
int libfsverity_sign_digest(const struct libfsverity_digest *digest,
const struct libfsverity_signature_params *sig_params, void **sig_ret, size_t *sig_size_ret);
#endif /* _LIBFSVERITY_H */
I.e.:
- The stuff in util.h and hash_algs.h isn't exposed to library users.
- Then names of all library functions and structs are appropriately prefixed and avoid collisions with the kernel header.
- Only signing functionality is included.
- There are reserved fields, so we can add more parameters later.
Before committing to any stable API, it would also be helpful to see the RPM patches to see what it actually does.
We'd also need to follow shared library best practices like compiling with -fvisibility=hidden and marking the API functions explicitly with __attribute__((visibility("default"))), and setting the 'soname' like -Wl,-soname=libfsverity.so.0.
Also, is the GPLv2+ license okay for the use case?
- Eric
Hi Eric,
Quoted 29 lines · Eric Biggers
Well, this might be a legitimate use case then. We need to define the library interface as simply as possible, though, so that we can maintain this code in the future without breaking users. I suggest starting with something along the lines of:
#ifndef
_LIBFSVERITY_H
#define_LIBFSVERITY_H#include <
stddef.h>
#include <stdint.h>#define
FS_VERITY_HASH_ALG_SHA2561
#defineFS_VERITY_HASH_ALG_SHA5122struct libfsverity_merkle_tree_params { uint32_t version; uint32_t hash_algorithm; uint32_t block_size; uint32_t salt_size; const uint8_t *salt; size_t reserved[11]; };struct libfsverity_digest { uint16_t digest_algorithm; uint16_t digest_size; uint8_t digest[]; };
Quoted 5 lines
struct libfsverity_signature_params {
const char *keyfile;
const char *certfile;
size_t reserved[11];
};This looks reasonable to me - I would do the reserved fields as void * or uint32_t, but that is a detail.
Quoted 9 lines
int libfsverity_compute_digest(int fd,
const struct libfsverity_merkle_tree_params *params, struct libfsverity_digest **digest_ret);int libfsverity_sign_digest(const struct
libfsverity_digest*digest,const struct libfsverity_signature_params *sig_params, void **sig_ret, size_t *sig_size_ret);#endif /*
_LIBFSVERITY_H*/
Looks good too, I deliberately named the functions as fsverity, but happy to prepend them with 'lib'. Didn't want to have a clash with 'sign_hash' as a function is actually named in a related library.
Quoted 7 lines
I.e.:
- The stuff in
util.handhash_algs.hisn't exposed to library users.
- Then names of all library functions and structs are appropriately prefixed and avoid collisions with the kernel header.
- Only signing functionality is included.
- There are reserved fields, so we can add more parameters later.
I was debating whether to expect the library to do the open or have the caller be responsible for that. Given we have to play the song and dance with the signing key and certificate filenames, it's a little quirky, but we're passing those to libopenssl so no way to really get around it.
Quoted 2 lines
Before committing to any stable API, it would also be helpful to see the RPM patches to see what it actually does.
Absolutely, I wanted to have us agree on the strategy first before taking it to the next step.
I'll take a stab at this.
Quoted 6 lines
We'd also need to follow shared library best practices like compiling with -fvisibility=hidden and marking the API functions explicitly with __attribute__((visibility("default"))), and setting the 'soname' like -Wl,-soname=libfsverity.so.0.
Also, is the GPLv2+ license okay for the use case?
Personally I only care about linking it into rpm, which is GPL v2, so from my perspective, that is sufficient. I am also fine making it LGPL, but given it's your code I am stealing, I cannot make that call.
Cheers,
Jes
Eric Biggers
maintainerQuoted 11 lines · Jes Sorensen
Quoted 6 lines
We'd also need to follow shared library best practices like compiling with -fvisibility=hidden and marking the API functions explicitly with __attribute__((visibility("default"))), and setting the 'soname' like -Wl,-soname=libfsverity.so.0.
Also, is the GPLv2+ license okay for the use case?
Personally I only care about linking it into rpm, which is GPL v2, so from my perspective, that is sufficient. I am also fine making it LGPL, but given it's your code I am stealing, I cannot make that call.
Hi Jes, I'd like to revisit this, as I'm concerned about future use cases where software under other licenses (e.g. LGPL, MIT, or Apache 2.0) might want to use libfsverity -- especially if libfsverity grows more functionality.
Also, fsverity-utils links to OpenSSL, which some people (e.g. Debian) consider to be incompatible with GPLv2.
We think the MIT license (https://opensource.org/licenses/MIT) would offer the most flexibility. Are you okay with changing the license of fsverity-utils to MIT? If so, I'll send a patch and you can give an Acked-by on it.
Thanks!
- Eric
Quoted 20 lines · Eric Biggers
Quoted 11 lines · Jes Sorensen
Quoted 6 lines
We'd also need to follow shared library best practices like compiling with -fvisibility=hidden and marking the API functions explicitly with __attribute__((visibility("default"))), and setting the 'soname' like -Wl,-soname=libfsverity.so.0.
Also, is the GPLv2+ license okay for the use case?
Personally I only care about linking it into rpm, which is GPL v2, so from my perspective, that is sufficient. I am also fine making it LGPL, but given it's your code I am stealing, I cannot make that call.
Hi Jes, I'd like to revisit this, as I'm concerned about future use cases where software under other licenses (e.g. LGPL, MIT, or Apache 2.0) might want to use libfsverity -- especially if libfsverity grows more functionality.
Also, fsverity-utils links to OpenSSL, which some people (e.g. Debian) consider to be incompatible with GPLv2.
Quoted 7 lines
We think the MIT license (https://opensource.org/licenses/MIT) would offer the most flexibility. Are you okay with changing the license of fsverity-utils to MIT? If so, I'll send a patch and you can give an Acked-by on it.
Thanks!
- Eric
Hi Eric,
I went back through my patches to make sure I didn't reuse code from other GPL projects. I don't see anything that looks like it was reused except from fsverity-utils itself, so it should be fine.
I think it's fair to relax the license so other projects can link to it. I would prefer we use the LGPL rather than the MIT license though?
CC'ing Chris Mason as well, since he has the auth to ack it on behalf of the company.
Cheers,
Jes
Quoted 35 lines · Jes Sorensen
Quoted 20 lines · Eric Biggers
Quoted 11 lines · Jes Sorensen
Quoted 6 lines
We'd also need to follow shared library best practices like compiling with -fvisibility=hidden and marking the API functions explicitly with __attribute__((visibility("default"))), and setting the 'soname' like -Wl,-soname=libfsverity.so.0.
Also, is the GPLv2+ license okay for the use case?
Personally I only care about linking it into rpm, which is GPL v2, so from my perspective, that is sufficient. I am also fine making it LGPL, but given it's your code I am stealing, I cannot make that call.
Hi Jes, I'd like to revisit this, as I'm concerned about future use cases where software under other licenses (e.g. LGPL, MIT, or Apache 2.0) might want to use libfsverity -- especially if libfsverity grows more functionality.
Also, fsverity-utils links to OpenSSL, which some people (e.g. Debian) consider to be incompatible with GPLv2.
Quoted 7 lines
We think the MIT license would offer the
most flexibility. Are you okay with changing the license of fsverity-utils to MIT? If so, I'll send a patch and you can give an Acked-by on it.Thanks!
- Eric
Hi Eric,
I went back through my patches to make sure I didn't reuse code from other GPL projects. I don't see anything that looks like it was reused except from fsverity-utils itself, so it should be fine.
Quoted 5 lines
I think it's fair to relax the license so other projects can link to it. I would prefer we use the LGPL rather than the MIT license though?
CC'ing Chris Mason as well, since he has the auth to ack it on behalf of the company.
MIT, BSD, LGPL are Signed-off-by: Chris Mason <[email protected]>
We’re flexible, the goal is just to fit into the rest of fsverity overall.
-chris
Eric Biggers
maintainerQuoted 48 lines · Chris Mason
Quoted 46 lines · Jes Sorensen
Quoted 27 lines · Eric Biggers
Quoted 7 lines · Jes Sorensen
Quoted 7 lines
We'd also need to follow shared library best practices like compiling with
-fvisibility=hidden and marking the API functions explicitly with __attribute__((visibility("default"))), and setting the 'soname' like
-Wl,-soname=libfsverity.so.0.Quoted 8 lines
Quoted 1 line
Also, is the GPLv2+ license okay for the use case?
Personally I only care about linking it into rpm, which is GPL v2, so
from my perspective, that is sufficient. I am also fine making it LGPL,
but given it's your code I am stealing, I cannot make that call.Hi Jes, I'd like to revisit this, as I'm concerned about future use cases where
software under other licenses (e.g. LGPL, MIT, or Apache 2.0) might want to use
libfsverity -- especially if libfsverity grows more functionality.Also, fsverity-utils links to OpenSSL, which some people (e.g. Debian) consider
to be incompatible with GPLv2.Quoted 8 lines
We think the MIT license would offer the
most flexibility. Are you okay with changing the license of fsverity-utils to
MIT? If so, I'll send a patch and you can give an Acked-by on it.Thanks!
- Eric
Hi Eric,
I went back through my patches to make sure I didn't reuse code from other GPL projects. I don't see anything that looks like it was reused except from fsverity-utils itself, so it should be fine.
I think it's fair to relax the license so other projects can link to it. I would prefer we use the LGPL rather than the MIT license though?
Quoted 8 lines
Quoted 2 lines
CC'ing Chris Mason as well, since he has the auth to ack it on behalf of the company.
MIT, BSD, LGPL are Signed-off-by: Chris Mason <[email protected]>
We’re flexible, the goal is just to fit into the rest of fsverity overall.
-chris
Thanks Chris and Jes.
At least on Google's side, a permissive license generally makes things easier for people -- even though in practice we'll be upstreaming all changes anyway. Since fsverity-utils is only a small project and is unlikely to be customized much by people (as it's closely tied to the upstream kernel support), for now I'd rather not create problems for users or cause duplication of effort.
If it were a larger project, or something people would be more likely to customize, the case for LGPL would be stronger IMO.
There are also OpenSSL linking exceptions out there even for the LGPL (!), so I'm not sure everyone agrees that one isn't needed... I'd like to avoid wasting time on any such issues and just write code :-)
Note that we can always choose to move to LGPL later, but LGPL => MIT won't be possible (since in line with kernel community norms, for fsverity-utils we're only requiring the DCO, not a CLA). I think we shouldn't go down a one-way street too early.
I've send out a patch to change the license. Can you two explicitly give Acked-by on the patch itself? Thanks!
- Eric