Skip to contentSkip to conversation

vfs: introduce helper function to safely NUL-terminate symlinks

PATCH Superseded Duane Griffin 1 participant 2 messages Dec 16, 2008 VFS

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 vfs: introduce helper function to safely NUL-terminate symlinks

A number of filesystems were potentially triggering kernel bugs due to corrupted symlink names on disk. This helper helps safely terminate the names.

---

Version 4, this time with size_t instead of unsigned. Thanks Al!

 include/linux/namei.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
include/linux/namei.h +5 -0
index 99eb803..231ce28 100644
@@ -94,4 +94,9 @@ static inline char *nd_get_link(struct nameidata *nd)
 	return nd->saved_names[nd->depth];
 }
 
+static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
+{
+	((char *) name)[min(len, maxlen)] = '\0';
+}
+
 #endif /* _LINUX_NAMEI_H */
Signature · 1 line
1.6.0.4
#1 lore raw

PATCH 1/1 vfs: introduce helper function to safely NUL-terminate symlinks

A number of filesystems were potentially triggering kernel bugs due to corrupted symlink names on disk. This helper helps safely terminate the names.

---
 include/linux/namei.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
include/linux/namei.h +5 -0
index 99eb803..231ce28 100644
@@ -94,4 +94,9 @@ static inline char *nd_get_link(struct nameidata *nd)
 	return nd->saved_names[nd->depth];
 }
 
+static inline void nd_terminate_link(void *name, size_t len, size_t maxlen)
+{
+	((char *) name)[min(len, maxlen)] = '\0';
+}
+
 #endif /* _LINUX_NAMEI_H */
Signature · 1 line
1.6.0.4