From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 06B0A3858C30 for ; Mon, 4 Sep 2023 14:27:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 06B0A3858C30 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 349E621850; Mon, 4 Sep 2023 14:27:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1693837630; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=11CYnX1DPTl4PPEzamw0+b22pGebEjInbThSYBOEw7E=; b=a/ct8DFlCZFdZFgqFQEinHJq8ANqKyG+wygU5Egxg05zbxrQXXTlyPnxY+1Nlb928hqFlV lQZc0Kmdu9g/H2k/bZK3M+UIifevScDAFgvlNXUlLhVGvLS9DpdjKDDmAa3HBlO3nG6G2y 3B6bmRZmZDl6nQ8G2jDvK1hKJY4/O/s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1693837630; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=11CYnX1DPTl4PPEzamw0+b22pGebEjInbThSYBOEw7E=; b=KU11Y+E3PHBo24R0bDhJN9HhJeMM0n77YkRe9w14DraISc8u+N0w2gZJs/4gZWZa11xDaM YkMiFqRF03VXRNAA== Received: from hawking.nue2.suse.org (unknown [10.168.4.11]) by relay2.suse.de (Postfix) with ESMTP id 2FA3C2C142; Mon, 4 Sep 2023 14:27:10 +0000 (UTC) Received: by hawking.nue2.suse.org (Postfix, from userid 17005) id 01C514A04C0; Mon, 4 Sep 2023 16:27:09 +0200 (CEST) From: Andreas Schwab To: Peter Edwards Cc: Peter Edwards via Libc-alpha Subject: Re: [PATCH] elf: Avoid pointer-arithmetic underflow in ldconfig In-Reply-To: (Peter Edwards's message of "Mon, 4 Sep 2023 13:32:12 +0100") References: <20230904105427.283848-1-peadar@arista.com> X-Yow: BARBARA STANWYCK makes me nervous!! Date: Mon, 04 Sep 2023 16:27:09 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sep 04 2023, Peter Edwards wrote: > On Mon, 4 Sept 2023 at 12:18, Andreas Schwab wrote: > >> >> > + loadoff = (uintptr_t)segment->p_vaddr - >> > + (uintptr_t)segment->p_offset; >> >> Shouldn't that use a signed difference, then? Since loadoff is now >> ptrdiff_t, I would expect the use of ptrdiff_t for the casts. >> > Hi, > For the 32-bit code, we were previously relying on the behaviour of > wrap-around on the unsigned type, this just extends that reliance to a > pointer-sized integer on the 64 bit platform. By using a wider (unsigned) type you are changing the wrap-around semantics. Wrap-around only works as expected when the type matches the value domain. > I guess intptr_t might be a better option than uintptr_t? I think a wide enough signed type would be better, since the result is supposed to be signed. -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."