[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 3 Mar 2015 13:50:59 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Florian Westphal' <fw@...len.de>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH v2] net: bridge: add compile-time assert for cb struct
size
From: Florian Westphal
> make build fail if structure no longer fits into ->cb storage.
>
> Signed-off-by: Florian Westphal <fw@...len.de>
> ---
> Change since v1: use FIELD_SIZEOF
>
> checkpatch complains about >80 chars, but line break is ugly here.
>
> diff --git a/net/bridge/br.c b/net/bridge/br.c
> index fb57ab6..02c24cf 100644
> --- a/net/bridge/br.c
> +++ b/net/bridge/br.c
> @@ -190,6 +190,8 @@ static int __init br_init(void)
> {
> int err;
>
> + BUILD_BUG_ON(sizeof(struct br_input_skb_cb) > FIELD_SIZEOF(struct sk_buff, cb));
> +
What about using something based on:
#define GET_CB(skb, type) ((type *)((skb)->cb + (sizeof (char[(sizeof (type) <= sizeof (skb->cb)) ? 1 : -1] - 1)))
to access skb->sb?
Then all invalid uses are likely to be picked up.
David
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists