Re: [PATCH] Fix missing of last user while dumping slab corruption log

Previous thread: [GIT PULL] sched/core: implement and cpuhog by Tejun Heo on Thursday, April 1, 2010 - 11:16 pm. (2 messages)

Next thread: [RFC][PATCH v2 0/3] Provide a zero-copy method on KVM virtio-net. by xiaohui.xin on Friday, April 2, 2010 - 12:25 am. (13 messages)
From: ShiYong LI
Date: Friday, April 2, 2010 - 12:21 am

Hi,

Even with SLAB_RED_ZONE and SLAB_STORE_USER enabled, kernel would NOT
store redzone and last user data around allocated memory space if arch
cache line > sizeof(unsigned long long). As a result, last user information
is unexpectedly MISSED while dumping slab corruption log.

This patch makes sure that redzone and last user tags get stored whatever
arch cache line.

Compared to original codes, the change surely affects head redzone (redzone1).
Actually, with SLAB_RED_ZONE and SLAB_STORE_USER enabled,
allocated memory layout is as below:

[ redzone1 ]   <--------- Affected area.
[ real object space ]
[ redzone2 ]
[ last user ]
[ ... ]

Let's do some analysis: (whatever SLAB_STORE_USER is).

1) With SLAB_RED_ZONE on, "align" >= sizeof(unsigned long long) according to
    the following codes:
	/* 2) arch mandated alignment */
	if (ralign < ARCH_SLAB_MINALIGN) {
		ralign = ARCH_SLAB_MINALIGN;
	}
	/* 3) caller mandated alignment */
	if (ralign < align) {
		ralign = align;
	}
	...
	/*
	 * 4) Store it.
	 */
	align = ralign;

    That's to say, could guarantee that redzone1 does NOT get broken
at all. Meanwhile,
    Real object space could meet the need of cache line size by using
"align"  argument.

2) With SLAB_RED_ZONE off, the change has no impact.


From 03b28964311090533643acd267abe0cbc3c9b0a5 Mon Sep 17 00:00:00 2001
From: Shiyong Li <shi-yong.li@motorola.com>
Date: Fri, 2 Apr 2010 14:50:30 +0800
Subject: [PATCH] Fix missing of last user info while getting
DEBUG_SLAB config enabled.

Even with SLAB_RED_ZONE and SLAB_STORE_USER enabled, kernel would NOT
store redzone and last user data around allocated memory space if arch
cache line > sizeof(unsigned long long). As a result, last user information
is unexpectedly MISSED while dumping slab corruption log.

This fix makes sure that redzone and last user tags get stored whatever
cache line.

Signed-off-by: Shiyong Li <shi-yong.li@motorola.com>
---
 mm/slab.c |    7 ++-----
 1 files changed, 2 ...
From: TAO HU
Date: Monday, April 5, 2010 - 6:24 pm

Hi, Pekka Enberg

This is the updated version with format fix and comments refinement.
Let us know whether you still have comments.

-- 
Best Regards
Hu Tao

--

From: TAO HU
Date: Wednesday, April 7, 2010 - 7:32 am

Hi, Pekka Enberg

Can we assume you have no objection for this patch? :)

-- 
Best Regards
Hu Tao

--

From: Pekka Enberg
Date: Wednesday, April 7, 2010 - 8:25 am

Hi,

(I'm cc'ing David who did some fixes in this area previously.)


The problem I have with this patch is that I am unable to convince
myself that it's correct.

The code in question is pretty hard to follow and it can break on
architectures with strict alignment requirements. I'm not sure I fully
understand why we've been disabling debugging in the first place.

On which architectures have you verified this fix?

                        Pekka
--

From: TAO HU
Date: Wednesday, April 7, 2010 - 8:13 pm

Hi, Pekka Enberg

We verified on OMAP3 (ARM V7).
1 thing we're sure
a) cachep->obj_offset will be aligned with "align" passed to
kmem_cache_create ()

Are you concerned about alignment for red-zone obj?
We'll double check.

-- 
Best Regards
Hu Tao

--

Previous thread: [GIT PULL] sched/core: implement and cpuhog by Tejun Heo on Thursday, April 1, 2010 - 11:16 pm. (2 messages)

Next thread: [RFC][PATCH v2 0/3] Provide a zero-copy method on KVM virtio-net. by xiaohui.xin on Friday, April 2, 2010 - 12:25 am. (13 messages)