mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [PATCH] Re: export of sys_call_table
@ 2002-10-09 12:20 Petr Vandrovec
  2002-10-09 19:54 ` Brian F. G. Bidulock
  0 siblings, 1 reply; 3+ messages in thread
From: Petr Vandrovec @ 2002-10-09 12:20 UTC (permalink / raw)
  To: Brian F. G. Bidulock; +Cc: linux-kernel, LiS, davem

On  8 Oct 02 at 18:21, Brian F. G. Bidulock wrote:
> --- kernel/sys.c.orig   2002-08-02 19:39:46.000000000 -0500
> +++ kernel/sys.c    2002-10-08 16:46:55.000000000 -0500
...

I believe that you should check that nobody else has registered its
own streams module. You can also allow for multiple streams modules
in parallel (and fall through when module returns on -ENOIOCTLCMD or -ENOTTY),
but I believe that usually only one module will be registered.

And I believe that export symbols should NOT be _GPL_ONLY: before
(non-GPL) export of syscall_table was available, non-GPL modules were
able to hook syscalls, and when _GPL_ONLY was introduced into kernel
it was promised that we'll never make currently provided functionality
GPL-only (as far as I remember).
                                                    Best regards,
                                                        Petr Vandrovec
                                                        
int register_streams_calls(...)
> +void register_streams_calls(int (*putpmsg) (int, void *, void *, int, int),
> +               int (*getpmsg) (int, void *, void *, int, int))
> +{

int err;
if (!putpmsg || !getpmsg) return -EINVAL;

> +   down_write(&streams_call_sem);

err = -EBUSY;
if (!do_putpmsg) {
  err = 0;

> +   do_putpmsg = putpmsg;
> +   do_getpmsg = getpmsg;

}

> +   up_write(&streams_call_sem);

return err;

> +}
> +
> +void unregister_streams_calls(void)
> +{

   down_write(&streams_call_sem);
   do_putpmsg = NULL;
   do_getpmsg = NULL;
   up_write(&streams_call_sem);
}
    

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Re: export of sys_call_table
  2002-10-09 12:20 [PATCH] Re: export of sys_call_table Petr Vandrovec
@ 2002-10-09 19:54 ` Brian F. G. Bidulock
  2002-10-10 16:01   ` [Linux-streams] " David Grothe
  0 siblings, 1 reply; 3+ messages in thread
From: Brian F. G. Bidulock @ 2002-10-09 19:54 UTC (permalink / raw)
  To: Petr Vandrovec; +Cc: linux-kernel, LiS, davem

Petr,

Thanks you for the constructive suggestions.  I'll see if we
can add those in an test it up.

--brian

On Wed, 09 Oct 2002, Petr Vandrovec wrote:

> On  8 Oct 02 at 18:21, Brian F. G. Bidulock wrote:
> > --- kernel/sys.c.orig   2002-08-02 19:39:46.000000000 -0500
> > +++ kernel/sys.c    2002-10-08 16:46:55.000000000 -0500
> ...
> 
> I believe that you should check that nobody else has registered its
> own streams module. You can also allow for multiple streams modules
> in parallel (and fall through when module returns on -ENOIOCTLCMD or -ENOTTY),
> but I believe that usually only one module will be registered.
> 
> And I believe that export symbols should NOT be _GPL_ONLY: before
> (non-GPL) export of syscall_table was available, non-GPL modules were
> able to hook syscalls, and when _GPL_ONLY was introduced into kernel
> it was promised that we'll never make currently provided functionality
> GPL-only (as far as I remember).
>                                                     Best regards,
>                                                         Petr Vandrovec
>                                                         
> int register_streams_calls(...)
> > +void register_streams_calls(int (*putpmsg) (int, void *, void *, int, int),
> > +               int (*getpmsg) (int, void *, void *, int, int))
> > +{
> 
> int err;
> if (!putpmsg || !getpmsg) return -EINVAL;
> 
> > +   down_write(&streams_call_sem);
> 
> err = -EBUSY;
> if (!do_putpmsg) {
>   err = 0;
> 
> > +   do_putpmsg = putpmsg;
> > +   do_getpmsg = getpmsg;
> 
> }
> 
> > +   up_write(&streams_call_sem);
> 
> return err;
> 
> > +}
> > +
> > +void unregister_streams_calls(void)
> > +{
> 
>    down_write(&streams_call_sem);
>    do_putpmsg = NULL;
>    do_getpmsg = NULL;
>    up_write(&streams_call_sem);
> }
>     

-- 
Brian F. G. Bidulock    ¦ The reasonable man adapts himself to the ¦
bidulock@openss7.org    ¦ world; the unreasonable one persists in  ¦
http://www.openss7.org/ ¦ trying  to adapt the  world  to himself. ¦
                        ¦ Therefore  all  progress  depends on the ¦
                        ¦ unreasonable man. -- George Bernard Shaw ¦

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Linux-streams] Re: [PATCH] Re: export of sys_call_table
  2002-10-09 19:54 ` Brian F. G. Bidulock
