All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/6] User pkey minor bug fixes
@ 2022-06-10 23:35 ` ira.weiny
  0 siblings, 0 replies; 36+ messages in thread
From: ira.weiny @ 2022-06-10 23:35 UTC (permalink / raw)
  To: linux-api
  Cc: Ira Weiny, Sohil Mehta, x86, linuxppc-dev, linux-kernel,
	linux-mm, linux-kselftest

From: Ira Weiny <ira.weiny@intel.com>


While evaluating the possibility of defining a new type for pkeys within the
kernel I found a couple of minor bugs.

Because these patches clean up the return codes from system calls I'm sending
this out RFC hoping that users will speak up if anything breaks.

I'm not too concerned about pkey_free() because it is unlikely that anyone is
checking the return code.  Interestingly enough, glibc recommends not calling
pkey_free() because it does not change the access rights to the key and may be
subsequently allocated again.[1][2]

The pkey_alloc() is more concerning.  However, I checked the Chrome source and
it does not differentiate among the return codes and maps all errors into
kNoMemoryProtectionKey.

glibc says it returns ENOSYS if the system does not support pkeys but I don't
see where ENOSYS is returned?  AFAICS it just returns what the kernel returns.
So it is probably up to user of glibc.

In addition I've enhanced the pkey tests to verify and test the changes.

Thanks to Rick Edgecombe and Sohil Mehta for internal review.


[1] Quote from manual/memory.texi:

Calling this function does not change the access rights of the freed
protection key.  The calling thread and other threads may retain access
to it, even if it is subsequently allocated again.  For this reason, it
is not recommended to call the @code{pkey_free} function.

[2] PKS had a similar issue and went to statically allocated keys instead.


Ira Weiny (6):
  testing/pkeys: Add command line options
  testing/pkeys: Don't use uninitialized variable
  testing/pkeys: Add additional test for pkey_alloc()
  pkeys: Lift pkey hardware check for pkey_alloc()
  pkeys: Up level pkey_free() checks
  pkeys: Change mm_pkey_free() to void

 arch/powerpc/include/asm/pkeys.h             | 18 ++---
 arch/x86/include/asm/pkeys.h                 |  7 +-
 include/linux/pkeys.h                        |  5 +-
 mm/mprotect.c                                | 13 +++-
 tools/testing/selftests/vm/pkey-helpers.h    |  7 +-
 tools/testing/selftests/vm/protection_keys.c | 75 +++++++++++++++++---
 6 files changed, 86 insertions(+), 39 deletions(-)


base-commit: 874c8ca1e60b2c564a48f7e7acc40d328d5c8733
-- 
2.35.1


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

end of thread, other threads:[~2022-06-16 20:25 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-10 23:35 [RFC PATCH 0/6] User pkey minor bug fixes ira.weiny
2022-06-10 23:35 ` ira.weiny
2022-06-10 23:35 ` [RFC PATCH 1/6] testing/pkeys: Add command line options ira.weiny
2022-06-10 23:35   ` ira.weiny
2022-06-13 22:31   ` Sohil Mehta
2022-06-13 22:31     ` Sohil Mehta
2022-06-13 23:41     ` Ira Weiny
2022-06-13 23:41       ` Ira Weiny
2022-06-10 23:35 ` [RFC PATCH 2/6] testing/pkeys: Don't use uninitialized variable ira.weiny
2022-06-10 23:35   ` ira.weiny
2022-06-13 22:48   ` Sohil Mehta
2022-06-13 22:48     ` Sohil Mehta
2022-06-13 23:59     ` Ira Weiny
2022-06-13 23:59       ` Ira Weiny
2022-06-10 23:35 ` [RFC PATCH 3/6] testing/pkeys: Add additional test for pkey_alloc() ira.weiny
2022-06-10 23:35   ` ira.weiny
2022-06-16 19:25   ` Sohil Mehta
2022-06-16 19:25     ` Sohil Mehta
2022-06-16 20:24     ` Dave Hansen
2022-06-16 20:24       ` Dave Hansen
2022-06-10 23:35 ` [RFC PATCH 4/6] pkeys: Lift pkey hardware check " ira.weiny
2022-06-10 23:35   ` ira.weiny
2022-06-16 19:31   ` Sohil Mehta
2022-06-16 19:31     ` Sohil Mehta
2022-06-10 23:35 ` [RFC PATCH 5/6] pkeys: Up level pkey_free() checks ira.weiny
2022-06-10 23:35   ` ira.weiny
2022-06-13  9:14   ` Christophe Leroy
2022-06-13  9:14     ` Christophe Leroy
2022-06-10 23:35 ` [RFC PATCH 6/6] pkeys: Change mm_pkey_free() to void ira.weiny
2022-06-10 23:35   ` ira.weiny
2022-06-13  9:17   ` Christophe Leroy
2022-06-13  9:17     ` Christophe Leroy
2022-06-13 16:16     ` Ira Weiny
2022-06-13 16:16       ` Ira Weiny
2022-06-13 22:05 ` [RFC PATCH 0/6] User pkey minor bug fixes Sohil Mehta
2022-06-13 22:05   ` Sohil Mehta

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.