diff options
| author | James Morris <jmorris@redhat.com> | 2004-05-08 01:05:57 -0700 |
|---|---|---|
| committer | David S. Miller <davem@nuts.davemloft.net> | 2004-05-08 01:05:57 -0700 |
| commit | 398b3c447d458db2a7972603b3c36ceb97eb976a (patch) | |
| tree | e9f6271bee7cf0099a04a18f2f453eeab62e5be7 /net/socket.c | |
| parent | e2943dca2d5b67e9578111986495483fe720d58b (diff) | |
[NET]: Add sock_create_lite()
The purpose of this is to allow sockets created by the kernel in this way
to be passed through the LSM socket creation hooks and be labeled and
mediated in the same manner as other sockets.
This patches addresses a class of potential issues with LSMs, where such
sockets will not be labeled correctly (if at all), or mediated during
creation. Under SELinux, it fixes a specific bug where RPC sockets
created by the kernel during TCP NFS serving are unlabeled.
Diffstat (limited to 'net/socket.c')
| -rw-r--r-- | net/socket.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/net/socket.c b/net/socket.c index f4ef38250280..f8d18942abd9 100644 --- a/net/socket.c +++ b/net/socket.c @@ -457,7 +457,7 @@ struct socket *sockfd_lookup(int fd, int *err) * NULL is returned. */ -struct socket *sock_alloc(void) +static struct socket *sock_alloc(void) { struct inode * inode; struct socket * sock; @@ -840,6 +840,27 @@ static int sock_ioctl(struct inode *inode, struct file *file, unsigned int cmd, return err; } +int sock_create_lite(int family, int type, int protocol, struct socket **res) +{ + int err; + struct socket *sock = NULL; + + err = security_socket_create(family, type, protocol, 1); + if (err) + goto out; + + sock = sock_alloc(); + if (!sock) { + err = -ENOMEM; + goto out; + } + + security_socket_post_create(sock, family, type, protocol, 1); + sock->type = type; +out: + *res = sock; + return err; +} /* No kernel lock held - perfect */ static unsigned int sock_poll(struct file *file, poll_table * wait) @@ -2001,6 +2022,7 @@ EXPORT_SYMBOL(sock_alloc); EXPORT_SYMBOL(sock_alloc_inode); EXPORT_SYMBOL(sock_create); EXPORT_SYMBOL(sock_create_kern); +EXPORT_SYMBOL(sock_create_lite); EXPORT_SYMBOL(sock_map_fd); EXPORT_SYMBOL(sock_recvmsg); EXPORT_SYMBOL(sock_register); |
