lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1347137279-17568-5-git-send-email-elezegarcia@gmail.com>
Date:	Sat,  8 Sep 2012 17:47:54 -0300
From:	Ezequiel Garcia <elezegarcia@...il.com>
To:	<linux-kernel@...r.kernel.org>, <linux-mm@...ck.org>
Cc:	Ezequiel Garcia <elezegarcia@...il.com>,
	Pekka Enberg <penberg@...nel.org>
Subject: [PATCH 05/10] mm, util: Use dup_user to duplicate user memory

Previously the strndup_user allocation was being done through memdup_user,
and the caller was wrongly traced as being strndup_user
(the correct trace must report the caller of strndup_user).

This is a common problem: in order to get accurate callsite tracing,
a utils function can't allocate through another utils function,
but instead do the allocation himself (or inlined).

Here we fix this by creating an always inlined dup_user() function to
performed the real allocation and to be used by memdup_user and strndup_user.

Cc: Pekka Enberg <penberg@...nel.org>
Signed-off-by: Ezequiel Garcia <elezegarcia@...il.com>
---
 mm/util.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/mm/util.c b/mm/util.c
index dc3036c..48d3ff8b 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -76,14 +76,14 @@ void *kmemdup(const void *src, size_t len, gfp_t gfp)
 EXPORT_SYMBOL(kmemdup);
 
 /**
- * memdup_user - duplicate memory region from user space
+ * dup_user - duplicate memory region from user space
  *
  * @src: source address in user space
  * @len: number of bytes to copy
  *
  * Returns an ERR_PTR() on failure.
  */
-void *memdup_user(const void __user *src, size_t len)
+static __always_inline void *dup_user(const void __user *src, size_t len)
 {
 	void *p;
 
@@ -103,6 +103,11 @@ void *memdup_user(const void __user *src, size_t len)
 
 	return p;
 }
+
+void *memdup_user(const void __user *src, size_t len)
+{
+	return dup_user(src, len);
+}
 EXPORT_SYMBOL(memdup_user);
 
 static __always_inline void *__do_krealloc(const void *p, size_t new_size,
@@ -214,7 +219,7 @@ char *strndup_user(const char __user *s, long n)
 	if (length > n)
 		return ERR_PTR(-EINVAL);
 
-	p = memdup_user(s, length);
+	p = dup_user(s, length);
 
 	if (IS_ERR(p))
 		return p;
-- 
1.7.8.6

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