24 Mar, 2019

1 commit

  • commit bb06c388fa20ae24cfe80c52488de718a7e3a53f upstream.

    If msize is less than 4096, we should close and put trans, destroy
    tagpool, not just free client. This patch fixes that.

    Link: http://lkml.kernel.org/m/1552464097-142659-1-git-send-email-zhengbin13@huawei.com
    Cc: stable@vger.kernel.org
    Fixes: 574d356b7a02 ("9p/net: put a lower bound on msize")
    Reported-by: Hulk Robot
    Signed-off-by: zhengbin
    Signed-off-by: Dominique Martinet
    Signed-off-by: Greg Kroah-Hartman

    zhengbin
     

13 Jan, 2019

1 commit

  • commit 574d356b7a02c7e1b01a1d9cba8a26b3c2888f45 upstream.

    If the requested msize is too small (either from command line argument
    or from the server version reply), we won't get any work done.
    If it's *really* too small, nothing will work, and this got caught by
    syzbot recently (on a new kmem_cache_create_usercopy() call)

    Just set a minimum msize to 4k in both code paths, until someone
    complains they have a use-case for a smaller msize.

    We need to check in both mount option and server reply individually
    because the msize for the first version request would be unchecked
    with just a global check on clnt->msize.

    Link: http://lkml.kernel.org/r/1541407968-31350-1-git-send-email-asmadeus@codewreck.org
    Reported-by: syzbot+0c1d61e4db7db94102ca@syzkaller.appspotmail.com
    Signed-off-by: Dominique Martinet
    Cc: Eric Van Hensbergen
    Cc: Latchesar Ionkov
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Dominique Martinet
     

21 Nov, 2018

1 commit

  • [ Upstream commit 62e3941776fea8678bb8120607039410b1b61a65 ]

    p9stat_free is more of a cleanup function than a 'free' function as it
    only frees the content of the struct; there are chances of use-after-free
    if it is improperly used (e.g. p9stat_free called twice as it used to be
    possible to)

    Clearing dangling pointers makes the function idempotent and safer to use.

    Link: http://lkml.kernel.org/r/1535410108-20650-2-git-send-email-asmadeus@codewreck.org
    Signed-off-by: Dominique Martinet
    Reported-by: syzbot+d4252148d198410b864f@syzkaller.appspotmail.com
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Dominique Martinet
     

18 Aug, 2018

1 commit

  • Pull 9p updates from Dominique Martinet:
    "This contains mostly fixes (6 to be backported to stable) and a few
    changes, here is the breakdown:

    - rework how fids are attributed by replacing some custom tracking in
    a list by an idr

    - for packet-based transports (virtio/rdma) validate that the packet
    length matches what the header says

    - a few race condition fixes found by syzkaller

    - missing argument check when NULL device is passed in sys_mount

    - a few virtio fixes

    - some spelling and style fixes"

    * tag '9p-for-4.19-2' of git://github.com/martinetd/linux: (21 commits)
    net/9p/trans_virtio.c: add null terminal for mount tag
    9p/virtio: fix off-by-one error in sg list bounds check
    9p: fix whitespace issues
    9p: fix multiple NULL-pointer-dereferences
    fs/9p/xattr.c: catch the error of p9_client_clunk when setting xattr failed
    9p: validate PDU length
    net/9p/trans_fd.c: fix race by holding the lock
    net/9p/trans_fd.c: fix race-condition by flushing workqueue before the kfree()
    net/9p/virtio: Fix hard lockup in req_done
    net/9p/trans_virtio.c: fix some spell mistakes in comments
    9p/net: Fix zero-copy path in the 9p virtio transport
    9p: Embed wait_queue_head into p9_req_t
    9p: Replace the fidlist with an IDR
    9p: Change p9_fid_create calling convention
    9p: Fix comment on smp_wmb
    net/9p/client.c: version pointer uninitialized
    fs/9p/v9fs.c: fix spelling mistake "Uknown" -> "Unknown"
    net/9p: fix error path of p9_virtio_probe
    9p/net/protocol.c: return -ENOMEM when kmalloc() failed
    net/9p/client.c: add missing '\n' at the end of p9_debug()
    ...

    Linus Torvalds
     

