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, 15 Mar 2010 01:48:50 +0100
From:	Wolfram Sang <w.sang@...gutronix.de>
To:	"Eric W. Biederman" <ebiederm@...ssion.com>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Jiri Kosina <jkosina@...e.cz>,
	Larry Finger <Larry.Finger@...inger.net>,
	WANG Cong <xiyou.wangcong@...il.com>,
	Greg Kroah-Hartman <gregkh@...e.de>, Tejun Heo <tj@...nel.org>,
	Julia Lawall <julia@...u.dk>
Subject: Re: [PATCH] base firmware: Fix BUG from sysfs attributes change in
	commit a2db6842873c8e5a70652f278d469128cb52db70

On Sun, Mar 14, 2010 at 12:08:55PM -0700, Eric W. Biederman wrote:
> Linus Torvalds <torvalds@...ux-foundation.org> writes:
> 
> > On Sun, 14 Mar 2010, Wolfram Sang wrote:
> >>
> >> coccinelle can apply semantic patches, rough description here [1]. So I wrote
> >> one which checks for every c-file in the kernel-tree:
> >>
> >> - Is there a structure containing (bin_)attribute?
> >> - Does a function declare a pointer to such a structure?
> >> - Is this pointer then used for a sysfs_create(_bin)_file?
> >> - If so, has there been a call to sysfs(_bin)_attr_init before?
> >>
> >> If not -> report. As coccinelle works on an abstract level of the code (not on
> >> source-code level), it can follow code-paths and such. Really nice tool, once
> >> you gathered the information to learn it.
> 
> Any chance you can post the semantic patch?  If it isn't too hard it
> would be nice to have the warm fuzzy of running it myself and seeing
> that there are no more of these left in the kernel.

(Strange, I sent an introductory message to the series:

http://kerneltrap.org/mailarchive/linux-kernel-janitors/2010/3/12/6848563

But it doesn't show up in the gmane-archives? And I just learned that CCs added
while editing the introductory message will be dropped by git-send-email. This
is why it isn't on lkml. I have to fix that next time.)

Sure, reviewing is very welcome. I am still new to the semantic patches, so a
double check is surely helpful (also adding Julia Lawall to cc, grand master of
this topic).

Here is the patch again for the binary-attributes (I recommend coccinelle
v0.2.2. Run it with 'spatch -sp_file <name> .' form kernel-top-level-dir):

@ init @
identifier struct_name, bin;
@@

        struct struct_name {
                ...
                struct bin_attribute bin;
                ...
        };

@ main extends init @
expression E;
statement S;
identifier name, err;
@@

(
        struct struct_name *name;
|
-       struct struct_name *name = NULL;
+       struct struct_name *name;
)
        ...
(
        sysfs_bin_attr_init(&name->bin);
|
+       sysfs_bin_attr_init(&name->bin);
        if (sysfs_create_bin_file(E, &name->bin))
                S
|
+       sysfs_bin_attr_init(&name->bin);
        err = sysfs_create_bin_file(E, &name->bin);
)


Here is my patch for the non-binary-attributes:

@ init @
identifier struct_name, attr;
@@

        struct struct_name {
                ...
                struct attribute attr;
                ...
        };

@ main extends init @
expression E;
statement S;
identifier name, err;
@@

(
        struct struct_name *name;
|
-       struct struct_name *name = NULL;
+       struct struct_name *name;
)
        ...
(
        sysfs_attr_init(&name->attr);
|
+       sysfs_attr_init(&name->attr);
        if (sysfs_create_file(E, &name->attr))
                S
|
+       sysfs_attr_init(&name->attr);
        err = sysfs_create_file(E, &name->attr);
)

Regards,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

Download attachment "signature.asc" of type "application/pgp-signature" (198 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