public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] more SAK stuff
@ 2001-07-02 13:03 Andries.Brouwer
  2001-08-03 18:40 ` Building multipart modules with subdirectories Steven J. Hill
  0 siblings, 1 reply; 3+ messages in thread
From: Andries.Brouwer @ 2001-07-02 13:03 UTC (permalink / raw)
  To: Andries.Brouwer, alan; +Cc: andrewm, linux-kernel, torvalds, tytso

>> (a) It does less, namely will not kill processes with uid 0.
>> Ted, any objections?

Alan:

> That breaks the security guarantee. Suppose I use a setuid app to confuse
> you into doing something ?

On second thoughts I agree. Here is the patch without test for p->uid.

Andries

diff -u --recursive --new-file ../linux-2.4.6-pre8/linux/drivers/char/keyboard.c ./linux/drivers/char/keyboard.c
--- ../linux-2.4.6-pre8/linux/drivers/char/keyboard.c	Mon Oct 16 21:58:51 2000
+++ ./linux/drivers/char/keyboard.c	Mon Jul  2 13:28:09 2001
@@ -506,6 +506,8 @@
 	 * them properly.
 	 */
 
+	if (!tty && ttytab && ttytab[0] && ttytab[0]->driver_data)
+		tty = ttytab[0];
 	do_SAK(tty);
 	reset_vc(fg_console);
 #if 0
diff -u --recursive --new-file ../linux-2.4.6-pre8/linux/drivers/char/tty_io.c ./linux/drivers/char/tty_io.c
--- ../linux-2.4.6-pre8/linux/drivers/char/tty_io.c	Sun Jul  1 15:19:26 2001
+++ ./linux/drivers/char/tty_io.c	Mon Jul  2 14:53:52 2001
@@ -1818,20 +1818,29 @@
  *
  * Nasty bug: do_SAK is being called in interrupt context.  This can
  * deadlock.  We punt it up to process context.  AKPM - 16Mar2001
+ *
+ * Treat all VTs as a single tty for the purposes of SAK.  A process with an
+ * open fd for one VT can do interesting things to all.  aeb, 2001-07-02
  */
-static void __do_SAK(void *arg)
+#ifdef CONFIG_VT
+static inline int tty_is_vt(struct tty_struct *tty)
 {
-#ifdef TTY_SOFT_SAK
-	tty_hangup(tty);
+	return tty ? (tty->driver.type == TTY_DRIVER_TYPE_CONSOLE) : 0;
+}
 #else
-	struct tty_struct *tty = arg;
+static inline int tty_is_vt(struct tty_struct *tty)
+{
+	return 0;
+}
+#endif
+
+static inline void tty_hard_SAK(struct tty_struct *tty)
+{
 	struct task_struct *p;
 	int session;
-	int		i;
-	struct file	*filp;
-	
-	if (!tty)
-		return;
+	int i;
+	struct file *filp;
+
 	session  = tty->session;
 	if (tty->ldisc.flush_buffer)
 		tty->ldisc.flush_buffer(tty);
@@ -1839,7 +1848,9 @@
 		tty->driver.flush_buffer(tty);
 	read_lock(&tasklist_lock);
 	for_each_task(p) {
+		/* all VTs are considered a single tty here */
 		if ((p->tty == tty) ||
+		    (tty_is_vt(tty) && tty_is_vt(p->tty)) ||
 		    ((session > 0) && (p->session == session))) {
 			send_sig(SIGKILL, p, 1);
 			continue;
@@ -1850,7 +1861,9 @@
 			for (i=0; i < p->files->max_fds; i++) {
 				filp = fcheck_files(p->files, i);
 				if (filp && (filp->f_op == &tty_fops) &&
-				    (filp->private_data == tty)) {
+				    (filp->private_data == tty ||
+				     (tty_is_vt(tty) &&
+				      tty_is_vt(filp->private_data)))) {
 					send_sig(SIGKILL, p, 1);
 					break;
 				}
@@ -1860,6 +1873,17 @@
 		task_unlock(p);
 	}
 	read_unlock(&tasklist_lock);
+}
+
+static void __do_SAK(void *arg)
+{
+	struct tty_struct *tty = arg;
+	if (!tty)		/* impossible */
+		return;
+#ifdef TTY_SOFT_SAK
+	tty_hangup(tty);
+#else
+	tty_hard_SAK(tty);
 #endif
 }
 
@@ -1872,6 +1896,8 @@
  */
 void do_SAK(struct tty_struct *tty)
 {
+	if (!tty)
+		return;
 	PREPARE_TQUEUE(&tty->SAK_tq, __do_SAK, tty);
 	schedule_task(&tty->SAK_tq);
 }

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

* Building multipart modules with subdirectories...
  2001-07-02 13:03 [PATCH] more SAK stuff Andries.Brouwer
@ 2001-08-03 18:40 ` Steven J. Hill
  2001-08-04 10:30   ` Keith Owens
  0 siblings, 1 reply; 3+ messages in thread
From: Steven J. Hill @ 2001-08-03 18:40 UTC (permalink / raw)
  To: linux-kernel

This question has to do with the kernel build system as it relates to
building a driver both as static and as a module. I have a solution,
but I don't like it. Please read on...

I have driver that is rather complex and in order to maintain it, the
module is broke up into 17 different subdirectories. I am maintaining it
and I am trying to integrate it into the kernel build system. No, I am
not the original architect. Regardless, in the top level Makefile of
my driver directory I have the statement:

subdir-$(CONFIG_FOO_DRV) += $(17 directories' names)

When the module is built, the 'foodrv.o' object is placed in the top
level directory. The problem is that when a 'make modules_install' is
done, it uses the directories defined in 'subdir-$(CONFIG_FOO_DRV)' and
proceeds to fail installing in each of the subdirectories because there
is no target in their makefiles and nor should there be since their
objects are part of the top-level module object.

I could use the 'subdir-' directive above only when I am statically
linking in the driver, hence place it in an 'if' statement. Then when
I build the driver as a module, I manually enter each directory and
do a 'make -C <dir> modules'. However, since the 'subdir-' definition
would be missing if I am building as a module, no '.depend' files are
generated in my subdirectories when I do a 'make dep' which means if
I change a critical header file in my driver's common include
directory, the .c files using it will not be rebuilt! If I could
override the 'modules_install' target in each of my subdirectories
makefiles the problem would be solved. This is possible according to
a solution in the info pages for make, but it requires me to create a
GNUmakefile in each of my directories. Can someone perhaps give me
some ideas for this dilemna? Thanks.

-Steve

-- 
 Steven J. Hill - Embedded SW Engineer

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

* Re: Building multipart modules with subdirectories...
  2001-08-03 18:40 ` Building multipart modules with subdirectories Steven J. Hill
