Skip to contentSkip to conversation

mm: overcommit updates

PATCH In review Nikita Danilov 4 participants 6 messages Jan 4, 2005 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 2 lines · Linux Kernel Mailing List

ChangeSet 1.2136.3.17, 2005/01/03 20:15:37-08:00, [email protected]

[...]

Review

Quoted 4 lines
(quoted diff) +3 -0
+	/* Leave the last 3% for root */
+	if (current->euid)
+		allowed -= allowed / 32;

This results in

	/*
	 * Leave the last 3% for root
	 */
	if (!capable(CAP_SYS_ADMIN))
		allowed -= allowed / 32;
	allowed += total_swap_pages;

	/* Leave the last 3% for root */
	if (current->euid)
		allowed -= allowed / 32;

in security/commoncaps.c (and similarly in security/dummy.c). Why "super-user" reservation is handled twice, and with that antiquated current->euid check instead of capabilities? Broken merge?

On another account, shouldn't capable(CAP_SYS_ADMIN) checks in cap_vm_enough_memory() be replaced with capable(CAP_SYS_RESOURCE):
(CAP_SYS_RESOURCE is used by file systems to control reserved disk blocks)?

Nikita.

#2 lore raw

PATCH 1/1 remove duplicated patch fragment

Quoted 10 lines · Nikita Danilov
	/*
	 * Leave the last 3% for root
	 */
	if (!capable(CAP_SYS_ADMIN))
		allowed -= allowed / 32;

	/* Leave the last 3% for root */
	if (current->euid)
		allowed -= allowed / 32;
Quoted 3 lines

in security/commoncaps.c (and similarly in security/dummy.c). Why "super-user" reservation is handled twice, and with that antiquated current->euid check instead of capabilities? Broken merge?

Yes - sorry. The first of these two semi-identical fragments is from Alan and appeared in patch-2.6.9, two weeks after the patch under discussion was made. So, the second half can be dropped. Below a patch.

Quoted 4 lines

On another account, shouldn't capable(CAP_SYS_ADMIN) checks in cap_vm_enough_memory() be replaced with capable(CAP_SYS_RESOURCE):
(CAP_SYS_RESOURCE is used by file systems to control reserved disk blocks)?

The use of current->euid comes from the use of current->euid in dummy.c a few lines higher up in the same routine.
The use of CAP_SYS_ADMIN comes from the use of CAP_SYS_ADMIN in commoncap.c a few lines higher up in the same routine.

I have no strong opinion about what is best.

Andries

security/commoncap.c +0 -4
diff -uprN -X /linux/dontdiff a/security/commoncap.c b/security/commoncap.c
@@ -386,10 +386,6 @@ int cap_vm_enough_memory(long pages)
 		allowed -= allowed / 32;
 	allowed += total_swap_pages;
 
-	/* Leave the last 3% for root */
-	if (current->euid)
-		allowed -= allowed / 32;
-
 	/* Don't let a single process grow too big:
 	   leave 3% of the size of this process for other processes */
 	allowed -= current->mm->total_vm / 32;
Acked-by on v1 1/1
#3 lore raw

Re: [PATCH] remove duplicated patch fragment

Quoted 4 lines · * Andries Brouwer ([email protected]) wrote:

Yes - sorry. The first of these two semi-identical fragments is from Alan and appeared in patch-2.6.9, two weeks after the patch under discussion was made. So, the second half can be dropped. Below a patch.

Yes, can this please be applied? ;-)

thanks,
-chris

Signature · 1 line
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net
#4 lore raw

Re: [PATCH] remove duplicated patch fragment

In reply to Andries Brouwer
Quoted 6 lines · * Andries Brouwer ([email protected]) wrote:
Quoted 4 lines · Nikita Danilov

On another account, shouldn't capable(CAP_SYS_ADMIN) checks in cap_vm_enough_memory() be replaced with capable(CAP_SYS_RESOURCE):
(CAP_SYS_RESOURCE is used by file systems to control reserved disk blocks)?

Quoted 6 lines

The use of current->euid comes from the use of current->euid in dummy.c a few lines higher up in the same routine.
The use of CAP_SYS_ADMIN comes from the use of CAP_SYS_ADMIN in commoncap.c a few lines higher up in the same routine.

I have no strong opinion about what is best.

Unfortunately, this what committed on 2003/05/25 (IOW, it's been in there since 2.5.70). So, we can't really change that w/out possibly breaking things.

thanks,
-chris

Signature · 1 line
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net
#5 lore raw
In reply to Nikita Danilov

Looks like a broken merge to me. When the 3% trick was proposed I rewrote it as capabilities and submitted it to Linus, now it looks like some months later the original one has been regurgitated out of -mm

#6 lore raw
Quoted 3 lines · Alan Cox

Looks like a broken merge to me. When the 3% trick was proposed I rewrote it as capabilities and submitted it to Linus, now it looks like some months later the original one has been regurgitated out of -mm

No. The two semi-identical fragments have independent origins.

Andries