24 Sep, 2020

2 commits


02 Sep, 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
     

01 Jul, 2020

3 commits


11 Jun, 2020

1 commit


28 Mar, 2020

1 commit

  • Current make_request based drivers use either blk_alloc_queue_node or
    blk_alloc_queue to allocate a queue, and then set up the make_request_fn
    function pointer and a few parameters using the blk_queue_make_request
    helper. Simplify this by passing the make_request pointer to
    blk_alloc_queue, and while at it merge the _node variant into the main
    helper by always passing a node_id, and remove the superfluous gfp_mask
    parameter. A lower-level __blk_alloc_queue is kept for the blk-mq case.

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

    Christoph Hellwig
     

27 Mar, 2020

1 commit


03 Jan, 2020

2 commits

  • This is the only ioctl command that does not have a proper
    compat handler. Making the normal implementation do the
    right thing is actually very simply, so just do that by
    using an in_compat_syscall() check to avoid the special
    case in the pkcdvd driver.

    Reviewed-by: Ben Hutchings
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     
  • There is only one implementation of this ioctl, so move the handling out
    of the common block layer code into the place where it's actually needed.

    It also gets called indirectly through pktcdvd, which needs to be aware
    of this change.

    As I noticed, the old implementation of the compat handler failed to
    convert the structure on the way out, so the updated fields never got
    written back to user space. This is either not important, or it has
    never worked and should be fixed now.

    Reviewed-by: Ben Hutchings
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

21 Dec, 2019

1 commit

  • The support for the compat ioctl did not actually do what it was
    supposed to do because of a typo, instead it broke native support for
    CDROM_LAST_WRITTEN and CDROM_SEND_PACKET on all architectures with
    CONFIG_COMPAT enabled.

    Fixes: 1b114b0817cc ("pktcdvd: add compat_ioctl handler")
    Signed-off-by: Arnd Bergmann
    ----
    Please apply for v5.5, I just noticed the regression while
    rebasing some of the patches I created on top.
    Signed-off-by: Jens Axboe

    Arnd Bergmann
     

23 Oct, 2019

1 commit

  • pkt_ioctl() implements the generic SCSI_IOCTL_SEND_COMMAND
    and some cdrom ioctls by forwarding to the underlying block
    device. For compat_ioctl handling, this always takes a
    roundtrip through fs/compat_ioctl.c that we should try
    to avoid, at least for the compatible commands.

    CDROM_SEND_PACKET is an exception here, it requires special
    translation in compat_blkdev_driver_ioctl().

    CDROM_LAST_WRITTEN has no compat handling at the moment.

    Cc: Jens Axboe
    Cc: linux-block@vger.kernel.org
    Signed-off-by: Arnd Bergmann

    Arnd Bergmann
     

23 Sep, 2019

