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:	Fri, 11 Jul 2008 03:21:59 -0500
From:	"Stoyan Gaydarov" <stoyboyker@...il.com>
To:	"Arnd Bergmann" <arnd@...db.de>
Cc:	rjw@...k.pl, pavel@...e.cz, linux-kernel@...r.kernel.org,
	linux-pm@...ts.linux-foundation.org
Subject: Re: [PATCH] ioctl conversion

On Fri, Jul 11, 2008 at 3:08 AM, Arnd Bergmann <arnd@...db.de> wrote:
> On Friday 11 July 2008, Stoyan Gaydarov wrote:
>> -       if (_IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC)
>> +       lock_kernel();
>> +
>> +       if (_IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC) {
>> +               unlock_kernel();
>>                 return -ENOTTY;
>> -       if (_IOC_NR(cmd) > SNAPSHOT_IOC_MAXNR)
>> +       }
>> +       if (_IOC_NR(cmd) > SNAPSHOT_IOC_MAXNR) {
>> +               unlock_kernel();
>>                 return -ENOTTY;
>> -       if (!capable(CAP_SYS_ADMIN))
>> +       }
>> +       if (!capable(CAP_SYS_ADMIN)) {
>> +               unlock_kernel();
>>                 return -EPERM;
>> +       }
>>
>>         data = filp->private_data;
>
> The more common way to express this is to end the function with
>
> out:
>        unlock_kernel();
>        return ret;
> }

This would work normally but there are three early returns and the
rest are just switch statements that set the return code.

>
> and then jump to that label in the error case. This makes it
> much easier to verify that you haven't missed a cased.
>
>        Arnd <><
>
--
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