Received: by 10.223.185.116 with SMTP id b49csp1035713wrg; Fri, 23 Feb 2018 10:44:36 -0800 (PST) X-Google-Smtp-Source: AH8x2245k/3XtdJ1j5zBE3G5KeVIW8rRx2tJkDSY7LHq+PpUBTlu1r3/wLAQTfZO/0pbl4eRWxw2 X-Received: by 2002:a17:902:7796:: with SMTP id o22-v6mr2603435pll.215.1519411476639; Fri, 23 Feb 2018 10:44:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519411476; cv=none; d=google.com; s=arc-20160816; b=BjDJyRBOe2tSTo/QDALcvAQNFzY1eQuNwB4fTEz2wB7/3OOe05j26R0lXaXLVSKPGl kozoR1evIuT9Pyqr7fe+11IzeSgHoTfCneqEswZxIwfFUV1gu9sYNP0kNfJpxENIl2sx em125WUv+gczWm0pSbBHp2OP5vm2ValIQhKWxkO/Z/br+N6Uz+w747IvumNSNJOtWVVp 40870MsIDzwZvefqo6AO3Ex+kEJpJXobZ+Zyxg1SWbuY7RZ6qdMABLD+tI0DF1ruTM29 6tGbsyLGS0k2vINn0OgB4pT+U80wRxwiWyCRHYwx8+sZ+ZiFjvzSR93dKlt/lJwRJW6L 7qZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=l/6tm4U/mfV/GwdY9onGqcSLfIDJcrEhr4GKSkqedvQ=; b=bwomNKqHQ2DypRHrlJWjcTV+x+HuJFjJe+u8bfbgtd1zW8MwozsehmeBYpbi7vB1gT Icu1V0TKoVbJ8V5XQmEmTi49i2HosIDJpD8ZyIb8f0hj6KhM4nWAHQNT1OpSyTV1Mx+0 +SNlQfCCAElEvpOtstxcncffeKrtTPUL//l0T3uwo8jAXvp8QEVJBVlvDJW18vUgOFi+ KKgZjj+De0ZqwPZIqzafQuQ/IznPBdpjaYKz56OPsOYyXgN2JeovOg9jrQe9zW930lsG G+SYU0pDdGxjAfkPrXD7yKVyXcF5T9NdBhLQkoHmkiDQ2/MLJFoCif588/seF3AzgDZk cU+g== ARC-Authentication-Results: i=1; mx.google.com; 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 e33-v6si2140674pld.493.2018.02.23.10.44.22; Fri, 23 Feb 2018 10:44:36 -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; 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 S933060AbeBWSmc (ORCPT + 99 others); Fri, 23 Feb 2018 13:42:32 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:41518 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932515AbeBWSm0 (ORCPT ); Fri, 23 Feb 2018 13:42:26 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7164FFA1; Fri, 23 Feb 2018 18:42:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+e4d4f9ddd4295539735d@syzkaller.appspotmail.com, Jason Wang , "Michael S. Tsirkin" , "David S. Miller" Subject: [PATCH 4.9 012/145] ptr_ring: fail early if queue occupies more than KMALLOC_MAX_SIZE Date: Fri, 23 Feb 2018 19:25:18 +0100 Message-Id: <20180223170726.257211330@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jason Wang commit 6e6e41c3112276288ccaf80c70916779b84bb276 upstream. To avoid slab to warn about exceeded size, fail early if queue occupies more than KMALLOC_MAX_SIZE. Reported-by: syzbot+e4d4f9ddd4295539735d@syzkaller.appspotmail.com Fixes: 2e0ab8ca83c12 ("ptr_ring: array based FIFO for pointers") Signed-off-by: Jason 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 @@ -351,6 +351,8 @@ static inline void *ptr_ring_consume_bh( static inline void **__ptr_ring_init_queue_alloc(unsigned int size, gfp_t gfp) { + if (size * sizeof(void *) > KMALLOC_MAX_SIZE) + return NULL; return kcalloc(size, sizeof(void *), gfp); }