Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3922736pxb; Mon, 4 Oct 2021 12:43:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOGSFnREuCFcjUe2VtGOhzpGFEw7luV4Dp9tHgCwrJFEJ7X2G6gTTJBzJf9Of4067vqyOs X-Received: by 2002:a17:906:ed1:: with SMTP id u17mr20104886eji.304.1633376633113; Mon, 04 Oct 2021 12:43:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633376633; cv=none; d=google.com; s=arc-20160816; b=GZAN5jnQvaO8pAdPCOClwQtzSOkcWEj18UtAUK0rhziVrrLvMHP4jJ9six/jO+Zthe qsGYehN4MYhPsEGILuhhiDc3XaMi9JBuHIw50FuOCdjxhh9/a5kMi4R+YD6rOOSbi62V SMK1bNb2yb57wYn2A53F2prCYAVk4rSOgrKbX/OdC81EcWjt86k2hWgUH8RSwXB5/Ea8 PxVjRpUk/aOr7yz8R+T1z9WX71C6cw3DUzniMoThyjb6dLrPolDJvM8BjTod/HpkkJcH QRJPgDf3XfNJbHnIJe0BMigp1Y4eF6QfYKowL6uk9TIX6Remhh3zfPO0ep2tQby/uQFp 2+yQ== 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=Z1tW5g3W+Ka9yecjsaOU3Q9NROauCnyqT4+35FzXPDg=; b=aojiUYv9ZrgWkV1vXvECyDKpEWUhBYnl/fFmGD61SLEJ7/fkW0ibIYnN3Q8YKPL0TA wvpwY/HICWjM6HOegOjKz+rrN1JxO9PUfSriPnGCPZysTbdb8h4cdZlMU5GPU6/5gMi1 WXnou8TyqsgZ0T3u+F3qkVnMGt8cAQFhblLMFbVsQVwcAft7eH3cneHsBm4Iw0CEDqhz U46H66qY7DaUtPiFp6Wbqt725wVZ5n8HMyvS49MI5pLyDjTa8Sq7OtXiEt8VHa4jeJ2n O57Oauc/3NZqczZP6j7FtrSP5vEgpojwkUZJItMignkBsTRbf0fbz0mW0bLFWR81OaUO 9V2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=szTZrn82; 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 5si18820774ejq.398.2021.10.04.12.43.29; Mon, 04 Oct 2021 12:43:53 -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=szTZrn82; 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 S234515AbhJDNJG (ORCPT + 99 others); Mon, 4 Oct 2021 09:09:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:39234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235301AbhJDNGr (ORCPT ); Mon, 4 Oct 2021 09:06:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9937D61B40; Mon, 4 Oct 2021 13:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633352483; bh=vqWyOeURbVSKl5y9uVz/VN+k2c77rNz1w9AaZ81FS7o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=szTZrn82o0OH2lGrdKrWXDw9oxFW8WWi+bk75mlTXf9m5LvwPhD05vuMgk3Z3sT+9 AkhVa1uHthW4VEOnO+lyuBHjfboHjEyuHidypWI2e9YptrqmctzDh9KCcJmBwPY/lt LI2IdaE8qK3I0AZyYL71RGpzUi1hG36gthda+aKc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+3493b1873fb3ea827986@syzkaller.appspotmail.com, syzbot+2b8443c35458a617c904@syzkaller.appspotmail.com, syzbot+ee5cb15f4a0e85e0d54e@syzkaller.appspotmail.com, Jozsef Kadlecsik , Pablo Neira Ayuso Subject: [PATCH 4.14 73/75] netfilter: ipset: Fix oversized kvmalloc() calls Date: Mon, 4 Oct 2021 14:52:48 +0200 Message-Id: <20211004125033.979324818@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125031.530773667@linuxfoundation.org> References: <20211004125031.530773667@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: Jozsef Kadlecsik commit 7bbc3d385bd813077acaf0e6fdb2a86a901f5382 upstream. The commit commit 7661809d493b426e979f39ab512e3adf41fbcc69 Author: Linus Torvalds Date: Wed Jul 14 09:45:49 2021 -0700 mm: don't allow oversized kvmalloc() calls limits the max allocatable memory via kvmalloc() to MAX_INT. Apply the same limit in ipset. Reported-by: syzbot+3493b1873fb3ea827986@syzkaller.appspotmail.com Reported-by: syzbot+2b8443c35458a617c904@syzkaller.appspotmail.com Reported-by: syzbot+ee5cb15f4a0e85e0d54e@syzkaller.appspotmail.com Signed-off-by: Jozsef Kadlecsik Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/ipset/ip_set_hash_gen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/netfilter/ipset/ip_set_hash_gen.h +++ b/net/netfilter/ipset/ip_set_hash_gen.h @@ -104,11 +104,11 @@ htable_size(u8 hbits) { size_t hsize; - /* We must fit both into u32 in jhash and size_t */ + /* We must fit both into u32 in jhash and INT_MAX in kvmalloc_node() */ if (hbits > 31) return 0; hsize = jhash_size(hbits); - if ((((size_t)-1) - sizeof(struct htable)) / sizeof(struct hbucket *) + if ((INT_MAX - sizeof(struct htable)) / sizeof(struct hbucket *) < hsize) return 0;