Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ax25: add link layer header validation function

As variable length protocol, AX25 fails link layer header validation
tests based on a minimum length. header_ops.validate allows protocols
to validate headers that are shorter than hard_header_len. Implement
this callback for AX25.

See also http://comments.gmane.org/gmane.linux.network/401064

Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Willem de Bruijn and committed by
David S. Miller
ea47781c 2793a23a

+15
+15
net/ax25/ax25_ip.c
··· 228 228 } 229 229 #endif 230 230 231 + static bool ax25_validate_header(const char *header, unsigned int len) 232 + { 233 + ax25_digi digi; 234 + 235 + if (!len) 236 + return false; 237 + 238 + if (header[0]) 239 + return true; 240 + 241 + return ax25_addr_parse(header + 1, len - 1, NULL, NULL, &digi, NULL, 242 + NULL); 243 + } 244 + 231 245 const struct header_ops ax25_header_ops = { 232 246 .create = ax25_hard_header, 247 + .validate = ax25_validate_header, 233 248 }; 234 249 235 250 EXPORT_SYMBOL(ax25_header_ops);