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


Groups > linux.kernel > #1741416

Re: [PATCH v2] netlink: do not proceed if dump's start() errs

From "Jason A. Donenfeld" <Jason@zx2c4.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] netlink: do not proceed if dump's start() errs
Date 2017-09-28 12:50 +0200
Message-ID <uuEye-7SR-13@gated-at.bofh.it> (permalink)
References <uukg9-35a-5@gated-at.bofh.it> <uutjr-En-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Sep 28, 2017 at 12:41:44AM +0200, Jason A. Donenfeld wrote:
> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> index 327807731b44..94c11cf0459d 100644
> --- a/net/netlink/af_netlink.c
> +++ b/net/netlink/af_netlink.c
> @@ -2270,10 +2270,13 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
>  
>  	mutex_unlock(nlk->cb_mutex);
>  
> +	ret = 0;
>  	if (cb->start)
> -		cb->start(cb);
> +		ret = cb->start(cb);
> +
> +	if (!ret)
> +		ret = netlink_dump(sk);
>  
> -	ret = netlink_dump(sk);
>  	sock_put(sk);
>  
>  	if (ret)


FYI, using this horrific hack to currently work around bug:

    #define KERNEL_VERSION_THAT_HAS_NETLINK_START_FIX KERNEL_VERSION(4, 14, 0) /* Hopefully! */

    static int get(struct sk_buff *skb, struct netlink_callback *cb)
    {
    #if LINUX_VERSION_CODE < KERNEL_VERSION_THAT_HAS_NETLINK_START_FIX
        /* https://marc.info/?l=linux-netdev&m=150655213004221&w=2 */
        if (!cb->args[0]) {
            ret = get_start(cb);
            if (ret)
                return ret;
        }
    #endif
        ...
    }

    static const struct genl_ops genl_ops[] = {
        {
            .cmd = CMD_GET,
    #if LINUX_VERSION_CODE >= KERNEL_VERSION_THAT_HAS_NETLINK_START_FIX
            /* https://marc.info/?l=linux-netdev&m=150655213004221&w=2 */
            .start = get_start,
    #endif
            .dumpit = get,
            ...
        }
    }

Gross.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] netlink: do not proceed if dump's start() errs "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-09-27 14:50 +0200
  Re: [PATCH] netlink: do not proceed if dump's start() errs "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-09-27 15:00 +0200
    Re: [PATCH] netlink: do not proceed if dump's start() errs "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-09-27 15:10 +0200
      [PATCH v2] netlink: do not proceed if dump's start() errs "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-09-28 00:50 +0200
        Re: [PATCH v2] netlink: do not proceed if dump's start() errs "Jason A. Donenfeld" <Jason@zx2c4.com> - 2017-09-28 12:50 +0200
        Re: [PATCH v2] netlink: do not proceed if dump's start() errs David Miller <davem@davemloft.net> - 2017-09-30 08:30 +0200
        Re: [PATCH v2] netlink: do not proceed if dump's start() errs Johannes Berg <johannes@sipsolutions.net> - 2017-09-30 09:40 +0200
          Re: [PATCH v2] netlink: do not proceed if dump's start() errs David Miller <davem@davemloft.net> - 2017-09-30 17:20 +0200
    Re: [PATCH] netlink: do not proceed if dump's start() errs Johannes Berg <johannes@sipsolutions.net> - 2017-09-27 15:10 +0200

csiph-web