This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/22121] New: tst-udp-error may fail if CLONE_NEWNET is not available


https://sourceware.org/bugzilla/show_bug.cgi?id=22121

            Bug ID: 22121
           Summary: tst-udp-error may fail if CLONE_NEWNET is not
                    available
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: samuel.thibault@ens-lyon.org
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

Hello,

I'm having issues with tst-udp-error when CLONE_NEWNET is not available,
because bad luck can make it that the client connection happens to get
the same port as the closed server, here is an example trace.

First tst-udp-error sets the server and closes it:

[pid 19899] socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_IP) = 3
[pid 19899] bind(3, {sa_family=AF_INET, sin_port=htons(0),
sin_addr=inet_addr("127.0.0.1")}, 16) = 0
[pid 19899] getsockname(3, {sa_family=AF_INET, sin_port=htons(40000),
sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
[pid 19899] close(3)                    = 0

Then clnt_call tries to bind to a privileged port, but can because we
don't have CLONE_NEWNET:

[pid 19899] socket(AF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_UDP) = 3
[pid 19899] bind(3, {sa_family=AF_INET, sin_port=htons(996),
sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EACCES (Permission denied)
[pid 19899] setsockopt(3, SOL_IP, IP_RECVERR, [1], 4) = 0

then it sends the request to the server

[pid 19899] sendto(3,
"\36\353\0330\0\0\0\0\0\0\0\2\0\0\0\1\0\0\0\2\0\0\0\3\0\0\0\0\0\0\0\0"..., 40,
0, {sa_family=AF_INET, sin_port=htons(40000), sin_addr=inet_addr("127.0.0.1")},
16) = 40

but actually receives it! (instead of getting an error for the send)

[pid 19899] poll([{fd=3, events=POLLIN}], 1, 1000) = 1 ([{fd=3,
revents=POLLIN}])
[pid 19899] recvfrom(3,
"\36\353\0330\0\0\0\0\0\0\0\2\0\0\0\1\0\0\0\2\0\0\0\3\0\0\0\0\0\0\0\0"...,
8800, MSG_DONTWAIT, {sa_family=AF_INET, sin_port=htons(40000),
sin_addr=inet_addr("127.0.0.1")}, [16]) = 40
[pid 19899] write(1, "error: tst-udp-error.c:56: not t"..., 158error:
tst-udp-error.c:56: not true: clnt_call (clnt, 3, (xdrproc_t) xdr_void, NULL,
(xdrproc_t) xdr_void, NULL, ((struct timeval) { 3, 0 })) == RPC_CANTRECV

That's because the system happened to bind the client socket to port
40000 too because of bad luck.

Samuel

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]