linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH 0/5] do not dereference NULL pools in pools' destroy() functions
@ 2015-06-09 12:04 Sergey Senozhatsky
  2015-06-09 12:04 ` [RFC][PATCH 1/5] mm/slab_common: allow NULL cache pointer in kmem_cache_destroy() Sergey Senozhatsky
                   ` (5 more replies)
  0 siblings, 6 replies; 44+ messages in thread
From: Sergey Senozhatsky @ 2015-06-09 12:04 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Minchan Kim, Christoph Lameter, Pekka Enberg, Joonsoo Kim,
	Michal Hocko, David Rientjes, linux-mm, linux-kernel,
	sergey.senozhatsky.work, Sergey Senozhatsky

Hello,

RFC

Proposed by Andrew Morton: https://lkml.org/lkml/2015/6/8/583

The existing pools' destroy() functions do not allow NULL pool pointers;
instead, every destructor() caller forced to check if pool is not NULL,
which:
 a) requires additional attention from developers/reviewers
 b) may lead to a NULL pointer dereferences if (a) didn't work


First 3 patches tweak
- kmem_cache_destroy()
- mempool_destroy()
- dma_pool_destroy()

to handle NULL pointers.
Basically, this patch set will:

1) Can prevent us from still undiscovered NULL pointer dereferences.
 (like the one that was addressed in https://lkml.org/lkml/2015/6/5/262)

2) Make a cleanup possible. Things like:
 [..]
         if (xhci->segment_pool)
                 dma_pool_destroy(xhci->segment_pool);
 	..
         if (xhci->device_pool)
                 dma_pool_destroy(xhci->device_pool);
 	..
         if (xhci->small_streams_pool)
                 dma_pool_destroy(xhci->small_streams_pool);
 	..
         if (xhci->medium_streams_pool)
                 dma_pool_destroy(xhci->medium_streams_pool);
 [..]
 
 or
 
 [..]
 fail_dma_pool:
         if (IS_QLA82XX(ha) || ql2xenabledif) {
                 dma_pool_destroy(ha->fcp_cmnd_dma_pool);
                 ha->fcp_cmnd_dma_pool = NULL;
         }
 fail_dl_dma_pool:
         if (IS_QLA82XX(ha) || ql2xenabledif) {
                 dma_pool_destroy(ha->dl_dma_pool);
                 ha->dl_dma_pool = NULL;
         }
 fail_s_dma_pool:
         dma_pool_destroy(ha->s_dma_pool);
         ha->s_dma_pool = NULL;
 [..]

 may now be simplified.


0004 and 0005 are not so necessary, simply because there are not
so many users of these two (added for pool's destroy() functions consistency):
-- zpool_destroy_pool()
-- zs_destroy_pool()

So, 0004 and 0005 can be dropped.


- zbud does kfree() in zbud_destroy_pool(), so I didn't touch it.


Sergey Senozhatsky (5):
  mm/slab_common: allow NULL cache pointer in kmem_cache_destroy()
  mm/mempool: allow NULL `pool' pointer in mempool_destroy()
  mm/dmapool: allow NULL `pool' pointer in dma_pool_destroy()
  mm/zpool: allow NULL `zpool' pointer in zpool_destroy_pool()
  mm/zsmalloc: allow NULL `pool' pointer in zs_destroy_pool()

 mm/dmapool.c     | 3 +++
 mm/mempool.c     | 3 +++
 mm/slab_common.c | 3 +++
 mm/zpool.c       | 3 +++
 mm/zsmalloc.c    | 3 +++
 5 files changed, 15 insertions(+)

-- 
2.4.3.368.g7974889


^ permalink raw reply	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2015-08-06 14:30 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-09 12:04 [RFC][PATCH 0/5] do not dereference NULL pools in pools' destroy() functions Sergey Senozhatsky
2015-06-09 12:04 ` [RFC][PATCH 1/5] mm/slab_common: allow NULL cache pointer in kmem_cache_destroy() Sergey Senozhatsky
2015-06-17 23:14   ` David Rientjes
2015-06-17 23:52     ` Sergey Senozhatsky
2015-06-19 15:50       ` Julia Lawall
2015-08-06 14:21         ` Sergey Senozhatsky
2015-08-06 14:27           ` Julia Lawall
2015-08-06 14:29             ` Sergey Senozhatsky
2015-06-20 16:25       ` Julia Lawall
2015-07-16  8:26         ` Sergey Senozhatsky
2015-06-09 12:04 ` [RFC][PATCH 2/5] mm/mempool: allow NULL `pool' pointer in mempool_destroy() Sergey Senozhatsky
2015-06-17 23:21   ` David Rientjes
2015-06-17 23:54     ` Sergey Senozhatsky
2015-06-09 12:04 ` [RFC][PATCH 3/5] mm/dmapool: allow NULL `pool' pointer in dma_pool_destroy() Sergey Senozhatsky
2015-06-17 23:22   ` David Rientjes
2015-06-09 12:04 ` [RFC][PATCH 4/5] mm/zpool: allow NULL `zpool' pointer in zpool_destroy_pool() Sergey Senozhatsky
2015-06-10 20:59   ` Dan Streetman
2015-06-10 23:58     ` Sergey Senozhatsky
2015-06-11  0:48       ` Joe Perches
2015-06-11  0:59         ` Sergey Senozhatsky
2015-06-11  1:01           ` Dan Streetman
2015-06-09 12:04 ` [RFC][PATCH 5/5] mm/zsmalloc: allow NULL `pool' pointer in zs_destroy_pool() Sergey Senozhatsky
2015-06-09 21:25 ` [RFC][PATCH 0/5] do not dereference NULL pools in pools' destroy() functions Andrew Morton
2015-06-10  0:06   ` Joe Perches
2015-06-10  4:39     ` [PATCH] checkpatch: Add some <foo>_destroy functions to NEEDLESS_IF tests Joe Perches
2015-06-10  5:52       ` [PATCH V2] " Joe Perches
2015-06-10 10:18         ` Sergey Senozhatsky
2015-06-11  9:41         ` Julia Lawall
2015-06-11  9:51           ` Sergey Senozhatsky
2015-06-11  9:55             ` Julia Lawall
2015-07-14 23:03         ` Andrew Morton
2015-07-15  0:27           ` Sergey Senozhatsky
2015-06-10  5:46     ` [RFC][PATCH 0/5] do not dereference NULL pools in pools' destroy() functions Julia Lawall
2015-06-10  6:41       ` Sergey Senozhatsky
2015-06-10  6:44         ` Julia Lawall
2015-06-10  6:52           ` Sergey Senozhatsky
2015-06-10  1:11   ` Christoph Lameter
2015-06-10  1:51     ` Andrew Morton
2015-06-10  2:00       ` Christoph Lameter
2015-06-10  2:17         ` Andrew Morton
2015-06-10  4:47           ` Joe Perches
2015-06-11 17:26           ` Christoph Lameter
2015-06-11 17:40             ` Andrew Morton
2015-06-10  2:04     ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).