/* Module to disable uselib()
 *
 * by Patrick Bernier <pat@TZoNE.ORG>
 *
 * 2.4.29 is taking it's sweet time to come out, so in the meantime
 * let's simply disable uselib() since I'm not using it even for the oldest
 * binary that I'm carrying around...
 *
 * Compile with:
 * gcc -O2 -fomit-frame-pointer -I/usr/src/linux-`uname -r`/include -c uselib_patch.c
 */

#define MODULE
#define __KERNEL__

#include <linux/config.h>
#include <linux/version.h>
#include <linux/module.h>

#if CONFIG_MODVERSIONS==1 
#define MODVERSIONS
#include <linux/modversions.h>
#endif

#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/linkage.h>
#include <linux/mm.h>
#include <linux/unistd.h>
#include <sys/syscall.h>


MODULE_AUTHOR("Patrick Bernier <pat@TZoNE.ORG>");
MODULE_DESCRIPTION("Disables uselib()");
MODULE_LICENSE("GPL");

extern void *sys_call_table[];

static int (*original_uselib)(const char*);

asmlinkage int hacked_uselib(const char *library)
{
	printk(KERN_WARNING "uselib_patch blocked uselib()\n");
	return -EACCES;
}

int init_module(void)
{
	original_uselib = sys_call_table[SYS_uselib];
	sys_call_table[SYS_uselib] = hacked_uselib;
	printk(KERN_INFO "uselib patch loaded.\n");
	return (0);
}

void cleanup_module(void)
{
	sys_call_table[SYS_uselib] = original_uselib;
	printk(KERN_INFO "uselib patch unloaded.\n");
}
