12 Feb, 2018

1 commit

  • This is the mindless scripted replacement of kernel use of POLL*
    variables as described by Al, done by this script:

    for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
    L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
    for f in $L; do sed -i "-es/^\([^\"]*\)\(\\)/\\1E\\2/" $f; done
    done

    with de-mangling cleanups yet to come.

    NOTE! On almost all architectures, the EPOLL* constants have the same
    values as the POLL* constants do. But they keyword here is "almost".
    For various bad reasons they aren't the same, and epoll() doesn't
    actually work quite correctly in some cases due to this on Sparc et al.

    The next patch from Al will sort out the final differences, and we
    should be all done.

    Scripted-by: Al Viro
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

29 Nov, 2017

1 commit


17 Jul, 2017

1 commit


16 Mar, 2017

1 commit

  • Usually every parallel port will have a single pardev registered with
    it. But ppdev driver is an exception. This userspace parallel port
    driver allows to create multiple parrallel port devices for a single
    parallel port. And as a result we were having a big warning like:
    "sysfs: cannot create duplicate filename '/devices/parport0/ppdev0.0'".
    And with that many parallel port printers stopped working.

    We have been using the minor number as the id field while registering
    a parralel port device with a parralel port. But when there are
    multiple parrallel port device for one single parallel port, they all
    tried to register with the same name like 'pardev0.0' and everything
    started failing.
    Use an incremented index as the id instead of the minor number.

    Fixes: 8b7d3a9d903e ("ppdev: use new parport device model")
    Cc: stable # v4.9+
    Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1414656
    Bugzilla: https://bugs.archlinux.org/task/52322
    Tested-by: James Feeney
    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Sudip Mukherjee
     

02 Mar, 2017

1 commit


11 Jan, 2017

1 commit

  • A previous fix of a memory leak now prints the string 'name'
    that was previously free'd. Fix this by free'ing the string
    at the end of the function and adding an error exit path for
    the error conditions.

    CoverityScan CID#1384523 ("Use after free")

    Fixes: 2bd362d5f45c1 ("ppdev: fix memory leak")
    Signed-off-by: Colin Ian King
    Acked-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Colin Ian King
     

30 Nov, 2016

3 commits

  • After parport starts using the device model, all pardevice drivers
    should decide in their match_port callback function if they want to
    attach with that particulatr port. ppdev has been converted to use the
    new parport device-model code but pp_attach() tried to attach with all
    the ports.
    Create a new array of pointer and use that to remember the ports we
    have attached. And use that information to skip attaching ports which
    we have already attached.

    Tested-by: Joe Lawrence
    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Sudip Mukherjee
     
  • The coding style recommends not to use printk. Use pr_* macros.

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

    Sudip Mukherjee
     
  • The variable name was only released if parport_register_dev_model()
    fails. Now that we are using the device-model the parport driver
    will duplicate the name and use it. So we can release the variable
    after the device has been registered with the parport.

    Suggested-by: Arnd Bergmann
    Signed-off-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Sudip Mukherjee
     

10 Nov, 2016

1 commit

  • free_pardevice() is called by parport_unregister_device() and already frees
    pp->pdev->name, don't try to do it again.

    This bug causes kernel crashes.

    I found and verified this with KASAN and some added pr_emerg()s:

    [ 60.316568] pp_release: pp->pdev->name == ffff88039cb264c0
    [ 60.316692] free_pardevice: freeing par_dev->name at ffff88039cb264c0
    [ 60.316706] pp_release: kfree(ffff88039cb264c0)
    [ 60.316714] ==========================================================
    [ 60.316722] BUG: Double free or freeing an invalid pointer
    [ 60.316731] Unexpected shadow byte: 0xFB
    [ 60.316801] Object at ffff88039cb264c0, in cache kmalloc-32 size: 32
    [ 60.316813] Allocated:
    [ 60.316824] PID = 1695
    [ 60.316869] Freed:
    [ 60.316880] PID = 1695
    [ 60.316935] ==========================================================

    Signed-off-by: Jann Horn
    Acked-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Jann Horn
     

31 Aug, 2016

1 commit

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

    Initially submitted and committed as:
    e7223f186033 ("ppdev: use new parport device model")

    But due to some regression it was reverted by:
    1701f680407c ("Revert "ppdev: use new parport device model"")

    Now that the original source of regression is fixed by:
    bbca503b2ee0 ("parport: use subsys_initcall") we can again modify ppdev
    to use device model.

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

    Sudip Mukherjee
     

26 Mar, 2016

