On 23/11/2022 17:23, Teo Couprie Diaz wrote:
On 23/11/2022 16:08, Kevin Brodsky wrote:
On 23/11/2022 11:57, Teo Couprie Diaz wrote:
The patch also removes the dependency on sbrk to get the current break as it has the same issues. Instead, call tst_syscall(__NR_brk, 0) which should always fail, returning the current break.
I think it can't both fail and return the current break 😄 Probably remove "which should always fail", or maybe s/always/never/?
Well, from my understanding that's exactly the expected behavior ! From the man page BRK(2):
[...], the actual Linux system call returns the new program break on success. *On
failure, the
system call returns the current break.* The glibc wrapper
function does
some work (i.e., checks whether the new break is less than
addr) to
provide the 0 and -1 return values described above.
Also in mm/mmap.c, at the end of SYSCALL_DEFINE1(brk, unsigned long, brk) :
out: mmap_write_unlock(mm); return origbrk;
Where origbrk is saved at the beginning and out is jumped to whenever there is an error.
So making a brk syscall with 0 should always fail (it's smaller than the minimum break), and also return the current(/original ?) break unchanged.
But maybe I am misunderstanding your comment itself ? Please let me know !
Right yes sorry I was thinking about it from the wrong angle, that is that no *wrapper* is failing (because tst_syscall() just makes a raw syscall). But yes indeed the syscall is technically failing when you do that. Maybe it's better to just say that calling tst_syscall this way always returns the current break without elaborating further?
Ah yeah ok, I see what you mean.
"Instead, call tst_syscall(__NR_brk, 0) which returns the current break."
Should be alright then, if that's ok with you ?
Fine by me, you can add "always" to make it clear it doesn't... fail to fail? :D
Kevin