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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 745CAC021AA for ; Wed, 19 Feb 2025 14:11:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ECB06440165; Wed, 19 Feb 2025 09:11:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E538C440156; Wed, 19 Feb 2025 09:11:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA645440165; Wed, 19 Feb 2025 09:11:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id AAB80440156 for ; Wed, 19 Feb 2025 09:11:14 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 727EC519A0 for ; Wed, 19 Feb 2025 14:10:11 +0000 (UTC) X-FDA: 83136878622.15.A8DEA2F Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf26.hostedemail.com (Postfix) with ESMTP id 2065B140003 for ; Wed, 19 Feb 2025 14:10:07 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=2+NLQTUM; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=R8r0Ax+L; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=2+NLQTUM; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=R8r0Ax+L; spf=pass (imf26.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1739974209; h=from:from:sender:reply-to:subject:subject: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:dkim-signature; bh=j0qvW9Ted+2fuZYC8Zw4Q6pvkin9Y9rXhmhvHhpbsXs=; b=uX0QzaonzhCnbR6nMGMS5z10IpV9cDQyRvgliYco5zYrL+91DETabhZsT8b3ca3ZtWM6d2 9yWEDjcCFfT2l/YHgDXRO72Qdibre2HU4DX4u2c16tuucSxDaIYeGED93u5HHFamwVBaQU ebw6Pzeelk0aWeWlQcKsiVBFeeEI1pc= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=2+NLQTUM; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=R8r0Ax+L; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=2+NLQTUM; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=R8r0Ax+L; spf=pass (imf26.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1739974209; a=rsa-sha256; cv=none; b=SXYz66Az9drE9w0DlzPAqLeV0wjfaQG+HpCbPX5BPkRgjKgnu6/q0JMo92ytJt/1IOaHZO Az4cA8Gm5DAytrjnSZ+LHU1yLEORg23gsH/idTKnxFfTXy6Uwvth0pB/kcNXJqE5TzcxaC fV4bd3fK/9KxkDjZLOxKJoJlrY29Qwo= 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 79275216E6; Wed, 19 Feb 2025 14:10:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1739974206; 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=j0qvW9Ted+2fuZYC8Zw4Q6pvkin9Y9rXhmhvHhpbsXs=; b=2+NLQTUM01xofWCr15NmORqyOX215/vzarmlAKGe1ka94Nc/Kct1uSb9ok6CtuUWQstnhF lKh66iO3AdKVFUMbm3wSK/dBLm5JzJG3y/WMEsGsB+EjsC72i5ScKQqNmDntO/JSD7UXJ/ 37yBUCDXJLCoSCOcLn5X0puWuAkKFiM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1739974206; 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=j0qvW9Ted+2fuZYC8Zw4Q6pvkin9Y9rXhmhvHhpbsXs=; b=R8r0Ax+LaUrZP3ReaJlNwEtlm4J7t7O/NTrEy2g0u+Sga0+lHr40eR5gklYrG+8gour/pj GnrJOO4EAfD/dPCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1739974206; 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=j0qvW9Ted+2fuZYC8Zw4Q6pvkin9Y9rXhmhvHhpbsXs=; b=2+NLQTUM01xofWCr15NmORqyOX215/vzarmlAKGe1ka94Nc/Kct1uSb9ok6CtuUWQstnhF lKh66iO3AdKVFUMbm3wSK/dBLm5JzJG3y/WMEsGsB+EjsC72i5ScKQqNmDntO/JSD7UXJ/ 37yBUCDXJLCoSCOcLn5X0puWuAkKFiM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1739974206; 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=j0qvW9Ted+2fuZYC8Zw4Q6pvkin9Y9rXhmhvHhpbsXs=; b=R8r0Ax+LaUrZP3ReaJlNwEtlm4J7t7O/NTrEy2g0u+Sga0+lHr40eR5gklYrG+8gour/pj GnrJOO4EAfD/dPCQ== 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 526C813715; Wed, 19 Feb 2025 14:10:06 +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 Q0LXEz7mtWdCFwAAD6G6ig (envelope-from ); Wed, 19 Feb 2025 14:10:06 +0000 Message-ID: <9155f04f-74d9-41a3-9690-2ba38b3d79f0@suse.cz> Date: Wed, 19 Feb 2025 15:10:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: How does swsusp work with randomization features? Content-Language: en-US To: Huacai Chen , "Harry (Hyeonggon) Yoo" <42.hyeyoo@gmail.com> Cc: Huacai Chen , Andrew Morton , linux-mm@kvack.org, "Rafael J . Wysocki" , Pavel Machek , linux-pm@vger.kernel.org, GONG Ruiqi , Xiu Jianfeng , stable@vger.kernel.org, Yuli Wang , Christoph Lameter , David Rientjes , Roman Gushchin , Pekka Enberg , Joonsoo Kim , Kees Cook , GONG Ruiqi References: <20250212141648.599661-1-chenhuacai@loongson.cn> From: Vlastimil Babka Autocrypt: addr=vbabka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g++veI6tXfpco/UiKEsDswL1WAr tEAZaruo7254TyH+gydURl2wJuzo/aZ7Y7PpqaODbYv727Dvm5eX64HCyyAH0s6sOCyGF5/p eIhrOn24oBf67KtdAN3H9JoFNUVTYJc1VJU3R1JtVdgwEdr+NEciEfYl0O19VpLE/PZxP4wX PWnhf5WjdoNI1Xec+RcJ5p/pSel0jnvBX8L2cmniYnmI883NhtGZsEWj++wyKiS4NranDFlA HdDM3b4lUth1pTtABKQ1YuTvehj7EfoWD3bv9kuGZGPrAeFNiHPdOT7DaXKeHpW9homgtBxj 8aX/UkSvEGJKUEbFL9cVa5tzyialGkSiZJNkWgeHe+jEcfRT6pJZOJidSCdzvJpbdJmm+eED w9XOLH1IIWh7RURU7G1iOfEfmImFeC3cbbS73LQEFGe1urxvIH5K/7vX+FkNcr9ujwWuPE9b 1C2o4i/yZPLXIVy387EjA6GZMqvQUFuSTs/GeBcv0NjIQi8867H3uLjz+mQy63fAitsDwLmR EP+ylKVEKb0Q2A== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Stat-Signature: fmpw9u7wzczokpdsyuh3dojowx77qqie X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 2065B140003 X-HE-Tag: 1739974207-32658 X-HE-Meta: U2FsdGVkX1/otaSuxGLSRj+F0ANu1k1BPIA+IUtySGa5Iel/vZC+tWz5nVHW/XyvVr4BV3Pg802fyPm8QXtvls+hlBadBTCmeOuaT6OQyyM32ZsPTwDvGiawqe9bKV5TC+XVMjVhcfaezObcSHI24YfHepdJa3urfN8FbipAwdpEWIIsOmhld5H9GNV1RRJg+hqZA/LUqzTed8832nO5n40jbhC4Rcssi/m0Mf1CUELJRnZEnXzlJPrhBtAiFDzrfU/W8leHwlCj5NHsvcdEq9mS0ifI2svqdx6Nbw116YSfRLk5iMNlEaQvsmkmAixVWoNouAEHQeU6LyYrahfJc0r+KaxtXB2KVjS4AlFJ7WD5t412Z5UzxTenfhzi6z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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: List-Subscribe: List-Unsubscribe: On 2/16/25 06:08, Huacai Chen wrote: > On Sat, Feb 15, 2025 at 10:05 PM Harry (Hyeonggon) Yoo > <42.hyeyoo@gmail.com> wrote: >> >> >> You mean when SLAB_FREELIST_RANDOM enabled? >> Assuming that... > Yes. > >> >> > the CPU1's idle task stack from >> > the booting kernel may be the CPU2's idle task stack from the target >> > kernel, and CPU2's idle task stack from the booting kernel may be the >> > CPU1's idle task stack from the target kernel >> The freelist can have more objects than the number of cpus and then it's not just exchanging stacks between cpus but also with whatever else allocates from the same slab. >> What happens if it's not the case? > SLAB means "objects with the same type", right? So it is probably the kmalloc() is not objects of the same type, just size > case. Yes, there is a very very low possibility that not the case, > but... > > In theory x86_64 also has a low possibility that the idle task's stack > or other metadata be overwritten, then should we also disable random > kmalloc for x86_64? Does x86 really have such possibility? Can you explain in more detail? > On the other hand, if we really need to handle this theoretic > possibility about SLAB_FREELIST_RANDOM now, we can simply move > init_freelist_randomization() after all initcalls, too. I think a more robust approach would be to make sure any allocations critical for hibernation/resume are static? Are there really multiple CPU's idle task stacks involved? Aren't the critical paths single cpu only? I'd assume when multiple cpus might be running at that phase, all bets about determinism are off? So there could be a statically allocated stack for the single cpu? Note I don't know much about how hibernation works. But it seems fragile to rely on rather complex allocators (slab over page allocators) to give me exactly the same addresses accross boots, and hack around their randomization features to help with that, if there's an alternative to use static allocations for the critical pieces of the hibernation/resume code. > Huacai > >> >> > but idle task's stack >> > from the booting kernel won't be other things from the target kernel >> > (and won't be overwritten by switching kernel). >> >> What guarantees that it won't be overwritten? >> To me it seems to be a fragile assumption that could be broken. >> >> Am I missing something? >> >> -- >> Harry >