From patchwork Fri Dec 22 19:47:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 852547 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=quantonium-net.20150623.gappssmtp.com header.i=@quantonium-net.20150623.gappssmtp.com header.b="ILW7nFWV"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3z3Jw20Ybsz9ryr for ; Sat, 23 Dec 2017 06:48:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756237AbdLVTsM (ORCPT ); Fri, 22 Dec 2017 14:48:12 -0500 Received: from mail-pf0-f172.google.com ([209.85.192.172]:41651 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755464AbdLVTsK (ORCPT ); Fri, 22 Dec 2017 14:48:10 -0500 Received: by mail-pf0-f172.google.com with SMTP id j28so15675050pfk.8 for ; Fri, 22 Dec 2017 11:48:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantonium-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=FIwBzIX1VcaoUWiLvuugsfyVLsvp603QMomlkmStPmQ=; b=ILW7nFWV+5IgoGIDx6zAoh+eTIvNQXVEPqEkad12aDZyjArYHSblXOiK2h0wplJAbj Fq3k3SJroVVRFURDiZte6pxr6gY/FTqH8dDX2QcRqBeWWyJFGuNgFo5hoxqBm3pPhnQv jluup9kEN2ZrdNH58pGUWzJcqdjwNwx7oer7WSYL/ZTBEr/6I+GouvLxpuLezVVvzryF ypzTnHL2xbwkFPhTWfv7lczcBDbBcyiHeVI38cMk2C6faXzij3KZt0Bi0mAC58do4K7+ R1bmv1U/fzOjYnX+nvwYcltR9L1jyQbZxn1yhc8qvx+P7R56+xtkZRSvFS19uYnPyTbV E6HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FIwBzIX1VcaoUWiLvuugsfyVLsvp603QMomlkmStPmQ=; b=WUKP/qLcjzLJirU2VsSD029EdWPTHVe9IHBHfa0ux3hLnxIvsHeszufNrQY64uBkJr zESif7AzRrooidF6U0dvj5Kj37hFaYQyqa44Rh1Aizis71YXgxp3V4zmxk5HLyZVo1WK NZ9IA1VFwazgNwNZSNyBzuEXoyo7He7KuHqX/yt/OOhOsF04ozpTOb+eDNFJfmfg7p2D aePPmsLOOM9/hCd9+RwCSORvLK8PWOlXlAqb6KwYoKrVkcqr8HQyNuocedkKuU6Affbf 26s3nrsV+95CNQ7SQ3dS9zQjPXxxCCALfh/WZjnmYmJPUnDSw+9EukbKYDzAkZM6vlHD ZLeg== X-Gm-Message-State: AKGB3mIJuiVwSP2Lr93bP6ORzDzn4P3KKx15/ZpfRUCDE6IzMXVGFv9e ld7Mqu5VVJjBPTXw32NQeT89HQ== X-Google-Smtp-Source: ACJfBoskWNWw4lbuSS5SMBfRf2XY4XOkKkEzt1JcTGWUYAhmF8NHOsFWPOzVEeGfmHxAgUfkqRYB+A== X-Received: by 10.99.108.7 with SMTP id h7mr13488039pgc.343.1513972089971; Fri, 22 Dec 2017 11:48:09 -0800 (PST) Received: from localhost.localdomain (c-73-162-13-107.hsd1.ca.comcast.net. [73.162.13.107]) by smtp.gmail.com with ESMTPSA id e7sm50080812pfj.44.2017.12.22.11.48.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Dec 2017 11:48:08 -0800 (PST) From: Tom Herbert To: davem@davemloft.net Cc: netdev@vger.kernel.org, dvyukov@google.com, john.fastabend@gmail.com, rohit@quantonium.net, Tom Herbert Subject: [PATCH net-next 0/4] kcm: Fix two locking issues Date: Fri, 22 Dec 2017 11:47:51 -0800 Message-Id: <20171222194755.8544-1-tom@quantonium.net> X-Mailer: git-send-email 2.11.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org One issue is lockdep warnings when sock_owned_by_user returns true in strparser. Fix is to add and call sock_owned_by_user_nocheck since the check for owned by user is not an error condition in this case. The other issue is a potential deadlock between TX and RX paths KCM socket lock and the psock socket lock are acquired in both the RX and TX path, however they take the locks in opposite order which can lead to deadlock. The fix is to add try_sock_lock to see if psock socket lock can get acquired in the TX path with KCM lock held. If not, then KCM socket is released and the psock socket lock and KCM socket lock are acquired in the same order as the RX path. Tested: Ran KCM traffic without incident. Tom Herbert (4): sock: Add sock_owned_by_user_nocheck strparser: Call sock_owned_by_user_nocheck sock_lock: Add try_sock_lock kcm: Address deadlock between TX and RX paths include/net/kcm.h | 1 + include/net/sock.h | 12 +++++++++ net/core/sock.c | 20 +++++++++++++++ net/kcm/kcmsock.c | 64 ++++++++++++++++++++++++++++++++++------------- net/strparser/strparser.c | 2 +- 5 files changed, 81 insertions(+), 18 deletions(-)