lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <40C2F764-6E43-418B-8904-952C5E99D9D9@getmailspring.com>
Date:   Wed, 6 May 2020 03:55:48 -0300
From:   "Daniel W. S. Almeida" <dwlsalmeida@...il.com>
To:     Mauro Carvalho Chehab <mchehab+huawei@...nel.org>
Cc:     "sean@...s.org" <sean@...s.org>,
        "kstewart@...uxfoundation.org" 
        <kstewart@...uxfoundation.org>,
        "allison@...utok.net" <allison@...utok.net>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "linux-media@...r.kernel.org" 
        <linux-media@...r.kernel.org>,
        "skhan@...uxfoundation.org" <skhan@...uxfoundation.org>,
        "linux-kernel-mentees@...ts.linuxfoundation.org" 
        <linux-kernel-mentees@...ts.linuxfoundation.org>,
        "linux-kernel@...r.kernel.org" 
        <linux-kernel@...r.kernel.org>
Subject: Re: [RFC, WIP, v4 09/11] media: vidtv: implement a PES
 packetizer

Hi Mauro,


> As commented, don't use WARN_ON(). At most, you could use WARN_ON_ONCE(),
> as otherwise, you may end by causing serious performance issues if
> the code starts to produce a flood of warnings at the dmesg.
> 
> I would use pr_warn_ratelimit() on all such cases.
> 

OK.




> I don't like the idea of changing the "from" buffer endiannes, copy
> and then restore it back to the original state. Is this really needed?
> 
> I would, instead, define:
> 
> 	struct pes_header {
> 	...
> 		__be32 bitfield;
> 		__be16 length;
> 	...
> 	};
> 
> Then wherever you would touch them:
> 
> 	u32 bitfield;
> 	u16 len;
> 
> 	/* Write into BE fields */
> 	pes_header.bitfield = cpu_to_be32(bitfield);
> 	pes_header.length = cpu_to_be16(len);
> 
> 	/* Read from BE fields */
> 	bitfield = be32_to_cpu(pes_header.bitfield);
> 	len = be16_to_cpu(pes_header.length);
> 
> 
> As a side effect, when you use "__be16" and "__be32" types, gcc
> and smatch/sparse will warn you if you mess with endiannes.
> 
> Same applies to similar code elsewhere.
> 

I don't like it either, it is error prone. I did not know about this
other possibility. Does this work for _bitfields_ though?

I think the authors for libdvbv5 used unions precisely so bswap() could
be called on a 'bitfield' member and from then on the bitfields could be
accessed directly, e.g.:

	union {
		u16 bitfield; <-- call bswap() on this
		struct {
                        --> then use these directly:
			u8  syntax:1;
			u8  zero:1;
			u8  one:2;
			u16 section_length:12;
		} __packed;
	} __packed

At least that's what I understood.

I found this: 
https://lwn.net/Articles/741762/

Maybe *_get_bits, *_replace_bits is the equivalent that I should use for bitfields?

Because I'd rather not do this:

> 	u32 bitfield;
> 	/* Write into BE fields */
> 	pes_header.bitfield = cpu_to_be32(bitfield);

Since I'd have to write the (many!) bitwise operations myself and I'm
sure I will mess this up at _some_ point.



thanks,
- Daniel


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