From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:46994 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753455AbbKQWl1 (ORCPT ); Tue, 17 Nov 2015 17:41:27 -0500 Subject: Patch "netlink: fix locking around NETLINK_LIST_MEMBERSHIPS" has been added to the 4.2-stable tree To: dh.herrmann@gmail.com, davem@davemloft.net, dvyukov@google.com, gregkh@linuxfoundation.org Cc: , From: Date: Tue, 17 Nov 2015 14:41:26 -0800 Message-ID: <1447800086242245@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled netlink: fix locking around NETLINK_LIST_MEMBERSHIPS to the 4.2-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: netlink-fix-locking-around-netlink_list_memberships.patch and it can be found in the queue-4.2 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From foo@baz Tue Nov 17 14:34:38 PST 2015 From: David Herrmann Date: Wed, 21 Oct 2015 11:47:43 +0200 Subject: netlink: fix locking around NETLINK_LIST_MEMBERSHIPS From: David Herrmann [ Upstream commit 47191d65b647af5eb5c82ede70ed4c24b1e93ef4 ] Currently, NETLINK_LIST_MEMBERSHIPS grabs the netlink table while copying the membership state to user-space. However, grabing the netlink table is effectively a write_lock_irq(), and as such we should not be triggering page-faults in the critical section. This can be easily reproduced by the following snippet: int s = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); void *p = mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0); int r = getsockopt(s, 0x10e, 9, p, (void*)((char*)p + 4092)); This should work just fine, but currently triggers EFAULT and a possible WARN_ON below handle_mm_fault(). Fix this by reducing locking of NETLINK_LIST_MEMBERSHIPS to a read-side lock. The write-lock was overkill in the first place, and the read-lock allows page-faults just fine. Reported-by: Dmitry Vyukov Signed-off-by: David Herrmann Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/netlink/af_netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -2346,7 +2346,7 @@ static int netlink_getsockopt(struct soc int pos, idx, shift; err = 0; - netlink_table_grab(); + netlink_lock_table(); for (pos = 0; pos * 8 < nlk->ngroups; pos += sizeof(u32)) { if (len - pos < sizeof(u32)) break; @@ -2361,7 +2361,7 @@ static int netlink_getsockopt(struct soc } if (put_user(ALIGN(nlk->ngroups / 8, sizeof(u32)), optlen)) err = -EFAULT; - netlink_table_ungrab(); + netlink_unlock_table(); break; } default: Patches currently in stable-queue which might be from dh.herrmann@gmail.com are queue-4.2/netlink-fix-locking-around-netlink_list_memberships.patch