[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221228141701.c64add46c4b09aa17f605baf@linux-foundation.org>
Date: Wed, 28 Dec 2022 14:17:01 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Wupeng Ma <mawupeng1@...wei.com>
Cc: <linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
<kuleshovmail@...il.com>, <aneesh.kumar@...ux.ibm.com>,
<clameter@....com>
Subject: Re: [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@...wei.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.
Powered by blists - more mailing lists