From: "Potyra, Stefan" <Stefan.Potyra@elektrobit.com>
To: Michal Hocko <mhocko@kernel.org>,
Daniel Jordan <daniel.m.jordan@oracle.com>
Cc: "Potyra, Stefan" <Stefan.Potyra@elektrobit.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Jordan, Tobias" <Tobias.Jordan@elektrobit.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"vbabka@suse.cz" <vbabka@suse.cz>,
"kirill.shutemov@linux.intel.com"
<kirill.shutemov@linux.intel.com>,
"linux-api@vger.kernel.org" <linux-api@vger.kernel.org>
Subject: [PATCH v2] mm: mlockall error for flag MCL_ONFAULT
Date: Mon, 27 May 2019 07:53:42 +0000 [thread overview]
Message-ID: <20190527075333.GA6339@er01809n.ebgroup.elektrobit.com> (raw)
In-Reply-To: <20190527070415.GA1658@dhcp22.suse.cz>
If mlockall() is called with only MCL_ONFAULT as flag,
it removes any previously applied lockings and does
nothing else.
This behavior is counter-intuitive and doesn't match the
Linux man page.
For mlockall():
EINVAL Unknown flags were specified or MCL_ONFAULT was specified with‐
out either MCL_FUTURE or MCL_CURRENT.
Consequently, return the error EINVAL, if only MCL_ONFAULT
is passed. That way, applications will at least detect that
they are calling mlockall() incorrectly.
Fixes: b0f205c2a308 ("mm: mlock: add mlock flags to enable VM_LOCKONFAULT usage")
Signed-off-by: Stefan Potyra <Stefan.Potyra@elektrobit.com>
Reviewed-by: Daniel Jordan <daniel.m.jordan@oracle.com>
Acked-by: Michal Hocko <mhocko@suse.com>
---
mm/mlock.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/mlock.c b/mm/mlock.c
index e492a155c51a..03f39cbdd4c4 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -797,7 +797,8 @@ SYSCALL_DEFINE1(mlockall, int, flags)
unsigned long lock_limit;
int ret;
- if (!flags || (flags & ~(MCL_CURRENT | MCL_FUTURE | MCL_ONFAULT)))
+ if (!flags || (flags & ~(MCL_CURRENT | MCL_FUTURE | MCL_ONFAULT)) ||
+ flags == MCL_ONFAULT)
return -EINVAL;
if (!can_do_mlock())
--
2.20.1
next prev parent reply other threads:[~2019-05-27 7:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-22 11:23 [PATCH] mm: mlockall error for flag MCL_ONFAULT Potyra, Stefan
2019-05-24 21:43 ` Daniel Jordan
2019-05-27 7:04 ` Michal Hocko
2019-05-27 7:53 ` Potyra, Stefan [this message]
2019-05-27 13:19 ` [PATCH v2] " Vlastimil Babka
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=20190527075333.GA6339@er01809n.ebgroup.elektrobit.com \
--to=stefan.potyra@elektrobit.com \
--cc=Tobias.Jordan@elektrobit.com \
--cc=akpm@linux-foundation.org \
--cc=daniel.m.jordan@oracle.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=vbabka@suse.cz \
/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;
as well as URLs for NNTP newsgroup(s).