All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarod Wilson <jarod@redhat.com>
To: Ang Way Chuang <wcang79@gmail.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH] dvb-core: Fix ULE decapsulation bug when less than 4 bytes of ULE SNDU is packed into the remaining bytes of a MPEG2-TS frame
Date: Thu, 27 May 2010 08:30:38 -0400	[thread overview]
Message-ID: <20100527123038.GA15893@redhat.com> (raw)
In-Reply-To: <4BFDFCD1.6020208@gmail.com>

On Thu, May 27, 2010 at 01:02:09PM +0800, Ang Way Chuang wrote:
> ULE (Unidirectional Lightweight Encapsulation RFC 4326)
> decapsulation code has a bug that incorrectly treats ULE SNDU packed
> into the remaining 2 or 3 bytes of a MPEG2-TS frame as having
> invalid pointer field on the subsequent MPEG2-TS frame.
> 
> This patch was generated and tested against the latest Linus's pre
> 2.6.35-rc1 tree.
> 
> Signed-off-by: Ang Way Chuang <wcang@nav6.org>

Looks good to me, thanks for the updated version. Good catch noting that
error needed to be reset to false after it was handled, I'd missed that.

Acked-by: Jarod Wilson <jarod@redhat.com>

> ---
> diff --git a/drivers/media/dvb/dvb-core/dvb_net.c b/drivers/media/dvb/dvb-core/dvb_net.c
> index f6dac2b..6c3a8a0 100644
> --- a/drivers/media/dvb/dvb-core/dvb_net.c
> +++ b/drivers/media/dvb/dvb-core/dvb_net.c
> @@ -351,6 +351,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
> 	const u8 *ts, *ts_end, *from_where = NULL;
> 	u8 ts_remain = 0, how_much = 0, new_ts = 1;
> 	struct ethhdr *ethh = NULL;
> +	bool error = false;
> 
> #ifdef ULE_DEBUG
> 	/* The code inside ULE_DEBUG keeps a history of the last 100 TS cells processed. */
> @@ -460,10 +461,16 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
> 
> 						/* Drop partly decoded SNDU, reset state, resync on PUSI. */
> 						if (priv->ule_skb) {
> -							dev_kfree_skb( priv->ule_skb );
> +							error = true;
> +							dev_kfree_skb(priv->ule_skb);
> +						}
> +
> +						if (error || priv->ule_sndu_remain) {
> 							dev->stats.rx_errors++;
> 							dev->stats.rx_frame_errors++;
> +							error = false;
> 						}
> +
> 						reset_ule(priv);
> 						priv->need_pusi = 1;
> 						continue;
> @@ -535,6 +542,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
> 				from_where += 2;
> 			}
> 
> +			priv->ule_sndu_remain = priv->ule_sndu_len + 2;
> 			/*
> 			 * State of current TS:
> 			 *   ts_remain (remaining bytes in the current TS cell)
> @@ -544,6 +552,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
> 			 */
> 			switch (ts_remain) {
> 				case 1:
> +					priv->ule_sndu_remain--;
> 					priv->ule_sndu_type = from_where[0] << 8;
> 					priv->ule_sndu_type_1 = 1; /* first byte of ule_type is set. */
> 					ts_remain -= 1; from_where += 1;
> @@ -557,6 +566,7 @@ static void dvb_net_ule( struct net_device *dev, const u8 *buf, size_t buf_len )
> 				default: /* complete ULE header is present in current TS. */
> 					/* Extract ULE type field. */
> 					if (priv->ule_sndu_type_1) {
> +						priv->ule_sndu_type_1 = 0;
> 						priv->ule_sndu_type |= from_where[0];
> 						from_where += 1; /* points to payload start. */
> 						ts_remain -= 1;

-- 
Jarod Wilson
jarod@redhat.com


  reply	other threads:[~2010-05-27 12:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-27  5:02 [PATCH] dvb-core: Fix ULE decapsulation bug when less than 4 bytes of ULE SNDU is packed into the remaining bytes of a MPEG2-TS frame Ang Way Chuang
2010-05-27 12:30 ` Jarod Wilson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2010-05-06 14:52 Ang Way Chuang
2010-05-06 12:19 Ang Way Chuang
2009-11-23  9:37 Ang Way Chuang
2009-11-23  9:37 ` Ang Way Chuang
2009-11-24  1:34 ` Ang Way Chuang
2009-11-24  1:34   ` Ang Way Chuang
2009-11-24  8:00 ` Dan Carpenter
2009-11-24  8:04   ` Ang Way Chuang
2009-11-24  8:04     ` Ang Way Chuang
2009-11-24  8:07     ` Ang Way Chuang
2009-11-24  8:07       ` Ang Way Chuang
2009-11-17 10:00 Ang Way Chuang
2009-11-17  9:56 Ang Way Chuang

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=20100527123038.GA15893@redhat.com \
    --to=jarod@redhat.com \
    --cc=linux-media@vger.kernel.org \
    --cc=wcang79@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.