[PATCH stable 6.1] mm: Fix is_zero_page() usage in try_grab_page()

Alex Williamson posted 1 patch 8 months ago
mm/gup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH stable 6.1] mm: Fix is_zero_page() usage in try_grab_page()
Posted by Alex Williamson 8 months ago
The backport of upstream commit c8070b787519 ("mm: Don't pin ZERO_PAGE
in pin_user_pages()") into v6.1.130 noted below in Fixes does not
account for commit 0f0892356fa1 ("mm: allow multiple error returns in
try_grab_page()"), which changed the return value of try_grab_page()
from bool to int.  Therefore returning 0, success in the upstream
version, becomes an error here.  Fix the return value.

Fixes: 476c1dfefab8 ("mm: Don't pin ZERO_PAGE in pin_user_pages()")
Link: https://lore.kernel.org/all/Z_6uhLQjJ7SSzI13@eldamar.lan
Reported-by: Salvatore Bonaccorso <carnil@debian.org>
Reported-by: Milan Broz <gmazyland@gmail.com>
Cc: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org
Cc: Sasha Levin <sashal@kernel.org>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
 mm/gup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/gup.c b/mm/gup.c
index b1daaa9d89aa..76a2b0943e2d 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -232,7 +232,7 @@ bool __must_check try_grab_page(struct page *page, unsigned int flags)
 		 * and it is used in a *lot* of places.
 		 */
 		if (is_zero_page(page))
-			return 0;
+			return true;
 
 		/*
 		 * Similar to try_grab_folio(): be sure to *also*
-- 
2.48.1
Re: [PATCH stable 6.1] mm: Fix is_zero_page() usage in try_grab_page()
Posted by David Hildenbrand 8 months ago
On 16.04.25 22:24, Alex Williamson wrote:
> The backport of upstream commit c8070b787519 ("mm: Don't pin ZERO_PAGE
> in pin_user_pages()") into v6.1.130 noted below in Fixes does not
> account for commit 0f0892356fa1 ("mm: allow multiple error returns in
> try_grab_page()"), which changed the return value of try_grab_page()
> from bool to int.  Therefore returning 0, success in the upstream
> version, becomes an error here.  Fix the return value.
> 
> Fixes: 476c1dfefab8 ("mm: Don't pin ZERO_PAGE in pin_user_pages()")
> Link: https://lore.kernel.org/all/Z_6uhLQjJ7SSzI13@eldamar.lan
> Reported-by: Salvatore Bonaccorso <carnil@debian.org>
> Reported-by: Milan Broz <gmazyland@gmail.com>
> Cc: stable@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: Sasha Levin <sashal@kernel.org>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
>   mm/gup.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/gup.c b/mm/gup.c
> index b1daaa9d89aa..76a2b0943e2d 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -232,7 +232,7 @@ bool __must_check try_grab_page(struct page *page, unsigned int flags)
>   		 * and it is used in a *lot* of places.
>   		 */
>   		if (is_zero_page(page))
> -			return 0;
> +			return true;
>   
>   		/*
>   		 * Similar to try_grab_folio(): be sure to *also*

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb
Re: [PATCH stable 6.1] mm: Fix is_zero_page() usage in try_grab_page()
Posted by Salvatore Bonaccorso 8 months ago
Hi Alex,

On Wed, Apr 16, 2025 at 02:24:39PM -0600, Alex Williamson wrote:
> The backport of upstream commit c8070b787519 ("mm: Don't pin ZERO_PAGE
> in pin_user_pages()") into v6.1.130 noted below in Fixes does not
> account for commit 0f0892356fa1 ("mm: allow multiple error returns in
> try_grab_page()"), which changed the return value of try_grab_page()
> from bool to int.  Therefore returning 0, success in the upstream
> version, becomes an error here.  Fix the return value.
> 
> Fixes: 476c1dfefab8 ("mm: Don't pin ZERO_PAGE in pin_user_pages()")
> Link: https://lore.kernel.org/all/Z_6uhLQjJ7SSzI13@eldamar.lan
> Reported-by: Salvatore Bonaccorso <carnil@debian.org>
> Reported-by: Milan Broz <gmazyland@gmail.com>
> Cc: stable@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-mm@kvack.org
> Cc: Sasha Levin <sashal@kernel.org>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
>  mm/gup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/gup.c b/mm/gup.c
> index b1daaa9d89aa..76a2b0943e2d 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -232,7 +232,7 @@ bool __must_check try_grab_page(struct page *page, unsigned int flags)
>  		 * and it is used in a *lot* of places.
>  		 */
>  		if (is_zero_page(page))
> -			return 0;
> +			return true;
>  
>  		/*
>  		 * Similar to try_grab_folio(): be sure to *also*
> -- 
> 2.48.1

Thank you, with your patch applied one test VM with a PCI passhtrough
configuration start again.

Tested-by: Salvatore Bonaccorso <carnil@debian.org>

Regards,
Salvatore
Re: [PATCH stable 6.1] mm: Fix is_zero_page() usage in try_grab_page()
Posted by Greg KH 7 months, 4 weeks ago
On Wed, Apr 16, 2025 at 11:49:24PM +0200, Salvatore Bonaccorso wrote:
> Hi Alex,
> 
> On Wed, Apr 16, 2025 at 02:24:39PM -0600, Alex Williamson wrote:
> > The backport of upstream commit c8070b787519 ("mm: Don't pin ZERO_PAGE
> > in pin_user_pages()") into v6.1.130 noted below in Fixes does not
> > account for commit 0f0892356fa1 ("mm: allow multiple error returns in
> > try_grab_page()"), which changed the return value of try_grab_page()
> > from bool to int.  Therefore returning 0, success in the upstream
> > version, becomes an error here.  Fix the return value.
> > 
> > Fixes: 476c1dfefab8 ("mm: Don't pin ZERO_PAGE in pin_user_pages()")
> > Link: https://lore.kernel.org/all/Z_6uhLQjJ7SSzI13@eldamar.lan
> > Reported-by: Salvatore Bonaccorso <carnil@debian.org>
> > Reported-by: Milan Broz <gmazyland@gmail.com>
> > Cc: stable@vger.kernel.org
> > Cc: linux-kernel@vger.kernel.org
> > Cc: linux-mm@kvack.org
> > Cc: Sasha Levin <sashal@kernel.org>
> > Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> > ---
> >  mm/gup.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/mm/gup.c b/mm/gup.c
> > index b1daaa9d89aa..76a2b0943e2d 100644
> > --- a/mm/gup.c
> > +++ b/mm/gup.c
> > @@ -232,7 +232,7 @@ bool __must_check try_grab_page(struct page *page, unsigned int flags)
> >  		 * and it is used in a *lot* of places.
> >  		 */
> >  		if (is_zero_page(page))
> > -			return 0;
> > +			return true;
> >  
> >  		/*
> >  		 * Similar to try_grab_folio(): be sure to *also*
> > -- 
> > 2.48.1
> 
> Thank you, with your patch applied one test VM with a PCI passhtrough
> configuration start again.
> 
> Tested-by: Salvatore Bonaccorso <carnil@debian.org>

Now queued up, thanks.

greg k-h