2002-10-12 21:52:44

by shadow

[permalink] [raw]
Subject: PATCH: AFS system call registration function (was Re: Two fixes for 2.4.19-pre5-ac3)

Considerably long ago, in article <[email protected]>
Alan Cox wrote:

> Correct. There was agreement a very long time ago that code should not
> patch the syscall table (for one its not safe). AFS probably needs
> fixing so the AFS syscall hook is exported portably and nicely in the
> syscall code.
>
> This wants fixing in 2.5 too - basically
>
> static int (*afs_syscall)(...);
> sys_afs_syscall(...)
> {
> if(afs_syscall)
> return afs_syscall(....)
> return -ENOSYS;
> }
>
> EXPORT_SYMBOL(afs_syscall)

And then, xyzzy, and nothing happened.
Anyhow, this implements more or less exactly what's in 2.4.19 for nfs,
and adds the necessary wrapper for s390x.

diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/alpha/kernel/entry.S linux/arch/alpha/kernel/entry.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/alpha/kernel/entry.S Fri Aug 2 20:39:42 2002
+++ linux/arch/alpha/kernel/entry.S Sat Oct 12 13:47:24 2002
@@ -1110,7 +1110,7 @@
.quad sys_sched_get_priority_max /* 335 */
.quad sys_sched_get_priority_min
.quad sys_sched_rr_get_interval
- .quad sys_ni_syscall /* sys_afs_syscall */
+ .quad sys_afs
.quad sys_newuname
.quad sys_nanosleep /* 340 */
.quad sys_mremap
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/arm/kernel/calls.S linux/arch/arm/kernel/calls.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/arm/kernel/calls.S Fri Aug 2 20:39:42 2002
+++ linux/arch/arm/kernel/calls.S Sat Oct 12 13:50:20 2002
@@ -151,7 +151,7 @@
.long SYMBOL_NAME(sys_bdflush)
/* 135 */ .long SYMBOL_NAME(sys_sysfs)
.long SYMBOL_NAME(sys_personality)
- .long SYMBOL_NAME(sys_ni_syscall) /* .long _sys_afs_syscall */
+ .long SYMBOL_NAME(sys_afs)
.long SYMBOL_NAME(sys_setfsuid16)
.long SYMBOL_NAME(sys_setfsgid16)
/* 140 */ .long SYMBOL_NAME(sys_llseek)
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/cris/kernel/entry.S linux/arch/cris/kernel/entry.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/cris/kernel/entry.S Fri Aug 2 20:39:42 2002
+++ linux/arch/cris/kernel/entry.S Sat Oct 12 13:53:10 2002
@@ -927,7 +927,7 @@
.long SYMBOL_NAME(sys_bdflush)
.long SYMBOL_NAME(sys_sysfs) /* 135 */
.long SYMBOL_NAME(sys_personality)
- .long SYMBOL_NAME(sys_ni_syscall) /* for afs_syscall */
+ .long SYMBOL_NAME(sys_afs)
.long SYMBOL_NAME(sys_setfsuid16)
.long SYMBOL_NAME(sys_setfsgid16)
.long SYMBOL_NAME(sys_llseek) /* 140 */
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/i386/kernel/entry.S linux/arch/i386/kernel/entry.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/i386/kernel/entry.S Fri Aug 2 20:39:42 2002
+++ linux/arch/i386/kernel/entry.S Sat Oct 12 13:47:04 2002
@@ -533,7 +533,7 @@
.long SYMBOL_NAME(sys_bdflush)
.long SYMBOL_NAME(sys_sysfs) /* 135 */
.long SYMBOL_NAME(sys_personality)
- .long SYMBOL_NAME(sys_ni_syscall) /* for afs_syscall */
+ .long SYMBOL_NAME(sys_afs)
.long SYMBOL_NAME(sys_setfsuid16)
.long SYMBOL_NAME(sys_setfsgid16)
.long SYMBOL_NAME(sys_llseek) /* 140 */
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/ia64/ia32/ia32_entry.S linux/arch/ia64/ia32/ia32_entry.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/ia64/ia32/ia32_entry.S Fri Aug 2 20:39:42 2002
+++ linux/arch/ia64/ia32/ia32_entry.S Sat Oct 12 13:50:58 2002
@@ -312,7 +312,7 @@
data8 sys32_ni_syscall /* sys_bdflush */
data8 sys_sysfs /* 135 */
data8 sys32_personality
- data8 sys32_ni_syscall /* for afs_syscall */
+ data8 sys_afs
data8 sys_setfsuid /* 16-bit version */
data8 sys_setfsgid /* 16-bit version */
data8 sys_llseek /* 140 */
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/ia64/kernel/entry.S linux/arch/ia64/kernel/entry.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/ia64/kernel/entry.S Fri Aug 2 20:39:42 2002
+++ linux/arch/ia64/kernel/entry.S Sat Oct 12 13:51:14 2002
@@ -1057,7 +1057,7 @@
data8 sys_bdflush
data8 sys_sysfs
data8 sys_personality // 1140
- data8 ia64_ni_syscall // sys_afs_syscall
+ data8 sys_afs
data8 sys_setfsuid
data8 sys_setfsgid
data8 sys_getdents
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/m68k/kernel/entry.S linux/arch/m68k/kernel/entry.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/m68k/kernel/entry.S Fri Aug 2 20:39:43 2002
+++ linux/arch/m68k/kernel/entry.S Sat Oct 12 13:50:02 2002
@@ -559,7 +559,7 @@
.long SYMBOL_NAME(sys_bdflush)
.long SYMBOL_NAME(sys_sysfs) /* 135 */
.long SYMBOL_NAME(sys_personality)
- .long SYMBOL_NAME(sys_ni_syscall) /* for afs_syscall */
+ .long SYMBOL_NAME(sys_afs)
.long SYMBOL_NAME(sys_setfsuid16)
.long SYMBOL_NAME(sys_setfsgid16)
.long SYMBOL_NAME(sys_llseek) /* 140 */
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/mips/kernel/syscalls.h linux/arch/mips/kernel/syscalls.h
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/mips/kernel/syscalls.h Fri Aug 2 20:39:43 2002
+++ linux/arch/mips/kernel/syscalls.h Sat Oct 12 13:48:07 2002
@@ -151,7 +151,7 @@
SYS(sys_bdflush, 2)
SYS(sys_sysfs, 3) /* 4135 */
SYS(sys_personality, 1)
-SYS(sys_ni_syscall, 0) /* for afs_syscall */
+SYS(sys_afs, 5)
SYS(sys_setfsuid, 1)
SYS(sys_setfsgid, 1)
SYS(sys_llseek, 5) /* 4140 */
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/mips64/kernel/scall_64.S linux/arch/mips64/kernel/scall_64.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/mips64/kernel/scall_64.S Fri Aug 2 20:39:43 2002
+++ linux/arch/mips64/kernel/scall_64.S Sat Oct 12 13:52:25 2002
@@ -270,7 +270,7 @@
PTR sys_bdflush
PTR sys_sysfs /* 5135 */
PTR sys_personality
- PTR sys_ni_syscall /* for afs_syscall */
+ PTR sys_afs
PTR sys_setfsuid
PTR sys_setfsgid
PTR sys_llseek /* 5140 */
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/mips64/kernel/scall_o32.S linux/arch/mips64/kernel/scall_o32.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/mips64/kernel/scall_o32.S Fri Aug 2 20:39:43 2002
+++ linux/arch/mips64/kernel/scall_o32.S Sat Oct 12 13:52:08 2002
@@ -383,7 +383,7 @@
sys sys_bdflush 2
sys sys_sysfs 3 /* 4135 */
sys sys32_personality 1
- sys sys_ni_syscall 0 /* for afs_syscall */
+ sys sys_afs 5
sys sys_setfsuid 1
sys sys_setfsgid 1
sys sys32_llseek 5 /* 4140 */
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/parisc/kernel/syscall.S linux/arch/parisc/kernel/syscall.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/parisc/kernel/syscall.S Fri Aug 2 20:39:43 2002
+++ linux/arch/parisc/kernel/syscall.S Sat Oct 12 13:52:57 2002
@@ -469,7 +469,7 @@
ENTRY_UHOH(bdflush)
ENTRY_SAME(sysfs) /* 135 */
ENTRY_SAME(personality)
- ENTRY_SAME(ni_syscall) /* for afs_syscall */
+ ENTRY_SAME(afs)
ENTRY_SAME(setfsuid)
ENTRY_SAME(setfsgid)
/* I think this might work */
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/ppc/kernel/misc.S linux/arch/ppc/kernel/misc.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/ppc/kernel/misc.S Fri Aug 2 20:39:43 2002
+++ linux/arch/ppc/kernel/misc.S Sat Oct 12 13:45:43 2002
@@ -1085,7 +1085,7 @@
.long sys_bdflush
.long sys_sysfs /* 135 */
.long sys_personality
- .long sys_ni_syscall /* for afs_syscall */
+ .long sys_afs
.long sys_setfsuid
.long sys_setfsgid
.long sys_llseek /* 140 */
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/ppc64/kernel/misc.S linux/arch/ppc64/kernel/misc.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/ppc64/kernel/misc.S Fri Aug 2 20:39:43 2002
+++ linux/arch/ppc64/kernel/misc.S Sat Oct 12 13:45:26 2002
@@ -658,7 +658,7 @@
.llong .sys32_bdflush
.llong .sys32_sysfs /* 135 */
.llong .sys32_personality
- .llong .sys_ni_syscall /* for afs_syscall */
+ .llong .sys_afs
.llong .sys_setfsuid
.llong .sys_setfsgid
.llong .sys_llseek /* 140 */
@@ -888,7 +888,7 @@
.llong .sys_bdflush
.llong .sys_sysfs /* 135 */
.llong .sys_personality
- .llong .sys_ni_syscall /* for afs_syscall */
+ .llong .sys_afs
.llong .sys_setfsuid
.llong .sys_setfsgid
.llong .sys_llseek /* 140 */
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/s390/kernel/entry.S linux/arch/s390/kernel/entry.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/s390/kernel/entry.S Fri Aug 2 20:39:43 2002
+++ linux/arch/s390/kernel/entry.S Sat Oct 12 13:52:40 2002
@@ -471,7 +471,7 @@
.long sys_bdflush
.long sys_sysfs /* 135 */
.long sys_personality
- .long sys_ni_syscall /* for afs_syscall */
+ .long sys_afs
.long sys_setfsuid16
.long sys_setfsgid16
.long sys_llseek /* 140 */
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/s390x/kernel/entry.S linux/arch/s390x/kernel/entry.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/s390x/kernel/entry.S Fri Aug 2 20:39:43 2002
+++ linux/arch/s390x/kernel/entry.S Sat Oct 12 13:46:29 2002
@@ -504,7 +504,7 @@
.long SYSCALL(sys_bdflush,sys32_bdflush_wrapper)
.long SYSCALL(sys_sysfs,sys32_sysfs_wrapper) /* 135 */
.long SYSCALL(sys_personality,sys32_personality_wrapper)
- .long SYSCALL(sys_ni_syscall,sys_ni_syscall) /* for afs_syscall */
+ .long SYSCALL(sys_afs,sys32_afs_wrapper)
.long SYSCALL(sys_ni_syscall,sys32_setfsuid16_wrapper) /* old setfsuid16 syscall */
.long SYSCALL(sys_ni_syscall,sys32_setfsgid16_wrapper) /* old setfsgid16 syscall */
.long SYSCALL(sys_llseek,sys32_llseek_wrapper) /* 140 */
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/s390x/kernel/wrapper32.S linux/arch/s390x/kernel/wrapper32.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/s390x/kernel/wrapper32.S Mon Feb 25 14:37:56 2002
+++ linux/arch/s390x/kernel/wrapper32.S Sat Oct 12 13:55:15 2002
@@ -616,6 +616,15 @@
llgfr %r2,%r2 # unsigned long
jg sys_personality # branch to system call

