Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3539505imu; Mon, 7 Jan 2019 05:18:48 -0800 (PST) X-Google-Smtp-Source: ALg8bN4xdI6o1w8fo6NgiGM7GN/i80DxYmUi66ZJ2b3juMaXZwhukq1vJi1+Hh+xjOhu32iLlGBN X-Received: by 2002:a63:9b11:: with SMTP id r17mr11004817pgd.416.1546867128565; Mon, 07 Jan 2019 05:18:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546867128; cv=none; d=google.com; s=arc-20160816; b=SZcra0IY0XIkuatOJ16gS/6QIwuTNjg/pEFjEvwGUdc+HtV0So9CIfh+U1WG9jIInY g/MzBmXfxKv52QtyaHQZ8LQ6T8b1fBjvobOs1ImMJgZW7PEPkUKt1ufOPgLJqSqggabg cL4t8gy3+QOCG2g2tReAqjpeSn6hmXlzfNcxc+ss2T9MW3cPcuoYpMakfRMQnsNxCrQI fHQENcZSgrKKIcxTJ4JcIeJBnpZEdOOgwaeg68X8ZX97MT6zBAJZ9q6qe9YuVWoGnnIw HO12FIMgRmCwvpOSNF57sS9glY15UGNx9/aUnmBIZQwxNQBa70FwuQaiOYhv9u5BOVko 6bqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1sX4zbtA4JEVyvsAY624kN8aORpnuEM4/fc9DlKGR80=; b=taMlwKW7OnUJ5HvekFactdgwyb2oJ14dqdqskFUM51Tm/tYq9LF0Y19kWPoDXufZwZ J4no2pbJZCAPFCiHo2NtQD/I4zVA8eBo3NJcyuCn1SnW0vCIumndiRY+Dgg6u+g9FsQX As1wZ43ycTFyriNZzh0bHjSTf5Ku+R8YYTEQcJFqK6LCPRuFyc0g2mBjpfg+Ct+XvtUO nSeYUyCSA6c3tHjWWGmyVfcrb8EVUg4560rwlAUtaMjTn9gU3jYQWVKgY8+Ij1b8IgIr PDbL97Ow4zpTcCPWn5HkUE2uj+iImJL+nBCQSuonEnlX+8L3IdLPBmKx+bumU4h04We+ 9WZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QPqUFzYU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ce11si11275459plb.420.2019.01.07.05.18.33; Mon, 07 Jan 2019 05:18:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QPqUFzYU; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729773AbfAGNAX (ORCPT + 99 others); Mon, 7 Jan 2019 08:00:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:47844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730435AbfAGNAT (ORCPT ); Mon, 7 Jan 2019 08:00:19 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8145E206BB; Mon, 7 Jan 2019 13:00:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546866019; bh=0e2IVA6aBRnOrzUZwNqWhCkwW54tu34JaU/qXezzldI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QPqUFzYUQtvgxZFULetwrJZZX+i7PoESQ6clUfSxEqbPaNCo8bqOEQe+77hEZL6Bi O/am3X8Z/rnSx0NjIT/biNfntfqxrQDa3TMGrHfx5uY9ku8bEcUu2AsOc1+C+D7wdf K/CmUIkteYAddGEojgpPHnOVdmsayB/DmmzY8yy4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+8993c0fa96d57c399735@syzkaller.appspotmail.com, "Michael S. Tsirkin" , John Fastabend , Jason Wang , Cong Wang , "David S. Miller" Subject: [PATCH 4.14 019/101] ptr_ring: wrap back ->producer in __ptr_ring_swap_queue() Date: Mon, 7 Jan 2019 13:32:07 +0100 Message-Id: <20190107105334.007994537@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107105330.372621917@linuxfoundation.org> References: <20190107105330.372621917@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cong Wang [ Upstream commit aff6db454599d62191aabc208930e891748e4322 ] __ptr_ring_swap_queue() tries to move pointers from the old ring to the new one, but it forgets to check if ->producer is beyond the new size at the end of the operation. This leads to an out-of-bound access in __ptr_ring_produce() as reported by syzbot. Reported-by: syzbot+8993c0fa96d57c399735@syzkaller.appspotmail.com Fixes: 5d49de532002 ("ptr_ring: resize support") Cc: "Michael S. Tsirkin" Cc: John Fastabend Cc: Jason Wang Signed-off-by: Cong Wang Acked-by: Michael S. Tsirkin Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/linux/ptr_ring.h | 2 ++ 1 file changed, 2 insertions(+) --- a/include/linux/ptr_ring.h +++ b/include/linux/ptr_ring.h @@ -551,6 +551,8 @@ static inline void **__ptr_ring_swap_que else if (destroy) destroy(ptr); + if (producer >= size) + producer = 0; __ptr_ring_set_size(r, size); r->producer = producer; r->consumer_head = 0;