Re: Reading large /proc entry from kernel module

From: Bob Bennett
Date: Wed Mar 09 2005 - 14:30:35 EST

Kristian SÃrensen <ks <at>> writes:

> Hi all!
> I have some trouble reading a 2346 byte /proc entry from our Umbrella kernel
> module.

> if (count != UMB_POLICY_SIZE) {
> printk("Umbrella: Error - /proc/umbrella is of invalid size\n");
> return -EFAULT;

> if (copy_from_user(lbuf, buffer, count)) {
> kfree(lbuf);
> kfree(policy);
> return -EFAULT;
> }
> strcpy(policy, lbuf);
> umb_parse_proc(policy);
> }

> Now that everything works, I want to write a string of excactly 2346
> characters to the /proc/umbrella file. However when I make the
> copy_from_user, I only get the first 1003 characters (
> - Do you have a pointer to where I do this thing wrong?
> What is the limit regarding the size of writing a /proc entry? (we consider
> importing binary public keys to the kernel this way in the future).
> Best regards,
> Kristian.

What makes you think you only have 1003 bytes? If UMB_POLICY_SIZE is defined as
2346, then user space must have written that amount. Probably the problem is
that you used strcpy() to copy the data from lbuf to policy, and there is a null
character after 1003 bytes. It is an unnecessary extra step to allocate two
buffers (lbuf & policy) and copy data from one to the other. Why not just pass
lbuff to umb_parse_proc()??

Bob Bennett

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at