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] [thread-next>] [day] [month] [year] [list]
Message-Id: <1350897568-14262-1-git-send-email-ffainelli@freebox.fr>
Date:	Mon, 22 Oct 2012 11:19:28 +0200
From:	Florian Fainelli <ffainelli@...ebox.fr>
To:	cbouatmailru@...il.com
Cc:	ccross@...roid.com, keescook@...omium.org, tony.luck@...el.com,
	linux-kernel@...r.kernel.org, Maxime Bizon <mbizon@...ebox.fr>,
	stable@...r.kernel.org, Florian Fainelli <ffainelli@...ebox.fr>
Subject: [PATCH v2] pstore/ram: fix undefined usage of rounddown_pow_of_two(0)

From: Maxime Bizon <mbizon@...ebox.fr>

record_size / console_size / ftrace_size can be 0 (this is how you
disable the feature), but rounddown_pow_of_two(0) is undefined. As suggested
by Kees Cook, use !is_power_of_2() as a condition to call rounddown_pow_of_two
and avoid its undefined behavior on the value 0. This issue has been present
since commit 1894a253 (ramoops: Move to fs/pstore/ram.c).

CC: stable@...r.kernel.org
Signed-off-by: Maxime Bizon <mbizon@...ebox.fr>
Signed-off-by: Florian Fainelli <ffainelli@...ebox.fr>
---
Changes since v1:
- use !is_power_of_2(size) instead of (!size)

 fs/pstore/ram.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 1a4f6da..bdd840d 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -374,10 +374,14 @@ static int __devinit ramoops_probe(struct platform_device *pdev)
 		goto fail_out;
 	}
 
-	pdata->mem_size = rounddown_pow_of_two(pdata->mem_size);
-	pdata->record_size = rounddown_pow_of_two(pdata->record_size);
-	pdata->console_size = rounddown_pow_of_two(pdata->console_size);
-	pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size);
+	if (!is_power_of_2(pdata->mem_size))
+		pdata->mem_size = rounddown_pow_of_two(pdata->mem_size);
+	if (!is_power_of_2(pdata->record_size))
+		pdata->record_size = rounddown_pow_of_two(pdata->record_size);
+	if (!is_power_of_2(pdata->console_size))
+		pdata->console_size = rounddown_pow_of_two(pdata->console_size);
+	if (!is_power_of_2(pdata->ftrace_size))
+		pdata->ftrace_size = rounddown_pow_of_two(pdata->ftrace_size);
 
 	cxt->dump_read_cnt = 0;
 	cxt->size = pdata->mem_size;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