17 Aug, 2018

2 commits

  • rdma.git merge resolution for the 4.19 merge window

    Conflicts:
    drivers/infiniband/core/rdma_core.c
    - Use the rdma code and revise with the new spelling for
    atomic_fetch_add_unless
    drivers/nvme/host/rdma.c
    - Replace max_sge with max_send_sge in new blk code
    drivers/nvme/target/rdma.c
    - Use the blk code and revise to use NULL for ib_post_recv when
    appropriate
    - Replace max_sge with max_recv_sge in new blk code
    net/rds/ib_send.c
    - Use the net code and revise to use NULL for ib_post_recv when
    appropriate

    Signed-off-by: Jason Gunthorpe

    Jason Gunthorpe
     
  • Resolve merge conflicts from the -rc cycle against the rdma.git tree:

    Conflicts:
    drivers/infiniband/core/uverbs_cmd.c
    - New ifs added to ib_uverbs_ex_create_flow in -rc and for-next
    - Merge removal of file->ucontext in for-next with new code in -rc
    drivers/infiniband/core/uverbs_main.c
    - for-next removed code from ib_uverbs_write() that was modified
    in for-rc

    Signed-off-by: Jason Gunthorpe

    Jason Gunthorpe
     

13 Aug, 2018

18 commits

  • chan->tag is Non-null terminated which will result in printing messy code
    when debugging code. So we should add '\0' for tag to make the code more
    convenient and robust. In addition, I drop char->tag_len to simplify the
    code.

    Link: http://lkml.kernel.org/r/5B641ECC.5030401@huawei.com
    Signed-off-by: Jun Piao
    Signed-off-by: Dominique Martinet

    piaojun
     
  • Because the value of limit is VIRTQUEUE_NUM, if index is equal to
    limit, it will cause sg array out of bounds, so correct the judgement
    of BUG_ON.

    Link: http://lkml.kernel.org/r/5B63D5F6.6080109@huawei.com
    Signed-off-by: Yiwen Jiang
    Reported-By: Dan Carpenter
    Acked-by: Jun Piao
    Cc: stable@vger.kernel.org
    Signed-off-by: Dominique Martinet

    jiangyiwen
     
  • Remove trailing whitespace and blank lines at EOF

    Link: http://lkml.kernel.org/m/20180724192918.31165-11-sthemmin@microsoft.com
    Signed-off-by: Stephen Hemminger
    Signed-off-by: Dominique Martinet

    Stephen Hemminger
     
  • Added checks to prevent GPFs from raising.

    Link: http://lkml.kernel.org/r/20180727110558.5479-1-tomasbortoli@gmail.com
    Signed-off-by: Tomas Bortoli
    Reported-by: syzbot+1a262da37d3bead15c39@syzkaller.appspotmail.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Dominique Martinet

    Tomas Bortoli
     
  • This commit adds length check for the PDU size.
    The size contained in the header has to match the actual size,
    except for TCP (trans_fd.c) where actual length is not known ahead
    and the header's length will be checked only against the validity
    range.

    Link: http://lkml.kernel.org/r/20180723154404.2406-1-tomasbortoli@gmail.com
    Signed-off-by: Tomas Bortoli
    Reported-by: syzbot+65c6b72f284a39d416b4@syzkaller.appspotmail.com
    To: Eric Van Hensbergen
    To: Ron Minnich
    To: Latchesar Ionkov
    Cc: David S. Miller
    Signed-off-by: Dominique Martinet

    Tomas Bortoli
     
  • It may be possible to run p9_fd_cancel() with a deleted req->req_list
    and incur in a double del. To fix hold the client->lock while changing
    the status, so the other threads will be synchronized.

    Link: http://lkml.kernel.org/r/20180723184253.6682-1-tomasbortoli@gmail.com
    Signed-off-by: Tomas Bortoli
    Reported-by: syzbot+735d926e9d1317c3310c@syzkaller.appspotmail.com
    To: Eric Van Hensbergen
    To: Ron Minnich
    To: Latchesar Ionkov
    Cc: Yiwen Jiang
    Cc: David S. Miller
    Signed-off-by: Dominique Martinet

    Tomas Bortoli
     
  • The patch adds the flush in p9_mux_poll_stop() as it the function used by
    p9_conn_destroy(), in turn called by p9_fd_close() to stop the async
    polling associated with the data regarding the connection.

    Link: http://lkml.kernel.org/r/20180720092730.27104-1-tomasbortoli@gmail.com
    Signed-off-by: Tomas Bortoli
    Reported-by: syzbot+39749ed7d9ef6dfb23f6@syzkaller.appspotmail.com
    To: Eric Van Hensbergen
    To: Ron Minnich
    To: Latchesar Ionkov
    Cc: Yiwen Jiang
    Cc: stable@vger.kernel.org
    Signed-off-by: Dominique Martinet

    Tomas Bortoli
     
  • When client has multiple threads that issue io requests
    all the time, and the server has a very good performance,
    it may cause cpu is running in the irq context for a long
    time because it can check virtqueue has buf in the *while*
    loop.

    So we should keep chan->lock in the whole loop.

    [ Dominique: reworded subject line ]
    Link: http://lkml.kernel.org/r/5B503AEC.5080404@huawei.com
    Signed-off-by: Yiwen Jiang
    To: Andrew Morton
    To: Eric Van Hensbergen
    To: Ron Minnich
    To: Latchesar Ionkov
    Signed-off-by: Dominique Martinet

    jiangyiwen
     
  • Fix spelling mistake in comments of p9_virtio_zc_request().

    Link: http://lkml.kernel.org/r/5B4EB7D9.9010108@huawei.com
    Signed-off-by: Jun Piao
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Cc: Andrew Morton
    Signed-off-by: Dominique Martinet

    piaojun
     
  • The zero-copy optimization when reading or writing large chunks of data
    is quite useful. However, the 9p messages created through the zero-copy
    write path have an incorrect message size: it should be the size of the
    header + size of the data being written but instead it's just the size
    of the header.

    This only works if the server ignores the size field of the message and
    otherwise breaks the framing of the protocol. Fix this by re-writing the
    message size field with the correct value.

    Tested by running `dd if=/dev/zero of=out bs=4k count=1` inside a
    virtio-9p mount.

    Link: http://lkml.kernel.org/r/20180717003529.114368-1-chirantan@chromium.org
    Signed-off-by: Chirantan Ekbote
    Reviewed-by: Greg Kurz
    Tested-by: Greg Kurz
    Cc: Dylan Reid
    Cc: Guenter Roeck
    Cc: stable@vger.kernel.org
    Signed-off-by: Dominique Martinet

    Chirantan Ekbote
     
  • On a 64-bit system, the wait_queue_head_t is 24 bytes while the pointer
    to it is 8 bytes. Growing the p9_req_t by 16 bytes is better than
    performing a 24-byte memory allocation.

    Link: http://lkml.kernel.org/r/20180711210225.19730-5-willy@infradead.org
    Signed-off-by: Matthew Wilcox
    Reviewed-by: Greg Kurz
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Dominique Martinet

    Matthew Wilcox
     
  • The p9_idpool being used to allocate the IDs uses an IDR to allocate
    the IDs ... which we then keep in a doubly-linked list, rather than in
    the IDR which allocated them. We can use an IDR directly which saves
    two pointers per p9_fid, and a tiny memory allocation per p9_client.

    Link: http://lkml.kernel.org/r/20180711210225.19730-4-willy@infradead.org
    Signed-off-by: Matthew Wilcox
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Dominique Martinet

    Matthew Wilcox
     
  • Return NULL instead of ERR_PTR when we can't allocate a FID. The ENOSPC
    return value was getting all the way back to userspace, and that's
    confusing for a userspace program which isn't expecting read() to tell it
    there's no space left on the filesystem. The best error we can return to
    indicate a temporary failure caused by lack of client resources is ENOMEM.

    Maybe it would be better to sleep until a FID is available, but that's
    not a change I'm comfortable making.

    Link: http://lkml.kernel.org/r/20180711210225.19730-3-willy@infradead.org
    Signed-off-by: Matthew Wilcox
    Reviewed-by: Jun Piao
    Reviewed-by: Greg Kurz
    Reviewed-by: Yiwen Jiang
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Dominique Martinet

    Matthew Wilcox
     
  • The previous comment misled me into thinking the barrier wasn't needed
    at all.

    Link: http://lkml.kernel.org/r/20180711210225.19730-2-willy@infradead.org
    Signed-off-by: Matthew Wilcox
    Reviewed-by: Greg Kurz
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Dominique Martinet

    Matthew Wilcox
     
  • The p9_client_version() does not initialize the version pointer. If the
    call to p9pdu_readf() returns an error and version has not been allocated
    in p9pdu_readf(), then the program will jump to the "error" label and will
    try to free the version pointer. If version is not initialized, free()
    will be called with uninitialized, garbage data and will provoke a crash.

    Link: http://lkml.kernel.org/r/20180709222943.19503-1-tomasbortoli@gmail.com
    Signed-off-by: Tomas Bortoli
    Reported-by: syzbot+65c6b72f284a39d416b4@syzkaller.appspotmail.com
    Reviewed-by: Jun Piao
    Reviewed-by: Yiwen Jiang
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Andrew Morton
    Cc: stable@vger.kernel.org
    Signed-off-by: Dominique Martinet

    Tomas Bortoli
     
  • Currently when virtio_find_single_vq fails, we go through del_vqs which
    throws a warning (Trying to free already-free IRQ). Skip del_vqs if vq
    allocation failed.

    Link: http://lkml.kernel.org/r/20180524101021.49880-1-jean-philippe.brucker@arm.com
    Signed-off-by: Jean-Philippe Brucker
    Reviewed-by: Greg Kurz
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Andrew Morton
    Signed-off-by: Dominique Martinet

    Jean-Philippe Brucker
     
  • We should return -ENOMEM to upper user when kmalloc failed to indicate
    accurate errno.

    Link: http://lkml.kernel.org/r/5B4552C5.60000@huawei.com
    Signed-off-by: Jun Piao
    Reviewed-by: Yiwen Jiang
    Reviewed-by: Andrew Morton
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Andrew Morton
    Signed-off-by: Dominique Martinet

    piaojun
     
  • In p9_client_getattr_dotl(), we should add '\n' at the end of printing
    log.

    Link: http://lkml.kernel.org/r/5B44589A.50302@huawei.com
    Signed-off-by: Jun Piao
    Reviewed-by: Yiwen Jiang
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Andrew Morton
    Signed-off-by: Dominique Martinet

    piaojun
     

