Mon Nov 7 08:32:35 2022 UTC ()
Increase sdl_data so that more then IFNAMSIZ bytes are available (again).

COMPAT_9 is not required.

 - The getifaddrs(3) function has no problem. The routing message has no
   problem because struct rtm_msglen has rtm_msglen and we can get the next
   message using with it. There is no any kernel data structure which has
   struct sockaddr_dl foobadr[xxx] array.

 - A data passed from userland and a kernel data are compared with
   sockaddr_cmp(). The return value is used to check if the size is
   inadequate or not.

 - In the kernel, sdl_len is not directly used for the length of memcpy()
   but the sockaddr_dl_measure() is used for it.


(msaitoh)
diff -r1.30 -r1.31 src/sys/net/if_dl.h

cvs diff -r1.30 -r1.31 src/sys/net/if_dl.h (expand / switch to unified diff)

--- src/sys/net/if_dl.h 2022/10/27 00:25:11 1.30
+++ src/sys/net/if_dl.h 2022/11/07 08:32:35 1.31
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_dl.h,v 1.30 2022/10/27 00:25:11 msaitoh Exp $ */ 1/* $NetBSD: if_dl.h,v 1.31 2022/11/07 08:32:35 msaitoh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1990, 1993 4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -58,31 +58,31 @@ @@ -58,31 +58,31 @@
58typedef __sa_family_t sa_family_t; 58typedef __sa_family_t sa_family_t;
59#define sa_family_t __sa_family_t 59#define sa_family_t __sa_family_t
60#endif 60#endif
61#ifndef socklen_t 61#ifndef socklen_t
62typedef __socklen_t socklen_t; 62typedef __socklen_t socklen_t;
63#define socklen_t __socklen_t 63#define socklen_t __socklen_t
64#endif 64#endif
65 65
66struct dl_addr { 66struct dl_addr {
67 uint8_t dl_type; /* interface type */ 67 uint8_t dl_type; /* interface type */
68 uint8_t dl_nlen; /* interface name length, no trailing 0 reqd. */ 68 uint8_t dl_nlen; /* interface name length, no trailing 0 reqd. */
69 uint8_t dl_alen; /* link level address length */ 69 uint8_t dl_alen; /* link level address length */
70 uint8_t dl_slen; /* link layer selector length */ 70 uint8_t dl_slen; /* link layer selector length */
71 /* 71 char dl_data[24]; /*
72 * minimum work area, can be larger; contains both if name 72 * minimum work area, can be larger; contains
73 * and ll address 73 * both if name and ll address; big enough for
74 */ 74 * IFNAMSIZ plus 8byte ll addr.
75 char dl_data[12]; 75 */
76}; 76};
77 77
78/* 78/*
79 * Structure of a Link-Level sockaddr: 79 * Structure of a Link-Level sockaddr:
80 */ 80 */
81struct sockaddr_dl { 81struct sockaddr_dl {
82 uint8_t sdl_len; /* Total length of sockaddr */ 82 uint8_t sdl_len; /* Total length of sockaddr */
83 sa_family_t sdl_family; /* AF_LINK */ 83 sa_family_t sdl_family; /* AF_LINK */
84 uint16_t sdl_index; /* if != 0, system given index for interface */ 84 uint16_t sdl_index; /* if != 0, system given index for interface */
85 struct dl_addr sdl_addr; 85 struct dl_addr sdl_addr;
86#define sdl_type sdl_addr.dl_type 86#define sdl_type sdl_addr.dl_type
87#define sdl_nlen sdl_addr.dl_nlen 87#define sdl_nlen sdl_addr.dl_nlen
88#define sdl_alen sdl_addr.dl_alen 88#define sdl_alen sdl_addr.dl_alen