From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from giraffe.ash.relay.mailchannels.net (giraffe.ash.relay.mailchannels.net [23.83.222.69]) by sourceware.org (Postfix) with ESMTPS id 0CF463858D28 for ; Fri, 11 Aug 2023 17:43:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0CF463858D28 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 61E9F761307; Fri, 11 Aug 2023 17:43:02 +0000 (UTC) Received: from pdx1-sub0-mail-a316.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id D6ED37610BB; Fri, 11 Aug 2023 17:43:01 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1691775782; a=rsa-sha256; cv=none; b=NbS85Xf6rUySciocPvaXr6i8FF+jsQw2YD0z1SFTx/NJ+Hk+J+FwMEOSUn5+Rfiw06xJFx lVPcZS5RbgX1uPMopiWSdeQup5l/MsUS584hb9mfvBFe/vs7rJADVjHoS1f0O1oRn/tUlI HkZSzXhrpFio9TNf5R1WlcjsfsDgrtNO2p7QkIWQPUlEiyqOe+To7ufzHZuiihBp8MNn04 +NTi20umrDMfOtosHl8PfV9EVdTfQmbpjxGW54SQ5SgbYOnnnxAhH+KcEN43b5gC9pbU30 RKbshbJSYdVFPajhdXJz4EWn4lBQUjcZTlgHCzlXeCKNzfNqVNp47C5YlVY0aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1691775782; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc: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=2Y8yfHYK4kENrkb8LlVp8ZFYQonvAUY/eIiaVCAGVNg=; b=yaxbjIF5E4irE0gWqfwoGl4Jt5YLPHGIocdnTOPUab36glgiJ6FehlqnjOleIdzzKR1n3V 8j2o5RvFepUvSShnG/4d8x0wfqhIfRilkOoHoBtBgVGg4xWDpc8zF/ptKrK3BNasq0+qYx yt1kx8GjqalfJme390qXcyeXWIYXrkbyOI66yxbyw/QVDut22bmyObhY7U8VvfFVEv9sWh Rzqh2sK/M+3lZgjQ9dibaGQFf7dDRXWqf39wScJjQmpP8pqjQH/aYOlloRP0POwQADXbFM LU7ZdUyX+j4Ces94VxtoZUXKfa5dha/U2PvCTfRKrWmH65Us6r7UJNCEbQTLMA== ARC-Authentication-Results: i=1; rspamd-749bd77c9c-4khnh; 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-Decisive-Tank: 75563798762c744d_1691775782226_1009066407 X-MC-Loop-Signature: 1691775782226:1211481287 X-MC-Ingress-Time: 1691775782225 Received: from pdx1-sub0-mail-a316.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.121.110.70 (trex/6.9.1); Fri, 11 Aug 2023 17:43:02 +0000 Received: from [192.168.224.119] (unknown [24.114.54.40]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a316.dreamhost.com (Postfix) with ESMTPSA id 4RMrjd2Y35z15; Fri, 11 Aug 2023 10:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1691775781; bh=2Y8yfHYK4kENrkb8LlVp8ZFYQonvAUY/eIiaVCAGVNg=; h=Date:Subject:To:Cc:From:Content-Type:Content-Transfer-Encoding; b=pdHaBYb1PauvXVeeZkETt+ss74HWTMg1cagNCjAABPBPX44Sp7vXXcE0SinxrBY7S G7a8zlxpLOV7rKAXViu1XEGDX/HuL+ttIALhObM1RL7cU9bypdIwH9fPHRMk32TLXp 1mf9hnWeR7ZPAmAuFWhEh5Oif8vtyMm/IjjA7xO5ATFlaFvXtEy7nAnR0+ME9iQ3rj p1Yj5tF+6OBaMRSwQAZ7xsQc8lTCef07H0lfK0oORH/1LlIYzzhcMUvGJWgWzn1u9k leT1eNBNyxpbaPurq6oOw9ij+Pdsh0JYWWTu+v9k9H1r7EL/3KCWbUmZAfpOjOskXY XZHXaZ1yTFFIg== Message-ID: <1e351e84-aaa9-cd38-fc7b-ab6ebc7d1f4f@gotplt.org> Date: Fri, 11 Aug 2023 13:42:59 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH v2] group_member: Get rid of unbounded alloca. Content-Language: en-US To: Florian Weimer , Joe Simmons-Talbott via Libc-alpha Cc: Joe Simmons-Talbott References: <20230808182843.678120-1-josimmon@redhat.com> <87cyzw1rgp.fsf@oldenburg.str.redhat.com> From: Siddhesh Poyarekar In-Reply-To: <87cyzw1rgp.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3030.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-08-09 05:43, Florian Weimer via Libc-alpha wrote: > * Joe Simmons-Talbott via Libc-alpha: > >> int >> __group_member (gid_t gid) >> { >> + int n; >> gid_t *groups; >> + struct scratch_buffer buf; >> + scratch_buffer_init (&buf); >> + >> + n = __getgroups (0, NULL); >> + if (!scratch_buffer_set_array_size (&buf, n, sizeof (*groups))) >> + abort (); >> + groups = buf.data; >> >> + n = __getgroups (n, groups); >> >> while (n-- > 0) >> if (groups[n] == gid) >> + { >> + scratch_buffer_free (&buf); >> + return 1; >> + } >> >> + scratch_buffer_free (&buf); >> return 0; >> } > > The abort isn't ideal. Should we deprecate this function because it > cannot be implemented correctly? It depends on how commonly used it is. It's a GNU extension, so we could just make a group_member2 that returns -1 for error (setting errno to indicate the reason for failure) and *then* deprecate this one, while also adding the abort() in there to guard against an unintentional overflow with tiny stacks. What do you think? Sid