[Devel] [PATCH 1/2] ve/fs: Use comparison of signed integers in ve_mount_allowed()

Evgenii Shatokhin eshatokhin at virtuozzo.com
Tue Jan 12 05:11:31 PST 2016


https://jira.sw.ru/browse/PSBM-42825

This patch is for vzkernel from beta3 (that is, 3.10.0-229.7.2.*).

ve->mnr_nr is a signed integer which may become negative in some cases:
* if the increments and decrements of ve->mnr_nr race against each other
  and the decrements win;
* if something is mounted by one VE but unmounted by another VE.

sysctl_ve_mount_nr is unsigned.

So the comparison (ve->mnr_nr < sysctl_ve_mount_nr) can actually be
compiled as ((unsigned int)ve->mnr_nr < sysctl_ve_mount_nr).
ve_mount_allowed() would return 0 in that case and the mount operation
would fail as a result.

This patch fixes the problem.

Signed-off-by: Evgenii Shatokhin <eshatokhin at virtuozzo.com>
---
 include/linux/ve.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/ve.h b/include/linux/ve.h
index b9374a1..bf04275 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -238,7 +238,7 @@ static inline int ve_mount_allowed(void)
 {
 	struct ve_struct *ve = get_exec_env();
 
-	return ve_is_super(ve) || ve->mnt_nr < sysctl_ve_mount_nr;
+	return ve_is_super(ve) || ve->mnt_nr < (int)sysctl_ve_mount_nr;
 }
 
 static inline void ve_mount_nr_inc(void)
-- 
2.6.3



More information about the Devel mailing list