+ .globl sys32_afs_wrapper
+sys32_afs_wrapper:
+ lgfr %r2,%r2 # long
+ lgfr %r3,%r3 # long
+ lgfr %r4,%r4 # long
+ lgfr %r5,%r5 # long
+ lgfr %r6,%r6 # long
+ jg sys_afs # branch to system call
+
.globl sys32_setfsuid16_wrapper
sys32_setfsuid16_wrapper:
llgfr %r2,%r2 # __kernel_old_uid_emu31_t
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/arch/sh/kernel/entry.S linux/arch/sh/kernel/entry.S
--- /afs/andrew/system/src/local/x86_l24/015/linux/arch/sh/kernel/entry.S Fri Aug 2 20:39:43 2002
+++ linux/arch/sh/kernel/entry.S Sat Oct 12 13:50:33 2002
@@ -1213,7 +1213,7 @@
.long SYMBOL_NAME(sys_bdflush)
.long SYMBOL_NAME(sys_sysfs) /* 135 */
.long SYMBOL_NAME(sys_personality)
- .long SYMBOL_NAME(sys_ni_syscall) /* for afs_syscall */
+ .long SYMBOL_NAME(sys_afs)
.long SYMBOL_NAME(sys_setfsuid16)
.long SYMBOL_NAME(sys_setfsgid16)
.long SYMBOL_NAME(sys_llseek) /* 140 */
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/fs/filesystems.c linux/fs/filesystems.c
--- /afs/andrew/system/src/local/x86_l24/015/linux/fs/filesystems.c Fri Aug 2 20:39:45 2002
+++ linux/fs/filesystems.c Sat Oct 12 13:56:50 2002
@@ -12,6 +12,7 @@
#include <linux/smp_lock.h>
#include <linux/kmod.h>
#include <linux/nfsd/interface.h>
+#include <linux/afs_interface.h>

