blob: 21ef3998b9d9916a98959c791e9cd955ac960710 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Thomas Grafbfa83a92005-11-10 02:25:51 +01002/*
3 * NETLINK Netlink attributes
4 *
5 * Authors: Thomas Graf <tgraf@suug.ch>
6 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
7 */
8
Paul Gortmaker8bc3bcc2011-11-16 21:29:17 -05009#include <linux/export.h>
Thomas Grafbfa83a92005-11-10 02:25:51 +010010#include <linux/kernel.h>
11#include <linux/errno.h>
12#include <linux/jiffies.h>
Thomas Grafbfa83a92005-11-10 02:25:51 +010013#include <linux/skbuff.h>
14#include <linux/string.h>
15#include <linux/types.h>
16#include <net/netlink.h>
17
David Ahern6e237d02017-12-06 20:09:12 -080018/* For these data types, attribute length should be exactly the given
19 * size. However, to maintain compatibility with broken commands, if the
20 * attribute length does not match the expected size a warning is emitted
21 * to the user that the command is sending invalid data and needs to be fixed.
22 */
David Ahern28033ae2017-11-07 21:59:40 -080023static const u8 nla_attr_len[NLA_TYPE_MAX+1] = {
Thomas Grafbfa83a92005-11-10 02:25:51 +010024 [NLA_U8] = sizeof(u8),
25 [NLA_U16] = sizeof(u16),
26 [NLA_U32] = sizeof(u32),
27 [NLA_U64] = sizeof(u64),
Julian Anastasov9eca2eb2012-08-25 22:47:57 +000028 [NLA_S8] = sizeof(s8),
29 [NLA_S16] = sizeof(s16),
30 [NLA_S32] = sizeof(s32),
31 [NLA_S64] = sizeof(s64),
Thomas Grafbfa83a92005-11-10 02:25:51 +010032};
33
David Ahern28033ae2017-11-07 21:59:40 -080034static const u8 nla_attr_minlen[NLA_TYPE_MAX+1] = {
David Ahern6e237d02017-12-06 20:09:12 -080035 [NLA_U8] = sizeof(u8),
36 [NLA_U16] = sizeof(u16),
37 [NLA_U32] = sizeof(u32),
38 [NLA_U64] = sizeof(u64),
David Ahern28033ae2017-11-07 21:59:40 -080039 [NLA_MSECS] = sizeof(u64),
40 [NLA_NESTED] = NLA_HDRLEN,
David Ahern6e237d02017-12-06 20:09:12 -080041 [NLA_S8] = sizeof(s8),
42 [NLA_S16] = sizeof(s16),
43 [NLA_S32] = sizeof(s32),
44 [NLA_S64] = sizeof(s64),
David Ahern28033ae2017-11-07 21:59:40 -080045};
46
Johannes Berg7690aa12020-04-30 22:13:06 +020047/*
48 * Nested policies might refer back to the original
49 * policy in some cases, and userspace could try to
50 * abuse that and recurse by nesting in the right
51 * ways. Limit recursion to avoid this problem.
52 */
53#define MAX_POLICY_RECURSION_DEPTH 10
54
55static int __nla_validate_parse(const struct nlattr *head, int len, int maxtype,
56 const struct nla_policy *policy,
57 unsigned int validate,
58 struct netlink_ext_ack *extack,
59 struct nlattr **tb, unsigned int depth);
60
Jamal Hadi Salim64c83d82017-07-30 13:24:49 -040061static int validate_nla_bitfield32(const struct nlattr *nla,
Johannes Berg47a14942020-04-30 22:13:05 +020062 const u32 valid_flags_mask)
Jamal Hadi Salim64c83d82017-07-30 13:24:49 -040063{
64 const struct nla_bitfield32 *bf = nla_data(nla);
Jamal Hadi Salim64c83d82017-07-30 13:24:49 -040065
Johannes Berg48fde902018-09-26 11:15:31 +020066 if (!valid_flags_mask)
Jamal Hadi Salim64c83d82017-07-30 13:24:49 -040067 return -EINVAL;
68
69 /*disallow invalid bit selector */
Johannes Berg47a14942020-04-30 22:13:05 +020070 if (bf->selector & ~valid_flags_mask)
Jamal Hadi Salim64c83d82017-07-30 13:24:49 -040071 return -EINVAL;
72
73 /*disallow invalid bit values */
Johannes Berg47a14942020-04-30 22:13:05 +020074 if (bf->value & ~valid_flags_mask)
Jamal Hadi Salim64c83d82017-07-30 13:24:49 -040075 return -EINVAL;
76
77 /*disallow valid bit values that are not selected*/
78 if (bf->value & ~bf->selector)
79 return -EINVAL;
80
81 return 0;
82}
83
Johannes Berg1501d132018-09-26 11:15:34 +020084static int nla_validate_array(const struct nlattr *head, int len, int maxtype,
85 const struct nla_policy *policy,
Johannes Berg8cb08172019-04-26 14:07:28 +020086 struct netlink_ext_ack *extack,
Johannes Berg7690aa12020-04-30 22:13:06 +020087 unsigned int validate, unsigned int depth)
Johannes Berg1501d132018-09-26 11:15:34 +020088{
89 const struct nlattr *entry;
90 int rem;
91
92 nla_for_each_attr(entry, head, len, rem) {
93 int ret;
94
95 if (nla_len(entry) == 0)
96 continue;
97
98 if (nla_len(entry) < NLA_HDRLEN) {
99 NL_SET_ERR_MSG_ATTR(extack, entry,
100 "Array element too short");
101 return -ERANGE;
102 }
103
Johannes Berg7690aa12020-04-30 22:13:06 +0200104 ret = __nla_validate_parse(nla_data(entry), nla_len(entry),
105 maxtype, policy, validate, extack,
106 NULL, depth + 1);
Johannes Berg1501d132018-09-26 11:15:34 +0200107 if (ret < 0)
108 return ret;
109 }
110
111 return 0;
112}
113
Johannes Bergd06a09b2020-04-30 22:13:08 +0200114static int nla_validate_int_range_unsigned(const struct nla_policy *pt,
115 const struct nlattr *nla,
116 struct netlink_ext_ack *extack)
Johannes Berg3e48be02018-09-27 11:28:35 +0200117{
Johannes Bergd06a09b2020-04-30 22:13:08 +0200118 struct netlink_range_validation _range = {
119 .min = 0,
120 .max = U64_MAX,
121 }, *range = &_range;
122 u64 value;
Johannes Berg3e48be02018-09-27 11:28:35 +0200123
Johannes Bergd06a09b2020-04-30 22:13:08 +0200124 WARN_ON_ONCE(pt->validation_type != NLA_VALIDATE_RANGE_PTR &&
125 (pt->min < 0 || pt->max < 0));
126
127 switch (pt->validation_type) {
128 case NLA_VALIDATE_RANGE:
129 range->min = pt->min;
130 range->max = pt->max;
131 break;
132 case NLA_VALIDATE_RANGE_PTR:
133 range = pt->range;
134 break;
135 case NLA_VALIDATE_MIN:
136 range->min = pt->min;
137 break;
138 case NLA_VALIDATE_MAX:
139 range->max = pt->max;
140 break;
141 }
Johannes Berg3e48be02018-09-27 11:28:35 +0200142
143 switch (pt->type) {
144 case NLA_U8:
145 value = nla_get_u8(nla);
146 break;
147 case NLA_U16:
148 value = nla_get_u16(nla);
149 break;
150 case NLA_U32:
151 value = nla_get_u32(nla);
152 break;
Johannes Bergd06a09b2020-04-30 22:13:08 +0200153 case NLA_U64:
Johannes Bergda4063b2020-04-30 22:13:09 +0200154 case NLA_MSECS:
Johannes Bergd06a09b2020-04-30 22:13:08 +0200155 value = nla_get_u64(nla);
156 break;
157 default:
158 return -EINVAL;
159 }
160
161 if (value < range->min || value > range->max) {
162 NL_SET_ERR_MSG_ATTR(extack, nla,
163 "integer out of range");
164 return -ERANGE;
165 }
166
167 return 0;
168}
169
170static int nla_validate_int_range_signed(const struct nla_policy *pt,
171 const struct nlattr *nla,
172 struct netlink_ext_ack *extack)
173{
174 struct netlink_range_validation_signed _range = {
175 .min = S64_MIN,
176 .max = S64_MAX,
177 }, *range = &_range;
178 s64 value;
179
180 switch (pt->validation_type) {
181 case NLA_VALIDATE_RANGE:
182 range->min = pt->min;
183 range->max = pt->max;
184 break;
185 case NLA_VALIDATE_RANGE_PTR:
186 range = pt->range_signed;
187 break;
188 case NLA_VALIDATE_MIN:
189 range->min = pt->min;
190 break;
191 case NLA_VALIDATE_MAX:
192 range->max = pt->max;
193 break;
194 }
195
196 switch (pt->type) {
Johannes Berg3e48be02018-09-27 11:28:35 +0200197 case NLA_S8:
198 value = nla_get_s8(nla);
199 break;
200 case NLA_S16:
201 value = nla_get_s16(nla);
202 break;
203 case NLA_S32:
204 value = nla_get_s32(nla);
205 break;
206 case NLA_S64:
207 value = nla_get_s64(nla);
208 break;
Johannes Berg3e48be02018-09-27 11:28:35 +0200209 default:
Johannes Berg3e48be02018-09-27 11:28:35 +0200210 return -EINVAL;
211 }
212
Johannes Bergd06a09b2020-04-30 22:13:08 +0200213 if (value < range->min || value > range->max) {
Johannes Berg3e48be02018-09-27 11:28:35 +0200214 NL_SET_ERR_MSG_ATTR(extack, nla,
215 "integer out of range");
216 return -ERANGE;
217 }
218
219 return 0;
220}
221
Johannes Bergd06a09b2020-04-30 22:13:08 +0200222static int nla_validate_int_range(const struct nla_policy *pt,
223 const struct nlattr *nla,
224 struct netlink_ext_ack *extack)
225{
226 switch (pt->type) {
227 case NLA_U8:
228 case NLA_U16:
229 case NLA_U32:
230 case NLA_U64:
Johannes Bergda4063b2020-04-30 22:13:09 +0200231 case NLA_MSECS:
Johannes Bergd06a09b2020-04-30 22:13:08 +0200232 return nla_validate_int_range_unsigned(pt, nla, extack);
233 case NLA_S8:
234 case NLA_S16:
235 case NLA_S32:
236 case NLA_S64:
237 return nla_validate_int_range_signed(pt, nla, extack);
238 default:
239 WARN_ON(1);
240 return -EINVAL;
241 }
242}
243
Jan Engelhardt36546542010-11-16 09:52:32 -0800244static int validate_nla(const struct nlattr *nla, int maxtype,
Johannes Berg8cb08172019-04-26 14:07:28 +0200245 const struct nla_policy *policy, unsigned int validate,
Johannes Berg7690aa12020-04-30 22:13:06 +0200246 struct netlink_ext_ack *extack, unsigned int depth)
Thomas Grafbfa83a92005-11-10 02:25:51 +0100247{
Johannes Berg56738f42019-04-26 14:07:30 +0200248 u16 strict_start_type = policy[0].strict_start_type;
Patrick McHardyef7c79e2007-06-05 12:38:30 -0700249 const struct nla_policy *pt;
Thomas Graf8f4c1f92007-09-12 14:44:36 +0200250 int minlen = 0, attrlen = nla_len(nla), type = nla_type(nla);
Johannes Bergc29f1842018-09-26 11:15:32 +0200251 int err = -ERANGE;
Thomas Grafbfa83a92005-11-10 02:25:51 +0100252
Johannes Berg56738f42019-04-26 14:07:30 +0200253 if (strict_start_type && type >= strict_start_type)
254 validate |= NL_VALIDATE_STRICT;
255
Thomas Graf8f4c1f92007-09-12 14:44:36 +0200256 if (type <= 0 || type > maxtype)
Thomas Grafbfa83a92005-11-10 02:25:51 +0100257 return 0;
258
Thomas Graf8f4c1f92007-09-12 14:44:36 +0200259 pt = &policy[type];
Thomas Grafbfa83a92005-11-10 02:25:51 +0100260
261 BUG_ON(pt->type > NLA_TYPE_MAX);
262
Johannes Bergb60b87f2018-09-17 11:57:29 +0200263 if ((nla_attr_len[pt->type] && attrlen != nla_attr_len[pt->type]) ||
264 (pt->type == NLA_EXACT_LEN_WARN && attrlen != pt->len)) {
David Ahern6e237d02017-12-06 20:09:12 -0800265 pr_warn_ratelimited("netlink: '%s': attribute type %d has an invalid length.\n",
266 current->comm, type);
Johannes Berg8cb08172019-04-26 14:07:28 +0200267 if (validate & NL_VALIDATE_STRICT_ATTRS) {
268 NL_SET_ERR_MSG_ATTR(extack, nla,
269 "invalid attribute length");
270 return -EINVAL;
271 }
David Ahern28033ae2017-11-07 21:59:40 -0800272 }
273
Michal Kubecekb424e432019-05-02 16:15:10 +0200274 if (validate & NL_VALIDATE_NESTED) {
275 if ((pt->type == NLA_NESTED || pt->type == NLA_NESTED_ARRAY) &&
276 !(nla->nla_type & NLA_F_NESTED)) {
277 NL_SET_ERR_MSG_ATTR(extack, nla,
278 "NLA_F_NESTED is missing");
279 return -EINVAL;
280 }
281 if (pt->type != NLA_NESTED && pt->type != NLA_NESTED_ARRAY &&
282 pt->type != NLA_UNSPEC && (nla->nla_type & NLA_F_NESTED)) {
283 NL_SET_ERR_MSG_ATTR(extack, nla,
284 "NLA_F_NESTED not expected");
285 return -EINVAL;
286 }
287 }
288
Thomas Grafa5531a52006-08-26 20:11:47 -0700289 switch (pt->type) {
Johannes Bergb60b87f2018-09-17 11:57:29 +0200290 case NLA_EXACT_LEN:
291 if (attrlen != pt->len)
Johannes Bergc29f1842018-09-26 11:15:32 +0200292 goto out_err;
Johannes Bergb60b87f2018-09-17 11:57:29 +0200293 break;
294
Johannes Berg568b7422018-09-17 11:57:28 +0200295 case NLA_REJECT:
Johannes Berg47a14942020-04-30 22:13:05 +0200296 if (extack && pt->reject_message) {
Johannes Bergc29f1842018-09-26 11:15:32 +0200297 NL_SET_BAD_ATTR(extack, nla);
Johannes Berg47a14942020-04-30 22:13:05 +0200298 extack->_msg = pt->reject_message;
Johannes Bergc29f1842018-09-26 11:15:32 +0200299 return -EINVAL;
300 }
301 err = -EINVAL;
302 goto out_err;
Johannes Berg568b7422018-09-17 11:57:28 +0200303
Thomas Grafa5531a52006-08-26 20:11:47 -0700304 case NLA_FLAG:
305 if (attrlen > 0)
Johannes Bergc29f1842018-09-26 11:15:32 +0200306 goto out_err;
Thomas Grafa5531a52006-08-26 20:11:47 -0700307 break;
Thomas Grafbfa83a92005-11-10 02:25:51 +0100308
Jamal Hadi Salim64c83d82017-07-30 13:24:49 -0400309 case NLA_BITFIELD32:
310 if (attrlen != sizeof(struct nla_bitfield32))
Johannes Bergc29f1842018-09-26 11:15:32 +0200311 goto out_err;
Jamal Hadi Salim64c83d82017-07-30 13:24:49 -0400312
Johannes Berg47a14942020-04-30 22:13:05 +0200313 err = validate_nla_bitfield32(nla, pt->bitfield32_valid);
Johannes Bergc29f1842018-09-26 11:15:32 +0200314 if (err)
315 goto out_err;
316 break;
Jamal Hadi Salim64c83d82017-07-30 13:24:49 -0400317
Thomas Grafa5531a52006-08-26 20:11:47 -0700318 case NLA_NUL_STRING:
319 if (pt->len)
320 minlen = min_t(int, attrlen, pt->len + 1);
321 else
322 minlen = attrlen;
Thomas Grafbfa83a92005-11-10 02:25:51 +0100323
Johannes Bergc29f1842018-09-26 11:15:32 +0200324 if (!minlen || memchr(nla_data(nla), '\0', minlen) == NULL) {
325 err = -EINVAL;
326 goto out_err;
327 }
Thomas Grafa5531a52006-08-26 20:11:47 -0700328 /* fall through */
329
330 case NLA_STRING:
331 if (attrlen < 1)
Johannes Bergc29f1842018-09-26 11:15:32 +0200332 goto out_err;
Thomas Grafa5531a52006-08-26 20:11:47 -0700333
334 if (pt->len) {
335 char *buf = nla_data(nla);
336
337 if (buf[attrlen - 1] == '\0')
338 attrlen--;
339
340 if (attrlen > pt->len)
Johannes Bergc29f1842018-09-26 11:15:32 +0200341 goto out_err;
Thomas Grafa5531a52006-08-26 20:11:47 -0700342 }
343 break;
344
Johannes Bergd30045a2007-03-23 11:37:48 -0700345 case NLA_BINARY:
346 if (pt->len && attrlen > pt->len)
Johannes Bergc29f1842018-09-26 11:15:32 +0200347 goto out_err;
Johannes Bergd30045a2007-03-23 11:37:48 -0700348 break;
349
Patrick McHardyea5693c2008-11-28 03:05:19 -0800350 case NLA_NESTED:
351 /* a nested attributes is allowed to be empty; if its not,
352 * it must have a size of at least NLA_HDRLEN.
353 */
354 if (attrlen == 0)
355 break;
Johannes Berg9a659a32018-09-26 11:15:33 +0200356 if (attrlen < NLA_HDRLEN)
357 goto out_err;
Johannes Berg47a14942020-04-30 22:13:05 +0200358 if (pt->nested_policy) {
Johannes Berg7690aa12020-04-30 22:13:06 +0200359 err = __nla_validate_parse(nla_data(nla), nla_len(nla),
360 pt->len, pt->nested_policy,
361 validate, extack, NULL,
362 depth + 1);
Johannes Berg9a659a32018-09-26 11:15:33 +0200363 if (err < 0) {
364 /*
365 * return directly to preserve the inner
366 * error message/attribute pointer
367 */
368 return err;
369 }
370 }
371 break;
Johannes Berg1501d132018-09-26 11:15:34 +0200372 case NLA_NESTED_ARRAY:
373 /* a nested array attribute is allowed to be empty; if its not,
374 * it must have a size of at least NLA_HDRLEN.
375 */
376 if (attrlen == 0)
377 break;
378 if (attrlen < NLA_HDRLEN)
379 goto out_err;
Johannes Berg47a14942020-04-30 22:13:05 +0200380 if (pt->nested_policy) {
Johannes Berg1501d132018-09-26 11:15:34 +0200381 int err;
382
383 err = nla_validate_array(nla_data(nla), nla_len(nla),
Johannes Berg47a14942020-04-30 22:13:05 +0200384 pt->len, pt->nested_policy,
Johannes Berg7690aa12020-04-30 22:13:06 +0200385 extack, validate, depth);
Johannes Berg1501d132018-09-26 11:15:34 +0200386 if (err < 0) {
387 /*
388 * return directly to preserve the inner
389 * error message/attribute pointer
390 */
391 return err;
392 }
393 }
394 break;
Johannes Berg6f455f52019-04-26 14:07:27 +0200395
396 case NLA_UNSPEC:
Johannes Berg8cb08172019-04-26 14:07:28 +0200397 if (validate & NL_VALIDATE_UNSPEC) {
398 NL_SET_ERR_MSG_ATTR(extack, nla,
399 "Unsupported attribute");
400 return -EINVAL;
401 }
402 /* fall through */
Johannes Berg6f455f52019-04-26 14:07:27 +0200403 case NLA_MIN_LEN:
404 if (attrlen < pt->len)
405 goto out_err;
406 break;
407
Thomas Grafa5531a52006-08-26 20:11:47 -0700408 default:
409 if (pt->len)
410 minlen = pt->len;
Johannes Berg6f455f52019-04-26 14:07:27 +0200411 else
Thomas Grafa5531a52006-08-26 20:11:47 -0700412 minlen = nla_attr_minlen[pt->type];
413
414 if (attrlen < minlen)
Johannes Bergc29f1842018-09-26 11:15:32 +0200415 goto out_err;
Thomas Grafa5531a52006-08-26 20:11:47 -0700416 }
Thomas Grafbfa83a92005-11-10 02:25:51 +0100417
Johannes Berg3e48be02018-09-27 11:28:35 +0200418 /* further validation */
419 switch (pt->validation_type) {
420 case NLA_VALIDATE_NONE:
421 /* nothing to do */
422 break;
Johannes Bergd06a09b2020-04-30 22:13:08 +0200423 case NLA_VALIDATE_RANGE_PTR:
Johannes Berg3e48be02018-09-27 11:28:35 +0200424 case NLA_VALIDATE_RANGE:
425 case NLA_VALIDATE_MIN:
426 case NLA_VALIDATE_MAX:
427 err = nla_validate_int_range(pt, nla, extack);
428 if (err)
429 return err;
430 break;
Johannes Berg33188bd2018-09-27 11:28:36 +0200431 case NLA_VALIDATE_FUNCTION:
432 if (pt->validate) {
433 err = pt->validate(nla, extack);
434 if (err)
435 return err;
436 }
437 break;
Johannes Berg3e48be02018-09-27 11:28:35 +0200438 }
439
Thomas Grafbfa83a92005-11-10 02:25:51 +0100440 return 0;
Johannes Bergc29f1842018-09-26 11:15:32 +0200441out_err:
442 NL_SET_ERR_MSG_ATTR(extack, nla, "Attribute failed policy validation");
443 return err;
Thomas Grafbfa83a92005-11-10 02:25:51 +0100444}
445
Johannes Berg8cb08172019-04-26 14:07:28 +0200446static int __nla_validate_parse(const struct nlattr *head, int len, int maxtype,
447 const struct nla_policy *policy,
448 unsigned int validate,
449 struct netlink_ext_ack *extack,
Johannes Berg7690aa12020-04-30 22:13:06 +0200450 struct nlattr **tb, unsigned int depth)
Thomas Grafbfa83a92005-11-10 02:25:51 +0100451{
Jan Engelhardt36546542010-11-16 09:52:32 -0800452 const struct nlattr *nla;
Johannes Bergfceb6432017-04-12 14:34:07 +0200453 int rem;
Thomas Grafbfa83a92005-11-10 02:25:51 +0100454
Johannes Berg7690aa12020-04-30 22:13:06 +0200455 if (depth >= MAX_POLICY_RECURSION_DEPTH) {
456 NL_SET_ERR_MSG(extack,
457 "allowed policy recursion depth exceeded");
458 return -EINVAL;
459 }
460
Johannes Berg8cb08172019-04-26 14:07:28 +0200461 if (tb)
462 memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
Johannes Bergfceb6432017-04-12 14:34:07 +0200463
Johannes Berg8cb08172019-04-26 14:07:28 +0200464 nla_for_each_attr(nla, head, len, rem) {
465 u16 type = nla_type(nla);
466
467 if (type == 0 || type > maxtype) {
468 if (validate & NL_VALIDATE_MAXTYPE) {
Michal Kubecekd54a16b2019-05-02 16:15:10 +0200469 NL_SET_ERR_MSG_ATTR(extack, nla,
470 "Unknown attribute type");
Johannes Berg8cb08172019-04-26 14:07:28 +0200471 return -EINVAL;
472 }
473 continue;
474 }
475 if (policy) {
476 int err = validate_nla(nla, maxtype, policy,
Johannes Berg7690aa12020-04-30 22:13:06 +0200477 validate, extack, depth);
Johannes Berg8cb08172019-04-26 14:07:28 +0200478
479 if (err < 0)
480 return err;
481 }
482
483 if (tb)
484 tb[type] = (struct nlattr *)nla;
485 }
486
487 if (unlikely(rem > 0)) {
488 pr_warn_ratelimited("netlink: %d bytes leftover after parsing attributes in process `%s'.\n",
489 rem, current->comm);
490 NL_SET_ERR_MSG(extack, "bytes leftover after parsing attributes");
491 if (validate & NL_VALIDATE_TRAILING)
492 return -EINVAL;
Thomas Grafbfa83a92005-11-10 02:25:51 +0100493 }
494
Johannes Bergfceb6432017-04-12 14:34:07 +0200495 return 0;
Thomas Grafbfa83a92005-11-10 02:25:51 +0100496}
Johannes Berg8cb08172019-04-26 14:07:28 +0200497
498/**
499 * __nla_validate - Validate a stream of attributes
500 * @head: head of attribute stream
501 * @len: length of attribute stream
502 * @maxtype: maximum attribute type to be expected
503 * @policy: validation policy
504 * @validate: validation strictness
505 * @extack: extended ACK report struct
506 *
507 * Validates all attributes in the specified attribute stream against the
508 * specified policy. Validation depends on the validate flags passed, see
509 * &enum netlink_validation for more details on that.
510 * See documenation of struct nla_policy for more details.
511 *
512 * Returns 0 on success or a negative error code.
513 */
514int __nla_validate(const struct nlattr *head, int len, int maxtype,
515 const struct nla_policy *policy, unsigned int validate,
516 struct netlink_ext_ack *extack)
517{
518 return __nla_validate_parse(head, len, maxtype, policy, validate,
Johannes Berg7690aa12020-04-30 22:13:06 +0200519 extack, NULL, 0);
Johannes Berg8cb08172019-04-26 14:07:28 +0200520}
521EXPORT_SYMBOL(__nla_validate);
Thomas Grafbfa83a92005-11-10 02:25:51 +0100522
523/**
Holger Eitzenbergere487eb992009-03-25 18:26:30 +0100524 * nla_policy_len - Determin the max. length of a policy
525 * @policy: policy to use
526 * @n: number of policies
527 *
528 * Determines the max. length of the policy. It is currently used
529 * to allocated Netlink buffers roughly the size of the actual
530 * message.
531 *
532 * Returns 0 on success or a negative error code.
533 */
534int
535nla_policy_len(const struct nla_policy *p, int n)
536{
537 int i, len = 0;
538
Lars Ellenberge3fa3af2011-02-28 12:38:25 -0800539 for (i = 0; i < n; i++, p++) {
Holger Eitzenbergere487eb992009-03-25 18:26:30 +0100540 if (p->len)
541 len += nla_total_size(p->len);
David Ahern28033ae2017-11-07 21:59:40 -0800542 else if (nla_attr_len[p->type])
543 len += nla_total_size(nla_attr_len[p->type]);
Holger Eitzenbergere487eb992009-03-25 18:26:30 +0100544 else if (nla_attr_minlen[p->type])
545 len += nla_total_size(nla_attr_minlen[p->type]);
546 }
547
548 return len;
549}
Fabian Frederick6d6a1382014-06-04 16:11:57 -0700550EXPORT_SYMBOL(nla_policy_len);
Holger Eitzenbergere487eb992009-03-25 18:26:30 +0100551
552/**
Johannes Berg8cb08172019-04-26 14:07:28 +0200553 * __nla_parse - Parse a stream of attributes into a tb buffer
Thomas Grafbfa83a92005-11-10 02:25:51 +0100554 * @tb: destination array with maxtype+1 elements
555 * @maxtype: maximum attribute type to be expected
556 * @head: head of attribute stream
557 * @len: length of attribute stream
Julius Volz10b595a2008-06-27 20:02:14 -0700558 * @policy: validation policy
Johannes Berg8cb08172019-04-26 14:07:28 +0200559 * @validate: validation strictness
560 * @extack: extended ACK pointer
Thomas Grafbfa83a92005-11-10 02:25:51 +0100561 *
562 * Parses a stream of attributes and stores a pointer to each attribute in
Johannes Berg8cb08172019-04-26 14:07:28 +0200563 * the tb array accessible via the attribute type.
564 * Validation is controlled by the @validate parameter.
Thomas Grafbfa83a92005-11-10 02:25:51 +0100565 *
566 * Returns 0 on success or a negative error code.
567 */
Johannes Berg8cb08172019-04-26 14:07:28 +0200568int __nla_parse(struct nlattr **tb, int maxtype,
569 const struct nlattr *head, int len,
570 const struct nla_policy *policy, unsigned int validate,
571 struct netlink_ext_ack *extack)
Thomas Grafbfa83a92005-11-10 02:25:51 +0100572{
Johannes Berg8cb08172019-04-26 14:07:28 +0200573 return __nla_validate_parse(head, len, maxtype, policy, validate,
Johannes Berg7690aa12020-04-30 22:13:06 +0200574 extack, tb, 0);
Thomas Grafbfa83a92005-11-10 02:25:51 +0100575}
Johannes Berg8cb08172019-04-26 14:07:28 +0200576EXPORT_SYMBOL(__nla_parse);
David Aherna5f6cba2018-10-07 20:16:25 -0700577
Thomas Grafbfa83a92005-11-10 02:25:51 +0100578/**
579 * nla_find - Find a specific attribute in a stream of attributes
580 * @head: head of attribute stream
581 * @len: length of attribute stream
582 * @attrtype: type of attribute to look for
583 *
584 * Returns the first attribute in the stream matching the specified type.
585 */
Jan Engelhardt36546542010-11-16 09:52:32 -0800586struct nlattr *nla_find(const struct nlattr *head, int len, int attrtype)
Thomas Grafbfa83a92005-11-10 02:25:51 +0100587{
Jan Engelhardt36546542010-11-16 09:52:32 -0800588 const struct nlattr *nla;
Thomas Grafbfa83a92005-11-10 02:25:51 +0100589 int rem;
590
591 nla_for_each_attr(nla, head, len, rem)
Thomas Graf8f4c1f92007-09-12 14:44:36 +0200592 if (nla_type(nla) == attrtype)
Jan Engelhardt36546542010-11-16 09:52:32 -0800593 return (struct nlattr *)nla;
Thomas Grafbfa83a92005-11-10 02:25:51 +0100594
595 return NULL;
596}
Fabian Frederick6d6a1382014-06-04 16:11:57 -0700597EXPORT_SYMBOL(nla_find);
Thomas Grafbfa83a92005-11-10 02:25:51 +0100598
599/**
600 * nla_strlcpy - Copy string attribute payload into a sized buffer
601 * @dst: where to copy the string to
Julius Volz10b595a2008-06-27 20:02:14 -0700602 * @nla: attribute to copy the string from
Thomas Grafbfa83a92005-11-10 02:25:51 +0100603 * @dstsize: size of destination buffer
604 *
605 * Copies at most dstsize - 1 bytes into the destination buffer.
606 * The result is always a valid NUL-terminated string. Unlike
607 * strlcpy the destination buffer is always padded out.
608 *
609 * Returns the length of the source buffer.
610 */
611size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dstsize)
612{
613 size_t srclen = nla_len(nla);
614 char *src = nla_data(nla);
615
616 if (srclen > 0 && src[srclen - 1] == '\0')
617 srclen--;
618
619 if (dstsize > 0) {
620 size_t len = (srclen >= dstsize) ? dstsize - 1 : srclen;
621
622 memset(dst, 0, dstsize);
623 memcpy(dst, src, len);
624 }
625
626 return srclen;
627}
Fabian Frederick6d6a1382014-06-04 16:11:57 -0700628EXPORT_SYMBOL(nla_strlcpy);
Thomas Grafbfa83a92005-11-10 02:25:51 +0100629
630/**
Phil Sutter2cf0c8b2017-07-27 16:56:40 +0200631 * nla_strdup - Copy string attribute payload into a newly allocated buffer
632 * @nla: attribute to copy the string from
633 * @flags: the type of memory to allocate (see kmalloc).
634 *
635 * Returns a pointer to the allocated buffer or NULL on error.
636 */
637char *nla_strdup(const struct nlattr *nla, gfp_t flags)
638{
639 size_t srclen = nla_len(nla);
640 char *src = nla_data(nla), *dst;
641
642 if (srclen > 0 && src[srclen - 1] == '\0')
643 srclen--;
644
645 dst = kmalloc(srclen + 1, flags);
646 if (dst != NULL) {
647 memcpy(dst, src, srclen);
648 dst[srclen] = '\0';
649 }
650 return dst;
651}
652EXPORT_SYMBOL(nla_strdup);
653
654/**
Thomas Grafbfa83a92005-11-10 02:25:51 +0100655 * nla_memcpy - Copy a netlink attribute into another memory area
656 * @dest: where to copy to memcpy
657 * @src: netlink attribute to copy from
658 * @count: size of the destination area
659 *
660 * Note: The number of bytes copied is limited by the length of
661 * attribute's payload. memcpy
662 *
663 * Returns the number of bytes copied.
664 */
Patrick McHardyb057efd2008-10-28 11:59:11 -0700665int nla_memcpy(void *dest, const struct nlattr *src, int count)
Thomas Grafbfa83a92005-11-10 02:25:51 +0100666{
667 int minlen = min_t(int, count, nla_len(src));
668
669 memcpy(dest, nla_data(src), minlen);
Jiri Benc5899f042015-03-29 16:05:28 +0200670 if (count > minlen)
671 memset(dest + minlen, 0, count - minlen);
Thomas Grafbfa83a92005-11-10 02:25:51 +0100672
673 return minlen;
674}
Fabian Frederick6d6a1382014-06-04 16:11:57 -0700675EXPORT_SYMBOL(nla_memcpy);
Thomas Grafbfa83a92005-11-10 02:25:51 +0100676
677/**
678 * nla_memcmp - Compare an attribute with sized memory area
679 * @nla: netlink attribute
680 * @data: memory area
681 * @size: size of memory area
682 */
683int nla_memcmp(const struct nlattr *nla, const void *data,
684 size_t size)
685{
686 int d = nla_len(nla) - size;
687
688 if (d == 0)
689 d = memcmp(nla_data(nla), data, size);
690
691 return d;
692}
Fabian Frederick6d6a1382014-06-04 16:11:57 -0700693EXPORT_SYMBOL(nla_memcmp);
Thomas Grafbfa83a92005-11-10 02:25:51 +0100694
695/**
696 * nla_strcmp - Compare a string attribute against a string
697 * @nla: netlink string attribute
698 * @str: another string
699 */
700int nla_strcmp(const struct nlattr *nla, const char *str)
701{
Pablo Neira8b7b9322014-04-01 19:38:44 +0200702 int len = strlen(str);
703 char *buf = nla_data(nla);
704 int attrlen = nla_len(nla);
705 int d;
Thomas Grafbfa83a92005-11-10 02:25:51 +0100706
Pablo Neira8b7b9322014-04-01 19:38:44 +0200707 if (attrlen > 0 && buf[attrlen - 1] == '\0')
708 attrlen--;
709
710 d = attrlen - len;
Thomas Grafbfa83a92005-11-10 02:25:51 +0100711 if (d == 0)
712 d = memcmp(nla_data(nla), str, len);
713
714 return d;
715}
Fabian Frederick6d6a1382014-06-04 16:11:57 -0700716EXPORT_SYMBOL(nla_strcmp);
Thomas Grafbfa83a92005-11-10 02:25:51 +0100717
Herbert Xu90800212009-03-11 23:18:32 +0800718#ifdef CONFIG_NET
Thomas Grafbfa83a92005-11-10 02:25:51 +0100719/**
720 * __nla_reserve - reserve room for attribute on the skb
721 * @skb: socket buffer to reserve room on
722 * @attrtype: attribute type
723 * @attrlen: length of attribute payload
724 *
725 * Adds a netlink attribute header to a socket buffer and reserves
726 * room for the payload but does not copy it.
727 *
728 * The caller is responsible to ensure that the skb provides enough
729 * tailroom for the attribute header and payload.
730 */
731struct nlattr *__nla_reserve(struct sk_buff *skb, int attrtype, int attrlen)
732{
733 struct nlattr *nla;
734
Johannes Berg4df864c2017-06-16 14:29:21 +0200735 nla = skb_put(skb, nla_total_size(attrlen));
Thomas Grafbfa83a92005-11-10 02:25:51 +0100736 nla->nla_type = attrtype;
737 nla->nla_len = nla_attr_size(attrlen);
738
739 memset((unsigned char *) nla + nla->nla_len, 0, nla_padlen(attrlen));
740
741 return nla;
742}
Herbert Xu90800212009-03-11 23:18:32 +0800743EXPORT_SYMBOL(__nla_reserve);
Thomas Grafbfa83a92005-11-10 02:25:51 +0100744
745/**
Nicolas Dichtel089bf1a2016-04-21 18:58:24 +0200746 * __nla_reserve_64bit - reserve room for attribute on the skb and align it
747 * @skb: socket buffer to reserve room on
748 * @attrtype: attribute type
749 * @attrlen: length of attribute payload
Nicolas Dichtel11a99572016-04-22 17:31:16 +0200750 * @padattr: attribute type for the padding
Nicolas Dichtel089bf1a2016-04-21 18:58:24 +0200751 *
752 * Adds a netlink attribute header to a socket buffer and reserves
753 * room for the payload but does not copy it. It also ensure that this
Nicolas Dichtel11a99572016-04-22 17:31:16 +0200754 * attribute will have a 64-bit aligned nla_data() area.
Nicolas Dichtel089bf1a2016-04-21 18:58:24 +0200755 *
756 * The caller is responsible to ensure that the skb provides enough
757 * tailroom for the attribute header and payload.
758 */
759struct nlattr *__nla_reserve_64bit(struct sk_buff *skb, int attrtype,
760 int attrlen, int padattr)
761{
762 if (nla_need_padding_for_64bit(skb))
763 nla_align_64bit(skb, padattr);
764
765 return __nla_reserve(skb, attrtype, attrlen);
766}
767EXPORT_SYMBOL(__nla_reserve_64bit);
768
769/**
Thomas Graffe4944e2006-08-04 23:03:05 -0700770 * __nla_reserve_nohdr - reserve room for attribute without header
771 * @skb: socket buffer to reserve room on
772 * @attrlen: length of attribute payload
773 *
774 * Reserves room for attribute payload without a header.
775 *
776 * The caller is responsible to ensure that the skb provides enough
777 * tailroom for the payload.
778 */
779void *__nla_reserve_nohdr(struct sk_buff *skb, int attrlen)
780{
yuan linyub952f4d2017-06-18 22:52:04 +0800781 return skb_put_zero(skb, NLA_ALIGN(attrlen));
Thomas Graffe4944e2006-08-04 23:03:05 -0700782}
Herbert Xu90800212009-03-11 23:18:32 +0800783EXPORT_SYMBOL(__nla_reserve_nohdr);
Thomas Graffe4944e2006-08-04 23:03:05 -0700784
785/**
Thomas Grafbfa83a92005-11-10 02:25:51 +0100786 * nla_reserve - reserve room for attribute on the skb
787 * @skb: socket buffer to reserve room on
788 * @attrtype: attribute type
789 * @attrlen: length of attribute payload
790 *
791 * Adds a netlink attribute header to a socket buffer and reserves
792 * room for the payload but does not copy it.
793 *
794 * Returns NULL if the tailroom of the skb is insufficient to store
795 * the attribute header and payload.
796 */
797struct nlattr *nla_reserve(struct sk_buff *skb, int attrtype, int attrlen)
798{
799 if (unlikely(skb_tailroom(skb) < nla_total_size(attrlen)))
800 return NULL;
801
802 return __nla_reserve(skb, attrtype, attrlen);
803}
Herbert Xu90800212009-03-11 23:18:32 +0800804EXPORT_SYMBOL(nla_reserve);
Thomas Grafbfa83a92005-11-10 02:25:51 +0100805
806/**
Nicolas Dichtel089bf1a2016-04-21 18:58:24 +0200807 * nla_reserve_64bit - reserve room for attribute on the skb and align it
808 * @skb: socket buffer to reserve room on
809 * @attrtype: attribute type
810 * @attrlen: length of attribute payload
Nicolas Dichtel11a99572016-04-22 17:31:16 +0200811 * @padattr: attribute type for the padding
Nicolas Dichtel089bf1a2016-04-21 18:58:24 +0200812 *
813 * Adds a netlink attribute header to a socket buffer and reserves
814 * room for the payload but does not copy it. It also ensure that this
Nicolas Dichtel11a99572016-04-22 17:31:16 +0200815 * attribute will have a 64-bit aligned nla_data() area.
Nicolas Dichtel089bf1a2016-04-21 18:58:24 +0200816 *
817 * Returns NULL if the tailroom of the skb is insufficient to store
818 * the attribute header and payload.
819 */
820struct nlattr *nla_reserve_64bit(struct sk_buff *skb, int attrtype, int attrlen,
821 int padattr)
822{
823 size_t len;
824
825 if (nla_need_padding_for_64bit(skb))
826 len = nla_total_size_64bit(attrlen);
827 else
828 len = nla_total_size(attrlen);
829 if (unlikely(skb_tailroom(skb) < len))
830 return NULL;
831
832 return __nla_reserve_64bit(skb, attrtype, attrlen, padattr);
833}
834EXPORT_SYMBOL(nla_reserve_64bit);
835
836/**
Julius Volz10b595a2008-06-27 20:02:14 -0700837 * nla_reserve_nohdr - reserve room for attribute without header
Thomas Graffe4944e2006-08-04 23:03:05 -0700838 * @skb: socket buffer to reserve room on
Julius Volz10b595a2008-06-27 20:02:14 -0700839 * @attrlen: length of attribute payload
Thomas Graffe4944e2006-08-04 23:03:05 -0700840 *
841 * Reserves room for attribute payload without a header.
842 *
843 * Returns NULL if the tailroom of the skb is insufficient to store
844 * the attribute payload.
845 */
846void *nla_reserve_nohdr(struct sk_buff *skb, int attrlen)
847{
848 if (unlikely(skb_tailroom(skb) < NLA_ALIGN(attrlen)))
849 return NULL;
850
851 return __nla_reserve_nohdr(skb, attrlen);
852}
Herbert Xu90800212009-03-11 23:18:32 +0800853EXPORT_SYMBOL(nla_reserve_nohdr);
Thomas Graffe4944e2006-08-04 23:03:05 -0700854
855/**
Thomas Grafbfa83a92005-11-10 02:25:51 +0100856 * __nla_put - Add a netlink attribute to a socket buffer
857 * @skb: socket buffer to add attribute to
858 * @attrtype: attribute type
859 * @attrlen: length of attribute payload
860 * @data: head of attribute payload
861 *
862 * The caller is responsible to ensure that the skb provides enough
863 * tailroom for the attribute header and payload.
864 */
865void __nla_put(struct sk_buff *skb, int attrtype, int attrlen,
866 const void *data)
867{
868 struct nlattr *nla;
869
870 nla = __nla_reserve(skb, attrtype, attrlen);
871 memcpy(nla_data(nla), data, attrlen);
872}
Herbert Xu90800212009-03-11 23:18:32 +0800873EXPORT_SYMBOL(__nla_put);
Thomas Grafbfa83a92005-11-10 02:25:51 +0100874
Thomas Graffe4944e2006-08-04 23:03:05 -0700875/**
Nicolas Dichtel089bf1a2016-04-21 18:58:24 +0200876 * __nla_put_64bit - Add a netlink attribute to a socket buffer and align it
877 * @skb: socket buffer to add attribute to
878 * @attrtype: attribute type
879 * @attrlen: length of attribute payload
880 * @data: head of attribute payload
Nicolas Dichtel11a99572016-04-22 17:31:16 +0200881 * @padattr: attribute type for the padding
Nicolas Dichtel089bf1a2016-04-21 18:58:24 +0200882 *
883 * The caller is responsible to ensure that the skb provides enough
884 * tailroom for the attribute header and payload.
885 */
886void __nla_put_64bit(struct sk_buff *skb, int attrtype, int attrlen,
887 const void *data, int padattr)
888{
889 struct nlattr *nla;
890
891 nla = __nla_reserve_64bit(skb, attrtype, attrlen, padattr);
892 memcpy(nla_data(nla), data, attrlen);
893}
894EXPORT_SYMBOL(__nla_put_64bit);
895
896/**
Thomas Graffe4944e2006-08-04 23:03:05 -0700897 * __nla_put_nohdr - Add a netlink attribute without header
898 * @skb: socket buffer to add attribute to
899 * @attrlen: length of attribute payload
900 * @data: head of attribute payload
901 *
902 * The caller is responsible to ensure that the skb provides enough
903 * tailroom for the attribute payload.
904 */
905void __nla_put_nohdr(struct sk_buff *skb, int attrlen, const void *data)
906{
907 void *start;
908
909 start = __nla_reserve_nohdr(skb, attrlen);
910 memcpy(start, data, attrlen);
911}
Herbert Xu90800212009-03-11 23:18:32 +0800912EXPORT_SYMBOL(__nla_put_nohdr);
Thomas Grafbfa83a92005-11-10 02:25:51 +0100913
914/**
915 * nla_put - Add a netlink attribute to a socket buffer
916 * @skb: socket buffer to add attribute to
917 * @attrtype: attribute type
918 * @attrlen: length of attribute payload
919 * @data: head of attribute payload
920 *
Thomas Grafbc3ed282008-06-03 16:36:54 -0700921 * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store
Thomas Grafbfa83a92005-11-10 02:25:51 +0100922 * the attribute header and payload.
923 */
924int nla_put(struct sk_buff *skb, int attrtype, int attrlen, const void *data)
925{
926 if (unlikely(skb_tailroom(skb) < nla_total_size(attrlen)))
Thomas Grafbc3ed282008-06-03 16:36:54 -0700927 return -EMSGSIZE;
Thomas Grafbfa83a92005-11-10 02:25:51 +0100928
929 __nla_put(skb, attrtype, attrlen, data);
930 return 0;
931}
Herbert Xu90800212009-03-11 23:18:32 +0800932EXPORT_SYMBOL(nla_put);
Thomas Grafbfa83a92005-11-10 02:25:51 +0100933
Thomas Graffe4944e2006-08-04 23:03:05 -0700934/**
Nicolas Dichtel089bf1a2016-04-21 18:58:24 +0200935 * nla_put_64bit - Add a netlink attribute to a socket buffer and align it
936 * @skb: socket buffer to add attribute to
937 * @attrtype: attribute type
938 * @attrlen: length of attribute payload
939 * @data: head of attribute payload
Nicolas Dichtel11a99572016-04-22 17:31:16 +0200940 * @padattr: attribute type for the padding
Nicolas Dichtel089bf1a2016-04-21 18:58:24 +0200941 *
942 * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store
943 * the attribute header and payload.
944 */
945int nla_put_64bit(struct sk_buff *skb, int attrtype, int attrlen,
946 const void *data, int padattr)
947{
948 size_t len;
949
950 if (nla_need_padding_for_64bit(skb))
951 len = nla_total_size_64bit(attrlen);
952 else
953 len = nla_total_size(attrlen);
954 if (unlikely(skb_tailroom(skb) < len))
955 return -EMSGSIZE;
956
957 __nla_put_64bit(skb, attrtype, attrlen, data, padattr);
958 return 0;
959}
960EXPORT_SYMBOL(nla_put_64bit);
961
962/**
Thomas Graffe4944e2006-08-04 23:03:05 -0700963 * nla_put_nohdr - Add a netlink attribute without header
964 * @skb: socket buffer to add attribute to
965 * @attrlen: length of attribute payload
966 * @data: head of attribute payload
967 *
Thomas Grafbc3ed282008-06-03 16:36:54 -0700968 * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store
Thomas Graffe4944e2006-08-04 23:03:05 -0700969 * the attribute payload.
970 */
971int nla_put_nohdr(struct sk_buff *skb, int attrlen, const void *data)
972{
973 if (unlikely(skb_tailroom(skb) < NLA_ALIGN(attrlen)))
Thomas Grafbc3ed282008-06-03 16:36:54 -0700974 return -EMSGSIZE;
Thomas Graffe4944e2006-08-04 23:03:05 -0700975
976 __nla_put_nohdr(skb, attrlen, data);
977 return 0;
978}
Herbert Xu90800212009-03-11 23:18:32 +0800979EXPORT_SYMBOL(nla_put_nohdr);
Thomas Grafbfa83a92005-11-10 02:25:51 +0100980
Patrick McHardy01480e12008-01-22 22:10:59 -0800981/**
982 * nla_append - Add a netlink attribute without header or padding
983 * @skb: socket buffer to add attribute to
984 * @attrlen: length of attribute payload
985 * @data: head of attribute payload
986 *
Thomas Grafbc3ed282008-06-03 16:36:54 -0700987 * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store
Patrick McHardy01480e12008-01-22 22:10:59 -0800988 * the attribute payload.
989 */
990int nla_append(struct sk_buff *skb, int attrlen, const void *data)
991{
992 if (unlikely(skb_tailroom(skb) < NLA_ALIGN(attrlen)))
Thomas Grafbc3ed282008-06-03 16:36:54 -0700993 return -EMSGSIZE;
Patrick McHardy01480e12008-01-22 22:10:59 -0800994
Johannes Berg59ae1d12017-06-16 14:29:20 +0200995 skb_put_data(skb, data, attrlen);
Patrick McHardy01480e12008-01-22 22:10:59 -0800996 return 0;
997}
Herbert Xu90800212009-03-11 23:18:32 +0800998EXPORT_SYMBOL(nla_append);
999#endif