Skip to content

Commit 9921b25

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6: CRED: Introduce credential access wrappers
2 parents 7a49efa + 9e2b2dc commit 9921b25

File tree

5 files changed

+57
-8
lines changed

5 files changed

+57
-8
lines changed

fs/xfs/linux-2.6/xfs_linux.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,6 @@
126126

127127
#define current_cpu() (raw_smp_processor_id())
128128
#define current_pid() (current->pid)
129-
#define current_fsuid(cred) (current->fsuid)
130-
#define current_fsgid(cred) (current->fsgid)
131129
#define current_test_flags(f) (current->flags & (f))
132130
#define current_set_flags_nested(sp, f) \
133131
(*(sp) = current->flags, current->flags |= (f))

fs/xfs/xfs_inode.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,8 +1081,8 @@ xfs_ialloc(
10811081
ip->i_d.di_onlink = 0;
10821082
ip->i_d.di_nlink = nlink;
10831083
ASSERT(ip->i_d.di_nlink == nlink);
1084-
ip->i_d.di_uid = current_fsuid(cr);
1085-
ip->i_d.di_gid = current_fsgid(cr);
1084+
ip->i_d.di_uid = current_fsuid();
1085+
ip->i_d.di_gid = current_fsgid();
10861086
ip->i_d.di_projid = prid;
10871087
memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
10881088

fs/xfs/xfs_vnodeops.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ xfs_setattr(
182182
xfs_ilock(ip, lock_flags);
183183

184184
/* boolean: are we the file owner? */
185-
file_owner = (current_fsuid(credp) == ip->i_d.di_uid);
185+
file_owner = (current_fsuid() == ip->i_d.di_uid);
186186

187187
/*
188188
* Change various properties of a file.
@@ -1533,7 +1533,7 @@ xfs_create(
15331533
* Make sure that we have allocated dquot(s) on disk.
15341534
*/
15351535
error = XFS_QM_DQVOPALLOC(mp, dp,
1536-
current_fsuid(credp), current_fsgid(credp), prid,
1536+
current_fsuid(), current_fsgid(), prid,
15371537
XFS_QMOPT_QUOTALL|XFS_QMOPT_INHERIT, &udqp, &gdqp);
15381538
if (error)
15391539
goto std_return;
@@ -2269,7 +2269,7 @@ xfs_mkdir(
22692269
* Make sure that we have allocated dquot(s) on disk.
22702270
*/
22712271
error = XFS_QM_DQVOPALLOC(mp, dp,
2272-
current_fsuid(credp), current_fsgid(credp), prid,
2272+
current_fsuid(), current_fsgid(), prid,
22732273
XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp);
22742274
if (error)
22752275
goto std_return;
@@ -2495,7 +2495,7 @@ xfs_symlink(
24952495
* Make sure that we have allocated dquot(s) on disk.
24962496
*/
24972497
error = XFS_QM_DQVOPALLOC(mp, dp,
2498-
current_fsuid(credp), current_fsgid(credp), prid,
2498+
current_fsuid(), current_fsgid(), prid,
24992499
XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp);
25002500
if (error)
25012501
goto std_return;

include/linux/cred.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* Credentials management
2+
*
3+
* Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
4+
* Written by David Howells ([email protected])
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU General Public Licence
8+
* as published by the Free Software Foundation; either version
9+
* 2 of the Licence, or (at your option) any later version.
10+
*/
11+
12+
#ifndef _LINUX_CRED_H
13+
#define _LINUX_CRED_H
14+
15+
#define get_current_user() (get_uid(current->user))
16+
17+
#define task_uid(task) ((task)->uid)
18+
#define task_gid(task) ((task)->gid)
19+
#define task_euid(task) ((task)->euid)
20+
#define task_egid(task) ((task)->egid)
21+
22+
#define current_uid() (current->uid)
23+
#define current_gid() (current->gid)
24+
#define current_euid() (current->euid)
25+
#define current_egid() (current->egid)
26+
#define current_suid() (current->suid)
27+
#define current_sgid() (current->sgid)
28+
#define current_fsuid() (current->fsuid)
29+
#define current_fsgid() (current->fsgid)
30+
#define current_cap() (current->cap_effective)
31+
32+
#define current_uid_gid(_uid, _gid) \
33+
do { \
34+
*(_uid) = current->uid; \
35+
*(_gid) = current->gid; \
36+
} while(0)
37+
38+
#define current_euid_egid(_uid, _gid) \
39+
do { \
40+
*(_uid) = current->euid; \
41+
*(_gid) = current->egid; \
42+
} while(0)
43+
44+
#define current_fsuid_fsgid(_uid, _gid) \
45+
do { \
46+
*(_uid) = current->fsuid; \
47+
*(_gid) = current->fsgid; \
48+
} while(0)
49+
50+
#endif /* _LINUX_CRED_H */

include/linux/sched.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ struct sched_param {
8787
#include <linux/task_io_accounting.h>
8888
#include <linux/kobject.h>
8989
#include <linux/latencytop.h>
90+
#include <linux/cred.h>
9091

9192
#include <asm/processor.h>
9293

0 commit comments

Comments
 (0)