Linux Security Modules development
 help / color / mirror / Atom feed
* [PATCH v2] media: dvb-core: extirpate defective and unsafe ULE debug block
@ 2026-09-05 14:22 Breno Rodrigues Alves
  2026-09-07 19:13 ` kernel test robot
  2026-09-07 21:59 ` kernel test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Breno Rodrigues Alves @ 2026-09-05 14:22 UTC (permalink / raw)
  To: gregkh
  Cc: torvalds, linux-media, linux-security-module, linux-kernel,
	Breno Rodrigues Alves

Completely purge the unmaintained DVB_ULE_DEBUG code block from
dvb_net.c and its Kconfig definition to eliminate severe lockless race
conditions and clean up the unused function signature parameter.

Assisted-by: OpenCode AI
Signed-off-by: Breno Rodrigues Alves <breno3011alves@gmail.com>
---
 drivers/media/dvb-core/Kconfig   | 11 ---------
 drivers/media/dvb-core/dvb_net.c | 42 +-------------------------------
 2 files changed, 1 insertion(+), 52 deletions(-)

diff --git a/drivers/media/dvb-core/Kconfig b/drivers/media/dvb-core/Kconfig
index 8b3f2d53c..c6a97add8 100644
--- a/drivers/media/dvb-core/Kconfig
+++ b/drivers/media/dvb-core/Kconfig
@@ -67,14 +67,3 @@ config DVB_DEMUX_SECTION_LOSS_LOG
 
 	  If you are unsure about this, say N here.
 
-config DVB_ULE_DEBUG
-	bool "Enable DVB net ULE packet debug messages"
-	depends on DVB_CORE
-	help
-	  Enable extra log messages meant to detect problems while
-	  handling DVB network ULE packet loss inside the Kernel.
-
-	  Should not be enabled on normal cases, as logs can
-	  be very verbose.
-
-	  If you are unsure about this, say N here.
diff --git a/drivers/media/dvb-core/dvb_net.c b/drivers/media/dvb-core/dvb_net.c
index a2159b2bc..5060b8866 100644
--- a/drivers/media/dvb-core/dvb_net.c
+++ b/drivers/media/dvb-core/dvb_net.c
@@ -68,19 +68,6 @@ static inline __u32 iov_crc32( __u32 c, struct kvec *iov, unsigned int cnt )
 
 #define DVB_NET_MULTICAST_MAX 10
 
