Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4912820pxb; Sun, 7 Nov 2021 01:02:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJwyAeNHk8iZU/x946b2tD8qwo01R30RBpavHCsSrQ6vymbAKRJzx7+fWxDhRN9CNsULDq5G X-Received: by 2002:a05:6602:1851:: with SMTP id d17mr7857232ioi.27.1636275749708; Sun, 07 Nov 2021 01:02:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636275749; cv=none; d=google.com; s=arc-20160816; b=D/3w9zLsXSQazK82+maY6bYwYsitTDDHTSH57rAzlxwDjct9Hyip8YiU+USWCD7wYm P6/aAL2Vsu09mC3tVNhiG7y7DwwSY3xB+DKP1wt8trRVEDl7e45EaEJPJnniHpPJUuxO 5kYRoGsBn4mo/XnngmmZYFiYe7JZBkSV9aSqz/c6nuG5Jg+YUcsnfIvDep20gHgpj5qD hguWkTBl1D2RvggBzqSIK9niZ3Ne0RzmAQXymTGTQV/N5R7DNeIz7aiMQlZ1vAwfh2qi fIuWjqAFLfSKtCT7xDcAB1mxuucq5K/3Xn5F5ZkuoTR/1RW34rP2B6HvHTR9y6w4sctB ekKA== 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=5Wwu2M5WHYhPnMcLZDitxKTSUEf/rrDMMpK5D1XcgpI=; b=kwTGNJW4RLD0DJ+gItfFygxaVOvJC/hNG25rxk2FPG2t+etM53WdXGQgkVzOUS57nw /BymvQSMrnoZ3sMmaqEz7Q0IiTiykfKWJOn19Tubo5cz2KL3bLUq0yaf6rOgG3o1S0OT l6WdTRr3CWEBITcbK0zpOH6L5qWOc63iYaj2Lm0Ml44O34OcQoYskJsNZXNvEFZ2ENBp s186vu2zM+VKNCDNkOhnI1FcRZ6sm4QACj5x5Q79u28SZeLm7v0Ay3TUQYlu1QLAxorG IVC+bi2iK5jFf70kIwckmR2oOqOuGqf+ypxxeKyM57tpcp/ebSYtCPpCksGeJ3S5PGT0 rRag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cxbc3sMI; 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 z7si19677043ils.59.2021.11.07.01.02.17; Sun, 07 Nov 2021 01:02:29 -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=cxbc3sMI; 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 S233715AbhKFUrb (ORCPT + 99 others); Sat, 6 Nov 2021 16:47:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230035AbhKFUrb (ORCPT ); Sat, 6 Nov 2021 16:47:31 -0400 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC0B2C061570; Sat, 6 Nov 2021 13:44:49 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id u2so20599424oiu.12; Sat, 06 Nov 2021 13:44:49 -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=5Wwu2M5WHYhPnMcLZDitxKTSUEf/rrDMMpK5D1XcgpI=; b=cxbc3sMI0xx6mOTKwBeoMKC5ALke1qGT8oAIHsPtlchEo3etwwXzdEKWR4+AEomfRj Ja37C5fwTUPWjpdG2bS8dj/GXbx7Ym2FFqk8txP3EdcgxnZgT+a5yuO9SIxsVLET5FUb 5vgFRkhYAdMiJa7u9AfC0KsHx694cA26/BFuy5kZ48/2b2oyMIOQCYOf9sOTlDSYN5Fz bxh+r6EYXZw0X58SE97VqbmYqUovJr6Da7QVpvUSrt0svJGHMxCwkol596rcJdF0mBxh JMoDhiI3BzpllFk5MuadzlJlc4ARNmnMV9qvi8QqtDshfg/oq2FhA7zO0mmIDj7TSe4x rKqw== 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=5Wwu2M5WHYhPnMcLZDitxKTSUEf/rrDMMpK5D1XcgpI=; b=LJjTwHbfttJ58x8NW+lMtKJTPCy48LJuveREx7UEO9Jssfvlhe6Vczbt32RG60j9cH muUbuXs8cXk0ksTnylAC8KDA5ANbRAP8a+9UxOgMy822IZOf9gwZ92iAkxZZCPt4Qux9 JzAIPpX1PA+FixmUCxqrB2YElkxjdkPT2/SNJylPu0YkTI0EurcZwWclJjSvp+Tc83Jt ieK9R7tJJc15cDiNpbBxZ5Nj7zGeFN5zKfHBhJUVGvy25bJOiv6d9ic6JAJ3ihlgJeIG JF/40ZrFsklnrW041+Z5JCzH6qfLKNYG0+e6A9fIcgJvVHCRyAaijcUzu/V2/inyolGT /msA== X-Gm-Message-State: AOAM531gFkDl4GuLBkIUz10iOXK2WLtUamRvTUOxvn/5EZlSL0dOw9xx mWu3MDxyDCwDw9NFtzcRJkn6tPIX3J+9sZQYESY= X-Received: by 2002:a05:6808:2108:: with SMTP id r8mr14746685oiw.118.1636231488597; Sat, 06 Nov 2021 13:44:48 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <9717b429-597f-7778-c880-94361bcdee7f@gmail.com> From: Ajay Garg Date: Sun, 7 Nov 2021 02:14:36 +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 > > > > That's the whole point of the discussion :) > > > > The method "vt_do_kdgkb_ioctl" does not manage "func_table[kb_func]". > > Thus, the method does not know whether or not > > strlen(func_table[kb_func]) < sizeof(user_kdgkb->kb_string). > > > > It manages. The code under `case KDSKBSENT:` sets func_table[] entries > via vt_kdskbsent(). > > kbs = strndup_user(..., sizeof(user_kdgkb->kb_string)); > > is used to allocate buffer for the func_table[] entry. That's my main > point :) func_table is set in vt_kdskbent, which itself is external. More importantly, vt_kdskbent is handled in case KDSKBSENT:, while the strlcpy issue we are dealing with is in case KDGKBSENT: In case KDGKBSENT, following are managed : ssize_t len = sizeof(user_kdgkb->kb_string); kbs = kmalloc(len, GFP_KERNEL); while func_table[kb_func] is external entity here, so no assumption ought to be made for it, just my 2 cents though :) Anyhow, really, it is the maintainers' choice now :), since there isn't a burning (compilation/runtime) issue. > > > > > With regards, > Pavel Skripkin