lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180621211754.12757-4-h.peter.anvin@intel.com>
Date:   Thu, 21 Jun 2018 14:17:50 -0700
From:   "H. Peter Anvin, Intel" <h.peter.anvin@...el.com>
To:     Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Cc:     "H. Peter Anvin" <hpa@...ux.intel.com>,
        "H . Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Andy Lutomirski <luto@...nel.org>,
        "Chang S . Bae" <chang.seok.bae@...el.com>,
        "Markus T . Metzger" <markus.t.metzger@...el.com>
Subject: [PATCH v3 3/7] x86: move fill_user_desc() from tls.c to desc.h and add validity check

From: "H. Peter Anvin" <hpa@...ux.intel.com>

This is generic code which is potentially useful in other contexts.
Unfortunately modify_ldt() is kind of stupid in that it returns a
descriptor in CPU format but takes a different format, but regsets
*have* to operate differently.

Signed-off-by: H. Peter Anvin (Intel) <hpa@...or.com>
Cc: Ingo Molnar <mingo@...nel.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Andy Lutomirski <luto@...nel.org>
Cc: Chang S. Bae <chang.seok.bae@...el.com>
Cc: Markus T. Metzger <markus.t.metzger@...el.com>
---
 arch/x86/include/asm/desc.h | 22 ++++++++++++++++++++++
 arch/x86/kernel/tls.c       | 19 -------------------
 2 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
index 13c5ee878a47..5e69f993c9ff 100644
--- a/arch/x86/include/asm/desc.h
+++ b/arch/x86/include/asm/desc.h
@@ -386,6 +386,28 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
 	desc->limit1 = (limit >> 16) & 0xf;
 }
 
+
+static inline void fill_user_desc(struct user_desc *info, int idx,
+			   const struct desc_struct *desc)
+
+{
+	memset(info, 0, sizeof(*info));
+	info->entry_number = idx;
+	if (desc->s && desc->dpl == 3) {
+		info->base_addr = get_desc_base(desc);
+		info->limit = get_desc_limit(desc);
+		info->seg_32bit = desc->d;
+		info->contents = desc->type >> 2;
+		info->read_exec_only = !(desc->type & 2);
+		info->limit_in_pages = desc->g;
+		info->seg_not_present = !desc->p;
+		info->useable = desc->avl;
+#ifdef CONFIG_X86_64
+		info->lm = desc->l;
+#endif
+	}
+}
+
 void update_intr_gate(unsigned int n, const void *addr);
 void alloc_intr_gate(unsigned int n, const void *addr);
 
diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
index a5b802a12212..7b8ecb760707 100644
--- a/arch/x86/kernel/tls.c
+++ b/arch/x86/kernel/tls.c
@@ -197,25 +197,6 @@ SYSCALL_DEFINE1(set_thread_area, struct user_desc __user *, u_info)
  * Get the current Thread-Local Storage area:
  */
 
-static void fill_user_desc(struct user_desc *info, int idx,
-			   const struct desc_struct *desc)
-
-{
-	memset(info, 0, sizeof(*info));
-	info->entry_number = idx;
-	info->base_addr = get_desc_base(desc);
-	info->limit = get_desc_limit(desc);
-	info->seg_32bit = desc->d;
-	info->contents = desc->type >> 2;
-	info->read_exec_only = !(desc->type & 2);
-	info->limit_in_pages = desc->g;
-	info->seg_not_present = !desc->p;
-	info->useable = desc->avl;
-#ifdef CONFIG_X86_64
-	info->lm = desc->l;
-#endif
-}
-
 int do_get_thread_area(struct task_struct *p, int idx,
 		       struct user_desc __user *u_info)
 {
-- 
2.14.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