Skip to content

Commit ab0a0dd

Browse files
oberparmehmetb0
authored andcommitted
s390/sclp: Prevent release of buffer in I/O
BugLink: https://bugs.launchpad.net/bugs/2083656 [ Upstream commit bf365071ea92b9579d5a272679b74052a5643e35 ] When a task waiting for completion of a Store Data operation is interrupted, an attempt is made to halt this operation. If this attempt fails due to a hardware or firmware problem, there is a chance that the SCLP facility might store data into buffers referenced by the original operation at a later time. Handle this situation by not releasing the referenced data buffers if the halt attempt fails. For current use cases, this might result in a leak of few pages of memory in case of a rare hardware/firmware malfunction. Reviewed-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
1 parent 11508b2 commit ab0a0dd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/s390/char/sclp_sd.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,14 @@ static int sclp_sd_store_data(struct sclp_sd_data *result, u8 di)
320320
&esize);
321321
if (rc) {
322322
/* Cancel running request if interrupted */
323-
if (rc == -ERESTARTSYS)
324-
sclp_sd_sync(page, SD_EQ_HALT, di, 0, 0, NULL, NULL);
323+
if (rc == -ERESTARTSYS) {
324+
if (sclp_sd_sync(page, SD_EQ_HALT, di, 0, 0, NULL, NULL)) {
325+
pr_warn("Could not stop Store Data request - leaking at least %zu bytes\n",
326+
(size_t)dsize * PAGE_SIZE);
327+
data = NULL;
328+
asce = 0;
329+
}
330+
}
325331
vfree(data);
326332
goto out;
327333
}

0 commit comments

Comments
 (0)