09 Aug, 2018

1 commit


25 Jul, 2018

1 commit


15 Jul, 2018

1 commit

  • In my testing, the second mount will fail after umounting successfully.
    The reason is that we put refcount of trans_mod in the correct case
    rather than the error case in parse_opts() at last. That will cause the
    refcount decrease to -1, and when we try to get trans_mod again in
    try_module_get(), we could only increase refcount to 0 which will cause
    failure as follows:

    parse_opts
    v9fs_get_trans_by_name
    try_module_get : return NULL to caller which cause error

    So we should put refcount of trans_mod in error case.

    Link: http://lkml.kernel.org/r/5B3F39A0.2030509@huawei.com
    Fixes: 9421c3e64137ec ("net/9p/client.c: fix potential refcnt problem of trans module")
    Signed-off-by: Jun Piao
    Reviewed-by: Yiwen Jiang
    Reviewed-by: Greg Kurz
    Reviewed-by: Dominique Martinet
    Tested-by: Dominique Martinet
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    piaojun
     

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
     

08 Jun, 2018

2 commits

  • rwlock.h should not be included directly. Instead linux/splinlock.h
    should be included. One thing it does is to break the RT build.

    Link: http://lkml.kernel.org/r/20180504100319.11880-1-bigeasy@linutronix.de
    Signed-off-by: Sebastian Andrzej Siewior
    Reviewed-by: Andrew Morton
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Sebastian Andrzej Siewior
     
  • Currently when detecting invalid options in option parsing, some
    options(e.g. msize) just set errno and allow to continuously validate
    other options so that it can detect invalid options as much as possible
    and give proper error messages together.

    This patch applies same rule to option 'trans' and 'version' when
    detecting -EINVAL.

    Link: http://lkml.kernel.org/r/1525340676-34072-1-git-send-email-cgxu519@gmx.com
    Signed-off-by: Chengguang Xu
    Reviewed-by: Andrew Morton
    Cc: Eric Van Hensbergen
    Cc: Ron Minnich
    Cc: Latchesar Ionkov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Chengguang Xu
     

