Skip to content

Commit 9ec84f7

Browse files
Luo Gengkunpcmoore
authored andcommitted
perf: Remove unnecessary parameter of security check
It seems that the attr parameter was never been used in security checks since it was first introduced by: commit da97e18 ("perf_event: Add support for LSM and SELinux checks") so remove it. Signed-off-by: Luo Gengkun <[email protected]> Reviewed-by: Ingo Molnar <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent 4632cd0 commit 9ec84f7

File tree

11 files changed

+25
-27
lines changed

11 files changed

+25
-27
lines changed

arch/x86/events/intel/bts.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ static int bts_event_init(struct perf_event *event)
559559
* to the user in a zero-copy fashion.
560560
*/
561561
if (event->attr.exclude_kernel) {
562-
ret = perf_allow_kernel(&event->attr);
562+
ret = perf_allow_kernel();
563563
if (ret)
564564
return ret;
565565
}

arch/x86/events/intel/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4168,7 +4168,7 @@ static int intel_pmu_hw_config(struct perf_event *event)
41684168
if (x86_pmu.version < 3)
41694169
return -EINVAL;
41704170

4171-
ret = perf_allow_cpu(&event->attr);
4171+
ret = perf_allow_cpu();
41724172
if (ret)
41734173
return ret;
41744174

arch/x86/events/intel/p4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ static int p4_validate_raw_event(struct perf_event *event)
776776
* the user needs special permissions to be able to use it
777777
*/
778778
if (p4_ht_active() && p4_event_bind_map[v].shared) {
779-
v = perf_allow_cpu(&event->attr);
779+
v = perf_allow_cpu();
780780
if (v)
781781
return v;
782782
}

drivers/perf/arm_spe_pmu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static_assert((PERF_EVENT_FLAG_ARCH & SPE_PMU_HW_FLAGS_CX) == SPE_PMU_HW_FLAGS_C
5050

5151
static void set_spe_event_has_cx(struct perf_event *event)
5252
{
53-
if (IS_ENABLED(CONFIG_PID_IN_CONTEXTIDR) && !perf_allow_kernel(&event->attr))
53+
if (IS_ENABLED(CONFIG_PID_IN_CONTEXTIDR) && !perf_allow_kernel())
5454
event->hw.flags |= SPE_PMU_HW_FLAGS_CX;
5555
}
5656

@@ -765,7 +765,7 @@ static int arm_spe_pmu_event_init(struct perf_event *event)
765765
set_spe_event_has_cx(event);
766766
reg = arm_spe_event_to_pmscr(event);
767767
if (reg & (PMSCR_EL1_PA | PMSCR_EL1_PCT))
768-
return perf_allow_kernel(&event->attr);
768+
return perf_allow_kernel();
769769

770770
return 0;
771771
}

include/linux/lsm_hook_defs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ LSM_HOOK(int, 0, bpf_token_capable, const struct bpf_token *token, int cap)
445445
LSM_HOOK(int, 0, locked_down, enum lockdown_reason what)
446446

447447
#ifdef CONFIG_PERF_EVENTS
448-
LSM_HOOK(int, 0, perf_event_open, struct perf_event_attr *attr, int type)
448+
LSM_HOOK(int, 0, perf_event_open, int type)
449449
LSM_HOOK(int, 0, perf_event_alloc, struct perf_event *event)
450450
LSM_HOOK(int, 0, perf_event_read, struct perf_event *event)
451451
LSM_HOOK(int, 0, perf_event_write, struct perf_event *event)

include/linux/perf_event.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,22 +1672,22 @@ static inline int perf_is_paranoid(void)
16721672
return sysctl_perf_event_paranoid > -1;
16731673
}
16741674

1675-
int perf_allow_kernel(struct perf_event_attr *attr);
1675+
int perf_allow_kernel(void);
16761676

1677-
static inline int perf_allow_cpu(struct perf_event_attr *attr)
1677+
static inline int perf_allow_cpu(void)
16781678
{
16791679
if (sysctl_perf_event_paranoid > 0 && !perfmon_capable())
16801680
return -EACCES;
16811681

1682-
return security_perf_event_open(attr, PERF_SECURITY_CPU);
1682+
return security_perf_event_open(PERF_SECURITY_CPU);
16831683
}
16841684

1685-
static inline int perf_allow_tracepoint(struct perf_event_attr *attr)
1685+
static inline int perf_allow_tracepoint(void)
16861686
{
16871687
if (sysctl_perf_event_paranoid > -1 && !perfmon_capable())
16881688
return -EPERM;
16891689

1690-
return security_perf_event_open(attr, PERF_SECURITY_TRACEPOINT);
1690+
return security_perf_event_open(PERF_SECURITY_TRACEPOINT);
16911691
}
16921692

16931693
extern int perf_exclude_event(struct perf_event *event, struct pt_regs *regs);

include/linux/security.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2324,14 +2324,13 @@ struct perf_event_attr;
23242324
struct perf_event;
23252325