#if ! defined(CONFIG_NFSD)
struct nfsd_linkage *nfsd_linkage;
@@ -38,3 +39,24 @@
EXPORT_SYMBOL(nfsd_linkage);

#endif /* CONFIG_NFSD */
+
+struct afs_linkage *afs_linkage = NULL;
+
+long
+asmlinkage sys_afs(long syscall, long parm1, long parm2, long parm3,
+ long parm4)
+{
+ int ret = -ENOSYS;
+
+ lock_kernel();
+
+ if (afs_linkage) {
+ __MOD_INC_USE_COUNT(afs_linkage->owner);
+ unlock_kernel();
+ ret = afs_linkage->do_afs(syscall, parm1, parm2, parm3, parm4);
+ __MOD_DEC_USE_COUNT(afs_linkage->owner);
+ } else
+ unlock_kernel();
+ return ret;
+}
+EXPORT_SYMBOL(afs_linkage);
diff -urN /afs/andrew/system/src/local/x86_l24/015/linux/include/linux/afs_interface.h linux/include/linux/afs_interface.h
--- /afs/andrew/system/src/local/x86_l24/015/linux/include/linux/afs_interface.h Wed Dec 31 19:00:00 1969
+++ linux/include/linux/afs_interface.h Sat Oct 12 13:57:08 2002
@@ -0,0 +1,21 @@
+/*
+ * include/linux/afs_interface.h
+ *
+ * defines interface between afs and other bits of
+ * the kernel. Modelled on NFSd.
+ *
+ * Copyright (C) 2002 Derrick J Brashear <[email protected]>
+ */
+
+#ifndef LINUX_AFS_INTERFACE_H
+#define LINUX_AFS_INTERFACE_H
+
+#include <linux/config.h>
+
+extern struct afs_linkage {
+ long (*do_afs)(long syscall, long parm1, long parm2, long parm3,
+ long parm4);
+ struct module *owner;
+} * afs_linkage;
+
+#endif /* LINUX_AFS_INTERFACE_H */


