Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3283887rdb; Sat, 9 Dec 2023 22:07:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPtH6tKqAORxGGKZbWanXF1VLOZkoR0iPYdtFsD8Mi3b/69lx6M4ZzzrWr0CBElP8aXW14 X-Received: by 2002:a05:6808:1642:b0:3b9:efe8:b9f0 with SMTP id az2-20020a056808164200b003b9efe8b9f0mr3438226oib.55.1702188467028; Sat, 09 Dec 2023 22:07:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702188466; cv=none; d=google.com; s=arc-20160816; b=g2KI2XS9+xzMM4E26mN0peDGSVB6SmDpGG2XtyvAij17cLDlLZ+DrDqygTAlGwIrdB RlGp08B/VpXc65QfuW1fGT9ZcbkKxK4VbRa6S7DeZD1sDorwe/YDVuL1K11I9GXc2uzU T+1ril9kO5y8xSP1ff48hS4Y6EZGa0Zu0Zn8lYyl0C0GcMjPUQVYv4+omNZsCv6hn3y3 QFlR9I2SZl8QEqoYdRmUz90fXWV1+Yrtus2mSeYtiZ0bnd5iD2+oar/exLvv+R5NF/Nk Mzz7UyNLiGdeheHMNOsulCiVBYCwDgWR4Ucf1oa/jcy901Xfr5XxCI9Nis87mKNSSFqy XUeA== 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=2qq9gnGlxSJBqTFRAS45alYednfidOCOYN7H/qxUtm8=; fh=V9AeBafJgTW96HdC48wsxGAfd7Fe9P2uAL8tLCjpUN4=; b=elKbWoyaTulbjBvuncTfueqeKLKz5eLrmHdmwELwgSpf9ajV5/IIlATB59EL6K+t4m N97wl/JzC0eFm69hppdCUi2VMyxu0ukKUi+tzjlya4tFRsZarCTTt8OSkVJ1ZaKYZNNJ LWGwK1iycTlv9bAychzD2c47kSL9mM6wAvsZ9GipLTXMSCk9S4TM8F3J/7oNZ5EesUAy O+dIuSVoQGQTTl89R9wF3avIxFKLbHOcS6/x5GurA1lKaFATZ/3+Z+jraCfbi1kWrMGZ /f0QQjNr4A22BzceVfZDQiT065eglPy+sRZhyTRyaZvW49IOtYFl4TlKwLFb8xZp7i2E 3sdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id g14-20020a056a000b8e00b006cb852928ffsi4074796pfj.66.2023.12.09.22.07.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Dec 2023 22:07:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 8C819807C5D7; Sat, 9 Dec 2023 22:07:18 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231532AbjLJGG4 (ORCPT + 99 others); Sun, 10 Dec 2023 01:06:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230074AbjLJGGy (ORCPT ); Sun, 10 Dec 2023 01:06:54 -0500 Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05DA9118 for ; Sat, 9 Dec 2023 22:07:00 -0800 (PST) Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-6d87bcf8a15so5253232a34.0 for ; Sat, 09 Dec 2023 22:06:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702188419; x=1702793219; 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=2qq9gnGlxSJBqTFRAS45alYednfidOCOYN7H/qxUtm8=; b=Ks6kKldFDtLz/9TcE0xxFaztBtVONcwyPLlR8PCkEmX9Y04SUMYw0oMI8c6Aj4Mi0X QDhR8MImARRLNh43YTx6bWOZys2wU2RLZMFPFmNCLaQ0HFOr8CfBMuzHvrNET0NqRS/1 uBifa+h1JnZcLnrSv/yE3lPR7H3GtrYHQFmn/74QNo22oUnACJo7znT289UzYjQNhC1v Ld+b2wfXTgi+QdPrrMUzLXz2WlMo1ywq3zQqcSgI/HDJCBg5dDrg0MoS7DNySbKaKiYQ 8GWkbC6t16pqDKh/QvhtgEMrcg9/xvurE0D2BJyKDIGH8ntLO0nsJnme1WVkEayWx10K BkFw== X-Gm-Message-State: AOJu0YzzdZudkfxKuw/7Mq0ux2dWP4fz4CiggB3/5QGMpqO8zgUr77IV QylOd4rl1UchwFeA+0gdRca1ewpBfH2LQJfiF4eUbtDqva5n8xk= MIME-Version: 1.0 X-Received: by 2002:a05:6830:3498:b0:6d9:f50f:1795 with SMTP id c24-20020a056830349800b006d9f50f1795mr2361464otu.4.1702188419357; Sat, 09 Dec 2023 22:06:59 -0800 (PST) Date: Sat, 09 Dec 2023 22:06:59 -0800 In-Reply-To: <000000000000bfba3a060bf4ffcf@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <00000000000013a049060c21a08b@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=1.1 required=5.0 tests=FROM_LOCAL_HEX, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SORBS_WEB, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Sat, 09 Dec 2023 22:07:18 -0800 (PST) X-Spam-Level: * 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: eadavis@qq.com please test memory leak in radix_tree_insert #syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 33cc938e65a9 diff --git a/include/linux/radix-tree.h b/include/linux/radix-tree.h index eae67015ce51..cc3e9fc7bae0 100644 --- a/include/linux/radix-tree.h +++ b/include/linux/radix-tree.h @@ -254,6 +254,7 @@ unsigned int radix_tree_gang_lookup_tag_slot(const struct radix_tree_root *, void __rcu ***results, unsigned long first_index, unsigned int max_items, unsigned int tag); int radix_tree_tagged(const struct radix_tree_root *, unsigned int tag); +unsigned long radix_tree_maxindex(const struct radix_tree_root *root); static inline void radix_tree_preload_end(void) { diff --git a/lib/radix-tree.c b/lib/radix-tree.c index b98e9f2c24ac..a89df8afa510 100644 --- a/lib/radix-tree.c +++ b/lib/radix-tree.c @@ -404,6 +404,18 @@ static unsigned radix_tree_load_root(const struct radix_tree_root *root, return 0; } +unsigned long radix_tree_maxindex(const struct radix_tree_root *root) +{ + struct radix_tree_node *node = rcu_dereference_raw(root->xa_head); + + if (likely(radix_tree_is_internal_node(node))) { + node = entry_to_node(node); + return node_maxindex(node); + } + + return 0; +} + /* * Extend a radix tree so it can store key @index. */ diff --git a/net/qrtr/af_qrtr.c b/net/qrtr/af_qrtr.c index 41ece61eb57a..abdae567a370 100644 --- a/net/qrtr/af_qrtr.c +++ b/net/qrtr/af_qrtr.c @@ -344,6 +344,12 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb, struct qrtr_hdr_v1 *hdr; size_t len = skb->len; int rc, confirm_rx; + unsigned long maxidx; + + if (to->sq_node == QRTR_NODE_BCAST) { + maxidx = radix_tree_maxindex(&node->qrtr_tx_flow); + to->sq_node = maxidx + 1; + } confirm_rx = qrtr_tx_wait(node, to->sq_node, to->sq_port, type); if (confirm_rx < 0) {