Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1420493 > unrolled thread

[patch] x86/ldt: silence a static checker warning

Started byDan Carpenter <dan.carpenter@oracle.com>
First post2016-06-13 09:00 +0200
Last post2016-06-14 12:50 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [patch] x86/ldt: silence a static checker warning Dan Carpenter <dan.carpenter@oracle.com> - 2016-06-13 09:00 +0200
    Re: [patch] x86/ldt: silence a static checker warning Andy Lutomirski <luto@amacapital.net> - 2016-06-13 23:20 +0200
      Re: [patch] x86/ldt: silence a static checker warning Dan Carpenter <dan.carpenter@oracle.com> - 2016-06-14 12:50 +0200

#1420493 — [patch] x86/ldt: silence a static checker warning

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-06-13 09:00 +0200
Subject[patch] x86/ldt: silence a static checker warning
Message-ID<rJu0O-2EM-7@gated-at.bofh.it>
It likely doesn't make a difference but my static checker complains
that we put an upper bound on "size" but not a lower bound.  Let's just
make it unsigned.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
index 6707039b..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] | [next] | [standalone]


#1421343

FromAndy Lutomirski <luto@amacapital.net>
Date2016-06-13 23:20 +0200
Message-ID<rJHr4-3m2-29@gated-at.bofh.it>
In reply to#1420493
On Sun, Jun 12, 2016 at 11:57 PM, Dan Carpenter
<dan.carpenter@oracle.com> wrote:
> It likely doesn't make a difference but my static checker complains
> that we put an upper bound on "size" but not a lower bound.  Let's just
> make it unsigned.

Shouldn't oldsize and newsize in write_ldt as well as the "size"
member in ldt_struct change, too?

--Andy

[toc] | [prev] | [next] | [standalone]


#1421762

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-06-14 12:50 +0200
Message-ID<rJU4W-3FD-21@gated-at.bofh.it>
In reply to#1421343
On Mon, Jun 13, 2016 at 02:14:39PM -0700, Andy Lutomirski wrote:
> On Sun, Jun 12, 2016 at 11:57 PM, Dan Carpenter
> <dan.carpenter@oracle.com> wrote:
> > It likely doesn't make a difference but my static checker complains
> > that we put an upper bound on "size" but not a lower bound.  Let's just
> > make it unsigned.
> 
> Shouldn't oldsize and newsize in write_ldt as well as the "size"
> member in ldt_struct change, too?
> 

Part of the joy of this check is that it complains about every time we
cap the upper bound and not the lower bound so it's very thourough, but
it also requires very minimal changes to silence the false positives.

We know newsize can't be negative.  If we change this one variable
then we know oldsize and ldt_struct size can't be negative either.

The problem really is that I haven't figured out out to deal with
recursion...

	new_ldt = alloc_ldt_struct(old_mm->context.ldt->size);

On the first run through, we don't know the value of ->size here so we
have to assume it can be anything.

regards,
dan carpenter

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web