lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 18 Jun 2020 11:35:20 -0000
From:   "tip-bot2 for Gustavo A. R. Silva" <tip-bot2@...utronix.de>
To:     linux-tip-commits@...r.kernel.org
Cc:     "Gustavo A. R. Silva" <gustavoars@...nel.org>,
        Borislav Petkov <bp@...e.de>, Tony Luck <tony.luck@...el.com>,
        x86 <x86@...nel.org>, LKML <linux-kernel@...r.kernel.org>
Subject: [tip: ras/core] x86/mce/dev-mcelog: Use struct_size() helper in kzalloc()

The following commit has been merged into the ras/core branch of tip:

Commit-ID:     5ba7821bcf7d82e35582fce8fe65cd160a6954b4
Gitweb:        https://git.kernel.org/tip/5ba7821bcf7d82e35582fce8fe65cd160a6954b4
Author:        Gustavo A. R. Silva <gustavoars@...nel.org>
AuthorDate:    Wed, 17 Jun 2020 16:17:34 -05:00
Committer:     Borislav Petkov <bp@...e.de>
CommitterDate: Thu, 18 Jun 2020 13:24:23 +02:00

x86/mce/dev-mcelog: Use struct_size() helper in kzalloc()

Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes.

This code was detected with the help of Coccinelle and, audited and
fixed manually.

Signed-off-by: Gustavo A. R. Silva <gustavoars@...nel.org>
Signed-off-by: Borislav Petkov <bp@...e.de>
Acked-by: Tony Luck <tony.luck@...el.com>
Link: https://lkml.kernel.org/r/20200617211734.GA9636@embeddedor
---
 arch/x86/kernel/cpu/mce/dev-mcelog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/mce/dev-mcelog.c b/arch/x86/kernel/cpu/mce/dev-mcelog.c
index 43c4660..03e5105 100644
--- a/arch/x86/kernel/cpu/mce/dev-mcelog.c
+++ b/arch/x86/kernel/cpu/mce/dev-mcelog.c
@@ -345,7 +345,7 @@ static __init int dev_mcelog_init_device(void)
 	int err;
 
 	mce_log_len = max(MCE_LOG_MIN_LEN, num_online_cpus());
-	mcelog = kzalloc(sizeof(*mcelog) + mce_log_len * sizeof(struct mce), GFP_KERNEL);
+	mcelog = kzalloc(struct_size(mcelog, entry, mce_log_len), GFP_KERNEL);
 	if (!mcelog)
 		return -ENOMEM;
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