Skip to content

Commit 12e130b

Browse files
dhowellsrustyrussell
authored andcommitted
MODSIGN: Don't use enum-type bitfields in module signature info block
Don't use enum-type bitfields in the module signature info block as we can't be certain how the compiler will handle them. As I understand it, it is arch dependent, and it is possible for the compiler to rearrange them based on endianness and to insert a byte of padding to pad the three enums out to four bytes. Instead use u8 fields for these, which the compiler should emit in the right order without padding. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent df2fc24 commit 12e130b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

kernel/module_signing.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
* - Information block
2828
*/
2929
struct module_signature {
30-
enum pkey_algo algo : 8; /* Public-key crypto algorithm */
31-
enum pkey_hash_algo hash : 8; /* Digest algorithm */
32-
enum pkey_id_type id_type : 8; /* Key identifier type */
33-
u8 signer_len; /* Length of signer's name */
34-
u8 key_id_len; /* Length of key identifier */
35-
u8 __pad[3];
36-
__be32 sig_len; /* Length of signature data */
30+
u8 algo; /* Public-key crypto algorithm [enum pkey_algo] */
31+
u8 hash; /* Digest algorithm [enum pkey_hash_algo] */
32+
u8 id_type; /* Key identifier type [enum pkey_id_type] */
33+
u8 signer_len; /* Length of signer's name */
34+
u8 key_id_len; /* Length of key identifier */
35+
u8 __pad[3];
36+
__be32 sig_len; /* Length of signature data */
3737
};
3838

3939
/*

0 commit comments

Comments
 (0)