2008-12-16 16:53:56

by Duane Griffin

[permalink] [raw]
Subject: [PATCH, v4] 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.

Cc: Al Viro <[email protected]>
Cc: Andrew Morton <[email protected]>
Signed-off-by: Duane Griffin <[email protected]>
---

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

include/linux/namei.h | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/include/linux/namei.h b/include/linux/namei.h
index 99eb803..231ce28 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -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 */
--
1.6.0.4


2008-12-16 16:54:18

by Duane Griffin

[permalink] [raw]
Subject: [PATCH] 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.

Cc: Al Viro <[email protected]>
Cc: Andrew Morton <[email protected]>
Signed-off-by: Duane Griffin <[email protected]>
---
include/linux/namei.h | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/include/linux/namei.h b/include/linux/namei.h
index 99eb803..231ce28 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -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 */
--
1.6.0.4

2008-12-19 15:04:14

by Duane Griffin

[permalink] [raw]
Subject: Re: [PATCH] vfs: introduce helper function to safely NUL-terminate symlinks

2008/12/17 Duane Griffin <[email protected]>:
> It is true for sysv, too. The ufs code also, but that has other
> issues, anyway. The generic page symlink and freevxfs patches should
> be fine, though.

Before I fire off another set of patches, should I be sending out the
complete set again or just the ones that need to be updated?

Cheers,
Duane.

--
"I never could learn to drink that blood and call it wine" - Bob Dylan

2008-12-19 19:29:24

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] vfs: introduce helper function to safely NUL-terminate symlinks

On Fri, 19 Dec 2008 15:03:52 +0000
"Duane Griffin" <[email protected]> wrote:

> 2008/12/17 Duane Griffin <[email protected]>:
> > It is true for sysv, too. The ufs code also, but that has other
> > issues, anyway. The generic page symlink and freevxfs patches should
> > be fine, though.
>
> Before I fire off another set of patches, should I be sending out the
> complete set again or just the ones that need to be updated?
>

It's more reliable to resend everything.

2008-12-19 19:43:50

by Al Viro

[permalink] [raw]
Subject: Re: [PATCH] vfs: introduce helper function to safely NUL-terminate symlinks

On Fri, Dec 19, 2008 at 03:03:52PM +0000, Duane Griffin wrote:
> 2008/12/17 Duane Griffin <[email protected]>:
> > It is true for sysv, too. The ufs code also, but that has other
> > issues, anyway. The generic page symlink and freevxfs patches should
> > be fine, though.
>
> Before I fire off another set of patches, should I be sending out the
> complete set again or just the ones that need to be updated?

Complete set, please...