linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Shilovsky <piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
To: Kernel Mailing List
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Al Viro <viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
	Bruce Fields <bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
Cc: linux-cifs <linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-fsdevel
	<linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Linux NFS Mailing list
	<linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	wine-devel-5vRYHf7vrtgdnm+yROfE0A@public.gmane.org
Subject: Re: [PATCH v7 0/7] Add O_DENY* support for VFS and CIFS/NFS
Date: Fri, 31 Jan 2014 19:51:52 +0400	[thread overview]
Message-ID: <CAKywueSAWjOFH7cCvjQScSiBMGLzGEApjTYNoV03gmzec8uxjQ@mail.gmail.com> (raw)
In-Reply-To: <1389953232-9428-1-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>

2014-01-17 Pavel Shilovsky <piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>:
> This patchset adds support of O_DENY* flags for Linux fs layer. These flags can be used by any application that needs share reservations to organize a file access. VFS already has some sort of this capability - now it's done through flock/LOCK_MAND mechanis, but that approach is non-atomic. This patchset build new capabilities on top of the existing one but doesn't bring any changes into the flock call semantic.
>
> These flags can be used by NFS (built-in-kernel) and CIFS (Samba) servers and Wine applications through VFS (for local filesystems) or CIFS/NFS modules. This will help when e.g. Samba and NFS server share the same directory for Windows and Linux users or Wine applications use Samba/NFS share to access the same data from different clients.
>
> According to the previous discussions the most problematic question is how to prevent situations like DoS attacks where e.g /lib/liba.so file can be open with DENYREAD, or smth like this. That's why extra mount option 'sharelock' is added for switching on/off O_DENY* flags processing. It allows to avoid use of these flags on critical places (like /, /lib) and turn them on if we really want it proccessed that way.
>
> So, we have 3 new flags:
> O_DENYREAD - to prevent other opens with read access,
> O_DENYWRITE - to prevent other opens with write access,
> O_DENYDELETE - to prevent delete operations
>
> The patchset avoids data races problem on newely created files: open with O_CREAT can return the -ESHAREDENIED error for a successfully created file if this files was locked with a sharelock by another task. Also, it turns flock/LOCK_MAND capability off for mounts with 'sharelock' option. This lets not mix one share reservation approach with another.
>
> Patches #1, #2 and #3 add O_DENY* flags to fcntl and implement VFS part. A patch #4 is related to CIFS client changes, #5 -- NFSD, #6 and #7 describe NFSv4 client parts.
>
> The preliminary patch for Samba that replaces the existing use of flock/LOCK_MAND mechanism with O_DENY* flags:
> http://git.etersoft.ru/people/piastry/packages/?p=samba.git;a=commitdiff;h=173070262b7f29134ad6b2e49a760017c11aec4a
>
> The future part of open man page patch:
>
> -----
> O_DENYREAD, O_DENYWRIYE, O_DENYDELETE - used to inforce a mandatory share reservation scheme of the file access. If these flag is passed, the open fails with -ESHAREDENIED in following cases:
> 1) if O_DENYREAD flag is specified and there is another open with READ access to the file;
> 2) if O_DENYWRITE flag is specified and there is another open with WRITE access to the file;
> 3) if READ access is requested and there is another open with O_DENYREAD flags;
> 4) if WRITE access is requested and there is another open with O_DENYWRITE flags.
>
> If O_DENYDELETE flag is specified and the open succeded, any further unlink operation will fail with -ESHAREDENIED untill this open is closed. Now this flag is processed by VFS and CIFS filesystem. NFS returns -EINVAL for opens with this flag.
>
> This mechanism is done through flocks. If O_DENY* flags are specified, flock syscall is processed after the open. The share modes are translated into flock according the following rules:
> 1) !O_DENYREAD   -> LOCK_READ   | LOCK_MAND
> 2) !O_DENYWRITE  -> LOCK_WRITE  | LOCK_MAND
> 3) !O_DENYDELETE -> LOCK_DELETE | LOCK_MAND
> -----
>
> Pavel Shilovsky (7):
>   VFS: Introduce new O_DENY* open flags
>   VFS: Add O_DENYDELETE support for VFS
>   locks: Disable LOCK_MAND support for MS_SHARELOCK mounts
>   CIFS: Add O_DENY* open flags support
>   NFSD: Pass share reservations flags to VFS
>   NFSv4: Add deny state handling for nfs4_state struct
>   NFSv4: Add O_DENY* open flags support
>
>  arch/alpha/include/uapi/asm/errno.h  |    2 +
>  arch/alpha/include/uapi/asm/fcntl.h  |    3 +
>  arch/mips/include/uapi/asm/errno.h   |    2 +
>  arch/parisc/include/uapi/asm/errno.h |    2 +
>  arch/parisc/include/uapi/asm/fcntl.h |    3 +
>  arch/sparc/include/uapi/asm/errno.h  |    2 +
>  arch/sparc/include/uapi/asm/fcntl.h  |    3 +
>  fs/cifs/cifsacl.c                    |    2 +
>  fs/cifs/cifsfs.c                     |    2 +-
>  fs/cifs/cifsglob.h                   |   17 +-
>  fs/cifs/cifssmb.c                    |    2 +-
>  fs/cifs/dir.c                        |    6 +
>  fs/cifs/file.c                       |   20 ++-
>  fs/cifs/inode.c                      |   12 +-
>  fs/cifs/link.c                       |    2 +
>  fs/cifs/netmisc.c                    |    2 +-
>  fs/cifs/smb1ops.c                    |    3 +
>  fs/cifs/smb2inode.c                  |    1 +
>  fs/cifs/smb2maperror.c               |    2 +-
>  fs/cifs/smb2ops.c                    |    6 +
>  fs/cifs/smb2pdu.c                    |    2 +-
>  fs/fcntl.c                           |    5 +-
>  fs/locks.c                           |  161 ++++++++++++++++--
>  fs/namei.c                           |   56 +++++-
>  fs/nfs/dir.c                         |   39 ++++-
>  fs/nfs/inode.c                       |    8 +-
>  fs/nfs/internal.h                    |    3 +-
>  fs/nfs/nfs4_fs.h                     |   83 ++++++++-
>  fs/nfs/nfs4file.c                    |    8 +-
>  fs/nfs/nfs4proc.c                    |  310 +++++++++++++++++++++++-----------
>  fs/nfs/nfs4state.c                   |   65 ++++---
>  fs/nfs/nfs4super.c                   |    9 +-
>  fs/nfs/nfs4xdr.c                     |   21 ++-
>  fs/nfs/super.c                       |    7 +-
>  fs/nfsd/nfs4state.c                  |   46 ++++-
>  fs/nfsd/nfsproc.c                    |    1 +
>  fs/proc_namespace.c                  |    1 +
>  include/linux/fs.h                   |   15 ++
>  include/linux/nfs_fs.h               |    5 +-
>  include/linux/nfs_xdr.h              |    1 +
>  include/uapi/asm-generic/errno.h     |    2 +
>  include/uapi/asm-generic/fcntl.h     |   12 ++
>  include/uapi/linux/fs.h              |    1 +
>  43 files changed, 789 insertions(+), 166 deletions(-)
>
> --
> 1.7.10.4
>

