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, 20 Aug 2007 14:31:51 +0530
From:	Balbir Singh <balbir@...ux.vnet.ibm.com>
To:	Alexey Dobriyan <adobriyan@...ru>
CC:	Andrew Morton <akpm@...ux-foundation.org>,
	Nick Piggin <npiggin@...e.de>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Dhaval Giani <dhaval@...ux.vnet.ibm.com>,
	YAMAMOTO Takashi <yamamoto@...inux.co.jp>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Linux MM Mailing List <linux-mm@...ck.org>,
	Linux Containers <containers@...ts.osdl.org>
Subject: Re: [Devel] [-mm PATCH 1/9] Memory controller resource counters (v6)

Alexey Dobriyan wrote:
> On Fri, Aug 17, 2007 at 02:12:38PM +0530, Balbir Singh wrote:
>> --- /dev/null
>> +++ linux-2.6.23-rc2-mm2-balbir/kernel/res_counter.c
>> +void res_counter_init(struct res_counter *counter)
>> +{
>> +	spin_lock_init(&counter->lock);
>> +	counter->limit = (unsigned long)LONG_MAX;
> 
> why cast?
> 

These patches come from Pavel. They add to readability since
limit is unsigned long.

>> +int res_counter_charge_locked(struct res_counter *counter, unsigned long val)
>> +{
>> +	if (counter->usage > (counter->limit - val)) {
> 
> () aren't needed.
> 

it makes the code more readable

>> +	if (WARN_ON(counter->usage < val))
>> +		val = counter->usage;
> 
> explicit if and WARN_ON(1) is clearer. I should send a patch banning such
> type of usage soon.
> 

We had a WARN_ON(1) before, but we changed it in v2 or v3 based on review
comments from Dave. I think WARN_ON(cond) is more readable than
WARN_ON(1) for the same reason as BUG_ON(cond) vs BUG_ON(1)

>> +	buf = kmalloc(nbytes + 1, GFP_KERNEL);
> 
> please, switch to fixed buffer, allocating memory depending on size
> told by userspace will beat later. Ditto for other proc writing
> functions.
> 

I agree with you in part, but the size of user input is not fixed.
Setting a fixed limit seems artificial, I'll see how this can be improved.


Thanks for the detailed review comments,

-- 
	Balbir Singh
	Linux Technology Center
	IBM, ISTL
-
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