Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp666623pxb; Tue, 5 Apr 2022 17:59:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOtCHzzzyN6rc8Yz9iitEkJbfLZDKh81JHVwZblzwTX7IqXkW6PiOla5NP/bszaHZ8I3Xz X-Received: by 2002:a17:907:6d92:b0:6e5:d50e:9170 with SMTP id sb18-20020a1709076d9200b006e5d50e9170mr6029867ejc.506.1649206667167; Tue, 05 Apr 2022 17:57:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649206667; cv=none; d=google.com; s=arc-20160816; b=RHAeEsHSOGl0/u85Pu4fzb8pszqB9da9NDLbge3n0nTWU0j2dT68NhaFgd0Y6IScBf eiicA2/OAgcWQB3g73iE2aXuHbQPfbSOZTCF6LTuVKbSyvlozNqE9pItdJzn0Ul5dSAP 3yKhek4z/B95wKkQUS27SxubBgyemFlc/hYKFAV8kwDy+3saAV3Asu2n7sqKFe97S4is fgTskhvVngirH4caUxq47cPtT+2aNY//KQYBJYG7+333do7CYKKCWZ8xdagiVB9LdDZb Ci1cYAcf6uSVruzj7+bWsGVHM6GrJyc0MsckW9pSnb5pQjrmoHoMgi4OGW2gt2pp2qpr 8yqA== 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=raBf6jNAzZk4HpJpGkiQohI10/4Tou0FSIdF5Z/ADQTEFF/px8DJEbfD3m/pKfBpnw zmLx1HUyrPqTUN4mrA3PZmMIjDMIDrDUMV7F4IyG2I0c4a7b8zq85xnAna/ArebJZ1js lKED7fV93gY7bZA67n5I1WUujwOK3b26P442uRCQjHzBXTTt8U6WdH7Fh0RwvyWWa0Ex zbiVJOGLJpzZ77YG/D4zFRWC4IqWREtfEcVG4XqLKDPsxd0Y6EI0Y4/2zKpZyfRNiVuJ QREyHHqIEMvkp3udfR4E3DTqzIfexhGvAZFIp+ncFHWl0oZi6mkWbezLLQ9LBMQkg8Y5 rcSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WVftuMhd; 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 eb11-20020a0564020d0b00b00418c2b5be17si13107955edb.249.2022.04.05.17.57.16; Tue, 05 Apr 2022 17:57:47 -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=WVftuMhd; 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 S1388380AbiDENWI (ORCPT + 99 others); Tue, 5 Apr 2022 09:22:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344732AbiDEJVI (ORCPT ); Tue, 5 Apr 2022 05:21:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A90724BFF; Tue, 5 Apr 2022 02:08:40 -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 6FB6561577; Tue, 5 Apr 2022 09:08:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7327EC385A1; Tue, 5 Apr 2022 09:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149718; bh=qW1x31HnZxqlWv9yLK7leVGiHSRFHxjgpFRqN+3ePM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WVftuMhdy1ZG54iKGq4PViKdgdmhkUJcT3WE9Und/3WKdfRAvOZz0D2OiNRy7eHgO +SCVbUh6890huTTQBgfkQ4FXhCKsdU7Q/qLZz5qYk8LJDJhBqEsIn6sgTckNEW4K7g 2CR1Yh3f6Oindm6yD676fsqDsCZBoEYYj7P2gc8w= 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 5.16 0816/1017] video: fbdev: nvidiafb: Use strscpy() to prevent buffer overflow Date: Tue, 5 Apr 2022 09:28:49 +0200 Message-Id: <20220405070418.471174787@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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.1 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