From patchwork Wed Jan 23 14:43:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cong Wang X-Patchwork-Id: 214973 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 23D152C007E for ; Thu, 24 Jan 2013 01:43:34 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753093Ab3AWOnb (ORCPT ); Wed, 23 Jan 2013 09:43:31 -0500 Received: from mail-da0-f43.google.com ([209.85.210.43]:34302 "EHLO mail-da0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751225Ab3AWOna (ORCPT ); Wed, 23 Jan 2013 09:43:30 -0500 Received: by mail-da0-f43.google.com with SMTP id u36so3844639dak.30 for ; Wed, 23 Jan 2013 06:43:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=YIWEEKRJi81nIqSEQqP69oqwKQ1YCzCNZkK5xBiprSc=; b=h3U+HcdEKCUabl6UAPc/fq4fzbK0g1mVe8JnRHN1xtbd0gjInqH10xQZMSlZFJpGcE H6YcqJv/c6Mu/F7IR2EAVYxXjLldXUJTAkDqY5ouy2Kwh5dx8Pmo5iUOPOyp+px+xFpt 2qz7ap4Cy2MeKHzUbOMbDVhXqI40nk1vFe0qe9MzCG899lEc8CMLuW/sPxLvBLWz2bEc nzRGvFlc8CGltZsAWCwhipgjr8x+GgrcTffTHZ1iQ5hDJTLg41LfoaGk+hZQgld8BlyF fVmGoAN1ol9oMHsSMa/0a+Xjoc0N4BkKAozy7Pdr8gliy13zHz+e8CSFb1G5WgOM83RI Mh9A== X-Received: by 10.66.80.65 with SMTP id p1mr5251556pax.20.1358952209802; Wed, 23 Jan 2013 06:43:29 -0800 (PST) Received: from cr0.redhat.com ([14.205.38.12]) by mx.google.com with ESMTPS id ux4sm12929412pbc.25.2013.01.23.06.43.24 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 23 Jan 2013 06:43:28 -0800 (PST) From: Cong Wang To: netdev@vger.kernel.org Cc: Yannick Koehler , Eric Dumazet , "David S. Miller" , Cong Wang Subject: [Patch net] unix: correct sk_rmem_alloc accounting Date: Wed, 23 Jan 2013 22:43:11 +0800 Message-Id: <1358952191-3374-1-git-send-email-xiyou.wangcong@gmail.com> X-Mailer: git-send-email 1.7.7.6 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Cong Wang Yannick reported [1] we probably forgot to account ->sk_rmem_alloc before moving the skb to other->sk_receive_queue. I believe he is right. So, just call skb_set_owner_r() before every time we queuing skb into other->sk_receive_queue. 1. http://marc.info/?l=linux-netdev&m=135882012924930&w=2 Reported-by: Yannick Koehler Cc: Yannick Koehler Cc: Eric Dumazet Cc: David S. Miller Signed-off-by: Cong Wang --- -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 5b5c876..7e9dba3 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -1205,6 +1205,7 @@ restart: unix_state_unlock(sk); + skb_set_owner_r(skb, other); /* take ten and and send info to listening sock */ spin_lock(&other->sk_receive_queue.lock); __skb_queue_tail(&other->sk_receive_queue, skb); @@ -1579,6 +1580,7 @@ restart: if (sock_flag(other, SOCK_RCVTSTAMP)) __net_timestamp(skb); maybe_add_creds(skb, sock, other); + skb_set_owner_r(skb, other); skb_queue_tail(&other->sk_receive_queue, skb); if (max_level > unix_sk(other)->recursion_level) unix_sk(other)->recursion_level = max_level; @@ -1694,6 +1696,7 @@ static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, goto pipe_err_free; maybe_add_creds(skb, sock, other); + skb_set_owner_r(skb, other); skb_queue_tail(&other->sk_receive_queue, skb); if (max_level > unix_sk(other)->recursion_level) unix_sk(other)->recursion_level = max_level;