From: Kees Cook Date: Wed, 5 Apr 2017 04:35:22 +0000 (-0700) Subject: randstruct: Whitelist UNIXCB cast X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b07b65846ba33a4deba03eb6e39043c8bc70903b;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git randstruct: Whitelist UNIXCB cast This is another false positive in bad cast detection: net/unix/af_unix.c: In function ‘unix_skb_scm_eq’: net/unix/af_unix.c:1621:31: note: found mismatched rhs struct pointer types: ‘struct unix_skb_parms’ and ‘char’ const struct unix_skb_parms *u = &UNIXCB(skb); ^ UNIXCB is: #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb)) And ->cb is: char cb[48] __aligned(8); This is a rather crazy cast, but appears to be safe in the face of randomization, so whitelist it in the plugin. Cc: Hannes Frederic Sowa Cc: David S. Miller Signed-off-by: Kees Cook --- diff --git a/scripts/gcc-plugins/randomize_layout_plugin.c b/scripts/gcc-plugins/randomize_layout_plugin.c index dc0df3765a8f..2e710bf29699 100644 --- a/scripts/gcc-plugins/randomize_layout_plugin.c +++ b/scripts/gcc-plugins/randomize_layout_plugin.c @@ -46,6 +46,8 @@ struct whitelist_entry { }; static const struct whitelist_entry whitelist[] = { + /* unix_skb_parms via UNIXCB() buffer */ + { "net/unix/af_unix.c", "unix_skb_parms", "char" }, /* walk struct security_hook_heads as an array of struct list_head */ { "security/security.c", "list_head", "security_hook_heads" }, { }