lkml.org 
[lkml]   [2022]   [Dec]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/4] mm/mlock: return EINVAL for illegal user memory range in mlock
On Mon, 5 Dec 2022 11:41:05 +0800 Wupeng Ma <mawupeng1@huawei.com> wrote:

> While testing mlock, we have a problem if the len of mlock is ULONG_MAX.
> The return value of mlock is zero. But nothing will be locked since the
> len in do_mlock overflows to zero due to the following code in mlock:
>
> len = PAGE_ALIGN(len + (offset_in_page(start)));
>
> The same problem happens in munlock.
>
> Since TASK_SIZE is the maximum user space address. The start or len of
> mlock shouldn't be bigger than this. Function access_ok can be used to
> check this issue, so return -EINVAL if bigger.

What happens if userspace uses a value somewhat smaller than ULONG_MAX?

mlock(addr, ULONG_MAX - 1000000);

?

Because if the above works successfully and if it no longer works
successfully with this patchset then that could be a
backward-compatibility problem.

\
 
 \ /
  Last update: 2023-03-26 23:22    [W:0.107 / U:0.936 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site