Skip to content

Commit

Permalink
netlink: pad nla_memcpy dest buffer with zeroes
Browse files Browse the repository at this point in the history
This is especially important in cases where the kernel allocs a new
structure and expects a field to be set from a netlink attribute. If such
attribute is shorter than expected, the rest of the field is left containing
previous data. When such field is read back by the user space, kernel memory
content is leaked.

Signed-off-by: Jiri Benc <[email protected]>
Acked-by: Thomas Graf <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Jiri Benc authored and davem330 committed Mar 31, 2015
1 parent f5e2dc5 commit 5899f04
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/nlattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ int nla_memcpy(void *dest, const struct nlattr *src, int count)
int minlen = min_t(int, count, nla_len(src));

memcpy(dest, nla_data(src), minlen);
if (count > minlen)
memset(dest + minlen, 0, count - minlen);

return minlen;
}
Expand Down

0 comments on commit 5899f04

Please sign in to comment.