Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp984248pxb; Wed, 6 Apr 2022 06:02:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5N+nk9FAlLRQnpenBfSedaY8zzjnT4tcl2ubmXvR2jS3msAezVue2Gv9/HtaXmSxUkZmZ X-Received: by 2002:a05:6638:16d2:b0:323:7285:474b with SMTP id g18-20020a05663816d200b003237285474bmr4863969jat.61.1649250172224; Wed, 06 Apr 2022 06:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649250172; cv=none; d=google.com; s=arc-20160816; b=Qlg2HHUEGzGIrfXCCnbhnvyA2DfHgD1gDYYji7XqvZx3TnUt/+i2rrwZ7u+AQmdOLG ayu6LHBWryiKX6/JD7S6A+XSC71/EnGiaskX8mikiFsno+JgaCdAC071fwbxOrtcrEmD IwpAlzqmNp5B+pjqvfLexV+p6ZL4ZNeAByWJpejhk3E4xdv8VfMJhdPKqKSZbWhGmYXZ L01pfcMsPkWXVnK5BoSfP1rTg2s+P2Ap+Igbp6aGU+ipvhI3n62QdcLHqyltuztQvjD3 yh4DRyw1vbDdUS4dUeiQjWXRImjqLpAJOldQYK5s/Pu7Y2hs/r5YrYk3uDltpNapVkX1 WXUQ== 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=ZR84kVguOmR7a6V7fHISHoRtse/Mvn5qzMlqMRZa2CQu+8s4fYNN2ly4AoylGLPWfI ejiHwEU6fejwj+CTd6sLviFEGqxiYuKIdKIfnWfutW2pStDt3H+97JkCTiJVKSFlumdk Idsq6I8A1TmUmGsFb+51AfDXt4iwFldaJfHNlKnfygIwdf553wlYqslPzrNfIEAeghH7 r+t5XBd+aIlsO0cX+opaRQ9k5Qy7uaF2hdCbE7RA/NWRMTvHd5FXacT4pB57kYsVhYf9 ZeiXxH0sXhR2XTRwlRE2dTFncXQvbwbol5qk9chYJGkCoqKgDQBV1rAMbG6FGipMQxRx YuSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qWz10RDK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v1-20020a056638250100b0031a2a42161asi10497101jat.60.2022.04.06.06.02.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:02:52 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qWz10RDK; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 43B44656F2C; Wed, 6 Apr 2022 03:20:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1584446AbiDEX6S (ORCPT + 99 others); Tue, 5 Apr 2022 19:58:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351687AbiDEKDL (ORCPT ); Tue, 5 Apr 2022 06:03:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3136973060; Tue, 5 Apr 2022 02:52:12 -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 81237616D7; Tue, 5 Apr 2022 09:52:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BFB5C385A2; Tue, 5 Apr 2022 09:52:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152331; bh=qW1x31HnZxqlWv9yLK7leVGiHSRFHxjgpFRqN+3ePM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qWz10RDKOyKNugTych2AqL1vRausJfYBSRUYZ7Bq5NDgsi8yNgQbA5wTyOj04hM/U ymkdTxPnTD5fQHsoXt81rge6I7uNnlSgfKnq8kN7wkgILsUcuWU4OTSx4yohwcdkul QnVLfc7pt1jbz6K0v2r907ZMYsHbfKm2K1SJBp+8= 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.15 737/913] video: fbdev: nvidiafb: Use strscpy() to prevent buffer overflow Date: Tue, 5 Apr 2022 09:29:59 +0200 Message-Id: <20220405070401.926691966@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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