From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTPS id 5D5213858010 for ; Fri, 5 Nov 2021 14:07:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5D5213858010 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-443-5_u31wDpPBuK2FG_pQmy_Q-1; Fri, 05 Nov 2021 10:07:43 -0400 X-MC-Unique: 5_u31wDpPBuK2FG_pQmy_Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0DFB779EE8; Fri, 5 Nov 2021 14:07:42 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2F2A9100239F; Fri, 5 Nov 2021 14:07:41 +0000 (UTC) From: Florian Weimer To: "H.J. Lu" Cc: GNU C Library Subject: Re: [PATCH 2/2] elf: Detect PT_LOAD segments that extend beyond EOF and refuse loading References: <27f078539ae2a5b390705ac6fa1a7437ae8ce97c.1636120354.git.fweimer@redhat.com> Date: Fri, 05 Nov 2021 15:07:39 +0100 In-Reply-To: (H. J. Lu's message of "Fri, 5 Nov 2021 07:04:48 -0700") Message-ID: <871r3uvgpg.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2021 14:07:47 -0000 * H. J. Lu: >> diff --git a/sysdeps/generic/dl-fileid.h b/sysdeps/generic/dl-fileid.h >> index bf437f3d71..c59627429c 100644 >> --- a/sysdeps/generic/dl-fileid.h >> +++ b/sysdeps/generic/dl-fileid.h >> @@ -27,10 +27,10 @@ struct r_file_id >> ino64_t ino; >> }; >> >> -/* Sample FD to fill in *ID. Returns true on success. >> - On error, returns false, with errno set. */ >> +/* Sample FD to fill in *ID, *SIZE. Returns true on success. On >> + error, returns false, with errno set. */ >> static inline bool >> -_dl_get_file_id (int fd, struct r_file_id *id) >> +_dl_get_file_id (int fd, struct r_file_id *id, off64_t *size) >> { >> struct __stat64_t64 st; >> >> @@ -39,6 +39,7 @@ _dl_get_file_id (int fd, struct r_file_id *id) >> >> id->dev = st.st_dev; >> id->ino = st.st_ino; >> + *size = st.st_size; > > Why not add a size field to struct r_file_id? struct r_file_d is stored in the link map, but we don't need the size information there. Thanks, Florian