From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFAC5C433EF for ; Mon, 4 Oct 2021 13:27:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC27861163 for ; Mon, 4 Oct 2021 13:27:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236880AbhJDN3L (ORCPT ); Mon, 4 Oct 2021 09:29:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:43760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236917AbhJDN13 (ORCPT ); Mon, 4 Oct 2021 09:27:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 825D661C15; Mon, 4 Oct 2021 13:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633353129; bh=LC4u59DajnY7qCHIrtUztguP3bj4eP8sydEVfQm05Jo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=es+bk1+4RzJL7vIoLeG4y1Z2GBloFjtJXkyXJUrAYF21tIjM6AvL5sn8w97FmQ1xy 6aGo0ZP6OKxx39RmaGYj9cQGr/LNT6GhTMWd/20n8oOO44GvwHHhCr8LzHM5eW5cpi vXCrQeblBLmYptSxIRfb9YMiVikWy5cBjKCsFt0s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+cd43695a64bcd21b8596@syzkaller.appspotmail.com, Pablo Neira Ayuso Subject: [PATCH 5.10 93/93] netfilter: nf_tables: Fix oversized kvmalloc() calls Date: Mon, 4 Oct 2021 14:53:31 +0200 Message-Id: <20211004125037.666201678@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004125034.579439135@linuxfoundation.org> References: <20211004125034.579439135@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: Pablo Neira Ayuso commit 45928afe94a094bcda9af858b96673d59bc4a0e9 upstream. The commit 7661809d493b ("mm: don't allow oversized kvmalloc() calls") limits the max allocatable memory via kvmalloc() to MAX_INT. Reported-by: syzbot+cd43695a64bcd21b8596@syzkaller.appspotmail.com Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_tables_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -4265,7 +4265,7 @@ static int nf_tables_newset(struct net * if (ops->privsize != NULL) size = ops->privsize(nla, &desc); alloc_size = sizeof(*set) + size + udlen; - if (alloc_size < size) + if (alloc_size < size || alloc_size > INT_MAX) return -ENOMEM; set = kvzalloc(alloc_size, GFP_KERNEL); if (!set)