[PATCH] netlink: fix append of whole original message on negative ack. - Kernel

This is a discussion on [PATCH] netlink: fix append of whole original message on negative ack. - Kernel ; From: Michel Lammertink ti-wmc.nl> Signed-off-by: Michel Lammertink ti-wmc.nl> Netlink can return an negative acknowledgement, which AFAICT should include an error code and the whole original message. This patch fixes the size argument given to the __nlmsg_put call. Without this patch ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: [PATCH] netlink: fix append of whole original message on negative ack.

  1. [PATCH] netlink: fix append of whole original message on negative ack.

    From: Michel Lammertink ti-wmc.nl>
    Signed-off-by: Michel Lammertink ti-wmc.nl>

    Netlink can return an negative acknowledgement, which AFAICT should include an error code and the whole original message. This patch fixes the size argument given to the __nlmsg_put call. Without this patch only the original header was attached.
    ---

    Can anyone explain to me why struct nlmsgerr contains an int error and the nlmsghdr struct. The comment in netlink_ack states that the whole message should be appended. Why not only include an int error in struct nlmsgerr and just append the original message?

    Comments appreciated.

    diff -uprN linux-2.6.27.3.orig/net/netlink/af_netlink.c linux-2.6.27.3/net/netlink/af_netlink.c
    --- linux-2.6.27.3.orig/net/netlink/af_netlink.c 2008-10-23 18:01:54.000000000 +0200
    +++ linux-2.6.27.3/net/netlink/af_netlink.c 2008-10-23 18:04:22.000000000 +0200
    @@ -1656,7 +1656,7 @@ void netlink_ack(struct sk_buff *in_skb,
    }

    rep = __nlmsg_put(skb, NETLINK_CB(in_skb).pid, nlh->nlmsg_seq,
    - NLMSG_ERROR, sizeof(struct nlmsgerr), 0);
    + NLMSG_ERROR, payload, 0);
    errmsg = nlmsg_data(rep);
    errmsg->error = err;
    memcpy(&errmsg->msg, nlh, err ? nlh->nlmsg_len : sizeof(*nlh));
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. Re: [PATCH] netlink: fix append of whole original message on negative ack.

    From: M Lammertink
    Date: Thu, 23 Oct 2008 20:17:51 +0200

    You'll get a much better review of this if you send it to
    the netdev mailing list, which is where all the networking
    developers are subscribed. They don't read linux-kernel

    Added to CC:

    > From: Michel Lammertink ti-wmc.nl>
    > Signed-off-by: Michel Lammertink ti-wmc.nl>
    >
    > Netlink can return an negative acknowledgement, which AFAICT should include an error code and the whole original message. This patch fixes the size argument given to the __nlmsg_put call. Without this patch only the original header was attached.
    > ---
    >
    > Can anyone explain to me why struct nlmsgerr contains an int error and the nlmsghdr struct. The comment in netlink_ack states that the whole message should be appended. Why not only include an int error in struct nlmsgerr and just append the original message?
    >
    > Comments appreciated.
    >
    > diff -uprN linux-2.6.27.3.orig/net/netlink/af_netlink.c linux-2.6.27.3/net/netlink/af_netlink.c
    > --- linux-2.6.27.3.orig/net/netlink/af_netlink.c 2008-10-23 18:01:54.000000000 +0200
    > +++ linux-2.6.27.3/net/netlink/af_netlink.c 2008-10-23 18:04:22.000000000 +0200
    > @@ -1656,7 +1656,7 @@ void netlink_ack(struct sk_buff *in_skb,
    > }
    >
    > rep = __nlmsg_put(skb, NETLINK_CB(in_skb).pid, nlh->nlmsg_seq,
    > - NLMSG_ERROR, sizeof(struct nlmsgerr), 0);
    > + NLMSG_ERROR, payload, 0);
    > errmsg = nlmsg_data(rep);
    > errmsg->error = err;
    > memcpy(&errmsg->msg, nlh, err ? nlh->nlmsg_len : sizeof(*nlh));
    > --
    > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    > the body of a message to majordomo@vger.kernel.org
    > More majordomo info at http://vger.kernel.org/majordomo-info.html
    > Please read the FAQ at http://www.tux.org/lkml/

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  3. Re: [PATCH] netlink: fix append of whole original message on negative ack.

    Hi.

    On Thu, Oct 23, 2008 at 01:45:13PM -0700, David Miller (davem@davemloft.net) wrote:
    > > Netlink can return an negative acknowledgement, which AFAICT should include an error code and the whole original message. This patch fixes the size argument given to the __nlmsg_put call. Without this patch only the original header was attached.
    > > ---
    > >
    > > Can anyone explain to me why struct nlmsgerr contains an int error and the nlmsghdr struct. The comment in netlink_ack states that the whole message should be appended. Why not only include an int error in struct nlmsgerr and just append the original message?


    Having header (even seq/pid only) is enough to find a message
    for that userspace which cares. Looks like your patch can break
    existing applications which are used to work with header only,
    even if that was a mistake? Although application is supposed to
    check the length, it still can expect only a header. I have to
    note, that I do not know any such application though.

    --
    Evgeniy Polyakov
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  4. Re: [PATCH] netlink: fix append of whole original message on negative ack.

    David Miller wrote:
    > From: M Lammertink
    > Date: Thu, 23 Oct 2008 20:17:51 +0200
    >
    >> Can anyone explain to me why struct nlmsgerr contains an int error and the nlmsghdr struct. The comment in netlink_ack states that the whole message should be appended. Why not only include an int error in struct nlmsgerr and just append the original message?
    >>
    >> Comments appreciated.
    >>
    >> diff -uprN linux-2.6.27.3.orig/net/netlink/af_netlink.c linux-2.6.27.3/net/netlink/af_netlink.c
    >> --- linux-2.6.27.3.orig/net/netlink/af_netlink.c 2008-10-23 18:01:54.000000000 +0200
    >> +++ linux-2.6.27.3/net/netlink/af_netlink.c 2008-10-23 18:04:22.000000000 +0200
    >> @@ -1656,7 +1656,7 @@ void netlink_ack(struct sk_buff *in_skb,
    >> }
    >>
    >> rep = __nlmsg_put(skb, NETLINK_CB(in_skb).pid, nlh->nlmsg_seq,
    >> - NLMSG_ERROR, sizeof(struct nlmsgerr), 0);
    >> + NLMSG_ERROR, payload, 0)


    You can't include the full message since the resulting message
    might exceed the 64k netlink limit.

    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread