Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3837893pxv; Mon, 28 Jun 2021 14:18:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaUSxWfgGp5duQ6PbgzALjEBKipjZE0zmVyZnsgejPvFfN9Qt4GD4bc/vGI350K29mCUTf X-Received: by 2002:a92:750c:: with SMTP id q12mr19505976ilc.303.1624915095634; Mon, 28 Jun 2021 14:18:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624915095; cv=none; d=google.com; s=arc-20160816; b=DhGf+OVCkyLZeM6GCQWZEBkaizWii3ud/oKbjqeEDt7fzSxa6wfBenBUZMkTQUsdly XjkNMtH8ZBFNx5Eh1KM2Bu7cCA4kGVi98ygA6lXFHMzMnl/DzGV3OWNtPBQTO4+SmEKO BZr0ReHlBwjoxw+sl9oDbZaWuEqW2Sd59t8CESVW3nT5J4y/SlTqFiPM0Czbb5PUnpdY Ajjqe28/wIqliLHlS6Im9WfipIxZ21V9P9upbEj64F/QsIFSl9eGnEDOV4+QPZ96gT6H F8YpScT0aw52p56EEHyqWS6PmM6zcw6S1ChObVgR47zhMq9wCC30FUr5MmghhrEybAo4 52xg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=roQfpUVkDmS8TMXxeEEuE0KeAt2FCm9fdUlxYgERaJQ=; b=Cl6hEKQxmQ/Cl6jH2TfLKAJZBOcsBDr1vR+UdGm0VxkCx0yCGp6iVvFTu/UdyG7xam Nhk5z62nH7XTrydoscvO8+rCTWwhPmCxltJu0IFwRo+KN0LACa6Y3yLBvB/A3SW0Aym8 ERe7MI0Z7PhPmGNBk08PXLFkuzHFhoGDclbiLzhg5TMdXuP0aqbvBUpRY28ctqzjom7f ZYpf/TpQGhxSp0LDM11Ta2otEmS9HQ5K9xjC9R0Aod98/Z4ksqPM+sfF61l3WSzjw9tg lq8CQWwClLcmCnB4g4EWVIQFf4oFiL3yMfTu/aAiBJVjcGSB994VC4zRj5+iSloCL4l1 eYMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Wz1seWJO; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o192si9560426jao.55.2021.06.28.14.17.59; Mon, 28 Jun 2021 14:18:15 -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=@kernel.org header.s=k20201202 header.b=Wz1seWJO; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237598AbhF1PUA (ORCPT + 99 others); Mon, 28 Jun 2021 11:20:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:60248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236993AbhF1O4d (ORCPT ); Mon, 28 Jun 2021 10:56:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6A7D261CDB; Mon, 28 Jun 2021 14:40:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891222; bh=ftUE13tRYyupKJbc2cKzf/4NtmPlVXOlc38hJzMPEiM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wz1seWJOkABDmmv8v14evhbTAHRL3zI/0Z+v+MiZ4ThypU7HtTvmWG3FN+Zp9UDh3 F2v5ts7j/xw6DLqs8NIqVPmv+dhZdVV68UhwjKIk7Amqh7msG/VQn+jLtyV5Vapa5u 1VfUCLxcmOCd1wH/yVoIJALpX5OiuwwIl43XK64WrK+BnOUaiK5Avnz1e6retWno83 io3nz4opdevcYmGLzNHSo+4plZbKdw28kk/G2K4hkdLyRpcb0luAiIxuNO1w+wE4PX 014AXbX84IPjvTmNDTNCicmlivA/8+fjpb/G6R76xwuJX3bqVnJL9Scue5mmyTol+w Ii2U4r9m8Aj7A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nanyong Sun , Hulk Robot , Paul Moore , "David S . Miller" , Sasha Levin Subject: [PATCH 4.9 19/71] net: ipv4: fix memory leak in netlbl_cipsov4_add_std Date: Mon, 28 Jun 2021 10:39:11 -0400 Message-Id: <20210628144003.34260-20-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628144003.34260-1-sashal@kernel.org> References: <20210628144003.34260-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.274-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.9.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.9.274-rc1 X-KernelTest-Deadline: 2021-06-30T14:39+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nanyong Sun [ Upstream commit d612c3f3fae221e7ea736d196581c2217304bbbc ] Reported by syzkaller: BUG: memory leak unreferenced object 0xffff888105df7000 (size 64): comm "syz-executor842", pid 360, jiffies 4294824824 (age 22.546s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<00000000e67ed558>] kmalloc include/linux/slab.h:590 [inline] [<00000000e67ed558>] kzalloc include/linux/slab.h:720 [inline] [<00000000e67ed558>] netlbl_cipsov4_add_std net/netlabel/netlabel_cipso_v4.c:145 [inline] [<00000000e67ed558>] netlbl_cipsov4_add+0x390/0x2340 net/netlabel/netlabel_cipso_v4.c:416 [<0000000006040154>] genl_family_rcv_msg_doit.isra.0+0x20e/0x320 net/netlink/genetlink.c:739 [<00000000204d7a1c>] genl_family_rcv_msg net/netlink/genetlink.c:783 [inline] [<00000000204d7a1c>] genl_rcv_msg+0x2bf/0x4f0 net/netlink/genetlink.c:800 [<00000000c0d6a995>] netlink_rcv_skb+0x134/0x3d0 net/netlink/af_netlink.c:2504 [<00000000d78b9d2c>] genl_rcv+0x24/0x40 net/netlink/genetlink.c:811 [<000000009733081b>] netlink_unicast_kernel net/netlink/af_netlink.c:1314 [inline] [<000000009733081b>] netlink_unicast+0x4a0/0x6a0 net/netlink/af_netlink.c:1340 [<00000000d5fd43b8>] netlink_sendmsg+0x789/0xc70 net/netlink/af_netlink.c:1929 [<000000000a2d1e40>] sock_sendmsg_nosec net/socket.c:654 [inline] [<000000000a2d1e40>] sock_sendmsg+0x139/0x170 net/socket.c:674 [<00000000321d1969>] ____sys_sendmsg+0x658/0x7d0 net/socket.c:2350 [<00000000964e16bc>] ___sys_sendmsg+0xf8/0x170 net/socket.c:2404 [<000000001615e288>] __sys_sendmsg+0xd3/0x190 net/socket.c:2433 [<000000004ee8b6a5>] do_syscall_64+0x37/0x90 arch/x86/entry/common.c:47 [<00000000171c7cee>] entry_SYSCALL_64_after_hwframe+0x44/0xae The memory of doi_def->map.std pointing is allocated in netlbl_cipsov4_add_std, but no place has freed it. It should be freed in cipso_v4_doi_free which frees the cipso DOI resource. Fixes: 96cb8e3313c7a ("[NetLabel]: CIPSOv4 and Unlabeled packet integration") Reported-by: Hulk Robot Signed-off-by: Nanyong Sun Acked-by: Paul Moore Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/cipso_ipv4.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c index 71409928763b..553cda6f887a 100644 --- a/net/ipv4/cipso_ipv4.c +++ b/net/ipv4/cipso_ipv4.c @@ -486,6 +486,7 @@ void cipso_v4_doi_free(struct cipso_v4_doi *doi_def) kfree(doi_def->map.std->lvl.local); kfree(doi_def->map.std->cat.cipso); kfree(doi_def->map.std->cat.local); + kfree(doi_def->map.std); break; } kfree(doi_def); -- 2.30.2