14 Oct, 2014

1 commit


27 Aug, 2014

3 commits


18 Jul, 2014

1 commit

  • Some driver might want to pass in an 64-bit value, so introduce
    a module param type 'ullong'.

    Signed-off-by: Hannes Reinecke
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Ewan Milne
    Acked-by: Rusty Russell
    Signed-off-by: Christoph Hellwig

    Hannes Reinecke
     

28 Apr, 2014

1 commit

  • 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: Rusty Russell

    Rusty Russell
     

04 Dec, 2013

1 commit


29 Sep, 2013

1 commit


13 Sep, 2013

1 commit


03 Sep, 2013

1 commit

  • 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: [] 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:[] [] 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] [] kobject_del+0x2e/0x40
    [ 1845.185026] [] kobject_delayed_cleanup+0x6e/0x1d0
    [ 1845.185026] [] process_one_work+0x1e5/0x670
    [ 1845.185026] [] ? process_one_work+0x183/0x670
    [ 1845.185026] [] worker_thread+0x113/0x370
    [ 1845.185026] [] ? rescuer_thread+0x290/0x290
    [ 1845.185026] [] kthread+0xda/0xe0
    [ 1845.185026] [] ? _raw_spin_unlock_irq+0x30/0x60
    [ 1845.185026] [] ? kthread_create_on_node+0x130/0x130
    [ 1845.185026] [] ret_from_fork+0x7a/0xb0
    [ 1845.185026] [] ? 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 87 00 01 00 00 01 74 1e 48 8d 7b 38 83 6b 38 01 0f 94 c0 84
    [ 1845.185026] RIP [] kobject_put+0x11/0x60
    [ 1845.185026] RSP
    [ 1845.185026] CR2: ffffffffa01601d0
    [ 1845.185026] ---[ end trace 49a70afd109f5653 ]---

    Signed-off-by: Li Zhong
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: Rusty Russell

    Li Zhong
     

20 Aug, 2013

3 commits

  • 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: Chen Gang
    Signed-off-by: Rusty Russell

    Chen Gang
     
  • 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: Steven Rostedt
    Signed-off-by: Rusty Russell

    Steven Rostedt
     
  • 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 (for ntb)
    Acked-by: Michal Nazarewicz (for g_ffs.c)
    Signed-off-by: Christoph Jaeger
    Signed-off-by: Rusty Russell

    Christoph Jaeger
     

02 Jul, 2013

1 commit


18 Mar, 2013

1 commit

  • On allocation failure, it would fail to free the old attrs array which
    was no longer referenced by anything (since it would free the old
    module_param_attrs struct on the way out).

    Comment the suspicious-looking krealloc() usage to explain why it *isn't*
    actually buggy, despite looking like a classic realloc() usage bug.

    Signed-off-by: David Woodhouse

    David Woodhouse
     

05 May, 2012

2 commits

  • I left 1 printk which uses __FILE__, __LINE__ explicitly, which should
    not be subject to generic preferences expressed via pr_fmt().

    + tweaks suggested by Joe Perches:
    - add doing to irq-enabled warning, like others. It wont happen often..
    - change sysfs failure crit, not just err, make it 1 line in logs.
    - coalese 2 format fragments into 1 >80 char line

    cc: Joe Perches
    Signed-off-by: Jim Cromie
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     
  • In commit 9fb48c744: "params: add 3rd arg to option handler callback
    signature", the if-guard added to the pr_debug was overzealous; no
    callers pass NULL, and existing code above and below the guard assumes
    as much. Change the if-guard to match, and silence the Smack
    complaint.

    CC: Dan Carpenter
    Signed-off-by: Jim Cromie
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     

01 May, 2012

1 commit

  • 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
    Signed-off-by: Jim Cromie
    Acked-by: Jason Baron
    Signed-off-by: Greg Kroah-Hartman

    Jim Cromie
     

26 Mar, 2012

