Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1538434 > unrolled thread
| Started by | Dan Carpenter <dan.carpenter@oracle.com> |
|---|---|
| First post | 2016-12-08 12:10 +0100 |
| Last post | 2016-12-10 09:20 +0100 |
| Articles | 4 — 4 participants |
Back to article view | Back to linux.kernel
[patch] x86/ldt: make a size variable unsigned Dan Carpenter <dan.carpenter@oracle.com> - 2016-12-08 12:10 +0100
Re: [patch] x86/ldt: make a size variable unsigned Andy Lutomirski <luto@amacapital.net> - 2016-12-08 23:40 +0100
Re: [patch] x86/ldt: make a size variable unsigned Thomas Gleixner <tglx@linutronix.de> - 2016-12-09 00:20 +0100
[tip:x86/cleanups] x86/ldt: Make a size argument unsigned tip-bot for Dan Carpenter <tipbot@zytor.com> - 2016-12-10 09:20 +0100
| From | Dan Carpenter <dan.carpenter@oracle.com> |
|---|---|
| Date | 2016-12-08 12:10 +0100 |
| Subject | [patch] x86/ldt: make a size variable unsigned |
| Message-ID | <sM4Km-5qs-29@gated-at.bofh.it> |
My static checker complains that we put an upper bound on the "size"
variable but not a lower bound. The checker is not smart enough to know
the possible ranges of "old_mm->context.ldt->size" from
init_new_context_ldt() so it thinks maybe it could be negative.
Let's make it unsigned to silence the warning and future proof the code
a bit.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index 4d12cdf2b453..d6320c63be45 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -34,7 +34,7 @@ static void flush_ldt(void *current_mm)
}
/* The caller must call finalize_ldt_struct on the result. LDT starts zeroed. */
-static struct ldt_struct *alloc_ldt_struct(int size)
+static struct ldt_struct *alloc_ldt_struct(unsigned int size)
{
struct ldt_struct *new_ldt;
int alloc_size;
[toc] | [next] | [standalone]
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Date | 2016-12-08 23:40 +0100 |
| Message-ID | <sMfw5-3sC-7@gated-at.bofh.it> |
| In reply to | #1538434 |
On Thu, Dec 8, 2016 at 2:56 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote: > My static checker complains that we put an upper bound on the "size" > variable but not a lower bound. The checker is not smart enough to know > the possible ranges of "old_mm->context.ldt->size" from > init_new_context_ldt() so it thinks maybe it could be negative. > > Let's make it unsigned to silence the warning and future proof the code > a bit. Acked-by: Andy Lutomirski <luto@kernel.org>
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2016-12-09 00:20 +0100 |
| Message-ID | <sMg8O-3WO-19@gated-at.bofh.it> |
| In reply to | #1538434 |
On Thu, 8 Dec 2016, Dan Carpenter wrote:
> My static checker complains that we put an upper bound on the "size"
> variable but not a lower bound. The checker is not smart enough to know
> the possible ranges of "old_mm->context.ldt->size" from
> init_new_context_ldt() so it thinks maybe it could be negative.
>
> Let's make it unsigned to silence the warning and future proof the code
> a bit.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
> index 4d12cdf2b453..d6320c63be45 100644
> --- a/arch/x86/kernel/ldt.c
> +++ b/arch/x86/kernel/ldt.c
> @@ -34,7 +34,7 @@ static void flush_ldt(void *current_mm)
> }
>
> /* The caller must call finalize_ldt_struct on the result. LDT starts zeroed. */
> -static struct ldt_struct *alloc_ldt_struct(int size)
> +static struct ldt_struct *alloc_ldt_struct(unsigned int size)
> {
> struct ldt_struct *new_ldt;
> int alloc_size;
So yes, this fixes the checker warning, but then it leaves the code in
inconsistent state:
alloc_size = size * LDT_ENTRY_SIZE;
Why not doing the obvious
- int alloc_size;
+ unsigned int alloc_size;
right away?
We have lots of places where we 'fixup' stuff and leave the rest untouched,
which then causes trouble a few month down the road. Probably not in this
case, but still.
I'm all for addressing such issues, but then please take the time aside of
mechanically fixing the checker fallout to make the overall usage
consistent.
Thanks,
tglx
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Dan Carpenter <tipbot@zytor.com> |
|---|---|
| Date | 2016-12-10 09:20 +0100 |
| Subject | [tip:x86/cleanups] x86/ldt: Make a size argument unsigned |
| Message-ID | <sML2W-6Rq-19@gated-at.bofh.it> |
| In reply to | #1538434 |
Commit-ID: 296dc5806de57dc84fce000d60fc201ba40f96e8
Gitweb: http://git.kernel.org/tip/296dc5806de57dc84fce000d60fc201ba40f96e8
Author: Dan Carpenter <dan.carpenter@oracle.com>
AuthorDate: Thu, 8 Dec 2016 13:56:03 +0300
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 10 Dec 2016 00:24:39 +0100
x86/ldt: Make a size argument unsigned
My static checker complains that we put an upper bound on the "size"
argument but not a lower bound. The checker is not smart enough to know
the possible ranges of "old_mm->context.ldt->size" from
init_new_context_ldt() so it thinks maybe it could be negative.
Let's make it unsigned to silence the warning and future proof the code
a bit.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Andy Lutomirski <luto@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: kernel-janitors@vger.kernel.org
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20161208105602.GA11382@elgon.mountain
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/kernel/ldt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index 6707039..e25b668 100644
--- a/arch/x86/kernel/ldt.c
+++ b/arch/x86/kernel/ldt.c
@@ -34,7 +34,7 @@ static void flush_ldt(void *current_mm)
}
/* The caller must call finalize_ldt_struct on the result. LDT starts zeroed. */
-static struct ldt_struct *alloc_ldt_struct(int size)
+static struct ldt_struct *alloc_ldt_struct(unsigned int size)
{
struct ldt_struct *new_ldt;
int alloc_size;
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web