From patchwork Mon Nov 12 08:08:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10678309 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EFDAA109C for ; Mon, 12 Nov 2018 08:09:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC49529DAD for ; Mon, 12 Nov 2018 08:09:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C889C29DE5; Mon, 12 Nov 2018 08:09:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14CA129DAD for ; Mon, 12 Nov 2018 08:09:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727000AbeKLSBF (ORCPT ); Mon, 12 Nov 2018 13:01:05 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:35760 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727996AbeKLSBF (ORCPT ); Mon, 12 Nov 2018 13:01:05 -0500 Received: by mail-pg1-f194.google.com with SMTP id 32-v6so3718930pgu.2 for ; Mon, 12 Nov 2018 00:09:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=m9syVmk20h9iJikBV9mV25pDAZHRbSgw8coBUpn8zC4=; b=g+SFN7iJJ7kIb0QG1xUwQwFDclxflbzsbM87sIZs73K8naJCLl29gP9ErAvL9dJSgi lFLU2CHczLRDJU1ppjXXk0QU+UQ8wLlentPubBhVqEuYItB6HlQUSCncxwkiszDyVuBC PPb17vwhDKOSxH0SR451BQnrZmqSFUTsFfCp9UDsxHrzGfBVn+xq77pL6iAUcUpDh0by APvu64Kn15qCR/q1ZFpfgdmhQ4/iuh4SaK9A/URxBntqxcsSrj7dGEa/05L9D1W9KdNi U+sv2AKG3qykkfzYP1CeWEHESvp0sA7vJ8cm1GREbyd89kTuugZOq+HHpQK7TOFcYHFd JVSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=m9syVmk20h9iJikBV9mV25pDAZHRbSgw8coBUpn8zC4=; b=oA5IqygtvzHLLyTCnZNJa47eeL4mOeykNK45cspuNttTf693x72y7QJaBBZmwYa7Ef ru8h+lqQWW2SEU9U0h3fubnTHvBEgeoH7fB3zmD+ES7vD1WtCjTvhE5ucYb7vw5XDWjO l1XNYr8fMjkQLv/iMDIv2czMu7VenTRlNlEgNhoTsDqsGhHcjJOSrynK96/xSkwHAjt1 GT27FXPoj9A/P+tdSfiPep6UBxSh8L4GHj0Oeb032+9Uk1YkU3NFQgC49bC5RKBKt7qP JoMsKwUchpEO7V97O9rM0CZcA9CNGNuBQmbyeUExdqyvMwQj4dgmFhUrTiz4W/WXiLKd CK+Q== X-Gm-Message-State: AGRZ1gJwPeAC7wCGR5khPKKot0Z/RLADgkwYLyRdrkDKaBU3/O2TGulx 5dZXRjhnqKQh3yu+/jfD4kEFpUtK7Co= X-Google-Smtp-Source: AJdET5cUnklAOZRiSU8E6YvKiPtRAveNelIlM8hUixiwNsDyn/3ZVDc4VYSwwwb41zLnDH/OQycd1g== X-Received: by 2002:a62:89d7:: with SMTP id n84-v6mr19418544pfk.255.1542010139573; Mon, 12 Nov 2018 00:08:59 -0800 (PST) Received: from vader.hsd1.wa.comcast.net ([2601:602:8b00:55d3:e6a7:a0ff:fe0b:c9a8]) by smtp.gmail.com with ESMTPSA id v12sm12710117pgg.41.2018.11.12.00.08.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 00:08:58 -0800 (PST) From: Omar Sandoval To: linux-block@vger.kernel.org Cc: Jens Axboe , kernel-team@fb.com, Jordan Glover , Bart Van Assche Subject: [PATCH v2] kyber: fix wrong strlcpy() size in trace_kyber_latency() Date: Mon, 12 Nov 2018 00:08:46 -0800 Message-Id: <7cd2a3c7ceed5dea16bc4ccf8edad77e90a49e7a.1542010053.git.osandov@fb.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval 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 Signed-off-by: Omar Sandoval Tested-by: Jordan Glover --- Changes from v1: - Change to using sizeof() instead of constants include/trace/events/kyber.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/trace/events/kyber.h b/include/trace/events/kyber.h index a9834c37ac40..c0e7d24ca256 100644 --- a/include/trace/events/kyber.h +++ b/include/trace/events/kyber.h @@ -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; @@ -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; ), @@ -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),