[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdmjQvCh__ZH+gLLgcKy4u1n5cgJQPU1WRuitEp+UZra5w@mail.gmail.com>
Date: Thu, 23 May 2019 11:05:28 -0700
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Nathan Chancellor <natechancellor@...il.com>
Cc: Cliff Whickman <cpw@....com>, Robin Holt <robinmholt@...il.com>,
Arnd Bergmann <arnd@...db.de>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
LKML <linux-kernel@...r.kernel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>,
Stephen Hines <srhines@...gle.com>, tony.luck@...el.com,
rja@....com, fenghua.yu@...el.com
Subject: Re: [PATCH] misc: sgi-xp: Properly initialize buf in xpc_get_rsvd_page_pa
On Thu, May 23, 2019 at 9:20 AM Nathan Chancellor
<natechancellor@...il.com> wrote:
>
> Clang warns:
>
> drivers/misc/sgi-xp/xpc_partition.c:73:14: warning: variable 'buf' is
> uninitialized when used within its own initialization [-Wuninitialized]
> void *buf = buf;
> ~~~ ^~~
> 1 warning generated.
>
> Initialize it to NULL, which is more deterministic.
>
> Fixes: 279290294662 ("[IA64-SGI] cleanup the way XPC locates the reserved page")
> Link: https://github.com/ClangBuiltLinux/linux/issues/466
> Suggested-by: Stephen Hines <srhines@...gle.com>
> Signed-off-by: Nathan Chancellor <natechancellor@...il.com>
>From https://github.com/ClangBuiltLinux/linux/issues/466#issuecomment-488781917
I tried to follow the rabbit hole, but eventually these void* get
converted to u64's and passed along to function that I have no idea
whether they handle the value `(u64)(void*)0` or not. Either way,
they definitely don't handle uninitialized values/UB.
I was going to cc Robin who's already cc'ed, but looks like this code
was last touched 7-10 years ago. + Tony and Fenghua for ia64 since
sn_partition_reserved_page_pa is defined in
arch/ia64/include/asm/sn/sn_sal.h.
In absence of consensus, I'll prefer NULL to uninitialized.
Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>
Thanks Nathan for following up on this.
> ---
>
> Thanks Steve for the suggestion, don't know why that never crossed my
> mind...
>
> I tried to follow buf all the way down in get_partition_rsvd_page to see
> if there would be any dereferences and I didn't see any but I could
> have easily missed something.
>
> drivers/misc/sgi-xp/xpc_partition.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c
> index 3eba1c420cc0..782ce95d3f17 100644
> --- a/drivers/misc/sgi-xp/xpc_partition.c
> +++ b/drivers/misc/sgi-xp/xpc_partition.c
> @@ -70,7 +70,7 @@ xpc_get_rsvd_page_pa(int nasid)
> unsigned long rp_pa = nasid; /* seed with nasid */
> size_t len = 0;
> size_t buf_len = 0;
> - void *buf = buf;
> + void *buf = NULL;
> void *buf_base = NULL;
> enum xp_retval (*get_partition_rsvd_page_pa)
> (void *, u64 *, unsigned long *, size_t *) =
> --
> 2.22.0.rc1
>
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists