[PATCH v2 06/20] randstruct: Whitelist UNIXCB cast
From: Kees Cook
Date: Fri May 26 2017 - 21:50:43 EST
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 <hannes@xxxxxxxxxxxxxxxxxxx>
Cc: Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
---
scripts/gcc-plugins/randomize_layout_plugin.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/gcc-plugins/randomize_layout_plugin.c b/scripts/gcc-plugins/randomize_layout_plugin.c
index e126ac7874af..bf110915a5aa 100644
--- a/scripts/gcc-plugins/randomize_layout_plugin.c
+++ b/scripts/gcc-plugins/randomize_layout_plugin.c
@@ -43,6 +43,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" },
{ }
--
2.7.4