Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1902813rdh; Sat, 25 Nov 2023 06:49:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IFs7RBPKyaP9sg9ImFuMWR7U6wX/3LStseqIYS/36uKGF2dVRbGE5slpx8jAs9sU76FJrd5 X-Received: by 2002:a17:90b:4f8b:b0:285:b6a6:c40b with SMTP id qe11-20020a17090b4f8b00b00285b6a6c40bmr279814pjb.42.1700923764101; Sat, 25 Nov 2023 06:49:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700923764; cv=none; d=google.com; s=arc-20160816; b=m1kHOVKAK4/LYDQtPqcqdzU5E/BIc1hDetn0ppl6o++TZ2m+leD3HSxPa6xPzsPIyj TF2gNcbmFi/YcNumq3fXXoqUN5yTE8aEgAR51ocXUFYFfL2mpwI5RFOwKzqkMdkpe4F1 ogF1Zo86HMmbOs89SOR3n3iu42E4WIXCnm9YVq7Ai6groVxvXzY9yMjjuLSoviP3E5Sj dUos/XtBqiFnZ9zo+LD+gjBghr9PnA6Sy/VVAQa670YpX5kExqdgHJIZzWxRCrYqyz3Z j7u62j/8oVklkWTAP4vYZmYyENeKIMPL9oMM/RJ3daWfLrw3+yGbIxlLovQ3pc6vLB5i Sr+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=MbBDsUYFRBbpaPGcvLn4ZOnFdI0AYXZ3B/wevF5TUtg=; fh=vmYkJfQ74n7GailaP7Ke2fMApNmAflwXd4+OEt3kEsA=; b=D6X+YuIX6w1i0F9yR52O1YQE+0al6EsP2vjAr0odXcYSBLcITPA/OiXdkF/7vU9zZJ nshrZxeV5yysc8T1H53DF8zyHnzbS2YEDNOm+Z+KvNa71IOC5487PeF9BKnImYLVFDIm +H9psBdedFZUoW5NueRfnpgNiN2sRSUF2RdqiMlbwHMF3yA1LkuZVA1QMnr5CKa2ywLi AF9YPgQcj1b2QwnA+EXJlVnCetJhJOul8mgmq2M9Fu7Odi9RJ67ep6h6yg9PI29/9SVu tLJ+XniXtPjxx4NCgpHj/42S1X20D84ZUsfCYY98iHiA8OmcvSbmNQn5VK+pniVEAsA0 8HtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=C7fevQaK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id f25-20020a635119000000b005c2124e421esi5999972pgb.156.2023.11.25.06.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 06:49:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=C7fevQaK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C63C2809CCA9; Sat, 25 Nov 2023 06:49:19 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232047AbjKYOrV (ORCPT + 99 others); Sat, 25 Nov 2023 09:47:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231808AbjKYOrU (ORCPT ); Sat, 25 Nov 2023 09:47:20 -0500 Received: from mail-yb1-xb31.google.com (mail-yb1-xb31.google.com [IPv6:2607:f8b0:4864:20::b31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C888C6 for ; Sat, 25 Nov 2023 06:47:26 -0800 (PST) Received: by mail-yb1-xb31.google.com with SMTP id 3f1490d57ef6-daf4f0e3a0fso2600102276.1 for ; Sat, 25 Nov 2023 06:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1700923645; x=1701528445; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=MbBDsUYFRBbpaPGcvLn4ZOnFdI0AYXZ3B/wevF5TUtg=; b=C7fevQaKpfPHGnPqXI6umr9h8FIA2PwoLCLMhZ0keu6Zd9i1n+Pmw1gz9F9QB8Nu1S S2ozkK3ozg1Wlv2yqslIOCPPYu+JZaL7O0gNmJ9bZErzJmwQFHy3fbEZi999H4Cwn9+0 z/Bdz2KveDUeVtLEV8yXqQgeq+b8YROpjStqpQGy5h+0MfX38M8hqh8vKto4afKXAFxl 8wKVpNFTAUViVGb4t2lRUhl8OsWv9PNIJ3DkCjfByYQgiWNQwzYaXqMPAmcNvSEljNWk nTz5HI5LcumNFtPgU3OTs0m2bKUiuItSHrgcPZLOg5TN/lF5ayaKAonocL5aaBWdVwil Aiow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700923645; x=1701528445; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MbBDsUYFRBbpaPGcvLn4ZOnFdI0AYXZ3B/wevF5TUtg=; b=r36YLbGMEV0LhUf/a0OYuVnzMDVV0xnmHXuPlN9fYrQnp8ifLUngEDvECqXJ+xmC2R pkjfvw6nCtBLdQ8s7RPiAJfuK2PcopYXFQDxPjjTd7YTI0ZLRuPZFpy1urkrk8eazy4z /BThMwWcLDR2V7PqyXpwnzFOH3kTAYyY6eAYvJVSRoGohcmKz+ziiSrcnLRt9+TJo1tj SqZaWkiiHYnXwr/56fnFLB+i7x8fx4is5Q9rAQ/rf3m0M+e46TMMfW7liZx53XDbaqiS Sm4xliGF/SCI1I3Gz63opes62DIVe7GHddlWhad2p6Wr1gWVaFIYlYzj0M/Mz2bsNlbg Z+rA== X-Gm-Message-State: AOJu0YwJ5z3kNh4lWNDznP6ZhKlmu7GBB8xxaiMSVO8jZTHpM6M9ek46 q10A+vWikAiyVmFZ04xmAcaiK72Zf2JrEZjWHbSd X-Received: by 2002:a25:bf8b:0:b0:daf:76da:fe2b with SMTP id l11-20020a25bf8b000000b00daf76dafe2bmr5842914ybk.10.1700923645597; Sat, 25 Nov 2023 06:47:25 -0800 (PST) MIME-Version: 1.0 References: <20231123092314.91299-1-Ilia.Gavrilov@infotecs.ru> In-Reply-To: <20231123092314.91299-1-Ilia.Gavrilov@infotecs.ru> From: Paul Moore Date: Sat, 25 Nov 2023 09:47:14 -0500 Message-ID: Subject: Re: [PATCH net v2] calipso: Fix memory leak in netlbl_calipso_add_pass() To: Gavrilov Ilia Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Huw Davies , "netdev@vger.kernel.org" , "linux-security-module@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "lvc-project@linuxtesting.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sat, 25 Nov 2023 06:49:20 -0800 (PST) On Thu, Nov 23, 2023 at 4:25=E2=80=AFAM Gavrilov Ilia wrote: > > If IPv6 support is disabled at boot (ipv6.disable=3D1), > the calipso_init() -> netlbl_calipso_ops_register() function isn't called= , > and the netlbl_calipso_ops_get() function always returns NULL. > In this case, the netlbl_calipso_add_pass() function allocates memory > for the doi_def variable but doesn't free it with the calipso_doi_free(). > > BUG: memory leak > unreferenced object 0xffff888011d68180 (size 64): > comm "syz-executor.1", pid 10746, jiffies 4295410986 (age 17.928s) > hex dump (first 32 bytes): > 00 00 00 00 02 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: > [<00000000730d8770>] kmalloc include/linux/slab.h:552 [inline] > [<00000000730d8770>] netlbl_calipso_add_pass net/netlabel/netlabel_ca= lipso.c:76 [inline] > [<00000000730d8770>] netlbl_calipso_add+0x22e/0x4f0 net/netlabel/netl= abel_calipso.c:111 > [<0000000002e662c0>] genl_family_rcv_msg_doit+0x22f/0x330 net/netlink= /genetlink.c:739 > [<00000000a08d6d74>] genl_family_rcv_msg net/netlink/genetlink.c:783 = [inline] > [<00000000a08d6d74>] genl_rcv_msg+0x341/0x5a0 net/netlink/genetlink.c= :800 > [<0000000098399a97>] netlink_rcv_skb+0x14d/0x440 net/netlink/af_netli= nk.c:2515 > [<00000000ff7db83b>] genl_rcv+0x29/0x40 net/netlink/genetlink.c:811 > [<000000000cf53b8c>] netlink_unicast_kernel net/netlink/af_netlink.c:= 1313 [inline] > [<000000000cf53b8c>] netlink_unicast+0x54b/0x800 net/netlink/af_netli= nk.c:1339 > [<00000000d78cd38b>] netlink_sendmsg+0x90a/0xdf0 net/netlink/af_netli= nk.c:1934 > [<000000008328a57f>] sock_sendmsg_nosec net/socket.c:651 [inline] > [<000000008328a57f>] sock_sendmsg+0x157/0x190 net/socket.c:671 > [<000000007b65a1b5>] ____sys_sendmsg+0x712/0x870 net/socket.c:2342 > [<0000000083da800e>] ___sys_sendmsg+0xf8/0x170 net/socket.c:2396 > [<000000004a9b827f>] __sys_sendmsg+0xea/0x1b0 net/socket.c:2429 > [<0000000061b64d3a>] do_syscall_64+0x30/0x40 arch/x86/entry/common.c:= 46 > [<00000000a1265347>] entry_SYSCALL_64_after_hwframe+0x61/0xc6 > > Found by InfoTeCS on behalf of Linux Verification Center > (linuxtesting.org) with Syzkaller > > Fixes: cb72d38211ea ("netlabel: Initial support for the CALIPSO netlink p= rotocol.") > Signed-off-by: Gavrilov Ilia > --- > v2: > - return the error code in netlbl_calipso_add() if the variable calipso= _hops is NULL > v1: https://lore.kernel.org/all/20231122135242.2779058-1-Ilia.Gavrilov@in= fotecs.ru/ > > net/netlabel/netlabel_calipso.c | 49 +++++++++++++++++---------------- > 1 file changed, 26 insertions(+), 23 deletions(-) This looks good to me, thanks! Acked-by: Paul Moore --=20 paul-moore.com