31 Aug, 2020

1 commit


28 Aug, 2020

1 commit


24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

13 Nov, 2019

1 commit

  • The layout of struct timeval is different on sparc64 from
    anything else, and the patch I did long ago failed to take
    this into account.

    Change it now to handle sparc64 user space correctly again.

    Quite likely nobody cares about parallel ports on sparc64,
    but there is no reason not to fix it.

    Cc: stable@vger.kernel.org
    Fixes: 9a450484089d ("lp: support 64-bit time_t user space")
    Signed-off-by: Arnd Bergmann
    Link: https://lore.kernel.org/r/20191108203435.112759-7-arnd@arndb.de
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     

21 May, 2019

1 commit

  • Add SPDX license identifiers to all files which:

    - Have no license information of any form

    - Have MODULE_LICENCE("GPL*") inside which was used in the initial
    scan/conversion to ignore the file

    These files fall under the project license, GPL v2 only. The resulting SPDX
    license identifier is:

    GPL-2.0-only

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

14 Feb, 2019

1 commit

  • In preparation to enabling -Wimplicit-fallthrough, mark switch
    cases where we are expecting to fall through.

    This patch fixes the following warnings:

    drivers/char/lp.c: In function ‘lp_compat_ioctl’:
    drivers/char/lp.c:756:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    if (!COMPAT_USE_64BIT_TIME) {
    ^
    drivers/char/lp.c:761:2: note: here
    case LPSETTIMEOUT_NEW:
    ^~~~
    drivers/char/lp.c: In function ‘lp_ioctl’:
    drivers/char/lp.c:728:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    if (BITS_PER_LONG == 32) {
    ^
    drivers/char/lp.c:733:2: note: here
    case LPSETTIMEOUT_NEW:
    ^~~~

    Warning level 3 was used: -Wimplicit-fallthrough=3

    Notice that in some cases, the code comment is modified in
    accordance with what GCC is expecting to find.

    This patch is part of the ongoing efforts to enable
    -Wimplicit-fallthrough.

    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Greg Kroah-Hartman

    Gustavo A. R. Silva
     

19 Dec, 2018

5 commits

  • Modify lp driver to use the new parallel port device model.

    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Sudip Mukherjee
     
  • When the parallel port is usb based and the lp attaches to it based on
    LP_PARPORT_AUTO, we do get /dev/lp0 and when we remove the usb device
    /dev/lp0 is unregistered. If we now reconnect the usb device we get
    our /dev/lp0 back. But if we now disconnect and reconnect eight times
    we donot get any lp device and dmesg shows:

    lp: ignoring parallel port (max. 8)

    Decrement the lp_count when the device detaches as this represents the
    number of lp devices connected to the system.

    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Sudip Mukherjee
     
  • When the parallel port is usb based and the lp attaches to it based on
    LP_PARPORT_AUTO, we do get /dev/lp0 and when we remove the usb device
    /dev/lp0 is unregistered. But if we now reconnect the usb device we get
    /dev/lp1, another disconnection and reconnection and we get /dev/lp2.

    Use the port number array to find the first unused lp number and use
    that to register the lp device with the parallel port.

    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Sudip Mukherjee
     
  • When the parallel port is usb based and the lp attaches to it, we do
    get /dev/lp0, but when we remove the usb device and the parallel port
    is gone, we are still left with /dev/lp0.
    Unregister the device properly in the detach routine based on the port
    number it has connected to.

    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Sudip Mukherjee
     
  • When we are registering lp in LP_PARPORT_AUTO mode, we are not keeping
    any record of the parallel port number to which lp is connecting.
    Add an array to save the port number to it.

    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Sudip Mukherjee
     

27 Nov, 2018

6 commits


25 Jan, 2018

1 commit


28 Nov, 2017

1 commit

  • Once we get a glibc with 64-bit time_t, the LPSETTIMEOUT ioctl stops
    working, since the command number and data structure no longer match.

    To work around that, this introduces a new command number LPSETTIMEOUT_NEW
    that is used whenever the modified user space evaluates the LPSETTIMEOUT
    macro.

    The trick we use is a bit convoluted but necessary: we cannot check for
    any macros set by the C library in linux/lp.h, because this particular
    header can be included before including sys/time.h. However, we can assume
    that by the time that LPSETTIMEOUT is seen in the code, the definition
    for 'timeval' and 'time_t' has been seen as well, so we can use the
    sizeof() operator to determine whether we should use the old or the
    new definition. We use the old one not only for traditional 32-bit user
    space with 32-bit time_t, but also for all 64-bit architectures and x32,
    which always use a 64-bit time_t, the new definition will be used only for
    32-bit user space with 64-bit time_t, which also requires a newer kernel.

    The compat_ioctl() handler now implements both commands, but has to
    use a special case for existing x32 binaries. The native ioctl handler
    now implements both command numbers on both 32-bit and 64-bit, though
    the latter version use the same interpretation for both.

    This is based on an earlier patch from Bamvor.

    Cc: Bamvor Jian Zhang
    Link: http://www.spinics.net/lists/y2038/msg01162.html
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Greg Kroah-Hartman

    Arnd Bergmann
     

17 May, 2017

1 commit

  • The lp_setup() code doesn't apply any bounds checking when passing
    "lp=none", and only in this case, resulting in an overflow of the
    parport_nr[] array. All versions in Git history are affected.

    Reported-By: Roee Hay
    Cc: Ben Hutchings
    Cc: stable@vger.kernel.org
    Signed-off-by: Willy Tarreau
    Signed-off-by: Greg Kroah-Hartman

    Willy Tarreau
     

02 Mar, 2017

1 commit


25 Dec, 2016

1 commit


19 Dec, 2013

1 commit


17 May, 2013

1 commit

  • The patch fixes a problem in the lp driver that can cause oopses as
    follows:
    process A: calls lp_write, which in turn calls
    parport_ieee1284_write_compat, and that invokes
    parport_wait_peripheral
    process B: meanwhile does an ioctl(LPGETSTATUS), which call
    lp_release_parport when done. This function will set
    physport->cad = NULL.
    process A: parport_wait_peripheral tries to dereference
    physport->cad and dies

    So, protect that code with the port_mutex in order to protect against
    simultaneous calls to lp_read/lp_write.

    Similar protection is probably required for ioctl(LPRESET)...

    This patch was done by IBM a while back and we (at suse) have that
    since at least 2004 in our repos. Let's make it upstream.

    Signed-off-by: okir@suse.de
    Signed-off-by: Jiri Slaby
    Cc: Arnd Bergmann
    Cc: Greg Kroah-Hartman
    Signed-off-by: Greg Kroah-Hartman

    salina@us.ibm.com
     

23 Feb, 2013

1 commit


30 Mar, 2012

1 commit

  • Pull x32 support for x86-64 from Ingo Molnar:
    "This tree introduces the X32 binary format and execution mode for x86:
    32-bit data space binaries using 64-bit instructions and 64-bit kernel
    syscalls.

    This allows applications whose working set fits into a 32 bits address
    space to make use of 64-bit instructions while using a 32-bit address
    space with shorter pointers, more compressed data structures, etc."

    Fix up trivial context conflicts in arch/x86/{Kconfig,vdso/vma.c}

    * 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (71 commits)
    x32: Fix alignment fail in struct compat_siginfo
    x32: Fix stupid ia32/x32 inversion in the siginfo format
    x32: Add ptrace for x32
    x32: Switch to a 64-bit clock_t
    x32: Provide separate is_ia32_task() and is_x32_task() predicates
    x86, mtrr: Use explicit sizing and padding for the 64-bit ioctls
    x86/x32: Fix the binutils auto-detect
    x32: Warn and disable rather than error if binutils too old
    x32: Only clear TIF_X32 flag once
    x32: Make sure TS_COMPAT is cleared for x32 tasks
    fs: Remove missed ->fds_bits from cessation use of fd_set structs internally
    fs: Fix close_on_exec pointer in alloc_fdtable
    x32: Drop non-__vdso weak symbols from the x32 VDSO
    x32: Fix coding style violations in the x32 VDSO code
    x32: Add x32 VDSO support
    x32: Allow x32 to be configured
    x32: If configured, add x32 system calls to system call tables
    x32: Handle process creation
    x32: Signal-related system calls
    x86: Add #ifdef CONFIG_COMPAT to
    ...

    Linus Torvalds
     

29 Mar, 2012

1 commit


21 Feb, 2012

1 commit


13 Jan, 2012

1 commit


23 Oct, 2010

1 commit

  • * 'llseek' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl:
    vfs: make no_llseek the default
    vfs: don't use BKL in default_llseek
    llseek: automatically add .llseek fop
    libfs: use generic_file_llseek for simple_attr
    mac80211: disallow seeks in minstrel debug code
    lirc: make chardev nonseekable
    viotape: use noop_llseek
    raw: use explicit llseek file operations
    ibmasmfs: use generic_file_llseek
    spufs: use llseek in all file operations
    arm/omap: use generic_file_llseek in iommu_debug
    lkdtm: use generic_file_llseek in debugfs
    net/wireless: use generic_file_llseek in debugfs
    drm: use noop_llseek

    Linus Torvalds
     

15 Oct, 2010

1 commit

  • All file_operations should get a .llseek operation so we can make
    nonseekable_open the default for future file operations without a
    .llseek pointer.

    The three cases that we can automatically detect are no_llseek, seq_lseek
    and default_llseek. For cases where we can we can automatically prove that
    the file offset is always ignored, we use noop_llseek, which maintains
    the current behavior of not returning an error from a seek.

    New drivers should normally not use noop_llseek but instead use no_llseek
    and call nonseekable_open at open time. Existing drivers can be converted
    to do the same when the maintainer knows for certain that no user code
    relies on calling seek on the device file.

    The generated code is often incorrectly indented and right now contains
    comments that clarify for each added line why a specific variant was
    chosen. In the version that gets submitted upstream, the comments will
    be gone and I will manually fix the indentation, because there does not
    seem to be a way to do that using coccinelle.

    Some amount of new code is currently sitting in linux-next that should get
    the same modifications, which I will do at the end of the merge window.

    Many thanks to Julia Lawall for helping me learn to write a semantic
    patch that does all this.

    ===== begin semantic patch =====
    // This adds an llseek= method to all file operations,
    // as a preparation for making no_llseek the default.
    //
    // The rules are
    // - use no_llseek explicitly if we do nonseekable_open
    // - use seq_lseek for sequential files
    // - use default_llseek if we know we access f_pos
    // - use noop_llseek if we know we don't access f_pos,
    // but we still want to allow users to call lseek
    //
    @ open1 exists @
    identifier nested_open;
    @@
    nested_open(...)
    {

    }

    @ open exists@
    identifier open_f;
    identifier i, f;
    identifier open1.nested_open;
    @@
    int open_f(struct inode *i, struct file *f)
    {

    }

    @ read disable optional_qualifier exists @
    identifier read_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    expression E;
    identifier func;
    @@
    ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
    {

    }

    @ read_no_fpos disable optional_qualifier exists @
    identifier read_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    @@
    ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
    {
    ... when != off
    }

    @ write @
    identifier write_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    expression E;
    identifier func;
    @@
    ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
    {

    }

    @ write_no_fpos @
    identifier write_f;
    identifier f, p, s, off;
    type ssize_t, size_t, loff_t;
    @@
    ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
    {
    ... when != off
    }

    @ fops0 @
    identifier fops;
    @@
    struct file_operations fops = {
    ...
    };

    @ has_llseek depends on fops0 @
    identifier fops0.fops;
    identifier llseek_f;
    @@
    struct file_operations fops = {
    ...
    .llseek = llseek_f,
    ...
    };

    @ has_read depends on fops0 @
    identifier fops0.fops;
    identifier read_f;
    @@
    struct file_operations fops = {
    ...
    .read = read_f,
    ...
    };

    @ has_write depends on fops0 @
    identifier fops0.fops;
    identifier write_f;
    @@
    struct file_operations fops = {
    ...
    .write = write_f,
    ...
    };

    @ has_open depends on fops0 @
    identifier fops0.fops;
    identifier open_f;
    @@
    struct file_operations fops = {
    ...
    .open = open_f,
    ...
    };

    // use no_llseek if we call nonseekable_open
    ////////////////////////////////////////////
    @ nonseekable1 depends on !has_llseek && has_open @
    identifier fops0.fops;
    identifier nso ~= "nonseekable_open";
    @@
    struct file_operations fops = {
    ... .open = nso, ...
    +.llseek = no_llseek, /* nonseekable */
    };

    @ nonseekable2 depends on !has_llseek @
    identifier fops0.fops;
    identifier open.open_f;
    @@
    struct file_operations fops = {
    ... .open = open_f, ...
    +.llseek = no_llseek, /* open uses nonseekable */
    };

    // use seq_lseek for sequential files
    /////////////////////////////////////
    @ seq depends on !has_llseek @
    identifier fops0.fops;
    identifier sr ~= "seq_read";
    @@
    struct file_operations fops = {
    ... .read = sr, ...
    +.llseek = seq_lseek, /* we have seq_read */
    };

    // use default_llseek if there is a readdir
    ///////////////////////////////////////////
    @ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier readdir_e;
    @@
    // any other fop is used that changes pos
    struct file_operations fops = {
    ... .readdir = readdir_e, ...
    +.llseek = default_llseek, /* readdir is present */
    };

    // use default_llseek if at least one of read/write touches f_pos
    /////////////////////////////////////////////////////////////////
    @ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read.read_f;
    @@
    // read fops use offset
    struct file_operations fops = {
    ... .read = read_f, ...
    +.llseek = default_llseek, /* read accesses f_pos */
    };

    @ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier write.write_f;
    @@
    // write fops use offset
    struct file_operations fops = {
    ... .write = write_f, ...
    + .llseek = default_llseek, /* write accesses f_pos */
    };

    // Use noop_llseek if neither read nor write accesses f_pos
    ///////////////////////////////////////////////////////////

    @ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read_no_fpos.read_f;
    identifier write_no_fpos.write_f;
    @@
    // write fops use offset
    struct file_operations fops = {
    ...
    .write = write_f,
    .read = read_f,
    ...
    +.llseek = noop_llseek, /* read and write both use no f_pos */
    };

    @ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier write_no_fpos.write_f;
    @@
    struct file_operations fops = {
    ... .write = write_f, ...
    +.llseek = noop_llseek, /* write uses no f_pos */
    };

    @ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    identifier read_no_fpos.read_f;
    @@
    struct file_operations fops = {
    ... .read = read_f, ...
    +.llseek = noop_llseek, /* read uses no f_pos */
    };

    @ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
    identifier fops0.fops;
    @@
    struct file_operations fops = {
    ...
    +.llseek = noop_llseek, /* no read or write fn */
    };
    ===== End semantic patch =====

    Signed-off-by: Arnd Bergmann
    Cc: Julia Lawall
    Cc: Christoph Hellwig

    Arnd Bergmann
     

05 Oct, 2010

1 commit

  • All these files use the big kernel lock in a trivial
    way to serialize their private file operations,
    typically resulting from an earlier semi-automatic
    pushdown from VFS.

    None of these drivers appears to want to lock against
    other code, and they all use the BKL as the top-level
    lock in their file operations, meaning that there
    is no lock-order inversion problem.

    Consequently, we can remove the BKL completely,
    replacing it with a per-file mutex in every case.
    Using a scripted approach means we can avoid
    typos.

    These drivers do not seem to be under active
    maintainance from my brief investigation. Apologies
    to those maintainers that I have missed.

    file=$1
    name=$2
    if grep -q lock_kernel ${file} ; then
    if grep -q 'include.*linux.mutex.h' ${file} ; then
    sed -i '/include.*/d' ${file}
    else
    sed -i 's/include.*.*$/include /g' ${file}
    fi
    sed -i ${file} \
    -e "/^#include.*linux.mutex.h/,$ {
    1,/^\(static\|int\|long\)/ {
    /^\(static\|int\|long\)/istatic DEFINE_MUTEX(${name}_mutex);

    } }" \
    -e "s/\(un\)*lock_kernel\>[ ]*()/mutex_\1lock(\&${name}_mutex)/g" \
    -e '/[ ]*cycle_kernel_lock();/d'
    else
    sed -i -e '/include.*\/d' ${file} \
    -e '/cycle_kernel_lock()/d'
    fi

    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

11 Dec, 2009

1 commit


17 Oct, 2008

1 commit


22 Jul, 2008

1 commit


21 Jun, 2008

1 commit


07 Feb, 2008

1 commit


17 Oct, 2007

1 commit


13 Oct, 2007

1 commit


09 May, 2007

1 commit