* [LTP] [PATCH v3] gethostname02: Accept EOVERFLOW on alpha
@ 2026-06-03 1:49 panzhe
2026-06-03 9:31 ` Cyril Hrubis
0 siblings, 1 reply; 6+ messages in thread
From: panzhe @ 2026-06-03 1:49 UTC (permalink / raw)
To: ltp
On alpha glibc's gethostname() directly calls the kernel
syscall and sets errno to EOVERFLOW when the buffer is
too small, because the kernel truncates silently and the
string is not null terminated.
On the other hand, the generic posix implementation used
on x86_64 sets ENAMETOOLONG in this case.
Fix this by accepting both errnos.
Closes: https://github.com/linux-test-project/ltp/issues/1319
Signed-off-by: panzhe <panzhe@kylinos.cn>
---
testcases/kernel/syscalls/gethostname/gethostname02.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/gethostname/gethostname02.c b/testcases/kernel/syscalls/gethostname/gethostname02.c
index c56fcb800..23ab25010 100644
--- a/testcases/kernel/syscalls/gethostname/gethostname02.c
+++ b/testcases/kernel/syscalls/gethostname/gethostname02.c
@@ -7,7 +7,7 @@
/*\
* Verify that gethostname(2) fails with
*
- * - ENAMETOOLONG when len is smaller than the actual size
+ * - ENAMETOOLONG or EOVERFLOW when len is smaller than the actual size
*/
#include "tst_test.h"
@@ -16,12 +16,14 @@ static void verify_gethostname(void)
{
char hostname[HOST_NAME_MAX + 1];
int real_length;
+ const int exp_errnos[] = {ENAMETOOLONG, EOVERFLOW};
SAFE_GETHOSTNAME(hostname, sizeof(hostname));
real_length = strlen(hostname);
- TST_EXP_FAIL(gethostname(hostname, real_length - 1), ENAMETOOLONG,
- "len is smaller than the actual size");
+ TST_EXP_FAIL_ARR(gethostname(hostname, real_length - 1),
+ exp_errnos, ARRAY_SIZE(exp_errnos),
+ "len is smaller than the actual size");
}
static struct tst_test test = {
--
2.25.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v3] gethostname02: Accept EOVERFLOW on alpha
2026-06-03 1:49 panzhe
@ 2026-06-03 9:31 ` Cyril Hrubis
0 siblings, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2026-06-03 9:31 UTC (permalink / raw)
To: panzhe; +Cc: ltp
Hi!
> On alpha glibc's gethostname() directly calls the kernel
> syscall and sets errno to EOVERFLOW when the buffer is
> too small, because the kernel truncates silently and the
> string is not null terminated.
>
> On the other hand, the generic posix implementation used
> on x86_64 sets ENAMETOOLONG in this case.
>
> Fix this by accepting both errnos.
Looking at man gethostname it's not supposed to return EOVERFLOW. I'm
not sure that we want to work around this in the tests.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v3] gethostname02: Accept EOVERFLOW on alpha
[not found] <--compose>
@ 2026-06-04 7:26 ` panzhe
2026-06-04 8:43 ` Cyril Hrubis
2026-06-09 8:11 ` Andrea Cervesato via ltp
0 siblings, 2 replies; 6+ messages in thread
From: panzhe @ 2026-06-04 7:26 UTC (permalink / raw)
To: chrubis; +Cc: ltp
Hi Cyril,
Thanks for your review.
The ENAMETOOLONG note in man describes the mainstream glibc implementation based on uname(2), but alpha has its own arch-specific implementation calling raw gethostname syscall and returning EOVERFLOW.
Alpha glibc source:
https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/alpha/gethostname.c.html
POSIX does not specify required errno here, this is existing upstream glibc behavior. I suggest accepting both errnos to resolve alpha test failures.
Regards,
panzhe
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v3] gethostname02: Accept EOVERFLOW on alpha
2026-06-04 7:26 ` [LTP] [PATCH v3] gethostname02: Accept EOVERFLOW on alpha panzhe
@ 2026-06-04 8:43 ` Cyril Hrubis
2026-06-09 8:11 ` Andrea Cervesato via ltp
1 sibling, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2026-06-04 8:43 UTC (permalink / raw)
To: panzhe; +Cc: ltp
Hi!
> The ENAMETOOLONG note in man describes the mainstream glibc implementation based on uname(2), but alpha has its own arch-specific implementation calling raw gethostname syscall and returning EOVERFLOW.
> Alpha glibc source:
> https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/alpha/gethostname.c.html
This really looks like a inconsistency in glibc. I suggest to ask a
question if this should be fixed in glibc on libc-alpha mailing list
first. Please CC ltp mailing list when you ask this question.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v3] gethostname02: Accept EOVERFLOW on alpha
2026-06-04 7:26 ` [LTP] [PATCH v3] gethostname02: Accept EOVERFLOW on alpha panzhe
2026-06-04 8:43 ` Cyril Hrubis
@ 2026-06-09 8:11 ` Andrea Cervesato via ltp
2026-06-09 9:53 ` Cyril Hrubis
1 sibling, 1 reply; 6+ messages in thread
From: Andrea Cervesato via ltp @ 2026-06-09 8:11 UTC (permalink / raw)
To: panzhe; +Cc: ltp
Hi Panzhe,
> Hi Cyril,
>
> Thanks for your review.
>
> The ENAMETOOLONG note in man describes the mainstream glibc implementation based on uname(2), but alpha has its own arch-specific implementation calling raw gethostname syscall and returning EOVERFLOW.
> Alpha glibc source:
> https://codebrowser.dev/glibc/glibc/sysdeps/unix/sysv/linux/alpha/gethostname.c.html
>
> POSIX does not specify required errno here, this is existing upstream glibc behavior. I suggest accepting both errnos to resolve alpha test failures.
>
>
> Regards,
> panzhe
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
for context, it was useful to add the following patch to the discussion:
https://patchwork.ozlabs.org/project/glibc/patch/20260604092410.185621-1-panzhe@kylinos.cn/
For me it's ok, but we need to see this patch being merged to glibc, before
updating LTP upstream. Please ping us when this will be official.
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
andrea.cervesato@suse.com
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH v3] gethostname02: Accept EOVERFLOW on alpha
2026-06-09 8:11 ` Andrea Cervesato via ltp
@ 2026-06-09 9:53 ` Cyril Hrubis
0 siblings, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2026-06-09 9:53 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> for context, it was useful to add the following patch to the discussion:
> https://patchwork.ozlabs.org/project/glibc/patch/20260604092410.185621-1-panzhe@kylinos.cn/
>
> For me it's ok, but we need to see this patch being merged to glibc, before
> updating LTP upstream. Please ping us when this will be official.
Actually if the patch gets merged into glibc there is nothing to be done
in LTP as the patch aligns the glibc implementation on alpha with our
test expectations.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-09 9:53 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <--compose>
2026-06-04 7:26 ` [LTP] [PATCH v3] gethostname02: Accept EOVERFLOW on alpha panzhe
2026-06-04 8:43 ` Cyril Hrubis
2026-06-09 8:11 ` Andrea Cervesato via ltp
2026-06-09 9:53 ` Cyril Hrubis
2026-06-03 1:49 panzhe
2026-06-03 9:31 ` Cyril Hrubis
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.