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]
Date:   Fri, 29 Jul 2022 13:38:46 +0800
From:   zhangqing <zhangqing@...ngson.cn>
To:     Youling Tang <tangyouling@...ngson.cn>,
        Huacai Chen <chenhuacai@...nel.org>
Cc:     WANG Xuerui <kernel@...0n.name>, loongarch@...ts.linux.dev,
        linux-kernel@...r.kernel.org,
        Jiaxun Yang <jiaxun.yang@...goat.com>, hejinyang@...ngson.cn
Subject: Re: [PATCH 2/3] LoongArch: Add prologue unwinder support



On 2022/7/29 上午10:03, Youling Tang wrote:
> 
> 
> On 07/28/2022 10:05 PM, Qing Zhang wrote:
>> It unwind the stack frame based on prologue code analyze.
>> CONFIG_KALLSYMS is needed, at least the address and length
>> of each function.
>>
>> Three stages when we do unwind,
>>   (1)unwind_start(), the prapare of unwinding, fill unwind_state.
>>   (2)unwind_done(), judge whether the unwind process is finished or not.
>>   (3)unwind_next_frame(), unwind the next frame.
>>
>> Dividing unwinder helps to add new unwinders in the future, eg:
>> unwind_frame, unwind_orc .etc
>>
>> Signed-off-by: Qing Zhang <zhangqing@...ngson.cn>
>>
>> +
>> +    while (ip < ip_end) {
>> +        if (is_ra_save_ins(ip)) {
>> +            frame_ra = ip->reg2i12_format.immediate;
> Because the immediate member in struct reg2i12_format is defined as an
> unsigned type, the value obtained by frame_ra here can only be a
> positive number.
> 
>> +            break;
>> +        }
>> +        if (is_branch_insn(*ip))
>> +            break;
>> +        ip++;
>> +    }
>> +
>> +    if (frame_ra < 0) {
> In addition to judging whether the initial value of frame_ra is
> negative, we also want to judge whether the previously assigned
> frame_ra is negative.
> 
> Save the ra value to the stack in the prologue, offset must be a
> positive number, so we can add another judgment to is_ra_save_ins, the
> code is as follows:
> +static inline bool is_ra_save_ins(union loongarch_instruction *ip)
> +{
> +    /* st.d $ra, $sp, offset */
> +    return ip->reg2i12_format.opcode == std_op &&
> +        ip->reg2i12_format.rj == LOONGARCH_GPR_SP &&
> +        ip->reg2i12_format.rd == LOONGARCH_GPR_RA &&
> +        !(ip->reg2i12_format.immediate & (1 << 11));
> +}

Hi,
youling

you are right and I will send v2.

Thanks,
Qing

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