From patchwork Thu Feb 8 18:46:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 1896723 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=PfWzn+ca; dkim-atps=neutral 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=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.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 (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TW5db1Zcjz23hb for ; Fri, 9 Feb 2024 05:50:11 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 30ACF3858439 for ; Thu, 8 Feb 2024 18:50:09 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oo1-xc2d.google.com (mail-oo1-xc2d.google.com [IPv6:2607:f8b0:4864:20::c2d]) by sourceware.org (Postfix) with ESMTPS id 59F87385841C for ; Thu, 8 Feb 2024 18:46:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 59F87385841C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 59F87385841C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::c2d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707418004; cv=none; b=YO8JloHnDPMl6DWca1/suCH93SN6Zsq1U+KEEZJQe7iqo72d6VRinNaBMszSbLEDUZbR6bhWPgiID9jnFKKwQAL/80H8yne7bZMTQlj9cxqRUUtV5QYa3U5+qWp/lOZeWGBV+Kh3pUiFBepMEhspn3wZeC/rukSAR/c60Mabs2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707418004; c=relaxed/simple; bh=lC3V/8/rcbKOdkq/r5wbAWpNDMHlYBNvhSHufWlznVM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=IEyt2SZBepLm5+57LbUuJAmyCoIvw2oNKhPr87ahFARuSGYAlIVWPZWH3Zcnc+Nx8Ek7j8A9TKO1KLFbAAjoKNE/3eJKcU7rb9+Bup7DmPpqQHky3xGTfTeKgxHphtQLAhtGufsXsXbZZUtlEv5DotzySxw4pHI0kAwX7TVMPpg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-59cf4872e1dso73311eaf.1 for ; Thu, 08 Feb 2024 10:46:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1707418001; x=1708022801; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ahnZUabbQXonvA8kJlBsyIjxa26cMYVFWEsdlWx7+nE=; b=PfWzn+ca4Ac1TYrsvZjxOvTz7viDixgUcCmXLJK3ORar/A3JivRwC7EOlrm6ASHU9N 6IVe3OwyL8qEtQnBu8DNCzb0OgDhv2jrpNlvf9tZYvKzJPgUhliq2rHp3qgKtxHpy2zr WgINROUX6Mj88PT4xTtn6zGQB5/zTjGMHItlfDp4fovLF01G7d2vbNeYZBBxLjjMI9bh G8J/ZmjZ0oeOtg7+iqQvzPCOD/EDhZkeOy1AJTZNtjaVijZASxfTt0YhuKKnwFpq+GPW bhDbMr4HjzDXZuq7zfQ7naZTGZDT0gsk/Pso/eDW0y3VwKFRUkn6hDAhEToXTy2fpwoJ e9Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707418001; x=1708022801; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ahnZUabbQXonvA8kJlBsyIjxa26cMYVFWEsdlWx7+nE=; b=ch5XojoNhndcQcXYyt1WMzpUQLkHyT/TfGVKJMGzMp2IAVwiZWtiWdKU7LzBrvuqRT hn93iHMJZF5iC84MyHR8LEvd+RSY884fikuPjsaLh/bU7zVrUIDmrUgRQh7c7UMLn2O/ TYqN5BAjOucNce4Z56UL1At5IzI3pZlosce3t9JhOF0c/U6pzcmibM6muvpTiwPXKCFY e4xF5hh9UFMApVus66WDOLqtsAyabZH7j9krNhs28DNdA/jwB4qfPAFvxi9m6tCWE6x9 hrPo/ia8c4HyLQFXHIpJ56hjxwLZNPus6zRDIwLcdvW1GLKUYJ0KMxuvKc8+3LGlKqM3 O9pg== X-Gm-Message-State: AOJu0Yx9SlcLukrdYkuQDXgW+Lxcsyn2MeF5zBMAaiFzW5a6NBlk3Us1 BO4Ltu92nemrj4MSQiOY5+8UvMJlyRKJRNZdeyCWPzhGM0D4G/CGPJBfGyFSg0vBEH4Ui9k6iN/ g X-Google-Smtp-Source: AGHT+IHG5+wQqmFRsymu2KOApadwhyO7jNxYJg0XydIAP3F+dMfVwElYF6Vofg7Q+gLwFe4qrekMpQ== X-Received: by 2002:a05:6359:459f:b0:175:d6b7:b5a9 with SMTP id no31-20020a056359459f00b00175d6b7b5a9mr7231223rwb.23.1707418000894; Thu, 08 Feb 2024 10:46:40 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:378:6793:1dc3:1346:d6d6]) by smtp.gmail.com with ESMTPSA id n26-20020a638f1a000000b005d7994a08dcsm156408pgd.36.2024.02.08.10.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 10:46:40 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Siddhesh Poyarekar Subject: [PATCH v3 07/10] syslog: Improve fortify with clang Date: Thu, 8 Feb 2024 15:46:19 -0300 Message-Id: <20240208184622.332678-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240208184622.332678-1-adhemerval.zanella@linaro.org> References: <20240208184622.332678-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org It improve fortify checks for syslog and vsyslog. The compile and runtime hecks have similar coverage as with GCC. The syslog fortify wrapper calls the va_arg version, since clang does not support __va_arg_pack. Checked on aarch64, armhf, x86_64, and i686. Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell --- misc/bits/syslog.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/misc/bits/syslog.h b/misc/bits/syslog.h index aadcd42000..100b0c78cc 100644 --- a/misc/bits/syslog.h +++ b/misc/bits/syslog.h @@ -36,6 +36,15 @@ syslog (int __pri, const char *__fmt, ...) { __syslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ()); } +#elif __fortify_use_clang && defined __USE_MISC +__fortify_function_error_function __attribute_overloadable__ void +syslog (int __pri, __fortify_clang_overload_arg (const char *, , __fmt), ...) +{ + __gnuc_va_list __fortify_ap; + __builtin_va_start (__fortify_ap, __fmt); + __vsyslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __fortify_ap); + __builtin_va_end (__fortify_ap); +} #elif !defined __cplusplus # define syslog(pri, ...) \ __syslog_chk (pri, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) @@ -43,8 +52,9 @@ syslog (int __pri, const char *__fmt, ...) #ifdef __USE_MISC -__fortify_function void -vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap) +__fortify_function __attribute_overloadable__ void +vsyslog (int __pri, __fortify_clang_overload_arg (const char *, ,__fmt), + __gnuc_va_list __ap) { __vsyslog_chk (__pri, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); }