lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <49C37E28.2020304@redhat.com>
Date:	Fri, 20 Mar 2009 07:29:44 -0400
From:	Masami Hiramatsu <mhiramat@...hat.com>
To:	ananth@...ibm.com
CC:	Ingo Molnar <mingo@...e.hu>, Steven Rostedt <rostedt@...dmis.org>,
	systemtap-ml <systemtap@...rces.redhat.com>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [RFC][PATCH -tip 7/9] tracing: kprobe-tracer plugin supports
 arguments

Ananth N Mavinakayanahalli wrote:
> On Thu, Mar 19, 2009 at 05:10:40PM -0400, Masami Hiramatsu wrote:
> 
>> +#if defined(__i386__)
>> +#define REGPARMS 3
>> +static unsigned long fetch_argument(struct pt_regs *regs, void *data)
>> +{
>> +	unsigned long n = (unsigned long)data;
>> +	if (n > REGPARMS) {
>> +		/*
>> +		 * The typical case: arg n is on the stack.
>> +		 * stack[0] = return address
>> +		 */
>> +		return fetch_stack(regs, (void *)(n - REGPARMS));
>> +	} else {
>> +		switch (n) {
>> +		case 1: return regs->ax;
>> +		case 2: return regs->dx;
>> +		case 3: return regs->cx;
>> +		}
>> +		return 0;
>> +	}
>> +}
>> +#elif define(__x86_64__)
> 
> #elif defined(__x86_64__)

Ahh, yes.

> 
>> +#define REGPARMS 6
>> +static unsigned long fetch_argument(struct pt_regs *regs, void *data)
>> +{
>> +	unsigned long n = (unsigned long)data;
>> +	if (n > REGPARMS) {
>> +		/*
>> +		 * The typical case: arg n is on the stack.
>> +		 * stack[0] = return address
>> +		 */
>> +		return fetch_stack(regs, (void *)(n - REGPARMS));
>> +	} else {
>> +		switch (n) {
>> +		case 1: return regs->di;
>> +		case 2: return regs->si;
>> +		case 3: return regs->dx;
>> +		case 4: return regs->cx;
>> +		case 5: return regs->r8;
>> +		case 6: return regs->r9;
>> +		}
>> +		return 0;
>> +	}
>> +}
>> +#else
>> +static unsigned long fetch_argument(struct pt_regs *regs, void *data)
>> +{
>> +	return fetch_stack(regs, data);
>> +}
>> +#endif
> 
> As mentioned in another email, if we can generalize something similar to
> syscall_get_arguments, this can be made to work for many !x86 archs.
> AFAICS the calling conventions mandated by the ABI are followed at
> syscall time, isn't it?

No, function calling conventions depend on gcc(i386)/ABI specification
(x86-64). And on i386, this just works on most of functions which are
compiled with -mregparm=3, and without asmlinkage(for asmlinkage functions,
all arguments are passed over stack).
So, it just provides a "user-friendly" interface :) , not a strict defined
interface.

Thanks,

> 
> Ananth

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@...hat.com

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