Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct Linux 4.X group_info fields detection #13341

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions config/kernel-group-info.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ dnl #
dnl # 4.9 API change
dnl # group_info changed from 2d array via >blocks to 1d array via ->gid
dnl #
AC_DEFUN([ZFS_AC_KERNEL_SRC_GROUP_INFO_GID], [
ZFS_LINUX_TEST_SRC([group_info_gid], [
AC_DEFUN([ZFS_AC_KERNEL_SRC_GROUP_INFO_NBLOCKS], [
ZFS_LINUX_TEST_SRC([group_info_nblocks], [
#include <linux/cred.h>
],[
struct group_info *gi = groups_alloc(1);
gi->gid[0] = KGIDT_INIT(0);
struct group_info gi;
gi.nblocks = 0;
(void)gi;
])
])

AC_DEFUN([ZFS_AC_KERNEL_GROUP_INFO_GID], [
AC_MSG_CHECKING([whether group_info->gid exists])
ZFS_LINUX_TEST_RESULT([group_info_gid], [
AC_DEFUN([ZFS_AC_KERNEL_GROUP_INFO_NBLOCKS], [
AC_MSG_CHECKING([whether group_info->nblocks exists])
ZFS_LINUX_TEST_RESULT([group_info_nblocks], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GROUP_INFO_GID, 1, [group_info->gid exists])
AC_DEFINE(HAVE_GROUP_INFO_NBLOCKS, 1, [group_info->nblocks exists])
],[
AC_MSG_RESULT(no)
])
Expand Down
1 change: 1 addition & 0 deletions config/kernel-userns-capabilities.m4
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_CRED_USER_NS], [
],[
struct cred cr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
struct cred cr;
struct cred cr __attribute__ ((unused));

This works, but we've tried to use the __attribute__ ((unused)) in the m4 config files instead of (void)cr.

Same change in ZFS_AC_KERNEL_SRC_GROUP_INFO_NBLOCKS

cr.user_ns = (struct user_namespace *)NULL;
(void)cr;
])
])

Expand Down
4 changes: 2 additions & 2 deletions config/kernel.m4
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [
ZFS_AC_KERNEL_SRC_WAIT
ZFS_AC_KERNEL_SRC_INODE_TIMES
ZFS_AC_KERNEL_SRC_INODE_LOCK
ZFS_AC_KERNEL_SRC_GROUP_INFO_GID
ZFS_AC_KERNEL_SRC_GROUP_INFO_NBLOCKS
ZFS_AC_KERNEL_SRC_RW
ZFS_AC_KERNEL_SRC_TIMER_SETUP
ZFS_AC_KERNEL_SRC_SUPER_USER_NS
Expand Down Expand Up @@ -165,7 +165,7 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [
ZFS_AC_KERNEL_WAIT
ZFS_AC_KERNEL_INODE_TIMES
ZFS_AC_KERNEL_INODE_LOCK
ZFS_AC_KERNEL_GROUP_INFO_GID
ZFS_AC_KERNEL_GROUP_INFO_NBLOCKS
ZFS_AC_KERNEL_RW
ZFS_AC_KERNEL_TIMER_SETUP
ZFS_AC_KERNEL_SUPER_USER_NS
Expand Down
4 changes: 2 additions & 2 deletions module/os/linux/spl/spl-cred.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ crgetngroups(const cred_t *cr)

gi = cr->group_info;
rc = gi->ngroups;
#ifndef HAVE_GROUP_INFO_GID
#if defined(HAVE_GROUP_INFO_NBLOCKS)
/*
* For Linux <= 4.8,
* crgetgroups will only returns gi->blocks[0], which contains only
Expand Down Expand Up @@ -102,7 +102,7 @@ crgetgroups(const cred_t *cr)
gid_t *gids = NULL;

gi = cr->group_info;
#ifdef HAVE_GROUP_INFO_GID
#if !defined(HAVE_GROUP_INFO_NBLOCKS)
gids = KGIDP_TO_SGIDP(gi->gid);
#else
if (gi->nblocks > 0)
Expand Down