From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from slategray.cherry.relay.mailchannels.net (slategray.cherry.relay.mailchannels.net [23.83.223.169]) by sourceware.org (Postfix) with ESMTPS id DEF503858D20 for ; Tue, 3 Oct 2023 16:47:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DEF503858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id CB9D0761E03; Tue, 3 Oct 2023 16:47:17 +0000 (UTC) Received: from pdx1-sub0-mail-a208.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 10FF6760B8E; Tue, 3 Oct 2023 16:47:17 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1696351637; a=rsa-sha256; cv=none; b=Uwgt+bPkjZejcwDn5mfH+7fQGSmbhDKyYoili9H6+7ONw+QyYmO7XtDszuDjhw8/LMVmuP cgzBRU76sy1kKAeFNXKpyL759/SYCzyai0CxqdPAwYQczO0hof3TSAD7subxWkuOw9QnUz P4jVh6vVOjNywXEM8bGOfrLMdDx+xWmy+PbHGWJksufsGrUfVG7fiRe+7ahl0OL9KarN0c ge9dAH1ATeoV5o9LtxvXdiJ1RoefBAek6kpifyy3c7q070tWcdbsCA0dz8ytOswEixQUOv RNjQTPIwfpVjcXh+FY6CsEj+axYR0eqSnhNDbBkVVGsohEAviup2kRVDs49KAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1696351637; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fkiKUsh0TACmgtK/Bjo/FILoI4Zrpux0Fb6zYroTcUg=; b=Z6ov3P4eKCDP2XP9w45OIzPVEduBHHS2Q9avyc8rWLau/igLO0Eu/H3LktHFmif+shruSr KQMxLl3PesBjasg3LyQf2qDAs+p2VC+8uEAuNJLGx6i7rRmmKlLl8Xv6i7NVrQURf1MIx0 BfKO98kLgwEgPlX1iA8BWXoLKKFEIKgLZRDh3E7JeA/IKeM9YcZyFr2rccUp5I6z6ljGew +tMVsTb7sl84odnbiV3VuJ/HYSol1Sd45zxds2WKzsRpXyQKPzlCfBOFR89NGOeUF6AU/R aigCsQ/bmxhhqz0djxGinx+U5SRiBoWB34w+fzto15VYg5mf9ZtalkiOuWuaFg== ARC-Authentication-Results: i=1; rspamd-7c449d4847-82qq2; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Name-Interest: 32656d8e02abc491_1696351637623_1735978827 X-MC-Loop-Signature: 1696351637623:1214117932 X-MC-Ingress-Time: 1696351637623 Received: from pdx1-sub0-mail-a208.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.104.112.136 (trex/6.9.1); Tue, 03 Oct 2023 16:47:17 +0000 Received: from [192.168.2.12] (bras-vprn-toroon4834w-lp130-02-142-113-138-41.dsl.bell.ca [142.113.138.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a208.dreamhost.com (Postfix) with ESMTPSA id 4S0Nyr53CRz6b; Tue, 3 Oct 2023 09:47:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1696351636; bh=fkiKUsh0TACmgtK/Bjo/FILoI4Zrpux0Fb6zYroTcUg=; h=Date:To:From:Subject:Content-Type:Content-Transfer-Encoding; b=aMHx30BcaqytnxzMFwtMk+WpfJbMdEnHJYRWVDpvkCvDWW9V0nCFbUwLLkouN3j1b ONbWHwisd86Y3SJOfLQoD4oc0gIpzwtqakhqzI1JanD0KniFeecSyqGTxrawvAHQMH jWi+lhBnlncD+n6LDJ7k6jSyCqnaTfW5Zo5jjqfgXpu3z1YVCcu1j9YSqkISRrfqX1 k361g1bRz2p5ntXMgD4jUt1lx+Ck80Fnm4iajXpDQv6cVevfxeW4xQbAiz9lXkcG6q JWvJKHmIQdsFhrqWkApmfb1Fc+o4lnHFKBYYzkxcY0WmG6caMa3IviLWjXd98OBP8m OBTrDS0S3ZYsQ== Message-ID: Date: Tue, 3 Oct 2023 12:47:15 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US To: =?UTF-8?Q?Volker_Wei=c3=9fmann?= , libc-alpha@sourceware.org References: <20231002155339.2571514-1-volker.weissmann@gmx.de> <74305391-aad9-de52-9ad7-07df57e727f6@gotplt.org> <7b06c348-0e48-45be-9d72-124c53c7960f@gmx.de> From: Siddhesh Poyarekar Subject: Re: [PATCH] Fix FORTIFY_SOURCE false positive In-Reply-To: <7b06c348-0e48-45be-9d72-124c53c7960f@gmx.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3035.5 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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 2023-10-03 09:22, Volker Weißmann wrote: > > On 02.10.23 20:00, Siddhesh Poyarekar wrote: >> >> Also, if you don't have a copyright assignment on file with the FSF, >> could you add a Signed-off-by to certify your contribution? > > This is my first patch I sent to a mailing list, so forgive me if the > formatting is wrong: No worries, please review the Contribution checklist[1], which goes into much detail about submitting a patch to glibc. One issue is, if you reply to a patch with a patch like you've done now, patchwork[2] does not pick it up; it is what we use to manage patches. Please fix the below review comments and send a v3. Basically in your git repo, commit your patch with the subject and body of this email as the git commit log (with the Signed-off-by) and then generate a patch like so: git format-patch --subject-prefix="PATCH v3" -1 and then send that patch to the list using "git send-email". > > > When -D_FORTIFY_SOURCE=2 was given during compilation, > > sprintf and similar functions will check if their > first argument is in read-only memory and exit with > *** %n in writable segment detected *** > otherwise. To check if the memory is read-only, glibc > reads form the file "/proc/self/maps". If opening this > file fails due to too many open files (EMFILE), glibc > will now ignore this error. > > Signed-off-by: Volker Weißmann > --- >  sysdeps/unix/sysv/linux/readonly-area.c | 10 +++++++++- >  1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/sysdeps/unix/sysv/linux/readonly-area.c > b/sysdeps/unix/sysv/linux/readonly-area.c > index edc68873f6..629163461a 100644 > --- a/sysdeps/unix/sysv/linux/readonly-area.c > +++ b/sysdeps/unix/sysv/linux/readonly-area.c > @@ -42,7 +42,15 @@ __readonly_area (const char *ptr, size_t size) >           to the /proc filesystem if it is set[ug]id.  There has >           been no willingness to change this in the kernel so >           far.  */ > -      || errno == EACCES) > +      || errno == EACCES > +          /* Example code to trigger EMFILE: > +          while(1) { > +            FILE *file = fopen("/dev/zero", "r"); > +            assert(file != NULL); > +          } > +          If your libc was compiled with -D_FORTIFY_SOURCE=2, we run > +          into this if clause here. */ Please replace this code in the comment with a descriptive line as Adhemerval suggested, something like "Process has reached the maximum number of open files." > +          || errno == EMFILE) >      return 1; >        return -1; >      } > -- > 2.42.0 >> >> Thanks, >> Sid > Thanks, Sid [1] https://sourceware.org/glibc/wiki/Contribution%20checklist [2] https://patchwork.sourceware.org/project/glibc/list/