@ 2001-08-04 10:30   ` Keith Owens
  0 siblings, 0 replies; 3+ messages in thread
From: Keith Owens @ 2001-08-04 10:30 UTC (permalink / raw)
  To: sjhill; +Cc: linux-kernel

On Fri, 03 Aug 2001 13:40:14 -0500, 
"Steven J. Hill" <sjhill@cotw.com> wrote:
>I have driver that is rather complex and in order to maintain it, the
>module is broke up into 17 different subdirectories. I am maintaining it
>and I am trying to integrate it into the kernel build system.

I had the same problem with XFS.  Code split over multiple directories,
code in the sub directories had to be compiled for modules but not be
installed as a module, instead the sub directory objects are linked
into the parent directory then the whole is installed as one module.
Is that your problem?

In the parent Makefile

--------

O_TARGET := foo.o
obj-m := $(O_TARGET)
foo_subdirs := sub directory list
subdir-$(CONFIG_FOO_DRV) += $(foo_subdirs)
obj-y += $(foreach dir,$(foo_subdirs),$(dir)/$(dir).o)
....
include $(TOPDIR)/Rules.make

# This is really nasty, but Rules.make was never designed for multi directory
# modules and it can race on parallel build.  Keith Owens.
foo.o: $(patsubst %,_modsubdir_%,$(subdir-m))

--------

In each sub directory

--------

O_TARGET := $(notdir $(CURDIR)).o
ifneq ($(MAKECMDGOALS),modules_install)
  obj-m := $(O_TARGET)
endif
obj-y += list of sub directory objects

--------

This is so much easier in kbuild 2.5 :).


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

end of thread, other threads:[~2001-08-04 10:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-07-02 13:03 [PATCH] more SAK stuff Andries.Brouwer
2001-08-03 18:40 ` Building multipart modules with subdirectories Steven J. Hill
2001-08-04 10:30   ` Keith Owens

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