1 commit

  • Anatoly reports that he gets the below warning when booting -git on
    a sparc64 box on debian unstable:

    ...
    [ 13.352975] aes_sparc64: Using sparc64 aes opcodes optimized AES
    implementation
    [ 13.428002] ------------[ cut here ]------------
    [ 13.428081] WARNING: CPU: 21 PID: 586 at
    drivers/block/pktcdvd.c:2597 pkt_setup_dev+0x2e4/0x5a0 [pktcdvd]
    [ 13.428147] Attempt to register a non-SCSI queue
    [ 13.428184] Modules linked in: pktcdvd libdes cdrom aes_sparc64
    n2_rng md5_sparc64 sha512_sparc64 rng_core sha256_sparc64 flash
    sha1_sparc64 ip_tables x_tables ipv6 crc_ccitt nf_defrag_ipv6 autofs4
    ext4 crc16 mbcache jbd2 raid10 raid456 async_raid6_recov async_memcpy
    async_pq async_xor xor async_tx raid6_pq raid1 raid0 multipath linear
    md_mod crc32c_sparc64
    [ 13.428452] CPU: 21 PID: 586 Comm: pktsetup Not tainted
    5.3.0-10169-g574cc4539762 #1234
    [ 13.428507] Call Trace:
    [ 13.428542] [00000000004635c0] __warn+0xc0/0x100
    [ 13.428582] [0000000000463634] warn_slowpath_fmt+0x34/0x60
    [ 13.428626] [000000001045b244] pkt_setup_dev+0x2e4/0x5a0 [pktcdvd]
    [ 13.428674] [000000001045ccf4] pkt_ctl_ioctl+0x94/0x220 [pktcdvd]
    [ 13.428724] [00000000006b95c8] do_vfs_ioctl+0x628/0x6e0
    [ 13.428764] [00000000006b96c8] ksys_ioctl+0x48/0x80
    [ 13.428803] [00000000006b9714] sys_ioctl+0x14/0x40
    [ 13.428847] [0000000000406294] linux_sparc_syscall+0x34/0x44
    [ 13.428890] irq event stamp: 4181
    [ 13.428924] hardirqs last enabled at (4189): []
    console_unlock+0x634/0x6c0
    [ 13.428984] hardirqs last disabled at (4196): []
    console_unlock+0x100/0x6c0
    [ 13.429048] softirqs last enabled at (3978): []
    __do_softirq+0x498/0x520
    [ 13.429110] softirqs last disabled at (3967): []
    do_softirq_own_stack+0x34/0x60
    [ 13.429172] ---[ end trace 2220ca468f32967d ]---
    [ 13.430018] pktcdvd: setup of pktcdvd device failed
    [ 13.455589] des_sparc64: Using sparc64 des opcodes optimized DES
    implementation
    [ 13.515334] camellia_sparc64: Using sparc64 camellia opcodes
    optimized CAMELLIA implementation
    [ 13.522856] pktcdvd: setup of pktcdvd device failed
    [ 13.529327] pktcdvd: setup of pktcdvd device failed
    [ 13.532932] pktcdvd: setup of pktcdvd device failed
    [ 13.536165] pktcdvd: setup of pktcdvd device failed
    [ 13.539372] pktcdvd: setup of pktcdvd device failed
    [ 13.542834] pktcdvd: setup of pktcdvd device failed
    [ 13.546536] pktcdvd: setup of pktcdvd device failed
    [ 15.431071] XFS (dm-0): Mounting V5 Filesystem
    ...

    Apparently debian auto-attaches any cdrom like device to pktcdvd, which
    can lead to the above warning. There's really no reason to warn for this
    situation, kill it.

    Reported-by: Anatoly Pugachev
    Signed-off-by: Jens Axboe

    Jens Axboe
     

13 Apr, 2019

1 commit

  • The async_events field, intended to be used for drivers that support
    asynchronous notifications about disk events (aka media change events),
    isn't currently used by any driver, and apparently that has been that
    way for a long time (if not forever). Remove it.

    Reviewed-by: Hannes Reinecke
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Martin Wilck
    Signed-off-by: Jens Axboe

    Martin Wilck
     

17 Nov, 2018

1 commit


16 Nov, 2018

1 commit

  • With the legacy request path gone there is no good reason to keep
    queue_lock as a pointer, we can always use the embedded lock now.

    Reviewed-by: Hannes Reinecke
    Signed-off-by: Christoph Hellwig

    Fixed floppy and blk-cgroup missing conversions and half done edits.

    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

02 Oct, 2018

1 commit


17 Aug, 2018

1 commit


03 Aug, 2018

1 commit

  • 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
     

28 Jul, 2018

1 commit

  • User controls @dev_minor which to be used as index of pkt_devs.
    So, It can be exploited via Spectre-like attack. (speculative execution)

    This kind of attack leaks address of pkt_devs, [1]
    It leads an attacker to bypass security mechanism such as KASLR.

    So sanitize @dev_minor before using it to prevent attack.

    [1] https://github.com/jinb-park/linux-exploit/
    tree/master/exploit-remaining-spectre-gadget/leak_pkt_devs.c

    Signed-off-by: Jinbum Park
    Signed-off-by: Jens Axboe

    Jinbum Park
     

18 Jul, 2018

1 commit


05 Jun, 2018

