Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3046878pxv; Mon, 12 Jul 2021 08:05:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7ZWV7y44hG5slJQuPLt5G+XYufqgm+ZhWJLWkhCpB4rFhCcOWlX0Amr6pcMfdW3P5Ncgc X-Received: by 2002:a17:906:5a6f:: with SMTP id my47mr18458136ejc.29.1626102301901; Mon, 12 Jul 2021 08:05:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626102301; cv=none; d=google.com; s=arc-20160816; b=PmBgFJxe3JR9NR8v7FgtdI6ebi0PdEhH7DUlBn+mzLZzvaqNkQ9EmXx6jAd+kW1bN/ LG5fbdMBBqlyynjM1upRDux6I6htM/ZFftOYf0GOWhG7vXaoiIW4EDK27HTZ2/Wx2BHx kfvScP8pMWQtD8xIDh/JhEVTrfU8EHAosRcj9GUySoIPq7h5jkYoU16Jq96+bjWT4E3H JGRk+cbHKmpTjivqGgQJznupBPm4X2+Okct6n9NAllHEu4duRe/ndH0XnDHncmedrHxY u3hkjaaCfuHkeHuPWGhxQzDlT56cP6H5X7LixDD2uokFvxTKUJJp1PrZUb/8zbhFfvel kACw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=e1cRp1VWHZe1p2M78fCVodbc0nQVrykOATx459rHnfg=; b=GyuxAvi5iwN6LoOk4R+QhK/JckDMlWjptUIib+EE1MhpMp2fR01S0SYFzij9mlGD9z Q670S9gMSs0h9jsbJ80GIhNdvkKG2WLnSzYv6OEc3nf4WHExXPgvfpt5X3XJLkpBY/WY tzvpy1Jliy62Fm9AfbnEdShDIQYa5M0eVyoxfZyr0WIAWyQyc5KTzAUH+B1BvvWphvgJ 1YUas1sLeM0914YGCVXgBlRpaCVK9s87lY1mK+P6+GmIOVz6yJZopaYOvD+A/9+jaoBB DJqg7dvDqUgobLSP2so+mRIP8+eR+kUHbXl7QfGigovjUZvlbNeAVwJhhUj31Mc9fJWU joCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=2SK+S5tC; 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 7si17027162ejh.506.2021.07.12.08.04.37; Mon, 12 Jul 2021 08:05:01 -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=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=2SK+S5tC; 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 S235385AbhGLPGF (ORCPT + 99 others); Mon, 12 Jul 2021 11:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235372AbhGLPGE (ORCPT ); Mon, 12 Jul 2021 11:06:04 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A912FC0613E9 for ; Mon, 12 Jul 2021 08:03:15 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id t3so28456436edt.12 for ; Mon, 12 Jul 2021 08:03:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=e1cRp1VWHZe1p2M78fCVodbc0nQVrykOATx459rHnfg=; b=2SK+S5tCOVGYy34JELKrYSvjyivDlFptBxUOgGUP6ayfifklBOtmpfjQFzXzn5gP2c RohYGrmiihMozczcGIsJCMW+h4bDnTRafPmryc99DiJy3/YMhujbydnlD6VUIuU4jpkf J5P+iLBj9C6PCrctj2YJ6Ak3fc8AZTdREx/X+7UIfE9Nasc9ynos4CoBSvALkb4XSpi8 HZv4LALQf2ASBc/DHEV3IJNHRbQE1NuHRtDK3d7T7aoM3/kbzTR4OHJ2VKt6haRIVQTd Zpg8ltNKKx6wZziX4BmA6/DtSVVCgUgJ6/29txsaXv95FX71/iVVOBAeBELIS7+HNfg/ UPzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=e1cRp1VWHZe1p2M78fCVodbc0nQVrykOATx459rHnfg=; b=sM1WV4bT4hM/X4EcpbJBnzQykVZs9sCkJ1d1PjdUoChhjnB7TvYa1fNuBlWQnzu74w HkLjg2FxO7DQeDe9c1t6mEM8LLY+2bRD25yjC9zh7VowKaIHOY2NxcTDLXxRGINb9n97 nLQog1Ir2oZd48MepEPs+I2Y2N0tIuFwXa/DxeNW2HIJE9q63ff7nTAbyEB9lUoaJB6B 7cNQDdGJAy0c6L2yDc26J+vP2gZc9X56dLmAQd1wxnVmJovwgjs+xAlSn5xNQxUJ7s6H FCtLz6mjKq4th/aH8qasCuY5mdgYEuCqAmEqa3HSN8hjyhf+tBnodYJ4VQuTWD885ZTB kszQ== X-Gm-Message-State: AOAM530u9zCGNRdPPJN9hfv0Sk41TAOsTVhBhv6qQuLLzLJeG0EWp38T m0IcKpG/svLT01kjgZ9WSG6B87az8aA/LlDpuVF3 X-Received: by 2002:aa7:d04d:: with SMTP id n13mr5334758edo.31.1626102194142; Mon, 12 Jul 2021 08:03:14 -0700 (PDT) MIME-Version: 1.0 References: <53de0ccd1aa3fffa6bce2a2ae7a5ca07e0af6d3a.1625900431.git.paskripkin@gmail.com> In-Reply-To: <53de0ccd1aa3fffa6bce2a2ae7a5ca07e0af6d3a.1625900431.git.paskripkin@gmail.com> From: Paul Moore Date: Mon, 12 Jul 2021 11:03:03 -0400 Message-ID: Subject: Re: [PATCH 1/2] net: cipso: fix warnings in netlbl_cipsov4_add_std To: Pavel Skripkin Cc: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org, netdev@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+cdd51ee2e6b0b2e18c0d@syzkaller.appspotmail.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 10, 2021 at 3:03 AM Pavel Skripkin wrote: > > Syzbot reported warning in netlbl_cipsov4_add(). The > problem was in too big doi_def->map.std->lvl.local_size > passed to kcalloc(). Since this value comes from userpace there is > no need to warn if value is not correct. > > The same problem may occur with other kcalloc() calls in > this function, so, I've added __GFP_NOWARN flag to all > kcalloc() calls there. > > Reported-and-tested-by: syzbot+cdd51ee2e6b0b2e18c0d@syzkaller.appspotmail.com > Fixes: 96cb8e3313c7 ("[NetLabel]: CIPSOv4 and Unlabeled packet integration") > Signed-off-by: Pavel Skripkin > --- > net/netlabel/netlabel_cipso_v4.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) This seems fine to me, callers will get a ENOMEM error code too so it isn't like the failure is going to be a mystery, especially in the case where an obscenely large translation mapping is being attempted. Acked-by: Paul Moore As an aside, I see no reason why this patch can't be merged and 2/2 simply dropped as already in-tree. As has already been pointed out, patch 2/2 is a duplicate; the in-tree commit is d612c3f3fae2 ("net: ipv4: fix memory leak in netlbl_cipsov4_add_std"). > diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c > index 4f50a64315cf..50f40943c815 100644 > --- a/net/netlabel/netlabel_cipso_v4.c > +++ b/net/netlabel/netlabel_cipso_v4.c > @@ -187,14 +187,14 @@ static int netlbl_cipsov4_add_std(struct genl_info *info, > } > doi_def->map.std->lvl.local = kcalloc(doi_def->map.std->lvl.local_size, > sizeof(u32), > - GFP_KERNEL); > + GFP_KERNEL | __GFP_NOWARN); > if (doi_def->map.std->lvl.local == NULL) { > ret_val = -ENOMEM; > goto add_std_failure; > } > doi_def->map.std->lvl.cipso = kcalloc(doi_def->map.std->lvl.cipso_size, > sizeof(u32), > - GFP_KERNEL); > + GFP_KERNEL | __GFP_NOWARN); > if (doi_def->map.std->lvl.cipso == NULL) { > ret_val = -ENOMEM; > goto add_std_failure; > @@ -263,7 +263,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info, > doi_def->map.std->cat.local = kcalloc( > doi_def->map.std->cat.local_size, > sizeof(u32), > - GFP_KERNEL); > + GFP_KERNEL | __GFP_NOWARN); > if (doi_def->map.std->cat.local == NULL) { > ret_val = -ENOMEM; > goto add_std_failure; > @@ -271,7 +271,7 @@ static int netlbl_cipsov4_add_std(struct genl_info *info, > doi_def->map.std->cat.cipso = kcalloc( > doi_def->map.std->cat.cipso_size, > sizeof(u32), > - GFP_KERNEL); > + GFP_KERNEL | __GFP_NOWARN); > if (doi_def->map.std->cat.cipso == NULL) { > ret_val = -ENOMEM; > goto add_std_failure; > -- > 2.32.0 -- paul moore www.paul-moore.com