Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp48192pxf; Wed, 24 Mar 2021 20:35:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8CZM4fSDwxUgbT87jLLQrH5IDqfK5OA9TCSJhUzm1fNtMzwtgsFbTuzqA+WwIgmcw/+cJ X-Received: by 2002:a17:906:9bc5:: with SMTP id de5mr7180308ejc.284.1616643303614; Wed, 24 Mar 2021 20:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616643303; cv=none; d=google.com; s=arc-20160816; b=FB7w54AGq/UOBQTTVwz2yJOvWYBup4wMpxNVeatHaq7XWlovviDRTGECx+seRDXGUW pj9F562GBJVG/PMK987yLY8MYhKP6l5m+NgYTp48xvSx4MfLrujKHKxU16luFOMw3d6R uJAhQi9DYsrfR6Edspm8MdFSAIKRe9MhKjzAoYBDJPe8vSaI473MWFjxgKb9bRzzNmNm iQUbzWHBE2g9+wWaLrM3WEPKYW/o74977p3LMleyLeq335Wn6qBTDZsoOHRgE+VioIKi t8N4t9wsu6gHxPOUbD5px/m83KqKDecQ8aBZU1eHUcUzLbOsaRiV66ZgxJbVbMmqH8i1 YBnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=BXa/nvbPA4pTBoeS4T/rX3z0EpK+vWd1tZzqwe42JHM=; b=nFy5sMqFHEGN86tKYQkqYAzIVVy3iRC8ZdPtTXQUCM8/xvvdw74t4tX49Hr7whNMC3 v9nGO5VKnPF/ab/zT8/unRI8TbdnnGOSE3asJ6lBDHtKs4rD5/l5H5Z5Jlz/WX08P2aO lmBC9R1UaPlS/YyXUW+nsctyop7ld++4Kr3qM0qAGu2ZkuPg5ZN0n9Mxg6M6QHq9cY0u E7yg8GMdLLHK95fEvj4VSsC7cHS8e0mi8zMisi5wuGgQnQZ8rPjlsP+gGPyVaYu58MGm OS0wN0wPL3HrUrDIuCfhonx6Rf7mZEN52bb8BRJN+Dxa9MxsA2JNlXPqDF6vytWTR8Px oVpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=mW4k3bZ+; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si1201081edr.505.2021.03.24.20.34.40; Wed, 24 Mar 2021 20:35:03 -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=@linux-foundation.org header.s=korg header.b=mW4k3bZ+; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229670AbhCXXUo (ORCPT + 99 others); Wed, 24 Mar 2021 19:20:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:34286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230385AbhCXXU3 (ORCPT ); Wed, 24 Mar 2021 19:20:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EE88661A0F; Wed, 24 Mar 2021 23:20:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1616628028; bh=DfPvVvnnPDOnWWAUCw/MMTu0BV/F1aFcs7Ds2Ng04gc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=mW4k3bZ+pK+Ysg7gscjEg94zbFO6h0wM0OI3WLRbjquYaGsdT9B6FGHJRwncMqk2o 3AmNZ3T7z2vK3kNKvl8TLZ6peKzmZHK9JXI2g/lDl6mAWf9awteRaHy4z57jtli3B4 Qg8KK7bbMeg+voQ1gLv3FOPPfzwy3S3GzuUFAHWY= Date: Wed, 24 Mar 2021 16:20:27 -0700 From: Andrew Morton To: Axel Rasmussen Cc: Alexander Viro , Andrea Arcangeli , Hugh Dickins , Jerome Glisse , Joe Perches , Lokesh Gidra , Mike Rapoport , Peter Xu , Shaohua Li , Shuah Khan , Wang Qing , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Brian Geffon , Cannon Matthews , "Dr . David Alan Gilbert" , David Rientjes , Michel Lespinasse , Mina Almasry , Oliver Upton Subject: Re: [PATCH] userfaultfd/shmem: fix minor fault page leak Message-Id: <20210324162027.cc723b545ff62b1ad6f5223e@linux-foundation.org> In-Reply-To: <20210322204836.1650221-1-axelrasmussen@google.com> References: <20210322204836.1650221-1-axelrasmussen@google.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 22 Mar 2021 13:48:35 -0700 Axel Rasmussen wrote: > This fix is analogous to Peter Xu's fix for hugetlb [0]. If we don't > put_page() after getting the page out of the page cache, we leak the > reference. > > The fix can be verified by checking /proc/meminfo and running the > userfaultfd selftest in shmem mode. Without the fix, we see MemFree / > MemAvailable steadily decreasing with each run of the test. With the > fix, memory is correctly freed after the test program exits. > > Fixes: 00da60b9d0a0 ("userfaultfd: support minor fault handling for shmem") Confused. The affected code: > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -1831,6 +1831,7 @@ static int shmem_getpage_gfp(struct inode *inode, pgoff_t index, > > if (page && vma && userfaultfd_minor(vma)) { > unlock_page(page); > + put_page(page); > *fault_type = handle_userfault(vmf, VM_UFFD_MINOR); > return 0; > } Is added by Peter's "page && vma && userfaultfd_minor". I assume that "Fixes:" is incorrect?