This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 2f4d017bb60232387fa04dc3136b66e5646ffc09 Author: Xiang Xiao <[email protected]> AuthorDate: Fri Sep 11 02:21:36 2026 +0800 fs/aio: add configurable AIO_LISTIO_MAX limit lio_listio() never validated 'nent' against {AIO_LISTIO_MAX}, so a batch larger than the documented limit was silently accepted, and the hard-coded _POSIX_AIO_LISTIO_MAX value of 2 was too small for real workloads (LTP uses 10 entries per call). Add the FS_AIO_LISTIO_MAX Kconfig option (default 10), use it for _POSIX_AIO_LISTIO_MAX in include/limits.h, validate 'nent' in lio_listio(), and report the limit through sysconf(_SC_AIO_LISTIO_MAX). Signed-off-by: tengshuangshuang <[email protected]> --- fs/aio/Kconfig | 12 ++++++++++++ fs/aio/lio_listio.c | 3 ++- include/limits.h | 2 +- libs/libc/unistd/lib_sysconf.c | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/fs/aio/Kconfig b/fs/aio/Kconfig index fa09b9a38cc..11d74133e43 100644 --- a/fs/aio/Kconfig +++ b/fs/aio/Kconfig @@ -11,6 +11,18 @@ config FS_AIO Enable support for asynchronous I/O. This selection enables the interfaces declared in include/aio.h. +config FS_AIO_LISTIO_MAX + int "Maximum number of AIO operations in listio" + default 10 + ---help--- + This option sets the maximum number of asynchronous I/O (AIO) operations + that can be submitted in a single call to lio_listio(). + + This value defines the upper limit for the 'nent' parameter in + lio_listio(mode, aiocb_list, nent, sevp). Increasing this value allows + more operations to be queued. + Default: 10 + if FS_AIO config FS_NAIOC diff --git a/fs/aio/lio_listio.c b/fs/aio/lio_listio.c index 1edbf7c7e25..196677529d4 100644 --- a/fs/aio/lio_listio.c +++ b/fs/aio/lio_listio.c @@ -334,7 +334,8 @@ int lio_listio(int mode, FAR struct aiocb *restrict const list[restrict], int ret; int i; - if (mode != LIO_WAIT && mode != LIO_NOWAIT) + if (nent < 0 || nent > AIO_LISTIO_MAX || + (mode != LIO_WAIT && mode != LIO_NOWAIT)) { set_errno(EINVAL); return ERROR; diff --git a/include/limits.h b/include/limits.h index 59357fe83f3..a2da21497b2 100644 --- a/include/limits.h +++ b/include/limits.h @@ -188,7 +188,7 @@ /* Required for asynchronous I/O */ -#define _POSIX_AIO_LISTIO_MAX 2 +#define _POSIX_AIO_LISTIO_MAX CONFIG_FS_AIO_LISTIO_MAX #define _POSIX_AIO_MAX 1 /* Required for POSIX message passing */ diff --git a/libs/libc/unistd/lib_sysconf.c b/libs/libc/unistd/lib_sysconf.c index 428482aea52..20655721c1b 100644 --- a/libs/libc/unistd/lib_sysconf.c +++ b/libs/libc/unistd/lib_sysconf.c @@ -266,6 +266,9 @@ long sysconf(int name) case _SC_THREAD_THREADS_MAX: return UINT8_MAX; + case _SC_AIO_LISTIO_MAX: + return AIO_LISTIO_MAX; + default: #if 0 /* Assume valid but not implemented for the time being */ errcode = EINVAL;
