NetBSD Problem Report #59388

From www@netbsd.org  Fri May  2 22:52:56 2025
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B9C191A9239
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  2 May 2025 22:52:55 +0000 (UTC)
Message-Id: <20250502225254.57CCB1A923C@mollari.NetBSD.org>
Date: Fri,  2 May 2025 22:52:54 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: ld.elf_so: -Wno-stack-protector applies too broadly
X-Send-Pr-Version: www-1.0

>Number:         59388
>Category:       lib
>Synopsis:       ld.elf_so: -Wno-stack-protector applies too broadly
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          needs-pullups
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri May 02 22:55:00 +0000 2025
>Closed-Date:    
>Last-Modified:  Fri May 02 23:07:32 +0000 2025
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The Rtalloca'd Stack Protector
>Environment:
>Description:
We currently build all of rtld.c and symbol.c with -Wno-stack-protector because _rtld_donelist_init uses alloca, intentionally (with a size limited by the number of objects currently loaded in the process; this was done as part of the work to make ld.elf_so thread-safe, PR lib/43005: ld.so needs locking).

But only a few functions actually use _rtld_donelist_init.  Those functions can be surrounded with the appropriate GCC diagnostic pragma, and the rest need not have the warning suppressed.
>How-To-Repeat:
code inspection
>Fix:
+_Pragma("GCC diagnostic push")	/* _rtld_donelist_init: -Wno-stack-protector */
+_Pragma("GCC diagnostic ignored \"-Wstack-protector\"")static void *
 do_dlsym(void *handle, const char *name, const Ver_Entry *ventry, void *retaddr)
 {
...
 }
+_Pragma("GCC diagnostic pop")

>Release-Note:

>Audit-Trail:
From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/59388 CVS commit: src/libexec/ld.elf_so
Date: Fri, 2 May 2025 23:04:31 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Fri May  2 23:04:31 UTC 2025

 Modified Files:
 	src/libexec/ld.elf_so: Makefile rtld.c rtld.h symbol.c

 Log Message:
 ld.elf_so: Narrow scope of -Wno-stack-protector.

 Don't need it outside immediate _rtld_donelist_init callers.

 PR lib/59388: ld.elf_so: -Wno-stack-protector applies too broadly


 To generate a diff of this commit:
 cvs rdiff -u -r1.149 -r1.150 src/libexec/ld.elf_so/Makefile \
     src/libexec/ld.elf_so/rtld.h
 cvs rdiff -u -r1.220 -r1.221 src/libexec/ld.elf_so/rtld.c
 cvs rdiff -u -r1.76 -r1.77 src/libexec/ld.elf_so/symbol.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->needs-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Fri, 02 May 2025 23:07:32 +0000
State-Changed-Why:
fixed in HEAD, needs pullup-9 and pullup-10 (if worthwhile, just for
better warnings)


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.