linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mm/shrinker: make unregister_shrinker() less fragile
@ 2015-07-11  2:51 Sergey Senozhatsky
  2015-07-11  2:51 ` [PATCH 1/2] mm/shrinker: do not NULL dereference uninitialized shrinker Sergey Senozhatsky
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Sergey Senozhatsky @ 2015-07-11  2:51 UTC (permalink / raw)
  To: Andrew Morton
  Cc: linux-mm, linux-kernel, Sergey Senozhatsky, Sergey Senozhatsky

Hello,

Shrinker API does not handle nicely unregister_shrinker() on a not-registered
->shrinker. Looking at shrinker users, they all have to
(a) carry on some sort of a flag to make sure that "unregister_shrinker()"
will not blow up later
(b) be fishy (potentially can Oops)
(c) access private members `struct shrinker' (e.g. `shrink.list.next')

Change unregister_shrinker() to consider all-zeroes shrinker as
'initialized, but not registered' shrinker, so we can avoid NULL
dereference when unregister_shrinker() accidentally receives such
a struct.

Introduce init_shrinker() function to init `critical' shrinkers members
when the entire shrinker cannot be, for some reason, zeroed out. This
also helps to avoid Oops in unregister_shrinker() in some cases (when
unregister_shrinker() receives not initialized and not registered shrinker).

Sergey Senozhatsky (2):
  mm/shrinker: do not NULL dereference uninitialized shrinker
  mm/shrinker: add init_shrinker() function

 include/linux/shrinker.h |  1 +
 mm/vmscan.c              | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

-- 
2.4.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

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

end of thread, other threads:[~2015-07-14  7:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-11  2:51 [PATCH 0/2] mm/shrinker: make unregister_shrinker() less fragile Sergey Senozhatsky
2015-07-11  2:51 ` [PATCH 1/2] mm/shrinker: do not NULL dereference uninitialized shrinker Sergey Senozhatsky
2015-07-11  2:51 ` [PATCH 2/2] mm/shrinker: add init_shrinker() function Sergey Senozhatsky
2015-07-11 10:02 ` [PATCH 0/2] mm/shrinker: make unregister_shrinker() less fragile Christoph Hellwig
2015-07-12  2:47   ` Sergey Senozhatsky
2015-07-13  6:33     ` Christoph Hellwig
2015-07-13  6:52       ` Sergey Senozhatsky
2015-07-13  9:03         ` Christoph Hellwig
2015-07-13  9:34           ` Sergey Senozhatsky
2015-07-14  7:17             ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox