08 Aug, 2020

2 commits

  • Merge misc updates from Andrew Morton:

    - a few MM hotfixes

    - kthread, tools, scripts, ntfs and ocfs2

    - some of MM

    Subsystems affected by this patch series: kthread, tools, scripts, ntfs,
    ocfs2 and mm (hofixes, pagealloc, slab-generic, slab, slub, kcsan,
    debug, pagecache, gup, swap, shmem, memcg, pagemap, mremap, mincore,
    sparsemem, vmalloc, kasan, pagealloc, hugetlb and vmscan).

    * emailed patches from Andrew Morton : (162 commits)
    mm: vmscan: consistent update to pgrefill
    mm/vmscan.c: fix typo
    khugepaged: khugepaged_test_exit() check mmget_still_valid()
    khugepaged: retract_page_tables() remember to test exit
    khugepaged: collapse_pte_mapped_thp() protect the pmd lock
    khugepaged: collapse_pte_mapped_thp() flush the right range
    mm/hugetlb: fix calculation of adjust_range_if_pmd_sharing_possible
    mm: thp: replace HTTP links with HTTPS ones
    mm/page_alloc: fix memalloc_nocma_{save/restore} APIs
    mm/page_alloc.c: skip setting nodemask when we are in interrupt
    mm/page_alloc: fallbacks at most has 3 elements
    mm/page_alloc: silence a KASAN false positive
    mm/page_alloc.c: remove unnecessary end_bitidx for [set|get]_pfnblock_flags_mask()
    mm/page_alloc.c: simplify pageblock bitmap access
    mm/page_alloc.c: extract the common part in pfn_to_bitidx()
    mm/page_alloc.c: replace the definition of NR_MIGRATETYPE_BITS with PB_migratetype_bits
    mm/shuffle: remove dynamic reconfiguration
    mm/memory_hotplug: document why shuffle_zone() is relevant
    mm/page_alloc: remove nr_free_pagecache_pages()
    mm: remove vm_total_pages
    ...

    Linus Torvalds
     
  • As said by Linus:

    A symmetric naming is only helpful if it implies symmetries in use.
    Otherwise it's actively misleading.

    In "kzalloc()", the z is meaningful and an important part of what the
    caller wants.

    In "kzfree()", the z is actively detrimental, because maybe in the
    future we really _might_ want to use that "memfill(0xdeadbeef)" or
    something. The "zero" part of the interface isn't even _relevant_.

    The main reason that kzfree() exists is to clear sensitive information
    that should not be leaked to other future users of the same memory
    objects.

    Rename kzfree() to kfree_sensitive() to follow the example of the recently
    added kvfree_sensitive() and make the intention of the API more explicit.
    In addition, memzero_explicit() is used to clear the memory to make sure
    that it won't get optimized away by the compiler.

    The renaming is done by using the command sequence:

    git grep -w --name-only kzfree |\
    xargs sed -i 's/kzfree/kfree_sensitive/'

    followed by some editing of the kfree_sensitive() kerneldoc and adding
    a kzfree backward compatibility macro in slab.h.

    [akpm@linux-foundation.org: fs/crypto/inline_crypt.c needs linux/slab.h]
    [akpm@linux-foundation.org: fix fs/crypto/inline_crypt.c some more]

    Suggested-by: Joe Perches
    Signed-off-by: Waiman Long
    Signed-off-by: Andrew Morton
    Acked-by: David Howells
    Acked-by: Michal Hocko
    Acked-by: Johannes Weiner
    Cc: Jarkko Sakkinen
    Cc: James Morris
    Cc: "Serge E. Hallyn"
    Cc: Joe Perches
    Cc: Matthew Wilcox
    Cc: David Rientjes
    Cc: Dan Carpenter
    Cc: "Jason A . Donenfeld"
    Link: http://lkml.kernel.org/r/20200616154311.12314-3-longman@redhat.com
    Signed-off-by: Linus Torvalds

    Waiman Long
     

03 Aug, 2020

1 commit


24 Jun, 2020

