Missing security labels for socket objects?
Subsystems (2)
Hi! Im trying to see where the access control for some socket objects occurs. And it seems not to be very detailed resolution for sockets. For some protocols there is NOTHING. I did a test. I created a own protocol. AF_PEG_IPC. This can be accessed without specific type definition or contexts. It need socket access. In my system there is about 20 different protocols. They are "all or nothing".
The question is how do I select which root task that can access AF_PEG_IPC and who can not. In selinux root is supposed to be in locked container.
The kernel test patch is for 3.4-ish. (ala android)
----------------------
Test program:
/* test program
* writen by [email protected]
* Open and write to a local defined IPC.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <errno.h>
#include <string.h>
#define AF_PEG_IPC 39
struct sockaddr_peg_ipc {
unsigned short family;
unsigned char reserved;
};
int main()
{
int fd,res;
char dummy_data[256];
struct sockaddr_peg_ipc dest_addr;
fd = socket(AF_PEG_IPC, SOCK_DGRAM, 0);
printf("Socket %d\n",fd);
if (fd > 0) {
dest_addr.family = AF_PEG_IPC;
res = sendto(fd, dummy_data, 256, MSG_DONTWAIT, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr_peg_ipc));
printf("res: %d\n",res);
if (res < 0) {
printf("Error: %s %d\n", strerror(errno),errno);
}
} else {
printf("Error: %s %d\n", strerror(errno),errno); }
return 0;
}
And the patch
From 77fea03d7c4cee8ef7f5ec21451206074d270b3d Mon Sep 17 00:00:00 2001
From: Peter Enderborg <[email protected]>
Date: Thu, 30 Oct 2014 16:28:23 +0100
Subject: [PATCH] Test of local defined IPC
Change-Id: Iaba1e7419fbae716424a042a47fb6abb704e814e
--- drivers/net/Makefile | 1 + drivers/net/peg.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 drivers/net/peg.c
drivers/net/Makefile +1 -0
@@ -7,6 +7,7 @@ # obj-$(CONFIG_BONDING) += bonding/ obj-$(CONFIG_DUMMY) += dummy.o +obj-$(CONFIG_DUMMY) += peg.o obj-$(CONFIG_EQUALIZER) += eql.o obj-$(CONFIG_IFB) += ifb.o obj-$(CONFIG_MACVLAN) += macvlan.o
drivers/net/peg.c new file +160 -0
160 lines not on this page · raw message
Signature · 1 line
1.8.2.2
Quoted 9 lines · peter enderborg
Hi! Im trying to see where the access control for some socket objects occurs.
And it seems not to be very detailed resolution for sockets. For some protocols there is NOTHING. I did a test. I created a own protocol.AF_PEG_IPC.
This can be accessed without specific type definition or contexts. It need socket access. In my system there is about 20 different protocols. They are "all or nothing".
Quoted 3 lines
The question is how do I select which root task that can access
AF_PEG_IPCand who can not. In selinux root is supposed to be in locked container.
SELinux applies a set of general socket permission checks (e.g. create, bind, connect, ...) for all sockets, but it can only distinguish among types of sockets for which security classes have been defined. All other socket address families are lumped together into the generic socket security class. If you want to be able to control this AF_PEG_IPC separately, you need to introduce a security class for it. See this similar answer on the seandroid-list,
http://marc.info/?l=seandroid-list&m=139056956927985&w=2
Is there any work going on the make it more granular? I did not see it in the "Remaning Work" backlog. It is a generic problem and should have a generic solution.
Quoted 24 lines · Stephen Smalley
Quoted 9 lines · peter enderborg
Hi! Im trying to see where the access control for some socket objects occurs.
And it seems not to be very detailed resolution for sockets. For some protocols there is NOTHING. I did a test. I created a own protocol.AF_PEG_IPC.
This can be accessed without specific type definition or contexts. It need socket access. In my system there is about 20 different protocols. They are "all or nothing".Quoted 3 lines
The question is how do I select which root task that can access
AF_PEG_IPCand who can not. In selinux root is supposed to be in locked container.SELinux applies a set of general socket permission checks (e.g. create, bind, connect, ...) for all sockets, but it can only distinguish among types of sockets for which security classes have been defined. All other socket address families are lumped together into the generic socket security class. If you want to be able to control this
AF_PEG_IPCseparately, you need to introduce a security class for it. See this similar answer on the seandroid-list,
http://marc.info/?l=seandroid-list&m=139056956927985&w=2
Quoted 3 lines · peter enderborg
Is there any work going on the make it more granular? I did not see it in the "Remaning Work" backlog. It is a generic problem and should have a generic solution.
It is on the new kernel to-do list, at the bottom of new items on:
https://github.com/SELinuxProject/selinux/wiki/Kernel-Todo
However, I'm not sure what the general solution would look like. I don't think we want to write policies on socket (domain, type, protocol) triples or introduce unique security classes for every such triple. The security class abstraction in SELinux (and its underlying Flask architecture) is intended to provide a higher level abstraction for security policy writers.
A sysfs tree with both dac and mac control would be nice.
Quoted 15 lines · Stephen Smalley
Quoted 3 lines · peter enderborg
Is there any work going on the make it more granular? I did not see it in the "Remaning Work" backlog. It is a generic problem and should have a generic solution.
It is on the new kernel to-do list, at the bottom of new items on:
https://github.com/SELinuxProject/selinux/wiki/Kernel-TodoHowever, I'm not sure what the general solution would look like. I don't think we want to write policies on socket (domain, type, protocol) triples or introduce unique security classes for every such triple. The security class abstraction in SELinux (and its underlying Flask architecture) is intended to provide a higher level abstraction for security policy writers.