From: David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
To: sbrivio-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org
Cc: dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org,
sd-y1jBWg8GRStKuXlAQpz2QA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org,
liuhangbin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH net] openvswitch: Don't swap table in nlattr_set() after OVS_ATTR_NESTED is found
Date: Fri, 04 May 2018 12:51:37 -0400 (EDT) [thread overview]
Message-ID: <20180504.125137.302577562059230472.davem@davemloft.net> (raw)
In-Reply-To: <44f4cc7dd6ceb5aac6045e59ff49dce70dd53e74.1525363636.git.sbrivio-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
From: Stefano Brivio <sbrivio-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Date: Thu, 3 May 2018 18:13:25 +0200
> If an OVS_ATTR_NESTED attribute type is found while walking
> through netlink attributes, we call nlattr_set() recursively
> passing the length table for the following nested attributes, if
> different from the current one.
>
> However, once we're done with those sub-nested attributes, we
> should continue walking through attributes using the current
> table, instead of using the one related to the sub-nested
> attributes.
>
> For example, given this sequence:
>
> 1 OVS_KEY_ATTR_PRIORITY
> 2 OVS_KEY_ATTR_TUNNEL
> 3 OVS_TUNNEL_KEY_ATTR_ID
> 4 OVS_TUNNEL_KEY_ATTR_IPV4_SRC
> 5 OVS_TUNNEL_KEY_ATTR_IPV4_DST
> 6 OVS_TUNNEL_KEY_ATTR_TTL
> 7 OVS_TUNNEL_KEY_ATTR_TP_SRC
> 8 OVS_TUNNEL_KEY_ATTR_TP_DST
> 9 OVS_KEY_ATTR_IN_PORT
> 10 OVS_KEY_ATTR_SKB_MARK
> 11 OVS_KEY_ATTR_MPLS
>
> we switch to the 'ovs_tunnel_key_lens' table on attribute #3,
> and we don't switch back to 'ovs_key_lens' while setting
> attributes #9 to #11 in the sequence. As OVS_KEY_ATTR_MPLS
> evaluates to 21, and the array size of 'ovs_tunnel_key_lens' is
> 15, we also get this kind of KASan splat while accessing the
> wrong table:
...
> Reported-by: Hangbin Liu <liuhangbin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Fixes: 982b52700482 ("openvswitch: Fix mask generation for nested attributes.")
> Signed-off-by: Stefano Brivio <sbrivio-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> Reviewed-by: Sabrina Dubroca <sd-y1jBWg8GRStKuXlAQpz2QA@public.gmane.org>
Looks good, applied and queued up for -stable.
Thanks.
prev parent reply other threads:[~2018-05-04 16:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-03 16:13 [PATCH net] openvswitch: Don't swap table in nlattr_set() after OVS_ATTR_NESTED is found Stefano Brivio
[not found] ` <44f4cc7dd6ceb5aac6045e59ff49dce70dd53e74.1525363636.git.sbrivio-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2018-05-04 16:51 ` David Miller [this message]
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=20180504.125137.302577562059230472.davem@davemloft.net \
--to=davem-ft/pcqaiutieiz0/mpfg9q@public.gmane.org \
--cc=dev-yBygre7rU0TnMu66kgdUjQ@public.gmane.org \
--cc=jesse-l0M0P4e3n4LQT0dZR+AlfA@public.gmane.org \
--cc=liuhangbin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sbrivio-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=sd-y1jBWg8GRStKuXlAQpz2QA@public.gmane.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