From patchwork Wed Jan 21 16:51:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 5679371 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A76D79F4DC for ; Wed, 21 Jan 2015 16:55:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D444420462 for ; Wed, 21 Jan 2015 16:55:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E55912045A for ; Wed, 21 Jan 2015 16:55:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754770AbbAUQzm (ORCPT ); Wed, 21 Jan 2015 11:55:42 -0500 Received: from mailout3.w1.samsung.com ([210.118.77.13]:41010 "EHLO mailout3.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754043AbbAUQwZ (ORCPT ); Wed, 21 Jan 2015 11:52:25 -0500 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NIJ00IN1DPXSMA0@mailout3.w1.samsung.com>; Wed, 21 Jan 2015 16:56:22 +0000 (GMT) X-AuditID: cbfec7f5-b7fc86d0000066b7-96-54bfd8b08b95 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id A0.1E.26295.0B8DFB45; Wed, 21 Jan 2015 16:49:52 +0000 (GMT) Received: from localhost.localdomain ([106.109.129.143]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NIJ003CDDIAO480@eusync3.samsung.com>; Wed, 21 Jan 2015 16:52:13 +0000 (GMT) From: Andrey Ryabinin To: linux-kernel@vger.kernel.org Cc: Andrey Ryabinin , Dmitry Vyukov , Konstantin Serebryany , Dmitry Chernenkov , Andrey Konovalov , Yuri Gribov , Konstantin Khlebnikov , Sasha Levin , Christoph Lameter , Joonsoo Kim , Andrew Morton , Dave Hansen , Andi Kleen , x86@kernel.org, linux-mm@kvack.org, Alexander Viro , linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS...)) Subject: [PATCH v9 08/17] fs: dcache: manually unpoison dname after allocation to shut up kasan's reports Date: Wed, 21 Jan 2015 19:51:36 +0300 Message-id: <1421859105-25253-9-git-send-email-a.ryabinin@samsung.com> X-Mailer: git-send-email 2.2.1 In-reply-to: <1421859105-25253-1-git-send-email-a.ryabinin@samsung.com> References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1421859105-25253-1-git-send-email-a.ryabinin@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRmVeSWpSXmKPExsVy+t/xq7obbuwPMbh73tJi269HbBa/985k tZizfg2bxZFr39ktrn97w2jx6eUDRovnDx+yW0x42MZusbK7mc1i+7O3TBYrOx+wWuzZe5LF 4vKuOWwW99b8Z7VYfOQ2s8W7Z5OZLc7/Pc5q8WPDY1YHIY/5Oz8yeuycdZfdY8GmUo/Fe14y eWxa1cnmsenTJHaPrrdXmDxOzPjN4vHkynQmj49Pb7F49G1ZxejxeZOcx6Ynb5kCeKO4bFJS czLLUov07RK4MnbNuMFUcICrYvq3TtYGxnMcXYycHBICJhL3/+1jhrDFJC7cW88GYgsJLGWU ePcnuYuRC8juY5LYe3IfO0iCTUBP4t+s7WBFIgIKEpt7n7GCFDELTGGVOL20E2ySsEC2xP6V 7WA2i4CqxP/d15hAbF4BN4mVj9+wQ2yTk9h4ZwUriM0p4C4x8/xEJohtTYwSn49sZ5vAyLuA kWEVo2hqaXJBcVJ6rpFecWJucWleul5yfu4mRkhUfN3BuPSY1SFGAQ5GJR5eCZ/9IUKsiWXF lbmHGCU4mJVEeOdfBwrxpiRWVqUW5ccXleakFh9iZOLglGpg5E+YKvF89+Qts568kV2+Iydq yYld1wye2e64XHCi2+nh93WcL5ZXGRmE/GLZ0Mi8s8c3+7XLylD78IXlJ0WT+XMOPbrbNNUm Qevo9BOHNi/w4FH52SuydP+ZfIHsd9FTmPpeLuZ/7DOr/l6e8pTut+4WLcKyVbs+XJt2UuXi r/2Hfrspz75yok2JpTgj0VCLuag4EQAXr/8LaAIAAA== Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to manually unpoison rounded up allocation size for dname to avoid kasan's reports in dentry_string_cmp(). When CONFIG_DCACHE_WORD_ACCESS=y dentry_string_cmp may access few bytes beyound requested in kmalloc() size. dentry_string_cmp() relates on that fact that dentry allocated using kmalloc and kmalloc internally round up allocation size. So this is not a bug, but this makes kasan to complain about such accesses. To avoid such reports we mark rounded up allocation size in shadow as accessible. Reported-by: Dmitry Vyukov Signed-off-by: Andrey Ryabinin --- fs/dcache.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/dcache.c b/fs/dcache.c index e368d4f..3c097f9 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -38,6 +38,8 @@ #include #include #include +#include + #include "internal.h" #include "mount.h" @@ -1430,6 +1432,9 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name) } atomic_set(&p->u.count, 1); dname = p->name; + if (IS_ENABLED(CONFIG_DCACHE_WORD_ACCESS)) + kasan_unpoison_shadow(dname, + round_up(name->len + 1, sizeof(unsigned long))); } else { dname = dentry->d_iname; }