summaryrefslogtreecommitdiffstats
path: root/testing/spl-grsec/linux-3.13.patch
blob: 483d559d3aa750bd7ff444c072c4140be0294cf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
From 50a0749eba31e821a7edf286f1e3b149f7d13c59 Mon Sep 17 00:00:00 2001
From: Richard Yao <ryao@gentoo.org>
Date: Mon, 25 Nov 2013 11:22:33 -0500
Subject: [PATCH] Linux 3.13 compat: Pass NULL for new delegated inode argument

This check was originally added for SLES10, a093c6a, to check for
a 'struct vfsmount *' argument which they added.  However, since
SLES10 is based on a 2.6.16 kernel which is no longer supported
this functionality was dropped.  The checks were refactored to
support Linux 3.13 without concern for historical versions.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #312
---
 config/spl-build.m4    | 52 ++++++++++++++++++++++++++++++++++++++++----------
 module/spl/spl-vnode.c | 22 ++++++++++++---------
 2 files changed, 55 insertions(+), 19 deletions(-)

diff --git a/config/spl-build.m4 b/config/spl-build.m4
index 7d744db..8426780 100644
--- a/config/spl-build.m4
+++ b/config/spl-build.m4
@@ -1842,41 +1842,73 @@ AC_DEFUN([SPL_AC_SET_FS_PWD_WITH_CONST],
 	EXTRA_KCFLAGS="$tmp_flags"
 ])
 
-dnl #
-dnl # SLES API change, never adopted in mainline,
-dnl # Third 'struct vfsmount *' argument removed.
-dnl #
 AC_DEFUN([SPL_AC_2ARGS_VFS_UNLINK],
 	[AC_MSG_CHECKING([whether vfs_unlink() wants 2 args])
 	SPL_LINUX_TRY_COMPILE([
 		#include <linux/fs.h>
 	],[
-		vfs_unlink(NULL, NULL);
+		vfs_unlink((struct inode *) NULL, (struct dentry *) NULL);
 	],[
 		AC_MSG_RESULT(yes)
 		AC_DEFINE(HAVE_2ARGS_VFS_UNLINK, 1,
 		          [vfs_unlink() wants 2 args])
 	],[
 		AC_MSG_RESULT(no)
+		dnl #
+		dnl # Linux 3.13 API change
+		dnl # Added delegated inode
+		dnl #
+		AC_MSG_CHECKING([whether vfs_unlink() wants 3 args])
+		SPL_LINUX_TRY_COMPILE([
+			#include <linux/fs.h>
+		],[
+			vfs_unlink((struct inode *) NULL,
+				(struct dentry *) NULL,
+				(struct inode **) NULL);
+		],[
+			AC_MSG_RESULT(yes)
+			AC_DEFINE(HAVE_3ARGS_VFS_UNLINK, 1,
+				  [vfs_unlink() wants 3 args])
+		],[
+			AC_MSG_ERROR(no)
+		])
+
 	])
 ])
 
-dnl #
-dnl # SLES API change, never adopted in mainline,
-dnl # Third and sixth 'struct vfsmount *' argument removed.
-dnl #
 AC_DEFUN([SPL_AC_4ARGS_VFS_RENAME],
 	[AC_MSG_CHECKING([whether vfs_rename() wants 4 args])
 	SPL_LINUX_TRY_COMPILE([
 		#include <linux/fs.h>
 	],[
-		vfs_rename(NULL, NULL, NULL, NULL);
+		vfs_rename((struct inode *) NULL, (struct dentry *) NULL,
+			(struct inode *) NULL, (struct dentry *) NULL);
 	],[
 		AC_MSG_RESULT(yes)
 		AC_DEFINE(HAVE_4ARGS_VFS_RENAME, 1,
 		          [vfs_rename() wants 4 args])
 	],[
 		AC_MSG_RESULT(no)
+		dnl #
+		dnl # Linux 3.13 API change
+		dnl # Added delegated inode
+		dnl #
+		AC_MSG_CHECKING([whether vfs_rename() wants 5 args])
+		SPL_LINUX_TRY_COMPILE([
+			#include <linux/fs.h>
+		],[
+			vfs_rename((struct inode *) NULL,
+				(struct dentry *) NULL,
+				(struct inode *) NULL,
+				(struct dentry *) NULL,
+				(struct inode **) NULL);
+		],[
+			AC_MSG_RESULT(yes)
+			AC_DEFINE(HAVE_5ARGS_VFS_RENAME, 1,
+				  [vfs_rename() wants 5 args])
+		],[
+			AC_MSG_ERROR(no)
+		])
 	])
 ])
 
diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c
index 0784ff2..5496067 100644
--- a/module/spl/spl-vnode.c
+++ b/module/spl/spl-vnode.c
@@ -334,7 +334,11 @@ vn_remove(const char *path, uio_seg_t seg, int flags)
 		if (inode)
 			ihold(inode);
 
