From patchwork Thu Dec 21 18:59:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 757038 Delivered-To: patch@linaro.org Received: by 2002:a5d:67c6:0:b0:336:6142:bf13 with SMTP id n6csp1055232wrw; Thu, 21 Dec 2023 11:01:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdk1f4aaSMyBSQsrYvWSNUzQbH1S4R4NsAGLTIXuo0Fig4lmP0BeCadUM5s5BGUtRmIuxE X-Received: by 2002:a05:6102:3a08:b0:466:991a:f0dc with SMTP id b8-20020a0561023a0800b00466991af0dcmr65877vsu.29.1703185317380; Thu, 21 Dec 2023 11:01:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703185317; cv=pass; d=google.com; s=arc-20160816; b=bJ4uH3sttvRruFwilY5OG6sxd85mmOlK9KnxQzTtzPvlsIH5ALzrgQ5UXC/TatV3ah wEcFfjZPtaEOdRHrFtNoY4EX1Q2xt+d062qACJkSsk00MOTiHgQCaIRl6tc9VfY7qaA9 Z+a8bJdPi+FmFEgFH7X5Vk2cSOY2HyII6IB7p2OPzwEjNTmCrzorqsK8ZMrYnSUlBgx4 7UHHvHKbLT4J1xX3ELdtiT5OQGX7953vZKZU6upe2+mIxZri5TujrWvUt7aDaEKwVCyp eYelVK2iPWh3lYM/ZZniZpoQOswsZtQuc/MFGOib471AXuUUz5wis9egmBt1DFtFphVT 01Sw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=DFiPWdaibLsWNpMdH26VAD+eJvMmerM/T8rQUKBZNmY=; fh=JNN3k7BRNI1OnWdIBK9jlpNeitGd8uBm02dHI75AGcg=; b=TCOWMle4+VP8xmeEsAHqNromtsYlXBZg86sxBhfFSSwtFdCf293QjS1Zi4/wHrlGpf zLv1xoYd3d1QKaU8Y+vzntGc9NawZpfEx7r3YtjGATk8uHWnFBjqq/ER4+WRii08VKxA QnnW7CaW0N6NjeGEzVHk4GTpiqHNKDpJ/EE+yLAXR6N+1+4E0FUP16hGT4x7scptWYGu ETMEJtwEEGyaAfuKPEItOc4sHMgtbaLdDLxWTX+f35FmW13i12EzKGFCovZW1RRkj/QW XjJsj7vWaGNXuXoo7GXfHh3xkGG3ywM3LSs/aVXDuutUuHUKr71eTs03S76xvy2kgnEf D98g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uqYONK06; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d23-20020a67c497000000b0046681bea6e8si500393vsk.721.2023.12.21.11.01.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 11:01:57 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uqYONK06; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6DC1038708F9 for ; Thu, 21 Dec 2023 19:01:53 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by sourceware.org (Postfix) with ESMTPS id B1A2F384DEC0 for ; Thu, 21 Dec 2023 19:00:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B1A2F384DEC0 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 B1A2F384DEC0 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703185208; cv=none; b=THSjJ3+6MB+ZF+8ohnCsRLb6p8HjRpFbNa6Kg485l8bIJCGMvnIw0XZWuv4kdCU2LLbHXrQzOoMENLEuMY1cFRwYgFZ62V7TzF5/VFvzfRczhOl1nKgt10z+B/moCwV0IkTtjiMSI2o5RFhOaN/xYaplzaL5joJkYNg74Xa+4iI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703185208; c=relaxed/simple; bh=KGPx8L9/99Xs+uFUrXQd69OoVbOgz1wPVCOc60k4rFs=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=H18mn9I+vcdUyTvqfu9On0oNbcH1r1Kg/w5rmJ/aSdUcIoIZiKa8yDI7YGHcLhNEan8Fw5czmRDItzbfm4BmwZjL0RXVnwb0Y9r8dRzMl3CotYDChVO8LLe6RtbGUXEw1oRltnKYVkduBkjiZpUgyjWr9TGYnsqabu5vVR0D4+M= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6d94308279dso834886b3a.2 for ; Thu, 21 Dec 2023 11:00:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1703185205; x=1703790005; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=DFiPWdaibLsWNpMdH26VAD+eJvMmerM/T8rQUKBZNmY=; b=uqYONK06fb9N3ueCFKx4w+BE3WEjYMlH6LRH2eawceb0dhNPUSsNJ23wx5ai2snP+5 9zyWrfl9pJLSlXH8F+26lS4+BRESikpCZW9QkbauwSlfdY3vhnrS2nsIiOlbTnXeo0Tc DWXMnxFuBJIqfmp+WoMmeaSB3wpsf2+9Va6rnC+PEnsQNBBVRXvZeebCV9Y/qsp0VOo5 r2BgwyAca5TlD3oRDV0OGWN1bmvjmPf282K/ghzFWZ8AWZucu/hAMeubIgkNcLyGzBmJ ynAzuSlu+VLgtLcAS8zJVuVDnC0gEJhNDq3KNPPCxyIlOSy3zLp5xVHQzDH9ok4pObsR 4P+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703185205; x=1703790005; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DFiPWdaibLsWNpMdH26VAD+eJvMmerM/T8rQUKBZNmY=; b=EBhzw0jEdBSpHgELb3kmgws5Kb//0TkQhDzcaJX7hxm+Xy/v7rDQZMXutXKELb1GPH 5opzcpeUyAHEysJaHEqN+lOLWIPlA3Q4nR/73EjcZyFZvaW9KzbESpDrvkxqCdW00b/4 6ZLpteB6TiHC0BVbtyOHEG1dFv+QmuRTqfjSj0zGssyxQrblnOVH+O4c9v+i0awUZZc7 03N0lNciu9PW6u2xPzJSVRDHCJwZuJ3edoxT+YkfWV92MvvYpc1YnZfsYcm+vpr9lsbC PmPCHAM8cSC7UdMH+KKNxqaTwexQU3VJMbVfD5uOq46+v3tVeaf8Zr+xh8F/rH8e1PNM CQmw== X-Gm-Message-State: AOJu0Yz40RjewwP09+yr0gxuIQPclZRq+8llCKbiEY6w8avxf4AcU550 6g9Nzu9I1WtU57g9/ziSbpnFxVVzxMHFpxdYpW3a855u80E= X-Received: by 2002:a05:6a20:9191:b0:190:9d87:f9e4 with SMTP id v17-20020a056a20919100b001909d87f9e4mr138631pzd.72.1703185205226; Thu, 21 Dec 2023 11:00:05 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:8192:ecd7:d327:bea0:14dc]) by smtp.gmail.com with ESMTPSA id a9-20020a63e409000000b005cdbebd61d8sm1946165pgi.9.2023.12.21.11.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 11:00:04 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Siddhesh Poyarekar Subject: [PATCH 12/15] syslog: Improve fortify with clang Date: Thu, 21 Dec 2023 15:59:26 -0300 Message-Id: <20231221185929.1307116-13-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231221185929.1307116-1-adhemerval.zanella@linaro.org> References: <20231221185929.1307116-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 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+patch=linaro.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. --- 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 d7de90ed14..969ce9e431 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); }