Skip to content

Commit

Permalink
acl: use uintptr_t for ace walker cookies
Browse files Browse the repository at this point in the history
Avoid assuming that a pointer can fit in a uint64_t and use uintptr_t
instead.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Signed-off-by: Brooks Davis <brooks.davis@sri.com>
Closes #14131
  • Loading branch information
brooksdavis authored and behlendorf committed Nov 3, 2022
1 parent 7309e94 commit d96303c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/os/freebsd/spl/acl/acl_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extern int acltrivial(const char *);
extern void adjust_ace_pair(ace_t *pair, mode_t mode);
extern void adjust_ace_pair_common(void *, size_t, size_t, mode_t);
extern int ace_trivial_common(void *, int,
uint64_t (*walk)(void *, uint64_t, int aclcnt, uint16_t *, uint16_t *,
uintptr_t (*walk)(void *, uintptr_t, int aclcnt, uint16_t *, uint16_t *,
uint32_t *mask));
#if !defined(_KERNEL)
extern acl_t *acl_alloc(acl_type_t);
Expand Down
4 changes: 2 additions & 2 deletions module/os/freebsd/spl/acl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1654,13 +1654,13 @@ acl_trivial_create(mode_t mode, boolean_t isdir, ace_t **acl, int *count)
*/
int
ace_trivial_common(void *acep, int aclcnt,
uint64_t (*walk)(void *, uint64_t, int aclcnt,
uintptr_t (*walk)(void *, uintptr_t, int aclcnt,
uint16_t *, uint16_t *, uint32_t *))
{
uint16_t flags;
uint32_t mask;
uint16_t type;
uint64_t cookie = 0;
uintptr_t cookie = 0;

while ((cookie = walk(acep, cookie, aclcnt, &flags, &type, &mask))) {
switch (flags & ACE_TYPE_FLAGS) {
Expand Down
6 changes: 3 additions & 3 deletions module/os/freebsd/zfs/zfs_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ zfs_acl_next_ace(zfs_acl_t *aclp, void *start, uint64_t *who,
return (NULL);
}

static uint64_t
zfs_ace_walk(void *datap, uint64_t cookie, int aclcnt,
static uintptr_t
zfs_ace_walk(void *datap, uintptr_t cookie, int aclcnt,
uint16_t *flags, uint16_t *type, uint32_t *mask)
{
(void) aclcnt;
Expand All @@ -642,7 +642,7 @@ zfs_ace_walk(void *datap, uint64_t cookie, int aclcnt,

acep = zfs_acl_next_ace(aclp, acep, &who, mask,
flags, type);
return ((uint64_t)(uintptr_t)acep);
return ((uintptr_t)acep);
}

/*
Expand Down
10 changes: 5 additions & 5 deletions module/os/linux/zfs/zfs_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,18 +629,18 @@ zfs_acl_next_ace(zfs_acl_t *aclp, void *start, uint64_t *who,
return (NULL);
}

static uint64_t
zfs_ace_walk(void *datap, uint64_t cookie, int aclcnt,
static uintptr_t
zfs_ace_walk(void *datap, uintptr_t cookie, int aclcnt,
uint16_t *flags, uint16_t *type, uint32_t *mask)
{
(void) aclcnt;
zfs_acl_t *aclp = datap;
zfs_ace_hdr_t *acep = (zfs_ace_hdr_t *)(uintptr_t)cookie;
zfs_ace_hdr_t *acep = (zfs_ace_hdr_t *)cookie;
uint64_t who;

acep = zfs_acl_next_ace(aclp, acep, &who, mask,
flags, type);
return ((uint64_t)(uintptr_t)acep);
return ((uintptr_t)acep);
}

/*
Expand Down Expand Up @@ -1285,7 +1285,7 @@ acl_trivial_access_masks(mode_t mode, boolean_t isdir, trivial_acl_t *masks)
*/
static int
ace_trivial_common(void *acep, int aclcnt,
uint64_t (*walk)(void *, uint64_t, int aclcnt,
uintptr_t (*walk)(void *, uintptr_t, int,
uint16_t *, uint16_t *, uint32_t *))
{
uint16_t flags;
Expand Down

0 comments on commit d96303c

Please sign in to comment.