All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: reorder can_do_mlock to fix audit denial
@ 2015-03-02 17:20 ` Jeff Vander Stoep
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Vander Stoep @ 2015-03-02 17:20 UTC (permalink / raw)
  To: nnk
  Cc: Jeff Vander Stoep, Andrew Morton, Sasha Levin, Paul E. McKenney,
	Rik van Riel, Vlastimil Babka, Paul Cassella, linux-mm,
	linux-kernel

A userspace call to mmap(MAP_LOCKED) may result in the successful
locking of memory while also producing a confusing audit log denial.
can_do_mlock checks capable and rlimit. If either of these return
positive can_do_mlock returns true. The capable check leads to an LSM
hook used by apparmour and selinux which produce the audit denial.
Reordering so rlimit is checked first eliminates the denial on success,
only recording a denial when the lock is unsuccessful as a result of
the denial.

Signed-off-by: Jeff Vander Stoep <jeffv@google.com>
---
 mm/mlock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/mlock.c b/mm/mlock.c
index 73cf098..8a54cd2 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -26,10 +26,10 @@
 
 int can_do_mlock(void)
 {
-	if (capable(CAP_IPC_LOCK))
-		return 1;
 	if (rlimit(RLIMIT_MEMLOCK) != 0)
 		return 1;
+	if (capable(CAP_IPC_LOCK))
+		return 1;
 	return 0;
 }
 EXPORT_SYMBOL(can_do_mlock);
-- 
2.2.0.rc0.207.ga3a616c


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH] mm: reorder can_do_mlock to fix audit denial
@ 2015-03-02 17:20 ` Jeff Vander Stoep
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Vander Stoep @ 2015-03-02 17:20 UTC (permalink / raw)
  To: nnk
  Cc: Jeff Vander Stoep, Andrew Morton, Sasha Levin, Paul E. McKenney,
	Rik van Riel, Vlastimil Babka, Paul Cassella, linux-mm,
	linux-kernel

A userspace call to mmap(MAP_LOCKED) may result in the successful
locking of memory while also producing a confusing audit log denial.
can_do_mlock checks capable and rlimit. If either of these return
positive can_do_mlock returns true. The capable check leads to an LSM
hook used by apparmour and selinux which produce the audit denial.
Reordering so rlimit is checked first eliminates the denial on success,
only recording a denial when the lock is unsuccessful as a result of
the denial.

Signed-off-by: Jeff Vander Stoep <jeffv@google.com>
---
 mm/mlock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/mlock.c b/mm/mlock.c
index 73cf098..8a54cd2 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -26,10 +26,10 @@
 
 int can_do_mlock(void)
 {
-	if (capable(CAP_IPC_LOCK))
-		return 1;
 	if (rlimit(RLIMIT_MEMLOCK) != 0)
 		return 1;
+	if (capable(CAP_IPC_LOCK))
+		return 1;
 	return 0;
 }
 EXPORT_SYMBOL(can_do_mlock);
-- 
2.2.0.rc0.207.ga3a616c

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] mm: reorder can_do_mlock to fix audit denial
  2015-03-02 17:20 ` Jeff Vander Stoep
@ 2015-03-02 21:49   ` Nick Kralevich
  -1 siblings, 0 replies; 8+ messages in thread
From: Nick Kralevich @ 2015-03-02 21:49 UTC (permalink / raw)
  To: Jeff Vander Stoep
  Cc: Andrew Morton, Sasha Levin, Paul E. McKenney, Rik van Riel,
	Vlastimil Babka, Paul Cassella, linux-mm, lkml, Stephen Smalley

On Mon, Mar 2, 2015 at 9:20 AM, Jeff Vander Stoep <jeffv@google.com> wrote:
> A userspace call to mmap(MAP_LOCKED) may result in the successful
> locking of memory while also producing a confusing audit log denial.
> can_do_mlock checks capable and rlimit. If either of these return
> positive can_do_mlock returns true. The capable check leads to an LSM
> hook used by apparmour and selinux which produce the audit denial.
> Reordering so rlimit is checked first eliminates the denial on success,
> only recording a denial when the lock is unsuccessful as a result of
> the denial.
>

Acked-By: Nick Kralevich <nnk@google.com>

