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: <20220306171400.a5cbab665b6338391447e541@linux-foundation.org>
Date:   Sun, 6 Mar 2022 17:14:00 -0800
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Miaohe Lin <linmiaohe@...wei.com>
Cc:     <mike.kravetz@...cle.com>, <shy828301@...il.com>,
        <willy@...radead.org>, <ying.huang@...el.com>, <ziy@...dia.com>,
        <minchan@...nel.org>, <apopple@...dia.com>,
        <ave.hansen@...ux.intel.com>, <o451686892@...il.com>,
        <almasrymina@...gle.com>, <jhubbard@...dia.com>,
        <rcampbell@...dia.com>, <peterx@...hat.com>,
        <naoya.horiguchi@....com>, <mhocko@...e.com>, <riel@...hat.com>,
        <linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 07/16] mm/migration: use helper macro min_t in
 do_pages_stat

On Fri, 4 Mar 2022 17:34:00 +0800 Miaohe Lin <linmiaohe@...wei.com> wrote:

> We could use helper macro min_t to help set the chunk_nr to simplify
> the code.
> 
> ...
>
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1858,9 +1858,7 @@ static int do_pages_stat(struct mm_struct *mm, unsigned long nr_pages,
>  	while (nr_pages) {
>  		unsigned long chunk_nr;
>  
> -		chunk_nr = nr_pages;
> -		if (chunk_nr > DO_PAGES_STAT_CHUNK_NR)
> -			chunk_nr = DO_PAGES_STAT_CHUNK_NR;
> +		chunk_nr = min_t(unsigned long, nr_pages, DO_PAGES_STAT_CHUNK_NR);
>  
>  		if (in_compat_syscall()) {
>  			if (get_compat_pages_array(chunk_pages, pages,

Getting the types correct is better than using min_t().

--- a/mm/migrate.c~mm-migration-use-helper-macro-min_t-in-do_pages_stat-fix
+++ a/mm/migrate.c
@@ -1844,14 +1844,12 @@ static int do_pages_stat(struct mm_struc
 			 const void __user * __user *pages,
 			 int __user *status)
 {
-#define DO_PAGES_STAT_CHUNK_NR 16
+#define DO_PAGES_STAT_CHUNK_NR 16UL
 	const void __user *chunk_pages[DO_PAGES_STAT_CHUNK_NR];
 	int chunk_status[DO_PAGES_STAT_CHUNK_NR];
 
 	while (nr_pages) {
-		unsigned long chunk_nr;
-
-		chunk_nr = min_t(unsigned long, nr_pages, DO_PAGES_STAT_CHUNK_NR);
+		unsigned long chunk_nr = min(nr_pages, DO_PAGES_STAT_CHUNK_NR);
 
 		if (in_compat_syscall()) {
 			if (get_compat_pages_array(chunk_pages, pages,
_

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