]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
x86/ldt: Make all size computations unsigned
authorThomas Gleixner <tglx@linutronix.de>
Fri, 9 Dec 2016 23:13:51 +0000 (00:13 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Fri, 9 Dec 2016 23:24:39 +0000 (00:24 +0100)
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>
arch/x86/events/core.c
arch/x86/include/asm/mmu_context.h
arch/x86/kernel/ldt.c

index 6e395c9969002839fc0fd1e94f95fe0ba77abe0b..55e6c8a397c25b110f32f6daff33baca659c22f0 100644 (file)
@@ -2299,7 +2299,7 @@ valid_user_frame(const void __user *fp, unsigned long size)
 static unsigned long get_segment_base(unsigned int segment)
 {
        struct desc_struct *desc;
-       int idx = segment >> 3;
+       unsigned int idx = segment >> 3;
 
        if ((segment & SEGMENT_TI_MASK) == SEGMENT_LDT) {
 #ifdef CONFIG_MODIFY_LDT_SYSCALL
index 8e0a9fe86de466eee5a520aa8ef9776a0e0e637d..306c7e12af55b6518943dcf6fe2ab89745efdd1b 100644 (file)
@@ -47,7 +47,7 @@ struct ldt_struct {
         * allocations, but it's not worth trying to optimize.
         */
        struct desc_struct *entries;
-       int size;
+       unsigned int size;
 };
 
 /*
index e25b6681cc65b14ff35822a3028b26f8772d1575..f09df2ff1bcca745be12a5b5e20e4102b80df307 100644 (file)
@@ -37,7 +37,7 @@ static void flush_ldt(void *current_mm)
 static struct ldt_struct *alloc_ldt_struct(unsigned int size)
 {
        struct ldt_struct *new_ldt;
-       int alloc_size;
+       unsigned int alloc_size;
 
        if (size > LDT_ENTRIES)
                return NULL;
@@ -207,11 +207,11 @@ static int read_default_ldt(void __user *ptr, unsigned long bytecount)
 static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
 {
        struct mm_struct *mm = current->mm;
+       struct ldt_struct *new_ldt, *old_ldt;
+       unsigned int oldsize, newsize;
+       struct user_desc ldt_info;
        struct desc_struct ldt;
        int error;
-       struct user_desc ldt_info;
-       int oldsize, newsize;
-       struct ldt_struct *new_ldt, *old_ldt;
 
        error = -EINVAL;
        if (bytecount != sizeof(ldt_info))
@@ -249,7 +249,7 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
 
        old_ldt = mm->context.ldt;
        oldsize = old_ldt ? old_ldt->size : 0;
-       newsize = max((int)(ldt_info.entry_number + 1), oldsize);
+       newsize = max(ldt_info.entry_number + 1, oldsize);
 
        error = -ENOMEM;
        new_ldt = alloc_ldt_struct(newsize);