• Stefan Hajnoczi's avatar
    net/atm: sk_err_soft must be positive · c685293a
    Stefan Hajnoczi authored
    The sk_err and sk_err_soft fields are positive errno values and
    userspace applications rely on this when using getsockopt(SO_ERROR).
    ATM code places an -errno into sk_err_soft in sigd_send() and returns it
    from svc_addparty()/svc_dropparty().
    Although I am not familiar with ATM code I came to this conclusion
    1. sigd_send() msg->type cases as_okay and as_error both have:
       sk->sk_err = -msg->reply;
       while the as_addparty and as_dropparty cases have:
       sk->sk_err_soft = msg->reply;
       This is the source of the inconsistency.
    2. svc_addparty() returns an -errno and assumes sk_err_soft is also an
           if (flags & O_NONBLOCK) {
               error = -EINPROGRESS;
               goto out;
           error = xchg(&sk->sk_err_soft, 0);
           return error;
       This shows that sk_err_soft is indeed being treated as an -errno.
    This patch ensures that sk_err_soft is always a positive errno.
    Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
signaling.c 6.22 KB