disablenetwork (v5): Simplify the disablenetwork sendmsg hook.
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): 20100117170431.GA2949@heat
Quoted 38 lines · Michael Stone
Quoted 15 lines · Michael Tsirkin
Quoted 14 lines · Michael Stone
The idea is that calls like
sendto(fd, buffer, len, 0, NULL, 0); send(fd, buffer, len, 0) write(fd, buffer, len)are all to be permitted but that calls like
sendto(fd, buffer, len, 0, (struct sockadr *) &addr, sizeof(addr));are to be rejected when the current task's network is disabled on the grounds that the former calls must use previously connected sockets but that the latter socket need not have been previously connected.
Quoted 6 lines
Quoted 1 line
Signed-off-by Michael Stone <[email protected]>Michael, if I understand correctly, with this patch one could use disablenetwork to pass an
af_packetsocket bound to a device to a task, and make sure that the task does not use it to inject packets into another device?Michael,
Thanks for writing. If I understand you correctly, you're asking:
May a network-disabled process use
recvmsg()withSCM_RIGHTScontrol messages to receive a file descriptor pointing to previously connected or boundAF_PACKETsocket and, having received such an fd, may the network-disabled process use the socket normally?If I've understood correctly, then the answer is "yes, to the extent that you can't do stupid things with
sendmsg(),fnctl(),ioctl(), and friends."I intend to look more carefully at the ability to use those calls to do stupid things in coming weeks.
Quoted 7 lines
Does this help?
Regards,
Michael
P.S. - Incidentally, what is the nature of your interest?
We discussed using af_packet sockets for networking in qemu. qemu is a large project so it might not be a great idea to run it as root all the
time: a better idea is to e.g. get fd from a priveledged server. However, we'd like to limit qemu even more, so that it can only use the fd for send/receive.
Quoted 1 line
(And was your question intentionally or accidentally off-list?)
Oops. Adding it back.
Signature · 1 line
MST
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
are all to be permitted but that calls like
sendto(fd, buffer, len, 0, (struct sockadr *) &addr, sizeof(addr));are to be rejected when the current task's network is disabled on the grounds that the former calls must use previously connected sockets but that the latter socket need not have been previously connected.
Not surprised to see this "simple" idea is unsurprisingly turning incredibly complex, full of policy and also holes. Can people now accept that the reason we have rather more complex models for security policy is because generally speaking these "oh so simple" little magic switches don't actually work or solve any real world problems.
And just to point out further problems - there are numerous cases where I can control the remote destination of messages without using sendto or passing addresses in obvious manners. You'll need to parse all the ioctls and protocol specific calls as a starter. You'll also need a policy engine of some form to detect when I can use send stuff in one socket I have rights to in order to influence routing of another by talking to network stuff or emitting controlling messages of any form.
(and even then there are tons of cases you can't fix that way as the early Java people found to their cost. Things like connecting to a web server via a socket that can only connect to port 80 and issuing proxy requests, or triggering a remote carefully placed cgi script to produce tunnels with total control.
Alan