Commit ea01007
net/rds: fix warn in rds_message_alloc_sgs
redundant copy_from_user in rds_sendmsg system call expose rds
to issue where rds_rdma_extra_size walk the rds iovec and and
calculate the number pf pages (sgs) it need to add to the tail of
rds message and later rds_cmsg_rdma_args copy the rds iovec again
and re calculate the same number and get different result causing
WARN_ON in rds_message_alloc_sgs.
fix this by doing the copy_from_user only once per rds_sendmsg
system call.
When issue occur the below dump is seen:
WARNING: CPU: 0 PID: 19789 at net/rds/message.c:316 rds_message_alloc_sgs+0x10c/0x160 net/rds/message.c:316
Kernel panic - not syncing: panic_on_warn set ...
CPU: 0 PID: 19789 Comm: syz-executor827 Not tainted 4.19.0-next-20181030+ #101
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x244/0x39d lib/dump_stack.c:113
panic+0x2ad/0x55c kernel/panic.c:188
__warn.cold.8+0x20/0x45 kernel/panic.c:540
report_bug+0x254/0x2d0 lib/bug.c:186
fixup_bug arch/x86/kernel/traps.c:178 [inline]
do_error_trap+0x11b/0x200 arch/x86/kernel/traps.c:271
do_invalid_op+0x36/0x40 arch/x86/kernel/traps.c:290
invalid_op+0x14/0x20 arch/x86/entry/entry_64.S:969
RIP: 0010:rds_message_alloc_sgs+0x10c/0x160 net/rds/message.c:316
Code: c0 74 04 3c 03 7e 6c 44 01 ab 78 01 00 00 e8 2b 9e 35 fa 4c 89 e0 48 83 c4 08 5b 41 5c 41 5d 41 5e 41 5f 5d c3 e8 14 9e 35 fa <0f> 0b 31 ff 44 89 ee e8 18 9f 35 fa 45 85 ed 75 1b e8 fe 9d 35 fa
RSP: 0018:ffff8801c51b7460 EFLAGS: 00010293
RAX: ffff8801bc412080 RBX: ffff8801d7bf4040 RCX: ffffffff8749c9e6
RDX: 0000000000000000 RSI: ffffffff8749ca5c RDI: 0000000000000004
RBP: ffff8801c51b7490 R08: ffff8801bc412080 R09: ffffed003b5c5b67
R10: ffffed003b5c5b67 R11: ffff8801dae2db3b R12: 0000000000000000
R13: 000000000007165c R14: 000000000007165c R15: 0000000000000005
rds_cmsg_rdma_args+0x82d/0x1510 net/rds/rdma.c:623
rds_cmsg_send net/rds/send.c:971 [inline]
rds_sendmsg+0x19a2/0x3180 net/rds/send.c:1273
sock_sendmsg_nosec net/socket.c:622 [inline]
sock_sendmsg+0xd5/0x120 net/socket.c:632
___sys_sendmsg+0x7fd/0x930 net/socket.c:2117
__sys_sendmsg+0x11d/0x280 net/socket.c:2155
__do_sys_sendmsg net/socket.c:2164 [inline]
__se_sys_sendmsg net/socket.c:2162 [inline]
__x64_sys_sendmsg+0x78/0xb0 net/socket.c:2162
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x44a859
Code: e8 dc e6 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 6b cb fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f1d4710ada8 EFLAGS: 00000297 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00000000006dcc28 RCX: 000000000044a859
RDX: 0000000000000000 RSI: 0000000020001600 RDI: 0000000000000003
RBP: 00000000006dcc20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000297 R12: 00000000006dcc2c
R13: 646e732f7665642f R14: 00007f1d4710b9c0 R15: 00000000006dcd2c
Kernel Offset: disabled
Rebooting in 86400 seconds..
Reported-by: syzbot+26de17458aeda9d305d8@syzkaller.appspotmail.com
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: shamir rabinovitch <shamir.rabinovitch@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>1 parent c6f4075 commit ea01007
3 files changed
+91
-42
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
517 | 517 | | |
518 | 518 | | |
519 | 519 | | |
520 | | - | |
| 520 | + | |
| 521 | + | |
521 | 522 | | |
522 | | - | |
| 523 | + | |
523 | 524 | | |
524 | 525 | | |
525 | 526 | | |
| |||
530 | 531 | | |
531 | 532 | | |
532 | 533 | | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
533 | 547 | | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
| 548 | + | |
538 | 549 | | |
539 | | - | |
| 550 | + | |
540 | 551 | | |
541 | 552 | | |
542 | 553 | | |
| |||
558 | 569 | | |
559 | 570 | | |
560 | 571 | | |
561 | | - | |
| 572 | + | |
| 573 | + | |
562 | 574 | | |
563 | 575 | | |
564 | 576 | | |
565 | 577 | | |
566 | 578 | | |
567 | 579 | | |
568 | | - | |
569 | | - | |
| 580 | + | |
570 | 581 | | |
571 | 582 | | |
572 | 583 | | |
| |||
586 | 597 | | |
587 | 598 | | |
588 | 599 | | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | | - | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
597 | 603 | | |
598 | 604 | | |
599 | | - | |
600 | | - | |
601 | | - | |
602 | | - | |
| 605 | + | |
603 | 606 | | |
604 | 607 | | |
605 | 608 | | |
606 | 609 | | |
607 | | - | |
| 610 | + | |
608 | 611 | | |
609 | 612 | | |
610 | 613 | | |
611 | 614 | | |
612 | 615 | | |
613 | | - | |
| 616 | + | |
614 | 617 | | |
615 | 618 | | |
616 | 619 | | |
| |||
623 | 626 | | |
624 | 627 | | |
625 | 628 | | |
626 | | - | |
| 629 | + | |
627 | 630 | | |
628 | 631 | | |
629 | 632 | | |
| |||
635 | 638 | | |
636 | 639 | | |
637 | 640 | | |
638 | | - | |
| 641 | + | |
639 | 642 | | |
640 | 643 | | |
641 | 644 | | |
| |||
681 | 684 | | |
682 | 685 | | |
683 | 686 | | |
684 | | - | |
| 687 | + | |
685 | 688 | | |
686 | 689 | | |
687 | 690 | | |
| |||
714 | 717 | | |
715 | 718 | | |
716 | 719 | | |
717 | | - | |
| 720 | + | |
718 | 721 | | |
719 | 722 | | |
720 | 723 | | |
721 | | - | |
722 | | - | |
723 | | - | |
| 724 | + | |
724 | 725 | | |
725 | 726 | | |
726 | 727 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
389 | 401 | | |
390 | 402 | | |
391 | 403 | | |
| |||
904 | 916 | | |
905 | 917 | | |
906 | 918 | | |
907 | | - | |
908 | | - | |
909 | | - | |
| 919 | + | |
| 920 | + | |
910 | 921 | | |
911 | 922 | | |
912 | 923 | | |
913 | | - | |
| 924 | + | |
| 925 | + | |
914 | 926 | | |
915 | 927 | | |
916 | 928 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
876 | 876 | | |
877 | 877 | | |
878 | 878 | | |
879 | | - | |
| 879 | + | |
| 880 | + | |
880 | 881 | | |
881 | 882 | | |
882 | 883 | | |
883 | 884 | | |
884 | 885 | | |
885 | 886 | | |
| 887 | + | |
886 | 888 | | |
887 | 889 | | |
888 | 890 | | |
| |||
893 | 895 | | |
894 | 896 | | |
895 | 897 | | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
896 | 914 | | |
897 | | - | |
| 915 | + | |
898 | 916 | | |
899 | 917 | | |
900 | 918 | | |
| |||
951 | 969 | | |
952 | 970 | | |
953 | 971 | | |
954 | | - | |
| 972 | + | |
| 973 | + | |
955 | 974 | | |
956 | 975 | | |
957 | | - | |
| 976 | + | |
958 | 977 | | |
959 | 978 | | |
960 | 979 | | |
| |||
968 | 987 | | |
969 | 988 | | |
970 | 989 | | |
971 | | - | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
972 | 994 | | |
973 | 995 | | |
974 | 996 | | |
| |||
1084 | 1106 | | |
1085 | 1107 | | |
1086 | 1108 | | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
1087 | 1114 | | |
1088 | 1115 | | |
1089 | 1116 | | |
| |||
1220 | 1247 | | |
1221 | 1248 | | |
1222 | 1249 | | |
1223 | | - | |
| 1250 | + | |
1224 | 1251 | | |
1225 | 1252 | | |
1226 | 1253 | | |
| |||
1270 | 1297 | | |
1271 | 1298 | | |
1272 | 1299 | | |
1273 | | - | |
| 1300 | + | |
1274 | 1301 | | |
1275 | 1302 | | |
1276 | 1303 | | |
| |||
1348 | 1375 | | |
1349 | 1376 | | |
1350 | 1377 | | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
1351 | 1383 | | |
1352 | 1384 | | |
1353 | 1385 | | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
1354 | 1390 | | |
1355 | 1391 | | |
1356 | 1392 | | |
| |||
0 commit comments