From a2ab598bae94a9ce0c95034c1a54bcd8e12d5a87 Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Thu, 4 May 2023 10:00:43 -0700 Subject: [PATCH] AIX: AFS_SMALLOCSIZ too small on newer OS releases Addresses a situation where a write in AFS space can cause a kernel panic. In src/afs/afs_osi_uio.c in the function afsio_partialcopy: size_t space_len = sizeof(struct uio) + sizeof(struct iovec) * AFS_MAXIOVCNT; /* Allocate a block that can contain both the UIO and the iovec */ space = osi_AllocSmallSpace(space_len); On newer AIX systems (since at least 6.1), space_len is larger than AFS_SMALLOCSIZ. When osi_AllocSmallSpace is called, the following test in src/afs/afs_osi_alloc.c causes a kernel panic: if (size > AFS_SMALLOCSIZ) osi_Panic("osi_AllocSmallS: size=%d\n", (int)size); This is due to the following definition in src/config/afs_args.h: /* * Note that the AFS_*ALLOCSIZ values should be multiples of sizeof(void*) to * accomodate pointer alignment. */ /* Used in rx.c as well as afs directory. */ /* XXX Because of rxkad_cprivate... XXX */ All the supported AIX platforms define AFS_AIX32_ENV in src/config/param.rs_aixXX.h, where XX is the AIX version. Therefore, all the AIX platforms end up with AFS_SMALLOCSIZ = 152 bytes instead of 256. To resolve this, we will modify the preprocessor test to use the second case for AIX versions greater than 6.1. This issue may be present on earlier releases of AIX as well, but AIX 5.3 and older test systems were not available at this time. Also, a spelling error in the comment was fixed. Reviewed-on: https://gerrit.openafs.org/15418 Reviewed-by: Mark Vitale Tested-by: BuildBot Reviewed-by: Cheyenne Wills Reviewed-by: Benjamin Kaduk (cherry picked from commit 8a2d4faa73d0f2e03a4016d7f84c5d5437040cec) Change-Id: I5a2fc4ad1a829f1ee30387da20ce477c84fa020f Reviewed-on: https://gerrit.openafs.org/15424 Tested-by: BuildBot Reviewed-by: Ben Huntsman Tested-by: Ben Huntsman Reviewed-by: Mark Vitale Reviewed-by: Michael Meffie Reviewed-by: Stephan Wiesand --- src/config/afs_args.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/afs_args.h b/src/config/afs_args.h index bf6b3ae0a0..5f44d5289a 100644 --- a/src/config/afs_args.h +++ b/src/config/afs_args.h @@ -197,10 +197,10 @@ enum { /* * Note that the AFS_*ALLOCSIZ values should be multiples of sizeof(void*) to - * accomodate pointer alignment. + * accommodate pointer alignment. */ /* Used in rx.c as well as afs directory. */ -#if defined(AFS_AIX32_ENV) || defined(AFS_HPUX_ENV) +#if (defined(AFS_AIX32_ENV) && !defined(AFS_AIX61_ENV)) || defined(AFS_HPUX_ENV) /* XXX Because of rxkad_cprivate... XXX */ #define AFS_SMALLOCSIZ (38*sizeof(void *)) /* "Small" allocated size */ #else