Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp2980018pxb; Mon, 6 Sep 2021 09:30:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxl+6mdGZ2kxDjybAYVCKvnJIV7K4HbW/gGKdB/svHdz/MMftI8h6PjdW1yoYtmRJdxYO9v X-Received: by 2002:a17:906:7256:: with SMTP id n22mr14413423ejk.173.1630945844694; Mon, 06 Sep 2021 09:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630945844; cv=none; d=google.com; s=arc-20160816; b=c1Ixol7Egh0gjyfFm+OTl0qRUk/wPjUi+vzyHRow4KOv+bouJ3g7VquynBTJHfQcfJ rs79+mH0ALjHQOKVR4LqlTA0fZjAhTgKllH+PMj4k96jjUe4bKppvKFDb0uGVrb8aF+O 8wgPxoV+xeX2mHk09+raRFzlSBPWJn7upDh4sLLvayNIm1bp4jDf5uNz9qS4NAC94reG 8r/m4/I4DzC5IAczuuho4lFSGc0Pv3/wSbhv/X1bX25ZUfKuuTtFXoumSHNanxxJzNVQ /kA+oOqTeMhYi7gCUeBF7kLDqlZjOGKfaUrgvcL8+MXauPzQpmqEVNTX+XEs+Z3uhDh2 TtTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:subject:to:from:date; bh=p7cXD5iUX2Hbvr+jblMHkm1PBaSYY045BcWcNXq/nJQ=; b=U0o/HKI2/e90NMyKUjWF0xLIs3qUKeqVrlfqPQ8KNN5A6HoUcAWbkWNGzMIkCpA+zq 7X0eiX5KhoToS7FnJHYrF2a6843+qPRhMuyi3Pe7wyTYfRgOfi4ZcT5Stdah3HO9Mb7s GClT6bLPUmYwNwhBhWqONskJReIWDqwX9eCI0A5QY0pR6FW+0MiFkhazA1SBV5OSdEJV v1S+TCXvPxmszq+MCM7FRyuLL0ToispLHzHJSc36zdyfNGQ5ppuVWcs1Ufo/7N2oAkXt N0DWFExzMZf8UsYomNWjFL3NlpiRt4VeRm2lcNtglIy0n35fbjT0rRJ4HlcNSsFZowSK bR7g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v28si9484491ejk.276.2021.09.06.09.30.20; Mon, 06 Sep 2021 09:30:44 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243992AbhIFQ1o (ORCPT + 99 others); Mon, 6 Sep 2021 12:27:44 -0400 Received: from smtp-out.kfki.hu ([148.6.0.48]:38065 "EHLO smtp-out.kfki.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243691AbhIFQ1n (ORCPT ); Mon, 6 Sep 2021 12:27:43 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp2.kfki.hu (Postfix) with ESMTP id 17DF6CC00FD; Mon, 6 Sep 2021 18:26:37 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at smtp2.kfki.hu Received: from smtp2.kfki.hu ([127.0.0.1]) by localhost (smtp2.kfki.hu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP; Mon, 6 Sep 2021 18:26:34 +0200 (CEST) Received: from blackhole.kfki.hu (blackhole.szhk.kfki.hu [148.6.240.2]) by smtp2.kfki.hu (Postfix) with ESMTP id D1CDBCC00FC; Mon, 6 Sep 2021 18:26:34 +0200 (CEST) Received: by blackhole.kfki.hu (Postfix, from userid 1000) id C8F8D340D60; Mon, 6 Sep 2021 18:26:34 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by blackhole.kfki.hu (Postfix) with ESMTP id C4B2B340D5D; Mon, 6 Sep 2021 18:26:34 +0200 (CEST) Date: Mon, 6 Sep 2021 18:26:34 +0200 (CEST) From: Jozsef Kadlecsik To: Pablo Neira Ayuso , netfilter-devel@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: [PATCH 1/1] netfilter: ipset: Fix oversized kvmalloc() calls Message-ID: <4591ee34-aa44-92d-51a8-22e8be5db20@netfilter.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- net/netfilter/ipset/ip_set_hash_gen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h index 6186358eac7c..6e391308431d 100644 --- a/net/netfilter/ipset/ip_set_hash_gen.h +++ b/net/netfilter/ipset/ip_set_hash_gen.h @@ -130,11 +130,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; -- 2.20.1 Best regards, Jozsef - E-mail : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.hu PGP key : https://wigner.hu/~kadlec/pgp_public_key.txt Address : Wigner Research Centre for Physics H-1525 Budapest 114, POB. 49, Hungary