{"id":2230259,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2230259/?format=json","web_url":"http://patchwork.ozlabs.org/project/ltp/patch/20260429142016.1483-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":"<20260429142016.1483-1-always.starving0@gmail.com>","date":"2026-04-29T14:20:14","name":"[v6] close02: add test for double close EBADF","commit_ref":null,"pull_url":null,"state":"needs-review-ack","archived":false,"hash":"2cf0be1abe97032f4ffbe32a03c29e2600161cd9","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/20260429142016.1483-1-always.starving0@gmail.com/mbox/","series":[{"id":502078,"url":"http://patchwork.ozlabs.org/api/1.1/series/502078/?format=json","web_url":"http://patchwork.ozlabs.org/project/ltp/list/?series=502078","date":"2026-04-29T14:20:14","name":"[v6] close02: add test for double close EBADF","version":6,"mbox":"http://patchwork.ozlabs.org/series/502078/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2230259/comments/","check":"warning","checks":"http://patchwork.ozlabs.org/api/patches/2230259/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=P3HtWQ0w;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it\n (client-ip=213.254.12.146; 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 [213.254.12.146])\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 4g5KGc21SGz1xqf\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 30 Apr 2026 00:20:55 +1000 (AEST)","from picard.linux.it (localhost [IPv6:::1])\n\tby picard.linux.it (Postfix) with ESMTP id 423153E49C2\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 16:20:53 +0200 (CEST)","from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it\n [IPv6:2001:4b78:1:20::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 19C5A3C66CA\n for <ltp@lists.linux.it>; Wed, 29 Apr 2026 16:20:47 +0200 (CEST)","from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com\n [IPv6:2607:f8b0:4864:20::1042])\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 9C6771400C79\n for <ltp@lists.linux.it>; Wed, 29 Apr 2026 16:20:46 +0200 (CEST)","by mail-pj1-x1042.google.com with SMTP id\n 98e67ed59e1d1-35da01fc0baso7984961a91.2\n for <ltp@lists.linux.it>; Wed, 29 Apr 2026 07:20:46 -0700 (PDT)","from localhost.localdomain ([211.196.223.197])\n by smtp.gmail.com with ESMTPSA id\n 98e67ed59e1d1-364a0303f52sm4154623a91.16.2026.04.29.07.20.43\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Wed, 29 Apr 2026 07:20:44 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1777472445; x=1778077245; 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=20+RWMRnNuoaXzYfRoID/2A5zx8Sdc5C8yJorq9Uqpo=;\n b=P3HtWQ0wl5HF7gj6bJdTvSmeeKkgV2OvPg94VgVzmO0ye9tavadUqCa+FlunL/qCkk\n 7ISGWR4v6fRb44ybcqfJ9awCZJLaBHyA/Sk/ti3h1tveEiDCwRsfUo/8fzyNka5PFQKV\n 4QXIM39B50Qir92IgWrTMYAsEyEphb4jVevaCHIpQ75lDZ0tm+8tWs7gwiEbWmxti9Lu\n zdEpDGFenhEV+wzNFFKHDwUNdBU78aORr7IYcFroAbit26Wu1Nf6nSMoG4HE8AUUs1H9\n jERl2kTI0/aqhx9QfwW/0Qxkpkod64e4rpeDpurk3Kfy5+UB43eV7zuPXsiJCpdz+L03\n XFgg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777472445; x=1778077245;\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=20+RWMRnNuoaXzYfRoID/2A5zx8Sdc5C8yJorq9Uqpo=;\n b=TCRjSTa099Z8btPNQ+01nm5k4iMzPiNKz/938QdZpA2q2AkuXL5htMOoDGonA005hX\n L53V3G+9zc0e+GAw01znzWDu78gtzjg2dDY6OnAjAf/vMI7JmlMTg+Ht3n3kBxB3/MBK\n LSkvzdwtKKlj+lCc+EI55S63u9Vjzd8k0h1sLMBJu5ocgyCMhFt7/So7DhhVcqbbpCuO\n sunm9x7gP+GWH4PWlwrWLtnxusv5HeExKtfm48L6JfuDDloAOwkM7d425lp3AsXkbfsI\n 3evf5hkfmZH9L3K95X1kCrxcTG5uK72i4S9TWLGjVZ7rgK2xeSqlPD7eqEy8kPlHntRG\n xAtw==","X-Gm-Message-State":"AOJu0YxUWNpmhWdEu/Syo5i//EqKQwC5YJnwEAwZ6WaJ8SL2ZPsxAUMP\n MSvhqMvx8bhRmvJ1oqxLSysXoakV7NgLP3XPuMRrOFz69D/RRGydh3U=","X-Gm-Gg":"AeBDievtb1hDh3PJf+75E5bPqbnNxR6Hf/BkU25hTCsqweLxClGFVKqA1WKqZ7qO7Hn\n XOV2YeuiAToNBkEhY6RpyKJULgWzb1LZZupUNYdvhOJPrUaKqDzbgxpconvj8zs1T6mPe+7DS37\n auhfLsZioQgq2vsbQF3AZ1RHBLBpoWRXL3UgUp4Hou+IUiJzrHSZSzidISaVqC5qy3a8ejownMq\n P9J+rhxLQfFpAunHXhr6TX8k4P++GPFNiG5+515Js5YnN3c3Te95w0jAbaWT/lUyjKh1k31qzIL\n 67XhRFLbcEQxvfEq7tmGYEbSx+qxcozS/UkdT9vGujAPZ7tG1QNn1YjjKz2KZ08Eeh1uzbyaslB\n plrZw8rK/khSdayMY1exWr+//xX14Twd6JhTvRL0GFI25JaTaVEhGK3Bc7xIpwgNfv1jmCdzKnE\n HhMfWYSlbVxAw1TMCOEhXhLUOPW7c/+Hyxfl29GAFK0fu0FD+Nu+jNipE=","X-Received":"by 2002:a17:90b:4a81:b0:35e:57cf:c0ae with SMTP id\n 98e67ed59e1d1-36491fc1658mr8207810a91.7.1777472444911;\n Wed, 29 Apr 2026 07:20:44 -0700 (PDT)","From":"Jinseok Kim <always.starving0@gmail.com>","To":"pvorel@suse.cz","Date":"Wed, 29 Apr 2026 23:20:14 +0900","Message-ID":"<20260429142016.1483-1-always.starving0@gmail.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20260422114126.GD402660@pevik>","References":"<20260422114126.GD402660@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 v6] close02: 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 v6:\n- Use a pointer for fd, referencing the bind01.c approach\n- Link to v5 : https://lore.kernel.org/ltp/20260421144246.2046-1-always.starving0@gmail.com\n\nChanges in v5:\n- Change file descriptor as static\n- Link to v4 : https://lore.kernel.org/ltp/20260416125554.2920-1-always.starving0@gmail.com\n\nChanges in v4:\n- Remove enum, add fd/expected errno in tcases, and move preparation\n  to setup().\n- Link to v3: https://lore.kernel.org/ltp/20260413165457.1349-1-always.starving0@gmail.com\n\nChanges in v3:\n- Add O_RDWR flag to SAFE_OPEN\n- Link to v2: https://lore.kernel.org/ltp/20260411110405.7330-1-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 | 36 ++++++++++++++++++++---\n 1 file changed, 32 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..c54789e7e 100644\n--- a/testcases/kernel/syscalls/close/close02.c\n+++ b/testcases/kernel/syscalls/close/close02.c\n@@ -5,17 +5,45 @@\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+static int fd_invalid = -1;\n+static int fd_closed = -1;\n+\n+static struct tcase {\n+\tconst char *desc;\n+\tint *fd;\n+\tint exp_errno;\n+} tcases[] = {\n+\t{ \"close(-1)\", &fd_invalid, EBADF },\n+\t{ \"close same fd twice\", &fd_closed, EBADF },\n+};\n+\n+static void verify_close(unsigned int i)\n+{\n+\tstruct tcase *tc = &tcases[i];\n+\n+\tTST_EXP_FAIL(close(*tc->fd), tc->exp_errno, \"%s\", tc->desc);\n+}\n+\n+static void setup(void)\n {\n-\tTST_EXP_FAIL(close(-1), EBADF);\n+\tfd_closed = SAFE_OPEN(\"close02\", O_CREAT | O_RDWR, 0600);\n+\tSAFE_CLOSE(fd_closed);\n }\n\n static struct tst_test test = {\n-\t.test_all = run,\n+\t.needs_tmpdir = 1,\n+\t.setup = setup,\n+\t.tcnt = ARRAY_SIZE(tcases),\n+\t.test = verify_close,\n };\n","prefixes":["v6"]}