Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp178292pxh; Tue, 9 Nov 2021 23:39:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqfndLUruG4SeMy3A8oCL2yDst84XzA9tpxDTyDK8v+axkrTdr6QMhblsbSdX+CxN3KHER X-Received: by 2002:a92:ca47:: with SMTP id q7mr10291810ilo.63.1636529994714; Tue, 09 Nov 2021 23:39:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636529994; cv=none; d=google.com; s=arc-20160816; b=O1PwSc4M2jeVfCm935ZByetcc/clL+DBgtmQn/pWlBA+qDXNe5QNWfKx1SNrtvjlFT zMA6wN4XLCuMFdxBjPnSBVLChoSXyVDnZt3bpwlR8xjPWIvn8PHaafi0ByHLL5J0D4mD L82C+DggrSARoi4Q4mMmaDoafu4AiOyIyvE48kGQwhFKbb47rb2t+SZYpqzZuNhM0qAW XhImxMZ+qpfJXrKapgU7oNFS6odCAfLv7/HjZ07hU7zXnhMPLLsdKwOMBYI8tX4dOFa1 op11Ek6OQ7iy0sOwagboK6wroGoKFXuNSAZmwrvdxor4vLY0LNMcqiFkPDEqWZUtfbe5 M8Fw== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=/X4dkcH3D0KFPXqvr+tVUucDH2yewcV+8RCqw/Q9S8I=; b=Q2kdz3Ht73DOnJBU4kp8aOyXe7mhjCFcEJJJ9mMmG5PQwG+XC3b7pOfNvH2VECsmkN sJTm6mnFy4GLkVnDFRH6sTxy5OY7piPvxF3gguUWuuXqBC+9dcnJK0EsLzAyw4UnTqob tWUQoYYnYxvQlPd0TgZy7OYjj2ItJASxvckHx3z/wRmg9RW8Xcd95eC0lXtdmZbx6nT9 HYEzNtl7NOMNq5seHKZIB01d485D0lxweBH9rvmGoWcM1etBhbEIkRkABeWuMv9Y8/mq KrA7HEmzYPtidhxyc2g6020Xks3/fIK2P+mNwtiN/x51CghKalgsBGsYh44N9HfeZRWq khpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=D37w0J8h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g17si8218856jat.94.2021.11.09.23.39.32; Tue, 09 Nov 2021 23:39:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=D37w0J8h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S229721AbhKJHkH (ORCPT + 99 others); Wed, 10 Nov 2021 02:40:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229567AbhKJHkG (ORCPT ); Wed, 10 Nov 2021 02:40:06 -0500 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8361CC061764; Tue, 9 Nov 2021 23:37:19 -0800 (PST) Received: by mail-lf1-x136.google.com with SMTP id k37so3898645lfv.3; Tue, 09 Nov 2021 23:37:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=/X4dkcH3D0KFPXqvr+tVUucDH2yewcV+8RCqw/Q9S8I=; b=D37w0J8hPbxHZeo6WRKapuDqP4BxywTntmVZXxBuEA+OrFkI7ysS36XjOC+J2d1KAR zCV1e9hOER28kHji5QvbEi9QZpRWOsGyqC+bZKreaswBeicw0Esd7TAzrLSVa+9D9t+C 1LDv9smpG5+/pfMnhIUwaRy6EY/MKiPLf5ENz4fb7WNtKvftSrvoWlyUnmE4VsxPe88B ffBkKRenu1X5yDGYQmenjq5p4NJFt2+Fs3rb8sh4+pJ2ef2hYbIQ3fWOB6KHwsxADRVH hHVdIm8O+ZpTmGT1+z+aIVXSEk5TG5xZMNgZpNZZl8NiQ/GxtxRcMeCXMmSdLaX3vfCD fKiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=/X4dkcH3D0KFPXqvr+tVUucDH2yewcV+8RCqw/Q9S8I=; b=0QQ+ePXQsn+de2yNNrx+cEYgArn6VYKS4p2ZAAGjxzPu7CY00lXdrEAjqrcZSAvnwb DmN70Ce80/WKf1xiE8PKo94C9/5e9cYIMQwEHFNZhRWFRp4eheVvze7p+wYnIRzDrjWe YLg4aUx3DiTMtMy5Y3rHTCZNQZGDkSyZFHfnyvNrFvqMc0v3t7TXaJFYfDfiiv+c9pJE Gg8ERQLU0iRk3/SMIfiufwdmcv9bT8ckOz+7xGau6nwf3BK2aqj8On+GGpRqtz6CT7ve HiSMDAn/a3LvOX0H5DqKYmo9dsEcGWb5/8cBMMD5EmxRHpQPRI+SP/vfCgyXuBQfBDMH dX3g== X-Gm-Message-State: AOAM5317MItCvGkosk89+j4j9y+sLPDk0Xbym7zLXMhDLCpbdCaW/6sL fYJl9eVlLmDmDVr0kFGxs84= X-Received: by 2002:a05:6512:3f86:: with SMTP id x6mr12707697lfa.389.1636529837835; Tue, 09 Nov 2021 23:37:17 -0800 (PST) Received: from [192.168.1.11] ([94.103.224.112]) by smtp.gmail.com with ESMTPSA id h19sm2646682lfu.60.2021.11.09.23.37.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Nov 2021 23:37:08 -0800 (PST) Message-ID: <1305bb43-b4bf-e129-af6e-957d1f30f269@gmail.com> Date: Wed, 10 Nov 2021 10:37:03 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH] tty: vt: keyboard: do not copy an extra-byte in copy_to_user Content-Language: en-US To: Jiri Slaby , Ajay Garg Cc: Andy Shevchenko , Greg KH , kernel@esmil.dk, David Laight , "linux-serial@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20211106092041.43745-1-ajaygargnsit@gmail.com> <9eafae1f-d9f0-298d-cf20-212865d0becc@gmail.com> <868025b485b94480ad17d0ec971b3ee9@AcuMS.aculab.com> <6b58a3e1-f2ea-cc4c-03b2-06334b559373@gmail.com> <9717b429-597f-7778-c880-94361bcdee7f@gmail.com> <65c45951-08ba-26bb-f96b-3d4442b1d4d4@gmail.com> <08c9e717-4367-5316-87cd-90b5ceb13ed9@kernel.org> From: Pavel Skripkin In-Reply-To: <08c9e717-4367-5316-87cd-90b5ceb13ed9@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/10/21 08:22, Jiri Slaby wrote: > I don't quite understand what the problem is. Provided I wrote the code, > is there something wrong with this commit (and its explanation), in > particular? > > commit 6ca03f90527e499dd5e32d6522909e2ad390896b > Author: Jiri Slaby > Date: Mon Oct 19 10:55:16 2020 +0200 > > vt: keyboard, simplify vt_kdgkbsent > > Use 'strlen' of the string, add one for NUL terminator and simply do > 'copy_to_user' instead of the explicit 'for' loop. This makes the > KDGKBSENT case more compact. > > The only thing we need to take care about is NULL 'func_table[i]'. Use > an empty string in that case. > > The original check for overflow could never trigger as the func_buf > strings are always shorter or equal to 'struct kbsentry's. > > thanks, > As I said in my few previous emails, I don't see any bugs/problems in current code. Ajay wants to be safe and he thinks, that relying on fact, that strlen(func_table[kb_func]) < sizeof(user_kdgkb->kb_string) is not good approach, since it's external for vt_do_kdgkb_ioctl. (I hope, I've explained his idea in the right way) With regards, Pavel Skripkin