Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp43752pxf; Wed, 24 Mar 2021 20:25:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwey7PhVThZLbGmXj+mRLtyLgDJ3WnsB++BmBqG2+lwtBkZi+AdEzs1eJI9/tjszCQNzCjE X-Received: by 2002:a17:906:b316:: with SMTP id n22mr6842836ejz.249.1616642707346; Wed, 24 Mar 2021 20:25:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616642707; cv=none; d=google.com; s=arc-20160816; b=GPh6ChFYfhk9w/rRIQJa9qUodEZ4xbTYT9d/XzCuL/uyz/Z1800gF6479FdHCvPGzl LXu8CaQhalLQD7gaPsjZx6Q3L6pxqgFrtIBjk3wnYybinzxGgaev9C6Kxh6f5x+SyWKd 22IPll+jOb4Mbpp9B4AfTxsL6wLfMVvuORomQU+fbNneom1ATHxqNtdwy2l02lR7X/Cz 0UvxMAnpQpbYM1ADbQJqQsw8LUBiSehSPOGyn9XHDZFSR775BqsqyqmQvE2CBd+tP2/Z IlVIc4DSH3Chwz4nyoaTyfBo8GJLIXotCxzJqqgMhJUzm2J2uKm1/4Hc8Sm84VXSzpn4 D5Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=Auz9GU/nly2FsewQcEm0zC7+u8Knwn1/X/29MeBpMvo=; b=otgc83N42f597c42hr3B+kbRMB6FtjWagcAEddCSLXjzR7qIfj77pAZif4720gpmpP /wqT9xMLRjEvGR+vLP51GBGwQFZqT7+JaZPSWzVOdfAapcc3XVVsBumyg5fJnCOMIxHn CxPwwgASy6O6A5AAlDlSjWNgvU+v/M4IE+iB9sng2uOUekhEojwuYNCCLXmJlWL1QURs Og6bCejq4k+GJafqgqxRCEXq5S4wqGOt7CsF19s507TRM+ytg7/Nu8Zs7g41sqXbl/sj 2cfErLDmo0ncLsO0ioxzu2eSGUB1DsnEd0wcH/7lL5OS6Vz6mXYWhAuUUAluhh14RQPg vTkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ck6TeoNq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mb15si3199587ejb.147.2021.03.24.20.24.43; Wed, 24 Mar 2021 20:25:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ck6TeoNq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237982AbhCXTxy (ORCPT + 99 others); Wed, 24 Mar 2021 15:53:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33454 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237980AbhCXTxp (ORCPT ); Wed, 24 Mar 2021 15:53:45 -0400 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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