From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by sourceware.org (Postfix) with ESMTPS id 77D2B3846060 for ; Fri, 10 Jun 2022 12:21:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 77D2B3846060 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-fe15832ce5so2978700fac.8 for ; Fri, 10 Jun 2022 05:21:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fZPD2owd/l+ny8GpVQIt9loXDjhI9ybHEA3F2rRMkI4=; b=zZGEbamDkV8Z3+EiHQf7dZ9czcyDbdoBtjXz5DP2xVNHKP4my+Da8BthekswVWFnek D6C4fAE1YiWMCmVfEDbjnBfy7516DMOVGk//3XWj2hZVqGg0wuWWdCtEaX16qX6J4XgB a+zZfwTK+li6iUyacWffH4TnSKneZ2pi73LlOO9vcqGcX98IGb8rJpt2z4sxASKfEORc 28p5JgDlXK/KnR2PYZDRoh3Yt+a/bod6t7RdpuVnVeXyuQ/B7W82RpFe2SktgZMHdDF7 OLscR+VzXOyu89dD5LUHZCrP+kDuYiHCKmUJZeILQP1vdh9Xei/J0+eNvNOuQzllNP/p Z/3w== X-Gm-Message-State: AOAM533lflJj3uTQSfq35Q/3bgeTTjcDgp12oqvayf+RV73B1V8ptT1b 4IIkgtWpfyca15iZ36H39HFE3L/n9B1Wag== X-Google-Smtp-Source: ABdhPJxORABbxRIXRi/hKXL7u8AHIF2xnQUi5JeIc21EmMCPrgS5FguTQT9BovgNgvBf9zz6UI+PlQ== X-Received: by 2002:a05:6870:a910:b0:e6:dca:5fd3 with SMTP id eq16-20020a056870a91000b000e60dca5fd3mr4398283oab.202.1654863715351; Fri, 10 Jun 2022 05:21:55 -0700 (PDT) Received: from birita.. ([2804:431:c7cb:a613:818b:b86c:a3f8:d455]) by smtp.gmail.com with ESMTPSA id k17-20020a4ae291000000b0035f627ac898sm13564231oot.10.2022.06.10.05.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 05:21:55 -0700 (PDT) From: Adhemerval Zanella To: libc-stable@sourceware.org Cc: Carlos O'Donell Subject: [COMMITTED 2.34,2.35] hppa: Remove _dl_skip_args usage (BZ# 29165) Date: Fri, 10 Jun 2022 09:21:47 -0300 Message-Id: <20220610122147.525082-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jun 2022 12:21:58 -0000 Different than other architectures, hppa creates an unrelated stack frame where ld.so argc/argv adjustments done by ad43cac44a6860eaefc is not done on the argc/argv saved/restore by _dl_start_user. Instead load _dl_argc and _dl_argv directlty instead of adjust them using _dl_skip_args value. Checked on hppa-linux-gnu. Reviewed-by: Carlos O'Donell (cherry picked from commit 6242602273feb8d68cd51cff0ad21b3c8ee11fc6) --- NEWS | 1 + sysdeps/hppa/dl-machine.h | 36 ++++++++++++++---------------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/NEWS b/NEWS index fe37985bc2..fdd46be860 100644 --- a/NEWS +++ b/NEWS @@ -101,6 +101,7 @@ The following bugs are resolved with this release: [29078] functions unusable during early auditing [29097] time: fchmodat does not handle 64 bit time_t for AT_SYMLINK_NOFOLLOW + [29165] libc: [Regression] broken argv adjustment [29203] libc: daemon is not y2038 aware [29204] libc: getusershell is not 2038 aware [29207] libc: posix_fallocate fallback implementation is not y2038 diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h index ac66f04418..df6269209f 100644 --- a/sysdeps/hppa/dl-machine.h +++ b/sysdeps/hppa/dl-machine.h @@ -374,10 +374,6 @@ asm ( \ "_start:\n" \ /* The kernel does not give us an initial stack frame. */ \ " ldo 64(%sp),%sp\n" \ - /* Save the relevant arguments (yes, those are the correct \ - registers, the kernel is weird) in their stack slots. */ \ -" stw %r25,-40(%sp)\n" /* argc */ \ -" stw %r24,-44(%sp)\n" /* argv */ \ \ /* We need the LTP, and we need it now. \ $PIC_pcrel$0 points 8 bytes past the current instruction, \ @@ -435,12 +431,7 @@ asm ( \ So, obviously, we can't just pass %sp to _dl_start. That's \ okay, argv-4 will do just fine. \ \ - The pleasant part of this is that if we need to skip \ - arguments we can just decrement argc and move argv, because \ - the stack pointer is utterly unrelated to the location of \ - the environment and argument vectors. */ \ - \ - /* This is always within range so we'll be okay. */ \ + This is always within range so we'll be okay. */ \ " bl _dl_start,%rp\n" \ " ldo -4(%r24),%r26\n" \ \ @@ -450,22 +441,23 @@ asm ( \ /* Save the entry point in %r3. */ \ " copy %ret0,%r3\n" \ \ - /* See if we were called as a command with the executable file \ - name as an extra leading argument. */ \ -" addil LT'_dl_skip_args,%r19\n" \ -" ldw RT'_dl_skip_args(%r1),%r20\n" \ -" ldw 0(%r20),%r20\n" \ - \ -" ldw -40(%sp),%r25\n" /* argc */ \ -" comib,= 0,%r20,.Lnofix\n" /* FIXME: Mispredicted branch */\ -" ldw -44(%sp),%r24\n" /* argv (delay slot) */ \ + /* The loader adjusts argc, argv, env, and the aux vectors \ + directly on the stack to remove any arguments used for \ + direct loader invocation. Thus, argc and argv must be \ + reloaded from from _dl_argc and _dl_argv. */ \ \ -" sub %r25,%r20,%r25\n" \ + /* Load argc from _dl_argc. */ \ +" addil LT'_dl_argc,%r19\n" \ +" ldw RT'_dl_argc(%r1),%r20\n" \ +" ldw 0(%r20),%r25\n" \ " stw %r25,-40(%sp)\n" \ -" sh2add %r20,%r24,%r24\n" \ + \ + /* Same for argv with _dl_argv. */ \ +" addil LT'_dl_argv,%r19\n" \ +" ldw RT'_dl_argv(%r1),%r20\n" \ +" ldw 0(%r20),%r24\n" \ " stw %r24,-44(%sp)\n" \ \ -".Lnofix:\n" \ /* Call _dl_init(main_map, argc, argv, envp). */ \ " addil LT'_rtld_local,%r19\n" \ " ldw RT'_rtld_local(%r1),%r26\n" \ -- 2.34.1