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 41C15C7EE23 for ; Tue, 28 Feb 2023 02:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229871AbjB1CS0 (ORCPT ); Mon, 27 Feb 2023 21:18:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229931AbjB1CSX (ORCPT ); Mon, 27 Feb 2023 21:18:23 -0500 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 484D9A5FC; Mon, 27 Feb 2023 18:18:20 -0800 (PST) Date: Tue, 28 Feb 2023 02:18:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1677550698; bh=M6DbHO+PeywxABD2rLvdeB8pVgOEidTHxi8y5J0nZ7w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=r9pbiEkv4aT4jJ3hyrNCr5GPqcRL8nDqobRz4+3qRr/5auhAaTgB5RYprY3BzJWG6 LytGoIeP3k9XiCjQRc/VoY+dzH4Q1Y3IA0iX2buKDpS4Epd1PJunUR7PGeDAaPKyYH XdXecx0lioG8Wb/0uiDAhgo66/duT3MCDp/faKs4= From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Linus Torvalds Cc: George Kennedy , 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() Message-ID: <64981d94-d00c-4b31-9063-43ad0a384bde@t-8ch.de> References: <1677529301-19530-1-git-send-email-george.kennedy@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 27, 2023 at 05:58:12PM -0800, Linus Torvalds wrote: > On Mon, Feb 27, 2023 at 5:46 PM 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 (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