From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7EB84C433DB for ; Wed, 24 Mar 2021 19:53:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1435861A1D for ; Wed, 24 Mar 2021 19:53:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1435861A1D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8CAAF6B0303; Wed, 24 Mar 2021 15:53:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 87A176B0304; Wed, 24 Mar 2021 15:53:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F4876B0305; Wed, 24 Mar 2021 15:53:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 503926B0303 for ; Wed, 24 Mar 2021 15:53:46 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0F9641802FA58 for ; Wed, 24 Mar 2021 19:53:46 +0000 (UTC) X-FDA: 77955818052.35.1B5DF38 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id B0FD2500152B for ; Wed, 24 Mar 2021 19:53:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616615624; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Auz9GU/nly2FsewQcEm0zC7+u8Knwn1/X/29MeBpMvo=; b=Ck6TeoNqlwv6nxvv9zDgJfoxGJGrPW2GnRgzkQOdZuYHsrdKtwmrZTnq9ULzUA/tV3nu+9 B6tSmD2i8oW8iPUC1oOrbSc4PanypN7LcktUU5oUrj1c8uP9ErPJ70wIiZJ5z3H79yVA+s U9ciCwiyOKJDYowXCWjKYeaWzEOXu8A= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-28-yS6nuVE5MomZcMEBSoNjgg-1; Wed, 24 Mar 2021 15:53:40 -0400 X-MC-Unique: yS6nuVE5MomZcMEBSoNjgg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0485F1009456; Wed, 24 Mar 2021 19:53:39 +0000 (UTC) Received: from [10.36.115.66] (ovpn-115-66.ams2.redhat.com [10.36.115.66]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE2B162677; Wed, 24 Mar 2021 19:53:28 +0000 (UTC) Subject: Re: [PATCH] mm: cma: fix corruption cma_sysfs_alloc_pages_count To: John Hubbard , Minchan Kim , Andrew Morton Cc: linux-mm , LKML , gregkh@linuxfoundation.org, surenb@google.com, joaodias@google.com, willy@infradead.org, digetx@gmail.com References: <20210324192044.1505747-1-minchan@kernel.org> <01e09f8b-93f9-cd59-1f12-7ab4c86743e6@nvidia.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: Date: Wed, 24 Mar 2021 20:53:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <01e09f8b-93f9-cd59-1f12-7ab4c86743e6@nvidia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Stat-Signature: juzn4gzxts49bzp8nfcnpqcumftb4p91 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: B0FD2500152B Received-SPF: none (redhat.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=us-smtp-delivery-124.mimecast.com; client-ip=170.10.133.124 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616615624-969417 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 24.03.21 20:45, John Hubbard wrote: > On 3/24/21 12:20 PM, Minchan Kim wrote: >> struct cma_stat's lifespan for cma_sysfs is different with >> struct cma because kobject for sysfs requires dynamic object >> while CMA is static object[1]. When CMA is initialized, >> it couldn't use slab to allocate cma_stat since slab was not >> initialized yet. Thus, it allocates the dynamic object >> in subsys_initcall. >> >> However, the cma allocation can happens before subsys_initcall >> then, it goes crash. >> >> Dmitry reported[2]: >> >> .. >> [ 1.226190] [] (cma_sysfs_alloc_pages_count) from [] (cma_alloc+0x153/0x274) >> [ 1.226720] [] (cma_alloc) from [] (__alloc_from_contiguous+0x37/0x8c) >> [ 1.227272] [] (__alloc_from_contiguous) from [] (atomic_pool_init+0x7b/0x126) >> [ 1.233596] [] (atomic_pool_init) from [] (do_one_initcall+0x45/0x1e4) >> [ 1.234188] [] (do_one_initcall) from [] (kernel_init_freeable+0x157/0x1a6) >> [ 1.234741] [] (kernel_init_freeable) from [] (kernel_init+0xd/0xe0) >> [ 1.235289] [] (kernel_init) from [] (ret_from_fork+0x11/0x1c) >> >> This patch moves those statistic fields of cma_stat into struct cma >> and introduces cma_kobject wrapper to follow kobject's rule. >> >> At the same time, it fixes other routines based on suggestions[3][4]. >> >> [1] https://lore.kernel.org/linux-mm/YCOAmXqt6dZkCQYs@kroah.com/ >> [2] https://lore.kernel.org/linux-mm/fead70a2-4330-79ff-e79a-d8511eab1256@gmail.com/ >> [3] https://lore.kernel.org/linux-mm/20210323195050.2577017-1-minchan@kernel.org/ >> [4] https://lore.kernel.org/linux-mm/20210324010547.4134370-1-minchan@kernel.org/ >> >> Reported-by: Dmitry Osipenko >> Tested-by: Dmitry Osipenko >> Suggested-by: Dmitry Osipenko >> Suggested-by: John Hubbard >> Suggested-by: Matthew Wilcox >> Signed-off-by: Minchan Kim >> --- >> I belive it's worth to have separate patch rather than replacing >> original patch. It will also help to merge without conflict >> since we already filed other patch based on it. >> Strictly speaking, separating fix part and readbility part >> in this patch would be better but it's gray to separate them >> since most code in this patch was done while we were fixing >> the bug. Since we don't release it yet, I hope it will work. >> Otherwise, I can send a replacement patch inclucing all of >> changes happend until now with gathering SoB. > > If we still have a choice, we should not merge a patch that has a known > serious problem, such as a crash. That's only done if the broken problematic > patch has already been committed to a tree that doesn't allow rebasing, > such as of course the main linux.git. > > Here, I *think* it's just in linux-next and mmotm, so we still are allowed > to fix the original patch. Yes, that's what we should do in case it's not upstream yet. Clean resend + re-apply. -- Thanks, David / dhildenb