1. 15 Apr, 2015 1 commit
  2. 20 Jan, 2015 1 commit
  3. 23 Dec, 2014 1 commit
  4. 18 Dec, 2014 1 commit
    • Kees Cook's avatar
      param: do not set store func without write perm · b0a65b0c
      Kees Cook authored
      
      When a module_param is defined without DAC write permissions, it can
      still be changed at runtime and updated. Drivers using a 0444 permission
      may be surprised that these values can still be changed.
      
      For drivers that want to allow updates, any S_IW* flag will set the
      "store" function as before. Drivers without S_IW* flags will have the
      "store" function unset, unforcing a read-only value. Drivers that wish
      neither "store" nor "get" can continue to use "0" for perms to stay out
      of sysfs entirely.
      
      Old behavior:
        # cd /sys/module/snd/parameters
        # ls -l
        total 0
        -r--r--r-- 1 root root 4096 Dec 11 13:55 cards_limit
        -r--r--r-- 1 root root 4096 Dec 11 13:55 major
        -r--r--r-- 1 root root 4096 Dec 11 13:55 slots
        # cat major
        116
        # echo -1 > major
        -bash: major: Permission denied
        # chmod u+w major
        # echo -1 > major
        # cat major
        -1
      
      New behavior:
        ...
        # chmod u+w major
        # echo -1 > major
        -bash: echo: write error: Input/output error
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      b0a65b0c
  5. 11 Nov, 2014 1 commit
    • Rusty Russell's avatar
      params: cleanup sysfs allocation · 18eb74fa
      Rusty Russell authored
      commit 63662139
      
       attempted to patch a
      leak (which would only happen on OOM, ie. never), but it didn't quite
      work.
      
      This rewrites the code to be as simple as possible.  add_sysfs_param()
      adds a parameter.  If it fails, it's the caller's responsibility to
      clean up the parameters which already exist.
      
      The kzalloc-then-always-krealloc pattern is perhaps overly simplistic,
      but this code has clearly confused people.  It worked on me...
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      18eb74fa
  6. 14 Oct, 2014 1 commit
  7. 27 Aug, 2014 3 commits
  8. 17 Jul, 2014 1 commit
  9. 28 Apr, 2014 1 commit
    • Rusty Russell's avatar
      param: hand arguments after -- straight to init · 51e158c1
      Rusty Russell authored
      
      The kernel passes any args it doesn't need through to init, except it
      assumes anything containing '.' belongs to the kernel (for a module).
      This change means all users can clearly distinguish which arguments
      are for init.
      
      For example, the kernel uses debug ("dee-bug") to mean log everything to
      the console, where systemd uses the debug from the Scandinavian "day-boog"
      meaning "fail to boot".  If a future versions uses argv[] instead of
      reading /proc/cmdline, this confusion will be avoided.
      
      eg: test 'FOO="this is --foo"' -- 'systemd.debug="true true true"'
      
      Gives:
      argv[0] = '/debug-init'
      argv[1] = 'test'
      argv[2] = 'systemd.debug=true true true'
      envp[0] = 'HOME=/'
      envp[1] = 'TERM=linux'
      envp[2] = 'FOO=this is --foo'
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      51e158c1
  10. 04 Dec, 2013 1 commit
  11. 28 Sep, 2013 1 commit
  12. 12 Sep, 2013 1 commit
  13. 03 Sep, 2013 1 commit
    • Li Zhong's avatar
      module: Fix mod->mkobj.kobj potentially freed too early · 942e4431
      Li Zhong authored
      
      DEBUG_KOBJECT_RELEASE helps to find the issue attached below.
      
      After some investigation, it seems the reason is:
      The mod->mkobj.kobj(ffffffffa01600d0 below) is freed together with mod
      itself in free_module(). However, its children still hold references to
      it, as the delay caused by DEBUG_KOBJECT_RELEASE. So when the
      child(holders below) tries to decrease the reference count to its parent
      in kobject_del(), BUG happens as it tries to access already freed memory.
      
      This patch tries to fix it by waiting for the mod->mkobj.kobj to be
      really released in the module removing process (and some error code
      paths).
      
      [ 1844.175287] kobject: 'holders' (ffff88007c1f1600): kobject_release, parent ffffffffa01600d0 (delayed)
      [ 1844.178991] kobject: 'notes' (ffff8800370b2a00): kobject_release, parent ffffffffa01600d0 (delayed)
      [ 1845.180118] kobject: 'holders' (ffff88007c1f1600): kobject_cleanup, parent ffffffffa01600d0
      [ 1845.182130] kobject: 'holders' (ffff88007c1f1600): auto cleanup kobject_del
      [ 1845.184120] BUG: unable to handle kernel paging request at ffffffffa01601d0
      [ 1845.185026] IP: [<ffffffff812cda81>] kobject_put+0x11/0x60
      [ 1845.185026] PGD 1a13067 PUD 1a14063 PMD 7bd30067 PTE 0
      [ 1845.185026] Oops: 0000 [#1] PREEMPT
      [ 1845.185026] Modules linked in: xfs libcrc32c [last unloaded: kprobe_example]
      [ 1845.185026] CPU: 0 PID: 18 Comm: kworker/0:1 Tainted: G           O 3.11.0-rc6-next-20130819+ #1
      [ 1845.185026] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2007
      [ 1845.185026] Workqueue: events kobject_delayed_cleanup
      [ 1845.185026] task: ffff88007ca51f00 ti: ffff88007ca5c000 task.ti: ffff88007ca5c000
      [ 1845.185026] RIP: 0010:[<ffffffff812cda81>]  [<ffffffff812cda81>] kobject_put+0x11/0x60
      [ 1845.185026] RSP: 0018:ffff88007ca5dd08  EFLAGS: 00010282
      [ 1845.185026] RAX: 0000000000002000 RBX: ffffffffa01600d0 RCX: ffffffff8177d638
      [ 1845.185026] RDX: ffff88007ca5dc18 RSI: 0000000000000000 RDI: ffffffffa01600d0
      [ 1845.185026] RBP: ffff88007ca5dd18 R08: ffffffff824e9810 R09: ffffffffffffffff
      [ 1845.185026] R10: ffff8800ffffffff R11: dead4ead00000001 R12: ffffffff81a95040
      [ 1845.185026] R13: ffff88007b27a960 R14: ffff88007c1f1600 R15: 0000000000000000
      [ 1845.185026] FS:  0000000000000000(0000) GS:ffffffff81a23000(0000) knlGS:0000000000000000
      [ 1845.185026] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      [ 1845.185026] CR2: ffffffffa01601d0 CR3: 0000000037207000 CR4: 00000000000006b0
      [ 1845.185026] Stack:
      [ 1845.185026]  ffff88007c1f1600 ffff88007c1f1600 ffff88007ca5dd38 ffffffff812cdb7e
      [ 1845.185026]  0000000000000000 ffff88007c1f1640 ffff88007ca5dd68 ffffffff812cdbfe
      [ 1845.185026]  ffff88007c974800 ffff88007c1f1640 ffff88007ff61a00 0000000000000000
      [ 1845.185026] Call Trace:
      [ 1845.185026]  [<ffffffff812cdb7e>] kobject_del+0x2e/0x40
      [ 1845.185026]  [<ffffffff812cdbfe>] kobject_delayed_cleanup+0x6e/0x1d0
      [ 1845.185026]  [<ffffffff81063a45>] process_one_work+0x1e5/0x670
      [ 1845.185026]  [<ffffffff810639e3>] ? process_one_work+0x183/0x670
      [ 1845.185026]  [<ffffffff810642b3>] worker_thread+0x113/0x370
      [ 1845.185026]  [<ffffffff810641a0>] ? rescuer_thread+0x290/0x290
      [ 1845.185026]  [<ffffffff8106bfba>] kthread+0xda/0xe0
      [ 1845.185026]  [<ffffffff814ff0f0>] ? _raw_spin_unlock_irq+0x30/0x60
      [ 1845.185026]  [<ffffffff8106bee0>] ? kthread_create_on_node+0x130/0x130
      [ 1845.185026]  [<ffffffff8150751a>] ret_from_fork+0x7a/0xb0
      [ 1845.185026]  [<ffffffff8106bee0>] ? kthread_create_on_node+0x130/0x130
      [ 1845.185026] Code: 81 48 c7 c7 28 95 ad 81 31 c0 e8 9b da 01 00 e9 4f ff ff ff 66 0f 1f 44 00 00 55 48 89 e5 53 48 89 fb 48 83 ec 08 48 85 ff 74 1d <f6> 87 00 01 00 00 01 74 1e 48 8d 7b 38 83 6b 38 01 0f 94 c0 84
      [ 1845.185026] RIP  [<ffffffff812cda81>] kobject_put+0x11/0x60
      [ 1845.185026]  RSP <ffff88007ca5dd08>
      [ 1845.185026] CR2: ffffffffa01601d0
      [ 1845.185026] ---[ end trace 49a70afd109f5653 ]---
      Signed-off-by: default avatarLi Zhong <zhong@linux.vnet.ibm.com>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      942e4431
  14. 20 Aug, 2013 3 commits
    • Chen Gang's avatar
      kernel/params.c: use scnprintf() instead of sprintf() · f4940ab7
      Chen Gang authored
      
      For some strings (e.g. version string), they are permitted to be larger
      than PAGE_SIZE (although meaningless), so recommend to use scnprintf()
      instead of sprintf().
      Signed-off-by: default avatarChen Gang <gang.chen@asianux.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      f4940ab7
    • Steven Rostedt's avatar
      module: Add flag to allow mod params to have no arguments · ab013c5f
      Steven Rostedt authored
      
      Currently the params.c code allows only two "set" functions to have
      no arguments. If a parameter does not have an argument, then it
      looks at the set function and tests if it is either param_set_bool()
      or param_set_bint(). If it is not one of these functions, then it
      fails the loading of the module.
      
      But there may be module parameters that have different set functions
      and still allow no arguments. But unless each of these cases adds
      their function to the if statement, it wont be allowed to have no
      arguments. This method gets rather messing and does not scale.
      
      Instead, introduce a flags field to the kernel_param_ops, where if
      the flag KERNEL_PARAM_FL_NOARG is set, the parameter will not fail
      if it does not contain an argument. It will be expected that the
      corresponding set function can handle a NULL pointer as "val".
      Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      ab013c5f
    • Christoph Jaeger's avatar
      module: fix sprintf format specifier in param_get_byte() · 79ac6834
      Christoph Jaeger authored
      
      In param_get_byte(), to which the macro STANDARD_PARAM_DEF(byte, ...) expands,
      "%c" is used to print an unsigned char. So it gets printed as a character what
      is not intended here. Use "%hhu" instead.
      
      [Rusty: note drivers which would be effected:
       drivers/net/wireless/cw1200/main.c
       drivers/ntb/ntb_transport.c:68
       drivers/scsi/lpfc/lpfc_attr.c
       drivers/usb/atm/speedtch.c
       drivers/usb/gadget/g_ffs.c
      ]
      
      Acked-by: Jon Mason <jon.mason@intel.com> (for ntb)
      Acked-by: Michal Nazarewicz <mina86@mina86.com> (for g_ffs.c)
      Signed-off-by: default avatarChristoph Jaeger <christophjaeger@linux.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      79ac6834
  15. 02 Jul, 2013 1 commit
  16. 18 Mar, 2013 1 commit
  17. 05 May, 2012 2 commits
  18. 30 Apr, 2012 1 commit
    • Jim Cromie's avatar
      params: add 3rd arg to option handler callback signature · 9fb48c74
      Jim Cromie authored
      
      Add a 3rd arg, named "doing", to unknown-options callbacks invoked
      from parse_args(). The arg is passed as:
      
        "Booting kernel" from start_kernel(),
        initcall_level_names[i] from do_initcall_level(),
        mod->name from load_module(), via parse_args(), parse_one()
      
      parse_args() already has the "name" parameter, which is renamed to
      "doing" to better reflect current uses 1,2 above.  parse_args() passes
      it to an altered parse_one(), which now passes it down into the
      unknown option handler callbacks.
      
      The mod->name will be needed to handle dyndbg for loadable modules,
      since params passed by modprobe are not qualified (they do not have a
      "$modname." prefix), and by the time the unknown-param callback is
      called, the module name is not otherwise available.
      
      Minor tweaks:
      
      Add param-name to parse_one's pr_debug(), current message doesnt
      identify the param being handled, add it.
      
      Add a pr_info to print current level and level_name of the initcall,
      and number of registered initcalls at that level.  This adds 7 lines
      to dmesg output, like:
      
         initlevel:6=device, 172 registered initcalls
      
      Drop "parameters" from initcall_level_names[], its unhelpful in the
      pr_info() added above.  This array is passed into parse_args() by
      do_initcall_level().
      
      CC: Rusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarJim Cromie <jim.cromie@gmail.com>
      Acked-by: default avatarJason Baron <jbaron@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9fb48c74
  19. 26 Mar, 2012 2 commits
  20. 29 Feb, 2012 1 commit
  21. 14 Feb, 2012 1 commit
  22. 12 Jan, 2012 2 commits
    • Rusty Russell's avatar
      module_param: avoid bool abuse, add bint for special cases. · 69116f27
      Rusty Russell authored
      
      For historical reasons, we allow module_param(bool) to take an int (or
      an unsigned int).  That's going away.
      
      A few drivers really want an int: they set it to -1 and a parameter
      will set it to 0 or 1.  This sucks: reading them from sysfs will give
      'Y' for both -1 and 1, but if we change it to an int, then the users
      might be broken (if they did "param" instead of "param=1").
      
      Use a new 'bint' parser for them.
      
      (ntfs has a different problem: it needs an int for debug_msgs because
      it's also exposed via sysctl.)
      
      Cc: Steve Glendinning <steve.glendinning@smsc.com>
      Cc: Jean Delvare <khali@linux-fr.org>
      Cc: Guenter Roeck <guenter.roeck@ericsson.com>
      Cc: Hoang-Nam Nguyen <hnguyen@de.ibm.com>
      Cc: Christoph Raisch <raisch@de.ibm.com>
      Cc: Roland Dreier <roland@kernel.org>
      Cc: Sean Hefty <sean.hefty@intel.com>
      Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
      Cc: linux390@de.ibm.com
      Cc: Anton Altaparmakov <anton@tuxera.com>
      Cc: Jaroslav Kysela <perex@perex.cz>
      Cc: Takashi Iwai <tiwai@suse.de>
      Cc: lm-sensors@lm-sensors.org
      Cc: linux-rdma@vger.kernel.org
      Cc: linux-s390@vger.kernel.org
      Cc: linux-ntfs-dev@lists.sourceforge.net
      Cc: alsa-devel@alsa-project.org
      Acked-by: Takashi Iwai <tiwai@suse.de> (For the sound part)
      Acked-by: Guenter Roeck <guenter.roeck@ericsson.com> (For the hwmon driver)
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      69116f27
    • Jim Cromie's avatar
      kernel/params: replace DEBUGP with pr_debug · 8487bfd9
      Jim Cromie authored
      
      Use more flexible pr_debug.  This allows:
      
        echo "module params +p" > /dbg/dynamic_debug/control
      
      to turn on debug messages when needed.
      Signed-off-by: default avatarJim Cromie <jim.cromie@gmail.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      8487bfd9
  23. 31 Oct, 2011 1 commit
    • Paul Gortmaker's avatar
      kernel: params.c needs module.h not moduleparam.h · 72a59aaa
      Paul Gortmaker authored
      
      Through various other implicit include paths, some files were
      getting the full module.h file, and hence living the illusion
      that they really only needed moduleparam.h -- but the reality
      is that once you remove the module.h presence, these show up:
      
      kernel/params.c:583: warning: ‘struct module_kobject’ declared inside parameter list
      
      Such files really require module.h so simply make it so.  As the
      file module.h grabs moduleparam.h on the fly, all will be well.
      Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
      72a59aaa
  24. 26 Oct, 2011 1 commit
  25. 24 Jul, 2011 3 commits
  26. 19 May, 2011 2 commits
  27. 25 Apr, 2011 1 commit
  28. 31 Mar, 2011 1 commit
  29. 24 Jan, 2011 1 commit
    • Dmitry Torokhov's avatar
      module: show version information for built-in modules in sysfs · e94965ed
      Dmitry Torokhov authored
      
      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: default avatarDmitry Torokhov <dtor@vmware.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      e94965ed
  30. 11 Aug, 2010 1 commit