lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CADvbK_e70AOti7p6VfCPcu9X3VTEiKXO2r4RJbAtX1w58GyZYg@mail.gmail.com>
Date:   Thu, 15 Apr 2021 17:24:32 -0400
From:   Xin Long <lucien.xin@...il.com>
To:     Jiri Pirko <jiri@...nulli.us>
Cc:     network dev <netdev@...r.kernel.org>, davem <davem@...emloft.net>,
        Jakub Kicinski <jakub.kicinski@...ronome.com>,
        alex.aring@...il.com, stefan@...enfreihafen.org,
        Jon Maloy <jon.maloy@...csson.com>,
        Ying Xue <ying.xue@...driver.com>, johannes.berg@...el.com,
        Michal Kubecek <mkubecek@...e.cz>,
        Yuehaibing <yuehaibing@...wei.com>, mlxsw@...lanox.com
Subject: Re: [patch net-next 07/10] net: tipc: have genetlink code to parse
 the attrs during dumpit

On Sat, Oct 5, 2019 at 2:09 PM Jiri Pirko <jiri@...nulli.us> wrote:
>
> From: Jiri Pirko <jiri@...lanox.com>
>
> Benefit from the fact that the generic netlink code can parse the attrs
> for dumpit op and avoid need to parse it in the op callback.
>
> Signed-off-by: Jiri Pirko <jiri@...lanox.com>
> ---
>  net/tipc/netlink.c   | 9 ++++++---
>  net/tipc/node.c      | 6 +-----
>  net/tipc/socket.c    | 6 +-----
>  net/tipc/udp_media.c | 6 +-----
>  4 files changed, 9 insertions(+), 18 deletions(-)
>
> diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
> index d6165ad384c0..5f5df232d72b 100644
> --- a/net/tipc/netlink.c
> +++ b/net/tipc/netlink.c
> @@ -176,7 +176,8 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
>         },
>         {
>                 .cmd    = TIPC_NL_PUBL_GET,
> -               .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
> +               .validate = GENL_DONT_VALIDATE_STRICT |
> +                           GENL_DONT_VALIDATE_DUMP_STRICT,
>                 .dumpit = tipc_nl_publ_dump,
>         },
>         {
> @@ -239,7 +240,8 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
>         },
>         {
>                 .cmd    = TIPC_NL_MON_PEER_GET,
> -               .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
> +               .validate = GENL_DONT_VALIDATE_STRICT |
> +                           GENL_DONT_VALIDATE_DUMP_STRICT,
>                 .dumpit = tipc_nl_node_dump_monitor_peer,
>         },
>         {
> @@ -250,7 +252,8 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
>  #ifdef CONFIG_TIPC_MEDIA_UDP
>         {
>                 .cmd    = TIPC_NL_UDP_GET_REMOTEIP,
> -               .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
> +               .validate = GENL_DONT_VALIDATE_STRICT |
> +                           GENL_DONT_VALIDATE_DUMP_STRICT,
>                 .dumpit = tipc_udp_nl_dump_remoteip,
>         },
Hi Jiri,

can I ask you why GENL_DONT_VALIDATE_DUMP_STRICT flag is needed when
using genl_dumpit_info(cb)->attrs in dumpit?

Thanks.

>  #endif
> diff --git a/net/tipc/node.c b/net/tipc/node.c
> index c8f6177dd5a2..f2e3cf70c922 100644
> --- a/net/tipc/node.c
> +++ b/net/tipc/node.c
> @@ -2484,13 +2484,9 @@ int tipc_nl_node_dump_monitor_peer(struct sk_buff *skb,
>         int err;
>
>         if (!prev_node) {
> -               struct nlattr **attrs;
> +               struct nlattr **attrs = genl_dumpit_info(cb)->attrs;
>                 struct nlattr *mon[TIPC_NLA_MON_MAX + 1];
>
> -               err = tipc_nlmsg_parse(cb->nlh, &attrs);
> -               if (err)
> -                       return err;
> -
>                 if (!attrs[TIPC_NLA_MON])
>                         return -EINVAL;
>
> diff --git a/net/tipc/socket.c b/net/tipc/socket.c
> index 3b9f8cc328f5..d579b64705b1 100644
> --- a/net/tipc/socket.c
> +++ b/net/tipc/socket.c
> @@ -3588,13 +3588,9 @@ int tipc_nl_publ_dump(struct sk_buff *skb, struct netlink_callback *cb)
>         struct tipc_sock *tsk;
>
>         if (!tsk_portid) {
> -               struct nlattr **attrs;
> +               struct nlattr **attrs = genl_dumpit_info(cb)->attrs;
>                 struct nlattr *sock[TIPC_NLA_SOCK_MAX + 1];
>
> -               err = tipc_nlmsg_parse(cb->nlh, &attrs);
> -               if (err)
> -                       return err;
> -
>                 if (!attrs[TIPC_NLA_SOCK])
>                         return -EINVAL;
>
> diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
> index 287df68721df..43ca5fd6574d 100644
> --- a/net/tipc/udp_media.c
> +++ b/net/tipc/udp_media.c
> @@ -448,15 +448,11 @@ int tipc_udp_nl_dump_remoteip(struct sk_buff *skb, struct netlink_callback *cb)
>         int i;
>
>         if (!bid && !skip_cnt) {
> +               struct nlattr **attrs = genl_dumpit_info(cb)->attrs;
>                 struct net *net = sock_net(skb->sk);
>                 struct nlattr *battrs[TIPC_NLA_BEARER_MAX + 1];
> -               struct nlattr **attrs;
>                 char *bname;
>
> -               err = tipc_nlmsg_parse(cb->nlh, &attrs);
> -               if (err)
> -                       return err;
> -
>                 if (!attrs[TIPC_NLA_BEARER])
>                         return -EINVAL;
>
> --
> 2.21.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