Linux-Next discussions
 help / color / mirror / Atom feed
From: coverity-bot <keescook@chromium.org>
To: Maxime Ripard <maxime@cerno.tech>
Cc: linux-kernel@vger.kernel.org, "Daniel Vetter" <daniel@ffwll.ch>,
	"Mateusz Kwiatkowski" <kfyatek+publicgit@gmail.com>,
	"David Airlie" <airlied@gmail.com>,
	dri-devel@lists.freedesktop.org,
	"Maxime Ripard" <mripard@kernel.org>,
	"Noralf Trønnes" <noralf@tronnes.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
	linux-next@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Coverity: drm_mode_parse_cmdline_named_mode(): Security best practices violations
Date: Thu, 17 Nov 2022 14:18:18 -0800	[thread overview]
Message-ID: <202211171417.5A924A838@keescook> (raw)

Hello!

This is an experimental semi-automated report about issues detected by
Coverity from a scan of next-20221117 as part of the linux-next scan project:
https://scan.coverity.com/projects/linux-next-weekly-scan

You're getting this email because you were associated with the identified
lines of code (noted below) that were touched by commits:

  Tue Nov 15 10:09:44 2022 +0100
    a7ab155397dd ("drm/modes: Switch to named mode descriptors")

Coverity reported the following:

*** CID 1527354:  Security best practices violations  (STRING_OVERFLOW)
drivers/gpu/drm/drm_modes.c:1812 in drm_mode_parse_cmdline_named_mode()
1806     		int ret;
1807
1808     		ret = str_has_prefix(name, mode->name);
1809     		if (ret != name_end)
1810     			continue;
1811
vvv     CID 1527354:  Security best practices violations  (STRING_OVERFLOW)
vvv     You might overrun the 32-character fixed-size string "cmdline_mode->name" by copying "mode->name" without checking the length.
1812     		strcpy(cmdline_mode->name, mode->name);
1813     		cmdline_mode->pixel_clock = mode->pixel_clock_khz;
1814     		cmdline_mode->xres = mode->xres;
1815     		cmdline_mode->yres = mode->yres;
1816     		cmdline_mode->interlace = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
1817     		cmdline_mode->specified = true;

If this is a false positive, please let us know so we can mark it as
such, or teach the Coverity rules to be smarter. If not, please make
sure fixes get into linux-next. :) For patches fixing this, please
include these lines (but double-check the "Fixes" first):

Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1527354 ("Security best practices violations")
Fixes: a7ab155397dd ("drm/modes: Switch to named mode descriptors")

Since mode->name is unbounded, this may overrun cmdline_mode->name
without CONFIG_FORTIFY_SOURCE=y. Please use strscpy().

Thanks for your attention!

-- 
Coverity-bot

                 reply	other threads:[~2022-11-17 22:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202211171417.5A924A838@keescook \
    --to=keescook@chromium.org \
    --cc=airlied@gmail.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavo@embeddedor.com \
    --cc=kfyatek+publicgit@gmail.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=maxime@cerno.tech \
    --cc=mripard@kernel.org \
    --cc=noralf@tronnes.org \
    --cc=tzimmermann@suse.de \
    /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