Commit bd09d9a
selftests/landlock: Fix TCP bind(AF_UNSPEC) test case
The nominal error code for bind(AF_UNSPEC) on an IPv6 socket
is -EAFNOSUPPORT, not -EINVAL. -EINVAL is only returned when
the supplied address struct is too short, which happens to be
the case in current selftests because they treat AF_UNSPEC
like IPv4 sockets do: as an alias for AF_INET (which is a
16-byte struct instead of the 24 bytes required by IPv6
sockets).
Make the union large enough for any address (by adding struct
sockaddr_storage to the union), and make AF_UNSPEC addresses
large enough for any family.
Test for -EAFNOSUPPORT instead, and add a dedicated test case
for truncated inputs with -EINVAL.
Fixes: a549d05 ("selftests/landlock: Add network tests")
Signed-off-by: Matthieu Buffet <matthieu@buffet.re>
Link: https://lore.kernel.org/r/20251027190726.626244-2-matthieu@buffet.re
Signed-off-by: Mickaël Salaün <mic@digikod.net>1 parent e4d82cb commit bd09d9a
2 files changed
Lines changed: 16 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
240 | 241 | | |
241 | 242 | | |
242 | 243 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
124 | 128 | | |
125 | 129 | | |
126 | 130 | | |
| |||
758 | 762 | | |
759 | 763 | | |
760 | 764 | | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
761 | 770 | | |
762 | 771 | | |
763 | 772 | | |
| |||
766 | 775 | | |
767 | 776 | | |
768 | 777 | | |
| 778 | + | |
| 779 | + | |
769 | 780 | | |
770 | 781 | | |
771 | 782 | | |
| |||
792 | 803 | | |
793 | 804 | | |
794 | 805 | | |
| 806 | + | |
| 807 | + | |
795 | 808 | | |
796 | 809 | | |
797 | 810 | | |
| |||
801 | 814 | | |
802 | 815 | | |
803 | 816 | | |
804 | | - | |
| 817 | + | |
| 818 | + | |
805 | 819 | | |
806 | 820 | | |
807 | 821 | | |
| |||
0 commit comments