Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp186341imn; Thu, 4 Aug 2022 01:48:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR5eTrZ/57Zi6j5Vz8iMG8+KBtgbpD6rNRF6+vpYZHdfFT0uKw5G+0rcWgTo5u9dSzJOPLmw X-Received: by 2002:a17:907:6890:b0:72c:7533:8901 with SMTP id qy16-20020a170907689000b0072c75338901mr720489ejc.100.1659602906838; Thu, 04 Aug 2022 01:48:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659602906; cv=none; d=google.com; s=arc-20160816; b=e6iMeFBumFLpwUF+enNMOsIzcEMLsq2j25k1fc1fqz/hAZiEyW7zolVKrArccr1cgN SDiP8jzSuJyhlWlWl6Afv7JudGkSqOZtdtE/G9etK21e4txeWu1be0vjPgfgTV0NFLKG LolRkS+XUgqmx9dm/w9v37lIl0sKVQLP8TMSYMC+wLbZcdjmMBK4/oi6y3/H1FqDmHfl xkGoG80MOHKZTz96Rkwb1EaSMjmHMkg18v9IJQZiy7ChTa8wAC4HADk8fuOeMGoXqRzF ZTgX26FSvU/R2J9bAZ3OH24N+TbaPudrDz1PLlXrVeUVHf+lRW89kwez8+xkp+bKCrXz masQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=HjeWwu5uGmHCXr9alisP2b/oJ8nt4SrWTXGN3vlzJhE=; b=rPHKCa36CWANW8HNMWnsneUwxMzLCT45HAzC9BlS4fPTnK9XSPoyUQCAbv/tbDs6+T bOMHWsxjClmnLkJCalMySOSS8q5shSkeigSo/PUmSZK2ZSbO3rK27D6P/o5nC/C6Ig2w FkhnzEuIjpGsnbricO7s+YXNkRDKE/Qmt6MWmavYbT0Mu8d3+ds2ihWHSgObOJx3I342 T5LS31X+hOPD0fEcm/k7FS8BBDidZh0X3mN3Pbw/YHI7qdn/nS/rlEidbSA8UfSHuQip 0+6Rdw9uOs+553VZKsyX6U0HPILuf2F2pAshWXtkTAE5kGz94w7yzgAn5uGN8V1L6dek aOvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b="CpTM/L9+"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho15-20020a1709070e8f00b0072f259df55bsi312010ejc.189.2022.08.04.01.48.01; Thu, 04 Aug 2022 01:48:26 -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=@gmx.net header.s=badeba3b8450 header.b="CpTM/L9+"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229592AbiHDIqU (ORCPT + 99 others); Thu, 4 Aug 2022 04:46:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229499AbiHDIpy (ORCPT ); Thu, 4 Aug 2022 04:45:54 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC9471E7; Thu, 4 Aug 2022 01:45:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1659602742; bh=zBHeLt3swzlhQhq8Mg+oecUGN1GpWSW7/ADB/NwqugE=; h=X-UI-Sender-Class:Date:Subject:From:To:References:In-Reply-To; b=CpTM/L9+EiQjofNeKED27cW/pamOhQHaWJ9kPCuJeGNRydk0SMqBL12zLE5U7scY2 ChiR3HgHcbzURgwYXlywvO9tNjrPyVfZ3hMk6FXlDhAEyjqgynuBMJYoxJz2+1Oxqs G67677hbWeXBbnsz7/tZ/dA52064VRTU6wi2QNN8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.20.60] ([92.116.176.33]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MGhuU-1oEcel3x1W-00DpdQ; Thu, 04 Aug 2022 10:45:42 +0200 Message-ID: <0fbc2150-b4aa-f2cb-5084-3a9f69b3455d@gmx.de> Date: Thu, 4 Aug 2022 10:44:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] tty: vt: selection: Add check for valid tiocl_selection values Content-Language: en-US From: Helge Deller To: Jiri Slaby , Khalid Masum , syzbot , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Greg Kroah-Hartman References: <000000000000bbdd0405d120c155@google.com> <20220729065139.6529-1-khalid.masum.92@gmail.com> <1eb62346-304b-54d5-8a62-8a35888d51bd@kernel.org> <35e860bb-c76c-ca5f-3f48-2bf6cb798689@gmx.de> In-Reply-To: <35e860bb-c76c-ca5f-3f48-2bf6cb798689@gmx.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:fvnbUjIfRjo7BJSx+mfDA4vZyG8NWXczmkia6v3VEBCbAyao9hd exfzNMaGvcGQxH4Wvi0pQPqDGVjRjsbygiweWzqqKN84vnc01cUaFT500sLFmneopmj6TuN 7D8EJ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i/iZkKUBApFP/7g8R3fIq3eWUWgw1yQghgEiA yp4/ctSMTC1V4CyUq5FSDXI39NTc47Oifz6kyw0yIaH4aQ3D1HKftyJgepHkvQDIjaMDcteUl JqmX9jvje5xHJOL+I8Q87bWPd7IFqWfnb4ETlQ5dNBl+VJBqYiGEzc+0amG0leXUMsi6KI9VY qwmRjvX9VRaDMvvEOmOmfJU4qF/5hyagZQAEzySWsild0wCtSTf7hWrsg== X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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 On 8/4/22 09:15, Helge Deller wrote: > Hello Jiri, > > Thanks for looking into this patch! > > On 8/4/22 07:47, Jiri Slaby wrote: >> On 30. 07. 22, 20:49, Helge Deller wrote: >>> The line and column numbers for the selection need to start at 1. >>> Add the checks to prevent invalid input. >>> >>> Signed-off-by: Helge Deller >>> Reported-by: syzbot+14b0e8f3fd1612e35350@syzkaller.appspotmail.com >>> >>> diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c >>> index f7755e73696e..58692a9b4097 100644 >>> --- a/drivers/tty/vt/selection.c >>> +++ b/drivers/tty/vt/selection.c >>> @@ -326,6 +326,9 @@ static int vc_selection(struct vc_data *vc, struct= tiocl_selection *v, >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return 0; >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >>> >>> +=C2=A0=C2=A0=C2=A0 if (!v->xs || !v->ys || !v->xe || !v->ye) >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return -EINVAL; >> >> Hmm, I'm not sure about this. It potentially breaks userspace (by >> returning EINVAL now). > > Right. > According to the code below, my interpretation is that all xs/ys/xe/ye v= alues > should be > 0. But of course I might be wrong on this, as I didn't find = any > documentation for TIOCL_SETSEL. > > And if userspace tries to set an invalid selection (e.g. by selecting ro= w 0), > my patch now returns -EINVAL, while it returned success before. > >> And the code below should handle this just fine, right: >>> v->xs =3D min_t(u16, v->xs - 1, vc->vc_cols - 1); >>> v->ys =3D min_t(u16, v->ys - 1, vc->vc_rows - 1); >>> v->xe =3D min_t(u16, v->xe - 1, vc->vc_cols - 1); > > It "handles it fine" in the sense that it can cope with the > input and will not crash. > But it returns (maybe?) unexpected results... After some more thinking maybe you are right. In case a user provided invalid values in the past, simply an unexpected selection was set, but nothing broke. Since the patch doesn't fix any critical issue, we could just drop this pa= tch and leave it as is. Helge