Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5995633pxb; Mon, 14 Feb 2022 12:41:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyinzCS9GHsXY+pb3dYeTpRsRxb9hlQijJFd23Ew6ZsorAb7zX32PfERLnhUBlQa7IbC44C X-Received: by 2002:a17:902:d4ca:: with SMTP id o10mr676597plg.172.1644871265222; Mon, 14 Feb 2022 12:41:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644871265; cv=none; d=google.com; s=arc-20160816; b=Bc/Bm7/kTbJ3iUOi8FbaAtcahflAWPCmA5vPxSmYL63/CNks/rgo5Ap8hgrKPLhsu5 ChUlcXXCwCKi+uhc2oceqjETGQCIhVGSZXggwebytilBCzufrhujijiYi6MuTQzQZ3lv Y6DFWmR3Ci2gHoJQfJhXsdgp3CV4rV77XZCibOQyLTFdxR5l3207KUMM3bN/O/JmkTwF qNjl0EZc3rX4B2y/NBut2IrqGAwaD9MUFxfp9zRvQKIeDUQQlZ0+iZp1J2jZSDgdbC/u PVi2OllEH6Qb+Iqh9A9hD8TARTpdyzLq4/4NkLaTs64uBGUFJZZdwSJUzg78y1KaDkRN LJDg== 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=GSLs4dzGQYb/RKyfkz++G1oUk23hKA0bxLPMdQFnjfk=; b=zKKRCrIixbob6QnVEUhNxSx63OfIw/iAWcu6/N3jwKq2KPlMT6+7t1maMMGGXVYTzr qPgstO0qJxqGviIrlyBcZn/9kshnX9v6PX/PunOD+lC1C5p3bqNwrGC+RIV4D+jrx3a1 0ywpPCQcKABcRieMkkrlOlm50t2iKNqILN31TtJl0Fz9E0nak8t/cBG5tA8IPfHfgi+3 KdPdXHoihERj5QWQFgTcpku3d8RmbQspGML/WJT65G8TqYNLmYbt52uB7UBuDs4XuzHu e56tUTupbwr1nZ5CZ3jxCBw2EngfHdDvrkotq1Ig17pwzxInZhWM5ioN9P75KtWnAl/1 2RHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K13JdqOe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id p21si4528767plr.574.2022.02.14.12.41.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 12:41:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K13JdqOe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1F2FD1B6511; Mon, 14 Feb 2022 12:09:17 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344622AbiBNJ4Y (ORCPT + 99 others); Mon, 14 Feb 2022 04:56:24 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:34446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344196AbiBNJve (ORCPT ); Mon, 14 Feb 2022 04:51:34 -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 146DC6948B; Mon, 14 Feb 2022 01:42:39 -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 A4E8F61190; Mon, 14 Feb 2022 09:42:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78F4DC36AE2; Mon, 14 Feb 2022 09:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644831758; bh=m5sa/+PfZ9zsXdIEYCzOmAijkdLetxOWvzMeLqvg8F4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K13JdqOey32GR7tvroGRYXvuLdYGIcSxrrIklj9Y2vzQ3/F3SwwfuKqgqBR3w6GT7 hyzliOw8CAsPfPd/lOBUrDnl6KcKhFz+3OAtN3Oj5iIGW3RfpAPhX9n0VsaBeL+304 96wLI5QlqCddje9LOLq7VxZgGxbGnyjPLkHZXzp8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brian Johannesmeyer , Jakob Koschel Subject: [PATCH 5.10 087/116] vt_ioctl: fix array_index_nospec in vt_setactivate Date: Mon, 14 Feb 2022 10:26:26 +0100 Message-Id: <20220214092501.771734304@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092458.668376521@linuxfoundation.org> References: <20220214092458.668376521@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: Jakob Koschel commit 61cc70d9e8ef5b042d4ed87994d20100ec8896d9 upstream. array_index_nospec ensures that an out-of-bounds value is set to zero on the transient path. Decreasing the value by one afterwards causes a transient integer underflow. vsa.console should be decreased first and then sanitized with array_index_nospec. Kasper Acknowledgements: Jakob Koschel, Brian Johannesmeyer, Kaveh Razavi, Herbert Bos, Cristiano Giuffrida from the VUSec group at VU Amsterdam. Co-developed-by: Brian Johannesmeyer Signed-off-by: Brian Johannesmeyer Signed-off-by: Jakob Koschel Link: https://lore.kernel.org/r/20220127144406.3589293-1-jakobkoschel@gmail.com Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/tty/vt/vt_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/tty/vt/vt_ioctl.c +++ b/drivers/tty/vt/vt_ioctl.c @@ -699,8 +699,8 @@ static int vt_setactivate(struct vt_seta if (vsa.console == 0 || vsa.console > MAX_NR_CONSOLES) return -ENXIO; - vsa.console = array_index_nospec(vsa.console, MAX_NR_CONSOLES + 1); vsa.console--; + vsa.console = array_index_nospec(vsa.console, MAX_NR_CONSOLES); console_lock(); ret = vc_allocate(vsa.console); if (ret) {