Replace SHA-1 with SHA-256
Subsystems (2)
PATCH 1/1 Replace SHA-1 with SHA-256
From: Petr Lautrbach <[email protected]>
SHA-1 is considered obsolete so move to SHA-256 as the default digest algorithm.
Import the public-domain SHA-256 implementation from WjCryptLib and use it for label digest handling.
The original source of sha256.c is
https://github.com/WaterJuice/WjCryptLib/releases/tag/Version_3.0.0
Ignore sha256.{c,h} in make-format and check-format targets in order to adopt possible future changes in WaterJuice/WjCryptLib simpler.
--- Makefile | 1 + libselinux/include/selinux/label.h | 6 +- libselinux/include/selinux/restorecon.h | 4 +- libselinux/man/man3/selabel_digest.3 | 4 +- libselinux/man/man3/selabel_open.3 | 2 +- libselinux/man/man3/selinux_restorecon.3 | 18 +- .../man/man3/selinux_restorecon_xattr.3 | 2 +- libselinux/src/Makefile | 2 +- libselinux/src/label_file.c | 40 +-- libselinux/src/label_internal.h | 10 +- libselinux/src/label_support.c | 17 +- libselinux/src/selinux_restorecon.c | 42 ++- libselinux/src/sha1.c | 284 ----------------- libselinux/src/sha1.h | 68 ---- libselinux/src/sha256.c | 294 ++++++++++++++++++ libselinux/src/sha256.h | 89 ++++++ libselinux/utils/selabel_digest.c | 26 +- .../selabel_get_digests_all_partial_matches.c | 30 +- policycoreutils/setfiles/restorecon.8 | 10 +- policycoreutils/setfiles/restorecon_xattr.8 | 8 +- policycoreutils/setfiles/restorecon_xattr.c | 12 +- policycoreutils/setfiles/setfiles.8 | 10 +- 22 files changed, 511 insertions(+), 468 deletions(-) delete mode 100644 libselinux/src/sha1.c delete mode 100644 libselinux/src/sha1.h create mode 100644 libselinux/src/sha256.c create mode 100644 libselinux/src/sha256.h
Makefile +1 -0
@@ -61,6 +61,7 @@ distclean: # We shouldn't have any unformatted files in the repo without an explicit exception. FORMAT_SOURCE_FILES := $(shell find $(SUBDIRS) -type f \( -name '*.c' -o -name '*.h' \)) +FORMAT_SOURCE_FILES := $(filter-out libselinux/src/sha256.c libselinux/src/sha256.h,$(FORMAT_SOURCE_FILES)) format: $(CLANG_FORMAT) -i $(FORMAT_SOURCE_FILES)
libselinux/include/selinux/label.h +3 -3
@@ -129,13 +129,13 @@ extern int selabel_lookup_best_match_raw(struct selabel_handle *handle, const char **aliases, int type);/** -* selabel_digest - Retrieve the SHA1 digest and the list of specfiles used to +* selabel_digest - Retrieve the SHA256 digest and the list of specfiles used to * generate the digest. The SELABEL_OPT_DIGEST option must * be set in selabel_open() to initiate the digest generation. * @handle: specifies backend instance to query -* @digest: returns a pointer to the SHA1 digest. +* @digest: returns a pointer to the SHA256 digest. * @digest_len: returns length of digest in bytes. -* @specfiles: a list of specfiles used in the SHA1 digest generation. +* @specfiles: a list of specfiles used in the SHA256 digest generation. * The list is NULL terminated and will hold @num_specfiles entries. * @num_specfiles: number of specfiles in the list. *
libselinux/include/selinux/restorecon.h +2 -2
@@ -43,8 +43,8 @@ extern int selinux_restorecon_parallel(const char *pathname,* restorecon_flags options */ /* -* Force the checking of labels even if the stored SHA1 digest -* matches the specfiles SHA1 digest (requires CAP_SYS_ADMIN). +* Force the checking of labels even if the stored SHA256 digest +* matches the specfiles SHA256 digest (requires CAP_SYS_ADMIN). */ #define SELINUX_RESTORECON_IGNORE_DIGEST 0x00001/*
libselinux/man/man3/selabel_digest.3 +2 -2
@@ -20,11 +20,11 @@ selabel_digest \- Return digest of specfiles and list of files used .BR selabel_digest () performs an operation on the handle .IR hnd , -returning the results of the SHA1 digest pointed to by +returning the results of the SHA256 digest pointed to by .IR digest , whose length will be .IR digest_len . -The list of specfiles used in the SHA1 digest calculation is returned in +The list of specfiles used in the SHA256 digest calculation is returned in .I specfiles with the number of entries in .IR num_specfiles .
libselinux/man/man3/selabel_open.3 +1 -1
@@ -69,7 +69,7 @@ is used; a custom validation function can be provided via Note that an invalid context may not be treated as an error unless it is actually encountered during a lookup operation. .TP .B SELABEL_OPT_DIGEST -A non-null value for this option enables the generation of an SHA1 digest of +A non-null value for this option enables the generation of an SHA256 digest of the spec files loaded as described in .BR selabel_digest (3) .
libselinux/man/man3/selinux_restorecon.3 +9 -9
@@ -36,7 +36,7 @@ If this is a directory and the .B SELINUX_RESTORECON_RECURSE has been set (for descending through directories), then .BR selinux_restorecon () -will write an SHA1 digest of specfile entries calculated by +will write an SHA256 digest of specfile entries calculated by .BR selabel_get_digests_all_partial_matches (3) to an extended attribute of .IR security.sehash
@@ -55,7 +55,7 @@ will take place. .br The .IR restorecon_flags -that can be used to manage the usage of the SHA1 digest are: +that can be used to manage the usage of the SHA256 digest are: .RS .B SELINUX_RESTORECON_SKIP_DIGEST .br
@@ -73,8 +73,8 @@ Do not check or update any extended attribute entries. .sp .B SELINUX_RESTORECON_IGNORE_DIGEST -force the checking of labels even if the stored SHA1 digest matches the -specfile entries SHA1 digest. The specfile entries digest will be written to the +force the checking of labels even if the stored SHA256 digest matches the +specfile entries SHA256 digest. The specfile entries digest will be written to the .IR security.sehash extended attribute once relabeling has been completed successfully provided the .B SELINUX_RESTORECON_NOCHANGE
@@ -95,7 +95,7 @@ default specfile context. .sp .B SELINUX_RESTORECON_RECURSE change file and directory labels recursively (descend directories) -and if successful write an SHA1 digest of the specfile entries to an +and if successful write an SHA256 digest of the specfile entries to an extended attribute as described in the .B NOTES section.
@@ -194,7 +194,7 @@ for fetching the ignored (skipped) error count after or .BR selinux_restorecon_parallel (3) completes with success. In case any errors were skipped during the file tree -walk, the specfile entries SHA1 digest will not have been written to the +walk, the specfile entries SHA256 digest will not have been written to the .IR security.sehash extended attribute. .sp
@@ -212,7 +212,7 @@ Use this option when relabeling untrusted directories that might contain hard links to files owned by others. .RE .sp -The behavior regarding the checking and updating of the SHA1 digest described +The behavior regarding the checking and updating of the SHA256 digest described above is the default behavior. It is possible to change this by first calling .BR selabel_open (3) and not enabling the
@@ -275,7 +275,7 @@ To improve performance when relabeling file systems recursively (e.g. the .B SELINUX_RESTORECON_RECURSE flag is set) .BR selinux_restorecon () -will write a calculated SHA1 digest of the specfile entries returned by +will write a calculated SHA256 digest of the specfile entries returned by .BR selabel_get_digests_all_partial_matches (3) to an extended attribute named .IR security.sehash
@@ -297,7 +297,7 @@ Should any of the specfile entries have changed, then when .BR selinux_restorecon () is run again with the .B SELINUX_RESTORECON_RECURSE -flag set, new SHA1 digests will be calculated and all files automatically +flag set, new SHA256 digests will be calculated and all files automatically relabeled depending on the settings of the .B SELINUX_RESTORECON_SET_SPECFILE_CTX flag (provided
libselinux/man/man3/selinux_restorecon_xattr.3 +1 -1
@@ -119,7 +119,7 @@ By default .BR selinux_restorecon_xattr (3) will use the default set of specfiles described in .BR files_contexts (5) -to calculate the SHA1 digests to be used for comparison. +to calculate the SHA256 digests to be used for comparison. To change this default behavior .BR selabel_open (3) must be called specifying the required
libselinux/src/Makefile +1 -1
@@ -130,7 +130,7 @@ DISABLE_FLAGS+= -DNO_MEDIA_BACKEND -DNO_DB_BACKEND -DNO_X_BACKEND \ -DBUILD_HOST SRCS= callbacks.c freecon.c label.c label_file.c \ label_backends_android.c regex.c label_support.c \ - matchpathcon.c setrans_client.c sha1.c booleans.c + matchpathcon.c setrans_client.c sha256.c booleans.c LABEL_BACKEND_ANDROID=y endif
libselinux/src/label_file.c +20 -20
@@ -2434,7 +2434,7 @@ static struct lookup_result *lookup_common(struct selabel_handle *rec,/* * Returns true if the digest of all partial matched contexts is the same as -* the one saved by setxattr, otherwise returns false. The length of the SHA1 +* the one saved by setxattr, otherwise returns false. The length of the SHA256 * digest will always be returned. The caller must free any returned digests. */ static bool get_digests_all_partial_matches(struct selabel_handle *rec,
@@ -2443,40 +2443,40 @@ static bool get_digests_all_partial_matches(struct selabel_handle *rec,uint8_t **xattr_digest, size_t *digest_len) { - uint8_t read_digest[SHA1_HASH_SIZE]; + uint8_t read_digest[SHA256_HASH_SIZE];ssize_t read_size =getxattr (pathname,RESTORECON_PARTIAL_MATCH_DIGEST , - read_digest,SHA1_HASH_SIZE + read_digest,SHA256_HASH_SIZE #ifdef __APPLE__ ,0 ,0 #endif /* __APPLE __ */ ); -uint8_t hash_digest[SHA1_HASH_SIZE ]; +uint8_t hash_digest[SHA256_HASH_SIZE ];bool status =selabel_hash_all_partial_matches (rec, pathname, hash_digest); *xattr_digest =NULL ; *calculated_digest =NULL ; - *digest_len =SHA1_HASH_SIZE ; + *digest_len =SHA256_HASH_SIZE ; -if (read_size ==SHA1_HASH_SIZE ) { - *xattr_digest =calloc (1 ,SHA1_HASH_SIZE +1 ); +if (read_size ==SHA256_HASH_SIZE ) { + *xattr_digest =calloc (1 ,SHA256_HASH_SIZE +1 );if (!*xattr_digest) goto oom; -memcpy (*xattr_digest, read_digest,SHA1_HASH_SIZE ); +memcpy (*xattr_digest, read_digest,SHA256_HASH_SIZE ); }if (status) { - *calculated_digest =calloc (1 ,SHA1_HASH_SIZE +1 ); + *calculated_digest =calloc (1 ,SHA256_HASH_SIZE +1 );if (!*calculated_digest) goto oom; -memcpy (*calculated_digest, hash_digest,SHA1_HASH_SIZE ); +memcpy (*calculated_digest, hash_digest,SHA256_HASH_SIZE ); } -if (status && read_size ==SHA1_HASH_SIZE && -memcmp (read_digest, hash_digest,SHA1_HASH_SIZE ) ==0 ) +if (status && read_size ==SHA256_HASH_SIZE && +memcmp (read_digest, hash_digest,SHA256_HASH_SIZE ) ==0 )return true;return false;
@@ -2497,22 +2497,22 @@ static bool hash_all_partial_matches(struct selabel_handle *rec,return false; } -Sha1Context context; -Sha1Initialise (&context); +Sha256Context context; +Sha256Initialise (&context);for (const struct lookup_result *m = matches; m; m = m->next) {const char *regex_str = m->regex_str;uint8_t file_kind = m->file_kind;const char *ctx_raw = m->lr->ctx_raw; -Sha1Update (&context, regex_str,strlen (regex_str) +1 ); -Sha1Update (&context, &file_kind,sizeof (file_kind)); -Sha1Update (&context, ctx_raw,strlen (ctx_raw) +1 ); +Sha256Update (&context, regex_str,strlen (regex_str) +1 ); +Sha256Update (&context, &file_kind,sizeof (file_kind)); +Sha256Update (&context, ctx_raw,strlen (ctx_raw) +1 ); } -SHA1_HASH sha1_hash; -Sha1Finalise (&context, &sha1_hash); -memcpy (digest, sha1_hash.bytes,SHA1_HASH_SIZE ); +SHA256_HASH sha256_hash; +Sha256Finalise (&context, &sha256_hash); +memcpy (digest, sha256_hash.bytes,SHA256_HASH_SIZE );free_lookup_result (matches);return true;
libselinux/src/label_internal.h +5 -5
@@ -14,7 +14,7 @@#include <stdbool.h> #include <selinux/selinux.h> #include <selinux/label.h> -#include "sha1.h" +#include "sha256.h" #if defined(ANDROID ) || defined(__APPLE__)// Android and Mac do not have fgets_unlocked()
@@ -42,15 +42,15 @@ int selabel_service_init(struct selabel_handle *rec,*/ /* -* Calculate an SHA1 hash of all the files used to build the specs. +* Calculate an SHA256 hash of all the files used to build the specs. * The hash value is held in rec->digest if SELABEL_OPT_DIGEST set. To * calculate the hash the hashbuf will hold a concatenation of all the files * used. This is released once the value has been calculated. */ -#define DIGEST_SPECFILE_SIZE SHA1_HASH_SIZE +#define DIGEST_SPECFILE_SIZE SHA256_HASH_SIZE#define DIGEST_FILES_MAX 8struct selabel_digest { -unsigned char *digest;/* SHA1 digest of specfiles */ +unsigned char *digest;/* SHA256 digest of specfiles */ unsigned char *hashbuf;/* buffer to hold specfiles */ size_t hashbuf_size;/* buffer size */ size_t specfile_cnt;/* how many specfiles processed */
@@ -103,7 +103,7 @@ struct selabel_handle {size_t spec_files_len;char **spec_files; -/* ptr to SHA1 hash information if SELABEL_OPT_DIGEST set */ +/* ptr to SHA256 hash information if SELABEL_OPT_DIGEST set */ struct selabel_digest *digest; };
libselinux/src/label_support.c +8 -9
@@ -214,28 +214,27 @@ int read_spec_entries(char *line_buf, size_t nread, const char **errbuf,/* Once all the specfiles are in the hash_buf, generate the hash. */ void digest_gen_hash (struct selabel_digest *digest) { -Sha1Context context; +Sha256Context context;size_t remaining_size;const unsigned char *ptr; -const uint32_t chunkSize =UINT32_MAX >>3 ;/* If SELABEL_OPT_DIGEST not set then just return */ if (!digest)return ; -Sha1Initialise (&context); +Sha256Initialise (&context);/* Process in blocks of chunkSize bytes */ remaining_size = digest->hashbuf_size; ptr = digest->hashbuf; -while (remaining_size > chunkSize) { -Sha1Update (&context, ptr, chunkSize); - remaining_size -= chunkSize; - ptr += chunkSize; +while (remaining_size >UINT32_MAX ) { +Sha256Update (&context, ptr,UINT32_MAX ); + remaining_size -=UINT32_MAX ; + ptr +=UINT32_MAX ; } -Sha1Update (&context, ptr, remaining_size); +Sha256Update (&context, ptr, remaining_size); -Sha1Finalise (&context, (SHA1_HASH *)digest->digest); +Sha256Finalise (&context, (SHA256_HASH *)digest->digest);free (digest->hashbuf); digest->hashbuf =NULL ; }
libselinux/src/selinux_restorecon.c +26 -16
127 lines not on this page · raw message
libselinux/src/sha1.c deleted +0 -284
284 lines not on this page · raw message
libselinux/src/sha1.h deleted +0 -68
68 lines not on this page · raw message
libselinux/src/sha256.c new file +294 -0
294 lines not on this page · raw message
libselinux/src/sha256.h new file +89 -0
89 lines not on this page · raw message
libselinux/utils/selabel_digest.c +13 -13
@@ -13,8 +13,8 @@ static __attribute__((__noreturn__)) void usage(const char *progname)"Where:\n\t" "-b The backend - \"file\", \"media\", \"x\", \"db\" or " "\"prop\"\n\t" -"-v Run \"cat <specfile_list> | openssl dgst -sha1 -hex\"\n\t" -" on the list of specfiles to compare the SHA1 digests.\n\t" +"-v Run \"cat <specfile_list> | openssl dgst -sha256 -hex\"\n\t" +" on the list of specfiles to compare the SHA256 digests.\n\t" "-B Use base specfiles only (valid for \"-b file\" only).\n\t" "-i Do not request a digest.\n\t" "-f Optional file containing the specs (defaults to\n\t"
@@ -70,12 +70,12 @@ int main(int argc, char **argv)int rc, opt, validate =0 ;char *baseonly =NULL , *file =NULL , *digest = (char *)1 ;char **specfiles =NULL ; -unsigned char *sha1_digest =NULL ; +unsigned char *sha256_digest =NULL ;size_t digest_len, i, num_specfiles;char cmd_buf[4096 ];char *cmd_ptr; -char *sha1_buf =NULL ; +char *sha256_buf =NULL ;struct selabel_handle *hnd;struct selinux_opt selabel_option[] = { {SELABEL_OPT_PATH , file },
@@ -145,7 +145,7 @@ int main(int argc, char **argv)return -1 ; } - rc =selabel_digest (hnd, &sha1_digest, &digest_len, &specfiles, + rc =selabel_digest (hnd, &sha256_digest, &digest_len, &specfiles, &num_specfiles);if (rc) {
@@ -160,19 +160,19 @@ int main(int argc, char **argv) goto err; } - sha1_buf =malloc (digest_len *2 +1 ); -if (!sha1_buf) { + sha256_buf =malloc (digest_len *2 +1 ); +if (!sha256_buf) {fprintf (stderr,"Could not malloc buffer ERROR: %s\n" ,strerror (errno)); rc =-1 ; goto err; } -printf ("SHA1 digest: " ); +printf ("SHA256 digest: " );for (i =0 ; i < digest_len; i++) -sprintf (&(sha1_buf[i *2 ]),"%02x" , sha1_digest[i]); +sprintf (&(sha256_buf[i *2 ]),"%02x" , sha256_digest[i]); -printf ("%s\n" , sha1_buf); +printf ("%s\n" , sha256_buf);printf ("calculated using the following specfile(s):\n" );if (specfiles) {
@@ -211,7 +211,7 @@ int main(int argc, char **argv)if (validate) { ret =snprintf (cmd_ptr, cmd_rem, -"| /usr/bin/openssl dgst -sha1 -hex" ); +"| /usr/bin/openssl dgst -sha256 -hex" );if (ret <0 || (size_t )ret >= cmd_rem) {fprintf (stderr,"Could not format validate command\n" );
@@ -219,12 +219,12 @@ int main(int argc, char **argv) goto err; } - rc =run_check_digest (cmd_buf, sha1_buf, digest_len); + rc =run_check_digest (cmd_buf, sha256_buf, digest_len); } } err: -free (sha1_buf); +free (sha256_buf);selabel_close (hnd);return rc; }
libselinux/utils/selabel_get_digests_all_partial_matches.c +16 -14
@@ -16,8 +16,8 @@ static __attribute__((__noreturn__)) void usage(const char *progname)"-v Validate file_contxts entries against loaded policy.\n\t" "-r Recursively descend directories.\n\t" "-f Optional file_contexts file (defaults to current policy).\n\t" -"path Path to check current SHA1 digest against file_contexts entries.\n\n" -"This will check the directory selinux.sehash SHA1 digest for " +"path Path to check current SHA256 digest against file_contexts entries.\n\n" +"This will check the directory selinux.sehash SHA256 digest for " "<path> against\na newly generated digest based on the " "file_context entries for that node\n(using the regx, mode " "and path entries).\n",
@@ -36,7 +36,7 @@ int main(int argc, char **argv)char *paths[2 ] = {NULL ,NULL };uint8_t *xattr_digest =NULL ;uint8_t *calculated_digest =NULL ; -char *sha1_buf =NULL ; +char *sha256_buf =NULL ;struct selabel_handle *hnd;struct selinux_opt selabel_option[] = {
@@ -101,8 +101,8 @@ int main(int argc, char **argv) hnd, ftsent->fts_path, &calculated_digest, &xattr_digest, &digest_len); - sha1_buf =calloc (1 , digest_len *2 +1 ); -if (!sha1_buf) { + sha256_buf =calloc (1 , digest_len *2 +1 ); +if (!sha256_buf) {fprintf (stderr,"Could not calloc buffer ERROR: %s\n" ,strerror (errno));
@@ -110,19 +110,20 @@ int main(int argc, char **argv) }if (status) {/* They match */ -printf ("xattr and file_contexts SHA1 digests match for: %s\n" , +printf ("xattr and file_contexts SHA256 digests match for: %s\n" , ftsent->fts_path);if (calculated_digest) {for (i =0 ; i < digest_len; i++) -sprintf ((&sha1_buf[i *2 ]), +sprintf ((&sha256_buf[i *2 ]),"%02x" , calculated_digest[i]); -printf ("SHA1 digest: %s\n" , sha1_buf); +printf ("SHA256 digest: %s\n" , + sha256_buf); } }else {if (!calculated_digest) { -printf ("No SHA1 digest available for: %s\n" , +printf ("No SHA256 digest available for: %s\n" , ftsent->fts_path);printf ("as file_context entry is \"<<none>>\"\n" ); goto cleanup;
@@ -132,25 +133,26 @@ int main(int argc, char **argv) ftsent->fts_path);for (i =0 ; i < digest_len; i++) -sprintf ((&sha1_buf[i *2 ]),"%02x" , +sprintf ((&sha256_buf[i *2 ]),"%02x" , calculated_digest[i]); -printf ("generated SHA1 digest: %s\n" , sha1_buf); +printf ("generated SHA256 digest: %s\n" , + sha256_buf);if (!xattr_digest) {printf ("however there is no selinux.sehash xattr entry.\n" ); }else {printf ("however it does NOT match the current entry of:\n" );for (i =0 ; i < digest_len; i++) -sprintf ((&sha1_buf[i *2 ]), +sprintf ((&sha256_buf[i *2 ]),"%02x" , xattr_digest[i]); -printf ("%s\n" , sha1_buf); +printf ("%s\n" , sha256_buf); } } cleanup:free (xattr_digest);free (calculated_digest); -free (sha1_buf); +free (sha256_buf);break ; }default :
policycoreutils/setfiles/restorecon.8 +5 -5
@@ -111,14 +111,14 @@ display usage information and exit. ignore files that do not exist. .TP .B \-I -ignore digest to force checking of labels even if the stored SHA1 digest -matches the specfiles SHA1 digest. The digest will then be updated provided +ignore digest to force checking of labels even if the stored SHA256 digest +matches the specfiles SHA256 digest. The digest will then be updated provided there are no errors. See the .B NOTES section for further details. .TP .B \-D -Set or update any directory SHA1 digests. Use this option to +Set or update any directory SHA256 digests. Use this option to enable usage of the .IR security.sehash extended attribute.
@@ -237,7 +237,7 @@ the .B \-D option to .B restorecon -will cause it to store a SHA1 digest of the default specfiles set in an extended +will cause it to store a SHA256 digest of the default specfiles set in an extended attribute named .IR security.sehash on each directory specified in
@@ -254,7 +254,7 @@ for further details. .sp The .B \-I -option will ignore the SHA1 digest from each directory specified in +option will ignore the SHA256 digest from each directory specified in .IR pathname \ ... and provided the .B \-n
policycoreutils/setfiles/restorecon_xattr.8 +4 -4
@@ -23,7 +23,7 @@ or .SH "DESCRIPTION" .B restorecon_xattr -will display the SHA1 digests added to extended attributes +will display the SHA256 digests added to extended attributes .I security.sehash or delete the attribute completely. These attributes are set by .BR restorecon (8)
@@ -48,12 +48,12 @@ extended attribute and are automatically excluded from searches. .sp By default .B restorecon_xattr -will display the SHA1 digests with "Match" appended if they match the default +will display the SHA256 digests with "Match" appended if they match the default specfile set or the .I specfile set used with the .B \-f -option. Non-matching SHA1 digests will be displayed with "No Match" appended. +option. Non-matching SHA256 digests will be displayed with "No Match" appended. This feature can be disabled by the .B \-n option.
@@ -87,7 +87,7 @@ Do not append "Match" or "No Match" to displayed digests. recursively descend directories. .TP .B \-v -display SHA1 digest generated by specfile set (Note that this digest is not +display SHA256 digest generated by specfile set (Note that this digest is not used to match the .I security.sehash directory digest entries, and is shown for reference only).
policycoreutils/setfiles/restorecon_xattr.c +6 -6
@@ -38,7 +38,7 @@ int main(int argc, char **argv)unsigned int xattr_flags =0 , delete_digest =0 , recurse =0 ;unsigned int delete_all_digests =0 , ignore_mounts =0 ;bool display_digest = false; -char *sha1_buf, **specfiles, *fc_file =NULL , *pathname =NULL ; +char *sha256_buf, **specfiles, *fc_file =NULL , *pathname =NULL ;unsigned char *fc_digest =NULL ;size_t i, fc_digest_len =0 , num_specfiles;
@@ -134,8 +134,8 @@ int main(int argc, char **argv)exit (-1 ); } - sha1_buf =malloc (fc_digest_len *2 +1 ); -if (!sha1_buf) { + sha256_buf =malloc (fc_digest_len *2 +1 ); +if (!sha256_buf) {fprintf (stderr,"Error allocating digest buffer: %s\n" ,strerror (errno));selabel_close (hnd);
@@ -143,16 +143,16 @@ int main(int argc, char **argv) }for (i =0 ; i < fc_digest_len; i++) -sprintf ((&sha1_buf[i *2 ]),"%02x" , fc_digest[i]); +sprintf ((&sha256_buf[i *2 ]),"%02x" , fc_digest[i]); -printf ("specfiles SHA1 digest: %s\n" , sha1_buf); +printf ("specfiles SHA256 digest: %s\n" , sha256_buf);printf ("calculated using the following specfile(s):\n" );if (specfiles) {for (i =0 ; i < num_specfiles; i++)printf ("%s\n" , specfiles[i]); } -free (sha1_buf); +free (sha256_buf);printf ("\n" ); }
policycoreutils/setfiles/setfiles.8 +5 -5
@@ -106,14 +106,14 @@ display usage information and exit. ignore files that do not exist. .TP .B \-I -ignore digest to force checking of labels even if the stored SHA1 digest -matches the specfiles SHA1 digest. The digest will then be updated provided +ignore digest to force checking of labels even if the stored SHA256 digest +matches the specfiles SHA256 digest. The digest will then be updated provided there are no errors. See the .B NOTES section for further details. .TP .B \-D -Set or update any directory SHA1 digests. Use this option to +Set or update any directory SHA256 digests. Use this option to enable usage of the .IR security.sehash extended attribute.
@@ -298,7 +298,7 @@ the .B \-D option to .B setfiles -will cause it to store a SHA1 digest of the +will cause it to store a SHA256 digest of the .B spec_file set in an extended attribute named .IR security.sehash
@@ -319,7 +319,7 @@ for further details. .sp The .B \-I -option will ignore the SHA1 digest from each directory specified in +option will ignore the SHA256 digest from each directory specified in .IR pathname \ ... and provided the .B \-n
Signature · 1 line
2.55.0
Quoted 8 lines · Petr Lautrbach
From: Petr Lautrbach <[email protected]>
SHA-1 is considered obsolete so move to SHA-256 as the default digest algorithm.
Import the public-domain SHA-256 implementation from WjCryptLib and use it for label digest handling.
Quoted 8 lines
The original source of
sha256.cis
https://github.com/WaterJuice/WjCryptLib/releases/tag/Version_3.0.0Ignore sha256.{c,h} in make-format and check-format targets in order to adopt possible future changes in WaterJuice/WjCryptLib simpler.
Signed-off-by Petr Lautrbach <[email protected]>---
A few comments below regarding compatibility / versioning and code formatting inconsistency, but otherwise
1. selabel_hash_all_partial_matches() output size grows from 20 to 32 bytes. selabel_hash_all_partial_matches() is a public exported symbol (libselinux.map, LIBSELINUX_2.9) whose prototype is uint8_t *digest with no length parameter and no man page. Any external caller sized for the old SHA-1 output gets a 12-byte OOB write from hash_all_partial_matches(). This interface/functionality was based on Android-specific functionality and I don't see any distro users, so this is probably fine to break, but it should be a stated decision and called out in the commit message and the 3.12 release notes. I will defer to the distros on whether it requires a libselinux.so version bump; I am fine either way.
2. restorecon_xattr no longer surfaces legacy 20-byte digests. get_digests_all_partial_matches() only returns xattr_digest when read_size == SHA256_HASH_SIZE, so an existing 20-byte security.sehash is treated as "no xattr". add_xattr_entry() then returns 1 without adding a list entry, so restorecon_xattr on an unconverted tree shows nothing where it used to show "No Match", and restorecon_xattr -d removes the legacy value silently instead of listing it as DELETED_NOMATCH. The removexattr() in the new legacy branch also fires (harmlessly, ENODATA) on every directory that never had a sehash. Not blocking but worth a follow-up so the transition is visible.
3. Two differently formatted copies of the same sha256.[ch] files. libsemanage/src/shas256.[ch] is the same source but already reformatted by the mass reformatting. We likely ought to be consistent for both either way.
4. The commit message could note that every existing security.sehash is a miss on the first restorecon -D after upgrade one-time full check
+ rewrite to 32 bytes; fsetxattr(...,0) at walk_next() overwrites in place.
5. There is a lingering comment in label_support.c "Process in blocks of chunkSize bytes" that references a no-longer-existing variable after this change; you could drop that comment in a v2 or follow-up patch.
Stephen Smalley
maintainerQuoted 23 lines · Stephen Smalley
Quoted 8 lines · Petr Lautrbach
From: Petr Lautrbach <[email protected]>
SHA-1 is considered obsolete so move to SHA-256 as the default digest algorithm.
Import the public-domain SHA-256 implementation from WjCryptLib and use it for label digest handling.
Quoted 8 lines
The original source of
sha256.cis
https://github.com/WaterJuice/WjCryptLib/releases/tag/Version_3.0.0Ignore sha256.{c,h} in make-format and check-format targets in order to adopt possible future changes in WaterJuice/WjCryptLib simpler.
Signed-off-by Petr Lautrbach <[email protected]>---
A few comments below regarding compatibility / versioning and code formatting inconsistency, but otherwise
Acked-by Stephen Smalley <[email protected]>
Quoted 11 lines
1.
selabel_hash_all_partial_matches()output size grows from 20 to 32 bytes.selabel_hash_all_partial_matches()is a public exported symbol (libselinux.map, LIBSELINUX_2.9) whose prototype isuint8_t*digest with no length parameter and no man page. Any external caller sized for the old SHA-1 output gets a 12-byte OOB write fromhash_all_partial_matches(). This interface/functionality was based on Android-specific functionality and I don't see any distro users, so this is probably fine to break, but it should be a stated decision and called out in the commit message and the 3.12 release notes. I will defer to the distros on whether it requires a libselinux.so version bump; I am fine either way.
Actually, if someone cares, we could just use symbol versioning for this and fallback on the old symbol to only write the first 20-bytes of the SHA256 hash to the output buffer to avoid a compatibility break. That said, the only user of this function that I see is in Android's libselinux and that wouldn't be helped by that.
Quoted 26 lines
2.
restorecon_xattrno longer surfaces legacy 20-byte digests.get_digests_all_partial_matches()only returnsxattr_digestwhenread_size==SHA256_HASH_SIZE, so an existing 20-byte security.sehash is treated as "no xattr".add_xattr_entry()then returns 1 without adding a list entry, sorestorecon_xattron an unconverted tree shows nothing where it used to show "No Match", andrestorecon_xattr-d removes the legacy value silently instead of listing it asDELETED_NOMATCH. Theremovexattr()in the new legacy branch also fires (harmlessly, ENODATA) on every directory that never had a sehash. Not blocking but worth a follow-up so the transition is visible.3. Two differently formatted copies of the same sha256.[ch] files. libsemanage/src/shas256.[ch] is the same source but already reformatted by the mass reformatting. We likely ought to be consistent for both either way.
4. The commit message could note that every existing security.sehash is a miss on the first restorecon -D after upgrade one-time full check
+ rewrite to 32 bytes;fsetxattr(...,0)atwalk_next()overwrites in place.5. There is a lingering comment in
label_support.c"Process in blocks of chunkSize bytes" that references a no-longer-existing variable after this change; you could drop that comment in a v2 or follow-up patch.
Quoted 18 lines · Stephen Smalley
Quoted 16 lines · Stephen Smalley
Quoted 14 lines · Petr Lautrbach
From: Petr Lautrbach <[email protected]>
SHA-1 is considered obsolete so move to SHA-256 as the default digest algorithm.
Import the public-domain SHA-256 implementation from WjCryptLib and use it for label digest handling.
The original source of
sha256.cis
https://github.com/WaterJuice/WjCryptLib/releases/tag/Version_3.0.0Ignore sha256.{c,h} in make-format and check-format targets in order to adopt possible future changes in WaterJuice/WjCryptLib simpler.
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines
Signed-off-by Petr Lautrbach <[email protected]>---
A few comments below regarding compatibility / versioning and code formatting inconsistency, but otherwise
Acked-by Stephen Smalley <[email protected]>
Thanks. I'll try to address all your comments. I have no answers for 1. and 2. at this moment, but 3., 4., 5. is clear
Quoted 12 lines
Quoted 11 lines
1.
selabel_hash_all_partial_matches()output size grows from 20 to 32 bytes.selabel_hash_all_partial_matches()is a public exported symbol (libselinux.map, LIBSELINUX_2.9) whose prototype isuint8_t*digest with no length parameter and no man page. Any external caller sized for the old SHA-1 output gets a 12-byte OOB write fromhash_all_partial_matches(). This interface/functionality was based on Android-specific functionality and I don't see any distro users, so this is probably fine to break, but it should be a stated decision and called out in the commit message and the 3.12 release notes. I will defer to the distros on whether it requires a libselinux.so version bump; I am fine either way.
Quoted 21 lines
Actually, if someone cares, we could just use symbol versioning for this and fallback on the old symbol to only write the first 20-bytes of the SHA256 hash to the output buffer to avoid a compatibility break. That said, the only user of this function that I see is in Android's libselinux and that wouldn't be helped by that.
Quoted 16 lines
2.
restorecon_xattrno longer surfaces legacy 20-byte digests.get_digests_all_partial_matches()only returnsxattr_digestwhenread_size==SHA256_HASH_SIZE, so an existing 20-byte security.sehash is treated as "no xattr".add_xattr_entry()then returns 1 without adding a list entry, sorestorecon_xattron an unconverted tree shows nothing where it used to show "No Match", andrestorecon_xattr-d removes the legacy value silently instead of listing it asDELETED_NOMATCH. Theremovexattr()in the new legacy branch also fires (harmlessly, ENODATA) on every directory that never had a sehash. Not blocking but worth a follow-up so the transition is visible.3. Two differently formatted copies of the same sha256.[ch] files. libsemanage/src/shas256.[ch] is the same source but already reformatted by the mass reformatting. We likely ought to be consistent for both either way.
Given that this project has already changes in libsemanage/src/sha256.* I'm going to backport changes from
https://github.com/WaterJuice/WjCryptLib/commit/e1a5f7866e74c9b608afc79d4e8c8000af2879a3
to libsemanage/src/sha256.* and then use the same code in libselinux/src/sha256*
Quoted 4 lines
Quoted 4 lines
4. The commit message could note that every existing security.sehash is a miss on the first restorecon -D after upgrade one-time full check
+ rewrite to 32 bytes;fsetxattr(...,0)atwalk_next()overwrites in place.
I'll add this
Quoted 4 lines
Quoted 4 lines
5. There is a lingering comment in
label_support.c"Process in blocks of chunkSize bytes" that references a no-longer-existing variable after this change; you could drop that comment in a v2 or follow-up patch.
I'll drop it.
Quoted 37 lines · Stephen Smalley
Quoted 23 lines · Stephen Smalley
Quoted 8 lines · Petr Lautrbach
From: Petr Lautrbach <[email protected]>
SHA-1 is considered obsolete so move to SHA-256 as the default digest algorithm.
Import the public-domain SHA-256 implementation from WjCryptLib and use it for label digest handling.
Quoted 8 lines
The original source of
sha256.cis
https://github.com/WaterJuice/WjCryptLib/releases/tag/Version_3.0.0Ignore sha256.{c,h} in make-format and check-format targets in order to adopt possible future changes in WaterJuice/WjCryptLib simpler.
Signed-off-by Petr Lautrbach <[email protected]>---
A few comments below regarding compatibility / versioning and code formatting inconsistency, but otherwise
Acked-by Stephen Smalley <[email protected]>Quoted 11 lines
1.
selabel_hash_all_partial_matches()output size grows from 20 to 32 bytes.selabel_hash_all_partial_matches()is a public exported symbol (libselinux.map, LIBSELINUX_2.9) whose prototype isuint8_t*digest with no length parameter and no man page. Any external caller sized for the old SHA-1 output gets a 12-byte OOB write fromhash_all_partial_matches(). This interface/functionality was based on Android-specific functionality and I don't see any distro users, so this is probably fine to break, but it should be a stated decision and called out in the commit message and the 3.12 release notes. I will defer to the distros on whether it requires a libselinux.so version bump; I am fine either way.
Quoted 6 lines
Actually, if someone cares, we could just use symbol versioning for this and fallback on the old symbol to only write the first 20-bytes of the SHA256 hash to the output buffer to avoid a compatibility break. That said, the only user of this function that I see is in Android's libselinux and that wouldn't be helped by that.
I guess it's related to
https://android.googlesource.com/platform/external/selinux/+/refs/heads/main/libselinux/src/android/android_device.c#394
It seems to me that symbol versioning would not help if android just pulled new libselinux and left other code intact.
What if we drop selabel_hash_all_partial_matches(), add new selabel_hash_all_partial_matches_with_len(struct selabel_handle *handle,
const char *key, uint8_t *digest, size_t
digest_len) or ..._sha256,bump libselinux.so version and also document the change.
This way 3rd party projects using selabel_hash_all_partial_matches() would not even build and it would highlight the change.
Quoted 26 lines
Quoted 26 lines
2.
restorecon_xattrno longer surfaces legacy 20-byte digests.get_digests_all_partial_matches()only returnsxattr_digestwhenread_size==SHA256_HASH_SIZE, so an existing 20-byte security.sehash is treated as "no xattr".add_xattr_entry()then returns 1 without adding a list entry, sorestorecon_xattron an unconverted tree shows nothing where it used to show "No Match", andrestorecon_xattr-d removes the legacy value silently instead of listing it asDELETED_NOMATCH. Theremovexattr()in the new legacy branch also fires (harmlessly, ENODATA) on every directory that never had a sehash. Not blocking but worth a follow-up so the transition is visible.3. Two differently formatted copies of the same sha256.[ch] files. libsemanage/src/shas256.[ch] is the same source but already reformatted by the mass reformatting. We likely ought to be consistent for both either way.
4. The commit message could note that every existing security.sehash is a miss on the first restorecon -D after upgrade one-time full check
+ rewrite to 32 bytes;fsetxattr(...,0)atwalk_next()overwrites in place.5. There is a lingering comment in
label_support.c"Process in blocks of chunkSize bytes" that references a no-longer-existing variable after this change; you could drop that comment in a v2 or follow-up patch.
Stephen Smalley
maintainerQuoted 53 lines · Petr Lautrbach
Quoted 37 lines · Stephen Smalley
Quoted 23 lines · Stephen Smalley
Quoted 8 lines · Petr Lautrbach
From: Petr Lautrbach <[email protected]>
SHA-1 is considered obsolete so move to SHA-256 as the default digest algorithm.
Import the public-domain SHA-256 implementation from WjCryptLib and use it for label digest handling.
Quoted 8 lines
The original source of
sha256.cis
https://github.com/WaterJuice/WjCryptLib/releases/tag/Version_3.0.0Ignore sha256.{c,h} in make-format and check-format targets in order to adopt possible future changes in WaterJuice/WjCryptLib simpler.
Signed-off-by Petr Lautrbach <[email protected]>---
A few comments below regarding compatibility / versioning and code formatting inconsistency, but otherwise
Acked-by Stephen Smalley <[email protected]>Quoted 11 lines
1.
selabel_hash_all_partial_matches()output size grows from 20 to 32 bytes.selabel_hash_all_partial_matches()is a public exported symbol (libselinux.map, LIBSELINUX_2.9) whose prototype isuint8_t*digest with no length parameter and no man page. Any external caller sized for the old SHA-1 output gets a 12-byte OOB write fromhash_all_partial_matches(). This interface/functionality was based on Android-specific functionality and I don't see any distro users, so this is probably fine to break, but it should be a stated decision and called out in the commit message and the 3.12 release notes. I will defer to the distros on whether it requires a libselinux.so version bump; I am fine either way.Quoted 6 lines
Actually, if someone cares, we could just use symbol versioning for this and fallback on the old symbol to only write the first 20-bytes of the SHA256 hash to the output buffer to avoid a compatibility break. That said, the only user of this function that I see is in Android's libselinux and that wouldn't be helped by that.
I guess it's related to
https://android.googlesource.com/platform/external/selinux/+/refs/heads/main/libselinux/src/android/android_device.c#394It seems to me that symbol versioning would not help if android just pulled new libselinux and left other code intact.
Quoted 8 lines
What if we drop
selabel_hash_all_partial_matches(), add new selabel_hash_all_partial_matches_with_len(structselabel_handle*handle,
const char *key,uint8_t*digest,size_t
digest_len) or ..._sha256,
bump libselinux.so version and also document the change.This way 3rd party projects using
selabel_hash_all_partial_matches()would not even build and it would highlight the change.
Bumping the .so version should be avoided if at all possible since it will mean some/all distros will have to ship both going forward. Using symbol versioning (already used elsewhere in libselinux) as I suggested would be better for the distros but as you note would not fix Android. libselinux already has #ifdef ANDROID blocks however so we could also just use that to have selabel_hash_all_partial_matches() truncate the SHA-256 hash at 20-bytes if that's acceptable for Android, or to do whatever they want done there.
Quoted 47 lines · Petr Lautrbach
Quoted 37 lines · Stephen Smalley
Quoted 23 lines · Stephen Smalley
Quoted 8 lines · Petr Lautrbach
From: Petr Lautrbach <[email protected]>
SHA-1 is considered obsolete so move to SHA-256 as the default digest algorithm.
Import the public-domain SHA-256 implementation from WjCryptLib and use it for label digest handling.
Quoted 8 lines
The original source of
sha256.cis
https://github.com/WaterJuice/WjCryptLib/releases/tag/Version_3.0.0Ignore sha256.{c,h} in make-format and check-format targets in order to adopt possible future changes in WaterJuice/WjCryptLib simpler.
Signed-off-by Petr Lautrbach <[email protected]>---
A few comments below regarding compatibility / versioning and code formatting inconsistency, but otherwise
Acked-by Stephen Smalley <[email protected]>Quoted 11 lines
1.
selabel_hash_all_partial_matches()output size grows from 20 to 32 bytes.selabel_hash_all_partial_matches()is a public exported symbol (libselinux.map, LIBSELINUX_2.9) whose prototype isuint8_t*digest with no length parameter and no man page. Any external caller sized for the old SHA-1 output gets a 12-byte OOB write fromhash_all_partial_matches(). This interface/functionality was based on Android-specific functionality and I don't see any distro users, so this is probably fine to break, but it should be a stated decision and called out in the commit message and the 3.12 release notes. I will defer to the distros on whether it requires a libselinux.so version bump; I am fine either way.Quoted 6 lines
Actually, if someone cares, we could just use symbol versioning for this and fallback on the old symbol to only write the first 20-bytes of the SHA256 hash to the output buffer to avoid a compatibility break. That said, the only user of this function that I see is in Android's libselinux and that wouldn't be helped by that.
Quoted 6 lines
I guess it's related to
https://android.googlesource.com/platform/external/selinux/+/refs/heads/main/libselinux/src/android/android_device.c#394It seems to me that symbol versioning would not help if android just pulled new libselinux and left other code intact.
Thanks for the patch.
Changing the content of security.sehash has a strong impact for us:
during a regular update, if /data needs to be relabeled (because the hash optimization is skipped), the boot time increases significantly, leading to reports from our users and partners.
It is also worth discussing why this migration is required. There is nothing wrong with treating SHA1 as a regular digest. On Android, the file_contexts used as input are all backed by dm-verity read-only partitions.
If we still want to move forward, I recommend using a different set of functions that explicitly uses SHA256 (or have a schema to support future hashing functions). To ease the transition, we could add an option to restorecon to trigger a migration from SHA1 to SHA256 (we could potentially run this as a background thread after boot).
Thanks,
Thiebaud
Stephen Smalley
maintainerQuoted 68 lines · Thiébaud Weksteen
Quoted 47 lines · Petr Lautrbach
Quoted 37 lines · Stephen Smalley
Quoted 23 lines · Stephen Smalley
Quoted 8 lines · Petr Lautrbach
From: Petr Lautrbach <[email protected]>
SHA-1 is considered obsolete so move to SHA-256 as the default digest algorithm.
Import the public-domain SHA-256 implementation from WjCryptLib and use it for label digest handling.
Quoted 8 lines
The original source of
sha256.cis
https://github.com/WaterJuice/WjCryptLib/releases/tag/Version_3.0.0Ignore sha256.{c,h} in make-format and check-format targets in order to adopt possible future changes in WaterJuice/WjCryptLib simpler.
Signed-off-by Petr Lautrbach <[email protected]>---
A few comments below regarding compatibility / versioning and code formatting inconsistency, but otherwise
Acked-by Stephen Smalley <[email protected]>Quoted 11 lines
1.
selabel_hash_all_partial_matches()output size grows from 20 to 32 bytes.selabel_hash_all_partial_matches()is a public exported symbol (libselinux.map, LIBSELINUX_2.9) whose prototype isuint8_t*digest with no length parameter and no man page. Any external caller sized for the old SHA-1 output gets a 12-byte OOB write fromhash_all_partial_matches(). This interface/functionality was based on Android-specific functionality and I don't see any distro users, so this is probably fine to break, but it should be a stated decision and called out in the commit message and the 3.12 release notes. I will defer to the distros on whether it requires a libselinux.so version bump; I am fine either way.Quoted 6 lines
Actually, if someone cares, we could just use symbol versioning for this and fallback on the old symbol to only write the first 20-bytes of the SHA256 hash to the output buffer to avoid a compatibility break. That said, the only user of this function that I see is in Android's libselinux and that wouldn't be helped by that.
Quoted 6 lines
I guess it's related to
https://android.googlesource.com/platform/external/selinux/+/refs/heads/main/libselinux/src/android/android_device.c#394It seems to me that symbol versioning would not help if android just pulled new libselinux and left other code intact.
Thanks for the patch.
Changing the content of security.sehash has a strong impact for us:
during a regular update, if /data needs to be relabeled (because the hash optimization is skipped), the boot time increases significantly, leading to reports from our users and partners.It is also worth discussing why this migration is required. There is nothing wrong with treating SHA1 as a regular digest. On Android, the
file_contextsused as input are all backed by dm-verity read-only partitions.
Quoted 5 lines
If we still want to move forward, I recommend using a different set of functions that explicitly uses SHA256 (or have a schema to support future hashing functions). To ease the transition, we could add an option to restorecon to trigger a migration from SHA1 to SHA256 (we could potentially run this as a background thread after boot).
Have a look at revised version of this patch and my suggested Android-specific fix in:
https://lore.kernel.org/selinux/CAEjxPJ4Mqw=wjktVfZDBkwQ_h9mO8oP4uPEHJL=M8z+5V84mbw@mail.gmail.com/
I think that would address your compatibility concern. WRT to whether or not to transition at all, Fedora has been shipping a version of this patch for years now and regrettably certain compliance frameworks complain about any usage of SHA-1 regardless of whether it is security-relevant.
Quoted 37 lines · Stephen Smalley
Quoted 23 lines · Stephen Smalley
Quoted 8 lines · Petr Lautrbach
From: Petr Lautrbach <[email protected]>
SHA-1 is considered obsolete so move to SHA-256 as the default digest algorithm.
Import the public-domain SHA-256 implementation from WjCryptLib and use it for label digest handling.
Quoted 8 lines
The original source of
sha256.cis
https://github.com/WaterJuice/WjCryptLib/releases/tag/Version_3.0.0Ignore sha256.{c,h} in make-format and check-format targets in order to adopt possible future changes in WaterJuice/WjCryptLib simpler.
Signed-off-by Petr Lautrbach <[email protected]>---
A few comments below regarding compatibility / versioning and code formatting inconsistency, but otherwise
Acked-by Stephen Smalley <[email protected]>Quoted 11 lines
1.
selabel_hash_all_partial_matches()output size grows from 20 to 32 bytes.selabel_hash_all_partial_matches()is a public exported symbol (libselinux.map, LIBSELINUX_2.9) whose prototype isuint8_t*digest with no length parameter and no man page. Any external caller sized for the old SHA-1 output gets a 12-byte OOB write fromhash_all_partial_matches(). This interface/functionality was based on Android-specific functionality and I don't see any distro users, so this is probably fine to break, but it should be a stated decision and called out in the commit message and the 3.12 release notes. I will defer to the distros on whether it requires a libselinux.so version bump; I am fine either way.
Quoted 6 lines
Actually, if someone cares, we could just use symbol versioning for this and fallback on the old symbol to only write the first 20-bytes of the SHA256 hash to the output buffer to avoid a compatibility break. That said, the only user of this function that I see is in Android's libselinux and that wouldn't be helped by that.
Just my 2 cents, I grepped through all opensuse/suse unpacked sources and did not find
anything that uses this really besides the selinux toolchain.
So on our end I think either way is fine, a new versioned symbol is a good idea, but also just breaking compat should not be a problem. I think it is unlikely that a existing third party uses this atm on our end, but I guess we have it easy here.
I don't think a new libselinux.so version is needed