From patchwork Tue Mar 26 14:41:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1916204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=f6vWTEKm; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=ziUMTIzC; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=f6vWTEKm; dkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=ziUMTIzC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (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 4V3svl4Tnnz1yWr for ; Wed, 27 Mar 2024 01:42:11 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 59AAA3D0EB2 for ; Tue, 26 Mar 2024 15:42:09 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 14B2F3CFED1 for ; Tue, 26 Mar 2024 15:41:50 +0100 (CET) Authentication-Results: in-2.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.cz (client-ip=195.135.223.130; helo=smtp-out1.suse.de; envelope-from=pvorel@suse.cz; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 9844F60081C for ; Tue, 26 Mar 2024 15:41:49 +0100 (CET) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 06E8437CD0; Tue, 26 Mar 2024 14:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1711464109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yl9cncS3BgAmk/NMcUayNglC+KbipLJ1paf+ARmNtoc=; b=f6vWTEKmbmfk8PX+Yc3qxLBybq1sGpB0UxGIJ+pReoVhhXOh6vWf6fpOdkeWNYsDi3j27X /0S8FNif/B5FtvKVMK1XF/4N7d/OHeMnBfF5rmXmGV+7xgo8JStuN+VW6o+i+ndQxqQzG7 LxmPOQCwUmQdV471pvtLBwxUDwdEOus= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1711464109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yl9cncS3BgAmk/NMcUayNglC+KbipLJ1paf+ARmNtoc=; b=ziUMTIzC0+qQni9tkB3WXKcYAbtx3dgE1x9lLhtSQM2Efh38/eXRies2POS/yn6zVkgnX1 7jhYLF2DS/cdDLDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1711464109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yl9cncS3BgAmk/NMcUayNglC+KbipLJ1paf+ARmNtoc=; b=f6vWTEKmbmfk8PX+Yc3qxLBybq1sGpB0UxGIJ+pReoVhhXOh6vWf6fpOdkeWNYsDi3j27X /0S8FNif/B5FtvKVMK1XF/4N7d/OHeMnBfF5rmXmGV+7xgo8JStuN+VW6o+i+ndQxqQzG7 LxmPOQCwUmQdV471pvtLBwxUDwdEOus= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1711464109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yl9cncS3BgAmk/NMcUayNglC+KbipLJ1paf+ARmNtoc=; b=ziUMTIzC0+qQni9tkB3WXKcYAbtx3dgE1x9lLhtSQM2Efh38/eXRies2POS/yn6zVkgnX1 7jhYLF2DS/cdDLDQ== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id D5FFA13AF2; Tue, 26 Mar 2024 14:41:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id yGFYMqzeAmYTTAAAn2gu4w (envelope-from ); Tue, 26 Mar 2024 14:41:48 +0000 From: Petr Vorel To: ltp@lists.linux.it Date: Tue, 26 Mar 2024 15:41:43 +0100 Message-ID: <20240326144145.747735-2-pvorel@suse.cz> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240326144145.747735-1-pvorel@suse.cz> References: <20240326144145.747735-1-pvorel@suse.cz> MIME-Version: 1.0 X-Spam-Score: 3.70 X-Spamd-Result: default: False [3.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[] Authentication-Results: smtp-out1.suse.de; none X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-2.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-2.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v3 1/3] lib: Add tst_selinux_enforcing() X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mete Durlu Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Reviewed-by: Li Wang Reviewed-by: Cyril Hrubis Co-developed-by: Mete Durlu Signed-off-by: Petr Vorel --- include/tst_security.h | 1 + lib/tst_security.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/tst_security.h b/include/tst_security.h index 438b16dbb..5d91f8a98 100644 --- a/include/tst_security.h +++ b/include/tst_security.h @@ -13,5 +13,6 @@ int tst_fips_enabled(void); int tst_lockdown_enabled(void); int tst_secureboot_enabled(void); +int tst_selinux_enforcing(void); #endif /* TST_SECURITY_H__ */ diff --git a/lib/tst_security.c b/lib/tst_security.c index 0fc704dfa..7d929fafe 100644 --- a/lib/tst_security.c +++ b/lib/tst_security.c @@ -7,6 +7,7 @@ #define PATH_FIPS "/proc/sys/crypto/fips_enabled" #define PATH_LOCKDOWN "/sys/kernel/security/lockdown" +#define SELINUX_STATUS_PATH "/sys/fs/selinux/enforce" #if defined(__powerpc64__) || defined(__ppc64__) # define SECUREBOOT_VAR "/proc/device-tree/ibm,secure-boot" @@ -16,6 +17,7 @@ # define VAR_DATA_SIZE 5 #endif +#include #include #include #include @@ -30,11 +32,11 @@ int tst_fips_enabled(void) { int fips = 0; - if (access(PATH_FIPS, R_OK) == 0) { + if (access(PATH_FIPS, R_OK) == 0) SAFE_FILE_SCANF(PATH_FIPS, "%d", &fips); - } tst_res(TINFO, "FIPS: %s", fips ? "on" : "off"); + return fips; } @@ -99,3 +101,15 @@ int tst_secureboot_enabled(void) tst_res(TINFO, "SecureBoot: %s", data[VAR_DATA_SIZE - 1] ? "on" : "off"); return data[VAR_DATA_SIZE - 1]; } + +int tst_selinux_enforcing(void) +{ + int res = 0; + + if (access(SELINUX_STATUS_PATH, F_OK) == 0) + SAFE_FILE_SCANF(SELINUX_STATUS_PATH, "%d", &res); + + tst_res(TINFO, "SELinux enforcing: %s", res ? "on" : "off"); + + return res; +} From patchwork Tue Mar 26 14:41:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1916205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=cXvqpWVd; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=4/GA1+EH; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=cXvqpWVd; dkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=4/GA1+EH; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V3sw51GKMz1yWr for ; Wed, 27 Mar 2024 01:42:28 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 7115D3CC7D4 for ; Tue, 26 Mar 2024 15:42:25 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 3498D3CC7D4 for ; Tue, 26 Mar 2024 15:41:50 +0100 (CET) Authentication-Results: in-2.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.cz (client-ip=195.135.223.130; helo=smtp-out1.suse.de; envelope-from=pvorel@suse.cz; receiver=lists.linux.it) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id A6E38601088 for ; Tue, 26 Mar 2024 15:41:49 +0100 (CET) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 32AC837CD1; Tue, 26 Mar 2024 14:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1711464109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sxmstvNkto+i2LYJrZU+n/yj3AXoImdkhfgXduDBfpM=; b=cXvqpWVdnE/kuP8vd4llvmtR/EHHqv+Is7QTi4MIgAnBuqpZtiTFiZ7qtnLZJ7mFrUrnU9 PSu0XdHJivjArbd7c6L5p5rCW+/F+1HgZtFewx+3/dD5p+kF73j9JTlC2Gw43Fj58WxA15 6dzIHMtOq5L8qk/ChqddguX4lP4yiQ0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1711464109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sxmstvNkto+i2LYJrZU+n/yj3AXoImdkhfgXduDBfpM=; b=4/GA1+EHMGOOfGe4wd8JlA7kXk1EjROf7RrTThntcHEhrdRYfjP0R5VKZDGV30SlnO7R7V QKOm8ZD9QqrSPwAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1711464109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sxmstvNkto+i2LYJrZU+n/yj3AXoImdkhfgXduDBfpM=; b=cXvqpWVdnE/kuP8vd4llvmtR/EHHqv+Is7QTi4MIgAnBuqpZtiTFiZ7qtnLZJ7mFrUrnU9 PSu0XdHJivjArbd7c6L5p5rCW+/F+1HgZtFewx+3/dD5p+kF73j9JTlC2Gw43Fj58WxA15 6dzIHMtOq5L8qk/ChqddguX4lP4yiQ0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1711464109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sxmstvNkto+i2LYJrZU+n/yj3AXoImdkhfgXduDBfpM=; b=4/GA1+EHMGOOfGe4wd8JlA7kXk1EjROf7RrTThntcHEhrdRYfjP0R5VKZDGV30SlnO7R7V QKOm8ZD9QqrSPwAQ== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 0D95813215; Tue, 26 Mar 2024 14:41:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id 2MmIAq3eAmYTTAAAn2gu4w (envelope-from ); Tue, 26 Mar 2024 14:41:49 +0000 From: Petr Vorel To: ltp@lists.linux.it Date: Tue, 26 Mar 2024 15:41:44 +0100 Message-ID: <20240326144145.747735-3-pvorel@suse.cz> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240326144145.747735-1-pvorel@suse.cz> References: <20240326144145.747735-1-pvorel@suse.cz> MIME-Version: 1.0 X-Spamd-Bar: +++ Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=cXvqpWVd; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="4/GA1+EH" X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [3.49 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:98:from]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DWL_DNSWL_BLOCKED(0.00)[suse.cz:dkim]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.cz:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:dkim,suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: 3.49 X-Rspamd-Queue-Id: 32AC837CD1 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-2.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-2.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v3 2/3] tst_test_macros.h: Require to pass array size in TST_EXP_FAIL*_ARR() X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Although having to pass ARRAY_SIZE() of the expected errnos is not ideal, it gives more flexibility to the tests allowing to use just portion of the array (will be used in fanotify14 in the next commit). It looks to be better than keep introduce yet another functions. Suggested-by: Cyril Hrubis Signed-off-by: Petr Vorel Reviewed-by: Cyril Hrubis --- include/tst_test_macros.h | 8 ++++---- lib/newlib_tests/test_macros02.c | 8 ++++---- testcases/kernel/syscalls/readahead/readahead01.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h index d2e50a219..6a7bcdce5 100644 --- a/include/tst_test_macros.h +++ b/include/tst_test_macros.h @@ -242,9 +242,9 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt); ##__VA_ARGS__); \ } while (0) -#define TST_EXP_FAIL_ARR(SCALL, EXP_ERRS, ...) \ +#define TST_EXP_FAIL_ARR(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...) \ TST_EXP_FAIL_ARR_(SCALL, #SCALL, EXP_ERRS, \ - ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__); + EXP_ERRS_CNT, ##__VA_ARGS__); #define TST_EXP_FAIL2_ARR_(SCALL, SSCALL, EXP_ERRS, EXP_ERRS_CNT, ...) \ do { \ @@ -254,9 +254,9 @@ const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt); TST_MSG_(TPASS | TTERRNO, " ", SSCALL, ##__VA_ARGS__); \ } while (0) -#define TST_EXP_FAIL2_ARR(SCALL, EXP_ERRS, ...) \ +#define TST_EXP_FAIL2_ARR(SCALL, EXP_ERRS, EXP_ERRS_CNT, ...) \ TST_EXP_FAIL2_ARR_(SCALL, #SCALL, EXP_ERRS, \ - ARRAY_SIZE(EXP_ERRS), ##__VA_ARGS__); + EXP_ERRS_CNT, ##__VA_ARGS__); #define TST_EXP_FAIL2(SCALL, EXP_ERR, ...) \ do { \ diff --git a/lib/newlib_tests/test_macros02.c b/lib/newlib_tests/test_macros02.c index 6c1ca7a8a..8e5a83346 100644 --- a/lib/newlib_tests/test_macros02.c +++ b/lib/newlib_tests/test_macros02.c @@ -39,9 +39,9 @@ static void do_test(void) tst_res(TINFO, "TST_PASS = %i", TST_PASS); TST_EXP_FAIL(inval_ret_fn(), ENOTTY, "inval_ret_fn()"); tst_res(TINFO, "TST_PASS = %i", TST_PASS); - TST_EXP_FAIL_ARR(fail_fn(), exp_errs_pass, "fail_fn()"); + TST_EXP_FAIL_ARR(fail_fn(), exp_errs_pass, ARRAY_SIZE(exp_errs_pass), "fail_fn()"); tst_res(TINFO, "TST_PASS = %i", TST_PASS); - TST_EXP_FAIL_ARR(fail_fn(), exp_errs_fail, "fail_fn()"); + TST_EXP_FAIL_ARR(fail_fn(), exp_errs_fail, ARRAY_SIZE(exp_errs_fail), "fail_fn()"); tst_res(TINFO, "TST_PASS = %i", TST_PASS); tst_res(TINFO, "Testing TST_EXP_FAIL2 macro"); @@ -53,9 +53,9 @@ static void do_test(void) tst_res(TINFO, "TST_PASS = %i", TST_PASS); TST_EXP_FAIL2(inval_ret_fn(), ENOTTY, "inval_ret_fn()"); tst_res(TINFO, "TST_PASS = %i", TST_PASS); - TST_EXP_FAIL2_ARR(fail_fn(), exp_errs_pass, "fail_fn()"); + TST_EXP_FAIL2_ARR(fail_fn(), exp_errs_pass, ARRAY_SIZE(exp_errs_pass), "fail_fn()"); tst_res(TINFO, "TST_PASS = %i", TST_PASS); - TST_EXP_FAIL2_ARR(fail_fn(), exp_errs_fail, "fail_fn()"); + TST_EXP_FAIL2_ARR(fail_fn(), exp_errs_fail, ARRAY_SIZE(exp_errs_fail), "fail_fn()"); tst_res(TINFO, "TST_PASS = %i", TST_PASS); } diff --git a/testcases/kernel/syscalls/readahead/readahead01.c b/testcases/kernel/syscalls/readahead/readahead01.c index 0f610daf8..d4b3f306f 100644 --- a/testcases/kernel/syscalls/readahead/readahead01.c +++ b/testcases/kernel/syscalls/readahead/readahead01.c @@ -61,7 +61,7 @@ static void test_invalid_fd(struct tst_fd *fd) int exp_errnos[] = {EBADF, EINVAL, ESPIPE}; TST_EXP_FAIL_ARR(readahead(fd->fd, 0, getpagesize()), exp_errnos, - "readahead() on %s", tst_fd_desc(fd)); + ARRAY_SIZE(exp_errnos), "readahead() on %s", tst_fd_desc(fd)); } static void test_readahead(void) From patchwork Tue Mar 26 14:41:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1916206 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=IWS93nb0; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=YQXNKmm6; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.cz header.i=@suse.cz header.a=rsa-sha256 header.s=susede2_rsa header.b=IWS93nb0; dkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=YQXNKmm6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=patchwork.ozlabs.org) Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4V3swP0XDtz1yWr for ; Wed, 27 Mar 2024 01:42:45 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 9949E3D0ED1 for ; Tue, 26 Mar 2024 15:42:41 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 94A683CC7D4 for ; Tue, 26 Mar 2024 15:41:50 +0100 (CET) Authentication-Results: in-5.smtp.seeweb.it; spf=pass (sender SPF authorized) smtp.mailfrom=suse.cz (client-ip=195.135.223.131; helo=smtp-out2.suse.de; envelope-from=pvorel@suse.cz; receiver=lists.linux.it) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 134C4601405 for ; Tue, 26 Mar 2024 15:41:49 +0100 (CET) Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 528125D719; Tue, 26 Mar 2024 14:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1711464109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j0Wn+z+hlmWBOPGNJl+VpbMNXO9YTHqCbIXZkufmuU0=; b=IWS93nb0pkNvEaTOn/0dNhGxP9mFX0doE5e4DT5Pfkq/BrPqsZr4GGyaPgnKNG+iHrtkXd 0PAASiaVIyK62KBgYsKlOQ37KMIwqRnVbg9YiZK1G/mpZ8g5wEP+HvPH2DWP/h+cQi8ccm V5T5djTdMUBLKfc15yTSKMnabJ2LW+k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1711464109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j0Wn+z+hlmWBOPGNJl+VpbMNXO9YTHqCbIXZkufmuU0=; b=YQXNKmm61uZ68zcKaGdCU7Y2M0gfshmzbMwxiC3LCAuaXnMR5N9MviIAjcKKx7irFYFKGx JIpa64a4z/7ceKDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1711464109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j0Wn+z+hlmWBOPGNJl+VpbMNXO9YTHqCbIXZkufmuU0=; b=IWS93nb0pkNvEaTOn/0dNhGxP9mFX0doE5e4DT5Pfkq/BrPqsZr4GGyaPgnKNG+iHrtkXd 0PAASiaVIyK62KBgYsKlOQ37KMIwqRnVbg9YiZK1G/mpZ8g5wEP+HvPH2DWP/h+cQi8ccm V5T5djTdMUBLKfc15yTSKMnabJ2LW+k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1711464109; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j0Wn+z+hlmWBOPGNJl+VpbMNXO9YTHqCbIXZkufmuU0=; b=YQXNKmm61uZ68zcKaGdCU7Y2M0gfshmzbMwxiC3LCAuaXnMR5N9MviIAjcKKx7irFYFKGx JIpa64a4z/7ceKDA== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 2F37A13AF2; Tue, 26 Mar 2024 14:41:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id YNxtCq3eAmYTTAAAn2gu4w (envelope-from ); Tue, 26 Mar 2024 14:41:49 +0000 From: Petr Vorel To: ltp@lists.linux.it Date: Tue, 26 Mar 2024 15:41:45 +0100 Message-ID: <20240326144145.747735-4-pvorel@suse.cz> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240326144145.747735-1-pvorel@suse.cz> References: <20240326144145.747735-1-pvorel@suse.cz> MIME-Version: 1.0 X-Spam-Score: 1.23 X-Spamd-Bar: + Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=IWS93nb0; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=YQXNKmm6 X-Spamd-Result: default: False [1.23 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; DWL_DNSWL_BLOCKED(0.00)[suse.cz:dkim]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.cz:+]; MX_GOOD(-0.01)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-2.26)[96.50%]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:dkim,suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[linux.ibm.com,gmail.com,suse.cz]; RCVD_TLS_ALL(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:98:from] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 528125D719 X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-5.smtp.seeweb.it X-Virus-Scanned: clamav-milter 1.0.3 at in-5.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v3 3/3] fanotify14: fix anonymous pipe testcases X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mete Durlu , Jan Kara Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From: Mete Durlu When SElinux is in enforcing state and SEpolicies disallow anonymous pipe usage with fanotify_mark(), related fanotify14 testcases fail with EACCES instead of EINVAL. Accept both errnos when SElinux is in enforcing state to correctly evaluate test results. Replace TST_EXP_FD_OR_FAIL with TST_EXP_FAIL when testing fanotify_mark() as it returns -1 on failure and 0 on success not a file descriptor. Reviewed-by: Amir Goldstein Reviewed-by: Jan Kara Co-developed-by: Petr Vorel Signed-off-by: Mete Durlu Signed-off-by: Petr Vorel --- testcases/kernel/syscalls/fanotify/fanotify14.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/testcases/kernel/syscalls/fanotify/fanotify14.c b/testcases/kernel/syscalls/fanotify/fanotify14.c index d02d81495..ee583a095 100644 --- a/testcases/kernel/syscalls/fanotify/fanotify14.c +++ b/testcases/kernel/syscalls/fanotify/fanotify14.c @@ -47,6 +47,7 @@ static int pipes[2] = {-1, -1}; static int fanotify_fd; static int ignore_mark_unsupported; static int filesystem_mark_unsupported; +static int se_enforcing; static unsigned int supported_init_flags; struct test_case_flags_t { @@ -274,6 +275,7 @@ static void do_test(unsigned int number) /* Set mark on non-dir only when expecting error ENOTDIR */ const char *path = tc->expected_errno == ENOTDIR ? FILE1 : MNTPOINT; + const int exp_errs[] = {tc->expected_errno, EACCES}; int dirfd = AT_FDCWD; if (tc->pfd) { @@ -283,9 +285,9 @@ static void do_test(unsigned int number) tst_res(TINFO, "Testing %s with %s", tc->mark.desc, tc->mask.desc); - TST_EXP_FD_OR_FAIL(fanotify_mark(fanotify_fd, FAN_MARK_ADD | tc->mark.flags, - tc->mask.flags, dirfd, path), - tc->expected_errno); + + TST_EXP_FAIL_ARR(fanotify_mark(fanotify_fd, FAN_MARK_ADD | tc->mark.flags, + tc->mask.flags, dirfd, path), exp_errs, se_enforcing ? 2 : 1); /* * ENOTDIR are errors for events/flags not allowed on a non-dir inode. @@ -334,6 +336,8 @@ static void do_setup(void) SAFE_FILE_PRINTF(FILE1, "0"); /* Create anonymous pipes to place marks on */ SAFE_PIPE2(pipes, O_CLOEXEC); + + se_enforcing = tst_selinux_enforcing(); } static void do_cleanup(void)