|
@@ -1272,9 +1272,26 @@ static inline int hdr2sc(struct hfi1_message_header *hdr, u64 rhf)
|
|
|
((!!(rhf_dc_info(rhf))) << 4);
|
|
|
}
|
|
|
|
|
|
+#define HFI1_JKEY_WIDTH 16
|
|
|
+#define HFI1_JKEY_MASK (BIT(16) - 1)
|
|
|
+#define HFI1_ADMIN_JKEY_RANGE 32
|
|
|
+
|
|
|
+/*
|
|
|
+ * J_KEYs are split and allocated in the following groups:
|
|
|
+ * 0 - 31 - users with administrator privileges
|
|
|
+ * 32 - 63 - kernel protocols using KDETH packets
|
|
|
+ * 64 - 65535 - all other users using KDETH packets
|
|
|
+ */
|
|
|
static inline u16 generate_jkey(kuid_t uid)
|
|
|
{
|
|
|
- return from_kuid(current_user_ns(), uid) & 0xffff;
|
|
|
+ u16 jkey = from_kuid(current_user_ns(), uid) & HFI1_JKEY_MASK;
|
|
|
+
|
|
|
+ if (capable(CAP_SYS_ADMIN))
|
|
|
+ jkey &= HFI1_ADMIN_JKEY_RANGE - 1;
|
|
|
+ else if (jkey < 64)
|
|
|
+ jkey |= BIT(HFI1_JKEY_WIDTH - 1);
|
|
|
+
|
|
|
+ return jkey;
|
|
|
}
|
|
|
|
|
|
/*
|