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]
Date:	Wed, 09 Jan 2013 16:29:39 +0100
From:	Stefani Seibold <stefani@...bold.net>
To:	Yuanhan Liu <yuanhan.liu@...ux.intel.com>
Cc:	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: Re: [PATCH 1/5] kfifo: remove unnecessary type check

Am Mittwoch, den 09.01.2013, 10:35 +0800 schrieb Yuanhan Liu:
> On Tue, Jan 08, 2013 at 10:51:04PM +0100, Stefani Seibold wrote:
> > Am Dienstag, den 08.01.2013, 22:57 +0800 schrieb Yuanhan Liu:
> > > Firstly, this kind of type check doesn't work. It does something similar
> > > as following:
> > > 	void * __dummy = NULL;
> > > 	__buf = __dummy;
> > > 
> > > __dummy is defined as void *. Thus it will not trigger warnings as
> > > expected.
> > > 
> > > Second, we don't need that kind of check. Since the prototype
> > > of __kfifo_out is:
> > > 	unsigned int __kfifo_out(struct __kfifo *fifo,  void *buf, unsigned int len)
> > > 
> > > buf is defined as void *, so we don't need do the type check. Remove it.
> > > 
> > 
> > Thats wrong.
> > 
> > First the type checking will be used in kfifo_put() and kfifo_in() for
> > const types to check if the passed type of the data can converted to the
> > fifo element type. 
> 
> Hi Stefani,
> 
> Yes, I see now. After rechecking the code, I found that this kind of
> type checking only works for those static defined kifo by
> DECLARE/DEFINE_KFIFO. As the ptrtype is the same as the data type:
> 
>     /* the 4th argument "type" is "ptrtype" */
>     #define STRUCT_KFIFO(type, size) struct __STRUCT_KFIFO(type, size, 0, type)
> 
>     #define DECLARE_KFIFO(fifo, type, size) STRUCT_KFIFO(type, size) fifo
> 
> While, for those kfifo dynamically allocated, the type checking will not
> work as expected then as ptrtype is always "void":
> 
>     struct kfifo __STRUCT_KFIFO_PTR(unsigned char, 0, void);
> 

You should avoid using struct kfifo, as you can read in kfifo.h this is
only for compatibility reason.

If you use the macro DECLARE_KFIFO_PTR(), DECLARE_KFIFO() or
DEFINE_KFIFO() instead.

Have a look at the examples files in the samples/kfifo directory.

- Stefani


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