Skip to content

Commit

Permalink
Silence the existing API for capability version compatibility check.
Browse files Browse the repository at this point in the history
When libcap, or other libraries attempt to confirm/determine the supported
capability version magic, they generally supply a NULL dataptr to capget().

In this case, while returning the supported/preferred magic (via a
modified header content), the return code of this system call may be 0,
-EINVAL, or -EFAULT.

No libcap code depends on the previous -EINVAL etc. return code, and
all of the above three return codes can accompany a valid (successful)
attempt to determine the requested magic value.

This patch cleans up the system call to return 0, if the call is
successfully being used to determine the supported/preferred capability
magic value.

Signed-off-by: Andrew G. Morgan <[email protected]>
Acked-by: Steve Grubb <[email protected]>
Acked-by: Serge Hallyn <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
AndrewGMorgan authored and James Morris committed Nov 23, 2009
1 parent fe542cf commit c4a5af5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
kernel_cap_t pE, pI, pP;

ret = cap_validate_magic(header, &tocopy);
if (ret != 0)
return ret;
if ((dataptr == NULL) || (ret != 0))
return ((dataptr == NULL) && (ret == -EINVAL)) ? 0 : ret;

if (get_user(pid, &header->pid))
return -EFAULT;
Expand Down

0 comments on commit c4a5af5

Please sign in to comment.