From patchwork Tue Feb 3 17:43:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Ryabinin X-Patchwork-Id: 5770591 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 62763BF440 for ; Tue, 3 Feb 2015 17:49:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9CE6820212 for ; Tue, 3 Feb 2015 17:49:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C18EE201EC for ; Tue, 3 Feb 2015 17:49:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966701AbbBCRsg (ORCPT ); Tue, 3 Feb 2015 12:48:36 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:47151 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966420AbbBCRnl (ORCPT ); Tue, 3 Feb 2015 12:43:41 -0500 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout4.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NJ70051SIRGTS60@mailout4.w1.samsung.com>; Tue, 03 Feb 2015 17:47:40 +0000 (GMT) X-AuditID: cbfec7f4-b7f126d000001e9a-b5-54d1083aff07 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id DC.82.07834.A3801D45; Tue, 03 Feb 2015 17:41:14 +0000 (GMT) Received: from localhost.localdomain ([106.109.129.143]) by eusync2.samsung.com (Oracle Communications Messaging Server 7u4-23.01 (7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0NJ700DO6IK39ZB0@eusync2.samsung.com>; Tue, 03 Feb 2015 17:43:39 +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 v11 10/19] fs: dcache: manually unpoison dname after allocation to shut up kasan's reports Date: Tue, 03 Feb 2015 20:43:03 +0300 Message-id: <1422985392-28652-11-git-send-email-a.ryabinin@samsung.com> X-Mailer: git-send-email 2.2.2 In-reply-to: <1422985392-28652-1-git-send-email-a.ryabinin@samsung.com> References: <1404905415-9046-1-git-send-email-a.ryabinin@samsung.com> <1422985392-28652-1-git-send-email-a.ryabinin@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRmVeSWpSXmKPExsVy+t/xK7pWHBdDDBa/07HY9usRm8XvvTNZ LeasX8NmceTad3aL69/eMFp8evmA0eL5w4fsFhMetrFbrOxuZrPY/uwtk8XKzgesFnv2nmSx uLxrDpvFvTX/WS0WH7nNbPHu2WRmi/N/j7Na/NjwmNVByGP+zo+MHjtn3WX3WLCp1GPxnpdM HptWdbJ5bPo0id2j6+0VJo8TM36zeDy5Mp3J4+PTWywefVtWMXp83iTnsenJW6YA3igum5TU nMyy1CJ9uwSujJebrrAWHOCquHt2D1MD4zmOLkZODgkBE4mPZy4xQthiEhfurWcDsYUEljJK 7D2g3MXIBWT3MUkcObaOFSTBJqAn8W/WdrAiEQEFic29z1hBipgFprBKnF7ayQySEBbIkVg4 YTXYVBYBVYkf8/aDNfMKuEt0b5zE1MXIAbRNTuLCx3iQMCdQeF//M0aIZU2MEm8WtzBPYORd wMiwilE0tTS5oDgpPddQrzgxt7g0L10vOT93EyMkJr7sYFx8zOoQowAHoxIP7wqjCyFCrIll xZW5hxglOJiVRHj3/AYK8aYkVlalFuXHF5XmpBYfYmTi4JRqYEyMvN5vu7j5/I22Kfo2xml7 WJY4eYZExkxQs72pevBHcYJ/lvPpnn0L7T7NNKiYdSn4/eGUVb8ZV8d13/q8zazKct6GOVfM vnm//vnhWWBjmprW7rmP69i3JdTtkPJ69eNOtGe+a+aMR2tDL1hW7F27nlVkTvCEhBCxvsK3 vy8c5TirJ2v7/boSS3FGoqEWc1FxIgD4Wn9KZwIAAA== 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 1467ab9..dc400fd 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -38,6 +38,8 @@ #include #include #include +#include + #include "internal.h" #include "mount.h" @@ -1539,6 +1541,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; }