ubifs: Don't leak kernel memory to the MTD
authorRichard Weinberger <richard@nod.at>
Fri, 16 Jun 2017 14:21:44 +0000 (16:21 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 12 Oct 2017 14:27:16 +0000 (15:27 +0100)
commit77cb7a747e0a0335a732373867d7f3f650fbd5a5
tree5d6a4e5715e06646ca92a05d6295e1331b0fad17
parent57e50f0a33f982c20fb0cdfdd8f9f6e0335cc6d2
ubifs: Don't leak kernel memory to the MTD

commit 4acadda74ff8b949c448c0282765ae747e088c87 upstream.

When UBIFS prepares data structures which will be written to the MTD it
ensues that their lengths are multiple of 8. Since it uses kmalloc() the
padded bytes are left uninitialized and we leak a few bytes of kernel
memory to the MTD.
To make sure that all bytes are initialized, let's switch to kzalloc().
Kzalloc() is fine in this case because the buffers are not huge and in
the IO path the performance bottleneck is anyway the MTD.

Fixes: 1e51764a3c2a ("UBIFS: add new flash file system")
Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
[bwh: Backported to 3.2:
 - Drop change in ubifs_jnl_xrename()
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/ubifs/journal.c