2 commits

  • This patch adds a set of macros that can be used to declare
    kernel parameters to be parsed _before_ initcalls at a chosen
    level are executed. We rename the now-unused "flags" field of
    struct kernel_param as the level. It's signed, for when we
    use this for early params as well, in future.

    Linker macro collating init calls had to be modified in order
    to add additional symbols between levels that are later used
    by the init code to split the calls into blocks.

    Signed-off-by: Pawel Moll
    Signed-off-by: Rusty Russell

    Pawel Moll
     
  • module_param(bool) used to counter-intuitively take an int. In
    fddd5201 (mid-2009) we allowed bool or int/unsigned int using a messy
    trick.

    This eliminates that code (though leaves the flags field in the struct,
    for impending use).

    Signed-off-by: Rusty Russell

    Rusty Russell
     

29 Feb, 2012

1 commit

  • Different tree maintainers picked up independently generated
    trivial compile fixes based on linux-next testing, resulting
    in some cases where a file would have got more than one addition
    of module.h once everything was all merged together.

    Delete any duplicates so includecheck isn't complaining about
    anything related to module.h/export.h changes.

    Signed-off-by: Paul Gortmaker

    Paul Gortmaker
     

14 Feb, 2012

1 commit


13 Jan, 2012

2 commits

  • 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
    Cc: Jean Delvare
    Cc: Guenter Roeck
    Cc: Hoang-Nam Nguyen
    Cc: Christoph Raisch
    Cc: Roland Dreier
    Cc: Sean Hefty
    Cc: Hal Rosenstock
    Cc: linux390@de.ibm.com
    Cc: Anton Altaparmakov
    Cc: Jaroslav Kysela
    Cc: Takashi Iwai
    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 (For the sound part)
    Acked-by: Guenter Roeck (For the hwmon driver)
    Signed-off-by: Rusty Russell

    Rusty Russell
     
  • 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: Jim Cromie
    Signed-off-by: Rusty Russell

    Jim Cromie
     

31 Oct, 2011

1 commit

  • 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: Paul Gortmaker

    Paul Gortmaker
     

26 Oct, 2011

1 commit

  • The user may use "foo-bar" for a kernel parameter defined as "foo_bar".
    Make sure it works the other way around too.

    Apply the equality of dashes and underscores on early_params and __setup
    params as well.

    The example given in Documentation/kernel-parameters.txt indicates that
    this is the intended behaviour.

    With the patch the kernel accepts "log-buf-len=1M" as expected.
    https://bugzilla.redhat.com/show_bug.cgi?id=744545

    Signed-off-by: Michal Schmidt
    Signed-off-by: Rusty Russell (neatened implementations)

    Michal Schmidt
     

24 Jul, 2011

3 commits

  • Userspace wants to manage module parameters with udev rules.
    This currently only works for loaded modules, but not for
    built-in ones.

    To allow access to the built-in modules we need to
    re-trigger all module load events that happened before any
    userspace was running. We already do the same thing for all
    devices, subsystems(buses) and drivers.

    This adds the currently missing /sys/module//uevent files
    to all module entries.

    Signed-off-by: Kay Sievers
    Signed-off-by: Rusty Russell (split & trivial fix)

    Kay Sievers
     
  • This simplifies the next patch, where we have an attribute on a
    builtin module (ie. module == NULL).

    Signed-off-by: Kay Sievers
    Signed-off-by: Rusty Russell (split into 2)

    Kay Sievers
     
  • In STANDARD_PARAM_DEF, param_set_* handles the case in which strtolfn
    returns -EINVAL but it may return -ERANGE. If it returns -ERANGE,
    param_set_* may set uninitialized value to the paramerter. We should handle
    both cases.

    The one of the cases in which strtolfn() returns -ERANGE is following:

    *Type of module parameter is long
    *Set the parameter more than LONG_MAX

    Signed-off-by: Satoru Moriya
    Signed-off-by: Rusty Russell

    Satoru Moriya
     

19 May, 2011