2002-10-13 13:05:46

by Christoph Hellwig

[permalink] [raw]
Subject: Re: PATCH: AFS system call registration function (was Re: Two fixes for 2.4.19-pre5-ac3)

On Sat, Oct 12, 2002 at 05:58:29PM -0400, [email protected] wrote:
> And then, xyzzy, and nothing happened.
> Anyhow, this implements more or less exactly what's in 2.4.19 for nfs,
> and adds the necessary wrapper for s390x.

Please don't put it into the NFS files. And I'd suggest to use u32
instead of long for the interface, to simplify 32bit compatiblity.

Also, what exactly is this call doing? I seems to be yet another
multiplexer syscall and we already have more than enough of those.

2002-10-14 01:43:43

by Derrick J Brashear

[permalink] [raw]
Subject: Re: PATCH: AFS system call registration function (was Re: Two fixes for 2.4.19-pre5-ac3)

On Sun, 13 Oct 2002, Christoph Hellwig wrote:

> On Sat, Oct 12, 2002 at 05:58:29PM -0400, [email protected] wrote:
> > And then, xyzzy, and nothing happened.
> > Anyhow, this implements more or less exactly what's in 2.4.19 for nfs,
> > and adds the necessary wrapper for s390x.
>
> Please don't put it into the NFS files.

