diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2016-12-09 18:13:51 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2016-12-09 18:24:39 -0500 |
commit | 990e9dc381e6999a0eba8ebaf8747daaa8c58337 (patch) | |
tree | e0531b6b297a4361cdca9da4d5f715ec44539c00 | |
parent | 296dc5806de57dc84fce000d60fc201ba40f96e8 (diff) |
x86/ldt: Make all size computations unsigned
ldt->size can never be negative. The helper functions take 'unsigned int'
arguments which are assigned from ldt->size. The related user space
user_desc struct member entry_number is unsigned as well.
But ldt->size itself and a few local variables which are related to
ldt->size are type 'int' which makes no sense whatsoever and results in
typecasts which make the eyes bleed.
Clean it up and convert everything which is related to ldt->size to
unsigned it.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
-rw-r--r-- | arch/x86/events/core.c | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/mmu_context.h | 2 | ||||
-rw-r--r-- | arch/x86/kernel/ldt.c | 10 |
3 files changed, 7 insertions, 7 deletions
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 6e395c996900..55e6c8a397c2 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c | |||
@@ -2299,7 +2299,7 @@ valid_user_frame(const void __user *fp, unsigned long size) | |||
2299 | static unsigned long get_segment_base(unsigned int segment) | 2299 | static unsigned long get_segment_base(unsigned int segment) |
2300 | { | 2300 | { |
2301 | struct desc_struct *desc; | 2301 | struct desc_struct *desc; |
2302 | int idx = segment >> 3; | 2302 | unsigned int idx = segment >> 3; |
2303 | 2303 | ||
2304 | if ((segment & SEGMENT_TI_MASK) == SEGMENT_LDT) { | 2304 | if ((segment & SEGMENT_TI_MASK) == SEGMENT_LDT) { |
2305 | #ifdef CONFIG_MODIFY_LDT_SYSCALL | 2305 | #ifdef CONFIG_MODIFY_LDT_SYSCALL |
diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index 8e0a9fe86de4..306c7e12af55 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h | |||
@@ -47,7 +47,7 @@ struct ldt_struct { | |||
47 | * allocations, but it's not worth trying to optimize. | 47 | * allocations, but it's not worth trying to optimize. |
48 | */ | 48 | */ |
49 | struct desc_struct *entries; | 49 | struct desc_struct *entries; |
50 | int size; | 50 | unsigned int size; |
51 | }; | 51 | }; |
52 | 52 | ||
53 | /* | 53 | /* |
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c index e25b6681cc65..f09df2ff1bcc 100644 --- a/arch/x86/kernel/ldt.c +++ b/arch/x86/kernel/ldt.c | |||
@@ -37,7 +37,7 @@ static void flush_ldt(void *current_mm) | |||
37 | static struct ldt_struct *alloc_ldt_struct(unsigned int size) | 37 | static struct ldt_struct *alloc_ldt_struct(unsigned int size) |
38 | { | 38 | { |
39 | struct ldt_struct *new_ldt; | 39 | struct ldt_struct *new_ldt; |
40 | int alloc_size; | 40 | unsigned int alloc_size; |
41 | 41 | ||
42 | if (size > LDT_ENTRIES) | 42 | if (size > LDT_ENTRIES) |
43 | return NULL; | 43 | return NULL; |
@@ -207,11 +207,11 @@ static int read_default_ldt(void __user *ptr, unsigned long bytecount) | |||
207 | static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode) | 207 | static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode) |
208 | { | 208 | { |
209 | struct mm_struct *mm = current->mm; | 209 | struct mm_struct *mm = current->mm; |
210 | struct ldt_struct *new_ldt, *old_ldt; | ||
211 | unsigned int oldsize, newsize; | ||
212 | struct user_desc ldt_info; | ||
210 | struct desc_struct ldt; | 213 | struct desc_struct ldt; |
211 | int error; | 214 | int error; |
212 | struct user_desc ldt_info; | ||
213 | int oldsize, newsize; | ||
214 | struct ldt_struct *new_ldt, *old_ldt; | ||
215 | 215 | ||
216 | error = -EINVAL; | 216 | error = -EINVAL; |
217 | if (bytecount != sizeof(ldt_info)) | 217 | if (bytecount != sizeof(ldt_info)) |
@@ -249,7 +249,7 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode) | |||
249 | 249 | ||
250 | old_ldt = mm->context.ldt; | 250 | old_ldt = mm->context.ldt; |
251 | oldsize = old_ldt ? old_ldt->size : 0; | 251 | oldsize = old_ldt ? old_ldt->size : 0; |
252 | newsize = max((int)(ldt_info.entry_number + 1), oldsize); | 252 | newsize = max(ldt_info.entry_number + 1, oldsize); |
253 | 253 | ||
254 | error = -ENOMEM; | 254 | error = -ENOMEM; |
255 | new_ldt = alloc_ldt_struct(newsize); | 255 | new_ldt = alloc_ldt_struct(newsize); |