Skip to content

Commit 452b670

Browse files
committed
lsm: move the perf hook comments to security/security.c
This patch relocates the LSM hook function comments to the function definitions, in keeping with the current kernel conventions. This should make the hook descriptions more easily discoverable and easier to maintain. While formatting changes have been done to better fit the kernel-doc style, content changes have been kept to a minimum and limited to text which was obviously incorrect and/or outdated. It is expected the future patches will improve the quality of the function header comments. Acked-by: Casey Schaufler <casey@schaufler-ca.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 55e8532 commit 452b670

2 files changed

Lines changed: 39 additions & 17 deletions

File tree

include/linux/lsm_hooks.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -196,23 +196,6 @@
196196
* @what: kernel feature being accessed.
197197
* Return 0 if permission is granted.
198198
*
199-
* Security hooks for perf events
200-
*
201-
* @perf_event_open:
202-
* Check whether the @type of perf_event_open syscall is allowed.
203-
* Return 0 if permission is granted.
204-
* @perf_event_alloc:
205-
* Allocate and save perf_event security info.
206-
* Return 0 on success, error on failure.
207-
* @perf_event_free:
208-
* Release (free) perf_event security info.
209-
* @perf_event_read:
210-
* Read perf_event security info if allowed.
211-
* Return 0 if permission is granted.
212-
* @perf_event_write:
213-
* Write perf_event security info if allowed.
214-
* Return 0 if permission is granted.
215-
*
216199
* Security hooks for io_uring
217200
*
218201
* @uring_override_creds:

security/security.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4927,26 +4927,65 @@ int security_locked_down(enum lockdown_reason what)
49274927
EXPORT_SYMBOL(security_locked_down);
49284928

49294929
#ifdef CONFIG_PERF_EVENTS
4930+
/**
4931+
* security_perf_event_open() - Check if a perf event open is allowed
4932+
* @attr: perf event attribute
4933+
* @type: type of event
4934+
*
4935+
* Check whether the @type of perf_event_open syscall is allowed.
4936+
*
4937+
* Return: Returns 0 if permission is granted.
4938+
*/
49304939
int security_perf_event_open(struct perf_event_attr *attr, int type)
49314940
{
49324941
return call_int_hook(perf_event_open, 0, attr, type);
49334942
}
49344943

4944+
/**
4945+
* security_perf_event_alloc() - Allocate a perf event LSM blob
4946+
* @event: perf event
4947+
*
4948+
* Allocate and save perf_event security info.
4949+
*
4950+
* Return: Returns 0 on success, error on failure.
4951+
*/
49354952
int security_perf_event_alloc(struct perf_event *event)
49364953
{
49374954
return call_int_hook(perf_event_alloc, 0, event);
49384955
}
49394956

4957+
/**
4958+
* security_perf_event_free() - Free a perf event LSM blob
4959+
* @event: perf event
4960+
*
4961+
* Release (free) perf_event security info.
4962+
*/
49404963
void security_perf_event_free(struct perf_event *event)
49414964
{
49424965
call_void_hook(perf_event_free, event);
49434966
}
49444967

4968+
/**
4969+
* security_perf_event_read() - Check if reading a perf event label is allowed
4970+
* @event: perf event
4971+
*
4972+
* Read perf_event security info if allowed.
4973+
*
4974+
* Return: Returns 0 if permission is granted.
4975+
*/
49454976
int security_perf_event_read(struct perf_event *event)
49464977
{
49474978
return call_int_hook(perf_event_read, 0, event);
49484979
}
49494980

4981+
/**
4982+
* security_perf_event_write() - Check if writing a perf event label is allowed
4983+
* @event: perf event
4984+
*
4985+
* Write perf_event security info if allowed.
4986+
*
4987+
* Return: Returns 0 if permission is granted.
4988+
*/
49504989
int security_perf_event_write(struct perf_event *event)
49514990
{
49524991
return call_int_hook(perf_event_write, 0, event);

0 commit comments

Comments
 (0)