|
|
a60cd7 |
From 10bea037a2ad82616b3698d07d07d287481e1bed Mon Sep 17 00:00:00 2001
|
|
|
a60cd7 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
a60cd7 |
Date: Wed, 6 May 2015 14:04:42 +0200
|
|
|
a60cd7 |
Subject: [ABRT PATCH] daemon: harden against race conditions in DELETE
|
|
|
a60cd7 |
|
|
|
a60cd7 |
There is a race between checking dump dir accessibility and deleting it
|
|
|
a60cd7 |
in abrt-server.
|
|
|
a60cd7 |
|
|
|
a60cd7 |
Related: #1214457.
|
|
|
a60cd7 |
|
|
|
a60cd7 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
a60cd7 |
---
|
|
|
a60cd7 |
src/daemon/abrt-server.c | 21 +++++++++++++++++++--
|
|
|
a60cd7 |
1 file changed, 19 insertions(+), 2 deletions(-)
|
|
|
a60cd7 |
|
|
|
a60cd7 |
diff --git a/src/daemon/abrt-server.c b/src/daemon/abrt-server.c
|
|
|
a60cd7 |
index 1030461..130c24a 100644
|
|
|
a60cd7 |
--- a/src/daemon/abrt-server.c
|
|
|
a60cd7 |
+++ b/src/daemon/abrt-server.c
|
|
|
a60cd7 |
@@ -91,8 +91,16 @@ static int delete_path(const char *dump_dir_name)
|
|
|
a60cd7 |
error_msg("Problem directory '%s' isn't owned by root:abrt or others are not restricted from access", dump_dir_name);
|
|
|
a60cd7 |
return 400; /* */
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
- if (!dump_dir_accessible_by_uid(dump_dir_name, client_uid))
|
|
|
a60cd7 |
+
|
|
|
a60cd7 |
+ int dir_fd = dd_openfd(dump_dir_name);
|
|
|
a60cd7 |
+ if (dir_fd < 0)
|
|
|
a60cd7 |
+ {
|
|
|
a60cd7 |
+ perror_msg("Can't open problem directory '%s'", dump_dir_name);
|
|
|
a60cd7 |
+ return 400;
|
|
|
a60cd7 |
+ }
|
|
|
a60cd7 |
+ if (!fdump_dir_accessible_by_uid(dir_fd, client_uid))
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
+ close(dir_fd);
|
|
|
a60cd7 |
if (errno == ENOTDIR)
|
|
|
a60cd7 |
{
|
|
|
a60cd7 |
error_msg("Path '%s' isn't problem directory", dump_dir_name);
|
|
|
a60cd7 |
@@ -102,7 +110,16 @@ static int delete_path(const char *dump_dir_name)
|
|
|
a60cd7 |
return 403; /* Forbidden */
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
|
|
|
a60cd7 |
- delete_dump_dir(dump_dir_name);
|
|
|
a60cd7 |
+ struct dump_dir *dd = dd_fdopendir(dir_fd, dump_dir_name, /*flags:*/ 0);
|
|
|
a60cd7 |
+ if (dd)
|
|
|
a60cd7 |
+ {
|
|
|
a60cd7 |
+ if (dd_delete(dd) != 0)
|
|
|
a60cd7 |
+ {
|
|
|
a60cd7 |
+ error_msg("Failed to delete problem directory '%s'", dump_dir_name);
|
|
|
a60cd7 |
+ dd_close(dd);
|
|
|
a60cd7 |
+ return 400;
|
|
|
a60cd7 |
+ }
|
|
|
a60cd7 |
+ }
|
|
|
a60cd7 |
|
|
|
a60cd7 |
return 0; /* success */
|
|
|
a60cd7 |
}
|
|
|
a60cd7 |
--
|
|
|
a60cd7 |
1.8.3.1
|
|
|
a60cd7 |
|