* [PATCH] lkdtm: Remove set but not used variable 'byte'
@ 2019-11-10 9:22 Zheng Yongjun
2019-11-10 18:13 ` Joe Perches
2019-11-10 18:18 ` Greg KH
0 siblings, 2 replies; 3+ messages in thread
From: Zheng Yongjun @ 2019-11-10 9:22 UTC (permalink / raw)
To: keescook, arnd, gregkh; +Cc: linux-kernel, zhengyongjun3, Hulk Robot
Fixes gcc '-Wunused-but-set-variable' warning:
drivers/misc/lkdtm/bugs.c: In function lkdtm_STACK_GUARD_PAGE_LEADING:
drivers/misc/lkdtm/bugs.c:236:25: warning: variable byte set but not used [-Wunused-but-set-variable]
drivers/misc/lkdtm/bugs.c: In function lkdtm_STACK_GUARD_PAGE_TRAILING:
drivers/misc/lkdtm/bugs.c:250:25: warning: variable byte set but not used [-Wunused-but-set-variable]
byte is never used, so remove it.
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
---
drivers/misc/lkdtm/bugs.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/drivers/misc/lkdtm/bugs.c b/drivers/misc/lkdtm/bugs.c
index 7284a22b1a09..fcd943725b66 100644
--- a/drivers/misc/lkdtm/bugs.c
+++ b/drivers/misc/lkdtm/bugs.c
@@ -249,12 +249,9 @@ void lkdtm_STACK_GUARD_PAGE_LEADING(void)
{
const unsigned char *stack = task_stack_page(current);
const unsigned char *ptr = stack - 1;
- volatile unsigned char byte;
pr_info("attempting bad read from page below current stack\n");
- byte = *ptr;
-
pr_err("FAIL: accessed page before stack!\n");
}
@@ -263,12 +260,9 @@ void lkdtm_STACK_GUARD_PAGE_TRAILING(void)
{
const unsigned char *stack = task_stack_page(current);
const unsigned char *ptr = stack + THREAD_SIZE;
- volatile unsigned char byte;
pr_info("attempting bad read from page above current stack\n");
- byte = *ptr;
-
pr_err("FAIL: accessed page after stack!\n");
}
--
2.23.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lkdtm: Remove set but not used variable 'byte'
2019-11-10 9:22 [PATCH] lkdtm: Remove set but not used variable 'byte' Zheng Yongjun
@ 2019-11-10 18:13 ` Joe Perches
2019-11-10 18:18 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Joe Perches @ 2019-11-10 18:13 UTC (permalink / raw)
To: Zheng Yongjun, keescook, arnd, gregkh; +Cc: linux-kernel, Hulk Robot
On Sun, 2019-11-10 at 17:22 +0800, Zheng Yongjun wrote:
> Fixes gcc '-Wunused-but-set-variable' warning:
>
> drivers/misc/lkdtm/bugs.c: In function lkdtm_STACK_GUARD_PAGE_LEADING:
> drivers/misc/lkdtm/bugs.c:236:25: warning: variable byte set but not used [-Wunused-but-set-variable]
> drivers/misc/lkdtm/bugs.c: In function lkdtm_STACK_GUARD_PAGE_TRAILING:
> drivers/misc/lkdtm/bugs.c:250:25: warning: variable byte set but not used [-Wunused-but-set-variable]
>
> byte is never used, so remove it.
I believe "hulk robot" needs to be updated instead.
It seems a generically bad idea to elide as byte
is in fact used because it's volatile and the
compiler was forced to perform the access of *ptr.
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> ---
> drivers/misc/lkdtm/bugs.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/drivers/misc/lkdtm/bugs.c b/drivers/misc/lkdtm/bugs.c
> index 7284a22b1a09..fcd943725b66 100644
> --- a/drivers/misc/lkdtm/bugs.c
> +++ b/drivers/misc/lkdtm/bugs.c
> @@ -249,12 +249,9 @@ void lkdtm_STACK_GUARD_PAGE_LEADING(void)
> {
> const unsigned char *stack = task_stack_page(current);
> const unsigned char *ptr = stack - 1;
> - volatile unsigned char byte;
>
> pr_info("attempting bad read from page below current stack\n");
>
> - byte = *ptr;
> -
> pr_err("FAIL: accessed page before stack!\n");
> }
>
> @@ -263,12 +260,9 @@ void lkdtm_STACK_GUARD_PAGE_TRAILING(void)
> {
> const unsigned char *stack = task_stack_page(current);
> const unsigned char *ptr = stack + THREAD_SIZE;
> - volatile unsigned char byte;
>
> pr_info("attempting bad read from page above current stack\n");
>
> - byte = *ptr;
> -
> pr_err("FAIL: accessed page after stack!\n");
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] lkdtm: Remove set but not used variable 'byte'
2019-11-10 9:22 [PATCH] lkdtm: Remove set but not used variable 'byte' Zheng Yongjun
2019-11-10 18:13 ` Joe Perches
@ 2019-11-10 18:18 ` Greg KH
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2019-11-10 18:18 UTC (permalink / raw)
To: Zheng Yongjun; +Cc: keescook, arnd, linux-kernel, Hulk Robot
On Sun, Nov 10, 2019 at 05:22:49PM +0800, Zheng Yongjun wrote:
> Fixes gcc '-Wunused-but-set-variable' warning:
>
> drivers/misc/lkdtm/bugs.c: In function lkdtm_STACK_GUARD_PAGE_LEADING:
> drivers/misc/lkdtm/bugs.c:236:25: warning: variable byte set but not used [-Wunused-but-set-variable]
> drivers/misc/lkdtm/bugs.c: In function lkdtm_STACK_GUARD_PAGE_TRAILING:
> drivers/misc/lkdtm/bugs.c:250:25: warning: variable byte set but not used [-Wunused-but-set-variable]
>
> byte is never used, so remove it.
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
> ---
> drivers/misc/lkdtm/bugs.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/drivers/misc/lkdtm/bugs.c b/drivers/misc/lkdtm/bugs.c
> index 7284a22b1a09..fcd943725b66 100644
> --- a/drivers/misc/lkdtm/bugs.c
> +++ b/drivers/misc/lkdtm/bugs.c
> @@ -249,12 +249,9 @@ void lkdtm_STACK_GUARD_PAGE_LEADING(void)
> {
> const unsigned char *stack = task_stack_page(current);
> const unsigned char *ptr = stack - 1;
> - volatile unsigned char byte;
>
> pr_info("attempting bad read from page below current stack\n");
>
> - byte = *ptr;
> -
You do realize just what this code is trying to do _is_ a bug, so it's
ok to leave it, right? You just broke the code here with your change as
you are trying to "fix" it :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-11-10 18:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-10 9:22 [PATCH] lkdtm: Remove set but not used variable 'byte' Zheng Yongjun
2019-11-10 18:13 ` Joe Perches
2019-11-10 18:18 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).