summaryrefslogtreecommitdiffstats
path: root/tools/hv/hv_kvp_daemon.c
diff options
context:
space:
mode:
authorTomas Hozza <thozza@redhat.com>2013-01-18 15:23:41 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-19 01:03:34 +0100
commit8467fdbb09ca0766b638171723624f3da8703055 (patch)
tree35ee42184fc4935fdafa9cebd1d26d0031cef912 /tools/hv/hv_kvp_daemon.c
parentDrivers: hv: Bind all vmbbus interrupts to the boot CPU (diff)
downloadlinux-8467fdbb09ca0766b638171723624f3da8703055.tar.xz
linux-8467fdbb09ca0766b638171723624f3da8703055.zip
tools: hv: Use CLOEXEC when opening kvp_pool files
Use CLOEXEC flag when opening kvp_pool_x files to prevent file descriptor leakage. Not using it was causing a problem when SELinux was enabled. Signed-off-by: Tomas Hozza <thozza@redhat.com> Acked-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/hv/hv_kvp_daemon.c')
-rw-r--r--tools/hv/hv_kvp_daemon.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index 384051745c5e..c800ea4c8bf9 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -151,7 +151,7 @@ static void kvp_update_file(int pool)
*/
kvp_acquire_lock(pool);
- filep = fopen(kvp_file_info[pool].fname, "w");
+ filep = fopen(kvp_file_info[pool].fname, "we");
if (!filep) {
kvp_release_lock(pool);
syslog(LOG_ERR, "Failed to open file, pool: %d", pool);
@@ -182,7 +182,7 @@ static void kvp_update_mem_state(int pool)
kvp_acquire_lock(pool);
- filep = fopen(kvp_file_info[pool].fname, "r");
+ filep = fopen(kvp_file_info[pool].fname, "re");
if (!filep) {
kvp_release_lock(pool);
syslog(LOG_ERR, "Failed to open file, pool: %d", pool);
@@ -246,13 +246,13 @@ static int kvp_file_init(void)
records_read = 0;
num_blocks = 1;
sprintf(fname, "%s/.kvp_pool_%d", KVP_CONFIG_LOC, i);
- fd = open(fname, O_RDWR | O_CREAT, 0644 /* rw-r--r-- */);
+ fd = open(fname, O_RDWR | O_CREAT | O_CLOEXEC, 0644 /* rw-r--r-- */);
if (fd == -1)
return 1;
- filep = fopen(fname, "r");
+ filep = fopen(fname, "re");
if (!filep)
return 1;