From patchwork Tue Jan 4 08:18:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1575071 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=N6BhaxqX; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JSlrJ5VZrz9sRR for ; Tue, 4 Jan 2022 19:18:56 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id EB94F3C8F89 for ; Tue, 4 Jan 2022 09:18:53 +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 [IPv6:2001:4b78:1:20::5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 1C8103C222E for ; Tue, 4 Jan 2022 09:18:43 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (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 A9D44600807 for ; Tue, 4 Jan 2022 09:18:42 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 0359A1F386; Tue, 4 Jan 2022 08:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641284322; 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=9TnmNDSFKZYUxjfango2FZqody8FAE5yjzKWThUVeqY=; b=N6BhaxqXcJapr6hSX+Tj1Wzxm8+Vwa3yxxLKlCaMNeAT6Anf8u90ojmLpEK1uipTC/Kd9P xOmAmv8/6VzcG85yFisLRskREuCmWBo762QbS01p2GRxdxrJPtPl6zZdgGR8+uAQyMaQCK Kl2Xbmb4GpUwIKVnNGYqfSwSU9ZiZKU= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A46B213AB9; Tue, 4 Jan 2022 08:18:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id UMJJIeEC1GGeZwAAMHmgww (envelope-from ); Tue, 04 Jan 2022 08:18:41 +0000 To: ltp@lists.linux.it Date: Tue, 4 Jan 2022 09:18:27 +0100 Message-Id: <20220104081836.22827-2-andrea.cervesato@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104081836.22827-1-andrea.cervesato@suse.com> References: <20220104081836.22827-1-andrea.cervesato@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean 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 autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH v1 01/10] Prepare watchqueue testing suite build 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: , X-Patchwork-Original-From: Andrea Cervesato via ltp From: Andrea Cervesato Reply-To: Andrea Cervesato Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Andrea Cervesato --- testcases/kernel/Makefile | 1 + testcases/kernel/watchqueue/.gitignore | 10 ++++++++++ testcases/kernel/watchqueue/Makefile | 8 ++++++++ 3 files changed, 19 insertions(+) create mode 100644 testcases/kernel/watchqueue/.gitignore create mode 100644 testcases/kernel/watchqueue/Makefile diff --git a/testcases/kernel/Makefile b/testcases/kernel/Makefile index 4604f1f38..d44856c57 100644 --- a/testcases/kernel/Makefile +++ b/testcases/kernel/Makefile @@ -38,6 +38,7 @@ SUBDIRS += connectors \ sound \ tracing \ uevents \ + watchqueue \ ifeq ($(WITH_POWER_MANAGEMENT_TESTSUITE),yes) SUBDIRS += power_management diff --git a/testcases/kernel/watchqueue/.gitignore b/testcases/kernel/watchqueue/.gitignore new file mode 100644 index 000000000..797ccc243 --- /dev/null +++ b/testcases/kernel/watchqueue/.gitignore @@ -0,0 +1,10 @@ +wqueue01 +wqueue02 +wqueue03 +wqueue04 +wqueue05 +wqueue06 +wqueue07 +wqueue08 +watch_test.c +watch_test diff --git a/testcases/kernel/watchqueue/Makefile b/testcases/kernel/watchqueue/Makefile new file mode 100644 index 000000000..0008b8cc4 --- /dev/null +++ b/testcases/kernel/watchqueue/Makefile @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../.. + +LDLIBS += $(KEYUTILS_LIBS) + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk From patchwork Tue Jan 4 08:18:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1575072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=Yv0DotJa; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JSlrW2rvHz9sRR for ; Tue, 4 Jan 2022 19:19:07 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id A520C3C9094 for ; Tue, 4 Jan 2022 09:19:03 +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 RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 9F9FB3C8FAD for ; Tue, 4 Jan 2022 09:18:43 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (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 0FA096008A8 for ; Tue, 4 Jan 2022 09:18:42 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 72205210E3; Tue, 4 Jan 2022 08:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641284322; 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=BuduZWapJ2/gyF7qCNCTEQtDRGZTlXrM/xJqLEyjJyI=; b=Yv0DotJaXckCWonf/ajpt/9tJZqCZ33+nIiFT0rCh/TVH5xX7p0lVa+hWlMr6/HZOj/ImQ ccVXezUogkpRPAhbLeaMpEYnzabFErmkWyhBImR+l6vmFEnUy85yqbPJFphkyfn1eX8Ezo 5gNO0b5kh8rfit0/xGKW8EgPbqsR5TI= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 20F4F13AB9; Tue, 4 Jan 2022 08:18:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yAGIA+IC1GGeZwAAMHmgww (envelope-from ); Tue, 04 Jan 2022 08:18:42 +0000 To: ltp@lists.linux.it Date: Tue, 4 Jan 2022 09:18:28 +0100 Message-Id: <20220104081836.22827-3-andrea.cervesato@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104081836.22827-1-andrea.cervesato@suse.com> References: <20220104081836.22827-1-andrea.cervesato@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean 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 autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH v1 02/10] Add wqueue01 new test 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: , X-Patchwork-Original-From: Andrea Cervesato via ltp From: Andrea Cervesato Reply-To: Andrea Cervesato Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This test checks if KEYCTL_UPDATE event is recognized by watch queue Signed-off-by: Andrea Cervesato --- testcases/kernel/watchqueue/common.h | 153 +++++++++++++++++++++++++ testcases/kernel/watchqueue/wqueue01.c | 68 +++++++++++ 2 files changed, 221 insertions(+) create mode 100644 testcases/kernel/watchqueue/common.h create mode 100644 testcases/kernel/watchqueue/wqueue01.c diff --git a/testcases/kernel/watchqueue/common.h b/testcases/kernel/watchqueue/common.h new file mode 100644 index 000000000..6a7ae213e --- /dev/null +++ b/testcases/kernel/watchqueue/common.h @@ -0,0 +1,153 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 Andrea Cervesato + */ + +#ifndef WQUEUE_COMMON_H__ +#define WQUEUE_COMMON_H__ + +#define _FCNTL_H + +#include +#include "tst_test.h" +#include "lapi/keyctl.h" + +static struct watch_notification_filter wqueue_key_filter = { + .nr_filters = 1, + .__reserved = 0, + .filters = { + [0] = { + .type = WATCH_TYPE_KEY_NOTIFY, + .subtype_filter[0] = UINT_MAX, + }, + }, +}; + +static const char *key_subtypes[256] = { + [NOTIFY_KEY_INSTANTIATED] = "instantiated", + [NOTIFY_KEY_UPDATED] = "updated", + [NOTIFY_KEY_LINKED] = "linked", + [NOTIFY_KEY_UNLINKED] = "unlinked", + [NOTIFY_KEY_CLEARED] = "cleared", + [NOTIFY_KEY_REVOKED] = "revoked", + [NOTIFY_KEY_INVALIDATED] = "invalidated", + [NOTIFY_KEY_SETATTR] = "setattr", +}; + +static inline long safe_keyctl(int cmd, ...) +{ + long ret; + va_list va; + unsigned long arg2, arg3, arg4, arg5; + + va_start(va, cmd); + arg2 = va_arg(va, unsigned long); + arg3 = va_arg(va, unsigned long); + arg4 = va_arg(va, unsigned long); + arg5 = va_arg(va, unsigned long); + va_end(va); + + ret = tst_syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5); + if (ret == -1) + tst_brk(TBROK, "keyctl error: %s", tst_strerrno(errno)); + + return ret; +} + +static int wqueue_key_event(struct watch_notification *n, size_t len, unsigned int wtype, int type) +{ + struct key_notification *k; + const char* msg; + + if (wtype != WATCH_TYPE_KEY_NOTIFY) + return 0; + + if (len != sizeof(struct key_notification)) + tst_brk(TBROK, "Incorrect key message length"); + + k = (struct key_notification *)n; + msg = key_subtypes[n->subtype]; + + tst_res(TINFO, "KEY %08x change=%u[%s] aux=%u", + k->key_id, n->subtype, msg, k->aux); + + if (n->subtype == type) + return 1; + + return 0; +} + +static key_serial_t wqueue_add_key(int fd) +{ + key_serial_t key; + + key = add_key("user", "ltptestkey", "a", 1, KEY_SPEC_SESSION_KEYRING); + if (key == -1) + tst_brk(TBROK, "add_key error: %s", tst_strerrno(errno)); + + safe_keyctl(KEYCTL_WATCH_KEY, key, fd, 0x01); + safe_keyctl(KEYCTL_WATCH_KEY, KEY_SPEC_SESSION_KEYRING, fd, 0x02); + + return key; +} + +static int wqueue_watch(int buf_size, struct watch_notification_filter *filter) +{ + int pipefd[2]; + int fd; + + SAFE_PIPE2(pipefd, O_NOTIFICATION_PIPE); + + fd = pipefd[0]; + + SAFE_IOCTL(fd, IOC_WATCH_QUEUE_SET_SIZE, buf_size); + SAFE_IOCTL(fd, IOC_WATCH_QUEUE_SET_FILTER, filter); + + return fd; +} + +typedef void (*wqueue_callback) (struct watch_notification *n, size_t len, unsigned int wtype); + +static void wqueue_consumer(int fd, volatile int *keep_polling, wqueue_callback cb) +{ + unsigned char buffer[433], *p, *end; + union { + struct watch_notification n; + unsigned char buf1[128]; + } n; + ssize_t buf_len; + + tst_res(TINFO, "Waiting for watch queue events"); + + while (*keep_polling) { + buf_len = SAFE_READ(0, fd, buffer, sizeof(buffer)); + + p = buffer; + end = buffer + buf_len; + while (p < end) { + size_t largest, len; + + largest = end - p; + if (largest > 128) + largest = 128; + + if (largest < sizeof(struct watch_notification)) + tst_brk(TBROK, "Short message header: %zu", largest); + + memcpy(&n, p, largest); + + tst_res(TINFO, "NOTIFY[%03zx]: ty=%06x sy=%02x i=%08x", + p - buffer, n.n.type, n.n.subtype, n.n.info); + + len = n.n.info & WATCH_INFO_LENGTH; + if (len < sizeof(n.n) || len > largest) + tst_brk(TBROK, "Bad message length: %zu/%zu", len, largest); + + cb(&n.n, len, n.n.type); + + p += len; + } + } +} + +#endif diff --git a/testcases/kernel/watchqueue/wqueue01.c b/testcases/kernel/watchqueue/wqueue01.c new file mode 100644 index 000000000..f22682eed --- /dev/null +++ b/testcases/kernel/watchqueue/wqueue01.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 Andrea Cervesato + */ + +/*\ + * [Description] + * + * Test if keyctl update is correctly recognized by watch queue. + */ + +#define _FCNTL_H + +#include "tst_test.h" +#include "lapi/keyctl.h" +#include "common.h" + +static int *keep_polling; + +static void saw_key_updated(struct watch_notification *n, size_t len, unsigned int wtype) +{ + if (wqueue_key_event(n, len, wtype, NOTIFY_KEY_UPDATED)) + tst_res(TPASS, "keyctl update has been recognized"); + else + tst_res(TFAIL, "keyctl update has not been recognized"); +} + +static void setup(void) +{ + keep_polling = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); +} + +static void cleanup(void) +{ + *keep_polling = 0; + SAFE_MUNMAP(keep_polling, sizeof(int)); +} + +static void run(void) +{ + int fd; + int pid; + key_serial_t key; + + fd = wqueue_watch(256, &wqueue_key_filter); + key = wqueue_add_key(fd); + + *keep_polling = 1; + + pid = SAFE_FORK(); + if (pid > 0) { + wqueue_consumer(fd, keep_polling, saw_key_updated); + return; + } + + safe_keyctl(KEYCTL_UPDATE, key, "b", 1); + + *keep_polling = 0; + + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = run, + .forks_child = 1 +}; From patchwork Tue Jan 4 08:18:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1575073 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=XM1Wx6bI; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JSlrh3pfMz9sRR for ; Tue, 4 Jan 2022 19:19:16 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id EF21B3C90EE for ; Tue, 4 Jan 2022 09:19:13 +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 RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id B18613C8FEA for ; Tue, 4 Jan 2022 09:18:43 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (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 499766008B0 for ; Tue, 4 Jan 2022 09:18:43 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DB001212B5; Tue, 4 Jan 2022 08:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641284322; 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=+Xp/U+p5YEnOlW3tVuRiATh5dbt9VQjN6PGGUUSh7OI=; b=XM1Wx6bInxR0HIssEE4l++aHdUi5/+YF+hYRx8jIiTiUhIBk0d0QuIE5iTtrYOVNtNgUbJ J71q9urfSIetqDuyiNTZ9+J7/V++wqNh3aV7t9psfry1W1wgOoVHIdH06WYGF8Tc44mZtS fy1M4un4a2F+qEtN6eY4lefJ8t2iZ04= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8CA0113AB9; Tue, 4 Jan 2022 08:18:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EEW+HuIC1GGeZwAAMHmgww (envelope-from ); Tue, 04 Jan 2022 08:18:42 +0000 To: ltp@lists.linux.it Date: Tue, 4 Jan 2022 09:18:29 +0100 Message-Id: <20220104081836.22827-4-andrea.cervesato@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104081836.22827-1-andrea.cervesato@suse.com> References: <20220104081836.22827-1-andrea.cervesato@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean 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 autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH v1 03/10] Add wqueue02 new test 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: , X-Patchwork-Original-From: Andrea Cervesato via ltp From: Andrea Cervesato Reply-To: Andrea Cervesato Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This test checks if KEYCTL_UNLINK is recognized by watch queue Signed-off-by: Andrea Cervesato --- testcases/kernel/watchqueue/wqueue02.c | 68 ++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 testcases/kernel/watchqueue/wqueue02.c diff --git a/testcases/kernel/watchqueue/wqueue02.c b/testcases/kernel/watchqueue/wqueue02.c new file mode 100644 index 000000000..2efefe90a --- /dev/null +++ b/testcases/kernel/watchqueue/wqueue02.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 Andrea Cervesato + */ + +/*\ + * [Description] + * + * Test if keyctl unlink is correctly recognized by watch queue. + */ + +#define _FCNTL_H + +#include "tst_test.h" +#include "lapi/keyctl.h" +#include "common.h" + +static int *keep_polling; + +static void saw_key_unlinked(struct watch_notification *n, size_t len, unsigned int wtype) +{ + if (wqueue_key_event(n, len, wtype, NOTIFY_KEY_UNLINKED)) + tst_res(TPASS, "keyctl unlink has been recognized"); + else + tst_res(TFAIL, "keyctl unlink has not been recognized"); +} + +static void setup(void) +{ + keep_polling = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); +} + +static void cleanup(void) +{ + *keep_polling = 0; + SAFE_MUNMAP(keep_polling, sizeof(int)); +} + +static void run(void) +{ + int fd; + int pid; + key_serial_t key; + + fd = wqueue_watch(256, &wqueue_key_filter); + key = wqueue_add_key(fd); + + *keep_polling = 1; + + pid = SAFE_FORK(); + if (pid > 0) { + wqueue_consumer(fd, keep_polling, saw_key_unlinked); + return; + } + + safe_keyctl(KEYCTL_UNLINK, key, KEY_SPEC_SESSION_KEYRING); + + *keep_polling = 0; + + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = run, + .forks_child = 1 +}; From patchwork Tue Jan 4 08:18:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1575074 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=fos4UCLJ; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JSlrs2DTjz9sRR for ; Tue, 4 Jan 2022 19:19:25 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 1559F3C9032 for ; Tue, 4 Jan 2022 09:19:23 +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 [IPv6:2001:4b78:1:20::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 64EB43C9046 for ; Tue, 4 Jan 2022 09:18:44 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (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 BED67600120 for ; Tue, 4 Jan 2022 09:18:43 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 598CA1F386; Tue, 4 Jan 2022 08:18:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641284323; 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=Oxy8o1JBAHgNcCUSdwmMQ2bxnPOv69Gbwestox36mBw=; b=fos4UCLJjhiUQVW+LIDPqA5lyekxyE7PfN1jdbjCdnp9mwuKUHQ9YAYCUjywqJrPipNPCs FwjgOUHZWIPg4Fmaii9MiJQTce10aNWEKKojHeiJ5sscRZq6WF+yz9SzQi5OEd3jV8lBJ8 7F9od0Nshkqjc2pqwudCkIITyx5awvc= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 03ACC13AB9; Tue, 4 Jan 2022 08:18:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sBBXOOIC1GGeZwAAMHmgww (envelope-from ); Tue, 04 Jan 2022 08:18:42 +0000 To: ltp@lists.linux.it Date: Tue, 4 Jan 2022 09:18:30 +0100 Message-Id: <20220104081836.22827-5-andrea.cervesato@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104081836.22827-1-andrea.cervesato@suse.com> References: <20220104081836.22827-1-andrea.cervesato@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-2.smtp.seeweb.it X-Virus-Status: Clean 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 autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH v1 04/10] Add wqueue03 new test 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: , X-Patchwork-Original-From: Andrea Cervesato via ltp From: Andrea Cervesato Reply-To: Andrea Cervesato Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This test checks if KEYCTL_REVOKE event is recognized by watch queue Signed-off-by: Andrea Cervesato --- testcases/kernel/watchqueue/wqueue03.c | 68 ++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 testcases/kernel/watchqueue/wqueue03.c diff --git a/testcases/kernel/watchqueue/wqueue03.c b/testcases/kernel/watchqueue/wqueue03.c new file mode 100644 index 000000000..a4bbdadcd --- /dev/null +++ b/testcases/kernel/watchqueue/wqueue03.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 Andrea Cervesato + */ + +/*\ + * [Description] + * + * Test if keyctl revoke is correctly recognized by watch queue. + */ + +#define _FCNTL_H + +#include "tst_test.h" +#include "lapi/keyctl.h" +#include "common.h" + +static int *keep_polling; + +static void saw_key_revoked(struct watch_notification *n, size_t len, unsigned int wtype) +{ + if (wqueue_key_event(n, len, wtype, NOTIFY_KEY_REVOKED)) + tst_res(TPASS, "keyctl revoke has been recognized"); + else + tst_res(TFAIL, "keyctl revoke has not been recognized"); +} + +static void setup(void) +{ + keep_polling = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); +} + +static void cleanup(void) +{ + *keep_polling = 0; + SAFE_MUNMAP(keep_polling, sizeof(int)); +} + +static void run(void) +{ + int fd; + int pid; + key_serial_t key; + + fd = wqueue_watch(256, &wqueue_key_filter); + key = wqueue_add_key(fd); + + *keep_polling = 1; + + pid = SAFE_FORK(); + if (pid > 0) { + wqueue_consumer(fd, keep_polling, saw_key_revoked); + return; + } + + safe_keyctl(KEYCTL_REVOKE, key); + + *keep_polling = 0; + + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = run, + .forks_child = 1 +}; From patchwork Tue Jan 4 08:18:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1575075 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=Y+c6qPYS; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JSls23Xjkz9sRR for ; Tue, 4 Jan 2022 19:19:34 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 60B7C3C902B for ; Tue, 4 Jan 2022 09:19:32 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it 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 RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id ED0583C9094 for ; Tue, 4 Jan 2022 09:18:44 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (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 2FC85200997 for ; Tue, 4 Jan 2022 09:18:44 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CA2971F398; Tue, 4 Jan 2022 08:18:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641284323; 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=tb7jA/3rgIWPPFe4FL6QdykTdYk3DzbDGR6eQxUuzrE=; b=Y+c6qPYSW5i2flRe7H67YI9E7sCpl9aKcN3OGS1H7zHfFPjiUIqlgy3VZlwR9HKEPwc9ol 5eMW2gxYp9crIQQOOOyD7/6Q2I6wwlARxCYFLaQq5OMaN/qtnLWA8SHzWj1qEiVj92cYF9 UYEJKqAqiA244xXT1dlFHlbK0OxdsYE= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 741A113AB9; Tue, 4 Jan 2022 08:18:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MNvWGOMC1GGeZwAAMHmgww (envelope-from ); Tue, 04 Jan 2022 08:18:43 +0000 To: ltp@lists.linux.it Date: Tue, 4 Jan 2022 09:18:31 +0100 Message-Id: <20220104081836.22827-6-andrea.cervesato@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104081836.22827-1-andrea.cervesato@suse.com> References: <20220104081836.22827-1-andrea.cervesato@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-7.smtp.seeweb.it X-Virus-Status: Clean 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 autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH v1 05/10] Add wqueue04 new test 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: , X-Patchwork-Original-From: Andrea Cervesato via ltp From: Andrea Cervesato Reply-To: Andrea Cervesato Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This test checks if KEYCTL_LINK event is recognized by watch queue Signed-off-by: Andrea Cervesato --- testcases/kernel/watchqueue/wqueue04.c | 68 ++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 testcases/kernel/watchqueue/wqueue04.c diff --git a/testcases/kernel/watchqueue/wqueue04.c b/testcases/kernel/watchqueue/wqueue04.c new file mode 100644 index 000000000..7d1bf375f --- /dev/null +++ b/testcases/kernel/watchqueue/wqueue04.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 Andrea Cervesato + */ + +/*\ + * [Description] + * + * Test if keyctl link is correctly recognized by watch queue. + */ + +#define _FCNTL_H + +#include "tst_test.h" +#include "lapi/keyctl.h" +#include "common.h" + +static int *keep_polling; + +static void saw_key_linked(struct watch_notification *n, size_t len, unsigned int wtype) +{ + if (wqueue_key_event(n, len, wtype, NOTIFY_KEY_LINKED)) + tst_res(TPASS, "keyctl link has been recognized"); + else + tst_res(TFAIL, "keyctl link has not been recognized"); +} + +static void setup(void) +{ + keep_polling = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); +} + +static void cleanup(void) +{ + *keep_polling = 0; + SAFE_MUNMAP(keep_polling, sizeof(int)); +} + +static void run(void) +{ + int fd; + int pid; + key_serial_t key; + + fd = wqueue_watch(256, &wqueue_key_filter); + key = wqueue_add_key(fd); + + *keep_polling = 1; + + pid = SAFE_FORK(); + if (pid > 0) { + wqueue_consumer(fd, keep_polling, saw_key_linked); + return; + } + + safe_keyctl(KEYCTL_LINK, key, KEY_SPEC_SESSION_KEYRING); + + *keep_polling = 0; + + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = run, + .forks_child = 1 +}; From patchwork Tue Jan 4 08:18:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1575076 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=fI3sYT5J; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JSlsF3GTKz9sRR for ; Tue, 4 Jan 2022 19:19:45 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id C4C4F3C8FE3 for ; Tue, 4 Jan 2022 09:19:42 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 0E5FB3C90A7 for ; Tue, 4 Jan 2022 09:18:44 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (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-4.smtp.seeweb.it (Postfix) with ESMTPS id 970EC100035C for ; Tue, 4 Jan 2022 09:18:44 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4629A1F3A0; Tue, 4 Jan 2022 08:18:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641284324; 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=SJ3xfCzUtNCnjB2gKLiK1kC3RxfvRV0Pxd7onhsssyc=; b=fI3sYT5JbibrAyCiIbjcWVfQFHaCZXumf4oRrM16G12tR3RdWhAbIhodqym6V8n4TjgZTi VQbU0OtVBjIteA+1/gequYl5bOtIHHZ/BAAYNSRm8pqpBHYw5JQJWKRVyfbRPOJYzkhNQt Gm/qYa/rXQfsAVEjbEC0KBbx6103ppc= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E4D5113AB9; Tue, 4 Jan 2022 08:18:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id gNJQNOMC1GGeZwAAMHmgww (envelope-from ); Tue, 04 Jan 2022 08:18:43 +0000 To: ltp@lists.linux.it Date: Tue, 4 Jan 2022 09:18:32 +0100 Message-Id: <20220104081836.22827-7-andrea.cervesato@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104081836.22827-1-andrea.cervesato@suse.com> References: <20220104081836.22827-1-andrea.cervesato@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean 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 autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH v1 06/10] Add wqueue05 new test 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: , X-Patchwork-Original-From: Andrea Cervesato via ltp From: Andrea Cervesato Reply-To: Andrea Cervesato Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This test checks if KEYCTL_INVALIDATE is recognized by watch queue Signed-off-by: Andrea Cervesato --- testcases/kernel/watchqueue/wqueue05.c | 68 ++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 testcases/kernel/watchqueue/wqueue05.c diff --git a/testcases/kernel/watchqueue/wqueue05.c b/testcases/kernel/watchqueue/wqueue05.c new file mode 100644 index 000000000..9dbf5102f --- /dev/null +++ b/testcases/kernel/watchqueue/wqueue05.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 Andrea Cervesato + */ + +/*\ + * [Description] + * + * Test if keyctl invalidate is correctly recognized by watch queue. + */ + +#define _FCNTL_H + +#include "tst_test.h" +#include "lapi/keyctl.h" +#include "common.h" + +static int *keep_polling; + +static void saw_key_invalidated(struct watch_notification *n, size_t len, unsigned int wtype) +{ + if (wqueue_key_event(n, len, wtype, NOTIFY_KEY_INVALIDATED)) + tst_res(TPASS, "keyctl invalidate has been recognized"); + else + tst_res(TFAIL, "keyctl invalidate has not been recognized"); +} + +static void setup(void) +{ + keep_polling = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); +} + +static void cleanup(void) +{ + *keep_polling = 0; + SAFE_MUNMAP(keep_polling, sizeof(int)); +} + +static void run(void) +{ + int fd; + int pid; + key_serial_t key; + + fd = wqueue_watch(256, &wqueue_key_filter); + key = wqueue_add_key(fd); + + *keep_polling = 1; + + pid = SAFE_FORK(); + if (pid > 0) { + wqueue_consumer(fd, keep_polling, saw_key_invalidated); + return; + } + + safe_keyctl(KEYCTL_INVALIDATE, key); + + *keep_polling = 0; + + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = run, + .forks_child = 1 +}; From patchwork Tue Jan 4 08:18:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1575077 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=eFh596FQ; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JSlsS2sKlz9sRR for ; Tue, 4 Jan 2022 19:19:56 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 395433C8F89 for ; Tue, 4 Jan 2022 09:19:54 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it 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 RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id D2A653C90B9 for ; Tue, 4 Jan 2022 09:18:45 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (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 5E1A320033D for ; Tue, 4 Jan 2022 09:18:45 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AF701210E3; Tue, 4 Jan 2022 08:18:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641284324; 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=jnWQJ2bYuZpmFvhMg4TJz9I08jN/LJ7JyqLlup0U6O4=; b=eFh596FQJ/Kf5N1MsPA5kQ9ha1UAOTWzZ5/Y1gpBSJDmclYKu4GI325rWQwXVAAYyqDpOP 6VmJGmok6k9IXCapgK97Hg7en3lgX2m8n+hrMHLjr7CRRaNb8S3BbyLd6bGxDK68nh/STB A8HTI9EhhU0qQnosFjgZGbYlpYBD6/o= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5BCCF13AB9; Tue, 4 Jan 2022 08:18:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0I4zE+QC1GGeZwAAMHmgww (envelope-from ); Tue, 04 Jan 2022 08:18:44 +0000 To: ltp@lists.linux.it Date: Tue, 4 Jan 2022 09:18:33 +0100 Message-Id: <20220104081836.22827-8-andrea.cervesato@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104081836.22827-1-andrea.cervesato@suse.com> References: <20220104081836.22827-1-andrea.cervesato@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-7.smtp.seeweb.it X-Virus-Status: Clean 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 autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH v1 07/10] Add wqueue06 new test 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: , X-Patchwork-Original-From: Andrea Cervesato via ltp From: Andrea Cervesato Reply-To: Andrea Cervesato Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This test checks if KEYCTL_CLEAR is recognized by watch queue Signed-off-by: Andrea Cervesato --- testcases/kernel/watchqueue/wqueue06.c | 67 ++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 testcases/kernel/watchqueue/wqueue06.c diff --git a/testcases/kernel/watchqueue/wqueue06.c b/testcases/kernel/watchqueue/wqueue06.c new file mode 100644 index 000000000..bb3f234f6 --- /dev/null +++ b/testcases/kernel/watchqueue/wqueue06.c @@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 Andrea Cervesato + */ + +/*\ + * [Description] + * + * Test if keyctl clear is correctly recognized by watch queue. + */ + +#define _FCNTL_H + +#include "tst_test.h" +#include "lapi/keyctl.h" +#include "common.h" + +static int *keep_polling; + +static void saw_key_cleared(struct watch_notification *n, size_t len, unsigned int wtype) +{ + if (wqueue_key_event(n, len, wtype, NOTIFY_KEY_CLEARED)) + tst_res(TPASS, "keyctl clear has been recognized"); + else + tst_res(TFAIL, "keyctl clear has not been recognized"); +} + +static void setup(void) +{ + keep_polling = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); +} + +static void cleanup(void) +{ + *keep_polling = 0; + SAFE_MUNMAP(keep_polling, sizeof(int)); +} + +static void run(void) +{ + int fd; + int pid; + + fd = wqueue_watch(256, &wqueue_key_filter); + wqueue_add_key(fd); + + *keep_polling = 1; + + pid = SAFE_FORK(); + if (pid > 0) { + wqueue_consumer(fd, keep_polling, saw_key_cleared); + return; + } + + safe_keyctl(KEYCTL_CLEAR, KEY_SPEC_SESSION_KEYRING); + + *keep_polling = 0; + + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = run, + .forks_child = 1 +}; From patchwork Tue Jan 4 08:18:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1575078 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=UN8iH8tn; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JSlsd5FJXz9sRR for ; Tue, 4 Jan 2022 19:20:05 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 850D23C9056 for ; Tue, 4 Jan 2022 09:20:03 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 5433B3C9094 for ; Tue, 4 Jan 2022 09:18:46 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (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-3.smtp.seeweb.it (Postfix) with ESMTPS id 85E871A00719 for ; Tue, 4 Jan 2022 09:18:45 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 1F1671F386; Tue, 4 Jan 2022 08:18:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641284325; 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=SujbahQi5U4f81g68I3F82NioalhexZTrnRBSl2Epds=; b=UN8iH8tnpa6hbGXG0wmJVEUU2/DcKi5ksHP3C9vCxioTazaU1feCLARYBhdk+n1pw06lR/ pwpRq477FJgmrPIlfQRy3T0a1wksFACtkjKcshFIVPqOw94MCEV6ijFdpfWZL9QlNHJLAP m1yZ0XRq1Hm4stImwEbKD146UmZmuL8= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C724413AB9; Tue, 4 Jan 2022 08:18:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id yOtfLeQC1GGeZwAAMHmgww (envelope-from ); Tue, 04 Jan 2022 08:18:44 +0000 To: ltp@lists.linux.it Date: Tue, 4 Jan 2022 09:18:34 +0100 Message-Id: <20220104081836.22827-9-andrea.cervesato@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104081836.22827-1-andrea.cervesato@suse.com> References: <20220104081836.22827-1-andrea.cervesato@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean 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 autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH v1 08/10] Add wqueue07 new test 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: , X-Patchwork-Original-From: Andrea Cervesato via ltp From: Andrea Cervesato Reply-To: Andrea Cervesato Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This test checks if KEYCTL_SETPERM is recognized by watch queue Signed-off-by: Andrea Cervesato --- testcases/kernel/watchqueue/wqueue07.c | 68 ++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 testcases/kernel/watchqueue/wqueue07.c diff --git a/testcases/kernel/watchqueue/wqueue07.c b/testcases/kernel/watchqueue/wqueue07.c new file mode 100644 index 000000000..99b3c9e70 --- /dev/null +++ b/testcases/kernel/watchqueue/wqueue07.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 Andrea Cervesato + */ + +/*\ + * [Description] + * + * Test if keyctl setperm is correctly recognized by watch queue. + */ + +#define _FCNTL_H + +#include "tst_test.h" +#include "lapi/keyctl.h" +#include "common.h" + +static int *keep_polling; + +static void saw_key_setattr(struct watch_notification *n, size_t len, unsigned int wtype) +{ + if (wqueue_key_event(n, len, wtype, NOTIFY_KEY_SETATTR)) + tst_res(TPASS, "keyctl setattr has been recognized"); + else + tst_res(TFAIL, "keyctl setattr has not been recognized"); +} + +static void setup(void) +{ + keep_polling = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); +} + +static void cleanup(void) +{ + *keep_polling = 0; + SAFE_MUNMAP(keep_polling, sizeof(int)); +} + +static void run(void) +{ + int fd; + int pid; + key_serial_t key; + + fd = wqueue_watch(256, &wqueue_key_filter); + key = wqueue_add_key(fd); + + *keep_polling = 1; + + pid = SAFE_FORK(); + if (pid > 0) { + wqueue_consumer(fd, keep_polling, saw_key_setattr); + return; + } + + safe_keyctl(KEYCTL_SETPERM, key, KEY_POS_ALL | KEY_USR_ALL); + + *keep_polling = 0; + + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = run, + .forks_child = 1 +}; From patchwork Tue Jan 4 08:18:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1575079 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=b2wm4iro; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JSlsr0z1hz9sRR for ; Tue, 4 Jan 2022 19:20:16 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id CEDF83C903B for ; Tue, 4 Jan 2022 09:20:13 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 74A573C910D for ; Tue, 4 Jan 2022 09:18:46 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (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-3.smtp.seeweb.it (Postfix) with ESMTPS id CD9541A008A7 for ; Tue, 4 Jan 2022 09:18:45 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 841BC1F398; Tue, 4 Jan 2022 08:18:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641284325; 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=XjjMpYIlb+Gv0Bh4vxWmd7YcXiYPDMHR25S6IA+GqIU=; b=b2wm4iro1EhlkQ2Y14j92KJDF0j47rG4xMqLdps/Uctz7KBl5O/GRx92U51LfhLK7ovFvf jZ87R5ZY/TflX2JByWVh1HLXIm5OCgfrA81LkHO/HLV+C11aL0k782TNtv5Sd/TdkelIeJ t4rf8312IFs8sIe7Qf/9VEZvCZEQzvU= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 38D4213AB9; Tue, 4 Jan 2022 08:18:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8IL7CeUC1GGeZwAAMHmgww (envelope-from ); Tue, 04 Jan 2022 08:18:45 +0000 To: ltp@lists.linux.it Date: Tue, 4 Jan 2022 09:18:35 +0100 Message-Id: <20220104081836.22827-10-andrea.cervesato@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104081836.22827-1-andrea.cervesato@suse.com> References: <20220104081836.22827-1-andrea.cervesato@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean 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 autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH v1 09/10] Add wqueue08 new test 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: , X-Patchwork-Original-From: Andrea Cervesato via ltp From: Andrea Cervesato Reply-To: Andrea Cervesato Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This test checks if KEYCTL_WATCH_KEY event is recognized by watch queue Signed-off-by: Andrea Cervesato --- testcases/kernel/watchqueue/wqueue08.c | 83 ++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 testcases/kernel/watchqueue/wqueue08.c diff --git a/testcases/kernel/watchqueue/wqueue08.c b/testcases/kernel/watchqueue/wqueue08.c new file mode 100644 index 000000000..202cc0274 --- /dev/null +++ b/testcases/kernel/watchqueue/wqueue08.c @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 Andrea Cervesato + */ + +/*\ + * [Description] + * + * Test if key watch removal is correctly recognized by watch queue. + */ + +#define _FCNTL_H + +#include "tst_test.h" +#include "lapi/keyctl.h" +#include "common.h" + +static int *keep_polling; + +static struct watch_notification_filter meta_filter = { + .nr_filters = 1, + .__reserved = 0, + .filters = { + [0] = { + .type = WATCH_TYPE_META, + .subtype_filter[0] = UINT_MAX, + }, + }, +}; + +static void saw_watch_removal(struct watch_notification *n, size_t len, unsigned int wtype) +{ + if (wtype != WATCH_TYPE_META) + return; + + if (n->subtype == WATCH_META_REMOVAL_NOTIFICATION) + tst_res(TPASS, "Meta removal notification received"); + else + tst_res(TFAIL, "Event not recognized"); +} + +static void setup(void) +{ + keep_polling = SAFE_MMAP(NULL, sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); +} + +static void cleanup(void) +{ + *keep_polling = 0; + SAFE_MUNMAP(keep_polling, sizeof(int)); +} + +static void run(void) +{ + int fd; + int pid; + key_serial_t key; + + fd = wqueue_watch(256, &meta_filter); + key = wqueue_add_key(fd); + + *keep_polling = 1; + + pid = SAFE_FORK(); + if (pid > 0) { + wqueue_consumer(fd, keep_polling, saw_watch_removal); + return; + } + + /* if watch_id = -1 key is removed from the watch queue */ + safe_keyctl(KEYCTL_WATCH_KEY, key, fd, -1); + + *keep_polling = 0; + + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = run, + .forks_child = 1 +}; From patchwork Tue Jan 4 08:18:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Cervesato X-Patchwork-Id: 1575080 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=YBHj5ZLQ; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JSlt14zSRz9sRR for ; Tue, 4 Jan 2022 19:20:25 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id EA6863C9029 for ; Tue, 4 Jan 2022 09:20:22 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id B846E3C9013 for ; Tue, 4 Jan 2022 09:18:46 +0100 (CET) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (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-4.smtp.seeweb.it (Postfix) with ESMTPS id 4EEC8100035C for ; Tue, 4 Jan 2022 09:18:46 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id F007E1F3A0; Tue, 4 Jan 2022 08:18:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1641284325; 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=zaOLdDF2S9D4LFu71zCrs5mMDHdKumz8RI8jREGVC6M=; b=YBHj5ZLQFV3fpEb+c/YQwLX1+Tdpm3PxanGXQluUHzIrmrsGPIsBqtZnbVrYm07UWaL759 N+OoLXxuyuTFmuBKnzFBCIRc9JUCNqq8dqHI0/KOWpet5WfszqOCxQBgqyEp/JCsF9GDyP OlurOB4B+1/iW+UViUyUNZxdDSOo/hY= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9FFAF13AB9; Tue, 4 Jan 2022 08:18:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eKJdI+UC1GGeZwAAMHmgww (envelope-from ); Tue, 04 Jan 2022 08:18:45 +0000 To: ltp@lists.linux.it Date: Tue, 4 Jan 2022 09:18:36 +0100 Message-Id: <20220104081836.22827-11-andrea.cervesato@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220104081836.22827-1-andrea.cervesato@suse.com> References: <20220104081836.22827-1-andrea.cervesato@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-4.smtp.seeweb.it X-Virus-Status: Clean 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 autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH v1 10/10] Define watchqueue testing suite in runtest 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: , X-Patchwork-Original-From: Andrea Cervesato via ltp From: Andrea Cervesato Reply-To: Andrea Cervesato Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Andrea Cervesato --- runtest/watchqueue | 8 ++++++++ scenario_groups/default | 1 + 2 files changed, 9 insertions(+) create mode 100644 runtest/watchqueue diff --git a/runtest/watchqueue b/runtest/watchqueue new file mode 100644 index 000000000..badf7afb0 --- /dev/null +++ b/runtest/watchqueue @@ -0,0 +1,8 @@ +wqueue01 wqueue01 +wqueue02 wqueue02 +wqueue03 wqueue03 +wqueue04 wqueue04 +wqueue05 wqueue05 +wqueue06 wqueue06 +wqueue07 wqueue07 +wqueue08 wqueue08 diff --git a/scenario_groups/default b/scenario_groups/default index 1dc2987d5..68bd5300d 100644 --- a/scenario_groups/default +++ b/scenario_groups/default @@ -30,3 +30,4 @@ cve crypto kernel_misc uevent +watchqueue