07 Jun, 2018

1 commit

  • Pull networking updates from David Miller:

    1) Add Maglev hashing scheduler to IPVS, from Inju Song.

    2) Lots of new TC subsystem tests from Roman Mashak.

    3) Add TCP zero copy receive and fix delayed acks and autotuning with
    SO_RCVLOWAT, from Eric Dumazet.

    4) Add XDP_REDIRECT support to mlx5 driver, from Jesper Dangaard
    Brouer.

    5) Add ttl inherit support to vxlan, from Hangbin Liu.

    6) Properly separate ipv6 routes into their logically independant
    components. fib6_info for the routing table, and fib6_nh for sets of
    nexthops, which thus can be shared. From David Ahern.

    7) Add bpf_xdp_adjust_tail helper, which can be used to generate ICMP
    messages from XDP programs. From Nikita V. Shirokov.

    8) Lots of long overdue cleanups to the r8169 driver, from Heiner
    Kallweit.

    9) Add BTF ("BPF Type Format"), from Martin KaFai Lau.

    10) Add traffic condition monitoring to iwlwifi, from Luca Coelho.

    11) Plumb extack down into fib_rules, from Roopa Prabhu.

    12) Add Flower classifier offload support to igb, from Vinicius Costa
    Gomes.

    13) Add UDP GSO support, from Willem de Bruijn.

    14) Add documentation for eBPF helpers, from Quentin Monnet.

    15) Add TLS tx offload to mlx5, from Ilya Lesokhin.

    16) Allow applications to be given the number of bytes available to read
    on a socket via a control message returned from recvmsg(), from
    Soheil Hassas Yeganeh.

    17) Add x86_32 eBPF JIT compiler, from Wang YanQing.

    18) Add AF_XDP sockets, with zerocopy support infrastructure as well.
    From Björn Töpel.

    19) Remove indirect load support from all of the BPF JITs and handle
    these operations in the verifier by translating them into native BPF
    instead. From Daniel Borkmann.

    20) Add GRO support to ipv6 gre tunnels, from Eran Ben Elisha.

    21) Allow XDP programs to do lookups in the main kernel routing tables
    for forwarding. From David Ahern.

    22) Allow drivers to store hardware state into an ELF section of kernel
    dump vmcore files, and use it in cxgb4. From Rahul Lakkireddy.

    23) Various RACK and loss detection improvements in TCP, from Yuchung
    Cheng.

    24) Add TCP SACK compression, from Eric Dumazet.

    25) Add User Mode Helper support and basic bpfilter infrastructure, from
    Alexei Starovoitov.

    26) Support ports and protocol values in RTM_GETROUTE, from Roopa
    Prabhu.

    27) Support bulking in ->ndo_xdp_xmit() API, from Jesper Dangaard
    Brouer.

    28) Add lots of forwarding selftests, from Petr Machata.

    29) Add generic network device failover driver, from Sridhar Samudrala.

    * ra.kernel.org:/pub/scm/linux/kernel/git/davem/net-next: (1959 commits)
    strparser: Add __strp_unpause and use it in ktls.
    rxrpc: Fix terminal retransmission connection ID to include the channel
    net: hns3: Optimize PF CMDQ interrupt switching process
    net: hns3: Fix for VF mailbox receiving unknown message
    net: hns3: Fix for VF mailbox cannot receiving PF response
    bnx2x: use the right constant
    Revert "net: sched: cls: Fix offloading when ingress dev is vxlan"
    net: dsa: b53: Fix for brcm tag issue in Cygnus SoC
    enic: fix UDP rss bits
    netdev-FAQ: clarify DaveM's position for stable backports
    rtnetlink: validate attributes in do_setlink()
    mlxsw: Add extack messages for port_{un, }split failures
    netdevsim: Add extack error message for devlink reload
    devlink: Add extack to reload and port_{un, }split operations
    net: metrics: add proper netlink validation
    ipmr: fix error path when ipmr_new_table fails
    ip6mr: only set ip6mr_table from setsockopt when ip6mr_new_table succeeds
    net: hns3: remove unused hclgevf_cfg_func_mta_filter
    netfilter: provide udp*_lib_lookup for nf_tproxy
    qed*: Utilize FW 8.37.2.0
    ...

    Linus Torvalds
     

