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] [day] [month] [year] [list]
Message-ID: <20121115081801.GB6098@yliu-dev.sh.intel.com>
Date:	Thu, 15 Nov 2012 16:18:01 +0800
From:	Yuanhan Liu <yuanhan.liu@...ux.intel.com>
To:	Stefani Seibold <stefani@...bold.net>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] kfifo: round up the fifo size power of 2

On Wed, Nov 14, 2012 at 08:03:49AM +0100, Stefani Seibold wrote:
> Am Freitag, den 09.11.2012, 10:32 +0800 schrieb Yuanhan Liu:
> > On Thu, Nov 08, 2012 at 01:37:15PM +0100, Stefani Seibold wrote:
> > > Am Donnerstag, den 08.11.2012, 20:24 +0800 schrieb Yuanhan Liu:
> 
> > Yes, it is. I will try log API then.
> > 
> > Stefani, I found an issue while rework to current API. Say the current
> > code of __kfifo_init:
> >     int __kfifo_init(struct __kfifo *fifo, void *buffer,
> >                     unsigned int size, size_t esize)
> >     {
> >         size /= esize;
> > 
> >         if (!is_power_of_2(size))
> >                 size = rounddown_pow_of_two(size);
> >         ....
> >     }
> > 
> > Even thought I changed the API to something like:
> >     int __kfifo_init(struct __kfifo *fifo, void *buffer,
> >                     int size_order, size_t esize)
> >     {
> > 	unsigned int size = 1 << size_order;
> > 
> > 	size /= esize;
> > 	...
> >     }
> > 
> > See? There is still a divide and we can't make it sure that it will be
> > power of 2 after that.
> > 
> > So, I came up 2 proposal to fix this.
> > 
> > 1. refactor the meaning of 'size' argument first.
> > 
> >    'size' means the size of pre-allocated buffer. We can refactor it to
> >    meaning of 'the number of fifo elements' just like __kfifo_alloc, so
> >    that we don't need do the size /= esize stuff.
> > 
> > 2. remove kfifo_init
> > 
> >    As we can't make sure that kfifo will do exactly what users asked(in
> >    the way of fifo size). It would be safe and good to maintain buffer
> >    and buffer size inside kfifo. So, I propose to remove it and use
> >    kfifo_alloc instead.
> > 
> >    git grep 'kfifo_init\>' shows that we currently have 2 users only.
> > 
> > 
> > The first way is hacky, and it doesn't make much sense to me. Since
> > buffer is pre-allocated by user but not kfifo. User has to calculate
> > element size and the number of elements, which is not friendly.
> > 
> > The second way does make more sense to me.
> 
> kfifo_init() was requested by some kernel developers, i never liked it.
> If you have a better and cleaner solution than do it, otherwise kick it
> away if you like.

There are only 2 kfifo_init users: libiscsi.c and libsrp.c under
drivers/scsi/, and they are with same logic.

I propose to replace them with kfifo_alloc. I will make patch for
this later to see if scsi guys OK with it or not.  If OK, we can
remove kfifo_init.

	--yliu
--
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