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:	Mon, 4 Feb 2013 08:37:16 -0800
From:	Tejun Heo <tj@...nel.org>
To:	Vlad Yasevich <vyasevich@...il.com>
Cc:	akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
	rusty@...tcorp.com.au, bfields@...ldses.org,
	skinsbursky@...allels.com, ebiederm@...ssion.com,
	jmorris@...ei.org, axboe@...nel.dk,
	Sridhar Samudrala <sri@...ibm.com>,
	Neil Horman <nhorman@...driver.com>, linux-sctp@...r.kernel.org
Subject: Re: [PATCH 60/62] sctp: convert to idr_alloc()

On Mon, Feb 04, 2013 at 11:22:26AM -0500, Vlad Yasevich wrote:
> >+	ret = idr_alloc(&sctp_assocs_id, asoc, idr_low, 0, GFP_NOWAIT);
> >+	if (ret >= 0) {
> 
> In SCTP, association id is not allowed to be 0, so we have to treat
> 0 as an error.

That condition is specified via @idr_low and 0 won't be returned.  If
your point is that the condition better be "ret > 0" for clarity, I
don't know.  At that point, we already requested an ID in the
acceptable range and testing whether the allocation succeeded or not
where failure will always be indicated by -errno.

We can surely add "if (ret == 0) ret = -EINVAL" but that would be a
completely dead path (should we add dead retry loop too?).  If we
don't add such code, the code would appear as silently ignoring error.

So, I think "ret >= 0" is better there.  Maybe we can throw in a
comment explaining idr_low never goes to zero.

BTW, this style of cyclic allocation is broken.  It's prone to -ENOSPC
failure after the first wrap around.  I think we need to implement
proper cyclic support in idr, but let's worry about that later.

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/

Powered by blists - more mailing lists