Commit 7c8011895330d3069b137233e2673f40ee6f4c91
1 parent
48f03bdad8
nfnetlink_acct: Stop using NLA_PUT*().
These macros contain a hidden goto, and are thus extremely error prone and make code hard to audit. Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 6 additions and 4 deletions Side-by-side Diff
net/netfilter/nfnetlink_acct.c
... | ... | @@ -109,7 +109,8 @@ |
109 | 109 | nfmsg->version = NFNETLINK_V0; |
110 | 110 | nfmsg->res_id = 0; |
111 | 111 | |
112 | - NLA_PUT_STRING(skb, NFACCT_NAME, acct->name); | |
112 | + if (nla_put_string(skb, NFACCT_NAME, acct->name)) | |
113 | + goto nla_put_failure; | |
113 | 114 | |
114 | 115 | if (type == NFNL_MSG_ACCT_GET_CTRZERO) { |
115 | 116 | pkts = atomic64_xchg(&acct->pkts, 0); |
... | ... | @@ -118,9 +119,10 @@ |
118 | 119 | pkts = atomic64_read(&acct->pkts); |
119 | 120 | bytes = atomic64_read(&acct->bytes); |
120 | 121 | } |
121 | - NLA_PUT_BE64(skb, NFACCT_PKTS, cpu_to_be64(pkts)); | |
122 | - NLA_PUT_BE64(skb, NFACCT_BYTES, cpu_to_be64(bytes)); | |
123 | - NLA_PUT_BE32(skb, NFACCT_USE, htonl(atomic_read(&acct->refcnt))); | |
122 | + if (nla_put_be64(skb, NFACCT_PKTS, cpu_to_be64(pkts)) || | |
123 | + nla_put_be64(skb, NFACCT_BYTES, cpu_to_be64(bytes)) || | |
124 | + nla_put_be32(skb, NFACCT_USE, htonl(atomic_read(&acct->refcnt)))) | |
125 | + goto nla_put_failure; | |
124 | 126 | |
125 | 127 | nlmsg_end(skb, nlh); |
126 | 128 | return skb->len; |