2 commits

  • Signed-off-by: Jonathan Cameron
    Signed-off-by: Rusty Russell

    Jonathan Cameron
     
  • On m68k natural alignment is 2-byte boundary but we are trying to
    align structures in __modver section on sizeof(void *) boundary.
    This causes trouble when we try to access elements in this section
    in array-like fashion when create "version" attributes for built-in
    modules.

    Moreover, as DaveM said, we can't reliably put structures into
    independent objects, put them into a special section, and then expect
    array access over them (via the section boundaries) after linking the
    objects together to just "work" due to variable alignment choices in
    different situations. The only solution that seems to work reliably
    is to make an array of plain pointers to the objects in question and
    put those pointers in the special section.

    Reported-by: Geert Uytterhoeven
    Signed-off-by: Dmitry Torokhov
    Signed-off-by: Rusty Russell

    Dmitry Torokhov
     

31 Mar, 2011

1 commit


24 Jan, 2011

1 commit

  • Currently only drivers that are built as modules have their versions
    shown in /sys/module//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: Dmitry Torokhov
    Signed-off-by: Rusty Russell

    Dmitry Torokhov
     

11 Aug, 2010

7 commits

  • There may be cases (most obviously, sysfs-writable charp parameters) where
    a module needs to prevent sysfs access to parameters.

    Rather than express this in terms of a big lock, the functions are
    expressed in terms of what they protect against. This is clearer, esp.
    if the implementation changes to a module-level or even param-level lock.

    Signed-off-by: Rusty Russell
    Reviewed-by: Takashi Iwai
    Tested-by: Phil Carmody

    Rusty Russell
     
  • Since this section can be read-only (they're in .rodata), they should
    always have been const. Minor flow-through various functions.

    Signed-off-by: Rusty Russell
    Tested-by: Phil Carmody

    Rusty Russell
     
  • Instead of using a "I kmalloced this" flag, we keep track of the kmalloced
    strings and use that list to check if we need to kfree (in practice, the
    list is very short).

    This means that kparams can be const again, and plugs a leak. This
    is important for drivers/usb/gadget/nokia.c which gets modprobe/rmmod'ed
    frequently on the N9000.

    Signed-off-by: Rusty Russell
    Reviewed-by: Takashi Iwai
    Cc: Artem Bityutskiy
    Tested-by: Phil Carmody

    Rusty Russell
     
  • This allows us to generalize the KPARAM_KMALLOCED flag, by calling a function
    on every parameter when a module is unloaded.

    Signed-off-by: Rusty Russell
    Reviewed-by: Takashi Iwai
    Tested-by: Phil Carmody

    Rusty Russell
     
  • This is more kernel-ish, saves some space, and also allows us to
    expand the ops without breaking all the callers who are happy for the
    new members to be NULL.

    The few places which defined their own param types are changed to the
    new scheme (more which crept in recently fixed in following patches).

    Since we're touching them anyway, we change get() and set() to take a
    const struct kernel_param (which they really are). This causes some
    harmless warnings until we fix them (in following patches).

    To reduce churn, module_param_call creates the ops struct so the callers
    don't have to change (and casts the functions to reduce warnings).
    The modern version which takes an ops struct is called module_param_cb.

    Signed-off-by: Rusty Russell
    Reviewed-by: Takashi Iwai
    Tested-by: Phil Carmody
    Cc: "David S. Miller"
    Cc: Ville Syrjala
    Cc: Dmitry Torokhov
    Cc: Alessandro Rubini
    Cc: Michal Januszewski
    Cc: Trond Myklebust
    Cc: "J. Bruce Fields"
    Cc: Neil Brown
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-input@vger.kernel.org
    Cc: linux-fbdev-devel@lists.sourceforge.net
    Cc: linux-nfs@vger.kernel.org
    Cc: netdev@vger.kernel.org

    Rusty Russell
     
  • This is modern style, and good to do before we start changing things.

    Signed-off-by: Rusty Russell
    Reviewed-by: Takashi Iwai
    Tested-by: Phil Carmody

    Rusty Russell
     
  • An audit by Dongdong Deng revealed that most driver-author-written param
    calls don't handle val == NULL (which happens when parameters are specified
    with no =, eg "foo" instead of "foo=1").

    The only real case to use this is boolean, so handle it specially for that
    case and remove a source of bugs for everyone else.

    Signed-off-by: Rusty Russell
    Cc: Dongdong Deng
    Cc: Américo Wang

    Rusty Russell