Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kyber: fix wrong strlcpy() size in trace_kyber_latency()

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: 6c3b7af1c975 ("kyber: add tracepoints")
Reported-by: Jordan Glover <Golden_Miller83@protonmail.ch>
Tested-by: Jordan Glover <Golden_Miller83@protonmail.ch>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Omar Sandoval and committed by
Jens Axboe
18e962ac de7b75d8

+4 -4
+4 -4
include/trace/events/kyber.h
··· 31 31 32 32 TP_fast_assign( 33 33 __entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent))); 34 - strlcpy(__entry->domain, domain, DOMAIN_LEN); 35 - strlcpy(__entry->type, type, DOMAIN_LEN); 34 + strlcpy(__entry->domain, domain, sizeof(__entry->domain)); 35 + strlcpy(__entry->type, type, sizeof(__entry->type)); 36 36 __entry->percentile = percentile; 37 37 __entry->numerator = numerator; 38 38 __entry->denominator = denominator; ··· 60 60 61 61 TP_fast_assign( 62 62 __entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent))); 63 - strlcpy(__entry->domain, domain, DOMAIN_LEN); 63 + strlcpy(__entry->domain, domain, sizeof(__entry->domain)); 64 64 __entry->depth = depth; 65 65 ), 66 66 ··· 82 82 83 83 TP_fast_assign( 84 84 __entry->dev = disk_devt(dev_to_disk(kobj_to_dev(q->kobj.parent))); 85 - strlcpy(__entry->domain, domain, DOMAIN_LEN); 85 + strlcpy(__entry->domain, domain, sizeof(__entry->domain)); 86 86 ), 87 87 88 88 TP_printk("%d,%d %s", MAJOR(__entry->dev), MINOR(__entry->dev),