Is malloc deterministic? Say If I have a forked process, that is, a replica of another process, and at some point both of them call the malloc
There is no reason at all for it to be deterministic, in fact there can be some benefit to it not being deterministic, for example increasing the complexity of exploiting bugs (see also this paper).
This randomness can be helpful at making exploits harder to write. To successfully exploit a buffer overflow you typically need to do two things:
If the memory location is unpredictable making that jump can become quite a lot harder.
The relevant quote from the standard §7.20.3.3/2:
The malloc function allocates space for an object whose size is specified by size and whose value is indeterminate
If it were the intention to make it deterministic then that would be clearly stated as such.
Even if it looks deterministic today I wouldn't bet on it remaining so with a newer kernel or a newer libc/GCC version.