libqasan: read and write hooks
MODIFY
qemu_mode/libqasan/hooks.c
qemu_mode/libqasan/hooks.c
@@ -26,6 +26,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "libqasan.h"
#include "map_macro.h"
+ssize_t (*__lq_libc_write)(int, const void *, size_t);
+ssize_t (*__lq_libc_read)(int, void *, size_t);
char *(*__lq_libc_fgets)(char *, int, FILE *);
int (*__lq_libc_atoi)(const char *);
long (*__lq_libc_atol)(const char *);
@@ -35,6 +37,8 @@ void __libqasan_init_hooks(void) {
__libqasan_init_malloc();
+ __lq_libc_write = ASSERT_DLSYM(write);
+ __lq_libc_read = ASSERT_DLSYM(read);
__lq_libc_fgets = ASSERT_DLSYM(fgets);
__lq_libc_atoi = ASSERT_DLSYM(atoi);
__lq_libc_atol = ASSERT_DLSYM(atol);
@@ -42,6 +46,30 @@ void __libqasan_init_hooks(void) {
}
+ssize_t write(int fd, const void *buf, size_t count) {
+
+ void *rtv = __builtin_return_address(0);
+
+ QASAN_DEBUG("%14p: write(%d, %p, %ld)\n", rtv, fd, buf, count);
+ ssize_t r = __lq_libc_write(fd, buf, count);
+ QASAN_DEBUG("\t\t = %p\n", r);
+
+ return r;
+
+}
+
+ssize_t read(int fd, void *buf, size_t count) {
+
+ void *rtv = __builtin_return_address(0);
+
+ QASAN_DEBUG("%14p: read(%d, %p, %ld)\n", rtv, fd, buf, count);
+ ssize_t r = __lq_libc_read(fd, buf, count);
+ QASAN_DEBUG("\t\t = %p\n", r);
+
+ return r;
+
+}
+
#ifdef __ANDROID__
size_t malloc_usable_size(const void *ptr) {

libqasan: read and write hooks