Received: by 2002:ac8:45c5:0:b0:405:464a:c27a with SMTP id e5csp1248578qto; Thu, 27 Jul 2023 08:53:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlHcgIaNYV6lMMlQluM95Rf6JOVX9oFZyn9wMdkxezaUkGXXKnwjzdzInKHzj7KZ7bk6qMzF X-Received: by 2002:a05:6a21:7982:b0:131:dc49:13eb with SMTP id bh2-20020a056a21798200b00131dc4913ebmr6267291pzc.35.1690473197409; Thu, 27 Jul 2023 08:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690473197; cv=none; d=google.com; s=arc-20160816; b=vOvocPZ3Ys+JcIMKIyqEATf9e3ByXhJQnv0jyZ93JUwScqOWc8TM65v+kwByv9PZgq aMwfCGmYqiDhTx+/ym1/MqxvcRxMD6UxjXkwttk9hgEDSMF2bVhFtCOB4q04r4LDAHHf yplgqsCS4poP+v17FppnInlEHTY/EXV98RIBgcnlaBjUEv9iI5APSKYsG2XU+A+yX188 9u1uJ0VOgw0iQG5WgD0oRlFKs+lsAySUoxyWujy16b8rBKdNZHwQbfd/buMruo3vkDbQ JU9q+kFd94riAKeGh5J9bU/LrzAyFHoH7lSg3Lz4DYmviToEprKYW4Hw+5jADeTnwlGx yjBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=NA8kva5zfcuAg5rJl+WVifuBQkmoSCkf0xxA+WFjl/s=; fh=tB+/iXL7TQj3+GypC6GIp0EwwoZe0L0tCNYCy2Qw98M=; b=ZoDJ0q5XhGlLTnR7rmJF7sTO3VvGPzoRyD5j2/t0VyXPZJ7dLTZoGvQO+VepufFSYN +irmGdY7vWp04R34xWwopR1c2S4ZhVRqrnrijGQLaTYNz/sWS7TTztETP8IjU7oFk1fc xmJu7SO6nMbJYbHSOC/W1EItQfI2sy4jvpIc4l1oii+BbV344t9yiP3odkPGhCoCZRZY rjwD2VXVYJkpZLq+H0WqPli9L0hVpKM8ORoqx0CrWvl/Cxkf6Gk3Sgtnvu2ER3WA5LrC X6cLPr3h//WgoD7wM0Bs89trC+jCGqmVcPa99Fkd54QdNr7bicSUYrKEs+q4G8dhiZNp dgvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GwkqZjoS; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g192-20020a636bc9000000b00557622a044esi1339837pgc.805.2023.07.27.08.53.04; Thu, 27 Jul 2023 08:53:17 -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=@intel.com header.s=Intel header.b=GwkqZjoS; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234438AbjG0PMP (ORCPT + 99 others); Thu, 27 Jul 2023 11:12:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232402AbjG0PMO (ORCPT ); Thu, 27 Jul 2023 11:12:14 -0400 Received: from mgamail.intel.com (unknown [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32A85B5 for ; Thu, 27 Jul 2023 08:12:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1690470734; x=1722006734; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=aLnYfgXFu9qFwcn/sovr3DuEibzC1WZUxyf9Izpe7QI=; b=GwkqZjoSTO7IIPMeGVPy9b1H02xaY9BJocOMe0PFDh7L9M5WAtqiX1K1 f5c6mqx4TM047CX8hAmHajdgTnrsu0TV31iYuFlmV6OpmaKDX+Mvg1H2g fTnZRjnTif5pTm7HyzWn98y3vZewZJHAFANMR8L7RuI49WfN+LaHJU5Jw HmF+D+7zMaIKHDCoCm4aFJPHjHFVJT4CF/Lkh8CuNgUzEYot4UvIlf3tC c2lDDI5GRDrTENwr0i3BTm/RdyIkd0a6GBQlSyFFLx6kvcBfL8hATEQl+ u5/xICra9bMIBEQjxmbycQa0+c3oJMhoBTrjhMPwE4XTw8VdRIy3NuRol w==; X-IronPort-AV: E=McAfee;i="6600,9927,10784"; a="368353700" X-IronPort-AV: E=Sophos;i="6.01,235,1684825200"; d="scan'208";a="368353700" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Jul 2023 08:12:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10784"; a="900906746" X-IronPort-AV: E=Sophos;i="6.01,235,1684825200"; d="scan'208";a="900906746" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga005.jf.intel.com with ESMTP; 27 Jul 2023 08:12:06 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qP2eq-009OVn-2G; Thu, 27 Jul 2023 18:12:04 +0300 Date: Thu, 27 Jul 2023 18:12:04 +0300 From: Andy Shevchenko To: Alexander Usyskin Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Tomas Winkler , Vitaly Lubart , Zhang Xiaoxu Subject: Re: [PATCH] mtd: fix use-after-free in mtd release Message-ID: References: <20230727145758.3880967-1-alexander.usyskin@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230727145758.3880967-1-alexander.usyskin@intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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 On Thu, Jul 27, 2023 at 05:57:58PM +0300, Alexander Usyskin wrote: > I case of partition device_unregister in mtd_device_release In device_unregister() mtd_device_release() > calls mtd_release which frees mtd_info structure for partition. mtd_release() > All code after device_unregister in mtd_device_release thus device_unregister() mtd_device_release() > works already freed memory. uses? > Move part of code to mtd_release and restict mtd->dev cleanup mtd_release() > to non-partion object. > For partition object such cleanup have no sense as partition > mtd_info is removed. > > Cc: Miquel Raynal > Cc: Zhang Xiaoxu > Fixes: 19bfa9ebebb5 ("mtd: use refcount to prevent corruption") Closes: ? -- With Best Regards, Andy Shevchenko