23 Oct, 2008
1 commit
-
With this patch all directory fops instances that have a readdir
that doesn't take the BKL are switched to generic_file_llseek.Signed-off-by: Christoph Hellwig
17 Oct, 2008
6 commits
-
It finally dawned on me what the clean fix to sysfs_rename_dir
calling kobject_set_name is. Move the work into kobject_rename
where it belongs. The callers serialize us anyway so this is
safe.Signed-off-by: Eric W. Biederman
Acked-by: Tejun Heo
Signed-off-by: Greg Kroah-Hartman -
Because they can be, and because code like this produces a warning if
they're not:struct device_attribute dev_attr;
sysfs_notify(&kobj, NULL, dev_attr.attr.name);
Signed-off-by: Trent Piepho
CC: Neil Brown
Signed-off-by: Greg Kroah-Hartman -
As inode creation is protected by sysfs_mutex, ilookup5_nowait()
always either fails to find at all or finds one which is fully
initialized, so using ilookup5_nowait() or ilookup5() doesn't make any
difference. Switch to ilookup5() as it's planned to be removed. This
change also makes lookup return value handling a bit simpler.This change was suggested by Al Viro.
Signed-off-by: Tejun Heo
Cc: Al Viro
Signed-off-by: Greg Kroah-Hartman -
On Thu, Sep 11, 2008 at 10:27:10AM +0200, Ingo Molnar wrote:
> and it's working fine on most boxes. One testbox found this new locking
> scenario:
>
> PM: Adding info for No Bus:vcsa7
> EDAC DEBUG: MC0: i82860_check()
>
> =======================================================
> [ INFO: possible circular locking dependency detected ]
> 2.6.27-rc6-tip #1
> -------------------------------------------------------
> X/4873 is trying to acquire lock:
> (&bb->mutex){--..}, at: [] mmap+0x40/0xa0
>
> but task is already holding lock:
> (&mm->mmap_sem){----}, at: [] sys_mmap2+0x8e/0xc0
>
> which lock already depends on the new lock.
>
>
> the existing dependency chain (in reverse order) is:
>
> -> #1 (&mm->mmap_sem){----}:
> [] validate_chain+0xa96/0xf50
> [] __lock_acquire+0x2cb/0x5b0
> [] lock_acquire+0x89/0xc0
> [] might_fault+0x6b/0x90
> [] copy_to_user+0x38/0x60
> [] read+0xfb/0x170
> [] vfs_read+0x95/0x110
> [] sys_pread64+0x63/0x80
> [] sysenter_do_call+0x12/0x43
> [] 0xffffffff
>
> -> #0 (&bb->mutex){--..}:
> [] validate_chain+0x6b7/0xf50
> [] __lock_acquire+0x2cb/0x5b0
> [] lock_acquire+0x89/0xc0
> [] __mutex_lock_common+0xab/0x3c0
> [] mutex_lock_nested+0x38/0x50
> [] mmap+0x40/0xa0
> [] mmap_region+0x14e/0x450
> [] do_mmap_pgoff+0x2ef/0x310
> [] sys_mmap2+0xad/0xc0
> [] sysenter_do_call+0x12/0x43
> [] 0xffffffff
>
> other info that might help us debug this:
>
> 1 lock held by X/4873:
> #0: (&mm->mmap_sem){----}, at: [] sys_mmap2+0x8e/0xc0
>
> stack backtrace:
> Pid: 4873, comm: X Not tainted 2.6.27-rc6-tip #1
> [] print_circular_bug_tail+0x79/0xc0
> [] validate_chain+0x6b7/0xf50
> [] ? trace_hardirqs_off_caller+0x15/0xb0
> [] __lock_acquire+0x2cb/0x5b0
> [] lock_acquire+0x89/0xc0
> [] ? mmap+0x40/0xa0
> [] __mutex_lock_common+0xab/0x3c0
> [] ? mmap+0x40/0xa0
> [] mutex_lock_nested+0x38/0x50
> [] ? mmap+0x40/0xa0
> [] mmap+0x40/0xa0
> [] mmap_region+0x14e/0x450
> [] ? arch_get_unmapped_area_topdown+0xf8/0x160
> [] do_mmap_pgoff+0x2ef/0x310
> [] sys_mmap2+0xad/0xc0
> [] sysenter_do_call+0x12/0x43
> [] ? __switch_to+0x130/0x220
> =======================
> evbug.c: Event. Dev: input3, Type: 20, Code: 0, Value: 500
> warning: `sudo' uses deprecated v2 capabilities in a way that may be insecure.
>
> i've attached the config.
>
> at first sight it looks like a genuine bug in fs/sysfs/bin.c?Yes, it is a real bug by the looks. bin.c takes bb->mutex under mmap_sem
when it is mmapped, and then does its copy_*_user under bb->mutex too.Here is a basic fix for the sysfs lor.
From: Nick Piggin
Signed-off-by: Ingo Molnar
Signed-off-by: Greg Kroah-Hartman -
Support sysfs_notify from atomic context with new sysfs_notify_dirent
sysfs_notify currently takes sysfs_mutex.
This means that it cannot be called in atomic context.
sysfs_mutex is sometimes held over a malloc (sysfs_rename_dir)
so it can block on low memory.In md I want to be able to notify on a sysfs attribute from
atomic context, and I don't want to block on low memory because I
could be in the writeout path for freeing memory.So:
- export the "sysfs_dirent" structure along with sysfs_get, sysfs_put
and sysfs_get_dirent so I can get the sysfs_dirent that I want to
notify on and hold it in an md structure.
- split sysfs_notify_dirent out of sysfs_notify so the sysfs_dirent
can be notified on with no blocking (just a spinlock).Signed-off-by: Neil Brown
Acked-by: Tejun Heo
Signed-off-by: Greg Kroah-Hartman -
Print the name of the last-accessed sysfs file when we oops, to help track
down oopses which occur in sysfs store/read handlers. Because these oopses
tend to not leave any trace of the offending code in the stack traces.Cc: Kay Sievers
Cc: Mathieu Desnoyers
Signed-off-by: Andrew Morton
Signed-off-by: Greg Kroah-Hartman
27 Jul, 2008
1 commit
-
Use WARN() instead of a printk+WARN_ON() pair; this way the message becomes
part of the warning section for better reporting/collection. Also, with this,
one fo the if() sections collapses entirely into the WARN().Signed-off-by: Arjan van de Ven
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
22 Jul, 2008
2 commits
-
driver core: Suppress sysfs warnings for device_rename().
Renaming network devices to an already existing name is not
something we want sysfs to print a scary warning for, since the
callers can deal with this correctly. So let's introduce
sysfs_create_link_nowarn() which gets rid of the common warning.Signed-off-by: Cornelia Huck
Signed-off-by: Greg Kroah-Hartman -
sysfs_chmod_file() calls notify_change() to change the permission bits
on a sysfs file. Replace with explicit call to sysfs_setattr() and
fsnotify_change().This is equivalent, except that security_inode_setattr() is not
called. This function is called by drivers, so the security checks do
not make any sense.Signed-off-by: Miklos Szeredi
Signed-off-by: Greg Kroah-Hartman
15 May, 2008
1 commit
-
It is possible that the entry in sysfs already exists, one case of this is
when a network device is renamed to bonding_masters. Anyway, in this case
the proper error path is for device_rename to return an error code, not to
generate bogus backtrace and errors.Also, to avoid possible races, the create link should be done before the
remove link. This makes a device rename atomic operation like other renames.Signed-off-by: Stephen Hemminger
Signed-off-by: Greg Kroah-Hartman
Signed-off-by: David S. Miller
01 May, 2008
1 commit
-
sysfs allows attribute files to be truncated, e.g. using ftruncate(), with the
expected effect on their inode. For most attributes, this doesn't change the
"real" size of the file i.e. how much can be read from it. However, the
parameter validation for reading and writing binary attribute files is based
on the inode size and not the size specified in the file's bin_attribute, so it
can be broken by this. For example, if we try using dd to write to such a file:# pwd
/sys/bus/pci/devices/0000:08:00.0
# ls -l config
-rw-r--r-- 1 root root 4096 Feb 1 17:35 config
# dd if=/dev/zero of=config bs=4 count=1
1+0 records in
1+0 records out
# ls -l config
-rw-r--r-- 1 root root 0 Feb 1 17:50 config
# dd if=/dev/zero of=config bs=4 count=1 seek=128
dd: writing `config': No space left on device
1+0 records in
0+0 records outAlso, after truncation to 0, parameter validation for read and write is
disabled. Most bin_attribute read and write methods also validate the size and
offset, but for some this will allow out-of-range access. This may be a
security issue, though access to such files is often limited to root. In any
case, the validation should remain for safety's sake!)This was previously reported in Bugzilla as bug 9867.
sysfs should ignore size changes or else refuse them (by returning -EINVAL).
This patch makes it ignore them.Signed-off-by: Ben Hutchings
Signed-off-by: Greg Kroah-Hartman
30 Apr, 2008
2 commits
-
__FUNCTION__ is gcc-specific, use __func__
Signed-off-by: Harvey Harrison
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Add a new BDI capability flag: BDI_CAP_NO_ACCT_WB. If this flag is
set, then don't update the per-bdi writeback stats from
test_set_page_writeback() and test_clear_page_writeback().Misc cleanups:
- convert bdi_cap_writeback_dirty() and friends to static inline functions
- create a flag that includes all three dirty/writeback related flags,
since almst all users will want to have them toghetherSigned-off-by: Miklos Szeredi
Cc: Peter Zijlstra
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
23 Apr, 2008
1 commit
-
We have a problem in scsi_transport_spi in that we need to customise
not only the visibility of the attributes, but also their mode. Fix
this by making the is_visible() callback return a mode, with 0
indicating is not visible.Also add a sysfs_update_group() API to allow us to change either the
visibility or mode of the files at any time on the fly.Acked-by: Kay Sievers
Signed-off-by: James Bottomley
20 Apr, 2008
2 commits
-
Requiring userspace to close and re-open sysfs attributes has been the
policy since before 2.6.12. It allows userspace to get a consistent
snapshot of kernel state and consume it with incremental reads and seeks.Now, if the file position is zero the kernel assumes userspace wants to see
the new value. The application for this change is to allow a userspace
RAID metadata handler to check the state of an array without causing any
memory allocations. Thus not causing writeback to a raid array that might
be blocked waiting for userspace to take action.Cc: Neil Brown
Acked-by: Tejun Heo
Signed-off-by: Dan Williams
Signed-off-by: Greg Kroah-Hartman -
After an experimental deletion of the unnecessary inclusion of
from the header file , the following
files under fs/sysfs were exposed as needing to explicitly include
.Signed-off-by: Robert P. J. Day
Signed-off-by: Greg Kroah-Hartman
18 Apr, 2008
1 commit
-
Allow callers of sysfs_remove_link() to pass a NULL kobj, in which case
sysfs_root will be used as the parent directory. This allows us to tear down
top level symlinks created via sysfs_create_link(), which already has
similar handling of a NULL parent object.Signed-off-by: Mark Fasheh
Acked-by: Greg Kroah-Hartman
25 Mar, 2008
1 commit
-
Try to find the culprit who caused
http://bugzilla.kernel.org/show_bug.cgi?id=10150Cc:
Signed-off-by: Andrew Morton
Signed-off-by: Greg Kroah-Hartman
08 Feb, 2008
1 commit
-
It's possible that the caller of sysfs_remove_group messed up and passed in an attribute group that was not really registered to this kobject. But don't panic for such a foolish error, spit out a warning about what happened, and continue on our way safely.
Cc: Roland Dreier
Cc: Tejun Heo
Signed-off-by: Greg Kroah-Hartman
26 Jan, 2008
1 commit
-
* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (200 commits)
[SCSI] usbstorage: use last_sector_bug flag universally
[SCSI] libsas: abstract STP task status into a function
[SCSI] ultrastor: clean up inline asm warnings
[SCSI] aic7xxx: fix firmware build
[SCSI] aacraid: fib context lock for management ioctls
[SCSI] ch: remove forward declarations
[SCSI] ch: fix device minor number management bug
[SCSI] ch: handle class_device_create failure properly
[SCSI] NCR5380: fix section mismatch
[SCSI] sg: fix /proc/scsi/sg/devices when no SCSI devices
[SCSI] IB/iSER: add logical unit reset support
[SCSI] don't use __GFP_DMA for sense buffers if not required
[SCSI] use dynamically allocated sense buffer
[SCSI] scsi.h: add macro for enclosure bit of inquiry data
[SCSI] sd: add fix for devices with last sector access problems
[SCSI] fix pcmcia compile problem
[SCSI] aacraid: add Voodoo Lite class of cards.
[SCSI] aacraid: add new driver features flags
[SCSI] qla2xxx: Update version number to 8.02.00-k7.
[SCSI] qla2xxx: Issue correct MBC_INITIALIZE_FIRMWARE command.
...
25 Jan, 2008
5 commits
-
Remove the no longer needed subsys_attributes, they are all converted to
the more sensical kobj_attributes.There is no longer a magic fallback in sysfs attribute operations, all
kobjects which create simple attributes need explicitely a ktype
assigned, which tells the core what was intended here.Signed-off-by: Kay Sievers
Signed-off-by: Greg Kroah-Hartman -
We don't need a "default" ktype for a kset. We should set this
explicitly every time for each kset. This change is needed so that we
can make ksets dynamic, and cleans up one of the odd, undocumented
assumption that the kset/kobject/ktype model has.This patch is based on a lot of help from Kay Sievers.
Nasty bug in the block code was found by Dave Young
Cc: Kay Sievers
Cc: Dave Young
Signed-off-by: Greg Kroah-Hartman -
SPIN_LOCK_UNLOCKED is deprecated, use DEFINE_SPINLOCK instead
Signed-off-by: Jiri Slaby
Signed-off-by: Andrew Morton
Cc: Tejun Heo
Signed-off-by: Greg Kroah-Hartman -
Instead of walking from the source down to the root of sysfs, and back
to the target, we stop at the first directory the source and the target
share.This link:
/devices/pci0000:00/0000:00:1d.7/usb1/1-0:1.0/ep_81pointed to:
../../../../../devices/pci0000:00/0000:00:1d.0/usb2/2-0:1.0/usb_endpoint/usbdev2.1_ep81now it just points to:
usb_endpoint/usbdev1.1_ep81Thanks to Denis Cheng for bringing this up, and sending the initial patch.
CC: Denis Cheng
Signed-off-by: Kay Sievers
Signed-off-by: Greg Kroah-Hartman -
Signed-off-by: Jean Delvare
Signed-off-by: Greg Kroah-Hartman
24 Jan, 2008
2 commits
-
This patch allows the various users of attribute_groups to selectively
allow the appearance of group attributes. The primary consumer of
this will be the transport classes in which we currently have
elaborate attribute selection algorithms to do this same thing.Acked-by: Greg KH
Signed-off-by: James Bottomley -
I can't see a reason why these shouldn't work on every group. However,
they only seem to work on named groups. This patch allows the group
functions to work on anonymous groups (those with NULL names).Acked-by: Tejun Heo
Acked-by: Kay Sievers
Acked-by: Greg Kroah-Hartman
Signed-off-by: James Bottomley
17 Jan, 2008
2 commits
-
sysfs_rename/move_dir() have the following bugs.
- On dentry lookup failure, kfree() is called on ERR_PTR() value.
- sysfs_move_dir() has an extra dput() on success path.Fix them.
Signed-off-by: Tejun Heo
Signed-off-by: Linus Torvalds -
sysfs tries to keep dcache a strict subset of sysfs_dirent tree by
shooting down dentries when a node is removed, that is, no negative
dentry for sysfs. However, the lookup function returned NULL and thus
created negative dentries when the target node didn't exist.Make sysfs_lookup() return ERR_PTR(-ENOENT) on lookup failure. This
fixes the NULL dereference bug in sysfs_get_dentry() discovered by
bluetooth rfcomm device moving around.Signed-off-by: Tejun Heo
Signed-off-by: Linus Torvalds
29 Nov, 2007
1 commit
-
I found that there is a off-by-one problem in the following code.
Version: 2.6.24-rc2
File: fs/sysfs/file.c:118-122
Function: fill_read_buffer
--------------------------------------------------------------------
count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);sysfs_put_active_two(attr_sd);
BUG_ON(count > (ssize_t)PAGE_SIZE);
--------------------------------------------------------------------Because according to the specification of the sysfs and the implement of
the show methods, the show methods return the number of bytes which would
be generated for the given input, excluding the trailing null.So if the
return value of the show methods equals PAGE_SIZE - 1, the buffer is full
in fact. And if the return value equals PAGE_SIZE, the resulting string
was already truncated,or buffer overflow occurred.This patch fixes an off-by-one error in fill_read_buffer.
Signed-off-by: Miao Xie
Signed-off-by: Andrew Morton
Acked-by: Tejun Heo
Signed-off-by: Greg Kroah-Hartman
31 Oct, 2007
1 commit
-
sysfs_{get,put}_active() can now become static.
Signed-off-by: Adrian Bunk
Signed-off-by: Greg Kroah-Hartman
20 Oct, 2007
1 commit
-
Spelling error in sysfs_create_file kerneldoc.
Signed-off-by: Chris Malley
Signed-off-by: Adrian Bunk
17 Oct, 2007
4 commits
-
Replace some SPIN_LOCK_UNLOCKED with DEFINE_SPINLOCK
Signed-off-by: Roel Kluin
Acked-by: Thomas Gleixner
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
provide BDI constructor/destructor hooks
[akpm@linux-foundation.org: compile fix]
Signed-off-by: Peter Zijlstra
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Try to fix the mess created by sysfs braindamage.
- refactor code internal to fs/namei.c a little to avoid too much
duplication:
o __lookup_hash_kern is renamed back to __lookup_hash
o the old __lookup_hash goes away, permission checks moves to
the two callers
o useless inline qualifiers on above functions go away
- lookup_one_len_kern loses it's last argument and is renamed to
lookup_one_noperm to make it's useage a little more clear
- added kerneldoc comments to describe lookup_one_len aswell as
lookup_one_noperm and make it very clear that no one should use
the latter ever.Signed-off-by: Christoph Hellwig
Cc: Josef 'Jeff' Sipek
Cc: Miklos Szeredi
Cc: Al Viro
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds -
Implement new aops for some of the simpler filesystems.
Signed-off-by: Nick Piggin
Signed-off-by: Andrew Morton
Signed-off-by: Linus Torvalds
13 Oct, 2007
3 commits
-
Sysfs has gone through considerable amount of reimplementation. Add
copyrights. Any objections? :-)Signed-off-by: Tejun Heo
Signed-off-by: Greg Kroah-Hartman -
Sysfs file poll implementation is scattered over sysfs and kobject.
Event numbering is done in sysfs_dirent but wait itself is done on
kobject. This not only unecessarily bloats both kobject and
sysfs_dirent but is also buggy - if a sysfs_dirent is removed while
there still are pollers, the associaton betwen the kobject and
sysfs_dirent breaks and kobject may be freed with the pollers still
sleeping on it.This patch moves whole poll implementation into sysfs_open_dirent.
Each time a sysfs_open_dirent is created, event number restarts from 1
and pollers sleep on sysfs_open_dirent. As event sequence number is
meaningless without any open file and pollers should have open file
and thus sysfs_open_dirent, this ephemeral event counting works and is
a saner implementation.This patch fixes the dnagling sleepers bug and reduces the sizes of
kobject and sysfs_dirent by one pointer.Signed-off-by: Tejun Heo
Acked-by: Cornelia Huck
Signed-off-by: Greg Kroah-Hartman -
Implement sysfs_open_dirent which represents an open file (attribute)
sysfs_dirent. A file sysfs_dirent with one or more open files have
one sysfs_dirent and all sysfs_buffers (one for each open instance)
are linked to it.sysfs_open_dirent doesn't actually do anything yet but will be used to
off-load things which are specific for open file sysfs_dirent from it.Signed-off-by: Tejun Heo
Acked-by: Cornelia Huck
Signed-off-by: Greg Kroah-Hartman