Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp257323pxh; Wed, 10 Nov 2021 01:08:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZ9XITpXCxA2QaEWMP8rYaoVWDbMm4Ejc6vR2//q8MPdmcCotRBL2A0PEA38HykH8KJTGN X-Received: by 2002:a05:6e02:1a06:: with SMTP id s6mr10335909ild.21.1636535322399; Wed, 10 Nov 2021 01:08:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636535322; cv=none; d=google.com; s=arc-20160816; b=h1pdhU5NoxI+mWg5vme7ZH38yhvSggcFb8aK+p+BDM5TO2jPQbLPeUTbs+0lNax0lu iLAhBFXTuMJ79cvQDC4K5D5mvxJX70D+J0onseafArjgBDL/1bo92KZJ2y9jHlRwpAev HFUHhJHRw2tiLXaAig5kk9TvyQqBjQE+V/qHprBhWSeP/cvA6vN/ehQrnsJQIkGLLoKf VPmAVHirznCgbZwYMEGWgBFCjCQavKB6z87SGY2KZIXUo18OORktmh+cWW4nuFHkP7lz auK2cqulG6+ek3ikbHwwoFX3w0P75ATgcOX3l17kWCN+hMDDVltz9xnGgYaoQhrjpUwb 7B0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=pA5umdeXJjTUuSqIQnDMMjrChHSoNhmfp7ulYjLvL5I=; b=iBj3BEMgh5GW93PG+/gkhNB6x6ySf5NbVPv4/dix8VkHSJOXuRBq5C5ITA6ifeMGo4 5uiyURpuj7TiQR9HIuIVrem5fimkGgWRYsNpW0aUNQe5XWJwvwu+BO+D1XZ0DNeqmqZz 7XV96taozbF8RBH5RgU92iSdJZ036OT8rzlbD6Wjz4ooSRQnCNOYS87iOsEcnIfkManq XvD2LTRhgFCODYX8rOPHBBIxllexZY9RLWC5Fl2Xbzk3AbpkIn6Ov7W2ojFLXu2P68Wa vtPjjenJvzQ5y8V01hZQT5BlcsTuCvv2Xh0nwbVqnkE8RU+kVQ1KDv00IcLC6wMx5ht1 YfjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=yH7VPWK6; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b22si572iow.23.2021.11.10.01.08.27; Wed, 10 Nov 2021 01:08:42 -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=@linuxfoundation.org header.s=korg header.b=yH7VPWK6; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230456AbhKJJJZ (ORCPT + 99 others); Wed, 10 Nov 2021 04:09:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:46272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229831AbhKJJJY (ORCPT ); Wed, 10 Nov 2021 04:09:24 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1D20061241; Wed, 10 Nov 2021 09:06:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1636535197; bh=cQh2gtzFbpiUqUoKtpQ5ieN8FrH0G315r3j++GSu4uo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=yH7VPWK6HT/e2u3+UQ6g9J3HCJea5fPZ2hGGJ6qTG0xTa3Wkv5aFsIQYGDVin+iNR pxQYpklmdQyOsJe64EyRBgUeNKCghHU63D06RHAykSC88qY8gJKvoIYLotk0T7kKNJ eYqcFWAlVIhP/CcUoEZxaCdC53GWegCJPkrNs7i4= Date: Wed, 10 Nov 2021 10:06:32 +0100 From: Greg KH To: Ajay Garg Cc: Pavel Skripkin , Jiri Slaby , Andy Shevchenko , kernel@esmil.dk, David Laight , "linux-serial@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] tty: vt: keyboard: do not copy an extra-byte in copy_to_user Message-ID: References: <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> <1305bb43-b4bf-e129-af6e-957d1f30f269@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 10, 2021 at 02:27:36PM +0530, Ajay Garg wrote: > > > > 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) > > > > That's right Pavel. > Every function must work correctly as it "advertises", instead of > relying on "chancy correctness" of the calls leading to the method. That is not how the kernel works, sorry. Otherwise every function would have to always verify all parameters passed to them, causing slow downs and redundant checks everywhere. When all users of functions are in the kernel tree itself, you can use tools and manual verification that the code is correct, because those are the only users of the functions. thanks, greg k-h