Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp271079lqr; Wed, 5 Jun 2024 05:51:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV14soWBwXxCwt1TjtXyxvRTBOferfbfolLFtM932n50HJNEDMfO0Ze9eUBHGRxdMBHRCvDg35ufS56XfHsCLZzL1N7eYi6wYJPOA40BQ== X-Google-Smtp-Source: AGHT+IFkathTOYGaMhaE4jaJolFuqMqocPOSFf9mKtBZapeYiIF6pm7Qs+Y9m+06nAfQovpux1mr X-Received: by 2002:a05:6512:104b:b0:52b:88db:a554 with SMTP id 2adb3069b0e04-52bab4c92e9mr1909522e87.8.1717591882914; Wed, 05 Jun 2024 05:51:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717591882; cv=pass; d=google.com; s=arc-20160816; b=kpfH4IvR/RZ6Wfcz5M/zjQx5ou8BNTJr0+nhiOoONCs2VP0yly9xC7029XVfE5CITL 9GUl2wxzYmfR+dzB/fq5bWOZdN1tkoA7Tz1N94BVUgfXzIyg0ZSaEl1fdMhAjGyc3hMZ VSRagMzeH3+SEo4lzS5xZbFNS+Ld/+wH78oU2SalT0eOyZKgUOotHXvXQIlZjKw4I1oV ei3y8TkzvTYKsmvoFtGmJ0coLBV76D+Zfz6wOAejqs0iAGXfWLk/DU8HDfr30xWUZ8h0 3nCNNcpdWgtIt+4hpaJ+ujER8WL26pIge5jb5VmEw/uEi3kbktH+37Aha3tCB7qfKdqw 301w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=zxjUWcOcv4xb8QeoDT83zUQslraxN01Z9NXXrodMjgo=; fh=qqnPBhyjCIMvgbkidnRINwOEujzP9apqd5l18KtxJAk=; b=IK9mbfo/97oXKIyHEiACJQbOolqFrfDbbeLrMzgikl0iUazDU+m7rK7EDHZl+jELuV FMi0NRIYzMZV+gfHl7dB+wGPGnCDETQbjUdFPOQSpdGdRFh4YAcmzXkvv3MQNxyFcRyN OlqlHl2tVC/BPEztY0W4O7Nv5XT1naLVaidT9vRHc82VOyomHbpdSTe1G0SUJC3rhT1F 0FtcWgm6X+rmSAXhMYzKIle/uPbiQ+08kBx7IbSJiGST61caKINeAIyRBCLB+oGd8Q+4 grK9rm0Qujz+JB7a36KxGZvubY9iw/eK+gv7gR7mHAFEuIL11qe62+KKRWoRB3Vsuug0 QwTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N7qU8FC9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202539-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202539-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31c631d2si6380043a12.313.2024.06.05.05.51.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 05:51:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202539-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=N7qU8FC9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202539-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202539-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9434F1F2A55E for ; Wed, 5 Jun 2024 12:51:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 681FC1D0076; Wed, 5 Jun 2024 12:05:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="N7qU8FC9" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 811471CF8BB; Wed, 5 Jun 2024 12:05:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717589147; cv=none; b=Huy43m0U0bnHFO1sTpTo8g6LgpYmpwUNBHDRoYGtKOC6BzbQcJjt/XZ7F+kMwBcGxeOy04D0jBnyfOitN6ppCiRRpfcjgvQ5EPePVwPDsNYI6To9x/zDSbFOGIkLczXlCzEbX/vintZsOxvCEjsCE5/6+a7hbAB6VW4FAqrdtEE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717589147; c=relaxed/simple; bh=Ki0uOE9OVNhemVSk0RYDvPVVhdi998Yhw6Tvj9L3ZUg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HSSmJJdqOlEfKpGwSFnlILgtSQrZkwRCEmugdNva/sbLDmK46HCvtoZMVrN/iLTj2ydJebuRen5/7loo+VtkSL2W/GWPRHvhrL+BMIDCoj7HPZC4B0Bb7PlboF8pgkHzv7NsVozP1pmZftVQcTQV7X7A+DCy8DZhADV/fO1wb7c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N7qU8FC9; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23D7CC3277B; Wed, 5 Jun 2024 12:05:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717589147; bh=Ki0uOE9OVNhemVSk0RYDvPVVhdi998Yhw6Tvj9L3ZUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N7qU8FC9CyUB6FJqfoMGSvOn+KwubGl+Sta5WSAVCIAlpEvg6DAfcLGe/0INuvCAl +TzlLEtmCOa8msafE6IxLIvjWW6Yz1Nn4R8xEKenL2FzeleW7dRa8FCF0NIdveJX5o MhUAla6ZM640BiPYKrweqHf6LFH4v2hcNv6CRgVEW702fXBhS6G1E0BGseynBDyOX8 jgVuz9oeVIf2HGTln9PQ8xpTGu576kPD+LAiH74ZgMF5LR+b01tQrfb0U+bGuLHq8F ENY8NIGBiPlzg21ndbAESnrm3B25CKHGKgkHQXIdbArHhtFgW6H6qBaaUjk30UvRgN ldpdVu82Xd79A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Edward Adam Davis , syzbot+71bfed2b2bcea46c98f2@syzkaller.appspotmail.com, "David S . Miller" , Sasha Levin , bongsu.jeon@samsung.com, krzk@kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.15 11/12] nfc/nci: Add the inconsistency check between the input data length and count Date: Wed, 5 Jun 2024 08:05:21 -0400 Message-ID: <20240605120528.2967750-11-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605120528.2967750-1-sashal@kernel.org> References: <20240605120528.2967750-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.160 Content-Transfer-Encoding: 8bit From: Edward Adam Davis [ Upstream commit 068648aab72c9ba7b0597354ef4d81ffaac7b979 ] write$nci(r0, &(0x7f0000000740)=ANY=[@ANYBLOB="610501"], 0xf) Syzbot constructed a write() call with a data length of 3 bytes but a count value of 15, which passed too little data to meet the basic requirements of the function nci_rf_intf_activated_ntf_packet(). Therefore, increasing the comparison between data length and count value to avoid problems caused by inconsistent data length and count. Reported-and-tested-by: syzbot+71bfed2b2bcea46c98f2@syzkaller.appspotmail.com Signed-off-by: Edward Adam Davis Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/nfc/virtual_ncidev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/nfc/virtual_ncidev.c b/drivers/nfc/virtual_ncidev.c index 6317e8505aaad..09d4ab0e63b1a 100644 --- a/drivers/nfc/virtual_ncidev.c +++ b/drivers/nfc/virtual_ncidev.c @@ -121,6 +121,10 @@ static ssize_t virtual_ncidev_write(struct file *file, kfree_skb(skb); return -EFAULT; } + if (strnlen(skb->data, count) != count) { + kfree_skb(skb); + return -EINVAL; + } nci_recv_frame(ndev, skb); return count; -- 2.43.0