From: Hugh Dickins <hughd@google.com>
To: Miaohe Lin <linmiaohe@huawei.com>
Cc: akpm@linux-foundation.org, Herbert.van.den.Bergh@oracle.com,
chris.mason@oracle.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/mlock: fix potential imbalanced rlimit ucounts adjustment
Date: Sun, 13 Mar 2022 19:40:08 -0700 (PDT) [thread overview]
Message-ID: <268b3146-2963-15b6-6d6-95a96853314@google.com> (raw)
In-Reply-To: <20220310132417.41189-1-linmiaohe@huawei.com>
On Thu, 10 Mar 2022, Miaohe Lin wrote:
> user_shm_lock forgets to set allowed to 0 when get_ucounts fails. So
> the later user_shm_unlock might do the extra dec_rlimit_ucounts. Fix
> this by resetting allowed to 0.
>
> Fixes: 5ed44a401ddf ("do not limit locked memory when RLIMIT_MEMLOCK is RLIM_INFINITY")
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
NAK. user_shm_lock() remembers to declare "int allowed = 0" on entry.
> ---
> mm/mlock.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/mlock.c b/mm/mlock.c
> index 29372c0eebe5..efd2dd2943de 100644
> --- a/mm/mlock.c
> +++ b/mm/mlock.c
> @@ -733,6 +733,7 @@ int user_shm_lock(size_t size, struct ucounts *ucounts)
> }
> if (!get_ucounts(ucounts)) {
> dec_rlimit_ucounts(ucounts, UCOUNT_RLIMIT_MEMLOCK, locked);
> + allowed = 0;
> goto out;
> }
> allowed = 1;
> --
> 2.23.0
>
>
>
next prev parent reply other threads:[~2022-03-14 2:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-10 13:24 Miaohe Lin
2022-03-14 2:40 ` Hugh Dickins [this message]
2022-03-14 2:49 ` Miaohe Lin
2022-03-14 3:11 ` Hugh Dickins
2022-03-14 3:49 ` Miaohe Lin
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=268b3146-2963-15b6-6d6-95a96853314@google.com \
--to=hughd@google.com \
--cc=Herbert.van.den.Bergh@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=chris.mason@oracle.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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