From nobody Sat Oct 22 01:32:22 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MvP2x02Xbz4gHCH for ; Sat, 22 Oct 2022 01:32:25 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MvP2w6f52z3qcK for ; Sat, 22 Oct 2022 01:32:24 +0000 (UTC) (envelope-from jrtc27@jrtc27.com) Received: by mail-wr1-f49.google.com with SMTP id bk15so7418670wrb.13 for ; Fri, 21 Oct 2022 18:32:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4AUmeCeY772S7lG51lAoOjP1I9gF5quz4knKGj9j8HI=; b=YwwW2jCBy1s7g/eFIA8Pj/urBJQ3NeoNBdeq1q7Z2NdKbO7aVe3iUBXcbhzsjnLYrl LWkc3fzv/MvzYjMx6cS5NH6nmU+YX3dTL1m0Whk90c871MCIfAiVJ6GTGDZIkKDm+HsI 7tNZ7nAwMIFCku3RsESWjyBS+aSgnA9BjWzJiTvyDBYnZ9chBef7vFpgvvhOrem9G9na V7tpmsZh0dDFQNhmLKRR81k5wOipAgWMeu2huXH7+rtdY73lGD5jN8TJnMNtuoo0qCgq 71kp0HN4SWiPXrIpfux/ijDbueDRljpvW99+0l84EeJat33lzXstTH8BBu0Ct0D9F3JH c+1w== X-Gm-Message-State: ACrzQf0j5peRjTtcCw1ObloONzkWzFPVkYq6Jj0Te9i658gzoa6iWZW4 37tuefIuGnuK+E7JSNdjKRn7VQ== X-Google-Smtp-Source: AMsMyM6co3wPPUHSFUWiMyDMo1ZR/r4Luou3p9HFg07CHgoMj9hDx/5KEmyPytNmBeTp9oko7QJ+Tw== X-Received: by 2002:a5d:5a11:0:b0:22e:3ed1:e426 with SMTP id bq17-20020a5d5a11000000b0022e3ed1e426mr13895890wrb.642.1666402343635; Fri, 21 Oct 2022 18:32:23 -0700 (PDT) Received: from smtpclient.apple (global-5-143.n-2.net.cam.ac.uk. [131.111.5.143]) by smtp.gmail.com with ESMTPSA id x6-20020a5d54c6000000b0022e2c38f8basm20013781wrv.14.2022.10.21.18.32.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Oct 2022 18:32:22 -0700 (PDT) Content-Type: text/plain; charset=utf-8 List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.80.82.1.1\)) Subject: Re: git: 9cabef3d146e - main - ldd: use direct exec mode unconditionally From: Jessica Clarke In-Reply-To: Date: Sat, 22 Oct 2022 02:32:22 +0100 Cc: Kristof Provost , src-committers , dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <9248FC86-7ACB-4099-978B-4A58CE68743D@freebsd.org> References: <202210061550.296FoVrm088661@gitrepo.freebsd.org> <7F982005-246F-4607-A17B-08C81CE65E0B@FreeBSD.org> <6AEBEA3C-24DD-44AA-8B59-8DCADF62CAFF@FreeBSD.org> To: Konstantin Belousov X-Mailer: Apple Mail (2.3696.80.82.1.1) X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Rspamd-Queue-Id: 4MvP2w6f52z3qcK X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On 22 Oct 2022, at 02:13, Konstantin Belousov = wrote: >=20 > On Fri, Oct 21, 2022 at 03:10:59PM +0200, Kristof Provost wrote: >> On 21 Oct 2022, at 15:07, Konstantin Belousov wrote: >>> On Fri, Oct 21, 2022 at 02:54:59PM +0200, Kristof Provost wrote: >>>> On 21 Oct 2022, at 14:50, Konstantin Belousov wrote: >>>>> On Fri, Oct 21, 2022 at 02:18:04PM +0200, Kristof Provost wrote: >>>>>> On 6 Oct 2022, at 17:50, Konstantin Belousov wrote: >>>>>>> The branch main has been updated by kib: >>>>>>>=20 >>>>>>> URL: = https://cgit.FreeBSD.org/src/commit/?id=3D9cabef3d146e9a844813b6bc8952d6cf= 2e9d45e5 >>>>>>>=20 >>>>>>> commit 9cabef3d146e9a844813b6bc8952d6cf2e9d45e5 >>>>>>> Author: Konstantin Belousov >>>>>>> AuthorDate: 2022-09-21 13:55:44 +0000 >>>>>>> Commit: Konstantin Belousov >>>>>>> CommitDate: 2022-10-06 15:50:26 +0000 >>>>>>>=20 >>>>>>> ldd: use direct exec mode unconditionally >>>>>>>=20 >>>>>>> Trying to exec malformed or unusual binary, for instance, a >>>>>>> non-FreeBSD >>>>>>> ABI, or using a non-standard interpreter, might give >>>>>>> unexpected >>>>>>> outcome. >>>>>>>=20 >>>>>>> Reported by: The UK's National Cyber Security Centre (NCSC) >>>>>>> Reviewed by: emaste, markj, philip >>>>>>> Discussed with: jhb >>>>>>> Sponsored by: The FreeBSD Foundation >>>>>>> admbug: 991 >>>>>>> PR: 127276, 175339, 231926 >>>>>>> MFC after: 1 week >>>>>>> Differential revision: https://reviews.freebsd.org/D36650 >>>>>>>=20 >>>>>> This appears to break things for armv7 (running on aarch64). >>>>>>=20 >>>>>> This manifests while building pfsense (for 3100 / armv7), which = we >>>>>> do on an >>>>>> aarch64 vm (to avoid having to deal with qemu, and because it=E2=80= =99s >>>>>> faster). >>>>>>=20 >>>>>> During that build a couple ports fail to build, including >>>>>> databases/sqlite3. >>>>>> It fails running `/usr/bin/ldd -a = "/wrkdirs/usr/ports/databases/sqlite3/work-default/stage/usr/local/bin/sql= ite3" = "/wrkdirs/usr/ports/databases/sqlite3/work-default/stage/usr/local/lib/lib= sqlite3.so=E2=80=9D`, >>>>>> which produces: >>>>>>=20 >>>>>> ld-elf.so.1: = /wrkdirs/usr/ports/databases/sqlite3/work-default/stage/usr/local/bin/sqli= te3: >>>>>> mmap of entire address space failed: Cannot allocate memory >>>>>> = /wrkdirs/usr/ports/databases/sqlite3/work-default/stage/usr/local/bin/sqli= te3: >>>>>> exit status 1 >>>>>>=20 >>>>>> That fails doing the `mapbase =3D mmap(base_addr, mapsize, = PROT_NONE, >>>>>> base_flags, -1, 0);` call in rtld-elf=E2=80=99s map_object():217. >>>>>> That call >>>>>> does >>>>>> `mmap(0x10000, 0x1dc000, PROT_NONE, 0x6010, -1, 0) =3D> = 0xffffffff`. >>>>>>=20 >>>>>> With this patch reverted we can build successfully. >>>>>=20 >>>>> Can you manually invoke ldd on the binary under ktrace -i, and >>>>> show me >>>>> the >>>>> kdump output? >>>>>=20 >>>> I might be doing something wrong: >>>>=20 >>>> # ktrace -i /usr/obj/usr/src/arm.armv7/usr.bin/ldd/ldd -a = "/wrkdirs/usr/ports/databases/sqlite3/work-default/stage/usr/local/bin/sql= ite3" >>>> ld-elf.so.1: = /wrkdirs/usr/ports/databases/sqlite3/work-default/stage/usr/local/bin/sqli= te3: >>>> mmap of entire address space failed: Cannot allocate memory >>>> = /wrkdirs/usr/ports/databases/sqlite3/work-default/stage/usr/local/bin/sqli= te3: >>>> exit status 1 >>>> # kdump -f ktrace.out >>>> 16 @ UNKNOWN(265) >>>> kdump: data too short >>>> # >>>>=20 >>>> Perhaps because this is running in a jail? >>> You need to run host-native kdump, because your kernel is arm64, I >>> guess. >>>=20 >> That seemed to do the trick: >=20 > Please try something along this lines: >=20 > diff --git a/sys/arm64/include/elf.h b/sys/arm64/include/elf.h > index 3f7c3964d428..22e968c632bf 100644 > --- a/sys/arm64/include/elf.h > +++ b/sys/arm64/include/elf.h > @@ -86,7 +86,7 @@ __ElfType(Auxinfo); > #endif >=20 > #if __ELF_WORD_SIZE =3D=3D 32 > -#define ET_DYN_LOAD_ADDR 0x12000 > +#define ET_DYN_LOAD_ADDR 0x01001000 > #else > #define ET_DYN_LOAD_ADDR 0x100000 > #endif Ouch... sys/arm=E2=80=99s is better at 0x500000 but that=E2=80=99s still = only ~4.9 MiB above LLD=E2=80=99s default image base of 0x10000 so I could see that = being hit a bunch. Then again 0x01001000 only gives ~15.9 MiB, which isn=E2=80=99t = great, but other architectures seem bad too... Jess