From: Wenwen Wang <wang6495@umn.edu>
To: Wenwen Wang <wang6495@umn.edu>
Cc: Kangjie Lu <kjlu@umn.edu>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-media@vger.kernel.org (open list:MEDIA INPUT
INFRASTRUCTURE (V4L/DVB)),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] media: dvb: fix a missing-check bug
Date: Fri, 19 Oct 2018 09:12:13 -0500 [thread overview]
Message-ID: <1539958334-11531-1-git-send-email-wang6495@umn.edu> (raw)
In dvb_audio_write(), the first byte of the user-space buffer 'buf' is
firstly copied and checked to see whether this is a TS packet, which always
starts with 0x47 for synchronization purposes. If yes, ts_play() will be
called. Otherwise, dvb_aplay() will be called. In ts_play(), the content of
'buf', including the first byte, is copied again from the user space.
However, after the copy, no check is re-enforced on the first byte of the
copied data. Given that 'buf' is in the user space, a malicious user can
race to change the first byte after the check in dvb_audio_write() but
before the copy in ts_play(). Through this way, the user can supply
inconsistent code, which can cause undefined behavior of the kernel and
introduce potential security risk.
This patch adds a necessary check in ts_play() to make sure the first byte
acquired in the second copy contains the expected value. Otherwise, an
error code EINVAL will be returned.
Signed-off-by: Wenwen Wang <wang6495@umn.edu>
---
drivers/media/pci/ttpci/av7110_av.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/media/pci/ttpci/av7110_av.c b/drivers/media/pci/ttpci/av7110_av.c
index ef1bc17..1ff6062 100644
--- a/drivers/media/pci/ttpci/av7110_av.c
+++ b/drivers/media/pci/ttpci/av7110_av.c
@@ -468,6 +468,8 @@ static ssize_t ts_play(struct av7110 *av7110, const char __user *buf,
}
if (copy_from_user(kb, buf, TS_SIZE))
return -EFAULT;
+ if (kb[0] != 0x47)
+ return -EINVAL;
write_ts_to_decoder(av7110, type, kb, TS_SIZE);
todo -= TS_SIZE;
buf += TS_SIZE;
--
2.7.4
next reply other threads:[~2018-10-19 22:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-19 14:12 Wenwen Wang [this message]
2018-10-29 18:46 ` [PATCH] media: dvb: fix a missing-check bug Wenwen Wang
2018-10-30 4:07 ` Bing Bu Cao
2018-11-27 10:43 ` Sean Young
-- strict thread matches above, loose matches on Subject: below --
2018-10-04 14:59 Wenwen Wang
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=1539958334-11531-1-git-send-email-wang6495@umn.edu \
--to=wang6495@umn.edu \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).