From patchwork Wed May 2 10:58:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 10375493 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9D73060384 for ; Wed, 2 May 2018 10:58:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D7071FF62 for ; Wed, 2 May 2018 10:58:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81327285DD; Wed, 2 May 2018 10:58:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8026F1FF62 for ; Wed, 2 May 2018 10:58:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3DD016B0005; Wed, 2 May 2018 06:58:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 38BB16B0006; Wed, 2 May 2018 06:58:44 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 27B746B0007; Wed, 2 May 2018 06:58:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id DC0936B0005 for ; Wed, 2 May 2018 06:58:43 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id x23so5246549pfm.7 for ; Wed, 02 May 2018 03:58:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=NLKwBNiqzDbwcDJDP2t1jHU0HtKeeBZtSmxv1RU2KoU=; b=PXwYWr73lfn078taVGqiDIAjT8Ya29JA6q0MJQ6AAmAsnp88YmXNEa8x0UMJU63/Q0 cwpHmW8oKWz/47D/faWsU9arxgREkiWJHVr5Hvw0OpcVGG7hxoc3Mv5weoM8mPC4MsJk /zho/UtKyXnpJUgBL51rG6c9WcfMuYH8MkDeZ/evDs9OVzWjaWKoQbeHYVFnFu7lLX71 8YTMKp0Dl2hjSauqlqDGGJnPD4hsAzqNplcsa6XBupC/hdlhk2pFl9p5bWsSiVqPs9cE hD/uT6a8DOTmCkupRG/ssYxJRF2zwItVd4LPgiWe9GItITvKyy2loOnPhVACsv8pydWs Vbmg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp X-Gm-Message-State: ALQs6tB0l1wMB4+6Qqwm0hQUdKZr2T/evbhvz+B4OZqhO/FlhpNdQVjQ 9ipQQ6xuQZfTBT3FdM9MsxgRHZC4591eBSgRUBcLSV7NwBPc3BkHv1Aq8oM71OYypeYpVzkEaX7 aN6S42iYLYic3+JCl2oDJujzHb2WZ+S8K34NQCj0Th+uT4QIn2KT15nkdgqzdseg3dA== X-Received: by 10.98.133.15 with SMTP id u15mr18815170pfd.160.1525258723487; Wed, 02 May 2018 03:58:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpdIlvUjqZPoNhsD5xuSwXY0es5N0lYb+lWaen2liEsGhBuAaz9xxDaRh4t3/21ACyaTcqa X-Received: by 10.98.133.15 with SMTP id u15mr18815105pfd.160.1525258722217; Wed, 02 May 2018 03:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525258722; cv=none; d=google.com; s=arc-20160816; b=CtpsoHEi2Dr3Quw0/SF4Hav9c6Hs0O8l0cLgqbz1I8aM5tk8/yLsjiFNP+oo+azX69 2MHgedPRAAsj34zvZy84uxf9l9prSw8og0NxAuEue6utxkcK9sj1DRrOavP9PoKPgJM5 aG003gkiffYVA/9QIb7egl/+QsTDnIK1NUURaTneKf7+AWNqh3OcRjyJsTpUhhPxnDZW O5UE9OibDql34i2AfsXsLeIShtJpC0fwQT/cdOUccMMXw7AGZ1FEcNnWdrk05YMwqfz2 l/oFliqJ9CJDuAxlsF4hS2FD6bu6cGKg4Q9WbwPkTabjZKQXOdmwU35J0dQRj0bzTyf6 a+Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=NLKwBNiqzDbwcDJDP2t1jHU0HtKeeBZtSmxv1RU2KoU=; b=EFAGz4AqUxb92ZSyEpYKzkrMLXjvkU12H1X+tUgIWOmZofzgFwfFE2U6iUkz1balwV 6Fi3OXcTZ+v3xrWdH3uA3MtnGCLjhNBWIlsCk0H7BEtacig5sSbGZugZA8iOwZ0tk6wg +HDejNts8BF+MmnT+rFkb2+8zYrA5gLgcdD1JAil/iy15/fkHICef5MVI8dRtAyo1wwC 3zn+s8BPVRWGRqmgNRwbimvN7HptMvqxO5PPc/F4vJhFp/Tar9e/jCkILvD8tTRKu3dV 7G4WntnfDRLvucp+af4QSyrmtH9aP6mCjGwoTEYl1GDb9PlXbQQjxTcYAejYLRsUoR1D +7XQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp Received: from www262.sakura.ne.jp (www262.sakura.ne.jp. [202.181.97.72]) by mx.google.com with ESMTPS id q22-v6si1112783pgc.150.2018.05.02.03.58.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 May 2018 03:58:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) client-ip=202.181.97.72; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp Received: from fsav301.sakura.ne.jp (fsav301.sakura.ne.jp [153.120.85.132]) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w42AwMKM040375; Wed, 2 May 2018 19:58:22 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav301.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav301.sakura.ne.jp); Wed, 02 May 2018 19:58:22 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav301.sakura.ne.jp) Received: from ccsecurity.localdomain (softbank126099184120.bbtec.net [126.99.184.120]) (authenticated bits=0) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id w42AwGWk040359 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 2 May 2018 19:58:22 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) From: Tetsuo Handa To: kasan-dev@googlegroups.com Cc: linux-mm@kvack.org, Tetsuo Handa , Alexander Potapenko , Andrey Konovalov , Andrey Ryabinin , Christoph Lameter , David Rientjes , Dmitry Chernenkov , Dmitry Vyukov , Joonsoo Kim , Konstantin Serebryany , Pekka Enberg , Steven Rostedt Subject: [PATCH] kasan: record timestamp of memory allocation/free Date: Wed, 2 May 2018 19:58:09 +0900 Message-Id: <1525258689-3430-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> X-Mailer: git-send-email 1.8.3.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP syzbot is reporting many refcount/use-after-free bugs along with flood of memory allocation fault injection messages. Showing timestamp of memory allocation/free would help narrowing down kernel messages to examine. Revive timestamp field which was removed by commit cd11016e5f5212c1 ("mm, kasan: stackdepot implementation. Enable stackdepot for SLAB"). Signed-off-by: Tetsuo Handa Cc: Alexander Potapenko Cc: Andrey Ryabinin Cc: Christoph Lameter Cc: Pekka Enberg Cc: David Rientjes Cc: Joonsoo Kim Cc: Andrey Konovalov Cc: Dmitry Vyukov Cc: Steven Rostedt Cc: Konstantin Serebryany Cc: Dmitry Chernenkov --- mm/kasan/kasan.c | 1 + mm/kasan/kasan.h | 1 + mm/kasan/report.c | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c index 135ce28..a336834 100644 --- a/mm/kasan/kasan.c +++ b/mm/kasan/kasan.c @@ -457,6 +457,7 @@ static inline depot_stack_handle_t save_stack(gfp_t flags) static inline void set_track(struct kasan_track *track, gfp_t flags) { track->pid = current->pid; + track->when = jiffies; track->stack = save_stack(flags); } diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h index c12dcfd..0e4951b 100644 --- a/mm/kasan/kasan.h +++ b/mm/kasan/kasan.h @@ -77,6 +77,7 @@ struct kasan_global { struct kasan_track { u32 pid; depot_stack_handle_t stack; + unsigned long when; }; struct kasan_alloc_meta { diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 5c169aa..062c8ae 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -183,7 +183,8 @@ static void kasan_end_report(unsigned long *flags) static void print_track(struct kasan_track *track, const char *prefix) { - pr_err("%s by task %u:\n", prefix, track->pid); + pr_err("%s by task %u (%lu jiffies ago):\n", prefix, track->pid, + jiffies - track->when); if (track->stack) { struct stack_trace trace;