From: Amerigo Wang <amwang@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: esandeen@redhat.com, eteo@redhat.com, eparis@redhat.com,
Amerigo Wang <amwang@redhat.com>,
linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org,
sds@tycho.nsa.gov, hirofumi@mail.parknet.co.jp,
viro@zeniv.linux.org.uk
Subject: [Patch 2/2] vfs: allow file truncations when both suid and write permissions set
Date: Wed, 19 Aug 2009 00:44:55 -0400 [thread overview]
Message-ID: <20090819044720.5380.45783.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20090819044658.5380.43869.sendpatchset@localhost.localdomain>
With patch 1/2 applied, now we can just simply add ATTR_FORCE flag, to
remove suid on truncation.
Signed-off-by: WANG Cong <amwang@redhat.com>
Cc: Eric Sandeen <esandeen@redhat.com>
Cc: Eric Paris <eparis@redhat.com>
Cc: Eugene Teo <eteo@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---
diff --git a/fs/open.c b/fs/open.c
index dd98e80..40d1fa2 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -199,7 +199,7 @@ out:
int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
struct file *filp)
{
- int err;
+ int ret;
struct iattr newattrs;
/* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */
@@ -214,12 +214,14 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
}
/* Remove suid/sgid on truncate too */
- newattrs.ia_valid |= should_remove_suid(dentry);
+ ret = should_remove_suid(dentry);
+ if (ret)
+ newattrs.ia_valid |= ret | ATTR_FORCE;
mutex_lock(&dentry->d_inode->i_mutex);
- err = notify_change(dentry, &newattrs);
+ ret = notify_change(dentry, &newattrs);
mutex_unlock(&dentry->d_inode->i_mutex);
- return err;
+ return ret;
}
static long do_sys_truncate(const char __user *pathname, loff_t length)
next prev parent reply other threads:[~2009-08-19 4:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-19 4:44 [V5 Patch 0/2] fix file truncations when both suid and write permissions set Amerigo Wang
2009-08-19 4:44 ` [Patch 1/2] selinux: adjust rules for ATTR_FORCE Amerigo Wang
2009-08-19 4:44 ` Amerigo Wang [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-08-17 7:07 [V4 Patch 0/2] fix file truncations when both suid and write permissions set Amerigo Wang
2009-08-17 7:07 ` [Patch 2/2] vfs: allow " Amerigo Wang
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=20090819044720.5380.45783.sendpatchset@localhost.localdomain \
--to=amwang@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=eparis@redhat.com \
--cc=esandeen@redhat.com \
--cc=eteo@redhat.com \
--cc=hirofumi@mail.parknet.co.jp \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sds@tycho.nsa.gov \
--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 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).