All of lore.kernel.org
 help / color / mirror / Atom feed
* Query - System Calls Arguments in Linux Audit Kernel
@ 2019-08-06 13:28 Muhammad Adil Inam
  2019-08-07 14:44 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: Muhammad Adil Inam @ 2019-08-06 13:28 UTC (permalink / raw)
  To: linux-audit; +Cc: Ali Ahad


[-- Attachment #1.1: Type: text/plain, Size: 1327 bytes --]

To whom it may concern,

Hi,

           I am a CS research assistant currently working at Lahore University of Management Sciences (LUMS), Pakistan. The project I am working on involves understanding and working with the Linux Audit Kernel.

As you know, linux-audit logs all the syscall arguments as a1, a2, a3, a4 as unsigned longs. In the case of some syscall, such as WRITE, the second argument, a2, stores the pointer to a buffer, where the buffer contains the content being written. I have been trying to deference the buffer from its address stored in a2. I am dereferencing the buffer currently in kernel/auditsc.c and dumping the dereferenced contents of a2 to printk. However, after building the customized kernel, auditd fails probably due to invalid pointer dereferencing.

                I am confused regarding the scope of that pointer variable stored in a2. I have two questions:

1) Is it possible to deference the syscall arguments in the Linux kernel, given the buffer was initially sent by the process that initiated the syscall?

2) If it is possible to do so, what is the right way to go about it. What is the right file to work if the goal is to dereference the address stored in one of the SYSCALL arguments?

Really looking forward to hearing back from you.

Best Regards,

Adil


[-- Attachment #1.2: Type: text/html, Size: 5277 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

* Re: Query - System Calls Arguments in Linux Audit Kernel
  2019-08-06 13:28 Query - System Calls Arguments in Linux Audit Kernel Muhammad Adil Inam
@ 2019-08-07 14:44 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2019-08-07 14:44 UTC (permalink / raw)
  To: Muhammad Adil Inam; +Cc: linux-audit, Ali Ahad

On Tue, Aug 6, 2019 at 11:35 AM Muhammad Adil Inam <20100180@lums.edu.pk> wrote:
> As you know, linux-audit logs all the syscall arguments as a1, a2, a3, a4 as unsigned longs. In the case of some syscall, such as WRITE, the second argument, a2, stores the pointer to a buffer, where the buffer contains the content being written. I have been trying to deference the buffer from its address stored in a2. I am dereferencing the buffer currently in kernel/auditsc.c and dumping the dereferenced contents of a2 to printk. However, after building the customized kernel, auditd fails probably due to invalid pointer dereferencing.
>
>I am confused regarding the scope of that pointer variable stored in a2. I have two questions:
>
> 1) Is it possible to deference the syscall arguments in the Linux kernel, given the buffer was initially sent by the process that initiated the syscall?

In order for the syscall to work, the kernel must be able to
dereference pointers to memory passed to it from userspace.  How would
open(2) work if the kernel couldn't dereference the pathname pointer?
If you look at how the kernel implements different syscalls you will
see how that is typically done, and you will surely notice that it can
be tricky to do so safely (you can't trust the calling process to be
well behaved).

> 2) If it is possible to do so, what is the right way to go about it. What is the right file to work if the goal is to dereference the address stored in one of the SYSCALL arguments?

The answer to this depends a lot on what exactly you are trying to do.
In general I would say that the audit subsystem is probably not the
best place to unpack/dereference syscall arguments; while we do
capture information that is closely related to the syscall arguments
(e.g. we record PATH records for the open(2) syscall), we only do so
in some special cases.

My gut feeling is that you might be better off looking into some of
the kernel tracing tools, or even just something like strace/ptrace.

-- 
paul moore
www.paul-moore.com

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

end of thread, other threads:[~2019-08-07 14:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-06 13:28 Query - System Calls Arguments in Linux Audit Kernel Muhammad Adil Inam
2019-08-07 14:44 ` Paul Moore

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.