23 Mar, 2018

1 commit


02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

15 Sep, 2017

1 commit

  • Pull ipc compat cleanup and 64-bit time_t from Al Viro:
    "IPC copyin/copyout sanitizing, including 64bit time_t work from Deepa
    Dinamani"

    * 'work.ipc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    utimes: Make utimes y2038 safe
    ipc: shm: Make shmid_kernel timestamps y2038 safe
    ipc: sem: Make sem_array timestamps y2038 safe
    ipc: msg: Make msg_queue timestamps y2038 safe
    ipc: mqueue: Replace timespec with timespec64
    ipc: Make sys_semtimedop() y2038 safe
    get rid of SYSVIPC_COMPAT on ia64
    semtimedop(): move compat to native
    shmat(2): move compat to native
    msgrcv(2), msgsnd(2): move compat to native
    ipc(2): move compat to native
    ipc: make use of compat ipc_perm helpers
    semctl(): move compat to native
    semctl(): separate all layout-dependent copyin/copyout
    msgctl(): move compat to native
    msgctl(): split the actual work from copyin/copyout
    ipc: move compat shmctl to native
    shmctl: split the work from copyin/copyout

    Linus Torvalds
     

04 Sep, 2017

1 commit

  • time_t is not y2038 safe. Replace all uses of
    time_t by y2038 safe time64_t.

    Similarly, replace the calls to get_seconds() with
    y2038 safe ktime_get_real_seconds().
    Note that this preserves fast access on 64 bit systems,
    but 32 bit systems need sequence counters.

    The syscall interface themselves are not changed as part of
    the patch. They will be part of a different series.

    Signed-off-by: Deepa Dinamani
    Reviewed-by: Arnd Bergmann
    Signed-off-by: Al Viro

    Deepa Dinamani
     

19 Jul, 2017

1 commit

  • Pull structure randomization updates from Kees Cook:
    "Now that IPC and other changes have landed, enable manual markings for
    randstruct plugin, including the task_struct.

    This is the rest of what was staged in -next for the gcc-plugins, and
    comes in three patches, largest first:

    - mark "easy" structs with __randomize_layout

    - mark task_struct with an optional anonymous struct to isolate the
    __randomize_layout section

    - mark structs to opt _out_ of automated marking (which will come
    later)

    And, FWIW, this continues to pass allmodconfig (normal and patched to
    enable gcc-plugins) builds of x86_64, i386, arm64, arm, powerpc, and
    s390 for me"

    * tag 'gcc-plugins-v4.13-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
    randstruct: opt-out externally exposed function pointer structs
    task_struct: Allow randomized layout
    randstruct: Mark various structs for randomization

    Linus Torvalds
     

13 Jul, 2017

2 commits

  • sem_ctime is initialized to the semget() time and then updated at every
    semctl() that changes the array.

    Thus it does not represent the time of the last change.

    Especially, semop() calls are only stored in sem_otime, not in
    sem_ctime.

    This is already described in ipc/sem.c, I just overlooked that there is
    a comment in include/linux/sem.h and man semctl(2) as well.

    So: Correct wrong comments.

    Link: http://lkml.kernel.org/r/20170515171912.6298-4-manfred@colorfullife.com
    Signed-off-by: Manfred Spraul
    Cc: Kees Cook
    Cc:
    Cc: Davidlohr Bueso
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: Fabian Frederick
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     
  • sma->sem_base is initialized with

    sma->sem_base = (struct sem *) &sma[1];

    The current code has four problems:
    - There is an unnecessary pointer dereference - sem_base is not needed.
    - Alignment for struct sem only works by chance.
    - The current code causes false positive for static code analysis.
    - This is a cast between different non-void types, which the future
    randstruct GCC plugin warns on.

    And, as bonus, the code size gets smaller:

    Before:
    0 .text 00003770
    After:
    0 .text 0000374e

    [manfred@colorfullife.com: s/[0]/[]/, per hch]
    Link: http://lkml.kernel.org/r/20170525185107.12869-2-manfred@colorfullife.com
    Link: http://lkml.kernel.org/r/20170515171912.6298-2-manfred@colorfullife.com
    Signed-off-by: Manfred Spraul
    Acked-by: Kees Cook
    Cc: Kees Cook
    Cc:
    Cc: Davidlohr Bueso
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Cc: Fabian Frederick
    Cc: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     

01 Jul, 2017

1 commit

  • This marks many critical kernel structures for randomization. These are
    structures that have been targeted in the past in security exploits, or
    contain functions pointers, pointers to function pointer tables, lists,
    workqueues, ref-counters, credentials, permissions, or are otherwise
    sensitive. This initial list was extracted from Brad Spengler/PaX Team's
    code in the last public patch of grsecurity/PaX based on my understanding
    of the code. Changes or omissions from the original code are mine and
    don't reflect the original grsecurity/PaX code.

    Left out of this list is task_struct, which requires special handling
    and will be covered in a subsequent patch.

    Signed-off-by: Kees Cook

    Kees Cook
     