Any other thoughts/reviews on this patchset?

-- 
Best regards,
Pavel Shilovsky.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-01-31 15:51 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-17 10:07 [PATCH v7 0/7] Add O_DENY* support for VFS and CIFS/NFS Pavel Shilovsky
2014-01-17 10:07 ` [PATCH v7 1/7] VFS: Introduce new O_DENY* open flags Pavel Shilovsky
     [not found]   ` <1389953232-9428-2-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2014-01-17 18:18     ` One Thousand Gnomes
     [not found]       ` <20140117181847.6c1f3831-mUKnrFFms3BCCTY1wZZT65JpZx93mCW/@public.gmane.org>
2014-01-20 10:45         ` Pavel Shilovsky
     [not found]           ` <CAKywueT=JsTkNC+w-vrN0ftam7F8Eqb8DXJ0w2G4q9vnt0hVNQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-20 13:34             ` One Thousand Gnomes
     [not found]               ` <20140120133424.09328108-mUKnrFFms3BCCTY1wZZT65JpZx93mCW/@public.gmane.org>
2014-01-21 13:19                 ` Pavel Shilovsky
2014-02-01 13:57         ` Jeff Layton
2014-02-01 13:20     ` Jeff Layton
     [not found]       ` <20140201082020.117bf3b3-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2014-02-04 12:03         ` Pavel Shilovsky
     [not found]           ` <CAKywueTAvxVV4+h3Vf3XLE+KnpPh_9zRGkHChTUR8x=i8zfDTw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-04 12:21             ` Jeff Layton
2014-01-17 10:07 ` [PATCH v7 3/7] locks: Disable LOCK_MAND support for MS_SHARELOCK mounts Pavel Shilovsky
2014-01-17 10:07 ` [PATCH v7 4/7] CIFS: Add O_DENY* open flags support Pavel Shilovsky
2014-01-17 10:07 ` [PATCH v7 5/7] NFSD: Pass share reservations flags to VFS Pavel Shilovsky
2014-01-17 10:07 ` [PATCH v7 6/7] NFSv4: Add deny state handling for nfs4_state struct Pavel Shilovsky
2014-01-17 10:07 ` [PATCH v7 7/7] NFSv4: Add O_DENY* open flags support Pavel Shilovsky
2014-01-17 18:43 ` [PATCH v7 0/7] Add O_DENY* support for VFS and CIFS/NFS Frank Filz
2014-01-20  9:56   ` Pavel Shilovsky
     [not found]     ` <CAKywueTOi-WPpgH7x3VK7EkGJXE8fHUqcLgSUm6o6UA+uaQtjA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-27 19:49       ` Frank Filz
     [not found] ` <1389953232-9428-1-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2014-01-17 10:07   ` [PATCH v7 2/7] VFS: Add O_DENYDELETE support for VFS Pavel Shilovsky
2014-01-20  8:14   ` [PATCH v7 0/7] Add O_DENY* support for VFS and CIFS/NFS Volker Lendecke
2014-01-20 10:20     ` Pavel Shilovsky
     [not found]       ` <CAKywueQwfFASPpevO8Z-_xwZqRjkzfkOceQJDya8D7FDW+UmMg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-20 10:31         ` Volker Lendecke
     [not found]           ` <E1W5C8U-000ozD-Ku-dqLtpHMqGvUyWpdLl23E4A@public.gmane.org>
2014-01-21 13:31             ` Pavel Shilovsky
     [not found]               ` <CAKywueQng9=u1YYwkYGCunWW8RBhARhJjEhBcoA6CKF6TrKSBg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-21 14:17                 ` Volker Lendecke
2014-01-31 15:51   ` Pavel Shilovsky [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-07-01 16:49 Pavel Shilovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKywueSAWjOFH7cCvjQScSiBMGLzGEApjTYNoV03gmzec8uxjQ@mail.gmail.com \
    --to=piastry-7qunaywfiewox3rin2dayq@public.gmane.org \
    --cc=bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org \
    --cc=linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
    --cc=wine-devel-5vRYHf7vrtgdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).