[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <sma534z36vpf4ijyalaemiefyze3miqdusp73ewfpegtuuwv6n@vlz6erzympst>
Date: Tue, 25 Jul 2023 08:44:42 +0200
From: Zahari Doychev <zahari.doychev@...ux.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: "David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Jamal Hadi Salim <jhs@...atatu.com>, Cong Wang <xiyou.wangcong@...il.com>,
Jiri Pirko <jiri@...nulli.us>, netdev@...r.kernel.org, eric.dumazet@...il.com,
syzbot <syzkaller@...glegroups.com>, Simon Horman <simon.horman@...igine.com>,
Ido Schimmel <idosch@...dia.com>
Subject: Re: [PATCH net] net: flower: fix stack-out-of-bounds in
fl_set_key_cfm()
On Mon, Jul 24, 2023 at 04:32:54PM +0000, Eric Dumazet wrote:
> Typical misuse of
>
> nla_parse_nested(array, XXX_MAX, ...);
>
> array must be declared as
>
> struct nlattr *array[XXX_MAX + 1];
>
> Fixes: 7cfffd5fed3e ("net: flower: add support for matching cfm fields")
> Reported-by: syzbot <syzkaller@...glegroups.com>
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> Cc: Simon Horman <simon.horman@...igine.com>
> Cc: Ido Schimmel <idosch@...dia.com>
> ---
> net/sched/cls_flower.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
> index 8da9d039d964ea417700a2f59ad95a9ce52f5eab..3c7a272bf7c7cf7d4ae21b5370cbc428086d6979 100644
> --- a/net/sched/cls_flower.c
> +++ b/net/sched/cls_flower.c
> @@ -1709,7 +1709,7 @@ static int fl_set_key_cfm(struct nlattr **tb,
> struct fl_flow_key *mask,
> struct netlink_ext_ack *extack)
> {
> - struct nlattr *nla_cfm_opt[TCA_FLOWER_KEY_CFM_OPT_MAX];
> + struct nlattr *nla_cfm_opt[TCA_FLOWER_KEY_CFM_OPT_MAX + 1];
I think we need to redefine TCA_FLOWER_KEY_CFM_OPT_MAX like this as well:
diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index 7865f5a9885b..4f3932bb712d 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -710,9 +710,11 @@ enum {
TCA_FLOWER_KEY_CFM_OPT_UNSPEC,
TCA_FLOWER_KEY_CFM_MD_LEVEL,
TCA_FLOWER_KEY_CFM_OPCODE,
- TCA_FLOWER_KEY_CFM_OPT_MAX,
+ __TCA_FLOWER_KEY_CFM_OPT_MAX,
};
+#define TCA_FLOWER_KEY_CFM_OPT_MAX (__TCA_FLOWER_KEY_CFM_OPT_MAX - 1)
Thanks,
Zahari
> int err;
>
> if (!tb[TCA_FLOWER_KEY_CFM])
> --
> 2.41.0.487.g6d72f3e995-goog
>
>
Powered by blists - more mailing lists