5563a724f6
- There are some important fixes merged in mdadm upstream which should go with jsc#SLE-13700. This is the update from upstream mdadm including the important fixes we should have. - Detail: show correct raid level when the array is inactive (jsc#SLE-13700) 0095-Detail-show-correct-raid-level-when-the-array-is-ina.patch - Don't create bitmap for raid5 with journal disk (jsc#SLE-13700) 0096-Don-t-create-bitmap-for-raid5-with-journal-disk.patch - Monitor: refresh mdstat fd after select (jsc#SLE-13700) 0097-Monitor-refresh-mdstat-fd-after-select.patch - Monitor: stop notifing about containers. (jsc#SLE-13700) 0098-Monitor-stop-notifing-about-containers.patch - mdmonitor: set small delay once (jsc#SLE-13700) 0099-mdmonitor-set-small-delay-once.patch - Check if other Monitor instance running before fork. (jsc#SLE-13700) 0100-Check-if-other-Monitor-instance-running-before-fork.patch - Super1: allow RAID0 layout setting to be removed. (jsc#SLE-13700) 0101-Super1-allow-RAID0-layout-setting-to-be-removed.patch - Detail: fix segfault during IMSM raid creation (jsc#SLE-13700) 0102-Detail-fix-segfault-during-IMSM-raid-creation.patch - Create.c: close mdfd and generate uevent (jsc#SLE-13700) 0103-Create.c-close-mdfd-and-generate-uevent.patch - imsm: update num_data_stripes according to dev_size (jsc#SLE-13700) 0104-imsm-update-num_data_stripes-according-to-dev_size.patch - imsm: remove redundant calls to imsm_get_map (jsc#SLE-13700) OBS-URL: https://build.opensuse.org/request/show/853269 OBS-URL: https://build.opensuse.org/package/show/Base:System/mdadm?expand=0&rev=191
56 lines
1.6 KiB
Diff
56 lines
1.6 KiB
Diff
From ca4b156b2059ee00a9143313267ee4a098967d76 Mon Sep 17 00:00:00 2001
|
|
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
|
|
Date: Tue, 24 Nov 2020 16:41:01 +0100
|
|
Subject: [PATCH 12/17] Monitor: don't use default modes when creating a file
|
|
|
|
Replace fopen() calls by open() with creation mode directly specified.
|
|
This fixes the potential security issue. Use octal values instead masks.
|
|
|
|
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
|
|
---
|
|
Monitor.c | 17 ++++++++++++-----
|
|
1 file changed, 12 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/Monitor.c b/Monitor.c
|
|
index 7fd4808..a82e99d 100644
|
|
--- a/Monitor.c
|
|
+++ b/Monitor.c
|
|
@@ -305,8 +305,11 @@ static int make_daemon(char *pidfile)
|
|
if (!pidfile)
|
|
printf("%d\n", pid);
|
|
else {
|
|
- FILE *pid_file;
|
|
- pid_file=fopen(pidfile, "w");
|
|
+ FILE *pid_file = NULL;
|
|
+ int fd = open(pidfile, O_WRONLY | O_CREAT | O_TRUNC,
|
|
+ 0644);
|
|
+ if (fd >= 0)
|
|
+ pid_file = fdopen(fd, "w");
|
|
if (!pid_file)
|
|
perror("cannot create pid file");
|
|
else {
|
|
@@ -368,13 +371,17 @@ static void write_autorebuild_pid()
|
|
{
|
|
char path[PATH_MAX];
|
|
int pid;
|
|
- FILE *fp;
|
|
+ FILE *fp = NULL;
|
|
sprintf(path, "%s/autorebuild.pid", MDMON_DIR);
|
|
|
|
- if (mkdir(MDMON_DIR, S_IRWXU) < 0 && errno != EEXIST) {
|
|
+ if (mkdir(MDMON_DIR, 0700) < 0 && errno != EEXIST) {
|
|
pr_err("Can't create autorebuild.pid file\n");
|
|
} else {
|
|
- fp = fopen(path, "w");
|
|
+ int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0700);
|
|
+
|
|
+ if (fd >= 0)
|
|
+ fp = fdopen(fd, "w");
|
|
+
|
|
if (!fp)
|
|
pr_err("Can't create autorebuild.pid file\n");
|
|
else {
|
|
--
|
|
2.26.2
|
|
|