Skip to contentSkip to conversation

trivial: make mmap_min_addr perms 600

PATCH In review Kyle McMartin 3 participants 4 messages Apr 21, 2010 – Apr 22, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trivial: make mmap_min_addr perms 600

Chuck points out that mmap_min_addr is 644...

CAP_SYS_RAWIO will deny users read/write to the file, let's let them see that this is intended.

---

kernel/sysctl.c +1 -1
index 8686b0f..5868481 100644
@@ -1209,7 +1209,7 @@ static struct ctl_table vm_table[] = {
 		.procname	= "mmap_min_addr",
 		.data		= &dac_mmap_min_addr,
 		.maxlen		= sizeof(unsigned long),
-		.mode		= 0644,
+		.mode		= 0600,
 		.proc_handler	= mmap_min_addr_handler,
 	},
 #endif
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Kyle McMartin

Chuck points out that mmap_min_addr is 644...

CAP_SYS_RAWIO will deny users read/write to the file, let's let them see that this is intended.

I'm fine with it. RAWIO was only really added to block writes as I recall, but I don't see a good reason normal users need to see this and blocking them with rwx perms first is a good idea.

James, do you want to pick up and push towards linus?

-Eric

Quoted 14 lines

---

kernel/sysctl.c +1 -1
index 8686b0f..5868481 100644
@@ -1209,7 +1209,7 @@ static struct ctl_table vm_table[] = {
 		.procname	= "mmap_min_addr",
 		.data		= &dac_mmap_min_addr,
 		.maxlen		= sizeof(unsigned long),
-		.mode		= 0644,
+		.mode		= 0600,
 		.proc_handler	= mmap_min_addr_handler,
 	},
 #endif
#2 lore raw
In reply to Kyle McMartin
Quoted 3 lines · Kyle McMartin

Chuck points out that mmap_min_addr is 644...
CAP_SYS_RAWIO will deny users read/write to the file, let's let them see that this is intended.

Hmm. Denying read is actually an unintended side-effect of the CAP_SYS_RAWIO check.

The value is useful information for an admin to see without being root ("is my system vulnerable to kernel NULL pointer attacks?") and its setting is trivially easy for an attacker to determine by calling mmap() in PAGE_SIZE increments starting at 0.

I would opt for greater transparency for the admin, and leave it 644 and instead more carefully check CAP_SYS_RAWIO.

---
 security/min_addr.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
security/min_addr.c +1 -1
index e86f297..f728728 100644
@@ -33,7 +33,7 @@ int mmap_min_addr_handler(struct ctl_table *table, int write,
 {
 	int ret;
 
-	if (!capable(CAP_SYS_RAWIO))
+	if (write && !capable(CAP_SYS_RAWIO))
 		return -EPERM;
 
 	ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
Signature · 6 lines
1.7.0.4


-- 
Kees Cook
Ubuntu Security Team