Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp382716imi; Thu, 21 Jul 2022 02:59:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tXPbOmD3tAFIlhI1TwiRhGC/lk9LfGM4S535Z80u9Ulu0Rwr6YNSaMcK6xDF9smkZdmPRG X-Received: by 2002:a17:902:a418:b0:16c:9ee2:8a02 with SMTP id p24-20020a170902a41800b0016c9ee28a02mr40081010plq.46.1658397583426; Thu, 21 Jul 2022 02:59:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658397583; cv=none; d=google.com; s=arc-20160816; b=PlxwAB6UTEza3+C+gNhGBMrOr2GJegvOklmVCDL9117DDwYUl/D3xEN3EID/Ja7akn 9oiDqKWngk6g6tdj7UEK8f52+QltHO40I+7+uZxTfafNAbii3jeCXFwS1fllDqaUEp3A vvQLLaPY0+pfGCpgSRCH4at90Clan6zNYbTKTcADNVUXgXRWiiipFjLoDAWfqqbO2IRc Et5kZ0z+HD3+nWvU2U0xr1EWfldGQuU6m30YyooD9Bu4oDtmcYq3yL0rvL1AOkPIrlDH bRjtRtdreRHxhFuTk67CxF+u5STUiATLE+T/4YkQt2leq4XkscDdI0oOefDgl/7KFiuY tByg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=s7pMiP/9j5gqy138DcdEwcvy+WfM/+/mQb8ZoyQMvi8=; b=tpyGsxhA0v0w1W2Vk9a2je7UmfQ4JfaPFxKGFXRg1PN0IeWrYBfxsvPh0E5VxQ5f3b oxMFdzIc54znknksgG7Qf42QiDbpERXDGGgy2pxDeKcRkm/w6BOAdBkU0vJCzDE9BW8E G03msWfaG/rygGLPwncAHp5CNGiE/pBQRklsjo3jRs2QkIqSOtJ5eLqmFMza3oWDUfKk rj19PGf8bDjGSJ+fLJcNeBmtUatzc5xQEbcHeN0/1kYtAQK4Iu4htaBznlz9NErEKrBh OXsoxRwOk4P8QVp5LIEIbgL51mE5RM5O5sBuJRVEVByVnwEpt3u4tXBspX8iLTLmNKTL pDog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Ng/k38Qz"; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i1-20020a625401000000b0052534e6f7a8si2082065pfb.34.2022.07.21.02.59.27; Thu, 21 Jul 2022 02:59:43 -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=@kernel.org header.s=k20201202 header.b="Ng/k38Qz"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232853AbiGUJzk (ORCPT + 99 others); Thu, 21 Jul 2022 05:55:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231911AbiGUJzi (ORCPT ); Thu, 21 Jul 2022 05:55:38 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 178B61F2D3; Thu, 21 Jul 2022 02:55:37 -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 ams.source.kernel.org (Postfix) with ESMTPS id AAC07B8239B; Thu, 21 Jul 2022 09:55:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC504C341C0; Thu, 21 Jul 2022 09:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658397334; bh=n0AzAmoKf2av80Wtb427rzY8dvn5DDBPRE8jvSLUUQg=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=Ng/k38QzzS2QMLtyvMtKXgQLx9LdlYBfteJzgtClXX3/l0Wmh1KkmI4tNZ7bgQWoh WKmAZAVjjSqKXfkehryWpsnXpjjzQFSu2a1LgclW6hA23KP+jKtEfzktDcTi+xcZco hNjf9yzz/TTu5xWbtAMCHsQAKsa7YojbqyG+fYS9EhfO83DMEW0js7fM91i9VQSYSG qpLtGUgpWXuhAEDQ3//RVSI0MdXb0inZQBNAxEcALF04OgGK9ekszusA9UUKz2OpAp C/ec/LGCHrM+7m0sH2Z2/qxWtrFNbx6FpC3v3MEEUquc9tIV8sLRE5e7ApjiHJCVYH VehXRKTmClFZw== Date: Thu, 21 Jul 2022 11:55:23 +0200 (CEST) From: Jiri Kosina To: Harshit Mogalapalli cc: dan.carpenter@oracle.com, Rishi Gupta , Benjamin Tissoires , linux-i2c@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] HID: mcp2221: prevent a buffer overflow in mcp_smbus_write() In-Reply-To: <20220620162824.58937-1-harshit.m.mogalapalli@oracle.com> Message-ID: References: <20220620162824.58937-1-harshit.m.mogalapalli@oracle.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-7.8 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 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 On Mon, 20 Jun 2022, Harshit Mogalapalli wrote: > Smatch Warning: > drivers/hid/hid-mcp2221.c:388 mcp_smbus_write() error: __memcpy() > '&mcp->txbuf[5]' too small (59 vs 255) > drivers/hid/hid-mcp2221.c:388 mcp_smbus_write() error: __memcpy() 'buf' > too small (34 vs 255) > > The 'len' variable can take a value between 0-255 as it can come from > data->block[0] and it is user data. So add an bound check to prevent a > buffer overflow in memcpy(). > > Fixes: 67a95c21463d ("HID: mcp2221: add usb to i2c-smbus host bridge") > Signed-off-by: Harshit Mogalapalli Applied, thanks. -- Jiri Kosina SUSE Labs