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
| ||
|
Message-ID: <ef53ce07-6d7e-efbd-0301-4984297c0f5b@suse.com> Date: Mon, 27 Mar 2023 07:44:30 +0200 From: Juergen Gross <jgross@...e.com> To: Borislav Petkov <bp@...en8.de> Cc: linux-kernel@...r.kernel.org, x86@...nel.org, Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, Dave Hansen <dave.hansen@...ux.intel.com>, "H. Peter Anvin" <hpa@...or.com> Subject: Re: [PATCH v4 07/12] x86/mtrr: allocate mtrr_value array dynamically On 27.03.23 00:05, Borislav Petkov wrote: > On Mon, Mar 06, 2023 at 05:34:20PM +0100, Juergen Gross wrote: >> The mtrr_value[] array is a static variable, which is used only in a >> few configurations. Consuming 6kB is ridiculous for this case, > > Ah, that struct mtrr_value is of size 24 due to that first member > mtrr_type getting padded even if it is a u8. > >> especially as the array doesn't need to be that large and it can easily >> be allocated dynamically. >> >> Signed-off-by: Juergen Gross <jgross@...e.com> >> --- >> arch/x86/kernel/cpu/mtrr/mtrr.c | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.c b/arch/x86/kernel/cpu/mtrr/mtrr.c >> index 0c83990501f5..50cd2287b6e1 100644 >> --- a/arch/x86/kernel/cpu/mtrr/mtrr.c >> +++ b/arch/x86/kernel/cpu/mtrr/mtrr.c >> @@ -581,7 +581,7 @@ struct mtrr_value { >> unsigned long lsize; >> }; >> >> -static struct mtrr_value mtrr_value[MTRR_MAX_VAR_RANGES]; >> +static struct mtrr_value *mtrr_value; >> >> static int mtrr_save(void) >> { >> @@ -750,6 +750,7 @@ static int __init mtrr_init_finialize(void) >> * TBD: is there any system with such CPU which supports >> * suspend/resume? If no, we should remove the code. >> */ >> + mtrr_value = kcalloc(num_var_ranges, sizeof(*mtrr_value), GFP_KERNEL); > > Pls put that over the comment. > > Also, you need to handle kcalloc() returning an error. Okay. Juergen Download attachment "OpenPGP_0xB0DE9DD628BF132F.asc" of type "application/pgp-keys" (3099 bytes) Download attachment "OpenPGP_signature" of type "application/pgp-signature" (496 bytes)
Powered by blists - more mailing lists