Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2811344rwb; Mon, 15 Aug 2022 11:49:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR59x7Grle5OG/kcltULMtt72sx3WQw7kQS41yq8Hxht5hLqhDvRNpyUSQ7yT9YW9rEcVa6L X-Received: by 2002:a05:6402:4441:b0:43d:5bcf:afa0 with SMTP id o1-20020a056402444100b0043d5bcfafa0mr15417547edb.91.1660589369282; Mon, 15 Aug 2022 11:49:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660589369; cv=none; d=google.com; s=arc-20160816; b=uimXIU8HO7e+7KvxtlnRUA6a0jowcDwN6AdwaXnZm3wZRMbqswXPdJ+gk3owcHRvu8 lyskp2KtXYC+ulIBQvV0nkEgJJNqInx/2+kvH7RLSVrTtEAQroGejW+U12qkrMIAEk15 87GBolhGV4L1VNW56Wx8oWvTzntSxlSTG/Iw6E7YdWpwxzYU8NBXeOeD1V3Wc0u6p42e XvMW88l9ll8IUq868dT95YvyKlSa0ty2z2xtXSArYKxKaIgKN0vpn6QceHyNWsyxcFv7 uiLQ9ugywSKqI2YuGW3PjVZ7YH+rmUxR6FxxB/tOun2q+hS4QhrTJNNJYa4Y9tpx1kzY eLcw== 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=yFM5NAH4FbqVZAUN+RpSLe1Fb5MJe458XF5fgVWxzb8=; b=XD6B0YpQA68vpGx0el8Bk9OzQ2V39gWnEgRJ/ODzCyUDQYqpsRLuM4y1pPjc6F0yvc EBlDklqFsO5UIFNUMgZWfAgxDaf/8cF3UEM/HazyoPLyKeLTdn5Fefn/jGz9rbdq/8q3 eA+xBhu09adNux69DWx9ZfPYxprU7YMSqYQDauS+rsIjR7gdqCpRWIabytzCa/qtKTzH tuSHCHvShA0BQd/uhRRlss66f6OTs4HUQhB1++7XAm7edZN/d1ZattMuKs1V5YzGob1C 7M7Trl9lw08YxZOK4QlrqfMxUrQPLGe6cPuTyVCdAAGPEI2FzXC21+tFjeMA5fJEsnFv liGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CK0iyepL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f21-20020a1709062c5500b007305cca877csi6592804ejh.425.2022.08.15.11.49.03; Mon, 15 Aug 2022 11:49:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CK0iyepL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231359AbiHORvZ (ORCPT + 99 others); Mon, 15 Aug 2022 13:51:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229785AbiHORvW (ORCPT ); Mon, 15 Aug 2022 13:51:22 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BE71D137; Mon, 15 Aug 2022 10:51:21 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id 17so6958306plj.10; Mon, 15 Aug 2022 10:51:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=yFM5NAH4FbqVZAUN+RpSLe1Fb5MJe458XF5fgVWxzb8=; b=CK0iyepL58aRSd9LzU3quaQk58TnfOXRzthLNyTjGfWMiRTJsrmdiF/ja9RaaNW2c7 +fHU/9iCI9PjCnXTg49kGl/pME6keQJQVdyeA1Q/TAR30FKQYG7X4gWMyXdlUKQE+T5x gi6wRafz2djcfvrN/EgRyKfGR06izb63WYF/zQa1pSgccwk9SttjFfIC7Y7uvne6ytQj BedEFLdHTBW+qMFCmXwtM53T6JqvB0nkw/iCOf5vgRRaZ6SgXdh63pIWmq/cBvj+7X6f jkKx7Qd02UV422TUXwxuJeFA4edIw4BqNEbUHPSGU5tfExwX8XRDDauCo7t5KsYuEPGU IeCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=yFM5NAH4FbqVZAUN+RpSLe1Fb5MJe458XF5fgVWxzb8=; b=2CO5Kx+M2JzG9aDv2Ad3MJRgX808JXGI6gavrCvpokhl/w7CbIFABDmRucJG+s6g/t tWFsxqXS2vfaC/MmKR/gx5XZiMDd0LZ737KRa6dLoFKtD0Dm8hI2DbVpLSj+EbTw72H1 omCBg4m2b2dhS1ZvzU1MYUf8YURC18q2nQ/sDRp12/JxKE/Sh2xAnzIhN9NqZ31G847d 5xi8/nTfm8wYOpZ51t2F9/jIaQfJ0cy/Qh2lGAuOYWFooDP0bF3Ge1w7yhZr5xL81jhQ gxRuty1HoJliv2GRW0rKr/PULjndKgpZhyyGrbHmMDDZdjrl8p8nwHsNJHlkHrr2D4Al kSEw== X-Gm-Message-State: ACgBeo1urG5m6kWstVjzoV4qv0JEN8s4wuib0LvzdDhSQsl4Ia4n7OvX WV+6nWMqerN10tnLxJehF7o= X-Received: by 2002:a17:902:dac2:b0:172:5f2a:f30 with SMTP id q2-20020a170902dac200b001725f2a0f30mr10831822plx.167.1660585880460; Mon, 15 Aug 2022 10:51:20 -0700 (PDT) Received: from carrot.. (i114-190-253-100.s42.a014.ap.plala.or.jp. [114.190.253.100]) by smtp.gmail.com with ESMTPSA id i8-20020a1709026ac800b0016c5306917fsm7259729plt.53.2022.08.15.10.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Aug 2022 10:51:18 -0700 (PDT) From: Ryusuke Konishi To: Andrew Morton Cc: Al Viro , linux-nilfs , LKML , Jiacheng Xu , Mudong Liang Subject: [PATCH] nilfs2: fix use-after-free bug in nilfs_mdt_destroy() Date: Tue, 16 Aug 2022 02:51:14 +0900 Message-Id: <20220815175114.23576-1-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In alloc_inode(), inode_init_always() could return -ENOMEM if security_inode_alloc() fails. If this happens for nilfs2, nilfs_free_inode() is called without initializing inode->i_private and nilfs_free_inode() wrongly calls nilfs_mdt_destroy(), which frees uninitialized inode->i_private and can trigger a crash. Fix this bug by initializing inode->i_private in nilfs_alloc_inode(). Link: https://lkml.kernel.org/r/CAFcO6XOcf1Jj2SeGt=jJV59wmhESeSKpfR0omdFRq+J9nD1vfQ@mail.gmail.com Link: https://lkml.kernel.org/r/20211011030956.2459172-1-mudongliangabcd@gmail.com Reported-by: butt3rflyh4ck Reported-by: Hao Sun Reported-by: Jiacheng Xu Reported-by: Mudong Liang Signed-off-by: Ryusuke Konishi Cc: Al Viro --- fs/nilfs2/super.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index ba108f915391..aca5614f1b44 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c @@ -159,6 +159,7 @@ struct inode *nilfs_alloc_inode(struct super_block *sb) ii->i_cno = 0; ii->i_assoc_inode = NULL; ii->i_bmap = &ii->i_bmap_data; + ii->vfs_inode.i_private = NULL; return &ii->vfs_inode; } -- 2.34.1