lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9dbf73fe-a459-4956-8dbc-e919d9728f5e@cs-soprasteria.com>
Date: Thu, 22 Aug 2024 05:25:10 +0000
From: LEROY Christophe <christophe.leroy2@...soprasteria.com>
To: Christian Lamparter <christian.lamparter@....uni-stuttgart.de>, Benjamin
 Herrenschmidt <benh@...nel.crashing.org>, Paul Mackerras <paulus@...ba.org>,
	Michael Ellerman <mpe@...erman.id.au>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>, Stan Johnson
	<userm57@...oo.com>, Finn Thain <fthain@...ux-m68k.org>, Christoph Hellwig
	<hch@....de>
Subject: Re: [PATCH v2] powerpc: warn on emulation of dcbz instruction in
 kernel mode

+ CC Christoph Hellwig

Hi,

Le 22/08/2024 à 00:39, Christian Lamparter a écrit :
> [Vous ne recevez pas souvent de courriers de
> christian.lamparter@....uni-stuttgart.de. Découvrez pourquoi ceci est
> important à https://aka.ms/LearnAboutSenderIdentification ]
>
> Sorry to write a reply to this old mail. But after years, I finally
> decided to tackle an "old" problem that has come up...
> And unfortunately it is related to this patch. But let me explain.
>
> On 9/16/21 4:52 PM, Christophe Leroy wrote:
>> dcbz instruction shouldn't be used on non-cached memory. Using
>> it on non-cached memory can result in alignment exception and
>> implies a heavy handling.
>>
>> Instead of silentely emulating the instruction and resulting in high
>> performance degradation, warn whenever an alignment exception is
>> taken in kernel mode due to dcbz, so that the user is made aware that
>> dcbz instruction has been used unexpectedly by the kernel.
>
>
>
> The devices that are affected are APM821xx: MyBook Live, Meraki MX60,
> Netgear WNDR4700, ...
> All these have this "splat" during boot:
>

...

>
> what happens is that the EMAC (ethernet driver) uses a
> dma_alloc_coherent here:


...

> and this results in a call to dma_direct_allocation(), which has one
> innocent looking memset():


memset() can't be used on non-cached memory, memset_io() has to be used
instead.

...

> And of course, this triggers the WARNING above. As for why memset uses
> that dcbz... this is explained in:
...

>
> could this WARN_ON_ONCE maybe be downgraded to a single pr_info_once?
> I don't see how to tackle this "neatly" in a better way.

Can you try with the change below ?

diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 4480a3cd92e0..e2bee5fcc172 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -283,13 +283,15 @@ void *dma_direct_alloc(struct device *dev, size_t
size,
                                __builtin_return_address(0));
                if (!ret)
                        goto out_free_pages;
+
+               memset_io(ret, 0, size);
        } else {
                ret = page_address(page);
                if (dma_set_decrypted(dev, ret, size))
                        goto out_leak_pages;
-       }

-       memset(ret, 0, size);
+               memset(ret, 0, size);
+       }

        if (set_uncached) {
                arch_dma_prep_coherent(page, size);



>
> BugLink:
> <https://github.com/openwrt/openwrt/pull/14037#issuecomment-2302485414>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