Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp261240lqr; Wed, 5 Jun 2024 05:32:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXBe+uhAXl+up62Wy6lcip4UG/tX/3lmsFRmJQF+Tct4V/1U04K9VxWNX5y9MLb4FCO1dCRCtYOK+q2Zut/2Zfh7hB4HiR/l3XPzrmE+w== X-Google-Smtp-Source: AGHT+IHmzrLu7hADxVb/m1QTBUa/A9gWkQkq+OuYjX9dvoXC8eWWRZ/F10knE7BPuOdtFXRclbXI X-Received: by 2002:a50:c31b:0:b0:574:ebf4:f78c with SMTP id 4fb4d7f45d1cf-57a8b676fdfmr1497696a12.7.1717590753405; Wed, 05 Jun 2024 05:32:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717590753; cv=pass; d=google.com; s=arc-20160816; b=WnHw6iiTzMEvUqXmmHZ+BTELWpffRAzn6LowqbGGQWdEV22OdYtEOm2gabh978NR/A ixOYXmiqdVGWJQuwlR4ovlWxnw8b4Q9sUXd9dxbM2K/zmHz0xjgj5U91oCEwPiCVBFJ0 Gk8t08vBsJBP90RXZXTyroUTbxs71wkvBSh0AR3pO7T+YT2FDARNpEA5ebYCrY40EAf5 Q8dAQgUJ/F7rYy47aWXVBkhRMYwUjLB+fvc4CNM2/s5HEnVqhHfZIHo/iwNeFoDEKxEa /8qzLxP6vNkDVbNeCwwlK8Nx4rjq/0DPIROy++9ryHAHZvyFsvDuCQi9JwNrCvAADGc6 /HCA== 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=+oVOmpTAxOMMKZjcjU13nEnV6cnoGQoBPqMYqm+V2YE=; fh=qqnPBhyjCIMvgbkidnRINwOEujzP9apqd5l18KtxJAk=; b=X6wi3UHe+h7kBKRdcbZdND/8oaCYqeRZ6xKIkl6zUKO+87CJkOco4pvVTXIlYEW+tJ owJuCqt9Ad3qPMop1kVrUZEAuUV+Hj8+c9XRSXoDs/ITNBxy2pcRFf+MYclTAwGdgHLq eaRy7NOwXgdvuyEg25KPPm+V7/JfoRLdvy4A8gLSlSe/p6G5HIYcgjF+1MHxs8sVt/N4 puF419Vx/gwcwjVhqT32hZy6nzdnDKosojPqtqEpzTZ/cuFQEXunsiM5Y/1vM/rbNnwn +J72Vss36159cp2IolYKBnzOh3Lwy6Fyhfh4pBKRX1nyRr1YXSuFtjUaY1A6D3iAuIiM aLFQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HrJxvW0O; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202467-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202467-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31ba8290si6038717a12.180.2024.06.05.05.32.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 05:32:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202467-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HrJxvW0O; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202467-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202467-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 217C51F256C3 for ; Wed, 5 Jun 2024 12:32:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 773621A0DE5; Wed, 5 Jun 2024 12:02:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HrJxvW0O" 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 9513C1A0DC7; Wed, 5 Jun 2024 12:02:49 +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=1717588969; cv=none; b=hhAUDh2no4B39qkydBXSTW2lqcGaZK7IfrSFYB2ojO2hkCRYzUgK7RMoAJdEKJN3uJOp+4G5J+3J8sJ/jCB3cTRuFbSnoWQGP/Tcx4JwStKeN84twzrp0EOFKae44/yRIqhciHNrJaU1AU/Qp6bMspA0ap6mc7DHtJyILUCOH5U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717588969; c=relaxed/simple; bh=m3CfvU2t8e740CAdb6g+m9jKiMWSdqG1ZUq+ET575AA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=asWR0NqN2DxzOlwTzVkHGAHmg2AbkzeKVlsjETsvbx+pxdmBvXatorYSQ70ITMxFLPUpsQTmP6aIFdJhUmD7Wj2gkDL3Yg8k64Y6t3TqNGVgVa6AKakwsDyNYzCT1ivrEXkokFMgMBIKd4MbTRmwV62+jzE0FhlS3zWFZJ5cEGk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HrJxvW0O; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FA0AC3277B; Wed, 5 Jun 2024 12:02:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717588969; bh=m3CfvU2t8e740CAdb6g+m9jKiMWSdqG1ZUq+ET575AA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HrJxvW0OAmkYrykbUtSD/4tBYKvA8KiyFfw732zHdrvIQLFIwUvuUnmzo6ATQ1yz/ C7wepcOsMjdQe2HlGsf+8y8gEBJDzNPgQFzna5JguVnJbT6aDrpo5bX9aNfG5Mv4+d foTE1noOc5Fqyqqv279OVjML5NLLrlNWaSSTt/ljqG0rbTvLTl1P1MeLCfRpfBZSlG z4ai0sWnECL9yDk5dBPHYjZoK1uMQJuj05pymc32P4Nq8OixObn2Ip4OsfjHkV3vdx uyfhm3Vnvkhz2vmdSLIqARtLBILCLL/W0Pwwfcs6wFUE9Cyr46ho5Tu0U3wIe1AJPu lMcD7WXkuJf8Q== 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 6.9 16/23] nfc/nci: Add the inconsistency check between the input data length and count Date: Wed, 5 Jun 2024 08:01:59 -0400 Message-ID: <20240605120220.2966127-16-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605120220.2966127-1-sashal@kernel.org> References: <20240605120220.2966127-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 6.9.3 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 590b038e449e5..6b89d596ba9af 100644 --- a/drivers/nfc/virtual_ncidev.c +++ b/drivers/nfc/virtual_ncidev.c @@ -125,6 +125,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(vdev->ndev, skb); return count; -- 2.43.0