Skip to contentSkip to conversation

kexec: kexec_crash_save_info() vs Misra C:2012 rule 8.3

PATCH Andrew Cooper 4 participants 6 messages May 13 – May 15 3 messages not in the archive

lore
Share & tools
lore

Andrew Cooper

author Acked-by
#2 lore raw
In reply to a message not in the archive
Quoted 7 lines · Jan Beulich

... ("All declarations of an object or function shall use the same names and type qualifiers"). The declaration doesn't use the typedef, so the definition shouldn't either.

---
Really, is the typedef of much use? I.e. can't we drop it altogether?

It doesn't look to be much use.

I thought I'd tried this fix before but it hadn't worked.  (I dropped it from my series as a result).  Perhaps the later include shuffling addressed the secondary issue I was seeing.

Reviewed-by
#3 lore raw
In reply to a message not in the archive
Quoted 5 lines · Jan Beulich

... ("All declarations of an object or function shall use the same names and type qualifiers"). The declaration doesn't use the typedef, so the definition shouldn't either.

Quoted 16 lines

---
Really, is the typedef of much use? I.e. can't we drop it altogether?

xen/common/kexec.c +1 -1
@@ -333,7 +333,7 @@ void kexec_crash_save_cpu(void)
 }
 
 /* Set up the single Xen-specific-info crash note. */
