From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00FDFC79F80 for ; Fri, 4 Sep 2026 07:42:16 +0000 (UTC) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 53E583E57EF for ; Fri, 4 Sep 2026 09:42:15 +0200 (CEST) Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) (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 7491E3E6F28 for ; Fri, 4 Sep 2026 09:41:31 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) (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-7.smtp.seeweb.it (Postfix) with ESMTPS id DB0442010E5 for ; Fri, 4 Sep 2026 09:41:30 +0200 (CEST) Received: from imap1.dmz-prg2.suse.org (unknown [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-out2.suse.de (Postfix) with ESMTPS id 9C0461FD69; Fri, 4 Sep 2026 07:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1788507685; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BH7DGf0aqzIuJvH7GFUcZtDbUhKLj0ldYvRtJjs6rA4=; b=iig/OqzrS/SEPz+v2INPeRNhlEiyqxyN+5kt2WtTLMY3ISJCM/WjK6M1+9h0QBX+gZku20 14SZu9qxidUASsp+0OUlhwjE3+P1PWxVeUE/ksbVeXEAYtP4KKmZ6FnC4m/G9SZRSUTMHu XX2a1NFhqYuXcZSyz6+YHU8omRIc7/M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1788507685; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BH7DGf0aqzIuJvH7GFUcZtDbUhKLj0ldYvRtJjs6rA4=; b=4HlAmOh2qMf1VT5PZq3gDffTmrKPW8G98MqceRsIyqd3v3mL4AhHpeEYTG4E484asI+PMm q1pwSNwRLDXXXIDQ== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1788507681; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BH7DGf0aqzIuJvH7GFUcZtDbUhKLj0ldYvRtJjs6rA4=; b=X1lvsoashi4YPJUavDeDNiVX/DZp575PMxfSkCHSuZdqWN2NAm7ObWqwvZTYu79MMqNSPY 5P4Pk2vd6EC+iW8b8e4Z7w5OenOMMMM8P71ziIZnqihv+hX9OjvEpL8d0+I6jsjHV+IARm W33UYzRaDR8IVn85BQCtNnb4lsgfEts= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1788507681; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BH7DGf0aqzIuJvH7GFUcZtDbUhKLj0ldYvRtJjs6rA4=; b=smzkrflmO61R5lIztj8KcKSfqYbxzBTeiXpltEwktTvZn71TTSxJtfEYV8ewyMULuStC43 LHyva7T/E/gfxNAw== 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 3B7FB13869; Fri, 4 Sep 2026 07:41:21 +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 6E3/CyF2mmoGHAAAD6G6ig (envelope-from ); Fri, 04 Sep 2026 07:41:21 +0000 From: Andrea Cervesato Date: Fri, 04 Sep 2026 09:41:21 +0200 MIME-Version: 1.0 Message-Id: <20260904-cve-ghostlock-v8-3-bd999083c7fb@suse.com> References: <20260904-cve-ghostlock-v8-0-bd999083c7fb@suse.com> In-Reply-To: <20260904-cve-ghostlock-v8-0-bd999083c7fb@suse.com> To: Linux Test Project X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1788507680; l=2886; i=andrea.cervesato@suse.com; s=20251210; h=from:subject:message-id; bh=y9d9josT3h9ixKPrnx3v7RCAXAhCRULCCJbMwXyWvZk=; b=7LU6Fzm9h2tpu0TrEFl4SRmPboah08rcGdc3nFXKncrfMlReywyK3P5r6tftj67E/eojIjo1I J3rDVBjv+mxCR8+XTfxAwLtBCHrwZW61q3/jnegkCt/1+pDrnFzMYzy X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=zKY+6GCauOiuHNZ//d8PQ/UL4jFCTKbXrzXAOQSLevI= X-Spamd-Result: default: False [-4.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.997]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_DN_ALL(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, suse.com:mid, suse.com:email] X-Virus-Scanned: clamav-milter 1.0.9 at in-7.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v8 3/5] lapi/sched: add SAFE_SCHED_SETATTR() 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ltp-bounces+ltp=archiver.kernel.org@lists.linux.it Sender: "ltp" From: Andrea Cervesato Add a safe variant of sched_setattr() that breaks the test with TBROK on failure and use it in sched_setattr01 and sched_getattr01. Signed-off-by: Andrea Cervesato --- include/lapi/sched.h | 29 ++++++++++++++++++++++ .../syscalls/sched_getattr/sched_getattr01.c | 5 ++-- .../syscalls/sched_setattr/sched_setattr01.c | 2 +- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/include/lapi/sched.h b/include/lapi/sched.h index 05b322c1c..22cd27e6d 100644 --- a/include/lapi/sched.h +++ b/include/lapi/sched.h @@ -169,4 +169,33 @@ static inline int getcpu(unsigned *cpu, unsigned *node) # define CLONE_INTO_CGROUP 0x200000000ULL #endif +static inline int safe_sched_setattr(const char *file, const int lineno, + pid_t pid, struct sched_attr *attr, + unsigned int flags) +{ + int ret; + + ret = sched_setattr(pid, attr, flags); + + if (ret == -1) { + tst_brk_(file, lineno, TBROK | TERRNO, + "sched_setattr(%i) failed", pid); + } + + return ret; +} + +/** + * SAFE_SCHED_SETATTR() - Safe wrapper for sched_setattr(). + * @pid: Target process or thread ID (0 for caller). + * @attr: Pointer to a sched_attr structure. + * @flags: Flags modifying the scheduling behavior. + * + * Calls sched_setattr() and breaks the test with TBROK | TERRNO on failure. + * + * Return: Zero on success. + */ +#define SAFE_SCHED_SETATTR(pid, attr, flags)\ + safe_sched_setattr(__FILE__, __LINE__, (pid), (attr), (flags)) + #endif /* LAPI_SCHED_H__ */ diff --git a/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c b/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c index 0edd9e47e..bd05164ca 100644 --- a/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c +++ b/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c @@ -34,7 +34,7 @@ static void reset_sched(void) .sched_policy = SCHED_OTHER, }; - sched_setattr(0, &normal, 0); + SAFE_SCHED_SETATTR(0, &normal, 0); } static void run(void) @@ -47,8 +47,7 @@ static void run(void) .sched_period = PERIOD_VAL, }; - if (sched_setattr(0, &attr, 0) == -1) - tst_brk(TBROK | TERRNO, "sched_setattr() failed"); + SAFE_SCHED_SETATTR(0, &attr, 0); memset((void *)read_attr, 0, sizeof(*read_attr)); diff --git a/testcases/kernel/syscalls/sched_setattr/sched_setattr01.c b/testcases/kernel/syscalls/sched_setattr/sched_setattr01.c index 721620850..9d121327b 100644 --- a/testcases/kernel/syscalls/sched_setattr/sched_setattr01.c +++ b/testcases/kernel/syscalls/sched_setattr/sched_setattr01.c @@ -130,7 +130,7 @@ static void reset_sched(void) .sched_policy = SCHED_OTHER, }; - sched_setattr(0, &normal, 0); + SAFE_SCHED_SETATTR(0, &normal, 0); } static void verify_sched_setattr(unsigned int n) -- 2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp