10 Sep, 2020

1 commit

  • The Sega GD-ROM driver does not have a ->revalidate_disk method, so it
    can just use bdev_check_media_change without any additional changes.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Johannes Thumshirn
    Reviewed-by: Hannes Reinecke
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

09 Jul, 2020

1 commit


11 Jun, 2020

2 commits


04 Jun, 2020

1 commit

  • Pull networking updates from David Miller:

    1) Allow setting bluetooth L2CAP modes via socket option, from Luiz
    Augusto von Dentz.

    2) Add GSO partial support to igc, from Sasha Neftin.

    3) Several cleanups and improvements to r8169 from Heiner Kallweit.

    4) Add IF_OPER_TESTING link state and use it when ethtool triggers a
    device self-test. From Andrew Lunn.

    5) Start moving away from custom driver versions, use the globally
    defined kernel version instead, from Leon Romanovsky.

    6) Support GRO vis gro_cells in DSA layer, from Alexander Lobakin.

    7) Allow hard IRQ deferral during NAPI, from Eric Dumazet.

    8) Add sriov and vf support to hinic, from Luo bin.

    9) Support Media Redundancy Protocol (MRP) in the bridging code, from
    Horatiu Vultur.

    10) Support netmap in the nft_nat code, from Pablo Neira Ayuso.

    11) Allow UDPv6 encapsulation of ESP in the ipsec code, from Sabrina
    Dubroca. Also add ipv6 support for espintcp.

    12) Lots of ReST conversions of the networking documentation, from Mauro
    Carvalho Chehab.

    13) Support configuration of ethtool rxnfc flows in bcmgenet driver,
    from Doug Berger.

    14) Allow to dump cgroup id and filter by it in inet_diag code, from
    Dmitry Yakunin.

    15) Add infrastructure to export netlink attribute policies to
    userspace, from Johannes Berg.

    16) Several optimizations to sch_fq scheduler, from Eric Dumazet.

    17) Fallback to the default qdisc if qdisc init fails because otherwise
    a packet scheduler init failure will make a device inoperative. From
    Jesper Dangaard Brouer.

    18) Several RISCV bpf jit optimizations, from Luke Nelson.

    19) Correct the return type of the ->ndo_start_xmit() method in several
    drivers, it's netdev_tx_t but many drivers were using
    'int'. From Yunjian Wang.

    20) Add an ethtool interface for PHY master/slave config, from Oleksij
    Rempel.

    21) Add BPF iterators, from Yonghang Song.

    22) Add cable test infrastructure, including ethool interfaces, from
    Andrew Lunn. Marvell PHY driver is the first to support this
    facility.

    23) Remove zero-length arrays all over, from Gustavo A. R. Silva.

    24) Calculate and maintain an explicit frame size in XDP, from Jesper
    Dangaard Brouer.

    25) Add CAP_BPF, from Alexei Starovoitov.

    26) Support terse dumps in the packet scheduler, from Vlad Buslov.

    27) Support XDP_TX bulking in dpaa2 driver, from Ioana Ciornei.

    28) Add devm_register_netdev(), from Bartosz Golaszewski.

    29) Minimize qdisc resets, from Cong Wang.

    30) Get rid of kernel_getsockopt and kernel_setsockopt in order to
    eliminate set_fs/get_fs calls. From Christoph Hellwig.

    * git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next: (2517 commits)
    selftests: net: ip_defrag: ignore EPERM
    net_failover: fixed rollback in net_failover_open()
    Revert "tipc: Fix potential tipc_aead refcnt leak in tipc_crypto_rcv"
    Revert "tipc: Fix potential tipc_node refcnt leak in tipc_rcv"
    vmxnet3: allow rx flow hash ops only when rss is enabled
    hinic: add set_channels ethtool_ops support
    selftests/bpf: Add a default $(CXX) value
    tools/bpf: Don't use $(COMPILE.c)
    bpf, selftests: Use bpf_probe_read_kernel
    s390/bpf: Use bcr 0,%0 as tail call nop filler
    s390/bpf: Maintain 8-byte stack alignment
    selftests/bpf: Fix verifier test
    selftests/bpf: Fix sample_cnt shared between two threads
    bpf, selftests: Adapt cls_redirect to call csum_level helper
    bpf: Add csum_level helper for fixing up csum levels
    bpf: Fix up bpf_skb_adjust_room helper's skb csum setting
    sfc: add missing annotation for efx_ef10_try_update_nic_stats_vf()
    crypto/chtls: IPv6 support for inline TLS
    Crypto/chcr: Fixes a coccinile check error
    Crypto/chcr: Fixes compilations warnings
    ...

    Linus Torvalds
     

