Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2536463rda; Wed, 25 Oct 2023 05:51:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF42l7ZEcXCTYjY3wQjZyZqXUz2rk7/oIlu/2XWJvQvLKROqgBtVxAPGVuolyeWpKDNBCLl X-Received: by 2002:a05:6870:1254:b0:1e9:dd69:2fc1 with SMTP id 20-20020a056870125400b001e9dd692fc1mr15898663oao.7.1698238269070; Wed, 25 Oct 2023 05:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698238269; cv=none; d=google.com; s=arc-20160816; b=R7NPx1TcCxrNfLz8x4DpOStQ7Gx8gkhjdUeZKs1k40vsIfVgZtoyOMV5Sw3Z7YrwHb OQZd0zFHWIWtzExHNa1oFeyl/BIWCc8kLwIpAy86ZFDm2FHIXyLP8FwxzDOjHMmQynuJ GhnInc22Wu3AgbnRaYFnqdIeWXwgJdOr2N/sQUUumZVT7PgDaWTR98/s16CpMorS3y8y mPwAdGfeJaW6y/NtL6UuyHQUekWQcxwCl3XwZ7cTOdgBO74RUpU2JLzn9MvFRkOyKAYR EecWgtq9vXzEY/251ohvzqYi4Mbk6ZgjFGc0V5hdnZyinguYz7Jyljkpb6HxCIGul5wO jQvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=xZ6ngCIhTC8alg3BfxAI2clnwLoGHV/EXnTHoPcJsnQ=; fh=b5tBcueN6LY+dVaPPQolDD9SEaIKpKfwi3vk0YeMIKA=; b=qFxO+R1oryqpK3/WlSaed5R8HAifV9RwmNHIzyGPMQpZg5MqZ2DROqiKv4dlVtkYt6 /x8gl8gQChRuerR74fNII/h/DK0UElNmWWM4ZlFUY61sckxYXuv0j/CkUjHAfuPCjJat vKGq36uYvJyahTVgGpXzabAKdktCPEWZyB0boyYABP0374mRK+S5kBRELXPFWNowNUbx qC2CEWp+C5ZhWKqKV6ZhSwiKPu5CB7oTvInuXPerzYAGk/UhUCBNOzlTmL1/4N11uHDu T1kZ4f6hWVQPybyfhWrb741wP04GQV8p9hQEvcm76+yVWj2KT3O5iN2M6Yjg1l02/DN7 4xqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=iC5fz81z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id s17-20020a81bf51000000b005a8f0111a3csi11546212ywk.26.2023.10.25.05.51.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 05:51:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=iC5fz81z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id A30888108369; Wed, 25 Oct 2023 05:50:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344015AbjJYMu2 (ORCPT + 99 others); Wed, 25 Oct 2023 08:50:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233759AbjJYMu1 (ORCPT ); Wed, 25 Oct 2023 08:50:27 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D6AC90 for ; Wed, 25 Oct 2023 05:50:24 -0700 (PDT) Received: from [192.168.1.110] (unknown [103.251.226.9]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 43D8F669; Wed, 25 Oct 2023 14:50:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698238208; bh=oYH78xkq3rGNll3M+52mpCZCqakXLm41mfL1RQ7j0So=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=iC5fz81zlp9L+pLFAUdNzs5GFrC8xQoLwHWFLKiEOkoU6qwk/wm8lXydDhNdCm0lZ KUHdjuLi46L2jyZTwFwBerKMZSgrq+oB7U3PWWQ8Wq0tC9Hv5aRwgbqUoDqkjrcGmB vcn3J2nACWElO97WmwkDyhOQfk9GjzKArdDp1EG0= Message-ID: <92b54548-6276-29c3-01af-80136c28da0c@ideasonboard.com> Date: Wed, 25 Oct 2023 18:20:12 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] staging: vc04_services: use snprintf instead of sprintf Content-Language: en-US To: "Ricardo B. Marliere" , Greg Kroah-Hartman , Florian Fainelli , Ray Jui , Scott Branden , Kieran Bingham , Laurent Pinchart , =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= , Stefan Wahren , Peter Zijlstra , Arnd Bergmann Cc: bcm-kernel-feedback-list@broadcom.com, linux-staging@lists.linux.dev, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Dan Carpenter References: <20231025122632.307385-4-ricardo@marliere.net> From: Umang Jain In-Reply-To: <20231025122632.307385-4-ricardo@marliere.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 25 Oct 2023 05:50:50 -0700 (PDT) Hi Ricardo, Thank you for the patch On 10/25/23 5:56 PM, Ricardo B. Marliere wrote: > All the occurrences of sprintf usage under vc04_services can be safely > replaced by snprintf, so as to avoid any possible overflow. > > Suggested-by: Dan Carpenter > Suggested-by: Umang Jain > Signed-off-by: Ricardo B. Marliere LGTM, Reviewed-by: Umang Jain > --- > .../bcm2835-camera/bcm2835-camera.c | 2 +- > .../interface/vchiq_arm/vchiq_arm.c | 16 ++++++++-------- > 2 files changed, 9 insertions(+), 9 deletions(-) > > diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > index e860fb89d42e..e6e89784d84b 100644 > --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c > @@ -855,7 +855,7 @@ static int vidioc_enum_input(struct file *file, void *priv, > return -EINVAL; > > inp->type = V4L2_INPUT_TYPE_CAMERA; > - sprintf((char *)inp->name, "Camera %u", inp->index); > + snprintf((char *)inp->name, sizeof(inp->name), "Camera %u", inp->index); > return 0; > } > > diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > index de6a24304a4d..9fb8f657cc78 100644 > --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c > @@ -1451,12 +1451,12 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, > } > > if (use_type == USE_TYPE_VCHIQ) { > - sprintf(entity, "VCHIQ: "); > + snprintf(entity, sizeof(entity), "VCHIQ: "); > entity_uc = &arm_state->peer_use_count; > } else if (service) { > - sprintf(entity, "%p4cc:%03d", > - &service->base.fourcc, > - service->client_id); > + snprintf(entity, sizeof(entity), "%p4cc:%03d", > + &service->base.fourcc, > + service->client_id); > entity_uc = &service->service_use_count; > } else { > vchiq_log_error(state->dev, VCHIQ_SUSPEND, "%s null service ptr", __func__); > @@ -1506,12 +1506,12 @@ vchiq_release_internal(struct vchiq_state *state, struct vchiq_service *service) > } > > if (service) { > - sprintf(entity, "%p4cc:%03d", > - &service->base.fourcc, > - service->client_id); > + snprintf(entity, sizeof(entity), "%p4cc:%03d", > + &service->base.fourcc, > + service->client_id); > entity_uc = &service->service_use_count; > } else { > - sprintf(entity, "PEER: "); > + snprintf(entity, sizeof(entity), "PEER: "); > entity_uc = &arm_state->peer_use_count; > } >