Skip to content

Commit

Permalink
kyber: fix wrong strlcpy() size in trace_kyber_latency()
Browse files Browse the repository at this point in the history
When copying to the latency type, we should be passing LATENCY_TYPE_LEN,
not DOMAIN_LEN (this isn't a problem in practice because we only pass
"total" or "I/O"). Fix it by changing all of the strlcpy() calls to use
sizeof().

Fixes: 6c3b7af ("kyber: add tracepoints")
Reported-by: Jordan Glover <[email protected]>
Tested-by: Jordan Glover <[email protected]>
Signed-off-by: Omar Sandoval <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
osandov authored and axboe committed Nov 12, 2018
1 parent de7b75d commit 18e962a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/trace/events/kyber.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ TRACE_EVENT(kyber_latency,

TP_fast_assign(
__entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent)));
strlcpy(__entry->domain, domain, DOMAIN_LEN);
strlcpy(__entry->type, type, DOMAIN_LEN);
strlcpy(__entry->domain, domain, sizeof(__entry->domain));
strlcpy(__entry->type, type, sizeof(__entry->type));
__entry->percentile = percentile;
__entry->numerator = numerator;
__entry->denominator = denominator;
Expand Down Expand Up @@ -60,7 +60,7 @@ TRACE_EVENT(kyber_adjust,

TP_fast_assign(
__entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent)));
strlcpy(__entry->domain, domain, DOMAIN_LEN);
strlcpy(__entry->domain, domain, sizeof(__entry->domain));
__entry->depth = depth;
),

Expand All @@ -82,7 +82,7 @@ TRACE_EVENT(kyber_throttled,

TP_fast_assign(
__entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent)));
strlcpy(__entry->domain, domain, DOMAIN_LEN);
strlcpy(__entry->domain, domain, sizeof(__entry->domain));
),

TP_printk("%d,%d %s", MAJOR(__entry->dev), MINOR(__entry->dev),
Expand Down

0 comments on commit 18e962a

Please sign in to comment.