From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161591AbcFGSnm (ORCPT ); Tue, 7 Jun 2016 14:43:42 -0400 Received: from mail-by2on0108.outbound.protection.outlook.com ([207.46.100.108]:32832 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1161118AbcFGSnk (ORCPT ); Tue, 7 Jun 2016 14:43:40 -0400 X-Greylist: delayed 1956 seconds by postgrey-1.27 at vger.kernel.org; Tue, 07 Jun 2016 14:43:40 EDT From: "Luruo, Kuthonuzo" To: Alexander Potapenko CC: Andrey Ryabinin , Dmitriy Vyukov , Christoph Lameter , "penberg@kernel.org" , "rientjes@google.com" , "Joonsoo Kim" , Andrew Morton , kasan-dev , LKML , "ynorov@caviumnetworks.com" Subject: RE: [PATCH v4 2/2] kasan: add double-free tests Thread-Topic: [PATCH v4 2/2] kasan: add double-free tests Thread-Index: AQHRucWS6+IH8piFWk+7iWYwWqWfuZ/eFu8AgABESyA= Date: Tue, 7 Jun 2016 18:10:53 +0000 Message-ID: References: <20160529161707.GA5711@cherokee.in.rdlabs.hpecorp.net> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=kuthonuzo.luruo@hpe.com; x-originating-ip: [106.51.235.33] x-ms-office365-filtering-correlation-id: 038e9fa4-4d5a-40a6-3518-08d38eff106f x-microsoft-exchange-diagnostics: 1;DF4PR84MB0090;5:aqInqcJnPwg3nOnNt1OdnJFRZy8q1BxZBHSi0nib6FZc7tbYYmAU4q3ZAkGCFypjzARhCtwAg3MNJuxtYy100PDAnix7M3KAd17Wjwy4jxL7D7fWH155+fYKm1rf4YjQDCm6uUwtMuTYrBKxlV0CHg==;24:g+xEwg389CMgljfQta/+TIcbC0w4n+9dYLrmVBz/XHNRshW0dh+39N4rajXzXT0ZQMZGEw9GEqUf+mD5TXqshs0p+Y61msjJcS2s1bwJ0SU=;7:NAticjSwUpPxLz7kWu5XhUde8C03ZzgK0vPkO8xSm0qG/G1vba3aVdm9sUHj1Bmd6LKVF3nULqLESInxi8uFYfNynskPKGfAwQBMX74EA1JQYss7uvt2n1Sc0LovsxWphtaqGti0OqFAuERvE0Q8uRoA9Fl9yKFc5AQniRzF+cZjvsNZ4HU+avJ/Sw/MRYRVPQtFzodV/8+/Zkg4CByfAm5/x90Z5xE84Sdqd+JgaVE= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DF4PR84MB0090; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001);SRVR:DF4PR84MB0090;BCL:0;PCL:0;RULEID:;SRVR:DF4PR84MB0090; x-forefront-prvs: 09669DB681 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(189002)(199003)(68736007)(2906002)(189998001)(77096005)(5002640100001)(110136002)(3846002)(102836003)(6116002)(66066001)(586003)(92566002)(54356999)(50986999)(76176999)(97736004)(4326007)(101416001)(2900100001)(87936001)(5003600100002)(10400500002)(2950100001)(106116001)(9456002)(86362001)(9686002)(122556002)(3660700001)(106356001)(81166006)(81156014)(8676002)(3280700002)(105586002)(8936002)(5008740100001)(33656002)(11100500001)(5004730100002)(99286002);DIR:OUT;SFP:1102;SCL:1;SRVR:DF4PR84MB0090;H:DF4PR84MB0089.NAMPRD84.PROD.OUTLOOK.COM;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jun 2016 18:10:53.1806 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: DF4PR84MB0090 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u57Ihk8f000456 > > + int cpu, cnt = num_online_cpus(); > > + cpumask_t mask = { CPU_BITS_NONE }; > > + size_t size = 4097; /* must be <= KMALLOC_MAX_CACHE_SIZE/2 */ > Can you please explicitly calculate |size| from KMALLOC_MAX_CACHE_SIZE? > > + > > + if (cnt == 1) > > + return; > > + cnt = cnt < MAX_THREADS ? cnt : MAX_THREADS; > > + pr_info("concurrent double-free (%d threads)\n", cnt); > > + p = kmalloc(size, GFP_KERNEL); > > + if (!p) > > + return; > > + for_each_online_cpu(cpu) { > > + cpumask_set_cpu(cpu, &mask); > > + if (!--cnt) > > + break; > > + } > > + on_each_cpu_mask(&mask, try_free, p, 0); > > +} > > + > > +static noinline void __init kasan_double_free(void) > > +{ > > + char *p; > > + size_t size = 2049; > Please avoid using magic constants. Alexander, Thanks very much for the review. I've changed alloc size for both to 100 in v5. Kuthonuzo