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 <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 8a2d4faa73d0f2e03a4016d7f84c5d5437040cec)

Change-Id: I5a2fc4ad1a829f1ee30387da20ce477c84fa020f
Reviewed-on: https://gerrit.openafs.org/15424
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Ben Huntsman <ben@huntsmans.net>
Tested-by: Ben Huntsman <ben@huntsmans.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
This commit is contained in:
Ben Huntsman 2023-05-04 10:00:43 -07:00 committed by Stephan Wiesand
parent af58c5cd15
commit a2ab598bae

View File

@ -197,10 +197,10 @@ enum {
/* /*
* Note that the AFS_*ALLOCSIZ values should be multiples of sizeof(void*) to * 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. */ /* 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 */ /* XXX Because of rxkad_cprivate... XXX */
#define AFS_SMALLOCSIZ (38*sizeof(void *)) /* "Small" allocated size */ #define AFS_SMALLOCSIZ (38*sizeof(void *)) /* "Small" allocated size */
#else #else