Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4726471ybf; Wed, 4 Mar 2020 09:27:08 -0800 (PST) X-Google-Smtp-Source: ADFU+vvXtaGj7/6/gXIC8byQ8Fh6+AD6p8HwqmtgUTuL88A9B3A1rS8x8/0YiBExLiRh55vlMgif X-Received: by 2002:a9d:ec7:: with SMTP id 65mr3322876otj.309.1583342828033; Wed, 04 Mar 2020 09:27:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583342828; cv=none; d=google.com; s=arc-20160816; b=KoiTSpnpdg/2O0UK5568ePbSMzPVGYzr6RqzgsFxfug72waRL4WAhLvFXf7eII6yXo hosurjEV/QXdfL/Ex0bIuj0e+3FasSHV6hxzS+hjXV/s5KMF6PaaN4jsa2ySLpjRAvaJ I2M3urTnMK9MZcCMu3yWDAXf91s0iXLUAGuKqib+n/3dM6b2DLfjMl/AIBhe+QsVLJG0 i/KYN/jpqQlKHVK28ceFi6sd8XlwyH/lMilcAKQkg4mD0IoWdegd++ujZYWHijrI8ycN AyQi9ppt8Xme+XkEUJu2BoVaFSgP2FJaL63FNfSAJ8p1uoAXodfAe5runQVQnxSnjybQ xfHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=CFwUxnp66AarZpwd13/jJhMXUZ1fFKQriRS/jYTatNs=; b=TJW9QugmDAlfxRodcMzkAazQMFO/OI6syE4ZuTeLcP/x9ePylcrNvu2l0HksA9JB8e zoSfDrqkk8sXQopZWqP68AbHMd2uZEDgNuqr7n7C10Y8nSGqtMkZ+3VV9w3SlH9czgpe LoZZBgjQsTgZRIQnMmLuArXgAXi//4ZCyxu2KfClZ3eJKr2kGxMwuG3uvGTszLAhjCLk 1vCMJ/BvJh9ZsnPAZYfdIsy14Tr0nNJZ586NRisoi0d2A1cU2pyU4BsztKu3WuU/fwBk GjzMiBX7tTf5zb+2oVYC8Joxe0xUE4lDIRlQtKvwXVCcd3EkELMzXquXfLFBBPSHlmht GkDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v81si1662059oia.114.2020.03.04.09.26.56; Wed, 04 Mar 2020 09:27:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729823AbgCDR0i (ORCPT + 99 others); Wed, 4 Mar 2020 12:26:38 -0500 Received: from mx2.suse.de ([195.135.220.15]:44324 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726561AbgCDR0i (ORCPT ); Wed, 4 Mar 2020 12:26:38 -0500 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/