From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E0DBC64EC4 for ; Fri, 10 Mar 2023 14:28:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232419AbjCJO2A (ORCPT ); Fri, 10 Mar 2023 09:28:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232253AbjCJO1n (ORCPT ); Fri, 10 Mar 2023 09:27:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87D89121431 for ; Fri, 10 Mar 2023 06:26:12 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EF3FF61745 for ; Fri, 10 Mar 2023 14:26:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FE58C433D2; Fri, 10 Mar 2023 14:26:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678458371; bh=h8x5Ys3GcAwhkVCB6D8L7pZJidYLCZKoqGpbrnPzUhk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yEBCZqBHtBC72XqyQ4jhRkN65xOwMKKfRQ6MbLuuIJmi1aymT9dHXZ5wLW5nHZLtT MlC4IAEJPuyQtBbBEG3nrCNSxjaVPrTHnPEj7QjvPT9voZdPbiGlm4BQKlKKXNVLnk WqH9QostPxIFL+KhBOTzGap+N13MYwPTy5O35GjM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jiri Slaby , George Kennedy , Linus Torvalds , Sasha Levin Subject: [PATCH 4.19 227/252] vc_screen: modify vcs_size() handling in vcs_read() Date: Fri, 10 Mar 2023 14:39:57 +0100 Message-Id: <20230310133726.146605026@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230310133718.803482157@linuxfoundation.org> References: <20230310133718.803482157@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: George Kennedy [ 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 Signed-off-by: George Kennedy Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- drivers/tty/vt/vc_screen.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c index 5b5e800ab1549..28bc9c70de3ec 100644 --- a/drivers/tty/vt/vc_screen.c +++ b/drivers/tty/vt/vc_screen.c @@ -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; -- 2.39.2