05 Jun, 2018

1 commit

  • Pull aio updates from Al Viro:
    "Majority of AIO stuff this cycle. aio-fsync and aio-poll, mostly.

    The only thing I'm holding back for a day or so is Adam's aio ioprio -
    his last-minute fixup is trivial (missing stub in !CONFIG_BLOCK case),
    but let it sit in -next for decency sake..."

    * 'work.aio-1' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (46 commits)
    aio: sanitize the limit checking in io_submit(2)
    aio: fold do_io_submit() into callers
    aio: shift copyin of iocb into io_submit_one()
    aio_read_events_ring(): make a bit more readable
    aio: all callers of aio_{read,write,fsync,poll} treat 0 and -EIOCBQUEUED the same way
    aio: take list removal to (some) callers of aio_complete()
    aio: add missing break for the IOCB_CMD_FDSYNC case
    random: convert to ->poll_mask
    timerfd: convert to ->poll_mask
    eventfd: switch to ->poll_mask
    pipe: convert to ->poll_mask
    crypto: af_alg: convert to ->poll_mask
    net/rxrpc: convert to ->poll_mask
    net/iucv: convert to ->poll_mask
    net/phonet: convert to ->poll_mask
    net/nfc: convert to ->poll_mask
    net/caif: convert to ->poll_mask
    net/bluetooth: convert to ->poll_mask
    net/sctp: convert to ->poll_mask
    net/tipc: convert to ->poll_mask
    ...

    Linus Torvalds
     

