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
| ||
|
Date: Tue, 8 Jun 2021 08:51:21 +0800 From: Huang Ying <ying.huang@...el.com> To: Andrew Morton <akpm@...ux-foundation.org> Cc: linux-mm@...ck.org, linux-kernel@...r.kernel.org, Huang Ying <ying.huang@...el.com>, Miaohe Lin <linmiaohe@...wei.com>, Matthew Wilcox <willy@...radead.org>, Minchan Kim <minchan@...nel.org>, Joonsoo Kim <iamjoonsoo.kim@....com>, Johannes Weiner <hannes@...xchg.org>, Vlastimil Babka <vbabka@...e.cz>, Hugh Dickins <hughd@...gle.com>, Mel Gorman <mgorman@...hsingularity.net>, Michal Hocko <mhocko@...nel.org>, Dan Williams <dan.j.williams@...el.com>, Christoph Hellwig <hch@....de>, Ilya Dryomov <idryomov@...il.com> Subject: [PATCH] swap: Check mapping_empty() for swap cache before being freed To check whether all pages and shadow entries in swap cache has been removed before swap cache is freed. Signed-off-by: "Huang, Ying" <ying.huang@...el.com> Cc: Miaohe Lin <linmiaohe@...wei.com> Cc: Matthew Wilcox <willy@...radead.org> Cc: Minchan Kim <minchan@...nel.org> Cc: Joonsoo Kim <iamjoonsoo.kim@....com> Cc: Johannes Weiner <hannes@...xchg.org> Cc: Vlastimil Babka <vbabka@...e.cz> Cc: 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> Cc: Ilya Dryomov <idryomov@...il.com> --- BTW: The patch reverts the following patch in -mm tree in effect. mm/swap: remove unused global variable nr_swapper_spaces --- mm/swap_state.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mm/swap_state.c b/mm/swap_state.c index 95e391f46468..c56aa9ac050d 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -37,6 +37,7 @@ static const struct address_space_operations swap_aops = { }; struct address_space *swapper_spaces[MAX_SWAPFILES] __read_mostly; +static unsigned int nr_swapper_spaces[MAX_SWAPFILES] __read_mostly; static bool enable_vma_readahead __read_mostly = true; #define SWAP_RA_WIN_SHIFT (PAGE_SHIFT / 2) @@ -684,6 +685,7 @@ int init_swap_address_space(unsigned int type, unsigned long nr_pages) /* swap cache doesn't use writeback related tags */ mapping_set_no_writeback_tags(space); } + nr_swapper_spaces[type] = nr; swapper_spaces[type] = spaces; return 0; @@ -691,7 +693,13 @@ 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_WARN_ON_ONCE(!mapping_empty(&spaces[i])); + kvfree(spaces); + nr_swapper_spaces[type] = 0; swapper_spaces[type] = NULL; } -- 2.30.2
Powered by blists - more mailing lists