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: <CACvQF52jWM1LFQGYZFyktCubt6YWdCx6kd3+aCW=3mCpzCR1Mw@mail.gmail.com>
Date:	Sat, 19 Apr 2014 22:04:06 +0800
From:	Lai Jiangshan <laijs@...fujitsu.com>
To:	Tejun Heo <tj@...nel.org>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Jean Delvare <jdelvare@...e.de>,
	Monam Agarwal <monamagarwal123@...il.com>,
	Jeff Layton <jlayton@...hat.com>,
	Andreas Gruenbacher <agruen@...bit.com>,
	Stephen Hemminger <stephen@...workplumber.org>
Subject: Re: [PATCH 5/9 V2] idr: covert BUG_ON() to WARN_ON_ONCE() if the
 argument is invalid.

On Sat, Apr 19, 2014 at 9:07 PM, Tejun Heo <tj@...nel.org> wrote:
> On Sat, Apr 19, 2014 at 07:38:12PM +0800, Lai Jiangshan wrote:
>> @@ -559,7 +559,7 @@ void idr_remove(struct idr *idp, int id)
>>       struct idr_layer *p;
>>       struct idr_layer *to_free;
>>
>> -     if (id < 0)
>> +     if (WARN_ON_ONCE(id < 0))
>>               return;
>
> ISTR callers which call in with error value, but yeah weeding them out
> could be a good idea.  Shouldn't it be idr_remove_warning() though?

WARN_ON_ONCE() for invalid id (negative id).
idr_remove_warning() for unallocated id.

>
>> @@ -1030,6 +1030,9 @@ void ida_remove(struct ida *ida, int id)
>>       int n;
>>       struct ida_bitmap *bitmap;
>>
>> +     if (WARN_ON_ONCE(id < 0))
>> +             return;
>
> Why not jump to err?

WARN_ON_ONCE() for invalid id (negative id).
"goto err" for unallocated id.

>
>> +
>>       if (idr_id > idr_max(ida->idr.layers))
>>               goto err;
>>
>> @@ -1096,13 +1099,14 @@ int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end,
>>       unsigned int max;
>>       unsigned long flags;
>>
>> -     BUG_ON((int)start < 0);
>> -     BUG_ON((int)end < 0);
>> +     if (WARN_ON_ONCE(((int)start < 0) || ((int)end < 0)))
>> +             return -EINVAL;
>>
>>       if (end == 0)
>>               max = 0x80000000;
>>       else {
>> -             BUG_ON(end < start);
>> +             if (WARN_ON_ONCE(end < start))
>> +                     return -ENOSPC;
>
> -EINVAL

In my V1 patch, it returns -EINVAL.

The V2 changelog explain this change: make the returned value as the
same as idr_alloc().
###
It is important for cyclic allocation (idr_alloc()).

int idr_alloc_cyclic(struct idr *idr, void *ptr, int start, int end,
gfp_t gfp_mask)
{
int id;

id = idr_alloc(idr, ptr, max(start, idr->cur), end, gfp_mask);
if (id == -ENOSPC)
id = idr_alloc(idr, ptr, start, end, gfp_mask);

if (likely(id >= 0))
idr->cur = id + 1;
return id;
}

idr->cur can equals to @end. idr_alloc() should return  -ENOSPC for
next idr_alloc().

>
> Thanks.
>
> --
> tejun
> --
> 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/
--
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