All of lore.kernel.org
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: akpm@linux-foundation.org
Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
	amwang@redhat.com, eparis@redhat.com, esandeen@redhat.com,
	eteo@redhat.com
Subject: Re: [patch 12/12] vfs: allow file truncations when both suid and write permissions set
Date: Fri, 07 Aug 2009 11:32:52 +0900	[thread overview]
Message-ID: <87ocqs2w17.fsf@devron.myhome.or.jp> (raw)
In-Reply-To: <200908062310.n76NAIEo013014@imap1.linux-foundation.org> (akpm@linux-foundation.org's message of "Thu, 06 Aug 2009 16:10:18 -0700")

akpm@linux-foundation.org writes:

> diff -puN fs/open.c~vfs-allow-file-truncations-when-both-suid-and-write-permissions-set fs/open.c
> --- a/fs/open.c~vfs-allow-file-truncations-when-both-suid-and-write-permissions-set
> +++ a/fs/open.c
> @@ -213,11 +213,15 @@ int do_truncate(struct dentry *dentry, l
>  		newattrs.ia_valid |= ATTR_FILE;
>  	}
>  
> +	mutex_lock(&dentry->d_inode->i_mutex);
>  	/* Remove suid/sgid on truncate too */
> -	newattrs.ia_valid |= should_remove_suid(dentry);
> +	err = dentry_remove_suid(dentry);
> +	if (err)
> +		goto unlock;

Can't we use ATTR_FORCE for this? Because this calls notify_change()
twice, and I guess this removes s[ug]id even if vmtruncate() (or in
future ->truncate() may return error) or something returned error.

I think it would not be good behavior.

Thanks.

> -	mutex_lock(&dentry->d_inode->i_mutex);
>  	err = notify_change(dentry, &newattrs);
> +
> + unlock:
>  	mutex_unlock(&dentry->d_inode->i_mutex);
>  	return err;
>  }
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

  reply	other threads:[~2009-08-07  2:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-06 23:10 [patch 12/12] vfs: allow file truncations when both suid and write permissions set akpm
2009-08-07  2:32 ` OGAWA Hirofumi [this message]
2009-08-07  3:21   ` Amerigo Wang
2009-08-07  4:17     ` OGAWA Hirofumi
2009-08-07  5:49       ` OGAWA Hirofumi
2009-08-07  9:20         ` Amerigo Wang
2009-08-07 11:06           ` OGAWA Hirofumi
2009-08-07  9:27       ` Amerigo Wang
2009-08-07 11:02         ` OGAWA Hirofumi
2009-08-07 11:25           ` OGAWA Hirofumi
2009-08-10  2:00             ` Amerigo Wang
2009-08-10  4:34               ` OGAWA Hirofumi

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=87ocqs2w17.fsf@devron.myhome.or.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=akpm@linux-foundation.org \
    --cc=amwang@redhat.com \
    --cc=eparis@redhat.com \
    --cc=esandeen@redhat.com \
    --cc=eteo@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.