mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-28 21:33:52 +00:00
libbpf: Fix alen calculation in libbpf_nla_dump_errormsg()
[ Upstream commit17bcd27a08
] The code assumes that everything that comes after nlmsgerr are nlattrs. When calculating their size, it does not account for the initial nlmsghdr. This may lead to accessing uninitialized memory. Fixes:bbf48c18ee
("libbpf: add error reporting in XDP") Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20230210001210.395194-8-iii@linux.ibm.com Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
a6a7d1541f
commit
d5bdae351a
1 changed files with 1 additions and 1 deletions
|
@ -170,7 +170,7 @@ int nla_dump_errormsg(struct nlmsghdr *nlh)
|
|||
hlen += nlmsg_len(&err->msg);
|
||||
|
||||
attr = (struct nlattr *) ((void *) err + hlen);
|
||||
alen = nlh->nlmsg_len - hlen;
|
||||
alen = (void *)nlh + nlh->nlmsg_len - (void *)attr;
|
||||
|
||||
if (nla_parse(tb, NLMSGERR_ATTR_MAX, attr, alen, extack_policy) != 0) {
|
||||
fprintf(stderr,
|
||||
|
|
Loading…
Reference in a new issue