Subject: linux 3.14.22 and patch-3.14.17-vs2.3.6.13.diff
From: Corey Wright <undefined@pobox.com>
Date: Mon, 27 Oct 2014 03:41:34 -0500
Mon, 27 Oct 2014 03:41:34 -0500
applying patch-3.14.17-vs2.3.6.13.diff to linux 3.14.22 fails in both
patching and testing/functionality.

the upstream addition of including "linux/hash.h" in "fs/namei.c" [1]
invalidated the patch hunk context.

[1]
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?h=linux-3.10.y&id=d4c96061fddd129778ce8b70fb093aa532f422d0

the upstream change of masking all capabilities above CAP_LAST_CAP (which the
linux-vserver patch does not adjust to account for its own CAP_CONTEXT)
breaks changing/manipulating contexts.

# vserver-info | grep V

Assumed 'SYSINFO' as no other option given; try '--help' for more information.
Versions:
                   VS-API: ???
                      VCI: ???
# chcontext --xid 1 -- true
chcontext: vc_new_s_context(): Function not implemented

[2]
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?h=linux-3.10.y&id=76f01555c78e496203105bd29b878db3431a2260

the attached patches account for the change in patch hunk context and the
masking of CAP_CONTEXT.

1. acquire linux-3.14.22
2. apply patch-3.14.17-vs2.3.6.13.diff
3. apply the attached patch-3.14.17-19-include_hash-vs2.3.6.13.diff
4. apply the attached patch-3.14.17-19-remove_caps-vs2.3.6.13.diff
5. manually fix the Makefile reject (EXTRAVERSION)

i've built the resulting kernel and tested it in virtualbox against testme.sh
and testfs.sh, started-entered-exited-stopped a vserver guest, and (specific
to the capabilities fix) tested "vserver-info | grep V" and "chcontext --xid
1 -- true" (though that's also indirectly tested through testme.sh and
exercising a vserver guest).

corey
--
undefined@pobox.com


addition of "#include <linux/hash.h>" invalidated patch hunk context

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?h=linux-3.14.y&id=a8be8af18485f9fade90e1743d940252a39eec84

diff -urNpd linux-3.14.22-vs2.3.6.13~/fs/namei.c linux-3.14.22-vs2.3.6.13/fs/namei.c
--- linux-3.14.22-vs2.3.6.13~/fs/namei.c	2014-10-15 21:33:01.000000000 -0500
+++ linux-3.14.22-vs2.3.6.13/fs/namei.c	2014-10-15 21:41:29.000000000 -0500
@@ -35,9 +35,19 @@
 #include <linux/fs_struct.h>
 #include <linux/posix_acl.h>
 #include <linux/hash.h>
+#include <linux/proc_fs.h>
+#include <linux/magic.h>
+#include <linux/vserver/inode.h>
+#include <linux/vs_base.h>
+#include <linux/vs_tag.h>
+#include <linux/vs_cowbl.h>
+#include <linux/vs_device.h>
+#include <linux/vs_context.h>
+#include <linux/pid_namespace.h>
 #include <asm/uaccess.h>
 
 #include "internal.h"
+#include "proc/internal.h"
 #include "mount.h"
 
 /* [Feb-1997 T. Schoebel-Theuer]


upstream addition of masking all capabilities above CAP_LAST_CAP did not
account for linux-vserver CAP_CONTEXT

https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?h=linux-3.14.y&id=1ae2c97a0a284ca73754acd2b3be33fe4f2505b2

diff -urNpd linux-3.14.22-vs2.3.6.13~/include/linux/capability.h linux-3.14.22-vs2.3.6.13/include/linux/capability.h
--- linux-3.14.22-vs2.3.6.13~/include/linux/capability.h	2014-10-15 01:42:04.000000000
-0500
+++ linux-3.14.22-vs2.3.6.13/include/linux/capability.h	2014-10-15 22:00:45.000000000
-0500
@@ -79,7 +79,8 @@ extern const kernel_cap_t __cap_init_eff
 #else /* HAND-CODED capability initializers */
 
 #define CAP_LAST_U32			((_KERNEL_CAPABILITY_U32S) - 1)
-#define CAP_LAST_U32_VALID_MASK		(CAP_TO_MASK(CAP_LAST_CAP + 1) -1)
+#define CAP_LAST_U32_VALID_MASK		((CAP_TO_MASK(CAP_LAST_CAP + 1) -1) \
+					| CAP_TO_MASK(CAP_CONTEXT))
 
 # define CAP_EMPTY_SET    ((kernel_cap_t){{ 0, 0 }})
 # define CAP_FULL_SET     ((kernel_cap_t){{ ~0, CAP_LAST_U32_VALID_MASK }})