Bug 1019929 - [PATCH] improve LOCAL_PEERCRED error handling
Summary: [PATCH] improve LOCAL_PEERCRED error handling
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-16 16:06 UTC by b.candler
Modified: 2014-05-13 21:07 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2013-10-17 12:28:49 UTC
Embargoed:


Attachments (Terms of Use)
Patch to LOCAL_PEERCRED error handling (1.69 KB, patch)
2013-10-16 16:06 UTC, b.candler
no flags Details | Diff

Description b.candler 2013-10-16 16:06:47 UTC
Created attachment 813025 [details]
Patch to LOCAL_PEERCRED error handling

This patch improves the error checking in the LOCAL_PEERCRED version of virNetSocketGetUNIXIdentity, used by FreeBSD and Mac OSX.

1. The error return paths now correctly unlock the socket. This is implemented in exactly the same way as the SO_PEERCRED version, using "goto cleanup"

2. cr.cr_ngroups is initialised to -1, and cr.cr_ngroups is checked for negative and overlarge values.

This means that if the getsockopt() call returns success but doesn't actually update the xucred structure, this is now caught. This happened previously when getsockopt was called with SOL_SOCKET instead of SOL_LOCAL, prior to commit 5a468b3, and resulted in random uids being accepted.

Comment 1 Eric Blake 2013-10-17 12:18:56 UTC
Can you please post this patch to the list (preferably via 'git send-email', but also acceptable as an attachment)?  Also, please fix it to not touch the .gnulib submodule.  It's harder for others to apply patches that didn't go through the list.

Comment 2 Eric Blake 2013-10-17 12:28:49 UTC
Nevermind; it's been fixed and pushed on your behalf:

commit aa0f09929d02ccdbf3ca9502a1fd39d90db0c690
Author: Brian Candler <b.candler>
Date:   Thu Oct 17 06:21:57 2013 -0600

    better error checking for LOCAL_PEERCRED
    
    This patch improves the error checking in the LOCAL_PEERCRED version
    of virNetSocketGetUNIXIdentity, used by FreeBSD and Mac OSX.
    
    1. The error return paths now correctly unlock the socket. This is
    implemented in exactly the same way as the SO_PEERCRED version,
    using "goto cleanup"
    
    2. cr.cr_ngroups is initialised to -1, and cr.cr_ngroups is checked
    for negative and overlarge values.
    
    This means that if the getsockopt() call returns success but doesn't
    actually update the xucred structure, this is now caught. This
    happened previously when getsockopt was called with SOL_SOCKET
    instead of SOL_LOCAL, prior to commit 5a468b3, and resulted in
    random uids being accepted.
    
    Signed-off-by: Eric Blake <eblake>


Note You need to log in before you can comment on or make changes to this bug.