03 Jun, 2018

2 commits

  • Filling in the padding slot in the bpf structure as a bug fix in 'ne'
    overlapped with actually using that padding area for something in
    'net-next'.

    Signed-off-by: David S. Miller

    David S. Miller
     
  • Pull rdma fixes from Jason Gunthorpe:
    "Just three small last minute regressions that were found in the last
    week. The Broadcom fix is a bit big for rc7, but since it is fixing
    driver crash regressions that were merged via netdev into rc1, I am
    sending it.

    - bnxt netdev changes merged this cycle caused the bnxt RDMA driver
    to crash under certain situations

    - Arnd found (several, unfortunately) kconfig problems with the
    patches adding INFINIBAND_ADDR_TRANS. Reverting this last part,
    will fix it more fully outside -rc.

    - Subtle change in error code for a uapi function caused breakage in
    userspace. This was bug was subtly introduced cycle"

    * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
    IB/core: Fix error code for invalid GID entry
    IB: Revert "remove redundant INFINIBAND kconfig dependencies"
    RDMA/bnxt_re: Fix broken RoCE driver due to recent L2 driver changes

    Linus Torvalds
     

29 May, 2018

1 commit

  • Several subsystems depend on INFINIBAND_ADDR_TRANS, which in turn depends
    on INFINIBAND. However, when with CONFIG_INIFIBAND=m, this leads to a
    link error when another driver using it is built-in. The
    INFINIBAND_ADDR_TRANS dependency is insufficient here as this is
    a 'bool' symbol that does not force anything to be a module in turn.

    fs/cifs/smbdirect.o: In function `smbd_disconnect_rdma_work':
    smbdirect.c:(.text+0x1e4): undefined reference to `rdma_disconnect'
    net/9p/trans_rdma.o: In function `rdma_request':
    trans_rdma.c:(.text+0x7bc): undefined reference to `rdma_disconnect'
    net/9p/trans_rdma.o: In function `rdma_destroy_trans':
    trans_rdma.c:(.text+0x830): undefined reference to `ib_destroy_qp'
    trans_rdma.c:(.text+0x858): undefined reference to `ib_dealloc_pd'

    Fixes: 9533b292a7ac ("IB: remove redundant INFINIBAND kconfig dependencies")
    Signed-off-by: Arnd Bergmann
    Acked-by: Greg Thelen
    Signed-off-by: Jason Gunthorpe

    Arnd Bergmann
     

27 May, 2018

1 commit


26 May, 2018

1 commit


25 May, 2018

1 commit

  • Pull rdma fixes from Jason Gunthorpe:
    "This is pretty much just the usual array of smallish driver bugs.

    - remove bouncing addresses from the MAINTAINERS file

    - kernel oops and bad error handling fixes for hfi, i40iw, cxgb4, and
    hns drivers

    - various small LOC behavioral/operational bugs in mlx5, hns, qedr
    and i40iw drivers

    - two fixes for patches already sent during the merge window

    - a long-standing bug related to not decreasing the pinned pages
    count in the right MM was found and fixed"

    * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: (28 commits)
    RDMA/hns: Move the location for initializing tmp_len
    RDMA/hns: Bugfix for cq record db for kernel
    IB/uverbs: Fix uverbs_attr_get_obj
    RDMA/qedr: Fix doorbell bar mapping for dpi > 1
    IB/umem: Use the correct mm during ib_umem_release
    iw_cxgb4: Fix an error handling path in 'c4iw_get_dma_mr()'
    RDMA/i40iw: Avoid panic when reading back the IRQ affinity hint
    RDMA/i40iw: Avoid reference leaks when processing the AEQ
    RDMA/i40iw: Avoid panic when objects are being created and destroyed
    RDMA/hns: Fix the bug with NULL pointer
    RDMA/hns: Set NULL for __internal_mr
    RDMA/hns: Enable inner_pa_vld filed of mpt
    RDMA/hns: Set desc_dma_addr for zero when free cmq desc
    RDMA/hns: Fix the bug with rq sge
    RDMA/hns: Not support qp transition from reset to reset for hip06
    RDMA/hns: Add return operation when configured global param fail
    RDMA/hns: Update convert function of endian format
    RDMA/hns: Load the RoCE dirver automatically
    RDMA/hns: Bugfix for rq record db for kernel
    RDMA/hns: Add rq inline flags judgement
    ...

    Linus Torvalds
     

12 May, 2018

1 commit

  • The bpf syscall and selftests conflicts were trivial
    overlapping changes.

    The r8169 change involved moving the added mdelay from 'net' into a
    different function.

    A TLS close bug fix overlapped with the splitting of the TLS state
    into separate TX and RX parts. I just expanded the tests in the bug
    fix from "ctx->conf == X" into "ctx->tx_conf == X && ctx->rx_conf
    == X".

    Signed-off-by: David S. Miller

    David S. Miller
     

11 May, 2018

1 commit