Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp727080imm; Thu, 13 Sep 2018 06:54:48 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZKEkoNBBBCXQlzY9eFbeorNFou7ijGuw/X/t7Ik8Z9T9SXI9qL3xn0oLDNWhjBoIXQiqOM X-Received: by 2002:a62:2f84:: with SMTP id v126-v6mr7638130pfv.115.1536846888826; Thu, 13 Sep 2018 06:54:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846888; cv=none; d=google.com; s=arc-20160816; b=yOGMHy1bz7QVR3NeDW0pu2jivEbdP8GfOkx49nc2Scfi/R9aTWBkELIebFGsWztLL0 fHNbLW70cbbnIA0bESXmCPrhVZ/sdentFqTo8OYHoSCJA/L2Hrv96X/cptmpEkte+L5X u689W7YExA3+zwKcAZkcyjfQ8eHq+A4ABw61LbkxpxVpbUZIFyswJNuPA+Xa35Gq41Ng cwJsZcVcqx+4rbKyCOhAEfJbCVb+g1jSCCAxmpPu5M7p8U8GZI8rSByzkjHk8eGIaEgM G/CB6GXHdKf5kyuRZLQBbEXmNcwOQpiPuLoW/o72MxlKXNMLpIcTPH1NwLdTe+i5fNJf 7AXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=5pZbErS+yJesUH8U93gKmBs6eiNRoW1Miwjxuu1egjk=; b=V3VsFkYt5hNVXHQ4ZR+qacnqvJlpkDynJcuphCJaczOcGpmRBkQSdTj/CeWQNM787C 7rtnudz2uOL+XLqyh7BwnaodFchOKHi+x9TB/u9qvFN5rGMNrx8ceY+5EWxUnvuhZnBr KUBFDjq5jjlNnpGRjzZ+zTN2WXZytG2NZsP6cKWIR8J4MZNxJ+I7sc0UIDToa5z79pwU z7gAYmwlbT7QIVLJ6UWehHdKRGlzt5vQdhgk6cDf6SjVzDmiVUenc+mmX5nNOD8hw9v+ +9NLD1vjT7glYdseTftOqouIB6QkfaDONb+xlEf79w4ASsXD7OzV3tMkDcDa1fGMdlSo R6nw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d7-v6si3521975pls.136.2018.09.13.06.54.33; Thu, 13 Sep 2018 06:54:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730836AbeIMTEE (ORCPT + 99 others); Thu, 13 Sep 2018 15:04:04 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33824 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727644AbeIMTED (ORCPT ); Thu, 13 Sep 2018 15:04:03 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 98EFED1A; Thu, 13 Sep 2018 13:54:27 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , Vegard Nossum , Al Viro , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.18 061/197] fs/dcache.c: fix kmemcheck splat at take_dentry_name_snapshot() Date: Thu, 13 Sep 2018 15:30:10 +0200 Message-Id: <20180913131843.962998773@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tetsuo Handa [ Upstream commit 6cd00a01f0c1ae6a852b09c59b8dd55cc6c35d1d ] Since only dentry->d_name.len + 1 bytes out of DNAME_INLINE_LEN bytes are initialized at __d_alloc(), we can't copy the whole size unconditionally. WARNING: kmemcheck: Caught 32-bit read from uninitialized memory (ffff8fa27465ac50) 636f6e66696766732e746d70000000000010000000000000020000000188ffff i i i i i i i i i i i i i u u u u u u u u u u i i i i i u u u u ^ RIP: 0010:take_dentry_name_snapshot+0x28/0x50 RSP: 0018:ffffa83000f5bdf8 EFLAGS: 00010246 RAX: 0000000000000020 RBX: ffff8fa274b20550 RCX: 0000000000000002 RDX: ffffa83000f5be40 RSI: ffff8fa27465ac50 RDI: ffffa83000f5be60 RBP: ffffa83000f5bdf8 R08: ffffa83000f5be48 R09: 0000000000000001 R10: ffff8fa27465ac00 R11: ffff8fa27465acc0 R12: ffff8fa27465ac00 R13: ffff8fa27465acc0 R14: 0000000000000000 R15: 0000000000000000 FS: 00007f79737ac8c0(0000) GS:ffffffff8fc30000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffff8fa274c0b000 CR3: 0000000134aa7002 CR4: 00000000000606f0 take_dentry_name_snapshot+0x28/0x50 vfs_rename+0x128/0x870 SyS_rename+0x3b2/0x3d0 entry_SYSCALL_64_fastpath+0x1a/0xa4 0xffffffffffffffff Link: http://lkml.kernel.org/r/201709131912.GBG39012.QMJLOVFSFFOOtH@I-love.SAKURA.ne.jp Signed-off-by: Tetsuo Handa Cc: Vegard Nossum Cc: Al Viro Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/dcache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/dcache.c +++ b/fs/dcache.c @@ -292,7 +292,8 @@ void take_dentry_name_snapshot(struct na spin_unlock(&dentry->d_lock); name->name = p->name; } else { - memcpy(name->inline_name, dentry->d_iname, DNAME_INLINE_LEN); + memcpy(name->inline_name, dentry->d_iname, + dentry->d_name.len + 1); spin_unlock(&dentry->d_lock); name->name = name->inline_name; }