Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp1194483ybh; Tue, 10 Mar 2020 17:01:22 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt7Q1YFcA6c8J0mYDZUWcWR1VYNZnfKtn+DjGE1X0eywTzDFqBO4mVm3z+7uQkS+rLq73Ci X-Received: by 2002:a9d:7617:: with SMTP id k23mr198821otl.329.1583884882488; Tue, 10 Mar 2020 17:01:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583884882; cv=none; d=google.com; s=arc-20160816; b=WGEW2qpJJN/AXh+QuKv4zjebaoQKlOOgjYw8T7U3tG+q9rOpvTrmS6amZx2aaAPC89 4CWxa/8crmtuHd/A7SsDDGcBJqRsnJjZTz/s6CZRhk5sAIpYb9VrCCAAVwRmtAZn4uHz 2qqHuoQCRTla6cp0faxS350QSckEIhNdEs1ZMfZiz38VuzI9/NGW0hBzceodkh6i7aoa 6NZTH7fWdyQPFLqSuoZdOdqeEBZE/f6QNinTbigFeoofVogecQOZwNpwdl3j1U8kkjno vrkWZEIAw/XN0QjF6EDc1r76S0+YsZxnqrtwS/cWY+HENS37xkDfPoQ7eS3jooFgGDt9 okpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=6LrB/QDB8/+9bMeHbl1G5SHGJAWHX7k/1TXkj1uMy8U=; b=J2oUVBY9mugT2u1oO9ZD0jPK25Ler30cacVA9apC6FabS6IJs2WgjqggiKOzIhcmV7 +IqJQvxcU/xbtUPJDYAcqECpZEE2dtZWwTAjhmpnSE6VohQ1duioG8/acaMyUdJisdwC 39D4XU2T6vBMGNB8KXmS2PVxv9MVKFc5wMeI6BPyKk5NruquGZJrpaR84cWkeEjlUjFT HJDNNaHFhc1k9YQ25FXSWIx3kwUUzL0KtMlJMRyM9WVThsExx+jp5yQq668vOAUjTMuA AcD2Zl20wriIOMwGAvVa/bh12A76aw1RpU6zLXNSlnqXs5iLK5yN/oxgLWmN4lil1e5/ TdIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=pbwHjYC6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y67si214543oia.184.2020.03.10.17.00.56; Tue, 10 Mar 2020 17:01:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lca.pw header.s=google header.b=pbwHjYC6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727768AbgCKAAM (ORCPT + 99 others); Tue, 10 Mar 2020 20:00:12 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:37626 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726899AbgCKAAM (ORCPT ); Tue, 10 Mar 2020 20:00:12 -0400 Received: by mail-qt1-f193.google.com with SMTP id l20so317199qtp.4 for ; Tue, 10 Mar 2020 17:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lca.pw; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6LrB/QDB8/+9bMeHbl1G5SHGJAWHX7k/1TXkj1uMy8U=; b=pbwHjYC6HIZiGsiNaSQogQyA8mwPFjrSsCN/p9MqJR5r4PIE+X+600DpIax/EpnnMD owUdmxNGULtRKav7JAzvOxDo+e214//K51jHYQ+1r/wJi4qkaGagA80V4MbFb1z4XDre TSsUpCq5w1gq9118Vy4P0pglXDMHE9W9jLFtX+iUs7wC3/wZwiNR0pc6VwbwtKcuYucj 7NTN2qBrYKdKRCxPy+nmC5Xhh5E4WPiAarBUhaQDH/vpm+JrTcxYDmbxNXojUbdJ/EHC 0JWAiRIk+1SRppVBZPWvIVTTvRGdc2CTci6uIzm0eXci7sds6BzvDwKOHnREksVmE+xB pwrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6LrB/QDB8/+9bMeHbl1G5SHGJAWHX7k/1TXkj1uMy8U=; b=tqf9ZIJ7LWeGe3jTqV8qWxAJGZwleG9JmpKMiAznZMus8AooDSBYOtR+pClJo+VRad SeEhfSb3VyufQkITg6HIOdpDSAZIFY/PsH36j6ddM1q7ZHNNbFKc6rK72WUTWcOLGqux LllifhgCtdt8Nt6GeTc8e+9OImNLyi2feqyE4wOWYyOfZTJhhFYpBFT5HkjH0ylMeW7f GehEG6EsK1HvRY7oGVW9qstOP8CdDNwvWddf5e2XAwNHjDZ8IdpclRkeEg4AmcivsC3D mn1FUmgm8PldSYMtDhcn6l+BcKZdPbGco6fYCbwVyzVv5C3/SH6YAGAbKF+rnr4S+QnE W+aA== X-Gm-Message-State: ANhLgQ3s0lHl86FSgZ2/ZJCj202WOfufFrJfusNjuWtw+orKQ1WvlRfJ R/J1IdpVvwe8mKdubo2TevkkXQ== X-Received: by 2002:ac8:41c9:: with SMTP id o9mr422919qtm.156.1583884810848; Tue, 10 Mar 2020 17:00:10 -0700 (PDT) Received: from ovpn-121-75.rdu2.redhat.com (pool-71-184-117-43.bstnma.fios.verizon.net. [71.184.117.43]) by smtp.gmail.com with ESMTPSA id r29sm3431503qtj.76.2020.03.10.17.00.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Mar 2020 17:00:10 -0700 (PDT) From: Qian Cai To: akpm@linux-foundation.org Cc: ying.huang@intel.com, kirill.shutemov@linux.intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Qian Cai , stable@vger.kernel.org Subject: [PATCH] page-flags: fix a crash at SetPageError(THP_SWAP) Date: Tue, 10 Mar 2020 19:58:46 -0400 Message-Id: <20200310235846.1319-1-cai@lca.pw> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The commit bd4c82c22c36 ("mm, THP, swap: delay splitting THP after swapped out") supported writing THP to a swap device but forgot to upgrade an older commit df8c94d13c7e ("page-flags: define behavior of FS/IO-related flags on compound pages") which could trigger a crash during THP swapping out with DEBUG_VM_PGFLAGS=y, kernel BUG at include/linux/page-flags.h:317! page dumped because: VM_BUG_ON_PAGE(1 && PageCompound(page)) page:fffff3b2ec3a8000 refcount:512 mapcount:0 mapping:000000009eb0338c index:0x7f6e58200 head:fffff3b2ec3a8000 order:9 compound_mapcount:0 compound_pincount:0 anon flags: 0x45fffe0000d8454(uptodate|lru|workingset|owner_priv_1|writeback|head|reclaim|swapbacked) end_swap_bio_write() SetPageError(page) VM_BUG_ON_PAGE(1 && PageCompound(page)) bio_endio+0x297/0x560 dec_pending+0x218/0x430 [dm_mod] clone_endio+0xe4/0x2c0 [dm_mod] bio_endio+0x297/0x560 blk_update_request+0x201/0x920 scsi_end_request+0x6b/0x4b0 scsi_io_completion+0x509/0x7e0 scsi_finish_command+0x1ed/0x2a0 scsi_softirq_done+0x1c9/0x1d0 __blk_mqnterrupt+0xf/0x20 Fix by checking PF_NO_TAIL in those places instead. Fixes: bd4c82c22c36 ("mm, THP, swap: delay splitting THP after swapped out") Cc: Signed-off-by: Qian Cai --- include/linux/page-flags.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 1bf83c8fcaa7..77de28bfefb0 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -311,7 +311,7 @@ static inline int TestClearPage##uname(struct page *page) { return 0; } __PAGEFLAG(Locked, locked, PF_NO_TAIL) PAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) __CLEARPAGEFLAG(Waiters, waiters, PF_ONLY_HEAD) -PAGEFLAG(Error, error, PF_NO_COMPOUND) TESTCLEARFLAG(Error, error, PF_NO_COMPOUND) +PAGEFLAG(Error, error, PF_NO_TAIL) TESTCLEARFLAG(Error, error, PF_NO_TAIL) PAGEFLAG(Referenced, referenced, PF_HEAD) TESTCLEARFLAG(Referenced, referenced, PF_HEAD) __SETPAGEFLAG(Referenced, referenced, PF_HEAD) -- 2.21.0 (Apple Git-122.2)