1 commit

  • Use array_size() instead of the open-coded version in the controlling
    expression of the if statement.

    Also, while there, use the preferred form for passing a size of a struct.
    The alternative form where struct name is spelled out hurts readability
    and introduces an opportunity for a bug when the pointer variable type is
    changed but the corresponding sizeof that is passed as argument is not.

    This issue was found with the help of Coccinelle and, audited and fixed
    manually.

    Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83
    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Steve French
    Reviewed-by: Aurelien Aptel
    Reviewed-by: Kees Cook
    Signed-off-by: Steve French

    Gustavo A. R. Silva
     

01 Jun, 2020

2 commits

  • Use pr_fmt to standardize all logging for fs/cifs.

    Some logging output had no CIFS: specific prefix.

    Now all output has one of three prefixes:

    o CIFS:
    o CIFS: VFS:
    o Root-CIFS:

    Miscellanea:

    o Convert printks to pr_
    o Neaten macro definitions
    o Remove embedded CIFS: prefixes from formats
    o Convert "illegal" to "invalid"
    o Coalesce formats
    o Add missing '\n' format terminations
    o Consolidate multiple cifs_dbg continuations into single calls
    o More consistent use of upper case first word output logging
    o Multiline statement argument alignment and wrapping

    Signed-off-by: Joe Perches
    Signed-off-by: Steve French

    Joe Perches
     
  • In order to support reconnect to hostnames that resolve to same ip
    address, besides relying on the currently set hostname to match DFS
    targets, attempt to resolve the targets and then match their addresses
    with the reconnected server ip address.

    For instance, if we have two hostnames "FOO" and "BAR", and both
    resolve to the same ip address, we would be able to handle failover in
    DFS paths like

    \\FOO\dfs\link1 -> [ \BAZ\share2 (*), \BAR\share1 ]
    \\FOO\dfs\link2 -> [ \BAZ\share2 (*), \FOO\share1 ]

    so when "BAZ" is no longer accessible, link1 and link2 would get
    reconnected despite having different target hostnames.

    Signed-off-by: Paulo Alcantara (SUSE)
    Reviewed-by: Aurelien Aptel
    Signed-off-by: Steve French

    Paulo Alcantara
     

23 Apr, 2020

1 commit

  • This patch is basically fixing the lookup of tcons (DFS specific) during
    reconnect (smb2pdu.c:__smb2_reconnect) to update their prefix paths.

    Previously, we relied on the TCP_Server_Info pointer
    (misc.c:tcp_super_cb) to determine which tcon to update the prefix path

    We could not rely on TCP server pointer to determine which super block
    to update the prefix path when reconnecting tcons since it might map
    to different tcons that share same TCP connection.

    Instead, walk through all cifs super blocks and compare their DFS full
    paths with the tcon being updated to.

    Signed-off-by: Paulo Alcantara (SUSE)
    Signed-off-by: Steve French
    Reviewed-by: Ronnie Sahlberg

    Paulo Alcantara
     

23 Mar, 2020

1 commit

  • For the case where we have a DFS path like below and we're currently
    connected to targetA:

    //dfsroot/link -> //targetA/share/foo, //targetB/share/bar

    after failover, we should make sure to update cifs_sb->prepath so the
    next operations will use the new prefix path "/bar".

    Besides, in order to simplify the use of different prefix paths,
    enforce CIFS_MOUNT_USE_PREFIX_PATH for DFS mounts so we don't have to
    revalidate the root dentry every time we set a new prefix path.

    Signed-off-by: Paulo Alcantara (SUSE)
    Acked-by: Ronnie Sahlberg
    Reviewed-by: Aurelien Aptel
    Signed-off-by: Steve French

    Paulo Alcantara (SUSE)
     

25 Nov, 2019

1 commit

  • Currenly we doesn't assume that a server may break a lease
    from RWH to RW which causes us setting a wrong lease state
    on a file and thus mistakenly flushing data and byte-range
    locks and purging cached data on the client. This leads to
    performance degradation because subsequent IOs go directly
    to the server.

    Fix this by propagating new lease state and epoch values
    to the oplock break handler through cifsFileInfo structure
    and removing the use of cifsInodeInfo flags for that. It
    allows to avoid some races of several lease/oplock breaks
    using those flags in parallel.

    Signed-off-by: Pavel Shilovsky
    Signed-off-by: Steve French

    Pavel Shilovsky
     

28 Aug, 2019

