* [PATCH net-next] rtnetlink: Move ifm in valid_fdb_dump_legacy to closer to use
@ 2018-10-08 20:57 David Ahern
2018-10-11 5:26 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: David Ahern @ 2018-10-08 20:57 UTC (permalink / raw)
To: netdev; +Cc: David Ahern
From: David Ahern <dsahern@gmail.com>
Move setting of local variable ifm to after the message parsing in
valid_fdb_dump_legacy. Avoid potential future use of unchecked variable.
Fixes: 8dfbda19a21b ("rtnetlink: Move input checking for rtnl_fdb_dump to helper")
Reported-by: Christian Brauner <christian@brauner.io>
Signed-off-by: David Ahern <dsahern@gmail.com>
---
net/core/rtnetlink.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 6406e26171ff..46328a10034a 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -3857,7 +3857,6 @@ static int valid_fdb_dump_legacy(const struct nlmsghdr *nlh,
int *br_idx, int *brport_idx,
struct netlink_ext_ack *extack)
{
- struct ifinfomsg *ifm = nlmsg_data(nlh);
struct nlattr *tb[IFLA_MAX+1];
int err;
@@ -3871,6 +3870,8 @@ static int valid_fdb_dump_legacy(const struct nlmsghdr *nlh,
if (nlmsg_len(nlh) != sizeof(struct ndmsg) &&
(nlmsg_len(nlh) != sizeof(struct ndmsg) +
nla_attr_size(sizeof(u32)))) {
+ struct ifinfomsg *ifm;
+
err = nlmsg_parse(nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX,
ifla_policy, extack);
if (err < 0) {
@@ -3880,6 +3881,7 @@ static int valid_fdb_dump_legacy(const struct nlmsghdr *nlh,
*br_idx = nla_get_u32(tb[IFLA_MASTER]);
}
+ ifm = nlmsg_data(nlh);
*brport_idx = ifm->ifi_index;
}
return 0;
--
2.11.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] rtnetlink: Move ifm in valid_fdb_dump_legacy to closer to use
2018-10-08 20:57 [PATCH net-next] rtnetlink: Move ifm in valid_fdb_dump_legacy to closer to use David Ahern
@ 2018-10-11 5:26 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-10-11 5:26 UTC (permalink / raw)
To: dsahern; +Cc: netdev, dsahern
From: David Ahern <dsahern@kernel.org>
Date: Mon, 8 Oct 2018 13:57:24 -0700
> From: David Ahern <dsahern@gmail.com>
>
> Move setting of local variable ifm to after the message parsing in
> valid_fdb_dump_legacy. Avoid potential future use of unchecked variable.
>
> Fixes: 8dfbda19a21b ("rtnetlink: Move input checking for rtnl_fdb_dump to helper")
> Reported-by: Christian Brauner <christian@brauner.io>
> Signed-off-by: David Ahern <dsahern@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-11 12:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-08 20:57 [PATCH net-next] rtnetlink: Move ifm in valid_fdb_dump_legacy to closer to use David Ahern
2018-10-11 5:26 ` David Miller
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).