Re: [PATCH] fix sys cpumap for > 352 NR_CPUS

From: Rusty Russell
Date: Wed Jun 02 2004 - 19:26:04 EST


On Thu, 2004-06-03 at 09:11, Paul Jackson wrote:
> + /*
> + * Hack alert:
> + * 1) This could overwrite a buffer w/o warning. Someone should
> + * pass us a buffer size (count) or use seq_file or something
> + * to avoid buffer overrun risks.

Then just use -1UL as the arg to scnprintf, if you don't have a real
number. That way the overflow will at least have a chance of detection
in the sysfs code, which I think it should check in
file.c:fill_read_buffer(). Greg?

> + * 2) This can return a count larger than the read size requested
> + * by the user code - possibly confusing it.

That's sysfs' problem, not yours, and it handles it fine AFAICT.

> + * 3) Following hardcodes that mask scnprintf format requires 9
> + * chars of output for each 32 bits of mask or fraction.

Yes. Don't do that.

> + * 4) Following prints stale node_dev->cpumap value, instead of
> + * evaluating afresh node_to_cpumask(node_dev->sysdev.id).
> + * 5) Why does struct node even has the field cpumap. Won't it
> + * just get stale, especially in the face of cpu hotplug?

Yes, that field should be removed.

Above all, by placing your questions inside a patch, you got results,
but please don't do this again.

Thanks,
Rusty.
--
Anyone who quotes me in their signature is an idiot -- Rusty Russell

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/