1. 11 12月, 2014 1 次提交
  2. 17 9月, 2014 1 次提交
  3. 11 2月, 2014 1 次提交
    • S
      [CIFS] Fix cifsacl mounts over smb2 to not call cifs · 42eacf9e
      Steve French 提交于
      When mounting with smb2/smb3 (e.g. vers=2.1) and cifsacl mount option,
      it was trying to get the mode by querying the acl over the cifs
      rather than smb2 protocol.  This patch makes that protocol
      independent and makes cifsacl smb2 mounts return a more intuitive
      operation not supported error (until we add a worker function
      for smb2_get_acl).
      
      Note that a previous patch fixed getxattr/setxattr for the CIFSACL xattr
      which would unconditionally call cifs_get_acl and cifs_set_acl (even when
      mounted smb2). I made those protocol independent last week (new protocol
      version operations "get_acl" and "set_acl" but did not add an
      smb2_get_acl and smb2_set_acl yet so those now simply return EOPNOTSUPP
      which at least is better than sending cifs requests on smb2 mount)
      
      The previous patches did not fix the one remaining case though ie
      mounting with "cifsacl" when getting mode from acl would unconditionally
      end up calling "cifs_get_acl_from_fid" even for smb2 - so made that protocol
      independent but to make that protocol independent had to make sure that the callers
      were passing the protocol independent handle structure (cifs_fid) instead
      of cifs specific _u16 network file handle (ie cifs_fid instead of cifs_fid->fid)
      
      Now mount with smb2 and cifsacl mount options will return EOPNOTSUP (instead
      of timing out) and a future patch will add smb2 operations (e.g. get_smb2_acl)
      to enable this.
      Signed-off-by: NSteve French <smfrench@gmail.com>
      42eacf9e
  4. 08 2月, 2014 1 次提交
    • S
      retrieving CIFS ACLs when mounted with SMB2 fails dropping session · 83e3bc23
      Steve French 提交于
      The get/set ACL xattr support for CIFS ACLs attempts to send old
      cifs dialect protocol requests even when mounted with SMB2 or later
      dialects. Sending cifs requests on an smb2 session causes problems -
      the server drops the session due to the illegal request.
      
      This patch makes CIFS ACL operations protocol specific to fix that.
      
      Attempting to query/set CIFS ACLs for SMB2 will now return
      EOPNOTSUPP (until we add worker routines for sending query
      ACL requests via SMB2) instead of sending invalid (cifs)
      requests.
      
      A separate followon patch will be needed to fix cifs_acl_to_fattr
      (which takes a cifs specific u16 fid so can't be abstracted
      to work with SMB2 until that is changed) and will be needed
      to fix mount problems when "cifsacl" is specified on mount
      with e.g. vers=2.1
      Signed-off-by: NSteve French <smfrench@gmail.com>
      Reviewed-by: NShirish Pargaonkar <spargaonkar@suse.com>
      CC: Stable <stable@kernel.org>
      83e3bc23
  5. 20 1月, 2014 1 次提交
  6. 05 5月, 2013 2 次提交
    • J
      [CIFS] cifs: Rename cERROR and cFYI to cifs_dbg · f96637be
      Joe Perches 提交于
      It's not obvious from reading the macro names that these macros
      are for debugging.  Convert the names to a single more typical
      kernel style cifs_dbg macro.
      
      	cERROR(1, ...)   -> cifs_dbg(VFS, ...)
      	cFYI(1, ...)     -> cifs_dbg(FYI, ...)
      	cFYI(DBG2, ...)  -> cifs_dbg(NOISY, ...)
      
      Move the terminating format newline from the macro to the call site.
      
      Add CONFIG_CIFS_DEBUG function cifs_vfs_err to emit the
      "CIFS VFS: " prefix for VFS messages.
      
      Size is reduced ~ 1% when CONFIG_CIFS_DEBUG is set (default y)
      
      $ size fs/cifs/cifs.ko*
         text    data     bss     dec     hex filename
       265245	   2525	    132	 267902	  4167e	fs/cifs/cifs.ko.new
       268359    2525     132  271016   422a8 fs/cifs/cifs.ko.old
      
      Other miscellaneous changes around these conversions:
      
      o Miscellaneous typo fixes
      o Add terminating \n's to almost all formats and remove them
        from the macros to be more kernel style like.  A few formats
        previously had defective \n's
      o Remove unnecessary OOM messages as kmalloc() calls dump_stack
      o Coalesce formats to make grep easier,
        added missing spaces when coalescing formats
      o Use %s, __func__ instead of embedded function name
      o Removed unnecessary "cifs: " prefixes
      o Convert kzalloc with multiply to kcalloc
      o Remove unused cifswarn macro
      Signed-off-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      f96637be
    • S
      fs: cifs: use kmemdup instead of kmalloc + memcpy · f7f7c185
      Silviu-Mihai Popescu 提交于
      This replaces calls to kmalloc followed by memcpy with a single call to
      kmemdup. This was found via make coccicheck.
      Signed-off-by: NSilviu-Mihai Popescu <silviupopescu1990@gmail.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      f7f7c185
  7. 13 2月, 2013 3 次提交
  8. 12 12月, 2012 1 次提交
  9. 09 12月, 2012 5 次提交
    • J
      cifs: deal with id_to_sid embedded sid reply corner case · 1f630680
      Jeff Layton 提交于
      A SID could potentially be embedded inside of payload.value if there are
      no subauthorities, and the arch has 8 byte pointers. Allow for that
      possibility there.
      
      While we're at it, rephrase the "embedding" check in terms of
      key->payload to allow for the possibility that the union might change
      size in the future.
      Reviewed-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      1f630680
    • J
      cifs: fix hardcoded default security descriptor length · 7ee0b4c6
      Jeff Layton 提交于
      It was hardcoded to 192 bytes, which was not enough when the max number
      of subauthorities went to 15. Redefine this constant in terms of sizeof
      the structs involved, and rename it for better clarity.
      
      While we're at it, remove a couple more unused constants from cifsacl.h.
      Reviewed-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      7ee0b4c6
    • J
      cifs: extra sanity checking for cifs.idmap keys · 2ae03025
      Jeff Layton 提交于
      Now that we aren't so rigid about the length of the key being passed
      in, we need to be a bit more rigorous about checking the length of
      the actual data against the claimed length (a'la num_subauths field).
      
      Check for the case where userspace sends us a seemingly valid key
      with a num_subauths field that goes beyond the end of the array. If
      that happens, return -EIO and invalidate the key.
      
      Also change the other places where we check for malformed keys in this
      code to invalidate the key as well.
      Reviewed-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      2ae03025
    • J
      cifs: avoid extra allocation for small cifs.idmap keys · 41a9f1f6
      Jeff Layton 提交于
      The cifs.idmap keytype always allocates memory to hold the payload from
      userspace. In the common case where we're translating a SID to a UID or
      GID, we're allocating memory to hold something that's less than or equal
      to the size of a pointer.
      
      When the payload is the same size as a pointer or smaller, just store
      it in the payload.value union member instead. That saves us an extra
      allocation on the sid_to_id upcall.
      
      Note that we have to take extra care to check the datalen when we
      go to dereference the .data pointer in the union, but the callers
      now check that as a matter of course anyway.
      Reviewed-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      41a9f1f6
    • J
      cifs: simplify id_to_sid and sid_to_id mapping code · faa65f07
      Jeff Layton 提交于
      The cifs.idmap handling code currently causes the kernel to cache the
      data from userspace twice. It first looks in a rbtree to see if there is
      a matching entry for the given id. If there isn't then it calls
      request_key which then checks its cache and then calls out to userland
      if it doesn't have one. If the userland program establishes a mapping
      and downcalls with that info, it then gets cached in the keyring and in
      this rbtree.
      
      Aside from the double memory usage and the performance penalty in doing
      all of these extra copies, there are some nasty bugs in here too. The
      code declares four rbtrees and spinlocks to protect them, but only seems
      to use two of them. The upshot is that the same tree is used to hold
      (eg) uid:sid and sid:uid mappings. The comparitors aren't equipped to
      deal with that.
      
      I think we'd be best off to remove a layer of caching in this code. If
      this was originally done for performance reasons, then that really seems
      like a premature optimization.
      
      This patch does that -- it removes the rbtrees and the locks that
      protect them and simply has the code do a request_key call on each call
      into sid_to_id and id_to_sid. This greatly simplifies this code and
      should roughly halve the memory utilization from using the idmapping
      code.
      Reviewed-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      faa65f07
  10. 06 12月, 2012 8 次提交
  11. 03 11月, 2012 1 次提交
    • J
      cifs: fix potential buffer overrun in cifs.idmap handling code · 36960e44
      Jeff Layton 提交于
      The userspace cifs.idmap program generally works with the wbclient libs
      to generate binary SIDs in userspace. That program defines the struct
      that holds these values as having a max of 15 subauthorities. The kernel
      idmapping code however limits that value to 5.
      
      When the kernel copies those values around though, it doesn't sanity
      check the num_subauths value handed back from userspace or from the
      server. It's possible therefore for userspace to hand us back a bogus
      num_subauths value (or one that's valid, but greater than 5) that could
      cause the kernel to walk off the end of the cifs_sid->sub_auths array.
      
      Fix this by defining a new routine for copying sids and using that in
      all of the places that copy it. If we end up with a sid that's longer
      than expected then this approach will just lop off the "extra" subauths,
      but that's basically what the code does today already. Better approaches
      might be to fix this code to reject SIDs with >5 subauths, or fix it
      to handle the subauths array dynamically.
      
      At the same time, change the kernel to check the length of the data
      returned by userspace. If it's shorter than struct cifs_sid, reject it
      and return -EIO. If that happens we'll end up with fields that are
      basically uninitialized.
      
      Long term, it might make sense to redefine cifs_sid using a flexarray at
      the end, to allow for variable-length subauth lists, and teach the code
      to handle the case where the subauths array being passed in from
      userspace is shorter than 5 elements.
      
      Note too, that I don't consider this a security issue since you'd need
      a compromised cifs.idmap program. If you have that, you can do all sorts
      of nefarious stuff. Still, this is probably reasonable for stable.
      
      Cc: stable@kernel.org
      Reviewed-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      36960e44
  12. 08 10月, 2012 1 次提交
    • D
      KEYS: Add payload preparsing opportunity prior to key instantiate or update · cf7f601c
      David Howells 提交于
      Give the key type the opportunity to preparse the payload prior to the
      instantiation and update routines being called.  This is done with the
      provision of two new key type operations:
      
      	int (*preparse)(struct key_preparsed_payload *prep);
      	void (*free_preparse)(struct key_preparsed_payload *prep);
      
      If the first operation is present, then it is called before key creation (in
      the add/update case) or before the key semaphore is taken (in the update and
      instantiate cases).  The second operation is called to clean up if the first
      was called.
      
      preparse() is given the opportunity to fill in the following structure:
      
      	struct key_preparsed_payload {
      		char		*description;
      		void		*type_data[2];
      		void		*payload;
      		const void	*data;
      		size_t		datalen;
      		size_t		quotalen;
      	};
      
      Before the preparser is called, the first three fields will have been cleared,
      the payload pointer and size will be stored in data and datalen and the default
      quota size from the key_type struct will be stored into quotalen.
      
      The preparser may parse the payload in any way it likes and may store data in
      the type_data[] and payload fields for use by the instantiate() and update()
      ops.
      
      The preparser may also propose a description for the key by attaching it as a
      string to the description field.  This can be used by passing a NULL or ""
      description to the add_key() system call or the key_create_or_update()
      function.  This cannot work with request_key() as that required the description
      to tell the upcall about the key to be created.
      
      This, for example permits keys that store PGP public keys to generate their own
      name from the user ID and public key fingerprint in the key.
      
      The instantiate() and update() operations are then modified to look like this:
      
      	int (*instantiate)(struct key *key, struct key_preparsed_payload *prep);
      	int (*update)(struct key *key, struct key_preparsed_payload *prep);
      
      and the new payload data is passed in *prep, whether or not it was preparsed.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      cf7f601c
  13. 03 10月, 2012 1 次提交
  14. 25 9月, 2012 1 次提交
  15. 13 9月, 2012 1 次提交
    • D
      KEYS: Add payload preparsing opportunity prior to key instantiate or update · d4f65b5d
      David Howells 提交于
      Give the key type the opportunity to preparse the payload prior to the
      instantiation and update routines being called.  This is done with the
      provision of two new key type operations:
      
      	int (*preparse)(struct key_preparsed_payload *prep);
      	void (*free_preparse)(struct key_preparsed_payload *prep);
      
      If the first operation is present, then it is called before key creation (in
      the add/update case) or before the key semaphore is taken (in the update and
      instantiate cases).  The second operation is called to clean up if the first
      was called.
      
      preparse() is given the opportunity to fill in the following structure:
      
      	struct key_preparsed_payload {
      		char		*description;
      		void		*type_data[2];
      		void		*payload;
      		const void	*data;
      		size_t		datalen;
      		size_t		quotalen;
      	};
      
      Before the preparser is called, the first three fields will have been cleared,
      the payload pointer and size will be stored in data and datalen and the default
      quota size from the key_type struct will be stored into quotalen.
      
      The preparser may parse the payload in any way it likes and may store data in
      the type_data[] and payload fields for use by the instantiate() and update()
      ops.
      
      The preparser may also propose a description for the key by attaching it as a
      string to the description field.  This can be used by passing a NULL or ""
      description to the add_key() system call or the key_create_or_update()
      function.  This cannot work with request_key() as that required the description
      to tell the upcall about the key to be created.
      
      This, for example permits keys that store PGP public keys to generate their own
      name from the user ID and public key fingerprint in the key.
      
      The instantiate() and update() operations are then modified to look like this:
      
      	int (*instantiate)(struct key *key, struct key_preparsed_payload *prep);
      	int (*update)(struct key *key, struct key_preparsed_payload *prep);
      
      and the new payload data is passed in *prep, whether or not it was preparsed.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      d4f65b5d
  16. 24 7月, 2012 2 次提交
  17. 19 1月, 2012 1 次提交
  18. 13 1月, 2012 1 次提交
  19. 17 10月, 2011 1 次提交
    • S
      cifs: Call id to SID mapping functions to change owner/group (try #4 repost) · a5ff3769
      Shirish Pargaonkar 提交于
      Now build security descriptor to change either owner or group at the
      server.  Initially security descriptor was built to change only
      (D)ACL, that functionality has been extended.
      
      When either an Owner or a Group of a file object at the server is changed,
      rest of security descriptor remains same (DACL etc.).
      
      To set security descriptor, it is necessary to open that file
      with permission bits of either WRITE_DAC if DACL is being modified or
      WRITE_OWNER (Take Ownership) if Owner or Group is being changed.
      
      It is the server that decides whether a set security descriptor with
      either owner or group change succeeds or not.
      Signed-off-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      a5ff3769
  20. 13 10月, 2011 2 次提交
    • S
      cifs: Add data structures and functions for uid/gid to SID mapping (try #4) · 21fed0d5
      Shirish Pargaonkar 提交于
      Add data structures and functions necessary to map a uid and gid to SID.
      These functions are very similar to the ones used to map a SID to uid and gid.
      This time, instead of storing sid to id mapping sorted on a sid value,
      id to sid is stored, sorted on an id.
      A cifs upcall sends an id (uid or gid) and expects a SID structure
      in return, if mapping was done successfully.
      
      A failed id to sid mapping to EINVAL.
      
      This patchset aims to enable chown and chgrp commands when
      cifsacl mount option is specified, especially to Windows SMB servers.
      Currently we can't do that.  So now along with chmod command,
      chown and chgrp work.
      
      Winbind is used to map id to a SID.  chown and chgrp use an upcall
      to provide an id to winbind and upcall returns with corrosponding
      SID if any exists. That SID is used to build security descriptor.
      The DACL part of a security descriptor is not changed by either
      chown or chgrp functionality.
      
      cifs client maintains a separate caches for uid to SID and
      gid to SID mapping. This is similar to the one used earlier
      to map SID to id (as part of ID mapping code).
      
      I tested it by mounting shares from a Windows (2003) server by
      authenticating as two users, one at a time, as Administrator and
      as a ordinary user.
      And then attempting to change owner of a file on the share.
      
      Depending on the permissions/privileges at the server for that file,
      chown request fails to either open a file (to change the ownership)
      or to set security descriptor.
      So it all depends on privileges on the file at the server and what
      user you are authenticated as at the server, cifs client is just a
      conduit.
      
      I compared the security descriptor during chown command to that
      what smbcacls sends when it is used with -M OWNNER: option
      and they are similar.
      
      This patchset aim to enable chown and chgrp commands when
      cifsacl mount option is specified, especially to Windows SMB servers.
      Currently we can't do that.  So now along with chmod command,
      chown and chgrp work.
      
      I tested it by mounting shares from a Windows (2003) server by
      authenticating as two users, one at a time, as Administrator and
      as a ordinary user.
      And then attempting to change owner of a file on the share.
      
      Depending on the permissions/privileges at the server for that file,
      chown request fails to either open a file (to change the ownership)
      or to set security descriptor.
      So it all depends on privileges on the file at the server and what
      user you are authenticated as at the server, cifs client is just a
      conduit.
      Signed-off-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      21fed0d5
    • S
      cifs: Add mount options for backup intent (try #6) · 3d3ea8e6
      Shirish Pargaonkar 提交于
      Add mount options backupuid and backugid.
      
      It allows an authenticated user to access files with the intent to back them
      up including their ACLs, who may not have access permission but has
      "Backup files and directories user right" on them (by virtue of being part
      of the built-in group Backup Operators.
      
      When mount options backupuid is specified, cifs client restricts the
      use of backup intents to the user whose effective user id is specified
      along with the mount option.
      
      When mount options backupgid is specified, cifs client restricts the
      use of backup intents to the users whose effective user id belongs to the
      group id specified along with the mount option.
      
      If an authenticated user is not part of the built-in group Backup Operators
      at the server, access to such files is denied, even if allowed by the client.
      Signed-off-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Reviewed-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <smfrench@gmail.com>
      3d3ea8e6
  21. 12 8月, 2011 1 次提交
    • S
      cifs: Do not set cifs/ntfs acl using a file handle (try #4) · e22906c5
      Shirish Pargaonkar 提交于
      Set security descriptor using path name instead of a file handle.
      We can't be sure that the file handle has adequate permission to
      set a security descriptor (to modify DACL).
      
      Function set_cifs_acl_by_fid() has been removed since we can't be
      sure how a file was opened for writing, a valid request can fail
      if the file was not opened with two above mentioned permissions.
      We could have opted to add on WRITE_DAC and WRITE_OWNER permissions
      to file opens and then use that file handle but adding addtional
      permissions such as WRITE_DAC and WRITE_OWNER could cause an
      any open to fail.
      
      And it was incorrect to look for read file handle to set a
      security descriptor anyway.
      Signed-off-by: NShirish Pargaonkar <shirishpargaonkar@gmail.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      e22906c5
  22. 30 5月, 2011 1 次提交
  23. 28 5月, 2011 1 次提交
  24. 27 5月, 2011 1 次提交