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] [day] [month] [year] [list]
Message-ID: <8DA842BD-929D-4CB2-88D8-405F33C9B559@zytor.com>
Date: Wed, 11 Jun 2025 15:56:17 -0700
From: "H. Peter Anvin" <hpa@...or.com>
To: Dave Hansen <dave.hansen@...el.com>, Em Sharnoff <sharnoff@...n.tech>,
        linux-kernel@...r.kernel.org, x86@...nel.org, linux-mm@...ck.org
CC: Ingo Molnar <mingo@...nel.org>, Dave Hansen <dave.hansen@...ux.intel.com>,
        Andy Lutomirski <luto@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>, Borislav Petkov <bp@...en8.de>,
        "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>,
        Oleg Vasilev <oleg@...n.tech>, Arthur Petukhovsky <arthur@...n.tech>,
        Stefan Radig <stefan@...n.tech>, Misha Sakhnov <misha@...n.tech>
Subject: Re: [PATCH v3 1/2] x86/mm: Handle alloc failure in phys_*_init()

On June 10, 2025 7:55:36 AM PDT, Dave Hansen <dave.hansen@...el.com> wrote:
>On 6/10/25 03:16, Em Sharnoff wrote:
>> +		if (!pmd)
>> +			return (unsigned long)ERR_PTR(-ENOMEM);
>
>All of this casting isn't great to look at. Just about every line of
>code that this patch touches also introduces has a cast.
>
>Could you please find a way to reduce the number of casts?
>
>> +		/*
>> +		 * We might have IS_ERR(paddr_last) if allocation failed, but we should
>> +		 * still update pud before bailing, so that subsequent retries can pick
>> +		 * up on progress (here and in phys_pmd_init) without leaking pmd.
>> +		 */
>
>Please write everything in imperative voice. No "we's", please.
>
>> -	for (i = 0; i < nr_range; i++)
>> +	for (i = 0; i < nr_range; i++) {
>>  		ret = kernel_physical_mapping_init(mr[i].start, mr[i].end,
>>  						   mr[i].page_size_mask,
>>  						   prot);
>> +		if (IS_ERR((void *)ret))
>> +			return ret;
>> +	}
>
>Are there any _actual_ users of 'paddr_last'? I see a lot of setting it
>and passing it around, but I _think_ this is the only place it actually
>gets used. Here, the fact that it's an address doesn't even matter.
>
>

Given that ERR_PTR and IS_ERR are basically just casts to and from pointers, why have them at all?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