09 May, 2017

1 commit

  • Assign 'struct kern_ipc_perm' its own cacheline to avoid false sharing
    with sysv ipc calls.

    While the structure itself is rather read-mostly throughout the lifespan
    of ipc, the spinlock causes most of the invalidations. One example is
    commit 31a7c4746e9 ("ipc/sem.c: cacheline align the ipc spinlock for
    semaphores"). Therefore, extend this to all ipc.

    The effect of cacheline alignment on sems can be seen in sembench, which
    deals mostly with semtimedop wait/wakes is seen to improve raw
    throughput (worker loops) between 8 to 12% on a 24-core x86 with over 4
    threads.

    Link: http://lkml.kernel.org/r/1486673582-6979-4-git-send-email-dave@stgolabs.net
    Signed-off-by: Davidlohr Bueso
    Cc: Manfred Spraul
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Davidlohr Bueso
     

28 Feb, 2017

1 commit

  • sysv sem has two lock modes: One with per-semaphore locks, one lock mode
    with a single global lock for the whole array. When switching from the
    per-semaphore locks to the global lock, all per-semaphore locks must be
    scanned for ongoing operations.

    The patch adds a hysteresis for switching from the global lock to the
    per semaphore locks. This reduces how often the per-semaphore locks
    must be scanned.

    Compared to the initial patch, this is a simplified solution: Setting
    USE_GLOBAL_LOCK_HYSTERESIS to 1 restores the current behavior.

    In theory, a workload with exactly 10 simple sops and then one complex
    op now scales a bit worse, but this is pure theory: If there is
    concurrency, the it won't be exactly 10:1:10:1:10:1:... If there is no
    concurrency, then there is no need for scalability.

    Link: http://lkml.kernel.org/r/1476851896-3590-3-git-send-email-manfred@colorfullife.com
    Signed-off-by: Manfred Spraul
    Cc: Peter Zijlstra
    Cc: Davidlohr Bueso
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: H. Peter Anvin
    Cc:
    Cc: kernel test robot
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     

12 Oct, 2016

1 commit

  • Commit 6d07b68ce16a ("ipc/sem.c: optimize sem_lock()") introduced a
    race:

    sem_lock has a fast path that allows parallel simple operations.
    There are two reasons why a simple operation cannot run in parallel:
    - a non-simple operations is ongoing (sma->sem_perm.lock held)
    - a complex operation is sleeping (sma->complex_count != 0)

    As both facts are stored independently, a thread can bypass the current
    checks by sleeping in the right positions. See below for more details
    (or kernel bugzilla 105651).

    The patch fixes that by creating one variable (complex_mode)
    that tracks both reasons why parallel operations are not possible.

    The patch also updates stale documentation regarding the locking.

    With regards to stable kernels:
    The patch is required for all kernels that include the
    commit 6d07b68ce16a ("ipc/sem.c: optimize sem_lock()") (3.10?)

    The alternative is to revert the patch that introduced the race.

    The patch is safe for backporting, i.e. it makes no assumptions
    about memory barriers in spin_unlock_wait().

    Background:
    Here is the race of the current implementation:

    Thread A: (simple op)
    - does the first "sma->complex_count == 0" test

    Thread B: (complex op)
    - does sem_lock(): This includes an array scan. But the scan can't
    find Thread A, because Thread A does not own sem->lock yet.
    - the thread does the operation, increases complex_count,
    drops sem_lock, sleeps

    Thread A:
    - spin_lock(&sem->lock), spin_is_locked(sma->sem_perm.lock)
    - sleeps before the complex_count test

    Thread C: (complex op)
    - does sem_lock (no array scan, complex_count==1)
    - wakes up Thread B.
    - decrements complex_count

    Thread A:
    - does the complex_count test

    Bug:
    Now both thread A and thread C operate on the same array, without
    any synchronization.

    Fixes: 6d07b68ce16a ("ipc/sem.c: optimize sem_lock()")
    Link: http://lkml.kernel.org/r/1469123695-5661-1-git-send-email-manfred@colorfullife.com
    Reported-by:
    Cc: "H. Peter Anvin"
    Cc: Peter Zijlstra
    Cc: Davidlohr Bueso
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc:
    Cc: [3.10+]
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     

10 Jul, 2013

2 commits

  • sem_otime contains the time of the last semaphore operation that
    completed successfully. Every operation updates this value, thus access
    from multiple cpus can cause thrashing.

    Therefore the patch replaces the variable with a per-semaphore variable.
    The per-array sem_otime is only calculated when required.

    No performance improvement on a single-socket i3 - only important for
    larger systems.

    Signed-off-by: Manfred Spraul
    Cc: Rik van Riel
    Cc: Davidlohr Bueso
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     
  • Introduce separate queues for operations that do not modify the
    semaphore values. Advantages:

    - Simpler logic in check_restart().
    - Faster update_queue(): Right now, all wait-for-zero operations are
    always tested, even if the semaphore value is not 0.
    - wait-for-zero gets again priority, as in linux
    Cc: Rik van Riel
    Cc: Davidlohr Bueso
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     

13 Oct, 2012

1 commit


03 Nov, 2011

2 commits

  • For the sysvsem undo, each task struct contains a sysv_sem structure with
    a pointer to the undo information.

    This pointer is only necessary if sysvipc is enabled - thus the pointer
    can be made conditional on CONFIG_SYSVIPC.

    Signed-off-by: Manfred Spraul
    Acked-by: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: Mike Galbraith
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     
  • include/linux/sem.h contains several structures that are only used within
    ipc/sem.c.

    The patch moves them into ipc/sem.c - there is no need to expose the
    structures to the whole kernel.

    No functional changes, only whitespace cleanups and 80-char per line
    fixes.

    Signed-off-by: Manfred Spraul
    Acked-by: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: Mike Galbraith
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     

27 Jul, 2011

1 commit

  • This allows us to move duplicated code in
    (atomic_inc_not_zero() for now) to

    Signed-off-by: Arun Sharma
    Reviewed-by: Eric Dumazet
    Cc: Ingo Molnar
    Cc: David Miller
    Cc: Eric Dumazet
    Acked-by: Mike Frysinger
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arun Sharma
     

28 May, 2010

1 commit

  • Cacheline align the spinlock for sysv semaphores. Without the patch, the
    spinlock and sem_otime [written by every semop that modified the array]
    and sem_base [read in the hot path of try_atomic_semop()] can be in the
    same cacheline.

    Signed-off-by: Manfred Spraul
    Cc: Chris Mason
    Cc: Zach Brown
    Cc: Jens Axboe
    Cc: Nick Piggin
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     

16 Dec, 2009

1 commit

  • Based on Nick's findings:

    sysv sem has the concept of semaphore arrays that consist out of multiple
    semaphores. Atomic operations that affect multiple semaphores are
    supported.

    The patch is the first step for optimizing simple, single semaphore
    operations: In addition to the global list of all pending operations, a
    2nd, per-semaphore list with the simple operations is added.

    Note: this patch does not make sense by itself, the new list is used
    nowhere.

    Signed-off-by: Manfred Spraul
    Cc: Nick Piggin
    Cc: Pierre Peiffer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     

26 Jul, 2008

4 commits

  • The attached patch:
    - reverses the locking order of ulp->lock and sem_lock:
    Previously, it was first ulp->lock, then inside sem_lock.
    Now it's the other way around.
    - converts the undo structure to rcu.

    Benefits:
    - With the old locking order, IPC_RMID could not kfree the undo structures.
    The stale entries remained in the linked lists and were released later.
    - The patch fixes a a race in semtimedop(): if both IPC_RMID and a semget() that
    recreates exactly the same id happen between find_alloc_undo() and sem_lock,
    then semtimedop() would access already kfree'd memory.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Manfred Spraul
    Reviewed-by: Nadia Derbey
    Cc: Pierre Peiffer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     
  • sem_array.sem_pending is a double linked list, the attached patch converts
    it to struct list_head.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Manfred Spraul
    Reviewed-by: Nadia Derbey
    Cc: Pierre Peiffer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     
  • sem_queue.sma and sem_queue.id were never used, the attached patch removes
    them.

    Signed-off-by: Manfred Spraul
    Reviewed-by: Nadia Derbey
    Cc: Pierre Peiffer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     
  • The undo structures contain two linked lists, the attached patch replaces
    them with generic struct list_head lists.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Manfred Spraul
    Cc: Nadia Derbey
    Cc: Pierre Peiffer
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Manfred Spraul
     

20 Oct, 2007

1 commit

  • This patch introduces ipcs storage into IDRs. The main changes are:
    . This ipc_ids structure is changed: the entries array is changed into a
    root idr structure.
    . The grow_ary() routine is removed: it is not needed anymore when adding
    an ipc structure, since we are now using the IDR facility.
    . The ipc_rmid() routine interface is changed:
    . there is no need for this routine to return the pointer passed in as
    argument: it is now declared as a void
    . since the id is now part of the kern_ipc_perm structure, no need to
    have it as an argument to the routine

    Signed-off-by: Nadia Derbey
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Nadia Derbey
     

25 Apr, 2006

1 commit


07 Nov, 2005

1 commit

  • Fix more include file problems that surfaced since I submitted the previous
    fix-missing-includes.patch. This should now allow not to include sched.h
    from module.h, which is done by a followup patch.

    Signed-off-by: Tim Schmielau
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tim Schmielau
     

08 Sep, 2005

1 commit


17 Apr, 2005

1 commit

  • Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.

    Let it rip!

    Linus Torvalds