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>] [day] [month] [year] [list]
Message-Id: <20221031021438.376636-1-senozhatsky@chromium.org>
Date:   Mon, 31 Oct 2022 11:14:38 +0900
From:   Sergey Senozhatsky <senozhatsky@...omium.org>
To:     Andrew Morton <akpm@...ux-foundation.org>,
        Minchan Kim <minchan@...nel.org>
Cc:     Nitin Gupta <ngupta@...are.org>, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, Sergey Senozhatsky <senozhatsky@...omium.org>,
        kernel test robot <lkp@...el.com>
Subject: [PATCH] zsmalloc: use temporary unsigned long for min_alloc_size calculations

kbuild reported the following warning:

mm/zsmalloc.c: In function 'zs_create_pool':
mm/zsmalloc.c:2220:69: warning: right shift count >= width of type [-Wshift-count-overflow]

Use unsigned long temp variable for calculations in zs_create_pool().

Reported-by: kernel test robot <lkp@...el.com>
Signed-off-by: Sergey Senozhatsky <senozhatsky@...omium.org>
---
 mm/zsmalloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 0bc9ed1f1a5d..181bfc66249b 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -2211,6 +2211,7 @@ struct zs_pool *zs_create_pool(const char *name, u32 max_pages_per_zspage)
 	int i;
 	struct zs_pool *pool;
 	struct size_class *prev_class = NULL;
+	unsigned long num_pages = max_pages_per_zspage;
 
 	if (WARN_ON(max_pages_per_zspage < ZS_MIN_PAGES_PER_ZSPAGE ||
 		    max_pages_per_zspage > ZS_MAX_PAGES_PER_ZSPAGE))
@@ -2221,8 +2222,7 @@ struct zs_pool *zs_create_pool(const char *name, u32 max_pages_per_zspage)
 		return NULL;
 
 	/* min_alloc_size must be multiple of ZS_ALIGN */
-	pool->min_alloc_size = (max_pages_per_zspage << PAGE_SHIFT) >>
-		OBJ_INDEX_BITS;
+	pool->min_alloc_size = num_pages << PAGE_SHIFT >> OBJ_INDEX_BITS;
 	pool->min_alloc_size = max(pool->min_alloc_size, ZS_MIN_ALLOC_SIZE);
 
 	pool->num_size_classes =
-- 
2.38.1.273.g43a17bfeac-goog

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