All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs receive hardening patches
@ 2015-04-14  9:17 Lauri Võsandi
  0 siblings, 0 replies; only message in thread
From: Lauri Võsandi @ 2015-04-14  9:17 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Lauri Võsandi

---
 cmds-receive.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/cmds-receive.c b/cmds-receive.c
index 44ef27e..6800401 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -867,15 +867,19 @@ static int do_receive(struct btrfs_receive *r, const char *tomnt, int r_fd,
 		goto out;
 	}
 
-	/*
-	 * find_mount_root returns a root_path that is a subpath of
-	 * dest_dir_full_path. Now get the other part of root_path,
-	 * which is the destination dir relative to root_path.
+	/**
+	 * Enforce chroot before parsing btrfs stream
 	 */
-	r->dest_dir_path = dest_dir_full_path + strlen(r->root_path);
-	while (r->dest_dir_path[0] == '/')
-		r->dest_dir_path++;
+	if (chroot(dest_dir_full_path)) {
+		fprintf(stderr,
+			"ERROR: failed to chroot to %s\n",
+			dest_dir_full_path);
+		ret = -errno;
+		goto out;
+	}
 
+	r->root_path = r->dest_dir_path = strdup("/");
+	
 	ret = subvol_uuid_search_init(r->mnt_fd, &r->sus);
 	if (ret < 0)
 		goto out;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-04-14  9:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-14  9:17 [PATCH] Btrfs receive hardening patches Lauri Võsandi

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.