Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4373742imw; Tue, 19 Jul 2022 05:34:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u7fdGLs41/vuf/yepkPSQK9tM4UQlkbJWD9kHN44nBYw+CKWdU+sB9cl2BPvy3Hg0+iNq2 X-Received: by 2002:a17:906:6a1c:b0:72f:2174:13db with SMTP id qw28-20020a1709066a1c00b0072f217413dbmr11331340ejc.687.1658234073863; Tue, 19 Jul 2022 05:34:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658234073; cv=none; d=google.com; s=arc-20160816; b=cA3TKNfXWM/9lv58fvX+viOFgX3jvIC8WqpPaB/YNcX9LacSlu60qjqHtQgyluSK9a hH7zoq34FucnWHkE5z3MlDQStYp8yqHJtt8RS6aRfe502NxY5rukwh1JMsu891uIZ3Y9 hot1BCKOpl3WJlFyVVenszTIUAy0NKy5vypDcSN89NGYnYM/y0pZ3a2osp7edVT+cyYI kpdyMq0ABEtkdbMdQriOuyLyGgIyEYAuq79jVv/hrWHMHCI6+j81MfytuzZU7RvSz6bX kpSnzzQgsA7PvBy47q4/UZy4MMdv3UrA+05wc4hqsRZbR4qEY3lhGTYeo4A8EE9c39vm 3IgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=F1Zz5dxsWy2u7THquiIJyp4pEUJt7WS1RGIcpuhfsfc=; b=jn6fRXJWopiFCf1Hq7rw+fKxNIFzRM+setk1b2AFGqdTxrRtB7fqatI4y34FgSoD6A Q6G2sN6e7zrrTHa1hnL6t+mbKxTnn+fVHuTqIJGYIfjBKfaNTqd0mplm2Ol4xRSFDLoR Ruqk6ghbg5bbT+NjkNiwECB+VHMYMenvVNDBoZva7Ha6c/jiZCr3DDvxAO9x1i/05+Mb RHhPr0cckcUK9KopZUfKMA4900hBNTRJZYZS5cgHf9jJ7P4p8+TrUo0VXSrOcJSqcSCC Lax0JH8QSV9pWDoflMhsKg/hx81vuhr8YbOio+Y0M29fR7iZ4E0Xf0U9AoP5dUg4H76k KlOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GjFziAZO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s25-20020a1709064d9900b00722e779f365si15893740eju.376.2022.07.19.05.34.06; Tue, 19 Jul 2022 05:34:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GjFziAZO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237568AbiGSM0v (ORCPT + 99 others); Tue, 19 Jul 2022 08:26:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240318AbiGSMYv (ORCPT ); Tue, 19 Jul 2022 08:24:51 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFA8850708; Tue, 19 Jul 2022 05:09:42 -0700 (PDT) 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 761B7615F4; Tue, 19 Jul 2022 12:09:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59F5AC341C6; Tue, 19 Jul 2022 12:09:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232581; bh=uWP81HW1luT6RyI7hLaOnr6CpVhKPPiiN3KFfDvXEsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GjFziAZOO/VHxMSrA2XjreuqXmbF+Wku9//sNzveIris6n4nR69EphfWOT/N/afUx /4ZcY5f2zBpC2CZaTirwKhWdz5BFt/yjsoMt6EYsM5RxLq6MN+ds7jvGM1GWZY2cY4 mD8rt/yH5tnohur5ai0mDlUtAXpMJQGyJJWrWzfY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Yangxi Xiang Subject: [PATCH 5.10 107/112] vt: fix memory overlapping when deleting chars in the buffer Date: Tue, 19 Jul 2022 13:54:40 +0200 Message-Id: <20220719114637.479365414@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114626.156073229@linuxfoundation.org> References: <20220719114626.156073229@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yangxi Xiang commit 39cdb68c64d84e71a4a717000b6e5de208ee60cc upstream. A memory overlapping copy occurs when deleting a long line. This memory overlapping copy can cause data corruption when scr_memcpyw is optimized to memcpy because memcpy does not ensure its behavior if the destination buffer overlaps with the source buffer. The line buffer is not always broken, because the memcpy utilizes the hardware acceleration, whose result is not deterministic. Fix this problem by using replacing the scr_memcpyw with scr_memmovew. Fixes: 81732c3b2fed ("tty vt: Fix line garbage in virtual console on command line edition") Cc: stable Signed-off-by: Yangxi Xiang Link: https://lore.kernel.org/r/20220628093322.5688-1-xyangxi5@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/vt/vt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -855,7 +855,7 @@ static void delete_char(struct vc_data * unsigned short *p = (unsigned short *) vc->vc_pos; vc_uniscr_delete(vc, nr); - scr_memcpyw(p, p + nr, (vc->vc_cols - vc->state.x - nr) * 2); + scr_memmovew(p, p + nr, (vc->vc_cols - vc->state.x - nr) * 2); scr_memsetw(p + vc->vc_cols - vc->state.x - nr, vc->vc_video_erase_char, nr * 2); vc->vc_need_wrap = 0;