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 3892DC47DD9 for ; Fri, 22 Mar 2024 10:03:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BAF426B0082; Fri, 22 Mar 2024 06:03:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B5F146B0083; Fri, 22 Mar 2024 06:03:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A26456B0087; Fri, 22 Mar 2024 06:03:07 -0400 (EDT) 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 94B096B0082 for ; Fri, 22 Mar 2024 06:03:07 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 45ADB8166F for ; Fri, 22 Mar 2024 10:03:07 +0000 (UTC) X-FDA: 81924236814.04.A8CE5BC Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by imf19.hostedemail.com (Postfix) with ESMTP id 3EE251A000D for ; Fri, 22 Mar 2024 10:03:04 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Ib4JzvsU; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (imf19.hostedemail.com: domain of mingo.kernel.org@gmail.com designates 209.85.128.47 as permitted sender) smtp.mailfrom=mingo.kernel.org@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711101785; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DcwNtDxsn4iutaQGAJ+vxh8SXtvPdgtKbGJ3VpVPuo0=; b=5m5DBqzoRrXWuEEOHHeaUsWWuUOMkYSjnGpQv+uIRDmC8bxOydKy8iNRTCTBCBYBm1uVIJ AKRJBAq0XDs934MN6zGy53vcU31MAcUkx2UxReitjYApTjHtknd5F6CuJU42qPfv0xeU49 v/TL7Xz4wED77XZtX/QY5jzf8xczSiU= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Ib4JzvsU; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=kernel.org (policy=none); spf=pass (imf19.hostedemail.com: domain of mingo.kernel.org@gmail.com designates 209.85.128.47 as permitted sender) smtp.mailfrom=mingo.kernel.org@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711101785; a=rsa-sha256; cv=none; b=NNF/9azjDPVr3MsegwY1yE4F/zbKKqN7+mIubi9Ql9xVmcbWdDmjdcCwiLURME/6FyilVp CUGW31Lr2XnfmQO5G/TSWYGSI6E3i5snIESYhIQUi0E9TfEnt800uTHncGmv6neJyvBOWN UySd1BiMwpRNofNz04gCZQUD5HLqI/4= Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4147d09eb8aso1811155e9.1 for ; Fri, 22 Mar 2024 03:03:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711101784; x=1711706584; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=DcwNtDxsn4iutaQGAJ+vxh8SXtvPdgtKbGJ3VpVPuo0=; b=Ib4JzvsUGqF7utro4+tP+OqNaSoJLxpvN1jv1rvkiVC7iIY40Q4dwuIz4TYn9Kp8Id tRVuC4dckDAeRtTE1npsfA1vVruk1Of3lkOL54A1dKxI5dpA+jMhxukSPkopENEY+GQi k3wccHOTBYuNjRqvKIfQVEKF1RNQGjxIKEas77JMK7uo6XOAEUwykrzkNEI0F1QnwRsq kubfz9Vul1H1Jm40hdJGcNLiW+CbLP76t4qcLtVDqmnt/Y4xhEB+YxjllBv6UyxqRCjy L0pJKNe1qjc1uXX9fsgs8MK4LURtGTfRMgBuxJcgSaPrIdP4phCbxpJq9fbgYs2CkugF 5ODw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711101784; x=1711706584; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DcwNtDxsn4iutaQGAJ+vxh8SXtvPdgtKbGJ3VpVPuo0=; b=ibmqUTJcfmLB5GBiN1Tai/tTu4rRJ2H7XwJ0ppzkUb+lVYQ12Bn9KHmgFVVhY3j9e2 09O0O2BZpfGGmqm3r1RB5xaleD791vbGOVeV4XiNVMSRFTjrLIEgkphMDZgtbVtJasn7 Dxc6IA0yazEITUvcCWNTFreY8AY2ygVk0KC+calOOsUBNV345mai/MueXZr+eTetSASL kvuC1dokkrStTHw2wK2oAUbwhVtX4chhusQwb0TS2ToxjsyFe4K0VIHI2WN9q+ZMwG0Z jhwbUrnqt/HvZPk+WtC3NXMldPaODA//Ifkc1yKzsHlVRGXSh1heYGXvZmhh42zHk/c3 8UhA== X-Forwarded-Encrypted: i=1; AJvYcCUeQkn8vtRFLV+QcGDAw24AUWPnfonRRkSjFu0+eUamTIhbGNR5pWrU8eJIkZcwkX8zlxhTE55DH5647775v7desqI= X-Gm-Message-State: AOJu0Yya2aTnlhe5XgESDNcF+pDcOg8xJ0e4C4IQXJoQ0e4ynsQJy4YA jtb1mhYALgOPd35VkeguIuuFIk8tG58pTGu58pTgKWUuD9peO3e2 X-Google-Smtp-Source: AGHT+IE2ICqUa/rZAmBl7E/hfsVmtG+zHnF5G3wg6d4I4m2ox/W1hTACC7I2VKaC/5R6C4CsFBXSlg== X-Received: by 2002:a05:6000:e92:b0:33e:c7e3:b1bb with SMTP id dz18-20020a0560000e9200b0033ec7e3b1bbmr1139362wrb.16.1711101783349; Fri, 22 Mar 2024 03:03:03 -0700 (PDT) Received: from gmail.com (1F2EF04C.nat.pool.telekom.hu. [31.46.240.76]) by smtp.gmail.com with ESMTPSA id w17-20020adfcd11000000b0033e786abf84sm1695832wrm.54.2024.03.22.03.03.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 03:03:02 -0700 (PDT) Date: Fri, 22 Mar 2024 11:03:00 +0100 From: Ingo Molnar To: Anton Altaparmakov Cc: Dave Hansen , "Rafael J . Wysocki" , Pavel Machek , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "x86@kernel.org" , "H . Peter Anvin" , Chen Yu , Pawan Gupta , Catalin Marinas , Linux Memory Management , "Rafael J . Wysocki" , "linux-pm@vger.kernel.org" , Linux Kernel , "stable@vger.kernel.org" Subject: Re: [PATCH] x86/pm: Fix false positive kmemleak report in msr_build_context(). Message-ID: References: <20240314142656.17699-1-anton@tuxera.com> <70261e2a-b87e-462e-964e-95a51ecde978@intel.com> <653BCAC0-8A79-400F-B496-23A2FA169786@tuxera.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <653BCAC0-8A79-400F-B496-23A2FA169786@tuxera.com> X-Rspamd-Queue-Id: 3EE251A000D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: mdrqodfzccdzg7giuorf3kmgfiijpqw8 X-HE-Tag: 1711101784-445993 X-HE-Meta: U2FsdGVkX19JyqK+GBzIWf1AUhKaTBInpzalpRZP8REoJnadrgk3qwG5vUNtImj/X4bp8N338nieYPwDk7WGfXK89z4Pu1SmTgvZ7sd/qYa77Ans6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EMCdwMM72/Ke+cZfzB9nN0zGXwadUVIF3f8ct+1cmX/ztFi+2+WG0JVRhs/lFGll1z85bzjllDzfpMrabXQZ24yzH6bl3ZkRlBmcD34TqXfFXr2R4nRV8oR6R5+ZKBu9afHDxRtu/HGeXKxsNEjRDR8h7/A6VD1zf+FBANkhmvF5+YJdSVgnKiuHtyLeuixbPezml20jl4asec7nTfYp6qfLRR9OF3PeUj6HE94jmjC0+HPFhALcEY3nzkqaRuPp4DEl5qAiJtlrtmXub23broxyKQweKsp2NSigb8Kk2Im75rP+VMYs6zqDye+v7/Qxt/ofP8j9aZNP72u0T7htymO8RUKN4LoQT4qMFtrfPsB0Bb55gEMVehzDIFIMcelaX7lEsoxGVVxII6Ii/PNu+7rpgZDlCR+5N+Xy2kLeERlR5JDDmtF45i+Yqf0RcoicihLVsSc2Bn93/hXPagLYcAEf6BVdCX18k9cf+U4lVCsnFg== 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: List-Subscribe: List-Unsubscribe: * Anton Altaparmakov wrote: > Hi Dave, > > > On 14 Mar 2024, at 15:05, Dave Hansen wrote: > > > > On 3/14/24 07:26, Anton Altaparmakov wrote: > >> /* image of the saved processor state */ > >> struct saved_context { > >> - /* > >> - * On x86_32, all segment registers except gs are saved at kernel > >> - * entry in pt_regs. > >> - */ > >> - u16 gs; > >> unsigned long cr0, cr2, cr3, cr4; > >> u64 misc_enable; > >> struct saved_msrs saved_msrs; > >> @@ -27,6 +22,11 @@ struct saved_context { > >> unsigned long tr; > >> unsigned long safety; > >> unsigned long return_address; > >> + /* > >> + * On x86_32, all segment registers except gs are saved at kernel > >> + * entry in pt_regs. > >> + */ > >> + u16 gs; > >> bool misc_enable_saved; > >> } __attribute__((packed)); > > > > Isn't this just kinda poking at the symptoms? This seems to be > > basically the exact same bug as b0b592cf08, just with a different source > > of unaligned structure members. > > Yes, that is exactly the same bug. That's how we figured out the solution in fact - it is totally the same problem with another struct member... > > > There's nothing to keep folks from reintroducing these kinds of issues > > and evidently no way to detect when they happen without lengthy reproducers. > > Correct. But short of adding asserts / documentation that pointers must be aligned or kmemleak won't work or fixing kmemleak (which I expect is not tractical as it would become a lot slower if nothing else) not sure what else can be done. > > Given I cannot see any alternative to fixing the kmemleak failures I think it is worth applying this fix. > > Unless you have better ideas how to fix this issue? > > What I can say is that we run a lot of tests with our CI and applying > this fix we do not see any kmemleak issues any more whilst without it we > see hundreds of the above - from a single, simple test run consisting of > 416 individual test cases on kernel 5.10 x86 with kmemleak enabled we got > 20 failures due to this which is quite a lot. With this fix applied we > get zero kmemleak related failures. I turned this tidbit into the following paragraph in the commit: Testing: We run a lot of tests with our CI, and after applying this fix we do not see any kmemleak issues any more whilst without it we see hundreds of the above report. From a single, simple test run consisting of 416 individual test cases on kernel 5.10 x86 with kmemleak enabled we got 20 failures due to this, which is quite a lot. With this fix applied we get zero kmemleak related failures. Describing the impact of a fix in a changelog is always helpful. Thanks, Ingo