From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752274AbdCWNFq (ORCPT ); Thu, 23 Mar 2017 09:05:46 -0400 Received: from mail-db5eur01on0122.outbound.protection.outlook.com ([104.47.2.122]:53120 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751170AbdCWNFo (ORCPT ); Thu, 23 Mar 2017 09:05:44 -0400 Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=virtuozzo.com; Subject: Re: [PATCH v2] kasan: report only the first error by default To: Mark Rutland References: <20170322160647.32032-1-aryabinin@virtuozzo.com> <20170323114916.29871-1-aryabinin@virtuozzo.com> <20170323124154.GE9287@leverpostej> CC: Andrew Morton , Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , , , From: Andrey Ryabinin Message-ID: Date: Thu, 23 Mar 2017 16:06:59 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170323124154.GE9287@leverpostej> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR09CA0079.eurprd09.prod.outlook.com (10.174.50.151) To VI1PR0801MB2062.eurprd08.prod.outlook.com (10.173.74.147) X-MS-Office365-Filtering-Correlation-Id: 48ef38f0-bbcb-4500-ca9c-08d471ed4eca X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:VI1PR0801MB2062; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB2062;3:XQeWY8Cc4KS+kwmM/9cljifdHG83weZKJMSw4dmjBVi2X+RpPV2t8emAhndjvLQJrLPSPCqmPCP8ZTwuaiMYqtUxMrwCTlJuoGxW2Ol0QpLNUr6vTkD4H8g/vKbna7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e4jR1sX9w5pYlNuo196kMX/h0GFNmB7t9FZTQYBnNtW9LWhwN3u2oKa0TNd1NC5gPcRloKxyYY3T1VP7YYlVDnbkJDq07KfDBIDS1FaOwJJgp+DVjFc3hAaWAcR8HRHY9FCZ/g2/2B9QUS1NXt8C5ncwjt7sOEr2qfVLIQQM+k0I4UVPc+0DUn1eEnP7dtaucu2lH8GI/qFhOAEU1IGJrgUi18ulMGK+3gi5v3NMJggElCGYCrNTCeBeyrxwdR42wIlAJgptfW6amqhZN07Sm5CPTduU8AiXadF9YoF/zrG+JCD5pg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(20558992708506); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123560025)(20161123564025)(20161123562025)(20161123558025)(20161123555025)(6072148);SRVR:VI1PR0801MB2062;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0801MB2062; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB2062;4:rgMKUNeX83woMpN+i+GzC1gbomFTRK34VwvpfCFJQ/H/bIJ+lMP4pMWuQ+9dWAKoLL4vO6a89Ph92MeGrEd448lIUy2sinZQn52DJ2rlYlqstz6VAKvjPkRG6/wNaAGG9iJRnMQqUXkZCHvv1vKqkMenMJfIJJZ/k9RHd1oDNABtBhMZF6bP7OsLHQ612JBTmjTNUQc92RNKM7156lYcHQc5lXYUJeU97Tgg7j7nVlNssorrp3hxLvfizoIFWFmAZxIxlaLpduVPZLmDhftQuBHUSfrjMbsmjoDnrewabf6D180NY3XRidhbH+qMgbwCZQ4QqB1iKZHrXSabgZbHVlQEJmRvlB/iHFGHFIODPexQrwnL+8crgBICtr/25jygjkiVPczXqiRTof8TL1WwRbHLT0LBDlGeZBDmvSKuvS4n8keeHSL5PzkL6fFrGsUMC9jzTRal2aw9l2u03lCyyLfB2RnwEey+WRzmQVyC9aUSsLUVoNwczVgBNoiriUx1vHq3jeDv4f64V1lbDLl8VcJktK4t8Axa134G38BMYYLhNTvkYXMqBGU6xF7ZTfjhg1PUkpLM7IowI3QFZlehguoA6IGQ5QlTYhl57kHkAsNR3KXMswQN7fnact436PrvO5RGhO4OTdGf2unChXZqbw== X-Forefront-PRVS: 0255DF69B9 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6049001)(39450400003)(377454003)(24454002)(54534003)(54906002)(110136004)(4326008)(50466002)(83506001)(6486002)(65956001)(25786009)(77096006)(2906002)(86362001)(6246003)(53936002)(230700001)(90366009)(229853002)(6116002)(38730400002)(31696002)(3846002)(8676002)(53546009)(47776003)(189998001)(50986999)(76176999)(36756003)(33646002)(4001350100001)(7736002)(54356999)(305945005)(23746002)(66066001)(6666003)(6916009)(42186005)(2950100002)(5660300001)(81166006)(31686004);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR0801MB2062;H:[172.16.25.12];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;VI1PR0801MB2062;23:p6QYlF/FIMDCH7m6/SOWRno/ZWUNoylkYAT?= =?Windows-1252?Q?F+tW2o8xhkZkZ/00Fkh7Ydny9bbr0Y/kw2zPnlYP6qLv27APHit1QwRQ?= =?Windows-1252?Q?v0QSOhvElsU7tdR7WCJpWu3jo6RLujAGOVEpWKfaXXheCxdCPSayfGQN?= =?Windows-1252?Q?8K3HyD0A/VWRzCs1nsN3gG+D6sSIekDhAKERzGutfTdIlkyL2STxWO54?= =?Windows-1252?Q?4vTkSS81P3oekRlw9//C09WpCXD23WtZAdQqLEhGQWqsr/XdRZZOtMSz?= =?Windows-1252?Q?y0TeXumEC1SUu7LWh63d0qUc7PD6F+WiL69PGHsSkiD2mdIs5+2/DDFR?= =?Windows-1252?Q?cyL+QMpSqMXf65KCMKP8QeKk/8yAr1R/MrGMUOnZFihelkBSpOKh4sc1?= =?Windows-1252?Q?WPnoYonuixcCOQ5HQJlooqiiHsWXrVjoXFfYjR1t9JYQveGi8kPpJjcl?= =?Windows-1252?Q?L7uewjhNo5gAdk08ASfvaBI8Y3RVO7od1HIgiAQBowuCxs6jIYxnrD6Y?= =?Windows-1252?Q?F15iODkmAaxuYvN7cYvCgDyF5OiG2xMS2iFU/Pibs2SQRtiHCBJQzzui?= =?Windows-1252?Q?D1ijRH7ClLTHdrlZjBQOKa9T1SGuig2g6oBg8JAUazQV/vO5SDyXz0Lw?= =?Windows-1252?Q?tb0be8oITyBgkkkeosPRCl1lGknOSnKHhtzs++UkBjAOBZ+zBTlwAu9O?= =?Windows-1252?Q?rgqlnZ5VITEl5Fb9f1gfxF+VV4z6YDTO/oIqgAC/siDaU4FhvkQHKdnV?= =?Windows-1252?Q?iwMap45wpwwJ1R+TvLU510B1IYaUvUJUQGI0bg0g8YN2mxnwVHniwe+Q?= =?Windows-1252?Q?t1uP93VH4V3eyz/q6fUEZ7QcEekJYlPT6bz+ncj9rz7RKX0dSgVU7Qyy?= =?Windows-1252?Q?jCPPVvMfjTchz5vUKlB1ySQ1eyvJr4A6uAbJYO1tUEGpJykb1/h9Y0uy?= =?Windows-1252?Q?R1iurmyMDk+OKznO/Rv8RoZ4J9/NdgpKZ1NdX9F86JWgcVFxFmxsKmK5?= =?Windows-1252?Q?Wwz8MextkZD7uioWB46y51Ab0o14bInEQxFjwuufsRfL7a9/oWgDhdu/?= =?Windows-1252?Q?/9vzr3wM0PDnC41v2Qo6QjjECJwuH9My5pevKzHc56FaHMG1FfLgxiRu?= =?Windows-1252?Q?EJQKB+9sWmjb4t0aUyuWNINy8N5Oao1cTNFnztc95/QaD9FFpgOdGzXq?= =?Windows-1252?Q?ytWe/Y4wrRYu6b/s10WLnPL/IGcly9blOJvPuHFHO0mRclNuVLzf7prN?= =?Windows-1252?Q?22lBByE1esYln8WlsPD96RsikuHRhYNEtDkfjc1M=3D?= X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB2062;6:ziEAwg+x5Wyg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2rQ==;20:2lIggGJQgyr7nKCZ0JBR/+NAE8YheAhyuDCjlT3lbjhCd7FZ5fF9zG3tf2/z2Rf0wmBDTiYgKTUBLnsLaNR8hknUpb4s1OaoF98UgEHe0okevEBkpESO3IOk6aU1OohdiyVnBDVTOeBB0MJr2fn+UfPv52wo85ZEoSL72NP6hhc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Mar 2017 13:05:40.0366 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB2062 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/23/2017 03:41 PM, Mark Rutland wrote: > On Thu, Mar 23, 2017 at 02:49:16PM +0300, Andrey Ryabinin wrote: >> + kasan_multi_shot >> + [KNL] Enforce KASAN (Kernel Address Sanitizer) to print >> + report on every invalid memory access. Without this >> + parameter KASAN will print report only for the first >> + invalid access. >> + > > The option looks fine to me. > >> static int __init kmalloc_tests_init(void) >> { >> + /* Rise reports limit high enough to see all the following bugs */ >> + atomic_add(100, &kasan_report_count); > >> + >> + /* >> + * kasan is unreliable now, disable reports if >> + * we are in single shot mode >> + */ >> + atomic_sub(100, &kasan_report_count); >> return -EAGAIN; >> } > > ... but these magic numbers look rather messy. > > [...] > >> +atomic_t kasan_report_count = ATOMIC_INIT(1); >> +EXPORT_SYMBOL_GPL(kasan_report_count); >> + >> +static int __init kasan_set_multi_shot(char *str) >> +{ >> + atomic_set(&kasan_report_count, 1000000000); >> + return 1; >> +} >> +__setup("kasan_multi_shot", kasan_set_multi_shot); > > ... likewise. > > Rather than trying to pick an arbitrarily large number, how about we use > separate flags to determine whether we're in multi-shot mode, and > whether a (oneshot) report has been made. > > How about the below? Yes, it deferentially looks better. Can you send a patch with a changelog, or do you want me to care of it? > Thanks, > Mark. > > diff --git a/mm/kasan/report.c b/mm/kasan/report.c > index f479365..f1c5892 100644 > --- a/mm/kasan/report.c > +++ b/mm/kasan/report.c > @@ -13,6 +13,7 @@ > * > */ > > +#include > #include We also need for __setup(). > #include > #include > @@ -293,6 +294,40 @@ static void kasan_report_error(struct kasan_access_info *info) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id BAB7C6B0351 for ; Thu, 23 Mar 2017 09:05:44 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id o126so393161802pfb.2 for ; Thu, 23 Mar 2017 06:05:44 -0700 (PDT) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0129.outbound.protection.outlook.com. [104.47.2.129]) by mx.google.com with ESMTPS id e65si3983024pfg.419.2017.03.23.06.05.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Mar 2017 06:05:43 -0700 (PDT) Subject: Re: [PATCH v2] kasan: report only the first error by default References: <20170322160647.32032-1-aryabinin@virtuozzo.com> <20170323114916.29871-1-aryabinin@virtuozzo.com> <20170323124154.GE9287@leverpostej> From: Andrey Ryabinin Message-ID: Date: Thu, 23 Mar 2017 16:06:59 +0300 MIME-Version: 1.0 In-Reply-To: <20170323124154.GE9287@leverpostej> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Mark Rutland Cc: Andrew Morton , Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org On 03/23/2017 03:41 PM, Mark Rutland wrote: > On Thu, Mar 23, 2017 at 02:49:16PM +0300, Andrey Ryabinin wrote: >> + kasan_multi_shot >> + [KNL] Enforce KASAN (Kernel Address Sanitizer) to print >> + report on every invalid memory access. Without this >> + parameter KASAN will print report only for the first >> + invalid access. >> + > > The option looks fine to me. > >> static int __init kmalloc_tests_init(void) >> { >> + /* Rise reports limit high enough to see all the following bugs */ >> + atomic_add(100, &kasan_report_count); > >> + >> + /* >> + * kasan is unreliable now, disable reports if >> + * we are in single shot mode >> + */ >> + atomic_sub(100, &kasan_report_count); >> return -EAGAIN; >> } > > ... but these magic numbers look rather messy. > > [...] > >> +atomic_t kasan_report_count = ATOMIC_INIT(1); >> +EXPORT_SYMBOL_GPL(kasan_report_count); >> + >> +static int __init kasan_set_multi_shot(char *str) >> +{ >> + atomic_set(&kasan_report_count, 1000000000); >> + return 1; >> +} >> +__setup("kasan_multi_shot", kasan_set_multi_shot); > > ... likewise. > > Rather than trying to pick an arbitrarily large number, how about we use > separate flags to determine whether we're in multi-shot mode, and > whether a (oneshot) report has been made. > > How about the below? Yes, it deferentially looks better. Can you send a patch with a changelog, or do you want me to care of it? > Thanks, > Mark. > > diff --git a/mm/kasan/report.c b/mm/kasan/report.c > index f479365..f1c5892 100644 > --- a/mm/kasan/report.c > +++ b/mm/kasan/report.c > @@ -13,6 +13,7 @@ > * > */ > > +#include > #include We also need for __setup(). > #include > #include > @@ -293,6 +294,40 @@ static void kasan_report_error(struct kasan_access_info *info) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org