PATCH mm/slab.c against 2.5.15 (was: slab cache broken on sparc64

Holzrichter, Bruce (bruce.holzrichter@monster.com)
Wed, 8 May 2002 15:04:13 -0500


>
> Do it like this instead.
>
> int fault;
> mm_segment_t old_fs;
>
> ...
>
> old_fs = get_fs();
> set_fs(KERNEL_DS);
> fault = __get_user(tmp, pc->name);
> set_fs(old_fs);
>
> if (fault) {
> ...
>

Dave/Andi

I've redone my patch against mm/slab.c for 2.5.15, although I can't test on
my Sparc ad I don't have a working kernel 2.5.15 yet for other reasons, but
it does compile. I have tested against 2.5.13 with this, and it works fine,
with your changes, mentioned above, so there's no reason it shouldn't.

This will make sure the __get_user is called correctly.

Thanks,
Bruce H.

--- linus-2.5/mm/slab.c Wed May 8 15:51:33 2002
+++ sparctest/mm/slab.c Wed May 8 15:43:04 2002
@@ -843,10 +843,19 @@
list_for_each(p, &cache_chain) {
kmem_cache_t *pc = list_entry(p, kmem_cache_t,
next);
char tmp;
+ int fault;
+ mm_segment_t old_fs;
+
/* This happens when the module gets unloaded and
doesn't
destroy its slab cache and noone else reuses the
vmalloc
area of the module. Print a warning. */
- if (__get_user(tmp,pc->name)) {
+
+ old_fs = get_fs();
+ set_fs(KERNEL_DS);
+ fault = __get_user(tmp, pc->name);
+ set_fs(old_fs);
+
+ if (fault) {
printk("SLAB: cache with size %d has lost
its name\n",
pc->objsize);
continue;
@@ -1912,13 +1921,16 @@
static int s_show(struct seq_file *m, void *p)
{
kmem_cache_t *cachep = p;
+ mm_segment_t old_fs;
struct list_head *q;
slab_t *slabp;
unsigned long active_objs;
unsigned long num_objs;
unsigned long active_slabs = 0;
unsigned long num_slabs;
- const char *name;
+ const char *name;
+ char tmp;
+ int fault;

if (p == (void*)1) {
/*
@@ -1963,11 +1975,13 @@
num_objs = num_slabs*cachep->num;

name = cachep->name;
- {
- char tmp;
- if (__get_user(tmp, name))
- name = "broken";
- }
+
+ old_fs = get_fs();
+ set_fs(KERNEL_DS);
+ fault = __get_user(tmp, name);
+ set_fs(old_fs);
+
+ if (fault) name = "broken";

seq_printf(m, "%-17s %6lu %6lu %6u %4lu %4lu %4u",
name, active_objs, num_objs, cachep->objsize,
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/