Write a small module with your implementation of malloc(). Compile with -fPIC option and turn it into a shared library:
Code:
$ gcc -fPIC -c my_malloc.c
$ ld -shared -o libmy_malloc.so my_malloc.o -lc
Send it to the user and have him give the command:
Code:
export LD_PRELOAD=libmy_malloc.so
This will override the standard library malloc() with your own. It will override it for ALL programs he runs after that point, at least in that shell.
Of course, you probably want your override malloc() to call the built-in malloc() at some point. You can refer to it in your stub code as __libc_malloc() (double underscore at front)