Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2459116imd; Fri, 2 Nov 2018 11:46:08 -0700 (PDT) X-Google-Smtp-Source: AJdET5fxjNngh/GJEGKLg6wmMzbgeCH0/wFqlrHdtKmseZ22LBOZeOfcD2QUk/aUzDItaBI5ilHc X-Received: by 2002:a17:902:584:: with SMTP id f4-v6mr12660101plf.132.1541184368559; Fri, 02 Nov 2018 11:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541184368; cv=none; d=google.com; s=arc-20160816; b=ePrSGm2oNJsDBRhj/s5vECTWDrrQzXh/rtGy7M/P/TOWaeQaMzd92SfprKozh/bo1W hFiseQyQcwVVXW0KUTCdfEsTyi3ZGBjtZP1eX+I01K9el85zEZL3i4FchlIuMfnRqFrq AHNw9HyW4n9oqH6ixldVcQTXB0TJCrgVa80YJos8neferuUGVzAO07u+yl+eCOAr1ZCl 5fOy1LViVUtJKYadeIUG54Rn3/hYul/eaoW1oPzvP9ywX1/89TMvP8FzJsi4SLCzBkhc R76g1JBI0ycdjbqsNwXz15gCpOgb5XUEL+dgA+d1djdb/6Tpi+U03/6NosiGkrEleMh7 vUPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fJyDIZEIA2TgmyQXEAMDFXnbkjoLSLJGyQAutekPo9Y=; b=eqFt4wcgpDIM9rxuGQ0gBx3yHc92FNw5O90dLzKlA1HXTcu0z1zCtHZk+8c9ZpYW52 6OrsTbsUCPaiEB9X0F84pIVVZBEkoU7o1VKYNncuEzoCNqoOKCIGHP9h7hYFwb4AP3Ob vSH6VzkZtrNjkUvSIjy/lETOlnTnLK6+Y1rEuhIrIeADLpSCoXh34nD01/P85yuuGG9H gxt5mDlrSqpuLhLe/7jsksLl8637ocXAh0ZPP3L02NHSwnFCwYA5ySiCJyWokGt1oL6L 2YqggahAF/d599u15XnD2vVQ9flXfN/Ac6XorW5cQX9YplBiuxSbKhxkpNxUYwRYxtEl n8Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M2xvjQCT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w20-v6si32654050plp.260.2018.11.02.11.45.53; Fri, 02 Nov 2018 11:46:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=M2xvjQCT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729588AbeKCDvo (ORCPT + 99 others); Fri, 2 Nov 2018 23:51:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:46950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728788AbeKCDvo (ORCPT ); Fri, 2 Nov 2018 23:51:44 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 13FF320847; Fri, 2 Nov 2018 18:43:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541184212; bh=38uJUiTLkeBDFZ3M6oaCxtfApjmNJ2audKWx11csZXE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M2xvjQCTYQoQUNpoIl0M5x1CI9sI0jOHE8Z/uMmCVWMBNOTbiGcRBQ/QzqK3V0Xmt YGrJnXn2VnyE7LcySW8bGLyaTq34X/pSKkaO6MEdkFKX/Za7KN+Zz01Ikj9Tu3X4gS mpbqmo9mnb8NIxSsD7kruKHMxYB/9wT/KXmejhZ8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+11e05f04c15e03be5254@syzkaller.appspotmail.com, Cong Wang , "David S. Miller" Subject: [PATCH 4.18 107/150] llc: set SOCK_RCU_FREE in llc_sap_add_socket() Date: Fri, 2 Nov 2018 19:34:29 +0100 Message-Id: <20181102182910.709949717@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cong Wang [ Upstream commit 5a8e7aea953bdb6d4da13aff6f1e7f9c62023499 ] WHen an llc sock is added into the sk_laddr_hash of an llc_sap, it is not marked with SOCK_RCU_FREE. This causes that the sock could be freed while it is still being read by __llc_lookup_established() with RCU read lock. sock is refcounted, but with RCU read lock, nothing prevents the readers getting a zero refcnt. Fix it by setting SOCK_RCU_FREE in llc_sap_add_socket(). Reported-by: syzbot+11e05f04c15e03be5254@syzkaller.appspotmail.com Signed-off-by: Cong Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/llc/llc_conn.c | 1 + 1 file changed, 1 insertion(+) --- a/net/llc/llc_conn.c +++ b/net/llc/llc_conn.c @@ -734,6 +734,7 @@ void llc_sap_add_socket(struct llc_sap * llc_sk(sk)->sap = sap; spin_lock_bh(&sap->sk_lock); + sock_set_flag(sk, SOCK_RCU_FREE); sap->sk_count++; sk_nulls_add_node_rcu(sk, laddr_hb); hlist_add_head(&llc->dev_hash_node, dev_hb);