Received: by 10.223.164.202 with SMTP id h10csp2732196wrb; Mon, 27 Nov 2017 23:53:46 -0800 (PST) X-Google-Smtp-Source: AGs4zMajoEueoFhYWoI200PL51J7z6xsS3mpdKUntoemfd6XNnDLo+ELYGAceUMDflNEKhbkJcuu X-Received: by 10.84.168.193 with SMTP id f59mr41062368plb.22.1511855626618; Mon, 27 Nov 2017 23:53:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511855626; cv=none; d=google.com; s=arc-20160816; b=QqXAk4ChV2kBNzvzppXzJo6zxATfV+/xLjmwnpGP0+/i45Xlmw3cYWE5Ri+QLqFITz 9lIAPfW9hzIb494+gqz/NKh2Km0hJZZdVmpvif3ac1J75MDTxSrS/ANDN+XTPgop12uo lEFziYu9ZIqdR8Ip0ahjVNicLxnR/An9rMkdSdtlFyWNnOcz6+Ys/kaW+xHXddgirnCs MHRf88xGICmVq5LN/Vk5RV4XYJCxTLTCQoIjRLsLJllVF86LxWEteBbEHW1gGA1cHNmF YzKqrmPB8DnrtQcB6howP0zKtruyjdo5fakPCARBKWubOvE0zTZ3G/NEcvsiqvL5zgJ6 R4BQ== 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=w6dog6vDhZE+sQRQyUzqVGLOzfpMS9CVvv0dUsd8AeI=; b=PnsDLZ72I+Q49ncevg0sNSoN6xroZRI783laMoz7JZSpAQa5d0BBQ7WA+L9lVDuRNd 6P2jExSN4U0+oH06sCKHxLr3taAaychtpL31xnJJ9OzMInhrO59jFraichAqS/AGXLc4 9vQHAblzlIycEOcgb90ZDU052SymsFeB97ri70PiIUlVeWn4uGPDI3Y0dy+6yrd1VO96 Di7heXJJaYiNqgh9GjH2LMClDPHChO1mxG6bqpQjMZ0DD314enxBwHCzE/wmcfS/JBOH 5ubdfxlwgWsLCMA2w2TeTYzQUY+1oMkvZ0rMKIGfbyJdA4ys8yPc2wUPGTQT16MASYql +o4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Btaqbja8; 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 f16si24218042pgt.658.2017.11.27.23.53.34; Mon, 27 Nov 2017 23:53:46 -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=Btaqbja8; 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 S1752312AbdK1Htx (ORCPT + 78 others); Tue, 28 Nov 2017 02:49:53 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:36868 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752261AbdK1Htu (ORCPT ); Tue, 28 Nov 2017 02:49:50 -0500 Received: by mail-pg0-f66.google.com with SMTP id m4so9992879pgc.4 for ; Mon, 27 Nov 2017 23:49:50 -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=w6dog6vDhZE+sQRQyUzqVGLOzfpMS9CVvv0dUsd8AeI=; b=Btaqbja870cN4FkjXKu7Kmtm7GSsmQthFlY8OSylTRGy1O3lm656hm1NjDdSlqMDIe 9+1NJwFUDcC+nYtJg5+tIhMBgGlTflzCrhWiym6dwcxHdvEv7l8gItm16o13hrzCpAcl r7EZor+nSgl2XNJ7bWmI+QAtsX5sjedKuS5upgubEDjBiuBm5XcXw0p5elu1upm5L3zO rY3hzpgbf5z+0Iewutqn+C1ripWrFGzQqImU7YlVgUzYxJ0Yiv+53cwkMlgUc2fWh7Tj CdauzyLj5mYysPQgISHStDmureExG/7GEmYkx0Q9mIFyWk37U6Rncni1V/4aT7Ie3Qu+ hcBQ== 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=w6dog6vDhZE+sQRQyUzqVGLOzfpMS9CVvv0dUsd8AeI=; b=ardcaKVkfV4DHB7PGQLRqo41aR/rtVFtfFk4n4zzcSkLHdlBgO+0yw/L2XiHkMIXiY 43cdex2wN9GlwsXdRKkU3SEOcPtHuYyNE8C6LeqpJwgZUk6FbnpsGNWC+OxqbTMIgLtg 5YZTvLb0sj0wAhMwe2qQuk1JjB5TywMisTZnlgJ9RTCjQTMM2nanwBQRRXEUj42bkUW7 AEk/k6cYcd4+n4yy+dEfPI+78sL549WVZVp168g+jAF+S4hsKRAJ5QTBpYOheS6E6YyB 7Xm5ob+KIipK4RaXMTPDEslScYPSweE4cg6wV6MjqIoi5sBrG1knXBsSPE7e16jtVAao +T0Q== X-Gm-Message-State: AJaThX4cNGDvyPY3qF5viHRXwmhpUFkeCBNRSagHt1c013wr6SKPSA7U vGpj/d61ooPpIRdwwsAe23M= X-Received: by 10.99.113.91 with SMTP id b27mr39584900pgn.351.1511855390350; Mon, 27 Nov 2017 23:49:50 -0800 (PST) Received: from localhost.localdomain ([124.56.155.17]) by smtp.gmail.com with ESMTPSA id 67sm39403946pfz.171.2017.11.27.23.49.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Nov 2017 23:49:49 -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 09/18] vchecker: Support toggle on/off of callstack check Date: Tue, 28 Nov 2017 16:48:44 +0900 Message-Id: <1511855333-3570-10-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: Namhyung Kim By default, callstack checker only collects callchains. When a user writes 'on' to the callstack file in debugfs, it checks and reports new callstacks. Writing 'off' to disable it again. # cd /sys/kernel/debug/vchecker # echo 0 8 > anon_vma/callstack # echo 1 > anon_vma/enable ... (do some work to collect enough callstacks) ... # echo on > anon_vma/callstack Signed-off-by: Namhyung Kim Signed-off-by: Joonsoo Kim --- mm/kasan/vchecker.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/mm/kasan/vchecker.c b/mm/kasan/vchecker.c index 0c9a4fc..6b3824f 100644 --- a/mm/kasan/vchecker.c +++ b/mm/kasan/vchecker.c @@ -69,6 +69,7 @@ struct vchecker_value_arg { struct vchecker_callstack_arg { depot_stack_handle_t *handles; atomic_t count; + bool enabled; }; static struct dentry *debugfs_root; @@ -698,8 +699,7 @@ static bool check_callstack(struct kmem_cache *s, struct vchecker_cb *cb, if (idx < CALLSTACK_MAX_HANDLE) arg->handles[idx] = handle; - /* TODO: support reporting new callstack */ - return true; + return !arg->enabled; } static int callstack_show(struct seq_file *f, void *v) @@ -712,9 +712,36 @@ static int callstack_open(struct inode *inode, struct file *file) return single_open(file, callstack_show, inode->i_private); } +static void callstack_onoff(struct file *filp, bool enable) +{ + struct kmem_cache *s = file_inode(filp)->i_private; + struct vchecker_cb *cb; + + mutex_lock(&vchecker_meta); + list_for_each_entry(cb, &s->vchecker_cache.checker->cb_list, list) { + if (cb->type == &vchecker_types[VCHECKER_TYPE_CALLSTACK]) { + struct vchecker_callstack_arg *arg = cb->arg; + + arg->enabled = enable; + } + } + mutex_unlock(&vchecker_meta); +} + static ssize_t callstack_write(struct file *filp, const char __user *ubuf, size_t cnt, loff_t *ppos) { + char buf[4]; + + if (copy_from_user(buf, ubuf, 4)) + return -EFAULT; + + /* turn on/off existing callstack checkers */ + if (!strncmp(buf, "on", 2) || !strncmp(buf, "off", 3)) { + callstack_onoff(filp, buf[1] == 'n'); + return cnt; + } + /* add a new (disabled) callstack checker at the given offset */ return vchecker_type_write(filp, ubuf, cnt, ppos, VCHECKER_TYPE_CALLSTACK); -- 2.7.4 From 1585416523952307997@xxx Wed Nov 29 15:56:59 +0000 2017 X-GM-THRID: 1585416523952307997 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread