Skip to contentSkip to conversation

post_create: setxattr failed, rc=122 (dev=09:03 ino=992086)

DISCUSSION Russell Coker 2 participants 6 messages Jan 7, 2004 – Jan 8, 2004 SELinux security module

lore
Share & tools
lore
#0 lore raw

What is the meaning of the above error?

Signature · 10 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#1 lore raw
Quoted 1 line · Russell Coker

What is the meaning of the above error?

errno 122 == EDQUOT, quota exceeded. So SELinux was unable to set the attribute value on a newly created file because of a quota restriction on the creating process. So the inode on disk is left unlabeled, although the SID on the incore inode will be set correctly. Not clear that MAC labels should count against quotas, although a failure at the same point would still be possible due to other reasons, e.g. no free space on the filesystem or an I/O error when trying to write the attribute value.

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#2 lore raw
Quoted 11 lines · Stephen Smalley
Quoted 1 line · Russell Coker

What is the meaning of the above error?

errno 122 == EDQUOT, quota exceeded. So SELinux was unable to set the attribute value on a newly created file because of a quota restriction on the creating process. So the inode on disk is left unlabeled, although the SID on the incore inode will be set correctly. Not clear that MAC labels should count against quotas, although a failure at the same point would still be possible due to other reasons, e.g. no free space on the filesystem or an I/O error when trying to write the attribute value.

Can this be changed? I think that ideally the quota would not be counted for file creation. But it may be an easier solution for the creation corner cases to have the creat() fail if the label can not be applied.

What would happen to the file in question? "find" does not report any file with that Inode in the file system, do I assume that the creating process detected the error about being unable to write any data to the file and then unlinked the zero byte file while the Inode was still in-core?

Signature · 10 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#3 lore raw
Quoted 3 lines · Russell Coker

Can this be changed? I think that ideally the quota would not be counted for file creation. But it may be an easier solution for the creation corner cases to have the creat() fail if the label can not be applied.

The post_create hook has no way to abort the create at present, and it would have to unlink the file as it has already been created at that point. Filesystem support for atomic create+setxattr would be nice, but not likely at this point.

Quoted 4 lines

What would happen to the file in question? "find" does not report any file with that Inode in the file system, do I assume that the creating process detected the error about being unable to write any data to the file and then unlinked the zero byte file while the Inode was still in-core?

Probably. Given that the contexts are small, the program likely failed upon attempts to write data to the file due to the same quota restriction and unlinked the file as part of its own cleanup. If the program did not unlink it, then the file would stay around, continuing to be treated as if it has the right SID as long as the inode remained incore, but reverting to the 'file' SID, i.e. file_t type, if the inode were evicted and then re-read subsequently or upon a reboot.

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#4 lore raw
Quoted 9 lines · Stephen Smalley
Quoted 5 lines

What would happen to the file in question?  "find" does not report any file with that Inode in the file system, do I assume that the creating process detected the error about being unable to write any data to the file and then unlinked the zero byte file while the Inode was still in-core?

Probably.  Given that the contexts are small, the program likely failed upon attempts to write data to the file due to the same quota restriction and unlinked the file as part of its own cleanup.  If the

I've tracked this down. The file in question was created by a user who has no disk space quota but lots of Inode quota. So the file gets created but they aren't allowed to allocate any more space.

A work-around for 99% of occurances of this would be to refuse to create a file when there is no disk space. In a more general sense we could perhaps have a sysctl entry for the number of free blocks in the quota necessary to create a file. We could specify that there must be two blocks left in the quota to create a file, one for the XATTR and one for data. Allowing creation of a zero byte file does little good.

Quoted 4 lines

program did not unlink it, then the file would stay around, continuing to be treated as if it has the right SID as long as the inode remained incore, but reverting to the 'file' SID, i.e. file_t type, if the inode were evicted and then re-read subsequently or upon a reboot.

Under the current policy this means a file that the user would never be able to unlink, and therefore a call for administrator intervention. This of course won't work for a university.

I have been discussing file_t with Dan, he suggests making the default policy (which isn't so restrictive) allow full access to file_t for almost everyone. It would solve this as well as some other corner cases. What do you think?

Signature · 11 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page



--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#5 lore raw
Quoted 3 lines · Russell Coker

I have been discussing file_t with Dan, he suggests making the default policy (which isn't so restrictive) allow full access to file_t for almost everyone. It would solve this as well as some other corner cases. What do you think?

That is precisely the opposite of what you want.

Signature · 8 lines
Stephen Smalley <[email protected]>
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.