18 Nov, 2017

1 commit


25 Jan, 2017

1 commit

  • After removing sunrpc module, I get many kmemleak information as,
    unreferenced object 0xffff88003316b1e0 (size 544):
    comm "gssproxy", pid 2148, jiffies 4294794465 (age 4200.081s)
    hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
    backtrace:
    [] kmemleak_alloc+0x4a/0xa0
    [] kmem_cache_alloc+0x15e/0x1f0
    [] ida_pre_get+0xaa/0x150
    [] ida_simple_get+0xad/0x180
    [] nlmsvc_lookup_host+0x4ab/0x7f0 [lockd]
    [] lockd+0x4d/0x270 [lockd]
    [] param_set_timeout+0x55/0x100 [lockd]
    [] svc_defer+0x114/0x3f0 [sunrpc]
    [] svc_defer+0x2d7/0x3f0 [sunrpc]
    [] rpc_show_info+0x8a/0x110 [sunrpc]
    [] proc_reg_write+0x7f/0xc0
    [] __vfs_write+0xdf/0x3c0
    [] vfs_write+0xef/0x240
    [] SyS_write+0xad/0x130
    [] entry_SYSCALL_64_fastpath+0x1a/0xa9
    [] 0xffffffffffffffff

    I found, the ida information (dynamic memory) isn't cleanup.

    Signed-off-by: Kinglong Mee
    Fixes: 2f048db4680a ("SUNRPC: Add an identifier for struct rpc_clnt")
    Cc: stable@vger.kernel.org # v3.12+
    Signed-off-by: Trond Myklebust

    Kinglong Mee
     

18 Nov, 2016

1 commit

  • Make struct pernet_operations::id unsigned.

    There are 2 reasons to do so:

    1)
    This field is really an index into an zero based array and
    thus is unsigned entity. Using negative value is out-of-bound
    access by definition.

    2)
    On x86_64 unsigned 32-bit data which are mixed with pointers
    via array indexing or offsets added or subtracted to pointers
    are preffered to signed 32-bit data.

    "int" being used as an array index needs to be sign-extended
    to 64-bit before being used.

    void f(long *p, int i)
    {
    g(p[i]);
    }

    roughly translates to

    movsx rsi, esi
    mov rdi, [rsi+...]
    call g

    MOVSX is 3 byte instruction which isn't necessary if the variable is
    unsigned because x86_64 is zero extending by default.

    Now, there is net_generic() function which, you guessed it right, uses
    "int" as an array index:

    static inline void *net_generic(const struct net *net, int id)
    {
    ...
    ptr = ng->ptr[id - 1];
    ...
    }

    And this function is used a lot, so those sign extensions add up.

    Patch snipes ~1730 bytes on allyesconfig kernel (without all junk
    messing with code generation):

    add/remove: 0/0 grow/shrink: 70/598 up/down: 396/-2126 (-1730)

    Unfortunately some functions actually grow bigger.
    This is a semmingly random artefact of code generation with register
    allocator being used differently. gcc decides that some variable
    needs to live in new r8+ registers and every access now requires REX
    prefix. Or it is shifted into r12, so [r12+0] addressing mode has to be
    used which is longer than [r8]

    However, overall balance is in negative direction:

    add/remove: 0/0 grow/shrink: 70/598 up/down: 396/-2126 (-1730)
    function old new delta
    nfsd4_lock 3886 3959 +73
    tipc_link_build_proto_msg 1096 1140 +44
    mac80211_hwsim_new_radio 2776 2808 +32
    tipc_mon_rcv 1032 1058 +26
    svcauth_gss_legacy_init 1413 1429 +16
    tipc_bcbase_select_primary 379 392 +13
    nfsd4_exchange_id 1247 1260 +13
    nfsd4_setclientid_confirm 782 793 +11
    ...
    put_client_renew_locked 494 480 -14
    ip_set_sockfn_get 730 716 -14
    geneve_sock_add 829 813 -16
    nfsd4_sequence_done 721 703 -18
    nlmclnt_lookup_host 708 686 -22
    nfsd4_lockt 1085 1063 -22
    nfs_get_client 1077 1050 -27
    tcf_bpf_init 1106 1076 -30
    nfsd4_encode_fattr 5997 5930 -67
    Total: Before=154856051, After=154854321, chg -0.00%

    Signed-off-by: Alexey Dobriyan
    Signed-off-by: David S. Miller

    Alexey Dobriyan
     

