19 Dec, 2014

1 commit

  • Pull module updates from Rusty Russell:
    "The exciting thing here is the getting rid of stop_machine on module
    removal. This is possible by using a simple atomic_t for the counter,
    rather than our fancy per-cpu counter: it turns out that no one is
    doing a module increment per net packet, so the slowdown should be in
    the noise"

    * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    param: do not set store func without write perm
    params: cleanup sysfs allocation
    kernel:module Fix coding style errors and warnings.
    module: Remove stop_machine from module unloading
    module: Replace module_ref with atomic_t refcnt
    lib/bug: Use RCU list ops for module_bug_list
    module: Unlink module with RCU synchronizing instead of stop_machine
    module: Wait for RCU synchronizing before releasing a module

    Linus Torvalds
     

11 Nov, 2014

6 commits

  • Fixed codin style errors and warnings. Changes printk with
    print_debug/warn. Changed seq_printf to seq_puts.

    Signed-off-by: Ionut Alexa
    Signed-off-by: Rusty Russell (removed bogus KERN_DEFAULT conversion)

    Ionut Alexa
     
  • Remove stop_machine from module unloading by adding new reference
    counting algorithm.

    This atomic refcounter works like a semaphore, it can get (be
    incremented) only when the counter is not 0. When loading a module,
    kmodule subsystem sets the counter MODULE_REF_BASE (= 1). And when
    unloading the module, it subtracts MODULE_REF_BASE from the counter.
    If no one refers the module, the refcounter becomes 0 and we can
    remove the module safely. If someone referes it, we try to recover
    the counter by adding MODULE_REF_BASE unless the counter becomes 0,
    because the referrer can put the module right before recovering.
    If the recovering is failed, we can get the 0 refcount and it
    never be incremented again, it can be removed safely too.

    Note that __module_get() forcibly gets the module refcounter,
    users should use try_module_get() instead of that.

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Rusty Russell

    Masami Hiramatsu
     
  • Replace module_ref per-cpu complex reference counter with
    an atomic_t simple refcnt. This is for code simplification.

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Rusty Russell

    Masami Hiramatsu
     
  • Actually since module_bug_list should be used in BUG context,
    we may not need this. But for someone who want to use this
    from normal context, this makes module_bug_list an RCU list.

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Rusty Russell

    Masami Hiramatsu
     
  • Unlink module from module list with RCU synchronizing instead
    of using stop_machine(). Since module list is already protected
    by rcu, we don't need stop_machine() anymore.

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Rusty Russell

    Masami Hiramatsu
     
  • Wait for RCU synchronizing on failure path of module loading
    before releasing struct module, because the memory of mod->list
    can still be accessed by list walkers (e.g. kallsyms).

    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Rusty Russell

    Masami Hiramatsu
     

28 Oct, 2014

1 commit

  • This is a genuine bug in add_unformed_module(), we cannot use blocking
    primitives inside a wait loop.

    So rewrite the wait_event_interruptible() usage to use the fresh
    wait_woken() stuff.

    Reported-by: Fengguang Wu
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: tglx@linutronix.de
    Cc: ilya.dryomov@inktank.com
    Cc: umgwanakikbuti@gmail.com
    Cc: Rusty Russell
    Cc: oleg@redhat.com
    Cc: Linus Torvalds
    Cc: Andrew Morton
    Cc: Greg Kroah-Hartman
    Link: http://lkml.kernel.org/r/20140924082242.458562904@infradead.org
    [ So this is probably complex to backport and the race wasn't reported AFAIK,
    so not marked for -stable. ]
    Signed-off-by: Ingo Molnar

    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

19 Oct, 2014

1 commit


15 Oct, 2014

