diff options
Diffstat (limited to 'net/netlink')
-rw-r--r-- | net/netlink/attr.c | 12 | ||||
-rw-r--r-- | net/netlink/genetlink.c | 21 |
2 files changed, 16 insertions, 17 deletions
diff --git a/net/netlink/attr.c b/net/netlink/attr.c index feb326f4a752..47bbf45ae5d7 100644 --- a/net/netlink/attr.c +++ b/net/netlink/attr.c | |||
@@ -400,13 +400,13 @@ void __nla_put_nohdr(struct sk_buff *skb, int attrlen, const void *data) | |||
400 | * @attrlen: length of attribute payload | 400 | * @attrlen: length of attribute payload |
401 | * @data: head of attribute payload | 401 | * @data: head of attribute payload |
402 | * | 402 | * |
403 | * Returns -1 if the tailroom of the skb is insufficient to store | 403 | * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store |
404 | * the attribute header and payload. | 404 | * the attribute header and payload. |
405 | */ | 405 | */ |
406 | int nla_put(struct sk_buff *skb, int attrtype, int attrlen, const void *data) | 406 | int nla_put(struct sk_buff *skb, int attrtype, int attrlen, const void *data) |
407 | { | 407 | { |
408 | if (unlikely(skb_tailroom(skb) < nla_total_size(attrlen))) | 408 | if (unlikely(skb_tailroom(skb) < nla_total_size(attrlen))) |
409 | return -1; | 409 | return -EMSGSIZE; |
410 | 410 | ||
411 | __nla_put(skb, attrtype, attrlen, data); | 411 | __nla_put(skb, attrtype, attrlen, data); |
412 | return 0; | 412 | return 0; |
@@ -418,13 +418,13 @@ int nla_put(struct sk_buff *skb, int attrtype, int attrlen, const void *data) | |||
418 | * @attrlen: length of attribute payload | 418 | * @attrlen: length of attribute payload |
419 | * @data: head of attribute payload | 419 | * @data: head of attribute payload |
420 | * | 420 | * |
421 | * Returns -1 if the tailroom of the skb is insufficient to store | 421 | * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store |
422 | * the attribute payload. | 422 | * the attribute payload. |
423 | */ | 423 | */ |
424 | int nla_put_nohdr(struct sk_buff *skb, int attrlen, const void *data) | 424 | int nla_put_nohdr(struct sk_buff *skb, int attrlen, const void *data) |
425 | { | 425 | { |
426 | if (unlikely(skb_tailroom(skb) < NLA_ALIGN(attrlen))) | 426 | if (unlikely(skb_tailroom(skb) < NLA_ALIGN(attrlen))) |
427 | return -1; | 427 | return -EMSGSIZE; |
428 | 428 | ||
429 | __nla_put_nohdr(skb, attrlen, data); | 429 | __nla_put_nohdr(skb, attrlen, data); |
430 | return 0; | 430 | return 0; |
@@ -436,13 +436,13 @@ int nla_put_nohdr(struct sk_buff *skb, int attrlen, const void *data) | |||
436 | * @attrlen: length of attribute payload | 436 | * @attrlen: length of attribute payload |
437 | * @data: head of attribute payload | 437 | * @data: head of attribute payload |
438 | * | 438 | * |
439 | * Returns -1 if the tailroom of the skb is insufficient to store | 439 | * Returns -EMSGSIZE if the tailroom of the skb is insufficient to store |
440 | * the attribute payload. | 440 | * the attribute payload. |
441 | */ | 441 | */ |
442 | int nla_append(struct sk_buff *skb, int attrlen, const void *data) | 442 | int nla_append(struct sk_buff *skb, int attrlen, const void *data) |
443 | { | 443 | { |
444 | if (unlikely(skb_tailroom(skb) < NLA_ALIGN(attrlen))) | 444 | if (unlikely(skb_tailroom(skb) < NLA_ALIGN(attrlen))) |
445 | return -1; | 445 | return -EMSGSIZE; |
446 | 446 | ||
447 | memcpy(skb_put(skb, attrlen), data, attrlen); | 447 | memcpy(skb_put(skb, attrlen), data, attrlen); |
448 | return 0; | 448 | return 0; |
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index d16929c9b4bc..3e1191cecaf0 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c | |||
@@ -444,8 +444,11 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
444 | if (ops->dumpit == NULL) | 444 | if (ops->dumpit == NULL) |
445 | return -EOPNOTSUPP; | 445 | return -EOPNOTSUPP; |
446 | 446 | ||
447 | return netlink_dump_start(genl_sock, skb, nlh, | 447 | genl_unlock(); |
448 | ops->dumpit, ops->done); | 448 | err = netlink_dump_start(genl_sock, skb, nlh, |
449 | ops->dumpit, ops->done); | ||
450 | genl_lock(); | ||
451 | return err; | ||
449 | } | 452 | } |
450 | 453 | ||
451 | if (ops->doit == NULL) | 454 | if (ops->doit == NULL) |
@@ -554,7 +557,8 @@ static int ctrl_fill_info(struct genl_family *family, u32 pid, u32 seq, | |||
554 | return genlmsg_end(skb, hdr); | 557 | return genlmsg_end(skb, hdr); |
555 | 558 | ||
556 | nla_put_failure: | 559 | nla_put_failure: |
557 | return genlmsg_cancel(skb, hdr); | 560 | genlmsg_cancel(skb, hdr); |
561 | return -EMSGSIZE; | ||
558 | } | 562 | } |
559 | 563 | ||
560 | static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 pid, | 564 | static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 pid, |
@@ -590,7 +594,8 @@ static int ctrl_fill_mcgrp_info(struct genl_multicast_group *grp, u32 pid, | |||
590 | return genlmsg_end(skb, hdr); | 594 | return genlmsg_end(skb, hdr); |
591 | 595 | ||
592 | nla_put_failure: | 596 | nla_put_failure: |
593 | return genlmsg_cancel(skb, hdr); | 597 | genlmsg_cancel(skb, hdr); |
598 | return -EMSGSIZE; | ||
594 | } | 599 | } |
595 | 600 | ||
596 | static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb) | 601 | static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb) |
@@ -601,9 +606,6 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb) | |||
601 | int chains_to_skip = cb->args[0]; | 606 | int chains_to_skip = cb->args[0]; |
602 | int fams_to_skip = cb->args[1]; | 607 | int fams_to_skip = cb->args[1]; |
603 | 608 | ||
604 | if (chains_to_skip != 0) | ||
605 | genl_lock(); | ||
606 | |||
607 | for (i = 0; i < GENL_FAM_TAB_SIZE; i++) { | 609 | for (i = 0; i < GENL_FAM_TAB_SIZE; i++) { |
608 | if (i < chains_to_skip) | 610 | if (i < chains_to_skip) |
609 | continue; | 611 | continue; |
@@ -621,9 +623,6 @@ static int ctrl_dumpfamily(struct sk_buff *skb, struct netlink_callback *cb) | |||
621 | } | 623 | } |
622 | 624 | ||
623 | errout: | 625 | errout: |
624 | if (chains_to_skip != 0) | ||
625 | genl_unlock(); | ||
626 | |||
627 | cb->args[0] = i; | 626 | cb->args[0] = i; |
628 | cb->args[1] = n; | 627 | cb->args[1] = n; |
629 | 628 | ||
@@ -768,7 +767,7 @@ static int __init genl_init(void) | |||
768 | 767 | ||
769 | /* we'll bump the group number right afterwards */ | 768 | /* we'll bump the group number right afterwards */ |
770 | genl_sock = netlink_kernel_create(&init_net, NETLINK_GENERIC, 0, | 769 | genl_sock = netlink_kernel_create(&init_net, NETLINK_GENERIC, 0, |
771 | genl_rcv, NULL, THIS_MODULE); | 770 | genl_rcv, &genl_mutex, THIS_MODULE); |
772 | if (genl_sock == NULL) | 771 | if (genl_sock == NULL) |
773 | panic("GENL: Cannot initialize generic netlink\n"); | 772 | panic("GENL: Cannot initialize generic netlink\n"); |
774 | 773 | ||