-crash_xen_info_t *kexec_crash_save_info(void)
+struct crash_xen_info *kexec_crash_save_info(void)
 {
     int cpu = smp_processor_id();
     crash_xen_info_t info;
#5 lore raw

Re: [PATCH 2/2] crypto/rijndael: adjust for Misra C:2012 rule 8.3

In reply to a message not in the archive
Quoted 10 lines · Jan Beulich

... ("All declarations of an object or function shall use the same names and type qualifiers"). Bring declarations in line with the corresponding definitions, accepting the use of the being-phased-out u<N> types. While we don't define NEED_RIJNDAEL_DECRYPT, cover rijndaelKeySetupDec() as well for completeness.

xen/include/crypto/rijndael.h int rijndael_set_key_enc_only(rijndael_c · line 54

Quoted 9 lines
xen/include/crypto/rijndael.h +2 -4
@@ -50,9 +50,8 @@ int	rijndael_set_key_enc_only(rijndael_c
 void	rijndael_decrypt(rijndael_ctx *ctx, const unsigned char *src, unsigned char *dst);
 void	rijndael_encrypt(rijndael_ctx *ctx, const unsigned char *src, unsigned char *dst);
 
-int	rijndaelKeySetupEnc(unsigned int rk[], const unsigned char cipherKey[], int keyBits);
-int	rijndaelKeySetupDec(unsigned int rk[], const unsigned char cipkerKey[], int keyBits);
-void	rijndaelEncrypt(const unsigned int rk[], int Nr, const unsigned char pt[16],
-			unsigned char ct[16]);
+int	rijndaelKeySetupEnc(u32 rk[], const u8 cipherKey[], int keyBits);
+int	rijndaelKeySetupDec(u32 rk[], const u8 cipkerKey[], int keyBits);

There is a typo "cipkerKey" which is only present in rijndael.h but not in rijndael.c

Quoted 5 lines
xen/include/crypto/rijndael.h +1 -0
+void	rijndaelEncrypt(const u32 rk[], int Nr, const u8 pt[16], u8 ct[16]);
 
 #endif /* __RIJNDAEL_H */
Reviewed-by
#6 lore raw

Re: [PATCH 2/2] crypto/rijndael: adjust for Misra C:2012 rule 8.3

In reply to a message not in the archive
Quoted 8 lines · Jan Beulich

... ("All declarations of an object or function shall use the same names and type qualifiers"). Bring declarations in line with the corresponding definitions, accepting the use of the being-phased-out u<N> types. While we don't define NEED_RIJNDAEL_DECRYPT, cover rijndaelKeySetupDec() as well for completeness.

with the typo in rijndaelKeySetupDec's declaration fixed as noted by Stefano

Quoted 21 lines
xen/include/crypto/rijndael.h +0 -3
@@ -50,9 +50,8 @@ int	rijndael_set_key_enc_only(rijndael_c
 void	rijndael_decrypt(rijndael_ctx *ctx, const unsigned char *src, 
 unsigned char *dst);
 void	rijndael_encrypt(rijndael_ctx *ctx, const unsigned char *src, 
 unsigned char *dst);
 
-int	rijndaelKeySetupEnc(unsigned int rk[], const unsigned char 
 cipherKey[], int keyBits);
-int	rijndaelKeySetupDec(unsigned int rk[], const unsigned char 
 cipkerKey[], int keyBits);
-void	rijndaelEncrypt(const unsigned int rk[], int Nr, const unsigned 

char pt[16],

xen/include/crypto/rijndael.h +3 -1
-			unsigned char ct[16]);
+int	rijndaelKeySetupEnc(u32 rk[], const u8 cipherKey[], int keyBits);
+int	rijndaelKeySetupDec(u32 rk[], const u8 cipkerKey[], int keyBits);
+void	rijndaelEncrypt(const u32 rk[], int Nr, const u8 pt[16], u8 

ct[16]);

#endif /* __RIJNDAEL_H */

Signature · 4 lines
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253
#7 lore raw

Re: [PATCH 2/2] crypto/rijndael: adjust for Misra C:2012 rule 8.3

In reply to a message not in the archive
Quoted 14 lines · Jan Beulich

... ("All declarations of an object or function shall use the same names and type qualifiers"). Bring declarations in line with the corresponding definitions, accepting the use of the being-phased-out u<N> types. While we don't define NEED_RIJNDAEL_DECRYPT, cover rijndaelKeySetupDec() as well for completeness.

xen/include/crypto/rijndael.h +0 -0
@@ -50,9 +50,8 @@ int	rijndael_set_key_enc_only(rijndael_c
 void	rijndael_decrypt(rijndael_ctx *ctx, const unsigned char *src, unsigned char *dst);
 void	rijndael_encrypt(rijndael_ctx *ctx, const unsigned char *src, unsigned char *dst);

xen/include/crypto/rijndael.h int rijndael_set_key_enc_only(rijndael_c · line 57

Quoted 10 lines
xen/include/crypto/rijndael.h +3 -4
 
-int	rijndaelKeySetupEnc(unsigned int rk[], const unsigned char cipherKey[], int keyBits);
-int	rijndaelKeySetupDec(unsigned int rk[], const unsigned char cipkerKey[], int keyBits);
-void	rijndaelEncrypt(const unsigned int rk[], int Nr, const unsigned char pt[16],
-			unsigned char ct[16]);
+int	rijndaelKeySetupEnc(u32 rk[], const u8 cipherKey[], int keyBits);
+int	rijndaelKeySetupDec(u32 rk[], const u8 cipkerKey[], int keyBits);
+void	rijndaelEncrypt(const u32 rk[], int Nr, const u8 pt[16], u8 ct[16]);
 
 #endif /* __RIJNDAEL_H */

Hmm.

The rijndael_encrypt() in context is a trivial wrapper of rijndaelEncrypt() using rijndael_ctx.  The only user is VMAC which defines aes_encryption() in terms of rijndaelEncrypt(), making rijndael_encrypt() dead code.  The decrypt side is even deader code.

It might be worth taking this patch in the short term, but I think we could get away with a lot of deletion.

~Andrew

#8 lore raw

Re: [PATCH 2/2] crypto/rijndael: adjust for Misra C:2012 rule 8.3

Quoted 28 lines · Andrew Cooper
Quoted 14 lines · Jan Beulich

... ("All declarations of an object or function shall use the same names and type qualifiers"). Bring declarations in line with the corresponding definitions, accepting the use of the being-phased-out u<N> types. While we don't define NEED_RIJNDAEL_DECRYPT, cover rijndaelKeySetupDec() as well for completeness.

xen/include/crypto/rijndael.h +0 -0
@@ -50,9 +50,8 @@ int	rijndael_set_key_enc_only(rijndael_c
 void	rijndael_decrypt(rijndael_ctx *ctx, const unsigned char *src, unsigned char *dst);
 void	rijndael_encrypt(rijndael_ctx *ctx, const unsigned char *src, unsigned char *dst);

xen/include/crypto/rijndael.h int rijndael_set_key_enc_only(rijndael_c · line 57

Quoted 10 lines
xen/include/crypto/rijndael.h +3 -4
 
-int	rijndaelKeySetupEnc(unsigned int rk[], const unsigned char cipherKey[], int keyBits);
-int	rijndaelKeySetupDec(unsigned int rk[], const unsigned char cipkerKey[], int keyBits);
-void	rijndaelEncrypt(const unsigned int rk[], int Nr, const unsigned char pt[16],
-			unsigned char ct[16]);
+int	rijndaelKeySetupEnc(u32 rk[], const u8 cipherKey[], int keyBits);
+int	rijndaelKeySetupDec(u32 rk[], const u8 cipkerKey[], int keyBits);
+void	rijndaelEncrypt(const u32 rk[], int Nr, const u8 pt[16], u8 ct[16]);
 
 #endif /* __RIJNDAEL_H */

Hmm.

Quoted 7 lines

The rijndael_encrypt() in context is a trivial wrapper of rijndaelEncrypt() using rijndael_ctx.  The only user is VMAC which defines aes_encryption() in terms of rijndaelEncrypt(), making rijndael_encrypt() dead code.  The decrypt side is even deader code.

It might be worth taking this patch in the short term, but I think we could get away with a lot of deletion.

Well, really this whole piece of code would likely better be replaced by something structured, assuming it's going to be needed at all anymore after TBOOT deletion.

Jan