Thread (21 messages) 21 messages, 3 authors, 2020-11-04

Re: [PATCH V2 05/10] x86/pks: Add PKS kernel API

From: Ira Weiny <hidden>
Date: 2020-11-03 18:42:24
Also in: linux-kselftest, linux-mm, lkml, nvdimm

On Tue, Nov 03, 2020 at 07:14:07PM +0100, Greg KH wrote:
On Tue, Nov 03, 2020 at 09:53:36AM -0800, Ira Weiny wrote:
quoted
On Tue, Nov 03, 2020 at 07:50:24AM +0100, Greg KH wrote:
quoted
On Mon, Nov 02, 2020 at 12:53:15PM -0800, ira.weiny@intel.com wrote:
quoted
From: Fenghua Yu <redacted>
[snip]
quoted
quoted
diff --git a/include/linux/pkeys.h b/include/linux/pkeys.h
index 2955ba976048..0959a4c0ca64 100644
--- a/include/linux/pkeys.h
+++ b/include/linux/pkeys.h
@@ -50,4 +50,28 @@ static inline void copy_init_pkru_to_fpregs(void)
 
 #endif /* ! CONFIG_ARCH_HAS_PKEYS */
 
+#define PKS_FLAG_EXCLUSIVE 0x00
+
+#ifndef CONFIG_ARCH_HAS_SUPERVISOR_PKEYS
+static inline int pks_key_alloc(const char * const pkey_user, int flags)
+{
+	return -EOPNOTSUPP;
+}
+static inline void pks_key_free(int pkey)
+{
+}
+static inline void pks_mk_noaccess(int pkey)
+{
+	WARN_ON_ONCE(1);
So for panic-on-warn systems, this is ok to reboot the box?
I would not expect this to reboot the box no.  But it is a violation of the API
contract.  If pky_key_alloc() returns an error calling any of the other
functions is an error.
quoted
Are you sure, that feels odd...
It does feel odd and downright wrong...  But there are a lot of WARN_ON_ONCE's
out there to catch this type of internal programming error.  Is panic-on-warn
commonly used?
Yes it is, and we are trying to recover from that as it is something
that you should recover from.  Properly handle the error and move on.
Sorry, I did not know that...  Ok I'll look at the series because I probably
have others I need to change.

Thanks,
Ira
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help