Skip to content

Commit b07b658

Browse files
committed
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 <[email protected]> Cc: David S. Miller <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent fd466e0 commit b07b658

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

scripts/gcc-plugins/randomize_layout_plugin.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ struct whitelist_entry {
4646
};
4747

4848
static const struct whitelist_entry whitelist[] = {
49+
/* unix_skb_parms via UNIXCB() buffer */
50+
{ "net/unix/af_unix.c", "unix_skb_parms", "char" },
4951
/* walk struct security_hook_heads as an array of struct list_head */
5052
{ "security/security.c", "list_head", "security_hook_heads" },
5153
{ }

0 commit comments

Comments
 (0)