aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/audit.h12
-rw-r--r--include/linux/inet_diag.h1
-rw-r--r--include/linux/init_task.h2
-rw-r--r--include/linux/ipc.h9
-rw-r--r--include/linux/key.h9
-rw-r--r--include/linux/loop.h2
-rw-r--r--include/linux/netlink.h1
-rw-r--r--include/linux/posix_acl.h8
-rw-r--r--include/linux/posix_acl_xattr.h18
-rw-r--r--include/linux/projid.h104
-rw-r--r--include/linux/quota.h136
-rw-r--r--include/linux/quotaops.h6
-rw-r--r--include/linux/sched.h2
-rw-r--r--include/linux/security.h6
-rw-r--r--include/linux/seq_file.h14
-rw-r--r--include/linux/tsacct_kern.h8
-rw-r--r--include/linux/tty.h4
-rw-r--r--include/linux/user_namespace.h3
18 files changed, 310 insertions, 35 deletions
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 36abf2aa7e68..12367cbadfe1 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -442,6 +442,8 @@ struct audit_krule {
442struct audit_field { 442struct audit_field {
443 u32 type; 443 u32 type;
444 u32 val; 444 u32 val;
445 kuid_t uid;
446 kgid_t gid;
445 u32 op; 447 u32 op;
446 char *lsm_str; 448 char *lsm_str;
447 void *lsm_rule; 449 void *lsm_rule;
@@ -525,7 +527,7 @@ static inline void audit_ptrace(struct task_struct *t)
525extern unsigned int audit_serial(void); 527extern unsigned int audit_serial(void);
526extern int auditsc_get_stamp(struct audit_context *ctx, 528extern int auditsc_get_stamp(struct audit_context *ctx,
527 struct timespec *t, unsigned int *serial); 529 struct timespec *t, unsigned int *serial);
528extern int audit_set_loginuid(uid_t loginuid); 530extern int audit_set_loginuid(kuid_t loginuid);
529#define audit_get_loginuid(t) ((t)->loginuid) 531#define audit_get_loginuid(t) ((t)->loginuid)
530#define audit_get_sessionid(t) ((t)->sessionid) 532#define audit_get_sessionid(t) ((t)->sessionid)
531extern void audit_log_task_context(struct audit_buffer *ab); 533extern void audit_log_task_context(struct audit_buffer *ab);
@@ -637,7 +639,7 @@ extern int audit_signals;
637#define audit_core_dumps(i) do { ; } while (0) 639#define audit_core_dumps(i) do { ; } while (0)
638#define audit_seccomp(i,s,c) do { ; } while (0) 640#define audit_seccomp(i,s,c) do { ; } while (0)
639#define auditsc_get_stamp(c,t,s) (0) 641#define auditsc_get_stamp(c,t,s) (0)
640#define audit_get_loginuid(t) (-1) 642#define audit_get_loginuid(t) (INVALID_UID)
641#define audit_get_sessionid(t) (-1) 643#define audit_get_sessionid(t) (-1)
642#define audit_log_task_context(b) do { ; } while (0) 644#define audit_log_task_context(b) do { ; } while (0)
643#define audit_ipc_obj(i) ((void)0) 645#define audit_ipc_obj(i) ((void)0)
@@ -700,10 +702,10 @@ extern void audit_log_secctx(struct audit_buffer *ab, u32 secid);
700extern int audit_update_lsm_rules(void); 702extern int audit_update_lsm_rules(void);
701 703
702 /* Private API (for audit.c only) */ 704 /* Private API (for audit.c only) */
703extern int audit_filter_user(struct netlink_skb_parms *cb); 705extern int audit_filter_user(void);
704extern int audit_filter_type(int type); 706extern int audit_filter_type(int type);
705extern int audit_receive_filter(int type, int pid, int uid, int seq, 707extern int audit_receive_filter(int type, int pid, int seq,
706 void *data, size_t datasz, uid_t loginuid, 708 void *data, size_t datasz, kuid_t loginuid,
707 u32 sessionid, u32 sid); 709 u32 sessionid, u32 sid);
708extern int audit_enabled; 710extern int audit_enabled;
709#else 711#else
diff --git a/include/linux/inet_diag.h b/include/linux/inet_diag.h
index f1362b5447fc..e788c186ed3a 100644
--- a/include/linux/inet_diag.h
+++ b/include/linux/inet_diag.h
@@ -159,6 +159,7 @@ struct inet_diag_handler {
159struct inet_connection_sock; 159struct inet_connection_sock;
160int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk, 160int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
161 struct sk_buff *skb, struct inet_diag_req_v2 *req, 161 struct sk_buff *skb, struct inet_diag_req_v2 *req,
162 struct user_namespace *user_ns,
162 u32 pid, u32 seq, u16 nlmsg_flags, 163 u32 pid, u32 seq, u16 nlmsg_flags,
163 const struct nlmsghdr *unlh); 164 const struct nlmsghdr *unlh);
164void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb, 165void inet_diag_dump_icsk(struct inet_hashinfo *h, struct sk_buff *skb,
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 89f1cb1056f0..6d087c5f57f7 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -92,7 +92,7 @@ extern struct group_info init_groups;
92 92
93#ifdef CONFIG_AUDITSYSCALL 93#ifdef CONFIG_AUDITSYSCALL
94#define INIT_IDS \ 94#define INIT_IDS \
95 .loginuid = -1, \ 95 .loginuid = INVALID_UID, \
96 .sessionid = -1, 96 .sessionid = -1,
97#else 97#else
98#define INIT_IDS 98#define INIT_IDS
diff --git a/include/linux/ipc.h b/include/linux/ipc.h
index 30e816148df4..ca833fdc3138 100644
--- a/include/linux/ipc.h
+++ b/include/linux/ipc.h
@@ -79,6 +79,7 @@ struct ipc_kludge {
79 79
80#ifdef __KERNEL__ 80#ifdef __KERNEL__
81#include <linux/spinlock.h> 81#include <linux/spinlock.h>
82#include <linux/uidgid.h>
82 83
83#define IPCMNI 32768 /* <= MAX_INT limit for ipc arrays (including sysctl changes) */ 84#define IPCMNI 32768 /* <= MAX_INT limit for ipc arrays (including sysctl changes) */
84 85
@@ -89,10 +90,10 @@ struct kern_ipc_perm
89 int deleted; 90 int deleted;
90 int id; 91 int id;
91 key_t key; 92 key_t key;
92 uid_t uid; 93 kuid_t uid;
93 gid_t gid; 94 kgid_t gid;
94 uid_t cuid; 95 kuid_t cuid;
95 gid_t cgid; 96 kgid_t cgid;
96 umode_t mode; 97 umode_t mode;
97 unsigned long seq; 98 unsigned long seq;
98 void *security; 99 void *security;
diff --git a/include/linux/key.h b/include/linux/key.h
index cef3b315ba7c..2393b1c040b6 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -24,6 +24,7 @@
24#include <linux/atomic.h> 24#include <linux/atomic.h>
25 25
26#ifdef __KERNEL__ 26#ifdef __KERNEL__
27#include <linux/uidgid.h>
27 28
28/* key handle serial number */ 29/* key handle serial number */
29typedef int32_t key_serial_t; 30typedef int32_t key_serial_t;
@@ -137,8 +138,8 @@ struct key {
137 time_t revoked_at; /* time at which key was revoked */ 138 time_t revoked_at; /* time at which key was revoked */
138 }; 139 };
139 time_t last_used_at; /* last time used for LRU keyring discard */ 140 time_t last_used_at; /* last time used for LRU keyring discard */
140 uid_t uid; 141 kuid_t uid;
141 gid_t gid; 142 kgid_t gid;
142 key_perm_t perm; /* access permissions */ 143 key_perm_t perm; /* access permissions */
143 unsigned short quotalen; /* length added to quota */ 144 unsigned short quotalen; /* length added to quota */
144 unsigned short datalen; /* payload data length 145 unsigned short datalen; /* payload data length
@@ -193,7 +194,7 @@ struct key {
193 194
194extern struct key *key_alloc(struct key_type *type, 195extern struct key *key_alloc(struct key_type *type,
195 const char *desc, 196 const char *desc,
196 uid_t uid, gid_t gid, 197 kuid_t uid, kgid_t gid,
197 const struct cred *cred, 198 const struct cred *cred,
198 key_perm_t perm, 199 key_perm_t perm,
199 unsigned long flags); 200 unsigned long flags);
@@ -262,7 +263,7 @@ extern int key_link(struct key *keyring,
262extern int key_unlink(struct key *keyring, 263extern int key_unlink(struct key *keyring,
263 struct key *key); 264 struct key *key);
264 265
265extern struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid, 266extern struct key *keyring_alloc(const char *description, kuid_t uid, kgid_t gid,
266 const struct cred *cred, 267 const struct cred *cred,
267 unsigned long flags, 268 unsigned long flags,
268 struct key *dest); 269 struct key *dest);
diff --git a/include/linux/loop.h b/include/linux/loop.h
index 11a41a8f08eb..9635116dd830 100644
--- a/include/linux/loop.h
+++ b/include/linux/loop.h
@@ -44,7 +44,7 @@ struct loop_device {
44 int lo_encrypt_key_size; 44 int lo_encrypt_key_size;
45 struct loop_func_table *lo_encryption; 45 struct loop_func_table *lo_encryption;
46 __u32 lo_init[2]; 46 __u32 lo_init[2];
47 uid_t lo_key_owner; /* Who set the key */ 47 kuid_t lo_key_owner; /* Who set the key */
48 int (*ioctl)(struct loop_device *, int cmd, 48 int (*ioctl)(struct loop_device *, int cmd,
49 unsigned long arg); 49 unsigned long arg);
50 50
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index f74dd133788f..c9fdde2bc73f 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -165,6 +165,7 @@ struct netlink_skb_parms {
165 struct ucred creds; /* Skb credentials */ 165 struct ucred creds; /* Skb credentials */
166 __u32 pid; 166 __u32 pid;
167 __u32 dst_group; 167 __u32 dst_group;
168 struct sock *ssk;
168}; 169};
169 170
170#define NETLINK_CB(skb) (*(struct netlink_skb_parms*)&((skb)->cb)) 171#define NETLINK_CB(skb) (*(struct netlink_skb_parms*)&((skb)->cb))
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 11bad91c4433..7931efe71175 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -36,7 +36,13 @@
36struct posix_acl_entry { 36struct posix_acl_entry {
37 short e_tag; 37 short e_tag;
38 unsigned short e_perm; 38 unsigned short e_perm;
39 unsigned int e_id; 39 union {
40 kuid_t e_uid;
41 kgid_t e_gid;
42#ifndef CONFIG_UIDGID_STRICT_TYPE_CHECKS
43 unsigned int e_id;
44#endif
45 };
40}; 46};
41 47
42struct posix_acl { 48struct posix_acl {
diff --git a/include/linux/posix_acl_xattr.h b/include/linux/posix_acl_xattr.h
index 6e53c34035cd..ad93ad0f1db0 100644
--- a/include/linux/posix_acl_xattr.h
+++ b/include/linux/posix_acl_xattr.h
@@ -52,7 +52,21 @@ posix_acl_xattr_count(size_t size)
52 return size / sizeof(posix_acl_xattr_entry); 52 return size / sizeof(posix_acl_xattr_entry);
53} 53}
54 54
55struct posix_acl *posix_acl_from_xattr(const void *value, size_t size); 55#ifdef CONFIG_FS_POSIX_ACL
56int posix_acl_to_xattr(const struct posix_acl *acl, void *buffer, size_t size); 56void posix_acl_fix_xattr_from_user(void *value, size_t size);
57void posix_acl_fix_xattr_to_user(void *value, size_t size);
58#else
59static inline void posix_acl_fix_xattr_from_user(void *value, size_t size)
60{
61}
62static inline void posix_acl_fix_xattr_to_user(void *value, size_t size)
63{
64}
65#endif
66
67struct posix_acl *posix_acl_from_xattr(struct user_namespace *user_ns,
68 const void *value, size_t size);
69int posix_acl_to_xattr(struct user_namespace *user_ns,
70 const struct posix_acl *acl, void *buffer, size_t size);
57 71
58#endif /* _POSIX_ACL_XATTR_H */ 72#endif /* _POSIX_ACL_XATTR_H */
diff --git a/include/linux/projid.h b/include/linux/projid.h
new file mode 100644
index 000000000000..36517b95be5c
--- /dev/null
+++ b/include/linux/projid.h
@@ -0,0 +1,104 @@
1#ifndef _LINUX_PROJID_H
2#define _LINUX_PROJID_H
3
4/*
5 * A set of types for the internal kernel types representing project ids.
6 *
7 * The types defined in this header allow distinguishing which project ids in
8 * the kernel are values used by userspace and which project id values are
9 * the internal kernel values. With the addition of user namespaces the values
10 * can be different. Using the type system makes it possible for the compiler
11 * to detect when we overlook these differences.
12 *
13 */
14#include <linux/types.h>
15
16struct user_namespace;
17extern struct user_namespace init_user_ns;
18
19typedef __kernel_uid32_t projid_t;
20
21#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
22
23typedef struct {
24 projid_t val;
25} kprojid_t;
26
27static inline projid_t __kprojid_val(kprojid_t projid)
28{
29 return projid.val;
30}
31
32#define KPROJIDT_INIT(value) (kprojid_t){ value }
33
34#else
35
36typedef projid_t kprojid_t;
37
38static inline projid_t __kprojid_val(kprojid_t projid)
39{
40 return projid;
41}
42
43#define KPROJIDT_INIT(value) ((kprojid_t) value )
44
45#endif
46
47#define INVALID_PROJID KPROJIDT_INIT(-1)
48#define OVERFLOW_PROJID 65534
49
50static inline bool projid_eq(kprojid_t left, kprojid_t right)
51{
52 return __kprojid_val(left) == __kprojid_val(right);
53}
54
55static inline bool projid_lt(kprojid_t left, kprojid_t right)
56{
57 return __kprojid_val(left) < __kprojid_val(right);
58}
59
60static inline bool projid_valid(kprojid_t projid)
61{
62 return !projid_eq(projid, INVALID_PROJID);
63}
64
65#ifdef CONFIG_USER_NS
66
67extern kprojid_t make_kprojid(struct user_namespace *from, projid_t projid);
68
69extern projid_t from_kprojid(struct user_namespace *to, kprojid_t projid);
70extern projid_t from_kprojid_munged(struct user_namespace *to, kprojid_t projid);
71
72static inline bool kprojid_has_mapping(struct user_namespace *ns, kprojid_t projid)
73{
74 return from_kprojid(ns, projid) != (projid_t)-1;
75}
76
77#else
78
79static inline kprojid_t make_kprojid(struct user_namespace *from, projid_t projid)
80{
81 return KPROJIDT_INIT(projid);
82}
83
84static inline projid_t from_kprojid(struct user_namespace *to, kprojid_t kprojid)
85{
86 return __kprojid_val(kprojid);
87}
88
89static inline projid_t from_kprojid_munged(struct user_namespace *to, kprojid_t kprojid)
90{
91 projid_t projid = from_kprojid(to, kprojid);
92 if (projid == (projid_t)-1)
93 projid = OVERFLOW_PROJID;
94 return projid;
95}
96
97static inline bool kprojid_has_mapping(struct user_namespace *ns, kprojid_t projid)
98{
99 return true;
100}
101
102#endif /* CONFIG_USER_NS */
103
104#endif /* _LINUX_PROJID_H */
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 524ede8a160a..dcd5721e626d 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -181,10 +181,135 @@ enum {
181#include <linux/dqblk_v2.h> 181#include <linux/dqblk_v2.h>
182 182
183#include <linux/atomic.h> 183#include <linux/atomic.h>
184#include <linux/uidgid.h>
185#include <linux/projid.h>
186
187#undef USRQUOTA
188#undef GRPQUOTA
189enum quota_type {
190 USRQUOTA = 0, /* element used for user quotas */
191 GRPQUOTA = 1, /* element used for group quotas */
192 PRJQUOTA = 2, /* element used for project quotas */
193};
184 194
185typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */ 195typedef __kernel_uid32_t qid_t; /* Type in which we store ids in memory */
186typedef long long qsize_t; /* Type in which we store sizes */ 196typedef long long qsize_t; /* Type in which we store sizes */
187 197
198struct kqid { /* Type in which we store the quota identifier */
199 union {
200 kuid_t uid;
201 kgid_t gid;
202 kprojid_t projid;
203 };
204 enum quota_type type; /* USRQUOTA (uid) or GRPQUOTA (gid) or PRJQUOTA (projid) */
205};
206
207extern bool qid_eq(struct kqid left, struct kqid right);
208extern bool qid_lt(struct kqid left, struct kqid right);
209extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
210extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
211extern bool qid_valid(struct kqid qid);
212
213/**
214 * make_kqid - Map a user-namespace, type, qid tuple into a kqid.
215 * @from: User namespace that the qid is in
216 * @type: The type of quota
217 * @qid: Quota identifier
218 *
219 * Maps a user-namespace, type qid tuple into a kernel internal
220 * kqid, and returns that kqid.
221 *
222 * When there is no mapping defined for the user-namespace, type,
223 * qid tuple an invalid kqid is returned. Callers are expected to
224 * test for and handle handle invalid kqids being returned.
225 * Invalid kqids may be tested for using qid_valid().
226 */
227static inline struct kqid make_kqid(struct user_namespace *from,
228 enum quota_type type, qid_t qid)
229{
230 struct kqid kqid;
231
232 kqid.type = type;
233 switch (type) {
234 case USRQUOTA:
235 kqid.uid = make_kuid(from, qid);
236 break;
237 case GRPQUOTA:
238 kqid.gid = make_kgid(from, qid);
239 break;
240 case PRJQUOTA:
241 kqid.projid = make_kprojid(from, qid);
242 break;
243 default:
244 BUG();
245 }
246 return kqid;
247}
248
249/**
250 * make_kqid_invalid - Explicitly make an invalid kqid
251 * @type: The type of quota identifier
252 *
253 * Returns an invalid kqid with the specified type.
254 */
255static inline struct kqid make_kqid_invalid(enum quota_type type)
256{
257 struct kqid kqid;
258
259 kqid.type = type;
260 switch (type) {
261 case USRQUOTA:
262 kqid.uid = INVALID_UID;
263 break;
264 case GRPQUOTA:
265 kqid.gid = INVALID_GID;
266 break;
267 case PRJQUOTA:
268 kqid.projid = INVALID_PROJID;
269 break;
270 default:
271 BUG();
272 }
273 return kqid;
274}
275
276/**
277 * make_kqid_uid - Make a kqid from a kuid
278 * @uid: The kuid to make the quota identifier from
279 */
280static inline struct kqid make_kqid_uid(kuid_t uid)
281{
282 struct kqid kqid;
283 kqid.type = USRQUOTA;
284 kqid.uid = uid;
285 return kqid;
286}
287
288/**
289 * make_kqid_gid - Make a kqid from a kgid
290 * @gid: The kgid to make the quota identifier from
291 */
292static inline struct kqid make_kqid_gid(kgid_t gid)
293{
294 struct kqid kqid;
295 kqid.type = GRPQUOTA;
296 kqid.gid = gid;
297 return kqid;
298}
299
300/**
301 * make_kqid_projid - Make a kqid from a projid
302 * @projid: The kprojid to make the quota identifier from
303 */
304static inline struct kqid make_kqid_projid(kprojid_t projid)
305{
306 struct kqid kqid;
307 kqid.type = PRJQUOTA;
308 kqid.projid = projid;
309 return kqid;
310}
311
312
188extern spinlock_t dq_data_lock; 313extern spinlock_t dq_data_lock;
189 314
190/* Maximal numbers of writes for quota operation (insert/delete/update) 315/* Maximal numbers of writes for quota operation (insert/delete/update)
@@ -294,10 +419,9 @@ struct dquot {
294 atomic_t dq_count; /* Use count */ 419 atomic_t dq_count; /* Use count */
295 wait_queue_head_t dq_wait_unused; /* Wait queue for dquot to become unused */ 420 wait_queue_head_t dq_wait_unused; /* Wait queue for dquot to become unused */
296 struct super_block *dq_sb; /* superblock this applies to */ 421 struct super_block *dq_sb; /* superblock this applies to */
297 unsigned int dq_id; /* ID this applies to (uid, gid) */ 422 struct kqid dq_id; /* ID this applies to (uid, gid, projid) */
298 loff_t dq_off; /* Offset of dquot on disk */ 423 loff_t dq_off; /* Offset of dquot on disk */
299 unsigned long dq_flags; /* See DQ_* */ 424 unsigned long dq_flags; /* See DQ_* */
300 short dq_type; /* Type of quota */
301 struct mem_dqblk dq_dqb; /* Diskquota usage */ 425 struct mem_dqblk dq_dqb; /* Diskquota usage */
302}; 426};
303 427
@@ -336,8 +460,8 @@ struct quotactl_ops {
336 int (*quota_sync)(struct super_block *, int); 460 int (*quota_sync)(struct super_block *, int);
337 int (*get_info)(struct super_block *, int, struct if_dqinfo *); 461 int (*get_info)(struct super_block *, int, struct if_dqinfo *);
338 int (*set_info)(struct super_block *, int, struct if_dqinfo *); 462 int (*set_info)(struct super_block *, int, struct if_dqinfo *);
339 int (*get_dqblk)(struct super_block *, int, qid_t, struct fs_disk_quota *); 463 int (*get_dqblk)(struct super_block *, struct kqid, struct fs_disk_quota *);
340 int (*set_dqblk)(struct super_block *, int, qid_t, struct fs_disk_quota *); 464 int (*set_dqblk)(struct super_block *, struct kqid, struct fs_disk_quota *);
341 int (*get_xstate)(struct super_block *, struct fs_quota_stat *); 465 int (*get_xstate)(struct super_block *, struct fs_quota_stat *);
342 int (*set_xstate)(struct super_block *, unsigned int, int); 466 int (*set_xstate)(struct super_block *, unsigned int, int);
343}; 467};
@@ -386,10 +510,10 @@ static inline unsigned int dquot_generic_flag(unsigned int flags, int type)
386} 510}
387 511
388#ifdef CONFIG_QUOTA_NETLINK_INTERFACE 512#ifdef CONFIG_QUOTA_NETLINK_INTERFACE
389extern void quota_send_warning(short type, unsigned int id, dev_t dev, 513extern void quota_send_warning(struct kqid qid, dev_t dev,
390 const char warntype); 514 const char warntype);
391#else 515#else
392static inline void quota_send_warning(short type, unsigned int id, dev_t dev, 516static inline void quota_send_warning(struct kqid qid, dev_t dev,
393 const char warntype) 517 const char warntype)
394{ 518{
395 return; 519 return;
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index ec6b65feaaba..1c50093ae656 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -44,7 +44,7 @@ void inode_sub_rsv_space(struct inode *inode, qsize_t number);
44 44
45void dquot_initialize(struct inode *inode); 45void dquot_initialize(struct inode *inode);
46void dquot_drop(struct inode *inode); 46void dquot_drop(struct inode *inode);
47struct dquot *dqget(struct super_block *sb, unsigned int id, int type); 47struct dquot *dqget(struct super_block *sb, struct kqid qid);
48void dqput(struct dquot *dquot); 48void dqput(struct dquot *dquot);
49int dquot_scan_active(struct super_block *sb, 49int dquot_scan_active(struct super_block *sb,
50 int (*fn)(struct dquot *dquot, unsigned long priv), 50 int (*fn)(struct dquot *dquot, unsigned long priv),
@@ -87,9 +87,9 @@ int dquot_writeback_dquots(struct super_block *sb, int type);
87int dquot_quota_sync(struct super_block *sb, int type); 87int dquot_quota_sync(struct super_block *sb, int type);
88int dquot_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 88int dquot_get_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
89int dquot_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii); 89int dquot_set_dqinfo(struct super_block *sb, int type, struct if_dqinfo *ii);
90int dquot_get_dqblk(struct super_block *sb, int type, qid_t id, 90int dquot_get_dqblk(struct super_block *sb, struct kqid id,
91 struct fs_disk_quota *di); 91 struct fs_disk_quota *di);
92int dquot_set_dqblk(struct super_block *sb, int type, qid_t id, 92int dquot_set_dqblk(struct super_block *sb, struct kqid id,
93 struct fs_disk_quota *di); 93 struct fs_disk_quota *di);
94 94
95int __dquot_transfer(struct inode *inode, struct dquot **transfer_to); 95int __dquot_transfer(struct inode *inode, struct dquot **transfer_to);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 765dffbb085e..d23ca6245d54 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1414,7 +1414,7 @@ struct task_struct {
1414 1414
1415 struct audit_context *audit_context; 1415 struct audit_context *audit_context;
1416#ifdef CONFIG_AUDITSYSCALL 1416#ifdef CONFIG_AUDITSYSCALL
1417 uid_t loginuid; 1417 kuid_t loginuid;
1418 unsigned int sessionid; 1418 unsigned int sessionid;
1419#endif 1419#endif
1420 struct seccomp seccomp; 1420 struct seccomp seccomp;
diff --git a/include/linux/security.h b/include/linux/security.h
index d143b8e01954..145accee9236 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -1436,7 +1436,7 @@ struct security_operations {
1436 int (*path_rename) (struct path *old_dir, struct dentry *old_dentry, 1436 int (*path_rename) (struct path *old_dir, struct dentry *old_dentry,
1437 struct path *new_dir, struct dentry *new_dentry); 1437 struct path *new_dir, struct dentry *new_dentry);
1438 int (*path_chmod) (struct path *path, umode_t mode); 1438 int (*path_chmod) (struct path *path, umode_t mode);
1439 int (*path_chown) (struct path *path, uid_t uid, gid_t gid); 1439 int (*path_chown) (struct path *path, kuid_t uid, kgid_t gid);
1440 int (*path_chroot) (struct path *path); 1440 int (*path_chroot) (struct path *path);
1441#endif 1441#endif
1442 1442
@@ -2831,7 +2831,7 @@ int security_path_link(struct dentry *old_dentry, struct path *new_dir,
2831int security_path_rename(struct path *old_dir, struct dentry *old_dentry, 2831int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
2832 struct path *new_dir, struct dentry *new_dentry); 2832 struct path *new_dir, struct dentry *new_dentry);
2833int security_path_chmod(struct path *path, umode_t mode); 2833int security_path_chmod(struct path *path, umode_t mode);
2834int security_path_chown(struct path *path, uid_t uid, gid_t gid); 2834int security_path_chown(struct path *path, kuid_t uid, kgid_t gid);
2835int security_path_chroot(struct path *path); 2835int security_path_chroot(struct path *path);
2836#else /* CONFIG_SECURITY_PATH */ 2836#else /* CONFIG_SECURITY_PATH */
2837static inline int security_path_unlink(struct path *dir, struct dentry *dentry) 2837static inline int security_path_unlink(struct path *dir, struct dentry *dentry)
@@ -2887,7 +2887,7 @@ static inline int security_path_chmod(struct path *path, umode_t mode)
2887 return 0; 2887 return 0;
2888} 2888}
2889 2889
2890static inline int security_path_chown(struct path *path, uid_t uid, gid_t gid) 2890static inline int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
2891{ 2891{
2892 return 0; 2892 return 0;
2893} 2893}
diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 83c44eefe698..68a04a343cad 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -13,6 +13,7 @@ struct file;
13struct path; 13struct path;
14struct inode; 14struct inode;
15struct dentry; 15struct dentry;
16struct user_namespace;
16 17
17struct seq_file { 18struct seq_file {
18 char *buf; 19 char *buf;
@@ -25,6 +26,9 @@ struct seq_file {
25 struct mutex lock; 26 struct mutex lock;
26 const struct seq_operations *op; 27 const struct seq_operations *op;
27 int poll_event; 28 int poll_event;
29#ifdef CONFIG_USER_NS
30 struct user_namespace *user_ns;
31#endif
28 void *private; 32 void *private;
29}; 33};
30 34
@@ -128,6 +132,16 @@ int seq_put_decimal_ull(struct seq_file *m, char delimiter,
128int seq_put_decimal_ll(struct seq_file *m, char delimiter, 132int seq_put_decimal_ll(struct seq_file *m, char delimiter,
129 long long num); 133 long long num);
130 134
135static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
136{
137#ifdef CONFIG_USER_NS
138 return seq->user_ns;
139#else
140 extern struct user_namespace init_user_ns;
141 return &init_user_ns;
142#endif
143}
144
131#define SEQ_START_TOKEN ((void *)1) 145#define SEQ_START_TOKEN ((void *)1)
132/* 146/*
133 * Helpers for iteration over list_head-s in seq_files 147 * Helpers for iteration over list_head-s in seq_files
diff --git a/include/linux/tsacct_kern.h b/include/linux/tsacct_kern.h
index 7e50ac795b0b..44893e5ec8f7 100644
--- a/include/linux/tsacct_kern.h
+++ b/include/linux/tsacct_kern.h
@@ -10,9 +10,13 @@
10#include <linux/taskstats.h> 10#include <linux/taskstats.h>
11 11
12#ifdef CONFIG_TASKSTATS 12#ifdef CONFIG_TASKSTATS
13extern void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk); 13extern void bacct_add_tsk(struct user_namespace *user_ns,
14 struct pid_namespace *pid_ns,
15 struct taskstats *stats, struct task_struct *tsk);
14#else 16#else
15static inline void bacct_add_tsk(struct taskstats *stats, struct task_struct *tsk) 17static inline void bacct_add_tsk(struct user_namespace *user_ns,
18 struct pid_namespace *pid_ns,
19 struct taskstats *stats, struct task_struct *tsk)
16{} 20{}
17#endif /* CONFIG_TASKSTATS */ 21#endif /* CONFIG_TASKSTATS */
18 22
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 1509b86825d8..4f6c59a5fb79 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -575,7 +575,7 @@ extern void tty_audit_fork(struct signal_struct *sig);
575extern void tty_audit_tiocsti(struct tty_struct *tty, char ch); 575extern void tty_audit_tiocsti(struct tty_struct *tty, char ch);
576extern void tty_audit_push(struct tty_struct *tty); 576extern void tty_audit_push(struct tty_struct *tty);
577extern int tty_audit_push_task(struct task_struct *tsk, 577extern int tty_audit_push_task(struct task_struct *tsk,
578 uid_t loginuid, u32 sessionid); 578 kuid_t loginuid, u32 sessionid);
579#else 579#else
580static inline void tty_audit_add_data(struct tty_struct *tty, 580static inline void tty_audit_add_data(struct tty_struct *tty,
581 unsigned char *data, size_t size) 581 unsigned char *data, size_t size)
@@ -594,7 +594,7 @@ static inline void tty_audit_push(struct tty_struct *tty)
594{ 594{
595} 595}
596static inline int tty_audit_push_task(struct task_struct *tsk, 596static inline int tty_audit_push_task(struct task_struct *tsk,
597 uid_t loginuid, u32 sessionid) 597 kuid_t loginuid, u32 sessionid)
598{ 598{
599 return 0; 599 return 0;
600} 600}
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index 4e72922e5a75..95142cae446a 100644
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -20,6 +20,7 @@ struct uid_gid_map { /* 64 bytes -- 1 cache line */
20struct user_namespace { 20struct user_namespace {
21 struct uid_gid_map uid_map; 21 struct uid_gid_map uid_map;
22 struct uid_gid_map gid_map; 22 struct uid_gid_map gid_map;
23 struct uid_gid_map projid_map;
23 struct kref kref; 24 struct kref kref;
24 struct user_namespace *parent; 25 struct user_namespace *parent;
25 kuid_t owner; 26 kuid_t owner;
@@ -49,8 +50,10 @@ static inline void put_user_ns(struct user_namespace *ns)
49struct seq_operations; 50struct seq_operations;
50extern struct seq_operations proc_uid_seq_operations; 51extern struct seq_operations proc_uid_seq_operations;
51extern struct seq_operations proc_gid_seq_operations; 52extern struct seq_operations proc_gid_seq_operations;
53extern struct seq_operations proc_projid_seq_operations;
52extern ssize_t proc_uid_map_write(struct file *, const char __user *, size_t, loff_t *); 54extern ssize_t proc_uid_map_write(struct file *, const char __user *, size_t, loff_t *);
53extern ssize_t proc_gid_map_write(struct file *, const char __user *, size_t, loff_t *); 55extern ssize_t proc_gid_map_write(struct file *, const char __user *, size_t, loff_t *);
56extern ssize_t proc_projid_map_write(struct file *, const char __user *, size_t, loff_t *);
54#else 57#else
55 58
56static inline struct user_namespace *get_user_ns(struct user_namespace *ns) 59static inline struct user_namespace *get_user_ns(struct user_namespace *ns)