Re: Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 14, 2002 at 01:29:21PM -0500, Israel Fdez wrote:
> I'm developing a file auditor kernel module. The auditing tasks are performed 
> by a userland daemond, and the sys_open and sys_exec system calls are 
> intercepted by the kernel module. I was using IPC V messages to communicate 
> both hte LKm anda the daemon, but I realize that they are not designed to run 
> within the kernel space. Now I'm tring with a /proc file, but, this is my 
> question:

You actually want a real device driver, /proc wasn't designed to be
abused like that.

> Whow can I make my daemond to wait a "signal" or something else from the 
> kernel module. This "signal" should contain the file path to be audited.

Use a semaphore (or some other kind of locking mechanism).

struct semaphore sem;

/* device "read" function */
static ssize_t read_func(struct file *filp, char *buf, size_t count,
                          loff_t *f_pos)
{
	if(down_interruptible(&sem))
                return -ERESTARTSYS;

	/* copy data to userland */
	
	return number of bytes written to userland;
}

/* other part of the driver that wants to wakeup userland (interrupt
/* handler, for example) */

	up(&sem);

/* initialisation at module load*/
	sema_init(&sem, 1);


Userland daemon reads the device, but blocks on the semaphore. Userland
gets woken up either when it receives a signal (hence the
down_interruptible()), or when the semaphore gets signaled with up()
(probably when data comes available). Again, see "linux device drivers,
2nd edition".


Erik

-- 
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Faculty
of Information Technology and Systems, Delft University of Technology,
PO BOX 5031, 2600 GA Delft, The Netherlands  Phone: +31-15-2783635
Fax: +31-15-2781843  Email: J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux