Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1335772 > unrolled thread

https://patchwork.ozlabs.org/patch/579654?

Started byRainer Weikusat <rweikusat@mobileactivedefense.com>
First post2016-02-16 21:10 +0100
Last post2016-02-16 23:50 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  https://patchwork.ozlabs.org/patch/579654? Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2016-02-16 21:10 +0100
    Re: https://patchwork.ozlabs.org/patch/579654? Hannes Frederic Sowa <hannes@stressinduktion.org> - 2016-02-16 23:50 +0100

#1335772 — https://patchwork.ozlabs.org/patch/579654?

FromRainer Weikusat <rweikusat@mobileactivedefense.com>
Date2016-02-16 21:10 +0100
Subjecthttps://patchwork.ozlabs.org/patch/579654?
Message-ID<r2U6D-4e2-21@gated-at.bofh.it>
https://patchwork.ozlabs.org/patch/579654

lists this as 'superseded', among with the older versions of the patch
which changed the error handling. But at least, I couldn't find anything
superseding it. This was supposed to address the different-but-related
problem demonstrated by the following (slightly modified) test program:

---------
#define _GNU_SOURCE
    
#include <stdlib.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>

int main(void)
{
    enum { server, client, size };
    int socket_fd[size];
    int const opt = 1;

    assert(socketpair(AF_LOCAL, SOCK_STREAM, 0, socket_fd) == 0);
    assert(setsockopt(socket_fd[server], SOL_SOCKET, SO_PASSCRED, &opt, sizeof(opt)) != -1);

    char const msg[] = "A random message";

    if (fork() == 0) {
	sleep(1);
	send(socket_fd[client], msg, sizeof msg, 0);

	_exit(0);
    }

    union {
        struct cmsghdr cmh;
        char control[CMSG_SPACE(sizeof(struct ucred))];
    } control_un;

    control_un.cmh.cmsg_len = CMSG_LEN(sizeof(struct ucred));
    control_un.cmh.cmsg_level = SOL_SOCKET;
    control_un.cmh.cmsg_type = SCM_CREDENTIALS;

    struct msghdr msgh;
    msgh.msg_name = NULL;
    msgh.msg_namelen = 0;
    msgh.msg_iov = NULL;
    msgh.msg_iovlen = 0;
    msgh.msg_control = control_un.control;
    msgh.msg_controllen = sizeof(control_un.control);

    recvmsg(socket_fd[server], &msgh, MSG_PEEK);
	
    printf("Success?\n");

    struct ucred *ucred;
    ucred = (void *)CMSG_DATA(&control_un.cmh);
    printf("...  pid %ld, uid %d, gid %d\n",
	   (long)ucred->pid, ucred->uid, ucred->gid);
    
    return 0;
}
--------

Because the receiver has to wait for the message, it will hit the
continue in unix_stream_read_generic. This causes the size-check of the
do-while loop to be executed which terminates the loop as the size is
zero without copying the credential information.

Just wondering if this might have been lost in the noise ...

[toc] | [next] | [standalone]


#1335899

FromHannes Frederic Sowa <hannes@stressinduktion.org>
Date2016-02-16 23:50 +0100
Message-ID<r2WBs-5LU-15@gated-at.bofh.it>
In reply to#1335772
On 16.02.2016 21:09, Rainer Weikusat wrote:
> https://patchwork.ozlabs.org/patch/579654
>
> lists this as 'superseded', among with the older versions of the patch
> which changed the error handling. But at least, I couldn't find anything
> superseding it. This was supposed to address the different-but-related
> problem demonstrated by the following (slightly modified) test program:
>
> ---------
 > [...]
> --------
>
> Because the receiver has to wait for the message, it will hit the
> continue in unix_stream_read_generic. This causes the size-check of the
> do-while loop to be executed which terminates the loop as the size is
> zero without copying the credential information.
>
> Just wondering if this might have been lost in the noise ...

I think the patch got lost, probably just resending is the easiest 
solution. ;)

For the patch:
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>

Thanks,
Hannes

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web