Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3750274rdb; Sun, 10 Dec 2023 20:30:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IG3Tm9ld2P96S+cjtp/dP//tooYpEHLhC2wzInXelAiK6kc+EKcw2v9V1IspJRqOZee2eVV X-Received: by 2002:a05:6808:11c8:b0:3ba:3c4:2630 with SMTP id p8-20020a05680811c800b003ba03c42630mr2482789oiv.113.1702269008290; Sun, 10 Dec 2023 20:30:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702269008; cv=none; d=google.com; s=arc-20160816; b=DUbmhexXROxmYvbSnFMBs92rQHSCXwMyw/Jo/3Ql+peVPUHr2uPOO3iPq7rbfWnj/X BqDsvyYOb+wC1Xden4p3+kQ33VtEnR6wJlnb/0sGRh2AnS+WNg2abncr9LsU1LZOMHZI q8axhMsi9kZZijN1iivsUs6ZqjNzkozExatFBIUauafn2OzjTomBhzCo4BaSh196gzkr p8cjAA2iIkSarzzY4zjSC38XbbMmiQE3jzHRaMlZnjghI4MV0PRRwB9adfLbgmcUrMtc QYSxBKMbjYpHbYoFu/Ad7jQO75lBdzmu76+HJz7JmHkKExolS/vV0wpYWosapkWT9ubP Gwyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:from:subject:message-id:in-reply-to:date :mime-version; bh=pjvSEW93B0Z+a+7NTpKonDf3aftegOCmS4ucjHOUqI4=; fh=V9AeBafJgTW96HdC48wsxGAfd7Fe9P2uAL8tLCjpUN4=; b=IabEpl/N33v15GFC83XTTCiEg6KKXKrAf5vGCFFfT8Q+wMzPCeLVHbA87ZSt3ihJKp S01DcEIGnW5jLclNhKp4Ir1pUYljnTsX7OiMAP60Am4BEM2gxE4Yt8Ek6ft6U6WX08f/ uBmjCtF7S99oZW1xCOyIBRwvcWrGY2q0/1b4N3cw8F3f7kLsvCJDNvI90ZhUmVlsSuvT yo3smM5+o1Vg73EnX2uFHw/566F89eG2lCARj85bnBpM9Zga+Xrj/eVItErwM2v+lWHZ 4LS4gUEWWGkl8y2C/+vnjqGbSoFpzwZV/hg9pgo99SWkc+Vr/mZbQLZRHC4mAvzQNcTS cktQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=appspotmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id o13-20020a65614d000000b005aaab9e7bcfsi5335671pgv.388.2023.12.10.20.30.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 20:30:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=appspotmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id A6757805F4AC; Sun, 10 Dec 2023 20:30:03 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229757AbjLKEYm (ORCPT + 99 others); Sun, 10 Dec 2023 23:24:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjLKEYm (ORCPT ); Sun, 10 Dec 2023 23:24:42 -0500 Received: from mail-oa1-f70.google.com (mail-oa1-f70.google.com [209.85.160.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3050E5 for ; Sun, 10 Dec 2023 20:24:47 -0800 (PST) Received: by mail-oa1-f70.google.com with SMTP id 586e51a60fabf-1fb1eef9152so7375316fac.0 for ; Sun, 10 Dec 2023 20:24:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702268687; x=1702873487; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pjvSEW93B0Z+a+7NTpKonDf3aftegOCmS4ucjHOUqI4=; b=j8h2BdZygmH54RcwWMx4YlY3Yahp9c2XrZgMp7wwB1FYK4Dlox6FNQ9Fts/gtf68gQ 0s/tCjNUZuD84sg3QW8YFsTKNYukvNR/G7e/MXLLlHnHehs9a9sMOMKoRJPNydQgaZ91 ZsC1aE3oOjeGg+I033LY8ngucZUk6FVFWTpGUikQO5C3+pZSD9vp0WHssqP3R0XNfG2n 2sn7BXD0hFGuJItwtm5ymUjVitI03dMdcdyWT0Vb9gWkT6pAHXox8K/umWIDjST/sYvm ZvXKwbS8BzJfoXkAo5zG6npy+xhx0RfK2h93aBUt7Uvl1xItzL/Y7VyRUpQ+j2IyIwP7 kAQw== X-Gm-Message-State: AOJu0YwKC9HnmP3YQQc9Ma1v9CnlD+oDJ7EOeCEGrEbAudBvveLeXzh0 rVCV7FNfAWpcf0p64hrwV6vmJc1KHkFTEmBOAsPj/cLkqXiNd8s= MIME-Version: 1.0 X-Received: by 2002:a05:6871:783:b0:1fb:166c:e070 with SMTP id o3-20020a056871078300b001fb166ce070mr4375220oap.1.1702268687088; Sun, 10 Dec 2023 20:24:47 -0800 (PST) Date: Sun, 10 Dec 2023 20:24:47 -0800 In-Reply-To: <000000000000bfba3a060bf4ffcf@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <000000000000680812060c3450ed@google.com> Subject: Re: [syzbot] [arm-msm?] [net?] memory leak in radix_tree_insert From: syzbot To: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.4 required=5.0 tests=FROM_LOCAL_HEX, 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 pete.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 (pete.vger.email [0.0.0.0]); Sun, 10 Dec 2023 20:30:04 -0800 (PST) For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org. *** Subject: [arm-msm?] [net?] memory leak in radix_tree_insert Author: lizhi.xu@windriver.com #syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 33cc938e65a9 diff --git a/lib/radix-tree.c b/lib/radix-tree.c index a89df8afa510..0a2dfecdcd30 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -613,12 +613,13 @@ static int __radix_tree_create(struct radix_tree_root *root, unsigned long index, struct radix_tree_node **nodep, void __rcu ***slotp) { - struct radix_tree_node *node = NULL, *child; + struct radix_tree_node *node = NULL, *child, *orig; void __rcu **slot = (void __rcu **)&root->xa_head; unsigned long maxindex; - unsigned int shift, offset = 0; + unsigned int shift, offset = 0, mmshift = 0; unsigned long max = index; gfp_t gfp = root_gfp_mask(root); + int ret; shift = radix_tree_load_root(root, &child, &maxindex); @@ -628,7 +629,9 @@ static int __radix_tree_create(struct radix_tree_root *root, if (error < 0) return error; shift = error; + mmshift = error; child = rcu_dereference_raw(root->xa_head); + orig = child; } while (shift > 0) { @@ -637,8 +640,11 @@ static int __radix_tree_create(struct radix_tree_root *root, /* Have to add a child node. */ child = radix_tree_node_alloc(gfp, node, root, shift, offset, 0, 0); - if (!child) - return -ENOMEM; + printk("nc: %p\n", child); + if (!child) { + ret = -ENOMEM; + goto freec; + } rcu_assign_pointer(*slot, node_to_entry(child)); if (node) node->count++; @@ -656,6 +662,18 @@ static int __radix_tree_create(struct radix_tree_root *root, if (slotp) *slotp = slot; return 0; +freec: + if (mmshift > 0) { + struct radix_tree_node *dn; + while (shift < mmshift) { + radix_tree_descend(orig, &dn, index); + printk("dc: %p\n", dn); + orig = orig->slots[0]; + radix_tree_node_rcu_free(&dn->rcu_head); + shift += RADIX_TREE_MAP_SHIFT; + } + } + return ret; } /*