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-next>] [day] [month] [year] [list]
Date:	Tue, 01 Apr 2014 10:51:58 +0900
From:	Jungseok Lee <jays.lee@...sung.com>
To:	konrad.wilk@...cle.com, linux-kernel@...r.kernel.org
Cc:	sungjinn.chung@...sung.com,
	linux-samsung-soc <linux-samsung-soc@...r.kernel.org>
Subject: [PATCH] swiotlb: Correct kernel command line handler

This patch corrects kernel command line handler when io_tlb_nslabs
is set to 0.

A current implementation allocates default size memory (64MB) when
0 is given to io_tlb_nslabs ("swiotlb=0") by kernel command line.
In other words, memory is allocated unintentionally.

Signed-off-by: Jungseok Lee <jays.lee@...sung.com>
Signed-off-by: Sungjinn Chung <sungjinn.chung@...sung.com>
---
 lib/swiotlb.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index b604b83..9fe9f71 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -55,6 +55,8 @@
 
 int swiotlb_force;
 
+static int swiotlb_no_use;
+
 /*
  * Used to do a quick range check in swiotlb_tbl_unmap_single and
  * swiotlb_tbl_sync_single_*, to see if the memory was in fact allocated by this
@@ -102,6 +104,8 @@ setup_io_tlb_npages(char *str)
 		io_tlb_nslabs = simple_strtoul(str, &str, 0);
 		/* avoid tail segment of size < IO_TLB_SEGSIZE */
 		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
+		if (!io_tlb_nslabs)
+			swiotlb_no_use = 1;
 	}
 	if (*str == ',')
 		++str;
@@ -212,7 +216,7 @@ swiotlb_init(int verbose)
 	unsigned char *vstart;
 	unsigned long bytes;
 
-	if (!io_tlb_nslabs) {
+	if (!swiotlb_no_use && !io_tlb_nslabs) {
 		io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
 		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
 	}
@@ -244,7 +248,7 @@ swiotlb_late_init_with_default_size(size_t default_size)
 	unsigned int order;
 	int rc = 0;
 
-	if (!io_tlb_nslabs) {
+	if (!swiotlb_no_use && !io_tlb_nslabs) {
 		io_tlb_nslabs = (default_size >> IO_TLB_SHIFT);
 		io_tlb_nslabs = ALIGN(io_tlb_nslabs, IO_TLB_SEGSIZE);
 	}
-- 
1.7.10.4


--
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