* [PATCH] Fix attribute list size in do_get_nl_link()
@ 2020-11-17 14:42 Mark Jonas
2020-11-17 14:54 ` Marc Kleine-Budde
0 siblings, 1 reply; 4+ messages in thread
From: Mark Jonas @ 2020-11-17 14:42 UTC (permalink / raw)
To: mkl; +Cc: linux-can, Wang Xin, Mark Jonas
From: Wang Xin <xin.wang7@cn.bosch.com>
The function do_get_nl_link() retrieves attributes from the response
RTM_NEWLINK. But it calculates the attribute list size with the wrong
structure struct ifaddrmsg. According to man 7 rtnetlink, RTM_NEWLINK
message uses struct ifinfomsg instead of struct ifaddrmsg. This causes
that additional 8 bytes are parsed and garbage attributes might be
retrieved. One of consequences is that the message will be dropped if
the garbage attribute is IFLA_IFNAME and contains an invalid interface
name.
To fix this issue, use struct ifinfomsg to calculate the size of
attribute list for RTM_NEWLINK.
Signed-off-by: Wang Xin <xin.wang7@cn.bosch.com>
Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
---
src/libsocketcan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libsocketcan.c b/src/libsocketcan.c
index c802849..60142cc 100644
--- a/src/libsocketcan.c
+++ b/src/libsocketcan.c
@@ -411,7 +411,7 @@ static int do_get_nl_link(int fd, __u8 acquire, const char *name, void *res)
struct rtattr *tb[IFLA_MAX + 1];
len =
- nl_msg->nlmsg_len - NLMSG_LENGTH(sizeof(struct ifaddrmsg));
+ nl_msg->nlmsg_len - NLMSG_LENGTH(sizeof(struct ifinfomsg));
parse_rtattr(tb, IFLA_MAX, IFLA_RTA(ifi), len);
/* Finish process if the reply message is matched */
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix attribute list size in do_get_nl_link()
2020-11-17 14:42 [PATCH] Fix attribute list size in do_get_nl_link() Mark Jonas
@ 2020-11-17 14:54 ` Marc Kleine-Budde
2020-11-17 15:28 ` AW: " Jonas Mark (BT-FIR/ENG1-Grb)
0 siblings, 1 reply; 4+ messages in thread
From: Marc Kleine-Budde @ 2020-11-17 14:54 UTC (permalink / raw)
To: Mark Jonas; +Cc: linux-can, Wang Xin
[-- Attachment #1.1: Type: text/plain, Size: 1133 bytes --]
On 11/17/20 3:42 PM, Mark Jonas wrote:
> From: Wang Xin <xin.wang7@cn.bosch.com>
>
> The function do_get_nl_link() retrieves attributes from the response
> RTM_NEWLINK. But it calculates the attribute list size with the wrong
> structure struct ifaddrmsg. According to man 7 rtnetlink, RTM_NEWLINK
> message uses struct ifinfomsg instead of struct ifaddrmsg. This causes
> that additional 8 bytes are parsed and garbage attributes might be
> retrieved. One of consequences is that the message will be dropped if
> the garbage attribute is IFLA_IFNAME and contains an invalid interface
> name.
>
> To fix this issue, use struct ifinfomsg to calculate the size of
> attribute list for RTM_NEWLINK.
>
> Signed-off-by: Wang Xin <xin.wang7@cn.bosch.com>
> Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
Applied to master.
Tnx,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* AW: [PATCH] Fix attribute list size in do_get_nl_link()
2020-11-17 14:54 ` Marc Kleine-Budde
@ 2020-11-17 15:28 ` Jonas Mark (BT-FIR/ENG1-Grb)
2020-11-17 15:53 ` Marc Kleine-Budde
0 siblings, 1 reply; 4+ messages in thread
From: Jonas Mark (BT-FIR/ENG1-Grb) @ 2020-11-17 15:28 UTC (permalink / raw)
To: Marc Kleine-Budde; +Cc: linux-can, WANG Xin (BT-FIR/ENG1-Zhu)
Hi Marc,
> On 11/17/20 3:42 PM, Mark Jonas wrote:
> > From: Wang Xin <xin.wang7@cn.bosch.com>
> >
> > The function do_get_nl_link() retrieves attributes from the response
> > RTM_NEWLINK. But it calculates the attribute list size with the wrong
> > structure struct ifaddrmsg. According to man 7 rtnetlink, RTM_NEWLINK
> > message uses struct ifinfomsg instead of struct ifaddrmsg. This
> > causes that additional 8 bytes are parsed and garbage attributes might
> > be retrieved. One of consequences is that the message will be dropped
> > if the garbage attribute is IFLA_IFNAME and contains an invalid
> > interface name.
> >
> > To fix this issue, use struct ifinfomsg to calculate the size of
> > attribute list for RTM_NEWLINK.
> >
> > Signed-off-by: Wang Xin <xin.wang7@cn.bosch.com>
> > Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
>
> Applied to master.
I plan to either add the patch to the libsocketcan recipe in meta-openembedded
or to upgrade the recipe to a new version of libsocketcan. I would prefer
upgrading the recipe to a new version.
Do you plan to release a new version of libsocketcan soon?
Greetings,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: AW: [PATCH] Fix attribute list size in do_get_nl_link()
2020-11-17 15:28 ` AW: " Jonas Mark (BT-FIR/ENG1-Grb)
@ 2020-11-17 15:53 ` Marc Kleine-Budde
0 siblings, 0 replies; 4+ messages in thread
From: Marc Kleine-Budde @ 2020-11-17 15:53 UTC (permalink / raw)
To: Jonas Mark (BT-FIR/ENG1-Grb); +Cc: linux-can, WANG Xin (BT-FIR/ENG1-Zhu)
[-- Attachment #1.1: Type: text/plain, Size: 1678 bytes --]
On 11/17/20 4:28 PM, Jonas Mark (BT-FIR/ENG1-Grb) wrote:
> Hi Marc,
>
>> On 11/17/20 3:42 PM, Mark Jonas wrote:
>>> From: Wang Xin <xin.wang7@cn.bosch.com>
>>>
>>> The function do_get_nl_link() retrieves attributes from the response
>>> RTM_NEWLINK. But it calculates the attribute list size with the wrong
>>> structure struct ifaddrmsg. According to man 7 rtnetlink, RTM_NEWLINK
>>> message uses struct ifinfomsg instead of struct ifaddrmsg. This
>>> causes that additional 8 bytes are parsed and garbage attributes might
>>> be retrieved. One of consequences is that the message will be dropped
>>> if the garbage attribute is IFLA_IFNAME and contains an invalid
>>> interface name.
>>>
>>> To fix this issue, use struct ifinfomsg to calculate the size of
>>> attribute list for RTM_NEWLINK.
>>>
>>> Signed-off-by: Wang Xin <xin.wang7@cn.bosch.com>
>>> Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
>>
>> Applied to master.
>
> I plan to either add the patch to the libsocketcan recipe in meta-openembedded
> or to upgrade the recipe to a new version of libsocketcan. I would prefer
> upgrading the recipe to a new version.
>
> Do you plan to release a new version of libsocketcan soon?
here you are:
https://git.pengutronix.de/cgit/tools/libsocketcan/tag/?h=v0.0.12
https://public.pengutronix.de/software/libsocketcan/libsocketcan-0.0.12.tar.bz2
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-17 15:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-17 14:42 [PATCH] Fix attribute list size in do_get_nl_link() Mark Jonas
2020-11-17 14:54 ` Marc Kleine-Budde
2020-11-17 15:28 ` AW: " Jonas Mark (BT-FIR/ENG1-Grb)
2020-11-17 15:53 ` Marc Kleine-Budde
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).