Received: by 10.223.164.202 with SMTP id h10csp2733363wrb; Mon, 27 Nov 2017 23:55:36 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ36Mrxdan44P5tfV34cgasdVVw1FWzr7+5oyt0bXS5pEGpW3QxFwuWjf1BopvLYuFC5cEE X-Received: by 10.98.93.92 with SMTP id r89mr40126769pfb.1.1511855736731; Mon, 27 Nov 2017 23:55:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511855736; cv=none; d=google.com; s=arc-20160816; b=DjiU5eKMBNKqnCq61z5oXxYKvoUri0ehto1KRNIrKE1TntjhgC3gW02u7djs3EwS8k 5EFD/AFBkt/hZ+XNY2v4Hg4lh7ZrrEtsqbWbPEasBLeXkm4qhhB/t/u9Ctf9kBGkpnhE 2M0qpcidC+CEGz30tVm8dvizFlujHOwjdmW48nzR4Y47Rxs3JLbViQRbSUTuDKoKBF8t Tg7MKC9aAmaMjrj7IJpCAfju36aeTIAUKiXv4nqOqwKY5FQivwOmUco2Y3dPf4BCUmDU LHku9Enk8ehHhWi100HXf8Nu+t/RE+dMYI9mf9j3sdB39wAJJgA1q01Fnm7LP0gEkOWT dQcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=AuoObDCQ2LY2W0fx7WDjSd1MMEKNLGxDYvOEs7pn76o=; b=XgWqt6wqay9s0pqMrsgyC8jwJdV06cqF7TL/wYLROMoHNBRSpeukkqmezd45OoeVMk sfP9Xel+5wxkQkENi3fSF40TYHE5X7AqQ4sTL9NZPoSZ9CJ0cVcq1gPIT6xtaWQg21WT kTGpFy4StayqbnBvA7hw4tPVy9TVmpOjq5/lSS0tBfuevsOHgfpKV+Cdd+G/SSCwphAg T2rb7cGVXkd/i/ev/+38MytBI6FNoeH7kg1limm0DMMwp+klJH76F2o2X5kYFdbMyL7z g6U1oHkgZbKcjzEm413Q3rIeH3+ZrbGnMHzsMcxd8iNoZOKP9y5VF4mohSZz+C0CmWc7 llSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fI5MxGr4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b193si24396183pga.103.2017.11.27.23.55.25; Mon, 27 Nov 2017 23:55:36 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fI5MxGr4; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752405AbdK1HxL (ORCPT + 78 others); Tue, 28 Nov 2017 02:53:11 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:45457 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752148AbdK1Htd (ORCPT ); Tue, 28 Nov 2017 02:49:33 -0500 Received: by mail-pf0-f196.google.com with SMTP id p62so1807507pfi.12 for ; Mon, 27 Nov 2017 23:49:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AuoObDCQ2LY2W0fx7WDjSd1MMEKNLGxDYvOEs7pn76o=; b=fI5MxGr4ZHJMBkc9CgIL+/osUwfoptSKZWPaEtxi85J2RkWRnenYmS5JiZxVm79q7Q 88xhXKJIUMRv6RJY0erKUyOVHb3gZgWsNQVD+9Z+GQ+RBQBBfz9k8DT6ndtKlJnEetGa TQ7mhjuFYAeDcLhr9CLcG4tNV0QLgz8oZHKWkZ0N13BwpRBZWF8Zord9rjaT8X+mJqS7 aTtgf29I/ZN9MroXMJgPCLFJBbSADm2v8akcRxGx+NbG7F2y2iZKQ9mR1c+EkNeW28ay 40UHpgoT8xmvY+cUoP2iRlAB6wwDyWAdz8KlVJevrxdWwJ3DIMdCHTpQ4T7HORJzxKwc rG4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AuoObDCQ2LY2W0fx7WDjSd1MMEKNLGxDYvOEs7pn76o=; b=XhLfVJQ9Nvp1GyhsE0ZO+Ipo8fBkKZC8ifJ5OtdjRaDJ3jOjKd1QOQbTxSXkdb2ZZy s1IvoBcsCzoy4bOUHBR2xOKQtb+E7cMAzhxluUbYc3Bv+4DA5KX2X9w8WkLxx47WUc77 Y60LuVu/vn40SrIbOQkx2/CvuPBK9o49XxbxbbP6F9Eqo9kJ6Pxok1eBWj46hsN2QTre H1Gs1P3gX7VjZ8yfPJ0ySAOarY+yjVhWH5VD1SJB+qsUcD3cm4EwGDV7BGbJG9HlqXuo QsevnLNUpq0XTIgX/fOMh2A6Gwdu8XTdqmkappkI96VwjLjt2Qaj096m7NTa8TUfrsAc Cs7g== X-Gm-Message-State: AJaThX5uNTYmi423Zm51xNYWthk+x/R3ZTnxwtdEeaUnUulS56ZFpaVz 7E94x3vBjkB/xch3e1xfFyo= X-Received: by 10.101.85.3 with SMTP id f3mr39377359pgr.45.1511855373313; Mon, 27 Nov 2017 23:49:33 -0800 (PST) Received: from localhost.localdomain ([124.56.155.17]) by smtp.gmail.com with ESMTPSA id 67sm39403946pfz.171.2017.11.27.23.49.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Nov 2017 23:49:32 -0800 (PST) From: js1304@gmail.com X-Google-Original-From: iamjoonsoo.kim@lge.com To: Andrew Morton Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Namhyung Kim , Wengang Wang , Joonsoo Kim Subject: [PATCH 04/18] vchecker: prepare per object memory for vchecker Date: Tue, 28 Nov 2017 16:48:39 +0900 Message-Id: <1511855333-3570-5-git-send-email-iamjoonsoo.kim@lge.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511855333-3570-1-git-send-email-iamjoonsoo.kim@lge.com> References: <1511855333-3570-1-git-send-email-iamjoonsoo.kim@lge.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joonsoo Kim To prepare per object memory for vchecker, we need to change the layout of the object when kmem_cache initialization. Add such code on vchecker_cache_create() which is called when kmem_cache initialization. And, this memory should be initialized when object is populated. Do it with another hook. This memory will be used in the following patch. Signed-off-by: Joonsoo Kim --- mm/kasan/vchecker.c | 15 +++++++++++++++ mm/kasan/vchecker.h | 4 ++++ mm/slab.c | 2 ++ mm/slub.c | 2 ++ 4 files changed, 23 insertions(+) diff --git a/mm/kasan/vchecker.c b/mm/kasan/vchecker.c index 0b8a1e7..be0f0cd 100644 --- a/mm/kasan/vchecker.c +++ b/mm/kasan/vchecker.c @@ -31,6 +31,10 @@ enum vchecker_type_num { VCHECKER_TYPE_MAX, }; +struct vchecker_data { + void *dummy; +}; + struct vchecker_type { char *name; const struct file_operations *fops; @@ -109,10 +113,21 @@ static int remove_cbs(struct kmem_cache *s, struct vchecker_type *t) return 0; } +void vchecker_init_slab_obj(struct kmem_cache *s, const void *object) +{ + struct vchecker_data *data; + + data = (void *)object + s->vchecker_cache.data_offset; + __memset(data, 0, sizeof(*data)); +} + void vchecker_cache_create(struct kmem_cache *s, size_t *size, slab_flags_t *flags) { *flags |= SLAB_VCHECKER; + + s->vchecker_cache.data_offset = *size; + *size += sizeof(struct vchecker_data); } void vchecker_kmalloc(struct kmem_cache *s, const void *object, size_t size) diff --git a/mm/kasan/vchecker.h b/mm/kasan/vchecker.h index aa22e8d..efebc63 100644 --- a/mm/kasan/vchecker.h +++ b/mm/kasan/vchecker.h @@ -7,6 +7,7 @@ struct vchecker_cb; struct vchecker_cache { struct vchecker *checker; struct dentry *dir; + int data_offset; }; @@ -18,6 +19,7 @@ int init_vchecker(struct kmem_cache *s); void fini_vchecker(struct kmem_cache *s); void vchecker_cache_create(struct kmem_cache *s, size_t *size, slab_flags_t *flags); +void vchecker_init_slab_obj(struct kmem_cache *s, const void *object); void vchecker_enable_cache(struct kmem_cache *s, bool enable); void vchecker_enable_obj(struct kmem_cache *s, const void *object, size_t size, bool enable); @@ -31,6 +33,8 @@ static inline int init_vchecker(struct kmem_cache *s) { return 0; } static inline void fini_vchecker(struct kmem_cache *s) { } static inline void vchecker_cache_create(struct kmem_cache *s, size_t *size, slab_flags_t *flags) {} +static inline void vchecker_init_slab_obj(struct kmem_cache *s, + const void *object) {} #endif diff --git a/mm/slab.c b/mm/slab.c index ba45c15..64d768b 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -2076,6 +2076,7 @@ int __kmem_cache_create(struct kmem_cache *cachep, slab_flags_t flags) } #endif + vchecker_cache_create(cachep, &size, &flags); kasan_cache_create(cachep, &size, &flags); size = ALIGN(size, cachep->align); @@ -2601,6 +2602,7 @@ static void cache_init_objs(struct kmem_cache *cachep, for (i = 0; i < cachep->num; i++) { objp = index_to_obj(cachep, page, i); + vchecker_init_slab_obj(cachep, objp); kasan_init_slab_obj(cachep, objp); /* constructor could break poison info */ diff --git a/mm/slub.c b/mm/slub.c index 67364cb..c099b33 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1418,6 +1418,7 @@ static void setup_object(struct kmem_cache *s, struct page *page, void *object) { setup_object_debug(s, page, object); + vchecker_init_slab_obj(s, object); kasan_init_slab_obj(s, object); if (unlikely(s->ctor)) { kasan_unpoison_object_data(s, object); @@ -3550,6 +3551,7 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order) size += 2 * sizeof(struct track); #endif + vchecker_cache_create(s, &size, &s->flags); kasan_cache_create(s, &size, &s->flags); #ifdef CONFIG_SLUB_DEBUG if (flags & SLAB_RED_ZONE) { -- 2.7.4 From 1585303134073213152@xxx Tue Nov 28 09:54:42 +0000 2017 X-GM-THRID: 1585265937777289060 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread