Skip to content
  1. Feb 20, 2019
  2. Feb 15, 2019
    • David Howells's avatar
      keys: Fix dependency loop between construction record and auth key · 822ad64d
      David Howells authored
      
      
      In the request_key() upcall mechanism there's a dependency loop by which if
      a key type driver overrides the ->request_key hook and the userspace side
      manages to lose the authorisation key, the auth key and the internal
      construction record (struct key_construction) can keep each other pinned.
      
      Fix this by the following changes:
      
       (1) Killing off the construction record and using the auth key instead.
      
       (2) Including the operation name in the auth key payload and making the
           payload available outside of security/keys/.
      
       (3) The ->request_key hook is given the authkey instead of the cons
           record and operation name.
      
      Changes (2) and (3) allow the auth key to naturally be cleaned up if the
      keyring it is in is destroyed or cleared or the auth key is unlinked.
      
      Fixes: 7ee02a316600 ("keys: Fix dependency loop between construction record and auth key")
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarJames Morris <james.morris@microsoft.com>
      822ad64d
  3. Feb 12, 2019
  4. Jan 29, 2019
  5. Jan 28, 2019
    • Yao Liu's avatar
      nfs: Fix NULL pointer dereference of dev_name · 80ff0017
      Yao Liu authored
      
      
      There is a NULL pointer dereference of dev_name in nfs_parse_devname()
      
      The oops looks something like:
      
        BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
        ...
        RIP: 0010:nfs_fs_mount+0x3b6/0xc20 [nfs]
        ...
        Call Trace:
         ? ida_alloc_range+0x34b/0x3d0
         ? nfs_clone_super+0x80/0x80 [nfs]
         ? nfs_free_parsed_mount_data+0x60/0x60 [nfs]
         mount_fs+0x52/0x170
         ? __init_waitqueue_head+0x3b/0x50
         vfs_kern_mount+0x6b/0x170
         do_mount+0x216/0xdc0
         ksys_mount+0x83/0xd0
         __x64_sys_mount+0x25/0x30
         do_syscall_64+0x65/0x220
         entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      Fix this by adding a NULL check on dev_name
      
      Signed-off-by: default avatarYao Liu <yotta.liu@ucloud.cn>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      80ff0017
  6. Jan 15, 2019
  7. Jan 02, 2019
  8. Dec 31, 2018
  9. Dec 28, 2018
  10. Dec 21, 2018
    • Chris Perl's avatar
      NFS: nfs_compare_mount_options always compare auth flavors. · 594d1644
      Chris Perl authored
      
      
      This patch removes the check from nfs_compare_mount_options to see if a
      `sec' option was passed for the current mount before comparing auth
      flavors and instead just always compares auth flavors.
      
      Consider the following scenario:
      
      You have a server with the address 192.168.1.1 and two exports /export/a
      and /export/b.  The first export supports `sys' and `krb5' security, the
      second just `sys'.
      
      Assume you start with no mounts from the server.
      
      The following results in EIOs being returned as the kernel nfs client
      incorrectly thinks it can share the underlying `struct nfs_server's:
      
      $ mkdir /tmp/{a,b}
      $ sudo mount -t nfs -o vers=3,sec=krb5 192.168.1.1:/export/a /tmp/a
      $ sudo mount -t nfs -o vers=3          192.168.1.1:/export/b /tmp/b
      $ df >/dev/null
      df: ‘/tmp/b’: Input/output error
      
      Signed-off-by: default avatarChris Perl <cperl@janestreet.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      594d1644
    • Al Viro's avatar
      LSM: new method: ->sb_add_mnt_opt() · 757cbe59
      Al Viro authored
      
      
      Adding options to growing mnt_opts.  NFS kludge with passing
      context= down into non-text-options mount switched to it, and
      with that the last use of ->sb_parse_opts_str() is gone.
      
      Reviewed-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      757cbe59
    • Al Viro's avatar
      LSM: hide struct security_mnt_opts from any generic code · 204cc0cc
      Al Viro authored
      
      
      Keep void * instead, allocate on demand (in parse_str_opts, at the
      moment).  Eventually both selinux and smack will be better off
      with private structures with several strings in those, rather than
      this "counter and two pointers to dynamically allocated arrays"
      ugliness.  This commit allows to do that at leisure, without
      disrupting anything outside of given module.
      
      Changes:
      	* instead of struct security_mnt_opt use an opaque pointer
      initialized to NULL.
      	* security_sb_eat_lsm_opts(), security_sb_parse_opts_str() and
      security_free_mnt_opts() take it as var argument (i.e. as void **);
      call sites are unchanged.
      	* security_sb_set_mnt_opts() and security_sb_remount() take
      it by value (i.e. as void *).
      	* new method: ->sb_free_mnt_opts().  Takes void *, does
      whatever freeing that needs to be done.
      	* ->sb_set_mnt_opts() and ->sb_remount() might get NULL as
      mnt_opts argument, meaning "empty".
      
      Reviewed-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      204cc0cc
    • Al Viro's avatar
      nfs_remount(): don't leak, don't ignore LSM options quietly · 6a0440e5
      Al Viro authored
      
      
      * if mount(2) passes something like "context=foo" with MS_REMOUNT
      in flags (/sbin/mount.nfs will _not_ do that - you need to issue
      the syscall manually), you'll get leaked copies for LSM options.
      The reason is that instead of nfs_{alloc,free}_parsed_mount_data()
      nfs_remount() uses kzalloc/kfree, which lacks the needed cleanup.
      
      * selinux options are not changed on remount (as for any other
      fs), but in case of NFS the failure is quiet - they are not compared
      to what we used to have, with complaint in case of attempted changes.
      Trivially fixed by converting to use of security_sb_remount().
      
      Reviewed-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      6a0440e5
    • Al Viro's avatar
      new helper: security_sb_eat_lsm_opts() · f5c0c26d
      Al Viro authored
      
      
      combination of alloc_secdata(), security_sb_copy_data(),
      security_sb_parse_opt_str() and free_secdata().
      
      Reviewed-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      f5c0c26d
  11. Dec 19, 2018
    • NeilBrown's avatar
      NFS/NFSD/SUNRPC: replace generic creds with 'struct cred'. · a52458b4
      NeilBrown authored
      
      
      SUNRPC has two sorts of credentials, both of which appear as
      "struct rpc_cred".
      There are "generic credentials" which are supplied by clients
      such as NFS and passed in 'struct rpc_message' to indicate
      which user should be used to authorize the request, and there
      are low-level credentials such as AUTH_NULL, AUTH_UNIX, AUTH_GSS
      which describe the credential to be sent over the wires.
      
      This patch replaces all the generic credentials by 'struct cred'
      pointers - the credential structure used throughout Linux.
      
      For machine credentials, there is a special 'struct cred *' pointer
      which is statically allocated and recognized where needed as
      having a special meaning.  A look-up of a low-level cred will
      map this to a machine credential.
      
      Signed-off-by: default avatarNeilBrown <neilb@suse.com>
      Acked-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      a52458b4
    • NeilBrown's avatar
      NFS: struct nfs_open_dir_context: convert rpc_cred pointer to cred. · 684f39b4
      NeilBrown authored
      
      
      Use the common 'struct cred' to pass credentials for readdir.
      
      Signed-off-by: default avatarNeilBrown <neilb@suse.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      684f39b4
    • NeilBrown's avatar
      NFS: change access cache to use 'struct cred'. · b68572e0
      NeilBrown authored
      
      
      Rather than keying the access cache with 'struct rpc_cred',
      use 'struct cred'.  Then use cred_fscmp() to compare
      credentials rather than comparing the raw pointer.
      
      A benefit of this approach is that in the common case we avoid the
      rpc_lookup_cred_nonblock() call which can be slow when the cred cache is large.
      This also keeps many fewer items pinned in the rpc cred cache, so the
      cred cache is less likely to get large.
      
      Signed-off-by: default avatarNeilBrown <neilb@suse.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      b68572e0
    • NeilBrown's avatar
      NFS: move credential expiry tracking out of SUNRPC into NFS. · ddf529ee
      NeilBrown authored
      
      
      NFS needs to know when a credential is about to expire so that
      it can modify write-back behaviour to finish the write inside the
      expiry time.
      It currently uses functions in SUNRPC code which make use of a
      fairly complex callback scheme and flags in the generic credientials.
      
      As I am working to discard the generic credentials, this has to change.
      
      This patch moves the logic into NFS, in part by finding and caching
      the low-level credential in the open_context.  We then make direct
      cred-api calls on that.
      
      This makes the code much simpler and removes a dependency on generic
      rpc credentials.
      
      Signed-off-by: default avatarNeilBrown <neilb@suse.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      ddf529ee
    • NeilBrown's avatar
      NFS/SUNRPC: don't lookup machine credential until rpcauth_bindcred(). · 5e16923b
      NeilBrown authored
      
      
      When NFS creates a machine credential, it is a "generic" credential,
      not tied to any auth protocol, and is really just a container for
      the princpal name.
      This doesn't get linked to a genuine credential until rpcauth_bindcred()
      is called.
      The lookup always succeeds, so various places that test if the machine
      credential is NULL, are pointless.
      
      As a step towards getting rid of generic credentials, this patch gets
      rid of generic machine credentials.  The nfs_client and rpc_client
      just hold a pointer to a constant principal name.
      When a machine credential is wanted, a special static 'struct rpc_cred'
      pointer is used. rpcauth_bindcred() recognizes this, finds the
      principal from the client, and binds the correct credential.
      
      Signed-off-by: default avatarNeilBrown <neilb@suse.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      5e16923b
    • NeilBrown's avatar
      NFSv4: don't require lock for get_renew_cred or get_machine_cred · f15e1e8b
      NeilBrown authored
      
      
      This lock is no longer necessary.
      
      If nfs4_get_renew_cred() needs to hunt through the open-state
      creds for a user cred, it still takes the lock to stablize
      the rbtree, but otherwise there are no races.
      
      Note that this completely removes the lock from nfs4_renew_state().
      It appears that the original need for the locking here was removed
      long ago, and there is no longer anything to protect.
      
      Signed-off-by: default avatarNeilBrown <neilb@suse.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      f15e1e8b
Loading