This patch fixes kmemcheck warning in switch_names. The function
switch_names swaps inline names of two dentries. It swaps full arrays
d_iname, no matter how many bytes are really used by the strings. Reading
data beyond string ends results in kmemcheck warning.

We fix the bug by marking both arrays as fully initialized.

Signed-off-by: Mikulas Patocka <mpato...@redhat.com>
Cc: sta...@vger.kernel.org # v3.15

---
 fs/dcache.c |    2 ++
 1 file changed, 2 insertions(+)

Index: linux-2.6/fs/dcache.c
===================================================================
--- linux-2.6.orig/fs/dcache.c  2014-09-04 23:04:21.000000000 +0200
+++ linux-2.6/fs/dcache.c       2014-09-04 23:43:11.000000000 +0200
@@ -2407,6 +2407,8 @@ static void switch_names(struct dentry *
                         */
                        unsigned int i;
                        BUILD_BUG_ON(!IS_ALIGNED(DNAME_INLINE_LEN, 
sizeof(long)));
+                       kmemcheck_mark_initialized(dentry->d_iname, 
DNAME_INLINE_LEN);
+                       kmemcheck_mark_initialized(target->d_iname, 
DNAME_INLINE_LEN);
                        for (i = 0; i < DNAME_INLINE_LEN / sizeof(long); i++) {
                                swap(((long *) &dentry->d_iname)[i],
                                     ((long *) &target->d_iname)[i]);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to