Subject: patching linux 4.1.11 with linux-vserver patch
From: Corey Wright <undefined@pobox.com>
Date: Fri, 23 Oct 2015 12:00:44 -0500
Fri, 23 Oct 2015 12:00:44 -0500
patch-4.1.3-vs2.3.8.2_donotuse.diff fails to apply to linux 4.1.11 in two
places (besides Makefile which will fail on anything other than 4.1.3).

patching file Makefile
Hunk #1 FAILED at 1.
1 out of 1 hunk FAILED -- saving rejects to file Makefile.rej
...
patching file fs/namei.c
Hunk #4 FAILED at 1551.
Hunk #5 succeeded at 1610 (offset 29 lines).
Hunk #6 succeeded at 2605 (offset 29 lines).
Hunk #7 succeeded at 2687 (offset 29 lines).
Hunk #8 succeeded at 2741 (offset 29 lines).
Hunk #9 succeeded at 3244 (offset 29 lines).
Hunk #10 succeeded at 3382 (offset 29 lines).
Hunk #11 succeeded at 3419 (offset 29 lines).
Hunk #12 succeeded at 3545 (offset 29 lines).
Hunk #13 succeeded at 4119 (offset 29 lines).
Hunk #14 succeeded at 4624 (offset 29 lines).
1 out of 14 hunks FAILED -- saving rejects to file fs/namei.c.rej
...
patching file kernel/printk/printk.c
Hunk #2 FAILED at 488.
Hunk #3 succeeded at 1265 with fuzz 2 (offset -3 lines).
Hunk #4 succeeded at 1278 (offset -3 lines).
Hunk #5 succeeded at 1300 (offset -3 lines).
1 out of 5 hunks FAILED -- saving rejects to file kernel/printk/printk.c.rej

upstream changed some code involving CAP_SYSLOG which doesn't directly affect
the linux-vserver patch, but changed the patch's context (adjacent source
code) and confused patch as to where to apply the associated patch hunk.  the
upstream change was
http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/kernel/printk/printk.c?h=linux-4.1.y&id=ae41bfc68161ea5d280091ccb9593e9f68d5db44

upstream changed some code involving dentry checking which broke the
linux-vserver patch context.  i'm not too sure about my "fix" as the only
thing affected was a "FIXME" comment which doesn't provide much context and
is hard to test for correctness. ;)  the upstream change was
http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/fs/namei.c?h=linux-4.1.y&id=2058efbcb0eb148db2086266cfb048da42fd0a93

step-by-step process:
0. get linux-4.1.11
1. apply patch-4.1.3-vs2.3.8.2_donotuse.diff [1]
2. apply delta-cow-fix30.diff [2]
2. apply attached patch-4.1.3-11-vs2.3.8.2_donotuse.diff

[1] http://vserver.13thfloor.at/Experimental/patch-4.1.3-vs2.3.8.2_donotuse.diff
[2] http://people.linux-vserver.org/~dhozac/p/k/delta-cow-fix30.diff

resulting kernel tested with debian wheezy on virtualbox, passing testme.sh
and testfs.sh, and successfully starting, entering, exiting, and stopping a
guest using util-vserver 0.30.216-pre3117 (with cleanupMount removed).

thanks to herbert for the 4.1.3 patch and daniel for the cow patch.

corey
--
undefined@pobox.com


http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/fs/namei.c?h=linux-4.1.y&id=2058efbcb0eb148db2086266cfb048da42fd0a93

diff -urNpd linux-4.1.11-vs2.3.8.2~/fs/namei.c linux-4.1.11-vs2.3.8.2/fs/namei.c
--- linux-4.1.11-vs2.3.8.2~/fs/namei.c	2015-10-22 19:05:02.606578156 -0500
+++ linux-4.1.11-vs2.3.8.2/fs/namei.c	2015-10-22 18:59:37.177576497 -0500
@@ -1580,6 +1580,9 @@ static int lookup_fast(struct nameidata
 		 */
 		if (negative)
 			return -ENOENT;
+
+		/* FIXME: check dx permission */
+
 		path->mnt = mnt;
 		path->dentry = dentry;
 		if (likely(__follow_mount_rcu(nd, path, inode)))

http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/kernel/printk/printk.c?h=linux-4.1.y&id=ae41bfc68161ea5d280091ccb9593e9f68d5db44

diff -urNpd linux-4.1.11-vs2.3.8.2~/kernel/printk/printk.c linux-4.1.11-vs2.3.8.2/kernel/printk/printk.c
--- linux-4.1.11-vs2.3.8.2~/kernel/printk/printk.c	2015-10-22 19:05:02.642577384 -0500
+++ linux-4.1.11-vs2.3.8.2/kernel/printk/printk.c	2015-10-22 19:03:42.040307387 -0500
@@ -488,7 +488,7 @@ int check_syslog_permissions(int type, b
 		goto ok;
 
 	if (syslog_action_restricted(type)) {
-		if (capable(CAP_SYSLOG))
+		if (vx_capable(CAP_SYSLOG, VXC_SYSLOG))
 			goto ok;
 		/*
 		 * For historical reasons, accept CAP_SYS_ADMIN too, with