Skip to content

[fips-9-compliant] net: sched: use RCU read-side critical section in taprio_dump() #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions net/sched/sch_taprio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1890,10 +1890,6 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb)
struct nlattr *nest, *sched_nest;
unsigned int i;

rcu_read_lock();
oper = rcu_dereference(q->oper_sched);
admin = rcu_dereference(q->admin_sched);

Comment on lines -1893 to -1896
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the first thing that jumped out the rcu_read_lock() this is not in the original sha

opt.num_tc = netdev_get_num_tc(dev);
memcpy(opt.prio_tc_map, dev->prio_tc_map, sizeof(opt.prio_tc_map));

Expand All @@ -1920,15 +1916,20 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb)
nla_put_u32(skb, TCA_TAPRIO_ATTR_TXTIME_DELAY, q->txtime_delay))
goto options_error;

rcu_read_lock();

Comment on lines +1919 to +1920
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2/?
However its added in here along with the label ptions_error_rcu: below and the fact that the done: label with rcu_unlock was already in the code, (I can't highlight this section because its out of scope. but its on lines 1938-1939

oper = rtnl_dereference(q->oper_sched);
admin = rtnl_dereference(q->admin_sched);

if (oper && dump_schedule(skb, oper))
goto options_error;
goto options_error_rcu;

if (!admin)
goto done;

sched_nest = nla_nest_start_noflag(skb, TCA_TAPRIO_ATTR_ADMIN_SCHED);
if (!sched_nest)
goto options_error;
goto options_error_rcu;

if (dump_schedule(skb, admin))
goto admin_error;
Expand All @@ -1943,6 +1944,9 @@ static int taprio_dump(struct Qdisc *sch, struct sk_buff *skb)
admin_error:
nla_nest_cancel(skb, sched_nest);

options_error_rcu:
rcu_read_unlock();

options_error:
nla_nest_cancel(skb, nest);

Expand Down