1 commit

  • A panic was seen in the following sitation.

    There are two threads running on the system. The first thread is a system
    monitoring thread that is reading /proc/modules. The second thread is
    loading and unloading a module (in this example I'm using my simple
    dummy-module.ko). Note, in the "real world" this occurred with the qlogic
    driver module.

    When doing this, the following panic occurred:

    ------------[ cut here ]------------
    kernel BUG at kernel/module.c:3739!
    invalid opcode: 0000 [#1] SMP
    Modules linked in: binfmt_misc sg nfsv3 rpcsec_gss_krb5 nfsv4 dns_resolver nfs fscache intel_powerclamp coretemp kvm_intel kvm crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel aesni_intel lrw igb gf128mul glue_helper iTCO_wdt iTCO_vendor_support ablk_helper ptp sb_edac cryptd pps_core edac_core shpchp i2c_i801 pcspkr wmi lpc_ich ioatdma mfd_core dca ipmi_si nfsd ipmi_msghandler auth_rpcgss nfs_acl lockd sunrpc xfs libcrc32c sr_mod cdrom sd_mod crc_t10dif crct10dif_common mgag200 syscopyarea sysfillrect sysimgblt i2c_algo_bit drm_kms_helper ttm isci drm libsas ahci libahci scsi_transport_sas libata i2c_core dm_mirror dm_region_hash dm_log dm_mod [last unloaded: dummy_module]
    CPU: 37 PID: 186343 Comm: cat Tainted: GF O-------------- 3.10.0+ #7
    Hardware name: Intel Corporation S2600CP/S2600CP, BIOS RMLSDP.86I.00.29.D696.1311111329 11/11/2013
    task: ffff8807fd2d8000 ti: ffff88080fa7c000 task.ti: ffff88080fa7c000
    RIP: 0010:[] [] module_flags+0xb5/0xc0
    RSP: 0018:ffff88080fa7fe18 EFLAGS: 00010246
    RAX: 0000000000000003 RBX: ffffffffa03b5200 RCX: 0000000000000000
    RDX: 0000000000001000 RSI: ffff88080fa7fe38 RDI: ffffffffa03b5000
    RBP: ffff88080fa7fe28 R08: 0000000000000010 R09: 0000000000000000
    R10: 0000000000000000 R11: 000000000000000f R12: ffffffffa03b5000
    R13: ffffffffa03b5008 R14: ffffffffa03b5200 R15: ffffffffa03b5000
    FS: 00007f6ae57ef740(0000) GS:ffff88101e7a0000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000000000404f70 CR3: 0000000ffed48000 CR4: 00000000001407e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
    Stack:
    ffffffffa03b5200 ffff8810101e4800 ffff88080fa7fe70 ffffffff810d666c
    ffff88081e807300 000000002e0f2fbf 0000000000000000 ffff88100f257b00
    ffffffffa03b5008 ffff88080fa7ff48 ffff8810101e4800 ffff88080fa7fee0
    Call Trace:
    [] m_show+0x19c/0x1e0
    [] seq_read+0x16e/0x3b0
    [] proc_reg_read+0x3d/0x80
    [] vfs_read+0x9c/0x170
    [] SyS_read+0x58/0xb0
    [] system_call_fastpath+0x16/0x1b
    Code: 48 63 c2 83 c2 01 c6 04 03 29 48 63 d2 eb d9 0f 1f 80 00 00 00 00 48 63 d2 c6 04 13 2d 41 8b 0c 24 8d 50 02 83 f9 01 75 b2 eb cb 0b 66 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 55 48 89 e5 41
    RIP [] module_flags+0xb5/0xc0
    RSP

    Consider the two processes running on the system.

    CPU 0 (/proc/modules reader)
    CPU 1 (loading/unloading module)

    CPU 0 opens /proc/modules, and starts displaying data for each module by
    traversing the modules list via fs/seq_file.c:seq_open() and
    fs/seq_file.c:seq_read(). For each module in the modules list, seq_read
    does

    op->start() show() stop() state == MODULE_STATE_UNFORMED);
    ...

    The other thread, CPU 1, in unloading the module calls the syscall
    delete_module() defined in kernel/module.c. The module_mutex is acquired
    for a short time, and then released. free_module() is called without the
    module_mutex. free_module() then sets mod->state = MODULE_STATE_UNFORMED,
    also without the module_mutex. Some additional code is called and then the
    module_mutex is reacquired to remove the module from the modules list:

    /* Now we can delete it from the lists */
    mutex_lock(&module_mutex);
    stop_machine(__unlink_module, mod, NULL);
    mutex_unlock(&module_mutex);

    This is the sequence of events that leads to the panic.

    CPU 1 is removing dummy_module via delete_module(). It acquires the
    module_mutex, and then releases it. CPU 1 has NOT set dummy_module->state to
    MODULE_STATE_UNFORMED yet.

    CPU 0, which is reading the /proc/modules, acquires the module_mutex and
    acquires a pointer to the dummy_module which is still in the modules list.
    CPU 0 calls m_show for dummy_module. The check in m_show() for
    MODULE_STATE_UNFORMED passed for dummy_module even though it is being
    torn down.

    Meanwhile CPU 1, which has been continuing to remove dummy_module without
    holding the module_mutex, now calls free_module() and sets
    dummy_module->state to MODULE_STATE_UNFORMED.

    CPU 0 now calls module_flags() with dummy_module and ...

    static char *module_flags(struct module *mod, char *buf)
    {
    int bx = 0;

    BUG_ON(mod->state == MODULE_STATE_UNFORMED);

    and BOOM.

    Acquire and release the module_mutex lock around the setting of
    MODULE_STATE_UNFORMED in the teardown path, which should resolve the
    problem.

    Testing: In the unpatched kernel I can panic the system within 1 minute by
    doing

    while (true) do insmod dummy_module.ko; rmmod dummy_module.ko; done

    and

    while (true) do cat /proc/modules; done

    in separate terminals.

    In the patched kernel I was able to run just over one hour without seeing
    any issues. I also verified the output of panic via sysrq-c and the output
    of /proc/modules looks correct for all three states for the dummy_module.

    dummy_module 12661 0 - Unloading 0xffffffffa03a5000 (OE-)
    dummy_module 12661 0 - Live 0xffffffffa03bb000 (OE)
    dummy_module 14015 1 - Loading 0xffffffffa03a5000 (OE+)

    Signed-off-by: Prarit Bhargava
    Reviewed-by: Oleg Nesterov
    Signed-off-by: Rusty Russell
    Cc: stable@kernel.org

    Prarit Bhargava
     

08 Oct, 2014

1 commit

  • Pull arm64 updates from Catalin Marinas:
    - eBPF JIT compiler for arm64
    - CPU suspend backend for PSCI (firmware interface) with standard idle
    states defined in DT (generic idle driver to be merged via a
    different tree)
    - Support for CONFIG_DEBUG_SET_MODULE_RONX
    - Support for unmapped cpu-release-addr (outside kernel linear mapping)
    - set_arch_dma_coherent_ops() implemented and bus notifiers removed
    - EFI_STUB improvements when base of DRAM is occupied
    - Typos in KGDB macros
    - Clean-up to (partially) allow kernel building with LLVM
    - Other clean-ups (extern keyword, phys_addr_t usage)

    * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: (51 commits)
    arm64: Remove unneeded extern keyword
    ARM64: make of_device_ids const
    arm64: Use phys_addr_t type for physical address
    aarch64: filter $x from kallsyms
    arm64: Use DMA_ERROR_CODE to denote failed allocation
    arm64: Fix typos in KGDB macros
    arm64: insn: Add return statements after BUG_ON()
    arm64: debug: don't re-enable debug exceptions on return from el1_dbg
    Revert "arm64: dmi: Add SMBIOS/DMI support"
    arm64: Implement set_arch_dma_coherent_ops() to replace bus notifiers
    of: amba: use of_dma_configure for AMBA devices
    arm64: dmi: Add SMBIOS/DMI support
    arm64: Correct ftrace calls to aarch64_insn_gen_branch_imm()
    arm64:mm: initialize max_mapnr using function set_max_mapnr
    setup: Move unmask of async interrupts after possible earlycon setup
    arm64: LLVMLinux: Fix inline arm64 assembly for use with clang
    arm64: pageattr: Correctly adjust unaligned start addresses
    net: bpf: arm64: fix module memory leak when JIT image build fails
    arm64: add PSCI CPU_SUSPEND based cpu_suspend support
    arm64: kernel: introduce cpu_init_idle CPU operation
    ...

    Linus Torvalds
     

03 Oct, 2014

1 commit

  • Similar to ARM, AArch64 is generating $x and $d syms... which isn't
    terribly helpful when looking at %pF output and the like. Filter those
    out in kallsyms, modpost and when looking at module symbols.

    Seems simplest since none of these check EM_ARM anyway, to just add it
    to the strchr used, rather than trying to make things overly
    complicated.

    initcall_debug improves:
    dmesg_before.txt: initcall $x+0x0/0x154 [sg] returned 0 after 26331 usecs
    dmesg_after.txt: initcall init_sg+0x0/0x154 [sg] returned 0 after 15461 usecs

    Signed-off-by: Kyle McMartin
    Acked-by: Rusty Russell
    Signed-off-by: Catalin Marinas

    Kyle McMartin
     

27 Aug, 2014

1 commit


16 Aug, 2014

1 commit

  • The commit

    4982223e51e8 module: set nx before marking module MODULE_STATE_COMING.

    introduced a regression: if a module fails to parse its arguments or
    if mod_sysfs_setup fails, then the module's memory will be freed
    while still read-only. Anything that reuses that memory will crash
    as soon as it tries to write to it.

    Cc: stable@vger.kernel.org # v3.16
    Cc: Rusty Russell
    Signed-off-by: Andy Lutomirski
    Signed-off-by: Rusty Russell

    Andy Lutomirski
     

11 Aug, 2014

1 commit

  • Pull module updates from Rusty Russell:
    "This finally applies the stricter sysfs perms checking we pulled out
    before last merge window. A few stragglers are fixed (thanks
    linux-next!)"

    * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    arch/powerpc/platforms/powernv/opal-dump.c: fix world-writable sysfs files
    arch/powerpc/platforms/powernv/opal-elog.c: fix world-writable sysfs files
    drivers/video/fbdev/s3c2410fb.c: don't make debug world-writable.
    ARM: avoid ARM binutils leaking ELF local symbols
    scripts: modpost: Remove numeric suffix pattern matching
    scripts: modpost: fix compilation warning
    sysfs: disallow world-writable files.
    module: return bool from within_module*()
    module: add within_module() function
    modules: Fix build error in moduleloader.h

    Linus Torvalds
     

27 Jul, 2014

2 commits

  • Symbols starting with .L are ELF local symbols and should not appear
    in ELF symbol tables. However, unfortunately ARM binutils leaks the
    .LANCHOR symbols into the symbol table, which leads kallsyms to report
    these symbols rather than the real name. It is not very useful when
    %pf reports symbols against these leaked .LANCHOR symbols.

    Arrange for kallsyms to ignore these symbols using the same mechanism
    that is used for the ARM mapping symbols.

    Signed-off-by: Russell King
    Signed-off-by: Rusty Russell

    Russell King
     
  • It is just a small optimization that allows to replace few
    occurrences of within_module_init() || within_module_core()
    with a single call.

    Signed-off-by: Petr Mladek
    Signed-off-by: Rusty Russell

    Petr Mladek
     

03 Jul, 2014

1 commit

  • Per further discussion with NIST, the requirements for FIPS state that
    we only need to panic the system on failed kernel module signature checks
    for crypto subsystem modules. This moves the fips-mode-only module
    signature check out of the generic module loading code, into the crypto
    subsystem, at points where we can catch both algorithm module loads and
    mode module loads. At the same time, make CONFIG_CRYPTO_FIPS dependent on
    CONFIG_MODULE_SIG, as this is entirely necessary for FIPS mode.

    v2: remove extraneous blank line, perform checks in static inline
    function, drop no longer necessary fips.h include.

    CC: "David S. Miller"
    CC: Rusty Russell
    CC: Stephan Mueller
    Signed-off-by: Jarod Wilson
    Acked-by: Neil Horman
    Signed-off-by: Herbert Xu

    Jarod Wilson
     

12 Jun, 2014

1 commit

  • Pull module updates from Rusty Russell:
    "Most of this is cleaning up various driver sysfs permissions so we can
    re-add the perm check (we unified the module param and sysfs checks,
    but the module ones were stronger so we weakened them temporarily).

    Param parsing gets documented, and also "--" now forces args to be
    handed to init (and ignored by the kernel).

    Module NX/RO protections get tightened: we now set them before calling
    parse_args()"

    * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    module: set nx before marking module MODULE_STATE_COMING.
    samples/kobject/: avoid world-writable sysfs files.
    drivers/hid/hid-picolcd_fb: avoid world-writable sysfs files.
    drivers/staging/speakup/: avoid world-writable sysfs files.
    drivers/regulator/virtual: avoid world-writable sysfs files.
    drivers/scsi/pm8001/pm8001_ctl.c: avoid world-writable sysfs files.
    drivers/hid/hid-lg4ff.c: avoid world-writable sysfs files.
    drivers/video/fbdev/sm501fb.c: avoid world-writable sysfs files.
    drivers/mtd/devices/docg3.c: avoid world-writable sysfs files.
    speakup: fix incorrect perms on speakup_acntsa.c
    cpumask.h: silence warning with -Wsign-compare
    Documentation: Update kernel-parameters.tx
    param: hand arguments after -- straight to init
    modpost: Fix resource leak in read_dump()

    Linus Torvalds
     

14 May, 2014

1 commit

  • We currently set RO & NX on modules very late: after we move them from
    MODULE_STATE_UNFORMED to MODULE_STATE_COMING, and after we call
    parse_args() (which can exec code in the module).

    Much better is to do it in complete_formation() and then call
    the notifier.

    This means that the notifiers will be called on a module which
    is already RO & NX, so that may cause problems (ftrace already
    changed so they're unaffected).

    Signed-off-by: Rusty Russell

    Rusty Russell
     

02 May, 2014

1 commit


28 Apr, 2014

3 commits

  • A race exists between module loading and enabling of function tracer.

    CPU 1 CPU 2
    ----- -----
    load_module()
    module->state = MODULE_STATE_COMING

    register_ftrace_function()
    mutex_lock(&ftrace_lock);
    ftrace_startup()
    update_ftrace_function();
    ftrace_arch_code_modify_prepare()
    set_all_module_text_rw();

    ftrace_arch_code_modify_post_process()
    set_all_module_text_ro();

    [ here all module text is set to RO,
    including the module that is
    loading!! ]

    blocking_notifier_call_chain(MODULE_STATE_COMING);
    ftrace_init_module()

    [ tries to modify code, but it's RO, and fails!
    ftrace_bug() is called]

    When this race happens, ftrace_bug() will produces a nasty warning and
    all of the function tracing features will be disabled until reboot.

    The simple solution is to treate module load the same way the core
    kernel is treated at boot. To hardcode the ftrace function modification
    of converting calls to mcount into nops. This is done in init/main.c
    there's no reason it could not be done in load_module(). This gives
    a better control of the changes and doesn't tie the state of the
    module to its notifiers as much. Ftrace is special, it needs to be
    treated as such.

    The reason this would work, is that the ftrace_module_init() would be
    called while the module is in MODULE_STATE_UNFORMED, which is ignored
    by the set_all_module_text_ro() call.

    Link: http://lkml.kernel.org/r/1395637826-3312-1-git-send-email-indou.takao@jp.fujitsu.com

    Reported-by: Takao Indoh
    Acked-by: Rusty Russell
    Cc: stable@vger.kernel.org # 2.6.38+
    Signed-off-by: Steven Rostedt

    Steven Rostedt (Red Hat)
     
  • 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
     
  • We remove the waiting module removal in commit 3f2b9c9cdf38 (September
    2013), but it turns out that modprobe in kmod (< version 16) was
    asking for waiting module removal. No one noticed since modprobe would
    check for 0 usage immediately before trying to remove the module, and
    the race is unlikely.

    However, it means that anyone running old (but not ancient) kmod
    versions is hitting the printk designed to see if anyone was running
    "rmmod -w". All reports so far have been false positives, so remove
    the warning.

    Fixes: 3f2b9c9cdf389e303b2273679af08aab5f153517
    Reported-by: Valerio Vanni
    Cc: Elliott, Robert (Server Storage)
    Cc: stable@kernel.org
    Acked-by: Lucas De Marchi
    Signed-off-by: Rusty Russell

    Rusty Russell
     

08 Apr, 2014

1 commit

  • The initialization of a structure is not subject to synchronization.
    The use of __this_cpu would trigger a false positive with the additional
    preemption checks for __this_cpu ops.

    So simply disable the check through the use of raw_cpu ops.

    Trace:

    __this_cpu_write operation in preemptible [00000000] code: modprobe/286
    caller is __this_cpu_preempt_check+0x38/0x60
    CPU: 3 PID: 286 Comm: modprobe Tainted: GF 3.12.0-rc4+ #187
    Call Trace:
    dump_stack+0x4e/0x82
    check_preemption_disabled+0xec/0x110
    __this_cpu_preempt_check+0x38/0x60
    load_module+0xcfd/0x2650
    SyS_init_module+0xa6/0xd0
    tracesys+0xe1/0xe6

    Signed-off-by: Christoph Lameter
    Acked-by: Ingo Molnar
    Acked-by: Rusty Russell
    Cc: Tejun Heo
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter
     

07 Apr, 2014

1 commit

  • Pull module updates from Rusty Russell:
    "Nothing major: the stricter permissions checking for sysfs broke a
    staging driver; fix included. Greg KH said he'd take the patch but
    hadn't as the merge window opened, so it's included here to avoid
    breaking build"

    * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    staging: fix up speakup kobject mode
    Use 'E' instead of 'X' for unsigned module taint flag.
    VERIFY_OCTAL_PERMISSIONS: stricter checking for sysfs perms.
    kallsyms: fix percpu vars on x86-64 with relocation.
    kallsyms: generalize address range checking
    module: LLVMLinux: Remove unused function warning from __param_check macro
    Fix: module signature vs tracepoints: add new TAINT_UNSIGNED_MODULE
    module: remove MODULE_GENERIC_TABLE
    module: allow multiple calls to MODULE_DEVICE_TABLE() per module
    module: use pr_cont

    Linus Torvalds
     

01 Apr, 2014

1 commit

  • Pull x86 LTO changes from Peter Anvin:
    "More infrastructure work in preparation for link-time optimization
    (LTO). Most of these changes is to make sure symbols accessed from
    assembly code are properly marked as visible so the linker doesn't
    remove them.

    My understanding is that the changes to support LTO are still not
    upstream in binutils, but are on the way there. This patchset should
    conclude the x86-specific changes, and remaining patches to actually
    enable LTO will be fed through the Kbuild tree (other than keeping up
    with changes to the x86 code base, of course), although not
    necessarily in this merge window"

    * 'x86-asmlinkage-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (25 commits)
    Kbuild, lto: Handle basic LTO in modpost
    Kbuild, lto: Disable LTO for asm-offsets.c
    Kbuild, lto: Add a gcc-ld script to let run gcc as ld
    Kbuild, lto: add ld-version and ld-ifversion macros
    Kbuild, lto: Drop .number postfixes in modpost
    Kbuild, lto, workaround: Don't warn for initcall_reference in modpost
    lto: Disable LTO for sys_ni
    lto: Handle LTO common symbols in module loader
    lto, workaround: Add workaround for initcall reordering
    lto: Make asmlinkage __visible
    x86, lto: Disable LTO for the x86 VDSO
    initconst, x86: Fix initconst mistake in ts5500 code
    initconst: Fix initconst mistake in dcdbas
    asmlinkage: Make trace_hardirqs_on/off_caller visible
    asmlinkage, x86: Fix 32bit memcpy for LTO
    asmlinkage Make __stack_chk_failed and memcmp visible
    asmlinkage: Mark rwsem functions that can be called from assembler asmlinkage
    asmlinkage: Make main_extable_sort_needed visible
    asmlinkage, mutex: Mark __visible
    asmlinkage: Make trace_hardirq visible
    ...

    Linus Torvalds
     

31 Mar, 2014

1 commit

  • Takashi Iwai says:
    > The letter 'X' has been already used for SUSE kernels for very long
    > time, to indicate the external supported modules. Can the new flag be
    > changed to another letter for avoiding conflict...?
    > (BTW, we also use 'N' for "no support", too.)

    Note: this code should be cleaned up, so we don't have such maps in
    three places!

    Signed-off-by: Rusty Russell

    Rusty Russell
     

21 Mar, 2014

1 commit


13 Mar, 2014

2 commits

  • Users have reported being unable to trace non-signed modules loaded
    within a kernel supporting module signature.

    This is caused by tracepoint.c:tracepoint_module_coming() refusing to
    take into account tracepoints sitting within force-loaded modules
    (TAINT_FORCED_MODULE). The reason for this check, in the first place, is
    that a force-loaded module may have a struct module incompatible with
    the layout expected by the kernel, and can thus cause a kernel crash
    upon forced load of that module on a kernel with CONFIG_TRACEPOINTS=y.

    Tracepoints, however, specifically accept TAINT_OOT_MODULE and
    TAINT_CRAP, since those modules do not lead to the "very likely system
    crash" issue cited above for force-loaded modules.

    With kernels having CONFIG_MODULE_SIG=y (signed modules), a non-signed
    module is tainted re-using the TAINT_FORCED_MODULE taint flag.
    Unfortunately, this means that Tracepoints treat that module as a
    force-loaded module, and thus silently refuse to consider any tracepoint
    within this module.

    Since an unsigned module does not fit within the "very likely system
    crash" category of tainting, add a new TAINT_UNSIGNED_MODULE taint flag
    to specifically address this taint behavior, and accept those modules
    within Tracepoints. We use the letter 'X' as a taint flag character for
    a module being loaded that doesn't know how to sign its name (proposed
    by Steven Rostedt).

    Also add the missing 'O' entry to trace event show_module_flags() list
    for the sake of completeness.

    Signed-off-by: Mathieu Desnoyers
    Acked-by: Steven Rostedt
    NAKed-by: Ingo Molnar
    CC: Thomas Gleixner
    CC: David Howells
    CC: Greg Kroah-Hartman
    Signed-off-by: Rusty Russell

    Mathieu Desnoyers
     
  • When dumping loaded modules, we print them one by one in separate
    printks. Let's use pr_cont as they are continuation prints.

    Signed-off-by: Jiri Slaby
    Cc: Rusty Russell
    Signed-off-by: Rusty Russell

    Jiri Slaby
     

14 Feb, 2014

1 commit

  • Here is the workaround I made for having the kernel not reject modules
    built with -flto. The clean solution would be to get the compiler to not
    emit the symbol. Or if it has to emit the symbol, then emit it as
    initialized data but put it into a comdat/linkonce section.

    Minor tweaks by AK over Joe's patch.

    Cc: Rusty Russell
    Signed-off-by: Andi Kleen
    Link: http://lkml.kernel.org/r/1391846481-31491-5-git-send-email-ak@linux.intel.com
    Signed-off-by: H. Peter Anvin

    Joe Mario
     

21 Jan, 2014

1 commit


15 Nov, 2013

1 commit

  • Pull module updates from Rusty Russell:
    "Mainly boring here, too. rmmod --wait finally removed, though"

    * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    modpost: fix bogus 'exported twice' warnings.
    init: fix in-place parameter modification regression
    asmlinkage, module: Make ksymtab and kcrctab symbols and __this_module __visible
    kernel: add support for init_array constructors
    modpost: Optionally ignore secondary errors seen if a single module build fails
    module: remove rmmod --wait option.

    Linus Torvalds
     

13 Nov, 2013

1 commit

  • kernel/module.c uses a mix of printk(KERN_foo and pr_foo(). Convert it
    all to pr_foo and make the offered cleanups.

    Not sure what to do about the printk(KERN_DEFAULT). We don't have a
    pr_default().

    Cc: Rusty Russell
    Cc: Joe Perches
    Cc: Frantisek Hrbata
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

17 Oct, 2013

1 commit

  • This adds the .init_array section as yet another section with constructors. This
    is needed because gcc could add __gcov_init calls to .init_array or .ctors
    section, depending on gcc (and binutils) version .

    v2: - reuse mod->ctors for .init_array section for modules, because gcc uses
    .ctors or .init_array, but not both at the same time
    v3: - fail to load if that does happen somehow.

    Signed-off-by: Frantisek Hrbata
    Signed-off-by: Rusty Russell

    Frantisek Hrbata
     

23 Sep, 2013

1 commit

  • The option to wait for a module reference count to reach zero was in
    the initial module implementation, but it was never supported in
    modprobe (you had to use rmmod --wait). After discussion with Lucas,
    It has been deprecated (with a 10 second sleep) in kmod for the last
    year.

    This finally removes it: the flag will evoke a printk warning and a
    normal (non-blocking) remove attempt.

    Cc: Lucas De Marchi
    Signed-off-by: Rusty Russell

    Rusty Russell
     

05 Sep, 2013

1 commit

  • Pull vfs pile 1 from Al Viro:
    "Unfortunately, this merge window it'll have a be a lot of small piles -
    my fault, actually, for not keeping #for-next in anything that would
    resemble a sane shape ;-/

    This pile: assorted fixes (the first 3 are -stable fodder, IMO) and
    cleanups + %pd/%pD formats (dentry/file pathname, up to 4 last
    components) + several long-standing patches from various folks.

    There definitely will be a lot more (starting with Miklos'
    check_submount_and_drop() series)"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (26 commits)
    direct-io: Handle O_(D)SYNC AIO
    direct-io: Implement generic deferred AIO completions
    add formats for dentry/file pathnames
    kvm eventfd: switch to fdget
    powerpc kvm: use fdget
    switch fchmod() to fdget
    switch epoll_ctl() to fdget
    switch copy_module_from_fd() to fdget
    git simplify nilfs check for busy subtree
    ibmasmfs: don't bother passing superblock when not needed
    don't pass superblock to hypfs_{mkdir,create*}
    don't pass superblock to hypfs_diag_create_files
    don't pass superblock to hypfs_vm_create_files()
    oprofile: get rid of pointless forward declarations of struct super_block
    oprofilefs_create_...() do not need superblock argument
    oprofilefs_mkdir() doesn't need superblock argument
    don't bother with passing superblock to oprofile_create_stats_files()
    oprofile: don't bother with passing superblock to ->create_files()
    don't bother passing sb to oprofile_create_files()
    coh901318: don't open-code simple_read_from_buffer()
    ...

    Linus Torvalds
     

04 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