Re: [PATCH] proc: use vmalloc for our kernel buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/13/20 10:59 AM, Matthew Wilcox wrote:
On Thu, Aug 13, 2020 at 10:53:05AM -0400, Josef Bacik wrote:
+/**
+ * vmemdup_user - duplicate memory region from user space and NUL-terminate

vmemdup_user_nul()

+void *vmemdup_user_nul(const void __user *src, size_t len)
+{
+	void *p;
+
+	p = kvmalloc(len, GFP_USER);

len+1, shirley?

+	if (!p)
+		return ERR_PTR(-ENOMEM);
+
+	if (copy_from_user(p, src, len)) {
+		kvfree(p);
+		return ERR_PTR(-EFAULT);
+	}

I think you forgot

         p[len] = '\0';


Sweet lord I need more sleep, my bad.  Thanks,

Josef



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux