From patchwork Tue Jun 20 18:41:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Simmons-Talbott X-Patchwork-Id: 1797535 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=sly+TLjw; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QlwV509tqz20Wk for ; Wed, 21 Jun 2023 04:42:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C41103857C43 for ; Tue, 20 Jun 2023 18:42:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C41103857C43 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1687286538; bh=vGM1oIxrObQwduPk6pZ9WHa24iHAosBC+yt6XcIaodo=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=sly+TLjwXCNX4yp0bhw9yUSefnMWR9ec+xBMrZBzKmCAGCt05HggSy448tE7yq39R m4Av5bxQ5NZJtWzpqGClZJb5R30VWoGBJG7uGB57eBuRrHXLr9a7TQa87xMFelmcqD iB/F4697a7x/d4aNDDAsN1x2w+ylo/JwCINx3b7c= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 9CF113858D1E for ; Tue, 20 Jun 2023 18:42:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9CF113858D1E Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-637-IGE6uSBHM_aIRAk3rtdFzg-1; Tue, 20 Jun 2023 14:41:59 -0400 X-MC-Unique: IGE6uSBHM_aIRAk3rtdFzg-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-763a3f66290so229559485a.0 for ; Tue, 20 Jun 2023 11:41:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687286518; x=1689878518; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vGM1oIxrObQwduPk6pZ9WHa24iHAosBC+yt6XcIaodo=; b=a30bIasGmvcPn5EcDSmdlA3K+3k0cFDgsuOT7J3O9AhhKY9FMwZO2Z5VdpqxM6kQU+ TgrSU5Guqi2/5kZGt8GAIittTtH7Tt7EPMvr1KBRkQaE/TwlMLa7s9RMdFmWbbW1gOWo CJH1Bw5Lkfdqo3LoCymGsXAfOlYZM1aQcQC1KptXH3EMWe5o5OaJY0FKctwxMUfHf+f5 CX67tFnPOqBR2XmWXPnDWNui0g1r5/6/QlARQq0K4XVBl0VOUW0MCPEKtJe48jqwZ2T8 ygjGZCR+cZ4YlhKy7pW7H63rjv4fTFLwq/QG+EqjI0cHp9zmh6D4TSJB00QfDSPz6fdM lLJw== X-Gm-Message-State: AC+VfDx7Uwf/QVsAHM5zcejZNycACrXlCmJefV5c28Df8BbRN6FE1NOQ KII+8j7Nd1blKQZMo+f0beMtG35iVdltRDORm8J4P96/joAhjM5Pxm7COoQQGoETbL5+/hQx4ek SyPVlLEEPJdmcnCz3C992pcTrom8cQn4sZ1JsqNvMXjFxcKTCmTuMpWXM/eby8Vbsut+/plGoG+ /KryaP X-Received: by 2002:a05:620a:2792:b0:763:9cf8:8707 with SMTP id g18-20020a05620a279200b007639cf88707mr5488932qkp.8.1687286517854; Tue, 20 Jun 2023 11:41:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6kUpEr7tM/2Uv1lszQctIRUQBDws+YI6Od9zR9LW/u3PineR7Uvsp3QF8BMKNKoYE60EKuEQ== X-Received: by 2002:a05:620a:2792:b0:763:9cf8:8707 with SMTP id g18-20020a05620a279200b007639cf88707mr5488920qkp.8.1687286517528; Tue, 20 Jun 2023 11:41:57 -0700 (PDT) Received: from oak.redhat.com (c-71-206-142-238.hsd1.va.comcast.net. [71.206.142.238]) by smtp.gmail.com with ESMTPSA id 25-20020a05620a06d900b0074e0e6aae1csm1413365qky.36.2023.06.20.11.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 11:41:57 -0700 (PDT) To: libc-alpha@sourceware.org Cc: Joe Simmons-Talbott Subject: [PATCH] libc_fatal: Add comment regarding alloca usage. Date: Tue, 20 Jun 2023 14:41:54 -0400 Message-Id: <20230620184154.3804141-1-josimmon@redhat.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 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_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Joe Simmons-Talbott via Libc-alpha From: Joe Simmons-Talbott Reply-To: Joe Simmons-Talbott Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Since __libc_message is only used in a few places and always with a const char * format string and a small fixed-sized struct the usage of alloca here is safe. Add a comment explaining this for both alloca usages. --- sysdeps/posix/libc_fatal.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sysdeps/posix/libc_fatal.c b/sysdeps/posix/libc_fatal.c index 70edcc10c1..caa01bcbf6 100644 --- a/sysdeps/posix/libc_fatal.c +++ b/sysdeps/posix/libc_fatal.c @@ -100,6 +100,9 @@ __libc_message (const char *fmt, ...) cp = next; } + /* alloca is safe here since the current usage of __libc_message uses + relatively short const char * format strings and a small fixed size + struct. */ struct str_list *newp = alloca (sizeof (struct str_list)); newp->str = str; newp->len = len; @@ -110,6 +113,9 @@ __libc_message (const char *fmt, ...) if (nlist > 0) { + /* alloca is safe here since the current usage of __libc_message uses + relatively short const char * format strings and a small fixed size + struct. */ struct iovec *iov = alloca (nlist * sizeof (struct iovec)); ssize_t total = 0;