{"id":2222382,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2222382/?format=json","web_url":"http://patchwork.ozlabs.org/project/ltp/patch/20260411110405.7330-1-always.starving0@gmail.com/","project":{"id":59,"url":"http://patchwork.ozlabs.org/api/1.1/projects/59/?format=json","name":"Linux Test Project development","link_name":"ltp","list_id":"ltp.lists.linux.it","list_email":"ltp@lists.linux.it","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260411110405.7330-1-always.starving0@gmail.com>","date":"2026-04-11T11:04:03","name":"[v2] close: add test for double close EBADF","commit_ref":null,"pull_url":null,"state":"changes-requested","archived":false,"hash":"604607c1b2444a4cc27c9395b7889fa0a7fe2f9b","submitter":{"id":92589,"url":"http://patchwork.ozlabs.org/api/1.1/people/92589/?format=json","name":"Jinseok Kim","email":"always.starving0@gmail.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/ltp/patch/20260411110405.7330-1-always.starving0@gmail.com/mbox/","series":[{"id":499548,"url":"http://patchwork.ozlabs.org/api/1.1/series/499548/?format=json","web_url":"http://patchwork.ozlabs.org/project/ltp/list/?series=499548","date":"2026-04-11T11:04:03","name":"[v2] close: add test for double close EBADF","version":2,"mbox":"http://patchwork.ozlabs.org/series/499548/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2222382/comments/","check":"success","checks":"http://patchwork.ozlabs.org/api/patches/2222382/checks/","tags":{},"headers":{"Return-Path":"<ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>","X-Original-To":["incoming@patchwork.ozlabs.org","ltp@lists.linux.it"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","ltp@picard.linux.it"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=qHfE2JN/;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it\n (client-ip=2001:1418:10:5::2; helo=picard.linux.it;\n envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it;\n receiver=patchwork.ozlabs.org)"],"Received":["from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4ft9mR4wPdz1yCx\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 11 Apr 2026 21:04:39 +1000 (AEST)","from picard.linux.it (localhost [IPv6:::1])\n\tby picard.linux.it (Postfix) with ESMTP id BAA803E23BD\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 11 Apr 2026 13:04:36 +0200 (CEST)","from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature ECDSA (secp384r1))\n (No client certificate requested)\n by picard.linux.it (Postfix) with ESMTPS id 653CF3CF0FF\n for <ltp@lists.linux.it>; Sat, 11 Apr 2026 13:04:33 +0200 (CEST)","from mail-pf1-x442.google.com (mail-pf1-x442.google.com\n [IPv6:2607:f8b0:4864:20::442])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by in-6.smtp.seeweb.it (Postfix) with ESMTPS id CF13F1400062\n for <ltp@lists.linux.it>; Sat, 11 Apr 2026 13:04:32 +0200 (CEST)","by mail-pf1-x442.google.com with SMTP id\n d2e1a72fcca58-82cebbdbdccso1436951b3a.1\n for <ltp@lists.linux.it>; Sat, 11 Apr 2026 04:04:32 -0700 (PDT)","from localhost.localdomain ([59.16.109.172])\n by smtp.gmail.com with ESMTPSA id\n d2e1a72fcca58-82f0c4b251esm5242114b3a.37.2026.04.11.04.04.29\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Sat, 11 Apr 2026 04:04:30 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1775905471; x=1776510271; darn=lists.linux.it;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=a8eBP1YjoBogaBX/+Bnbn/aJMUD2+nA+csx2I54oe4Y=;\n b=qHfE2JN/8OBdNaJe+3QvEpI/EWJVUylbOKI7UOOgmc6vjXqLggCdE0WVPMRcOPZNWv\n iGcpdwT3df4ZzsZl+th7J/9uVfxZ/8xmXHwnTd0ZO8UvnXkjx0FQdGlN1FBlEAumKE5l\n k8Sx0+6rrqtExZwoyYrdrHP6MeojBF4xsiFBytbhonIf/hXgcP/y5779xAlgzqfMdGT2\n IFQg5gBJtnzKNJL97LII3/ZQbWqbeWefey5xKpJfbMLy3FNbBsILHp2Bsg/Z1vgjasTq\n g6PxCeU6x3x2iFyBNi4OrnbgFSxdU5SpSPVD6PYLkqBZMsaMLewI8F/t1QL7q1UQWXvX\n ohJA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775905471; x=1776510271;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=a8eBP1YjoBogaBX/+Bnbn/aJMUD2+nA+csx2I54oe4Y=;\n b=YCUT12w6/yCKdlqNqRVa24bQWJyWc9N/WZ7R28zPU9+FHae+EBt5BnrS8j7fmvcnfi\n lSN6COI56XzeforojM5w8sr9nZcrDK/u1++DWytliynmELilR2FyADfY0fQ14oGVR2O2\n K6JtLscw7P/SjZYj6g28L49cmoWMQyVvPXSx5VAxVIko3aLZBAP6BIkFH8a20MUY7LLp\n Q8Kn7slg0eyC8yfYFk9bywntoHadxb/jH5uQTyH5hMrEvySR3mcdcnW5Cw3oVqZuf8V+\n 3AzS2lNELDG11ofUXNZtQccz/xA/pqrWkZDoCbPyXU80Qvh2KhZ6IFht7QfrLoDtt3bL\n Z/4w==","X-Gm-Message-State":"AOJu0Yw5zixcLH6bDsASqDiaT62levnIUL1Ou0SAdCoJnQY7na2xtvh8\n ixdbRrH0fWRCLXh0VVkBUKKjC1Wc/xBsYSDtyEmSaSWHg+ToZtuCtm0=","X-Gm-Gg":"AeBDievn9HS/ngOvpJMmCKMIm09rtd1zbTKz5AqEf951kP9+6Ac/Q0e7okZoRc7zNyX\n KLu7zuEAGjO1IRleKk+18z3hoygaMDoBnAq58UHHKttftKzL6rQA6bJSqnOJd82b93HM217WpOb\n P4n5Gi7pC43k2cDqDkWjgYaXlDYRqhV6+rrtGOqLUVQL1E/p2C8jRCGONu5hVRJCNLXbfgE1vc+\n cjZaF6k7DdmIbsdUb1acQFlHYe7O5DsiRSYY5uRDT3YapBs/qhZ610WJ4XW0MxKP2yMVK57LfUP\n UfMUbRjqpngJfWXcoBJ1Ss2nj4DZV/Ot4oed36GTClM8zB4F7C450K6VcPiOl94/hQWCfyXNBAd\n 87D9TFpgYc+76O+2NFYncfzw8+ZK9TQFYTVJa+FbkKfbYOx7VaLuEKNRnVMvffIXyZZc6u6taMG\n oJi7hyW2kxYrmihanGXKfmZOw+jLy/DpjNLi6uFvvKtw==","X-Received":"by 2002:a05:6a00:1f18:b0:82a:76ab:3279 with SMTP id\n d2e1a72fcca58-82dd8a1d540mr9089419b3a.4.1775905470956;\n Sat, 11 Apr 2026 04:04:30 -0700 (PDT)","From":"Jinseok Kim <always.starving0@gmail.com>","To":"pvorel@suse.cz","Date":"Sat, 11 Apr 2026 20:04:03 +0900","Message-ID":"<20260411110405.7330-1-always.starving0@gmail.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260409081546.GB96667@pevik>","References":"<20260409081546.GB96667@pevik>","MIME-Version":"1.0","X-Spam-Status":"No, score=0.3 required=7.0 tests=DKIM_SIGNED,DKIM_VALID,\n DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,\n SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=disabled version=4.0.1","X-Spam-Checker-Version":"SpamAssassin 4.0.1 (2024-03-25) on in-6.smtp.seeweb.it","X-Virus-Scanned":"clamav-milter 1.0.9 at in-6.smtp.seeweb.it","X-Virus-Status":"Clean","Subject":"[LTP] [PATCH v2] close: add test for double close EBADF","X-BeenThere":"ltp@lists.linux.it","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"Linux Test Project <ltp.lists.linux.it>","List-Unsubscribe":"<https://lists.linux.it/options/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=unsubscribe>","List-Archive":"<http://lists.linux.it/pipermail/ltp/>","List-Post":"<mailto:ltp@lists.linux.it>","List-Help":"<mailto:ltp-request@lists.linux.it?subject=help>","List-Subscribe":"<https://lists.linux.it/listinfo/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=subscribe>","Cc":"ltp@lists.linux.it","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it","Sender":"\"ltp\" <ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>"},"content":"Verify that calling close() on an already closed file descriptor fails\nwith EBADF.\n\nThis test adds coverage for a common state transition case where a\npreviously valid file descriptor becomes invalid after close().\n\nSigned-off-by: Jinseok Kim <always.starving0@gmail.com>\n---\nChanges in v2:\n- Add additional test coverage to close02 instead of creating a separate\n  close03 test.\n- Link to v1: https://lore.kernel.org/ltp/20260406133134.17238-2-always.starving0@gmail.com\n---\n testcases/kernel/syscalls/close/close02.c | 42 ++++++++++++++++++++---\n 1 file changed, 38 insertions(+), 4 deletions(-)\n\n--\n2.43.0","diff":"diff --git a/testcases/kernel/syscalls/close/close02.c b/testcases/kernel/syscalls/close/close02.c\nindex 617c48237..768361e56 100644\n--- a/testcases/kernel/syscalls/close/close02.c\n+++ b/testcases/kernel/syscalls/close/close02.c\n@@ -5,17 +5,51 @@\n  */\n\n /*\\\n- * Call close(-1) and expects it to return EBADF.\n+ * Verify :manpage:`close(2)` failure cases:\n+ *\n+ * 1) close(-1) returns EBADF.\n+ * 2) closing the same fd twice returns EBADF on the second call.\n  */\n\n #include <errno.h>\n+#include <fcntl.h>\n+\n #include \"tst_test.h\"\n\n-static void run(void)\n+enum case_type {\n+\tINVALID_FD,\n+\tDOUBLE_CLOSE,\n+};\n+\n+static struct tcase {\n+\tconst char *desc;\n+\tenum case_type type;\n+} tcases[] = {\n+\t{ \"close(-1)\", INVALID_FD },\n+\t{ \"close same fd twice\", DOUBLE_CLOSE },\n+};\n+\n+static void verify_close(unsigned int i)\n {\n-\tTST_EXP_FAIL(close(-1), EBADF);\n+\tint fd;\n+\tstruct tcase *tc = &tcases[i];\n+\n+\tswitch (tc->type) {\n+\tcase INVALID_FD:\n+\t\tTST_EXP_FAIL(close(-1), EBADF, \"%s\", tc->desc);\n+\t\tbreak;\n+\n+\tcase DOUBLE_CLOSE:\n+\t\tfd = SAFE_OPEN(\"close02\", O_CREAT, 0600);\n+\n+\t\tTST_EXP_PASS(close(fd), \"%s: first close()\", tc->desc);\n+\t\tTST_EXP_FAIL(close(fd), EBADF, \"%s: second close()\", tc->desc);\n+\t\tbreak;\n+\t}\n }\n\n static struct tst_test test = {\n-\t.test_all = run,\n+\t.needs_tmpdir = 1,\n+\t.tcnt = ARRAY_SIZE(tcases),\n+\t.test = verify_close,\n };\n","prefixes":["v2"]}