slab: don't put freepointer outside of object if only orig_size
authorChengming Zhou <chengming.zhou@linux.dev>
Fri, 7 Jun 2024 08:40:13 +0000 (16:40 +0800)
committerVlastimil Babka <vbabka@suse.cz>
Fri, 7 Jun 2024 09:03:24 +0000 (11:03 +0200)
commitadef2aeaa2b936c97865d56c59be2cb7266acbb7
tree79957bf4bc610ff7de0112abd6b9573ccd258210
parent47d911b02cbe61494bb066ad84cc66d25091d506
slab: don't put freepointer outside of object if only orig_size

The commit 946fa0dbf2d8 ("mm/slub: extend redzone check to extra
allocated kmalloc space than requested") will extend right redzone
when allocating for orig_size < object_size. So we can't overlay the
freepointer in the object space in this case.

But the code looks like it forgot to check SLAB_RED_ZONE, since there
won't be extended right redzone if only orig_size enabled.

As we are here, make this complex conditional expressions a little
prettier and add some comments about extending right redzone when
slub_debug_orig_size() enabled.

Reviewed-by: Feng Tang <feng.tang@intel.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Chengming Zhou <chengming.zhou@linux.dev>
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
mm/slub.c