Skip to content

Commit

Permalink
make sure the shm cache entry size is a multiple of 8 bytes
Browse files Browse the repository at this point in the history
see #1067; thanks @sanzinger

Signed-off-by: Hans Zandbelt <[email protected]>
  • Loading branch information
zandbelt committed Dec 28, 2023
1 parent 3c7978e commit 4a4e198
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
12/28/2023
- set memory alignment of shm cache structs to 64 bytes; see #1067
should fix running on Raspberry PI / ARMv7 32 bits (arm32v7)
- make sure the shm cache entry size is a multiple of 8 bytes, see #1067; thanks @sanzinger
- bump to 2.4.15rc13

12/22/2023
Expand Down
5 changes: 3 additions & 2 deletions auth_openidc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -635,11 +635,12 @@
# OIDCCacheShmMax <number>

# When using OIDCCacheType "shm":
# Specifies the maximum size for a single cache entry in bytes with a minimum of 8464 bytes.
# Specifies the maximum size for a single cache entry in bytes with a minimum of 8736 bytes.
# The value must a multiple of 8 bytes.
# When caching large values such as numbers of attributes in a session or large metadata documents the
# entry size limit may be overrun, in which case errors will be displayed in the error.log
# and the OIDCCacheShmEntrySizeMax value has to be increased.
# When not specified, a default entry size of 16913 bytes (16384 value + 512 key + 17 overhead) is used.
# When not specified, a default entry size of 16928 bytes (16384 value + 512 key + 32 overhead) is used.
# OIDCCacheShmEntrySizeMax <bytes>

# When using OIDCCacheType "file":
Expand Down
2 changes: 1 addition & 1 deletion src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
/* default max cache size for shm */
#define OIDC_DEFAULT_CACHE_SHM_SIZE 10000
/* default max cache entry size for shm: # value + # key + # overhead */
#define OIDC_DEFAULT_CACHE_SHM_ENTRY_SIZE_MAX 16384 + 512 + 17
#define OIDC_DEFAULT_CACHE_SHM_ENTRY_SIZE_MAX 16384 + 512 + 32
/* for issued-at timestamp (iat) checking */
#define OIDC_DEFAULT_IDTOKEN_IAT_SLACK 600
/* for file-based caching: clean interval in seconds */
Expand Down
9 changes: 6 additions & 3 deletions src/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,19 @@ const char *oidc_parse_session_type(apr_pool_t *pool, const char *arg, int *type
}

/* minimum size of a SHM cache entry */
#define OIDC_MINIMUM_CACHE_SHM_ENTRY_SIZE_MAX 8192 + 512 + 17 // 8Kb plus overhead
#define OIDC_MINIMUM_CACHE_SHM_ENTRY_SIZE_MAX 8192 + 512 + 32 // 8Kb plus overhead
/* maximum size of a SHM cache entry */
#define OIDC_MAXIMUM_CACHE_SHM_ENTRY_SIZE_MAX 1024 * 1024 // 1Mb incl. overhead

/*
* parse the slot size of a SHM cache entry
*/
const char *oidc_parse_cache_shm_entry_size_max(apr_pool_t *pool, const char *arg, int *int_value) {
return oidc_parse_int_min_max(pool, arg, int_value, OIDC_MINIMUM_CACHE_SHM_ENTRY_SIZE_MAX,
OIDC_MAXIMUM_CACHE_SHM_ENTRY_SIZE_MAX);
const char *rv = oidc_parse_int_min_max(pool, arg, int_value, OIDC_MINIMUM_CACHE_SHM_ENTRY_SIZE_MAX,
OIDC_MAXIMUM_CACHE_SHM_ENTRY_SIZE_MAX);
if ((rv == NULL) && (((*int_value) % 8) != 0))
rv = "the slot size must be a multiple of 8";
return rv;
}

/*
Expand Down

0 comments on commit 4a4e198

Please sign in to comment.