Bug 440743 - Socketpair wrapper does not handle emulated resource limit properly
Summary: Socketpair wrapper does not handle emulated resource limit properly
Status: REPORTED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Unspecified
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-08 14:14 UTC by Alois Wohlschlager
Modified: 2021-08-08 14:14 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alois Wohlschlager 2021-08-08 14:14:47 UTC
SUMMARY

The syscall wrapper for socketpair returns success if the emulated resource limit for open files is exhausted. It should fail with error EMFILE.

STEPS TO REPRODUCE
1. Compile the following test program:
#include <stdio.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <unistd.h>

int main()
{
	struct rlimit lim;
	getrlimit(RLIMIT_NOFILE, &lim);
	lim.rlim_cur = 3;
	setrlimit(RLIMIT_NOFILE, &lim);
	int sv[2];
	printf("%d\n", socketpair(AF_UNIX, SOCK_STREAM, 0, sv));
}

2. Run the compiled program with valgrind (the tool does not matter)

OBSERVED RESULT

Test program prints 0

EXPECTED RESULT

Test program prints -1

SOFTWARE/OS VERSIONS
Valgrind: 3.17.0