1 commit

  • Using strscpy is cleaner, and avoids some problems with
    handling maximum length strings. Linus noticed the
    original problem and Aurelien pointed out some additional
    problems. Fortunately most of this is SMB1 code (and
    in particular the ASCII string handling older, which
    is less common).

    Reported-by: Linus Torvalds
    Reviewed-by: Aurelien Aptel
    Signed-off-by: Ronnie Sahlberg
    Signed-off-by: Steve French

    Ronnie Sahlberg
     

08 Jul, 2019

1 commit


07 May, 2019

1 commit

  • Pull crypto update from Herbert Xu:
    "API:
    - Add support for AEAD in simd
    - Add fuzz testing to testmgr
    - Add panic_on_fail module parameter to testmgr
    - Use per-CPU struct instead multiple variables in scompress
    - Change verify API for akcipher

    Algorithms:
    - Convert x86 AEAD algorithms over to simd
    - Forbid 2-key 3DES in FIPS mode
    - Add EC-RDSA (GOST 34.10) algorithm

    Drivers:
    - Set output IV with ctr-aes in crypto4xx
    - Set output IV in rockchip
    - Fix potential length overflow with hashing in sun4i-ss
    - Fix computation error with ctr in vmx
    - Add SM4 protected keys support in ccree
    - Remove long-broken mxc-scc driver
    - Add rfc4106(gcm(aes)) cipher support in cavium/nitrox"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (179 commits)
    crypto: ccree - use a proper le32 type for le32 val
    crypto: ccree - remove set but not used variable 'du_size'
    crypto: ccree - Make cc_sec_disable static
    crypto: ccree - fix spelling mistake "protedcted" -> "protected"
    crypto: caam/qi2 - generate hash keys in-place
    crypto: caam/qi2 - fix DMA mapping of stack memory
    crypto: caam/qi2 - fix zero-length buffer DMA mapping
    crypto: stm32/cryp - update to return iv_out
    crypto: stm32/cryp - remove request mutex protection
    crypto: stm32/cryp - add weak key check for DES
    crypto: atmel - remove set but not used variable 'alg_name'
    crypto: picoxcell - Use dev_get_drvdata()
    crypto: crypto4xx - get rid of redundant using_sd variable
    crypto: crypto4xx - use sync skcipher for fallback
    crypto: crypto4xx - fix cfb and ofb "overran dst buffer" issues
    crypto: crypto4xx - fix ctr-aes missing output IV
    crypto: ecrdsa - select ASN1 and OID_REGISTRY for EC-RDSA
    crypto: ux500 - use ccflags-y instead of CFLAGS_.o
    crypto: ccree - handle tee fips error during power management resume
    crypto: ccree - add function to handle cryptocell tee fips error
    ...

    Linus Torvalds
     

25 Apr, 2019

2 commits

  • The flags field in 'struct shash_desc' never actually does anything.
    The only ostensibly supported flag is CRYPTO_TFM_REQ_MAY_SLEEP.
    However, no shash algorithm ever sleeps, making this flag a no-op.

    With this being the case, inevitably some users who can't sleep wrongly
    pass MAY_SLEEP. These would all need to be fixed if any shash algorithm
    actually started sleeping. For example, the shash_ahash_*() functions,
    which wrap a shash algorithm with the ahash API, pass through MAY_SLEEP
    from the ahash API to the shash API. However, the shash functions are
    called under kmap_atomic(), so actually they're assumed to never sleep.

    Even if it turns out that some users do need preemption points while
    hashing large buffers, we could easily provide a helper function
    crypto_shash_update_large() which divides the data into smaller chunks
    and calls crypto_shash_update() and cond_resched() for each chunk. It's
    not necessary to have a flag in 'struct shash_desc', nor is it necessary
    to make individual shash algorithms aware of this at all.

    Therefore, remove shash_desc::flags, and document that the
    crypto_shash_*() functions can be called from any context.

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     
  • CIFS can leak pages reference gotten through GUP (get_user_pages*()
    through iov_iter_get_pages()). This happen if cifs_send_async_read()
    or cifs_write_from_iter() calls fail from within __cifs_readv() and
    __cifs_writev() respectively. This patch move page unreference to
    cifs_aio_ctx_release() which will happens on all code paths this is
    all simpler to follow for correctness.

    Signed-off-by: Jérôme Glisse
    Cc: Steve French
    Cc: linux-cifs@vger.kernel.org
    Cc: samba-technical@lists.samba.org
    Cc: Alexander Viro
    Cc: linux-fsdevel@vger.kernel.org
    Cc: Linus Torvalds
    Cc: Stable
    Signed-off-by: Steve French
    Reviewed-by: Pavel Shilovsky

    Jérôme Glisse
     

