Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp756006imm; Thu, 13 Sep 2018 07:17:48 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb1VUzValS19Blguuq07YzdGnpuKRIiKh+KqElyaoiZk/2ED8wUb7lvAc4SLo+uoF/m2IBN X-Received: by 2002:a63:8a41:: with SMTP id y62-v6mr7551712pgd.278.1536848268815; Thu, 13 Sep 2018 07:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536848268; cv=none; d=google.com; s=arc-20160816; b=c4VP23a0k6o/TYFrdXG2e8aNks4CAZ3EGdH1HusnftkrcrD0lv8lI1Av7IqIThUo2R zhH1pjaxMTq/e2gsek8sQ1h3hN0w/8ihfgfU/mh4+92tbP9r5eLvNHfVS89CXMKYo7uY 1QjtNpKTWmu9NBH0DAw01pmV+EwcFAcM7vrVR5hFhpG/yy429EVZguKh6fga/ftgEoyK g0dC5eriIMgtr4XDuXXb6luxdPK1y2qyqWm8YQn1/Nnv9tuewQJBCU7qe4IYf/FWxgd7 05oVokG1kb653OUbMZM4unk77VZcXtsTS8D/CP2TMY9LyPlJb0hj0E4dn3UlYpsJtCUc wSkg== 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=nPs2MbTMyXGTeVKsBjyZDCJBu8QQTWvXrFcAjPZOskQ=; b=Q6PEsCzGrr4AFVAUkA3jbf0D9kNT76EIfJh1h431Y4KwzdfnvPAbZTtlMzJpzGki0e rWr+VRw+HZhUasmmwOM5Kak710DYVMs8r0Mwln2+EwgW2Du2V66SBxe4dFAFVYfrcviF BSIHq9DWwUpcZI26kCeIMYwKSLvyiglcgtyW4tMHYQ2rbFVKmHR+AEbhnhzqu1VogSqo DjZHV1p/J85ek1MAClJ+sqaMQLUAEWE4ZjJ5r5Pr9xZFrXbwYaLXxPX8QL0S14OFVrf+ M4cbuMF8AJ7riVGkrVLXCN8KJRAjP/QMZ/6hpTV1korn4ZQsbZI9uDdK7FwmRioe25gn BHBA== 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 30-v6si4201160pgt.678.2018.09.13.07.17.29; Thu, 13 Sep 2018 07:17: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 S1729870AbeIMSxJ (ORCPT + 99 others); Thu, 13 Sep 2018 14:53:09 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60362 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729312AbeIMSxG (ORCPT ); Thu, 13 Sep 2018 14:53:06 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 664C2D10; Thu, 13 Sep 2018 13:43:33 +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.14 036/115] fs/dcache.c: fix kmemcheck splat at take_dentry_name_snapshot() Date: Thu, 13 Sep 2018 15:30:56 +0200 Message-Id: <20180913131825.924069508@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131823.327472833@linuxfoundation.org> References: <20180913131823.327472833@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.14-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 @@ -291,7 +291,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; }