Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3115827rdb; Wed, 15 Nov 2023 23:57:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfm51c/bLWyz2RYN5F2aU2u046w+OQjiqazwFvFMDw7wf9AP81dX7sXdWGioLXhLf7Qyas X-Received: by 2002:a05:6a21:329d:b0:186:e43:c600 with SMTP id yt29-20020a056a21329d00b001860e43c600mr17348947pzb.10.1700121475948; Wed, 15 Nov 2023 23:57:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700121475; cv=none; d=google.com; s=arc-20160816; b=sIhLoW3XHCoeNUcTHqXPvk8VfSI81SrJ4Am08odx6ixo2p21QvXZyRuTFii/Gbh62F dyUE2iTvBNc4SwaBcxhA8t2OYdYERMAqNebLRB32S/MlvjMfDbDFYBMxT6/qkSCW1R2d thvsQuIZVPuGaOevDTHcmq8+tT3zp8KIWRDsLjiHlfwKbExlaLT1umxhbo9YE2fBVfGS LTcXWvYhvbiMJyQYV/yl8bVS7gCngq5KJq8VUeahiL+wnCVT8PMPfpoG9qmiRkIAvqpk ZQsIKIrCf/ltjVSSDhm26Wo03Mdg/rBkcOBFQzRttiROWvv05OCjsFZqNliI6otjsxO8 g9PQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=/zP01sxmtmsF220wNPZnDB4E4Ss9Od2fBbOpBrQvCQo=; fh=isUPTU0jSGeB45YGmLdxhAqRwQEfci/6WOBArNZWYwU=; b=iby2viBcSOY9kF2XWLx/xpn4zApBBX69AoTLRUm8minY2p1EAZeH1mJOluuH13GQcW FOmR017U4a3MmcX8w4050PECh9h4EI9CoRF1gYxRXs4MHLgmibwnVtQHEdE/7/RzLV2W Ua3UzYZICQqKa3F25wKV2D+gZy9ULgEM7iqKGwQevRQ6FNbZXCLAmSGdJGhcW4zBaXJW EW1PASvc49m2yjGhTf/aJHjTuO45mFR6NYqS0TQVZIU+qxp7sgStdC8saaG/00645ZbE 4V8z9j8hexZf7+btmzoiFWcNys5Vfg0jrLxXEcHG0YHunW2u7AxGvXkGW5FuHi4ZXmoC elTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NmZThr+d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ot3-20020a17090b3b4300b002832041e149si1542379pjb.167.2023.11.15.23.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 23:57:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=NmZThr+d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 8FAAA80D04FE; Wed, 15 Nov 2023 23:57:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229984AbjKPH5r (ORCPT + 99 others); Thu, 16 Nov 2023 02:57:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbjKPH5q (ORCPT ); Thu, 16 Nov 2023 02:57:46 -0500 Received: from mail-oa1-x42.google.com (mail-oa1-x42.google.com [IPv6:2001:4860:4864:20::42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA5D9120; Wed, 15 Nov 2023 23:57:43 -0800 (PST) Received: by mail-oa1-x42.google.com with SMTP id 586e51a60fabf-1f48b6e0388so121874fac.0; Wed, 15 Nov 2023 23:57:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700121463; x=1700726263; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/zP01sxmtmsF220wNPZnDB4E4Ss9Od2fBbOpBrQvCQo=; b=NmZThr+d9eVYMZzNP0iB390nkOs7IjovgGuc+xKBCKNFRZObT14kAcyIepuysRNgof ZAMCuRu6a8vOkxn8ot+bowOcjDFPrQpq4uxVvjUqJIprhl0fdQ0Qp+Yn1jFGzqSSiZ0/ la/d3gB/vsWEahGZ95jjNCG12YTnMmvInDR4dFvpLNhEMDyeMjJ+8I9bg0ArPqkhy0AD a9xulmroKA0z5XjmYQZsEIqEi9dXbfeIZm3WdiHnMmYBX4h/cSI1d/DOBju/RjWaUTWY DTti8llbAXCiBL1FTomV4W1BlJWoNsaMAxkBfldiN2Qe0V8K72QozmxdLkPirXmkhoDN y75Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700121463; x=1700726263; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/zP01sxmtmsF220wNPZnDB4E4Ss9Od2fBbOpBrQvCQo=; b=gfjINUPSg7DA6es2B1l+t958FeDZOgfmadLbGx+S3uENm7BwQ1PQEfFl7JWClIvt18 eX9V5OrvxRrTGcZCPfesdWaZJThoLpwuQJLUhAl/VS/PNMoLdrWm966rLrUtLHIlHpdH ufi/nPFtCMRasxuWH8L/PfP+/wTMvZUGIZJIbgu0pLI6Ur9YQA96nY9mrrBPTopPE+5M 6hByNA4mPBNFLBHzsJbrYoHq3zOEs0TfaLOwSRT0gYEEP0Ad/7v2gN2wNEIODIjhc1kx Hj364WoYS9uwBFert1dbfdNGF+saTJ9lLEa6hIQq+RB0ltnu+0lso1PPt3SGEmPeseRe ZWfQ== X-Gm-Message-State: AOJu0YykdS1tNjfs7fCz4mvuQVDStdbxBrm3izpZ6F4e2Quat+i55sy9 AErSF71G2ge03mPTtAtmcTQ= X-Received: by 2002:a05:6871:5c47:b0:1e9:bbfe:6458 with SMTP id os7-20020a0568715c4700b001e9bbfe6458mr9725172oac.1.1700121463234; Wed, 15 Nov 2023 23:57:43 -0800 (PST) Received: from hbh25y.mshome.net ([103.114.158.1]) by smtp.gmail.com with ESMTPSA id z19-20020aa785d3000000b00690c0cf97c9sm3969890pfn.73.2023.11.15.23.57.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 23:57:42 -0800 (PST) From: Hangyu Hua To: miklos@szeredi.hu, vgoyal@redhat.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Hangyu Hua Subject: [PATCH] fs: fuse: dax: set fc->dax to NULL in fuse_dax_conn_free() Date: Thu, 16 Nov 2023 15:57:26 +0800 Message-Id: <20231116075726.28634-1-hbh25y@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 15 Nov 2023 23:57:53 -0800 (PST) fuse_dax_conn_free() will be called when fuse_fill_super_common() fails after fuse_dax_conn_alloc(). Then deactivate_locked_super() in virtio_fs_get_tree() will call virtio_kill_sb() to release the discarded superblock. This will call fuse_dax_conn_free() again in fuse_conn_put(), resulting in a possible double free. Fixes: 1dd539577c42 ("virtiofs: add a mount option to enable dax") Signed-off-by: Hangyu Hua --- fs/fuse/dax.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index 23904a6a9a96..12ef91d170bb 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -1222,6 +1222,7 @@ void fuse_dax_conn_free(struct fuse_conn *fc) if (fc->dax) { fuse_free_dax_mem_ranges(&fc->dax->free_ranges); kfree(fc->dax); + fc->dax = NULL; } } -- 2.34.1