23262326
#ifdef CONFIG_SECURITY
2327-
extern int security_perf_event_open(struct perf_event_attr *attr, int type);
2327+
extern int security_perf_event_open(int type);
23282328
extern int security_perf_event_alloc(struct perf_event *event);
23292329
extern void security_perf_event_free(struct perf_event *event);
23302330
extern int security_perf_event_read(struct perf_event *event);
23312331
extern int security_perf_event_write(struct perf_event *event);
23322332
#else
2333-
static inline int security_perf_event_open(struct perf_event_attr *attr,
2334-
int type)
2333+
static inline int security_perf_event_open(int type)
23352334
{
23362335
return 0;
23372336
}

kernel/events/core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4883,7 +4883,7 @@ find_get_context(struct task_struct *task, struct perf_event *event)
48834883

48844884
if (!task) {
48854885
/* Must be root to operate on a CPU event: */
4886-
err = perf_allow_cpu(&event->attr);
4886+
err = perf_allow_cpu();
48874887
if (err)
48884888
return ERR_PTR(err);
48894889

@@ -12532,7 +12532,7 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
1253212532
}
1253312533
/* privileged levels capture (kernel, hv): check permissions */
1253412534
if (mask & PERF_SAMPLE_BRANCH_PERM_PLM) {
12535-
ret = perf_allow_kernel(attr);
12535+
ret = perf_allow_kernel();
1253612536
if (ret)
1253712537
return ret;
1253812538
}
@@ -12789,12 +12789,12 @@ SYSCALL_DEFINE5(perf_event_open,
1278912789
return err;
1279012790

1279112791
/* Do we allow access to perf_event_open(2) ? */
12792-
err = security_perf_event_open(&attr, PERF_SECURITY_OPEN);
12792+
err = security_perf_event_open(PERF_SECURITY_OPEN);
1279312793
if (err)
1279412794
return err;
1279512795

1279612796
if (!attr.exclude_kernel) {
12797-
err = perf_allow_kernel(&attr);
12797+
err = perf_allow_kernel();
1279812798
if (err)
1279912799
return err;
1280012800
}
@@ -12814,7 +12814,7 @@ SYSCALL_DEFINE5(perf_event_open,
1281412814

1281512815
/* Only privileged users can get physical addresses */
1281612816
if ((attr.sample_type & PERF_SAMPLE_PHYS_ADDR)) {
12817-
err = perf_allow_kernel(&attr);
12817+
err = perf_allow_kernel();
1281812818
if (err)
1281912819
return err;
1282012820
}
@@ -13647,12 +13647,12 @@ const struct perf_event_attr *perf_event_attrs(struct perf_event *event)
1364713647
return &event->attr;
1364813648
}
1364913649

13650-
int perf_allow_kernel(struct perf_event_attr *attr)
13650+
int perf_allow_kernel(void)
1365113651
{
1365213652
if (sysctl_perf_event_paranoid > 1 && !perfmon_capable())
1365313653
return -EACCES;
1365413654

13655-
return security_perf_event_open(attr, PERF_SECURITY_KERNEL);
13655+
return security_perf_event_open(PERF_SECURITY_KERNEL);
1365613656
}
1365713657
EXPORT_SYMBOL_GPL(perf_allow_kernel);
1365813658

kernel/trace/trace_event_perf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static int perf_trace_event_perm(struct trace_event_call *tp_event,
4949

5050
/* The ftrace function trace is allowed only for root. */
5151
if (ftrace_event_is_function(tp_event)) {
52-
ret = perf_allow_tracepoint(&p_event->attr);
52+
ret = perf_allow_tracepoint();
5353
if (ret)
5454
return ret;
5555

@@ -86,7 +86,7 @@ static int perf_trace_event_perm(struct trace_event_call *tp_event,
8686
* ...otherwise raw tracepoint data can be a severe data leak,
8787
* only allow root to have these.
8888
*/
89-
ret = perf_allow_tracepoint(&p_event->attr);
89+
ret = perf_allow_tracepoint();
9090
if (ret)
9191
return ret;
9292

security/security.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5883,16 +5883,15 @@ EXPORT_SYMBOL(security_bdev_setintegrity);
58835883
#ifdef CONFIG_PERF_EVENTS
58845884
/**
58855885
* security_perf_event_open() - Check if a perf event open is allowed
5886-
* @attr: perf event attribute
58875886
* @type: type of event
58885887
*
58895888
* Check whether the @type of perf_event_open syscall is allowed.
58905889
*
58915890
* Return: Returns 0 if permission is granted.
58925891
*/
5893-
int security_perf_event_open(struct perf_event_attr *attr, int type)
5892+
int security_perf_event_open(int type)
58945893
{
5895-
return call_int_hook(perf_event_open, attr, type);
5894+
return call_int_hook(perf_event_open, type);
58965895
}
58975896

58985897
/**

0 commit comments

Comments
 (0)