Skip to content

Commit 23ca0c7

Browse files
committed
vc_screen: don't clobber return value in vcs_read
jira VULN-358 jira VULN-55184 cve-bf CVE-2023-3567 cve-bf CVE-2023-52973 commit-author Thomas Weißschuh <[email protected]> commit ae3419f Commit 226fae1 ("vc_screen: move load of struct vc_data pointer in vcs_read() to avoid UAF") moved the call to vcs_vc() into the loop. While doing this it also moved the unconditional assignment of ret = -ENXIO; This unconditional assignment was valid outside the loop but within it it clobbers the actual value of ret. To avoid this only assign "ret = -ENXIO" when actually needed. [ Also, the 'goto unlock_out" needs to be just a "break", so that it does the right thing when it exits on later iterations when partial success has happened - Linus ] Reported-by: Storm Dragon <[email protected]> Link: https://lore.kernel.org/lkml/Y%[email protected]/ Fixes: 226fae1 ("vc_screen: move load of struct vc_data pointer in vcs_read() to avoid UAF") Signed-off-by: Thomas Weißschuh <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Linus Torvalds <[email protected]> (cherry picked from commit ae3419f) Signed-off-by: Marcin Wcisło <[email protected]>
1 parent a09e234 commit 23ca0c7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/tty/vt/vc_screen.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,11 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
403403
unsigned int this_round, skip = 0;
404404
int size;
405405

406-
ret = -ENXIO;
407406
vc = vcs_vc(inode, &viewed);
408-
if (!vc)
409-
goto unlock_out;
407+
if (!vc) {
408+
ret = -ENXIO;
409+
break;
410+
}
410411

411412
/* Check whether we are above size each round,
412413
* as copy_to_user at the end of this loop

0 commit comments

Comments
 (0)