Repository navigation
Commit bf64ff4
genetlink: get rid of family->attrbuf
genl_family_rcv_msg_attrs_parse() reuses the global family->attrbuf
when family->parallel_ops is false. However, family->attrbuf is not
protected by any lock on the genl_family_rcv_msg_doit() code path.
This leads to several different consequences, one of them is UAF,
like the following:
genl_family_rcv_msg_doit(): genl_start():
genl_family_rcv_msg_attrs_parse()
attrbuf = family->attrbuf
__nlmsg_parse(attrbuf);
genl_family_rcv_msg_attrs_parse()
attrbuf = family->attrbuf
__nlmsg_parse(attrbuf);
info->attrs = attrs;
cb->data = info;
netlink_unicast_kernel():
consume_skb()
genl_lock_dumpit():
genl_dumpit_info(cb)->attrs
Note family->attrbuf is an array of pointers to the skb data, once
the skb is freed, any dereference of family->attrbuf will be a UAF.
Maybe we could serialize the family->attrbuf with genl_mutex too, but
that would make the locking more complicated. Instead, we can just get
rid of family->attrbuf and always allocate attrbuf from heap like the
family->parallel_ops==true code path. This may add some performance
overhead but comparing with taking the global genl_mutex, it still
looks better.
Fixes: 75cdbdd ("net: ieee802154: have genetlink code to parse the attrs during dumpit")
Fixes: 057af70 ("net: tipc: have genetlink code to parse the attrs during dumpit")
Reported-and-tested-by: syzbot+3039ddf6d7b13daf3787@syzkaller.appspotmail.com
Reported-and-tested-by: syzbot+80cad1e3cb4c41cde6ff@syzkaller.appspotmail.com
Reported-and-tested-by: syzbot+736bcbcb11b60d0c0792@syzkaller.appspotmail.com
Reported-and-tested-by: syzbot+520f8704db2b68091d44@syzkaller.appspotmail.com
Reported-and-tested-by: syzbot+c96e4dfb32f8987fdeed@syzkaller.appspotmail.com
Cc: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>1 parent 33c568b commit bf64ff4
2 files changed
Lines changed: 13 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
69 | | - | |
70 | 68 | | |
71 | 69 | | |
72 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
351 | 351 | | |
352 | 352 | | |
353 | 353 | | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | 354 | | |
366 | 355 | | |
367 | 356 | | |
368 | 357 | | |
369 | | - | |
| 358 | + | |
370 | 359 | | |
371 | 360 | | |
372 | 361 | | |
| |||
385 | 374 | | |
386 | 375 | | |
387 | 376 | | |
388 | | - | |
389 | | - | |
390 | 377 | | |
391 | 378 | | |
392 | 379 | | |
| |||
419 | 406 | | |
420 | 407 | | |
421 | 408 | | |
422 | | - | |
423 | | - | |
424 | 409 | | |
425 | 410 | | |
426 | 411 | | |
| |||
485 | 470 | | |
486 | 471 | | |
487 | 472 | | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
496 | 477 | | |
497 | 478 | | |
498 | 479 | | |
499 | 480 | | |
500 | | - | |
501 | | - | |
| 481 | + | |
502 | 482 | | |
503 | 483 | | |
504 | 484 | | |
505 | 485 | | |
506 | 486 | | |
507 | | - | |
508 | | - | |
| 487 | + | |
509 | 488 | | |
510 | | - | |
511 | | - | |
| 489 | + | |
512 | 490 | | |
513 | 491 | | |
514 | 492 | | |
| |||
542 | 520 | | |
543 | 521 | | |
544 | 522 | | |
545 | | - | |
| 523 | + | |
546 | 524 | | |
547 | 525 | | |
548 | 526 | | |
| |||
559 | 537 | | |
560 | 538 | | |
561 | 539 | | |
562 | | - | |
| 540 | + | |
563 | 541 | | |
564 | 542 | | |
565 | 543 | | |
| |||
588 | 566 | | |
589 | 567 | | |
590 | 568 | | |
591 | | - | |
| 569 | + | |
592 | 570 | | |
593 | 571 | | |
594 | 572 | | |
| |||
601 | 579 | | |
602 | 580 | | |
603 | 581 | | |
604 | | - | |
| 582 | + | |
605 | 583 | | |
606 | 584 | | |
607 | 585 | | |
| |||
694 | 672 | | |
695 | 673 | | |
696 | 674 | | |
697 | | - | |
| 675 | + | |
698 | 676 | | |
699 | 677 | | |
700 | 678 | | |
| |||
0 commit comments