2015-04-29 16:00:45

by Shawn C

[permalink] [raw]
Subject: [PATCH 2/2] Fix variable "error" missing initialization

From: Shawn C <[email protected]>

Signed-off-by: Shawn C <[email protected]>
---
mm/mlock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/mlock.c b/mm/mlock.c
index c7f6785..660e5c5 100644
--- a/mm/mlock.c
+++ b/mm/mlock.c
@@ -557,7 +557,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
{
unsigned long nstart, end, tmp;
struct vm_area_struct * vma, * prev;
- int error;
+ int error = 0;

VM_BUG_ON(start & ~PAGE_MASK);
VM_BUG_ON(len != PAGE_ALIGN(len));
--
1.9.1


2015-04-29 17:25:08

by Mateusz Guzik

[permalink] [raw]
Subject: Re: [PATCH 2/2] Fix variable "error" missing initialization

On Thu, Apr 30, 2015 at 12:00:34AM +0800, Shawn Chang wrote:
> From: Shawn C <[email protected]>
>
> Signed-off-by: Shawn C <[email protected]>
> ---
> mm/mlock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/mlock.c b/mm/mlock.c
> index c7f6785..660e5c5 100644
> --- a/mm/mlock.c
> +++ b/mm/mlock.c
> @@ -557,7 +557,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
> {
> unsigned long nstart, end, tmp;
> struct vm_area_struct * vma, * prev;
> - int error;
> + int error = 0;
>
> VM_BUG_ON(start & ~PAGE_MASK);
> VM_BUG_ON(len != PAGE_ALIGN(len));
> --
> 1.9.1
>

This change does not make sense.

The very first read of error is after it gets set.

I see you sent another patch which credited grsecurity. In their
patchset it makes sense - do_mlock is modified in a way which can
interrupt the loop upcoming loop before it gets the chance to set error.

--
Mateusz Guzik