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: <20210120074652.GA9371@dhcp22.suse.cz>
Date:   Wed, 20 Jan 2021 08:46:52 +0100
From:   Michal Hocko <mhocko@...e.com>
To:     Huang Ying <ying.huang@...el.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, Minchan Kim <minchan@...nel.org>,
        Joonsoo Kim <iamjoonsoo.kim@....com>,
        Johannes Weiner <hannes@...xchg.org>,
        Vlastimil Babka <vbabka@...e.cz>,
        Mel Gorman <mgorman@...hsingularity.net>,
        Dan Williams <dan.j.williams@...el.com>,
        Christoph Hellwig <hch@....de>
Subject: Re: [PATCH] swap: Check nrexceptional of swap cache before being
 freed

On Wed 20-01-21 15:27:11, Huang Ying wrote:
> To catch the error in updating the swap cache shadow entries or their count.

What is the error? Can it happens in the real life? Why do we need this
patch? Is crashing the kernel the right way to handle the situation?

> Signed-off-by: "Huang, Ying" <ying.huang@...el.com>
> Cc: Minchan Kim <minchan@...nel.org>
> Cc: Joonsoo Kim <iamjoonsoo.kim@....com>,
> Cc: Johannes Weiner <hannes@...xchg.org>,
> Cc: Vlastimil Babka <vbabka@...e.cz>, Hugh Dickins <hughd@...gle.com>,
> Cc: Mel Gorman <mgorman@...hsingularity.net>,
> Cc: Michal Hocko <mhocko@...nel.org>,
> Cc: Dan Williams <dan.j.williams@...el.com>,
> Cc: Christoph Hellwig <hch@....de>, Ilya Dryomov <idryomov@...il.com>,
> ---
>  mm/swap_state.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/swap_state.c b/mm/swap_state.c
> index d0d417efeecc..240a4f97594a 100644
> --- a/mm/swap_state.c
> +++ b/mm/swap_state.c
> @@ -703,7 +703,12 @@ int init_swap_address_space(unsigned int type, unsigned long nr_pages)
>  
>  void exit_swap_address_space(unsigned int type)
>  {
> -	kvfree(swapper_spaces[type]);
> +	int i;
> +	struct address_space *spaces = swapper_spaces[type];
> +
> +	for (i = 0; i < nr_swapper_spaces[type]; i++)
> +		VM_BUG_ON(spaces[i].nrexceptional);
> +	kvfree(spaces);
>  	nr_swapper_spaces[type] = 0;
>  	swapper_spaces[type] = NULL;
>  }
> -- 
> 2.29.2

-- 
Michal Hocko
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