Re: [PATCH 2/4] dma-debug: add debugfs file for driver filter

From: Joerg Roedel
Date: Tue Jun 02 2009 - 09:33:43 EST


On Mon, Jun 01, 2009 at 03:04:18PM -0700, Andrew Morton wrote:
> On Thu, 28 May 2009 17:19:29 +0200
> Joerg Roedel <joerg.roedel@xxxxxxx> wrote:
>
> > + /*
> > + * We can't copy from userspace directly. Access to
> > + * current_driver_name is protected with a write_lock with irqs
> > + * disabled. Since copy_from_user can fault and may sleep we
> > + * need to copy to temporary buffer first
> > + */
> > + len = min(count, len);
> > + if (copy_from_user(buf, userbuf, len))
> > + return -EFAULT;
> > +
> > + buf[NAME_MAX_LEN - 1] = 0;
>
> Might be able to use strncpy_from_user() here.
>

Hmm, no, not in this place because I can't be sure that userspace passes
a NULL-terminated string. So setting a character in the resulting string
to \0 is always required. This eliminates the benefit of
strncpy_from_user() here.

Joerg

--
| Advanced Micro Devices GmbH
Operating | Karl-Hammerschmidt-Str. 34, 85609 Dornach bei München
System |
Research | Geschäftsführer: Thomas M. McCoy, Giuliano Meroni
Center | Sitz: Dornach, Gemeinde Aschheim, Landkreis München
| Registergericht München, HRB Nr. 43632

--
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/