Re: [PATCH] mm: cma: fix corruption cma_sysfs_alloc_pages_count

2021-03-24 Thread Minchan Kim
On Wed, Mar 24, 2021 at 11:02:47PM +0300, Dmitry Osipenko wrote: > 24.03.2021 22:57, Minchan Kim пишет: > > On Wed, Mar 24, 2021 at 10:49:58PM +0300, Dmitry Osipenko wrote: > >> 24.03.2021 22:43, Dmitry Osipenko пишет: > >>> 24.03.2021 22:20, Minchan Kim пишет: > static int __init cma_sysfs_i

Re: [PATCH] mm: cma: fix corruption cma_sysfs_alloc_pages_count

2021-03-24 Thread Dmitry Osipenko
24.03.2021 22:57, Minchan Kim пишет: > On Wed, Mar 24, 2021 at 10:49:58PM +0300, Dmitry Osipenko wrote: >> 24.03.2021 22:43, Dmitry Osipenko пишет: >>> 24.03.2021 22:20, Minchan Kim пишет: static int __init cma_sysfs_init(void) { - int i = 0; + struct kobject *cma_kobj_root;

Re: [PATCH] mm: cma: fix corruption cma_sysfs_alloc_pages_count

2021-03-24 Thread Minchan Kim
On Wed, Mar 24, 2021 at 10:49:58PM +0300, Dmitry Osipenko wrote: > 24.03.2021 22:43, Dmitry Osipenko пишет: > > 24.03.2021 22:20, Minchan Kim пишет: > >> static int __init cma_sysfs_init(void) > >> { > >> - int i = 0; > >> + struct kobject *cma_kobj_root; > >> + struct cma_kobject *cma_kobj; >

Re: [PATCH] mm: cma: fix corruption cma_sysfs_alloc_pages_count

2021-03-24 Thread Minchan Kim
On Wed, Mar 24, 2021 at 08:53:26PM +0100, David Hildenbrand wrote: > 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

Re: [PATCH] mm: cma: fix corruption cma_sysfs_alloc_pages_count

2021-03-24 Thread David Hildenbrand
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

Re: [PATCH] mm: cma: fix corruption cma_sysfs_alloc_pages_count

2021-03-24 Thread Dmitry Osipenko
24.03.2021 22:43, Dmitry Osipenko пишет: > 24.03.2021 22:20, Minchan Kim пишет: >> static int __init cma_sysfs_init(void) >> { >> -int i = 0; >> +struct kobject *cma_kobj_root; >> +struct cma_kobject *cma_kobj; >> struct cma *cma; >> +unsigned int i; > >> while (--i >=

Re: [PATCH] mm: cma: fix corruption cma_sysfs_alloc_pages_count

2021-03-24 Thread Minchan Kim
On Wed, Mar 24, 2021 at 10:43:49PM +0300, Dmitry Osipenko wrote: > 24.03.2021 22:20, Minchan Kim пишет: > > static int __init cma_sysfs_init(void) > > { > > - int i = 0; > > + struct kobject *cma_kobj_root; > > + struct cma_kobject *cma_kobj; > > struct cma *cma; > > + unsigned int i;

Re: [PATCH] mm: cma: fix corruption cma_sysfs_alloc_pages_count

2021-03-24 Thread John Hubbard
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. Thu

Re: [PATCH] mm: cma: fix corruption cma_sysfs_alloc_pages_count

2021-03-24 Thread Dmitry Osipenko
24.03.2021 22:20, Minchan Kim пишет: > static int __init cma_sysfs_init(void) > { > - int i = 0; > + struct kobject *cma_kobj_root; > + struct cma_kobject *cma_kobj; > struct cma *cma; > + unsigned int i; > while (--i >= 0) { Do you realize that this doesn't work any

[PATCH] mm: cma: fix corruption cma_sysfs_alloc_pages_count

2021-03-24 Thread Minchan Kim
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 subs