Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 202974
b: refs/heads/master
c: 3f551f9
h: refs/heads/master
v: v3
  • Loading branch information
Eric W. Biederman authored and David S. Miller committed Jun 16, 2010
1 parent 76bb918 commit d5f199f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5c1469de7545a35a16ff2b902e217044a7d2f8a5
refs/heads/master: 3f551f9436c05a3b5eccdd6e94733df5bb98d2a5
5 changes: 5 additions & 0 deletions trunk/include/linux/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ struct __kernel_sockaddr_storage {
#include <linux/types.h> /* pid_t */
#include <linux/compiler.h> /* __user */

struct pid;
struct cred;

#define __sockaddr_check_size(size) \
BUILD_BUG_ON(((size) > sizeof(struct __kernel_sockaddr_storage)))

Expand Down Expand Up @@ -309,6 +312,8 @@ struct ucred {
#define IPX_TYPE 1

#ifdef __KERNEL__
extern void cred_to_ucred(struct pid *pid, const struct cred *cred, struct ucred *ucred);

extern int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len);
extern int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
int offset, int len);
Expand Down
14 changes: 14 additions & 0 deletions trunk/net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
#include <linux/tcp.h>
#include <linux/init.h>
#include <linux/highmem.h>
#include <linux/user_namespace.h>

#include <asm/uaccess.h>
#include <asm/system.h>
Expand Down Expand Up @@ -749,6 +750,19 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
EXPORT_SYMBOL(sock_setsockopt);


void cred_to_ucred(struct pid *pid, const struct cred *cred,
struct ucred *ucred)
{
ucred->pid = pid_vnr(pid);
ucred->uid = ucred->gid = -1;
if (cred) {
struct user_namespace *current_ns = current_user_ns();

ucred->uid = user_ns_map_uid(current_ns, cred, cred->euid);
ucred->gid = user_ns_map_gid(current_ns, cred, cred->egid);
}
}

int sock_getsockopt(struct socket *sock, int level, int optname,
char __user *optval, int __user *optlen)
{
Expand Down

0 comments on commit d5f199f

Please sign in to comment.