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 X-Spam-Level: X-Spam-Status: No, score=-21.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94464C4320E for ; Mon, 30 Aug 2021 16:45:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7243060E90 for ; Mon, 30 Aug 2021 16:45:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237847AbhH3QqV (ORCPT ); Mon, 30 Aug 2021 12:46:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:32838 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233446AbhH3QqU (ORCPT ); Mon, 30 Aug 2021 12:46:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E234060E90; Mon, 30 Aug 2021 16:45:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1630341926; bh=1qZTcEvIsAXBUStNE8UgF9NAfGDDOJr5XumUMJdnFBY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=hs71tLE/RxlvQj0tMheczqyzM4fDjXgScgYeTuHGXOdVOGdPDbfiIP9KF1dHstL9h OBa6vxnPLnJrvd/x+BNRN4vCL+eokWpBIO7eAn0xej6wdvFXg2+p3DPSZdPUUplypi IweUDAd2Hvb3pBlQW29I3cgXHLEBAGUmNwzHWbau7SLJhCtxEmzdIkQNxvkQk+6GDZ 2VWxLW2fYSD7B8gpNb6xhr9eSQJ519bsuTUhT9Cg0NW/eQHTVID9IQYRu21/hK/nXe ng6+jNQsBxVg1Dm7RRW1BWtDWjervsuWQkwSDRXff99BMyXHVLlXT5JSpV/VMwKEkU 3WEB4rO7Nr5ZA== Date: Mon, 30 Aug 2021 09:45:25 -0700 From: Jakub Kicinski To: Paul Moore Cc: =?UTF-8?B?546L6LSH?= , "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , netdev@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] net: fix NULL pointer reference in cipso_v4_doi_free Message-ID: <20210830094525.3c97e460@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: References: <18f0171e-0cc8-6ae6-d04a-a69a2a3c1a39@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 30 Aug 2021 10:17:05 -0400 Paul Moore wrote: > On Mon, Aug 30, 2021 at 6:28 AM =E7=8E=8B=E8=B4=87 wrote: > > > > In netlbl_cipsov4_add_std() when 'doi_def->map.std' alloc > > failed, we sometime observe panic: > > > > BUG: kernel NULL pointer dereference, address: > > ... > > RIP: 0010:cipso_v4_doi_free+0x3a/0x80 > > ... > > Call Trace: > > netlbl_cipsov4_add_std+0xf4/0x8c0 > > netlbl_cipsov4_add+0x13f/0x1b0 > > genl_family_rcv_msg_doit.isra.15+0x132/0x170 > > genl_rcv_msg+0x125/0x240 > > > > This is because in cipso_v4_doi_free() there is no check > > on 'doi_def->map.std' when doi_def->type got value 1, which > > is possibe, since netlbl_cipsov4_add_std() haven't initialize > > it before alloc 'doi_def->map.std'. > > > > This patch just add the check to prevent panic happen in similar > > cases. > > > > Reported-by: Abaci > > Signed-off-by: Michael Wang > > --- > > net/netlabel/netlabel_cipso_v4.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) =20 >=20 > I see this was already merged, but it looks good to me, thanks for > making those changes. FWIW it looks like v1 was also merged: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id= =3D733c99ee8b