16 Apr, 2019

1 commit

  • In the oplock break handler, writing pending changes from pages puts
    the FileInfo handle. If the refcount reaches zero it closes the handle
    and waits for any oplock break handler to return, thus causing a deadlock.

    To prevent this situation:

    * We add a wait flag to cifsFileInfo_put() to decide whether we should
    wait for running/pending oplock break handlers

    * We keep an additionnal reference of the SMB FileInfo handle so that
    for the rest of the handler putting the handle won't close it.
    - The ref is bumped everytime we queue the handler via the
    cifs_queue_oplock_break() helper.
    - The ref is decremented at the end of the handler

    This bug was triggered by xfstest 464.

    Also important fix to address the various reports of
    oops in smb2_push_mandatory_locks

    Signed-off-by: Aurelien Aptel
    Signed-off-by: Steve French
    Reviewed-by: Pavel Shilovsky
    CC: Stable

    Aurelien Aptel
     

29 Dec, 2018

3 commits

  • After a successful failover in cifs_reconnect(), the smb2_reconnect()
    function will make sure to reconnect every tcon to new target server.

    For SMB2+.

    Signed-off-by: Paulo Alcantara
    Signed-off-by: Aurelien Aptel
    Signed-off-by: Steve French

    Paulo Alcantara
     
  • This patch adds support for failover when failing to connect in
    cifs_mount().

    Signed-off-by: Paulo Alcantara
    Reviewed-by: Aurelien Aptel
    Signed-off-by: Steve French

    Paulo Alcantara
     
  • kzalloc can return NULL so an additional check is needed. While there
    is a check for ret_buf there is no check for the allocation of
    ret_buf->crfid.fid - this check is thus added. Both call-sites
    of tconInfoAlloc() check for NULL return of tconInfoAlloc()
    so returning NULL on failure of kzalloc() here seems appropriate.
    As the kzalloc() is the only thing here that can fail it is
    moved to the beginning so as not to initialize other resources
    on failure of kzalloc.

    Fixes: 3d4ef9a15343 ("smb3: fix redundant opens on root")

    Signed-off-by: Joe Perches
    Signed-off-by: Steve French

    Joe Perches
     

24 Dec, 2018

2 commits


02 Nov, 2018

1 commit

  • Pull AFS updates from Al Viro:
    "AFS series, with some iov_iter bits included"

    * 'work.afs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (26 commits)
    missing bits of "iov_iter: Separate type from direction and use accessor functions"
    afs: Probe multiple fileservers simultaneously
    afs: Fix callback handling
    afs: Eliminate the address pointer from the address list cursor
    afs: Allow dumping of server cursor on operation failure
    afs: Implement YFS support in the fs client
    afs: Expand data structure fields to support YFS
    afs: Get the target vnode in afs_rmdir() and get a callback on it
    afs: Calc callback expiry in op reply delivery
    afs: Fix FS.FetchStatus delivery from updating wrong vnode
    afs: Implement the YFS cache manager service
    afs: Remove callback details from afs_callback_break struct
    afs: Commit the status on a new file/dir/symlink
    afs: Increase to 64-bit volume ID and 96-bit vnode ID for YFS
    afs: Don't invoke the server to read data beyond EOF
    afs: Add a couple of tracepoints to log I/O errors
    afs: Handle EIO from delivery function
    afs: Fix TTL on VL server and address lists
    afs: Implement VL server rotation
    afs: Improve FS server rotation error handling
    ...

    Linus Torvalds
     

24 Oct, 2018

