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 0FE11C79F80 for ; Fri, 4 Sep 2026 07:42:44 +0000 (UTC) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id B789E3E936B for ; Fri, 4 Sep 2026 09:42:42 +0200 (CEST) Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::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 488063E9366 for ; Fri, 4 Sep 2026 09:41:30 +0200 (CEST) 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 1E34D600F10 for ; Fri, 4 Sep 2026 09:41:29 +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-out2.suse.de (Postfix) with ESMTPS id 64F1A1FD19; 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=pccv7m049sOP8ZX4oTHq9tPcf1LQK+T7Whjf5cdMSoU=; b=D62bk/gvmb3Dir25TVoThL7DtgO4DnvC3SzMH+IkWklD/3xDnV+65dTafIJyTsgZYlm2hq 4qQTeoQb08UZKGh765BexYqSVlOzuf5kfsKG11ZoYj9qtfvTia3c//MY2Tz5KznHcL23i/ /61FdhCw35h34PcdpiERpbCpTqnserk= 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=pccv7m049sOP8ZX4oTHq9tPcf1LQK+T7Whjf5cdMSoU=; b=/lLeEW0WSsj+dYrcKxw/plgDd+4e8QENmBXqKpjlc38Zgk5Pa5aO6tJFaCHnxQQtZRthJ2 gCGdmFj1CDFe3gCQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=nMpMbScG; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=dp3ZWVC8 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=pccv7m049sOP8ZX4oTHq9tPcf1LQK+T7Whjf5cdMSoU=; b=nMpMbScGmmEx4k8MOeJ29mlYMt7T1Wsdl8UdPfm3VP8NAMnX0M2PSHLvcd+YQAxglIxTXg VJQ+iJs0PE7qaBp6pWJmkgdjZdirqB/PboF4pZFqOHo8Q5e8XJoNiqeYQLYGe0BpDxJt4q BHrdrMyi4mKiTYZ4sb8FBhY5sP/vnck= 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=pccv7m049sOP8ZX4oTHq9tPcf1LQK+T7Whjf5cdMSoU=; b=dp3ZWVC8JZRLP4xaRUrKI/MAw4QfKaV3aYSCCw8BdWzFvlF8oHWHY5EcqgYDvp1dQWD48Y WEXCLFJXKSczwDDQ== 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 02E7913738; Fri, 4 Sep 2026 07:41:20 +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 QLZwOSB2mmoGHAAAD6G6ig (envelope-from ); Fri, 04 Sep 2026 07:41:20 +0000 From: Andrea Cervesato Date: Fri, 04 Sep 2026 09:41:20 +0200 MIME-Version: 1.0 Message-Id: <20260904-cve-ghostlock-v8-2-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=5869; i=andrea.cervesato@suse.com; s=20251210; h=from:subject:message-id; bh=qYPOZmAxaNbRFdbCB22L6f12JijwWIW/PDWWN2W/8bA=; b=QiiUTxhT1wT3Sy2u/0dAU75woi0/nOu3suwcqGdBh4kOESkSLA22hEAv/pnCIVZDXmOanzr5a z+5OY0P1MonBEH8gy5vwId1iVfK5EmCdw6sisU02bkAAsRA3eO1Bmiz X-Developer-Key: i=andrea.cervesato@suse.com; a=ed25519; pk=zKY+6GCauOiuHNZ//d8PQ/UL4jFCTKbXrzXAOQSLevI= X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 64F1A1FD19 X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.com:mid,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+] X-Virus-Scanned: clamav-milter 1.0.9 at in-5.smtp.seeweb.it X-Virus-Status: Clean Subject: [LTP] [PATCH v8 2/5] sched_getattr01: Convert to new API 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 Rewrite the test to use the modern LTP API (tst_test.h) with TST_EXP_* macros and cleanup callback. Signed-off-by: Andrea Cervesato --- testcases/kernel/syscalls/sched_getattr/Makefile | 1 - .../syscalls/sched_getattr/sched_getattr01.c | 143 ++++++++------------- 2 files changed, 57 insertions(+), 87 deletions(-) diff --git a/testcases/kernel/syscalls/sched_getattr/Makefile b/testcases/kernel/syscalls/sched_getattr/Makefile index ea299ff4a..4cef5e763 100644 --- a/testcases/kernel/syscalls/sched_getattr/Makefile +++ b/testcases/kernel/syscalls/sched_getattr/Makefile @@ -5,6 +5,5 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk -CFLAGS += -pthread include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c b/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c index 2e06d1809..0edd9e47e 100644 --- a/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c +++ b/testcases/kernel/syscalls/sched_getattr/sched_getattr01.c @@ -1,105 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) Huawei Technologies Co., Ltd., 2015 - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Copyright (C) 2026 SUSE LLC Andrea Cervesato + */ + +/*\ + * Verify that :manpage:`sched_getattr(2)` correctly reads back the scheduling + * attributes of a task configured with :manpage:`sched_setattr(2)`. + * + * Root is required (:c:macro:`CAP_SYS_NICE`) to configure the + * :c:macro:`SCHED_DEADLINE` policy. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. + * The test relies on the LTP harness process isolation and resets the + * scheduling policy to :c:macro:`SCHED_OTHER` after testing to prevent + * :c:macro:`SCHED_DEADLINE` constraints from leaking across test iterations. */ #define _GNU_SOURCE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "test.h" +#include "tst_test.h" #include "lapi/sched.h" -char *TCID = "sched_getattr01"; -int TST_TOTAL = 1; - #define RUNTIME_VAL 10000000 #define PERIOD_VAL 30000000 #define DEADLINE_VAL 30000000 -void *run_deadline(void *data LTP_ATTRIBUTE_UNUSED) -{ - struct sched_attr attr, attr_copy; - int ret; - unsigned int flags = 0; - unsigned int size; - - attr.size = sizeof(attr); - attr.sched_flags = 0; - attr.sched_nice = 0; - attr.sched_priority = 0; - - /* This creates a 10ms/30ms reservation */ - attr.sched_policy = SCHED_DEADLINE; - attr.sched_runtime = RUNTIME_VAL; - attr.sched_period = PERIOD_VAL; - attr.sched_deadline = DEADLINE_VAL; - - ret = sched_setattr(0, &attr, flags); - if (ret < 0) - tst_brkm(TFAIL | TERRNO, NULL, "sched_setattr() failed"); - - size = sizeof(attr_copy); - ret = sched_getattr(0, &attr_copy, size, flags); - if (ret < 0) - tst_brkm(TFAIL | TERRNO, NULL, "sched_getattr() failed"); +static struct sched_attr *read_attr; - int fail = 0; - - if (attr_copy.sched_runtime != RUNTIME_VAL) { - tst_resm(TINFO, "sched_runtime is incorrect (%"PRIu64")," - " expected %u", attr.sched_runtime, RUNTIME_VAL); - fail++; - } - if (attr_copy.sched_period != PERIOD_VAL) { - tst_resm(TINFO, "sched_period is incorrect (%"PRIu64")," - " expected %u", attr.sched_period, PERIOD_VAL); - fail++; - } - if (attr_copy.sched_deadline != DEADLINE_VAL) { - tst_resm(TINFO, "sched_deadline is incorrect (%"PRIu64")," - " expected %u", attr.sched_deadline, DEADLINE_VAL); - fail++; - } - - if (fail) - tst_resm(TFAIL, "attributes were read back incorrectly"); - else - tst_resm(TPASS, "attributes were read back correctly"); +static void reset_sched(void) +{ + struct sched_attr normal = { + .size = sizeof(normal), + .sched_policy = SCHED_OTHER, + }; - return NULL; + sched_setattr(0, &normal, 0); } -int main(int argc, char **argv) +static void run(void) { - pthread_t thread; - int lc; - - tst_parse_opts(argc, argv, NULL, NULL); - - tst_require_root(); - - for (lc = 0; TEST_LOOPING(lc); lc++) { - pthread_create(&thread, NULL, run_deadline, NULL); - pthread_join(thread, NULL); - } - - tst_exit(); + struct sched_attr attr = { + .size = sizeof(attr), + .sched_policy = SCHED_DEADLINE, + .sched_runtime = RUNTIME_VAL, + .sched_deadline = DEADLINE_VAL, + .sched_period = PERIOD_VAL, + }; + + if (sched_setattr(0, &attr, 0) == -1) + tst_brk(TBROK | TERRNO, "sched_setattr() failed"); + + memset((void *)read_attr, 0, sizeof(*read_attr)); + + TST_EXP_PASS(sched_getattr(0, read_attr, sizeof(*read_attr), 0), + "sched_getattr() with valid parameters"); + if (!TST_PASS) + return; + + TST_EXP_EQ_LU(read_attr->sched_policy, SCHED_DEADLINE); + TST_EXP_EQ_LU(read_attr->sched_runtime, RUNTIME_VAL); + TST_EXP_EQ_LU(read_attr->sched_deadline, DEADLINE_VAL); + TST_EXP_EQ_LU(read_attr->sched_period, PERIOD_VAL); + + reset_sched(); } + +static struct tst_test test = { + .test_all = run, + .cleanup = reset_sched, + .needs_root = 1, + .bufs = (struct tst_buffers []) { + {&read_attr, .size = sizeof(*read_attr)}, + {}, + }, +}; -- 2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp