Commit db10cb9
committed
virt: sevguest: Fix passing a stack buffer as a scatterlist target
CONFIG_DEBUG_SG highlights that get_{report,ext_report,derived_key)()}
are passing stack buffers as the @req_buf argument to
handle_guest_request(), generating a Call Trace of the following form:
WARNING: CPU: 0 PID: 1175 at include/linux/scatterlist.h:187 enc_dec_message+0x518/0x5b0 [sev_guest]
[..]
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/26/2023
RIP: 0010:enc_dec_message+0x518/0x5b0 [sev_guest]
Call Trace:
<TASK>
[..]
handle_guest_request+0x135/0x520 [sev_guest]
get_ext_report+0x1ec/0x3e0 [sev_guest]
snp_guest_ioctl+0x157/0x200 [sev_guest]
Note that the above Call Trace was with the DEBUG_SG BUG_ON()s converted
to WARN_ON()s.
This is benign as long as there are no hardware crypto accelerators
loaded for the aead cipher, and no subsequent dma_map_sg() is performed
on the scatterlist. However, sev-guest can not assume the presence of
an aead accelerator nor can it assume that CONFIG_DEBUG_SG is disabled.
Resolve this bug by allocating virt_addr_valid() memory, similar to the
other buffers am @snp_dev instance carries, to marshal requests from
user buffers to kernel buffers.
Reported-by: Peter Gonda <pgonda@google.com>
Closes: http://lore.kernel.org/r/CAMkAt6r2VPPMZ__SQfJse8qWsUyYW3AgYbOUVM0S_Vtk=KvkxQ@mail.gmail.com
Fixes: fce96cf ("virt: Add SEV-SNP guest driver")
Cc: Borislav Petkov <bp@alien8.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Dionna Glaze <dionnaglaze@google.com>
Cc: Jeremi Piotrowski <jpiotrowski@linux.microsoft.com>
Tested-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>1 parent 6465e26 commit db10cb9
1 file changed
Lines changed: 25 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
60 | 65 | | |
61 | 66 | | |
62 | 67 | | |
| |||
473 | 478 | | |
474 | 479 | | |
475 | 480 | | |
| 481 | + | |
476 | 482 | | |
477 | | - | |
478 | 483 | | |
479 | 484 | | |
480 | 485 | | |
481 | 486 | | |
482 | 487 | | |
483 | 488 | | |
484 | 489 | | |
485 | | - | |
| 490 | + | |
486 | 491 | | |
487 | 492 | | |
488 | 493 | | |
| |||
496 | 501 | | |
497 | 502 | | |
498 | 503 | | |
499 | | - | |
| 504 | + | |
500 | 505 | | |
501 | 506 | | |
502 | 507 | | |
| |||
511 | 516 | | |
512 | 517 | | |
513 | 518 | | |
| 519 | + | |
514 | 520 | | |
515 | 521 | | |
516 | | - | |
517 | 522 | | |
518 | 523 | | |
519 | 524 | | |
| |||
532 | 537 | | |
533 | 538 | | |
534 | 539 | | |
535 | | - | |
| 540 | + | |
536 | 541 | | |
537 | 542 | | |
538 | 543 | | |
539 | | - | |
| 544 | + | |
540 | 545 | | |
541 | 546 | | |
542 | 547 | | |
| |||
552 | 557 | | |
553 | 558 | | |
554 | 559 | | |
| 560 | + | |
555 | 561 | | |
556 | | - | |
557 | 562 | | |
558 | 563 | | |
559 | 564 | | |
| |||
562 | 567 | | |
563 | 568 | | |
564 | 569 | | |
565 | | - | |
| 570 | + | |
566 | 571 | | |
567 | 572 | | |
568 | 573 | | |
569 | | - | |
| 574 | + | |
570 | 575 | | |
571 | 576 | | |
572 | | - | |
573 | | - | |
| 577 | + | |
| 578 | + | |
574 | 579 | | |
575 | 580 | | |
576 | | - | |
| 581 | + | |
577 | 582 | | |
578 | 583 | | |
579 | 584 | | |
| |||
582 | 587 | | |
583 | 588 | | |
584 | 589 | | |
585 | | - | |
586 | | - | |
| 590 | + | |
| 591 | + | |
587 | 592 | | |
588 | 593 | | |
589 | 594 | | |
| |||
597 | 602 | | |
598 | 603 | | |
599 | 604 | | |
600 | | - | |
601 | | - | |
| 605 | + | |
| 606 | + | |
602 | 607 | | |
603 | 608 | | |
604 | 609 | | |
605 | | - | |
| 610 | + | |
606 | 611 | | |
607 | | - | |
| 612 | + | |
608 | 613 | | |
609 | 614 | | |
610 | 615 | | |
611 | 616 | | |
612 | 617 | | |
613 | 618 | | |
614 | 619 | | |
615 | | - | |
616 | | - | |
| 620 | + | |
| 621 | + | |
617 | 622 | | |
618 | 623 | | |
619 | 624 | | |
| |||
0 commit comments