Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp334449rwi; Fri, 14 Oct 2022 02:43:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5MnjLl/SlfKBQ2ZpHDhxk85N4kmhagcPPZ3NxoKkAZT1V80P6y593W6D9YVt4d+mTXTg33 X-Received: by 2002:a17:907:7627:b0:78d:b6f5:9f15 with SMTP id jy7-20020a170907762700b0078db6f59f15mr2960848ejc.149.1665740605727; Fri, 14 Oct 2022 02:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665740605; cv=none; d=google.com; s=arc-20160816; b=yGqfOU69VwPy4QXPhKfle6TvCzy5Zufruv0pK+kIIcq/MAklOxtZrBMSqTQe8VlaPd +Bs4j/MEJYoTwvUHWiH2vH3HE29IOALAmZoRoERR7fF7MnXTvSXf4GSj61OROJdNBf0U DSrfKF9d/pxuUwOd6fwfbtvXiGvsfkg75ExlI5AnJVug9qTX2Xq0sVMs4XswefhmYS6g FaO2mo9nnPb8ysba4HHgbZDw3RizLwrYDNbXTeIZMzaW7sqM0wwpxhEXJFQLADlYZVoU i85aSKtH6oQP45sBExJFBJy+WNNjI7ofktJiFMNufb9ehmrfEcofZWTxBM4Mv20Goh0D 64GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=Z0VGtJ9Ga07XYW6RtddW9XEl9eF9thFhwKrYGC9xYqU=; b=ecl/NiJ/PmWHCtpPl8LZAhWVz0YcwJDDW1GnVhTXO9LZBsfCHD5TbBDaSTXXesdmFW XBqxQFJAOINAD4hdlv3UW2PIQWftwl/Sd4nHQExrr76kucPQRbgf942vhLEdZoQJE9/g +1e/Fo3rtICVKc0pNSOVj80KXiirb034AEt2HxPxXK6KZVoDr21AQa2HyT4NlFFfK91z 9b+K2wxpF1Ijwnx96lyy1TqTAReHsp59IyZ21rpeJR8RIEl2zJVEoZg4KyxeRq7UXAM4 iUfsTHT/QAbtEIxyx29ZNnRU4QW154V+TO/KU+LrmzUgvoByLBkA+b6j/IppNcI/mHuA efFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=FgW3g6NE; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a13-20020a50ff0d000000b0045c9904fdafsi1757777edu.74.2022.10.14.02.43.00; Fri, 14 Oct 2022 02:43:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=FgW3g6NE; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229803AbiJNIws (ORCPT + 99 others); Fri, 14 Oct 2022 04:52:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230101AbiJNIwY (ORCPT ); Fri, 14 Oct 2022 04:52:24 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A73D51C9384; Fri, 14 Oct 2022 01:51:48 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B9FD91F74A; Fri, 14 Oct 2022 08:51:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1665737506; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z0VGtJ9Ga07XYW6RtddW9XEl9eF9thFhwKrYGC9xYqU=; b=FgW3g6NEfPtOkVnlFccCNTIrRzixQUE2DOsUwGRoi9uqm4EwT31zzJlTo0MUlsolrFfPOB tTKyOfva/SQdFbKXYyu1MXIMJQedtZV+A4LWksKjz6jqjvmiU4PZuY7qSLIJ+1ouO8cpzk 3+PfG/W5BBdQBtWvbB/bYRiVzc6EHBA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1665737506; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z0VGtJ9Ga07XYW6RtddW9XEl9eF9thFhwKrYGC9xYqU=; b=V4zn5GhyabVgTunDoDFFROObFcUfUPovZLMIV2Yw7bhMou+dUy2IbmBMTWQCoYzdieLwbH ilCoTsLixeQkqWCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 720EC13451; Fri, 14 Oct 2022 08:51:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id XHIBGyIjSWMVCwAAMHmgww (envelope-from ); Fri, 14 Oct 2022 08:51:46 +0000 Message-ID: Date: Fri, 14 Oct 2022 10:51:46 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH v2] mm: Make failslab writable again Content-Language: en-US To: Alexander Atanasov , Jonathan Corbet , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: kernel@openvz.org, Kees Cook , Roman Gushchin , Jann Horn , Vijayanand Jitta , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20220920121111.1792905-1-alexander.atanasov@virtuozzo.com> From: Vlastimil Babka In-Reply-To: <20220920121111.1792905-1-alexander.atanasov@virtuozzo.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/20/22 14:11, Alexander Atanasov wrote: > In (060807f841ac mm, slub: make remaining slub_debug related attributes > read-only) failslab was made read-only. > I think it became a collateral victim to the two other options for which > the reasons are perfectly valid. > Here is why: > - sanity_checks and trace are slab internal debug options, > failslab is used for fault injection. > - for fault injections, which by presumption are random, it > does not matter if it is not set atomically. And you need to > set atleast one more option to trigger fault injection. > - in a testing scenario you may need to change it at runtime > example: module loading - you test all allocations limited > by the space option. Then you move to test only your module's > own slabs. > - when set by command line flags it effectively disables all > cache merges. > > Cc: Vlastimil Babka > Cc: Andrew Morton > Cc: Kees Cook > Cc: Roman Gushchin > Cc: Christoph Lameter > Cc: Jann Horn > Cc: Vijayanand Jitta > Cc: David Rientjes > Cc: Joonsoo Kim > Cc: Pekka Enberg > Link: http://lkml.kernel.org/r/20200610163135.17364-5-vbabka@suse.cz > > Signed-off-by: Alexander Atanasov Thanks, added to slab.git for-6.2/slub-sysfs > --- > Documentation/mm/slub.rst | 2 ++ > mm/slub.c | 16 +++++++++++++++- > 2 files changed, 17 insertions(+), 1 deletion(-) > > V1->V2: Fixed commit message. Flags are set using WRITE_ONCE. > > diff --git a/Documentation/mm/slub.rst b/Documentation/mm/slub.rst > index 43063ade737a..86837073a39e 100644 > --- a/Documentation/mm/slub.rst > +++ b/Documentation/mm/slub.rst > @@ -116,6 +116,8 @@ options from the ``slub_debug`` parameter translate to the following files:: > T trace > A failslab > > +failslab file is writable, so writing 1 or 0 will enable or disable > +the option at runtime. Write returns -EINVAL if cache is an alias. > Careful with tracing: It may spew out lots of information and never stop if > used on the wrong slab. > > diff --git a/mm/slub.c b/mm/slub.c > index 862dbd9af4f5..57cf18936526 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -5617,7 +5617,21 @@ static ssize_t failslab_show(struct kmem_cache *s, char *buf) > { > return sysfs_emit(buf, "%d\n", !!(s->flags & SLAB_FAILSLAB)); > } > -SLAB_ATTR_RO(failslab); > + > +static ssize_t failslab_store(struct kmem_cache *s, const char *buf, > + size_t length) > +{ > + if (s->refcount > 1) > + return -EINVAL; > + > + if (buf[0] == '1') > + WRITE_ONCE(s->flags, s->flags | SLAB_FAILSLAB); > + else > + WRITE_ONCE(s->flags, s->flags & ~SLAB_FAILSLAB); > + > + return length; > +} > +SLAB_ATTR(failslab); > #endif > > static ssize_t shrink_show(struct kmem_cache *s, char *buf) > > base-commit: 80e78fcce86de0288793a0ef0f6acf37656ee4cf