Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933177AbcLMN7P (ORCPT ); Tue, 13 Dec 2016 08:59:15 -0500 Received: from mail-db5eur01on0094.outbound.protection.outlook.com ([104.47.2.94]:15514 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932254AbcLMN7N (ORCPT ); Tue, 13 Dec 2016 08:59:13 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=aryabinin@virtuozzo.com; Subject: Re: [PATCH v2] kasan: Support for r/w instrumentation control To: Dmitry Vyukov References: <1481608665-26941-1-git-send-email-maninder1.s@samsung.com> <6cc0eadc-5204-ce36-f5e8-88ba76bb6826@virtuozzo.com> CC: Maninder Singh , Alexander Potapenko , Jonathan Corbet , Michal Marek , Andrew Morton , kasan-dev , , LKML , "open list:KERNEL BUILD + fi..." , PANKAJ MISHRA , Ajeet Kumar Yadav , Vaneet narang From: Andrey Ryabinin Message-ID: Date: Tue, 13 Dec 2016 16:59:37 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.10] X-ClientProxiedBy: HE1PR0101CA0018.eurprd01.prod.exchangelabs.com (10.168.141.156) To VI1PR0801MB2064.eurprd08.prod.outlook.com (10.173.74.149) X-MS-Office365-Filtering-Correlation-Id: d450d51e-26d3-4841-ceba-08d423603554 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:VI1PR0801MB2064; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB2064;3:FAg9ymIhVR5NDAoQGgHn6fTyT+kSWUrZNhYTkvK1vDVUV9+hk4+GBAYO4hHLlsXpgGpFKLAZdvBiqh1MnBLhTa8duktJ53ZHstxRoNYfBMhUyl2StILw8HJL5lmg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Q5bMAhv0GOL+w4v/b0Um+TVXXXxujvnZtIAnO4dGEhCn80GqrXGZX04YlYyeGWKYJeyXeKRcxqPVyZnWgn2UconSs6Te3Jt8kVwhkrzXY1kveNclKUpYCVxewxhjLD04/WOwQU062rjfOVDpWKaLRtpSbPltXVO6wiqGNHHvsn0o/33IgwKAPmy0IZ0+K/u7iF7XWMqz/u0XOxYQevZSOTc5mtyrl+YjdhkSqp/ZOuRZVuGiS7/5mYiLVRPA==;20:/htmRkQxosudTQEBp7VBFZOfR108Y5iA/LzGvMhcaLZ6hZMtiWV21yxRyQuFGtA4j94oZ9Gv7QEnkyyrzUcpOHavI88MXYFZpS959gDDqFL/6KGBPKgl4XaV1CwPeTFUYpPZVtF7b7xLvYriyTaDtXgdZQCv5KH8uigggZ2OGcquPdbizQKVoKtyjh3MvMeyjTxdkAAA7bYMXhoqai7gjYvHAXrQCXanDr8ts6wV1E5204Ow1R2KKOPktwD5xZ43 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123555025)(20161123560025)(20161123564025)(20161123562025)(6072148);SRVR:VI1PR0801MB2064;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0801MB2064; X-Microsoft-Exchange-Diagnostics: 1;VI1PR0801MB2064;4:V0YbZPXs4DdqZlwSo4HMQhSw5eoW/z0rkfNNFEZCr3H74eZIy8bOnJS293F6yBDJM80GSAdby9NsnsjVUkzZ2HSWiiqD0x+EE8INwPvsSFThHpNOCegNoWBS6OZ3yWPuJAAVD01YHBUO870OcRhlclpzOrBYWVi2lwSsmcOhKa/yLQogVPUDwQpy/16ergbeVcUdtooS0l1mkvXopQ7w8A798VoTP7b+dXCfRbRlovUa+3BX+5xbDm/tJOjklAu49WGFIieoQka7VlYogoP2V6IWYFRHD1ZN/kOixg770dJgh/ih+fmbZ2JO6wlsrS+qYt0FXHuZI4bsSJGf1mSz6bZT5AbH+jrtzGf7mNcvFfPpezNGlCI2IPdcMqUIavxcpP0lpLp0kupH27BtPXX6myWrRoZdJtB/6xlzBdEjafYjdrRMIBrbRRWbaRGcmt3VqO8z1qCviLGxRrzTFfq8VgTtV1rL+HvBWNLkVShyEKwxnzZggfsWjwCP6peWJ6pByV7BzXD0xV0Lw92mr5QVR4jJJ74nQKwxhj+JmNc5wNa4yxHLwiUfY4dw3tBFt4rKv861nDpx514iOSSOGvw0Xw== X-Forefront-PRVS: 01559F388D X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(4630300001)(6009001)(6049001)(7916002)(39450400003)(189002)(24454002)(199003)(377454003)(7416002)(68736007)(8676002)(93886004)(31696002)(7736002)(81166006)(81156014)(50466002)(33646002)(6916009)(65826007)(2950100002)(305945005)(229853002)(38730400001)(6486002)(5660300001)(110136003)(6666003)(77096006)(230700001)(90366009)(83506001)(54356999)(3846002)(76176999)(64126003)(4001350100001)(97736004)(50986999)(86362001)(65806001)(47776003)(4326007)(65956001)(66066001)(101416001)(42186005)(31686004)(36756003)(106356001)(105586002)(23676002)(6116002)(92566002)(2906002)(189998001);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR0801MB2064;H:[10.30.19.223];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtWSTFQUjA4MDFNQjIwNjQ7MjM6SnZVRGhURWVJWFBiNkpEME13OWJtR1lS?= =?utf-8?B?MDg5YlV2bHZFUWRrNGFLMmh6ZDhMNVo1RTlVWVZBdFBRaDlrbnlWWEJpQnpv?= =?utf-8?B?Q0dLdGd5ZWpobDFwRkVVZDc2VUVWNC85UEdKdHRaRnFpZUNGMHVab3VuejNV?= =?utf-8?B?akNwS0lqblNrcERENGtlMktsMkowS2VER01sS3BBRGtMT2hudHBqNndrSDBN?= =?utf-8?B?U1JZTnRqQm9SWi9VTDgyMWh3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ig8hJGy5PY+sNz51vHSUs3Z5kr+Wnykr/eSf9iMl4xWr6BVU+uXiyGuk4vvMnRjH88PrDvSZPdneCS8NcGDFf8n31vsg6iuhvJmMltz9x6pP6q8uY7XBSWSLyyLM+7vTYI0Q3x8JKPcygtT32EeD2og= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2016 13:59:06.7451 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0801MB2064 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1701 Lines: 42 On 12/13/2016 12:38 PM, Dmitry Vyukov wrote: > On Tue, Dec 13, 2016 at 10:20 AM, Andrey Ryabinin > wrote: >> >> >> On 12/13/2016 11:58 AM, Dmitry Vyukov wrote: >> >>> --- a/Documentation/dev-tools/kasan.rst >>> +++ b/Documentation/dev-tools/kasan.rst >>> @@ -40,6 +40,14 @@ similar to the following to the respective kernel Makefile: >>> >>> KASAN_SANITIZE := n >>> >>> +Sometimes it may be useful to disable instrumentation of reads, or writes >>> +or both for the entire kernel. For example, if binary size is a concern, >>> +it may be useful to disable instrumentation of reads to reduce binary size but >>> +still catch more harmful bugs on writes. Or, if one is interested only in >>> +sanitization of a particular module and performance is a concern, she can >>> +disable instrumentation of both reads and writes for kernel code. >>> +Instrumentation can be disabled with CONFIG_KASAN_READS and >>> CONFIG_KASAN_WRITES. >>> + >> >> I don't understand this. How this can be related to modules? Configs are global. >> You can't just disable/enable config per module. > > > Build everything without instrumentation. Then enable instrumentation > and do "make lib/test_kasan.ko". > Or build everything, copy out bzImage, change config, build everything again. Yeah, this is soooooo convenient... Seriously speaking, per-file instrumentation is absolutely irrelevant to this patch and should have been addressed from a different angle. E.g. see how UBSAN/GCOV/KCOV do that. As for this patch, I'd say only one option would be enough - KASAN_DONT_SANITIZE_READS. Nobody wants to sanitize only reads without writes, right? Writes are fewer and more dangerous.