[aklug] Re: Strange hard linking

From: <bryanm@acsalaska.net>
Date: Sat Nov 27 2010 - 02:41:41 AKST

On Fri, November 26, 2010 5:45 pm, Shane R. Spencer wrote:
> On 11/26/2010 02:24 PM, Christopher Howard wrote:
>> So, I was messing around the other day, and found this rather wierd behavior
>> in Linux:
<snip>
>> So, in summary, as a non-root user, I have the ability to "create"
>> (preserve?) files that I do not own and that I cannot delete.
>>
>
> What filesystem are you using? What distro?
>
> Shouldn't be possible if your operating system is at all secure (doesn't run
> ln as setuid
> root). You cannot modify (including create) files owned by root even if it's
> the same
> inode as another file. In order not to sound like a dork I attempted the
> following on
> XFS/JFS2/GFS2/NFS+EXT4/EXT4
>
> spencersr@banzai:/tmp$ sudo touch woman
> spencersr@banzai:/tmp$ ln woman man
> ln: creating hard link `man' => `woman': Operation not permitted
>
> Here.. running ln as setuid root gets things rocking :)
>
> spencersr@banzai:/tmp$ sudo chmod u+s /bin/ln
> spencersr@banzai:/tmp$ ln woman man
> spencersr@banzai:/tmp$ ls -lai man woman
> 34857277 -rw-r--r-- 2 root root 0 2010-11-26 17:36 man
> 34857277 -rw-r--r-- 2 root root 0 2010-11-26 17:36 woman

This is really interesting. Let me add my own data. On my
Slackware 11 box, I'm able to create root-owned links, just
as Christopher did, on JFS and EXT3 filesystems. A minix
filesystem will *not* let me do it.

The directory you're in makes a difference, though. I'm able
to hardlink *and* remove root-owned files in a directory owned
by my regular user.

Shane, do you have any older filesystems you could try on the
same system? That could help narrow down whether it's a
filesystem issue or an OS (Linux VFS?) issue.

--
Bryan Medsker
bryanm@acsalaska.net
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Sat Nov 27 02:41:49 2010

This archive was generated by hypermail 2.1.8 : Sat Nov 27 2010 - 02:41:49 AKST