From f87dc57a7189bea4777fd645576a7ab1b71e4b96 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Mon, 24 Mar 2014 14:33:50 -0300 Subject: [PATCH] libkmod: Fix unaligned access From Jan Engelhardt: Program received signal SIGBUS, Bus error. [Switching to process 11100] 0x00035278 in kmod_module_signature_info (file=0x4eeb8, sig_info=0xffffc254) at libkmod/libkmod-signature.c:124 124 sig_len = be32toh(modsig->sig_len); (gdb) p modsig $1 = (const struct module_signature *) 0xf7dfe143 modsig->sig_len can be unaligned if modsig is unaligned, so the padding in the struct has no effect since we are mapping it to the mem buffer. --- libkmod/libkmod-signature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libkmod/libkmod-signature.c b/libkmod/libkmod-signature.c index 6237ab7..a3ac15e 100644 --- a/libkmod/libkmod-signature.c +++ b/libkmod/libkmod-signature.c @@ -121,7 +121,7 @@ bool kmod_module_signature_info(const struct kmod_file *file, struct kmod_signat modsig->hash >= PKEY_HASH__LAST || modsig->id_type >= PKEY_ID_TYPE__LAST) return false; - sig_len = be32toh(modsig->sig_len); + sig_len = be32toh(get_unaligned(&modsig->sig_len)); if (size < (off_t)(modsig->signer_len + modsig->key_id_len + sig_len)) return false;