[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20090316111542.2be181c1@gondolin>
Date: Mon, 16 Mar 2009 11:15:42 +0100
From: Cornelia Huck <cornelia.huck@...ibm.com>
To: Alex Chiang <achiang@...com>
Cc: Greg KH <gregkh@...e.de>, Tejun Heo <tj@...nel.org>,
Vegard Nossum <vegard.nossum@...il.com>,
Pekka Enberg <penberg@...helsinki.fi>,
Ingo Molnar <mingo@...e.hu>, jbarnes@...tuousgeek.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sysfs: only allow one scheduled removal callback per
kobj
On Fri, 13 Mar 2009 12:07:36 -0600,
Alex Chiang <achiang@...com> wrote:
> The only way for a sysfs attribute to remove itself (without
> deadlock) is to use the sysfs_schedule_callback() interface.
>
> Vegard Nossum discovered that a poorly written sysfs ->store
> callback can repeatedly schedule remove callbacks on the same
> device over and over, e.g.
>
> $ while true ; do echo 1 > /sys/devices/.../remove ; done
>
> If the 'remove' attribute uses the sysfs_schedule_callback API
> and also does not protect itself from concurrent accesses, its
> callback handler will be called multiple times, and will
> eventually attempt to perform operations on a freed kobject,
> leading to many problems.
>
> Instead of requiring all callers of sysfs_schedule_callback to
> implement their own synchronization, provide the protection in
> the infrastructure.
>
> Now, sysfs_schedule_callback will only allow one scheduled
> callback per kobject. On subsequent calls with the same kobject,
> return -EAGAIN.
>
> This is a short term fix. The long term fix is to allow sysfs
> attributes to remove themselves directly, without any of this
> callback hokey pokey.
>
> [cornelia.huck@...ibm.com: s390 ccwgroup bits]
> Cc: cornelia.huck@...ibm.com
> Reported-by: vegard.nossum@...il.com
> Signed-off-by: Alex Chiang <achiang@...com>
> ---
> drivers/s390/cio/ccwgroup.c | 5 +++--
> fs/sysfs/file.c | 26 +++++++++++++++++++++++---
> 2 files changed, 26 insertions(+), 5 deletions(-)
Acked-by: Cornelia Huck <cornelia.huck@...ibm.com>
--
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