Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2724702pxb; Sun, 17 Oct 2021 23:53:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzr+K11R8+hp1B67ZqdlruGmEo6JQTISE1/4LddXcRUWgGiyKlu6GEh1iX1nkeilAciG1pH X-Received: by 2002:a17:90a:6782:: with SMTP id o2mr45702332pjj.165.1634540008794; Sun, 17 Oct 2021 23:53:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634540008; cv=none; d=google.com; s=arc-20160816; b=tNrGTNdTCfvY08WJxKd+iVM9Qa5z3jG7feAAgPiJDR90EZk62gxIPK6OKEVgBGV4xF x1o444JccLgj6RB/T/WujQjVQjC7FbMB6hccShtIm7K1T0KReeAaPahPxT6YxKUKQUop GwKshkEQr6i9r55l7pBpQCRQ1yYyd9vF18pSalPFddVZwE3bFUwoeFl07CJ+6XPfHdok IzgOUZvqI5Q0BeWu7pJODArdBBHjwobzQNvebX30mYIrjAX+JiwmgkCHeYRHLnL5WRIA 56b+Nnq/vDKp/NhRJPfuTJmV+E4fKAdzFEy6Y/nS12PqjY5vIMMBOT1tDGzwqLHqEQPU +8sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ngwKYGUafsruL5oNcBtKpGZoiNGcsxviVWEdO/FDJrI=; b=Zx7OVif62YbMjiQf6Xuf3fqLCnSD5KFkhIlmLLMj5+gASGCWRYoSKE9slaMv2SxjTq JqlOCh9GIbAaTwyszhsIGYjWe+HqvWjgK+4/KGXAXoGR2vcoZakA7/QMef/LbxAuB2a6 mSsteLF/7DhTUUKGRetQZQLZ/UvXaJvefy3KA64vvz8Lw1Q+xaeoGMbBS2MbGXGLr4O/ SrcIJhh6V84IvPw3Y1/3KEQYoisKuZkzk2E4sI/BHagAHjrkBSUcgZ95XvhuecVeR0Jc u2clus4cjA+4kLfvjyvoSAm1eMgPJpbUxgsKJ3r+SPQjYdH9hRtC6uWPaO6gevgReVf1 RaKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t8si22338383plg.3.2021.10.17.23.53.16; Sun, 17 Oct 2021 23:53:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230363AbhJRGx0 (ORCPT + 99 others); Mon, 18 Oct 2021 02:53:26 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:14824 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230222AbhJRGxZ (ORCPT ); Mon, 18 Oct 2021 02:53:25 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4HXnTQ5srLz90F9; Mon, 18 Oct 2021 14:46:18 +0800 (CST) Received: from dggpeml500017.china.huawei.com (7.185.36.243) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Mon, 18 Oct 2021 14:51:13 +0800 Received: from linux-suspe12sp5.huawei.com (10.67.133.83) by dggpeml500017.china.huawei.com (7.185.36.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.15; Mon, 18 Oct 2021 14:51:12 +0800 From: ChenJingwen To: CC: , , , , , , , , , Subject: [PATCH] elf: don't use MAP_FIXED_NOREPLACE for elf interpreter mappings Date: Mon, 18 Oct 2021 14:51:12 +0800 Message-ID: <20211018065112.170631-1-chenjingwen6@huawei.com> X-Mailer: git-send-email 2.12.3 In-Reply-To: <202110041255.83A6616D9@keescook> References: <202110041255.83A6616D9@keescook> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.133.83] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500017.china.huawei.com (7.185.36.243) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > The reason is that the elf interpreter (ld.so) has overlapping segments. > > > Ewww. What toolchain generated this (and what caused it to just start > happening)? (This was added in v4.17; it's been 3 years.) gcc 7.3.0 for powerpc Book3E (e5500). I wonder if there are some linker options related to the overlapping segments. I tried to find it out why but I failed. And I also didn't see the answer in the previous discussion yet (Maybe I missed it). What confuses me is why the other reports only have overlapping sections for executable binaries or dynamic libraries, but not for their ld.so. I can keep looking for the reason but it may take a longe time for me. > > readelf -l ld-2.31.so > > Program Headers: > > Type Offset VirtAddr PhysAddr > > FileSiz MemSiz Flags Align > > LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000 > > 0x000000000002c94c 0x000000000002c94c R E 0x10000 > > LOAD 0x000000000002dae0 0x000000000003dae0 0x000000000003dae0 > > 0x00000000000021e8 0x0000000000002320 RW 0x10000 > > LOAD 0x000000000002fe00 0x000000000003fe00 0x000000000003fe00 > > 0x00000000000011ac 0x0000000000001328 RW 0x10000 > > > > The reason for this problem is the same as described in > > commit ad55eac74f20 ("elf: enforce MAP_FIXED on overlaying elf segments"). > > Not only executable binaries, elf interpreters (e.g. ld.so) can have > > overlapping elf segments, so we better drop MAP_FIXED_NOREPLACE and go > > back to MAP_FIXED in load_elf_interp. > > We could also just expand the logic that fixed[1] this for ELF, yes? > > Andrew, are you able to pick up [1], BTW? It seems to have fallen > through the cracks. > > [1] https://lore.kernel.org/all/20210916215947.3993776-1-keescook@chromium.org/T/#u Yes, I expand the logic[1] to load_elf_interp and "init" succeeds to start. Should I submit another patch?