Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10668396rwd; Thu, 22 Jun 2023 03:12:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5o3K2u/mldEuCMTckSATFp90Z1KrwFrj7hutTZmCH+1blsAE5mbXIn8sT6Y3Zu9e02Bjxi X-Received: by 2002:a05:6358:f55:b0:132:d3ea:f225 with SMTP id c21-20020a0563580f5500b00132d3eaf225mr941295rwj.24.1687428777228; Thu, 22 Jun 2023 03:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687428777; cv=none; d=google.com; s=arc-20160816; b=I74lZIFNRECJp0SaRD1V56NA00toBX5wA+v0pw5Uh7I/+KPMAChVu56n0ByGB0uMh5 qKTrYDSviFSRzGTbJUyDCFqbUQOHEUi5xoxSlCubAaNb+CdjTsTv8vG1rq8iwj3iBbyQ qONJ4HO6HQE/8cx3ukz80JGv272rrB7tCL4jWcWZLntQlpioOt6/bCMv2WCxzD/513n0 WQkDFAYnEtFcf18e5ueqb23w7tsaoEDsn6NNNxBX1i4z7dtiqLqdKqmq2TnlvpzbqmWK RkRYWMGy9BqRfkL+OlKYs2nt6JAqBa5EGyl4o0xo22XM+WMmCzmwtpZXzru1baNdBa6X QBHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Ey/Vv80nE8uwWSfVUbghuywv9z3ddX7tceISdZ9mqHQ=; b=cQ8SsumeDqbciNSk+SxAiF+QlZPgvJHPqZRbH0EceNk2brIqPL9nKxLcNKW0nLpxbu tBiaw7vYJW7sIrJCe1bmsZc9UOmI2LCmumLC4N/Tk+PzPJsM7sgm7r9IkRkRCyCps+3k ehNMZU+zQ8Ry+jprsjLuM/g55Or2Tr7hWpVcnowilXhfFYDvM3Ne6mL/7WWTlpPkY+X4 JeqtVmYIW/YkeoyTuGiJWLfwRfavmR5UK1I67+d8m2erb0wpewEWigyHCegM7wokurbk ldf1Dqb0/CAbcN7HoAdGpYiWoZjB6IhAltpz2uVunrWK27kjBEXAqBIDbq6K5ptmCf0R mXKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ZuhJosSD; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w30-20020aa79a1e000000b00666eec0a978si1088965pfj.5.2023.06.22.03.12.45; Thu, 22 Jun 2023 03:12:57 -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=@gmail.com header.s=20221208 header.b=ZuhJosSD; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229874AbjFVJzQ (ORCPT + 99 others); Thu, 22 Jun 2023 05:55:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231137AbjFVJye (ORCPT ); Thu, 22 Jun 2023 05:54:34 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D03E346A5; Thu, 22 Jun 2023 02:50:32 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-988e6fc41ccso474464366b.3; Thu, 22 Jun 2023 02:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687427431; x=1690019431; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Ey/Vv80nE8uwWSfVUbghuywv9z3ddX7tceISdZ9mqHQ=; b=ZuhJosSDsY60LXl7JXyeiDnvD/VEIpS8YfFW3xBvbs4IDk00SXPsap3eXc5LzTD35d rxBWcmgyf5m+UNAhBencyEfX0HkFE27AT+imGLcxrrEY2dRM3gBrgAOm3oawv+hjh/63 pMYbJlaJvSvzoMN2q5bpR6dpGtxv1eB/JYdaOjF+09Ab9kkAUTFf19LasKBUp0w5lCoe Gvkk60v7g2vG35PNDTcHvn90MggKTeMCyDHftHjpMUTHSSOrwSbHjg2t0JuF3kkH44JF 6KQPldWFgG3FYxca+lJr3sSeA/w8R4b14KDknQMmFtO5r7bL1oBMpXkEHpyHeRRtxnl/ 9GrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687427431; x=1690019431; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ey/Vv80nE8uwWSfVUbghuywv9z3ddX7tceISdZ9mqHQ=; b=daMiFjP/s3Srikjy4QgQ+8aYSSfKlmc5H+9l38BTnnDiss8eg/Wq2XdyoOcyJXABch lcIImGki+lYmE6ZO8qHdIjbz56csBLEAnoBq30p3BhfAgE/ldgNNx8nEWfuVnVKel+Jk XFlSKPChSH+zdIk7zCBEdiSKtgUXH9xjh7uzOiUiI9D0Wn1aDBrAlw/PDHEtZxC6YzLw wR0H2Ug7PxBY+kS2+TrrGKJVeMRbcFULv6PZ28NsQ7m9FoPiWv84pgLgektpAQCiFouE Wsx3mLzNBQe+H6cYjnf3PcO+8IMK1YFdyVtcTqH5BjDrxkhgvvJzbLe78rkxIpIiAEAt sB9w== X-Gm-Message-State: AC+VfDzm+mzUuX+GAkBdaHvK+FtLC3qHsU/B30tFGMv5nF4ExvGgNNyL W45AkOidVULMCzxBWDra+s7GFqbSFap4WQ7BLeI= X-Received: by 2002:a17:907:9303:b0:973:d06d:545f with SMTP id bu3-20020a170907930300b00973d06d545fmr13381565ejc.24.1687427431062; Thu, 22 Jun 2023 02:50:31 -0700 (PDT) MIME-Version: 1.0 References: <20230621083026.591323-1-dangel101@gmail.com> In-Reply-To: <20230621083026.591323-1-dangel101@gmail.com> From: Enric Balletbo Serra Date: Thu, 22 Jun 2023 11:50:19 +0200 Message-ID: Subject: Re: [PATCH v2] selftests/input: add test to cover len > maxlen in bits_to_user() To: Dana Elfassy Cc: shuah@kernel.org, usama.anjum@collabora.com, eballetbo@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Dana Elfassy Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi Dana, Thank you for the patch. Missatge de Dana Elfassy del dia dc., 21 de juny 2023 a les 10:30: > > In order to cover this case, setting 'maxlen =3D 0', with the following > explanation: > EVIOCGKEY is executed from evdev_do_ioctl(), which is called from > evdev_ioctl_handler(). > evdev_ioctl_handler() is called from 2 functions, where by code coverage, > only the first one is in use. > =E2=80=98compat=E2=80=99 is given the value =E2=80=980=E2=80=99 [1]. > Thus, the condition [2] is always false. > This means =E2=80=98len=E2=80=99 always equals a positive number [3] > =E2=80=98maxlen=E2=80=99 in evdev_handle_get_val [4] is defined locally i= n > evdev_do_ioctl() [5], and is sent in the variable 'size' [6] > Like the comment in my previous patch I think this is understandable for someone that has some context, but I am not sure it is understood for people that don't have such context. So I'd try to rephrase and explain in a more plain way. I.e. selftests/input: introduce a test for the EVIOCGKEY ioctl This patch introduces a specific test case for the EVIOCGKEY ioctl. The test covers the case where len > maxlen in the EVIOCGKEY(sizeof(keystate)), keystate) ioctl. > [1] https://elixir.bootlin.com/linux/v6.2/source/drivers/input/evdev.c#L1= 281 > [2] https://elixir.bootlin.com/linux/v6.2/source/drivers/input/evdev.c#L7= 05 > [3] https://elixir.bootlin.com/linux/v6.2/source/drivers/input/evdev.c#L7= 07 > [4] https://elixir.bootlin.com/linux/v6.2/source/drivers/input/evdev.c#L8= 86 > [5] https://elixir.bootlin.com/linux/v6.2/source/drivers/input/evdev.c#L1= 155 > [6] https://elixir.bootlin.com/linux/v6.2/source/drivers/input/evdev.c#L1= 141 > Also, usually is not a good idea to add links in commit messages reference to links that can easily end as dead links. > Signed-off-by: Dana Elfassy > --- > Changes in v2: > - Added following note about the patch's dependency > > This patch depends on '[v3] selftests/input: Introduce basic tests for ev= dev ioctls' [1] sent to the ML. > [1] https://patchwork.kernel.org/project/linux-input/patch/20230607153214= .15933-1-eballetbo@kernel.org/ > > tools/testing/selftests/input/evioc-test.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/tools/testing/selftests/input/evioc-test.c b/tools/testing/s= elftests/input/evioc-test.c > index ad7b93fe39cf..b94de2ee5596 100644 > --- a/tools/testing/selftests/input/evioc-test.c > +++ b/tools/testing/selftests/input/evioc-test.c > @@ -234,4 +234,23 @@ TEST(eviocsrep_set_repeat_settings) > selftest_uinput_destroy(uidev); > } > > +TEST(eviocgkey_get_global_key_state) > +{ > + struct selftest_uinput *uidev; > + int rep_values[2]; nit: rep_values sounds like repeat values, I'd use a variable name more similar to what we really need to pass to the ioctl, like keystate. Also I think this can be simply int keystate; > + int rc; > + > + memset(rep_values, 0, sizeof(rep_values)); > + and then, this memset is not really needed. > + rc =3D selftest_uinput_create_device(&uidev); This one without extra arguments need to be: rc =3D selftest_uinput_create_device(&uidev, -1); otherwise the vararg loop is going to keep the room warm for no reason. > + ASSERT_EQ(0, rc); > + ASSERT_NE(NULL, uidev); > + > + /* ioctl to create the scenario where len > maxlen in bits_to_use= r() */ > + rc =3D ioctl(uidev->evdev_fd, EVIOCGKEY(0), rep_values); > + ASSERT_EQ(0, rc); > + while we are here, and as it should be easy, maybe we can also extend this to cover the normal workflow to get the global key status? > + selftest_uinput_destroy(uidev); > +} > + > TEST_HARNESS_MAIN > -- > 2.41.0 > Thanks, Enric