Skip to content

Commit b08d8d9

Browse files
pvts-matbmastbergen
authored andcommitted
powerpc/lib: Validate size for vector operations
jira VULN-8150 cve CVE-2023-52606 commit-author Naveen N Rao <[email protected]> commit 8f9abaa Some of the fp/vmx code in sstep.c assume a certain maximum size for the instructions being emulated. The size of those operations however is determined separately in analyse_instr(). Add a check to validate the assumption on the maximum size of the operations, so as to prevent any unintended kernel stack corruption. Signed-off-by: Naveen N Rao <[email protected]> Reviewed-by: Gustavo A. R. Silva <[email protected]> Build-tested-by: Gustavo A. R. Silva <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected] (cherry picked from commit 8f9abaa) Signed-off-by: Marcin Wcisło <[email protected]>
1 parent 26cdbdf commit b08d8d9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

arch/powerpc/lib/sstep.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,8 @@ static int do_fp_load(struct instruction_op *op, unsigned long ea,
591591
} u;
592592

593593
nb = GETSIZE(op->type);
594+
if (nb > sizeof(u))
595+
return -EINVAL;
594596
if (!address_ok(regs, ea, nb))
595597
return -EFAULT;
596598
rn = op->reg;
@@ -641,6 +643,8 @@ static int do_fp_store(struct instruction_op *op, unsigned long ea,
641643
} u;
642644

643645
nb = GETSIZE(op->type);
646+
if (nb > sizeof(u))
647+
return -EINVAL;
644648
if (!address_ok(regs, ea, nb))
645649
return -EFAULT;
646650
rn = op->reg;
@@ -685,6 +689,9 @@ static nokprobe_inline int do_vec_load(int rn, unsigned long ea,
685689
u8 b[sizeof(__vector128)];
686690
} u = {};
687691

692+
if (size > sizeof(u))
693+
return -EINVAL;
694+
688695
if (!address_ok(regs, ea & ~0xfUL, 16))
689696
return -EFAULT;
690697
/* align to multiple of size */
@@ -712,6 +719,9 @@ static nokprobe_inline int do_vec_store(int rn, unsigned long ea,
712719
u8 b[sizeof(__vector128)];
713720
} u;
714721

722+
if (size > sizeof(u))
723+
return -EINVAL;
724+
715725
if (!address_ok(regs, ea & ~0xfUL, 16))
716726
return -EFAULT;
717727
/* align to multiple of size */

0 commit comments

Comments
 (0)