From patchwork Mon Jan 8 20:21:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 83567 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E431D3857BAF for ; Mon, 8 Jan 2024 20:24:41 +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 71A35385841E for ; Mon, 8 Jan 2024 20:22:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 71A35385841E 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 71A35385841E 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=1704745329; cv=none; b=cRj44XL+emLkA5zMeMEGtvvKT1v5t2E714y+cgazHal0DSAKlPuA8kdQZAKiLLAShL3zAXK/D64Mv9OqlBznji9+Q6kQkKBzKHonYpz4VwiZ4ks+WuBLsTt2IwbrMBHYa15yWtLtrnXOvKrwIrcaJbtNBU+pjah9i8B7HR1K+lE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704745329; c=relaxed/simple; bh=lC3V/8/rcbKOdkq/r5wbAWpNDMHlYBNvhSHufWlznVM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=LPc27Rq733+2ppX95RlkUTm4gu0OyobRPeOVO0GRjCl21T5Ssnj14LpGSF20Hs5Vyq6M1d6cOxYcK5J+OZfxhYaElTwzMnBoH7KhufGHPsxYTDvGVrdoVu2/1AjQKIX8IHvNR2U5+M1M2R5QDtpDpnss81JMqJQ9Dbj6kGBwFok= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6daf9d5f111so1001180b3a.0 for ; Mon, 08 Jan 2024 12:22:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704745326; x=1705350126; 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=ahnZUabbQXonvA8kJlBsyIjxa26cMYVFWEsdlWx7+nE=; b=wXGwOKlT26qu7uTDjj8mZdCyDz+ZNtJutPoT8AIxCLbUya4NpzNIj3xCL+ihQxFCS9 tzWA5TS025k0L9xxpy4JeS7Is/Yi0SZEqu2Q43mDkRlL4ZtRLX1EpcezqsuEt4RTjCnU l1t5z/hPDCKJ/XNm9m4FSXdLUImgHSERWOk4kTk4dG/qeDk2wavVKkO95ngtdPfehGMJ P1BtjjLktCslzForiCDEmmNM/H2BkMRe3lkNC1QN5eOITA7dPZqZE+ANyhvr3IlZ7/Cl nHWFZwq4i4HlbDrKEgUlBYs0b41K+Oy27WoxNBou32jxNjyfAnhfe3wWS7/roq0fxVSk Z2TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704745326; x=1705350126; 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=ahnZUabbQXonvA8kJlBsyIjxa26cMYVFWEsdlWx7+nE=; b=ros286/P/a7l2BYGbEFaJnTsahtqfIxDEVKYkKlLCYlMQoEMN+HZDG62hduVhSqpWi T9yElVm79E9szJQEPnnPFeK5/DRPg5XeuQJVQd71JCrp/sgTVR2a3ZJGFPjPoWM/yzuR iD3mU6eoTAvsqu6AeEMw9eNrEHD9NW0jrZ7/C3MrZPm8SuRA6GQf9tVMuR1me5Xw1PFs sfHKkrcLuF3eMneDVeMmF5jH0Gp6O4bh89kKmrWooN71hR86coP+tXSjqiuw+/SvZb2k SqDOAGobuWrdrjZHLYwFEG93m60SDvhDLckShE2hqOTb2hpdhYylA3IvcwgI4sdu/6av Fx9A== X-Gm-Message-State: AOJu0Yyc87ReDjA8NxdlVguVCXdLQXgtGm3p9e2aUMlAxcxAf0Y9iHqz Zqmvz+uzOY0GYwq/sVPvk9Mk2UPA19ggSa2x4UNb2vDyu8w= X-Google-Smtp-Source: AGHT+IF+WDbAkiyfZ8oNK1MM6CNF9Si7OUarAfYQr+tSRnZDWiC7rR1jjyAxkB/p6q4zT218sXslGQ== X-Received: by 2002:a62:aa0e:0:b0:6da:5504:8c6f with SMTP id e14-20020a62aa0e000000b006da55048c6fmr4355562pff.33.1704745326142; Mon, 08 Jan 2024 12:22:06 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c1:9dd2:7f25:c108:2fff:5f8e]) by smtp.gmail.com with ESMTPSA id z13-20020a62d10d000000b006d9bdc0f765sm287936pfg.53.2024.01.08.12.22.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 12:22:05 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 07/10] syslog: Improve fortify with clang Date: Mon, 8 Jan 2024 17:21:46 -0300 Message-Id: <20240108202149.335305-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240108202149.335305-1-adhemerval.zanella@linaro.org> References: <20240108202149.335305-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 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+patchwork=sourceware.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 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); }