mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Thomas Weißschuh" <linux@weissschuh.net>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: George Kennedy <george.kennedy@oracle.com>,
	jirislaby@kernel.org, gregkh@linuxfoundation.org,
	sfr@canb.auug.org.au, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	regressions@lists.linux.dev
Subject: Re: [PATCH v2] vc_screen: modify vcs_size() handling in vcs_read()
Date: Tue, 28 Feb 2023 02:18:16 +0000	[thread overview]
Message-ID: <64981d94-d00c-4b31-9063-43ad0a384bde@t-8ch.de> (raw)
In-Reply-To: <CAHk-=whxC0ob3f--B-igBp34ujA5PZQMcTnDQ8Zh8HA7+ZbeWg@mail.gmail.com>

On Mon, Feb 27, 2023 at 05:58:12PM -0800, Linus Torvalds wrote:
> On Mon, Feb 27, 2023 at 5:46 PM <linux@weissschuh.net> wrote:
> >
> > This still seems to be broken for me.
> 
> Looks that way.
> 
> > I still need the patch from
> >
> > https://lore.kernel.org/lkml/20230220064612.1783-1-linux@weissschuh.net/
> 
> .. and that has the same problem with "what if the error happens
> during an iteration that wasn't the first, and we already succeeded
> partially".

Indeed.

> The "goto unlock_out" is bogus, since it jumps over all the "update
> pos and check if we read something".
> 
> It was the correct thing to do *above* the loop, but not inside the loop.
> 
> IOW, I think the proper patch is to also turn the "goto unlock_out"
> into a "break". Mind testing something like this (whitespace-damaged,
> but you get the idea):

Makes sense and seems to work correctly.

Tested-By: Thomas Weißschuh <linux@weissschuh.net>

(Or feel free to use my patch from above and fixup the goto/break line)

> 
>     --- 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)
>     -                   goto unlock_out;
>     +           if (!vc) {
>     +                   ret = -ENXIO;
>     +                   break;
>     +           }
> 
>                 /* Check whether we are above size each round,
>                  * as copy_to_user at the end of this loop
> 
> which hopefully really fixes this (at least I don't see any other
> "goto unlock_out" cases).
> 
>               Linus

  reply	other threads:[~2023-02-28  2:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-27 20:21 George Kennedy
2023-02-28  0:12 ` Linus Torvalds
2023-02-28  1:45 ` linux
2023-02-28  1:58   ` Linus Torvalds
2023-02-28  2:18     ` Thomas Weißschuh [this message]
2023-02-28  2:40       ` Linus Torvalds

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=64981d94-d00c-4b31-9063-43ad0a384bde@t-8ch.de \
    --to=linux@weissschuh.net \
    --cc=akpm@linux-foundation.org \
    --cc=george.kennedy@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=regressions@lists.linux.dev \
    --cc=sfr@canb.auug.org.au \
    --cc=torvalds@linux-foundation.org \
    /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®