@ 2002-10-10 16:01   ` David Grothe
  0 siblings, 0 replies; 3+ messages in thread
From: David Grothe @ 2002-10-10 16:01 UTC (permalink / raw)
  To: bidulock, Petr Vandrovec; +Cc: linux-kernel, LiS, davem

[-- Attachment #1: Type: text/plain, Size: 287 bytes --]

Brian, Petr, et al:

Does this patch address your suggestions?  This has been tested on 2.4.19.

Thanks,
Dave

At 01:54 PM 10/9/2002 Wednesday, Brian F. G. Bidulock wrote:
>Petr,
>
>Thanks you for the constructive suggestions.  I'll see if we
>can add those in an test it up.
>
>--brian

[-- Attachment #2: stock-i386-2.4.19.txt --]
[-- Type: text/plain, Size: 2699 bytes --]

--- arch/i386/kernel/entry.S.orig	2002-08-02 19:39:42.000000000 -0500
+++ arch/i386/kernel/entry.S	2002-10-08 15:43:08.000000000 -0500
@@ -584,8 +584,8 @@
 	.long SYMBOL_NAME(sys_capset)           /* 185 */
 	.long SYMBOL_NAME(sys_sigaltstack)
 	.long SYMBOL_NAME(sys_sendfile)
-	.long SYMBOL_NAME(sys_ni_syscall)		/* streams1 */
-	.long SYMBOL_NAME(sys_ni_syscall)		/* streams2 */
+	.long SYMBOL_NAME(sys_getpmsg)		/* streams1 */
+	.long SYMBOL_NAME(sys_putpmsg)		/* streams2 */
 	.long SYMBOL_NAME(sys_vfork)            /* 190 */
 	.long SYMBOL_NAME(sys_getrlimit)
 	.long SYMBOL_NAME(sys_mmap2)
--- kernel/ksyms.c.orig	2002-08-02 19:39:46.000000000 -0500
+++ kernel/ksyms.c	2002-10-10 10:46:43.000000000 -0500
@@ -497,6 +497,11 @@
 EXPORT_SYMBOL(seq_release);
 EXPORT_SYMBOL(seq_read);
 EXPORT_SYMBOL(seq_lseek);
+extern int register_streams_calls(int (*putpmsg) (int,void *,void *,int,int),
+				   int (*getpmsg) (int,void *,void *,int,int));
+extern void unregister_streams_calls(void);
+EXPORT_SYMBOL(register_streams_calls);
+EXPORT_SYMBOL(unregister_streams_calls);
 
 /* Program loader interfaces */
 EXPORT_SYMBOL(setup_arg_pages);
--- kernel/sys.c.orig	2002-08-02 19:39:46.000000000 -0500
+++ kernel/sys.c	2002-10-10 10:51:27.000000000 -0500
@@ -167,6 +167,50 @@
 	return notifier_chain_unregister(&reboot_notifier_list, nb);
 }
 
+static int (*do_putpmsg) (int, void *, void *, int, int) = NULL;
+static int (*do_getpmsg) (int, void *, void *, int, int) = NULL;
+
+static DECLARE_RWSEM(streams_call_sem) ;
+
+long asmlinkage sys_putpmsg(int fd, void *ctlptr, void *datptr, int band, int flags)
+{
+	int ret = -ENOSYS;
+	down_read(&streams_call_sem) ;	/* should return int, but doesn't */
+	if (do_putpmsg)
+		ret = (*do_putpmsg) (fd, ctlptr, datptr, band, flags);
+	up_read(&streams_call_sem);
+	return ret;
+}
+
+long asmlinkage sys_getpmsg(int fd, void *ctlptr, void *datptr, int band, int flags)
+{
+	int ret = -ENOSYS;
+	down_read(&streams_call_sem) ;	/* should return int, but doesn't */
+	if (do_getpmsg)
+		ret = (*do_getpmsg) (fd, ctlptr, datptr, band, flags);
+	up_read(&streams_call_sem);
+	return ret;
+}
+
+int register_streams_calls(int (*putpmsg) (int, void *, void *, int, int),
+			    int (*getpmsg) (int, void *, void *, int, int))
+{
+	down_write(&streams_call_sem) ;	/* should return int, but doesn't */
+	if (   (putpmsg != NULL && do_putpmsg != NULL)
+	    || (getpmsg != NULL && do_getpmsg != NULL)
+	   )
+		return -EBUSY;
+	do_putpmsg = putpmsg;
+	do_getpmsg = getpmsg;
+	up_write(&streams_call_sem);
+	return 0 ;
+}
+
+void unregister_streams_calls(void)
+{
+	register_streams_calls(NULL, NULL);
+}
+
 asmlinkage long sys_ni_syscall(void)
 {
 	return -ENOSYS;

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-10-10 15:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-09 12:20 [PATCH] Re: export of sys_call_table Petr Vandrovec
2002-10-09 19:54 ` Brian F. G. Bidulock
2002-10-10 16:01   ` [Linux-streams] " David Grothe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®