Skip to content

Commit b146cbf

Browse files
committed
af_unix: Silence randstruct GCC plugin warning
While preparing for Clang randstruct support (which duplicated many of the warnings the randstruct GCC plugin warned about), one strange one remained only for the randstruct GCC plugin. Eliminating this rids the plugin of the last exception. It seems the plugin is happy to dereference individual members of a cross-struct cast, but it is upset about casting to a whole object pointer. This only manifests in one place in the kernel, so just replace the variable with individual member accesses. There is no change in executable instruction output. Drop the last exception from the randstruct GCC plugin. Cc: "David S. Miller" <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Paolo Abeni <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Cong Wang <[email protected]> Cc: Al Viro <[email protected]> Cc: [email protected] Cc: [email protected] Acked-by: Kuniyuki Iwashima <[email protected]> Link: https://lore.kernel.org/lkml/[email protected] Acked-by: Jakub Kicinski <[email protected]> Link: https://lore.kernel.org/lkml/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent 2dcfe9e commit b146cbf

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

net/unix/af_unix.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,11 +1808,9 @@ static int maybe_init_creds(struct scm_cookie *scm,
18081808
static bool unix_skb_scm_eq(struct sk_buff *skb,
18091809
struct scm_cookie *scm)
18101810
{
1811-
const struct unix_skb_parms *u = &UNIXCB(skb);
1812-
1813-
return u->pid == scm->pid &&
1814-
uid_eq(u->uid, scm->creds.uid) &&
1815-
gid_eq(u->gid, scm->creds.gid) &&
1811+
return UNIXCB(skb).pid == scm->pid &&
1812+
uid_eq(UNIXCB(skb).uid, scm->creds.uid) &&
1813+
gid_eq(UNIXCB(skb).gid, scm->creds.gid) &&
18161814
unix_secdata_eq(scm, skb);
18171815
}
18181816

scripts/gcc-plugins/randomize_layout_plugin.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ 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" },
5149
{ }
5250
};
5351

0 commit comments

Comments
 (0)