From patchwork Mon Aug 30 11:16:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1522192 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GynpW212xz9sT6 for ; Mon, 30 Aug 2021 21:17:07 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4C2BE3C8DA6 for ; Mon, 30 Aug 2021 13:17:03 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) (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 0B0C53C2AE0 for ; Mon, 30 Aug 2021 13:16:52 +0200 (CEST) Received: from JPN01-OS2-obe.outbound.protection.outlook.com (mail-os2jpn01olkn0175.outbound.protection.outlook.com [104.47.92.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 5FB5A140044F for ; Mon, 30 Aug 2021 13:16:51 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Izs15XSARFBnsB1L7mfjqDmyp5C+TrK0M9i3KRN22c/yle/LLbbg9WJiELiMVD+KOe9inkLTSKD9mmOzsBOy38s52a9pqjkJ8MHC2QAoAmW6jM0fjM1XpXu9dgYwHLcUP2gclwq1RlgxLl7p54exFisGbpLQBZIOHq4hO4D6aUwXHYf/DilM+hdQmXxGQRTNYyNuDSRdwyLmo7hYnTeBhElU/G8Vl8W1s7OMPm+bKfx2Epp/ig9X1P5wGMDpygUvNhzgWkqebTOuoRZe+kHg6pICBnS9Qad+mCw7pz4srXqbKLV5gTjmPZIrAi+RuOiMZx9QwwgdUj0tbziCxUKdPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E/VjkScQD52H2qqRbAzicggWZY1bJPNjC+5Tk0Md/74=; b=T5Ufit59bfy3P9+XzSF6BYboLMVuG7xJvX6RkL6qE/1SlZFsz9v8pDr155JVRGGWpgQ9QFQSVpMk9jOI7ruP3lAcJjY+83VWpGaeOrkH/wB7D6ZQTrUo6zr4AeZZPpDC9JIXlW3CgfBnQTvAscSKvIuELHcyvk7/e7UYHgsJKrwzpoBPRw6LrYOj1qJrNLN1ntiEhpxqgwKugMZ6tp/Z/BsEVET+GMBQu9LDtwyH3RDWlJE62MxCLOJTP4iabh/qmTlBBLaVz+02sR/FxwEKzOHEDm4bRMqLdE9GFLp0+d+Km5zLByrty1yX1HC6Is3s/6YgHJxj+wJNQ8mIxm/7VQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E/VjkScQD52H2qqRbAzicggWZY1bJPNjC+5Tk0Md/74=; b=DHb+/Rdna9N0nA+X+d6eQ/V3IjHkrKhYqD9pyFuebnfNSK4rCX3y7expadohWwY+9AwkvfE1e1qxxB+Ma7VIQTR3OMovxKaTSP0rmGCoCqsD2PeuUXCSjBaL2IxrE5u8uke6W3bSTYk1w8TFTDzOq/hM5Ay5OT+x3FWO7sjnU7SGQlLh360zCJusWDh+6TWkPsWSuWML3qO03C/NZtViVB0NzV7hc6ikO0itQ175GC3fs4CQp0FVinoNsBbCMAsM2b+Bf5VlTIhhJEC4MlWwyDc+lKzWRPzVj5Ju4TvIRjs9hArvshbeWQyZCsCqiDEP2xFoBPRuDG/4ueN4qDUUyw== Received: from OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:e9::13) by OSZP286MB0888.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:eb::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.19; Mon, 30 Aug 2021 11:16:47 +0000 Received: from OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM ([fe80::fc56:5558:8b5e:4209]) by OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM ([fe80::fc56:5558:8b5e:4209%5]) with mapi id 15.20.4457.024; Mon, 30 Aug 2021 11:16:47 +0000 From: Xie Ziyao To: ltp@lists.linux.it Date: Mon, 30 Aug 2021 19:16:36 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210830111638.66371-1-ziyaoxie@outlook.com> References: <20210830111638.66371-1-ziyaoxie@outlook.com> X-TMN: [GFNGge3JK2jZehW25Zfzsyln6gpu1yqV] X-ClientProxiedBy: HK2PR04CA0078.apcprd04.prod.outlook.com (2603:1096:202:15::22) To OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:e9::13) X-Microsoft-Original-Message-ID: <20210830111638.66371-2-ziyaoxie@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (14.127.251.239) by HK2PR04CA0078.apcprd04.prod.outlook.com (2603:1096:202:15::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Mon, 30 Aug 2021 11:16:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ad03e45-eb22-493e-5e0c-08d96ba7a7ff X-MS-TrafficTypeDiagnostic: OSZP286MB0888: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N4t93Fd0tpnZ7fYdc1vxptE63TbK2Iki0lfkvX5MnVje/VDemhti0e9t6k28pg9MMFKlQukQ11S4nU3oses27shBy9NTllntfdLAqjvizvKQLQniUCUvrPRpH1Zzx8QIxwUHMUGgiHq8bpBvwqZTh1qikR01WEc/9r6kRrp1Nbc5QSVaft5150pmxkVAaPzZWaBrajEqZz0qUfuqx/5k26H1HtwFm0XN6GGlNswvb16VhmjNujJjA1WKZDPEPmY4aqhqlnQKfClhc3vpZigleZQC7ibqfbMSfyRavTtBwfoFW4KGjCEIiZOApZwFJKRSqPnCpOSqT8id1xj/nnBoIvp9jMFLevQHSIfOD2cW4RkfXh7ndMiFIFJjtA24pnWG244GuJ21GDpKv1qZ5CgMaPuNH9opimubTedRxfCGG7c6993gpa79XrkJQdRRYIeS X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rpGdLcr5/+rRk0ZlTAIMTNfS2Q0TmCFpNrsbYiOklpxmzp5vM8eVMC/6FNlS08q/J5yhm9OjhLzlxjFKpbdr1Nj0garIxDJ201/ZsXn/N4QPhUr/PW3TFzk9hByM0S59KDTZxO0v7ac74KgqSIXrHA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ad03e45-eb22-493e-5e0c-08d96ba7a7ff X-MS-Exchange-CrossTenant-AuthSource: OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2021 11:16:47.3410 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZP286MB0888 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.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,FREEMAIL_FROM,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 1/3] epoll_ctl: Add test for epoll_ctl04 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" Verify that the maximum number of nesting allowed inside epoll sets is 5, otherwise epoll_ctl fails with EINVAL. Signed-off-by: Xie Ziyao --- runtest/syscalls | 1 + .../kernel/syscalls/epoll_ctl/.gitignore | 1 + .../kernel/syscalls/epoll_ctl/epoll_ctl04.c | 69 +++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_ctl/epoll_ctl04.c -- 2.25.1 diff --git a/runtest/syscalls b/runtest/syscalls index 75bb6571d..100ca932f 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -165,6 +165,7 @@ epoll01 epoll-ltp epoll_ctl01 epoll_ctl01 epoll_ctl02 epoll_ctl02 epoll_ctl03 epoll_ctl03 +epoll_ctl04 epoll_ctl04 epoll_wait01 epoll_wait01 epoll_wait02 epoll_wait02 epoll_wait03 epoll_wait03 diff --git a/testcases/kernel/syscalls/epoll_ctl/.gitignore b/testcases/kernel/syscalls/epoll_ctl/.gitignore index 2b50d924c..f78db4002 100644 --- a/testcases/kernel/syscalls/epoll_ctl/.gitignore +++ b/testcases/kernel/syscalls/epoll_ctl/.gitignore @@ -1,3 +1,4 @@ epoll_ctl01 epoll_ctl02 epoll_ctl03 +epoll_ctl04 diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl04.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl04.c new file mode 100644 index 000000000..fce754e96 --- /dev/null +++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl04.c @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) Linux Test Project, 2021 + * Author: Xie Ziyao + */ + +/*\ + * [Description] + * + * Verify that the maximum number of nesting allowed inside epoll sets is 5, + * otherwise epoll_ctl fails with EINVAL. + */ + +#include +#include + +#include "tst_test.h" + +#define MAX_DEPTH 5 + +static int epfd, new_epfd; +static int fd[2]; + +static struct epoll_event events = {.events = EPOLLIN}; + +static void setup(void) +{ + int depth; + + SAFE_PIPE(fd); + + for (depth = 0, epfd = fd[0]; depth < MAX_DEPTH; depth++) { + new_epfd = epoll_create(1); + if (new_epfd == -1) + tst_brk(TBROK | TERRNO, "fail to create epoll instance"); + + events.data.fd = epfd; + if (epoll_ctl(new_epfd, EPOLL_CTL_ADD, epfd, &events)) + tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)"); + + epfd = new_epfd; + } +} + +static void cleanup(void) +{ + if (fd[0]) + SAFE_CLOSE(fd[0]); + + if (fd[1]) + SAFE_CLOSE(fd[1]); +} + +static void verify_epoll_ctl(void) +{ + new_epfd = epoll_create(1); + if (new_epfd == -1) + tst_brk(TBROK | TERRNO, "fail to create epoll instance"); + + events.data.fd = epfd; + TST_EXP_FAIL(epoll_ctl(new_epfd, EPOLL_CTL_ADD, epfd, &events), EINVAL, + "epoll_clt(..., EPOLL_CTL_ADD, ...) with number of nesting is 5"); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = verify_epoll_ctl, +}; From patchwork Mon Aug 30 11:16:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1522193 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 4Gynpj4Fzgz9sT6 for ; Mon, 30 Aug 2021 21:17:17 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4E3303C9B10 for ; Mon, 30 Aug 2021 13:17:13 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) (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 CD3233C2BA4 for ; Mon, 30 Aug 2021 13:16:52 +0200 (CEST) Received: from JPN01-OS2-obe.outbound.protection.outlook.com (mail-os2jpn01olkn0175.outbound.protection.outlook.com [104.47.92.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 22289140044F for ; Mon, 30 Aug 2021 13:16:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QFeMJiLIjlm2gmyiqyzBcHtPszjPo3JVRVUf2kV42Eoj5YiM4uphiT62TmzpVqO7psFAMOo+Ix5swg0Iw+rkKdMi1fOXE2U0Dok2n5G0SDDBQ1PbgcAolaxh1LOL09GVdnTcs7fwxM8HbnblC46SWfHluBTmIG5fsvGBY/jWOGLiBXkmpsbHQgPv85wMWFUOrdNgAmg/3gvh2S6tO/UCEhSFZ/moS7tqc+AG9DErezJN59VCcchpPX/YV37wwgv2EmvI7WFmptekeVnpK4NI2Gw0MVuFuj6aKi5P5IozCxBZ3D5YWN9zlypkMHY4Fj2I/+nydeRVT7clJie76MhN9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r44Km29fmz0Rws3lYxMhDRb4UAZDwvlhVmYiaAybLnc=; b=conrjyySM4jRxouiasjIZopWwHcbql6XsWWT8IKxXSygL1D06O/IEwltRjMoKDszohELRhyvfHHD55XWlxiWS2M6qIKoH/nx7GE+S3hMUYW6fHHPI8o+B5i5vobcn/9Mc74hws3UEbO4lI+IAXqmKkzQbXdK2J6ojDJA2KA762W9zoMZFpos4kAheaJSO9ml3d9atr67bIEjHTXMWV2gTDY81JSUHIutrauv4m/mPRza8NHYtfzpLeDpRpfjoQkH1m7+V8hoKNRm4pe87Dr4mL5CHgesIKntPtlVKoJ6bWnSHw9sdmBLwRJO+wJKUIv+0nrEPswEFMZwana8wNpMeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r44Km29fmz0Rws3lYxMhDRb4UAZDwvlhVmYiaAybLnc=; b=GnmYT/cSd9FEOCSMH07tH0pGOJiUl5QsqBKgLDdHizKWb1SP25v2ccgQZrKY22hJyL0/EOEg7ehdGbOAoX3d/8Oz12j78XRKvsH+DOSLimon3B3GIyRchNhsvDTy8BO3oAQvkmecUobiF/+l64RpNAfd+FqXHhpBEYdx0S2RuYfKo+PVAws2ngfLPQyH33YHMaJL8+kzBMS+sQVjTuaYZ+8D7VAVTpKf+wbthMYZwLCVxoL0kE2E9rKaYMFgCPEFn6PsSHXPeJFa4RpATb4hYv+GscU0eKh0IPJ+r2ncCluFav0F+iUTTqJaMqpx5j4N5vgPFFO8wSta4w8YGBQaLg== Received: from OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:e9::13) by OSZP286MB0888.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:eb::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.19; Mon, 30 Aug 2021 11:16:47 +0000 Received: from OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM ([fe80::fc56:5558:8b5e:4209]) by OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM ([fe80::fc56:5558:8b5e:4209%5]) with mapi id 15.20.4457.024; Mon, 30 Aug 2021 11:16:47 +0000 From: Xie Ziyao To: ltp@lists.linux.it Date: Mon, 30 Aug 2021 19:16:37 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210830111638.66371-1-ziyaoxie@outlook.com> References: <20210830111638.66371-1-ziyaoxie@outlook.com> X-TMN: [IH7U7jatHFvtGAUW7tmZZXd++nnfJPAV] X-ClientProxiedBy: HK2PR04CA0078.apcprd04.prod.outlook.com (2603:1096:202:15::22) To OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:e9::13) X-Microsoft-Original-Message-ID: <20210830111638.66371-3-ziyaoxie@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (14.127.251.239) by HK2PR04CA0078.apcprd04.prod.outlook.com (2603:1096:202:15::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Mon, 30 Aug 2021 11:16:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: baab1909-8de6-4aee-4d7b-08d96ba7a84d X-MS-TrafficTypeDiagnostic: OSZP286MB0888: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qXc8S7QQq2Y4/qBCIMzsgiKq2NCo/cLXRWWZjtet9ynN9Tx4KXHVvysz5SBPmzJ5qqXztMHAmydrbs3MZpR9kg17wOVMFlVm7Eoi7Yc15/h6MRgXcXGBNfydNKrdySkfByUcj/5nF+TOpbNcqzbsGp/X6sypEsyz+BZHVE5hwpP4L4yP1devmfd4AUJV4eH0ZfdOfGIk3uplgongrDNaFn47Q5jPNEk6LXJpRCyt9YL50eHbW1JFTZBMDgdzf/8bF08XPNjN4oQGBFoSRL7qwxA39Gt7eJ2oEJ6CyjtncrW6twjrcfj74A7jIaoKHTEWWxaXn0oVOwrYFn+ZGKubBmD6Nz0MUoEMmWpK+lphpWUpDBIxxH4QgfS7K1t3fgd/uSsxwP3Q4e9icrSS3awwe004i73k+9Pt1Ys/pIRaU9nyBmka4233ydy2sXtzGi6y X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: o+ipdZciEPOEqWgSzi2NIim+kQ0TdOx5XuLjffCA9tGvxkg259D/HVW1JXjlnExE9JbOatf4BZVfYFr1qrG0mxSYXsybVrNtBkLm7wjB4IdUJVxIzx5SVjaeU02UhLCZobEjORCBNZxYu0UPHDMwYg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: baab1909-8de6-4aee-4d7b-08d96ba7a84d X-MS-Exchange-CrossTenant-AuthSource: OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2021 11:16:47.8378 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZP286MB0888 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.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,FREEMAIL_FROM,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 2/3] epoll_ctl: Add test for epoll_ctl05 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" Verify that epoll_ctl() fails with ELOOP if fd refers to an epoll instance and this EPOLL_CTL_ADD operation would result in a circular loop of epoll instances monitoring one another. Signed-off-by: Xie Ziyao --- runtest/syscalls | 1 + .../kernel/syscalls/epoll_ctl/.gitignore | 1 + .../kernel/syscalls/epoll_ctl/epoll_ctl05.c | 71 +++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 testcases/kernel/syscalls/epoll_ctl/epoll_ctl05.c -- 2.25.1 diff --git a/runtest/syscalls b/runtest/syscalls index 100ca932f..4c6b75dfa 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -166,6 +166,7 @@ epoll_ctl01 epoll_ctl01 epoll_ctl02 epoll_ctl02 epoll_ctl03 epoll_ctl03 epoll_ctl04 epoll_ctl04 +epoll_ctl05 epoll_ctl05 epoll_wait01 epoll_wait01 epoll_wait02 epoll_wait02 epoll_wait03 epoll_wait03 diff --git a/testcases/kernel/syscalls/epoll_ctl/.gitignore b/testcases/kernel/syscalls/epoll_ctl/.gitignore index f78db4002..3e05f2e1f 100644 --- a/testcases/kernel/syscalls/epoll_ctl/.gitignore +++ b/testcases/kernel/syscalls/epoll_ctl/.gitignore @@ -2,3 +2,4 @@ epoll_ctl01 epoll_ctl02 epoll_ctl03 epoll_ctl04 +epoll_ctl05 diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl05.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl05.c new file mode 100644 index 000000000..d03009cf3 --- /dev/null +++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl05.c @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) Linux Test Project, 2021 + * Author: Xie Ziyao + */ + +/*\ + * [Description] + * + * Verify that epoll_ctl() fails with ELOOP if fd refers to an epoll instance + * and this EPOLL_CTL_ADD operation would result in a circular loop of epoll + * instances monitoring one another. + */ + +#include +#include + +#include "tst_test.h" + +#define MAX_DEPTH 5 + +static int epfd, origin_epfd, new_epfd; +static int fd[2]; + +static struct epoll_event events = {.events = EPOLLIN}; + +static void setup(void) +{ + int i; + + SAFE_PIPE(fd); + + for (i = 0, epfd = fd[0]; i < MAX_DEPTH; i++, epfd = new_epfd) { + new_epfd = epoll_create(1); + if (new_epfd == -1) + tst_brk(TBROK | TERRNO, "fail to create epoll instance"); + + if (i == 0) + origin_epfd = new_epfd; + + events.data.fd = epfd; + if (epoll_ctl(new_epfd, EPOLL_CTL_ADD, epfd, &events)) + tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_ADD, ...)"); + } + + events.data.fd = fd[0]; + if (epoll_ctl(origin_epfd, EPOLL_CTL_DEL, fd[0], &events)) + tst_brk(TBROK | TERRNO, "epoll_clt(..., EPOLL_CTL_DEL, ...)"); +} + +static void cleanup(void) +{ + if (fd[0]) + SAFE_CLOSE(fd[0]); + + if (fd[1]) + SAFE_CLOSE(fd[1]); +} + +static void verify_epoll_ctl(void) +{ + events.data.fd = epfd; + TST_EXP_FAIL(epoll_ctl(origin_epfd, EPOLL_CTL_ADD, epfd, &events), + ELOOP, "epoll_clt(..., EPOLL_CTL_ADD, ...)"); +} + +static struct tst_test test = { + .setup = setup, + .cleanup = cleanup, + .test_all = verify_epoll_ctl, +}; From patchwork Mon Aug 30 11:16:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xie Ziyao X-Patchwork-Id: 1522194 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 4Gynpv4sBjz9sT6 for ; Mon, 30 Aug 2021 21:17:27 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 2A98D3C9AB7 for ; Mon, 30 Aug 2021 13:17:25 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) (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 9454B3C8DA7 for ; Mon, 30 Aug 2021 13:16:53 +0200 (CEST) Received: from JPN01-OS2-obe.outbound.protection.outlook.com (mail-os2jpn01olkn0175.outbound.protection.outlook.com [104.47.92.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id E46EA1400437 for ; Mon, 30 Aug 2021 13:16:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B0xjT1VGJpH0RctYt+/GUxteG2XDI+Vujuqx1O5hsAsgp0UX22BZjgMIcOLZb2NaB8bBxRv3//+zlBI2UArAgzOU9LGpEolLGZfI22R1bW5TRWutNkomnpss2qXcGIOJUTNAJM7tmqOt42ThnDU4Tzl52+mar6wckZZQakihH/Qbuy4O3COGboQd2LN+GhvVdHFS9E3xOtMHGqoQTikRtx65DwP5gGjB0BxubeajWOjST52bjSjCn9OAjFztBZC81orXD3rJergasp5BV5nk+T0UQ7DPm5siBOfrYvCGm4kOaM5+a/sXD3afZ1owpdNuKyeuZosaYq8IUsKrrbRtAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GnuQRKsI/p3UC015Ecd+VLJECUZD9zwSpQ1HPtpOCS4=; b=nHnHx+6gra0mN3QmMtsTyKDeSs1FbCF7QMIGKB0KRkPAA+MvqDIILpfNeipcqzr+2gnz/ihiGy5fSKzE9GSs9GmzTBhrnT0GtRDxFdk0eGs81jmGfadAtFPHkDI4Fs5yIyof23m9MQwlSWQu2cfe7rfnoQP8pFqkRMk3G+iI0iczcTTA3MHJf/DAmo/uKOWyyHDhTOlunw4lB/Zi96m1iQ1+i+17XkYgU9K3nQIBqT/w7PySC3InuktI/fDWEy3j5ZZmSz2d1miJML/pkihKWiF6I2jVdB7VWT3zYVA4S/aXLydf74V2H7zhPp4aTE4c3ehyvAvTpJevtNddpu/YUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GnuQRKsI/p3UC015Ecd+VLJECUZD9zwSpQ1HPtpOCS4=; b=HeE4jY42CprCqCQzWc+fPfMhDfjM4nteRT+zf0/rOWcYzvs5St3OT0bKMWOx4B1d4ZXbX18NVxYzpQt90k8YF64YIdRVMj+NK9YXtV5n1G8HESJKXRfZOW0pTnJ+FUJf/DQPFg/sX4bZIAo1ZWTMuWNWlrALDuFCSwK69QlpfAlcxcGtPQSCy3/PnON91t1Nax/1Usc42vekpR+TXdLHBgL1NTHWmpYyljO9PHReSiRqS3UMgx5h8IC3ootcn7X5WsdVnSbWWzIMwX/ZiYPPt6ba8ayQosnuti3XrUbmSwPHiydNCqC1oYD78l5epeeYYq/np+gg8sD/Xi+AYhUChw== Received: from OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:e9::13) by OSZP286MB0888.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:eb::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.19; Mon, 30 Aug 2021 11:16:48 +0000 Received: from OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM ([fe80::fc56:5558:8b5e:4209]) by OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM ([fe80::fc56:5558:8b5e:4209%5]) with mapi id 15.20.4457.024; Mon, 30 Aug 2021 11:16:48 +0000 From: Xie Ziyao To: ltp@lists.linux.it Date: Mon, 30 Aug 2021 19:16:38 +0800 Message-ID: X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210830111638.66371-1-ziyaoxie@outlook.com> References: <20210830111638.66371-1-ziyaoxie@outlook.com> X-TMN: [v0RO/sfi8qmLAqKcRlUHs/cPej8hDPns] X-ClientProxiedBy: HK2PR04CA0078.apcprd04.prod.outlook.com (2603:1096:202:15::22) To OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:e9::13) X-Microsoft-Original-Message-ID: <20210830111638.66371-4-ziyaoxie@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (14.127.251.239) by HK2PR04CA0078.apcprd04.prod.outlook.com (2603:1096:202:15::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17 via Frontend Transport; Mon, 30 Aug 2021 11:16:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8f77f793-d9bb-4a53-7404-08d96ba7a89c X-MS-TrafficTypeDiagnostic: OSZP286MB0888: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dYM40MrJjvBcmAj25ew3Cs9JKUdVYqls7W+QpySwtQlkiJIyEiUCaCr6Gxg8lQa44Idi+KYfx12cj+jDipvo6CCBiS9hD+jSVg8I3waMFt1Tg1rM93mQfiroy8bHQr4K+98GdrK3deOhF+9RXRuN5OH8cMRuxekQCucV6axhgEDZil92x5gBnW9xBsBiOWBUL9afvdZLwzB/14vukuLhiEUJegQEnQTHfQijhTQbDmsiG35Slpb+TBk2Qccd3evUbz1a55zlh6MqAwX62mJ/PEO0lEhXXefq4sbUtrVEMHNOU9XJIw4JLlyTL7ZhSALtdGElq6CHPDhwhx35edxebxXk7xN7xyqRdBau/3WZ1fVfMBz47koSw7H+Fwi8Xzd2xAvONW4y4LXkNPpwFvm7MH4kFOx0qHxfD9pHpgPp4e59ZSZyCTZhOVoIM5yK2Del X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aghGL1cbmXGuJXB15pazn4iv122/77RNVAJAxb81JHyintMlmD1kKH0/fRYCu8apu1aMBgyu2EqOuGOoj423lW9tIbq9g/l8o+0V9m8WaWIR3n8SuaRO8ckdf0ottB1iFi/ivyJEexh3D8whKWu0rQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f77f793-d9bb-4a53-7404-08d96ba7a89c X-MS-Exchange-CrossTenant-AuthSource: OSZP286MB0871.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2021 11:16:48.3725 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZP286MB0888 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.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,FREEMAIL_FROM,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH 3/3] epoll_ctl02: Add test for fd not supporting epoll 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" Verify that epoll_ctl() fails with EPERM if fd does not support epoll. This error can occur if fd refers to, for example, a regular file or a directory. Signed-off-by: Xie Ziyao --- testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c index 4872fcacb..fe16ad1cb 100644 --- a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c +++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c @@ -7,9 +7,10 @@ /*\ * [Description] * - * Verify that epoll_cnt() fails with: + * Verify that epoll_ctl() fails with: * * - EBADF if epfd is an invalid fd. + * - EPERM if fd does not support epoll. * - EBADF if fd is an invalid fd. * - EINVAL if op is not supported. * - EINVAL if fd is the same as epfd. @@ -25,7 +26,7 @@ #include "tst_test.h" static int epfd; -static int fd[2]; +static int fd[2], unsupported_fd; static int inv = -1; static struct epoll_event events[2] = { @@ -42,6 +43,7 @@ static struct testcase { const char *desc; } tc[] = { {&inv, EPOLL_CTL_ADD, &fd[1], &events[1], EBADF, "epfd is an invalid fd"}, + {&epfd, EPOLL_CTL_ADD, &unsupported_fd, &events[1], EPERM, "fd does not support epoll"}, {&epfd, EPOLL_CTL_ADD, &inv, &events[1], EBADF, "fd is an invalid fd"}, {&epfd, -1, &fd[1], &events[1], EINVAL, "op is not supported"}, {&epfd, EPOLL_CTL_ADD, &epfd, &events[1], EINVAL, "fd is the same as epfd"}, @@ -53,6 +55,8 @@ static struct testcase { static void setup(void) { + unsupported_fd = SAFE_OPEN(".", O_RDONLY|O_DIRECTORY, 0); + epfd = epoll_create(2); if (epfd == -1) tst_brk(TBROK | TERRNO, "fail to create epoll instance");