linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Ajay Kaher <akaher@vmware.com>
To: Vlastimil Babka <vbabka@suse.cz>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: "linux-mm@kvack.org" <linux-mm@kvack.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Jann Horn <jannh@google.com>,
	Matthew Wilcox <willy@infradead.org>,
	"stable@kernel.org" <stable@kernel.org>,
	Srivatsa Bhat <srivatsab@vmware.com>,
	"srivatsa@csail.mit.edu" <srivatsa@csail.mit.edu>,
	Vasavi Sirnapalli <vsirnapalli@vmware.com>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Subject: Re: [PATCH STABLE 4.4 5/8] mm: prevent get_user_pages() from overflowing page refcount
Date: Mon, 9 Dec 2019 08:54:55 +0000	[thread overview]
Message-ID: <64284E33-3828-46E9-AFFB-649E0DA41023@vmware.com> (raw)
In-Reply-To: <fc4e3b6e-90fc-cd9f-75ad-452b060250d6@suse.cz>



On 06/12/19, 8:02 PM, "Vlastimil Babka" <vbabka@suse.cz> wrote:

> On 12/6/19 5:15 AM, Ajay Kaher wrote:
>> 
>> 
>> On 03/12/19, 6:28 PM, "Vlastimil Babka" <vbabka@suse.cz> wrote:
>>>>>    
>>>>> [ 4.4 backport: there's get_page_foll(), so add try_get_page()-like checks
>>>>>                 in there, enabled by a new parameter, which is false where
>>>>>                 upstream patch doesn't replace get_page() with try_get_page()
>>>>>                 (the THP and hugetlb callers).
>>>>
>>>> Could we have try_get_page_foll(), as in:
>>>> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fstable%2F1570581863-12090-3-git-send-email-akaher%40vmware.com%2F&amp;data=02%7C01%7Cakaher%40vmware.com%7Cb65cf5622ca8401fd2ba08d77a5914e8%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C637112395344338606&amp;sdata=sLbw%2BQWu0%2BB0y2OpfaQS%2FxXX6Z9jNB3wPeTcPsawNJA%3D&amp;reserved=0
>>>>
>>>> + Code will be in sync as we have try_get_page()
>>>> + No need to add extra argument to try_get_page()
>>>> + No need to modify the callers of try_get_page()
>> 
>> Any reason for not using try_get_page_foll().
>    
> Ah, sorry, I missed that previously. It's certainly possible to do it
> that way, I just didn't care so strongly to rewrite the existing SLES
> patch. It's a stable backport for a rather old LTS, not a codebase for
> further development.
 
Thanks for your response.

I would appreciate if you would like to include try_get_page_foll(),
and resend this patch series again.

Greg may require Acked-by from my side also, so if it's fine with you,
you can add or I will add once you will post this patch series again.

Let me know if anything else I can do here.

>>>>> 		In gup_pte_range(), we don't expect tail pages, so just check
>>>>>                 page ref count instead of try_get_compound_head()
>>>>
>>>> Technically it's fine. If you want to keep the code of stable versions in sync
>>>> with latest versions then this could be done in following ways (without any
>>>> modification in upstream patch for gup_pte_range()):
>>>>
>>>> Apply 7aef4172c7957d7e65fc172be4c99becaef855d4 before applying
>>>> 8fde12ca79aff9b5ba951fce1a2641901b8d8e64, as done here:
>>>> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fstable%2F1570581863-12090-4-git-send-email-akaher%40vmware.com%2F&amp;data=02%7C01%7Cakaher%40vmware.com%7Cb65cf5622ca8401fd2ba08d77a5914e8%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C637112395344348599&amp;sdata=MYA%2Fx7oVu8x1c7%2FGkEw%2B69FX7WN1O34Oq8lkMiFs1Wk%3D&amp;reserved=0
>>     
>>> Yup, I have considered that, and deliberately didn't add that commit
>>> 7aef4172c795 ("mm: handle PTE-mapped tail pages in gerneric fast gup
>>> implementaiton") as it's part of a large THP refcount rework. In 4.4 we
>>> don't expect to GUP tail pages so I wanted to keep it that way -
>>> minimally, the compound_head() operation is a unnecessary added cost,
>>> although it would also work.
>>     

Thanks for above explanation.
    
    


  reply	other threads:[~2019-12-09  8:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-08  9:38 [PATCH STABLE 4.4 0/8] page refcount overflow backports Vlastimil Babka
2019-11-08  9:38 ` [PATCH STABLE 4.4 1/8] mm, gup: remove broken VM_BUG_ON_PAGE compound check for hugepages Vlastimil Babka
2019-11-08  9:38 ` [PATCH STABLE 4.4 2/8] mm, gup: ensure real head page is ref-counted when using hugepages Vlastimil Babka
2019-11-08  9:38 ` [PATCH STABLE 4.4 3/8] mm: make page ref count overflow check tighter and more explicit Vlastimil Babka
2019-11-08  9:38 ` [PATCH STABLE 4.4 4/8] mm: add 'try_get_page()' helper function Vlastimil Babka
2019-11-08  9:38 ` [PATCH STABLE 4.4 5/8] mm: prevent get_user_pages() from overflowing page refcount Vlastimil Babka
2019-12-03 12:25   ` Ajay Kaher
2019-12-03 12:57     ` Vlastimil Babka
2019-12-06  4:15       ` Ajay Kaher
2019-12-06 14:32         ` Vlastimil Babka
2019-12-09  8:54           ` Ajay Kaher [this message]
2019-12-09  9:10             ` Vlastimil Babka
2019-11-08  9:38 ` [PATCH STABLE 4.4 6/8] pipe: add pipe_buf_get() helper Vlastimil Babka
2019-11-08  9:38 ` [PATCH STABLE 4.4 7/8] fs: prevent page refcount overflow in pipe_buf_get Vlastimil Babka
2019-11-08  9:38 ` [PATCH STABLE 4.4 8/8] x86, mm, gup: prevent get_page() race with munmap in paravirt guest Vlastimil Babka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=64284E33-3828-46E9-AFFB-649E0DA41023@vmware.com \
    --to=akaher@vmware.com \
    --cc=jannh@google.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=srivatsa@csail.mit.edu \
    --cc=srivatsab@vmware.com \
    --cc=stable@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=vbabka@suse.cz \
    --cc=vsirnapalli@vmware.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox