From: Vasily Kulikov <segoon@openwall.com>
To: kernel-hardening@lists.openwall.com, Kees Cook <keescook@chromium.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Eric Paris <eparis@redhat.com>, Matthew Wilcox <matthew@wil.cx>,
Doug Ledford <dledford@redhat.com>,
Joe Korty <joe.korty@ccur.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Ingo Molnar <mingo@elte.hu>, David Howells <dhowells@redhat.com>,
James Morris <james.l.morris@oracle.com>,
linux-doc@vger.kernel.org,
Dan Rosenberg <drosenberg@vsecurity.com>
Subject: Re: [kernel-hardening] [PATCH 1/2] fs: add link restrictions
Date: Wed, 8 Aug 2012 16:19:38 +0400 [thread overview]
Message-ID: <20120808121938.GA9995@albatros> (raw)
In-Reply-To: <1343262548-21743-2-git-send-email-keescook@chromium.org>
Hi Kees,
On Wed, Jul 25, 2012 at 17:29 -0700, Kees Cook wrote:
> +/**
> + * safe_hardlink_source - Check for safe hardlink conditions
> + * @inode: the source inode to hardlink from
> + *
> + * Return false if at least one of the following conditions:
> + * - inode is not a regular file
> + * - inode is setuid
> + * - inode is setgid and group-exec
> + * - access failure for read and write
> + *
> + * Otherwise returns true.
> + */
> +static bool safe_hardlink_source(struct inode *inode)
> +{
> + umode_t mode = inode->i_mode;
> +
> + /* Special files should not get pinned to the filesystem. */
> + if (!S_ISREG(mode))
> + return false;
> +
> + /* Setuid files should not get pinned to the filesystem. */
> + if (mode & S_ISUID)
> + return false;
We don't want to make hardlinks of SUID files, but we still allow to create
hardlinks to SUID'ish cap'ed files. Probably check whether the inode is
setcap'ed?
Probably we can enhance this further and allow LSMs to define whether this
particular file is special in LSM's point of view (IOW, it can be able to move
a process to another security domain which is served by LSM).
> +
> + /* Executable setgid files should not get pinned to the filesystem. */
> + if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
> + return false;
> +
> + /* Hardlinking to unreadable or unwritable sources is dangerous. */
> + if (inode_permission(inode, MAY_READ | MAY_WRITE))
> + return false;
> +
> + return true;
> +}
Thanks,
--
Vasily
next prev parent reply other threads:[~2012-08-08 12:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-26 0:29 [RESEND][PATCH v2012.5 0/2] fs: add link restrictions Kees Cook
2012-07-26 0:29 ` [PATCH 1/2] " Kees Cook
2012-08-03 4:26 ` James Morris
2012-08-03 17:01 ` [kernel-hardening] " Kees Cook
2012-08-06 23:55 ` Eric W. Biederman
2012-08-06 23:57 ` Kees Cook
2012-08-06 23:59 ` [kernel-hardening] " Kees Cook
2012-08-08 12:19 ` Vasily Kulikov [this message]
2012-08-12 6:34 ` Kees Cook
2012-08-12 19:32 ` [kernel-hardening] " Vasily Kulikov
2012-07-26 0:29 ` [PATCH 2/2] fs: add link restriction audit reporting Kees Cook
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=20120808121938.GA9995@albatros \
--to=segoon@openwall.com \
--cc=akpm@linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=dledford@redhat.com \
--cc=drosenberg@vsecurity.com \
--cc=ebiederm@xmission.com \
--cc=eparis@redhat.com \
--cc=james.l.morris@oracle.com \
--cc=joe.korty@ccur.com \
--cc=keescook@chromium.org \
--cc=kernel-hardening@lists.openwall.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=mingo@elte.hu \
--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).