lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADvbK_dtGaAs1CofnWzMuhCkb4HBoj3xCWzVa1tEe1m2jE1NuQ@mail.gmail.com>
Date: Mon, 2 Dec 2024 10:03:10 -0500
From: Xin Long <lucien.xin@...il.com>
To: Cong Wang <xiyou.wangcong@...il.com>, Shuang Li <shuali@...hat.com>
Cc: network dev <netdev@...r.kernel.org>, davem@...emloft.net, kuba@...nel.org, 
	Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>, 
	Jamal Hadi Salim <jhs@...atatu.com>, Jiri Pirko <jiri@...nulli.us>, 
	Davide Caratti <dcaratti@...hat.com>, Simon Horman <horms@...nel.org>
Subject: Re: [PATCH net] net: sched: fix erspan_opt settings in cls_flower

On Thu, Nov 28, 2024 at 8:59 PM Cong Wang <xiyou.wangcong@...il.com> wrote:
>
> On Mon, Nov 25, 2024 at 03:56:51PM -0500, Xin Long wrote:
> > When matching erspan_opt in cls_flower, only the (version, dir, hwid)
> > fields are relevant. However, in fl_set_erspan_opt() it initializes
> > all bits of erspan_opt and its mask to 1. This inadvertently requires
> > packets to match not only the (version, dir, hwid) fields but also the
> > other fields that are unexpectedly set to 1.
>
> Do you have a test case for this? Please consider adding one (in a
> separate patch) to tools/testing/selftests/tc-testing/.
>
Yes, Shuang Li has one (attached), I will check if she will be able to
add it to selftests.

> >
> > This patch resolves the issue by ensuring that only the (version, dir,
> > hwid) fields are configured in fl_set_erspan_opt(), leaving the other
> > fields to 0 in erspan_opt.
> >
> > Fixes: 79b1011cb33d ("net: sched: allow flower to match erspan options")
> > Reported-by: Shuang Li <shuali@...hat.com>
> > Signed-off-by: Xin Long <lucien.xin@...il.com>
> > ---
> >  net/sched/cls_flower.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
> > index e280c27cb9f9..c89161c5a119 100644
> > --- a/net/sched/cls_flower.c
> > +++ b/net/sched/cls_flower.c
> > @@ -1369,7 +1369,6 @@ static int fl_set_erspan_opt(const struct nlattr *nla, struct fl_flow_key *key,
> >       int err;
> >
> >       md = (struct erspan_metadata *)&key->enc_opts.data[key->enc_opts.len];
> > -     memset(md, 0xff, sizeof(*md));
> >       md->version = 1;
> >
> >       if (!depth)
> > @@ -1398,9 +1397,9 @@ static int fl_set_erspan_opt(const struct nlattr *nla, struct fl_flow_key *key,
> >                       NL_SET_ERR_MSG(extack, "Missing tunnel key erspan option index");
> >                       return -EINVAL;
> >               }
> > +             memset(&md->u.index, 0xff, sizeof(md->u.index));
> >               if (tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX]) {
> >                       nla = tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX];
> > -                     memset(&md->u, 0x00, sizeof(md->u));
> >                       md->u.index = nla_get_be32(nla);
> >               }
> >       } else if (md->version == 2) {
> > @@ -1409,10 +1408,12 @@ static int fl_set_erspan_opt(const struct nlattr *nla, struct fl_flow_key *key,
> >                       NL_SET_ERR_MSG(extack, "Missing tunnel key erspan option dir or hwid");
> >                       return -EINVAL;
> >               }
> > +             md->u.md2.dir = 1;
> >               if (tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR]) {
> >                       nla = tb[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR];
> >                       md->u.md2.dir = nla_get_u8(nla);
> >               }
> > +             set_hwid(&md->u.md2, 0x3f);
>
> I think using 0xff is easier to understand, otherwise we would need to
> look into set_hwid() to figure out what 0x3f means. :-/
>
Right, will post v2.

Thanks.

Download attachment "erspan.V3.sh" of type "application/x-sh" (6321 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