> Signed-off-by: Jeff Vander Stoep <jeffv@google.com>
> ---
>  mm/mlock.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/mlock.c b/mm/mlock.c
> index 73cf098..8a54cd2 100644
> --- a/mm/mlock.c
> +++ b/mm/mlock.c
> @@ -26,10 +26,10 @@
>
>  int can_do_mlock(void)
>  {
> -       if (capable(CAP_IPC_LOCK))
> -               return 1;
>         if (rlimit(RLIMIT_MEMLOCK) != 0)
>                 return 1;
> +       if (capable(CAP_IPC_LOCK))
> +               return 1;
>         return 0;
>  }
>  EXPORT_SYMBOL(can_do_mlock);
> --
> 2.2.0.rc0.207.ga3a616c
>



-- 
Nick Kralevich | Android Security | nnk@google.com | 650.214.4037

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mm: reorder can_do_mlock to fix audit denial
@ 2015-03-02 21:49   ` Nick Kralevich
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Kralevich @ 2015-03-02 21:49 UTC (permalink / raw)
  To: Jeff Vander Stoep
  Cc: Andrew Morton, Sasha Levin, Paul E. McKenney, Rik van Riel,
	Vlastimil Babka, Paul Cassella, linux-mm, lkml, Stephen Smalley

On Mon, Mar 2, 2015 at 9:20 AM, Jeff Vander Stoep <jeffv@google.com> wrote:
> A userspace call to mmap(MAP_LOCKED) may result in the successful
> locking of memory while also producing a confusing audit log denial.
> can_do_mlock checks capable and rlimit. If either of these return
> positive can_do_mlock returns true. The capable check leads to an LSM
> hook used by apparmour and selinux which produce the audit denial.
> Reordering so rlimit is checked first eliminates the denial on success,
> only recording a denial when the lock is unsuccessful as a result of
> the denial.
>

Acked-By: Nick Kralevich <nnk@google.com>

> Signed-off-by: Jeff Vander Stoep <jeffv@google.com>
> ---
>  mm/mlock.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/mlock.c b/mm/mlock.c
> index 73cf098..8a54cd2 100644
> --- a/mm/mlock.c
> +++ b/mm/mlock.c
> @@ -26,10 +26,10 @@
>
>  int can_do_mlock(void)
>  {
> -       if (capable(CAP_IPC_LOCK))
> -               return 1;
>         if (rlimit(RLIMIT_MEMLOCK) != 0)
>                 return 1;
> +       if (capable(CAP_IPC_LOCK))
> +               return 1;
>         return 0;
>  }
>  EXPORT_SYMBOL(can_do_mlock);
> --
> 2.2.0.rc0.207.ga3a616c
>



-- 
Nick Kralevich | Android Security | nnk@google.com | 650.214.4037

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mm: reorder can_do_mlock to fix audit denial
  2015-03-02 17:20 ` Jeff Vander Stoep
@ 2015-03-03  0:42   ` Andrew Morton
  -1 siblings, 0 replies; 8+ messages in thread
From: Andrew Morton @ 2015-03-03  0:42 UTC (permalink / raw)
  To: Jeff Vander Stoep
  Cc: nnk, Sasha Levin, Paul E. McKenney, Rik van Riel,
	Vlastimil Babka, Paul Cassella, linux-mm, linux-kernel

On Mon,  2 Mar 2015 09:20:32 -0800 Jeff Vander Stoep <jeffv@google.com> wrote:

> A userspace call to mmap(MAP_LOCKED) may result in the successful
> locking of memory while also producing a confusing audit log denial.
> can_do_mlock checks capable and rlimit. If either of these return
> positive can_do_mlock returns true. The capable check leads to an LSM
> hook used by apparmour and selinux which produce the audit denial.
> Reordering so rlimit is checked first eliminates the denial on success,
> only recording a denial when the lock is unsuccessful as a result of
> the denial.

I'm assuming that this is a minor issue - a bogus audit log, no other
consequences.  And based on this I queued the patch for 4.0 with no
-stable backport.

All of this might have been wrong - the changelog wasn't very helpful
in making such decisions (hint).

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mm: reorder can_do_mlock to fix audit denial
@ 2015-03-03  0:42   ` Andrew Morton
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Morton @ 2015-03-03  0:42 UTC (permalink / raw)
  To: Jeff Vander Stoep
  Cc: nnk, Sasha Levin, Paul E. McKenney, Rik van Riel,
	Vlastimil Babka, Paul Cassella, linux-mm, linux-kernel

