linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bo YU <tsu.yubo@gmail.com>
To: l.stach@pengutronix.de, linux+etnaviv@armlinux.org.uk,
	christian.gmeiner@gmail.com, airlied@linux.ie, daniel@ffwll.ch,
	linux-kernel@vger.kernel.org
Cc: Bo YU <tsu.yubo@gmail.com>,
	etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	yuzibode@126.com
Subject: [PATCH v2] drm: etnaviv: fix strncpy sizeof argument
Date: Thu, 28 Mar 2019 04:09:18 -0400	[thread overview]
Message-ID: <20190328080918.9290-1-tsu.yubo@gmail.com> (raw)

Calling strncpy with a maximum size argument of 64 bytes on destination
array "domain->name" of size 64 bytes might leave the destination string
unterminated.

Detected by CoverityScan, CID# 1443992:  Memory - illegal accesses (BUFFER_SIZE_WARNING)

Fixes: 9e2c2e2730126 (drm/etnaviv: add infrastructure to query perf counter)
Signed-off-by: Bo YU <tsu.yubo@gmail.com>
---
v2: accroding to Russell's suggestion, replace strncpy with strlcpy
---
 drivers/gpu/drm/etnaviv/etnaviv_perfmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c
index 4227a4006c34..ce178f23e86a 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_perfmon.c
@@ -414,7 +414,7 @@ int etnaviv_pm_query_dom(struct etnaviv_gpu *gpu,
 
 	domain->id = domain->iter;
 	domain->nr_signals = dom->nr_signals;
-	strncpy(domain->name, dom->name, sizeof(domain->name));
+	strlcpy(domain->name, dom->name, sizeof(domain->name));
 
 	domain->iter++;
 	if (domain->iter == meta->nr_domains)
-- 
2.11.0


             reply	other threads:[~2019-03-28  8:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-28  8:09 Bo YU [this message]
2019-04-02  1:30 ` [PATCH v2] drm: etnaviv: fix strncpy sizeof argument Bo YU

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190328080918.9290-1-tsu.yubo@gmail.com \
    --to=tsu.yubo@gmail.com \
    --cc=airlied@linux.ie \
    --cc=christian.gmeiner@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=etnaviv@lists.freedesktop.org \
    --cc=l.stach@pengutronix.de \
    --cc=linux+etnaviv@armlinux.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yuzibode@126.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).