1 commit

  • Pull procfs updates from Al Viro:
    "Christoph's proc_create_... cleanups series"

    * 'hch.procfs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (44 commits)
    xfs, proc: hide unused xfs procfs helpers
    isdn/gigaset: add back gigaset_procinfo assignment
    proc: update SIZEOF_PDE_INLINE_NAME for the new pde fields
    tty: replace ->proc_fops with ->proc_show
    ide: replace ->proc_fops with ->proc_show
    ide: remove ide_driver_proc_write
    isdn: replace ->proc_fops with ->proc_show
    atm: switch to proc_create_seq_private
    atm: simplify procfs code
    bluetooth: switch to proc_create_seq_data
    netfilter/x_tables: switch to proc_create_seq_private
    netfilter/xt_hashlimit: switch to proc_create_{seq,single}_data
    neigh: switch to proc_create_seq_data
    hostap: switch to proc_create_{seq,single}_data
    bonding: switch to proc_create_seq_data
    rtc/proc: switch to proc_create_single_data
    drbd: switch to proc_create_single
    resource: switch to proc_create_seq_data
    staging/rtl8192u: simplify procfs code
    jfs: simplify procfs code
    ...

    Linus Torvalds
     

31 May, 2018

1 commit


25 May, 2018

1 commit

  • Convert the S_ symbolic permissions to their octal equivalents as
    using octal and not symbolic permissions is preferred by many as more
    readable.

    see: https://lkml.org/lkml/2016/8/2/1945

    Done with automated conversion via:
    $ ./scripts/checkpatch.pl -f --types=SYMBOLIC_PERMS --fix-inplace

    Miscellanea:

    o Wrapped modified multi-line calls to a single line where appropriate
    o Realign modified multi-line calls to open parenthesis

    Signed-off-by: Joe Perches
    Signed-off-by: Jens Axboe

    Joe Perches
     

16 May, 2018

1 commit


15 May, 2018

1 commit

  • Found a bug (with ASAN) where we were passing a bio to bio_copy_data()
    with bi_next not NULL, when it should have been - a driver had left
    bi_next set to something after calling bio_endio().

    Since the normal case is only copying single bios, split out
    bio_list_copy_data() to avoid more bugs like this in the future.

    Signed-off-by: Kent Overstreet
    Signed-off-by: Jens Axboe

    Kent Overstreet
     

14 May, 2018

2 commits


01 Mar, 2018

1 commit

  • Fix a typo in pkt_start_recovery.

    Fixes: 74d46992e0d9 ("block: replace bi_bdev with a gendisk pointer and partitions index")
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Jiufei Xue
    Signed-off-by: Jens Axboe

    Jiufei Xue
     

06 Jan, 2018

2 commits

  • Call bdev_get_queue(bdev) after bdev->bd_disk has been initialized
    instead of just before that pointer has been initialized. This patch
    avoids that the following command

    pktsetup 1 /dev/sr0

    triggers the following kernel crash:

    BUG: unable to handle kernel NULL pointer dereference at 0000000000000548
    IP: pkt_setup_dev+0x2db/0x670 [pktcdvd]
    CPU: 2 PID: 724 Comm: pktsetup Not tainted 4.15.0-rc4-dbg+ #1
    Call Trace:
    pkt_ctl_ioctl+0xce/0x1c0 [pktcdvd]
    do_vfs_ioctl+0x8e/0x670
    SyS_ioctl+0x3c/0x70
    entry_SYSCALL_64_fastpath+0x23/0x9a

    Reported-by: Maciej S. Szmigiero
    Fixes: commit ca18d6f769d2 ("block: Make most scsi_req_init() calls implicit")
    Signed-off-by: Bart Van Assche
    Tested-by: Maciej S. Szmigiero
    Cc: Maciej S. Szmigiero
    Cc: # v4.13
    Signed-off-by: Jens Axboe

    Bart Van Assche
     
  • Commit 523e1d399ce0 ("block: make gendisk hold a reference to its queue")
    modified add_disk() and disk_release() but did not update any of the
    error paths that trigger a put_disk() call after disk->queue has been
    assigned. That introduced the following behavior in the pktcdvd driver
    if pkt_new_dev() fails:

    Kernel BUG at 00000000e98fd882 [verbose debug info unavailable]

    Since disk_release() calls blk_put_queue() anyway if disk->queue != NULL,
    fix this by removing the blk_cleanup_queue() call from the pkt_setup_dev()
    error path.

    Fixes: commit 523e1d399ce0 ("block: make gendisk hold a reference to its queue")
    Signed-off-by: Bart Van Assche
    Cc: Tejun Heo
    Cc: Maciej S. Szmigiero
    Cc: # v3.2
    Signed-off-by: Jens Axboe

    Bart Van Assche
     

