]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
vc_screen: modify vcs_size() handling in vcs_read()
authorGeorge Kennedy <george.kennedy@oracle.com>
Mon, 27 Feb 2023 20:21:41 +0000 (15:21 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 15:31:59 +0000 (16:31 +0100)
[ Upstream commit 46d733d0efc79bc8430d63b57ab88011806d5180 ]

Restore the vcs_size() handling in vcs_read() to what
it had been in previous version.

Fixes: 226fae124b2d ("vc_screen: move load of struct vc_data pointer in vcs_read() to avoid UAF")
Suggested-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: George Kennedy <george.kennedy@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tty/vt/vc_screen.c

index 5b5e800ab15490919606f95ee147e587d0c75473..28bc9c70de3ec56b7e87a26e94d89c213bc1ea97 100644 (file)
@@ -278,10 +278,8 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
                 */
                size = vcs_size(inode);
                if (size < 0) {
-                       if (read)
-                               break;
                        ret = size;
-                       goto unlock_out;
+                       break;
                }
                if (pos >= size)
                        break;