Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp87690pxb; Thu, 30 Sep 2021 01:35:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyH21eejM0YHZ43gTGfoSOe3khfrIj+bUn4k4EavkU1M9HJlgMxAsZmwx9ezCmpbwTO7cDq X-Received: by 2002:a17:906:314e:: with SMTP id e14mr5232897eje.165.1632990915600; Thu, 30 Sep 2021 01:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632990915; cv=none; d=google.com; s=arc-20160816; b=nPd3ODvdboR+FXP4gu6WSUDfsd+ZIvbdIpZRpJejn8eKy3ndpMF1ivP0UzPuih3l7y LqFIMR1/6Y2eb8HBLKyekgOLpcfH+amD6mExf1Ug5nUks6rVxL/QAUnuMAVJYc79SAqe cuTU9LaDQXzu7p4ICuCFRnD0+tnPR+aLxGLQEhXQGQsmDjm5NPIhLZfdmghQoG4a1dIm ITNcHZVN8+1M3ci2VS28Xdi+lPEqdYLQTVYBTySOwmbmNAiPje78Gw77PfiJawIc48ex 7LqionRNjZ38wHlYMJE09Fnd5scS+UIVsvW6kjc2WlToskUKr2yLHKESa639X+5kjwHS QWPg== 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:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature:dkim-signature; bh=N5Thg/LdS+f/OKiGebbx9x8XYiOc+eM0qG2VzPO3ksA=; b=pOLS3Oz+5bV7Ou0x+f0HtOG6F+afb/HNTlAVFUAdF7/LkydoyPwVjOeAU8U9GFhlnn 7KuL9AtrI5STY21a6BBdg8mX9k2hUhu7UiPjpo4qttyDOssNK+mERrakueK1QJMSelBC 5XhP84UErTBHWJpyaXXBZOdy2miX+L7s8I/WP8FqNm1DdJ0ti211E0Av96I+JRYdBZ9W IniNq2b7iqzF4wKpLGBfQCAuKC7C76dH2O73yk5stJRYZgqa7wm7gAKDcMNjIchG7rUg hUH3+SggpBK5dqlFFEHK0jw3YszY9H00VgDW/OgOqWCmpUpcWS6VMvlQWcqwUTvmwhUD jpLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=hrvXjqxl; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t7si3838085edd.36.2021.09.30.01.34.29; Thu, 30 Sep 2021 01:35:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=hrvXjqxl; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348924AbhI3IPZ (ORCPT + 99 others); Thu, 30 Sep 2021 04:15:25 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:39170 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348866AbhI3IPY (ORCPT ); Thu, 30 Sep 2021 04:15:24 -0400 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-out1.suse.de (Postfix) with ESMTPS id 230E522604; Thu, 30 Sep 2021 08:13:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1632989621; 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=N5Thg/LdS+f/OKiGebbx9x8XYiOc+eM0qG2VzPO3ksA=; b=hrvXjqxldUZaVP6V9n8Ne2cJpHPgc53PR5EUoYb3IoavUPBpwGK1vQbl0IQBFJIr7CElyr l00SIPUnq4rWthUOhUoLFBrLbL/49ZhI+w852lCVVzPLkk+6cE9mj/GBxlRByxn3BOPKdr yUO6/O4Zqyst7gHhae3vlaEhx4HSIFw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1632989621; 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=N5Thg/LdS+f/OKiGebbx9x8XYiOc+eM0qG2VzPO3ksA=; b=qW7AxlIsdvqS3QXhaO/Apmfy+pkRmM9UlKBjSJ4/soig/IGHz6HanIdehExw0AJRZarJLz V78KLOOgcJSib3Bg== 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 E5BB0140CC; Thu, 30 Sep 2021 08:13:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id HRZfN7RxVWEdJwAAMHmgww (envelope-from ); Thu, 30 Sep 2021 08:13:40 +0000 Message-ID: <17f537b3-e2eb-5d0a-1465-20f3d3c960e2@suse.cz> Date: Thu, 30 Sep 2021 10:13:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 Content-Language: en-US To: Dave Chinner , Rustam Kovhaev Cc: djwong@kernel.org, linux-xfs@vger.kernel.org, cl@linux.com, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, gregkh@linuxfoundation.org, Al Viro References: <20210929212347.1139666-1-rkovhaev@gmail.com> <20210930044202.GP2361455@dread.disaster.area> From: Vlastimil Babka Subject: Re: [PATCH] xfs: use kmem_cache_free() for kmem_cache objects In-Reply-To: <20210930044202.GP2361455@dread.disaster.area> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/30/21 06:42, Dave Chinner wrote: > On Wed, Sep 29, 2021 at 02:23:47PM -0700, Rustam Kovhaev wrote: >> For kmalloc() allocations SLOB prepends the blocks with a 4-byte header, >> and it puts the size of the allocated blocks in that header. >> Blocks allocated with kmem_cache_alloc() allocations do not have that >> header. >> >> SLOB explodes when you allocate memory with kmem_cache_alloc() and then >> try to free it with kfree() instead of kmem_cache_free(). >> SLOB will assume that there is a header when there is none, read some >> garbage to size variable and corrupt the adjacent objects, which >> eventually leads to hang or panic. >> >> Let's make XFS work with SLOB by using proper free function. >> >> Fixes: 9749fee83f38 ("xfs: enable the xfs_defer mechanism to process extents to free") >> Signed-off-by: Rustam Kovhaev > > IOWs, XFS has been broken on SLOB for over 5 years and nobody > anywhere has noticed. > > And we've just had a discussion where the very best solution was to > use kfree() on kmem_cache_alloc() objects so we didn't ahve to spend > CPU doing global type table lookups or use an extra 8 bytes of > memory per object to track the slab cache just so we could call > kmem_cache_free() with the correct slab cache. > > But, of course, SLOB doesn't allow this and I was really tempted to > solve that by adding a Kconfig "depends on SLAB|SLUB" option so that > we don't have to care about SLOB not working. > > However, as it turns out that XFS on SLOB has already been broken > for so long, maybe we should just not care about SLOB code and > seriously consider just adding a specific dependency on SLAB|SLUB... I think it's fair if something like XFS (not meant for tiny systems AFAIK?) excludes SLOB (meant for tiny systems). Clearly nobody tried to use these two together last 5 years anyway. Maybe we could also just add the 4 bytes to all SLOB objects, declare kfree() is always fine and be done with it. Yes, it will make SLOB footprint somewhat less tiny, but even whan we added kmalloc power of two alignment guarantees, the impact on SLOB was negligible. > Thoughts? > > Cheers, > > Dave. >