01 Apr, 2015

1 commit

  • We currently have a problem that SELinux policy is being enforced when
    creating debugfs files. If a debugfs file is created as a side effect of
    doing some syscall, then that creation can fail if the SELinux policy
    for that process prevents it.

    This seems wrong. We don't do that for files under /proc, for instance,
    so Bruce has proposed a patch to fix that.

    While discussing that patch however, Greg K.H. stated:

    "No kernel code should care / fail if a debugfs function fails, so
    please fix up the sunrpc code first."

    This patch converts all of the sunrpc debugfs setup code to be void
    return functins, and the callers to not look for errors from those
    functions.

    This should allow rpc_clnt and rpc_xprt creation to work, even if the
    kernel fails to create debugfs files for some reason.

    Symptoms were failing krb5 mounts on systems using gss-proxy and
    selinux.

    Fixes: 388f0c776781 "sunrpc: add a debugfs rpc_xprt directory..."
    Cc: stable@vger.kernel.org
    Signed-off-by: Jeff Layton
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: J. Bruce Fields

    Jeff Layton
     

28 Nov, 2014

1 commit

  • It's possible to get a dump of the RPC task queue by writing a value to
    /proc/sys/sunrpc/rpc_debug. If you write any value to that file, you get
    a dump of the RPC client task list into the log buffer. This is a rather
    inconvenient interface however, and makes it hard to get immediate info
    about the task queue.

    Add a new directory hierarchy under debugfs:

    sunrpc/
    rpc_clnt/
    /

    Within each clientid directory we create a new "tasks" file that will
    dump info similar to what shows up in the log buffer, but with a few
    small differences -- we avoid printing raw kernel addresses in favor of
    symbolic names and the XID is also displayed.

    Signed-off-by: Jeff Layton
    Signed-off-by: Trond Myklebust

    Jeff Layton
     

25 Nov, 2014

1 commit


07 Dec, 2013

1 commit

  • rpc.gssd will naturally hold open any pipe named */clnt*/gssd that shows
    up under rpc_pipefs. That behavior gives us a reliable mechanism to tell
    whether it's actually running or not.

    Create a new toplevel "gssd" directory in rpc_pipefs when it's mounted.
    Under that directory create another directory called "clntXX", and then
    within that a pipe called "gssd".

    We'll never send an upcall along that pipe, and any downcall written to
    it will just return -EINVAL.

    Signed-off-by: Jeff Layton
    Signed-off-by: Trond Myklebust

    Jeff Layton
     

18 Apr, 2012

1 commit

  • PipeFS superblock creation routine relays on SUNRPC pernet data presense, which
    is created on register_pernet_subsys() call in SUNRPC module init function.
    Registering of PipeFS filesystem prior to registering of per-net subsystem
    leads to races (mount of PipeFS can dereference uninitialized data).

    Signed-off-by: Stanislav Kinsbursky
    Signed-off-by: Trond Myklebust

    Stanislav Kinsbursky
     

12 Mar, 2012

1 commit

  • net/sunrpc/svcsock.c:412:22: warning: incorrect type in assignment
    (different address spaces)
    - svc_partial_recvfrom now takes a struct kvec, so the variable
    save_iovbase needs to be an ordinary (void *)

    Make a bunch of variables in net/sunrpc/xprtsock.c static

    Fix a couple of "warning: symbol 'foo' was not declared. Should it be
    static?" reports.

    Fix a couple of conflicting function declarations.

    Signed-off-by: Trond Myklebust

    Trond Myklebust
     

17 Feb, 2012

1 commit


01 Feb, 2012

