02 Jun, 2012

12 commits

  • Pull third pile of signal handling patches from Al Viro:
    "This time it's mostly helpers and conversions to them; there's a lot
    of stuff remaining in the tree, but that'll either go in -rc2
    (isolated bug fixes, ideally via arch maintainers' trees) or will sit
    there until the next cycle."

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal:
    x86: get rid of calling do_notify_resume() when returning to kernel mode
    blackfin: check __get_user() return value
    whack-a-mole with TIF_FREEZE
    FRV: Optimise the system call exit path in entry.S [ver #2]
    FRV: Shrink TIF_WORK_MASK [ver #2]
    FRV: Prevent syscall exit tracing and notify_resume at end of kernel exceptions
    new helper: signal_delivered()
    powerpc: get rid of restore_sigmask()
    most of set_current_blocked() callers want SIGKILL/SIGSTOP removed from set
    set_restore_sigmask() is never called without SIGPENDING (and never should be)
    TIF_RESTORE_SIGMASK can be set only when TIF_SIGPENDING is set
    don't call try_to_freeze() from do_signal()
    pull clearing RESTORE_SIGMASK into block_sigmask()
    sh64: failure to build sigframe != signal without handler
    openrisc: tracehook_signal_handler() is supposed to be called on success
    new helper: sigmask_to_save()
    new helper: restore_saved_sigmask()
    new helpers: {clear,test,test_and_clear}_restore_sigmask()
    HAVE_RESTORE_SIGMASK is defined on all architectures now

    Linus Torvalds
     
  • Pull vfs changes from Al Viro.
    "A lot of misc stuff. The obvious groups:
    * Miklos' atomic_open series; kills the damn abuse of
    ->d_revalidate() by NFS, which was the major stumbling block for
    all work in that area.
    * ripping security_file_mmap() and dealing with deadlocks in the
    area; sanitizing the neighborhood of vm_mmap()/vm_munmap() in
    general.
    * ->encode_fh() switched to saner API; insane fake dentry in
    mm/cleancache.c gone.
    * assorted annotations in fs (endianness, __user)
    * parts of Artem's ->s_dirty work (jff2 and reiserfs parts)
    * ->update_time() work from Josef.
    * other bits and pieces all over the place.

    Normally it would've been in two or three pull requests, but
    signal.git stuff had eaten a lot of time during this cycle ;-/"

    Fix up trivial conflicts in Documentation/filesystems/vfs.txt (the
    'truncate_range' inode method was removed by the VM changes, the VFS
    update adds an 'update_time()' method), and in fs/btrfs/ulist.[ch] (due
    to sparse fix added twice, with other changes nearby).

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (95 commits)
    nfs: don't open in ->d_revalidate
    vfs: retry last component if opening stale dentry
    vfs: nameidata_to_filp(): don't throw away file on error
    vfs: nameidata_to_filp(): inline __dentry_open()
    vfs: do_dentry_open(): don't put filp
    vfs: split __dentry_open()
    vfs: do_last() common post lookup
    vfs: do_last(): add audit_inode before open
    vfs: do_last(): only return EISDIR for O_CREAT
    vfs: do_last(): check LOOKUP_DIRECTORY
    vfs: do_last(): make ENOENT exit RCU safe
    vfs: make follow_link check RCU safe
    vfs: do_last(): use inode variable
    vfs: do_last(): inline walk_component()
    vfs: do_last(): make exit RCU safe
    vfs: split do_lookup()
    Btrfs: move over to use ->update_time
    fs: introduce inode operation ->update_time
    reiserfs: get rid of resierfs_sync_super
    reiserfs: mark the superblock as dirty a bit later
    ...

    Linus Torvalds
     
  • Pull Ext4 updates from Theodore Ts'o:
    "The major new feature added in this update is Darrick J Wong's
    metadata checksum feature, which adds crc32 checksums to ext4's
    metadata fields.

    There is also the usual set of cleanups and bug fixes."

    * tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (44 commits)
    ext4: hole-punch use truncate_pagecache_range
    jbd2: use kmem_cache_zalloc wrapper instead of flag
    ext4: remove mb_groups before tearing down the buddy_cache
    ext4: add ext4_mb_unload_buddy in the error path
    ext4: don't trash state flags in EXT4_IOC_SETFLAGS
    ext4: let getattr report the right blocks in delalloc+bigalloc
    ext4: add missing save_error_info() to ext4_error()
    ext4: add debugging trigger for ext4_error()
    ext4: protect group inode free counting with group lock
    ext4: use consistent ssize_t type in ext4_file_write()
    ext4: fix format flag in ext4_ext_binsearch_idx()
    ext4: cleanup in ext4_discard_allocated_blocks()
    ext4: return ENOMEM when mounts fail due to lack of memory
    ext4: remove redundundant "(char *) bh->b_data" casts
    ext4: disallow hard-linked directory in ext4_lookup
    ext4: fix potential integer overflow in alloc_flex_gd()
    ext4: remove needs_recovery in ext4_mb_init()
    ext4: force ro mount if ext4_setup_super() fails
    ext4: fix potential NULL dereference in ext4_free_inodes_counts()
    ext4/jbd2: add metadata checksumming to the list of supported features
    ...

    Linus Torvalds
     
  • Does block_sigmask() + tracehook_signal_handler(); called when
    sigframe has been successfully built. All architectures converted
    to it; block_sigmask() itself is gone now (merged into this one).

    I'm still not too happy with the signature, but that's a separate
    story (IMO we need a structure that would contain signal number +
    siginfo + k_sigaction, so that get_signal_to_deliver() would fill one,
    signal_delivered(), handle_signal() and probably setup...frame() -
    take one).

    Signed-off-by: Al Viro

    Al Viro
     
  • Only 3 out of 63 do not. Renamed the current variant to __set_current_blocked(),
    added set_current_blocked() that will exclude unblockable signals, switched
    open-coded instances to it.

    Signed-off-by: Al Viro

    Al Viro
     
  • Signed-off-by: Al Viro

    Al Viro
     
  • replace boilerplate "should we use ->saved_sigmask or ->blocked?"
    with calls of obvious inlined helper...

    Signed-off-by: Al Viro

    Al Viro
     
  • first fruits of ..._restore_sigmask() helpers: now we can take
    boilerplate "signal didn't have a handler, clear RESTORE_SIGMASK
    and restore the blocked mask from ->saved_mask" into a common
    helper. Open-coded instances switched...

    Signed-off-by: Al Viro

    Al Viro
     
  • helpers parallel to set_restore_sigmask(), used in the next commits

    Signed-off-by: Al Viro

    Al Viro
     
  • Everyone either defines it in arch thread_info.h or has TIF_RESTORE_SIGMASK
    and picks default set_restore_sigmask() in linux/thread_info.h. Kill the
    ifdefs, slap #error in linux/thread_info.h to catch breakage when new ones
    get merged.

    Signed-off-by: Al Viro

    Al Viro
     
  • NFS optimizes away d_revalidates for last component of open. This means that
    open itself can find the dentry stale.

    This patch allows the filesystem to return EOPENSTALE and the VFS will retry the
    lookup on just the last component if possible.

    If the lookup was done using RCU mode, including the last component, then this
    is not possible since the parent dentry is lost. In this case fall back to
    non-RCU lookup. Currently this is not used since NFS will always leave RCU
    mode.

    Signed-off-by: Miklos Szeredi
    Signed-off-by: Al Viro

    Miklos Szeredi
     
  • Btrfs has to make sure we have space to allocate new blocks in order to modify
    the inode, so updating time can fail. We've gotten around this by having our
    own file_update_time but this is kind of a pain, and Christoph has indicated he
    would like to make xfs do something different with atime updates. So introduce
    ->update_time, where we will deal with i_version an a/m/c time updates and
    indicate which changes need to be made. The normal version just does what it
    has always done, updates the time and marks the inode dirty, and then
    filesystems can choose to do something different.

    I've gone through all of the users of file_update_time and made them check for
    errors with the exception of the fault code since it's complicated and I wasn't
    quite sure what to do there, also Jan is going to be pushing the file time
    updates into page_mkwrite for those who have it so that should satisfy btrfs and
    make it not a big deal to check the file_update_time() return code in the
    generic fault path. Thanks,

    Signed-off-by: Josef Bacik

    Josef Bacik
     

01 Jun, 2012

28 commits

  • Pull the rest of the nfsd commits from Bruce Fields:
    "... and then I cherry-picked the remainder of the patches from the
    head of my previous branch"

    This is the rest of the original nfsd branch, rebased without the
    delegation stuff that I thought really needed to be redone.

    I don't like rebasing things like this in general, but in this situation
    this was the lesser of two evils.

    * 'for-3.5' of git://linux-nfs.org/~bfields/linux: (50 commits)
    nfsd4: fix, consolidate client_has_state
    nfsd4: don't remove rebooted client record until confirmation
    nfsd4: remove some dprintk's and a comment
    nfsd4: return "real" sequence id in confirmed case
    nfsd4: fix exchange_id to return confirm flag
    nfsd4: clarify that renewing expired client is a bug
    nfsd4: simpler ordering of setclientid_confirm checks
    nfsd4: setclientid: remove pointless assignment
    nfsd4: fix error return in non-matching-creds case
    nfsd4: fix setclientid_confirm same_cred check
    nfsd4: merge 3 setclientid cases to 2
    nfsd4: pull out common code from setclientid cases
    nfsd4: merge last two setclientid cases
    nfsd4: setclientid/confirm comment cleanup
    nfsd4: setclientid remove unnecessary terms from a logical expression
    nfsd4: move rq_flavor into svc_cred
    nfsd4: stricter cred comparison for setclientid/exchange_id
    nfsd4: move principal name into svc_cred
    nfsd4: allow removing clients not holding state
    nfsd4: rearrange exchange_id logic to simplify
    ...

    Linus Torvalds
     
  • after all, 0 bytes and 0 pages is the same thing...

    Signed-off-by: Al Viro

    Al Viro
     
  • Signed-off-by: Al Viro

    Al Viro
     
  • Pull second pile of signal handling patches from Al Viro:
    "This one is just task_work_add() series + remaining prereqs for it.

    There probably will be another pull request from that tree this
    cycle - at least for helpers, to get them out of the way for per-arch
    fixes remaining in the tree."

    Fix trivial conflict in kernel/irq/manage.c: the merge of Andrew's pile
    had brought in commit 97fd75b7b8e0 ("kernel/irq/manage.c: use the
    pr_foo() infrastructure to prefix printks") which changed one of the
    pr_err() calls that this merge moves around.

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal:
    keys: kill task_struct->replacement_session_keyring
    keys: kill the dummy key_replace_session_keyring()
    keys: change keyctl_session_to_parent() to use task_work_add()
    genirq: reimplement exit_irq_thread() hook via task_work_add()
    task_work_add: generic process-context callbacks
    avr32: missed _TIF_NOTIFY_RESUME on one of do_notify_resume callers
    parisc: need to check NOTIFY_RESUME when exiting from syscall
    move key_repace_session_keyring() into tracehook_notify_resume()
    TIF_NOTIFY_RESUME is defined on all targets now

    Linus Torvalds
     
  • Pull nfsd update from Bruce Fields.

    * 'for-3.5-take-2' of git://linux-nfs.org/~bfields/linux: (23 commits)
    nfsd: trivial: use SEEK_SET instead of 0 in vfs_llseek
    SUNRPC: split upcall function to extract reusable parts
    nfsd: allocate id-to-name and name-to-id caches in per-net operations.
    nfsd: make name-to-id cache allocated per network namespace context
    nfsd: make id-to-name cache allocated per network namespace context
    nfsd: pass network context to idmap init/exit functions
    nfsd: allocate export and expkey caches in per-net operations.
    nfsd: make expkey cache allocated per network namespace context
    nfsd: make export cache allocated per network namespace context
    nfsd: pass pointer to export cache down to stack wherever possible.
    nfsd: pass network context to export caches init/shutdown routines
    Lockd: pass network namespace to creation and destruction routines
    NFSd: remove hard-coded dereferences to name-to-id and id-to-name caches
    nfsd: pass pointer to expkey cache down to stack wherever possible.
    nfsd: use hash table from cache detail in nfsd export seq ops
    nfsd: pass svc_export_cache pointer as private data to "exports" seq file ops
    nfsd: use exp_put() for svc_export_cache put
    nfsd: use cache detail pointer from svc_export structure on cache put
    nfsd: add link to owner cache detail to svc_export structure
    nfsd: use passed cache_detail pointer expkey_parse()
    ...

    Linus Torvalds
     
  • Merge misc patches from Andrew Morton:

    - the "misc" tree - stuff from all over the map

    - checkpatch updates

    - fatfs

    - kmod changes

    - procfs

    - cpumask

    - UML

    - kexec

    - mqueue

    - rapidio

    - pidns

    - some checkpoint-restore feature work. Reluctantly. Most of it
    delayed a release. I'm still rather worried that we don't have a
    clear roadmap to completion for this work.

    * emailed from Andrew Morton : (78 patches)
    kconfig: update compression algorithm info
    c/r: prctl: add ability to set new mm_struct::exe_file
    c/r: prctl: extend PR_SET_MM to set up more mm_struct entries
    c/r: procfs: add arg_start/end, env_start/end and exit_code members to /proc/$pid/stat
    syscalls, x86: add __NR_kcmp syscall
    fs, proc: introduce /proc//task//children entry
    sysctl: make kernel.ns_last_pid control dependent on CHECKPOINT_RESTORE
    aio/vfs: cleanup of rw_copy_check_uvector() and compat_rw_copy_check_uvector()
    eventfd: change int to __u64 in eventfd_signal()
    fs/nls: add Apple NLS
    pidns: make killed children autoreap
    pidns: use task_active_pid_ns in do_notify_parent
    rapidio/tsi721: add DMA engine support
    rapidio: add DMA engine support for RIO data transfers
    ipc/mqueue: add rbtree node caching support
    tools/selftests: add mq_perf_tests
    ipc/mqueue: strengthen checks on mqueue creation
    ipc/mqueue: correct mq_attr_ok test
    ipc/mqueue: improve performance of send/recv
    selftests: add mq_open_tests
    ...

    Linus Torvalds
     
  • When we do restore we would like to have a way to setup a former
    mm_struct::exe_file so that /proc/pid/exe would point to the original
    executable file a process had at checkpoint time.

    For this the PR_SET_MM_EXE_FILE code is introduced. This option takes a
    file descriptor which will be set as a source for new /proc/$pid/exe
    symlink.

    Note it allows to change /proc/$pid/exe if there are no VM_EXECUTABLE
    vmas present for current process, simply because this feature is a special
    to C/R and mm::num_exe_file_vmas become meaningless after that.

    To minimize the amount of transition the /proc/pid/exe symlink might have,
    this feature is implemented in one-shot manner. Thus once changed the
    symlink can't be changed again. This should help sysadmins to monitor the
    symlinks over all process running in a system.

    In particular one could make a snapshot of processes and ring alarm if
    there unexpected changes of /proc/pid/exe's in a system.

    Note -- this feature is available iif CONFIG_CHECKPOINT_RESTORE is set and
    the caller must have CAP_SYS_RESOURCE capability granted, otherwise the
    request to change symlink will be rejected.

    Signed-off-by: Cyrill Gorcunov
    Reviewed-by: Oleg Nesterov
    Cc: KOSAKI Motohiro
    Cc: Pavel Emelyanov
    Cc: Kees Cook
    Cc: Tejun Heo
    Cc: Matt Helsley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Cyrill Gorcunov
     
  • During checkpoint we dump whole process memory to a file and the dump
    includes process stack memory. But among stack data itself, the stack
    carries additional parameters such as command line arguments, environment
    data and auxiliary vector.

    So when we do restore procedure and once we've restored stack data itself
    we need to setup mm_struct::arg_start/end, env_start/end, so restored
    process would be able to find command line arguments and environment data
    it had at checkpoint time. The same applies to auxiliary vector.

    For this reason additional PR_SET_MM_(ARG_START | ARG_END | ENV_START |
    ENV_END | AUXV) codes are introduced.

    Signed-off-by: Cyrill Gorcunov
    Acked-by: Kees Cook
    Cc: Tejun Heo
    Cc: Andrew Vagin
    Cc: Serge Hallyn
    Cc: Pavel Emelyanov
    Cc: Vasiliy Kulikov
    Cc: KAMEZAWA Hiroyuki
    Cc: Michael Kerrisk
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Cyrill Gorcunov
     
  • While doing the checkpoint-restore in the user space one need to determine
    whether various kernel objects (like mm_struct-s of file_struct-s) are
    shared between tasks and restore this state.

    The 2nd step can be solved by using appropriate CLONE_ flags and the
    unshare syscall, while there's currently no ways for solving the 1st one.

    One of the ways for checking whether two tasks share e.g. mm_struct is to
    provide some mm_struct ID of a task to its proc file, but showing such
    info considered to be not that good for security reasons.

    Thus after some debates we end up in conclusion that using that named
    'comparison' syscall might be the best candidate. So here is it --
    __NR_kcmp.

    It takes up to 5 arguments - the pids of the two tasks (which
    characteristics should be compared), the comparison type and (in case of
    comparison of files) two file descriptors.

    Lookups for pids are done in the caller's PID namespace only.

    At moment only x86 is supported and tested.

    [akpm@linux-foundation.org: fix up selftests, warnings]
    [akpm@linux-foundation.org: include errno.h]
    [akpm@linux-foundation.org: tweak comment text]
    Signed-off-by: Cyrill Gorcunov
    Acked-by: "Eric W. Biederman"
    Cc: Pavel Emelyanov
    Cc: Andrey Vagin
    Cc: KOSAKI Motohiro
    Cc: Ingo Molnar
    Cc: H. Peter Anvin
    Cc: Thomas Gleixner
    Cc: Glauber Costa
    Cc: Andi Kleen
    Cc: Tejun Heo
    Cc: Matt Helsley
    Cc: Pekka Enberg
    Cc: Eric Dumazet
    Cc: Vasiliy Kulikov
    Cc: Alexey Dobriyan
    Cc: Valdis.Kletnieks@vt.edu
    Cc: Michal Marek
    Cc: Frederic Weisbecker
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Cyrill Gorcunov
     
  • A cleanup of rw_copy_check_uvector and compat_rw_copy_check_uvector after
    changes made to support CMA in an earlier patch.

    Rather than having an additional check_access parameter to these
    functions, the first paramater type is overloaded to allow the caller to
    specify CHECK_IOVEC_ONLY which means check that the contents of the iovec
    are valid, but do not check the memory that they point to. This is used
    by process_vm_readv/writev where we need to validate that a iovec passed
    to the syscall is valid but do not want to check the memory that it points
    to at this point because it refers to an address space in another process.

    Signed-off-by: Chris Yeoh
    Reviewed-by: Oleg Nesterov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christopher Yeoh
     
  • eventfd_ctx->count is an __u64 counter which is allowed to reach
    ULLONG_MAX. eventfd_write() adds a __u64 value to "count", but the kernel
    side eventfd_signal() only adds an int value to it. Make them consistent.

    [akpm@linux-foundation.org: update interface documentation]
    Signed-off-by: Sha Zhengju
    Cc: Davide Libenzi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sha Zhengju
     
  • Adds DMA Engine framework support into RapidIO subsystem.

    Uses DMA Engine DMA_SLAVE interface to generate data transfers to/from
    remote RapidIO target devices.

    Introduces RapidIO-specific wrapper for prep_slave_sg() interface with an
    extra parameter to pass target specific information.

    Uses scatterlist to describe local data buffer. Address flat data buffer
    on a remote side.

    Signed-off-by: Alexandre Bounine
    Cc: Dan Williams
    Acked-by: Vinod Koul
    Cc: Li Yang
    Cc: Matt Porter
    Cc: Paul Gortmaker
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexandre Bounine
     
  • Commit b231cca4381e ("message queues: increase range limits") changed
    mqueue default value when attr parameter is specified NULL from hard
    coded value to fs.mqueue.{msg,msgsize}_max sysctl value.

    This made large side effect. When user need to use two mqueue
    applications 1) using !NULL attr parameter and it require big message
    size and 2) using NULL attr parameter and only need small size message,
    app (1) require to raise fs.mqueue.msgsize_max and app (2) consume large
    memory size even though it doesn't need.

    Doug Ledford propsed to switch back it to static hard coded value.
    However it also has a compatibility problem. Some applications might
    started depend on the default value is tunable.

    The solution is to separate default value from maximum value.

    Signed-off-by: KOSAKI Motohiro
    Signed-off-by: Doug Ledford
    Acked-by: Doug Ledford
    Acked-by: Joe Korty
    Cc: Amerigo Wang
    Acked-by: Serge E. Hallyn
    Cc: Jiri Slaby
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • Mqueue limitation is slightly naieve parameter likes other ipcs because
    unprivileged user can consume kernel memory by using ipcs.

    Thus, too aggressive raise bring us security issue. Example, current
    setting allow evil unprivileged user use 256GB (= 256 * 1024 * 1024*1024)
    and it's enough large to system will belome unresponsive. Don't do that.

    Instead, every admin should adjust the knobs for their own systems.

    Signed-off-by: KOSAKI Motohiro
    Acked-by: Doug Ledford
    Acked-by: Joe Korty
    Cc: Amerigo Wang
    Acked-by: Serge E. Hallyn
    Cc: Jiri Slaby
    Cc: Manfred Spraul
    Cc: Dave Hansen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • Commit b231cca4381e ("message queues: increase range limits") changed the
    maximum size of a message in a message queue from INT_MAX to 8192*128.
    Unfortunately, we had customers that relied on a size much larger than
    8192*128 on their production systems. After reviewing POSIX, we found
    that it is silent on the maximum message size. We did find a couple other
    areas in which it was not silent. Fix up the mqueue maximums so that the
    customer's system can continue to work, and document both the POSIX and
    real world requirements in ipc_namespace.h so that we don't have this
    issue crop back up.

    Also, commit 9cf18e1dd74cd0 ("ipc: HARD_MSGMAX should be higher not lower
    on 64bit") fiddled with HARD_MSGMAX without realizing that the number was
    intentionally in place to limit the msg queue depth to one that was small
    enough to kmalloc an array of pointers (hence why we divided 128k by
    sizeof(long)). If we wish to meet POSIX requirements, we have no choice
    but to change our allocation to a vmalloc instead (at least for the large
    queue size case). With that, it's possible to increase our allowed
    maximum to the POSIX requirements (or more if we choose).

    [sfr@canb.auug.org.au: using vmalloc requires including vmalloc.h]
    Signed-off-by: Doug Ledford
    Cc: Serge E. Hallyn
    Cc: Amerigo Wang
    Cc: Joe Korty
    Cc: Jiri Slaby
    Acked-by: KOSAKI Motohiro
    Cc: Manfred Spraul
    Signed-off-by: Stephen Rothwell
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Doug Ledford
     
  • Commit b231cca4381e ("message queues: increase range limits") changed
    how we create a queue that does not include an attr struct passed to
    open so that it creates the queue with whatever the maximum values are.
    However, if the admin has set the maximums to allow flexibility in
    creating a queue (aka, both a large size and large queue are allowed,
    but combined they create a queue too large for the RLIMIT_MSGQUEUE of
    the user), then attempts to create a queue without an attr struct will
    fail. Switch back to using acceptable defaults regardless of what the
    maximums are.

    Note: so far, we only know of a few applications that rely on this
    behavior (specifically, set the maximums in /proc, then run the
    application which calls mq_open() without passing in an attr struct, and
    the application expects the newly created message queue to have the
    maximum sizes that were set in /proc used on the mq_open() call, and all
    of those applications that we know of are actually part of regression
    test suites that were coded to do something like this:

    for size in 4096 65536 $((1024 * 1024)) $((16 * 1024 * 1024)); do
    echo $size > /proc/sys/fs/mqueue/msgsize_max
    mq_open || echo "Error opening mq with size $size"
    done

    These test suites that depend on any behavior like this are broken. The
    concept that programs should rely upon the system wide maximum in order
    to get their desired results instead of simply using a attr struct to
    specify what they want is fundamentally unfriendly programming practice
    for any multi-tasking OS.

    Fixing this will break those few apps that we know of (and those app
    authors recognize the brokenness of their code and the need to fix it).
    However, the following patch "mqueue: separate mqueue default value"
    allows a workaround in the form of new knobs for the default msg queue
    creation parameters for any software out there that we don't already
    know about that might rely on this behavior at the moment.

    Signed-off-by: Doug Ledford
    Cc: Serge E. Hallyn
    Cc: Amerigo Wang
    Cc: Joe Korty
    Cc: Jiri Slaby
    Acked-by: KOSAKI Motohiro
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Doug Ledford
     
  • Since commit b231cca4381e ("message queues: increase range limits") on
    Oct 18, 2008, calls to mq_open() that did not pass in an attribute
    struct and expected to get default values for the size of the queue and
    the max message size now get the system wide maximums instead of
    hardwired defaults like they used to get.

    This was uncovered when one of the earlier patches in this patch set
    increased the default system wide maximums at the same time it increased
    the hard ceiling on the system wide maximums (a customer specifically
    needed the hard ceiling brought back up, the new ceiling that commit
    b231cca4381e introduced was too low for their production systems). By
    increasing the default maximums and not realising they were tied to any
    attempt to create a message queue without an attribute struct, I had
    inadvertently made it such that all message queue creation attempts
    without an attribute struct were failing because the new default
    maximums would create a queue that exceeded the default rlimit for
    message queue bytes.

    As a result, the system wide defaults were brought back down to their
    previous levels, and the system wide ceilings on the maximums were
    raised to meet the customer's needs. However, the fact that the no
    attribute struct behavior of mq_open() could be broken by changing the
    system wide maximums for message queues was seen as fundamentally broken
    itself. So we hardwired the no attribute case back like it used to be.
    But, then we realized that on the very off chance that some piece of
    software in the wild depended on that behavior, we could work around
    that issue by adding two new knobs to /proc that allowed setting the
    defaults for message queues created without an attr struct separately
    from the system wide maximums.

    What is not an option IMO is to leave the current behavior in place. No
    piece of software should ever rely on setting the system wide maximums
    in order to get a desired message queue. Such a reliance would be so
    fundamentally multitasking OS unfriendly as to not really be tolerable.
    Fortunately, we don't know of any software in the wild that uses this
    except for a regression test program that caught the issue in the first
    place. If there is though, we have made accommodations with the two new
    /proc knobs (and that's all the accommodations such fundamentally broken
    software can be allowed)..

    This patch:

    The various defines for minimums and maximums of the sysctl controllable
    mqueue values are scattered amongst different files and named
    inconsistently. Move them all into ipc_namespace.h and make them have
    consistent names. Additionally, make the number of queues per namespace
    also have a minimum and maximum and use the same sysctl function as the
    other two settable variables.

    Signed-off-by: Doug Ledford
    Acked-by: Serge E. Hallyn
    Cc: Amerigo Wang
    Cc: Joe Korty
    Cc: Jiri Slaby
    Acked-by: KOSAKI Motohiro
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Doug Ledford
     
  • Add userspace definitions, guard all relevant kernel structures. While at
    it document stuff and remove now useless userspace hint.

    It is easy to add the relevant system call to respective libc's, but it
    seems pointless to have to duplicate the data structures.

    This is based on the kexec-tools headers, with the exception of just using
    int on return (succes or failure) and using size_t instead of 'unsigned
    long int' for the number of segments argument of kexec_load().

    Signed-off-by: maximilian attems
    Cc: Simon Horman
    Cc: Vivek Goyal
    Cc: Haren Myneni
    Cc: "Eric W. Biederman"
    Cc: Martin Schwidefsky
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    maximilian attems
     
  • Many architectures clear tasks' mm_cpumask like this:

    read_lock(&tasklist_lock);
    for_each_process(p) {
    if (p->mm)
    cpumask_clear_cpu(cpu, mm_cpumask(p->mm));
    }
    read_unlock(&tasklist_lock);

    Depending on the context, the code above may have several problems,
    such as:

    1. Working with task->mm w/o getting mm or grabing the task lock is
    dangerous as ->mm might disappear (exit_mm() assigns NULL under
    task_lock(), so tasklist lock is not enough).

    2. Checking for process->mm is not enough because process' main
    thread may exit or detach its mm via use_mm(), but other threads
    may still have a valid mm.

    This patch implements a small helper function that does things
    correctly, i.e.:

    1. We take the task's lock while whe handle its mm (we can't use
    get_task_mm()/mmput() pair as mmput() might sleep);

    2. To catch exited main thread case, we use find_lock_task_mm(),
    which walks up all threads and returns an appropriate task
    (with task lock held).

    Also, Per Peter Zijlstra's idea, now we don't grab tasklist_lock in
    the new helper, instead we take the rcu read lock. We can do this
    because the function is called after the cpu is taken down and marked
    offline, so no new tasks will get this cpu set in their mm mask.

    Signed-off-by: Anton Vorontsov
    Cc: Richard Weinberger
    Cc: Oleg Nesterov
    Cc: Peter Zijlstra
    Cc: Russell King
    Cc: Benjamin Herrenschmidt
    Cc: Mike Frysinger
    Cc: Paul Mundt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Anton Vorontsov
     
  • Commit 8f92054e7ca1 ("CRED: Fix __task_cred()'s lockdep check and banner
    comment"):

    add the following validation condition:

    task->exit_state >= 0

    to permit the access if the target task is dead and therefore
    unable to change its own credentials.

    OK, but afaics currently this can only help wait_task_zombie() which calls
    __task_cred() without rcu lock.

    Remove this validation and change wait_task_zombie() to use task_uid()
    instead. This means we do rcu_read_lock() only to shut up the lockdep,
    but we already do the same in, say, wait_task_stopped().

    task_is_dead() should die, task->exit_state != 0 means that this task has
    passed exit_notify(), only do_wait-like code paths should use this.

    Unfortunately, we can't kill task_is_dead() right now, it has already
    acquired buggy users in drivers/staging. The fix already exists.

    Signed-off-by: Oleg Nesterov
    Reviewed-by: "Eric W. Biederman"
    Acked-by: David Howells
    Cc: Jiri Olsa
    Cc: Paul E. McKenney
    Cc: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • If we move call_usermodehelper_fns() to kmod.c file and EXPORT_SYMBOL it
    we can avoid exporting all it's helper functions:
    call_usermodehelper_setup
    call_usermodehelper_setfns
    call_usermodehelper_exec
    And make all of them static to kmod.c

    Since the optimizer will see all these as a single call site it will
    inline them inside call_usermodehelper_fns(). So we loose the call to
    _fns but gain 3 calls to the helpers. (Not that it matters)

    Signed-off-by: Boaz Harrosh
    Cc: Oleg Nesterov
    Cc: Tetsuo Handa
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Boaz Harrosh
     
  • call_usermodehelper_freeinfo() is not used outside of kmod.c. So unexport
    it, and make it static to kmod.c

    Signed-off-by: Boaz Harrosh
    Cc: Oleg Nesterov
    Cc: Tetsuo Handa
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Boaz Harrosh
     
  • This is patchset makes fatfs stop using the VFS '->write_super()' method
    for writing out the FSINFO block.

    The final goal is to get rid of the 'sync_supers()' kernel thread. This
    kernel thread wakes up every 5 seconds (by default) and calls
    '->write_super()' for all mounted file-systems. And the bad thing is that
    this is done even if all the superblocks are clean. Moreover, some
    file-systems do not even need this end they do not register the
    '->write_super()' method at all (e.g., btrfs).

    So 'sync_supers()' most often just generates useless wake-ups and wastes
    power. I am trying to make all file-systems independent of
    '->write_super()' and plan to remove 'sync_supers()' and '->write_super'
    completely once there are no more users.

    The '->write_supers()' method is mostly used by baroque file-systems like
    hfs, udf, etc. Modern file-systems like btrfs and xfs do not use it.
    This justifies removing this stuff from VFS completely and make every FS
    self-manage own superblock.

    Tested with xfstests.

    This patch:

    Preparation for further changes. It introduces a special inode
    ('fsinfo_inode') in FAT file-system which we'll later use for managing the
    FSINFO block. Note, this there is already one special inode ('fat_inode')
    which is used for managing the FAT tables.

    Introduce new 'MSDOS_FSINFO_INO' constant for this special inode. It is
    safe to do because FAT file-system does not store inode numbers on the
    media but generates them run-time.

    I've also cleaned up the comment to existing 'MSDOS_ROOT_INO' constant,
    while on it.

    Signed-off-by: Artem Bityutskiy
    Cc: OGAWA Hirofumi
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Artem Bityutskiy
     
  • Previous code was using optimizations which were developed to work well
    even on narrow-word CPUs (by today's standards). But Linux runs only on
    32-bit and wider CPUs. We can use that.

    First: using 32x32->64 multiply and trivial 32-bit shift, we can correctly
    divide by 10 much larger numbers, and thus we can print groups of 9 digits
    instead of groups of 5 digits.

    Next: there are two algorithms to print larger numbers. One is generic:
    divide by 1000000000 and repeatedly print groups of (up to) 9 digits.
    It's conceptually simple, but requires an (unsigned long long) /
    1000000000 division.

    Second algorithm splits 64-bit unsigned long long into 16-bit chunks,
    manipulates them cleverly and generates groups of 4 decimal digits. It so
    happens that it does NOT require long long division.

    If long is > 32 bits, division of 64-bit values is relatively easy, and we
    will use the first algorithm. If long long is > 64 bits (strange
    architecture with VERY large long long), second algorithm can't be used,
    and we again use the first one.

    Else (if long is 32 bits and long long is 64 bits) we use second one.

    And third: there is a simple optimization which takes fast path not only
    for zero as was done before, but for all one-digit numbers.

    In all tested cases new code is faster than old one, in many cases by 30%,
    in few cases by more than 50% (for example, on x86-32, conversion of
    12345678). Code growth is ~0 in 32-bit case and ~130 bytes in 64-bit
    case.

    This patch is based upon an original from Michal Nazarewicz.

    [akpm@linux-foundation.org: checkpatch fixes]
    Signed-off-by: Michal Nazarewicz
    Signed-off-by: Denys Vlasenko
    Cc: Douglas W Jones
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Denys Vlasenko
     
  • ULONG_MAX is often used to check for integer overflow when calculating
    allocation size. While ULONG_MAX happens to work on most systems, there
    is no guarantee that `size_t' must be the same size as `long'.

    This patch introduces SIZE_MAX, the maximum value of `size_t', to improve
    portability and readability for allocation size validation.

    Signed-off-by: Xi Wang
    Acked-by: Alex Elder
    Cc: David Airlie
    Cc: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Xi Wang
     
  • Move the rq_flavor into struct svc_cred, and use it in setclientid and
    exchange_id comparisons as well.

    Signed-off-by: J. Bruce Fields

    J. Bruce Fields
     
  • Instead of keeping the principal name associated with a request in a
    structure that's private to auth_gss and using an accessor function,
    move it to svc_cred.

    Signed-off-by: J. Bruce Fields

    J. Bruce Fields
     
  • This new routine is responsible for service registration in a specified
    network context.

    The idea is to separate service creation from per-net operations.

    Note also: since registering service with svc_bind() can fail, the
    service will be destroyed and during destruction it will try to
    unregister itself from rpcbind. In this case unregistration has to be
    skipped.

    Signed-off-by: Stanislav Kinsbursky
    Signed-off-by: J. Bruce Fields

    Stanislav Kinsbursky