Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4014517pxj; Tue, 15 Jun 2021 13:31:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/fee6/mOCkWeBDsPnVy6HBgeL6gGX+F1Ih5x4COssqZngV1r+SKs1fJtlO2hDmrGpVPF7 X-Received: by 2002:a05:6402:4413:: with SMTP id y19mr1692970eda.207.1623789082442; Tue, 15 Jun 2021 13:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623789082; cv=none; d=google.com; s=arc-20160816; b=FZjA1fBWYaBnKgQmrd9/8krTmmPZgTMi5w0WbHvk3aJm+7cUCVhwkvhfMaLRxuIG+k wazktbZx4+q3FPhZO+Br8pqIeWyGpB6bHll2pnMiJqI0qNxprBOA8X2XklVLE8/bkF13 moMp1fGDtpXQDIgI+QLUFDJjFYq51Z9w9MypNolGCJ/EhcWqW/jFJiAh3aNsRf8umVqo ub8GLo0M5muzP67zKsLXeBtqAFvXgIf7fUEll50XwVEieXmhc13MEMizaKgAWhc6nIe0 RjOn8Pkx2DxlJn25N6EcyjpQf8PYn3nJODDV3GuJvyDPC2COwJrHhj0ph7dYwh+l5zCg xKUA== 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=2tUb3d+vrU01SWNkHnqFTp6elP7WYKyt6weZt4gpH4c=; b=lb9/E+wCa1k6EnQLynOMrdZ7a8QSD/06IQjBSz3fs+ga0JdqiHitTXHwCN5AuUK7MI t/17axAl4gYIGNZ8kTr2BkhtGg4bgeqczTxjjrxbb2Vb66bugnjDhaHPoONv2O7+QCkx em/shkEMtgy9REoyAfqUk3L+mDEUXB2tK2BQ/UEtuFW+iaMrTwfkODmaYZ9e+vPE5g/A /KVTRh58L6nWPczsvXz7x74Zt4bid/0TIs7fBZXQbHJXpYRW4uoendoq+t75U4drR6tC 6VFbMvoR/SYW9Brl8MhNf/fGOytlXxUHAVybAmJEuby/Ff0jJQsjNebb68HnH4MiK0eb AMZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b="C/5aCfxM"; 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 eo21si68791ejc.35.2021.06.15.13.30.22; Tue, 15 Jun 2021 13:31:22 -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="C/5aCfxM"; 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 S229898AbhFOUbX (ORCPT + 99 others); Tue, 15 Jun 2021 16:31:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229965AbhFOUbW (ORCPT ); Tue, 15 Jun 2021 16:31:22 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71FEEC061767 for ; Tue, 15 Jun 2021 13:29:17 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id z12so4050048edc.1 for ; Tue, 15 Jun 2021 13:29:17 -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=2tUb3d+vrU01SWNkHnqFTp6elP7WYKyt6weZt4gpH4c=; b=C/5aCfxMDXSWhUT85X6FPMeKiIG3eCf+CiG388aSOsCzVxxv5aUtvXkMKfZpqeLgpN fgcM5N8j89oL+w3ZpjZPwEWjWHi2z2VaseFPqcMwyqdgN3nV5MMxGwOT/FglPkhBsV5i TivylFGYXHo2LuYghMO2RtojnU5N/Gcao841b15cz6djORQYc7QFzSvGHQeBGyWJflFx ZJWeO6LTWwS1IYQLQ4uCTk9UvjjH/Cv67l2kXMMw8LOOzOCRRnqX4lFWIiri/IsmgIyJ Wcpd0wwUjs7tvN54hzMk0Z8fb6GloOjscB0TqT4YYsQ9w/MG6AZSH5Z3jTni91p1Ht0f Ri5w== 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=2tUb3d+vrU01SWNkHnqFTp6elP7WYKyt6weZt4gpH4c=; b=IMQFO7YgmQy6onDzTuW9q8ACy0EJdDmYfJdvplxehikCf9zO36vmCiHRg0MXSFeIVO 70cC7DX4fal4xFbR9k44xc1KDnu49WFd0eW/zfSYJLBY6AyZOC8+Pprc9kuYlj67C/5G guSXftTgFXS/n+4e/leJcEkqPwj2nlvOV6OQpGRofaP0yh+xPsXcD7QK5OZN0ZVm0S/E Hw2nKl6pnj5B2xF8Za/0uQajNjkFB8NJsVLo7fZVYwjvE4ianwaJPxLwH8Fm1GPp4aeE 3UTGzbb0+NwjN5UVAoQUWzpFanNJ4UMeEqL5CllUs0Ais1XCyLahnjKPX0ke8+sbrpKe 4clg== X-Gm-Message-State: AOAM532CEi+Mb67WorLbqSNu0QG8JScM1AZ8fYGZ2wQvnPMA17KP6qzF D/KCxm2jOIlF1J10S01rMLP0NzB+3k5YasKjQdSj X-Received: by 2002:a05:6402:1771:: with SMTP id da17mr1679082edb.31.1623788955775; Tue, 15 Jun 2021 13:29:15 -0700 (PDT) MIME-Version: 1.0 References: <20210615021444.2306687-1-liushixin2@huawei.com> In-Reply-To: <20210615021444.2306687-1-liushixin2@huawei.com> From: Paul Moore Date: Tue, 15 Jun 2021 16:29:04 -0400 Message-ID: Subject: Re: [PATCH -next v3] netlabel: Fix memory leak in netlbl_mgmt_add_common To: Liu Shixin Cc: Dongliang Mu , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 14, 2021 at 9:43 PM Liu Shixin wrote: > > Hulk Robot reported memory leak in netlbl_mgmt_add_common. > The problem is non-freed map in case of netlbl_domhsh_add() failed. > > BUG: memory leak > unreferenced object 0xffff888100ab7080 (size 96): > comm "syz-executor537", pid 360, jiffies 4294862456 (age 22.678s) > hex dump (first 32 bytes): > 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > fe 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 ................ > backtrace: > [<0000000008b40026>] netlbl_mgmt_add_common.isra.0+0xb2a/0x1b40 > [<000000003be10950>] netlbl_mgmt_add+0x271/0x3c0 > [<00000000c70487ed>] genl_family_rcv_msg_doit.isra.0+0x20e/0x320 > [<000000001f2ff614>] genl_rcv_msg+0x2bf/0x4f0 > [<0000000089045792>] netlink_rcv_skb+0x134/0x3d0 > [<0000000020e96fdd>] genl_rcv+0x24/0x40 > [<0000000042810c66>] netlink_unicast+0x4a0/0x6a0 > [<000000002e1659f0>] netlink_sendmsg+0x789/0xc70 > [<000000006e43415f>] sock_sendmsg+0x139/0x170 > [<00000000680a73d7>] ____sys_sendmsg+0x658/0x7d0 > [<0000000065cbb8af>] ___sys_sendmsg+0xf8/0x170 > [<0000000019932b6c>] __sys_sendmsg+0xd3/0x190 > [<00000000643ac172>] do_syscall_64+0x37/0x90 > [<000000009b79d6dc>] entry_SYSCALL_64_after_hwframe+0x44/0xae > > Fixes: 63c416887437 ("netlabel: Add network address selectors to the NetLabel/LSM domain mapping") > Reported-by: Hulk Robot > Signed-off-by: Liu Shixin > --- > v1->v2: According to Dongliang's and Paul's advices, simplify the code. > v2->v3: Fix the style error. > > net/netlabel/netlabel_mgmt.c | 19 ++++++++++--------- > 1 file changed, 10 insertions(+), 9 deletions(-) Thanks for the updated patch, it looks good to me. I see it's already been merged, but for posterity's sake ... Acked-by: Paul Moore -- paul moore www.paul-moore.com