From patchwork Thu Jul 11 20:13:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1959519 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=d9lS3wub; dkim=fail reason="signature verification failed" header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=DQbtqemX; 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=d9lS3wub; dkim=neutral header.d=suse.cz header.i=@suse.cz header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=DQbtqemX; 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 4WKmBW5bNVz1xpd for ; Fri, 12 Jul 2024 06:13:23 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 057323D0D30 for ; Thu, 11 Jul 2024 22:13:21 +0200 (CEST) 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 [IPv6:2001:4b78:1:20::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 75BD03C2220 for ; Thu, 11 Jul 2024 22:13:17 +0200 (CEST) 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 76C726067A7 for ; Thu, 11 Jul 2024 22:13:15 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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 4E7EA21ABB; Thu, 11 Jul 2024 20:13:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1720728795; 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; bh=tIW5+h1Z9U0VHBT7rHRSX1AkOouTjroXdeXZAG6RrPo=; b=d9lS3wub1g1jn48pss0hXqnF7uzcQqfKTTjidlSTq1HhIuupot9k7wHhwfXVeEdBPwXtuo 8Yr6Pn1Ni8DgUhKstcVELjoNL1QeODUBFUqjMoXw1BiOMpQ/SVr3pwSzZVl9QR014oMNNf cckueCk8J9fu1yFSWgkRl2ziSRDTVRA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1720728795; 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; bh=tIW5+h1Z9U0VHBT7rHRSX1AkOouTjroXdeXZAG6RrPo=; b=DQbtqemXYIQQ9RzADDPp+rIJFl9nafkCS3+tqlO2eCptyKB1y+NNuH/nZW1Z/wdP0uGhvx /22vjcY9xKb0t8DA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=d9lS3wub; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=DQbtqemX DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1720728795; 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; bh=tIW5+h1Z9U0VHBT7rHRSX1AkOouTjroXdeXZAG6RrPo=; b=d9lS3wub1g1jn48pss0hXqnF7uzcQqfKTTjidlSTq1HhIuupot9k7wHhwfXVeEdBPwXtuo 8Yr6Pn1Ni8DgUhKstcVELjoNL1QeODUBFUqjMoXw1BiOMpQ/SVr3pwSzZVl9QR014oMNNf cckueCk8J9fu1yFSWgkRl2ziSRDTVRA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1720728795; 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; bh=tIW5+h1Z9U0VHBT7rHRSX1AkOouTjroXdeXZAG6RrPo=; b=DQbtqemXYIQQ9RzADDPp+rIJFl9nafkCS3+tqlO2eCptyKB1y+NNuH/nZW1Z/wdP0uGhvx /22vjcY9xKb0t8DA== Received: from imap1.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 18B9B139E0; Thu, 11 Jul 2024 20:13:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id xv8tA9s8kGbYbwAAD6G6ig (envelope-from ); Thu, 11 Jul 2024 20:13:15 +0000 From: Petr Vorel To: ltp@lists.linux.it Date: Thu, 11 Jul 2024 22:13:05 +0200 Message-ID: <20240711201306.98519-1-pvorel@suse.cz> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: 4E7EA21ABB X-Spam-Score: 0.99 X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [0.99 / 50.00]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; FUZZY_BLOCKED(0.00)[rspamd.com]; DWL_DNSWL_BLOCKED(0.00)[suse.cz:dkim]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[suse.cz:+] X-Spam-Level: X-Spamd-Bar: / 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 1/1] lib: Add missing checks for invalid return value 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" It's a common approach to test invalid return value in safe macros. Signed-off-by: Petr Vorel Reviewed-by: Li Wang --- include/lapi/landlock.h | 12 ++++++++++++ lib/tst_safe_macros.c | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/include/lapi/landlock.h b/include/lapi/landlock.h index 6d85eb12e3..d3fa760e5b 100644 --- a/include/lapi/landlock.h +++ b/include/lapi/landlock.h @@ -133,6 +133,10 @@ static inline int safe_landlock_create_ruleset(const char *file, const int linen tst_brk_(file, lineno, TBROK | TERRNO, "landlock_create_ruleset(%p, %lu, %u)", attr, size, flags); + } else if (rval < 0) { + tst_brk_(file, lineno, TBROK | TERRNO, + "Invalid landlock_create_ruleset(%p, %lu, %u) return value %d", + attr, size, flags, rval); } return rval; @@ -151,6 +155,10 @@ static inline int safe_landlock_add_rule(const char *file, const int lineno, tst_brk_(file, lineno, TBROK | TERRNO, "landlock_add_rule(%d, %d, %p, %u)", ruleset_fd, rule_type, rule_attr, flags); + } else if (rval < 0) { + tst_brk_(file, lineno, TBROK | TERRNO, + "Invalid landlock_add_rule(%d, %d, %p, %u) return value %d", + ruleset_fd, rule_type, rule_attr, flags, rval); } return rval; @@ -166,6 +174,10 @@ static inline int safe_landlock_restrict_self(const char *file, const int lineno tst_brk_(file, lineno, TBROK | TERRNO, "landlock_restrict_self(%d, %u)", ruleset_fd, flags); + } else if (rval < 0) { + tst_brk_(file, lineno, TBROK | TERRNO, + "Invalid landlock_restrict_self(%d, %u) return value %d", + ruleset_fd, flags, rval); } return rval; diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c index 9301f3dd27..1bc5c92f58 100644 --- a/lib/tst_safe_macros.c +++ b/lib/tst_safe_macros.c @@ -723,6 +723,10 @@ int safe_prctl(const char *file, const int lineno, tst_brk_(file, lineno, TBROK | TERRNO, "prctl(%d, %lu, %lu, %lu, %lu)", option, arg2, arg3, arg4, arg5); + } else if (rval < 0) { + tst_brk_(file, lineno, TBROK | TERRNO, + "Invalid prctl(%d, %lu, %lu, %lu, %lu) return value %d", + option, arg2, arg3, arg4, arg5, rval); } return rval;