mdmon: ensure Unix domain socket is created with safe permissions.

In the unlikely case that mdmon is started with an overly
permissive umask, we don't want to risk giving away world acccess.

All other "mkdir" and  "O_CREAT" calls in mdmon and mdadm set
a suitably restrictive permission mask.  'bind' don't take an
explicit mask so it needs an implicit one.

Reported-by: Vincent Berg <vberg@ioactive.com>
Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2014-07-03 17:06:45 +10:00
parent f99a9e1563
commit 120ec6f7b9
1 changed files with 1 additions and 0 deletions

View File

@ -232,6 +232,7 @@ static int make_control_sock(char *devname)
addr.sun_family = PF_LOCAL;
strcpy(addr.sun_path, path);
umask(077); /* ensure no world write access */
if (bind(sfd, &addr, sizeof(addr)) < 0) {
close(sfd);
return -1;