Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4910543pxb; Sun, 7 Nov 2021 01:59:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfmGRPvUnUomkizGfxKcDuxiCTR/5d9PTBl5N94Ky+sAClOdRx8Eqn3kOsawz0MQBE7jPT X-Received: by 2002:a92:3642:: with SMTP id d2mr49339703ilf.91.1636275563902; Sun, 07 Nov 2021 01:59:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636275563; cv=none; d=google.com; s=arc-20160816; b=LnGhuxi+w3rcflnLP53w4fyYhyYq1l/SSPgKJ4vc3X3d3y6jffZouTADOyO0yd5EFV X+nI+FHLavI8GwYUP20pep7mbWRxEhNhvmG6SLciuyUglPzwAMsiC2AmZq+VESeBnY4F bh8YRkvYiU3NwieW+VdMghfhOsdZ4VaKHu3BwKVyy2jYDOG/JIEfxBuxbo0R6Ek9WYyp I24OGIPxalJXXotM0PJHewnt/b3Vw8q7xEUZTr7PuK21krcQIVp4OqgILKd/elcqYQqP OhcumjkeBEWMyeNm3tzlQWk0QsY6dsizWVKwQ3fummFRDLYK2R125RFHNXzCIs9LSnZS mHgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=sdTYFujjwLADyUlxwHtcQ7DYIHzD91NyqxtAXDYdeaM=; b=hT+cIIgFSJdHnNRO9CYgt5K0Hj2CCla93nCAKOA7icGGOPZ3V3vVZPDV5fWN3L92Kb QbJN/Ef4YJhAI0SCqavQLR5oK8Y/UrnK3VkpJEZ327KKgZ+CFRtWWCw8uym3JS4E4ZDp mv6EVw0wIqGJuMmuIYUYsCJ7YvoflkfW+sibFH9N0hXSodHhJSxg/CR5McfHQfUXZUOC nyok1+C3v0HZcQB/L1fWA0e0IPrmIZ+Ewwm+Zg8Sn7zBFVa3bJprt8sVTJhmRuuSdDo9 9guTKAMyQEUs0LSqz8p5DSbe6pERDDRMOr7OiwdFiPhdE0RA6JGLZ3C8eQma/QcT7wvf h3mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=ZNRKqF3B; 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 i16si24858452ila.84.2021.11.07.01.59.11; Sun, 07 Nov 2021 01:59:23 -0700 (PDT) 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=ZNRKqF3B; 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 S235003AbhKFUK0 (ORCPT + 99 others); Sat, 6 Nov 2021 16:10:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231844AbhKFUK0 (ORCPT ); Sat, 6 Nov 2021 16:10:26 -0400 Received: from mail-oo1-xc34.google.com (mail-oo1-xc34.google.com [IPv6:2607:f8b0:4864:20::c34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A461CC061746; Sat, 6 Nov 2021 13:07:44 -0700 (PDT) Received: by mail-oo1-xc34.google.com with SMTP id d1-20020a4a3c01000000b002c2612c8e1eso447317ooa.6; Sat, 06 Nov 2021 13:07:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sdTYFujjwLADyUlxwHtcQ7DYIHzD91NyqxtAXDYdeaM=; b=ZNRKqF3ByES7hiKALKWZC2nQmd+5n7S8pi8ChmgD3YYcPLIuLQ97qG5SQTAuE6yw+Q FxuVH8bCpYSO8v1c/3UixuQOwJBOIQKGTiKIbpN6hCTKpKJpbgC513zdKJDLSzTNAYGF z/7PkwXBi3vhC2qNNK0CtCLSZ0kfkRiMeLLk/G/r00xUO3FwqXZTLSQpVaLHNFCUG9I0 234+AfUWTnPeirLgx0wYL8YYMZnVTRj4vl3CkJDok9aXrGTDdN1vX1U3W8h9zB9TbLgx 6F2uMjrSwdIQEq6Av+vaWudW4VpjF48XVxbvpnRqw2XeQ3OPeoaNnOvJTbg161EiDmrx 2FlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sdTYFujjwLADyUlxwHtcQ7DYIHzD91NyqxtAXDYdeaM=; b=ndvlPByU3a+7IYJEUIMrMseJnFKeT731o/suH5ELw68zdhqslNE1CGUjUzAVc+n1mI ZBHQoZTc/Yg44w1HmHcppvCQ7XOHH/iLtEiRCm1/VtWo+Af7av8o27GfUvHQy3hUqeTQ h5j66mMGVIvN9xOACN2NqERbvwta+5kGYt1qgG7miwPXt51CUoaJ5eyB8HSvsDPOyHSx HMK8L5MpzrJeVu0kCJdDJ5dcCdAmlMw80iI93xZFwhzgtt/iLfARba2ATnqRFwCQPd98 D+1vHKtSsFkz7VOGkrXgnceMEa5gc71W+IPJa/0x+zLiEMbHFAJLClQqFxgqjoSYPREo n2SQ== X-Gm-Message-State: AOAM532Xszb/0nhVVrQmfAeKnQgK4EByXgNujo1t3IqJpIDPvbO5LeuD 5/Rr1Tx1FB9e0x8epbcgah8ldg89LnpuHCgFPvV2ATby X-Received: by 2002:a4a:c304:: with SMTP id c4mr14435636ooq.34.1636229264046; Sat, 06 Nov 2021 13:07:44 -0700 (PDT) MIME-Version: 1.0 References: <20211106092041.43745-1-ajaygargnsit@gmail.com> <9eafae1f-d9f0-298d-cf20-212865d0becc@gmail.com> <868025b485b94480ad17d0ec971b3ee9@AcuMS.aculab.com> <58f5cf69-3b3b-62f2-9f73-49c51176a534@gmail.com> In-Reply-To: <58f5cf69-3b3b-62f2-9f73-49c51176a534@gmail.com> From: Ajay Garg Date: Sun, 7 Nov 2021 01:37:31 +0530 Message-ID: Subject: Re: [PATCH] tty: vt: keyboard: do not copy an extra-byte in copy_to_user To: Pavel Skripkin Cc: Andy Shevchenko , Greg KH , jirislaby@kernel.org, kernel@esmil.dk, David Laight , "linux-serial@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 7, 2021 at 1:26 AM Pavel Skripkin wrote: > > On 11/6/21 22:20, Ajay Garg wrote: > > I vote for David's strscpy "fix", as it is simple, and does away with > > the dependency on the length of "func_table[kb_func]". > > > > strscpy fix sounds reasonable to me. just to be save in future. > > There is only one thing I am wondering about: translation table entries > are set by user using this struct > > struct kbsentry { > unsigned char kb_func; > unsigned char kb_string[512]; > }; > > it means entries cannot be longer than sizeof(kbsentry::kb_string) - 1 > at all. Do we need extra branching with strscpy() or do we need to do > anything else here? Hi Pavel, Please see my latest comments in the last reply. > > > > With regards, > Pavel Skripkin