Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1609905 > unrolled thread

Getting the way a SIGSEGV append when catching a SIGSEGV from within

Started bynone <ytrezq@sdf-eu.org>
First post2017-03-27 17:00 +0200
Last post2017-03-27 21:30 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  Getting the way a SIGSEGV append when catching a SIGSEGV from within none <ytrezq@sdf-eu.org> - 2017-03-27 17:00 +0200
    Re: Getting the way a SIGSEGV append when catching a SIGSEGV from within Richard Weinberger <richard.weinberger@gmail.com> - 2017-03-27 17:40 +0200
      Re: Getting the way a SIGSEGV append when catching a SIGSEGV from  within none <ytrezq@sdf-eu.org> - 2017-03-27 21:00 +0200
        Re: Getting the way a SIGSEGV append when catching a SIGSEGV from  within Richard Weinberger <richard@nod.at> - 2017-03-27 21:30 +0200

#1609905 — Getting the way a SIGSEGV append when catching a SIGSEGV from within

Fromnone <ytrezq@sdf-eu.org>
Date2017-03-27 17:00 +0200
SubjectGetting the way a SIGSEGV append when catching a SIGSEGV from within
Message-ID<tpEhH-17e-11@gated-at.bofh.it>
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 ?

[toc] | [next] | [standalone]


#1609957

FromRichard Weinberger <richard.weinberger@gmail.com>
Date2017-03-27 17:40 +0200
Message-ID<tpEUp-1P8-17@gated-at.bofh.it>
In reply to#1609905
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

[toc] | [prev] | [next] | [standalone]


#1610074 — Re: Getting the way a SIGSEGV append when catching a SIGSEGV from within

Fromnone <ytrezq@sdf-eu.org>
Date2017-03-27 21:00 +0200
SubjectRe: Getting the way a SIGSEGV append when catching a SIGSEGV from within
Message-ID<tpI1X-46a-1@gated-at.bofh.it>
In reply to#1609957
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 ?

[toc] | [prev] | [next] | [standalone]


#1610084 — Re: Getting the way a SIGSEGV append when catching a SIGSEGV from within

FromRichard Weinberger <richard@nod.at>
Date2017-03-27 21:30 +0200
SubjectRe: Getting the way a SIGSEGV append when catching a SIGSEGV from within
Message-ID<tpIuZ-4vN-1@gated-at.bofh.it>
In reply to#1610074
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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web