From: Jeff Layton <jlayton@samba.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Steve French <sfrench@samba.org>,
linux-cifs@vger.kernel.org, samba-technical@lists.samba.org
Subject: Re: [patch] cifs: accidentally creating empty files
Date: Thu, 13 Oct 2011 13:27:55 -0400 [thread overview]
Message-ID: <20111013132755.6c5db87e@barsoom.rdu.redhat.com> (raw)
In-Reply-To: <20110927212810.GA12900@elgon.mountain>
On Wed, 28 Sep 2011 00:28:10 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> This solves a problem for where a user without write permissions
> was creating empty files. This function was supposed to do a lookup
> only, the create happens later.
>
Not quite. This uses the open-intent goop in the VFS layer that Al Viro
is trying to get rid of. The idea here is that doing a lookup just to
do an open is a waste, when you could just attempt the open. There's no
real reason to exempt creates from that if cifs used a sane permissions
model...
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
> index 72d448b..8515afe 100644
> --- a/fs/cifs/dir.c
> +++ b/fs/cifs/dir.c
> @@ -566,11 +566,13 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry,
> if (nd && !(nd->flags & LOOKUP_DIRECTORY) &&
> (nd->flags & LOOKUP_OPEN) && !pTcon->broken_posix_open &&
> (nd->intent.open.file->f_flags & O_CREAT)) {
> + unsigned int f_flags;
> +
> + f_flags = (nd->intent.open.file->f_flags & ~O_CREAT);
> rc = cifs_posix_open(full_path, &newInode,
> parent_dir_inode->i_sb,
> nd->intent.open.create_mode,
> - nd->intent.open.file->f_flags, &oplock,
> - &fileHandle, xid);
> + f_flags, &oplock, &fileHandle, xid);
...so this makes it only do the open at lookup time if the
file already exists.
I suspect the real problem here is that cifs is trying to
enforce permissions on the client, which happens after the
lookup.
If the client simply allowed the server to handle the
permissions (and used the right credentials for each user),
then this would probably work fine. Another nail in the coffin
for the whole model of client side permissions enforcement,
IMO...
In any case, this seems fine to me, so...
> /*
> * The check below works around a bug in POSIX
> * open in samba versions 3.3.1 and earlier where
Acked-by: Jeff Layton <jlayton@samba.org>
next prev parent reply other threads:[~2011-10-13 17:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-27 21:28 [patch] cifs: accidentally creating empty files Dan Carpenter
2011-10-13 14:00 ` Dan Carpenter
2011-10-13 15:45 ` Steve French
2011-10-13 17:27 ` Jeff Layton [this message]
[not found] ` <20111013132755.6c5db87e-xSBYVWDuneFaJnirhKH9O4GKTjYczspe@public.gmane.org>
2011-10-13 18:09 ` Steve French
2011-10-20 2:14 ` Steve French
2011-10-28 7:20 ` Dan Carpenter
[not found] ` <20111028072019.GA14900-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org>
2011-10-28 15:27 ` Steve French
[not found] ` <CAH2r5msb_+tenSg1kWCn_0xi2EZu6vboqvmbQ17vRBYoqHp2Eg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-10-29 3:44 ` Jeff Layton
[not found] ` <20111028234406.01fd23ba-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-10-29 5:07 ` Steve French
[not found] ` <CAH2r5mvHF0X6PQ8FyBfVEpQeyWgd7RGkawJykapkKt0K84QTHw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-10-29 5:48 ` Jeff Layton
2011-10-29 22:03 ` Steve French
[not found] ` <CAH2r5muq4n34Liy_=CQQX-PeTinJFDAPi81fA-eqsTcXw5remQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-10-30 2:48 ` Jeff Layton
[not found] ` <20111029224852.15ee6302-4QP7MXygkU+dMjc06nkz3ljfA9RmPOcC@public.gmane.org>
2011-10-30 2:53 ` Steve French
[not found] ` <CAH2r5msVoEuxo8vGj6sYjjNqjPeo9wxa-r7bAq6Or1_xS9EWFg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-10-30 5:36 ` Jeff Layton
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=20111013132755.6c5db87e@barsoom.rdu.redhat.com \
--to=jlayton@samba.org \
--cc=dan.carpenter@oracle.com \
--cc=linux-cifs@vger.kernel.org \
--cc=samba-technical@lists.samba.org \
--cc=sfrench@samba.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