Received: by 10.223.185.116 with SMTP id b49csp1084640wrg; Fri, 23 Feb 2018 11:38:56 -0800 (PST) X-Google-Smtp-Source: AH8x226L/glQaAqlcGcBfRuZZsO4+r9BCDGF0oXa3QDYTiVL22n3teWADRg96+mOjAa6x4pqwu82 X-Received: by 10.101.75.193 with SMTP id p1mr2267947pgr.63.1519414736483; Fri, 23 Feb 2018 11:38:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519414736; cv=none; d=google.com; s=arc-20160816; b=PLHfgeRNxmL8CE43LyjqCwix4VwyYj0DWdB95yl4isFYINiyUGnameejiZ4qc4A7Zw qTNXNXQrmqTXIZpUCDdUwyrlMVDXzMfnqcFqfZVQctdZB76SvxyivL/yIe237MfHLT0F nSzx2d+BeY/jefmtJf4WiYS+aZE+hTwYxm+A7bUPk98x/h++27qxtgV4dUAtyizd8fk0 SGYibTJRtjunh8shubUt56cr0QnLecjduglO7vT9n88YA8rijXuHfwGrDLuh+nFB6tvv rxblaoQyBLyowl4STbae36dQ6pV4vDCMUPD1YNy531uqGVwAt3xwGkHjxAaa3g7BY/vv Eoig== 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=1EcMNvvYSypI0PqS9DDwWxyo6vh5asN3T3LF0quZI0I=; b=EKQb9+S/f+9s0VpYEji4ZDO5BEip2REVhLEP9iNbGNBAzlh51M+BPtAEByK9ODgMoq ZLHxCQF2UULtgMjvRGl47BOJCKBOvwtu5fUpWgDXimwE8qNpokB1t+W/F6OeUSqaJRwS 273NjJGCCtI3M1Uv+RAviRRFSrpHPGd4ChYFPJx9BZtKxWZsDkuVmMdPvBpvyClmmQz6 J4waIBYHix924gyE6IDscZwJYTAcP9N3Cgs2xPG8k4AVvlpOmub6MUPvn1Ttsbq8zTmq 0VnIjDd5Uka5dB/hSBThRQ7CJ+aIG8XKGy1WyUWyWtB7602bnOSqpOdGBFMJA//LzklJ yEXQ== 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 h12si1859955pgn.439.2018.02.23.11.38.42; Fri, 23 Feb 2018 11:38:56 -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 S934676AbeBWSuM (ORCPT + 99 others); Fri, 23 Feb 2018 13:50:12 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:45518 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934662AbeBWSuI (ORCPT ); Fri, 23 Feb 2018 13:50:08 -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 F120E11B5; Fri, 23 Feb 2018 18:50:07 +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.14 024/159] ptr_ring: fail early if queue occupies more than KMALLOC_MAX_SIZE Date: Fri, 23 Feb 2018 19:25:32 +0100 Message-Id: <20180223170746.103599233@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170743.086611315@linuxfoundation.org> References: <20180223170743.086611315@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.14-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 @@ -447,6 +447,8 @@ static inline int ptr_ring_consume_batch 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); }