Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3938069pxj; Mon, 21 Jun 2021 09:46:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxn72KlY/Wtq6XjqksIKFvtYPkd2Ab7wpVqOxWxwdxpvXNvfr8KATEJavg8hwZOjzOB9CG/ X-Received: by 2002:a92:c563:: with SMTP id b3mr3307469ilj.275.1624293987872; Mon, 21 Jun 2021 09:46:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293987; cv=none; d=google.com; s=arc-20160816; b=aW8PTRAAFgDGCU0dsRxCpv34lA0wIzSoPTmc00yWGh39LSXzj8x6K/x5femQFL4n4y KrygEtNqT7F2h2GOgp6PXDiM+cuaWcFtXlmH2/fW7vJcKIicFeGSel9Tl3cpoVVvn4SK L3p/w3UQMXDNEQy3GPsu+ebTGjf09Hk3Kdy7noplAtAePQzHOP3v0UuPFeYCN5QsbBk0 c1WhBpMwNAIxGzSqaIfeIeJ1gl3ro72KeARfcIXFVUR/sNyHVQ0r59zclm4UPOeDIWyK NI8l7SAu3Rscr6FCPew6W+qTcT+K/psJ9+Z+Rbrz9vY3Ao+n/kwwobW/7M/y/+gvk7lL YHEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bJ9kCDsuKRqd1FVhDm85neO1XPnk82Sdnp/lzUxJdKo=; b=lAxwGggPcin/ds9BIJdfWt8zc9bkxIhTLmDGkKlr3GvKTwZjOgrHGepwBGAXfQDiHk CWiGxo+z63NORhomhv83yE6kEVPafYnpPVcIEOAwgeZR0TDNMYLpmy+fZdDIe9tJTG5Y BV4RLQiWYesMRoOxjJ3qDHSBwMBTB9zEysmEwp1Q6bpYTxjSOQbGZk71LiiGi0AAzK4v JC3zRqu6x3c78uId48Ouqju/g0hAqdxzgOHliqhmyqNye1v7SIIwyNWfXlIFqJdQd27Y jNUlZiLw3u6tWGxloy9NBXzIncVH7vAjaYxy0iI31r3ssGzeszldh8tnDJsspv3JchSw /hsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f1pgO8nq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 141si21601258iou.9.2021.06.21.09.46.16; Mon, 21 Jun 2021 09:46:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f1pgO8nq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232596AbhFUQrv (ORCPT + 99 others); Mon, 21 Jun 2021 12:47:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:33868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233163AbhFUQnR (ORCPT ); Mon, 21 Jun 2021 12:43:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3840D61445; Mon, 21 Jun 2021 16:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624293089; bh=G6azULgzfCzqoGEWeSwpKyauIDsk5HwKoz6iDfwBgMs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f1pgO8nq0kykThVHWr4aW10Ve0CemcPqelg48oU8SD8dKyk2hmCBpYXsC6HlcOv+D pLiwkagI1LFV7y7X74J1c6mQkG9Epufhpejc/AF/NqUg3PQyIh+p0mvYA47/ChpRMX S8mggN3n3Q1Hji6Qcx8W7pQPrfo2P24xNe6faIK8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin , Bjorn Andersson , "David S. Miller" , Sasha Levin , syzbot+1917d778024161609247@syzkaller.appspotmail.com Subject: [PATCH 5.12 061/178] net: qrtr: fix OOB Read in qrtr_endpoint_post Date: Mon, 21 Jun 2021 18:14:35 +0200 Message-Id: <20210621154924.560861055@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154921.212599475@linuxfoundation.org> References: <20210621154921.212599475@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Skripkin [ Upstream commit ad9d24c9429e2159d1e279dc3a83191ccb4daf1d ] Syzbot reported slab-out-of-bounds Read in qrtr_endpoint_post. The problem was in wrong _size_ type: if (len != ALIGN(size, 4) + hdrlen) goto err; If size from qrtr_hdr is 4294967293 (0xfffffffd), the result of ALIGN(size, 4) will be 0. In case of len == hdrlen and size == 4294967293 in header this check won't fail and skb_put_data(skb, data + hdrlen, size); will read out of bound from data, which is hdrlen allocated block. Fixes: 194ccc88297a ("net: qrtr: Support decoding incoming v2 packets") Reported-and-tested-by: syzbot+1917d778024161609247@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin Reviewed-by: Bjorn Andersson Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/qrtr/qrtr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index 1e4fb568fa84..24f10bf7d8a3 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c @@ -435,7 +435,7 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) struct qrtr_sock *ipc; struct sk_buff *skb; struct qrtr_cb *cb; - unsigned int size; + size_t size; unsigned int ver; size_t hdrlen; -- 2.30.2