From patchwork Tue Dec 12 12:17:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 753055 Delivered-To: patch@linaro.org Received: by 2002:a5d:4c83:0:b0:333:3a04:f257 with SMTP id z3csp1869550wrs; Tue, 12 Dec 2023 04:24:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IEiXCV2cd/2nTV+Di+YlaBkSpyTukcBOJ/AVrP0MDajXwjgEYIwXrcwRerJ2hHicQnGx6Nt X-Received: by 2002:a05:622a:104e:b0:425:918b:f189 with SMTP id f14-20020a05622a104e00b00425918bf189mr8170454qte.105.1702383867448; Tue, 12 Dec 2023 04:24:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702383867; cv=none; d=google.com; s=arc-20160816; b=Bo74QON4Ld/CYmTsUKhfBw444EB2rm+3boWCz1XjUaJ+xp7Q+dDMXeTB0LA83WPMex vfU3c6kOPFzGtcZq4paOWuc0Y58+HsvTzMtfTiSwUzb+HSNPo4ROK3ivdTg7Xojh69SM f99kYxoe8iZZN6FReAz5pQw3NHiKBwtJIvakyZCf8+BRoWK/HBoC0I9kBZNTqyxUdyzG ga1AIHHE9mV4IJvu/A3rRgBHwpKVao2k0eR+ZLz+szASPzh1ZqrX+K+VHL+gtB0S5WGE EU2p2Z0iGHVFli92ULTLOlnWFMcJoRmWN5fw41uG4ODcby83R1o/Ydy+y21XGzd2fJFp nOuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=GOcItsBaxNMMWib6q9WmvrYRC4MrPr1jMClrImyr4Sc=; fh=bMaafE1clBtiBaCrlbrbcY1DSEPhhFUklUk4XoVHiPU=; b=IWr6xyyLNnElBNlngx2dzaPrWSxcFuaR88EocUBACproQbDRrayxaZOiahoftpkpJu yesOWIjZwhwHyfF22jIFr4Nr9/+r7MBnB4xrrdOYCD3YIUx8EEqGJsrgPNhuA5/dBd9L 2lTLlcMGq+pWWh4bIsdf+EVMffALnJzFn8A9dh3J3tZVuUpHFnlz+fbmQyDrc3qkiUp5 I/zpVkAbWjMdutjltdFrJLLZ8kYsvtWlo0xuHNCDi5tHaY4AsaW2bZsjNF4EYwyi9oZ4 H8lVSRZeGrovmZNjRXwGDVmKnMgW20s/i4jY0+2Eo7kLqN90Wrp7eQmFiRroWBlEqyCg HigQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id kf5-20020a05622a2a8500b004236ecc968dsi9912911qtb.67.2023.12.12.04.24.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Dec 2023 04:24:27 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rD1jH-0005Bi-Aq; Tue, 12 Dec 2023 07:19:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rD1jF-0005Aw-2j; Tue, 12 Dec 2023 07:19:13 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rD1jC-0000Ic-HX; Tue, 12 Dec 2023 07:19:11 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 300BB3AEF9; Tue, 12 Dec 2023 15:18:49 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id EB80E3B947; Tue, 12 Dec 2023 15:18:31 +0300 (MSK) Received: (nullmailer pid 1003416 invoked by uid 1000); Tue, 12 Dec 2023 12:18:31 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Richard Henderson , Michael Tokarev Subject: [Stable-8.1.4 06/31] linux-user: Fix loaddr computation for some elf files Date: Tue, 12 Dec 2023 15:17:54 +0300 Message-Id: <20231212121831.1003318-6-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson The file offset of the load segment is not relevant to the low address, only the beginning of the virtual address page. Cc: qemu-stable@nongnu.org Fixes: a93934fecd4 ("elf: take phdr offset into account when calculating the program load address") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1952 Signed-off-by: Richard Henderson Reviewed-by: Michael Tokarev (cherry picked from commit 82d70a84c8ee42ef969a9cfddc0f5b30b16165f5) Signed-off-by: Michael Tokarev diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 47170fe5d3..b1462842b6 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -3093,7 +3093,7 @@ static void load_elf_image(const char *image_name, int image_fd, for (i = 0; i < ehdr->e_phnum; ++i) { struct elf_phdr *eppnt = phdr + i; if (eppnt->p_type == PT_LOAD) { - abi_ulong a = eppnt->p_vaddr - eppnt->p_offset; + abi_ulong a = eppnt->p_vaddr & TARGET_PAGE_MASK; if (a < loaddr) { loaddr = a; }