what NFS files? It changes sys call tables, adds a header which is
completely new, and augments fs/filesystems.c, which in my source is:
"table of configured filesystems"

> And I'd suggest to use u32
> instead of long for the interface, to simplify 32bit compatiblity.

Ok.

> Also, what exactly is this call doing? I seems to be yet another
> multiplexer syscall and we already have more than enough of those.

Who wants to share theirs with us? Note that it was already reserved for
us (look at the comments in the sys call table diffs) and we've been using
it for years.





2002-10-14 01:53:30

by Derrick J Brashear

[permalink] [raw]
Subject: Re: PATCH: AFS system call registration function (was Re: Two fixes for 2.4.19-pre5-ac3)

On Sun, 13 Oct 2002, Derrick J Brashear wrote:

Actually:

> > And I'd suggest to use u32
> > instead of long for the interface, to simplify 32bit compatiblity.
>
> Ok.

The version we have now uses long, so... (read on)

> > Also, what exactly is this call doing? I seems to be yet another
> > multiplexer syscall and we already have more than enough of those.
>
> Who wants to share theirs with us? Note that it was already reserved for
> us (look at the comments in the sys call table diffs) and we've been using
> it for years.

we have people with deployed utilities which call the afs system call,
because, well, it's the AFS system call. it would be good to maintain
compatibility with those, which means we should
a) keep using the same system call if we can
b) if so, keep using "long".



2002-10-14 14:18:03

by Christoph Hellwig

[permalink] [raw]
Subject: Re: PATCH: AFS system call registration function (was Re: Two fixes for 2.4.19-pre5-ac3)

On Sun, Oct 13, 2002 at 09:58:00PM -0400, Derrick J Brashear wrote:
> The version we have now uses long, so... (read on)

I know..

> we have people with deployed utilities which call the afs system call,
> because, well, it's the AFS system call. it would be good to maintain
> compatibility with those, which means we should
> a) keep using the same system call if we can
> b) if so, keep using "long".


AFS is currently not in mainline. You request a new feature, in this
case an optional syscall that only was reserved previously. In
general we don|t merge random stuff asis in the kernel just because it
happens to exist. There is no reason you canb't add a sane API
for openafs 1.3

2002-10-14 14:27:56

by Derrick J Brashear

[permalink] [raw]
Subject: Re: PATCH: AFS system call registration function (was Re: Two fixes for 2.4.19-pre5-ac3)

On Mon, 14 Oct 2002, Christoph Hellwig wrote:

> On Sun, Oct 13, 2002 at 09:58:00PM -0400, Derrick J Brashear wrote:
> > The version we have now uses long, so... (read on)
>
> I know..
>
> > we have people with deployed utilities which call the afs system call,
> > because, well, it's the AFS system call. it would be good to maintain
> > compatibility with those, which means we should
> > a) keep using the same system call if we can
> > b) if so, keep using "long".
>
>
> AFS is currently not in mainline. You request a new feature, in this
> case an optional syscall that only was reserved previously.

Well, given the previous commentary I would have expected the hook to have
already existed, and if it had we would have changed to conform to it
months ago.

> In
> general we don|t merge random stuff asis in the kernel just because it
> happens to exist. There is no reason you can't add a sane API
> for openafs 1.3

