[1835] | 1 | From 29ef9bb31f31c371272ee9b2860729af2277ab95 Mon Sep 17 00:00:00 2001 |
---|
| 2 | From: Marc Dionne <marc.c.dionne@gmail.com> |
---|
| 3 | Date: Fri, 28 Jan 2011 19:41:32 -0500 |
---|
| 4 | Subject: [PATCH 4/8] Linux: 2.6.38: Adjust for permission inode operation changes |
---|
| 5 | |
---|
| 6 | The permission i_op has a new signature with a flags argument, and |
---|
| 7 | must now deal with RCU path walking. |
---|
| 8 | - Fix existing configure test for this i_op, it succeeds when it |
---|
| 9 | shouldn't |
---|
| 10 | - Add a new configure test for the new signature |
---|
| 11 | - Make our permission i_op "RCU-walk aware" - return ECHILD if |
---|
| 12 | called in that mode |
---|
| 13 | |
---|
| 14 | Reviewed-on: http://gerrit.openafs.org/3770 |
---|
| 15 | Tested-by: BuildBot <buildbot@rampaginggeek.com> |
---|
| 16 | Reviewed-by: Derrick Brashear <shadow@dementia.org> |
---|
| 17 | (cherry picked from commit 5bcc0ea735ea519298c98b46c66bf1326cdee5e4) |
---|
| 18 | |
---|
| 19 | Change-Id: I38db16f0f62500f46fad9c92d045ccfa6cfe1c38 |
---|
| 20 | Signed-off-by: Anders Kaseorg <andersk@mit.edu> |
---|
| 21 | Reviewed-on: http://gerrit.openafs.org/3997 |
---|
| 22 | Reviewed-by: Simon Wilkinson <sxw@inf.ed.ac.uk> |
---|
| 23 | Tested-by: BuildBot <buildbot@rampaginggeek.com> |
---|
| 24 | Reviewed-by: Russ Allbery <rra@stanford.edu> |
---|
| 25 | Reviewed-on: http://gerrit.openafs.org/4040 |
---|
| 26 | Reviewed-by: Derrick Brashear <shadow@dementia.org> |
---|
| 27 | Tested-by: Derrick Brashear <shadow@dementia.org> |
---|
| 28 | --- |
---|
| 29 | acinclude.m4 | 1 + |
---|
| 30 | src/afs/LINUX/osi_vnodeops.c | 13 +++++++++++-- |
---|
| 31 | src/cf/linux-test4.m4 | 16 ++++++++++++++-- |
---|
| 32 | 3 files changed, 26 insertions(+), 4 deletions(-) |
---|
| 33 | |
---|
| 34 | diff --git a/acinclude.m4 b/acinclude.m4 |
---|
| 35 | index 60c47d1..de82283 100644 |
---|
| 36 | --- a/acinclude.m4 |
---|
| 37 | +++ b/acinclude.m4 |
---|
| 38 | @@ -768,6 +768,7 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) |
---|
| 39 | LINUX_WRITE_INODE_RETURN_TYPE |
---|
| 40 | LINUX_IOP_I_CREATE_TAKES_NAMEIDATA |
---|
| 41 | LINUX_IOP_I_LOOKUP_TAKES_NAMEIDATA |
---|
| 42 | + LINUX_IOP_I_PERMISSION_TAKES_FLAGS |
---|
| 43 | LINUX_IOP_I_PERMISSION_TAKES_NAMEIDATA |
---|
| 44 | LINUX_IOP_I_PUT_LINK_TAKES_COOKIE |
---|
| 45 | LINUX_DOP_D_REVALIDATE_TAKES_NAMEIDATA |
---|
| 46 | diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c |
---|
| 47 | index 2389389..8352769 100644 |
---|
| 48 | --- a/src/afs/LINUX/osi_vnodeops.c |
---|
| 49 | +++ b/src/afs/LINUX/osi_vnodeops.c |
---|
| 50 | @@ -1786,16 +1786,25 @@ afs_linux_updatepage(struct file *fp, struct page *pp, unsigned long offset, |
---|
| 51 | * Check access rights - returns error if can't check or permission denied. |
---|
| 52 | */ |
---|
| 53 | static int |
---|
| 54 | -#ifdef IOP_PERMISSION_TAKES_NAMEIDATA |
---|
| 55 | +#if defined(IOP_PERMISSION_TAKES_FLAGS) |
---|
| 56 | +afs_linux_permission(struct inode *ip, int mode, unsigned int flags) |
---|
| 57 | +#elif defined(IOP_PERMISSION_TAKES_NAMEIDATA) |
---|
| 58 | afs_linux_permission(struct inode *ip, int mode, struct nameidata *nd) |
---|
| 59 | #else |
---|
| 60 | afs_linux_permission(struct inode *ip, int mode) |
---|
| 61 | #endif |
---|
| 62 | { |
---|
| 63 | int code; |
---|
| 64 | - cred_t *credp = crref(); |
---|
| 65 | + cred_t *credp; |
---|
| 66 | int tmp = 0; |
---|
| 67 | |
---|
| 68 | +#if defined(IOP_PERMISSION_TAKES_FLAGS) |
---|
| 69 | + /* We don't support RCU path walking */ |
---|
| 70 | + if (flags & IPERM_FLAG_RCU) |
---|
| 71 | + return -ECHILD; |
---|
| 72 | +#endif |
---|
| 73 | + |
---|
| 74 | + credp = crref(); |
---|
| 75 | AFS_GLOCK(); |
---|
| 76 | if (mode & MAY_EXEC) |
---|
| 77 | tmp |= VEXEC; |
---|
| 78 | diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4 |
---|
| 79 | index 67ddf91..88e4863 100644 |
---|
| 80 | --- a/src/cf/linux-test4.m4 |
---|
| 81 | +++ b/src/cf/linux-test4.m4 |
---|
| 82 | @@ -680,12 +680,24 @@ AC_DEFUN([LINUX_IOP_I_PERMISSION_TAKES_NAMEIDATA], [ |
---|
| 83 | [#include <linux/fs.h> |
---|
| 84 | #include <linux/namei.h>], |
---|
| 85 | [struct inode _inode; |
---|
| 86 | -struct dentry _dentry; |
---|
| 87 | struct nameidata _nameidata; |
---|
| 88 | (void)_inode.i_op->permission(&_inode, 0, &_nameidata);], |
---|
| 89 | [IOP_PERMISSION_TAKES_NAMEIDATA], |
---|
| 90 | [define if your iops.permission takes a nameidata argument], |
---|
| 91 | - []) |
---|
| 92 | + [-Werror]) |
---|
| 93 | +]) |
---|
| 94 | + |
---|
| 95 | + |
---|
| 96 | +AC_DEFUN([LINUX_IOP_I_PERMISSION_TAKES_FLAGS], [ |
---|
| 97 | + AC_CHECK_LINUX_BUILD([whether inode_operations.permission takes flags], |
---|
| 98 | + [ac_cv_linux_func_i_permission_takes_flags], |
---|
| 99 | + [#include <linux/fs.h>], |
---|
| 100 | + [struct inode _inode; |
---|
| 101 | + unsigned int flags = 0; |
---|
| 102 | + (void)_inode.i_op->permission(&_inode, 0, flags);], |
---|
| 103 | + [IOP_PERMISSION_TAKES_FLAGS], |
---|
| 104 | + [define if your iops.permission takes a flags argument], |
---|
| 105 | + [-Werror]) |
---|
| 106 | ]) |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | -- |
---|
| 110 | 1.7.3.4 |
---|
| 111 | |
---|