Skip to content

Commit 587edd7

Browse files
aeglbp3tk0v
authored andcommitted
x86/resctrl: Initialize on-stack struct rmid_read instances
New semantics rely on some struct rmid_read members having NULL values to distinguish between the SNC and non-SNC scenarios. resctrl can thus no longer rely on this struct not being initialized properly. Initialize all on-stack declarations of struct rmid_read: rdtgroup_mondata_show() mbm_update() mkdir_mondata_subdir() to ensure that garbage values from the stack are not passed down to other functions. [ bp: Massage commit message. ] Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Tested-by: Babu Moger <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fb1f51f commit 587edd7

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

arch/x86/kernel/cpu/resctrl/ctrlmondata.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ void mon_event_read(struct rmid_read *rr, struct rdt_resource *r,
529529
rr->evtid = evtid;
530530
rr->r = r;
531531
rr->d = d;
532-
rr->val = 0;
533532
rr->first = first;
534533
rr->arch_mon_ctx = resctrl_arch_mon_ctx_alloc(r, evtid);
535534
if (IS_ERR(rr->arch_mon_ctx)) {
@@ -557,12 +556,12 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg)
557556
{
558557
struct kernfs_open_file *of = m->private;
559558
struct rdt_domain_hdr *hdr;
559+
struct rmid_read rr = {0};
560560
struct rdt_mon_domain *d;
561561
u32 resid, evtid, domid;
562562
struct rdtgroup *rdtgrp;
563563
struct rdt_resource *r;
564564
union mon_data_bits md;
565-
struct rmid_read rr;
566565
int ret = 0;
567566

568567
rdtgrp = rdtgroup_kn_lock_live(of->kn);

arch/x86/kernel/cpu/resctrl/monitor.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,9 +780,8 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_mon_domain *dom_mbm)
780780
static void mbm_update(struct rdt_resource *r, struct rdt_mon_domain *d,
781781
u32 closid, u32 rmid)
782782
{
783-
struct rmid_read rr;
783+
struct rmid_read rr = {0};
784784

785-
rr.first = false;
786785
rr.r = r;
787786
rr.d = d;
788787

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3029,10 +3029,10 @@ static int mkdir_mondata_subdir(struct kernfs_node *parent_kn,
30293029
struct rdt_mon_domain *d,
30303030
struct rdt_resource *r, struct rdtgroup *prgrp)
30313031
{
3032+
struct rmid_read rr = {0};
30323033
union mon_data_bits priv;
30333034
struct kernfs_node *kn;
30343035
struct mon_evt *mevt;
3035-
struct rmid_read rr;
30363036
char name[32];
30373037
int ret;
30383038

0 commit comments

Comments
 (0)