mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-11 08:54:28 -05:00
56 lines
1.2 KiB
Diff
56 lines
1.2 KiB
Diff
diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
|
|
index f7fec09..e7650bd 100644
|
|
--- a/arch/x86/kernel/tls.c
|
|
+++ b/arch/x86/kernel/tls.c
|
|
@@ -27,6 +27,21 @@
|
|
return -ESRCH;
|
|
}
|
|
|
|
+static bool tls_desc_okay(const struct user_desc *info)
|
|
+{
|
|
+ if (LDT_empty(info))
|
|
+ return true;
|
|
+
|
|
+ /*
|
|
+ * espfix is required for 16-bit data segments, but espfix
|
|
+ * only works for LDT segments.
|
|
+ */
|
|
+ if (!info->seg_32bit)
|
|
+ return false;
|
|
+
|
|
+ return true;
|
|
+}
|
|
+
|
|
static void set_tls_desc(struct task_struct *p, int idx,
|
|
const struct user_desc *info, int n)
|
|
{
|
|
@@ -66,6 +81,9 @@
|
|
if (copy_from_user(&info, u_info, sizeof(info)))
|
|
return -EFAULT;
|
|
|
|
+ if (!tls_desc_okay(&info))
|
|
+ return -EINVAL;
|
|
+
|
|
if (idx == -1)
|
|
idx = info.entry_number;
|
|
|
|
@@ -192,6 +210,7 @@
|
|
{
|
|
struct user_desc infobuf[GDT_ENTRY_TLS_ENTRIES];
|
|
const struct user_desc *info;
|
|
+ int i;
|
|
|
|
if (pos >= GDT_ENTRY_TLS_ENTRIES * sizeof(struct user_desc) ||
|
|
(pos % sizeof(struct user_desc)) != 0 ||
|
|
@@ -205,6 +224,10 @@
|
|
else
|
|
info = infobuf;
|
|
|
|
+ for (i = 0; i < count / sizeof(struct user_desc); i++)
|
|
+ if (!tls_desc_okay(info + i))
|
|
+ return -EINVAL;
|
|
+
|
|
set_tls_desc(target,
|
|
GDT_ENTRY_TLS_MIN + (pos / sizeof(struct user_desc)),
|
|
info, count / sizeof(struct user_desc));
|