24 Aug, 2017

1 commit

  • This way we don't need a block_device structure to submit I/O. The
    block_device has different life time rules from the gendisk and
    request_queue and is usually only available when the block device node
    is open. Other callers need to explicitly create one (e.g. the lightnvm
    passthrough code, or the new nvme multipathing code).

    For the actual I/O path all that we need is the gendisk, which exists
    once per block device. But given that the block layer also does
    partition remapping we additionally need a partition index, which is
    used for said remapping in generic_make_request.

    Note that all the block drivers generally want request_queue or
    sometimes the gendisk, so this removes a layer of indirection all
    over the stack.

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

    Christoph Hellwig
     

04 Jul, 2017

1 commit

  • Pull driver core updates from Greg KH:
    "Here is the big driver core update for 4.13-rc1.

    The large majority of this is a lot of cleanup of old fields in the
    driver core structures and their remaining usages in random drivers.
    All of those fixes have been reviewed by the various subsystem
    maintainers. There's also some small firmware updates in here, a new
    kobject uevent api interface that makes userspace interaction easier,
    and a few other minor things.

    All of these have been in linux-next for a long while with no reported
    issues"

    * tag 'driver-core-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (56 commits)
    arm: mach-rpc: ecard: fix build error
    zram: convert remaining CLASS_ATTR() to CLASS_ATTR_RO()
    driver-core: remove struct bus_type.dev_attrs
    powerpc: vio_cmo: use dev_groups and not dev_attrs for bus_type
    powerpc: vio: use dev_groups and not dev_attrs for bus_type
    USB: usbip: convert to use DRIVER_ATTR_RW
    s390: drivers: convert to use DRIVER_ATTR_RO/WO
    platform: thinkpad_acpi: convert to use DRIVER_ATTR_RO/RW
    pcmcia: ds: convert to use DRIVER_ATTR_RO
    wireless: ipw2x00: convert to use DRIVER_ATTR_RW
    net: ehea: convert to use DRIVER_ATTR_RO
    net: caif: convert to use DRIVER_ATTR_RO
    TTY: hvc: convert to use DRIVER_ATTR_RW
    PCI: pci-driver: convert to use DRIVER_ATTR_WO
    IB: nes: convert to use DRIVER_ATTR_RW
    HID: hid-core: convert to use DRIVER_ATTR_RO and drv_groups
    arm: ecard: fix dev_groups patch typo
    tty: serdev: use dev_groups and not dev_attrs for bus_type
    sparc: vio: use dev_groups and not dev_attrs for bus_type
    hid: intel-ish-hid: use dev_groups and not dev_attrs for bus_type
    ...

    Linus Torvalds
     

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
     

19 Jun, 2017

2 commits

  • pktcdvd doesn't change the bi_io_vec of the clone bio,
    so it is more efficient to use bio_clone_fast(), and not clone
    the bi_io_vec.
    This requires providing a bio_set, and it is safest to
    provide a dedicated bio_set rather than sharing
    fs_bio_set, which filesytems use.
    This new bio_set, pkt_bio_set, can also be use for the bio_split()
    call as the two allocations (bio_clone_fast, and bio_split) are
    independent, neither can block a bio allocated by the other.

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

    NeilBrown
     
  • blk_queue_split() is always called with the last arg being q->bio_split,
    where 'q' is the first arg.

    Also blk_queue_split() sometimes uses the passed-in 'bs' and sometimes uses
    q->bio_split.

    This is inconsistent and unnecessary. Remove the last arg and always use
    q->bio_split inside blk_queue_split()

    Reviewed-by: Christoph Hellwig
    Reviewed-by: Ming Lei
    Credit-to: Javier González (Noticed that lightnvm was missed)
    Reviewed-by: Javier González
    Tested-by: Javier González
    Signed-off-by: NeilBrown
    Signed-off-by: Jens Axboe

    NeilBrown
     

09 Jun, 2017

1 commit

  • Replace bi_error with a new bi_status to allow for a clear conversion.
    Note that device mapper overloaded bi_error with a private value, which
    we'll have to keep arround at least for now and thus propagate to a
    proper blk_status_t value.

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

    Christoph Hellwig