[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <65aa6e41-ff13-4c27-8a78-e7d6f2471834@redhat.com>
Date: Fri, 11 Apr 2025 10:44:34 +0200
From: David Hildenbrand <david@...hat.com>
To: Baoquan He <bhe@...hat.com>, linux-mm@...ck.org
Cc: akpm@...ux-foundation.org, osalvador@...e.de, yanjun.zhu@...ux.dev,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 1/4] mm/gup: fix wrongly calculated returned value in
fault_in_safe_writeable()
On 10.04.25 05:57, Baoquan He wrote:
> Not like fault_in_readable() or fault_in_writeable(), in
> fault_in_safe_writeable() local variable 'start' is increased page
> by page to loop till the whole address range is handled. However,
> it mistakenly calcalates the size of handled range with 'uaddr - start'.
>
> Fix it here.
>
> Signed-off-by: Baoquan He <bhe@...hat.com>
> Fixes: fe673d3f5bf1 ("mm: gup: make fault_in_safe_writeable() use fixup_user_fault()")
> ---
> mm/gup.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/gup.c b/mm/gup.c
> index 92351e2fa876..84461d384ae2 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -2207,8 +2207,8 @@ size_t fault_in_safe_writeable(const char __user *uaddr, size_t size)
> } while (start != end);
> mmap_read_unlock(mm);
>
> - if (size > (unsigned long)uaddr - start)
> - return size - ((unsigned long)uaddr - start);
> + if (size > start - (unsigned long)uaddr)
> + return size - (start - (unsigned long)uaddr);
> return 0;
> }
> EXPORT_SYMBOL(fault_in_safe_writeable);
Acked-by: David Hildenbrand <david@...hat.com>
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists