lib: add SAFE_CALLOC macro
PATCH v3 1/2 lib: add SAFE_CALLOC macro
--- include/tst_safe_macros.h | 5 +++++ lib/tst_safe_macros.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+)
include/tst_safe_macros.h +5 -0
@@ -75,6 +75,11 @@ int safe_dup2(const char *file, const int lineno, int oldfd, int newfd);#define SAFE_MALLOC (size) \ safe_malloc(__FILE__, __LINE__, NULL, (size)) +void *safe_calloc (const char *file,const int lineno,size_t nmemb,size_t size); + +#define SAFE_CALLOC (nmemb, size) \ + safe_calloc(__FILE__, __LINE__, (nmemb), (size)) +void *safe_realloc (const char *file,const int lineno,void *ptr,size_t size);#define SAFE_REALLOC (ptr, size) \
lib/tst_safe_macros.c +14 -0
@@ -546,6 +546,20 @@ int safe_dup2(const char *file, const int lineno, int oldfd, int newfd)return rval; } +void *safe_calloc (const char *file,const int lineno,size_t nmemb,size_t size) +{ +void *rval; + + rval =calloc (nmemb, size); + +if (rval ==NULL ) { +tst_brk_ (file, lineno,TBROK |TERRNO , +"calloc(%zu, %zu) failed" , nmemb, size); + } + +return rval; +} +void *safe_realloc (const char *file,const int lineno,void *ptr,size_t size) {void *ret;
Signature · 5 lines
2.44.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 2/2 kallsyms01: Utilize ksymbol table for unauthorized address access
Access the system symbols with root permission to test whether it's possible to read and write the memory addresses of kernel-space from user-space. This helps in identifying potential vulnerabilities where user-space processes can inappropriately access kernel memory.
---
Notes:
v2 --> v3
* update GPL lisence to 2.0-or-later
* move the sigaction to the test setup
* init segv_caught to 0 in the main
* add TFAIL print in report
runtest/mm | 2 + testcases/kernel/security/kallsyms/.gitignore | 1 + testcases/kernel/security/kallsyms/Makefile | 6 + testcases/kernel/security/kallsyms/kallsyms.c | 145 ++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 testcases/kernel/security/kallsyms/.gitignore create mode 100644 testcases/kernel/security/kallsyms/Makefile create mode 100644 testcases/kernel/security/kallsyms/kallsyms.c
runtest/mm +2 -0
@@ -58,6 +58,8 @@ mmap10_2 mmap10 -s mmap10_3 mmap10 -a -s mmap10_4 mmap10 -a -s -i 60 +kallsyms kallsyms + ksm01 ksm01 ksm01_1 ksm01 -u 128 ksm02 ksm02
testcases/kernel/security/kallsyms/.gitignore new file +1 -0
@@ -0,0 +1 @@ +kallsyms
testcases/kernel/security/kallsyms/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/security/kallsyms/kallsyms.c new file +145 -0
145 lines not on this page · raw message
Signature · 5 lines
2.44.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [Patch v3 2/2] kallsyms01: Utilize ksymbol table for unauthorized address access
Hi!
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [Patch v3 2/2] kallsyms01: Utilize ksymbol table for unauthorized address access
Cyril Hrubis <[email protected]> wrote:
Hi!
Quoted 2 lines
Reviewed-by Cyril Hrubis <[email protected]>
Patch applied, thanks for the review.
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp