From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 63F0D3858029; Fri, 2 Feb 2024 21:45:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63F0D3858029 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1706910307; bh=kj/uAXAM5cU4CcHJGngqfhFzKiy5EerExxGf6ivNBpc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Tb7MZUrrqs9YL/KtrzrN+60XuhF3ThkWJXwlnLFefG82WCCv4Jaw7xBKTOhTsAwM+ fpj/rpC5LfOn6/dflfyCHrVwhHkUEMiknAITfZzcubkBqE9hvoZ+A5oUU3ue1epDrT rHfmQwRnm7LmBTgGiaKjSzMqucV2BRGd87Km5cYU= From: "mark at klomp dot org" To: elfutils-devel@sourceware.org Subject: [Bug libelf/31225] Crash when using elf_memory() on a compressed section; fixed with s/ELF_C_READ/ELF_C_READ_MMAP/ Date: Fri, 02 Feb 2024 21:45:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: elfutils X-Bugzilla-Component: libelf X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mark at klomp dot org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: mark at klomp dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: resolution bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31225 Mark Wielaard changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|ASSIGNED |RESOLVED --- Comment #5 from Mark Wielaard --- commit cc44ac6740797a23cd0af0cb22bd828d569224b8 Author: Mark Wielaard Date: Thu Feb 1 14:56:18 2024 +0100 libelf: Treat elf_memory as if using ELF_C_READ_MMAP An Elf handle created through elf_memory was treated as if opened with ELF_C_READ. Which means libelf believed it had read the memory itself and could simply write to it if it wanted (because it wasn't mmaped directly on top of a file). This causes issues when that memory was actually read-only. Work around this by pretending the memory was actually read with ELF_C_READ_MMAP (so directly readable, but not writable). Add extra tests to elfgetzdata to check using elf_memory with read-only memory works as expected. * libelf/elf_memory.c (elf_memory): Call __libelf_read_mmaped_file with ELF_C_READ_MMAP. * tests/elfgetzdata.c (main): Add new "mem" option. * tests/run-elfgetzdata.sh: Also run all tests with new "mem" option. https://sourceware.org/bugzilla/show_bug.cgi?id=3D31225 Reported-by: Derek Bruening Signed-off-by: Mark Wielaard --=20 You are receiving this mail because: You are on the CC list for the bug.=