From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0953DC52D7B for ; Tue, 13 Aug 2024 04:53:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 777126B00A1; Tue, 13 Aug 2024 00:53:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 726C96B00A2; Tue, 13 Aug 2024 00:53:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C6E46B00A3; Tue, 13 Aug 2024 00:53:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 3EC946B00A1 for ; Tue, 13 Aug 2024 00:53:18 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id EA2D540606 for ; Tue, 13 Aug 2024 04:53:17 +0000 (UTC) X-FDA: 82446003234.07.3FBAD2D Received: from omr02.pc5.atmailcloud.com (omr02.pc5.atmailcloud.com [54.206.55.205]) by imf02.hostedemail.com (Postfix) with ESMTP id F25C78001A for ; Tue, 13 Aug 2024 04:53:14 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=westnet.com.au header.s=202309 header.b=tkOZaraJ; spf=pass (imf02.hostedemail.com: domain of gregungerer@westnet.com.au designates 54.206.55.205 as permitted sender) smtp.mailfrom=gregungerer@westnet.com.au; dmarc=pass (policy=reject) header.from=westnet.com.au ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723524740; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3cJHkeEWJdTOPVkgsndMVLebgcWMcA0m5U/SakPWxQY=; b=l9qvnJrsUWi22jsUfNzv/cGzmWAlNT/fF3W2Tb93yx/QrVvh5iVd/bepC5a+3xqbu4ye8h 8bl7Uq3ecpDgup/ltPMQp6atP4f2L1tVsvaAeG6AI+XrUc3OVPOPPo1lG5XIkZy1EqXsWP g936lLJtTiQsooLYxojmG8HdpRvfiVo= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=westnet.com.au header.s=202309 header.b=tkOZaraJ; spf=pass (imf02.hostedemail.com: domain of gregungerer@westnet.com.au designates 54.206.55.205 as permitted sender) smtp.mailfrom=gregungerer@westnet.com.au; dmarc=pass (policy=reject) header.from=westnet.com.au ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723524740; a=rsa-sha256; cv=none; b=XjKM0mzSnefUk/WD8rIUdDMaPNc7VPqlypvexYULyTv1G3Xf1pbjB25+hn9jpOsdXS20DO VuTK0cBJn7z0kKvUiZFhFaQFuQ+7nUild2Zb7moH/sq640bJEygQ0w0q5zBkwlsWsRmom9 wbarcINaAy7/oCpKtGsQGJrwlWaHov8= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=westnet.com.au; s=202309; h=Content-Type:From:To:Subject:MIME-Version:Date: Message-ID; bh=3cJHkeEWJdTOPVkgsndMVLebgcWMcA0m5U/SakPWxQY=; b=tkOZaraJYTjLyZ XUpMdUu9RBTqo9x0MAMwPf4FNM/BKUwTWVEt0lAo73SQ9hQUcb37HwyLxO8vSUoIKG+zd7gyf0s2f 691njGEOdoTspkJrOwmDZyTwnF5AI/8dNoejNwuB4HIkMMEkhDWwYN1l5BRkPyqV+k3AM/FFzGgVT wGIufyxj6+v+L5LAS3y41emtekHO3Eun/IqCop1+QtJXEKuJDsKXOCzsMVYm1reZkL574H1Qm9Iyp 4fb0tTRImuZRQ1d319SgPJTgUO524gDBXqrjOh5dZ1gO5Wz6ag+VBTl5Ho/La8AJRoo9d0Menj8dt MjWp/Rxo843lnvdxNRlA==; Received: from CMR-KAKADU04.i-058615fd6484c2476 by OMR.i-0e491b094b8af55fe with esmtps (envelope-from ) id 1sdjWw-00049a-PY; Tue, 13 Aug 2024 04:53:10 +0000 Received: from [27.33.250.67] (helo=[192.168.0.22]) by CMR-KAKADU04.i-058615fd6484c2476 with esmtpsa (envelope-from ) id 1sdjWw-0001YC-0C; Tue, 13 Aug 2024 04:53:10 +0000 Message-ID: Date: Tue, 13 Aug 2024 14:53:07 +1000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] binfmt_elf_fdpic: fix /proc//auxv To: Max Filippov Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Eric Biederman , Kees Cook , Alexander Viro , Christian Brauner , Jan Kara References: <20240322195418.2160164-1-jcmvbkbc@gmail.com> <5b51975f-6d0b-413c-8b38-39a6a45e8821@westnet.com.au> Content-Language: en-US From: Greg Ungerer In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Atmail-Id: gregungerer@westnet.com.au X-atmailcloud-spam-action: no action X-Cm-Analysis: v=2.4 cv=dZSG32Xe c=1 sm=1 tr=0 ts=66bae6b6 a=Pz+tuLbDt1M46b9uk18y4g==:117 a=Pz+tuLbDt1M46b9uk18y4g==:17 a=IkcTkHD0fZMA:10 a=yoJbH4e0A30A:10 a=80-xaVIC0AIA:10 a=x7bEGLp0ZPQA:10 a=8-D65JXZAAAA:8 a=pGLkceISAAAA:8 a=NEAV23lmAAAA:8 a=wDIXi1D9eSG_FC4LhKkA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Cm-Envelope: MS4xfGLLfUTOnIyosU8mZRs+INHuoDdA5S0SVVGBv2L8f3kXyXEZSVvjnrVglC3oauLk/3M9hDB+OJwXATfshCbPyX9+pDh3gNqB+dHGrd3YSTeTnPcL2cuE kppVlSMtE8zEIWT1uwhFqGy0rnqMVpgvVxj/Vk6smPooxnDaOKDwZm5sfUGrw+3wGfXybDw/ZVMQ+Q== X-atmailcloud-route: unknown X-Stat-Signature: grk8xxp61t4x7gk6qxx8p4ec3n366pac X-Rspam-User: X-Rspamd-Queue-Id: F25C78001A X-Rspamd-Server: rspam02 X-HE-Tag: 1723524794-167304 X-HE-Meta: U2FsdGVkX194QTVDEP/vel42zO7cBSF65sikzLp9VyFMeZFMNjXskSCE7ZLcDn2HVhBNp/HSjSltFYcjmRK5WD9oHaJQNISxG/dDGEzb/hsnPzZDEOHBKm4hZqvBdVEVSWcK9osZD71HyDMU2zMUinIVO5b1z8SjJkxs5E46uFRUw4xbyzHfRfIjNE6wrN8/ctJqHfTO5YeEbOcILrQ04QuodVPBjD5O5T5xBNZbh79pNeseUDLEYKpA5JAIR/xC7KMX5Eu/qPdSiYbjFg1oESLga4/OLuuhuEyzfxE+BlJ01o3uLwHiaJ0+kbX9ksx3DDSGxh98e5LfQ5FPbtCcqn4ctdnFtS7ObIlRfspzS6F4v8YY3PIL98dZZO8cUNtOaMRYGT7CkDkSM/g4j2ztfMj8Dhs1bt/tciYWs4vc3p7mzURffa+HODvEvcnoEYDYzwW9MmqBvVk7/nxbVVYgfTpDyg/uXjIbANdiJVudrt1sCX5gQ+tPmayAxhobQ/RIMBx+rf5ARAITD2COaRzd7cUsfeKxNGJxYbc1uSAlE0G89V88liTgwu3NNCGyRzWsr/vjqXw4mjNaKPsKjs+GSYJ+QHhGfIvH78Sp8uXVcimJWjhowWzv9Ci7Lf8Mv5O5b+DO8cGypbGjjAt57nAz407WSfDYe/Kh5CAqV1Gk2I7n/zjw9rr8/nxU9km7NI7uI9/Jtqc18fO1ULHIhAnHe2RpYYTI66nygxgdJdwk599OwFZeAyG85JARug8jOLhz4ls40y/1csA3BvCkBqHP1aM3HoTet23MoJcJBxMj7PVDvZkC3FYn0l//nmb6EC15Utzeq7k9/+S8pbuPDIAyLZ96N13CiLKOtdI5tUGBBYQzQ5DvLRa30DADbDXz1QDaY5n98hY0Oy/pUDcw5Utv/NSjVt1ADvTb/LCLu2N+dLXikGvw+lhi5mQKVjLv90VJ/NbuDnnFc+1Pd0lXHVl WzPJRH5X DD5ucN9Tj9Db99duyQCtUzxk7Z6nhV9rzlTeH2K9KPHifss7U6Tr0jMOOc4zJ6s1GX8vO7+3IgjerYd8OtR44NyECbFfhY5UWVAPLvUs/wlYWyFJrTrjn5GAVVvDm5DHpD+jdpxp6xIJBt+tTcSZp3CQR67s+svZCw/sVtcQK9D8+1DbEnHm/jeA2nSY2/fa9fhxCwSGr5BeatHGDCuZUk3zC3OA14DgLSOpviDTjO3xMl/lIMs3IuvEwniDusFRTkcfL8uzVyGDO2F3dxLqMQaFmPiPx7M8CkLwdI/SJXeM8/LPkNSeSJGWNRtu2kRxV+WsA0+LsOvSfy69MuiabFI11DHvuK9Endywn2AjufBaAxX7J9+It0JUut8ldHu1I9VO7ScK/AUqzx+WoQ1uIXgC+TW8Rm8cnMAJN/4bu0ookkgh4ak34roThXYKwBKC02IaHycwG3ldNhF3qxLS2YlW9ssnFFeTZAd5FeGvHMGCsyRDAj2YqXB5aZ0b+6kCXyUx1+1jmmifSPOsgwQ+OwkNsWQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi Max, On 13/8/24 04:02, Max Filippov wrote: > Hi Greg, > > On Sun, Aug 11, 2024 at 7:26 PM Greg Ungerer wrote: >> On 23/3/24 05:54, Max Filippov wrote: >>> Althought FDPIC linux kernel provides /proc//auxv files they are >>> empty because there's no code that initializes mm->saved_auxv in the >>> FDPIC ELF loader. >>> >>> Synchronize FDPIC ELF aux vector setup with ELF. Replace entry-by-entry >>> aux vector copying to userspace with initialization of mm->saved_auxv >>> first and then copying it to userspace as a whole. >>> >>> Signed-off-by: Max Filippov >> >> This is breaking ARM nommu builds supporting fdpic and elf binaries for me. >> >> Tests I have for m68k and riscv nommu setups running elf binaries >> don't show any problems - I am only seeing this on ARM. >> >> >> ... >> Freeing unused kernel image (initmem) memory: 472K >> This architecture does not have kernel memory protection. >> Run /init as init process >> Internal error: Oops - undefined instruction: 0 [#1] ARM >> Modules linked in: >> CPU: 0 PID: 1 Comm: init Not tainted 6.10.0 #1 >> Hardware name: ARM-Versatile (Device Tree Support) >> PC is at load_elf_fdpic_binary+0xb34/0xb80 >> LR is at 0x0 >> pc : [<00109ce8>] lr : [<00000000>] psr: 80000153 >> sp : 00823e40 ip : 00000000 fp : 00b8fee4 >> r10: 009c9b80 r9 : 00b8ff80 r8 : 009ee800 >> r7 : 00000000 r6 : 009f7e80 r5 : 00b8fedc r4 : 00b87000 >> r3 : 00b8fed8 r2 : 00b8fee0 r1 : 00b87128 r0 : 00b8fef0 >> Flags: Nzcv IRQs on FIQs off Mode SVC_32 ISA ARM Segment none >> Control: 00091176 Table: 00000000 DAC: 00000000 >> Register r0 information: non-slab/vmalloc memory >> Register r1 information: slab/vmalloc mm_struct start 00b87000 pointer offset 296 size 428 >> Register r2 information: non-slab/vmalloc memory >> Register r3 information: non-slab/vmalloc memory >> Register r4 information: slab/vmalloc mm_struct start 00b87000 pointer offset 0 size 428 >> Register r5 information: non-slab/vmalloc memory >> Register r6 information: slab/vmalloc kmalloc-32 start 009f7e80 pointer offset 0 size 32 >> Register r7 information: non-slab/vmalloc memory >> Register r8 information: slab/vmalloc kmalloc-512 start 009ee800 pointer offset 0 size 512 >> Register r9 information: non-slab/vmalloc memory >> Register r10 information: slab/vmalloc kmalloc-128 start 009c9b80 pointer offset 0 size 128 >> Register r11 information: non-slab/vmalloc memory >> Register r12 information: non-slab/vmalloc memory >> Process init (pid: 1, stack limit = 0x(ptrval)) >> Stack: (0x00823e40 to 0x00824000) >> 3e40: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> 3e60: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> 3e80: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> 3ea0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> 3ec0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> 3ee0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> 3f00: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> 3f20: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> 3f40: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> 3f60: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> 3f80: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> 3fa0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> 3fc0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> 3fe0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> Call trace: >> load_elf_fdpic_binary from bprm_execve+0x1b4/0x488 >> bprm_execve from kernel_execve+0x154/0x1e4 >> kernel_execve from kernel_init+0x4c/0x108 >> kernel_init from ret_from_fork+0x14/0x38 >> Exception stack(0x00823fb0 to 0x00823ff8) >> 3fa0: ???????? ???????? ???????? ???????? >> 3fc0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ???????? >> 3fe0: ???????? ???????? ???????? ???????? ???????? ???????? >> Code: bad PC value >> ---[ end trace 0000000000000000 ]--- >> note: init[1] exited with irqs disabled >> Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b >> ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]--- >> >> >> The code around that PC is: >> >> 109cd0: e2833ff1 add r3, r3, #964 @ 0x3c4 >> 109cd4: e5933000 ldr r3, [r3] >> 109cd8: e5933328 ldr r3, [r3, #808] @ 0x328 >> 109cdc: e5933084 ldr r3, [r3, #132] @ 0x84 >> 109ce0: e5843034 str r3, [r4, #52] @ 0x34 >> 109ce4: eafffdbc b 1093dc >> 109ce8: e7f001f2 .word 0xe7f001f2 >> 109cec: eb09471d bl 35b968 <__stack_chk_fail> >> 109cf0: e59f0038 ldr r0, [pc, #56] @ 109d30 >> 109cf4: eb092f03 bl 355908 <_printk> >> 109cf8: eafffdb7 b 1093dc >> >> >> Reverting just this change gets it working again. >> >> Any idea what might be going on? > > Other than that the layout of the aux vector has slightly changed I don't > see anything. I can take a look at what's going on if you can share the > reproducer. I build the test binary using a simple script: https://github.com/gregungerer/simple-linux/blob/master/build-armnommu-linux-uclibc-fdpic.sh Run the resulting vmlinux and devicetree under qemu as per comments at top of that script. Note that that script has a revert of this change (at line 191), so you would need to take that out to reproduce the problem. This script will look for a couple of configs and a versatile patch: https://github.com/gregungerer/simple-linux/blob/master/configs/linux-6.10-armnommu-versatile.config https://github.com/gregungerer/simple-linux/blob/master/configs/uClibc-ng-1.0.49-armnommu-fdpic.config https://github.com/gregungerer/simple-linux/blob/master/configs/busybox-1.36.1.config https://github.com/gregungerer/simple-linux/blob/master/configs/rootfs.dev https://github.com/gregungerer/simple-linux/blob/master/patches/linux-6.10-armnommu-versatile.patch https://github.com/gregungerer/simple-linux/blob/master/patches/linux-6.10-binfmt_elf_fdpic-fix-proc-pid-auxv.patch Or you could just clone the whole small set in one step from: https://github.com/gregungerer/simple-linux.git If you need to me to run something I can do that easily too. Regards Greg