* [PATCH lkdtm] lkdtm: Fix reference preceded by free
@ 2021-10-22 1:28 davidcomponentone
[not found] ` <CA+E=9osPJSZDqHkd0j-JwL7Tufs3vG3tRtG94+Rsdo4kVgBjAg@mail.gmail.com>
2021-10-22 3:38 ` He Ying
0 siblings, 2 replies; 3+ messages in thread
From: davidcomponentone @ 2021-10-22 1:28 UTC (permalink / raw)
To: keescook; +Cc: arnd, gregkh, linux-kernel, Yang Guang, Zeal Robot
From: Yang Guang <yang.guang5@zte.com.cn>
The coccinelle check report:
./drivers/misc/lkdtm/heap.c:115:7-11:
ERROR: reference preceded by free on line 112
Moving the "kfree(base)" after using place to fix it.
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
---
drivers/misc/lkdtm/heap.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/misc/lkdtm/heap.c b/drivers/misc/lkdtm/heap.c
index 8a92f5a800fa..4c6341e7bdca 100644
--- a/drivers/misc/lkdtm/heap.c
+++ b/drivers/misc/lkdtm/heap.c
@@ -109,8 +109,6 @@ void lkdtm_READ_AFTER_FREE(void)
base[offset] = *val;
pr_info("Value in memory before free: %x\n", base[offset]);
- kfree(base);
-
pr_info("Attempting bad read from freed memory\n");
saw = base[offset];
if (saw != *val) {
@@ -121,6 +119,7 @@ void lkdtm_READ_AFTER_FREE(void)
pr_expected_config_param(CONFIG_INIT_ON_FREE_DEFAULT_ON, "init_on_free");
}
+ kfree(base);
kfree(val);
}
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread[parent not found: <CA+E=9osPJSZDqHkd0j-JwL7Tufs3vG3tRtG94+Rsdo4kVgBjAg@mail.gmail.com>]
* Re: [PATCH lkdtm] lkdtm: Fix reference preceded by free
[not found] ` <CA+E=9osPJSZDqHkd0j-JwL7Tufs3vG3tRtG94+Rsdo4kVgBjAg@mail.gmail.com>
@ 2021-10-22 3:36 ` Kees Cook
0 siblings, 0 replies; 3+ messages in thread
From: Kees Cook @ 2021-10-22 3:36 UTC (permalink / raw)
To: David Yang; +Cc: Yang Guang, Zeal Robot, arnd, gregkh, linux-kernel
On Fri, Oct 22, 2021 at 09:38:59AM +0800, David Yang wrote:
> From: Yang Guang <yang.guang5@zte.com.cn>
> >
> > The coccinelle check report:
> > ./drivers/misc/lkdtm/heap.c:115:7-11:
> > ERROR: reference preceded by free on line 112
> > Moving the "kfree(base)" after using place to fix it.
> >
> > Reported-by: Zeal Robot <zealci@zte.com.cn>
> > Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
>
> Please ignore this patch. Thanks.
Heh, no worries. It's nice to know that the Coccinelle checks are
finding broken things, though! :) (It's just that LKDTM is intentionally
broken.) ;)
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH lkdtm] lkdtm: Fix reference preceded by free
2021-10-22 1:28 [PATCH lkdtm] lkdtm: Fix reference preceded by free davidcomponentone
[not found] ` <CA+E=9osPJSZDqHkd0j-JwL7Tufs3vG3tRtG94+Rsdo4kVgBjAg@mail.gmail.com>
@ 2021-10-22 3:38 ` He Ying
1 sibling, 0 replies; 3+ messages in thread
From: He Ying @ 2021-10-22 3:38 UTC (permalink / raw)
To: davidcomponentone, keescook
Cc: arnd, gregkh, linux-kernel, Yang Guang, Zeal Robot
在 2021/10/22 9:28, davidcomponentone@gmail.com 写道:
> From: Yang Guang <yang.guang5@zte.com.cn>
>
> The coccinelle check report:
> ./drivers/misc/lkdtm/heap.c:115:7-11:
> ERROR: reference preceded by free on line 112
> Moving the "kfree(base)" after using place to fix it.
Look at the name of the function "lkdtm_READ_AFTER_FREE". It's meant to
use after free to test something.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Yang Guang <yang.guang5@zte.com.cn>
> ---
> drivers/misc/lkdtm/heap.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/misc/lkdtm/heap.c b/drivers/misc/lkdtm/heap.c
> index 8a92f5a800fa..4c6341e7bdca 100644
> --- a/drivers/misc/lkdtm/heap.c
> +++ b/drivers/misc/lkdtm/heap.c
> @@ -109,8 +109,6 @@ void lkdtm_READ_AFTER_FREE(void)
> base[offset] = *val;
> pr_info("Value in memory before free: %x\n", base[offset]);
>
> - kfree(base);
> -
> pr_info("Attempting bad read from freed memory\n");
> saw = base[offset];
> if (saw != *val) {
> @@ -121,6 +119,7 @@ void lkdtm_READ_AFTER_FREE(void)
> pr_expected_config_param(CONFIG_INIT_ON_FREE_DEFAULT_ON, "init_on_free");
> }
>
> + kfree(base);
> kfree(val);
> }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-22 3:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-22 1:28 [PATCH lkdtm] lkdtm: Fix reference preceded by free davidcomponentone
[not found] ` <CA+E=9osPJSZDqHkd0j-JwL7Tufs3vG3tRtG94+Rsdo4kVgBjAg@mail.gmail.com>
2021-10-22 3:36 ` Kees Cook
2021-10-22 3:38 ` He Ying
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®