From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward503j.mail.yandex.net (forward503j.mail.yandex.net [5.45.198.239]) by sourceware.org (Postfix) with ESMTPS id 1785E3853D4A for ; Thu, 17 Nov 2022 18:51:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1785E3853D4A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yandex.ru Received: from iva5-344f444591f3.qloud-c.yandex.net (iva5-344f444591f3.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:687:0:640:344f:4445]) by forward503j.mail.yandex.net (Yandex) with ESMTP id 6BC731DAEDAA; Thu, 17 Nov 2022 21:51:27 +0300 (MSK) Received: by iva5-344f444591f3.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id M10DKIt2KS-pPgCOIog; Thu, 17 Nov 2022 21:51:26 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1668711087; bh=NfJRC7bZcjhcgpjsH62QIMuCs7un7Lh4u5jsKtQ+JuE=; h=Message-Id:To:Date:References:Cc:In-Reply-To:From:Subject; b=S2jOtJuQoPtyL6DZ9Yzhz8ZF0WNn325+hBES5c3RHeGR8GuGVy0ocUcu1Y1mft1l9 UbdYIlFs4rxSaNXl9jhPuET+AEv+VMtgg8ItA558BrGC9T8IMhCVueBmz/WHHgKARq t+Ff8SutH5LlyDq/FvfcRFG7khQQdZXW3mrv61Qo= Authentication-Results: iva5-344f444591f3.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.80.82.1.1\)) Subject: Re: [PATCH] elf: Fix rtld-audit trampoline for aarch64 From: Vladislav Khmelevsky In-Reply-To: <3180cd8a-a3e2-b6bb-cb6a-af7c2a4fca22@linaro.org> Date: Thu, 17 Nov 2022 22:51:23 +0400 Cc: libc-alpha@sourceware.org, woodard@redhat.com Content-Transfer-Encoding: quoted-printable Message-Id: <8E908272-FB79-4940-9183-A705EDA36D05@yandex.ru> References: <20221117084729.2794073-1-och95@yandex.ru> <8c6d9a21-464b-3b8d-661a-a3b3733e1bb7@linaro.org> <3180cd8a-a3e2-b6bb-cb6a-af7c2a4fca22@linaro.org> To: Adhemerval Zanella Netto X-Mailer: Apple Mail (2.3696.80.82.1.1) X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GIT_PATCH_0,KAM_NUMSUBJECT,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Thanks! But I would need some guidance from you if you don't mind. First = of all I don't have write access to the repo, I would very appreciate if = you or somebody would help me to merge this :) > 17 =D0=BD=D0=BE=D1=8F=D0=B1. 2022 =D0=B3., =D0=B2 22:36, Adhemerval = Zanella Netto =D0=BD=D0=B0=D0=BF=D0=B8=D1=81= =D0=B0=D0=BB(=D0=B0): >=20 >=20 >=20 > On 17/11/22 15:23, Vladislav Khmelevsky wrote: >> Thank you for reviewing! >> Yes, it is true tat inly x0/x1 are used as return register. But I = have a specific audit library code that was storing some metadata in a = free registers during plt entrer and reading it during plt exit :) As = for a normal use cases both problems doesn't really affect anything. >>=20 >=20 > Fair enough, although we might want to backport this. >=20 > Reviewed-by: Adhemerval Zanella >=20 >>> 17 =D0=BD=D0=BE=D1=8F=D0=B1. 2022 =D0=B3., =D0=B2 22:15, Adhemerval = Zanella Netto =D0=BD=D0=B0=D0=BF=D0=B8=D1=81= =D0=B0=D0=BB(=D0=B0): >>>=20 >>>=20 >>>=20 >>> On 17/11/22 05:47, Vladislav Khmelevsky wrote: >>>> This patch fixes two problems with audit: >>>> 1. The DL_OFFSET_RV_VPCS offset was mixed up with = DL_OFFSET_RG_VPCS, >>>> resulting in x2 register value nulling in RG structure. >>>> 2. We need to preserve the x8 register before function call, but = don't have >>>> to save it's new value and restore it before return. Anyway the = final >>>> restore was using OFFSET_RV instead of OFFSET_RG value which is = wrong (althoug doesn't affect anything). >>>=20 >>> Patch looks ok, although I think currently the ABI only uses x0 = and/or x1 >>> to return value (for __int128_t for instance). So I think it should = not >>> be a user-visible issue (at least tst-audit26 does check that = lr_vpcs >>> and lrv_vpcs are zeroed). Are you seeing any issue with current = code? >>> If so could you open a bug please? >>>=20 >>>> --- >>>> sysdeps/aarch64/dl-trampoline.S | 4 +--- >>>> 1 file changed, 1 insertion(+), 3 deletions(-) >>>>=20 >>>> diff --git a/sysdeps/aarch64/dl-trampoline.S = b/sysdeps/aarch64/dl-trampoline.S >>>> index 909b208578..d66f0b9c45 100644 >>>> --- a/sysdeps/aarch64/dl-trampoline.S >>>> +++ b/sysdeps/aarch64/dl-trampoline.S >>>> @@ -298,12 +298,11 @@ _dl_runtime_profile: >>>> stp x2, x3, [x29, #OFFSET_RV + DL_OFFSET_RV_X0 + 16*1] >>>> stp x4, x5, [x29, #OFFSET_RV + DL_OFFSET_RV_X0 + 16*2] >>>> stp x6, x7, [x29, #OFFSET_RV + DL_OFFSET_RV_X0 + 16*3] >>>> - str x8, [x29, #OFFSET_RG + DL_OFFSET_RG_X0 + 16*4] >>>> stp q0, q1, [x29, #OFFSET_RV + DL_OFFSET_RV_V0 + 32*0] >>>> stp q2, q3, [x29, #OFFSET_RV + DL_OFFSET_RV_V0 + 32*1] >>>> stp q4, q5, [x29, #OFFSET_RV + DL_OFFSET_RV_V0 + 32*2] >>>> stp q6, q7, [x29, #OFFSET_RV + DL_OFFSET_RV_V0 + 32*3] >>>> - str xzr, [X29, #OFFSET_RV + DL_OFFSET_RG_VPCS] >>>> + str xzr, [X29, #OFFSET_RV + DL_OFFSET_RV_VPCS] >>>>=20 >>>> /* Setup call to pltexit */ >>>> ldp x0, x1, [x29, #OFFSET_SAVED_CALL_X0] >>>> @@ -315,7 +314,6 @@ _dl_runtime_profile: >>>> ldp x2, x3, [x29, #OFFSET_RV + DL_OFFSET_RV_X0 + 16*1] >>>> ldp x4, x5, [x29, #OFFSET_RV + DL_OFFSET_RV_X0 + 16*2] >>>> ldp x6, x7, [x29, #OFFSET_RV + DL_OFFSET_RV_X0 + 16*3] >>>> - ldr x8, [x29, #OFFSET_RV + DL_OFFSET_RV_X0 + 16*4] >>>> ldp q0, q1, [x29, #OFFSET_RV + DL_OFFSET_RV_V0 + 32*0] >>>> ldp q2, q3, [x29, #OFFSET_RV + DL_OFFSET_RV_V0 + 32*1] >>>> ldp q4, q5, [x29, #OFFSET_RV + DL_OFFSET_RV_V0 + 32*2] >>=20