24 Oct, 2018
3 commits
-
We do not call cifs_open_file() for directories and thus we do not have a
pSMBFile we can extract the FIDs from.Solve this by instead always using a compounded open/query/close for
the passthrough ioctl.Signed-off-by: Ronnie Sahlberg
Signed-off-by: Steve French -
This allows userspace tools to query the raw info levels for cifs files
and process the response in userspace.
In particular this is useful for many of those data where there is no
corresponding native data structure in linux.
For example querying the security descriptor for a file and extract the
SIDs.Signed-off-by: Ronnie Sahlberg
Signed-off-by: Steve French -
Fixes gcc '-Wunused-but-set-variable' warning:
fs/cifs/ioctl.c: In function 'cifs_ioctl':
fs/cifs/ioctl.c:164:23: warning:
variable 'cifs_sb' set but not used [-Wunused-but-set-variable]Signed-off-by: YueHaibing
Signed-off-by: Steve French
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
04 May, 2017
1 commit
-
An open directory may have a NULL private_data pointer prior to readdir.
Fixes: 0de1f4c6f6c0 ("Add way to query server fs info for smb3")
Cc: stable@vger.kernel.org
Signed-off-by: David Disseldorp
Signed-off-by: Steve French
03 May, 2017
1 commit
-
As with 618763958b22, an open directory may have a NULL private_data
pointer prior to readdir. CIFS_ENUMERATE_SNAPSHOTS must check for this
before dereference.Fixes: 834170c85978 ("Enable previous version support")
Signed-off-by: David Disseldorp
CC: Stable
Signed-off-by: Steve French
28 Apr, 2017
1 commit
-
commit 620d8745b35d ("Introduce cifs_copy_file_range()") changes the
behaviour of the cifs ioctl call CIFS_IOC_COPYCHUNK_FILE. In case of
successful writes, it now returns the number of bytes written. This
return value is treated as an error by the xfstest cifs/001. Depending
on the errno set at that time, this may or may not result in the test
failing.The patch fixes this by setting the return value to 0 in case of
successful writes.Fixes: commit 620d8745b35d ("Introduce cifs_copy_file_range()")
Reported-by: Eryu Guan
Signed-off-by: Sachin Prabhu
Acked-by: Pavel Shilovsky
Cc: stable@vger.kernel.org
Signed-off-by: Steve French
07 Apr, 2017
2 commits
-
The earlier changes to copy range for cifs unintentionally disabled the more
common form of server side copy.The patch introduces the file_operations helper cifs_copy_file_range()
which is used by the syscall copy_file_range. The new file operations
helper allows us to perform server side copies for SMB2.0 and 2.1
servers as well as SMB 3.0+ servers which do not support the ioctl
FSCTL_DUPLICATE_EXTENTS_TO_FILE.The new helper uses the ioctl FSCTL_SRV_COPYCHUNK_WRITE to perform
server side copies. The helper is called by vfs_copy_file_range() only
once an attempt to clone the file using the ioctl
FSCTL_DUPLICATE_EXTENTS_TO_FILE has failed.Signed-off-by: Sachin Prabhu
Reviewed-by: Pavel Shilovsky
CC: Stable
Signed-off-by: Steve French -
Server side copy is one of the most important mechanisms smb2/smb3
supports and it was unintentionally disabled for most use cases.Renaming calls to reflect the underlying smb2 ioctl called. This is
similar to the name duplicate_extents used for a similar ioctl which is
also used to duplicate files by reusing fs blocks. The name change is to
avoid confusion.Signed-off-by: Sachin Prabhu
CC: Stable
Signed-off-by: Steve French
Reviewed-by: Pavel Shilovsky
03 Dec, 2016
1 commit
-
Cc: Stable # v4.9+
Reviewed-by: Aurelien Aptel
Acked-by: Sachin Prabhu
Signed-off-by: Pavel Shilovsky
14 Oct, 2016
1 commit
-
Add ioctl to query previous versions of file
Allows listing snapshots on files on SMB3 mounts.
Signed-off-by: Steve French
08 Dec, 2015
1 commit
-
The btrfs clone ioctls are now adopted by other file systems, with NFS
and CIFS already having support for them, and XFS being under active
development. To avoid growth of various slightly incompatible
implementations, add one to the VFS. Note that clones are different from
file copies in several ways:- they are atomic vs other writers
- they support whole file clones
- they support 64-bit legth clones
- they do not allow partial success (aka short writes)
- clones are expected to be a fast metadata operationBecause of that it would be rather cumbersome to try to piggyback them on
top of the recent clone_file_range infrastructure. The converse isn't
true and the clone_file_range system call could try clone file range as
a first attempt to copy, something that further patches will enable.Based on earlier work from Peng Tao.
Signed-off-by: Christoph Hellwig
Signed-off-by: Al Viro
09 Nov, 2015
1 commit
-
FSCTL_SRV_COPYCHUNK_WRITE only requires that the source and target
be on the same server (not the same volume or same share),
so relax the existing check (which required them to be on
the same share). Note that this works to Windows (and presumably
most other NAS) but Samba requires that the source
and target be on the same share. Moving a file across
shares is a common use case and can be very heplful (100x faster).Signed-off-by: Steve French
Reviewed-by: David Disseldorp
11 Sep, 2015
1 commit
-
This might lead to local privilege escalation (code execution as
kernel) for systems where the following conditions are met:- CONFIG_CIFS_SMB2 and CONFIG_CIFS_POSIX are enabled
- a cifs filesystem is mounted where:
- the mount option "vers" was used and set to a value >=2.0
- the attacker has write access to at least one file on the filesystemTo attack this, an attacker would have to guess the target_tcon
pointer (but guessing wrong doesn't cause a crash, it just returns an
error code) and win a narrow race.CC: Stable
Signed-off-by: Jann Horn
Signed-off-by: Steve French
20 Aug, 2015
1 commit
-
The server exports information about the share and underlying
device under an SMB3 export, including its attributes and
capabilities, which is stored by cifs.ko when first connecting
to the share.Add ioctl to cifs.ko to allow user space smb3 helper utilities
(in cifs-utils) to display this (e.g. via smb3util).This information is also useful for debugging and for
resolving configuration errors.Signed-off-by: Steve French
29 Jun, 2015
2 commits
-
set integrity increases reliability of files stored on SMB3 servers.
Add ioctl to allow setting this on files on SMB3 and later mounts.Signed-off-by: Steve French
-
Getting fantastic copy performance with cp --reflink over SMB3.11
using the new FSCTL_DUPLICATE_EXTENTS.This FSCTL was added in the SMB3.11 dialect (testing was
against REFS file system) so have put it as a 3.11 protocol
specific operation ("vers=3.1.1" on the mount). Tested at
the SMB3 plugfest in Redmond.It depends on the new FS Attribute (BLOCK_REFCOUNTING) which
is used to advertise support for the ability to do this ioctl
(if you can support multiple files pointing to the same block
than this refcounting ability or equivalent is needed to
support the new reflink-like duplicate extent SMB3 ioctl.Signed-off-by: Steve French
19 Jan, 2015
1 commit
-
It really needs to check that src is non-directory *and* use
{un,}lock_two_nodirectories(). As it is, it's trivial to cause
double-lock (ioctl(fd, CIFS_IOC_COPYCHUNK_FILE, fd)) and if the
last argument is an fd of directory, we are asking for trouble
by violating the locking order - all directories go before all
non-directories. If the last argument is an fd of parent
directory, it has 50% odds of locking child before parent,
which will cause AB-BA deadlock if we race with unlink().Cc: stable@vger.kernel.org @ 3.13+
Signed-off-by: Al Viro
22 May, 2014
1 commit
-
Signed-off-by: Libo Chen
Acked-by: Jeff Layton
Signed-off-by: Steve French
25 Nov, 2013
1 commit
-
Change cifs.ko to using CIFS_IOCTL_COPYCHUNK instead
of BTRFS_IOC_CLONE to avoid confusion about whether
copy-on-write is required or optional for this operation.SMB2/SMB3 copyoffload had used the BTRFS_IOC_CLONE ioctl since
they both speed up copy by offloading the copy rather than
passing many read and write requests back and forth and both have
identical syntax (passing file handles), but for SMB2/SMB3
CopyChunk the server is not required to use copy-on-write
to make a copy of the file (although some do), and Christoph
has commented that since CopyChunk does not require
copy-on-write we should not reuse BTRFS_IOC_CLONE.This patch renames the ioctl to use a cifs specific IOCTL
CIFS_IOCTL_COPYCHUNK. This ioctl is particularly important
for SMB2/SMB3 since large file copy over the network otherwise
can be very slow, and with this is often more than 100 times
faster putting less load on server and client.Note that if a copy syscall is ever introduced, depending on
its requirements/format it could end up using one of the other
three methods that CIFS/SMB2/SMB3 can do for copy offload,
but this method is particularly useful for file copy
and broadly supported (not just by Samba server).Signed-off-by: Steve French
Reviewed-by: Jeff Layton
Reviewed-by: David Disseldorp
14 Nov, 2013
1 commit
-
This first patch adds the ability for us to do a server side copy
(ie fast copy offloaded to the server to perform, aka refcopy)"cp --reflink"
of one file to another located on the same server. This
is much faster than traditional copy (which requires
reading and writing over the network and extra
memcpys).This first version is not going to be copy
files larger than about 1MB (to Samba) until I add
support for multiple chunks and for autoconfiguring
the chunksize.It includes:
1) processing of the ioctl
2) marshalling and sending the SMB2/SMB3 fsctl over the network
3) simple parsing of the responseIt does not include yet (these will be in followon patches to come soon):
1) support for multiple chunks
2) support for autoconfiguring and remembering the chunksize
3) Support for the older style copychunk which Samba 4.1 server supports
(because this requires write permission on the target file, which
cp does not give you, apparently per-posix). This may require
a distinct tool (other than cp) and other ioctl to implement.Reviewed-by: Pavel Shilovsky
Signed-off-by: Steve French
03 Nov, 2013
1 commit
-
Fix unused variable warning when CONFIG_CIFS_POSIX disabled.
fs/cifs/ioctl.c: In function 'cifs_ioctl':
>> fs/cifs/ioctl.c:40:8: warning: unused variable 'ExtAttrMask' [-Wunused-variable]
__u64 ExtAttrMask = 0;
^
Pointed out by 0-DAY kernel build testing backendSigned-off-by: Steve French
28 Oct, 2013
1 commit
-
Allow cifs/smb2/smb3 to return whether or not a file is compressed
via lsattr, and allow SMB2/SMB3 to set the per-file compression
flag ("chattr +c filename" on an smb3 mount).Windows users often set the compressed flag (it can be
done from the desktop and file manager). David Disseldorp
has patches to Samba server to support this (at least on btrfs)
which are complementary to thisSigned-off-by: Steve French
05 May, 2013
1 commit
-
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.oldOther 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 macroSigned-off-by: Joe Perches
Signed-off-by: Jeff Layton
Signed-off-by: Steve French
23 Feb, 2013
1 commit
-
Signed-off-by: Al Viro
25 Sep, 2012
2 commits
-
...as promised for 3.7.
Signed-off-by: Jeff Layton
Signed-off-by: Steve French -
This is help us to extend the code for future protocols that can use
another fid mechanism (as SMB2 that has it divided into two parts:
persistent and violatile).Also rename variables and refactor the code around the changes.
Reviewed-by: Jeff Layton
Signed-off-by: Pavel Shilovsky
Signed-off-by: Steve French
24 Jul, 2012
1 commit
-
Acked-by: Jeff Layton
Signed-off-by: Pavel Shilovsky
Signed-off-by: Steve French
17 May, 2012
1 commit
-
This was used by an ancient version of umount.cifs and in nowhere else
that I'm aware of. Let's add a warning now and dump it for 3.7.Signed-off-by: Jeff Layton
27 May, 2011
1 commit
-
secMode to sec_mode
and
cifsTconInfo to cifs_tcon
and
cifsSesInfo to cifs_sesSigned-off-by: Steve French
09 Nov, 2010
1 commit
-
Commit 13cfb7334e made cifs_ioctl use the tlink attached to the
cifsFileInfo for a filp. This ignores the case of an open directory
however, which in CIFS can have a NULL private_data until a readdir
is done on it.This patch re-adds the NULL pointer checks that were removed in commit
50ae28f01 and moves the setting of tcon and "caps" variables lower.Long term, a better fix would be to establish a f_op->open routine for
directories that populates that field at open time, but that requires
some other changes to how readdir calls are handled.Reported-by: Kjell Rune Skaaraas
Reviewed-and-Tested-by: Suresh Jayaraman
Signed-off-by: Jeff Layton
Signed-off-by: Steve French
02 Nov, 2010
1 commit
-
Stanse found that pSMBFile in cifs_ioctl and file->f_path.dentry in
cifs_user_write are dereferenced prior their test to NULL.The alternative is not to dereference them before the tests. The patch is
to point out the problem, you have to decide.While at it we cache the inode in cifs_user_write to a local variable
and use all over the function.Signed-off-by: Jiri Slaby
Cc: Steve French
Cc: linux-cifs@vger.kernel.org
Cc: Jeff Layton
Cc: Christoph Hellwig
Signed-off-by: Steve French
07 Oct, 2010
1 commit
-
cifsFileInfo needs a pointer to a tcon, but it doesn't currently hold a
reference to it. Change it to keep a pointer to a tcon_link instead and
hold a reference to it.That will keep the tcon from being freed until the file is closed.
Signed-off-by: Jeff Layton
Signed-off-by: Steve French
30 Sep, 2010
1 commit
-
...where it's available and appropriate.
Signed-off-by: Jeff Layton
Signed-off-by: Steve French
02 Aug, 2010
1 commit
-
Signed-off-by: Joe Perches
Signed-off-by: Steve French
21 Apr, 2010
1 commit
-
Neaten cERROR and cFYI macros, reduce text space
~2.5KConvert '__FILE__ ": " fmt' to '"%s: " fmt', __FILE__' to save text space
Surround macros with do {} while
Add parentheses to macros
Make statement expression macro from macro with assign
Remove now unnecessary parentheses from cFYI and cERROR usesdefconfig with CIFS support old
$ size fs/cifs/built-in.o
text data bss dec hex filename
156012 1760 148 157920 268e0 fs/cifs/built-in.odefconfig with CIFS support old
$ size fs/cifs/built-in.o
text data bss dec hex filename
153508 1760 148 155416 25f18 fs/cifs/built-in.oallyesconfig old:
$ size fs/cifs/built-in.o
text data bss dec hex filename
309138 3864 74824 387826 5eaf2 fs/cifs/built-in.oallyesconfig new
$ size fs/cifs/built-in.o
text data bss dec hex filename
305655 3864 74824 384343 5dd57 fs/cifs/built-in.oSigned-off-by: Joe Perches
Signed-off-by: Steve French
14 Nov, 2008
1 commit
-
Wrap access to task credentials so that they can be separated more easily from
the task_struct during the introduction of COW creds.Change most current->(|e|s|fs)[ug]id to current_(|e|s|fs)[ug]id().
Change some task->e?[ug]id to task_e?[ug]id(). In some places it makes more
sense to use RCU directly rather than a convenient wrapper; these will be
addressed by later patches.Signed-off-by: David Howells
Reviewed-by: James Morris
Acked-by: Serge Hallyn
Cc: Steve French
Cc: linux-cifs-client@lists.samba.org
Signed-off-by: James Morris
15 May, 2008
1 commit
-
cifs_ioctl doesn't seem to need the BKL for anything, so convert it over
to use unlocked_ioctl.Signed-off-by: Andi Kleen
Signed-off-by: Andrew Morton
Signed-off-by: Steve French
08 Feb, 2008
1 commit
-
Signed-off-by: Steve French
10 Jul, 2007
1 commit
-
More than halfway there
Signed-off-by: Steve French