No disagreement (on that). Do you propose we orphan old versions? (Which
isn't to say "Yes" is a wrong answer)

Also, we're not ready for 1.3 yet. RedHat 8.0's kernel sort of forced the
issue sooner than we would have liked to have dealt with this, and
actually causes another problem; It means the "extra groups" encoding for
PAGs breaks. That's certainly not the end of the world, but the obvious
solution is a Linux Security Module, and at least as yet that's not in
their kernel.







2002-10-14 16:26:16

by Christoph Hellwig

[permalink] [raw]
Subject: Re: PATCH: AFS system call registration function (was Re: Two fixes for 2.4.19-pre5-ac3)

On Mon, Oct 14, 2002 at 10:31:41AM -0400, Derrick J Brashear wrote:
> Well, given the previous commentary I would have expected the hook to have
> already existed, and if it had we would have changed to conform to it
> months ago.

Which hook?

> No disagreement (on that). Do you propose we orphan old versions? (Which
> isn't to say "Yes" is a wrong answer)

For plattforms where your old hack doesn't work (Linux 2.5 and
Red Hat's 8.x vendor tree): yes.

2002-10-14 17:59:19

by Christoph Hellwig

[permalink] [raw]
Subject: Re: PATCH: AFS system call registration function (was Re: Two fixes for 2.4.19-pre5-ac3)

On Mon, Oct 14, 2002 at 02:02:27PM -0400, Derrick J Brashear wrote:
> On Mon, 14 Oct 2002, Christoph Hellwig wrote:
>
> > On Mon, Oct 14, 2002 at 10:31:41AM -0400, Derrick J Brashear wrote:
> > > Well, given the previous commentary I would have expected the hook to have
> > > already existed, and if it had we would have changed to conform to it
> > > months ago.
> >
> > Which hook?
>
> For this system call. The message from Alan I quoted which was from April.

Call me stupid, but where did you quote it? Would you mind
including it again?

2002-10-14 17:56:46

by Derrick J Brashear

[permalink] [raw]
Subject: Re: PATCH: AFS system call registration function (was Re: Two fixes for 2.4.19-pre5-ac3)

On Mon, 14 Oct 2002, Christoph Hellwig wrote:

> On Mon, Oct 14, 2002 at 10:31:41AM -0400, Derrick J Brashear wrote:
> > Well, given the previous commentary I would have expected the hook to have
> > already existed, and if it had we would have changed to conform to it
> > months ago.
>
> Which hook?

For this system call. The message from Alan I quoted which was from April.


2002-10-14 18:15:56

by Derrick J Brashear

[permalink] [raw]
Subject: Re: PATCH: AFS system call registration function (was Re: Two fixes for 2.4.19-pre5-ac3)

On Mon, 14 Oct 2002, Christoph Hellwig wrote:

> > > On Mon, Oct 14, 2002 at 10:31:41AM -0400, Derrick J Brashear wrote:
> > > > Well, given the previous commentary I would have expected the hook to have
> > > > already existed, and if it had we would have changed to conform to it
> > > > months ago.
> > >
> > > Which hook?
> >
> > For this system call. The message from Alan I quoted which was from April.
>
> Call me stupid, but where did you quote it? Would you mind
> including it again?

The first message I posted, with the first iteration of the patch.
There was some discussion around then (which I wasn't reading for, but
only came back to later) which essentially suggested that an nfsservctl
style hook for the AFS system call would be a reasonable way to deal.

As far as that goes, I think the best thing from where I'm sitting would
be actually 2 versions of this, one which takes a set of longs and can be
used as now for 2.4 kernels, and one with a new interface for 2.5 kernels.
That's not really a hard and fast position, perhaps it is in the best
interests of everyone for there to be only one version of this function
for the "new interface".

Incidentally, nothing in the kernel source tree provides an example
"explanation of the usage of nfsservctl"; I'll be happy to work out the
new interface and provide appropriate information, but is there some place
in particular such things end up being documented? I'm not averse to
submitting information to go in /Documentation but it doesn't appear
there's precedent for that.

Without further ado, previous quoted text:

7 Apr 2002, Alan said in message ID E16uGg1-0006Ln-00_at_the-village.bc.nu:
> And, unless this is reversed the OpenAFS kernel module won't load (it
> needs sys_call_table.):

Correct. There was agreement a very long time ago that code should not
patch
the syscall table (for one its not safe). AFS probably needs fixing so the
AFS syscall hook is exported portably and nicely in the syscall code.

This wants fixing in 2.5 too - basically

static int (*afs_syscall)(...);
sys_afs_syscall(...)
{
if(afs_syscall)
return afs_syscall(....)
return -ENOSYS;
}

EXPORT_SYMBOL(afs_syscall)




2002-10-14 18:28:11

by Alexander Viro

[permalink] [raw]
Subject: Re: PATCH: AFS system call registration function (was Re: Two fixes for 2.4.19-pre5-ac3)



On Mon, 14 Oct 2002, Derrick J Brashear wrote:

> Incidentally, nothing in the kernel source tree provides an example
> "explanation of the usage of nfsservctl"; I'll be happy to work out the
> new interface and provide appropriate information, but is there some place
> in particular such things end up being documented? I'm not averse to
> submitting information to go in /Documentation but it doesn't appear
> there's precedent for that.

Notice that in 2.5 (and that's backportable to 2.4 - I'll do that after
Oct 31) nfsservctl() is a trivial wrapper around open/write/read/close.
IOW, mountd and friends could stop using that syscall - all functionality
is available for userland without it.

See fs/nfsctl.c and fs/nfsd/nfsctl.c for example of doing that.

What things are done by afs_syscall()? If you are passing some requests
to the afs driver - just tell what these requests are, writing that
stuff is a matter of an hour...

2002-10-14 18:58:27

by Derrick J Brashear

[permalink] [raw]
Subject: Re: PATCH: AFS system call registration function (was Re: Two fixes for 2.4.19-pre5-ac3)

I should say I wasn't intending to pick on nfsservctl, but since it was
the interface this was modelled on, more or less per the suggestion made
in April, I was using it as a reference.

On Mon, 14 Oct 2002, Alexander Viro wrote:

> On Mon, 14 Oct 2002, Derrick J Brashear wrote:
>
> > Incidentally, nothing in the kernel source tree provides an example
> > "explanation of the usage of nfsservctl"; I'll be happy to work out the
> > new interface and provide appropriate information, but is there some place
> > in particular such things end up being documented? I'm not averse to
> > submitting information to go in /Documentation but it doesn't appear
> > there's precedent for that.
>
> Notice that in 2.5 (and that's backportable to 2.4 - I'll do that after
> Oct 31) nfsservctl() is a trivial wrapper around open/write/read/close.
> IOW, mountd and friends could stop using that syscall - all functionality
> is available for userland without it.
>
> See fs/nfsctl.c and fs/nfsd/nfsctl.c for example of doing that.
>
> What things are done by afs_syscall()? If you are passing some requests
> to the afs driver - just tell what these requests are, writing that
> stuff is a matter of an hour...

One is the "afs operation" call, which includes items which historically
donated contexts to the kernel by making the system calls at startup, but
as of our last release we made changes that make most of this obsolete,
switching to kernel threads, so this could be simplified to basically one
operation to start and another to stop.

One of the operations, however, is an upcall, particularly, the afsd
daemon donates a child which stays in a syscall until a DNS lookup
(of AFSDB resource records to find new cells) is needed, then it returns.

Another two are used for adding new cells and cell aliases while AFS is
running.

The other things which exist at this point (under that umbrella) are all
startup items for the client and can probably be rewritten to work other
ways. However, one possible answer for dealing with kerberos v5 is
another upcall interface involving a donated child, because ideally you
want not just a single kerberos credential as essentially happens now,
but instead the ability to use a single credential per server host, and
there's no way of knowing at startup what all server hosts you'll access
during operation, because new servers can be registered and put in
service on the fly.

Then there are the things which might properly be additional system calls,
except that their possible generic use never caught on, hence they are
still under the AFS umbrella.

-pioctl, which works like ioctl except instead of taking an open
file descriptor, it takes a path. Dealing with this would be troublesome.

-setpag, which may be able to be changed in the Linux Security Module
universe, but again we don't know yet how to support RedHat 8's not quite
2.4.19, which doesn't have this and yet doesn't export sys_call_table

-"icl", basically a mechanism to pass messages between userspace and the
AFS kernel trace facility.

-icreate/iopen/idec/iinc, which we don't actually use on Linux, and thus
don't need to consider in this proposal.

I'm open to reworking this as much as I can but it does leave the sticking
point of RedHat 8, which is unfortunate, since if we could do this purely
in terms of new interfaces I think we could be much cleaner. Instead I
think we have to make some compromise to make something which will also
work with whatever portions they've already backported. Most of our users
seem to use RedHat or Debian, so basically we'd like to continue
supporting those people.