Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[cascardo/linux.git] / net / sctp / sctp_diag.c
index cef0cee..048954e 100644 (file)
@@ -106,7 +106,8 @@ static int inet_sctp_diag_fill(struct sock *sk, struct sctp_association *asoc,
                               const struct inet_diag_req_v2 *req,
                               struct user_namespace *user_ns,
                               int portid, u32 seq, u16 nlmsg_flags,
-                              const struct nlmsghdr *unlh)
+                              const struct nlmsghdr *unlh,
+                              bool net_admin)
 {
        struct sctp_endpoint *ep = sctp_sk(sk)->ep;
        struct list_head *addr_list;
@@ -133,7 +134,7 @@ static int inet_sctp_diag_fill(struct sock *sk, struct sctp_association *asoc,
                r->idiag_retrans = 0;
        }
 
-       if (inet_diag_msg_attrs_fill(sk, skb, r, ext, user_ns))
+       if (inet_diag_msg_attrs_fill(sk, skb, r, ext, user_ns, net_admin))
                goto errout;
 
        if (ext & (1 << (INET_DIAG_SKMEMINFO - 1))) {
@@ -203,6 +204,7 @@ struct sctp_comm_param {
        struct netlink_callback *cb;
        const struct inet_diag_req_v2 *r;
        const struct nlmsghdr *nlh;
+       bool net_admin;
 };
 
 static size_t inet_assoc_attr_size(struct sctp_association *asoc)
@@ -219,6 +221,7 @@ static size_t inet_assoc_attr_size(struct sctp_association *asoc)
                + nla_total_size(1) /* INET_DIAG_SHUTDOWN */
                + nla_total_size(1) /* INET_DIAG_TOS */
                + nla_total_size(1) /* INET_DIAG_TCLASS */
+               + nla_total_size(4) /* INET_DIAG_MARK */
                + nla_total_size(addrlen * asoc->peer.transport_count)
                + nla_total_size(addrlen * addrcnt)
                + nla_total_size(sizeof(struct inet_diag_meminfo))
@@ -256,7 +259,8 @@ static int sctp_tsp_dump_one(struct sctp_transport *tsp, void *p)
        err = inet_sctp_diag_fill(sk, assoc, rep, req,
                                  sk_user_ns(NETLINK_CB(in_skb).sk),
                                  NETLINK_CB(in_skb).portid,
-                                 nlh->nlmsg_seq, 0, nlh);
+                                 nlh->nlmsg_seq, 0, nlh,
+                                 commp->net_admin);
        release_sock(sk);
        if (err < 0) {
                WARN_ON(err == -EMSGSIZE);
@@ -299,7 +303,8 @@ static int sctp_sock_dump(struct sock *sk, void *p)
                                        sk_user_ns(NETLINK_CB(cb->skb).sk),
                                        NETLINK_CB(cb->skb).portid,
                                        cb->nlh->nlmsg_seq,
-                                       NLM_F_MULTI, cb->nlh) < 0) {
+                                       NLM_F_MULTI, cb->nlh,
+                                       commp->net_admin) < 0) {
                        cb->args[3] = 1;
                        err = 1;
                        goto release;
@@ -309,7 +314,8 @@ static int sctp_sock_dump(struct sock *sk, void *p)
                if (inet_sctp_diag_fill(sk, assoc, skb, r,
                                        sk_user_ns(NETLINK_CB(cb->skb).sk),
                                        NETLINK_CB(cb->skb).portid,
-                                       cb->nlh->nlmsg_seq, 0, cb->nlh) < 0) {
+                                       cb->nlh->nlmsg_seq, 0, cb->nlh,
+                                       commp->net_admin) < 0) {
                        err = 1;
                        goto release;
                }
@@ -389,7 +395,7 @@ static int sctp_ep_dump(struct sctp_endpoint *ep, void *p)
                                sk_user_ns(NETLINK_CB(cb->skb).sk),
                                NETLINK_CB(cb->skb).portid,
                                cb->nlh->nlmsg_seq, NLM_F_MULTI,
-                               cb->nlh) < 0) {
+                               cb->nlh, commp->net_admin) < 0) {
                err = 2;
                goto out;
        }
@@ -426,6 +432,7 @@ static int sctp_diag_dump_one(struct sk_buff *in_skb,
                .skb = in_skb,
                .r = req,
                .nlh = nlh,
+               .net_admin = netlink_net_capable(in_skb, CAP_NET_ADMIN),
        };
 
        if (req->sdiag_family == AF_INET) {
@@ -461,6 +468,7 @@ static void sctp_diag_dump(struct sk_buff *skb, struct netlink_callback *cb,
                .skb = skb,
                .cb = cb,
                .r = r,
+               .net_admin = netlink_net_capable(cb->skb, CAP_NET_ADMIN),
        };
 
        /* eps hashtable dumps