On Mon,  2 Mar 2015 09:20:32 -0800 Jeff Vander Stoep <jeffv@google.com> wrote:

> A userspace call to mmap(MAP_LOCKED) may result in the successful
> locking of memory while also producing a confusing audit log denial.
> can_do_mlock checks capable and rlimit. If either of these return
> positive can_do_mlock returns true. The capable check leads to an LSM
> hook used by apparmour and selinux which produce the audit denial.
> Reordering so rlimit is checked first eliminates the denial on success,
> only recording a denial when the lock is unsuccessful as a result of
> the denial.

I'm assuming that this is a minor issue - a bogus audit log, no other
consequences.  And based on this I queued the patch for 4.0 with no
-stable backport.

All of this might have been wrong - the changelog wasn't very helpful
in making such decisions (hint).

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mm: reorder can_do_mlock to fix audit denial
  2015-03-03  0:42   ` Andrew Morton
@ 2015-03-03  0:49     ` Jeffrey Vander Stoep
  -1 siblings, 0 replies; 8+ messages in thread
From: Jeffrey Vander Stoep @ 2015-03-03  0:49 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Nick Kralevich, Sasha Levin, Paul E. McKenney, Rik van Riel,
	Vlastimil Babka, Paul Cassella, linux-mm, linux-kernel

Yes, minor issue.

I appreciate the advice.

On Mon, Mar 2, 2015 at 4:42 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Mon,  2 Mar 2015 09:20:32 -0800 Jeff Vander Stoep <jeffv@google.com> wrote:
>
>> A userspace call to mmap(MAP_LOCKED) may result in the successful
>> locking of memory while also producing a confusing audit log denial.
>> can_do_mlock checks capable and rlimit. If either of these return
>> positive can_do_mlock returns true. The capable check leads to an LSM
>> hook used by apparmour and selinux which produce the audit denial.
>> Reordering so rlimit is checked first eliminates the denial on success,
>> only recording a denial when the lock is unsuccessful as a result of
>> the denial.
>
> I'm assuming that this is a minor issue - a bogus audit log, no other
> consequences.  And based on this I queued the patch for 4.0 with no
> -stable backport.
>
> All of this might have been wrong - the changelog wasn't very helpful
> in making such decisions (hint).

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] mm: reorder can_do_mlock to fix audit denial
@ 2015-03-03  0:49     ` Jeffrey Vander Stoep
  0 siblings, 0 replies; 8+ messages in thread
From: Jeffrey Vander Stoep @ 2015-03-03  0:49 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Nick Kralevich, Sasha Levin, Paul E. McKenney, Rik van Riel,
	Vlastimil Babka, Paul Cassella, linux-mm, linux-kernel

Yes, minor issue.

I appreciate the advice.

On Mon, Mar 2, 2015 at 4:42 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Mon,  2 Mar 2015 09:20:32 -0800 Jeff Vander Stoep <jeffv@google.com> wrote:
>
>> A userspace call to mmap(MAP_LOCKED) may result in the successful
>> locking of memory while also producing a confusing audit log denial.
>> can_do_mlock checks capable and rlimit. If either of these return
>> positive can_do_mlock returns true. The capable check leads to an LSM
>> hook used by apparmour and selinux which produce the audit denial.
>> Reordering so rlimit is checked first eliminates the denial on success,
>> only recording a denial when the lock is unsuccessful as a result of
>> the denial.
>
> I'm assuming that this is a minor issue - a bogus audit log, no other
> consequences.  And based on this I queued the patch for 4.0 with no
> -stable backport.
>
> All of this might have been wrong - the changelog wasn't very helpful
> in making such decisions (hint).

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-03-03  0:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-02 17:20 [PATCH] mm: reorder can_do_mlock to fix audit denial Jeff Vander Stoep
2015-03-02 17:20 ` Jeff Vander Stoep
2015-03-02 21:49 ` Nick Kralevich
2015-03-02 21:49   ` Nick Kralevich
2015-03-03  0:42 ` Andrew Morton
2015-03-03  0:42   ` Andrew Morton
2015-03-03  0:49   ` Jeffrey Vander Stoep
2015-03-03  0:49     ` Jeffrey Vander Stoep

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.