3 commits

  • To allow better debugging (for example applications with
    handle leaks, or complex reconnect scenarios) display the
    number of open files (on the client) and number of open
    server file handles for each tcon in /proc/fs/cifs/Stats.
    Note that open files on server is one larger than local
    due to handle caching (in this case of the root of
    the share). In this example there are two local
    open files, and three (two file and one directory handle)
    open on the server.

    Sample output:

    $ cat /proc/fs/cifs/Stats
    Resources in use
    CIFS Session: 1
    Share (unique mount targets): 2
    SMB Request/Response Buffer: 1 Pool size: 5
    SMB Small Req/Resp Buffer: 1 Pool size: 30
    Operations (MIDs): 0

    0 session 0 share reconnects
    Total vfs operations: 36 maximum at one time: 2

    1) \\localhost\test
    SMBs: 69
    Bytes read: 27 Bytes written: 0
    Open files: 2 total (local), 3 open on server
    TreeConnects: 1 total 0 failed
    TreeDisconnects: 0 total 0 failed
    Creates: 19 total 0 failed
    Closes: 16 total 0 failed
    ...

    Signed-off-by: Steve French

    Steve French
     
  • In the iov_iter struct, separate the iterator type from the iterator
    direction and use accessor functions to access them in most places.

    Convert a bunch of places to use switch-statements to access them rather
    then chains of bitwise-AND statements. This makes it easier to add further
    iterator types. Also, this can be more efficient as to implement a switch
    of small contiguous integers, the compiler can use ~50% fewer compare
    instructions than it has to use bitwise-and instructions.

    Further, cease passing the iterator type into the iterator setup function.
    The iterator function can set that itself. Only the direction is required.

    Signed-off-by: David Howells

    David Howells
     
  • Use accessor functions to access an iterator's type and direction. This
    allows for the possibility of using some other method of determining the
    type of iterator than if-chains with bitwise-AND conditions.

    Signed-off-by: David Howells

    David Howells
     

13 Sep, 2018

1 commit


08 Aug, 2018

1 commit

  • CONFIG_CIFS_STATS should always be enabled as Pavel recently
    noted. Simple statistics are not a significant performance hit,
    and removing the ifdef simplifies the code slightly.

    Signed-off-by: Steve French
    Reviewed-by: Ronnie Sahlberg
    Reviewed-by: Pavel Shilovsky

    Steve French
     

15 Jun, 2018

2 commits


13 Jun, 2018

