* [LTP] [PATCH v2] epoll_ctl06: Fix BPF map on old kernels
@ 2026-09-30 7:23 Andrea Cervesato
2026-09-30 8:10 ` [LTP] " linuxtestproject.agent
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Andrea Cervesato @ 2026-09-30 7:23 UTC (permalink / raw)
To: Linux Test Project
From: Andrea Cervesato <andrea.cervesato@suse.com>
BPF map file descriptors gained a poll callback in upstream kernel
5.8. Without that callback, EPOLL_CTL_ADD fails with EPERM, while the
test expected it to succeed.
Detect BPF map poll support at runtime so that older kernels with
backported support are handled correctly as well.
Fixes: c4c0ca4c749e ("syscalls: Add epoll_ctl06")
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
tst_tmpdir.c:309: TINFO: Using /var/tmp/LTP_epoXsyHnT as tmpdir (btrfs filesystem)
tst_test.c:2067: TINFO: LTP version: 20260529
tst_test.c:2070: TINFO: Tested kernel: 4.4.140-491.1.TDC.gedc1884-default #1 SMP Wed Sep 23 11:06:41 UTC 2026 (edc1884) x86_64
tst_kconfig.c:90: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:760: TINFO: CONFIG_FAULT_INJECTION kernel option detected which might slow the execution
tst_test.c:1897: TINFO: Overall timeout per run is 0h 02m 00s
epoll_ctl06.c:57: TPASS: epoll_ctl() on file : EPERM (1)
epoll_ctl06.c:57: TPASS: epoll_ctl() on O_PATH file : EBADF (9)
epoll_ctl06.c:57: TPASS: epoll_ctl() on directory : EPERM (1)
epoll_ctl06.c:57: TPASS: epoll_ctl() on /dev/zero : EPERM (1)
epoll_ctl06.c:57: TPASS: epoll_ctl() on /proc/self/maps : EPERM (1)
epoll_ctl06.c:57: TPASS: epoll_ctl() on pipe read end passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on pipe write end passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on unix socket passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on inet socket passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on epoll passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on eventfd passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on signalfd passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on timerfd passed
tst_fd.c:144: TCONF: pidfd_open(): ENOSYS (38)
epoll_ctl06.c:57: TPASS: epoll_ctl() on fanotify passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on inotify passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on userfaultfd passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on perf event passed
tst_fd.c:200: TCONF: Skipping io uring: ENOSYS (38)
epoll_ctl06.c:57: TFAIL: epoll_ctl() on bpf map failed: EPERM (1)
tst_fd.c:225: TCONF: Skipping fsopen: ENOSYS (38)
tst_fd.c:234: TCONF: Skipping fspick: ENOSYS (38)
tst_fd.c:243: TCONF: Skipping open_tree: ENOSYS (38)
epoll_ctl06.c:57: TPASS: epoll_ctl() on memfd : EPERM (1)
tst_fd.c:261: TCONF: Skipping memfd secret: ENOSYS (38)
Summary:
passed 18
failed 1
broken 0
skipped 6
warnings 0
---
Changes in v2:
- skip after 5.8 kernel
- Link to v1: https://lore.kernel.org/20260929-fix_epoll_bpf-v1-1-39b19ab043c7@suse.com
---
testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c
index 69321582f..9c6cd2460 100644
--- a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c
+++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c
@@ -12,19 +12,23 @@
* poll file operation are expected to succeed. The rest must fail with:
*
* - EPERM for fds that are valid but lack poll support (regular files,
- * directories, /dev/zero, /proc files, memfd).
+ * directories, /dev/zero, /proc files, memfd and BPF maps on kernels
+ * without BPF map poll support).
* - EBADF for fds that are not usable for I/O (O_PATH, open_tree).
*/
+#include <poll.h>
#include <sys/epoll.h>
#include "tst_test.h"
#include "tst_epoll.h"
#include "tst_fd.h"
-static int exp_errno(enum tst_fd_type type)
+static int exp_errno(struct tst_fd *fd)
{
- switch (type) {
+ struct pollfd pfd = {.fd = fd->fd, .events = POLLIN};
+
+ switch (fd->type) {
case TST_FD_FILE:
case TST_FD_DIR:
case TST_FD_DEV_ZERO:
@@ -37,6 +41,16 @@ static int exp_errno(enum tst_fd_type type)
case TST_FD_PATH:
case TST_FD_OPEN_TREE:
return EBADF;
+ case TST_FD_BPF_MAP:
+ if (tst_kvercmp(5, 8, 0) >= 0)
+ return 0;
+
+ /*
+ * The BPF poll callback returns POLLERR for array maps. Without
+ * the callback, poll() returns the default readiness mask.
+ */
+ SAFE_POLL(&pfd, 1, 0);
+ return pfd.revents & POLLERR ? 0 : EPERM;
default:
return 0;
}
@@ -50,7 +64,7 @@ static void run(void)
TST_FD_FOREACH(fd) {
efd = SAFE_EPOLL_CREATE1(0);
ev.data.fd = fd.fd;
- err = exp_errno(fd.type);
+ err = exp_errno(&fd);
TST_EXP_PASS_OR_FAIL(epoll_ctl(efd, EPOLL_CTL_ADD,
fd.fd, &ev), err,
---
base-commit: 1cbe713ca9d55bed7e4d52c6f2216ba3e2089346
change-id: 20260929-fix_epoll_bpf-5e472da8e63c
Best regards,
--
Andrea Cervesato <andrea.cervesato@suse.com>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [LTP] epoll_ctl06: Fix BPF map on old kernels
2026-09-30 7:23 [LTP] [PATCH v2] epoll_ctl06: Fix BPF map on old kernels Andrea Cervesato
@ 2026-09-30 8:10 ` linuxtestproject.agent
2026-09-30 9:57 ` [LTP] [PATCH v2] " Petr Vorel
2026-09-30 13:45 ` Martin Doucha
2 siblings, 0 replies; 6+ messages in thread
From: linuxtestproject.agent @ 2026-09-30 8:10 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi Andrea,
On Wed Sep 30 09:23:19 2026 +0200, Andrea Cervesato wrote:
> epoll_ctl06: Fix BPF map on old kernels
Verdict - Reviewed
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v2] epoll_ctl06: Fix BPF map on old kernels
2026-09-30 7:23 [LTP] [PATCH v2] epoll_ctl06: Fix BPF map on old kernels Andrea Cervesato
2026-09-30 8:10 ` [LTP] " linuxtestproject.agent
@ 2026-09-30 9:57 ` Petr Vorel
2026-09-30 13:45 ` Martin Doucha
2 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2026-09-30 9:57 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: Linux Test Project
Hi Andrea,
> BPF map file descriptors gained a poll callback in upstream kernel
> 5.8. Without that callback, EPOLL_CTL_ADD fails with EPERM, while the
> test expected it to succeed.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
LGTM, thanks!
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v2] epoll_ctl06: Fix BPF map on old kernels
2026-09-30 7:23 [LTP] [PATCH v2] epoll_ctl06: Fix BPF map on old kernels Andrea Cervesato
2026-09-30 8:10 ` [LTP] " linuxtestproject.agent
2026-09-30 9:57 ` [LTP] [PATCH v2] " Petr Vorel
@ 2026-09-30 13:45 ` Martin Doucha
2026-09-30 14:08 ` Petr Vorel
2 siblings, 1 reply; 6+ messages in thread
From: Martin Doucha @ 2026-09-30 13:45 UTC (permalink / raw)
To: Andrea Cervesato, Linux Test Project
Hi,
look good to me.
Reviewed-by: Martin Doucha <mdoucha@suse.cz>
On 9/30/26 09:23, Andrea Cervesato wrote:
> From: Andrea Cervesato <andrea.cervesato@suse.com>
>
> BPF map file descriptors gained a poll callback in upstream kernel
> 5.8. Without that callback, EPOLL_CTL_ADD fails with EPERM, while the
> test expected it to succeed.
>
> Detect BPF map poll support at runtime so that older kernels with
> backported support are handled correctly as well.
>
> Fixes: c4c0ca4c749e ("syscalls: Add epoll_ctl06")
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> tst_tmpdir.c:309: TINFO: Using /var/tmp/LTP_epoXsyHnT as tmpdir (btrfs filesystem)
> tst_test.c:2067: TINFO: LTP version: 20260529
> tst_test.c:2070: TINFO: Tested kernel: 4.4.140-491.1.TDC.gedc1884-default #1 SMP Wed Sep 23 11:06:41 UTC 2026 (edc1884) x86_64
> tst_kconfig.c:90: TINFO: Parsing kernel config '/proc/config.gz'
> tst_kconfig.c:760: TINFO: CONFIG_FAULT_INJECTION kernel option detected which might slow the execution
> tst_test.c:1897: TINFO: Overall timeout per run is 0h 02m 00s
> epoll_ctl06.c:57: TPASS: epoll_ctl() on file : EPERM (1)
> epoll_ctl06.c:57: TPASS: epoll_ctl() on O_PATH file : EBADF (9)
> epoll_ctl06.c:57: TPASS: epoll_ctl() on directory : EPERM (1)
> epoll_ctl06.c:57: TPASS: epoll_ctl() on /dev/zero : EPERM (1)
> epoll_ctl06.c:57: TPASS: epoll_ctl() on /proc/self/maps : EPERM (1)
> epoll_ctl06.c:57: TPASS: epoll_ctl() on pipe read end passed
> epoll_ctl06.c:57: TPASS: epoll_ctl() on pipe write end passed
> epoll_ctl06.c:57: TPASS: epoll_ctl() on unix socket passed
> epoll_ctl06.c:57: TPASS: epoll_ctl() on inet socket passed
> epoll_ctl06.c:57: TPASS: epoll_ctl() on epoll passed
> epoll_ctl06.c:57: TPASS: epoll_ctl() on eventfd passed
> epoll_ctl06.c:57: TPASS: epoll_ctl() on signalfd passed
> epoll_ctl06.c:57: TPASS: epoll_ctl() on timerfd passed
> tst_fd.c:144: TCONF: pidfd_open(): ENOSYS (38)
> epoll_ctl06.c:57: TPASS: epoll_ctl() on fanotify passed
> epoll_ctl06.c:57: TPASS: epoll_ctl() on inotify passed
> epoll_ctl06.c:57: TPASS: epoll_ctl() on userfaultfd passed
> epoll_ctl06.c:57: TPASS: epoll_ctl() on perf event passed
> tst_fd.c:200: TCONF: Skipping io uring: ENOSYS (38)
> epoll_ctl06.c:57: TFAIL: epoll_ctl() on bpf map failed: EPERM (1)
> tst_fd.c:225: TCONF: Skipping fsopen: ENOSYS (38)
> tst_fd.c:234: TCONF: Skipping fspick: ENOSYS (38)
> tst_fd.c:243: TCONF: Skipping open_tree: ENOSYS (38)
> epoll_ctl06.c:57: TPASS: epoll_ctl() on memfd : EPERM (1)
> tst_fd.c:261: TCONF: Skipping memfd secret: ENOSYS (38)
>
> Summary:
> passed 18
> failed 1
> broken 0
> skipped 6
> warnings 0
> ---
> Changes in v2:
> - skip after 5.8 kernel
> - Link to v1: https://lore.kernel.org/20260929-fix_epoll_bpf-v1-1-39b19ab043c7@suse.com
> ---
> testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c | 22 ++++++++++++++++++----
> 1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c
> index 69321582f..9c6cd2460 100644
> --- a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c
> +++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c
> @@ -12,19 +12,23 @@
> * poll file operation are expected to succeed. The rest must fail with:
> *
> * - EPERM for fds that are valid but lack poll support (regular files,
> - * directories, /dev/zero, /proc files, memfd).
> + * directories, /dev/zero, /proc files, memfd and BPF maps on kernels
> + * without BPF map poll support).
> * - EBADF for fds that are not usable for I/O (O_PATH, open_tree).
> */
>
> +#include <poll.h>
> #include <sys/epoll.h>
>
> #include "tst_test.h"
> #include "tst_epoll.h"
> #include "tst_fd.h"
>
> -static int exp_errno(enum tst_fd_type type)
> +static int exp_errno(struct tst_fd *fd)
> {
> - switch (type) {
> + struct pollfd pfd = {.fd = fd->fd, .events = POLLIN};
> +
> + switch (fd->type) {
> case TST_FD_FILE:
> case TST_FD_DIR:
> case TST_FD_DEV_ZERO:
> @@ -37,6 +41,16 @@ static int exp_errno(enum tst_fd_type type)
> case TST_FD_PATH:
> case TST_FD_OPEN_TREE:
> return EBADF;
> + case TST_FD_BPF_MAP:
> + if (tst_kvercmp(5, 8, 0) >= 0)
> + return 0;
> +
> + /*
> + * The BPF poll callback returns POLLERR for array maps. Without
> + * the callback, poll() returns the default readiness mask.
> + */
> + SAFE_POLL(&pfd, 1, 0);
> + return pfd.revents & POLLERR ? 0 : EPERM;
> default:
> return 0;
> }
> @@ -50,7 +64,7 @@ static void run(void)
> TST_FD_FOREACH(fd) {
> efd = SAFE_EPOLL_CREATE1(0);
> ev.data.fd = fd.fd;
> - err = exp_errno(fd.type);
> + err = exp_errno(&fd);
>
> TST_EXP_PASS_OR_FAIL(epoll_ctl(efd, EPOLL_CTL_ADD,
> fd.fd, &ev), err,
>
> ---
> base-commit: 1cbe713ca9d55bed7e4d52c6f2216ba3e2089346
> change-id: 20260929-fix_epoll_bpf-5e472da8e63c
>
> Best regards,
> --
> Andrea Cervesato <andrea.cervesato@suse.com>
>
>
--
Martin Doucha mdoucha@suse.cz
SW Quality Engineer
SUSE LINUX, s.r.o.
CORSO IIa
Krizikova 148/34
186 00 Prague 8
Czech Republic
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH] epoll_ctl06: Fix BPF map on old kernels
@ 2026-09-29 14:15 Andrea Cervesato
2026-09-29 17:49 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 6+ messages in thread
From: Andrea Cervesato @ 2026-09-29 14:15 UTC (permalink / raw)
To: Linux Test Project
From: Andrea Cervesato <andrea.cervesato@suse.com>
BPF map file descriptors gained a poll callback in upstream kernel
5.8. Without that callback, EPOLL_CTL_ADD fails with EPERM, while the
test expected it to succeed.
Detect BPF map poll support at runtime so that older kernels with
backported support are handled correctly as well.
Fixes: c4c0ca4c749e ("syscalls: Add epoll_ctl06")
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
tst_tmpdir.c:309: TINFO: Using /var/tmp/LTP_epoXsyHnT as tmpdir (btrfs filesystem)
tst_test.c:2067: TINFO: LTP version: 20260529
tst_test.c:2070: TINFO: Tested kernel: 4.4.140-491.1.TDC.gedc1884-default #1 SMP Wed Sep 23 11:06:41 UTC 2026 (edc1884) x86_64
tst_kconfig.c:90: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:760: TINFO: CONFIG_FAULT_INJECTION kernel option detected which might slow the execution
tst_test.c:1897: TINFO: Overall timeout per run is 0h 02m 00s
epoll_ctl06.c:57: TPASS: epoll_ctl() on file : EPERM (1)
epoll_ctl06.c:57: TPASS: epoll_ctl() on O_PATH file : EBADF (9)
epoll_ctl06.c:57: TPASS: epoll_ctl() on directory : EPERM (1)
epoll_ctl06.c:57: TPASS: epoll_ctl() on /dev/zero : EPERM (1)
epoll_ctl06.c:57: TPASS: epoll_ctl() on /proc/self/maps : EPERM (1)
epoll_ctl06.c:57: TPASS: epoll_ctl() on pipe read end passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on pipe write end passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on unix socket passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on inet socket passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on epoll passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on eventfd passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on signalfd passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on timerfd passed
tst_fd.c:144: TCONF: pidfd_open(): ENOSYS (38)
epoll_ctl06.c:57: TPASS: epoll_ctl() on fanotify passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on inotify passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on userfaultfd passed
epoll_ctl06.c:57: TPASS: epoll_ctl() on perf event passed
tst_fd.c:200: TCONF: Skipping io uring: ENOSYS (38)
epoll_ctl06.c:57: TFAIL: epoll_ctl() on bpf map failed: EPERM (1)
tst_fd.c:225: TCONF: Skipping fsopen: ENOSYS (38)
tst_fd.c:234: TCONF: Skipping fspick: ENOSYS (38)
tst_fd.c:243: TCONF: Skipping open_tree: ENOSYS (38)
epoll_ctl06.c:57: TPASS: epoll_ctl() on memfd : EPERM (1)
tst_fd.c:261: TCONF: Skipping memfd secret: ENOSYS (38)
Summary:
passed 18
failed 1
broken 0
skipped 6
warnings 0
---
testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c
index 69321582f..e85e9e259 100644
--- a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c
+++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl06.c
@@ -12,19 +12,23 @@
* poll file operation are expected to succeed. The rest must fail with:
*
* - EPERM for fds that are valid but lack poll support (regular files,
- * directories, /dev/zero, /proc files, memfd).
+ * directories, /dev/zero, /proc files, memfd and BPF maps on kernels
+ * without BPF map poll support).
* - EBADF for fds that are not usable for I/O (O_PATH, open_tree).
*/
+#include <poll.h>
#include <sys/epoll.h>
#include "tst_test.h"
#include "tst_epoll.h"
#include "tst_fd.h"
-static int exp_errno(enum tst_fd_type type)
+static int exp_errno(struct tst_fd *fd)
{
- switch (type) {
+ struct pollfd pfd = {.fd = fd->fd, .events = POLLIN};
+
+ switch (fd->type) {
case TST_FD_FILE:
case TST_FD_DIR:
case TST_FD_DEV_ZERO:
@@ -37,6 +41,13 @@ static int exp_errno(enum tst_fd_type type)
case TST_FD_PATH:
case TST_FD_OPEN_TREE:
return EBADF;
+ case TST_FD_BPF_MAP:
+ /*
+ * The BPF poll callback returns POLLERR for array maps. Without
+ * the callback, poll() returns the default readiness mask.
+ */
+ SAFE_POLL(&pfd, 1, 0);
+ return pfd.revents & POLLERR ? 0 : EPERM;
default:
return 0;
}
@@ -50,7 +61,7 @@ static void run(void)
TST_FD_FOREACH(fd) {
efd = SAFE_EPOLL_CREATE1(0);
ev.data.fd = fd.fd;
- err = exp_errno(fd.type);
+ err = exp_errno(&fd);
TST_EXP_PASS_OR_FAIL(epoll_ctl(efd, EPOLL_CTL_ADD,
fd.fd, &ev), err,
---
base-commit: 0596b09f22f449cb300e8ad2d08d8b186f551a05
change-id: 20260929-fix_epoll_bpf-5e472da8e63c
Best regards,
--
Andrea Cervesato <andrea.cervesato@suse.com>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-09-30 14:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-30 7:23 [LTP] [PATCH v2] epoll_ctl06: Fix BPF map on old kernels Andrea Cervesato
2026-09-30 8:10 ` [LTP] " linuxtestproject.agent
2026-09-30 9:57 ` [LTP] [PATCH v2] " Petr Vorel
2026-09-30 13:45 ` Martin Doucha
2026-09-30 14:08 ` Petr Vorel
-- strict thread matches above, loose matches on Subject: below --
2026-09-29 14:15 [LTP] [PATCH] " Andrea Cervesato
2026-09-29 17:49 ` [LTP] " linuxtestproject.agent
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.