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]
Date:	Wed, 24 Oct 2012 09:47:01 +0200
From:	Daniel Borkmann <danborkmann@...earbox.net>
To:	Ben Hutchings <bhutchings@...arflare.com>
Cc:	Eric Dumazet <eric.dumazet@...il.com>, davem@...emloft.net,
	netdev@...r.kernel.org
Subject: Re: [PATCH net-next 1/2] packet: clean up error variable assignments

On Wed, Oct 24, 2012 at 1:10 AM, Ben Hutchings
<bhutchings@...arflare.com> wrote:
> On Tue, 2012-10-23 at 19:05 +0200, Eric Dumazet wrote:
>> On Tue, 2012-10-23 at 13:56 +0200, Daniel Borkmann wrote:
>> > This patch performs clean-ups of packet's err variables where appropriate.
>> > In particular, errnos are *only* assigned in error cases, which saves
>> > useless instructions in non-error cases and makes the code more readable
>> > in terms of which error type belongs to which evaluated error condition.
>> > Also, in some cases an errno was set, but not used until the next assignment.
>>
>> I see no value in this patch.
>>
>> Setting err before a test is a common way to handle error cases and
>> generates smaller code in linux kernel.
>>
>> Better live with it than trying to change it ?
>>
>> err = -ENOMEM;
>> match = kzalloc(xxxx);
>> if (!match)
>>       goto error;
>>
>>
>> is smaller (source code & generated code) than :
>>
>> match = kzalloc(xxxx);
>> if (!match) {
>>       err = -ENOMEM;
>>       goto error;
>> }
>>
>> An immediate load is basically free, but code size matters.
>
> In my experience gcc is generally able to perform this optimisation
> itself, at least for x86.  Setting 'err' only after checking for failure
> seems clearer, but I think this is really a matter of taste.

It might also be more likely in case code gets removed, that the
relating 'err' will be removed as well. If I remember correctly, I've
seen one or two cases where there was an assignment with no 'return'
in between the next assignment of 'err'. But probably spatch could
detect such cases as well.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