1. 24 1月, 2011 1 次提交
    • D
      module: show version information for built-in modules in sysfs · e94965ed
      Dmitry Torokhov 提交于
      Currently only drivers that are built as modules have their versions
      shown in /sys/module/<module_name>/version, but this information might
      also be useful for built-in drivers as well. This especially important
      for drivers that do not define any parameters - such drivers, if
      built-in, are completely invisible from userspace.
      
      This patch changes MODULE_VERSION() macro so that in case when we are
      compiling built-in module, version information is stored in a separate
      section. Kernel then uses this data to create 'version' sysfs attribute
      in the same fashion it creates attributes for module parameters.
      Signed-off-by: NDmitry Torokhov <dtor@vmware.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      e94965ed
  2. 11 8月, 2010 7 次提交
  3. 08 3月, 2010 3 次提交
  4. 07 3月, 2010 1 次提交
  5. 05 2月, 2010 1 次提交
  6. 16 12月, 2009 1 次提交
    • A
      tree-wide: convert open calls to remove spaces to skip_spaces() lib function · e7d2860b
      André Goddard Rosa 提交于
      Makes use of skip_spaces() defined in lib/string.c for removing leading
      spaces from strings all over the tree.
      
      It decreases lib.a code size by 47 bytes and reuses the function tree-wide:
         text    data     bss     dec     hex filename
        64688     584     592   65864   10148 (TOTALS-BEFORE)
        64641     584     592   65817   10119 (TOTALS-AFTER)
      
      Also, while at it, if we see (*str && isspace(*str)), we can be sure to
      remove the first condition (*str) as the second one (isspace(*str)) also
      evaluates to 0 whenever *str == 0, making it redundant. In other words,
      "a char equals zero is never a space".
      
      Julia Lawall tried the semantic patch (http://coccinelle.lip6.fr) below,
      and found occurrences of this pattern on 3 more files:
          drivers/leds/led-class.c
          drivers/leds/ledtrig-timer.c
          drivers/video/output.c
      
      @@
      expression str;
      @@
      
      ( // ignore skip_spaces cases
      while (*str &&  isspace(*str)) { \(str++;\|++str;\) }
      |
      - *str &&
      isspace(*str)
      )
      Signed-off-by: NAndré Goddard Rosa <andre.goddard@gmail.com>
      Cc: Julia Lawall <julia@diku.dk>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Richard Purdie <rpurdie@rpsys.net>
      Cc: Neil Brown <neilb@suse.de>
      Cc: Kyle McMartin <kyle@mcmartin.ca>
      Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
      Cc: David Howells <dhowells@redhat.com>
      Cc: <linux-ext4@vger.kernel.org>
      Cc: Samuel Ortiz <samuel@sortiz.org>
      Cc: Patrick McHardy <kaber@trash.net>
      Cc: Takashi Iwai <tiwai@suse.de>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      e7d2860b
  7. 29 10月, 2009 3 次提交
    • R
      param: fix setting arrays of bool · 3c7d76e3
      Rusty Russell 提交于
      We create a dummy struct kernel_param on the stack for parsing each
      array element, but we didn't initialize the flags word.  This matters
      for arrays of type "bool", where the flag indicates if it really is
      an array of bools or unsigned int (old-style).
      Reported-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Cc: stable@kernel.org
      3c7d76e3
    • R
      param: fix NULL comparison on oom · d553ad86
      Rusty Russell 提交于
      kp->arg is always true: it's the contents of that pointer we care about.
      Reported-by: NTakashi Iwai <tiwai@suse.de>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Cc: stable@kernel.org
      d553ad86
    • R
      param: fix lots of bugs with writing charp params from sysfs, by leaking mem. · 65afac7d
      Rusty Russell 提交于
      e180a6b7 "param: fix charp parameters set via sysfs" fixed the case
      where charp parameters written via sysfs were freed, leaving drivers
      accessing random memory.
      
      Unfortunately, storing a flag in the kparam struct was a bad idea: it's
      rodata so setting it causes an oops on some archs.  But that's not all:
      
      1) module_param_array() on charp doesn't work reliably, since we use an
         uninitialized temporary struct kernel_param.
      2) there's a fundamental race if a module uses this parameter and then
         it's changed: they will still access the old, freed, memory.
      
      The simplest fix (ie. for 2.6.32) is to never free the memory.  This
      prevents all these problems, at cost of a memory leak.  In practice, there
      are only 18 places where a charp is writable via sysfs, and all are
      root-only writable.
      Reported-by: NTakashi Iwai <tiwai@suse.de>
      Cc: Sitsofe Wheeler <sitsofe@yahoo.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Christof Schmitt <christof.schmitt@de.ibm.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Cc: stable@kernel.org
      65afac7d
  8. 24 9月, 2009 1 次提交
    • P
      param: allow whitespace as kernel parameter separator · 26d052bf
      Peter Oberparleiter 提交于
      Some boot mechanisms require that kernel parameters are stored in a
      separate file which is loaded to memory without further processing
      (e.g. the "Load from FTP" method on s390). When such a file contains
      newline characters, the kernel parameter preceding the newline might
      not be correctly parsed (due to the newline being stuck to the end of
      the actual parameter value) which can lead to boot failures.
      
      This patch improves kernel command line usability in such a situation
      by allowing generic whitespace characters as separators between kernel
      parameters.
      Signed-off-by: NPeter Oberparleiter <oberpar@linux.vnet.ibm.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      26d052bf
  9. 12 6月, 2009 3 次提交
  10. 31 3月, 2009 1 次提交
  11. 24 10月, 2008 1 次提交
  12. 22 10月, 2008 3 次提交
    • R
      core_param() for genuinely core kernel parameters · 67e67cea
      Rusty Russell 提交于
      There are a lot of one-liner uses of __setup() in the kernel: they're
      cumbersome and not queryable (definitely not settable) via /sys.  Yet
      it's ugly to simplify them to module_param(), because by default that
      inserts a prefix of the module name (usually filename).
      
      So, introduce a "core_param".  The parameter gets no prefix, but
      appears in /sys/module/kernel/parameters/ (if non-zero perms arg).  I
      thought about using the name "core", but that's more common than
      "kernel".  And if you create a module called "kernel", you will die
      a horrible death.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      67e67cea
    • R
      param: Fix duplicate module prefixes · 9b473de8
      Rusty Russell 提交于
      Instead of insisting each new module_param sysfs entry is unique,
      handle the case where it already exists (for builtin modules).
      
      The current code assumes that all identical prefixes are together in
      the section: true for normal uses, but not necessarily so if someone
      overrides MODULE_PARAM_PREFIX.  More importantly, it's not true with
      the new "core_param()" code which uses "kernel" as a prefix.
      
      This simplifies the caller for the builtin case, at a slight loss of
      efficiency (we do the lookup every time to see if the directory
      exists).
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      9b473de8
    • R
      module: check kernel param length at compile time, not runtime · 730b69d2
      Rusty Russell 提交于
      The kparam code tries to handle over-length parameter prefixes at
      runtime.  Not only would I bet this has never been tested, it's not
      clear that truncating names is a good idea either.
      
      So let's check at compile time.  We need to move the #define to
      moduleparam.h to do this, though.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      730b69d2
  13. 09 2月, 2008 1 次提交
    • Y
      Add new string functions strict_strto* and convert kernel params to use them · 06b2a76d
      Yi Yang 提交于
      Currently, for every sysfs node, the callers will be responsible for
      implementing store operation, so many many callers are doing duplicate
      things to validate input, they have the same mistakes because they are
      calling simple_strtol/ul/ll/uul, especially for module params, they are
      just numeric, but you can echo such values as 0x1234xxx, 07777888 and
      1234aaa, for these cases, module params store operation just ignores
      succesive invalid char and converts prefix part to a numeric although input
      is acctually invalid.
      
      This patch tries to fix the aforementioned issues and implements
      strict_strtox serial functions, kernel/params.c uses them to strictly
      validate input, so module params will reject such values as 0x1234xxxx and
      returns an error:
      
      write error: Invalid argument
      
      Any modules which export numeric sysfs node can use strict_strtox instead of
      simple_strtox to reject any invalid input.
      
      Here are some test results:
      
      Before applying this patch:
      
      [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
      4096
      [root@yangyi-dev /]# echo 0x1000 > /sys/module/e1000/parameters/copybreak
      [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
      4096
      [root@yangyi-dev /]# echo 0x1000g > /sys/module/e1000/parameters/copybreak
      [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
      4096
      [root@yangyi-dev /]# echo 0x1000gggggggg > /sys/module/e1000/parameters/copybreak
      [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
      4096
      [root@yangyi-dev /]# echo 010000 > /sys/module/e1000/parameters/copybreak
      [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
      4096
      [root@yangyi-dev /]# echo 0100008 > /sys/module/e1000/parameters/copybreak
      [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
      4096
      [root@yangyi-dev /]# echo 010000aaaaa > /sys/module/e1000/parameters/copybreak
      [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
      4096
      [root@yangyi-dev /]#
      
      After applying this patch:
      
      [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
      4096
      [root@yangyi-dev /]# echo 0x1000 > /sys/module/e1000/parameters/copybreak
      [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
      4096
      [root@yangyi-dev /]# echo 0x1000g > /sys/module/e1000/parameters/copybreak
      -bash: echo: write error: Invalid argument
      [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
      4096
      [root@yangyi-dev /]# echo 0x1000gggggggg > /sys/module/e1000/parameters/copybreak
      -bash: echo: write error: Invalid argument
      [root@yangyi-dev /]# echo 010000 > /sys/module/e1000/parameters/copybreak
      [root@yangyi-dev /]# echo 0100008 > /sys/module/e1000/parameters/copybreak
      -bash: echo: write error: Invalid argument
      [root@yangyi-dev /]# echo 010000aaaaa > /sys/module/e1000/parameters/copybreak
      -bash: echo: write error: Invalid argument
      [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
      4096
      [root@yangyi-dev /]# echo -n 4096 > /sys/module/e1000/parameters/copybreak
      [root@yangyi-dev /]# cat /sys/module/e1000/parameters/copybreak
      4096
      [root@yangyi-dev /]#
      
      [akpm@linux-foundation.org: fix compiler warnings]
      [akpm@linux-foundation.org: fix off-by-one found by tiwai@suse.de]
      Signed-off-by: NYi Yang <yi.y.yang@intel.com>
      Cc: Greg KH <greg@kroah.com>
      Cc: "Randy.Dunlap" <rdunlap@xenotime.net>
      Cc: Takashi Iwai <tiwai@suse.de>
      Cc: Hugh Dickins <hugh@veritas.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      06b2a76d
  14. 07 2月, 2008 1 次提交
  15. 29 1月, 2008 1 次提交
  16. 25 1月, 2008 4 次提交
  17. 24 1月, 2008 1 次提交
  18. 23 12月, 2007 1 次提交
    • G
      Modules: fix memory leak of module names · d172f4ef
      Greg Kroah-Hartman 提交于
      Due to the change in kobject name handling, the module kobject needs to
      have a null release function to ensure that the name it previously set
      will be properly cleaned up.
      
      All of this wierdness goes away in 2.6.25 with the rework of the kobject
      name and cleanup logic, but this is required for 2.6.24.
      
      Thanks to Alexey Dobriyan for finding the problem, and to Kay Sievers
      for pointing out the simple way to fix it after I tried many complex
      ways.
      
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      
      d172f4ef
  19. 15 11月, 2007 1 次提交
  20. 19 10月, 2007 1 次提交
    • D
      param_sysfs_builtin memchr argument fix · faf8c714
      Dave Young 提交于
      If memchr argument is longer than strlen(kp->name), there will be some
      weird result.
      
      It will casuse duplicate filenames in sysfs for the "nousb".  kernel
      warning messages are as bellow:
      
      sysfs: duplicate filename 'usbcore' can not be created
      WARNING: at fs/sysfs/dir.c:416 sysfs_add_one()
       [<c01c4750>] sysfs_add_one+0xa0/0xe0
       [<c01c4ab8>] create_dir+0x48/0xb0
       [<c01c4b69>] sysfs_create_dir+0x29/0x50
       [<c024e0fb>] create_dir+0x1b/0x50
       [<c024e3b6>] kobject_add+0x46/0x150
       [<c024e2da>] kobject_init+0x3a/0x80
       [<c053b880>] kernel_param_sysfs_setup+0x50/0xb0
       [<c053b9ce>] param_sysfs_builtin+0xee/0x130
       [<c053ba33>] param_sysfs_init+0x23/0x60
       [<c024d062>] __next_cpu+0x12/0x20
       [<c052aa30>] kernel_init+0x0/0xb0
       [<c052aa30>] kernel_init+0x0/0xb0
       [<c052a856>] do_initcalls+0x46/0x1e0
       [<c01bdb12>] create_proc_entry+0x52/0x90
       [<c0158d4c>] register_irq_proc+0x9c/0xc0
       [<c01bda94>] proc_mkdir_mode+0x34/0x50
       [<c052aa30>] kernel_init+0x0/0xb0
       [<c052aa92>] kernel_init+0x62/0xb0
       [<c0104f83>] kernel_thread_helper+0x7/0x14
       =======================
      kobject_add failed for usbcore with -EEXIST, don't try to register things with the same name in the same directory.
       [<c024e466>] kobject_add+0xf6/0x150
       [<c053b880>] kernel_param_sysfs_setup+0x50/0xb0
       [<c053b9ce>] param_sysfs_builtin+0xee/0x130
       [<c053ba33>] param_sysfs_init+0x23/0x60
       [<c024d062>] __next_cpu+0x12/0x20
       [<c052aa30>] kernel_init+0x0/0xb0
       [<c052aa30>] kernel_init+0x0/0xb0
       [<c052a856>] do_initcalls+0x46/0x1e0
       [<c01bdb12>] create_proc_entry+0x52/0x90
       [<c0158d4c>] register_irq_proc+0x9c/0xc0
       [<c01bda94>] proc_mkdir_mode+0x34/0x50
       [<c052aa30>] kernel_init+0x0/0xb0
       [<c052aa92>] kernel_init+0x62/0xb0
       [<c0104f83>] kernel_thread_helper+0x7/0x14
       =======================
      Module 'usbcore' failed to be added to sysfs, error number -17
      The system will be unstable now.
      Signed-off-by: NDave Young <hidave.darkstar@gmail.com>
      Cc: Greg KH <greg@kroah.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      faf8c714
  21. 17 10月, 2007 1 次提交
  22. 31 7月, 2007 1 次提交
  23. 12 7月, 2007 1 次提交
    • T
      sysfs: kill unnecessary attribute->owner · 7b595756
      Tejun Heo 提交于
      sysfs is now completely out of driver/module lifetime game.  After
      deletion, a sysfs node doesn't access anything outside sysfs proper,
      so there's no reason to hold onto the attribute owners.  Note that
      often the wrong modules were accounted for as owners leading to
      accessing removed modules.
      
      This patch kills now unnecessary attribute->owner.  Note that with
      this change, userland holding a sysfs node does not prevent the
      backing module from being unloaded.
      
      For more info regarding lifetime rule cleanup, please read the
      following message.
      
        http://article.gmane.org/gmane.linux.kernel/510293
      
      (tweaked by Greg to not delete the field just yet, to make it easier to
      merge things properly.)
      Signed-off-by: NTejun Heo <htejun@gmail.com>
      Cc: Cornelia Huck <cornelia.huck@de.ibm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
      7b595756