-#ifdef DVB_ULE_DEBUG
-/*
- * The code inside DVB_ULE_DEBUG keeps a history of the
- * last 100 TS cells processed.
- */
-static unsigned char ule_hist[100*TS_SZ] = { 0 };
-static unsigned char *ule_where = ule_hist, ule_dump;
-
-static void hexdump(const unsigned char *buf, unsigned short len)
-{
-	print_hex_dump_debug("", DUMP_PREFIX_OFFSET, 16, 1, buf, len, true);
-}
-#endif
 
 struct dvb_net_priv {
 	int in_use;
@@ -320,16 +307,6 @@ static int dvb_net_ule_new_ts_cell(struct dvb_net_ule_handle *h)
 {
 	/* We are about to process a new TS cell. */
 
-#ifdef DVB_ULE_DEBUG
-	if (ule_where >= &ule_hist[100*TS_SZ])
-		ule_where = ule_hist;
-	memcpy(ule_where, h->ts, TS_SZ);
-	if (ule_dump) {
-		hexdump(ule_where, TS_SZ);
-		ule_dump = 0;
-	}
-	ule_where += TS_SZ;
-#endif
 
 	/*
 	 * Check TS h->error conditions: sync_byte, transport_error_indicator,
@@ -659,23 +636,6 @@ static void dvb_net_ule_check_crc(struct dvb_net_ule_handle *h,
 			h->ts_remain > 2 ?
 				*(unsigned short *)h->from_where : 0);
 
-	#ifdef DVB_ULE_DEBUG
-		hexdump(iov[0].iov_base, iov[0].iov_len);
-		hexdump(iov[1].iov_base, iov[1].iov_len);
-		hexdump(iov[2].iov_base, iov[2].iov_len);
-
-		if (ule_where == ule_hist) {
-			hexdump(&ule_hist[98*TS_SZ], TS_SZ);
-			hexdump(&ule_hist[99*TS_SZ], TS_SZ);
-		} else if (ule_where == &ule_hist[TS_SZ]) {
-			hexdump(&ule_hist[99*TS_SZ], TS_SZ);
-			hexdump(ule_hist, TS_SZ);
-		} else {
-			hexdump(ule_where - TS_SZ - TS_SZ, TS_SZ);
-			hexdump(ule_where - TS_SZ, TS_SZ);
-		}
-		ule_dump = 1;
-	#endif
 
 		h->dev->stats.rx_errors++;
 		h->dev->stats.rx_crc_errors++;
@@ -843,7 +803,7 @@ static void dvb_net_ule(struct net_device *dev, const u8 *buf, size_t buf_len)
 				       *(tail - 2) << 8 |
 				       *(tail - 1);
 
-			dvb_net_ule_check_crc(&h, iov, ule_crc, expected_crc);
+			dvb_net_ule_check_crc(&h, ule_crc, expected_crc);
 
 			/* Prepare for next SNDU. */
 			reset_ule(h.priv);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] media: dvb-core: extirpate defective and unsafe ULE debug block
  2026-09-05 14:22 [PATCH v2] media: dvb-core: extirpate defective and unsafe ULE debug block Breno Rodrigues Alves
@ 2026-09-07 19:13 ` kernel test robot
  2026-09-07 21:59 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-09-07 19:13 UTC (permalink / raw)
  To: Breno Rodrigues Alves, gregkh
  Cc: oe-kbuild-all, torvalds, linux-media, linux-security-module,
	linux-kernel, Breno Rodrigues Alves

Hi Breno,

kernel test robot noticed the following build errors:

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on staging/staging-next staging/staging-linus linuxtv-media-pending/master media-tree/master sailus-media-tree/master linus/master linux/master sailus-media-tree/streams v7.3-rc2 next-20260907]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Breno-Rodrigues-Alves/media-dvb-core-extirpate-defective-and-unsafe-ULE-debug-block/20260905-112222
base:   staging/staging-testing
patch link:    https://lore.kernel.org/r/20260905142222.22818-1-breno3011alves%40gmail.com
patch subject: [PATCH v2] media: dvb-core: extirpate defective and unsafe ULE debug block
config: x86_64-randconfig-r071-20260907 (https://download.01.org/0day-ci/archive/20260908/202609080307.AVMbAAz0-lkp@intel.com/config)
compiler: clang version 22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb4502213fcf902a211)
smatch: v0.5.0-9187-g5189e3fb
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260908/202609080307.AVMbAAz0-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202609080307.AVMbAAz0-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/media/dvb-core/dvb_net.c:806:51: error: too few arguments to function call, expected 4, have 3
     806 |                         dvb_net_ule_check_crc(&h, ule_crc, expected_crc);
         |                         ~~~~~~~~~~~~~~~~~~~~~                          ^
   drivers/media/dvb-core/dvb_net.c:625:13: note: 'dvb_net_ule_check_crc' declared here
     625 | static void dvb_net_ule_check_crc(struct dvb_net_ule_handle *h,
         |             ^                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     626 |                                   struct kvec iov[3],
         |                                   ~~~~~~~~~~~~~~~~~~~
     627 |                                   u32 ule_crc, u32 expected_crc)
         |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   1 error generated.


vim +806 drivers/media/dvb-core/dvb_net.c

   721	
   722	static void dvb_net_ule(struct net_device *dev, const u8 *buf, size_t buf_len)
   723	{
   724		int ret;
   725		struct dvb_net_ule_handle h = {
   726			.dev = dev,
   727			.priv = netdev_priv(dev),
   728			.ethh = NULL,
   729			.buf = buf,
   730			.buf_len = buf_len,
   731			.skipped = 0L,
   732			.ts = NULL,
   733			.ts_end = NULL,
   734			.from_where = NULL,
   735			.ts_remain = 0,
   736			.how_much = 0,
   737			.new_ts = 1,
   738			.error = false,
   739		};
   740	
   741		/*
   742		 * For all TS cells in current buffer.
   743		 * Appearently, we are called for every single TS cell.
   744		 */
   745		for (h.ts = h.buf, h.ts_end = h.buf + h.buf_len;
   746		     h.ts < h.ts_end; /* no incr. */) {
   747			if (h.new_ts) {
   748				/* We are about to process a new TS cell. */
   749				if (dvb_net_ule_new_ts_cell(&h))
   750					continue;
   751			}
   752	
   753			/* Synchronize on PUSI, if required. */
   754			if (h.priv->need_pusi) {
   755				if (dvb_net_ule_ts_pusi(&h))
   756					continue;
   757			}
   758	
   759			if (h.new_ts) {
   760				if (dvb_net_ule_new_ts(&h))
   761					continue;
   762			}
   763	
   764			/* Check if new payload needs to be started. */
   765			if (h.priv->ule_skb == NULL) {
   766				ret = dvb_net_ule_new_payload(&h);
   767				if (ret < 0)
   768					return;
   769				if (ret)
   770					continue;
   771			}
   772	
   773			/* Copy data into our current skb. */
   774			h.how_much = min(h.priv->ule_sndu_remain, (int)h.ts_remain);
   775			skb_put_data(h.priv->ule_skb, h.from_where, h.how_much);
   776			h.priv->ule_sndu_remain -= h.how_much;
   777			h.ts_remain -= h.how_much;
   778			h.from_where += h.how_much;
   779	
   780			/* Check for complete payload. */
   781			if (h.priv->ule_sndu_remain <= 0) {
   782				/* Check CRC32, we've got it in our skb already. */
   783				__be16 ulen = htons(h.priv->ule_sndu_len);
   784				__be16 utype = htons(h.priv->ule_sndu_type);
   785				const u8 *tail;
   786				struct kvec iov[3] = {
   787					{ &ulen, sizeof ulen },
   788					{ &utype, sizeof utype },
   789					{ h.priv->ule_skb->data,
   790					  h.priv->ule_skb->len - 4 }
   791				};
   792				u32 ule_crc = ~0L, expected_crc;
   793				if (h.priv->ule_dbit) {
   794					/* Set D-bit for CRC32 verification,
   795					 * if it was set originally. */
   796					ulen |= htons(0x8000);
   797				}
   798	
   799				ule_crc = iov_crc32(ule_crc, iov, 3);
   800				tail = skb_tail_pointer(h.priv->ule_skb);
   801				expected_crc = *(tail - 4) << 24 |
   802					       *(tail - 3) << 16 |
   803					       *(tail - 2) << 8 |
   804					       *(tail - 1);
   805	
 > 806				dvb_net_ule_check_crc(&h, ule_crc, expected_crc);
   807	
   808				/* Prepare for next SNDU. */
   809				reset_ule(h.priv);
   810			}
   811	
   812			/* More data in current TS (look at the bytes following the CRC32)? */
   813			if (h.ts_remain >= 2 && *((unsigned short *)h.from_where) != 0xFFFF) {
   814				/* Next ULE SNDU starts right there. */
   815				h.new_ts = 0;
   816				h.priv->ule_skb = NULL;
   817				h.priv->ule_sndu_type_1 = 0;
   818				h.priv->ule_sndu_len = 0;
   819				// pr_warn("More data in current TS: [%#x %#x %#x %#x]\n",
   820				//	*(h.from_where + 0), *(h.from_where + 1),
   821				//	*(h.from_where + 2), *(h.from_where + 3));
   822				// pr_warn("h.ts @ %p, stopped @ %p:\n", h.ts, h.from_where + 0);
   823				// hexdump(h.ts, 188);
   824			} else {
   825				h.new_ts = 1;
   826				h.ts += TS_SZ;
   827				h.priv->ts_count++;
   828				if (h.priv->ule_skb == NULL) {
   829					h.priv->need_pusi = 1;
   830					h.priv->ule_sndu_type_1 = 0;
   831					h.priv->ule_sndu_len = 0;
   832				}
   833			}
   834		}	/* for all available TS cells */
   835	}
   836	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] media: dvb-core: extirpate defective and unsafe ULE debug block
  2026-09-05 14:22 [PATCH v2] media: dvb-core: extirpate defective and unsafe ULE debug block Breno Rodrigues Alves
  2026-09-07 19:13 ` kernel test robot
@ 2026-09-07 21:59 ` kernel test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-09-07 21:59 UTC (permalink / raw)
  To: Breno Rodrigues Alves, gregkh
  Cc: oe-kbuild-all, torvalds, linux-media, linux-security-module,
	linux-kernel, Breno Rodrigues Alves

Hi Breno,

kernel test robot noticed the following build errors:

[auto build test ERROR on staging/staging-testing]
[also build test ERROR on staging/staging-next staging/staging-linus linuxtv-media-pending/master media-tree/master sailus-media-tree/master linus/master linux/master sailus-media-tree/streams v7.3-rc2 next-20260907]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Breno-Rodrigues-Alves/media-dvb-core-extirpate-defective-and-unsafe-ULE-debug-block/20260905-112222
base:   staging/staging-testing
patch link:    https://lore.kernel.org/r/20260905142222.22818-1-breno3011alves%40gmail.com
patch subject: [PATCH v2] media: dvb-core: extirpate defective and unsafe ULE debug block
config: nios2-allmodconfig (https://download.01.org/0day-ci/archive/20260908/202609080524.kwJEdv90-lkp@intel.com/config)
compiler: nios2-linux-gcc (GCC) 11.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260908/202609080524.kwJEdv90-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202609080524.kwJEdv90-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   drivers/media/dvb-core/dvb_net.c: In function 'dvb_net_ule':
>> drivers/media/dvb-core/dvb_net.c:806:51: warning: passing argument 2 of 'dvb_net_ule_check_crc' makes pointer from integer without a cast [-Wint-conversion]
     806 |                         dvb_net_ule_check_crc(&h, ule_crc, expected_crc);
         |                                                   ^~~~~~~
         |                                                   |
         |                                                   u32 {aka unsigned int}
   drivers/media/dvb-core/dvb_net.c:626:47: note: expected 'struct kvec *' but argument is of type 'u32' {aka 'unsigned int'}
     626 |                                   struct kvec iov[3],
         |                                   ~~~~~~~~~~~~^~~~~~
>> drivers/media/dvb-core/dvb_net.c:806:25: error: too few arguments to function 'dvb_net_ule_check_crc'
     806 |                         dvb_net_ule_check_crc(&h, ule_crc, expected_crc);
         |                         ^~~~~~~~~~~~~~~~~~~~~
   drivers/media/dvb-core/dvb_net.c:625:13: note: declared here
     625 | static void dvb_net_ule_check_crc(struct dvb_net_ule_handle *h,
         |             ^~~~~~~~~~~~~~~~~~~~~


vim +/dvb_net_ule_check_crc +806 drivers/media/dvb-core/dvb_net.c

   721	
   722	static void dvb_net_ule(struct net_device *dev, const u8 *buf, size_t buf_len)
   723	{
   724		int ret;
   725		struct dvb_net_ule_handle h = {
   726			.dev = dev,
   727			.priv = netdev_priv(dev),
   728			.ethh = NULL,
   729			.buf = buf,
   730			.buf_len = buf_len,
   731			.skipped = 0L,
   732			.ts = NULL,
   733			.ts_end = NULL,
   734			.from_where = NULL,
   735			.ts_remain = 0,
   736			.how_much = 0,
   737			.new_ts = 1,
   738			.error = false,
   739		};
   740	
   741		/*
   742		 * For all TS cells in current buffer.
   743		 * Appearently, we are called for every single TS cell.
   744		 */
   745		for (h.ts = h.buf, h.ts_end = h.buf + h.buf_len;
   746		     h.ts < h.ts_end; /* no incr. */) {
   747			if (h.new_ts) {
   748				/* We are about to process a new TS cell. */
   749				if (dvb_net_ule_new_ts_cell(&h))
   750					continue;
   751			}
   752	
   753			/* Synchronize on PUSI, if required. */
   754			if (h.priv->need_pusi) {
   755				if (dvb_net_ule_ts_pusi(&h))
   756					continue;
   757			}
   758	
   759			if (h.new_ts) {
   760				if (dvb_net_ule_new_ts(&h))
   761					continue;
   762			}
   763	
   764			/* Check if new payload needs to be started. */
   765			if (h.priv->ule_skb == NULL) {
   766				ret = dvb_net_ule_new_payload(&h);
   767				if (ret < 0)
   768					return;
   769				if (ret)
   770					continue;
   771			}
   772	
   773			/* Copy data into our current skb. */
   774			h.how_much = min(h.priv->ule_sndu_remain, (int)h.ts_remain);
   775			skb_put_data(h.priv->ule_skb, h.from_where, h.how_much);
   776			h.priv->ule_sndu_remain -= h.how_much;
   777			h.ts_remain -= h.how_much;
   778			h.from_where += h.how_much;
   779	
   780			/* Check for complete payload. */
   781			if (h.priv->ule_sndu_remain <= 0) {
   782				/* Check CRC32, we've got it in our skb already. */
   783				__be16 ulen = htons(h.priv->ule_sndu_len);
   784				__be16 utype = htons(h.priv->ule_sndu_type);
   785				const u8 *tail;
   786				struct kvec iov[3] = {
   787					{ &ulen, sizeof ulen },
   788					{ &utype, sizeof utype },
   789					{ h.priv->ule_skb->data,
   790					  h.priv->ule_skb->len - 4 }
   791				};
   792				u32 ule_crc = ~0L, expected_crc;
   793				if (h.priv->ule_dbit) {
   794					/* Set D-bit for CRC32 verification,
   795					 * if it was set originally. */
   796					ulen |= htons(0x8000);
   797				}
   798	
   799				ule_crc = iov_crc32(ule_crc, iov, 3);
   800				tail = skb_tail_pointer(h.priv->ule_skb);
   801				expected_crc = *(tail - 4) << 24 |
   802					       *(tail - 3) << 16 |
   803					       *(tail - 2) << 8 |
   804					       *(tail - 1);
   805	
 > 806				dvb_net_ule_check_crc(&h, ule_crc, expected_crc);
   807	
   808				/* Prepare for next SNDU. */
   809				reset_ule(h.priv);
   810			}
   811	
   812			/* More data in current TS (look at the bytes following the CRC32)? */
   813			if (h.ts_remain >= 2 && *((unsigned short *)h.from_where) != 0xFFFF) {
   814				/* Next ULE SNDU starts right there. */
   815				h.new_ts = 0;
   816				h.priv->ule_skb = NULL;
   817				h.priv->ule_sndu_type_1 = 0;
   818				h.priv->ule_sndu_len = 0;
   819				// pr_warn("More data in current TS: [%#x %#x %#x %#x]\n",
   820				//	*(h.from_where + 0), *(h.from_where + 1),
   821				//	*(h.from_where + 2), *(h.from_where + 3));
   822				// pr_warn("h.ts @ %p, stopped @ %p:\n", h.ts, h.from_where + 0);
   823				// hexdump(h.ts, 188);
   824			} else {
   825				h.new_ts = 1;
   826				h.ts += TS_SZ;
   827				h.priv->ts_count++;
   828				if (h.priv->ule_skb == NULL) {
   829					h.priv->need_pusi = 1;
   830					h.priv->ule_sndu_type_1 = 0;
   831					h.priv->ule_sndu_len = 0;
   832				}
   833			}
   834		}	/* for all available TS cells */
   835	}
   836	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-07 21:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-05 14:22 [PATCH v2] media: dvb-core: extirpate defective and unsafe ULE debug block Breno Rodrigues Alves
2026-09-07 19:13 ` kernel test robot
2026-09-07 21:59 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox