* Getting the way a SIGSEGV append when catching a SIGSEGV from within
@ 2017-03-27 14:45 none
2017-03-27 15:30 ` Richard Weinberger
0 siblings, 1 reply; 4+ messages in thread
From: none @ 2017-03-27 14:45 UTC (permalink / raw)
To: Linux Kernel, linux-x86_64
Hello,
There’s three way to perform an invalid memory access :
The attempt to execute/jump at an invalid address.
The attempt to read at an invalid address.
The attempt to write at an invalid address.
Determining the execute case with rt_sigaction is easy : the last value
of eip match the value of the address which caused the segfault.
But how to know if the SIGSEGV occurred by a read or by a write attempt
? In the same time shouldn’t that information belong in the mmu ?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Getting the way a SIGSEGV append when catching a SIGSEGV from within
2017-03-27 14:45 Getting the way a SIGSEGV append when catching a SIGSEGV from within none
@ 2017-03-27 15:30 ` Richard Weinberger
2017-03-27 18:55 ` none
0 siblings, 1 reply; 4+ messages in thread
From: Richard Weinberger @ 2017-03-27 15:30 UTC (permalink / raw)
To: none; +Cc: Linux Kernel, linux-x86_64
On Mon, Mar 27, 2017 at 4:45 PM, none <ytrezq@sdf-eu.org> wrote:
> Hello,
>
> There’s three way to perform an invalid memory access :
>
> The attempt to execute/jump at an invalid address.
> The attempt to read at an invalid address.
> The attempt to write at an invalid address.
>
> Determining the execute case with rt_sigaction is easy : the last value of
> eip match the value of the address which caused the segfault.
>
> But how to know if the SIGSEGV occurred by a read or by a write attempt ? In
> the same time shouldn’t that information belong in the mmu ?
Did you look at the machine specific context of SIGSEGV?
It will give you access to the error code and the trap number.
--
Thanks,
//richard
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Getting the way a SIGSEGV append when catching a SIGSEGV from within
2017-03-27 15:30 ` Richard Weinberger
@ 2017-03-27 18:55 ` none
2017-03-27 19:20 ` Richard Weinberger
0 siblings, 1 reply; 4+ messages in thread
From: none @ 2017-03-27 18:55 UTC (permalink / raw)
To: Richard Weinberger; +Cc: Linux Kernel, linux-x86_64
Le 2017-03-27 17:30, Richard Weinberger a écrit :
> On Mon, Mar 27, 2017 at 4:45 PM, none <ytrezq@sdf-eu.org> wrote:
>> Hello,
>>
>> There’s three way to perform an invalid memory access :
>>
>> The attempt to execute/jump at an invalid address.
>> The attempt to read at an invalid address.
>> The attempt to write at an invalid address.
>>
>> Determining the execute case with rt_sigaction is easy : the last
>> value of
>> eip match the value of the address which caused the segfault.
>>
>> But how to know if the SIGSEGV occurred by a read or by a write
>> attempt ? In
>> the same time shouldn’t that information belong in the mmu ?
>
> Did you look at the machine specific context of SIGSEGV?
> It will give you access to the error code and the trap number.
Sorry but so, in the case of x86_64, which is the struct member I need
to look at ?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Getting the way a SIGSEGV append when catching a SIGSEGV from within
2017-03-27 18:55 ` none
@ 2017-03-27 19:20 ` Richard Weinberger
0 siblings, 0 replies; 4+ messages in thread
From: Richard Weinberger @ 2017-03-27 19:20 UTC (permalink / raw)
To: none; +Cc: Linux Kernel, linux-x86_64
Am 27.03.2017 um 20:55 schrieb none:
> Le 2017-03-27 17:30, Richard Weinberger a écrit :
>> On Mon, Mar 27, 2017 at 4:45 PM, none <ytrezq@sdf-eu.org> wrote:
>>> Hello,
>>>
>>> There’s three way to perform an invalid memory access :
>>>
>>> The attempt to execute/jump at an invalid address.
>>> The attempt to read at an invalid address.
>>> The attempt to write at an invalid address.
>>>
>>> Determining the execute case with rt_sigaction is easy : the last value of
>>> eip match the value of the address which caused the segfault.
>>>
>>> But how to know if the SIGSEGV occurred by a read or by a write attempt ? In
>>> the same time shouldn’t that information belong in the mmu ?
>>
>> Did you look at the machine specific context of SIGSEGV?
>> It will give you access to the error code and the trap number.
>
> Sorry but so, in the case of x86_64, which is the struct member I need to look at ?
ucontext_t *c = context; // context is the 3rd parameter to your SIGSEGV handler when SA_SIGINFO is set
mcontext_t m = c->uc_mcontext;
m.gregs[REG_ERR] and m.gregs[REG_TRAPNO] are what you want.
HTH,
//richard
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-27 19:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-27 14:45 Getting the way a SIGSEGV append when catching a SIGSEGV from within none
2017-03-27 15:30 ` Richard Weinberger
2017-03-27 18:55 ` none
2017-03-27 19:20 ` Richard Weinberger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).