hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/lib/nlattr.c
....@@ -10,6 +10,7 @@
1010 #include <linux/kernel.h>
1111 #include <linux/errno.h>
1212 #include <linux/jiffies.h>
13
+#include <linux/nospec.h>
1314 #include <linux/skbuff.h>
1415 #include <linux/string.h>
1516 #include <linux/types.h>
....@@ -44,21 +45,34 @@
4445 [NLA_S64] = sizeof(s64),
4546 };
4647
48
+/*
49
+ * Nested policies might refer back to the original
50
+ * policy in some cases, and userspace could try to
51
+ * abuse that and recurse by nesting in the right
52
+ * ways. Limit recursion to avoid this problem.
53
+ */
54
+#define MAX_POLICY_RECURSION_DEPTH 10
55
+
56
+static int __nla_validate_parse(const struct nlattr *head, int len, int maxtype,
57
+ const struct nla_policy *policy,
58
+ unsigned int validate,
59
+ struct netlink_ext_ack *extack,
60
+ struct nlattr **tb, unsigned int depth);
61
+
4762 static int validate_nla_bitfield32(const struct nlattr *nla,
48
- u32 *valid_flags_allowed)
63
+ const u32 valid_flags_mask)
4964 {
5065 const struct nla_bitfield32 *bf = nla_data(nla);
51
- u32 *valid_flags_mask = valid_flags_allowed;
5266
53
- if (!valid_flags_allowed)
67
+ if (!valid_flags_mask)
5468 return -EINVAL;
5569
5670 /*disallow invalid bit selector */
57
- if (bf->selector & ~*valid_flags_mask)
71
+ if (bf->selector & ~valid_flags_mask)
5872 return -EINVAL;
5973
6074 /*disallow invalid bit values */
61
- if (bf->value & ~*valid_flags_mask)
75
+ if (bf->value & ~valid_flags_mask)
6276 return -EINVAL;
6377
6478 /*disallow valid bit values that are not selected*/
....@@ -68,15 +82,295 @@
6882 return 0;
6983 }
7084
71
-static int validate_nla(const struct nlattr *nla, int maxtype,
72
- const struct nla_policy *policy)
85
+static int nla_validate_array(const struct nlattr *head, int len, int maxtype,
86
+ const struct nla_policy *policy,
87
+ struct netlink_ext_ack *extack,
88
+ unsigned int validate, unsigned int depth)
7389 {
90
+ const struct nlattr *entry;
91
+ int rem;
92
+
93
+ nla_for_each_attr(entry, head, len, rem) {
94
+ int ret;
95
+
96
+ if (nla_len(entry) == 0)
97
+ continue;
98
+
99
+ if (nla_len(entry) < NLA_HDRLEN) {
100
+ NL_SET_ERR_MSG_ATTR_POL(extack, entry, policy,
101
+ "Array element too short");
102
+ return -ERANGE;
103
+ }
104
+
105
+ ret = __nla_validate_parse(nla_data(entry), nla_len(entry),
106
+ maxtype, policy, validate, extack,
107
+ NULL, depth + 1);
108
+ if (ret < 0)
109
+ return ret;
110
+ }
111
+
112
+ return 0;
113
+}
114
+
115
+void nla_get_range_unsigned(const struct nla_policy *pt,
116
+ struct netlink_range_validation *range)
117
+{
118
+ WARN_ON_ONCE(pt->validation_type != NLA_VALIDATE_RANGE_PTR &&
119
+ (pt->min < 0 || pt->max < 0));
120
+
121
+ range->min = 0;
122
+
123
+ switch (pt->type) {
124
+ case NLA_U8:
125
+ range->max = U8_MAX;
126
+ break;
127
+ case NLA_U16:
128
+ case NLA_BINARY:
129
+ range->max = U16_MAX;
130
+ break;
131
+ case NLA_U32:
132
+ range->max = U32_MAX;
133
+ break;
134
+ case NLA_U64:
135
+ case NLA_MSECS:
136
+ range->max = U64_MAX;
137
+ break;
138
+ default:
139
+ WARN_ON_ONCE(1);
140
+ return;
141
+ }
142
+
143
+ switch (pt->validation_type) {
144
+ case NLA_VALIDATE_RANGE:
145
+ case NLA_VALIDATE_RANGE_WARN_TOO_LONG:
146
+ range->min = pt->min;
147
+ range->max = pt->max;
148
+ break;
149
+ case NLA_VALIDATE_RANGE_PTR:
150
+ *range = *pt->range;
151
+ break;
152
+ case NLA_VALIDATE_MIN:
153
+ range->min = pt->min;
154
+ break;
155
+ case NLA_VALIDATE_MAX:
156
+ range->max = pt->max;
157
+ break;
158
+ default:
159
+ break;
160
+ }
161
+}
162
+
163
+static int nla_validate_range_unsigned(const struct nla_policy *pt,
164
+ const struct nlattr *nla,
165
+ struct netlink_ext_ack *extack,
166
+ unsigned int validate)
167
+{
168
+ struct netlink_range_validation range;
169
+ u64 value;
170
+
171
+ switch (pt->type) {
172
+ case NLA_U8:
173
+ value = nla_get_u8(nla);
174
+ break;
175
+ case NLA_U16:
176
+ value = nla_get_u16(nla);
177
+ break;
178
+ case NLA_U32:
179
+ value = nla_get_u32(nla);
180
+ break;
181
+ case NLA_U64:
182
+ case NLA_MSECS:
183
+ value = nla_get_u64(nla);
184
+ break;
185
+ case NLA_BINARY:
186
+ value = nla_len(nla);
187
+ break;
188
+ default:
189
+ return -EINVAL;
190
+ }
191
+
192
+ nla_get_range_unsigned(pt, &range);
193
+
194
+ if (pt->validation_type == NLA_VALIDATE_RANGE_WARN_TOO_LONG &&
195
+ pt->type == NLA_BINARY && value > range.max) {
196
+ pr_warn_ratelimited("netlink: '%s': attribute type %d has an invalid length.\n",
197
+ current->comm, pt->type);
198
+ if (validate & NL_VALIDATE_STRICT_ATTRS) {
199
+ NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt,
200
+ "invalid attribute length");
201
+ return -EINVAL;
202
+ }
203
+
204
+ /* this assumes min <= max (don't validate against min) */
205
+ return 0;
206
+ }
207
+
208
+ if (value < range.min || value > range.max) {
209
+ bool binary = pt->type == NLA_BINARY;
210
+
211
+ if (binary)
212
+ NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt,
213
+ "binary attribute size out of range");
214
+ else
215
+ NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt,
216
+ "integer out of range");
217
+
218
+ return -ERANGE;
219
+ }
220
+
221
+ return 0;
222
+}
223
+
224
+void nla_get_range_signed(const struct nla_policy *pt,
225
+ struct netlink_range_validation_signed *range)
226
+{
227
+ switch (pt->type) {
228
+ case NLA_S8:
229
+ range->min = S8_MIN;
230
+ range->max = S8_MAX;
231
+ break;
232
+ case NLA_S16:
233
+ range->min = S16_MIN;
234
+ range->max = S16_MAX;
235
+ break;
236
+ case NLA_S32:
237
+ range->min = S32_MIN;
238
+ range->max = S32_MAX;
239
+ break;
240
+ case NLA_S64:
241
+ range->min = S64_MIN;
242
+ range->max = S64_MAX;
243
+ break;
244
+ default:
245
+ WARN_ON_ONCE(1);
246
+ return;
247
+ }
248
+
249
+ switch (pt->validation_type) {
250
+ case NLA_VALIDATE_RANGE:
251
+ range->min = pt->min;
252
+ range->max = pt->max;
253
+ break;
254
+ case NLA_VALIDATE_RANGE_PTR:
255
+ *range = *pt->range_signed;
256
+ break;
257
+ case NLA_VALIDATE_MIN:
258
+ range->min = pt->min;
259
+ break;
260
+ case NLA_VALIDATE_MAX:
261
+ range->max = pt->max;
262
+ break;
263
+ default:
264
+ break;
265
+ }
266
+}
267
+
268
+static int nla_validate_int_range_signed(const struct nla_policy *pt,
269
+ const struct nlattr *nla,
270
+ struct netlink_ext_ack *extack)
271
+{
272
+ struct netlink_range_validation_signed range;
273
+ s64 value;
274
+
275
+ switch (pt->type) {
276
+ case NLA_S8:
277
+ value = nla_get_s8(nla);
278
+ break;
279
+ case NLA_S16:
280
+ value = nla_get_s16(nla);
281
+ break;
282
+ case NLA_S32:
283
+ value = nla_get_s32(nla);
284
+ break;
285
+ case NLA_S64:
286
+ value = nla_get_s64(nla);
287
+ break;
288
+ default:
289
+ return -EINVAL;
290
+ }
291
+
292
+ nla_get_range_signed(pt, &range);
293
+
294
+ if (value < range.min || value > range.max) {
295
+ NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt,
296
+ "integer out of range");
297
+ return -ERANGE;
298
+ }
299
+
300
+ return 0;
301
+}
302
+
303
+static int nla_validate_int_range(const struct nla_policy *pt,
304
+ const struct nlattr *nla,
305
+ struct netlink_ext_ack *extack,
306
+ unsigned int validate)
307
+{
308
+ switch (pt->type) {
309
+ case NLA_U8:
310
+ case NLA_U16:
311
+ case NLA_U32:
312
+ case NLA_U64:
313
+ case NLA_MSECS:
314
+ case NLA_BINARY:
315
+ return nla_validate_range_unsigned(pt, nla, extack, validate);
316
+ case NLA_S8:
317
+ case NLA_S16:
318
+ case NLA_S32:
319
+ case NLA_S64:
320
+ return nla_validate_int_range_signed(pt, nla, extack);
321
+ default:
322
+ WARN_ON(1);
323
+ return -EINVAL;
324
+ }
325
+}
326
+
327
+static int nla_validate_mask(const struct nla_policy *pt,
328
+ const struct nlattr *nla,
329
+ struct netlink_ext_ack *extack)
330
+{
331
+ u64 value;
332
+
333
+ switch (pt->type) {
334
+ case NLA_U8:
335
+ value = nla_get_u8(nla);
336
+ break;
337
+ case NLA_U16:
338
+ value = nla_get_u16(nla);
339
+ break;
340
+ case NLA_U32:
341
+ value = nla_get_u32(nla);
342
+ break;
343
+ case NLA_U64:
344
+ value = nla_get_u64(nla);
345
+ break;
346
+ default:
347
+ return -EINVAL;
348
+ }
349
+
350
+ if (value & ~(u64)pt->mask) {
351
+ NL_SET_ERR_MSG_ATTR(extack, nla, "reserved bit set");
352
+ return -EINVAL;
353
+ }
354
+
355
+ return 0;
356
+}
357
+
358
+static int validate_nla(const struct nlattr *nla, int maxtype,
359
+ const struct nla_policy *policy, unsigned int validate,
360
+ struct netlink_ext_ack *extack, unsigned int depth)
361
+{
362
+ u16 strict_start_type = policy[0].strict_start_type;
74363 const struct nla_policy *pt;
75364 int minlen = 0, attrlen = nla_len(nla), type = nla_type(nla);
365
+ int err = -ERANGE;
366
+
367
+ if (strict_start_type && type >= strict_start_type)
368
+ validate |= NL_VALIDATE_STRICT;
76369
77370 if (type <= 0 || type > maxtype)
78371 return 0;
79372
373
+ type = array_index_nospec(type, maxtype + 1);
80374 pt = &policy[type];
81375
82376 BUG_ON(pt->type > NLA_TYPE_MAX);
....@@ -84,19 +378,51 @@
84378 if (nla_attr_len[pt->type] && attrlen != nla_attr_len[pt->type]) {
85379 pr_warn_ratelimited("netlink: '%s': attribute type %d has an invalid length.\n",
86380 current->comm, type);
381
+ if (validate & NL_VALIDATE_STRICT_ATTRS) {
382
+ NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt,
383
+ "invalid attribute length");
384
+ return -EINVAL;
385
+ }
386
+ }
387
+
388
+ if (validate & NL_VALIDATE_NESTED) {
389
+ if ((pt->type == NLA_NESTED || pt->type == NLA_NESTED_ARRAY) &&
390
+ !(nla->nla_type & NLA_F_NESTED)) {
391
+ NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt,
392
+ "NLA_F_NESTED is missing");
393
+ return -EINVAL;
394
+ }
395
+ if (pt->type != NLA_NESTED && pt->type != NLA_NESTED_ARRAY &&
396
+ pt->type != NLA_UNSPEC && (nla->nla_type & NLA_F_NESTED)) {
397
+ NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt,
398
+ "NLA_F_NESTED not expected");
399
+ return -EINVAL;
400
+ }
87401 }
88402
89403 switch (pt->type) {
404
+ case NLA_REJECT:
405
+ if (extack && pt->reject_message) {
406
+ NL_SET_BAD_ATTR(extack, nla);
407
+ extack->_msg = pt->reject_message;
408
+ return -EINVAL;
409
+ }
410
+ err = -EINVAL;
411
+ goto out_err;
412
+
90413 case NLA_FLAG:
91414 if (attrlen > 0)
92
- return -ERANGE;
415
+ goto out_err;
93416 break;
94417
95418 case NLA_BITFIELD32:
96419 if (attrlen != sizeof(struct nla_bitfield32))
97
- return -ERANGE;
420
+ goto out_err;
98421
99
- return validate_nla_bitfield32(nla, pt->validation_data);
422
+ err = validate_nla_bitfield32(nla, pt->bitfield32_valid);
423
+ if (err)
424
+ goto out_err;
425
+ break;
100426
101427 case NLA_NUL_STRING:
102428 if (pt->len)
....@@ -104,13 +430,15 @@
104430 else
105431 minlen = attrlen;
106432
107
- if (!minlen || memchr(nla_data(nla), '\0', minlen) == NULL)
108
- return -EINVAL;
433
+ if (!minlen || memchr(nla_data(nla), '\0', minlen) == NULL) {
434
+ err = -EINVAL;
435
+ goto out_err;
436
+ }
109437 /* fall through */
110438
111439 case NLA_STRING:
112440 if (attrlen < 1)
113
- return -ERANGE;
441
+ goto out_err;
114442
115443 if (pt->len) {
116444 char *buf = nla_data(nla);
....@@ -119,79 +447,193 @@
119447 attrlen--;
120448
121449 if (attrlen > pt->len)
122
- return -ERANGE;
450
+ goto out_err;
123451 }
124452 break;
125453
126454 case NLA_BINARY:
127455 if (pt->len && attrlen > pt->len)
128
- return -ERANGE;
456
+ goto out_err;
129457 break;
130458
131
- case NLA_NESTED_COMPAT:
132
- if (attrlen < pt->len)
133
- return -ERANGE;
134
- if (attrlen < NLA_ALIGN(pt->len))
135
- break;
136
- if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN)
137
- return -ERANGE;
138
- nla = nla_data(nla) + NLA_ALIGN(pt->len);
139
- if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN + nla_len(nla))
140
- return -ERANGE;
141
- break;
142459 case NLA_NESTED:
143460 /* a nested attributes is allowed to be empty; if its not,
144461 * it must have a size of at least NLA_HDRLEN.
145462 */
146463 if (attrlen == 0)
147464 break;
465
+ if (attrlen < NLA_HDRLEN)
466
+ goto out_err;
467
+ if (pt->nested_policy) {
468
+ err = __nla_validate_parse(nla_data(nla), nla_len(nla),
469
+ pt->len, pt->nested_policy,
470
+ validate, extack, NULL,
471
+ depth + 1);
472
+ if (err < 0) {
473
+ /*
474
+ * return directly to preserve the inner
475
+ * error message/attribute pointer
476
+ */
477
+ return err;
478
+ }
479
+ }
480
+ break;
481
+ case NLA_NESTED_ARRAY:
482
+ /* a nested array attribute is allowed to be empty; if its not,
483
+ * it must have a size of at least NLA_HDRLEN.
484
+ */
485
+ if (attrlen == 0)
486
+ break;
487
+ if (attrlen < NLA_HDRLEN)
488
+ goto out_err;
489
+ if (pt->nested_policy) {
490
+ int err;
491
+
492
+ err = nla_validate_array(nla_data(nla), nla_len(nla),
493
+ pt->len, pt->nested_policy,
494
+ extack, validate, depth);
495
+ if (err < 0) {
496
+ /*
497
+ * return directly to preserve the inner
498
+ * error message/attribute pointer
499
+ */
500
+ return err;
501
+ }
502
+ }
503
+ break;
504
+
505
+ case NLA_UNSPEC:
506
+ if (validate & NL_VALIDATE_UNSPEC) {
507
+ NL_SET_ERR_MSG_ATTR(extack, nla,
508
+ "Unsupported attribute");
509
+ return -EINVAL;
510
+ }
511
+ if (attrlen < pt->len)
512
+ goto out_err;
513
+ break;
514
+
148515 default:
149516 if (pt->len)
150517 minlen = pt->len;
151
- else if (pt->type != NLA_UNSPEC)
518
+ else
152519 minlen = nla_attr_minlen[pt->type];
153520
154521 if (attrlen < minlen)
155
- return -ERANGE;
522
+ goto out_err;
523
+ }
524
+
525
+ /* further validation */
526
+ switch (pt->validation_type) {
527
+ case NLA_VALIDATE_NONE:
528
+ /* nothing to do */
529
+ break;
530
+ case NLA_VALIDATE_RANGE_PTR:
531
+ case NLA_VALIDATE_RANGE:
532
+ case NLA_VALIDATE_RANGE_WARN_TOO_LONG:
533
+ case NLA_VALIDATE_MIN:
534
+ case NLA_VALIDATE_MAX:
535
+ err = nla_validate_int_range(pt, nla, extack, validate);
536
+ if (err)
537
+ return err;
538
+ break;
539
+ case NLA_VALIDATE_MASK:
540
+ err = nla_validate_mask(pt, nla, extack);
541
+ if (err)
542
+ return err;
543
+ break;
544
+ case NLA_VALIDATE_FUNCTION:
545
+ if (pt->validate) {
546
+ err = pt->validate(nla, extack);
547
+ if (err)
548
+ return err;
549
+ }
550
+ break;
551
+ }
552
+
553
+ return 0;
554
+out_err:
555
+ NL_SET_ERR_MSG_ATTR_POL(extack, nla, pt,
556
+ "Attribute failed policy validation");
557
+ return err;
558
+}
559
+
560
+static int __nla_validate_parse(const struct nlattr *head, int len, int maxtype,
561
+ const struct nla_policy *policy,
562
+ unsigned int validate,
563
+ struct netlink_ext_ack *extack,
564
+ struct nlattr **tb, unsigned int depth)
565
+{
566
+ const struct nlattr *nla;
567
+ int rem;
568
+
569
+ if (depth >= MAX_POLICY_RECURSION_DEPTH) {
570
+ NL_SET_ERR_MSG(extack,
571
+ "allowed policy recursion depth exceeded");
572
+ return -EINVAL;
573
+ }
574
+
575
+ if (tb)
576
+ memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
577
+
578
+ nla_for_each_attr(nla, head, len, rem) {
579
+ u16 type = nla_type(nla);
580
+
581
+ if (type == 0 || type > maxtype) {
582
+ if (validate & NL_VALIDATE_MAXTYPE) {
583
+ NL_SET_ERR_MSG_ATTR(extack, nla,
584
+ "Unknown attribute type");
585
+ return -EINVAL;
586
+ }
587
+ continue;
588
+ }
589
+ type = array_index_nospec(type, maxtype + 1);
590
+ if (policy) {
591
+ int err = validate_nla(nla, maxtype, policy,
592
+ validate, extack, depth);
593
+
594
+ if (err < 0)
595
+ return err;
596
+ }
597
+
598
+ if (tb)
599
+ tb[type] = (struct nlattr *)nla;
600
+ }
601
+
602
+ if (unlikely(rem > 0)) {
603
+ pr_warn_ratelimited("netlink: %d bytes leftover after parsing attributes in process `%s'.\n",
604
+ rem, current->comm);
605
+ NL_SET_ERR_MSG(extack, "bytes leftover after parsing attributes");
606
+ if (validate & NL_VALIDATE_TRAILING)
607
+ return -EINVAL;
156608 }
157609
158610 return 0;
159611 }
160612
161613 /**
162
- * nla_validate - Validate a stream of attributes
614
+ * __nla_validate - Validate a stream of attributes
163615 * @head: head of attribute stream
164616 * @len: length of attribute stream
165617 * @maxtype: maximum attribute type to be expected
166618 * @policy: validation policy
619
+ * @validate: validation strictness
167620 * @extack: extended ACK report struct
168621 *
169622 * Validates all attributes in the specified attribute stream against the
170
- * specified policy. Attributes with a type exceeding maxtype will be
171
- * ignored. See documenation of struct nla_policy for more details.
623
+ * specified policy. Validation depends on the validate flags passed, see
624
+ * &enum netlink_validation for more details on that.
625
+ * See documenation of struct nla_policy for more details.
172626 *
173627 * Returns 0 on success or a negative error code.
174628 */
175
-int nla_validate(const struct nlattr *head, int len, int maxtype,
176
- const struct nla_policy *policy,
177
- struct netlink_ext_ack *extack)
629
+int __nla_validate(const struct nlattr *head, int len, int maxtype,
630
+ const struct nla_policy *policy, unsigned int validate,
631
+ struct netlink_ext_ack *extack)
178632 {
179
- const struct nlattr *nla;
180
- int rem;
181
-
182
- nla_for_each_attr(nla, head, len, rem) {
183
- int err = validate_nla(nla, maxtype, policy);
184
-
185
- if (err < 0) {
186
- if (extack)
187
- extack->bad_attr = nla;
188
- return err;
189
- }
190
- }
191
-
192
- return 0;
633
+ return __nla_validate_parse(head, len, maxtype, policy, validate,
634
+ extack, NULL, 0);
193635 }
194
-EXPORT_SYMBOL(nla_validate);
636
+EXPORT_SYMBOL(__nla_validate);
195637
196638 /**
197639 * nla_policy_len - Determin the max. length of a policy
....@@ -223,55 +665,30 @@
223665 EXPORT_SYMBOL(nla_policy_len);
224666
225667 /**
226
- * nla_parse - Parse a stream of attributes into a tb buffer
668
+ * __nla_parse - Parse a stream of attributes into a tb buffer
227669 * @tb: destination array with maxtype+1 elements
228670 * @maxtype: maximum attribute type to be expected
229671 * @head: head of attribute stream
230672 * @len: length of attribute stream
231673 * @policy: validation policy
674
+ * @validate: validation strictness
675
+ * @extack: extended ACK pointer
232676 *
233677 * Parses a stream of attributes and stores a pointer to each attribute in
234
- * the tb array accessible via the attribute type. Attributes with a type
235
- * exceeding maxtype will be silently ignored for backwards compatibility
236
- * reasons. policy may be set to NULL if no validation is required.
678
+ * the tb array accessible via the attribute type.
679
+ * Validation is controlled by the @validate parameter.
237680 *
238681 * Returns 0 on success or a negative error code.
239682 */
240
-int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,
241
- int len, const struct nla_policy *policy,
242
- struct netlink_ext_ack *extack)
683
+int __nla_parse(struct nlattr **tb, int maxtype,
684
+ const struct nlattr *head, int len,
685
+ const struct nla_policy *policy, unsigned int validate,
686
+ struct netlink_ext_ack *extack)
243687 {
244
- const struct nlattr *nla;
245
- int rem, err;
246
-
247
- memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
248
-
249
- nla_for_each_attr(nla, head, len, rem) {
250
- u16 type = nla_type(nla);
251
-
252
- if (type > 0 && type <= maxtype) {
253
- if (policy) {
254
- err = validate_nla(nla, maxtype, policy);
255
- if (err < 0) {
256
- NL_SET_ERR_MSG_ATTR(extack, nla,
257
- "Attribute failed policy validation");
258
- goto errout;
259
- }
260
- }
261
-
262
- tb[type] = (struct nlattr *)nla;
263
- }
264
- }
265
-
266
- if (unlikely(rem > 0))
267
- pr_warn_ratelimited("netlink: %d bytes leftover after parsing attributes in process `%s'.\n",
268
- rem, current->comm);
269
-
270
- err = 0;
271
-errout:
272
- return err;
688
+ return __nla_validate_parse(head, len, maxtype, policy, validate,
689
+ extack, tb, 0);
273690 }
274
-EXPORT_SYMBOL(nla_parse);
691
+EXPORT_SYMBOL(__nla_parse);
275692
276693 /**
277694 * nla_find - Find a specific attribute in a stream of attributes
....@@ -457,8 +874,7 @@
457874 struct nlattr *__nla_reserve_64bit(struct sk_buff *skb, int attrtype,
458875 int attrlen, int padattr)
459876 {
460
- if (nla_need_padding_for_64bit(skb))
461
- nla_align_64bit(skb, padattr);
877
+ nla_align_64bit(skb, padattr);
462878
463879 return __nla_reserve(skb, attrtype, attrlen);
464880 }