Patch "powerpc/pseries: Fix alignment of PLPKS structures and buffers" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    powerpc/pseries: Fix alignment of PLPKS structures and buffers

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     powerpc-pseries-fix-alignment-of-plpks-structures-an.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit f58516ccf6583693733f37d30b066ea5bccb39e2
Author: Andrew Donnellan <ajd@xxxxxxxxxxxxx>
Date:   Fri Feb 10 19:03:37 2023 +1100

    powerpc/pseries: Fix alignment of PLPKS structures and buffers
    
    [ Upstream commit fcf63d6b8ab9b12c2ce1b4bde12a3c391029c998 ]
    
    A number of structures and buffers passed to PKS hcalls have alignment
    requirements, which could on occasion cause problems:
    
    - Authorisation structures must be 16-byte aligned and must not cross a
      page boundary
    
    - Label structures must not cross page boundaries
    
    - Password output buffers must not cross page boundaries
    
    To ensure correct alignment, we adjust the allocation size of each of
    these structures/buffers to be the closest power of 2 that is at least the
    size of the structure/buffer (since kmalloc() guarantees that an
    allocation of a power of 2 size will be aligned to at least that size).
    
    Reported-by: Benjamin Gray <bgray@xxxxxxxxxxxxx>
    Fixes: 2454a7af0f2a ("powerpc/pseries: define driver for Platform KeyStore")
    Signed-off-by: Andrew Donnellan <ajd@xxxxxxxxxxxxx>
    Reviewed-by: Russell Currey <ruscur@xxxxxxxxxx>
    Signed-off-by: Russell Currey <ruscur@xxxxxxxxxx>
    Signed-off-by: Michael Ellerman <mpe@xxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230210080401.345462-3-ajd@xxxxxxxxxxxxx
    Stable-dep-of: 932bed412170 ("powerpc/kexec_file: fix cpus node update to FDT")
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/powerpc/platforms/pseries/plpks.c b/arch/powerpc/platforms/pseries/plpks.c
index 25f95440a773b..d54188a355c9c 100644
--- a/arch/powerpc/platforms/pseries/plpks.c
+++ b/arch/powerpc/platforms/pseries/plpks.c
@@ -113,7 +113,8 @@ static int plpks_gen_password(void)
 	u8 *password, consumer = PLPKS_OS_OWNER;
 	int rc;
 
-	password = kzalloc(maxpwsize, GFP_KERNEL);
+	// The password must not cross a page boundary, so we align to the next power of 2
+	password = kzalloc(roundup_pow_of_two(maxpwsize), GFP_KERNEL);
 	if (!password)
 		return -ENOMEM;
 
@@ -149,7 +150,9 @@ static struct plpks_auth *construct_auth(u8 consumer)
 	if (consumer > PLPKS_OS_OWNER)
 		return ERR_PTR(-EINVAL);
 
-	auth = kzalloc(struct_size(auth, password, maxpwsize), GFP_KERNEL);
+	// The auth structure must not cross a page boundary and must be
+	// 16 byte aligned. We align to the next largest power of 2
+	auth = kzalloc(roundup_pow_of_two(struct_size(auth, password, maxpwsize)), GFP_KERNEL);
 	if (!auth)
 		return ERR_PTR(-ENOMEM);
 
@@ -183,7 +186,8 @@ static struct label *construct_label(char *component, u8 varos, u8 *name,
 	if (component && slen > sizeof(label->attr.prefix))
 		return ERR_PTR(-EINVAL);
 
-	label = kzalloc(sizeof(*label), GFP_KERNEL);
+	// The label structure must not cross a page boundary, so we align to the next power of 2
+	label = kzalloc(roundup_pow_of_two(sizeof(*label)), GFP_KERNEL);
 	if (!label)
 		return ERR_PTR(-ENOMEM);
 




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux