path: root/security
AgeCommit message (Collapse)AuthorFilesLines
2008-04-10SELinux: don't BUG if fs reuses a superblockEric Paris1-4/+4
I (wrongly) assumed that nfs_xdev_get_sb() would not ever share a superblock and so cloning mount options would always be correct. Turns out that isn't the case and we could fall over a BUG_ON() that wasn't a BUG at all. Since there is little we can do to reconcile different mount options this patch just leaves the sb alone and the first set of options wins. Signed-off-by: Eric Paris <> Acked-by: Stephen Smalley <> Acked-by: Trond Myklebust <> Signed-off-by: James Morris <>
2008-04-08SELinux: more GFP_NOFS fixups to prevent selinux from re-entering the fs codeStephen Smalley3-9/+13
More cases where SELinux must not re-enter the fs code. Called from the d_instantiate security hook. Signed-off-by: Stephen Smalley <> Signed-off-by: James Morris <>
2008-04-04selinux: prevent rentry into the FSJosef Bacik1-2/+2
BUG fix. Keep us from re-entering the fs when we aren't supposed to. See discussion at Signed-off-by: Josef Bacik <> Acked-by: Stephen Smalley <> Signed-off-by: James Morris <>
2008-04-02selinux: handle files opened with flags 3 by checking ioctl permissionStephen Smalley1-0/+6
Handle files opened with flags 3 by checking ioctl permission. Default to returning FILE__IOCTL from file_to_av() if the f_mode has neither FMODE_READ nor FMODE_WRITE, and thus check ioctl permission on exec or transfer, thereby validating such descriptors early as with normal r/w descriptors and catching leaks of them prior to attempted usage. Signed-off-by: Stephen Smalley <> Acked-by: Eric Paris <> Signed-off-by: James Morris <>
2008-03-24smackfs: remove redundant lock, fix open(,O_RDWR)Ahmed S. Darwish1-33/+2
Older smackfs was parsing MAC rules by characters, thus a need of locking write sessions on open() was needed. This lock is no longer useful now since each rule is handled by a single write() call. This is also a bugfix since seq_open() was not called if an open() O_RDWR flag was given, leading to a seq_read() without an initialized seq_file, thus an Oops. Signed-off-by: Ahmed S. Darwish <> Reported-by: Jonathan Corbet <> Acked-by: Casey Schaufler <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2008-03-20file capabilities: remove cap_task_kill()Serge Hallyn3-46/+0
The original justification for cap_task_kill() was as follows: check_kill_permission() does appropriate uid equivalence checks. However with file capabilities it becomes possible for an unprivileged user to execute a file with file capabilities resulting in a more privileged task with the same uid. However now that cap_task_kill() always returns 0 (permission granted) when p->uid==current->uid, the whole hook is worthless, and only likely to create more subtle problems in the corner cases where it might still be called but return -EPERM. Those cases are basically when uids are different but euid/suid is equivalent as per the check in check_kill_permission(). One example of a still-broken application is 'at' for non-root users. This patch removes cap_task_kill(). Signed-off-by: Serge Hallyn <> Acked-by: Andrew G. Morgan <> Earlier-version-tested-by: Luiz Fernando N. Capitulino <> Acked-by: Casey Schaufler <> Signed-off-by: Linus Torvalds <>
2008-03-19smack: do not dereference NULL ipc objectAhmed S. Darwish1-3/+6
In the SYSV ipc msgctl(),semctl(),shmctl() family, if the user passed *_INFO as the desired operation, no specific object is meant to be controlled and only system-wide information is returned. This leads to a NULL IPC object in the LSM hooks if the _INFO flag is given. Avoid dereferencing this NULL pointer in Smack ipc *ctl() methods. Signed-off-by: Ahmed S. Darwish <> Acked-by: Casey Schaufler <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2008-03-18make selinux_parse_opts_str() staticAdrian Bunk1-1/+2
This patch makes the needlessly global selinux_parse_opts_str() static. Signed-off-by: Adrian Bunk <> Acked-by: Eric Paris <> Signed-off-by: James Morris <>
2008-03-13smackfs: do not trust `count' in inodes write()sAhmed S. Darwish2-19/+20
Smackfs write() implementation does not put a higher bound on the number of bytes to copy from user-space. This may lead to a DOS attack if a malicious `count' field is given. Assure that given `count' is exactly the length needed for a /smack/load rule. In case of /smack/cipso where the length is relative, assure that `count' does not exceed the size needed for a buffer representing maximum possible number of CIPSO 2.2 categories. Signed-off-by: Ahmed S. Darwish <> Acked-by: Casey Schaufler <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2008-03-06LSM/SELinux: Interfaces to allow FS to control mount optionsEric Paris5-107/+128
Introduce new LSM interfaces to allow an FS to deal with their own mount options. This includes a new string parsing function exported from the LSM that an FS can use to get a security data blob and a new security data blob. This is particularly useful for an FS which uses binary mount data, like NFS, which does not pass strings into the vfs to be handled by the loaded LSM. Also fix a BUG() in both SELinux and SMACK when dealing with binary mount data. If the binary mount data is less than one page the copy_page() in security_sb_copy_data() can cause an illegal page fault and boom. Remove all NFSisms from the SELinux code since they were broken by past NFS changes. Signed-off-by: Eric Paris <> Acked-by: Stephen Smalley <> Acked-by: Casey Schaufler <> Signed-off-by: James Morris <>
2008-02-23Smack: update for file capabilitiesCasey Schaufler1-13/+74
Update the Smack LSM to allow the registration of the capability "module" as a secondary LSM. Integrate the new hooks required for file based capabilities. Signed-off-by: Casey Schaufler <> Cc: Serge Hallyn <> Cc: Stephen Smalley <> Cc: Paul Moore <> Cc: James Morris <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2008-02-23file capabilities: simplify signal checkSerge E. Hallyn1-1/+1
Simplify the uid equivalence check in cap_task_kill(). Anyone can kill a process owned by the same uid. Without this patch wireshark is reported to fail. Signed-off-by: Serge E. Hallyn <> Signed-off-by: Andrew G. Morgan <> Cc: <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2008-02-19Smack: unlabeled outgoing ambient packetsCasey Schaufler2-23/+74
Smack uses CIPSO labeling, but allows for unlabeled packets by specifying an "ambient" label that is applied to incoming unlabeled packets. Because the other end of the connection may dislike IP options, and ssh is one know application that behaves thus, it is prudent to respond in kind. This patch changes the network labeling behavior such that an outgoing packet that would be given a CIPSO label that matches the ambient label is left unlabeled. An "unlbl" domain is added and the netlabel defaulting mechanism invoked rather than assuming that everything is CIPSO. Locking has been added around changes to the ambient label as the mechanisms used to do so are more involved. Signed-off-by: Casey Schaufler <> Acked-by: Paul Moore <> Signed-off-by: Linus Torvalds <>
2008-02-14d_path: Use struct path in struct avc_audit_dataJan Blunck3-25/+24
audit_log_d_path() is a d_path() wrapper that is used by the audit code. To use a struct path in audit_log_d_path() I need to embed it into struct avc_audit_data. [ coding-style fixes] Signed-off-by: Jan Blunck <> Acked-by: Christoph Hellwig <> Cc: Al Viro <> Cc: "J. Bruce Fields" <> Cc: Neil Brown <> Cc: Stephen Smalley <> Cc: James Morris <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2008-02-14Embed a struct path into struct nameidata instead of nd->{dentry,mnt}Jan Blunck2-3/+3
This is the central patch of a cleanup series. In most cases there is no good reason why someone would want to use a dentry for itself. This series reflects that fact and embeds a struct path into nameidata. Together with the other patches of this series - it enforced the correct order of getting/releasing the reference count on <dentry,vfsmount> pairs - it prepares the VFS for stacking support since it is essential to have a struct path in every place where the stack can be traversed - it reduces the overall code size: without patch series: text data bss dec hex filename 5321639 858418 715768 6895825 6938d1 vmlinux with patch series: text data bss dec hex filename 5320026 858418 715768 6894212 693284 vmlinux This patch: Switch from nd->{dentry,mnt} to nd->path.{dentry,mnt} everywhere. [ coding-style fixes] [ fix cifs] [ fix smack] Signed-off-by: Jan Blunck <> Signed-off-by: Andreas Gruenbacher <> Acked-by: Christoph Hellwig <> Cc: Al Viro <> Cc: Casey Schaufler <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2008-02-13Smack: check for 'struct socket' with NULL skAhmed S. Darwish1-4/+5
There's a small problem with smack and NFS. A similar report was also sent here: I've also added similar checks in inode_{get/set}security(). Cheating from SELinux post_create_socket(), it does the same. [ remove uneeded BUG_ON()] Signed-off-by: Ahmed S. Darwish <> Acked-by: Casey Schaufler <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2008-02-11selinux: support 64-bit capabilitiesStephen Smalley5-2/+27
Fix SELinux to handle 64-bit capabilities correctly, and to catch future extensions of capabilities beyond 64 bits to ensure that SELinux is properly updated. Signed-off-by: Stephen Smalley <> Signed-off-by: James Morris <>
2008-02-07Convert ERR_PTR(PTR_ERR(p)) instances to ERR_CAST(p)David Howells4-4/+4
Convert instances of ERR_PTR(PTR_ERR(p)) to ERR_CAST(p) using: perl -spi -e 's/ERR_PTR[(]PTR_ERR[(](.*)[)][)]/ERR_CAST(\1)/' `grep -rl 'ERR_PTR[(]*PTR_ERR' fs crypto net security` Signed-off-by: David Howells <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2008-02-06SELinux: Remove security_get_policycaps()Paul Moore2-34/+0
The security_get_policycaps() functions has a couple of bugs in it and it isn't currently used by any in-tree code, so get rid of it and all of it's bugginess. Signed-off-by: Paul Moore <> Signed-off-by: James Morris <jmorris@localhost.localdomain>
2008-02-06security: allow Kconfig to set default mmap_min_addr protectionEric Paris2-1/+21
Since it was decided that low memory protection from userspace couldn't be turned on by default add a Kconfig option to allow users/distros to set a default at compile time. This value is still tunable after boot in /proc/sys/vm/mmap_min_addr Discussion: Signed-off-by: Eric Paris <> Signed-off-by: James Morris <>
2008-02-05Smack: Simplified Mandatory Access Control KernelCasey Schaufler8-0/+4095
Smack is the Simplified Mandatory Access Control Kernel. Smack implements mandatory access control (MAC) using labels attached to tasks and data containers, including files, SVIPC, and other tasks. Smack is a kernel based scheme that requires an absolute minimum of application support and a very small amount of configuration data. Smack uses extended attributes and provides a set of general mount options, borrowing technics used elsewhere. Smack uses netlabel for CIPSO labeling. Smack provides a pseudo-filesystem smackfs that is used for manipulation of system Smack attributes. The patch, patches for ls and sshd, a README, a startup script, and x86 binaries for ls and sshd are also available on Development has been done using Fedora Core 7 in a virtual machine environment and on an old Sony laptop. Smack provides mandatory access controls based on the label attached to a task and the label attached to the object it is attempting to access. Smack labels are deliberately short (1-23 characters) text strings. Single character labels using special characters are reserved for system use. The only operation applied to Smack labels is equality comparison. No wildcards or expressions, regular or otherwise, are used. Smack labels are composed of printable characters and may not include "/". A file always gets the Smack label of the task that created it. Smack defines and uses these labels: "*" - pronounced "star" "_" - pronounced "floor" "^" - pronounced "hat" "?" - pronounced "huh" The access rules enforced by Smack are, in order: 1. Any access requested by a task labeled "*" is denied. 2. A read or execute access requested by a task labeled "^" is permitted. 3. A read or execute access requested on an object labeled "_" is permitted. 4. Any access requested on an object labeled "*" is permitted. 5. Any access requested by a task on an object with the same label is permitted. 6. Any access requested that is explicitly defined in the loaded rule set is permitted. 7. Any other access is denied. Rules may be explicitly defined by writing subject,object,access triples to /smack/load. Smack rule sets can be easily defined that describe Bell&LaPadula sensitivity, Biba integrity, and a variety of interesting configurations. Smack rule sets can be modified on the fly to accommodate changes in the operating environment or even the time of day. Some practical use cases: Hierarchical levels. The less common of the two usual uses for MLS systems is to define hierarchical levels, often unclassified, confidential, secret, and so on. To set up smack to support this, these rules could be defined: C Unclass rx S C rx S Unclass rx TS S rx TS C rx TS Unclass rx A TS process can read S, C, and Unclass data, but cannot write it. An S process can read C and Unclass. Note that specifying that TS can read S and S can read C does not imply TS can read C, it has to be explicitly stated. Non-hierarchical categories. This is the more common of the usual uses for an MLS system. Since the default rule is that a subject cannot access an object with a different label no access rules are required to implement compartmentalization. A case that the Bell & LaPadula policy does not allow is demonstrated with this Smack access rule: A case that Bell&LaPadula does not allow that Smack does: ESPN ABC r ABC ESPN r On my portable video device I have two applications, one that shows ABC programming and the other ESPN programming. ESPN wants to show me sport stories that show up as news, and ABC will only provide minimal information about a sports story if ESPN is covering it. Each side can look at the other's info, neither can change the other. Neither can see what FOX is up to, which is just as well all things considered. Another case that I especially like: SatData Guard w Guard Publish w A program running with the Guard label opens a UDP socket and accepts messages sent by a program running with a SatData label. The Guard program inspects the message to ensure it is wholesome and if it is sends it to a program running with the Publish label. This program then puts the information passed in an appropriate place. Note that the Guard program cannot write to a Publish file system object because file system semanitic require read as well as write. The four cases (categories, levels, mutual read, guardbox) here are all quite real, and problems I've been asked to solve over the years. The first two are easy to do with traditonal MLS systems while the last two you can't without invoking privilege, at least for a while. Signed-off-by: Casey Schaufler <> Cc: Joshua Brindle <> Cc: Paul Moore <> Cc: Stephen Smalley <> Cc: Chris Wright <> Cc: James Morris <> Cc: "Ahmed S. Darwish" <> Cc: Andrew G. Morgan <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2008-02-05capabilities: introduce per-process capability bounding setSerge E. Hallyn1-17/+27
The capability bounding set is a set beyond which capabilities cannot grow. Currently cap_bset is per-system. It can be manipulated through sysctl, but only init can add capabilities. Root can remove capabilities. By default it includes all caps except CAP_SETPCAP. This patch makes the bounding set per-process when file capabilities are enabled. It is inherited at fork from parent. Noone can add elements, CAP_SETPCAP is required to remove them. One example use of this is to start a safer container. For instance, until device namespaces or per-container device whitelists are introduced, it is best to take CAP_MKNOD away from a container. The bounding set will not affect pP and pE immediately. It will only affect pP' and pE' after subsequent exec()s. It also does not affect pI, and exec() does not constrain pI'. So to really start a shell with no way of regain CAP_MKNOD, you would do prctl(PR_CAPBSET_DROP, CAP_MKNOD); cap_t cap = cap_get_proc(); cap_value_t caparray[1]; caparray[0] = CAP_MKNOD; cap_set_flag(cap, CAP_INHERITABLE, 1, caparray, CAP_DROP); cap_set_proc(cap); cap_free(cap); The following test program will get and set the bounding set (but not pI). For instance ./bset get (lists capabilities in bset) ./bset drop cap_net_raw (starts shell with new bset) (use capset, setuid binary, or binary with file capabilities to try to increase caps) ************************************************************ cap_bound.c ************************************************************ #include <sys/prctl.h> #include <linux/capability.h> #include <sys/types.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #ifndef PR_CAPBSET_READ #define PR_CAPBSET_READ 23 #endif #ifndef PR_CAPBSET_DROP #define PR_CAPBSET_DROP 24 #endif int usage(char *me) { printf("Usage: %s get\n", me); printf(" %s drop <capability>\n", me); return 1; } #define numcaps 32 char *captable[numcaps] = { "cap_chown", "cap_dac_override", "cap_dac_read_search", "cap_fowner", "cap_fsetid", "cap_kill", "cap_setgid", "cap_setuid", "cap_setpcap", "cap_linux_immutable", "cap_net_bind_service", "cap_net_broadcast", "cap_net_admin", "cap_net_raw", "cap_ipc_lock", "cap_ipc_owner", "cap_sys_module", "cap_sys_rawio", "cap_sys_chroot", "cap_sys_ptrace", "cap_sys_pacct", "cap_sys_admin", "cap_sys_boot", "cap_sys_nice", "cap_sys_resource", "cap_sys_time", "cap_sys_tty_config", "cap_mknod", "cap_lease", "cap_audit_write", "cap_audit_control", "cap_setfcap" }; int getbcap(void) { int comma=0; unsigned long i; int ret; printf("i know of %d capabilities\n", numcaps); printf("capability bounding set:"); for (i=0; i<numcaps; i++) { ret = prctl(PR_CAPBSET_READ, i); if (ret < 0) perror("prctl"); else if (ret==1) printf("%s%s", (comma++) ? ", " : " ", captable[i]); } printf("\n"); return 0; } int capdrop(char *str) { unsigned long i; int found=0; for (i=0; i<numcaps; i++) { if (strcmp(captable[i], str) == 0) { found=1; break; } } if (!found) return 1; if (prctl(PR_CAPBSET_DROP, i)) { perror("prctl"); return 1; } return 0; } int main(int argc, char *argv[]) { if (argc<2) return usage(argv[0]); if (strcmp(argv[1], "get")==0) return getbcap(); if (strcmp(argv[1], "drop")!=0 || argc<3) return usage(argv[0]); if (capdrop(argv[2])) { printf("unknown capability\n"); return 1; } return execl("/bin/bash", "/bin/bash", NULL); } ************************************************************ [ fix typo] Signed-off-by: Serge E. Hallyn <> Signed-off-by: Andrew G. Morgan <> Cc: Stephen Smalley <> Cc: James Morris <> Cc: Chris Wright <> Cc: Casey Schaufler <>a Signed-off-by: "Serge E. Hallyn" <> Tested-by: Jiri Slaby <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2008-02-05Add 64-bit capability support to the kernelAndrew Morgan2-36/+68
The patch supports legacy (32-bit) capability userspace, and where possible translates 32-bit capabilities to/from userspace and the VFS to 64-bit kernel space capabilities. If a capability set cannot be compressed into 32-bits for consumption by user space, the system call fails, with -ERANGE. FWIW libcap-2.00 supports this change (and earlier capability formats) [ coding-syle fixes] [ use get_task_comm()] [ build fix] [ do not initialise statics to 0 or NULL] [ unused var] [ export __cap_ symbols] Signed-off-by: Andrew G. Morgan <> Cc: Stephen Smalley <> Acked-by: Serge Hallyn <> Cc: Chris Wright <> Cc: James Morris <> Cc: Casey Schaufler <> Signed-off-by: Erez Zadok <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2008-02-05revert "capabilities: clean up file capability reading"Andrew Morton1-15/+8
Revert b68680e4731abbd78863063aaa0dca2a6d8cc723 to make way for the next patch: "Add 64-bit capability support to the kernel". We want to keep the[] structure, using two 'data's for 64-bit caps (and later three for 96-bit caps), whereas b68680e4731abbd78863063aaa0dca2a6d8cc723 had gotten rid of the 'data' struct made its members inline. The 64-bit caps patch keeps the stack abuse fix at get_file_caps(), which was the more important part of that patch. [ coding-style fixes] Cc: Stephen Smalley <> Cc: Serge Hallyn <> Cc: Chris Wright <> Cc: James Morris <> Cc: Casey Schaufler <> Cc: Andrew Morgan <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2008-02-05VFS/Security: Rework inode_getsecurity and callers to return resulting bufferDavid P. Quigley3-31/+18
This patch modifies the interface to inode_getsecurity to have the function return a buffer containing the security blob and its length via parameters instead of relying on the calling function to give it an appropriately sized buffer. Security blobs obtained with this function should be freed using the release_secctx LSM hook. This alleviates the problem of the caller having to guess a length and preallocate a buffer for this function allowing it to be used elsewhere for Labeled NFS. The patch also removed the unused err parameter. The conversion is similar to the one performed by Al Viro for the security_getprocattr hook. Signed-off-by: David P. Quigley <> Cc: Stephen Smalley <> Cc: Chris Wright <> Acked-by: James Morris <> Acked-by: Serge Hallyn <> Cc: Casey Schaufler <> Cc: Al Viro <> Cc: Christoph Hellwig <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
2008-02-01[AUDIT] add session id to audit messagesEric Paris2-9/+13
In order to correlate audit records to an individual login add a session id. This is incremented every time a user logs in and is included in almost all messages which currently output the auid. The field is labeled ses= or oses= Signed-off-by: Eric Paris <>
2008-02-01[PATCH] switch audit_get_loginuid() to task_struct *Al Viro2-4/+4
all callers pass something->audit_context Signed-off-by: Al Viro <>
2008-01-31[SELinux]: Fix double free in selinux_netlbl_sock_setsid()Paul Moore1-1/+0
As pointed out by Adrian Bunk, commit 45c950e0f839fded922ebc0bfd59b1081cc71b70 ("fix memory leak in netlabel code") caused a double-free when security_netlbl_sid_to_secattr() fails. This patch fixes this by removing the netlbl_secattr_destroy() call from that function since we are already releasing the secattr memory in selinux_netlbl_sock_setsid(). Signed-off-by: Paul Moore <> Signed-off-by: David S. Miller <>
2008-01-30security: compile capabilities by
Capabilities have long been the default when CONFIG_SECURITY=n, and its help text suggests turning it on when CONFIG_SECURITY=y. But it is set to default n. Default it to y instead. Signed-off-by: Serge Hallyn <> Acked-by: Matt LaPlante <> Signed-off-by: James Morris <>
2008-01-30selinux: make selinux_set_mnt_opts() staticAdrian Bunk1-2/+2
selinux_set_mnt_opts() can become static. Signed-off-by: Adrian Bunk <> Signed-off-by: James Morris <>
2008-01-30SELinux: Add warning messages on network denial due to errorPaul Moore3-8/+40
Currently network traffic can be sliently dropped due to non-avc errors which can lead to much confusion when trying to debug the problem. This patch adds warning messages so that when these events occur there is a user visible notification. Signed-off-by: Paul Moore <> Signed-off-by: James Morris <>
2008-01-30SELinux: Add network ingress and egress control permission checksPaul Moore1-122/+280
This patch implements packet ingress/egress controls for SELinux which allow SELinux security policy to control the flow of all IPv4 and IPv6 packets into and out of the system. Currently SELinux does not have proper control over forwarded packets and this patch corrects this problem. Special thanks to Venkat Yekkirala <> whose earlier work on this topic eventually led to this patch. Signed-off-by: Paul Moore <> Signed-off-by: James Morris <>
2008-01-30SELinux: Allow NetLabel to directly cache SIDsPaul Moore5-134/+55
Now that the SELinux NetLabel "base SID" is always the netmsg initial SID we can do a big optimization - caching the SID and not just the MLS attributes. This not only saves a lot of per-packet memory allocations and copies but it has a nice side effect of removing a chunk of code. Signed-off-by: Paul Moore <> Signed-off-by: James Morris <>
2008-01-30SELinux: Enable dynamic enable/disable of the network access checksPaul Moore4-13/+83
This patch introduces a mechanism for checking when labeled IPsec or SECMARK are in use by keeping introducing a configuration reference counter for each subsystem. In the case of labeled IPsec, whenever a labeled SA or SPD entry is created the labeled IPsec/XFRM reference count is increased and when the entry is removed it is decreased. In the case of SECMARK, when a SECMARK target is created the reference count is increased and later decreased when the target is removed. These reference counters allow SELinux to quickly determine if either of these subsystems are enabled. NetLabel already has a similar mechanism which provides the netlbl_enabled() function. This patch also renames the selinux_relabel_packet_permission() function to selinux_secmark_relabel_packet_permission() as the original name and description were misleading in that they referenced a single packet label which is not the case. Signed-off-by: Paul Moore <> Signed-off-by: James Morris <>
2008-01-30SELinux: Better integration between peer labeling subsystemsPaul Moore6-100/+208
Rework the handling of network peer labels so that the different peer labeling subsystems work better together. This includes moving both subsystems to a single "peer" object class which involves not only changes to the permission checks but an improved method of consolidating multiple packet peer labels. As part of this work the inbound packet permission check code has been heavily modified to handle both the old and new behavior in as sane a fashion as possible. Signed-off-by: Paul Moore <> Signed-off-by: James Morris <>
2008-01-30SELinux: Add a new peer class and permissions to the Flask definitionsPaul Moore4-0/+26
Add additional Flask definitions to support the new "peer" object class and additional permissions to the netif, node, and packet object classes. Also, bring the kernel Flask definitions up to date with the Fedora SELinux policies by adding the "flow_in" and "flow_out" permissions to the "packet" class. Signed-off-by: Paul Moore <> Signed-off-by: James Morris <>
2008-01-30SELinux: Add a capabilities bitmap to SELinux policy version 22Paul Moore6-8/+185
Add a new policy capabilities bitmap to SELinux policy version 22. This bitmap will enable the security server to query the policy to determine which features it supports. Signed-off-by: Paul Moore <> Signed-off-by: James Morris <>
2008-01-30SELinux: Add a network node caching mechanism similar to the sel_netif_*() ↵Paul Moore5-17/+416
functions This patch adds a SELinux IP address/node SID caching mechanism similar to the sel_netif_*() functions. The node SID queries in the SELinux hooks files are also modified to take advantage of this new functionality. In addition, remove the address length information from the sk_buff parsing routines as it is redundant since we already have the address family. Signed-off-by: Paul Moore <> Signed-off-by: James Morris <>
2008-01-30SELinux: Only store the network interface's ifindexPaul Moore3-6/+15
Instead of storing the packet's network interface name store the ifindex. This allows us to defer the need to lookup the net_device structure until the audit record is generated meaning that in the majority of cases we never need to bother with this at all. Signed-off-by: Paul Moore <> Signed-off-by: James Morris <>
2008-01-30SELinux: Convert the netif code to use ifindex valuesPaul Moore6-125/+155
The current SELinux netif code requires the caller have a valid net_device struct pointer to lookup network interface information. However, we don't always have a valid net_device pointer so convert the netif code to use the ifindex values we always have as part of the sk_buff. This patch also removes the default message SID from the network interface record, it is not being used and therefore is "dead code". Signed-off-by: Paul Moore <> Signed-off-by: James Morris <>
2008-01-30NetLabel: Add IP address family information to the netlbl_skbuff_getattr() ↵Paul Moore3-15/+38
function In order to do any sort of IP header inspection of incoming packets we need to know which address family, AF_INET/AF_INET6/etc., it belongs to and since the sk_buff structure does not store this information we need to pass along the address family separate from the packet itself. Signed-off-by: Paul Moore <> Signed-off-by: James Morris <>
2008-01-30NetLabel: Add secid token support to the NetLabel secattr structPaul Moore2-6/+9
This patch adds support to the NetLabel LSM secattr struct for a secid token and a type field, paving the way for full LSM/SELinux context support and "static" or "fallback" labels. In addition, this patch adds a fair amount of documentation to the core NetLabel structures used as part of the NetLabel kernel API. Signed-off-by: Paul Moore <> Signed-off-by: James Morris <>
2008-01-28[NETFILTER]: Introduce NF_INET_ hook valuesPatrick McHardy1-2/+2
The IPv4 and IPv6 hook values are identical, yet some code tries to figure out the "correct" value by looking at the address family. Introduce NF_INET_* values for both IPv4 and IPv6. The old values are kept in a #ifndef __KERNEL__ section for userspace compatibility. Signed-off-by: Patrick McHardy <> Acked-by: Herbert Xu <> Signed-off-by: David S. Miller <>
2008-01-26selinux: fix labeling of /proc/net inodesStephen Smalley1-0/+3
The proc net rewrite had a side effect on selinux, leading it to mislabel the /proc/net inodes, thereby leading to incorrect denials. Fix security_genfs_sid to ignore extra leading / characters in the path supplied by selinux_proc_get_sid since we now get "//net/..." rather than "/net/...". Signed-off-by: Stephen Smalley <> Signed-off-by: James Morris <>
2008-01-25Merge branch 'for-linus' of ↵Linus Torvalds8-277/+564
git:// * 'for-linus' of git:// selinux: make mls_compute_sid always polyinstantiate security/selinux: constify function pointer tables and fields security: add a secctx_to_secid() hook security: call security_file_permission from rw_verify_area security: remove security_sb_post_mountroot hook Security: remove security.h include from mm.h Security: remove security_file_mmap hook sparse-warnings (NULL as 0). Security: add get, set, and cloning of superblock security information security/selinux: Add missing "space"
2008-01-24Kobject: convert remaining kobject_unregister() to kobject_put()Greg Kroah-Hartman1-1/+1
There is no need for kobject_unregister() anymore, thanks to Kay's kobject cleanup changes, so replace all instances of it with kobject_put(). Cc: Kay Sievers <> Signed-off-by: Greg Kroah-Hartman <>
2008-01-24kobject: convert kernel_kset to be a kobjectGreg Kroah-Hartman1-1/+1
kernel_kset does not need to be a kset, but a much simpler kobject now that we have kobj_attributes. We also rename kernel_kset to kernel_kobj to catch all users of this symbol with a build error instead of an easy-to-ignore build warning. Cc: Kay Sievers <> Signed-off-by: Greg Kroah-Hartman <>
2008-01-24kset: convert kernel_subsys to use kset_createGreg Kroah-Hartman1-1/+1
Dynamically create the kset instead of declaring it statically. We also rename kernel_subsys to kernel_kset to catch all users of this symbol with a build error instead of an easy-to-ignore build warning. Cc: Kay Sievers <> Signed-off-by: Greg Kroah-Hartman <>
2008-01-24kobject: convert securityfs to use kobject_createGreg Kroah-Hartman1-6/+5
We don't need a kset here, a simple kobject will do just fine, so dynamically create the kobject and use it. Cc: Kay Sievers <> Acked-by: Chris Wright <> Signed-off-by: Greg Kroah-Hartman <>
2008-01-24kobject: remove struct kobj_type from struct ksetGreg Kroah-Hartman1-2/+2
We don't need a "default" ktype for a kset. We should set this explicitly every time for each kset. This change is needed so that we can make ksets dynamic, and cleans up one of the odd, undocumented assumption that the kset/kobject/ktype model has. This patch is based on a lot of help from Kay Sievers. Nasty bug in the block code was found by Dave Young <> Cc: Kay Sievers <> Cc: Dave Young <> Signed-off-by: Greg Kroah-Hartman <>