mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
ubifs: Don't leak kernel memory to the MTD
commit4acadda74fupstream. 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:1e51764a3c("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
02131aea6b
commit
ec469b5e2a
@@ -576,7 +576,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
|
||||
/* Make sure to also account for extended attributes */
|
||||
len += host_ui->data_len;
|
||||
|
||||
dent = kmalloc(len, GFP_NOFS);
|
||||
dent = kzalloc(len, GFP_NOFS);
|
||||
if (!dent)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -952,7 +952,7 @@ int ubifs_jnl_xrename(struct ubifs_info *c, const struct inode *fst_dir,
|
||||
if (twoparents)
|
||||
len += plen;
|
||||
|
||||
dent1 = kmalloc(len, GFP_NOFS);
|
||||
dent1 = kzalloc(len, GFP_NOFS);
|
||||
if (!dent1)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -1102,7 +1102,7 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
|
||||
len = aligned_dlen1 + aligned_dlen2 + ALIGN(ilen, 8) + ALIGN(plen, 8);
|
||||
if (move)
|
||||
len += plen;
|
||||
dent = kmalloc(len, GFP_NOFS);
|
||||
dent = kzalloc(len, GFP_NOFS);
|
||||
if (!dent)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -1466,7 +1466,7 @@ int ubifs_jnl_delete_xattr(struct ubifs_info *c, const struct inode *host,
|
||||
hlen = host_ui->data_len + UBIFS_INO_NODE_SZ;
|
||||
len = aligned_xlen + UBIFS_INO_NODE_SZ + ALIGN(hlen, 8);
|
||||
|
||||
xent = kmalloc(len, GFP_NOFS);
|
||||
xent = kzalloc(len, GFP_NOFS);
|
||||
if (!xent)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -1573,7 +1573,7 @@ int ubifs_jnl_change_xattr(struct ubifs_info *c, const struct inode *inode,
|
||||
aligned_len1 = ALIGN(len1, 8);
|
||||
aligned_len = aligned_len1 + ALIGN(len2, 8);
|
||||
|
||||
ino = kmalloc(aligned_len, GFP_NOFS);
|
||||
ino = kzalloc(aligned_len, GFP_NOFS);
|
||||
if (!ino)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user