Skip to content

Commit 0aff004

Browse files
committed
Merge branch 'atm-fix-uninit-and-mem-accounting-leak-in-vcc_sendmsg'
Kuniyuki Iwashima says: ==================== atm: Fix uninit and mem accounting leak in vcc_sendmsg(). Patch 1 fixes uninit issue reported by KMSAN, and patch 2 fixes another issue found by Simon Horman during review for v1 patch. v1: https://lore.kernel.org/[email protected] ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 6dbb0d9 + 7851263 commit 0aff004

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

drivers/atm/atmtcp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,9 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
288288
struct sk_buff *new_skb;
289289
int result = 0;
290290

291-
if (!skb->len) return 0;
291+
if (skb->len < sizeof(struct atmtcp_hdr))
292+
goto done;
293+
292294
dev = vcc->dev_data;
293295
hdr = (struct atmtcp_hdr *) skb->data;
294296
if (hdr->length == ATMTCP_HDR_MAGIC) {

include/linux/atmdev.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ static inline void atm_account_tx(struct atm_vcc *vcc, struct sk_buff *skb)
249249
ATM_SKB(skb)->atm_options = vcc->atm_options;
250250
}
251251

252+
static inline void atm_return_tx(struct atm_vcc *vcc, struct sk_buff *skb)
253+
{
254+
WARN_ON_ONCE(refcount_sub_and_test(ATM_SKB(skb)->acct_truesize,
255+
&sk_atm(vcc)->sk_wmem_alloc));
256+
}
257+
252258
static inline void atm_force_charge(struct atm_vcc *vcc,int truesize)
253259
{
254260
atomic_add(truesize, &sk_atm(vcc)->sk_rmem_alloc);

net/atm/common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,7 @@ int vcc_sendmsg(struct socket *sock, struct msghdr *m, size_t size)
635635

636636
skb->dev = NULL; /* for paths shared with net_device interfaces */
637637
if (!copy_from_iter_full(skb_put(skb, size), size, &m->msg_iter)) {
638+
atm_return_tx(vcc, skb);
638639
kfree_skb(skb);
639640
error = -EFAULT;
640641
goto out;

net/atm/raw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static void atm_pop_raw(struct atm_vcc *vcc, struct sk_buff *skb)
3636

3737
pr_debug("(%d) %d -= %d\n",
3838
vcc->vci, sk_wmem_alloc_get(sk), ATM_SKB(skb)->acct_truesize);
39-
WARN_ON(refcount_sub_and_test(ATM_SKB(skb)->acct_truesize, &sk->sk_wmem_alloc));
39+
atm_return_tx(vcc, skb);
4040
dev_kfree_skb_any(skb);
4141
sk->sk_write_space(sk);
4242
}

0 commit comments

Comments
 (0)