From patchwork Mon Dec 18 13:58:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13497025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 812CAC35274 for ; Mon, 18 Dec 2023 13:58:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 685568D0008; Mon, 18 Dec 2023 08:58:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 60CEC8D0001; Mon, 18 Dec 2023 08:58:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4856A8D0008; Mon, 18 Dec 2023 08:58:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3925C8D0001 for ; Mon, 18 Dec 2023 08:58:54 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 039B28134C for ; Mon, 18 Dec 2023 13:58:53 +0000 (UTC) X-FDA: 81580094988.05.03E5C2A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf04.hostedemail.com (Postfix) with ESMTP id 5DC4C40019 for ; Mon, 18 Dec 2023 13:58:52 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=DTyqitNw; spf=none (imf04.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702907932; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1MBkPk64KnUCtWs6hUkkJI8+9eArZ9bghM4uWRzSldU=; b=MXrqvd3K4YJB49VyJPV0/l3A+If9vhayhcnViJgf1IYD7WJpOICWlx7yONmXrTX9Kiwq0M vb+ywqWoC0SrelqT/eC2QAMYyZ1WE9TQAQSIEhrMT6RefbavpoZV+oRPODAIsQsM3NL2qt 1KG7OxiCMf8vwRzP+tZ75+YpJ4r1GPo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702907932; a=rsa-sha256; cv=none; b=m85ZYC4Gtlod041CgjKhe4nDuT36y87q0LXYk9qGiGvHwidNkR+QcoWhMvfFWGTEh3h+wO b++OU73NdFqUkKMYrdwNrzQdYiaPBd70pIobFlJkDBPeqHFxNP7Y2LRIxP1NydaAkLj5Ay CWVcvtdxOy8E46YiweVF3EaRDzH46B0= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=DTyqitNw; spf=none (imf04.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=1MBkPk64KnUCtWs6hUkkJI8+9eArZ9bghM4uWRzSldU=; b=DTyqitNwZmgyU2BBv/AwwA8oMg ZgC3wsQ43DD+kqvXtCR5Mw4En2zuTqcy1KZxYHH4LNVPWStRUiyoo7eBhTwUQ/fn4orOuCjqlrejK Y2UBE/yQNkOT8GAgD61LO6c7bPzyIZ9Fxd0uKwJyDK9idTV+qcMyySXDJ7+/0kSvfjmrBfzUd77/P wrH1D7+sGBi9HLL/1iJPkXwCg8i7KesTOu9gR22shbfGJKsOiN/VvfQRucDA9vwJ8T72D+KtOEHcG V/kFUiHUCjmULvQ+Yl4gPi7nC8MQksB6Og0Pd6jz7v/jJStFJ5Ipk/xU8HFoHHoz2Ejvmv/Ai4cDp Vai8syIg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rFE8l-00DtCM-Br; Mon, 18 Dec 2023 13:58:39 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Naoya Horiguchi , Dan Williams , stable@vger.kernel.org Subject: [PATCH 1/3] mm/memory-failure: Pass the folio and the page to collect_procs() Date: Mon, 18 Dec 2023 13:58:35 +0000 Message-Id: <20231218135837.3310403-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231218135837.3310403-1-willy@infradead.org> References: <20231218135837.3310403-1-willy@infradead.org> MIME-Version: 1.0 X-Stat-Signature: 8aou161rzb58gacnr5btmuyppnfqpj3s X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 5DC4C40019 X-Rspam-User: X-HE-Tag: 1702907932-147572 X-HE-Meta: U2FsdGVkX181m9zxh6Qx9+onYsMeEcfBGlw0K604WHiBDpaTZDgT9w4UJmuY0eVLRSVHOuXMwd7D4I1oq0jXA4Z6WgAJh9aUw8z3B4p270cZzjagk3iOWafAxqyJ3qQD3MAd8lOxdRWiB2X0qV1UanFZ06803/8GXxCWHx0lT5csO2DZfm2V3t2EG73gdDIHNwnne34fv38u4JXpJgpolT2sDPrR2dzAqGnkYNb6c/EulHkpOKfnUGCkL2GsWVe1emfLeD5Xf5lYRv1xpnmMZti+DXxxo16I3+q1OxwubX0NpZ9gcosYKNbWYAVhFJ/xLmvXkoMrvg8vK46PVnJ63f4q/BNsy0zDP9Qc49aLJDzUFHmIhGHhrxL3qWoBo4Z8fyc1BdbqJxUuBmEKIta7KLiNt3iKglDQneEVOMCm78pvZwwTmNQ8v891x+xYNJHfcr+6pG0Jkp5kdDNxHPiOR8uVC9rtEhiK63Ak5gCpiv9Z6D4izLXdL3vMXIJ96bg2pG7Megxwf4q4U/Kmc38CY8B/cp5u5rUxq0pW8cTUI5WzpeyikRk54DkgoQiQ1uP8GF3SjvlosUlYu4BMscT/4Rm45UKBBL+lWJ2cSViS7IerJt/MwQSx+Ct4SQGh2G0NzMVXOxm8+w0IXcP1cjoAMjc+T+6mhZt2U9H/z5cx/TWFbLwPRh4p7ehyQUMo5whxSm/XlSwITW6OkFO+x7Gy2dJZmXDkahuBCqLN5r8HaLl0olYx7Kj/6rBbStEwhNG+f7FJz+eE8wWQkcpYkpm7Gd4lizwUgBRyl1VnAqfx+ovnHTv7/4kUuSLLklBcTkChxfhFKXCqkwa+5S+sX++3G8tko5Z38p7/2WixbxPGPR+rpoAh6zkNbRazaKQFeV4ALSRL4CwlbhJRt9HiewmsqrswW321dKrB8+nP7NPSIVt1VxncZxp3JFmhCwMM8zyxMw0D4NmnvpkGt6g4vjH stdRCROu S9Gt93u2Qf2oeNklTuj3XFxHJt0HyQRchXRxlCEfjt/GHnM++8Vyp33oLD4huoq9BZiiTXXDCyoMYVQYCritko/Kv5igkpOIOH1ABaIthPqjwYz9WAkbv9nI00mJfJCvGaicVIMiA7+yD7ryuBNHpmtgeDUTl4nSJztU7wkhudc00+FiZXylS+O9EZHgL5ESiG+hmGLdK0TE7vfmDkucBukrVNJIt6iJRwzZnScHWR5UYzG+Jm74DkQ5Qn//v05bL24gHgzJXOyZv+Xxd9lHPmdcpIODRaYBSSvYe X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Both collect_procs_anon() and collect_procs_file() iterate over the VMA interval trees looking for a single pgoff, so it is wrong to look for the pgoff of the head page as is currently done. However, it is also wrong to look at page->mapping of the precise page as this is invalid for tail pages. Clear up the confusion by passing both the folio and the precise page to collect_procs(). Fixes: 415c64c1453a ("mm/memory-failure: split thp earlier in memory error handling") Cc: stable@vger.kernel.org Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 660c21859118..6953bda11e6e 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -595,10 +595,9 @@ struct task_struct *task_early_kill(struct task_struct *tsk, int force_early) /* * Collect processes when the error hit an anonymous page. */ -static void collect_procs_anon(struct page *page, struct list_head *to_kill, - int force_early) +static void collect_procs_anon(struct folio *folio, struct page *page, + struct list_head *to_kill, int force_early) { - struct folio *folio = page_folio(page); struct vm_area_struct *vma; struct task_struct *tsk; struct anon_vma *av; @@ -633,12 +632,12 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill, /* * Collect processes when the error hit a file mapped page. */ -static void collect_procs_file(struct page *page, struct list_head *to_kill, - int force_early) +static void collect_procs_file(struct folio *folio, struct page *page, + struct list_head *to_kill, int force_early) { struct vm_area_struct *vma; struct task_struct *tsk; - struct address_space *mapping = page->mapping; + struct address_space *mapping = folio->mapping; pgoff_t pgoff; i_mmap_lock_read(mapping); @@ -704,17 +703,17 @@ static void collect_procs_fsdax(struct page *page, /* * Collect the processes who have the corrupted page mapped to kill. */ -static void collect_procs(struct page *page, struct list_head *tokill, - int force_early) +static void collect_procs(struct folio *folio, struct page *page, + struct list_head *tokill, int force_early) { - if (!page->mapping) + if (!folio->mapping) return; if (unlikely(PageKsm(page))) collect_procs_ksm(page, tokill, force_early); else if (PageAnon(page)) - collect_procs_anon(page, tokill, force_early); + collect_procs_anon(folio, page, tokill, force_early); else - collect_procs_file(page, tokill, force_early); + collect_procs_file(folio, page, tokill, force_early); } struct hwpoison_walk { @@ -1602,7 +1601,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, * mapped in dirty form. This has to be done before try_to_unmap, * because ttu takes the rmap data structures down. */ - collect_procs(hpage, &tokill, flags & MF_ACTION_REQUIRED); + collect_procs(folio, p, &tokill, flags & MF_ACTION_REQUIRED); if (PageHuge(hpage) && !PageAnon(hpage)) { /* @@ -1772,7 +1771,7 @@ static int mf_generic_kill_procs(unsigned long long pfn, int flags, * SIGBUS (i.e. MF_MUST_KILL) */ flags |= MF_ACTION_REQUIRED | MF_MUST_KILL; - collect_procs(&folio->page, &to_kill, true); + collect_procs(folio, &folio->page, &to_kill, true); unmap_and_kill(&to_kill, pfn, folio->mapping, folio->index, flags); unlock: From patchwork Mon Dec 18 13:58:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13497024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92F3DC35274 for ; Mon, 18 Dec 2023 13:58:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBEE58D0007; Mon, 18 Dec 2023 08:58:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E6F1C8D0001; Mon, 18 Dec 2023 08:58:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CC25B8D0007; Mon, 18 Dec 2023 08:58:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B70428D0001 for ; Mon, 18 Dec 2023 08:58:51 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 3ECBC1A1309 for ; Mon, 18 Dec 2023 13:58:51 +0000 (UTC) X-FDA: 81580094862.21.D458CC9 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id 97DE64001F for ; Mon, 18 Dec 2023 13:58:49 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lj7R6Q+G; dmarc=none; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702907929; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=y48/RgxA4nfcI2a4m0fGd6f8VrRcn5zgGTlb3Ss4JS8=; b=IVWztKBI6UlviplnEFls8vdXdv2xkAbdKa4sje0QFAgJ6ZFWhUKqjOG/6OmVTCC4aggAJG fHXLgODu8063/4/S7S4gmzoybUMXtXhgESNQnIT61EVzS4hhbkdKUkGJThdpWSvWtcYRa9 iCHZzuHXeQVx38vTlaQBFd5s8pfKJ1g= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=lj7R6Q+G; dmarc=none; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702907929; a=rsa-sha256; cv=none; b=dzWOuNYbiWEX5HF6+2/XtZFRw2hX3ju3BxwITa8xqVIKbVXIU95bt2viyxabyfQ8zafoft Pe9zPWrivKh0UKjZpdPt5tFIbPitG9KFwqkRpSzuxv5rGjAO/3KtdI+htk1Egyy5LScznK eDM/6jrWP0VTi8c1se35LD0yT2bDZ+g= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=y48/RgxA4nfcI2a4m0fGd6f8VrRcn5zgGTlb3Ss4JS8=; b=lj7R6Q+Gh/P4ky+VC2j7LwEvYI wDbJ31fFiEvtIKehx+Q6fCRtVx9Z++4gkzRKJNSo1F2cq18NcCB1CkOozGh3OHZTyY7tXcLk9Npmc FG/YsObFXeN7Pz+XWQsxJeqBxw5I4hk/JDGeGE0648cOzSgdhSFg8d9Lys1jJb54FZrDZwcvXVN/G WQpV9A1AxcCpex4F3gBh1Zvc5msenhmhJ3HZgDWFe8o9WK4+CLC0fqlW/lzpW0KrOzVJY3/un/xig ovMvr1DEO8Ok8I7wB9Xb3PJ0H7k9GFqGPOM8YGmYMyapM/CEbMu/Rv1zjGQi8DUz5i5ioDbZ9DzkB sr7ivZRA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rFE8l-00DtCO-F4; Mon, 18 Dec 2023 13:58:39 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Naoya Horiguchi , Dan Williams , stable@vger.kernel.org Subject: [PATCH 2/3] mm/memory-failure: Check the mapcount of the precise page Date: Mon, 18 Dec 2023 13:58:36 +0000 Message-Id: <20231218135837.3310403-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231218135837.3310403-1-willy@infradead.org> References: <20231218135837.3310403-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 97DE64001F X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: bccthr1awhdhnnhmfugcxomucbhh6c5b X-HE-Tag: 1702907929-794399 X-HE-Meta: U2FsdGVkX185H84hoarlhzObFLiLOEIfDLKHDQNpsRPJ6Wpw8jR6TC3Q/ivUu3EHV4zCZJitiYzZ0p7kCSNwYzx2GA8b/iOkXQwjVLmvey3RK3sOZL0ddOiPe9R3Gbz+s7Ht+/dNIH93Y3YC2vHViNeOhrCdtsQnNq9xXk1OsTCUOMdTvKK6BlhlS+a6YYPYkwo8TTfU0aL0omHDuJS/dEjTDYdHmPcf6wZIiELeyBifpsGERUI/bsbxa6tM5Mt0Skjc9iPjVtCIdbknTpWw3Ce6ReB0wWMo60i/ikmcrzBMu+GRwKUOT7iHedrK6+k3j3tomF8VR2iGfX3NBjs5RZqDnWXRlfoK1xwRdJFvDpM3qIpctaPj19Z9qqnm522n8pvSkbAOd/LHfb1wiXYDuh2I6HNbHCvvP3+e82pHO4cMgsaMgWfM9f8riaJZ2lUoRl+74kYOXytacnTvlrNFOaxNZsjW4fNmZ0ly4GrVB8kStCnnm5MuPKr8pLqCd/DSZCUDqRURmT4zQRBMAB4uWDnYn469LFN5BzVP9dN+e/CsXVmbvZSlGfYFGhYzakknREksQzzMDn7M7u6SocunXvIUxC+8mHfjBO9CW1uwatkZUYnFUp4lAfe4EF3UMWEL/FbISm81z3hQExRm2iezlwWRFMRWXNV6Mx6FI6IEpczvBar1s2b986r8fUJ2l6spETP4fU+2vQD32O2KXHcHzzujIFs2fpbf3Fem2IexYrczeuWi4GGVWP/0e/lFjHNe1WCGwRS4RR+ZjVKkbqawF/MOYDukeqENFIlH+89hx9cWHQA06TnBJ0iXZony0QPWxolHuSFkhTDPodAOGXD3GWiK+yUdyJjixqYShX1avQUUA7WNKfI6N2sTAG0hPaqYKP2rGeVfbbIHhihRNA1agJWkrYB+Rss7Gy+RABdl0769yPnkPiqdqif0rZDg+1HBw+TWPO72GcmMlwUusb5 3AUqKJJW tH4Nj550S281xeeYogNWe3rjYQXB/f4yeY1gyOx8bjOSPDtZwhqGBakYc14HjSCsYAZcX+O+MWsvzKSWeBVoaqfzYCJGvApH6UYSYfw+rctnsQyd20WO70ag8RktVZ2iYE3Znpc0aC3aLgRmWHBXGXNFrsyohRz4d7zMUowzAV9AgEpb6Tep7S4mpr66J5AWRVP9vGSMPYPGsuonE6wYViT6ewirjzFbCFmcaMUswVZnWnkk= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: A process may map only some of the pages in a folio, and might be missed if it maps the poisoned page but not the head page. Or it might be unnecessarily hit if it maps the head page, but not the poisoned page. Fixes: 7af446a841a2 ("HWPOISON, hugetlb: enable error handling path for hugepage") Cc: stable@vger.kernel.org Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 6953bda11e6e..82e15baabb48 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1570,7 +1570,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, * This check implies we don't kill processes if their pages * are in the swap cache early. Those are always late kills. */ - if (!page_mapped(hpage)) + if (!page_mapped(p)) return true; if (PageSwapCache(p)) { @@ -1621,10 +1621,10 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn, try_to_unmap(folio, ttu); } - unmap_success = !page_mapped(hpage); + unmap_success = !page_mapped(p); if (!unmap_success) pr_err("%#lx: failed to unmap page (mapcount=%d)\n", - pfn, page_mapcount(hpage)); + pfn, page_mapcount(p)); /* * try_to_unmap() might put mlocked page in lru cache, so call From patchwork Mon Dec 18 13:58:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13497023 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5212C46CCD for ; Mon, 18 Dec 2023 13:58:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B626D8D0006; Mon, 18 Dec 2023 08:58:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B12B88D0001; Mon, 18 Dec 2023 08:58:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 98C868D0007; Mon, 18 Dec 2023 08:58:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 783DF8D0001 for ; Mon, 18 Dec 2023 08:58:48 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 49618140122 for ; Mon, 18 Dec 2023 13:58:48 +0000 (UTC) X-FDA: 81580094736.23.E04B83D Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf17.hostedemail.com (Postfix) with ESMTP id 8F5C940007 for ; Mon, 18 Dec 2023 13:58:46 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=MRN9fROQ; dmarc=none; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702907926; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lk4ShxhGVru3Bk7ei2k86xrh9E3OhTWS1/aDPPIk7O8=; b=l+W0RYVeqg6upajLa1/ZGqm4gF7qIzCQJZklo6qMzgGd38uspTCTTVA45y4TDnsod74Yh9 f2/ik2n+pRJvzk3jI0Cw1xTrNhoHmN6fsngvOMHjC7x7fNrj48iQNJ0eJC8FdFheOop0FW l+07hyrZHglqlitqfomsCiSV502zeB4= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=MRN9fROQ; dmarc=none; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702907926; a=rsa-sha256; cv=none; b=Szl8pgTt/WR8XH8NMhwZxTRR7hG0HavYLcfckVpU3idUIycp84ni2E1tJ9208ZUFk2l5pG 7AIcqqJ/5QnE60OyN+pQX+83aVGJJYLdbUsGu5z7Yr69RrgF/GdSpYFEyKrEbPI7eEEdYj UiEvzpLhPy+MMRq7tUH4C9U3iVMsIWA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=lk4ShxhGVru3Bk7ei2k86xrh9E3OhTWS1/aDPPIk7O8=; b=MRN9fROQ5pLlJRCR4KlgWLhKPg wdR5cGTZGP2N6uvHx24BwIKWTO5Qu4mmAE0Yl8zDP4JcDnWomX3F3XSDI1hTJOwchkpQjljgLaVJP LKJnH8i5pwqcYKW3GiAJsxA8vRrx5anMYlOARSITjSxOB2XvQWc98C2vICOHDCmA9XnVDzXzs8CC6 BjOMaA7g+wU4Xdl/V2XwnGGD1YJnnpoIntlYiyS4+qZwpcgr+trJqf3SHwiLBvImUVNdWVf5Hf8xr 5EDPy15+9WjPSgITT4Mgut90Bl18Wtsiid0W2P3LNv3rL4TJvF1Zf8Wtsr8TB0IPpJN/clCNkaXgc a47ii+Cg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rFE8l-00DtCQ-Hx; Mon, 18 Dec 2023 13:58:39 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Naoya Horiguchi , Dan Williams , stable@vger.kernel.org Subject: [PATCH 3/3] mm/memory-failure: Cast index to loff_t before shifting it Date: Mon, 18 Dec 2023 13:58:37 +0000 Message-Id: <20231218135837.3310403-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231218135837.3310403-1-willy@infradead.org> References: <20231218135837.3310403-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8F5C940007 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 44no3ekqafquyj79g7e3u8gz59qg4u3c X-HE-Tag: 1702907926-231570 X-HE-Meta: U2FsdGVkX1/d3Sjn71fHB3KccLhgoM+Tv0LshOyESqLxuut1np42IKeXNpPCBFJQDVNzziRDiE/L6wCIj1oToYkzQ6pmVs2Q1WQJPaCni8pRrHz4lfPYh4LDf4bNvNWuLo7VoPyvVGG7QD8/S4m4hzcqQz4USw2wA9bWLOKZ2A4l+DeK3kyMFZPXLlHRwYq/Mb3nYv12URcA8XxiB1ix+BJ1ONGy05FgJ1rSjjPB1Og/NWSyKN2AQyFw0X7Jq42DJNa/LECKZ6YHzdTrRvgMY/BtV8aYqxnfKOxnI2QjkC41UhjTnB+6rK+9L6r6eQheQh35NCRSCvamIxRj/RF0CbYl0YqdaIxRMrtPqPqe8bOfjcNU7nP4igP56b7FfA7iquJ5x1GYfY0X3awFGX7xxwRdgrO0kOiiAOVnCQW+CKbA+e+JRFA50ua9+Jo5gHbgjyuwQlqrLJynMmJBfITyoNxA/bfpUIbsld4WwIdMXVFj4fbxRSFyT3f6UmzBxfBP9WFS5aY2L8+RTVanKUz3DkdAQmRJeUVxLZT3j5Y6tIk/QXu7/bsVdfxRCvgP3hw1GCbVwAUiPV9tL7gHBGH85K1gdL6ACcMZjG5TAg/vWFtD5TTzM6ivVLx0RnJ7rMlOXDIiugOsxSp0bIRnvtYnwTIwRVmmwaiP8fD+ElBwlf9QfAsMeO9lalKVplF4vNhljBLC3OGr28SHdMxF66Ny/waajn9tBO7AZe/v0J5TejGIefc2FX19AcjJFMXbEpsEdqbRf2ZJyymvIfqebxfoVhDRuhkjRz/zRuW6WSe+G0dvzFBW0qE9CacFKK8Ik2Zqu/5gRXs+UEeDO3q1hi/0Ci1Hpo9HO3tTGKE8nPhqSmT22XbbuzslMp9XKyOA8hKfGK3mzrGRYvh+lqzrt6t7OO7T6LIPYRbdvYU7aCGYu+ycr7H6c2JRABxSzD8G2qaPyhHqp8a7TVOCN9RuMFi ingTxvIC UInF1dYR//yNBQXcUPh2ElIWJmOsgL11ecSmumnsXimaLidVR0tzEhCi64UCNkjWFlNONlFlduutLHUipmKfrixkZqcsguAat59zHKfVbKxVDs+hjaU0JVoQYtt0TErmUhcFqomgdzN8ldFEb0hXWGzmzYHL05IR58Njt+xF5Px5H+FTOIBozqyGiCtsCWvuv+BG5YAVsogZu/wt3yB3A2RrfTqjgCSbSyWsHdx31N10xjUIDNFZe1ddjcdWICCEzFMYB6LRutNkO0uwvqFH+P7myJKveg0dGrEsH X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 32-bit systems, we'll lose the top bits of index because arithmetic will be performed in unsigned long instead of unsigned long long. This affects files over 4GB in size. Fixes: 6100e34b2526 ("mm, memory_failure: Teach memory_failure() about dev_pagemap pages") Cc: stable@vger.kernel.org Signed-off-by: Matthew Wilcox (Oracle) Acked-by: Naoya Horiguchi --- mm/memory-failure.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memory-failure.c b/mm/memory-failure.c index 82e15baabb48..455093f73a70 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -1704,7 +1704,7 @@ static void unmap_and_kill(struct list_head *to_kill, unsigned long pfn, * mapping being torn down is communicated in siginfo, see * kill_proc() */ - loff_t start = (index << PAGE_SHIFT) & ~(size - 1); + loff_t start = ((loff_t)index << PAGE_SHIFT) & ~(size - 1); unmap_mapping_range(mapping, start, size, 0); }