From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D30761AC884 for ; Mon, 14 Oct 2024 14:55:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728917705; cv=none; b=PZq85uTXSit10V0dGW4IPn/IUKIQvsV0+UORLXVcj0fEE9eX4gKsax9AgZMz5tyyiCxcXDXryrcLqNWIekR04Le8WRNFr6AS/xBAQVtKaZl3LY5s9f9u41Djkg+IFt1jwXCUbL9NPrd1aoX/Kh1vzE5yH7B0ilvgYEi0NPLnE7o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728917705; c=relaxed/simple; bh=1j89w/mcbIa859ixmIc+Chf2D395sYVECktWhbhTA10=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Q9odyE0AZI5/PhpUMl3oYCCmt8fY/wwRw0EwHkvWhUrNcPrTcDoMXTlQbchFRxAy4ZtpWx9gm/80eKcsAYrcgPh0P+CGMTcjW1/ub36mS6n24Zs1f88Hay+Dfv+0Ef7a1sAkv3c/gJARMxKf0VuGuMYiLCMyoCWvnaTRwOgGveM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=A8Cd7Hox; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=D2kxP8TM; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=A8Cd7Hox; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=D2kxP8TM; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="A8Cd7Hox"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="D2kxP8TM"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="A8Cd7Hox"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="D2kxP8TM" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0146D21D47; Mon, 14 Oct 2024 14:55:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1728917702; 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:autocrypt:autocrypt; bh=W8u9gbZijSd45DjThUUJz+yJSLX8ITYzCAOg+8vtfF8=; b=A8Cd7HoxtEgUSE4BixmbeprkurMYm9+3Wc6kvNINAZKb04JrAGJNuu5VmZdHBDm+y/3UAd ftrFhdBGM7gb96Cpo+NXvaPxSP1upW6G2ihqw/w/RmFmgXetsBosZ9Bb2cownFSPuvrpa0 lDnwI4FvwNvzfDoLjYI0c94cjtUR1g4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1728917702; 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:autocrypt:autocrypt; bh=W8u9gbZijSd45DjThUUJz+yJSLX8ITYzCAOg+8vtfF8=; b=D2kxP8TMdF6oqs8X6+OwTMJs4zthHhWlfDhlZB8LYetfYLYQtsl+th6MaY+dBz9LChBCpQ GVpSqBygfUI1mpAA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1728917702; 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:autocrypt:autocrypt; bh=W8u9gbZijSd45DjThUUJz+yJSLX8ITYzCAOg+8vtfF8=; b=A8Cd7HoxtEgUSE4BixmbeprkurMYm9+3Wc6kvNINAZKb04JrAGJNuu5VmZdHBDm+y/3UAd ftrFhdBGM7gb96Cpo+NXvaPxSP1upW6G2ihqw/w/RmFmgXetsBosZ9Bb2cownFSPuvrpa0 lDnwI4FvwNvzfDoLjYI0c94cjtUR1g4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1728917702; 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:autocrypt:autocrypt; bh=W8u9gbZijSd45DjThUUJz+yJSLX8ITYzCAOg+8vtfF8=; b=D2kxP8TMdF6oqs8X6+OwTMJs4zthHhWlfDhlZB8LYetfYLYQtsl+th6MaY+dBz9LChBCpQ GVpSqBygfUI1mpAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D84CE13A42; Mon, 14 Oct 2024 14:55:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id NMEFNMUwDWcscAAAD6G6ig (envelope-from ); Mon, 14 Oct 2024 14:55:01 +0000 Message-ID: <7726cccb-78f8-4696-ac7e-57598c35576d@suse.cz> Date: Mon, 14 Oct 2024 16:55:01 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] mm/slub: Avoid list corruption when removing a slab from the full list Content-Language: en-US To: David Rientjes , "yuan.gao" Cc: "Christoph Lameter (Ampere)" , penberg@kernel.org, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20241011102020.58087-1-yuan.gao@ucloud.cn> <572f7473-1781-388b-103e-d4382f58f2f9@google.com> From: Vlastimil Babka Autocrypt: addr=vbabka@suse.cz; keydata= xsFNBFZdmxYBEADsw/SiUSjB0dM+vSh95UkgcHjzEVBlby/Fg+g42O7LAEkCYXi/vvq31JTB KxRWDHX0R2tgpFDXHnzZcQywawu8eSq0LxzxFNYMvtB7sV1pxYwej2qx9B75qW2plBs+7+YB 87tMFA+u+L4Z5xAzIimfLD5EKC56kJ1CsXlM8S/LHcmdD9Ctkn3trYDNnat0eoAcfPIP2OZ+ 9oe9IF/R28zmh0ifLXyJQQz5ofdj4bPf8ecEW0rhcqHfTD8k4yK0xxt3xW+6Exqp9n9bydiy tcSAw/TahjW6yrA+6JhSBv1v2tIm+itQc073zjSX8OFL51qQVzRFr7H2UQG33lw2QrvHRXqD Ot7ViKam7v0Ho9wEWiQOOZlHItOOXFphWb2yq3nzrKe45oWoSgkxKb97MVsQ+q2SYjJRBBH4 8qKhphADYxkIP6yut/eaj9ImvRUZZRi0DTc8xfnvHGTjKbJzC2xpFcY0DQbZzuws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itsDwLmR EP+ylKVEKb0Q2A== In-Reply-To: <572f7473-1781-388b-103e-d4382f58f2f9@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_SEVEN(0.00)[10]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; TAGGED_RCPT(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_MATCH_FROM(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[gentwo.org,kernel.org,lge.com,linux-foundation.org,linux.dev,gmail.com,kvack.org,vger.kernel.org]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo] X-Spam-Flag: NO X-Spam-Level: On 10/13/24 22:46, David Rientjes wrote: > On Sat, 12 Oct 2024, yuan.gao wrote: > >> On 24/10/11 11:07AM, Christoph Lameter (Ampere) wrote: >> > On Fri, 11 Oct 2024, yuan.gao wrote: >> > >> > > When an object belonging to the slab got freed later, the remove_full() >> > > function is called. Because the slab is neither on the partial list nor >> > > on the full list, it eventually lead to a list corruption. >> > >> > We detect list poison.... >> > >> > > diff --git a/mm/slab.h b/mm/slab.h >> > > index 6c6fe6d630ce..7681e71d9a13 100644 >> > > --- a/mm/slab.h >> > > +++ b/mm/slab.h >> > > @@ -73,6 +73,10 @@ struct slab { >> > > struct { >> > > unsigned inuse:16; >> > > unsigned objects:15; >> > > + /* >> > > + * Reuse frozen bit for slab with debug enabled: >> > >> > "If slab debugging is enabled then the frozen bit can bereused to >> > indicate that the slab was corrupted" >> > >> > > index 5b832512044e..b9265e9f11aa 100644 >> > > --- a/mm/slub.c >> > > +++ b/mm/slub.c >> > > @@ -1423,6 +1423,11 @@ static int check_slab(struct kmem_cache *s, struct slab *slab) >> > > slab->inuse, slab->objects); >> > > return 0; >> > > } >> > > + if (slab->frozen) { >> > > + slab_err(s, slab, "Corrupted slab"); >> > >> > >> > "Slab folio disabled due to metadata corruption" ? >> > >> > >> >> Yes, that's what I meant. >> Perhaps I should change the description from "Corrupted slab" to >> "Metadata corrupt"? >> > > I think the point here is that slab page corruption is different from slab > metadata corruption :) > > The suggested phrasing, "Slab folio disabled due to metadata corruption", > sounds good to me. What about: "Slab disabled due to previous consistency check failure" ? > >> > > @@ -2744,7 +2750,10 @@ static void *alloc_single_from_partial(struct kmem_cache *s, >> > > slab->inuse++; >> > > >> > > if (!alloc_debug_processing(s, slab, object, orig_size)) { >> > > - remove_partial(n, slab); >> > > + if (folio_test_slab(slab_folio(slab))) { Your patch adds add_full() here as in the previous versions. I wouldn't do it anymore. Thanks to the frozen bit check in check_slab(), no further list manipulation should happen that would trigger the list poison being detected. Adding to full list would rather mean each sysfs-triggered validation will reach the slab and output the new slab_err() message, which is not useful. We want the corrupted slab to stay away from everything else, and only be informed of further object freeing attempts. >> > >> > >> > Does folio_test_slab test for the frozen bit?? >> > >> >> For slab folios, slab->fronzen has been set to 1. >> For non-slab folios, we should not call remove_partial(). >> I'm not sure if I understand this correctly. >> >> Thanks >>