Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3742330pxb; Tue, 19 Apr 2022 08:58:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxOGo0U3dIKm5ZuSWTaloLK12omV6tgzmAm7uNHmtJfxWlvjUKEexzoqyhApSY1tKXcyz0 X-Received: by 2002:a63:5013:0:b0:399:5816:fd0d with SMTP id e19-20020a635013000000b003995816fd0dmr15056452pgb.68.1650383904754; Tue, 19 Apr 2022 08:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650383904; cv=none; d=google.com; s=arc-20160816; b=cGwgXv6BQg7gueQaGQnzkLc1tirtaz6qdtI6+iS9L70csaPrU9gGjzJSBaUGQZwPqc cq68J5wUhBe56q0BiL/Yrpm2+fha4xi8St921PmcnEOhgTl7QXWb7ni8LGWFkEN32l8o 2pQF+4BvFmJhDzw6PoBxq72dlINAw13h2aoh9bJ9786xnRZ/DusjjUH/iSjIpW1xcMXL /f7G21ib17ULRQoPdfP2In8Jg2OdGvkvo5QhfJ6R+RPS0XRAj+EcFOHj//4iBORXOGD2 qGeSt9BfqUayjzai/y4D1CyT8Uywvj8W/4pPfa04m3pcAM+0R31jhNLu7ff4NrtHYxuF gcnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=y7tbgokD98W+ffF+NFExKaQSIB5bjYjGTkXnH7eOUvI=; b=sEya+SZpGw6nzpx/5tPGQP0tuUpRDKStFJzV5rBpydYB7dtNeeZIzkbUgk9yjh5+4R AYNHTfz9LKyvh0cevwupJ8q7BOpxD00QKviZA9jybZ0Sk9dmB48d6LI1mNeWqBhaqr9o 8uJciaUeQvk/Wi5K6mrxQj+sVBlZdDB1eGxp8VpOlvx5UNhHF95tC89XKQm3sCQ7Phl4 ZDcndIT0BCOYH1Ph9gbg31hpNlzz4DeR23VAQqi7OvZDea8mn47f9L6qjEhJXNqyYqWD iHoieZ8C+aQaYua0NJV4XpxeRgHXPCNl8w6uQE8/aSM28OA/Uel6gc99BNOaxeTTgR42 sinw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bgSTcaxb; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e8-20020aa78c48000000b005060ce352e8si11588291pfd.171.2022.04.19.08.58.07; Tue, 19 Apr 2022 08:58:24 -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=@linuxfoundation.org header.s=korg header.b=bgSTcaxb; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239214AbiDRNwP (ORCPT + 99 others); Mon, 18 Apr 2022 09:52:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244832AbiDRNa5 (ORCPT ); Mon, 18 Apr 2022 09:30:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C1AC1EC4D; Mon, 18 Apr 2022 05:55:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A575F6115A; Mon, 18 Apr 2022 12:55:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98571C385A1; Mon, 18 Apr 2022 12:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286541; bh=qW1x31HnZxqlWv9yLK7leVGiHSRFHxjgpFRqN+3ePM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bgSTcaxb0dDI/PHPt1aylF28ruTXr9mu5FngDlLKwh+4aKlTDscnUU5FarV6jJUwQ 3cQfwsMw1Gi0NciBEQV4cKPM8ywCFijawl7W5bdOMdl48fmUVB1mwkCapnzMfXfxiT gKUBwVKgJ/9V//DUpEkfcge++TCyBslbrMIFJRWM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Antonino Daplas , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Tim Gardner , Helge Deller , Sasha Levin Subject: [PATCH 4.14 165/284] video: fbdev: nvidiafb: Use strscpy() to prevent buffer overflow Date: Mon, 18 Apr 2022 14:12:26 +0200 Message-Id: <20220418121216.436578242@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Tim Gardner [ Upstream commit 37a1a2e6eeeb101285cd34e12e48a881524701aa ] Coverity complains of a possible buffer overflow. However, given the 'static' scope of nvidia_setup_i2c_bus() it looks like that can't happen after examiniing the call sites. CID 19036 (#1 of 1): Copy into fixed size buffer (STRING_OVERFLOW) 1. fixed_size_dest: You might overrun the 48-character fixed-size string chan->adapter.name by copying name without checking the length. 2. parameter_as_source: Note: This defect has an elevated risk because the source argument is a parameter of the current function. 89 strcpy(chan->adapter.name, name); Fix this warning by using strscpy() which will silence the warning and prevent any future buffer overflows should the names used to identify the channel become much longer. Cc: Antonino Daplas Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Tim Gardner Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- drivers/video/fbdev/nvidia/nv_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/nvidia/nv_i2c.c b/drivers/video/fbdev/nvidia/nv_i2c.c index d7994a173245..0b48965a6420 100644 --- a/drivers/video/fbdev/nvidia/nv_i2c.c +++ b/drivers/video/fbdev/nvidia/nv_i2c.c @@ -86,7 +86,7 @@ static int nvidia_setup_i2c_bus(struct nvidia_i2c_chan *chan, const char *name, { int rc; - strcpy(chan->adapter.name, name); + strscpy(chan->adapter.name, name, sizeof(chan->adapter.name)); chan->adapter.owner = THIS_MODULE; chan->adapter.class = i2c_class; chan->adapter.algo_data = &chan->algo; -- 2.34.1