From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 394ADC3F2D1 for ; Wed, 4 Mar 2020 17:26:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0884A24654 for ; Wed, 4 Mar 2020 17:26:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0884A24654 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9330D6B0003; Wed, 4 Mar 2020 12:26:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E48C6B0005; Wed, 4 Mar 2020 12:26:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F9576B0007; Wed, 4 Mar 2020 12:26:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0183.hostedemail.com [216.40.44.183]) by kanga.kvack.org (Postfix) with ESMTP id 668746B0003 for ; Wed, 4 Mar 2020 12:26:39 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 0CEA2181AC9B6 for ; Wed, 4 Mar 2020 17:26:39 +0000 (UTC) X-FDA: 76558359276.11.jail66_7433382e99137 X-HE-Tag: jail66_7433382e99137 X-Filterd-Recvd-Size: 2718 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf08.hostedemail.com (Postfix) with ESMTP for ; Wed, 4 Mar 2020 17:26:38 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id DDBB8AD89; Wed, 4 Mar 2020 17:26:35 +0000 (UTC) Subject: Re: SLUB: sysfs lets root force slab order below required minimum, causing memory corruption To: Kees Cook , David Rientjes Cc: Jann Horn , Christoph Lameter , Pekka Enberg , Joonsoo Kim , Andrew Morton , Linux-MM , kernel list , Matthew Garrett , Vijayanand Jitta References: <202003031820.7A0C4FF302@keescook> From: Vlastimil Babka Message-ID: Date: Wed, 4 Mar 2020 18:26:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <202003031820.7A0C4FF302@keescook> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: On 3/4/20 3:22 AM, Kees Cook wrote: > On Tue, Mar 03, 2020 at 05:26:14PM -0800, David Rientjes wrote: > > Seems reasonable! > > For the race concerns, should this logic just make sure the resulting > order can never shrink? Or does it need much stronger atomicity? If order grows, I think we also need to recalculate the random sequence for freelist randomization [1]. I expect that would be rather problematic with parallel allocations/freeing going on. As was also noted, the any_slab_objects(s) checks are racy - might return false and immediately some other CPU can allocate some. I wonder if this race window could be fixed at all without introducing extra locking in the fast path? Which means it's probably not worth the trouble of having these runtime knobs. How about making the files read-only (if not remove completely). Vijayanand described a use case in [2], shouldn't it be possible to implement that scenario (all caches have debugging enabled except zram cache) with kernel parameters only? Thanks, Vlastimil [1] https://lore.kernel.org/linux-mm/d3acc069-a5c6-f40a-f95c-b546664bc4ee@suse.cz/ [2] https://lore.kernel.org/linux-mm/1383cd32-1ddc-4dac-b5f8-9c42282fa81c@codeaurora.org/