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: 760790 Delivered-To: patch@linaro.org Received: by 2002:a5d:6e02:0:b0:337:62d3:c6d5 with SMTP id h2csp1062694wrz; Mon, 8 Jan 2024 12:24:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHp8dXvrrMywVDpaAz0O1M4lhFZq/qSla0deZy/v+TPa1ZmZkgAbhfNFe6MEU8I308OoynL X-Received: by 2002:a05:622a:1346:b0:429:99d9:2b58 with SMTP id w6-20020a05622a134600b0042999d92b58mr1210210qtk.37.1704745467914; Mon, 08 Jan 2024 12:24:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704745467; cv=pass; d=google.com; s=arc-20160816; b=XbyVpHwPPo/mPZuDFZfNOw+pZyxBax1L1gcYWHvbV9LBBszOKel7EiPgtkT/mGbT2l A0SNkx/1NOi74BaSpyWFUqRHaNAxUvipMwh+Gm7Jv1OiwUKz/imH5WtyMa367AgXQ+TL vVVVg/0akYdlzf0Yj0PAkklAHf+hG7kcwwxy1nURw3td+vQQ1Hr9DJzc0hSnd9/chdJx /y6UjSe/ubs9TjahSyurbGpY6VohlqwJ06UBbYv0i3ZLwkMPE1wITSHaxoMu0davchMO 8ms4fLLEMNq6GO+Ql+PxWeyCt37QFfIgXg4hY7ViVxzO9cncLKrhJ5R4v/GmpcJ5A1HZ HI/A== 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=ahnZUabbQXonvA8kJlBsyIjxa26cMYVFWEsdlWx7+nE=; fh=dHLBnA+MhGtNtN2B2JMAELi4oD+gmgMg7DL8H0jYbkI=; b=q5DLw0HerITt+qQK8wRWn2MA98L34ltAOO+KmcFUW98txi4jGsuzCiR9E/Uu3k3Bi9 4xJ8XbuoFWNqp83P4u/dcDFnIAz1a9LIGGd70TpZXccHmsVW4JhAAXxhDv8c16vYfSVL jSJrfA1AhR0v1n+sYuOdyDRUsG1TubhIQI/nCMBtP7b08ZOTwHJ/Tof3a+dxH9NruwAW hlC3/wOflrko9O0R32xV5cB7wqqyS34J8N8aZs+rnSY/L3B16A2LYpgNPA+2vfVVf/Lq O0N8A/64yw8mD5M2b1F5Q+1qxwzjEWcilMEiWGn9/dnR+ePlPrbp1a8mewIOg6d21Q7o +o0A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wXGwOKlT; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id w19-20020a05622a135300b0042997993bc2si473484qtk.233.2024.01.08.12.24.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 12:24:27 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wXGwOKlT; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 8C11B38582AC for ; Mon, 8 Jan 2024 20:24:27 +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-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+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 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); }