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 X-Patchwork-Id: 770875 Delivered-To: patch@linaro.org Received: by 2002:adf:9dca:0:b0:33b:4db1:f5b3 with SMTP id q10csp479864wre; Thu, 8 Feb 2024 10:50:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX0mL32QG5Ykrr8ldbQglq57hYfZyBsV5Vix8t2DGgnv8dDirWMVhjVdIa8Yslo6PW6KcT+AqO2v5nReg69AAAm X-Google-Smtp-Source: AGHT+IFp1U9jf4g8GEb0ZfZ0pwHXZo3XH/aJXivZ8lZacy5si5CzgrD/3F5tdinqgODNXZ8QnVia X-Received: by 2002:a05:6214:b6b:b0:68c:85b2:c05a with SMTP id ey11-20020a0562140b6b00b0068c85b2c05amr88057qvb.59.1707418204146; Thu, 08 Feb 2024 10:50:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707418204; cv=pass; d=google.com; s=arc-20160816; b=DAepUzn4D3pHulYU7wTHvHv+zMuJVEpcPG5ohQ5/ZHFM5iDzAsTJSf8VQc2KTkuUNB 5ohHlYZ2dP8eQuNyCCJH62kNNwLg98pRgzrFnEer3k5dI2CiCrNRTsUbDhyjyYP/Zh5Y lkQrPlPsI7dZxr9Ey5z3mNdZUo0fdCRyJ8FfPNjDWUF2aRE34ha2WzOTAjmMch1ZIYRI ZYSVLphJmYYVp/RDIRxF0Hvt9fnG7m6i7RbNjOWq7WfqCneUm4VPy9vIUJ5Hx5mYeJGs a+8l03lEDnU9msUu2qQXj9nuxUW6k7nmhiYvg9WY1k22ZBevjyjXIudQwILOleNUnne1 POlQ== 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:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=ahnZUabbQXonvA8kJlBsyIjxa26cMYVFWEsdlWx7+nE=; fh=LRYad9MlZkZLwmoE0tMZ0zEyJTUIMdqQKHilyrtN3Hs=; b=LCw5wihp/Y9osfI6+WfF2Bq25pK/CmHwc6tzX56mDXU0nhWVCxJF8N7cF8+ApYvd4M 8yhMhKQWfG+6/vg6eaX17LyP7gx66r00wh1ER6dezZlScMGWTH2vMLHuIce7n6PFFs8u hWCZ4yT05Z6uJLnrwHKookCGFk+5FTlUFNlPJM3GNYDjwLXSYfP2pwHlEpilehPrVJE7 0cihx1owbCvP/zyq7ApV8kfXdldh5QAF+RYM1UF69cBF7vomRogiuaGXVB6sGnBehCFf aj13KOzIYrxIT7YzAWOh9o+aCXU9zju02TKRaDt1qmj22rWBV4AwuESoS5AnuyTCgwsb +YiA==; darn=linaro.org ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PfWzn+ca; 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 X-Forwarded-Encrypted: i=2; AJvYcCXryegx+MrBGGVwpxUh2IGVBhnnQk4yTyA1GyhTnQJXyaT5v6uI2aUrHSHmrrDCgXFgtf4tj1rhc7+l/3apua++ Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id eq7-20020ad45967000000b0068c469b290asi125777qvb.512.2024.02.08.10.50.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 10:50:04 -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=PfWzn+ca; 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 90FAD385841D for ; Thu, 8 Feb 2024 18:50:03 +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-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+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. 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); }