1. 06 8月, 2010 1 次提交
  2. 26 7月, 2010 1 次提交
    • E
      Driver-core: Always create class directories for classses that support namespaces. · 24b1442d
      Eric W. Biederman 提交于
      This fixes the regression in 2.6.35-rcX where bluetooth network devices
      would fail to be deleted from sysfs, causing their destruction and
      recreation to fail.  In addition this fixes the mac80211_hwsim driver
      where it would leave around sysfs files when the driver was removed.
      
      This problem is discussed at
        https://bugzilla.kernel.org/show_bug.cgi?id=16257
      
      The reason for the regression is that the network namespace support
      added to sysfs expects and requires that network devices be put in
      directories that can contain only network devices.
      
      Today get_device_parent almost provides that guarantee for all class
      devices, except for a specific exception when the parent of a class
      devices is a class device.  It would be nice to simply remove that
      arguably incorrect special case, but apparently the input devices depend
      on it being there.  So I have only removed it for class devices with
      network namespace support.  Which today are the network devices.
      
      It has been suggested that a better fix would be to change the parent
      device from a class device to a bus device, which in the case of the
      bluetooth driver would change /sys/class/bluetooth to /sys/bus/bluetoth,
      I can not see how we would avoid significant userspace breakage if we
      were to make that change.
      
      Adding an extra directory in the path to the device will also be
      userspace visible but it is much less likely to break things.
      Everything is still accessible from /sys/class (for example), and it
      fixes two bugs.  Adding an extra directory fixes a 3 year old regression
      introduced with the new sysfs layout that makes it impossible to rename
      bnep0 network devices to names that conflict with hci device attributes
      like hci_revsion.  Adding an additional directory removes the new
      failure modes introduced by the network namespace code.
      
      If it weren't for the regession in the renaming of network devices I
      would figure out how to just make the sysfs code deal with this
      configuration of devices.
      
      In summary this patch fixes regressions by changing:
      "/sys/class/bluetooth/hci0/bnep0" to "/sys/class/bluetooth/hci0/net/bnep0".
      Reported-by: NJohannes Berg <johannes@sipsolutions.net>
      Reported-by: NJanusz Krzysztofik <jkrzyszt@tis.icnet.pl>
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      24b1442d
  3. 05 7月, 2010 1 次提交
  4. 22 5月, 2010 7 次提交
  5. 19 3月, 2010 1 次提交
  6. 08 3月, 2010 5 次提交
    • E
      driver core: Use sysfs_rename_link in device_rename · 2354dcc7
      Eric W. Biederman 提交于
      Don't open code the renaming of symlinks in sysfs
      instead use the new helper function sysfs_rename_link
      Acked-by: NTejun Heo <tj@kernel.org>
      Acked-by: NSerge Hallyn <serue@us.ibm.com>
      Signed-off-by: NEric W. Biederman <ebiederm@aristanetworks.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2354dcc7
    • E
      Driver core: Constify struct sysfs_ops in struct kobj_type · 52cf25d0
      Emese Revfy 提交于
      Constify struct sysfs_ops.
      
      This is part of the ops structure constification
      effort started by Arjan van de Ven et al.
      
      Benefits of this constification:
      
       * prevents modification of data that is shared
         (referenced) by many other structure instances
         at runtime
      
       * detects/prevents accidental (but not intentional)
         modification attempts on archs that enforce
         read-only kernel data at runtime
      
       * potentially better optimized code as the compiler
         can assume that the const data cannot be changed
      
       * the compiler/linker move const data into .rodata
         and therefore exclude them from false sharing
      Signed-off-by: NEmese Revfy <re.emese@gmail.com>
      Acked-by: NDavid Teigland <teigland@redhat.com>
      Acked-by: NMatt Domsch <Matt_Domsch@dell.com>
      Acked-by: NMaciej Sosnowski <maciej.sosnowski@intel.com>
      Acked-by: NHans J. Koch <hjk@linutronix.de>
      Acked-by: NPekka Enberg <penberg@cs.helsinki.fi>
      Acked-by: NJens Axboe <jens.axboe@oracle.com>
      Acked-by: NStephen Hemminger <shemminger@vyatta.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      52cf25d0
    • E
      kobject: Constify struct kset_uevent_ops · 9cd43611
      Emese Revfy 提交于
      Constify struct kset_uevent_ops.
      
      This is part of the ops structure constification
      effort started by Arjan van de Ven et al.
      
      Benefits of this constification:
      
       * prevents modification of data that is shared
         (referenced) by many other structure instances
         at runtime
      
       * detects/prevents accidental (but not intentional)
         modification attempts on archs that enforce
         read-only kernel data at runtime
      
       * potentially better optimized code as the compiler
         can assume that the const data cannot be changed
      
       * the compiler/linker move const data into .rodata
         and therefore exclude them from false sharing
      Signed-off-by: NEmese Revfy <re.emese@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      9cd43611
    • K
      Driver-Core: require valid action string in uevent trigger · 3f5468c9
      Kay Sievers 提交于
      No longer fall back to "add" and warn, but always require a valid
      action-string written to the "uevent" file.
      Signed-off-by: NKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      3f5468c9
    • T
      driver-core: fix race condition in get_device_parent() · 77d3d7c1
      Tejun Heo 提交于
      sysfs is creating several devices in cuse class concurrently and with
      CONFIG_SYSFS_DEPRECATED turned off, it triggers the following oops.
      
       BUG: unable to handle kernel NULL pointer dereference at 0000000000000038
       IP: [<ffffffff81158b0a>] sysfs_addrm_start+0x4a/0xf0
       PGD 75bb067 PUD 75be067 PMD 0
       Oops: 0000 [#1] PREEMPT SMP
       last sysfs file: /sys/devices/system/cpu/cpu7/topology/core_siblings
       CPU 1
       Modules linked in: cuse fuse
       Pid: 4737, comm: osspd Not tainted 2.6.31-work #77
       RIP: 0010:[<ffffffff81158b0a>]  [<ffffffff81158b0a>] sysfs_addrm_start+0x4a/0xf0
       RSP: 0018:ffff88000042f8f8  EFLAGS: 00010296
       RAX: ffff88000042ffd8 RBX: 0000000000000000 RCX: 0000000000000000
       RDX: 0000000000000000 RSI: ffff880007eef660 RDI: 0000000000000001
       RBP: ffff88000042f918 R08: 0000000000000000 R09: 0000000000000000
       R10: 0000000000000001 R11: ffffffff81158b0a R12: ffff88000042f928
       R13: 00000000fffffff4 R14: 0000000000000000 R15: ffff88000042f9a0
       FS:  00007fe93905a950(0000) GS:ffff880008600000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
       CR2: 0000000000000038 CR3: 00000000077c9000 CR4: 00000000000006e0
       DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
       DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
       Process osspd (pid: 4737, threadinfo ffff88000042e000, task ffff880007eef040)
       Stack:
        ffff880005da10e8 0000000011cc8d6e ffff88000042f928 ffff880003d28a28
       <0> ffff88000042f988 ffffffff811592d7 0000000000000000 0000000000000000
       <0> 0000000000000000 0000000000000000 ffff88000042f958 0000000011cc8d6e
       Call Trace:
        [<ffffffff811592d7>] create_dir+0x67/0xe0
        [<ffffffff811593a8>] sysfs_create_dir+0x58/0xb0
        [<ffffffff8128ca7c>] ? kobject_add_internal+0xcc/0x220
        [<ffffffff812942e1>] ? vsnprintf+0x3c1/0xb90
        [<ffffffff8128cab7>] kobject_add_internal+0x107/0x220
        [<ffffffff8128cd37>] kobject_add_varg+0x47/0x80
        [<ffffffff8128ce53>] kobject_add+0x53/0x90
        [<ffffffff81357d84>] device_add+0xd4/0x690
        [<ffffffff81356c2b>] ? dev_set_name+0x4b/0x70
        [<ffffffffa001a884>] cuse_process_init_reply+0x2b4/0x420 [cuse]
        ...
      
      The problem is that kobject_add_internal() first adds a kobject to the
      kset and then try to create sysfs directory for it.  If the creation
      fails, it remove the kobject from the kset.  get_device_parent()
      accesses class_dirs kset while only holding class_dirs.list_lock to
      see whether the cuse class dir exists.  But when it exists, it may not
      have finished initialization yet or may fail and get removed soon.  In
      the above case, the former happened so the second one ends up trying
      to create subdirectory under NULL sysfs_dirent.
      
      Fix it by grabbing a mutex in get_device_parent().
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Reported-by: NColin Guthrie <cguthrie@mandriva.org>
      Cc: stable <stable@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      77d3d7c1
  7. 24 12月, 2009 3 次提交
  8. 12 12月, 2009 3 次提交
  9. 20 9月, 2009 1 次提交
  10. 16 9月, 2009 4 次提交
    • K
      Driver Core: devtmpfs - kernel-maintained tmpfs-based /dev · 2b2af54a
      Kay Sievers 提交于
      Devtmpfs lets the kernel create a tmpfs instance called devtmpfs
      very early at kernel initialization, before any driver-core device
      is registered. Every device with a major/minor will provide a
      device node in devtmpfs.
      
      Devtmpfs can be changed and altered by userspace at any time,
      and in any way needed - just like today's udev-mounted tmpfs.
      Unmodified udev versions will run just fine on top of it, and will
      recognize an already existing kernel-created device node and use it.
      The default node permissions are root:root 0600. Proper permissions
      and user/group ownership, meaningful symlinks, all other policy still
      needs to be applied by userspace.
      
      If a node is created by devtmps, devtmpfs will remove the device node
      when the device goes away. If the device node was created by
      userspace, or the devtmpfs created node was replaced by userspace, it
      will no longer be removed by devtmpfs.
      
      If it is requested to auto-mount it, it makes init=/bin/sh work
      without any further userspace support. /dev will be fully populated
      and dynamic, and always reflect the current device state of the kernel.
      With the commonly used dynamic device numbers, it solves the problem
      where static devices nodes may point to the wrong devices.
      
      It is intended to make the initial bootup logic simpler and more robust,
      by de-coupling the creation of the inital environment, to reliably run
      userspace processes, from a complex userspace bootstrap logic to provide
      a working /dev.
      Signed-off-by: NKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NJan Blunck <jblunck@suse.de>
      Tested-By: NHarald Hoyer <harald@redhat.com>
      Tested-By: NScott James Remnant <scott@ubuntu.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      2b2af54a
    • D
      driver model: constify attribute groups · a4dbd674
      David Brownell 提交于
      Let attribute group vectors be declared "const".  We'd
      like to let most attribute metadata live in read-only
      sections... this is a start.
      Signed-off-by: NDavid Brownell <dbrownell@users.sourceforge.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      a4dbd674
    • G
      Driver core: move dev_get/set_drvdata to drivers/base/dd.c · b4028437
      Greg Kroah-Hartman 提交于
      No one should directly access the driver_data field, so remove the field
      and make it private.  We dynamically create the private field now if it
      is needed, to handle drivers that call get/set before they are
      registered with the driver core.
      
      Also update the copyright notices on these files while we are there.
      
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      b4028437
    • A
      Driver core: add new device to bus's list before probing · 2023c610
      Alan Stern 提交于
      This patch (as1271) affects when new devices get linked into their
      bus's list of devices.  Currently this happens after probing, and it
      doesn't happen at all if probing fails.  Clearly this is wrong,
      because at that point quite a few symbolic links have already been
      created in sysfs.  We are committed to adding the device, so it should
      be linked into the bus's list regardless.
      
      In addition, this needs to happen before the uevent announcing the new
      device gets issued.  Otherwise user programs might try to access the
      device before it has been added to the bus.
      
      To fix both these problems, the patch moves the call to
      klist_add_tail() forward from bus_attach_device() to bus_add_device().
      Since bus_attach_device() now does nothing but probe for drivers, it
      has been renamed to bus_probe_device().  And lastly, the kerneldoc is
      updated.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      CC: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      
      
      2023c610
  11. 16 6月, 2009 3 次提交
  12. 29 5月, 2009 1 次提交
  13. 20 4月, 2009 1 次提交
    • K
      driver: dont update dev_name via device_add path · 8a577ffc
      Kay Sievers 提交于
      notice one system /proc/iomem some entries missed the name for pci_devices
      
      it turns that dev->dev.kobj name is changed after device_add.
      
      for pci code: via acpi_pci_root_driver.ops.add (aka acpi_pci_root_add)
      ==> pci_acpi_scan_root is used to scan pci bus/device, and at the same
      time we read the resource for pci_dev in the pci_read_bases, we have
      res->name = pci_name(pci_dev); pci_name is calling dev_name.
      
      later via acpi_pci_root_driver.ops.start (aka acpi_pci_root_start) ==>
      pci_bus_add_device to add all pci_dev in kobj tree.  pci_bus_add_device
      will call device_add.
      
      actually in device_add
      
              /* first, register with generic layer. */
              error = kobject_add(&dev->kobj, dev->kobj.parent, "%s", dev_name(dev));
              if (error)
                      goto Error;
      
      will get one new name for that kobj, old name is freed.
      
      [Impact: fix corrupted names in /proc/iomem ]
      Signed-off-by: NYinghai Lu <yinghai@kernel.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8a577ffc
  14. 17 4月, 2009 1 次提交
  15. 25 3月, 2009 5 次提交
  16. 29 1月, 2009 1 次提交
  17. 21 1月, 2009 1 次提交
    • R
      driver core: Convert '/' to '!' in dev_set_name() · 7143f7a1
      Roland Dreier 提交于
      Commit 3ada8b7e ("block: struct device - replace bus_id with dev_name(),
      dev_set_name()") deleted the code in register_disk() that changed a '/'
      to a '!' in the device name when registering a disk, but dev_set_name()
      does not perform this conversion.
      
      This leads to amusing problems with disks that have '/' in their names:
      for example a failure to boot with the root partition on a cciss device,
      even though the kernel says it knows about the root device:
      
          VFS: Cannot open root device "cciss/c0d0p6" or unknown-block(0,0)
          Please append a correct "root=" boot option; here are the available partitions:
          6800        71652960 cciss/c0d0 driver: cciss
            6802               1 cciss/c0d0p2
            6805         2931831 cciss/c0d0p5
            6806        34354908 cciss/c0d0p6
          6810        71652960 cciss/c0d1 driver: cciss
      
      Fix this by adding code to change '/' to '!' in dev_set_name() to handle
      this until dev_set_name() is converted to use kobject_set_name().
      Signed-off-by: NRoland Dreier <rolandd@cisco.com>
      Acked-by: NKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      7143f7a1