* [PATCH v2] net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64
@ 2023-07-24 1:46 Lin Ma
2023-07-24 21:29 ` Victor Nogueira
2023-07-24 23:02 ` Jakub Kicinski
0 siblings, 2 replies; 11+ messages in thread
From: Lin Ma @ 2023-07-24 1:46 UTC (permalink / raw)
To: jhs, xiyou.wangcong, jiri, davem, edumazet, kuba, pabeni, netdev,
linux-kernel
Cc: Lin Ma
The nla_for_each_nested parsing in function mqprio_parse_nlattr() does
not check the length of the nested attribute. This can lead to an
out-of-attribute read and allow a malformed nlattr (e.g., length 0) to
be viewed as 8 byte integer and passed to priv->max_rate/min_rate.
This patch adds the check based on nla_len() when check the nla_type(),
which ensures that the length of these two attribute must equals
sizeof(u64).
Fixes: 4e8b86c06269 ("mqprio: Introduce new hardware offload mode and shaper in mqprio")
Signed-off-by: Lin Ma <linma@zju.edu.cn>
---
V1 -> V2: do check with != rather than < as suggested
seperate the check and give clearer error message
net/sched/sch_mqprio.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
index ab69ff7577fc..f1d141a6d0aa 100644
--- a/net/sched/sch_mqprio.c
+++ b/net/sched/sch_mqprio.c
@@ -290,6 +290,13 @@ static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt,
"Attribute type expected to be TCA_MQPRIO_MIN_RATE64");
return -EINVAL;
}
+
+ if (nla_len(attr) != sizeof(u64)) {
+ NL_SET_ERR_MSG_ATTR(extack, attr,
+ "Attribute TCA_MQPRIO_MIN_RATE64 expected to have 8 bytes length");
+ return -EINVAL;
+ }
+
if (i >= qopt->num_tc)
break;
priv->min_rate[i] = nla_get_u64(attr);
@@ -312,6 +319,13 @@ static int mqprio_parse_nlattr(struct Qdisc *sch, struct tc_mqprio_qopt *qopt,
"Attribute type expected to be TCA_MQPRIO_MAX_RATE64");
return -EINVAL;
}
+
+ if (nla_len(attr) != sizeof(u64)) {
+ NL_SET_ERR_MSG_ATTR(extack, attr,
+ "Attribute TCA_MQPRIO_MAX_RATE64 expected to have 8 bytes length");
+ return -EINVAL;
+ }
+
if (i >= qopt->num_tc)
break;
priv->max_rate[i] = nla_get_u64(attr);
--
2.17.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2] net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64
2023-07-24 1:46 [PATCH v2] net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64 Lin Ma
@ 2023-07-24 21:29 ` Victor Nogueira
2023-07-24 23:02 ` Jakub Kicinski
1 sibling, 0 replies; 11+ messages in thread
From: Victor Nogueira @ 2023-07-24 21:29 UTC (permalink / raw)
To: Lin Ma, jhs, xiyou.wangcong, jiri, davem, edumazet, kuba, pabeni,
netdev, linux-kernel
On 23/07/2023 22:46, Lin Ma wrote:
> The nla_for_each_nested parsing in function mqprio_parse_nlattr() does
> not check the length of the nested attribute. This can lead to an
> out-of-attribute read and allow a malformed nlattr (e.g., length 0) to
> be viewed as 8 byte integer and passed to priv->max_rate/min_rate.
>
> This patch adds the check based on nla_len() when check the nla_type(),
> which ensures that the length of these two attribute must equals
> sizeof(u64).
>
> Fixes: 4e8b86c06269 ("mqprio: Introduce new hardware offload mode and shaper in mqprio")
> Signed-off-by: Lin Ma <linma@zju.edu.cn>
Reviewed-by: Victor Nogueira <victor@mojatatu.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64
2023-07-24 1:46 [PATCH v2] net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64 Lin Ma
2023-07-24 21:29 ` Victor Nogueira
@ 2023-07-24 23:02 ` Jakub Kicinski
2023-07-25 0:15 ` Lin Ma
1 sibling, 1 reply; 11+ messages in thread
From: Jakub Kicinski @ 2023-07-24 23:02 UTC (permalink / raw)
To: Lin Ma
Cc: jhs, xiyou.wangcong, jiri, davem, edumazet, pabeni, netdev,
linux-kernel
On Mon, 24 Jul 2023 09:46:25 +0800 Lin Ma wrote:
> The nla_for_each_nested parsing in function mqprio_parse_nlattr() does
> not check the length of the nested attribute. This can lead to an
> out-of-attribute read and allow a malformed nlattr (e.g., length 0) to
> be viewed as 8 byte integer and passed to priv->max_rate/min_rate.
>
> This patch adds the check based on nla_len() when check the nla_type(),
> which ensures that the length of these two attribute must equals
> sizeof(u64).
How do you run get_maintainer? You didn't CC the author of the code.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64
2023-07-24 23:02 ` Jakub Kicinski
@ 2023-07-25 0:15 ` Lin Ma
2023-07-25 0:56 ` Jakub Kicinski
0 siblings, 1 reply; 11+ messages in thread
From: Lin Ma @ 2023-07-25 0:15 UTC (permalink / raw)
To: Jakub Kicinski
Cc: jhs, xiyou.wangcong, jiri, davem, edumazet, pabeni, netdev,
linux-kernel
Hello Jakub,
> > The nla_for_each_nested parsing in function mqprio_parse_nlattr() does
> > not check the length of the nested attribute. This can lead to an
> > out-of-attribute read and allow a malformed nlattr (e.g., length 0) to
> > be viewed as 8 byte integer and passed to priv->max_rate/min_rate.
> >
> > This patch adds the check based on nla_len() when check the nla_type(),
> > which ensures that the length of these two attribute must equals
> > sizeof(u64).
>
> How do you run get_maintainer? You didn't CC the author of the code.
That's weird, I just ran code below and send this patch to all 9 emails poped out.
# ./scripts/get_maintainer.pl net/sched/sch_mqprio.c
Jamal Hadi Salim <jhs@mojatatu.com> (maintainer:TC subsystem)
Cong Wang <xiyou.wangcong@gmail.com> (maintainer:TC subsystem)
Jiri Pirko <jiri@resnulli.us> (maintainer:TC subsystem)
"David S. Miller" <davem@davemloft.net> (maintainer:NETWORKING [GENERAL])
Eric Dumazet <edumazet@google.com> (maintainer:NETWORKING [GENERAL])
Jakub Kicinski <kuba@kernel.org> (maintainer:NETWORKING [GENERAL])
Paolo Abeni <pabeni@redhat.com> (maintainer:NETWORKING [GENERAL])
netdev@vger.kernel.org (open list:TC subsystem)
linux-kernel@vger.kernel.org (open list)
Can you tell me which one is missing and I will resend the patch to him.
Thanks
Lin
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64
2023-07-25 0:15 ` Lin Ma
@ 2023-07-25 0:56 ` Jakub Kicinski
2023-07-25 1:33 ` Lin Ma
2023-07-25 3:59 ` Joe Perches
0 siblings, 2 replies; 11+ messages in thread
From: Jakub Kicinski @ 2023-07-25 0:56 UTC (permalink / raw)
To: Lin Ma, Joe Perches
Cc: jhs, xiyou.wangcong, jiri, davem, edumazet, pabeni, netdev,
linux-kernel
On Tue, 25 Jul 2023 08:15:39 +0800 (GMT+08:00) Lin Ma wrote:
> > > The nla_for_each_nested parsing in function mqprio_parse_nlattr() does
> > > not check the length of the nested attribute. This can lead to an
> > > out-of-attribute read and allow a malformed nlattr (e.g., length 0) to
> > > be viewed as 8 byte integer and passed to priv->max_rate/min_rate.
> > >
> > > This patch adds the check based on nla_len() when check the nla_type(),
> > > which ensures that the length of these two attribute must equals
> > > sizeof(u64).
> >
> > How do you run get_maintainer? You didn't CC the author of the code.
>
> That's weird, I just ran code below and send this patch to all 9 emails poped out.
>
> # ./scripts/get_maintainer.pl net/sched/sch_mqprio.c
Joe, here's another case.
Lin Ma, you need to run the script on the file generated by
git format-patch, rather than the file path. That gives better
coverage for keywords included in the commit message (especially
the Fixes tag). Please rerun it on the patch and repost with
the right CC list.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64
2023-07-25 0:56 ` Jakub Kicinski
@ 2023-07-25 1:33 ` Lin Ma
2023-07-25 3:59 ` Joe Perches
1 sibling, 0 replies; 11+ messages in thread
From: Lin Ma @ 2023-07-25 1:33 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Joe Perches, jhs, xiyou.wangcong, jiri, davem, edumazet, pabeni,
netdev, linux-kernel
Hi Jakub,
> > > > The nla_for_each_nested parsing in function mqprio_parse_nlattr() does
> > > > not check the length of the nested attribute. This can lead to an
> > > > out-of-attribute read and allow a malformed nlattr (e.g., length 0) to
> > > > be viewed as 8 byte integer and passed to priv->max_rate/min_rate.
> > > >
> > > > This patch adds the check based on nla_len() when check the nla_type(),
> > > > which ensures that the length of these two attribute must equals
> > > > sizeof(u64).
> > >
> > > How do you run get_maintainer? You didn't CC the author of the code.
> >
> > That's weird, I just ran code below and send this patch to all 9 emails poped out.
> >
> > # ./scripts/get_maintainer.pl net/sched/sch_mqprio.c
>
> Joe, here's another case.
>
> Lin Ma, you need to run the script on the file generated by
> git format-patch, rather than the file path. That gives better
> coverage for keywords included in the commit message (especially
> the Fixes tag). Please rerun it on the patch and repost with
> the right CC list.
Copy that. Sorry for the inconvenience that was raised by that. Will
resend the patch with the correct CC list ASAP.
Regards
Lin
> --
> pw-bot: cr
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64
2023-07-25 0:56 ` Jakub Kicinski
2023-07-25 1:33 ` Lin Ma
@ 2023-07-25 3:59 ` Joe Perches
2023-07-25 19:38 ` Jakub Kicinski
1 sibling, 1 reply; 11+ messages in thread
From: Joe Perches @ 2023-07-25 3:59 UTC (permalink / raw)
To: Jakub Kicinski, Lin Ma
Cc: jhs, xiyou.wangcong, jiri, davem, edumazet, pabeni, netdev,
linux-kernel
On Mon, 2023-07-24 at 17:56 -0700, Jakub Kicinski wrote:
> On Tue, 25 Jul 2023 08:15:39 +0800 (GMT+08:00) Lin Ma wrote:
> > > > The nla_for_each_nested parsing in function mqprio_parse_nlattr() does
> > > > not check the length of the nested attribute. This can lead to an
> > > > out-of-attribute read and allow a malformed nlattr (e.g., length 0) to
> > > > be viewed as 8 byte integer and passed to priv->max_rate/min_rate.
> > > >
> > > > This patch adds the check based on nla_len() when check the nla_type(),
> > > > which ensures that the length of these two attribute must equals
> > > > sizeof(u64).
> > >
> > > How do you run get_maintainer? You didn't CC the author of the code.
> >
> > That's weird, I just ran code below and send this patch to all 9 emails poped out.
> >
> > # ./scripts/get_maintainer.pl net/sched/sch_mqprio.c
>
> Joe, here's another case.
What do you think the "case" is here?
Do you think John Fastabend, who hasn't touched the file in 7+ years
should be cc'd? Why?
> Lin Ma, you need to run the script on the file generated by
> git format-patch, rather than the file path. That gives better
> coverage for keywords included in the commit message (especially
> the Fixes tag). Please rerun it on the patch and repost with
> the right CC list.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64
2023-07-25 3:59 ` Joe Perches
@ 2023-07-25 19:38 ` Jakub Kicinski
2023-07-25 19:50 ` Joe Perches
0 siblings, 1 reply; 11+ messages in thread
From: Jakub Kicinski @ 2023-07-25 19:38 UTC (permalink / raw)
To: Joe Perches
Cc: Lin Ma, jhs, xiyou.wangcong, jiri, davem, edumazet, pabeni,
netdev, linux-kernel
On Mon, 24 Jul 2023 20:59:53 -0700 Joe Perches wrote:
> > Joe, here's another case.
>
> What do you think the "case" is here?
>
> Do you think John Fastabend, who hasn't touched the file in 7+ years
> should be cc'd? Why?
Nope. The author of the patch under Fixes.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64
2023-07-25 19:38 ` Jakub Kicinski
@ 2023-07-25 19:50 ` Joe Perches
2023-07-25 19:56 ` Jakub Kicinski
0 siblings, 1 reply; 11+ messages in thread
From: Joe Perches @ 2023-07-25 19:50 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Lin Ma, jhs, xiyou.wangcong, jiri, davem, edumazet, pabeni,
netdev, linux-kernel
On Tue, 2023-07-25 at 12:38 -0700, Jakub Kicinski wrote:
> On Mon, 24 Jul 2023 20:59:53 -0700 Joe Perches wrote:
> > > Joe, here's another case.
> >
> > What do you think the "case" is here?
> >
> > Do you think John Fastabend, who hasn't touched the file in 7+ years
> > should be cc'd? Why?
>
> Nope. The author of the patch under Fixes.
It adds that already since 2019.
commit 2f5bd343694ed53b3abc4a616ce975505271afe7
Author: Joe Perches <joe@perches.com>
Date: Wed Dec 4 16:50:29 2019 -0800
scripts/get_maintainer.pl: add signatures from Fixes: <badcommit> lines in commit message
A Fixes: lines in a commit message generally indicate that a previous
commit was inadequate for whatever reason.
The signers of the previous inadequate commit should also be cc'd on
this new commit so update get_maintainer to find the old commit and add
the original signers.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64
2023-07-25 19:50 ` Joe Perches
@ 2023-07-25 19:56 ` Jakub Kicinski
2023-07-25 21:04 ` Joe Perches
0 siblings, 1 reply; 11+ messages in thread
From: Jakub Kicinski @ 2023-07-25 19:56 UTC (permalink / raw)
To: Joe Perches
Cc: Lin Ma, jhs, xiyou.wangcong, jiri, davem, edumazet, pabeni,
netdev, linux-kernel
On Tue, 25 Jul 2023 12:50:00 -0700 Joe Perches wrote:
> > > What do you think the "case" is here?
> > >
> > > Do you think John Fastabend, who hasn't touched the file in 7+ years
> > > should be cc'd? Why?
> >
> > Nope. The author of the patch under Fixes.
>
> It adds that already since 2019.
Which is awesome! But for that to work you have to run get_maintainer
on the patchfile not the file paths. Lin Ma used:
# ./scripts/get_maintainer.pl net/sched/sch_mqprio.c
That's what I keep complaining about. People run get_maintainer on
paths and miss out on all the get_maintainer features which need
to see the commit message.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2] net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64
2023-07-25 19:56 ` Jakub Kicinski
@ 2023-07-25 21:04 ` Joe Perches
0 siblings, 0 replies; 11+ messages in thread
From: Joe Perches @ 2023-07-25 21:04 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Lin Ma, jhs, xiyou.wangcong, jiri, davem, edumazet, pabeni,
netdev, linux-kernel
On Tue, 2023-07-25 at 12:56 -0700, Jakub Kicinski wrote:
> On Tue, 25 Jul 2023 12:50:00 -0700 Joe Perches wrote:
> > > > What do you think the "case" is here?
> > > >
> > > > Do you think John Fastabend, who hasn't touched the file in 7+ years
> > > > should be cc'd? Why?
> > >
> > > Nope. The author of the patch under Fixes.
> >
> > It adds that already since 2019.
>
> Which is awesome! But for that to work you have to run get_maintainer
> on the patchfile not the file paths. Lin Ma used:
>
> # ./scripts/get_maintainer.pl net/sched/sch_mqprio.c
>
> That's what I keep complaining about. People run get_maintainer on
> paths and miss out on all the get_maintainer features which need
> to see the commit message.
Which is useful when editing a file but not when sending
a patch. get_maintainer does _both_.
Again, there's no issue with get_maintainer, but there is
in its use. If there's a real issue, it's with people
and their knowledge of process documentation.
It's _not_ the tool itself as you stated.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-07-25 21:04 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-24 1:46 [PATCH v2] net/sched: mqprio: Add length check for TCA_MQPRIO_{MAX/MIN}_RATE64 Lin Ma
2023-07-24 21:29 ` Victor Nogueira
2023-07-24 23:02 ` Jakub Kicinski
2023-07-25 0:15 ` Lin Ma
2023-07-25 0:56 ` Jakub Kicinski
2023-07-25 1:33 ` Lin Ma
2023-07-25 3:59 ` Joe Perches
2023-07-25 19:38 ` Jakub Kicinski
2023-07-25 19:50 ` Joe Perches
2023-07-25 19:56 ` Jakub Kicinski
2023-07-25 21:04 ` Joe Perches
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).