aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@kernellabs.com>2012-05-21 16:47:15 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-08-13 18:51:33 -0400
commitae53020527796a123e61698160b3cf193ce8cf48 (patch)
tree749ed1d2889819028b10591c29af3e7129f87727 /drivers/media/dvb
parentd9bc8510c5fb55ce7092ebc928c0791e738ea5ae (diff)
[media] DVB: improve handling of TS packets containing a raised TEI bit
When the TEI bit is raised, we should not trust any of the contents of the packet in question, including but not limited to its PID number. Considering that we don't trust the PID number of this packet, we should not proceed to check the packet counter (if dvb_demux_tscheck is set). We should expect to see at least one discontinuity after a bad packet is received, so any time a TEI is detected, a following TS packet counter mismatch is to be expected. There is no real reason to ever allow bad packets to pass through the kernel demux, other than for purposes of attempting error correction via software or statistical information. However, since we have always passed these bad packets though the demux, we should not change this default behavior. Without altering module options, this patch merely prevents the TS packet counter check on packets containing a raised TEI. If module option dvb_demux_feed_err_pkts is set to 0, the kernel demux will drop these error packets entirely, preventing any possibility of corruption caused by userspace programs that are expecting valid data. Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/dvb-core/dvb_demux.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/drivers/media/dvb/dvb-core/dvb_demux.c b/drivers/media/dvb/dvb-core/dvb_demux.c
index d82469f842e2..17cb81fd194c 100644
--- a/drivers/media/dvb/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb/dvb-core/dvb_demux.c
@@ -50,6 +50,11 @@ module_param(dvb_demux_speedcheck, int, 0644);
50MODULE_PARM_DESC(dvb_demux_speedcheck, 50MODULE_PARM_DESC(dvb_demux_speedcheck,
51 "enable transport stream speed check"); 51 "enable transport stream speed check");
52 52
53static int dvb_demux_feed_err_pkts = 1;
54module_param(dvb_demux_feed_err_pkts, int, 0644);
55MODULE_PARM_DESC(dvb_demux_feed_err_pkts,
56 "when set to 0, drop packets with the TEI bit set (1 by default)");
57
53#define dprintk_tscheck(x...) do { \ 58#define dprintk_tscheck(x...) do { \
54 if (dvb_demux_tscheck && printk_ratelimit()) \ 59 if (dvb_demux_tscheck && printk_ratelimit()) \
55 printk(x); \ 60 printk(x); \
@@ -426,14 +431,18 @@ static void dvb_dmx_swfilter_packet(struct dvb_demux *demux, const u8 *buf)
426 }; 431 };
427 }; 432 };
428 433
434 if (buf[1] & 0x80) {
435 dprintk_tscheck("TEI detected. "
436 "PID=0x%x data1=0x%x\n",
437 pid, buf[1]);
438 /* data in this packet cant be trusted - drop it unless
439 * module option dvb_demux_feed_err_pkts is set */
440 if (!dvb_demux_feed_err_pkts)
441 return;
442 } else /* if TEI bit is set, pid may be wrong- skip pkt counter */
429 if (demux->cnt_storage && dvb_demux_tscheck) { 443 if (demux->cnt_storage && dvb_demux_tscheck) {
430 /* check pkt counter */ 444 /* check pkt counter */
431 if (pid < MAX_PID) { 445 if (pid < MAX_PID) {
432 if (buf[1] & 0x80)
433 dprintk_tscheck("TEI detected. "
434 "PID=0x%x data1=0x%x\n",
435 pid, buf[1]);
436
437 if ((buf[3] & 0xf) != demux->cnt_storage[pid]) 446 if ((buf[3] & 0xf) != demux->cnt_storage[pid])
438 dprintk_tscheck("TS packet counter mismatch. " 447 dprintk_tscheck("TS packet counter mismatch. "
439 "PID=0x%x expected 0x%x " 448 "PID=0x%x expected 0x%x "