[PATCH] support: add check_mem_access

Florian Weimer fweimer@redhat.com
Tue Sep 9 18:52:23 GMT 2025


* Yury Khrustalev:

> diff --git a/support/check_mem_access.h b/support/check_mem_access.h
> new file mode 100644
> index 0000000000..cd5ea07c9e
> --- /dev/null
> +++ b/support/check_mem_access.h
> @@ -0,0 +1,12 @@
> +#ifndef SUPPORT_CHECK_MEM_ACCESS_H
> +#define SUPPORT_CHECK_MEM_ACCESS_H
> +
> +#include <sys/cdefs.h>
> +
> +__BEGIN_DECLS
> +
> +bool check_mem_access (const void *addr, bool write);
> +
> +__END_DECLS
> +
> +#endif // SUPPORT_CHECK_MEM_ACCESS_H

This needs to document the limitations of the implementation: not
thread-safe, it changes the SIGSEGV signal handler.

It's possible to avoid both by using vfork to isolate the fault, but
it's going to be much slower.

I'd also add the standard license header to the new files.

Thanks,
Florian



More information about the Libc-alpha mailing list