Skip to content

Commit 78ee8b1

Browse files
committed
Merge branch 'next-general' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security
Pull security subsystem updates from James Morris: "Just a few bugfixes and documentation updates" * 'next-general' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: seccomp: fix up grammar in comment Revert "security: inode: fix a missing check for securityfs_create_file" Yama: mark function as static security: inode: fix a missing check for securityfs_create_file keys: safe concurrent user->{session,uid}_keyring access security: don't use RCU accessors for cred->session_keyring Yama: mark local symbols as static LSM: lsm_hooks.h: fix documentation format LSM: fix documentation for the shm_* hooks LSM: fix documentation for the sem_* hooks LSM: fix documentation for the msg_queue_* hooks LSM: fix documentation for the audit_* hooks LSM: fix documentation for the path_chmod hook LSM: fix documentation for the socket_getpeersec_dgram hook LSM: fix documentation for the task_setscheduler hook LSM: fix documentation for the socket_post_create hook LSM: fix documentation for the syslog hook LSM: fix documentation for sb_copy_data hook
2 parents 9bff9df + 6beff00 commit 78ee8b1

File tree

6 files changed

+115
-121
lines changed

6 files changed

+115
-121
lines changed

include/linux/cred.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ struct cred {
138138
#ifdef CONFIG_KEYS
139139
unsigned char jit_keyring; /* default keyring to attach requested
140140
* keys to */
141-
struct key __rcu *session_keyring; /* keyring inherited over fork */
141+
struct key *session_keyring; /* keyring inherited over fork */
142142
struct key *process_keyring; /* keyring private to this process */
143143
struct key *thread_keyring; /* keyring private to this thread */
144144
struct key *request_key_auth; /* assumed request_key authority */

include/linux/lsm_hooks.h

Lines changed: 81 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@
127127
* options cleanly (a filesystem may modify the data e.g. with strsep()).
128128
* This also allows the original mount data to be stripped of security-
129129
* specific options to avoid having to make filesystems aware of them.
130-
* @type the type of filesystem being mounted.
131130
* @orig the original mount data copied from userspace.
132131
* @copy copied data which will be passed to the security module.
133132
* Returns 0 if the copy was successful.
@@ -320,10 +319,11 @@
320319
* @new_dentry contains the dentry structure of the new link.
321320
* Return 0 if permission is granted.
322321
* @path_chmod:
323-
* Check for permission to change DAC's permission of a file or directory.
324-
* @dentry contains the dentry structure.
325-
* @mnt contains the vfsmnt structure.
326-
* @mode contains DAC's mode.
322+
* Check for permission to change a mode of the file @path. The new
323+
* mode is specified in @mode.
324+
* @path contains the path structure of the file to change the mode.
325+
* @mode contains the new DAC's permission, which is a bitmask of
326+
* constants from <include/uapi/linux/stat.h>
327327
* Return 0 if permission is granted.
328328
* @path_chown:
329329
* Check for permission to change owner/group of a file or directory.
@@ -502,7 +502,7 @@
502502
* Return 0 if permission is granted.
503503
* @file_lock:
504504
* Check permission before performing file locking operations.
505-
* Note: this hook mediates both flock and fcntl style locks.
505+
* Note the hook mediates both flock and fcntl style locks.
506506
* @file contains the file structure.
507507
* @cmd contains the posix-translated lock operation to perform
508508
* (e.g. F_RDLCK, F_WRLCK).
@@ -645,12 +645,12 @@
645645
* @p contains the task_struct of process.
646646
* @nice contains the new nice value.
647647
* Return 0 if permission is granted.
648-
* @task_setioprio
648+
* @task_setioprio:
649649
* Check permission before setting the ioprio value of @p to @ioprio.
650650
* @p contains the task_struct of process.
651651
* @ioprio contains the new ioprio value
652652
* Return 0 if permission is granted.
653-
* @task_getioprio
653+
* @task_getioprio:
654654
* Check permission before getting the ioprio value of @p.
655655
* @p contains the task_struct of process.
656656
* Return 0 if permission is granted.
@@ -672,17 +672,15 @@
672672
* Return 0 if permission is granted.
673673
* @task_setscheduler:
674674
* Check permission before setting scheduling policy and/or parameters of
675-
* process @p based on @policy and @lp.
675+
* process @p.
676676
* @p contains the task_struct for process.
677-
* @policy contains the scheduling policy.
678-
* @lp contains the scheduling parameters.
679677
* Return 0 if permission is granted.
680678
* @task_getscheduler:
681679
* Check permission before obtaining scheduling information for process
682680
* @p.
683681
* @p contains the task_struct for process.
684682
* Return 0 if permission is granted.
685-
* @task_movememory
683+
* @task_movememory:
686684
* Check permission before moving memory owned by process @p.
687685
* @p contains the task_struct for process.
688686
* Return 0 if permission is granted.
@@ -769,9 +767,9 @@
769767
* socket structure, but rather, the socket security information is stored
770768
* in the associated inode. Typically, the inode alloc_security hook will
771769
* allocate and and attach security information to
772-
* sock->inode->i_security. This hook may be used to update the
773-
* sock->inode->i_security field with additional information that wasn't
774-
* available when the inode was allocated.
770+
* SOCK_INODE(sock)->i_security. This hook may be used to update the
771+
* SOCK_INODE(sock)->i_security field with additional information that
772+
* wasn't available when the inode was allocated.
775773
* @sock contains the newly created socket structure.
776774
* @family contains the requested protocol family.
777775
* @type contains the requested communications type.
@@ -876,13 +874,13 @@
876874
* @socket_getpeersec_dgram:
877875
* This hook allows the security module to provide peer socket security
878876
* state for udp sockets on a per-packet basis to userspace via
879-
* getsockopt SO_GETPEERSEC. The application must first have indicated
880-
* the IP_PASSSEC option via getsockopt. It can then retrieve the
877+
* getsockopt SO_GETPEERSEC. The application must first have indicated
878+
* the IP_PASSSEC option via getsockopt. It can then retrieve the
881879
* security state returned by this hook for a packet via the SCM_SECURITY
882880
* ancillary message type.
883-
* @skb is the skbuff for the packet being queried
884-
* @secdata is a pointer to a buffer in which to copy the security data
885-
* @seclen is the maximum length for @secdata
881+
* @sock contains the peer socket. May be NULL.
882+
* @skb is the sk_buff for the packet being queried. May be NULL.
883+
* @secid pointer to store the secid of the packet.
886884
* Return 0 on success, error on failure.
887885
* @sk_alloc_security:
888886
* Allocate and attach a security structure to the sk->sk_security field,
@@ -906,9 +904,9 @@
906904
* @secmark_relabel_packet:
907905
* check if the process should be allowed to relabel packets to
908906
* the given secid
909-
* @security_secmark_refcount_inc
907+
* @secmark_refcount_inc:
910908
* tells the LSM to increment the number of secmark labeling rules loaded
911-
* @security_secmark_refcount_dec
909+
* @secmark_refcount_dec:
912910
* tells the LSM to decrement the number of secmark labeling rules loaded
913911
* @req_classify_flow:
914912
* Sets the flow's sid to the openreq sid.
@@ -1113,41 +1111,41 @@
11131111
*
11141112
* @msg_queue_alloc_security:
11151113
* Allocate and attach a security structure to the
1116-
* msq->q_perm.security field. The security field is initialized to
1114+
* @perm->security field. The security field is initialized to
11171115
* NULL when the structure is first created.
1118-
* @msq contains the message queue structure to be modified.
1116+
* @perm contains the IPC permissions of the message queue.
11191117
* Return 0 if operation was successful and permission is granted.
11201118
* @msg_queue_free_security:
1121-
* Deallocate security structure for this message queue.
1122-
* @msq contains the message queue structure to be modified.
1119+
* Deallocate security field @perm->security for the message queue.
1120+
* @perm contains the IPC permissions of the message queue.
11231121
* @msg_queue_associate:
11241122
* Check permission when a message queue is requested through the
1125-
* msgget system call. This hook is only called when returning the
1123+
* msgget system call. This hook is only called when returning the
11261124
* message queue identifier for an existing message queue, not when a
11271125
* new message queue is created.
1128-
* @msq contains the message queue to act upon.
1126+
* @perm contains the IPC permissions of the message queue.
11291127
* @msqflg contains the operation control flags.
11301128
* Return 0 if permission is granted.
11311129
* @msg_queue_msgctl:
11321130
* Check permission when a message control operation specified by @cmd
1133-
* is to be performed on the message queue @msq.
1134-
* The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
1135-
* @msq contains the message queue to act upon. May be NULL.
1131+
* is to be performed on the message queue with permissions @perm.
1132+
* The @perm may be NULL, e.g. for IPC_INFO or MSG_INFO.
1133+
* @perm contains the IPC permissions of the msg queue. May be NULL.
11361134
* @cmd contains the operation to be performed.
11371135
* Return 0 if permission is granted.
11381136
* @msg_queue_msgsnd:
11391137
* Check permission before a message, @msg, is enqueued on the message
1140-
* queue, @msq.
1141-
* @msq contains the message queue to send message to.
1138+
* queue with permissions @perm.
1139+
* @perm contains the IPC permissions of the message queue.
11421140
* @msg contains the message to be enqueued.
11431141
* @msqflg contains operational flags.
11441142
* Return 0 if permission is granted.
11451143
* @msg_queue_msgrcv:
11461144
* Check permission before a message, @msg, is removed from the message
1147-
* queue, @msq. The @target task structure contains a pointer to the
1145+
* queue. The @target task structure contains a pointer to the
11481146
* process that will be receiving the message (not equal to the current
11491147
* process when inline receives are being performed).
1150-
* @msq contains the message queue to retrieve message from.
1148+
* @perm contains the IPC permissions of the message queue.
11511149
* @msg contains the message destination.
11521150
* @target contains the task structure for recipient process.
11531151
* @type contains the type of message requested.
@@ -1157,69 +1155,69 @@
11571155
* Security hooks for System V Shared Memory Segments
11581156
*
11591157
* @shm_alloc_security:
1160-
* Allocate and attach a security structure to the shp->shm_perm.security
1161-
* field. The security field is initialized to NULL when the structure is
1158+
* Allocate and attach a security structure to the @perm->security
1159+
* field. The security field is initialized to NULL when the structure is
11621160
* first created.
1163-
* @shp contains the shared memory structure to be modified.
1161+
* @perm contains the IPC permissions of the shared memory structure.
11641162
* Return 0 if operation was successful and permission is granted.
11651163
* @shm_free_security:
1166-
* Deallocate the security struct for this memory segment.
1167-
* @shp contains the shared memory structure to be modified.
1164+
* Deallocate the security structure @perm->security for the memory segment.
1165+
* @perm contains the IPC permissions of the shared memory structure.
11681166
* @shm_associate:
11691167
* Check permission when a shared memory region is requested through the
1170-
* shmget system call. This hook is only called when returning the shared
1168+
* shmget system call. This hook is only called when returning the shared
11711169
* memory region identifier for an existing region, not when a new shared
11721170
* memory region is created.
1173-
* @shp contains the shared memory structure to be modified.
1171+
* @perm contains the IPC permissions of the shared memory structure.
11741172
* @shmflg contains the operation control flags.
11751173
* Return 0 if permission is granted.
11761174
* @shm_shmctl:
11771175
* Check permission when a shared memory control operation specified by
1178-
* @cmd is to be performed on the shared memory region @shp.
1179-
* The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
1180-
* @shp contains shared memory structure to be modified.
1176+
* @cmd is to be performed on the shared memory region with permissions @perm.
1177+
* The @perm may be NULL, e.g. for IPC_INFO or SHM_INFO.
1178+
* @perm contains the IPC permissions of the shared memory structure.
11811179
* @cmd contains the operation to be performed.
11821180
* Return 0 if permission is granted.
11831181
* @shm_shmat:
11841182
* Check permissions prior to allowing the shmat system call to attach the
1185-
* shared memory segment @shp to the data segment of the calling process.
1186-
* The attaching address is specified by @shmaddr.
1187-
* @shp contains the shared memory structure to be modified.
1183+
* shared memory segment with permissions @perm to the data segment of the
1184+
* calling process. The attaching address is specified by @shmaddr.
1185+
* @perm contains the IPC permissions of the shared memory structure.
11881186
* @shmaddr contains the address to attach memory region to.
11891187
* @shmflg contains the operational flags.
11901188
* Return 0 if permission is granted.
11911189
*
11921190
* Security hooks for System V Semaphores
11931191
*
11941192
* @sem_alloc_security:
1195-
* Allocate and attach a security structure to the sma->sem_perm.security
1196-
* field. The security field is initialized to NULL when the structure is
1193+
* Allocate and attach a security structure to the @perm->security
1194+
* field. The security field is initialized to NULL when the structure is
11971195
* first created.
1198-
* @sma contains the semaphore structure
1196+
* @perm contains the IPC permissions of the semaphore.
11991197
* Return 0 if operation was successful and permission is granted.
12001198
* @sem_free_security:
1201-
* deallocate security struct for this semaphore
1202-
* @sma contains the semaphore structure.
1199+
* Deallocate security structure @perm->security for the semaphore.
1200+
* @perm contains the IPC permissions of the semaphore.
12031201
* @sem_associate:
12041202
* Check permission when a semaphore is requested through the semget
1205-
* system call. This hook is only called when returning the semaphore
1203+
* system call. This hook is only called when returning the semaphore
12061204
* identifier for an existing semaphore, not when a new one must be
12071205
* created.
1208-
* @sma contains the semaphore structure.
1206+
* @perm contains the IPC permissions of the semaphore.
12091207
* @semflg contains the operation control flags.
12101208
* Return 0 if permission is granted.
12111209
* @sem_semctl:
12121210
* Check permission when a semaphore operation specified by @cmd is to be
1213-
* performed on the semaphore @sma. The @sma may be NULL, e.g. for
1211+
* performed on the semaphore. The @perm may be NULL, e.g. for
12141212
* IPC_INFO or SEM_INFO.
1215-
* @sma contains the semaphore structure. May be NULL.
1213+
* @perm contains the IPC permissions of the semaphore. May be NULL.
12161214
* @cmd contains the operation to be performed.
12171215
* Return 0 if permission is granted.
12181216
* @sem_semop:
12191217
* Check permissions before performing operations on members of the
1220-
* semaphore set @sma. If the @alter flag is nonzero, the semaphore set
1218+
* semaphore set. If the @alter flag is nonzero, the semaphore set
12211219
* may be modified.
1222-
* @sma contains the semaphore structure.
1220+
* @perm contains the IPC permissions of the semaphore.
12231221
* @sops contains the operations to perform.
12241222
* @nsops contains the number of operations to perform.
12251223
* @alter contains the flag indicating whether changes are to be made.
@@ -1292,13 +1290,12 @@
12921290
* Check permission before accessing the kernel message ring or changing
12931291
* logging to the console.
12941292
* See the syslog(2) manual page for an explanation of the @type values.
1295-
* @type contains the type of action.
1296-
* @from_file indicates the context of action (if it came from /proc).
1293+
* @type contains the SYSLOG_ACTION_* constant from <include/linux/syslog.h>
12971294
* Return 0 if permission is granted.
12981295
* @settime:
12991296
* Check permission to change the system time.
1300-
* struct timespec64 is defined in include/linux/time64.h and timezone
1301-
* is defined in include/linux/time.h
1297+
* struct timespec64 is defined in <include/linux/time64.h> and timezone
1298+
* is defined in <include/linux/time.h>
13021299
* @ts contains new time
13031300
* @tz contains new timezone
13041301
* Return 0 if permission is granted.
@@ -1340,17 +1337,17 @@
13401337
* @audit_rule_init:
13411338
* Allocate and initialize an LSM audit rule structure.
13421339
* @field contains the required Audit action.
1343-
* Fields flags are defined in include/linux/audit.h
1340+
* Fields flags are defined in <include/linux/audit.h>
13441341
* @op contains the operator the rule uses.
13451342
* @rulestr contains the context where the rule will be applied to.
13461343
* @lsmrule contains a pointer to receive the result.
13471344
* Return 0 if @lsmrule has been successfully set,
13481345
* -EINVAL in case of an invalid rule.
13491346
*
13501347
* @audit_rule_known:
1351-
* Specifies whether given @rule contains any fields related to
1348+
* Specifies whether given @krule contains any fields related to
13521349
* current LSM.
1353-
* @rule contains the audit rule of interest.
1350+
* @krule contains the audit rule of interest.
13541351
* Return 1 in case of relation found, 0 otherwise.
13551352
*
13561353
* @audit_rule_match:
@@ -1359,13 +1356,13 @@
13591356
* @secid contains the security id in question.
13601357
* @field contains the field which relates to current LSM.
13611358
* @op contains the operator that will be used for matching.
1362-
* @rule points to the audit rule that will be checked against.
1359+
* @lrule points to the audit rule that will be checked against.
13631360
* Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure.
13641361
*
13651362
* @audit_rule_free:
13661363
* Deallocate the LSM audit rule structure previously allocated by
13671364
* audit_rule_init.
1368-
* @rule contains the allocated rule
1365+
* @lsmrule contains the allocated rule
13691366
*
13701367
* @inode_invalidate_secctx:
13711368
* Notify the security module that it must revalidate the security context
@@ -1378,9 +1375,7 @@
13781375
* this hook to initialize the security context in its incore inode to the
13791376
* value provided by the server for the file when the server returned the
13801377
* file's attributes to the client.
1381-
*
13821378
* Must be called with inode->i_mutex locked.
1383-
*
13841379
* @inode we wish to set the security context of.
13851380
* @ctx contains the string which we wish to set in the inode.
13861381
* @ctxlen contains the length of @ctx.
@@ -1393,17 +1388,14 @@
13931388
* this hook to change the security context in its incore inode and on the
13941389
* backing filesystem to a value provided by the client on a SETATTR
13951390
* operation.
1396-
*
13971391
* Must be called with inode->i_mutex locked.
1398-
*
13991392
* @dentry contains the inode we wish to set the security context of.
14001393
* @ctx contains the string which we wish to set in the inode.
14011394
* @ctxlen contains the length of @ctx.
14021395
*
14031396
* @inode_getsecctx:
14041397
* On success, returns 0 and fills out @ctx and @ctxlen with the security
14051398
* context for the given @inode.
1406-
*
14071399
* @inode we wish to get the security context of.
14081400
* @ctx is a pointer in which to place the allocated security context.
14091401
* @ctxlen points to the place to put the length of @ctx.
@@ -1640,28 +1632,28 @@ union security_list_options {
16401632
int (*msg_msg_alloc_security)(struct msg_msg *msg);
16411633
void (*msg_msg_free_security)(struct msg_msg *msg);
16421634

1643-
int (*msg_queue_alloc_security)(struct kern_ipc_perm *msq);
1644-
void (*msg_queue_free_security)(struct kern_ipc_perm *msq);
1645-
int (*msg_queue_associate)(struct kern_ipc_perm *msq, int msqflg);
1646-
int (*msg_queue_msgctl)(struct kern_ipc_perm *msq, int cmd);
1647-
int (*msg_queue_msgsnd)(struct kern_ipc_perm *msq, struct msg_msg *msg,
1635+
int (*msg_queue_alloc_security)(struct kern_ipc_perm *perm);
1636+
void (*msg_queue_free_security)(struct kern_ipc_perm *perm);
1637+
int (*msg_queue_associate)(struct kern_ipc_perm *perm, int msqflg);
1638+
int (*msg_queue_msgctl)(struct kern_ipc_perm *perm, int cmd);
1639+
int (*msg_queue_msgsnd)(struct kern_ipc_perm *perm, struct msg_msg *msg,
16481640
int msqflg);
1649-
int (*msg_queue_msgrcv)(struct kern_ipc_perm *msq, struct msg_msg *msg,
1641+
int (*msg_queue_msgrcv)(struct kern_ipc_perm *perm, struct msg_msg *msg,
16501642
struct task_struct *target, long type,
16511643
int mode);
16521644

1653-
int (*shm_alloc_security)(struct kern_ipc_perm *shp);
1654-
void (*shm_free_security)(struct kern_ipc_perm *shp);
1655-
int (*shm_associate)(struct kern_ipc_perm *shp, int shmflg);
1656-
int (*shm_shmctl)(struct kern_ipc_perm *shp, int cmd);
1657-
int (*shm_shmat)(struct kern_ipc_perm *shp, char __user *shmaddr,
1645+
int (*shm_alloc_security)(struct kern_ipc_perm *perm);
1646+
void (*shm_free_security)(struct kern_ipc_perm *perm);
1647+
int (*shm_associate)(struct kern_ipc_perm *perm, int shmflg);
1648+
int (*shm_shmctl)(struct kern_ipc_perm *perm, int cmd);
1649+
int (*shm_shmat)(struct kern_ipc_perm *perm, char __user *shmaddr,
16581650
int shmflg);
16591651

1660-
int (*sem_alloc_security)(struct kern_ipc_perm *sma);
1661-
void (*sem_free_security)(struct kern_ipc_perm *sma);
1662-
int (*sem_associate)(struct kern_ipc_perm *sma, int semflg);
1663-
int (*sem_semctl)(struct kern_ipc_perm *sma, int cmd);
1664-
int (*sem_semop)(struct kern_ipc_perm *sma, struct sembuf *sops,
1652+
int (*sem_alloc_security)(struct kern_ipc_perm *perm);
1653+
void (*sem_free_security)(struct kern_ipc_perm *perm);
1654+
int (*sem_associate)(struct kern_ipc_perm *perm, int semflg);
1655+
int (*sem_semctl)(struct kern_ipc_perm *perm, int cmd);
1656+
int (*sem_semop)(struct kern_ipc_perm *perm, struct sembuf *sops,
16651657
unsigned nsops, int alter);
16661658

16671659
int (*netlink_send)(struct sock *sk, struct sk_buff *skb);

0 commit comments

Comments
 (0)