Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3964944pxb; Mon, 4 Oct 2021 13:52:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2REwhFBB7lWXKz/Z2xH/bIiKJkN71OWWub6NiOFbhESBbGsYrp+klKy+9i63lOEghOQ3R X-Received: by 2002:a17:907:987b:: with SMTP id ko27mr729569ejc.130.1633380777547; Mon, 04 Oct 2021 13:52:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633380777; cv=none; d=google.com; s=arc-20160816; b=rHpaaHusZRuzvj28T5FSOVo1ksd5/DgQDkDb74XovRLwCJEeWL51OQ+ODJ5FGin3+1 V32ODCoOuxR7RBDHiP9KOnh2foXUoNV+NnTAwyI7DGr+PNXtQDkkYlnCZ4572msnYXrb 1JFPVgvT7woc5dmmHFW5I4CWxI7x1/ltyRYWIkotSFPfEGpEpwHvYe7qY6Mmi7sJL3uQ bu87k/7ha2QbR7D4xh8BE+jG89hmnlhAEfY0rdd6nsIrbnnoFeBvHCpR3b21hWQr9J2J vi9thXkpXwMPUudUneB+/qgLv1feVdDOlrZseJ+KCzgl49czgsIr6gAvHOK/OeUUeUcU jkOQ== 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=NoqmkgcDfDBhNmTIFqSF4Nyiy+GI1h3LB0lJWVENq9M=; b=EXEucXnStnu/9syYdojljoeG1wu80TP6y5luQgsLnBQfi7zChuyJhgeR1SyLNaLKqs 7ieWOUgtfy6Ian7j2tISNMS1WRZ7goAMGRhUkj0jD6Lvxtv1Y7TB0gZrzKMGTDBqKY35 K0wEACdsTDT3JtujulWPQflqvq8B8zAXdHWJQkUS7is+kC3zS6BIsDieXPOhHaeSBRjL P1olaMtWCoijkiATnmTl/m4GLTXOc2ImpY17EW6Y8F6kcoaUSIqZEg8ULj2eWa3ESr1j hdAsdudaJATDz8IzoFlSvphakBc5/14eBiUoEerdotNk+NGa0deXi/GasnRh6ZOfaD31 P3NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V9BCLGkj; 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 g14si17610528ejj.426.2021.10.04.13.52.33; Mon, 04 Oct 2021 13:52:57 -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=V9BCLGkj; 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 S238757AbhJDNo1 (ORCPT + 99 others); Mon, 4 Oct 2021 09:44:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:53144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238683AbhJDNmK (ORCPT ); Mon, 4 Oct 2021 09:42:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5EE9B6325E; Mon, 4 Oct 2021 13:19:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353569; bh=X/ptOpXz0zVL/f5EkXAzeEEizI0Woco8mDP2WaV85gA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V9BCLGkjQIDdkvtTzzwkqdE3C0rgGe2KglKwbbA5I9YSYO6LXqLP0wYfgk1KCuPdo RmgEePCZyHX9Mdl0RkS0CuEjscOhKU0yUYAO+yWY1lD1Qze6b9j/iow6ONl4ZP1Dpi 1w7FaUAGr5MQ2BvdhTc4wFGzWS63BeDIcvXbb72o= 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 5.14 164/172] netfilter: ipset: Fix oversized kvmalloc() calls Date: Mon, 4 Oct 2021 14:53:34 +0200 Message-Id: <20211004125050.268507665@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125044.945314266@linuxfoundation.org> References: <20211004125044.945314266@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 @@ -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;