[linux-l] FreeS/Wan - Kernel ohne Modulsupport

Steffen Dettmer steffen at dett.de
Do Mär 27 09:06:17 CET 2003


* Steffen Dettmer wrote on Thu, Mar 27, 2003 at 08:52 +0100:
> Ist ja ein Ding: ich benutze Module dafür:

100 Zeilen darf man ja mal anhängen, was? :) Paßt auch gut zum
Kernel-Modul-Artikel aus dem Linux Magazin 4/2003.

stammt vom letzem ptrace bug. Sollte wohl auch jetzt
funktionieren. Ach so, Makefile ist auch immer in? Hier:

#include <nowarrantyatall>
#include <stddisclaimer>
install: ntp.o
        VERSION=`uname -r` ; export PATH=/lib/modules/$$VERSION ;       \
                echo "installing ntp.o to $$PATH" ; \
                test -d $$PATH || exit 1 ; \
                /usr/bin/install -o root -g root -m 700 \
                        ntp.o $$PATH/ntp.o || exit 1 ; \
                /bin/grep 'ntp.o' /etc/rc.d/boot.local > /dev/null && { \
                echo "already installed in /etc/rc.d/boot.local?" ; \
                exit 1; } ; \
                echo "/sbin/insmod $$PATH/ntp.o" >> /etc/rc.d/boot.local

ntp.o: ntp.c
        $(CC) -c ntp.c -o ntp.o
        @echo "do as root: insmod ntp.o"


:)

oki,

Steffen

-- 
Dieses Schreiben wurde maschinell erstellt,
es trägt daher weder Unterschrift noch Siegel.
-------------- nächster Teil --------------
/* no ptrace module
   fast prevention for kenrel bug
   (c) 2001 a Lam3rZ odyssey
*/


#define MODULE
#define __KERNEL__

#include <linux/module.h>
#include <linux/unistd.h>
#include <linux/sched.h>
#include <sys/syscall.h>

#ifndef KERNEL_VERSION
#define KERNEL_VERSION(a,b,c) ((a)*65536+(b)*256+(c))
#endif

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
#include <asm/unistd.h>
#endif

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,14)
#include <bits/syscall.h>
#endif

extern void *sys_call_table[];

int (*orig_ptrace)(int, int, int, int);

int no_ptrace (int request, int pid, int addr, int data)
{
    //printk("ptrace(): uid=%d, comm=%s\n", current->uid, current->comm);
    //return -1;
    if (current->euid ==0 ) {
        return (orig_ptrace)(request, pid, addr, data);
    } else {
        printk("ptrace(): BLOCKED uid=%d, comm=%s\n", 
                current->uid, current->comm);
        return -1;
    }
}


int init_module(void) {
	
	orig_ptrace = sys_call_table[__NR_ptrace];
	sys_call_table[__NR_ptrace]=no_ptrace;
	return 0;
}

void cleanup_module(void) {
	
	sys_call_table[__NR_ptrace]=orig_ptrace;
}


Mehr Informationen über die Mailingliste linux-l