1 commit

  • This reverts commit e7223f18603374d235d8bb0398532323e5f318b9.

    It causes problems when a ppdev tries to register before the parport
    driver has been registered with the device model. That will trigger the

    BUG_ON(!drv->bus->p);

    at drivers/base/driver.c:153. The call chain is

    kernel_init ->
    kernel_init_freeable ->
    do_one_initcall ->
    ppdev_init ->
    __parport_register_driver ->
    driver_register *BOOM*

    Reported-by: kernel test robot
    Reported-by: Ross Zwisler
    Reported-by: Petr Mladek
    Cc: Sudip Mukherjee
    Cc: Greg Kroah-Hartman
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

15 Feb, 2016

8 commits


09 Feb, 2016

2 commits

  • The arg of ioctl in ppdev is the pointer of integer except the
    timeval in PPSETTIME, PPGETTIME. Different size of timeval
    is already supported by the previous patches. So, it is safe
    to add compat support.

    Signed-off-by: Bamvor Jian Zhang
    Reviewed-by: Arnd Bergmann
    Tested-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Bamvor Jian Zhang
     
  • The y2038 issue for ppdev is changes of timeval in the ioctl
    (PPSETTIME and PPGETTIME). The size of struct timeval changes from
    8bytes to 16bytes due to the changes of time_t. It lead to the
    changes of the command of ioctl, e.g. for PPGETTIME, We have:

    on 32-bit (old): 0x80087095
    on 32-bit (new): 0x80107095
    on 64-bit : 0x80107095

    This patch define these two ioctl commands to support the 32bit
    and 64bit time_t application at the same time. And, introduce
    pp_set_timeout to remove some duplicated code.

    Signed-off-by: Bamvor Jian Zhang
    Reviewed-by: Arnd Bergmann
    Tested-by: Sudip Mukherjee
    Signed-off-by: Greg Kroah-Hartman

    Bamvor Jian Zhang
     

23 Feb, 2013

1 commit


29 Oct, 2012

1 commit


16 Oct, 2012

1 commit

  • We always update bytes_written before we check signal_pending so it
    follows that we can't get a signal return for 0 bytes so we don't
    need to check in the singal path. The cases a signal causes an earlier
    abort are handled before this and will not hit this path

    Signed-off-by: Alan Cox
    Signed-off-by: Jiri Kosina

    Alan Cox
     

06 Sep, 2012

1 commit

  • Error handling of parport_register_driver() in ppdev_init()
    is broken because it deallocates all resources but still
    returns zero.

    Currently parport_register_driver() always succeeds.
    Nevertheless it is worth to fix the issue.

    Found by Linux Driver Verification project (linuxtesting.org).

    Signed-off-by: Alexey Khoroshilov
    Signed-off-by: Greg Kroah-Hartman

    Alexey Khoroshilov
     

27 May, 2011

1 commit

  • parport_find_number() calls parport_get_port() on its result, so there
    should be a corresponding call to parport_put_port() before dropping the
    reference. Similar code is found in the function register_device() in the
    same file.

    The semantic match that finds this problem is as follows:
    (http://coccinelle.lip6.fr/)

    //
    @exists@
    local idexpression struct parport * x;
    expression ra,rr;
    statement S1,S2;
    @@

    x = parport_find_number(...)
    ... when != x = rr
    when any
    when != parport_put_port(x,...)
    when != if (...) { ... parport_put_port(x,...) ...}
    (
    if() S1 else S2
    |
    if(...) { ... when != x = ra
    when forall
    when != parport_put_port(x,...)
    *return...;
    }
    )
    //

    Signed-off-by: Julia Lawall
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Julia Lawall
     

28 Oct, 2010

1 commit


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
     

28 May, 2010

1 commit

  • kasprintf combines kmalloc and sprintf, and takes care of the size
    calculation itself.

    The semantic patch that makes this change is as follows:
    (http://coccinelle.lip6.fr/)

    //
    @@
    expression a,flag;
    expression list args;
    statement S;
    @@

    a =
    - \(kmalloc\|kzalloc\)(...,flag)
    + kasprintf(flag,args)

    - sprintf(a,args);
    //

    Signed-off-by: Julia Lawall
    Cc: Michael Buesch
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Julia Lawall
     

30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

19 Jun, 2009

1 commit

  • One of my programs frequently grabs the parport, does something with it
    and then drops it again. This results in spamming of the kernel log with

    "... registered pardevice"
    "... unregistered pardevice"

    These messages are completely useless, except for debugging ppdev,
    probably. So put them under DEBUG (or dynamic debug).

    Signed-off-by: Michael Buesch
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Buesch
     

17 Oct, 2008

1 commit


26 Jul, 2008

1 commit


22 Jul, 2008

1 commit


21 Jun, 2008

2 commits


24 Oct, 2007

1 commit


17 Oct, 2007

1 commit


09 May, 2007

1 commit