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=-3.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 15121C433DF for ; Fri, 5 Jun 2020 21:06:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C81D5207D5 for ; Fri, 5 Jun 2020 21:06:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XXMpqOwr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C81D5207D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 62AC4280001; Fri, 5 Jun 2020 17:06:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B38B8E0006; Fri, 5 Jun 2020 17:06:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47C4D280001; Fri, 5 Jun 2020 17:06:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id 316A38E0006 for ; Fri, 5 Jun 2020 17:06:42 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E22BF8248D51 for ; Fri, 5 Jun 2020 21:06:41 +0000 (UTC) X-FDA: 76896392202.10.ball68_2503bf026da3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id B8BA416A4C1 for ; Fri, 5 Jun 2020 21:06:41 +0000 (UTC) X-HE-Tag: ball68_2503bf026da3 X-Filterd-Recvd-Size: 5164 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Fri, 5 Jun 2020 21:06:41 +0000 (UTC) Received: by mail-pj1-f67.google.com with SMTP id nm22so3157694pjb.4 for ; Fri, 05 Jun 2020 14:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=jTFZ1Ntt0kQNuevlOB6AQQvurETxN1GO4XXrxqpEowE=; b=XXMpqOwrg1ljeko+PJv6zkswcdEPWXabDr5dTWWlyRlic0+6DTvw5i0gF7mWBtLLvi hPOrmw2bfjOlzUV/W33tnshN/uzU8OKT3q+so2ymM85dnPPNFjynBw+abclNukvfnc/N dtkz4tRiS4qIo8O3v7NcDU93Xiw75XOh/xnIo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jTFZ1Ntt0kQNuevlOB6AQQvurETxN1GO4XXrxqpEowE=; b=CEYKKSjhPYBD8bVh1jHT0JLelcT6nIt1GabKz/t2r8eecSNWhvmKyG5t4gbbesU5En E45w7h/1mJN70UvEyZi5g2XS0dDELrqJU/2SD6jWujryfusxAnHCDDZ2aqbm/JmwTOxq lY5XxlzXSBWeROiFC2B2QTrbYHtpptOQNymNFJ+Hy2kWQt1biOXnjvh0RoljUq0BfYUB 1ALyD0e3S2Yp7AAOV9Yy6ucu5ND5Jg3o60yjE/s7g4ochaQw0E0tKahSJslL1AsujW6k gsDjTEDekY5DhFNiFkjikjIGHInsAtpfUS4/Gp827+Jk1vtvxPcpLO+wvsLAAYIpogmf fDBw== X-Gm-Message-State: AOAM533jZ1PiptEOLUa5ni8Na3GIMtQvoaUAcJUg9fGvvmQvAh0UzC7c u28tMhDQnXLCjcmXX4xDrbFWDw== X-Google-Smtp-Source: ABdhPJw9p3+Hn63u4279CMG0IiKsFJJeM4m/W9kT/nl2W8VMXr0TQpj7zoUQQHEP5v/V0lPhv9NCLQ== X-Received: by 2002:a17:90b:108b:: with SMTP id gj11mr5094045pjb.227.1591391200338; Fri, 05 Jun 2020 14:06:40 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g29sm458387pfr.47.2020.06.05.14.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2020 14:06:39 -0700 (PDT) Date: Fri, 5 Jun 2020 14:06:38 -0700 From: Kees Cook To: Vlastimil Babka Cc: Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@android.com, vinmenon@codeaurora.org, Matthew Garrett , Vijayanand Jitta , Jann Horn Subject: Re: [RFC PATCH 2/5] mm, slub: make some slub_debug related attributes read-only Message-ID: <202006051406.CB3237B0@keescook> References: <20200602141519.7099-1-vbabka@suse.cz> <20200602141519.7099-3-vbabka@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200602141519.7099-3-vbabka@suse.cz> X-Rspamd-Queue-Id: B8BA416A4C1 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 Tue, Jun 02, 2020 at 04:15:16PM +0200, Vlastimil Babka wrote: > SLUB_DEBUG creates several files under /sys/kernel/slab// that can be > read to check if the respective debugging options are enabled for given cache. > The options can be also toggled at runtime by writing into the files. Some of > those, namely red_zone, poison, and store_user can be toggled only when no > objects yet exist in the cache. > > Vijayanand reports [1] that there is a problem with freelist randomization if > changing the debugging option's state results in different number of objects > per page, and the random sequence cache needs thus needs to be recomputed. > > However, another problem is that the check for "no objects yet exist in the > cache" is racy, as noted by Jann [2] and fixing that would add overhead or > otherwise complicate the allocation/freeing paths. Thus it would be much > simpler just to remove the runtime toggling support. The documentation > describes it's "In case you forgot to enable debugging on the kernel command > line", but the neccessity of having no objects limits its usefulness anyway for > many caches. > > Vijayanand describes an use case [3] where debugging is enabled for all but > zram caches for memory overhead reasons, and using the runtime toggles was the > only way to achieve such configuration. After the previous patch it's now > possible to do that directly from the kernel boot option, so we can remove the > dangerous runtime toggles by making the /sys attribute files read-only. > > While updating it, also improve the documentation of the debugging /sys files. > > [1] https://lkml.kernel.org/r/1580379523-32272-1-git-send-email-vjitta@codeaurora.org > [2] https://lore.kernel.org/r/CAG48ez31PP--h6_FzVyfJ4H86QYczAFPdxtJHUEEan+7VJETAQ@mail.gmail.com > [3] https://lore.kernel.org/r/1383cd32-1ddc-4dac-b5f8-9c42282fa81c@codeaurora.org > > Reported-by: Vijayanand Jitta > Reported-by: Jann Horn > Signed-off-by: Vlastimil Babka Reviewed-by: Kees Cook -- Kees Cook