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

Joerg Roedel joerg.roedel at amd.com
Tue Jun 2 06:33:21 PDT 2009


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 at amd.com> 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



More information about the iommu mailing list