mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Slaby <jirislaby@kernel.org>
To: linux@weissschuh.net, George Kennedy <george.kennedy@oracle.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
	Randy Dunlap <rdunlap@infradead.org>,
	Storm Dragon <stormdragon2976@gmail.com>
Subject: Re: [PATCH] vc_screen: don't clobber return value in vcs_read
Date: Mon, 20 Feb 2023 12:48:59 +0100	[thread overview]
Message-ID: <dcaaf7d5-b2d5-dbb9-f3fe-2232ee525cc8@kernel.org> (raw)
In-Reply-To: <20230220064612.1783-1-linux@weissschuh.net>

On 20. 02. 23, 7:46, linux@weissschuh.net wrote:
> From: Thomas Weißschuh <linux@weissschuh.net>
> 
> Commit 226fae124b2d
> ("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.

Not sure -- I cannot find it -- but hasn't George fixed this yet?

> Reported-by: Storm Dragon <stormdragon2976@gmail.com>
> Link: https://lore.kernel.org/lkml/Y%2FKS6vdql2pIsCiI@hotmail.com/
> Fixes: 226fae124b2d ("vc_screen: move load of struct vc_data pointer in vcs_read() to avoid UAF")
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> 
> ---
> 
> @Storm Could you validate this patch?
> ---
>   drivers/tty/vt/vc_screen.c | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c
> index f566eb1839dc..2ef519a40a87 100644
> --- a/drivers/tty/vt/vc_screen.c
> +++ b/drivers/tty/vt/vc_screen.c
> @@ -403,10 +403,11 @@ vcs_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
>   		unsigned int this_round, skip = 0;
>   		int size;
>   
> -		ret = -ENXIO;
>   		vc = vcs_vc(inode, &viewed);
> -		if (!vc)
> +		if (!vc) {
> +			ret = -ENXIO;
>   			goto unlock_out;
> +		}
>   
>   		/* Check whether we are above size each round,
>   		 * as copy_to_user at the end of this loop
> 
> base-commit: c9c3395d5e3dcc6daee66c6908354d47bf98cb0c

-- 
js
suse labs


  reply	other threads:[~2023-02-20 11:49 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-19 21:21 Bug with /dev/vcs* devices Storm Dragon
2023-02-19 22:11 ` Randy Dunlap
2023-02-19 23:13   ` Storm Dragon
2023-02-20  6:46     ` [PATCH] vc_screen: don't clobber return value in vcs_read linux
2023-02-20 11:48       ` Jiri Slaby [this message]
2023-02-20 16:34         ` Thomas Weißschuh
2023-02-21 13:30           ` George Kennedy
2023-02-21 13:49             ` Thomas Weißschuh
2023-02-21 13:50             ` Greg Kroah-Hartman
2023-02-27 14:20               ` Linux regression tracking (Thorsten Leemhuis)
2023-02-27 19:59                 ` George Kennedy
2023-02-28  5:38                   ` Linux regression tracking (Thorsten Leemhuis)
2023-02-20 16:06       ` Storm Dragon
2023-03-03 21:12         ` Thomas Weißschuh
2023-03-03 21:46           ` Storm Dragon
2023-03-03 23:25             ` Thomas Weißschuh
2023-03-04  3:30               ` Storm Dragon
2023-03-04  3:42               ` Storm Dragon
2023-03-04 19:58               ` Storm Dragon
2023-03-04 22:33                 ` Thomas Weißschuh
2023-03-10 21:32                 ` Thomas Weißschuh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dcaaf7d5-b2d5-dbb9-f3fe-2232ee525cc8@kernel.org \
    --to=jirislaby@kernel.org \
    --cc=george.kennedy@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=rdunlap@infradead.org \
    --cc=stormdragon2976@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®