From: Amit Shah <amit.shah@redhat.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
kernel-janitors@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
virtualization@lists.linux-foundation.org
Subject: Re: [patch] virtio_console: use snprintf() for safety
Date: Fri, 8 May 2015 12:01:18 +0530 [thread overview]
Message-ID: <20150508063118.GA6361@grmbl.mre> (raw)
In-Reply-To: <20150508061902.GA14769@mwanda>
On (Fri) 08 May 2015 [09:19:02], Dan Carpenter wrote:
> My static checker complains that this sprintf() can overflow.
>
> vdev->index is selected by ida_simple_get() in register_virtio_device()
> so my reading of the code is that this overflow is theoretically
> possible. The max value of "id" is configurable and I'm not sure what
> typical values are.
vdev->index is per-device, and starts with 0 for the first attached
virtio-serial-pci device. So to overflow, a lot of devices have to be
attached, which isn't possible with current qemu. 16 bytes was
already overkill..
> Anyway, it's simple enough to make the buffer larger and I changed it to
> snprintf() as well.
Any reason to choose 28? I think 16 is enough.
The snprintf change is fine, though.
Amit
next parent reply other threads:[~2015-05-08 6:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20150508061902.GA14769@mwanda>
2015-05-08 6:31 ` Amit Shah [this message]
2015-05-08 9:16 ` [patch v2] virtio_console: silence a static checker warning Dan Carpenter
2015-05-08 9:29 ` Amit Shah
2015-05-08 9:30 ` walter harms
[not found] ` <554C8221.9070304@bfs.de>
2015-05-08 9:47 ` Dan Carpenter
2015-05-08 9:56 ` Amit Shah
[not found] ` <20150508095616.GB5527@grmbl.mre>
2015-05-08 11:13 ` walter harms
[not found] ` <554C9A52.4030707@bfs.de>
2015-05-08 12:18 ` Dan Carpenter
2015-05-08 6:19 [patch] virtio_console: use snprintf() for safety Dan Carpenter
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=20150508063118.GA6361@grmbl.mre \
--to=amit.shah@redhat.com \
--cc=arnd@arndb.de \
--cc=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/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).