Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp615639pxj; Thu, 3 Jun 2021 15:09:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMDYtsLk0kcJKHoDAzv/rRyLty41olOme0kwLf6DzHipS0OLNoP0yxAQqUPxGhpDmLZtXG X-Received: by 2002:a17:906:d0c9:: with SMTP id bq9mr1226553ejb.313.1622758169742; Thu, 03 Jun 2021 15:09:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622758169; cv=none; d=google.com; s=arc-20160816; b=hFPnXXnuk8YxMo5iPDr6VFmFeHGmuYLPmZu9yJkB4nZy+nijerYTA/0Kj9cPg0idyz TsDC2X6Ea7RhfgHMrPFr4zJqQ9xuRBBkOhUnt42KEdgTKhLhbqQ4VThUqkbDiWn7ZU8W nxV7BZgCJM8w6S5iLwhOIWKiuCGfGIfUmhyA3gSEglvmunknF+c51U8/VRaTkkW+GIFH nzeS4MLHizOHKRHbRYzI5XzCzWEgjviUz2k1aGZy3kNu2KW4pB/KOiWqzagu8H9L0kZO VddXZ0YYR+mDSMKQqj5L+LjjSd+82tSIl6p9rrdPBt7MEze4XqbaORtWAPaB41TBv4Kk v+RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=u1tlwNvgMK6HDkbzCbRrxIHsT2mloTx7ykpfpBmaMA0=; b=am+PYWXrQfsgPER+VaydhI9pBX0qCOswilxqEvGccfv1b9eNLSacNSjsn8GEWhTLSz hyArXLz+76lV03yN/I+mHpsuY25HBRDbG9yH6zWyvQYMmJYQy8El2IEKe+5f6P9WXvuu zpgsvQmCSFpVANl0yYooNJjoSdhn9JBrDiQd0NLVhGpVQNONHGeLbGx8Ku4DHCnznrhv Zoutki2Eexv59UrqSuoc1oxzL0tLZMcFhesVmVnmWkT7QAgywGzYXu9Mp22Zxa0qiCxd vcvtD8lJLcenToN4G45w2Tngt461PLsO9SlMIOqBnmsjkEHDQvGU1KA2gFit56csMfNs DyVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nbHY1PV1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f10si3047916ejt.614.2021.06.03.15.09.03; Thu, 03 Jun 2021 15:09:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nbHY1PV1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230158AbhFCWJI (ORCPT + 99 others); Thu, 3 Jun 2021 18:09:08 -0400 Received: from mail-ed1-f45.google.com ([209.85.208.45]:33606 "EHLO mail-ed1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbhFCWJI (ORCPT ); Thu, 3 Jun 2021 18:09:08 -0400 Received: by mail-ed1-f45.google.com with SMTP id f5so3840417eds.0 for ; Thu, 03 Jun 2021 15:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=u1tlwNvgMK6HDkbzCbRrxIHsT2mloTx7ykpfpBmaMA0=; b=nbHY1PV1SLGjG+b/ZqVO2Y+L5GYBOYqCA8RXJRsiWjEUYVCKtFajPZ1nvKxCcDcLf1 /GTOlyTfe1nDDR8MAKDVYj97GlJ3cQ/T9SyzQlRbD1ulhLfpp46JbkubYXN+vo0ANPpK C8uhf5c4bkB7N4AkNIOYUfXJbe6bQIV5TXdwie2vnsvSHXkj8LnrZa545RWWGmSrd1KW S593SvG+od8ttC/tp19kfPvurTNlV/3wfpMOkTjw1CwYo8Ha55r2OfTCd8radlQ+9y7I FQotCJXeJEGWfSLJvkG/TN/VtRipfPu10vVAg9riVmNhHxzUPSGIXRcSPNKga5FFCxkf samw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=u1tlwNvgMK6HDkbzCbRrxIHsT2mloTx7ykpfpBmaMA0=; b=oRdQmxCodPa+ZaV28oYSWAKluh1xzWQiaTzcfhYZnWZ5t0MpYS8vffX1hbCPJOes33 ZIu5re6EK8qy5xQE+vhIH3UYP6N1V4BRZ/jjootAOYikqGqKO4joCZG5KRHWyEgYtQeh A6Sh5dWMKyEtwpa/4oG5o1oeJU0/2wRt0WKliwI5hPk1bii9TZyLhAnXQH5rELd0q2Zc DSvNcPnvKOkUcBNr8gJKmN26LPBzk2gcMgNggjm4ASp0M679x/OeuMFimQSqWmgjeYI3 rz1xSkJS2abNxG5SOOvVTB8MtJzfhDNcE9l0qsKWoRIKuMUd/SHUbxJm/qEX9Xxp/VUu IX4w== X-Gm-Message-State: AOAM5339qKSJAcFBCiz1svoYT/59OdYo8sVHA0TY5mEmL50HWtgYo3o2 20vQJlv5V56gHA0B9ZB2NZl92fiH5+iAUylZaws= X-Received: by 2002:a05:6402:42d2:: with SMTP id i18mr1488267edc.168.1622757973907; Thu, 03 Jun 2021 15:06:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Yang Shi Date: Thu, 3 Jun 2021 15:06:01 -0700 Message-ID: Subject: Re: [PATCH 4/7] mm/thp: fix page_address_in_vma() on file THP tails To: Hugh Dickins Cc: Andrew Morton , "Kirill A. Shutemov" , Wang Yugui , Matthew Wilcox , Naoya Horiguchi , Alistair Popple , Ralph Campbell , Zi Yan , Miaohe Lin , Minchan Kim , Jue Wang , Peter Xu , Jan Kara , Linux MM , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 1, 2021 at 2:11 PM Hugh Dickins wrote: > > From: Jue Wang > > Anon THP tails were already supported, but memory-failure may need to use > page_address_in_vma() on file THP tails, which its page->mapping check did > not permit: fix it. > > hughd adds: no current usage is known to hit the issue, but this does fix > a subtle trap in a general helper: best fixed in stable sooner than later. > > Fixes: 800d8c63b2e9 ("shmem: add huge pages support") > Signed-off-by: Jue Wang > Signed-off-by: Hugh Dickins > Cc: Reviewed-by: Yang Shi > --- > mm/rmap.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/mm/rmap.c b/mm/rmap.c > index 144de54efc1c..e05c300048e6 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -716,11 +716,11 @@ unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma) > if (!vma->anon_vma || !page__anon_vma || > vma->anon_vma->root != page__anon_vma->root) > return -EFAULT; > - } else if (page->mapping) { > - if (!vma->vm_file || vma->vm_file->f_mapping != page->mapping) > - return -EFAULT; > - } else > + } else if (!vma->vm_file) { > + return -EFAULT; > + } else if (vma->vm_file->f_mapping != compound_head(page)->mapping) { > return -EFAULT; > + } > > return vma_address(page, vma); > } > -- > 2.32.0.rc0.204.g9fa02ecfa5-goog > >