1 commit

  • The vmalloc() function has no 2-factor argument form, so multiplication
    factors need to be wrapped in array_size(). This patch replaces cases of:

    vmalloc(a * b)

    with:
    vmalloc(array_size(a, b))

    as well as handling cases of:

    vmalloc(a * b * c)

    with:

    vmalloc(array3_size(a, b, c))

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

    vmalloc(4 * 1024)

    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 Coccinelle script used for this was:

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

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

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

    (
    vmalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    vmalloc(
    - 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;
    @@

    (
    vmalloc(
    - sizeof(TYPE) * (COUNT_ID)
    + array_size(COUNT_ID, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT_ID
    + array_size(COUNT_ID, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * (COUNT_CONST)
    + array_size(COUNT_CONST, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT_CONST
    + array_size(COUNT_CONST, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT_ID)
    + array_size(COUNT_ID, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT_ID
    + array_size(COUNT_ID, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT_CONST)
    + array_size(COUNT_CONST, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT_CONST
    + array_size(COUNT_CONST, sizeof(THING))
    , ...)
    )

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

    vmalloc(
    - SIZE * COUNT
    + array_size(COUNT, SIZE)
    , ...)

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

    (
    vmalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    vmalloc(
    - 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;
    @@

    (
    vmalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    vmalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    vmalloc(
    - 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;
    @@

    (
    vmalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    vmalloc(
    - 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;
    @@

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

    // And then all remaining 2 factors products when they're not all constants.
    @@
    expression E1, E2;
    constant C1, C2;
    @@

    (
    vmalloc(C1 * C2, ...)
    |
    vmalloc(
    - E1 * E2
    + array_size(E1, E2)
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

06 Jun, 2018

1 commit


01 Jun, 2018

1 commit


28 May, 2018

2 commits

  • and change the smb2 version to take heder_preamble_size into account
    instead of hardcoding it as 4 bytes.

    Signed-off-by: Ronnie Sahlberg
    Signed-off-by: Steve French

    Ronnie Sahlberg
     
  • In SMB2/SMB3 unlike in cifs we unnecessarily open the root of the share
    over and over again in various places during mount and path revalidation
    and also in statfs. This patch cuts redundant traffic (opens and closes)
    by simply keeping the directory handle for the root around (and reopening
    it as needed on reconnect), so query calls don't require three round
    trips to copmlete - just one, and eases load on network, client and
    server (on mount alone, cuts network traffic by more than a third).

    Also add a new cifs mount parm "nohandlecache" to allow users whose
    servers might have resource constraints (eg in case they have a server
    with so many users connecting to it that this extra handle per mount
    could possibly be a resource concern).

    Signed-off-by: Steve French
    Reviewed-by: Ronnie Sahlberg

    Steve French
     

02 Apr, 2018

1 commit

  • shash and sdesc and always allocated and freed together.
    * abstract this in new functions cifs_alloc_hash() and cifs_free_hash().
    * make smb2/3 crypto allocation independent from each other.

    Signed-off-by: Aurelien Aptel
    Signed-off-by: Steve French
    Reviewed-by: Ronnie Sahlberg
    CC: Stable

    Aurelien Aptel
     

27 Jan, 2018

1 commit


09 Jul, 2017

1 commit

  • Remove the CONFIG_CIFS_SMB2 ifdef and Kconfig option since they
    must always be on now.

    For various security reasons, SMB3 and later are STRONGLY preferred
    over CIFS and older dialects, and SMB3 (and later) will now be
    the default dialects so we do not want to allow them to be
    ifdeffed out.

    In the longer term, we may be able to make older CIFS support
    disableable in Kconfig with a new set of #ifdef, but we always
    want SMB3 and later support enabled.

    Signed-off-by: Steven French
    Reviewed-by: Pavel Shilovsky

    Steve French
     

21 Jun, 2017

1 commit

  • pages is being allocated however a null check on bv is being used
    to see if the allocation failed. Fix this by checking if pages is
    null.

    Detected by CoverityScan, CID#1432974 ("Logically dead code")

    Fixes: ccf7f4088af2dd ("CIFS: Add asynchronous context to support kernel AIO")
    Signed-off-by: Colin Ian King
    Reviewed-by: Pavel Shilovsky
    Signed-off-by: Steve French

    Colin Ian King
     

03 May, 2017

2 commits

  • When the final cifsFileInfo_put() is called from cifsiod and an oplock
    break work is queued, lockdep complains loudly:

    =============================================
    [ INFO: possible recursive locking detected ]
    4.11.0+ #21 Not tainted
    ---------------------------------------------
    kworker/0:2/78 is trying to acquire lock:
    ("cifsiod"){++++.+}, at: flush_work+0x215/0x350

    but task is already holding lock:
    ("cifsiod"){++++.+}, at: process_one_work+0x255/0x8e0

    other info that might help us debug this:
    Possible unsafe locking scenario:

    CPU0
    ----
    lock("cifsiod");
    lock("cifsiod");

    *** DEADLOCK ***

    May be due to missing lock nesting notation

    2 locks held by kworker/0:2/78:
    #0: ("cifsiod"){++++.+}, at: process_one_work+0x255/0x8e0
    #1: ((&wdata->work)){+.+...}, at: process_one_work+0x255/0x8e0

    stack backtrace:
    CPU: 0 PID: 78 Comm: kworker/0:2 Not tainted 4.11.0+ #21
    Workqueue: cifsiod cifs_writev_complete
    Call Trace:
    dump_stack+0x85/0xc2
    __lock_acquire+0x17dd/0x2260
    ? match_held_lock+0x20/0x2b0
    ? trace_hardirqs_off_caller+0x86/0x130
    ? mark_lock+0xa6/0x920
    lock_acquire+0xcc/0x260
    ? lock_acquire+0xcc/0x260
    ? flush_work+0x215/0x350
    flush_work+0x236/0x350
    ? flush_work+0x215/0x350
    ? destroy_worker+0x170/0x170
    __cancel_work_timer+0x17d/0x210
    ? ___preempt_schedule+0x16/0x18
    cancel_work_sync+0x10/0x20
    cifsFileInfo_put+0x338/0x7f0
    cifs_writedata_release+0x2a/0x40
    ? cifs_writedata_release+0x2a/0x40
    cifs_writev_complete+0x29d/0x850
    ? preempt_count_sub+0x18/0xd0
    process_one_work+0x304/0x8e0
    worker_thread+0x9b/0x6a0
    kthread+0x1b2/0x200
    ? process_one_work+0x8e0/0x8e0
    ? kthread_create_on_node+0x40/0x40
    ret_from_fork+0x31/0x40

    This is a real warning. Since the oplock is queued on the same
    workqueue this can deadlock if there is only one worker thread active
    for the workqueue (which will be the case during memory pressure when
    the rescuer thread is handling it).

    Furthermore, there is at least one other kind of hang possible due to
    the oplock break handling if there is only worker. (This can be
    reproduced without introducing memory pressure by having passing 1 for
    the max_active parameter of cifsiod.) cifs_oplock_break() can wait
    indefintely in the filemap_fdatawait() while the cifs_writev_complete()
    work is blocked:

    sysrq: SysRq : Show Blocked State
    task PC stack pid father
    kworker/0:1 D 0 16 2 0x00000000
    Workqueue: cifsiod cifs_oplock_break
    Call Trace:
    __schedule+0x562/0xf40
    ? mark_held_locks+0x4a/0xb0
    schedule+0x57/0xe0
    io_schedule+0x21/0x50
    wait_on_page_bit+0x143/0x190
    ? add_to_page_cache_lru+0x150/0x150
    __filemap_fdatawait_range+0x134/0x190
    ? do_writepages+0x51/0x70
    filemap_fdatawait_range+0x14/0x30
    filemap_fdatawait+0x3b/0x40
    cifs_oplock_break+0x651/0x710
    ? preempt_count_sub+0x18/0xd0
    process_one_work+0x304/0x8e0
    worker_thread+0x9b/0x6a0
    kthread+0x1b2/0x200
    ? process_one_work+0x8e0/0x8e0
    ? kthread_create_on_node+0x40/0x40
    ret_from_fork+0x31/0x40
    dd D 0 683 171 0x00000000
    Call Trace:
    __schedule+0x562/0xf40
    ? mark_held_locks+0x29/0xb0
    schedule+0x57/0xe0
    io_schedule+0x21/0x50
    wait_on_page_bit+0x143/0x190
    ? add_to_page_cache_lru+0x150/0x150
    __filemap_fdatawait_range+0x134/0x190
    ? do_writepages+0x51/0x70
    filemap_fdatawait_range+0x14/0x30
    filemap_fdatawait+0x3b/0x40
    filemap_write_and_wait+0x4e/0x70
    cifs_flush+0x6a/0xb0
    filp_close+0x52/0xa0
    __close_fd+0xdc/0x150
    SyS_close+0x33/0x60
    entry_SYSCALL_64_fastpath+0x1f/0xbe

    Showing all locks held in the system:
    2 locks held by kworker/0:1/16:
    #0: ("cifsiod"){.+.+.+}, at: process_one_work+0x255/0x8e0
    #1: ((&cfile->oplock_break)){+.+.+.}, at: process_one_work+0x255/0x8e0

    Showing busy workqueues and worker pools:
    workqueue cifsiod: flags=0xc
    pwq 0: cpus=0 node=0 flags=0x0 nice=0 active=1/1
    in-flight: 16:cifs_oplock_break
    delayed: cifs_writev_complete, cifs_echo_request
    pool 0: cpus=0 node=0 flags=0x0 nice=0 hung=0s workers=3 idle: 750 3

    Fix these problems by creating a a new workqueue (with a rescuer) for
    the oplock break work.

    Signed-off-by: Rabin Vincent
    Signed-off-by: Steve French
    CC: Stable

    Rabin Vincent
     
  • Currently the code doesn't recognize asynchronous calls passed
    by io_submit() and processes all calls synchronously. This is not
    what kernel AIO expects. This patch introduces a new async context
    that keeps track of all issued i/o requests and moves a response
    collecting procedure to a separate thread. This allows to return
    to a caller immediately for async calls and call iocb->ki_complete()
    once all requests are completed. For sync calls the current thread
    simply waits until all requests are completed.

    Signed-off-by: Pavel Shilovsky
    Signed-off-by: Steve French

    Pavel Shilovsky
     

28 Apr, 2017

1 commit