+#ifdef HAVE_2ARGS_VFS_UNLINK
 		rc = vfs_unlink(parent.dentry->d_inode, dentry);
+#else
+		rc = vfs_unlink(parent.dentry->d_inode, dentry, NULL);
+#endif /* HAVE_2ARGS_VFS_UNLINK */
 exit1:
 		dput(dentry);
 	} else {
@@ -412,10 +416,10 @@ vn_rename(const char *oldname, const char *newname, int x1)
 
 #ifdef HAVE_4ARGS_VFS_RENAME
 	rc = vfs_rename(old_dir->d_inode, old_dentry,
-			new_dir->d_inode, new_dentry);
+	    new_dir->d_inode, new_dentry);
 #else
-	rc = vfs_rename(old_dir->d_inode, old_dentry, oldnd.nd_mnt,
-			new_dir->d_inode, new_dentry, newnd.nd_mnt);
+	rc = vfs_rename(old_dir->d_inode, old_dentry,
+	    new_dir->d_inode, new_dentry, NULL);
 #endif /* HAVE_4ARGS_VFS_RENAME */
 exit4:
 	unlock_rename(new_dir, old_dir);
@@ -478,9 +482,9 @@ vn_remove(const char *path, uio_seg_t seg, int flags)
                 if (inode)
                         atomic_inc(&inode->i_count);
 #ifdef HAVE_2ARGS_VFS_UNLINK
-                rc = vfs_unlink(nd.nd_dentry->d_inode, dentry);
+		rc = vfs_unlink(nd.nd_dentry->d_inode, dentry);
 #else
-                rc = vfs_unlink(nd.nd_dentry->d_inode, dentry, nd.nd_mnt);
+		rc = vfs_unlink(nd.nd_dentry->d_inode, dentry, NULL);
 #endif /* HAVE_2ARGS_VFS_UNLINK */
 exit2:
                 dput(dentry);
@@ -571,11 +575,11 @@ vn_rename(const char *oldname, const char *newname, int x1)
                 SGOTO(exit5, rc);
 
 #ifdef HAVE_4ARGS_VFS_RENAME
-        rc = vfs_rename(old_dir->d_inode, old_dentry,
-                        new_dir->d_inode, new_dentry);
+	rc = vfs_rename(old_dir->d_inode, old_dentry,
+	    new_dir->d_inode, new_dentry);
 #else
-        rc = vfs_rename(old_dir->d_inode, old_dentry, oldnd.nd_mnt,
-                        new_dir->d_inode, new_dentry, newnd.nd_mnt);
+	rc = vfs_rename(old_dir->d_inode, old_dentry,
+	    new_dir->d_inode, new_dentry, NULL);
 #endif /* HAVE_4ARGS_VFS_RENAME */
 exit5:
         dput(new_dentry);
-- 
1.9.3




From 3e96de17d723d6f6c9e2fd04b059b50d4e0bbef0 Mon Sep 17 00:00:00 2001
From: Richard Yao <ryao@gentoo.org>
Date: Thu, 8 Aug 2013 04:30:55 -0400
Subject: [PATCH] Linux 3.13 compat: Remove unused flags variable from
 __cv_init()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

GCC 4.8.1 complained about an unused flags variable when building
against Linux 2.6.26.8:

/var/tmp/portage/sys-kernel/spl-9999/work/spl-9999/module/spl/../../module/spl/spl-condvar.c:
In function ‘__cv_init’:
/var/tmp/portage/sys-kernel/spl-9999/work/spl-9999/module/spl/../../module/spl/spl-condvar.c:39:6:
error: variable ‘flags’ set but not used
[-Werror=unused-but-set-variable]
  int flags = KM_SLEEP;
        ^
	cc1: all warnings being treated as errors

Additionally, the superfluous code uses a preempt_count variable that is
no longer available on Linux 3.13. Deleting the unnecessary code fixes a
Linux 3.13 compatibility issue.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #312
---
 module/spl/spl-condvar.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/module/spl/spl-condvar.c b/module/spl/spl-condvar.c
index 283648a..8236412 100644
--- a/module/spl/spl-condvar.c
+++ b/module/spl/spl-condvar.c
@@ -36,8 +36,6 @@
 void
 __cv_init(kcondvar_t *cvp, char *name, kcv_type_t type, void *arg)
 {
-	int flags = KM_SLEEP;
-
 	SENTRY;
 	ASSERT(cvp);
 	ASSERT(name == NULL);
@@ -51,12 +49,6 @@ __cv_init(kcondvar_t *cvp, char *name, kcv_type_t type, void *arg)
 	atomic_set(&cvp->cv_refs, 1);
 	cvp->cv_mutex = NULL;
 
-        /* We may be called when there is a non-zero preempt_count or
-	 * interrupts are disabled is which case we must not sleep.
-	 */
-        if (current_thread_info()->preempt_count || irqs_disabled())
-		flags = KM_NOSLEEP;
-
 	SEXIT;
 }
 EXPORT_SYMBOL(__cv_init);
-- 
1.9.3