05 May, 2020

3 commits


27 Apr, 2020

1 commit

  • Instead of having all the sysctl handlers deal with user pointers, which
    is rather hairy in terms of the BPF interaction, copy the input to and
    from userspace in common code. This also means that the strings are
    always NUL-terminated by the common code, making the API a little bit
    safer.

    As most handler just pass through the data to one of the common handlers
    a lot of the changes are mechnical.

    Signed-off-by: Christoph Hellwig
    Acked-by: Andrey Ignatov
    Signed-off-by: Al Viro

    Christoph Hellwig
     

25 Feb, 2020

1 commit

  • Arnd Bergmann inadvertently typoed these in d320a9551e394 and 64cbfa96551a;
    they seem to be the cause of
    https://bugzilla.redhat.com/show_bug.cgi?id=1801353 , invalid SCSI commands
    when udev tries to query a DVD drive.

    [arnd] Found another instance of the same bug, also introduced in my
    compat_ioctl series.

    Link: https://bugzilla.redhat.com/show_bug.cgi?id=1801353
    Link: https://lore.kernel.org/r/20200219165139.3467320-1-arnd@arndb.de
    Fixes: c103d6ee69f9 ("compat_ioctl: ide: floppy: add handler")
    Fixes: 64cbfa96551a ("compat_ioctl: move cdrom commands into cdrom.c")
    Fixes: d320a9551e39 ("compat_ioctl: scsi: move ioctl handling into drivers")
    Bisected-by: Chris Murphy
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Adam Williamson
    Signed-off-by: Martin K. Petersen

    Adam Williamson
     

03 Jan, 2020

3 commits


27 Nov, 2019

1 commit

  • Reading the TOC only works if the device can play audio, otherwise
    these commands fail (and possibly bring the device to an unhealthy
    state.)

    Similarly, cdrom_mmc3_profile() should only be called if the device
    supports generic packet commands.

    To: Jens Axboe
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-scsi@vger.kernel.org
    Signed-off-by: Diego Elio Pettenò
    Signed-off-by: Jens Axboe

    Diego Elio Pettenò
     

26 Nov, 2019

1 commit

  • Pull printk updates from Petr Mladek:

    - Allow to print symbolic error names via new %pe modifier.

    - Use pr_warn() instead of the remaining pr_warning() calls. Fix
    formatting of the related lines.

    - Add VSPRINTF entry to MAINTAINERS.

    * tag 'printk-for-5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk: (32 commits)
    checkpatch: don't warn about new vsprintf pointer extension '%pe'
    MAINTAINERS: Add VSPRINTF
    tools lib api: Renaming pr_warning to pr_warn
    ASoC: samsung: Use pr_warn instead of pr_warning
    lib: cpu_rmap: Use pr_warn instead of pr_warning
    trace: Use pr_warn instead of pr_warning
    dma-debug: Use pr_warn instead of pr_warning
    vgacon: Use pr_warn instead of pr_warning
    fs: afs: Use pr_warn instead of pr_warning
    sh/intc: Use pr_warn instead of pr_warning
    scsi: Use pr_warn instead of pr_warning
    platform/x86: intel_oaktrail: Use pr_warn instead of pr_warning
    platform/x86: asus-laptop: Use pr_warn instead of pr_warning
    platform/x86: eeepc-laptop: Use pr_warn instead of pr_warning
    oprofile: Use pr_warn instead of pr_warning
    of: Use pr_warn instead of pr_warning
    macintosh: Use pr_warn instead of pr_warning
    idsn: Use pr_warn instead of pr_warning
    ide: Use pr_warn instead of pr_warning
    crypto: n2: Use pr_warn instead of pr_warning
    ...

    Linus Torvalds
     