4 commits

  • This patch makes GSS auth cache details allocated and registered per network
    namespace context.
    Thus with this patch rsi_cache and rsc_cache contents for network namespace "X"
    are controlled from proc file system mount for the same network namespace "X".

    Signed-off-by: Stanislav Kinsbursky
    Signed-off-by: Trond Myklebust
    Acked-by: J. Bruce Fields

    Stanislav Kinsbursky
     
  • v2:
    1) fixed silly usage of template cache as a real one (this code left from
    static global cache for all)

    This patch makes unix_gid_cache cache detail allocated and registered per
    network namespace context.
    Thus with this patch unix_gid_cache contents for network namespace "X" are
    controlled from proc file system mount for the same network namespace "X".

    Signed-off-by: Stanislav Kinsbursky
    Signed-off-by: Trond Myklebust
    Acked-by: J. Bruce Fields

    Stanislav Kinsbursky
     
  • This patch moves static SUNRPC clients list and it's lock to sunrpc_net
    structure.
    Currently this list is used only for debug purposes. But later it will be used
    also for selecting clients by networks namespace on PipeFS mount/umount events.
    Per-network namespace lists will make this faster and simplier.

    Note: client list is taken from "init_net" network namespace context in
    rpc_show_tasks(). This will be changed some day later with making SUNRPC
    sysctl's per network namespace context.

    Signed-off-by: Stanislav Kinsbursky
    Signed-off-by: Trond Myklebust

    Stanislav Kinsbursky
     
  • During per-net pipes creation and destruction we have to make sure, that pipefs
    sb exists for the whole creation/destruction cycle. This is done by using
    special mutex which controls pipefs sb reference on network namespace context.
    Helper consists of two parts: first of them (rpc_get_dentry_net) searches for
    dentry with specified name and returns with mutex taken on success. When pipe
    creation or destructions is completed, caller should release this mutex by
    rpc_put_dentry_net call.

    Signed-off-by: Stanislav Kinsbursky
    Signed-off-by: Trond Myklebust

    Stanislav Kinsbursky
     

25 Oct, 2011

1 commit


27 Sep, 2010

3 commits


08 Aug, 2010

1 commit

  • * 'for-2.6.36' of git://linux-nfs.org/~bfields/linux: (34 commits)
    nfsd4: fix file open accounting for RDWR opens
    nfsd: don't allow setting maxblksize after svc created
    nfsd: initialize nfsd versions before creating svc
    net: sunrpc: removed duplicated #include
    nfsd41: Fix a crash when a callback is retried
    nfsd: fix startup/shutdown order bug
    nfsd: minor nfsd read api cleanup
    gcc-4.6: nfsd: fix initialized but not read warnings
    nfsd4: share file descriptors between stateid's
    nfsd4: fix openmode checking on IO using lock stateid
    nfsd4: miscellaneous process_open2 cleanup
    nfsd4: don't pretend to support write delegations
    nfsd: bypass readahead cache when have struct file
    nfsd: minor nfsd_svc() cleanup
    nfsd: move more into nfsd_startup()
    nfsd: just keep single lockd reference for nfsd
    nfsd: clean up nfsd_create_serv error handling
    nfsd: fix error handling in __write_ports_addxprt
    nfsd: fix error handling when starting nfsd with rpcbind down
    nfsd4: fix v4 state shutdown error paths
    ...

    Linus Torvalds
     

04 Aug, 2010

1 commit


07 Jul, 2010

1 commit

  • This patch makes the cache_cleaner workqueue deferrable, to prevent
    unnecessary system wake-ups, which is very important for embedded
    battery-powered devices.

    do_cache_clean() is called every 30 seconds at the moment, and often
    makes the system wake up from its power-save sleep state. With this
    change, when the workqueue uses a deferrable timer, the
    do_cache_clean() invocation will be delayed and combined with the
    closest "real" wake-up. This improves the power consumption situation.

    Note, I tried to create a DECLARE_DELAYED_WORK_DEFERRABLE() helper
    macro, similar to DECLARE_DELAYED_WORK(), but failed because of the
    way the timer wheel core stores the deferrable flag (it is the
    LSBit in the time->base pointer). My attempt to define a static
    variable with this bit set ended up with the "initializer element is
    not constant" error.

    Thus, I have to use run-time initialization, so I created a new
    cache_initialize() function which is called once when sunrpc is
    being initialized.

    Signed-off-by: Artem Bityutskiy
    Signed-off-by: J. Bruce Fields

    Artem Bityutskiy
     

04 Dec, 2009

