Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp26206pxj; Tue, 1 Jun 2021 14:13:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0vsCvQvMCt6zp5cNrWECy4prLm/z8IWWM6zL50IMAYKIV9/8u6sMRbwXTvhKchDyPMPPq X-Received: by 2002:a6b:3119:: with SMTP id j25mr21892289ioa.64.1622582026019; Tue, 01 Jun 2021 14:13:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622582026; cv=none; d=google.com; s=arc-20160816; b=AGDwteUKxW+9ixgwjiW1CSH5cAzsmOdNuDaHHW9PP0TWemM0bHEhQA0UROwbvAvR7B /38VPevK9Rgm//kg0Ur5D6dKCk4DekZw2hk3MryMCaoe82W0oDP7F5vI0BkObCE+yMBA uK4FnQAMiRRuCXxNqHQPKhnTnT9Lr99PxxpxLxKnjRrqNjGBXOyJzFIJp561h7hMpQMd k0JjiaJUAcSOChuhvrIk1VgO8kAu/aTQcq44QIT8kuyPwPwTRtn19TnB66FmmWeWZL+U xAEYpgMuyqI+TdGAQDksY7skbhjrsR0b/H461dJzm5Y3381q3ni9v/4lzRzvMAAO7fZ4 LPYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=mGezqLCwqfVvLkMCE7dsqP76GlZ1rrIMTNorbY8nnRE=; b=yHLJwdBnZ+0rpl/RyMO9uJAqctdhGfcA81x1tIXc5MGf2nT2A3BCfkb6iQFLdaVbCT Q5K3S1l6sxaY8lhnJjOXPkzw+sKHhd14sZsJ9TLZ/qthocJj2B1EL70yw9o17oxWaJWf UUptcBx4/Yh3giVWnr2ulpws7YslyD44p29j0rMugxnZt89xIKqWCWXOWQAPPYvL/+gw 0V6hhxKtPXcrHxRn6wz1JN+n2m8CMYops4lMRITlkpy1LdBrmWWUNEDQlPXnk896W+Ed 0hbbaU50cULvexnk0f5kE/H1wxrFcGkB3M32/CA727t4t15QXKBNyeu6zKXsjhhyP+6d V6VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XiFqJgKb; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j2si19630348ilr.133.2021.06.01.14.13.26; Tue, 01 Jun 2021 14:13:46 -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=@google.com header.s=20161025 header.b=XiFqJgKb; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234851AbhFAVNJ (ORCPT + 99 others); Tue, 1 Jun 2021 17:13:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234782AbhFAVNI (ORCPT ); Tue, 1 Jun 2021 17:13:08 -0400 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04671C061574 for ; Tue, 1 Jun 2021 14:11:26 -0700 (PDT) Received: by mail-ot1-x32c.google.com with SMTP id 66-20020a9d02c80000b02903615edf7c1aso559250otl.13 for ; Tue, 01 Jun 2021 14:11:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=mGezqLCwqfVvLkMCE7dsqP76GlZ1rrIMTNorbY8nnRE=; b=XiFqJgKbQf+NFm9F2qeWGDqMQtIusE6tfI/d7uCReiNCeI8t1UgzW0tp8FS3tjI6Qn MM058Q8yao+WMfmJTIHUWTNzTCfxl0dIXFzHmnGtdNyydEMDn2/e3yjwWs/UzgnrXiML QqN3GCoZNMystw71jGSHVCRio97HkV3DOsCbiacwt0uIOU20iUscldneY3FmvXADytiw qcm939hv9ywb7M2e+4AI/6XxQYrUoTPfjXtvMcRDBA3OWOrUJYdf8NTD8fr9lVL5CNAr lijoUGLV2r+wmMfg5xsYNOja0Wpem4iA836KRAUuaYwYszImmI/uOurTB+d/d9VaEbPt V9GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=mGezqLCwqfVvLkMCE7dsqP76GlZ1rrIMTNorbY8nnRE=; b=PL582XI12cIYohdq189+mlOC2Rr9pzWfWHSgdzjTfQC5L+x2hhY0LmqAFaPQXKIsXM RgsKOmHopERfP6SBj5sLVg6aRkdsDsv39JvEDTm04ok3mlzKdxaujRvEN5K/9h37CiIE wtnoG+xYP/8mLfMXwS0ZJ8UAM9xs/YkVA3lzEywS5R/YWcP2Y4Q2vOYGh8GaX1rCMCuH LRWeWI2Wmyy9CLXNkr3INn4vAsufTrJG72IlZtx9dlie5iF+t5gPcj2ddNMntLs3ouLH V7PjCSsYVN71aiPNMxNzrEp2+plFoh6/rXTF2jqetmTMAmxlGD2+Hf1vLUdvqPfepoUA KH4Q== X-Gm-Message-State: AOAM533d1Ncmj1UXTSRVWIiUIZxgd4zk3DRAgD2im5BEfjoZI7faQdQj smhxmHgnXWzkHNRe+ScsGOxUSg== X-Received: by 2002:a9d:684e:: with SMTP id c14mr23250577oto.295.1622581885174; Tue, 01 Jun 2021 14:11:25 -0700 (PDT) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id t14sm3644391ooh.39.2021.06.01.14.11.23 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Tue, 01 Jun 2021 14:11:24 -0700 (PDT) Date: Tue, 1 Jun 2021 14:11:22 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrew Morton cc: Hugh Dickins , "Kirill A. Shutemov" , Yang Shi , Wang Yugui , Matthew Wilcox , Naoya Horiguchi , Alistair Popple , Ralph Campbell , Zi Yan , Miaohe Lin , Minchan Kim , Jue Wang , Peter Xu , Jan Kara , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] mm/thp: fix page_address_in_vma() on file THP tails In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: --- 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