From mboxrd@z Thu Jan 1 00:00:00 1970 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 C30FC17623C; Tue, 16 Jul 2024 16:00:28 +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=1721145628; cv=none; b=hS41gHBOgrtnidn/gI6NVL7zUKUegaQezbhWCExxkj+SieTNKyjd1WtpuGt96zf4LmHBrJbAbB3u/eDwg4vof5Fn0bGnvPXXnJaUUKzAp/2hqvTVf2Kc6ts68WgML1IiWgaB+ql39Rd5kj5UaT/jKncfQNLBEwmNNVXTvOtoG48= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721145628; c=relaxed/simple; bh=+ddMzR7yvZMI41QgOKRcM8PVTgs8RGJ3ijtsGLA2J+E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OClKLC6N73NCGIIfBl/B64q7NkimZhOIkVe85yojv/5anOQdEE+0dY/QC69AzPxNNxm8ax5AU/EeAuGX3E2S1xgyevAS3xzq6xQiHTnwKoACZqJZRIPb+fnVmFEGpS1OQavQpLkTnIlNq9ACfLq6hKL66PQR/sXMHEXlVXPHNhI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NNyHeKOw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="NNyHeKOw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F16D1C116B1; Tue, 16 Jul 2024 16:00:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1721145628; bh=+ddMzR7yvZMI41QgOKRcM8PVTgs8RGJ3ijtsGLA2J+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NNyHeKOwSYQNMW2wrOrzyEv6C0GoK74RW5dWA0eQP/hZifUQbxLVI4EyyzUPxyFjS zzfU6Il9M+jJvEPweXTf1M12Uv4GtcEKHTzKY7js+OnXQgDP8uu6im+ZEghvCTX39M H6O8yQetLFobBYT73GL7Wmb5UoDmkp3U5fM3A/i4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+ec0723ba9605678b14bf@syzkaller.appspotmail.com, Dmitry Antipov , Paolo Abeni , Sasha Levin Subject: [PATCH 6.6 031/121] ppp: reject claimed-as-LCP but actually malformed packets Date: Tue, 16 Jul 2024 17:31:33 +0200 Message-ID: <20240716152752.521788997@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240716152751.312512071@linuxfoundation.org> References: <20240716152751.312512071@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dmitry Antipov [ Upstream commit f2aeb7306a898e1cbd03963d376f4b6656ca2b55 ] Since 'ppp_async_encode()' assumes valid LCP packets (with code from 1 to 7 inclusive), add 'ppp_check_packet()' to ensure that LCP packet has an actual body beyond PPP_LCP header bytes, and reject claimed-as-LCP but actually malformed data otherwise. Reported-by: syzbot+ec0723ba9605678b14bf@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=ec0723ba9605678b14bf Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Dmitry Antipov Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- drivers/net/ppp/ppp_generic.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index a9beacd552cf8..370c84f393759 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -70,6 +70,7 @@ #define MPHDRLEN_SSN 4 /* ditto with short sequence numbers */ #define PPP_PROTO_LEN 2 +#define PPP_LCP_HDRLEN 4 /* * An instance of /dev/ppp can be associated with either a ppp @@ -491,6 +492,15 @@ static ssize_t ppp_read(struct file *file, char __user *buf, return ret; } +static bool ppp_check_packet(struct sk_buff *skb, size_t count) +{ + /* LCP packets must include LCP header which 4 bytes long: + * 1-byte code, 1-byte identifier, and 2-byte length. + */ + return get_unaligned_be16(skb->data) != PPP_LCP || + count >= PPP_PROTO_LEN + PPP_LCP_HDRLEN; +} + static ssize_t ppp_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { @@ -513,6 +523,11 @@ static ssize_t ppp_write(struct file *file, const char __user *buf, kfree_skb(skb); goto out; } + ret = -EINVAL; + if (unlikely(!ppp_check_packet(skb, count))) { + kfree_skb(skb); + goto out; + } switch (pf->kind) { case INTERFACE: -- 2.43.0