Skip to content

Commit 75f72fe

Browse files
stephensmalleypcmoore
authored andcommitted
selinux: rename task_security_struct to cred_security_struct
Before Linux had cred structures, the SELinux task_security_struct was per-task and although the structure was switched to being per-cred long ago, the name was never updated. This change renames it to cred_security_struct to avoid confusion and pave the way for the introduction of an actual per-task security structure for SELinux. No functional change. Cc: stable@vger.kernel.org Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 211ddde commit 75f72fe

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

security/selinux/hooks.c

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static int selinux_lsm_notifier_avc_callback(u32 event)
210210
*/
211211
static void cred_init_security(void)
212212
{
213-
struct task_security_struct *tsec;
213+
struct cred_security_struct *tsec;
214214

215215
/* NOTE: the lsm framework zeros out the buffer on allocation */
216216

@@ -223,7 +223,7 @@ static void cred_init_security(void)
223223
*/
224224
static inline u32 cred_sid(const struct cred *cred)
225225
{
226-
const struct task_security_struct *tsec;
226+
const struct cred_security_struct *tsec;
227227

228228
tsec = selinux_cred(cred);
229229
return tsec->sid;
@@ -437,7 +437,7 @@ static int may_context_mount_sb_relabel(u32 sid,
437437
struct superblock_security_struct *sbsec,
438438
const struct cred *cred)
439439
{
440-
const struct task_security_struct *tsec = selinux_cred(cred);
440+
const struct cred_security_struct *tsec = selinux_cred(cred);
441441
int rc;
442442

443443
rc = avc_has_perm(tsec->sid, sbsec->sid, SECCLASS_FILESYSTEM,
@@ -454,7 +454,7 @@ static int may_context_mount_inode_relabel(u32 sid,
454454
struct superblock_security_struct *sbsec,
455455
const struct cred *cred)
456456
{
457-
const struct task_security_struct *tsec = selinux_cred(cred);
457+
const struct cred_security_struct *tsec = selinux_cred(cred);
458458
int rc;
459459
rc = avc_has_perm(tsec->sid, sbsec->sid, SECCLASS_FILESYSTEM,
460460
FILESYSTEM__RELABELFROM, NULL);
@@ -1788,7 +1788,7 @@ static int file_has_perm(const struct cred *cred,
17881788
* Determine the label for an inode that might be unioned.
17891789
*/
17901790
static int
1791-
selinux_determine_inode_label(const struct task_security_struct *tsec,
1791+
selinux_determine_inode_label(const struct cred_security_struct *tsec,
17921792
struct inode *dir,
17931793
const struct qstr *name, u16 tclass,
17941794
u32 *_new_isid)
@@ -1817,7 +1817,7 @@ static int may_create(struct inode *dir,
18171817
struct dentry *dentry,
18181818
u16 tclass)
18191819
{
1820-
const struct task_security_struct *tsec = selinux_cred(current_cred());
1820+
const struct cred_security_struct *tsec = selinux_cred(current_cred());
18211821
struct inode_security_struct *dsec;
18221822
struct superblock_security_struct *sbsec;
18231823
u32 sid, newsid;
@@ -2251,8 +2251,8 @@ static u32 ptrace_parent_sid(void)
22512251
}
22522252

22532253
static int check_nnp_nosuid(const struct linux_binprm *bprm,
2254-
const struct task_security_struct *old_tsec,
2255-
const struct task_security_struct *new_tsec)
2254+
const struct cred_security_struct *old_tsec,
2255+
const struct cred_security_struct *new_tsec)
22562256
{
22572257
int nnp = (bprm->unsafe & LSM_UNSAFE_NO_NEW_PRIVS);
22582258
int nosuid = !mnt_may_suid(bprm->file->f_path.mnt);
@@ -2305,8 +2305,8 @@ static int check_nnp_nosuid(const struct linux_binprm *bprm,
23052305

23062306
static int selinux_bprm_creds_for_exec(struct linux_binprm *bprm)
23072307
{
2308-
const struct task_security_struct *old_tsec;
2309-
struct task_security_struct *new_tsec;
2308+
const struct cred_security_struct *old_tsec;
2309+
struct cred_security_struct *new_tsec;
23102310
struct inode_security_struct *isec;
23112311
struct common_audit_data ad;
23122312
struct inode *inode = file_inode(bprm->file);
@@ -2483,7 +2483,7 @@ static inline void flush_unauthorized_files(const struct cred *cred,
24832483
*/
24842484
static void selinux_bprm_committing_creds(const struct linux_binprm *bprm)
24852485
{
2486-
struct task_security_struct *new_tsec;
2486+
struct cred_security_struct *new_tsec;
24872487
struct rlimit *rlim, *initrlim;
24882488
int rc, i;
24892489

@@ -2529,7 +2529,7 @@ static void selinux_bprm_committing_creds(const struct linux_binprm *bprm)
25292529
*/
25302530
static void selinux_bprm_committed_creds(const struct linux_binprm *bprm)
25312531
{
2532-
const struct task_security_struct *tsec = selinux_cred(current_cred());
2532+
const struct cred_security_struct *tsec = selinux_cred(current_cred());
25332533
u32 osid, sid;
25342534
int rc;
25352535

@@ -2911,7 +2911,7 @@ static int selinux_dentry_create_files_as(struct dentry *dentry, int mode,
29112911
{
29122912
u32 newsid;
29132913
int rc;
2914-
struct task_security_struct *tsec;
2914+
struct cred_security_struct *tsec;
29152915

29162916
rc = selinux_determine_inode_label(selinux_cred(old),
29172917
d_inode(dentry->d_parent), name,
@@ -2929,7 +2929,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir,
29292929
const struct qstr *qstr,
29302930
struct xattr *xattrs, int *xattr_count)
29312931
{
2932-
const struct task_security_struct *tsec = selinux_cred(current_cred());
2932+
const struct cred_security_struct *tsec = selinux_cred(current_cred());
29332933
struct superblock_security_struct *sbsec;
29342934
struct xattr *xattr = lsm_get_xattr_slot(xattrs, xattr_count);
29352935
u32 newsid, clen;
@@ -3110,7 +3110,7 @@ static noinline int audit_inode_permission(struct inode *inode,
31103110
* Clear the task's AVD cache in @tsec and reset it to the current policy's
31113111
* and task's info.
31123112
*/
3113-
static inline void task_avdcache_reset(struct task_security_struct *tsec)
3113+
static inline void task_avdcache_reset(struct cred_security_struct *tsec)
31143114
{
31153115
memset(&tsec->avdcache.dir, 0, sizeof(tsec->avdcache.dir));
31163116
tsec->avdcache.sid = tsec->sid;
@@ -3127,7 +3127,7 @@ static inline void task_avdcache_reset(struct task_security_struct *tsec)
31273127
* Search @tsec for a AVD cache entry that matches @isec and return it to the
31283128
* caller via @avdc. Returns 0 if a match is found, negative values otherwise.
31293129
*/
3130-
static inline int task_avdcache_search(struct task_security_struct *tsec,
3130+
static inline int task_avdcache_search(struct cred_security_struct *tsec,
31313131
struct inode_security_struct *isec,
31323132
struct avdc_entry **avdc)
31333133
{
@@ -3167,7 +3167,7 @@ static inline int task_avdcache_search(struct task_security_struct *tsec,
31673167
* Update the AVD cache in @tsec with the @avdc and @audited info associated
31683168
* with @isec.
31693169
*/
3170-
static inline void task_avdcache_update(struct task_security_struct *tsec,
3170+
static inline void task_avdcache_update(struct cred_security_struct *tsec,
31713171
struct inode_security_struct *isec,
31723172
struct av_decision *avd,
31733173
u32 audited)
@@ -3201,7 +3201,7 @@ static int selinux_inode_permission(struct inode *inode, int requested)
32013201
{
32023202
int mask;
32033203
u32 perms;
3204-
struct task_security_struct *tsec;
3204+
struct cred_security_struct *tsec;
32053205
struct inode_security_struct *isec;
32063206
struct avdc_entry *avdc;
32073207
int rc, rc2;
@@ -3283,7 +3283,7 @@ static int selinux_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
32833283

32843284
static int selinux_inode_getattr(const struct path *path)
32853285
{
3286-
struct task_security_struct *tsec;
3286+
struct cred_security_struct *tsec;
32873287

32883288
tsec = selinux_cred(current_cred());
32893289

@@ -3659,7 +3659,7 @@ static void selinux_inode_getlsmprop(struct inode *inode, struct lsm_prop *prop)
36593659
static int selinux_inode_copy_up(struct dentry *src, struct cred **new)
36603660
{
36613661
struct lsm_prop prop;
3662-
struct task_security_struct *tsec;
3662+
struct cred_security_struct *tsec;
36633663
struct cred *new_creds = *new;
36643664

36653665
if (new_creds == NULL) {
@@ -3697,7 +3697,7 @@ static int selinux_inode_copy_up_xattr(struct dentry *dentry, const char *name)
36973697
static int selinux_kernfs_init_security(struct kernfs_node *kn_dir,
36983698
struct kernfs_node *kn)
36993699
{
3700-
const struct task_security_struct *tsec = selinux_cred(current_cred());
3700+
const struct cred_security_struct *tsec = selinux_cred(current_cred());
37013701
u32 parent_sid, newsid, clen;
37023702
int rc;
37033703
char *context;
@@ -4161,8 +4161,8 @@ static int selinux_task_alloc(struct task_struct *task,
41614161
static int selinux_cred_prepare(struct cred *new, const struct cred *old,
41624162
gfp_t gfp)
41634163
{
4164-
const struct task_security_struct *old_tsec = selinux_cred(old);
4165-
struct task_security_struct *tsec = selinux_cred(new);
4164+
const struct cred_security_struct *old_tsec = selinux_cred(old);
4165+
struct cred_security_struct *tsec = selinux_cred(new);
41664166

41674167
*tsec = *old_tsec;
41684168
return 0;
@@ -4173,8 +4173,8 @@ static int selinux_cred_prepare(struct cred *new, const struct cred *old,
41734173
*/
41744174
static void selinux_cred_transfer(struct cred *new, const struct cred *old)
41754175
{
4176-
const struct task_security_struct *old_tsec = selinux_cred(old);
4177-
struct task_security_struct *tsec = selinux_cred(new);
4176+
const struct cred_security_struct *old_tsec = selinux_cred(old);
4177+
struct cred_security_struct *tsec = selinux_cred(new);
41784178

41794179
*tsec = *old_tsec;
41804180
}
@@ -4195,7 +4195,7 @@ static void selinux_cred_getlsmprop(const struct cred *c, struct lsm_prop *prop)
41954195
*/
41964196
static int selinux_kernel_act_as(struct cred *new, u32 secid)
41974197
{
4198-
struct task_security_struct *tsec = selinux_cred(new);
4198+
struct cred_security_struct *tsec = selinux_cred(new);
41994199
u32 sid = current_sid();
42004200
int ret;
42014201

@@ -4219,7 +4219,7 @@ static int selinux_kernel_act_as(struct cred *new, u32 secid)
42194219
static int selinux_kernel_create_files_as(struct cred *new, struct inode *inode)
42204220
{
42214221
struct inode_security_struct *isec = inode_security(inode);
4222-
struct task_security_struct *tsec = selinux_cred(new);
4222+
struct cred_security_struct *tsec = selinux_cred(new);
42234223
u32 sid = current_sid();
42244224
int ret;
42254225

@@ -4744,7 +4744,7 @@ static int selinux_conn_sid(u32 sk_sid, u32 skb_sid, u32 *conn_sid)
47444744

47454745
/* socket security operations */
47464746

4747-
static int socket_sockcreate_sid(const struct task_security_struct *tsec,
4747+
static int socket_sockcreate_sid(const struct cred_security_struct *tsec,
47484748
u16 secclass, u32 *socksid)
47494749
{
47504750
if (tsec->sockcreate_sid > SECSID_NULL) {
@@ -4797,7 +4797,7 @@ static int sock_has_perm(struct sock *sk, u32 perms)
47974797
static int selinux_socket_create(int family, int type,
47984798
int protocol, int kern)
47994799
{
4800-
const struct task_security_struct *tsec = selinux_cred(current_cred());
4800+
const struct cred_security_struct *tsec = selinux_cred(current_cred());
48014801
u32 newsid;
48024802
u16 secclass;
48034803
int rc;
@@ -4816,7 +4816,7 @@ static int selinux_socket_create(int family, int type,
48164816
static int selinux_socket_post_create(struct socket *sock, int family,
48174817
int type, int protocol, int kern)
48184818
{
4819-
const struct task_security_struct *tsec = selinux_cred(current_cred());
4819+
const struct cred_security_struct *tsec = selinux_cred(current_cred());
48204820
struct inode_security_struct *isec = inode_security_novalidate(SOCK_INODE(sock));
48214821
struct sk_security_struct *sksec;
48224822
u16 sclass = socket_type_to_security_class(family, type, protocol);
@@ -6526,7 +6526,7 @@ static void selinux_d_instantiate(struct dentry *dentry, struct inode *inode)
65266526
static int selinux_lsm_getattr(unsigned int attr, struct task_struct *p,
65276527
char **value)
65286528
{
6529-
const struct task_security_struct *tsec;
6529+
const struct cred_security_struct *tsec;
65306530
int error;
65316531
u32 sid;
65326532
u32 len;
@@ -6581,7 +6581,7 @@ static int selinux_lsm_getattr(unsigned int attr, struct task_struct *p,
65816581

65826582
static int selinux_lsm_setattr(u64 attr, void *value, size_t size)
65836583
{
6584-
struct task_security_struct *tsec;
6584+
struct cred_security_struct *tsec;
65856585
struct cred *new;
65866586
u32 mysid = current_sid(), sid = 0, ptsid;
65876587
int error;
@@ -6876,7 +6876,7 @@ static int selinux_inode_getsecctx(struct inode *inode, struct lsm_context *cp)
68766876
static int selinux_key_alloc(struct key *k, const struct cred *cred,
68776877
unsigned long flags)
68786878
{
6879-
const struct task_security_struct *tsec;
6879+
const struct cred_security_struct *tsec;
68806880
struct key_security_struct *ksec = selinux_key(k);
68816881

68826882
tsec = selinux_cred(cred);
@@ -7137,7 +7137,7 @@ static int selinux_bpf_token_create(struct bpf_token *token, union bpf_attr *att
71377137
#endif
71387138

71397139
struct lsm_blob_sizes selinux_blob_sizes __ro_after_init = {
7140-
.lbs_cred = sizeof(struct task_security_struct),
7140+
.lbs_cred = sizeof(struct cred_security_struct),
71417141
.lbs_file = sizeof(struct file_security_struct),
71427142
.lbs_inode = sizeof(struct inode_security_struct),
71437143
.lbs_ipc = sizeof(struct ipc_security_struct),

security/selinux/include/objsec.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct avdc_entry {
3737
bool permissive; /* AVC permissive flag */
3838
};
3939

40-
struct task_security_struct {
40+
struct cred_security_struct {
4141
u32 osid; /* SID prior to last execve */
4242
u32 sid; /* current SID */
4343
u32 exec_sid; /* exec SID */
@@ -54,7 +54,7 @@ struct task_security_struct {
5454
} avdcache;
5555
} __randomize_layout;
5656

57-
static inline bool task_avdcache_permnoaudit(struct task_security_struct *tsec)
57+
static inline bool task_avdcache_permnoaudit(struct cred_security_struct *tsec)
5858
{
5959
return (tsec->avdcache.permissive_neveraudit &&
6060
tsec->sid == tsec->avdcache.sid &&
@@ -172,7 +172,7 @@ struct perf_event_security_struct {
172172
};
173173

174174
extern struct lsm_blob_sizes selinux_blob_sizes;
175-
static inline struct task_security_struct *selinux_cred(const struct cred *cred)
175+
static inline struct cred_security_struct *selinux_cred(const struct cred *cred)
176176
{
177177
return cred->security + selinux_blob_sizes.lbs_cred;
178178
}
@@ -207,7 +207,7 @@ selinux_ipc(const struct kern_ipc_perm *ipc)
207207
*/
208208
static inline u32 current_sid(void)
209209
{
210-
const struct task_security_struct *tsec = selinux_cred(current_cred());
210+
const struct cred_security_struct *tsec = selinux_cred(current_cred());
211211

212212
return tsec->sid;
213213
}

0 commit comments

Comments
 (0)