Received: by 10.223.164.202 with SMTP id h10csp2737912wrb; Tue, 28 Nov 2017 00:01:49 -0800 (PST) X-Google-Smtp-Source: AGs4zMaelJfzFCYC09FShNU/tV7bJ/VWCNQPxy2FRH5jzAvEjBgQcWfU/7jkPhzFcV0Zy4aCuZBj X-Received: by 10.99.155.9 with SMTP id r9mr13838126pgd.202.1511856109048; Tue, 28 Nov 2017 00:01:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511856109; cv=none; d=google.com; s=arc-20160816; b=D++0Wu2t3OVjN1Zo4AX8twYXWQXq/bkVyxOJc/inAAwRe4FXro+L3lx4wSoUXsRABj MNIHvNvxh91jKQoivL158Qw+kH9mMQBMe+4O0ssiYDX4q8UY9lk5QhTmcB9xrW5gHn0m 4sTQALZ8X4Rbc+zuwsA54cnzPSFFtSApUO2QwFaSkf+uH+/g1fH6y80WAsBPJ9kOcSz2 n6jDvQQpp7IGChL1+6jcX8OjukWTMI+Nd4VKZC5THyu0v/C/QH7Ddy4g4hQTbZiAY51k hRZOM4vrIoMPzNU4vYTWxCVIKeDnFvmD508Ut4kRtK7yyj3Y8KPnBZXUHLos7iTc2CEX fgDg== 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=CCTWoW4ZNnVlvLNgRGvVYn+OOhO1P1lOqxbO9sbD/2U=; b=okTpm+oNuyfMdi1heL+cSGpuvxCSeEHiRye78EWj4cgvwSnCZi03nqoXX0tL7vD/SV mD08DeOnksycSUafFHp6/aidk4TQdj6lv9a6U0wwH+AnO7jwORWueIbHz5DLlv09Kcl5 KmkQAuRCPp3jPCPJA3n1BbGuUI7o/icr89BXucJwmIA+ufDJnKzzzO6/hyfa1Kvuz0yQ E6Xe5pOPEA+ndA3gnAiPOffVxuZ9ixqGsNVXd6nZL8gdopJA/V6leUhFtURQjEUp0cn1 lEdp52rKlNp5JwCpoYnyguidNw53S5mGRWmyXxj1nv5Jt7oJRpK7dd+1LeXeSkuKoiIx Ywvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MjUeQiQJ; 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 k23si18762308pff.141.2017.11.28.00.01.37; Tue, 28 Nov 2017 00:01:48 -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=MjUeQiQJ; 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 S1752374AbdK1HuD (ORCPT + 78 others); Tue, 28 Nov 2017 02:50:03 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:46879 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752324AbdK1HuB (ORCPT ); Tue, 28 Nov 2017 02:50:01 -0500 Received: by mail-pl0-f67.google.com with SMTP id k7so10172466pln.13 for ; Mon, 27 Nov 2017 23:50:00 -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=CCTWoW4ZNnVlvLNgRGvVYn+OOhO1P1lOqxbO9sbD/2U=; b=MjUeQiQJ2yWLUN/fkRYpifD9rvwFCAoO8TPNXsidrQKgw2dxKXgUwGJs5WezdzWPo0 MJ0R+derPHkrLz9jnUlT9B9EWHA/zYyRhaPL1HvSYDi8IEe2w1BHebKn434dZ0GZ3drN 3TfJVtHdlczSFBCgvHaKNFw+y3v1NjGfBaMn4RebscUpp3QbITDW5e0FVzgGkRjzxgcS mDUYfjHNvSOilrpLmzSEbShw29CHITFMboRwjmJ5+rropaVOZD8Q/dJzjqjfLmoV/Osr WAiU0A+s9napn0GLwptsqgxuKo/kvdmzGvbscPK00zOYM1tWP8p7m0eOgD4KdBXZPX0d Ssiw== 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=CCTWoW4ZNnVlvLNgRGvVYn+OOhO1P1lOqxbO9sbD/2U=; b=gvuh9BsyNUwBFaJMxnya5Vzs8/UJtUA+GXTOYmMrJlDBAlRE3a30XIlEHJaKxWfxBI A8WLqiANKHVbEE0YtJWwrbi+t6xdvx8KgUpGiuwzR9eXSauRjBRNRz44rqOtu3GRYCL4 vOoep8bTXIjKT02Zkm7XfsUYy0t6vdAyTRv4k2/LZrRut5EYcjfJKXbYHv0nogrJAmpT zlIccyf35Yh3dTKOjTU8UGquu6EFebKBb4RHTy6Yr6z9VN7V/iw8HKLMAfn9lfgQ2/+3 E5OoNAgqBUnZdkIelCEe07++rmfd/Kkm4sXR2HCPWjR91xiLwfNV3IQ4rC/12nPoQb3E Xi+Q== X-Gm-Message-State: AJaThX6SSHVszJfJYocxBHbnfpOqGzjIgLH9MxQkEjB52P6oV3TMjaoP aSje88hXWaD80aQZDLX4FrU= X-Received: by 10.84.224.206 with SMTP id k14mr41635365pln.403.1511855400623; Mon, 27 Nov 2017 23:50:00 -0800 (PST) Received: from localhost.localdomain ([124.56.155.17]) by smtp.gmail.com with ESMTPSA id 67sm39403946pfz.171.2017.11.27.23.49.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Nov 2017 23:49:59 -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 12/18] vchecker: fix 'remove' handling on callstack checker Date: Tue, 28 Nov 2017 16:48:47 +0900 Message-Id: <1511855333-3570-13-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 Since stack depot library doesn't support removal operation, after removing and adding again callstack cb, callstack checker cannot correctly judge whether this callstack is new or not for current cb if the same callstack happens for previous cb. This problem can be fixed by per-user stack depot since we can create/destroy it when callstack cb is created/destroyed. With that, is_new always shows correct result for current cb. Signed-off-by: Joonsoo Kim --- mm/kasan/vchecker.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/mm/kasan/vchecker.c b/mm/kasan/vchecker.c index dc3a9a7..acead62 100644 --- a/mm/kasan/vchecker.c +++ b/mm/kasan/vchecker.c @@ -68,6 +68,7 @@ struct vchecker_value_arg { #define CALLSTACK_MAX_HANDLE (PAGE_SIZE / sizeof(depot_stack_handle_t)) struct vchecker_callstack_arg { + struct stackdepot *s; depot_stack_handle_t *handles; atomic_t count; bool enabled; @@ -307,8 +308,8 @@ static void filter_vchecker_stacks(struct stack_trace *trace, } } -static noinline depot_stack_handle_t save_stack(unsigned long ret_ip, - bool *is_new) +static noinline depot_stack_handle_t save_stack(struct stackdepot *s, + unsigned long ret_ip, bool *is_new) { unsigned long entries[VCHECKER_STACK_DEPTH]; struct stack_trace trace = { @@ -328,7 +329,7 @@ static noinline depot_stack_handle_t save_stack(unsigned long ret_ip, return 0; filter_vchecker_stacks(&trace, ret_ip); - handle = depot_save_stack(NULL, &trace, __GFP_ATOMIC, is_new); + handle = depot_save_stack(s, &trace, __GFP_ATOMIC, is_new); WARN_ON(!handle); return handle; @@ -570,7 +571,7 @@ static bool check_value(struct kmem_cache *s, struct vchecker_cb *cb, if (!write) goto check; - handle = save_stack(ret_ip, NULL); + handle = save_stack(NULL, ret_ip, NULL); if (!handle) { pr_err("VCHECKER: %s: fail at addr %p\n", __func__, object); dump_stack(); @@ -637,6 +638,14 @@ static int init_callstack(struct kmem_cache *s, struct vchecker_cb *cb, kfree(arg); return -ENOMEM; } + + arg->s = create_stackdepot(); + if (!arg->s) { + free_page((unsigned long)arg->handles); + kfree(arg); + return -ENOMEM; + } + atomic_set(&arg->count, 0); cb->begin = begin; @@ -650,6 +659,7 @@ static void fini_callstack(struct vchecker_cb *cb) { struct vchecker_callstack_arg *arg = cb->arg; + destroy_stackdepot(arg->s); free_page((unsigned long)arg->handles); kfree(arg); } @@ -662,7 +672,7 @@ static void show_callstack_handle(struct seq_file *f, int idx, seq_printf(f, "callstack #%d\n", idx); - depot_fetch_stack(NULL, arg->handles[idx], &trace); + depot_fetch_stack(arg->s, arg->handles[idx], &trace); for (i = 0; i < trace.nr_entries; i++) seq_printf(f, " %pS\n", (void *)trace.entries[i]); @@ -705,7 +715,7 @@ static bool check_callstack(struct kmem_cache *s, struct vchecker_cb *cb, struct vchecker_callstack_arg *arg = cb->arg; int idx; - handle = save_stack(ret_ip, &is_new); + handle = save_stack(arg->s, ret_ip, &is_new); if (!is_new) return true; -- 2.7.4 From 1590379040552481497@xxx Tue Jan 23 10:34:04 +0000 2018 X-GM-THRID: 1586207145591504664 X-Gmail-Labels: Inbox,Category Forums,Downloaded_2018-01