Skip to content

Commit 6a25b27

Browse files
eparisJames Morris
authored andcommitted
SELinux: open perm for sock files
When I did open permissions I didn't think any sockets would have an open. Turns out AF_UNIX sockets can have an open when they are bound to the filesystem namespace. This patch adds a new SOCK_FILE__OPEN permission. It's safe to add this as the open perms are already predicated on capabilities and capabilities means we have unknown perm handling so systems should be as backwards compatible as the policy wants them to be. https://bugzilla.redhat.com/show_bug.cgi?id=475224 Signed-off-by: Eric Paris <eparis@redhat.com> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: James Morris <jmorris@namei.org>
1 parent 113a0e4 commit 6a25b27

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

security/selinux/hooks.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,8 @@ static inline u32 open_file_to_av(struct file *file)
18381838
av |= FIFO_FILE__OPEN;
18391839
else if (S_ISDIR(mode))
18401840
av |= DIR__OPEN;
1841+
else if (S_ISSOCK(mode))
1842+
av |= SOCK_FILE__OPEN;
18411843
else
18421844
printk(KERN_ERR "SELinux: WARNING: inside %s with "
18431845
"unknown mode:%o\n", __func__, mode);

security/selinux/include/av_perm_to_string.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
S_(SECCLASS_CHR_FILE, CHR_FILE__EXECMOD, "execmod")
2525
S_(SECCLASS_CHR_FILE, CHR_FILE__OPEN, "open")
2626
S_(SECCLASS_BLK_FILE, BLK_FILE__OPEN, "open")
27+
S_(SECCLASS_SOCK_FILE, SOCK_FILE__OPEN, "open")
2728
S_(SECCLASS_FIFO_FILE, FIFO_FILE__OPEN, "open")
2829
S_(SECCLASS_FD, FD__USE, "use")
2930
S_(SECCLASS_TCP_SOCKET, TCP_SOCKET__CONNECTTO, "connectto")

security/selinux/include/av_permissions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
#define SOCK_FILE__SWAPON 0x00004000UL
175175
#define SOCK_FILE__QUOTAON 0x00008000UL
176176
#define SOCK_FILE__MOUNTON 0x00010000UL
177+
#define SOCK_FILE__OPEN 0x00020000UL
177178
#define FIFO_FILE__IOCTL 0x00000001UL
178179
#define FIFO_FILE__READ 0x00000002UL
179180
#define FIFO_FILE__WRITE 0x00000004UL

0 commit comments

Comments
 (0)