All of lore.kernel.org
 help / color / mirror / Atom feed
From: tal.tchwella@gmail.com
To: linux-kernel@vger.kernel.org
Cc: tchwella@mit.edu
Subject: [PATCH 2/3] socket checks for uds fds transfer
Date: Wed, 20 Mar 2013 06:09:06 -0700	[thread overview]
Message-ID: <1363784947-24060-3-git-send-email-tal.tchwella@gmail.com> (raw)
In-Reply-To: <1363784947-24060-1-git-send-email-tal.tchwella@gmail.com>

From: Tal Tchwella <tchwella@mit.edu>

This patch checks whether another user is trying to send a chrooted application by
a non-root user a fd to a directory, which will allow it to escape.
By preventing this kind of fd transfer to chrooted applications by non-root users,
certain security risks are mitigated.

Signed-off-by: Tal Tchwella <tchwella@mit.edu>
---
 net/core/scm.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/net/core/scm.c b/net/core/scm.c
index ff52ad0..e505528 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -282,6 +282,15 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
 	for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
 	     i++, cmfptr++)
 	{
+		/*
+		 * Restricts passing of fds via unix domain sockets to non-root
+		 * chrooted applications to files and does not allow directories
+		 * to be passed.
+		 */
+		if (current->user_chroot == CHROOT_USER_MODE) {
+			if (S_ISDIR(fp[i]->f_dentry->d_inode->i_mode))
+				continue;
+		}
 		int new_fd;
 		err = security_file_receive(fp[i]);
 		if (err)
-- 
1.7.9.5


  parent reply	other threads:[~2013-03-20 13:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-20 13:09 [PATCH 0/3] Patches to enable chroot for all users tal.tchwella
2013-03-20 13:09 ` [PATCH 1/3] enabled " tal.tchwella
2013-03-20 13:09 ` tal.tchwella [this message]
2013-03-20 13:09 ` [PATCH 3/3] open fds check when starting chroot tal.tchwella
2013-03-20 15:35 ` [PATCH 0/3] Patches to enable chroot for all users Casey Schaufler
  -- strict thread matches above, loose matches on Subject: below --
2013-03-20 12:53 Tal Tchwella
2013-03-20 12:53 ` [PATCH 2/3] socket checks for uds fds transfer Tal Tchwella

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=1363784947-24060-3-git-send-email-tal.tchwella@gmail.com \
    --to=tal.tchwella@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tchwella@mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.