Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cxl: Fix off by one error allowing subsequent mmap page to be accessed

It was discovered that if a process mmaped their problem state area they
were able to access one page more than expected, potentially allowing
them to access the problem state area of an unrelated process.

This was due to a simple off by one error in the mmap fault handler
introduced in 0712dc7e73e59d79bcead5d5520acf4e9e917e87 ("cxl: Fix issues
when unmapping contexts"), which is fixed in this patch.

Cc: stable@vger.kernel.org
Fixes: 0712dc7e73e5 ("cxl: Fix issues when unmapping contexts")
Signed-off-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Ian Munsie and committed by
Michael Ellerman
10a5894f 5caaf534

+2 -2
+2 -2
drivers/misc/cxl/context.c
··· 113 113 114 114 if (ctx->afu->current_mode == CXL_MODE_DEDICATED) { 115 115 area = ctx->afu->psn_phys; 116 - if (offset > ctx->afu->adapter->ps_size) 116 + if (offset >= ctx->afu->adapter->ps_size) 117 117 return VM_FAULT_SIGBUS; 118 118 } else { 119 119 area = ctx->psn_phys; 120 - if (offset > ctx->psn_size) 120 + if (offset >= ctx->psn_size) 121 121 return VM_FAULT_SIGBUS; 122 122 } 123 123