From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Amerigo Wang <amwang@redhat.com>
Cc: akpm@linux-foundation.org, viro@zeniv.linux.org.uk,
linux-fsdevel@vger.kernel.org, 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 14:49:59 +0900 [thread overview]
Message-ID: <878whwuq9k.fsf@devron.myhome.or.jp> (raw)
In-Reply-To: <871vno1cn7.fsf@devron.myhome.or.jp> (OGAWA Hirofumi's message of "Fri, 07 Aug 2009 13:17:00 +0900")
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> writes:
> Sorry for same argument. I see. However, um...
>
> I found this piece in security/selinux/hooks.c
>
> static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr)
> {
> const struct cred *cred = current_cred();
>
> if (iattr->ia_valid & ATTR_FORCE)
> return 0;
>
> if (iattr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
> ATTR_ATIME_SET | ATTR_MTIME_SET))
> return dentry_has_perm(cred, NULL, dentry, FILE__SETATTR);
>
> return dentry_has_perm(cred, NULL, dentry, FILE__WRITE);
> }
>
> I guess it's assuming the ia_valid doesn't have (ATTR_MODE | ATTR_SIZE),
> but truncate() already does it, I don't know whether it's ok. The
> definition of ATTR_FORCE is unclear at all, it would be problem. But,
> I'm not sure though, I suspect the above code also has problem...
I found the SuSv3 says for ftruncate():
Upon successful completion, if fildes refers to a regular file,
ftruncate() shall mark for update the last data modification and last
file status change timestamps of the file and the S_ISUID and S_ISGID
bits of the file mode may be cleared. If the ftruncate() function is
unsuccessful, the file is unaffected.
And vmtruncate() can return error easily with RLIMIT_FSIZE or
->s_maxbytes. So, I think clearing s[ug]id first may be bad behavior
without good reason.
Thanks.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
next prev parent reply other threads:[~2009-08-07 5:50 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
2009-08-07 3:21 ` Amerigo Wang
2009-08-07 4:17 ` OGAWA Hirofumi
2009-08-07 5:49 ` OGAWA Hirofumi [this message]
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=878whwuq9k.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox