Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp1027506rdf; Wed, 22 Nov 2023 03:53:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZ9FEpoQrcKMMl8jYkdUiVPkU9AUKWx/xXuQoM5UXmM5u3U8eRFQxq7S/RBQq1jLff7tK4 X-Received: by 2002:a05:6a20:748e:b0:181:6b3d:ca1c with SMTP id p14-20020a056a20748e00b001816b3dca1cmr7963330pzd.3.1700654013666; Wed, 22 Nov 2023 03:53:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700654013; cv=none; d=google.com; s=arc-20160816; b=PEQIPbYwcNWU89t/IZ1Yzmu5KrHNBl0tmlDtTgfLzl9NTRwFGIbPY4Yj5n063TGFcw LevwZXMmAXWibn6Vby52+x5BSpeK0zxEIR5SALYl+TFE7aqdayd77M10MafCl8abJmDF He3nwqRHnBVULIdZfG/2JQWpw5tLd+CDFw2nHr2+laN65o78y7o1uFwXwkJo+6//WF1d phV4+3nObuoa5OK1ncUVI67AXzGePs7X7E0B634psSTY6t61BC5zzsw1hz1AdPit/t9a UOerO3nI+KOEyyTqrzSQEN9YAh4lH2bZHuZ9idVivPJGlqWUxZtnmOuxgxsaks2Qo9pD hXxg== 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:date :message-id:subject:references:in-reply-to:cc:to:from:dkim-signature; bh=i9R+bNug9gL4MtR26arZWZpqQ7hlsN6OfyT+unVRUoo=; fh=cc8VKOROgyCXfqNerI00NltS7Ge8BvCDRESUtF2uLFk=; b=EE5z+gUB5DvqOISSgZ6pzZhaWrFjyrPmf+lsjQpdmhR8T8SmRPde8qWXsyA5FIPrjb rIkwYWVQy0y8SiGgQnBYChqmKyOtMH5LidvC+24+3EKuTC9g51HkeFcDTehGDFYqmmcB QJEVeBy02SsnefazeXibHOa07uPfvBq77ySNQN1QXuTej/FaswTW0+wmPaNb9bFdnuNw DS1M8GLACgnA1Diz+fXBk9BThl/3EVzSJZpyV81JyiMqgwh8fcVmKOwKof/kIvSY8se+ k5AjWyCTSZL0UHDrkYD2miDazuHug384i+t0tcMuFPVMHWEJIVZnQFbR+xPe1c5lTFM1 uAbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GKwiYsrw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id 17-20020a631151000000b005b999968b87si12376880pgr.580.2023.11.22.03.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 03:53:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GKwiYsrw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2481681C0C96; Wed, 22 Nov 2023 03:53:31 -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 S1343919AbjKVLxZ (ORCPT + 99 others); Wed, 22 Nov 2023 06:53:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343819AbjKVLxX (ORCPT ); Wed, 22 Nov 2023 06:53:23 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F45D1BC for ; Wed, 22 Nov 2023 03:53:20 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93917C433C8; Wed, 22 Nov 2023 11:53:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700654000; bh=K+VyxU9+3wW62WbOigu1weinCYoVJfJ+ufPp61LPh54=; h=From:To:Cc:In-Reply-To:References:Subject:Date:From; b=GKwiYsrwf7fq6SO3hzB9JoIaSsbl8hFlTz09O5fenYcbfYKlaUK16grVcMwU8ayWy WmiJLrm4qXMs3IvjDbVpugwh5hJhp4MtiYDLWUVAI6dokP7GI206vyCfsGz8S33PAz XpM0SJ1czh1x5aWSDdpvP128oRe/Sgu+AH3hKZuiteGMEuvG2HASWtcJALp0qa6bxU C4+986Y+G9ormMvnMvphmtuNKSWx0N8ZaYFTkHZoTUJ0xOPH0ria0E/xebVAlzjOYE ailbbVS7E2Cj2zaauHWUUsdNLUjnURKFIAVHAo1OxpSMY5mbKUtOwgvvzhn5cOXvA0 FeBpQ6yRs+S8w== From: Leon Romanovsky To: mustafa.ismail@intel.com, shiraz.saleem@intel.com, jgg@ziepe.ca, gustavoars@kernel.org, Shifeng Li Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, dinghui@sangfor.com.cn In-Reply-To: <20231121101236.581694-1-lishifeng1992@126.com> References: <20231121101236.581694-1-lishifeng1992@126.com> Subject: Re: [PATCH v3] RDMA/irdma: Fix UAF in irdma_sc_ccq_get_cqe_info() Message-Id: <170065399591.29157.1831837396009274154.b4-ty@kernel.org> Date: Wed, 22 Nov 2023 13:53:15 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Mailer: b4 0.12-dev-a055d X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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]); Wed, 22 Nov 2023 03:53:31 -0800 (PST) On Tue, 21 Nov 2023 02:12:36 -0800, Shifeng Li wrote: > When removing the irdma driver or unplugging its aux device, the ccq > queue is released before destorying the cqp_cmpl_wq queue. > But in the window, there may still be completion events for wqes. That > will cause a UAF in irdma_sc_ccq_get_cqe_info(). > > [34693.333191] BUG: KASAN: use-after-free in irdma_sc_ccq_get_cqe_info+0x82f/0x8c0 [irdma] > [34693.333194] Read of size 8 at addr ffff889097f80818 by task kworker/u67:1/26327 > [34693.333194] > [34693.333199] CPU: 9 PID: 26327 Comm: kworker/u67:1 Kdump: loaded Tainted: G O --------- -t - 4.18.0 #1 > [34693.333200] Hardware name: SANGFOR Inspur/NULL, BIOS 4.1.13 08/01/2016 > [34693.333211] Workqueue: cqp_cmpl_wq cqp_compl_worker [irdma] > [34693.333213] Call Trace: > [34693.333220] dump_stack+0x71/0xab > [34693.333226] print_address_description+0x6b/0x290 > [34693.333238] ? irdma_sc_ccq_get_cqe_info+0x82f/0x8c0 [irdma] > [34693.333240] kasan_report+0x14a/0x2b0 > [34693.333251] irdma_sc_ccq_get_cqe_info+0x82f/0x8c0 [irdma] > [34693.333264] ? irdma_free_cqp_request+0x151/0x1e0 [irdma] > [34693.333274] irdma_cqp_ce_handler+0x1fb/0x3b0 [irdma] > [34693.333285] ? irdma_ctrl_init_hw+0x2c20/0x2c20 [irdma] > [34693.333290] ? __schedule+0x836/0x1570 > [34693.333293] ? strscpy+0x83/0x180 > [34693.333296] process_one_work+0x56a/0x11f0 > [34693.333298] worker_thread+0x8f/0xf40 > [34693.333301] ? __kthread_parkme+0x78/0xf0 > [34693.333303] ? rescuer_thread+0xc50/0xc50 > [34693.333305] kthread+0x2a0/0x390 > [34693.333308] ? kthread_destroy_worker+0x90/0x90 > [34693.333310] ret_from_fork+0x1f/0x40 > > [...] Applied, thanks! [1/1] RDMA/irdma: Fix UAF in irdma_sc_ccq_get_cqe_info() https://git.kernel.org/rdma/rdma/c/2b78832f50c4d7 Best regards, -- Leon Romanovsky