From patchwork Tue Mar 26 03:20:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan O'Rear X-Patchwork-Id: 13603376 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 09926CD11DF for ; Tue, 26 Mar 2024 03:21:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 679CD6B0082; Mon, 25 Mar 2024 23:21:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 602466B0085; Mon, 25 Mar 2024 23:21:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 454C86B0087; Mon, 25 Mar 2024 23:21:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2F8B06B0082 for ; Mon, 25 Mar 2024 23:21:05 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id A3F081403D3 for ; Tue, 26 Mar 2024 03:21:04 +0000 (UTC) X-FDA: 81937738848.17.24BA224 Received: from fhigh8-smtp.messagingengine.com (fhigh8-smtp.messagingengine.com [103.168.172.159]) by imf16.hostedemail.com (Postfix) with ESMTP id 93D8818000E for ; Tue, 26 Mar 2024 03:21:02 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=fastmail.com header.s=fm2 header.b="Q/Yd8VHt"; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=ON1c2YIq; spf=pass (imf16.hostedemail.com: domain of sorear@fastmail.com designates 103.168.172.159 as permitted sender) smtp.mailfrom=sorear@fastmail.com; dmarc=pass (policy=none) header.from=fastmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711423262; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=1hRyPax4QBs5FbRonwEHFPXlx7oziPZG9Z5t18jQQI4=; b=ONFPXl/c1UKOFhxUyZ3nHK2MXMuaulmmnx0nVwm6PGWFJZaAzWTyYQHPvBeTsQlkRjf/Kh IZsG2p31z999Y/ekRiilLLWWNoYeXQwR8WueYXw0pnSKo/Ah/0fdwvR9e4i4+TFey0SLFU Nl7SH1TljF5bysgwmzIZFPC7lGl4YSw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711423262; a=rsa-sha256; cv=none; b=59omD5BWKOEhRJN4UQ1rUefj8+VNSwt8XsfOwRkjptCHcDXp7QicOSWSqhIx1Pcy3oockv XmR9ME8ci37NCxV4UhacxnqZ9Lm3PgVkEihZ54UqdZiQkOHTDtlzv30Sjsn6d7FsPxrTRy byk4jhN/RIgpdUQPEjGnjcczbDKtnmg= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=fastmail.com header.s=fm2 header.b="Q/Yd8VHt"; dkim=pass header.d=messagingengine.com header.s=fm2 header.b=ON1c2YIq; spf=pass (imf16.hostedemail.com: domain of sorear@fastmail.com designates 103.168.172.159 as permitted sender) smtp.mailfrom=sorear@fastmail.com; dmarc=pass (policy=none) header.from=fastmail.com Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfhigh.nyi.internal (Postfix) with ESMTP id C3DC51140133; Mon, 25 Mar 2024 23:21:01 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 25 Mar 2024 23:21:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to; s=fm2; t=1711423261; x=1711509661; bh=1hRyPax4QBs5FbRonwEHF PXlx7oziPZG9Z5t18jQQI4=; b=Q/Yd8VHtq2w7trRU+PenSAEB8WDpXZnJbO1Qz XBxNN78ifZQ7x5TCWrGA6SGjGEc5arGrMThA4ZyqVWEqDAFoI4Khf1LwlZwiT3bv SFQMxpfku/OFMDxKxLaj0cUqYu0+HDo+Hv0du6luyB4q7rcIhx0ParitNa2dFlyJ Hqur5MWFOR97UUSkstYiFTEoFrVP/RMZijKo8HianWdx76xhq0EwsBU+kpZmzSTG YM0E0cmW5VCXXd+R+YOjBgg5meYZbFNPygSNfnMXxo5zYt4gpIw50mWA/1as3Vu4 llTrM1nV6vbUpc7qc1cbFJLVrM/BBt6b5Zj7y4VTqvyv8eVUw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1711423261; x=1711509661; bh=1hRyPax4QBs5FbRonwEHFPXlx7oz iPZG9Z5t18jQQI4=; b=ON1c2YIq7YCCjVvp6ulRYsagl1sKh4LYiABlIcSBx1wr bmaybp3i2/staaPJ204QjAnMIMMyr6wH2xUTv9mjUh0m0wF5zek9vb/IqEvJWzjp ToAZ8VQJVa1cnVt357Kig52uUy+mfTW2hF79yHSLBqI/I5Nd1eHDMe1atdVW9Tvh 9SFoVLg6z2xdfGh0XkdbIG+GjIUCBNYuZid8p/noWWwWY9fIKFurkkPIEVUVCC97 BupAnePXRe/NhLk5BQ3tAOWoDkrSOu7xs11bfHukDiDshHbAt9n+QxcLRnuRgRiq 5qbhmMrP7sAOj+59py3tPa/l1jiLRG21syv+TGx6kw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudduvddgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgggfestdekredtredttdenucfhrhhomhepufhtvghfrghn ucfqkdftvggrrhcuoehsohhrvggrrhesfhgrshhtmhgrihhlrdgtohhmqeenucggtffrrg htthgvrhhnpeeugfejveekgffhgfegvdetgfegvdekieffvefhiedugeefuedvieekieev heeuheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hsohhrvggrrhesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: i84414492:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 25 Mar 2024 23:21:00 -0400 (EDT) From: Stefan O'Rear To: linux-mm@kvack.org, linux-riscv@lists.infradead.org Cc: Eric Biederman , Kees Cook , Damien Le Moal , Greg Ungerer , Waldemar Brodkorb , Stefan O'Rear Subject: [PATCH] binfmt_flat: Fix corruption when not offsetting data start Date: Mon, 25 Mar 2024 23:20:37 -0400 Message-Id: <20240326032037.2478816-1-sorear@fastmail.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 93D8818000E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: i4ugsgb5ha5x1noyudyi1kptkx7wfzxm X-HE-Tag: 1711423262-310725 X-HE-Meta: U2FsdGVkX19eMXAt/n4geHxLGcT86/jQmLLAP+ngciWwiheFVEgaXgXZ5uwL/im4sXrlhcBcv0GrWMei8IDls7jV/xEf3ID/OcVGiBCxAgTXd2tt8kVISotqslicC9vBmefPqi9MRV3JvZLOMmMn5r14ExBKhre6wAIVkM85nso5sO4miFq0uFW8EbO6yuRunC94MTTBOz4/VDpkB0MrNb6z+xzYYZgeeLwBZDqSskvagtinvl3kqc85/5VB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Ihj5K6dB5u2ECLLLreJW2YTGa2FeDDPgWpcln0K/ngjz85snDI4sbW2J8LcSlV2F1MPwNUwyLwMkzLOsSs5Vv7C3SmEVcw= 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: Commit 04d82a6d0881 ("binfmt_flat: allow not offsetting data start") introduced a RISC-V specific variant of the FLAT format which does not allocate any space for the (obsolescent) array of shared library pointers. However, it did not disable the code which initializes the array, resulting in the corruption of sizeof(long) bytes before the DATA segment, generally the end of the TEXT segment. Use CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET to guard initialization the shared library pointer region so that it will only be initialized if space is reserved for it. Fixes: 04d82a6d0881 ("binfmt_flat: allow not offsetting data start") Signed-off-by: Stefan O'Rear Tested-by: Waldemar Brodkorb Reviewed-by: Damien Le Moal