1 commit

  • The kernel's rpcbind client creates and deletes an rpc_clnt and its
    underlying transport socket for every upcall to the local rpcbind
    daemon.

    When starting a typical NFS server on IPv4 and IPv6, the NFS service
    itself does three upcalls (one per version) times two upcalls (one
    per transport) times two upcalls (one per address family), making 12,
    plus another one for the initial call to unregister previous NFS
    services. Starting the NLM service adds an additional 13 upcalls,
    for similar reasons.

    (Currently the NFS service doesn't start IPv6 listeners, but it will
    soon enough).

    Instead, let's create an rpc_clnt for rpcbind upcalls during the
    first local rpcbind query, and cache it. This saves the overhead of
    creating and destroying an rpc_clnt and a socket for every upcall.

    The new logic also prevents the kernel from attempting an RPCB_SET or
    RPCB_UNSET if it knows from the start that the local portmapper does
    not support rpcbind protocol version 4. This will cut down on the
    number of rpcbind upcalls in legacy environments.

    Signed-off-by: Chuck Lever

    Chuck Lever
     

21 Aug, 2009

1 commit


27 Jun, 2009

1 commit

  • The sunrpc module uses rcu_call() thus it should use rcu_barrier() on
    module unload.

    Have not verified that the possibility for new call_rcu() callbacks
    has been disabled. As a hint for checking, the functions calling
    call_rcu() (unx_destroy_cred and generic_destroy_cred) are
    registered as crdestroy function pointer in struct rpc_credops.

    Acked-by: Paul E. McKenney
    Acked-by: Trond Myklebust
    Signed-off-by: Jesper Dangaard Brouer
    Signed-off-by: David S. Miller

    Jesper Dangaard Brouer
     

02 Feb, 2008

4 commits


30 Jan, 2008

1 commit


10 Oct, 2007

1 commit


11 Jul, 2007

6 commits


15 May, 2007

1 commit

  • - net/sunrpc/xprtsock.c:1635:5: warning: symbol 'init_socket_xprt' was not
    declared. Should it be static?
    - net/sunrpc/xprtsock.c:1649:6: warning: symbol 'cleanup_socket_xprt' was
    not declared. Should it be static?

    Signed-off-by: Trond Myklebust

    Trond Myklebust
     

10 May, 2007

1 commit

  • register_rpc_pipefs() needs to clean up rpc_inode_cache
    by kmem_cache_destroy() on register_filesystem() failure.

    init_sunrpc() needs to unregister rpc_pipe_fs by unregister_rpc_pipefs()
    when rpc_init_mempool() returns error.

    Signed-off-by: Akinobu Mita
    Cc: Neil Brown
    Cc: Trond Myklebust
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Akinobu Mita
     

15 Feb, 2007

2 commits

  • After Al Viro (finally) succeeded in removing the sched.h #include in module.h
    recently, it makes sense again to remove other superfluous sched.h includes.
    There are quite a lot of files which include it but don't actually need
    anything defined in there. Presumably these includes were once needed for
    macros that used to live in sched.h, but moved to other header files in the
    course of cleaning it up.

    To ease the pain, this time I did not fiddle with any header files and only
    removed #includes from .c-files, which tend to cause less trouble.

    Compile tested against 2.6.20-rc2 and 2.6.20-rc2-mm2 (with offsets) on alpha,
    arm, i386, ia64, mips, powerpc, and x86_64 with allnoconfig, defconfig,
    allmodconfig, and allyesconfig as well as a few randconfigs on x86_64 and all
    configs in arch/arm/configs on arm. I also checked that no new warnings were
    introduced by the patch (actually, some warnings are removed that were emitted
    by unnecessarily included header files).

    Signed-off-by: Tim Schmielau
    Acked-by: Russell King
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tim Schmielau
     
  • AUTH_UNIX authentication (the standard with NFS) has a limit of 16 groups ids.
    This causes problems for people in more than 16 groups.

    So allow the server to map a uid into a list of group ids based on local
    knowledge rather depending on the (possibly truncated) list from the client.

    If there is no process on the server responding to upcalls, the gidlist in the
    request will still be used.

    Signed-off-by: Neil Brown
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    NeilBrown