18 Oct, 2019

1 commit

  • As said in commit f2c2cbcc35d4 ("powerpc: Use pr_warn instead of
    pr_warning"), removing pr_warning so all logging messages use a
    consistent _warn style. Let's do it.

    Link: http://lkml.kernel.org/r/20191018031850.48498-10-wangkefeng.wang@huawei.com
    To: linux-kernel@vger.kernel.org
    Cc: Jens Axboe
    Signed-off-by: Kefeng Wang
    Reviewed-by: Sergey Senozhatsky
    Signed-off-by: Petr Mladek

    Kefeng Wang
     

15 Jun, 2019

2 commits

  • The stuff there is almost already at ReST format. A
    conversion for them is trivial: just add a missing titles
    and fix some scape codes for them to match ReST syntax.

    While here, rename the cdrom-standard.txt, with was converted
    from LaTeX to ReST on the previous patch, and add it to the
    index file.

    At its new index.rst, let's add a :orphan: while this is not linked to
    the main index.rst file, in order to avoid build warnings.

    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Jonathan Corbet

    Mauro Carvalho Chehab
     
  • This is the only LaTeX documentation file inside the documentation.

    Instead of having a Latex document directly there, convert
    it to ReST format, as this is the format we're using for docs.

    For now, let's keep the extension as .txt in order to avoid
    warnings when building the documentation with Sphinx.

    The next patch patch will rename it to .rst and add it to the
    building system.

    Signed-off-by: Mauro Carvalho Chehab
    Signed-off-by: Jonathan Corbet

    Mauro Carvalho Chehab
     

21 May, 2019

1 commit

  • Based on 2 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not write to the free software foundation inc
    51 franklin street fifth floor boston ma 02110 1301 usa

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option [no]_[pad]_[ctrl] any later version this program is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details you should have received a copy of the gnu general
    public license along with this program if not write to the free
    software foundation inc 51 franklin street fifth floor boston ma
    02110 1301 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 176 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Jilayne Lovejoy
    Reviewed-by: Steve Winslow
    Reviewed-by: Allison Randal
    Reviewed-by: Kate Stewart
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190519154040.652910950@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

13 Apr, 2019

1 commit

  • This reverts commit 9fd097b14918875bd6f125ed699d7bbbba5893ee.

    Instead of leaving disk->events completely empty, we now export the
    supported events again, and tell the block layer not to forward events to
    user space by not setting DISK_EVENT_FLAG_UEVENT. This allows the block
    layer to distinguish between devices that for which events should be
    handled in kernel only, and devices which don't support any meda change
    events at all.

    Cc: Jiri Kosina
    Cc: Tim Waugh
    Cc: Michal Simek
    Reviewed-by: Hannes Reinecke
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Martin Wilck
    Signed-off-by: Jens Axboe

    Martin Wilck
     

08 Feb, 2019

1 commit

  • The following traceback is sometimes seen when booting an image in qemu:

    [ 54.608293] cdrom: Uniform CD-ROM driver Revision: 3.20
    [ 54.611085] Fusion MPT base driver 3.04.20
    [ 54.611877] Copyright (c) 1999-2008 LSI Corporation
    [ 54.616234] Fusion MPT SAS Host driver 3.04.20
    [ 54.635139] sysctl duplicate entry: /dev/cdrom//info
    [ 54.639578] CPU: 0 PID: 266 Comm: kworker/u4:5 Not tainted 5.0.0-rc5 #1
    [ 54.639578] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
    [ 54.641273] Workqueue: events_unbound async_run_entry_fn
    [ 54.641273] Call Trace:
    [ 54.641273] dump_stack+0x67/0x90
    [ 54.641273] __register_sysctl_table+0x50b/0x570
    [ 54.641273] ? rcu_read_lock_sched_held+0x6f/0x80
    [ 54.641273] ? kmem_cache_alloc_trace+0x1c7/0x1f0
    [ 54.646814] __register_sysctl_paths+0x1c8/0x1f0
    [ 54.646814] cdrom_sysctl_register.part.7+0xc/0x5f
    [ 54.646814] register_cdrom.cold.24+0x2a/0x33
    [ 54.646814] sr_probe+0x4bd/0x580
    [ 54.646814] ? __driver_attach+0xd0/0xd0
    [ 54.646814] really_probe+0xd6/0x260
    [ 54.646814] ? __driver_attach+0xd0/0xd0
    [ 54.646814] driver_probe_device+0x4a/0xb0
    [ 54.646814] ? __driver_attach+0xd0/0xd0
    [ 54.646814] bus_for_each_drv+0x73/0xc0
    [ 54.646814] __device_attach+0xd6/0x130
    [ 54.646814] bus_probe_device+0x9a/0xb0
    [ 54.646814] device_add+0x40c/0x670
    [ 54.646814] ? __pm_runtime_resume+0x4f/0x80
    [ 54.646814] scsi_sysfs_add_sdev+0x81/0x290
    [ 54.646814] scsi_probe_and_add_lun+0x888/0xc00
    [ 54.646814] ? scsi_autopm_get_host+0x21/0x40
    [ 54.646814] __scsi_add_device+0x116/0x130
    [ 54.646814] ata_scsi_scan_host+0x93/0x1c0
    [ 54.646814] async_run_entry_fn+0x34/0x100
    [ 54.646814] process_one_work+0x237/0x5e0
    [ 54.646814] worker_thread+0x37/0x380
    [ 54.646814] ? rescuer_thread+0x360/0x360
    [ 54.646814] kthread+0x118/0x130
    [ 54.646814] ? kthread_create_on_node+0x60/0x60
    [ 54.646814] ret_from_fork+0x3a/0x50

    The only sensible explanation is that cdrom_sysctl_register() is called
    twice, once from the module init function and once from register_cdrom().
    cdrom_sysctl_register() is not mutex protected and may happily execute
    twice if the second call is made before the first call is complete.

    Use a static atomic to ensure that the function is executed exactly once.

    Signed-off-by: Guenter Roeck
    Signed-off-by: Jens Axboe

    Guenter Roeck
     

29 Dec, 2018

1 commit

  • In probe_gdrom(), the buffer pointed by 'gd.cd_info' is allocated through
    kzalloc() and is used to hold the information of the gdrom device. To
    register and unregister the device, the pointer 'gd.cd_info' is passed to
    the functions register_cdrom() and unregister_cdrom(), respectively.
    However, this buffer is not freed after it is used, which can cause a
    memory leak bug.

    This patch simply frees the buffer 'gd.cd_info' in exit_gdrom() to fix the
    above issue.

    Signed-off-by: Wenwen Wang
    Signed-off-by: Jens Axboe

    Wenwen Wang
     

26 Oct, 2018

2 commits

  • Apparently the kbuild bots missed this one originally, but at least
    it caught it now. Fix compilation error:

    All errors (new ones prefixed by >>):

    drivers/cdrom/gdrom.c: In function 'probe_gdrom':
    >> drivers/cdrom/gdrom.c:797:3: error: 'rc' undeclared (first use in this function)
    rc = PTR_ERR(gd.gdrom_rq);
    ^~
    drivers/cdrom/gdrom.c:797:3: note: each undeclared identifier is reported only once for each function it appears in

    Fixes: ad5fc6bb7221 ("gdrom: convert to blk-mq")
    Signed-off-by: Jens Axboe

    Jens Axboe
     
  • tocuse is not used after setting its value. It is safe to remove
    the unused variable.

    Signed-off-by: zhong jiang
    Signed-off-by: Jens Axboe

    zhong jiang
     

16 Oct, 2018

1 commit


15 Oct, 2018

1 commit

  • We can't modify cdo->capability as it is defined as a const.
    Change the modification hack to just WARN_ON_ONCE() if we hit
    any of the invalid combinations.

    This fixes a regression for pcd, which doesn't work after the
    constify patch.

    Fixes: 853fe1bf7554 ("cdrom: Make device operations read-only")
    Tested-by: Ondrej Zary
    Signed-off-by: Jens Axboe

    Jens Axboe
     

04 Oct, 2018

1 commit


29 Aug, 2018

1 commit

  • Like d88b6d04: "cdrom: information leak in cdrom_ioctl_media_changed()"

    There is another cast from unsigned long to int which causes
    a bounds check to fail with specially crafted input. The value is
    then used as an index in the slot array in cdrom_slot_status().

    Signed-off-by: Scott Bauer
    Signed-off-by: Scott Bauer
    Cc: stable@vger.kernel.org
    Signed-off-by: Jens Axboe

    Scott Bauer
     

03 Aug, 2018

2 commits

  • This removes more casts of struct request_sense and uses the standard
    struct scsi_sense_hdr instead. This also fixes any possible stale values
    since the prior code did not check the sense length.

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Kees Cook
    Signed-off-by: Jens Axboe

    Kees Cook
     
  • There is a lot of needless struct request_sense usage in the CDROM
    code. These can all be struct scsi_sense_hdr instead, to avoid any
    confusion over their respective structure sizes. This patch is a lot
    of noise changing "sense" to "sshdr", but the final code is more
    readable to distinguish between "sense" meaning "struct request_sense"
    and "sshdr" meaning "struct scsi_sense_hdr".

    Reviewed-by: Christoph Hellwig
    Signed-off-by: Kees Cook
    Signed-off-by: Jens Axboe

    Kees Cook
     

13 Jun, 2018

1 commit

  • The kmalloc() function has a 2-factor argument form, kmalloc_array(). This
    patch replaces cases of:

    kmalloc(a * b, gfp)

    with:
    kmalloc_array(a * b, gfp)

    as well as handling cases of:

    kmalloc(a * b * c, gfp)

    with:

    kmalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kmalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kmalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The tools/ directory was manually excluded, since it has its own
    implementation of kmalloc().

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kmalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kmalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kmalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kmalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kmalloc
    + kmalloc_array
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kmalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kmalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kmalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kmalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kmalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kmalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kmalloc(C1 * C2 * C3, ...)
    |
    kmalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kmalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kmalloc(sizeof(THING) * C2, ...)
    |
    kmalloc(sizeof(TYPE) * C2, ...)
    |
    kmalloc(C1 * C2 * C3, ...)
    |
    kmalloc(C1 * C2, ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kmalloc
    + kmalloc_array
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

14 May, 2018

1 commit


18 Apr, 2018

1 commit

  • This cast is wrong. "cdi->capacity" is an int and "arg" is an unsigned
    long. The way the check is written now, if one of the high 32 bits is
    set then we could read outside the info->slots[] array.

    This bug is pretty old and it predates git.

    Reviewed-by: Christoph Hellwig
    Cc: stable@vger.kernel.org
    Signed-off-by: Dan Carpenter
    Signed-off-by: Jens Axboe

    Dan Carpenter
     

09 Mar, 2018

1 commit

  • when mounting an ISO filesystem sometimes (very rarely)
    the system hangs because of a race condition between two tasks.

    PID: 6766 TASK: ffff88007b2a6dd0 CPU: 0 COMMAND: "mount"
    #0 [ffff880078447ae0] __schedule at ffffffff8168d605
    #1 [ffff880078447b48] schedule_preempt_disabled at ffffffff8168ed49
    #2 [ffff880078447b58] __mutex_lock_slowpath at ffffffff8168c995
    #3 [ffff880078447bb8] mutex_lock at ffffffff8168bdef
    #4 [ffff880078447bd0] sr_block_ioctl at ffffffffa00b6818 [sr_mod]
    #5 [ffff880078447c10] blkdev_ioctl at ffffffff812fea50
    #6 [ffff880078447c70] ioctl_by_bdev at ffffffff8123a8b3
    #7 [ffff880078447c90] isofs_fill_super at ffffffffa04fb1e1 [isofs]
    #8 [ffff880078447da8] mount_bdev at ffffffff81202570
    #9 [ffff880078447e18] isofs_mount at ffffffffa04f9828 [isofs]
    #10 [ffff880078447e28] mount_fs at ffffffff81202d09
    #11 [ffff880078447e70] vfs_kern_mount at ffffffff8121ea8f
    #12 [ffff880078447ea8] do_mount at ffffffff81220fee
    #13 [ffff880078447f28] sys_mount at ffffffff812218d6
    #14 [ffff880078447f80] system_call_fastpath at ffffffff81698c49
    RIP: 00007fd9ea914e9a RSP: 00007ffd5d9bf648 RFLAGS: 00010246
    RAX: 00000000000000a5 RBX: ffffffff81698c49 RCX: 0000000000000010
    RDX: 00007fd9ec2bc210 RSI: 00007fd9ec2bc290 RDI: 00007fd9ec2bcf30
    RBP: 0000000000000000 R8: 0000000000000000 R9: 0000000000000010
    R10: 00000000c0ed0001 R11: 0000000000000206 R12: 00007fd9ec2bc040
    R13: 00007fd9eb6b2380 R14: 00007fd9ec2bc210 R15: 00007fd9ec2bcf30
    ORIG_RAX: 00000000000000a5 CS: 0033 SS: 002b

    This task was trying to mount the cdrom. It allocated and configured a
    super_block struct and owned the write-lock for the super_block->s_umount
    rwsem. While exclusively owning the s_umount lock, it called
    sr_block_ioctl and waited to acquire the global sr_mutex lock.

    PID: 6785 TASK: ffff880078720fb0 CPU: 0 COMMAND: "systemd-udevd"
    #0 [ffff880078417898] __schedule at ffffffff8168d605
    #1 [ffff880078417900] schedule at ffffffff8168dc59
    #2 [ffff880078417910] rwsem_down_read_failed at ffffffff8168f605
    #3 [ffff880078417980] call_rwsem_down_read_failed at ffffffff81328838
    #4 [ffff8800784179d0] down_read at ffffffff8168cde0
    #5 [ffff8800784179e8] get_super at ffffffff81201cc7
    #6 [ffff880078417a10] __invalidate_device at ffffffff8123a8de
    #7 [ffff880078417a40] flush_disk at ffffffff8123a94b
    #8 [ffff880078417a88] check_disk_change at ffffffff8123ab50
    #9 [ffff880078417ab0] cdrom_open at ffffffffa00a29e1 [cdrom]
    #10 [ffff880078417b68] sr_block_open at ffffffffa00b6f9b [sr_mod]
    #11 [ffff880078417b98] __blkdev_get at ffffffff8123ba86
    #12 [ffff880078417bf0] blkdev_get at ffffffff8123bd65
    #13 [ffff880078417c78] blkdev_open at ffffffff8123bf9b
    #14 [ffff880078417c90] do_dentry_open at ffffffff811fc7f7
    #15 [ffff880078417cd8] vfs_open at ffffffff811fc9cf
    #16 [ffff880078417d00] do_last at ffffffff8120d53d
    #17 [ffff880078417db0] path_openat at ffffffff8120e6b2
    #18 [ffff880078417e48] do_filp_open at ffffffff8121082b
    #19 [ffff880078417f18] do_sys_open at ffffffff811fdd33
    #20 [ffff880078417f70] sys_open at ffffffff811fde4e
    #21 [ffff880078417f80] system_call_fastpath at ffffffff81698c49
    RIP: 00007f29438b0c20 RSP: 00007ffc76624b78 RFLAGS: 00010246
    RAX: 0000000000000002 RBX: ffffffff81698c49 RCX: 0000000000000000
    RDX: 00007f2944a5fa70 RSI: 00000000000a0800 RDI: 00007f2944a5fa70
    RBP: 00007f2944a5f540 R8: 0000000000000000 R9: 0000000000000020
    R10: 00007f2943614c40 R11: 0000000000000246 R12: ffffffff811fde4e
    R13: ffff880078417f78 R14: 000000000000000c R15: 00007f2944a4b010
    ORIG_RAX: 0000000000000002 CS: 0033 SS: 002b

    This task tried to open the cdrom device, the sr_block_open function
    acquired the global sr_mutex lock. The call to check_disk_change()
    then saw an event flag indicating a possible media change and tried
    to flush any cached data for the device.
    As part of the flush, it tried to acquire the super_block->s_umount
    lock associated with the cdrom device.
    This was the same super_block as created and locked by the previous task.

    The first task acquires the s_umount lock and then the sr_mutex_lock;
    the second task acquires the sr_mutex_lock and then the s_umount lock.

    This patch fixes the issue by moving check_disk_change() out of
    cdrom_open() and let the caller take care of it.

    Signed-off-by: Maurizio Lombardi
    Signed-off-by: Jens Axboe

    Maurizio Lombardi
     

15 Nov, 2017

1 commit

  • Pull core block layer updates from Jens Axboe:
    "This is the main pull request for block storage for 4.15-rc1.

    Nothing out of the ordinary in here, and no API changes or anything
    like that. Just various new features for drivers, core changes, etc.
    In particular, this pull request contains:

    - A patch series from Bart, closing the whole on blk/scsi-mq queue
    quescing.

    - A series from Christoph, building towards hidden gendisks (for
    multipath) and ability to move bio chains around.

    - NVMe
    - Support for native multipath for NVMe (Christoph).
    - Userspace notifications for AENs (Keith).
    - Command side-effects support (Keith).
    - SGL support (Chaitanya Kulkarni)
    - FC fixes and improvements (James Smart)
    - Lots of fixes and tweaks (Various)

    - bcache
    - New maintainer (Michael Lyle)
    - Writeback control improvements (Michael)
    - Various fixes (Coly, Elena, Eric, Liang, et al)

    - lightnvm updates, mostly centered around the pblk interface
    (Javier, Hans, and Rakesh).

    - Removal of unused bio/bvec kmap atomic interfaces (me, Christoph)

    - Writeback series that fix the much discussed hundreds of millions
    of sync-all units. This goes all the way, as discussed previously
    (me).

    - Fix for missing wakeup on writeback timer adjustments (Yafang
    Shao).

    - Fix laptop mode on blk-mq (me).

    - {mq,name} tupple lookup for IO schedulers, allowing us to have
    alias names. This means you can use 'deadline' on both !mq and on
    mq (where it's called mq-deadline). (me).

    - blktrace race fix, oopsing on sg load (me).

    - blk-mq optimizations (me).

    - Obscure waitqueue race fix for kyber (Omar).

    - NBD fixes (Josef).

    - Disable writeback throttling by default on bfq, like we do on cfq
    (Luca Miccio).

    - Series from Ming that enable us to treat flush requests on blk-mq
    like any other request. This is a really nice cleanup.

    - Series from Ming that improves merging on blk-mq with schedulers,
    getting us closer to flipping the switch on scsi-mq again.

    - BFQ updates (Paolo).

    - blk-mq atomic flags memory ordering fixes (Peter Z).

    - Loop cgroup support (Shaohua).

    - Lots of minor fixes from lots of different folks, both for core and
    driver code"

    * 'for-4.15/block' of git://git.kernel.dk/linux-block: (294 commits)
    nvme: fix visibility of "uuid" ns attribute
    blk-mq: fixup some comment typos and lengths
    ide: ide-atapi: fix compile error with defining macro DEBUG
    blk-mq: improve tag waiting setup for non-shared tags
    brd: remove unused brd_mutex
    blk-mq: only run the hardware queue if IO is pending
    block: avoid null pointer dereference on null disk
    fs: guard_bio_eod() needs to consider partitions
    xtensa/simdisk: fix compile error
    nvme: expose subsys attribute to sysfs
    nvme: create 'slaves' and 'holders' entries for hidden controllers
    block: create 'slaves' and 'holders' entries for hidden gendisks
    nvme: also expose the namespace identification sysfs files for mpath nodes
    nvme: implement multipath access to nvme subsystems
    nvme: track shared namespaces
    nvme: introduce a nvme_ns_ids structure
    nvme: track subsystems
    block, nvme: Introduce blk_mq_req_flags_t
    block, scsi: Make SCSI quiesce and resume work reliably
    block: Add the QUEUE_FLAG_PREEMPT_ONLY request queue flag
    ...

    Linus Torvalds
     

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
     

01 Nov, 2017

1 commit

  • Instead of referring from inside drivers/cdrom/Makefile to all the
    drivers that use this driver, let these drivers select the cdrom
    driver. This change makes the cdrom build code follow the approach
    that is used for most other drivers, namely refer from the higher
    layers to the lower layer instead of from the lower layer to the
    higher layers.

    Reviewed-by: Hannes Reinecke
    Signed-off-by: Bart Van Assche
    Cc: Christoph Hellwig
    Cc: Johannes Thumshirn
    Signed-off-by: Jens Axboe

    Bart Van Assche
     

28 Jun, 2017

1 commit


21 Jun, 2017

1 commit

  • Instead of explicitly calling scsi_req_init() after blk_get_request(),
    call that function from inside blk_get_request(). Add an
    .initialize_rq_fn() callback function to the block drivers that need
    it. Merge the IDE .init_rq_fn() function into .initialize_rq_fn()
    because it is too small to keep it as a separate function. Keep the
    scsi_req_init() call in ide_prep_sense() because it follows a
    blk_rq_init() call.

    References: commit 82ed4db499b8 ("block: split scsi_request out of struct request")
    Signed-off-by: Bart Van Assche
    Cc: Christoph Hellwig
    Cc: Hannes Reinecke
    Cc: Omar Sandoval
    Cc: Nicholas Bellinger
    Signed-off-by: Jens Axboe

    Bart Van Assche
     

09 Jun, 2017

1 commit

  • Currently we use nornal Linux errno values in the block layer, and while
    we accept any error a few have overloaded magic meanings. This patch
    instead introduces a new blk_status_t value that holds block layer specific
    status codes and explicitly explains their meaning. Helpers to convert from
    and to the previous special meanings are provided for now, but I suspect
    we want to get rid of them in the long run - those drivers that have a
    errno input (e.g. networking) usually get errnos that don't know about
    the special block layer overloads, and similarly returning them to userspace
    will usually return somethings that strictly speaking isn't correct
    for file system operations, but that's left as an exercise for later.

    For now the set of errors is a very limited set that closely corresponds
    to the previous overloaded errno values, but there is some low hanging
    fruite to improve it.

    blk_status_t (ab)uses the sparse __bitwise annotations to allow for sparse
    typechecking, so that we can easily catch places passing the wrong values.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Jens Axboe

    Christoph Hellwig