From: Tom Herbert <tom@herbertland.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: <kernel-team@fb.com>
Subject: [PATCH net-next] flow_dissector: Fix function argument ordering dependency
Date: Tue, 1 Sep 2015 18:11:04 -0700 [thread overview]
Message-ID: <1441156264-38469-1-git-send-email-tom@herbertland.com> (raw)
Commit c6cc1ca7f4d70c ("flowi: Abstract out functions to get flow hash
based on flowi") introduced a bug in __skb_set_sw_hash where we
require a dependency on evaluating arguments in a function in order.
There is no such ordering enforced in C, so this incorrect. This
patch fixes that by splitting out the arguments. This bug was
found via a compiler warning that keys may be uninitialized.
Signed-off-by: Tom Herbert <tom@herbertland.com>
---
include/linux/skbuff.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 9e62687..eabfb81 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1035,9 +1035,9 @@ static inline __u32 skb_get_hash_flowi6(struct sk_buff *skb, struct flowi6 *fl6)
{
if (!skb->l4_hash && !skb->sw_hash) {
struct flow_keys keys;
+ __u32 hash = __get_hash_from_flowi6(fl6, &keys);
- __skb_set_sw_hash(skb, __get_hash_from_flowi6(fl6, &keys),
- flow_keys_have_l4(&keys));
+ __skb_set_sw_hash(skb, hash, flow_keys_have_l4(&keys));
}
return skb->hash;
@@ -1049,9 +1049,9 @@ static inline __u32 skb_get_hash_flowi4(struct sk_buff *skb, struct flowi4 *fl4)
{
if (!skb->l4_hash && !skb->sw_hash) {
struct flow_keys keys;
+ __u32 hash = __get_hash_from_flowi4(fl4, &keys);
- __skb_set_sw_hash(skb, __get_hash_from_flowi4(fl4, &keys),
- flow_keys_have_l4(&keys));
+ __skb_set_sw_hash(skb, hash, flow_keys_have_l4(&keys));
}
return skb->hash;
--
1.8.1
next reply other threads:[~2015-09-02 1:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-02 1:11 Tom Herbert [this message]
2015-09-02 1:34 ` [PATCH net-next] flow_dissector: Fix function argument ordering dependency Joe Perches
2015-09-02 3:20 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1441156264-38469-1-git-send-email-tom@herbertland.com \
--to=tom@herbertland.com \
--cc=davem@davemloft.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).