Received: by 10.223.185.116 with SMTP id b49csp820855wrg; Sat, 10 Feb 2018 21:09:38 -0800 (PST) X-Google-Smtp-Source: AH8x227HIMGllDWSzd3tp+Hr/bzksgXgWhXl0OU0EcrS8pt//lqKUnFV7bD7riDwfVwmX835NXyl X-Received: by 10.98.87.195 with SMTP id i64mr7876808pfj.34.1518325778481; Sat, 10 Feb 2018 21:09:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518325778; cv=none; d=google.com; s=arc-20160816; b=BBFms0JxLzh2+N5J+6Xai9Rrdp2m2YWegUD58EpWzDa26KNWjQ+kvvkqYtZip87XM9 rzwGR2Rhcx2w7rfGD9Y/xdSU8iaPNrLgjgPQZ9Q4xmbtFQplgTgkt+3hwpc2yDrUgtnc Eh/n48mZBqC7UHOWb5xNk/WiLqbEOjphqlSqNhKzy/iYMtEvQYIY4QmXK2d3/zG5kWyA JrzkuQmeC9+oLYs5WJ+3mU9ImQ8zDmCGO3UDKcLkHxpxTXab+/c2bhQd7cj59FsJ5b4o JbClUq8KAD7e8Hu/uTdOzG/yvXGsISbAr5vxbUuQJpqL9JiJHxsml1CtUaNiCoLDPpvL ZjZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=I38j7KqPMgZaGKRBdldA0r1vYU/o3jDifGioPPlLI1o=; b=0nRe9iDXgic9WzgjmmRD49cwYRRsbyf0TxyPHqaGQDtWnOiseMEfoj0yacg7yOSf+R Wse0oZt/QMt5VN/iWqrm62Kq1v4Nlg/VjFQpl7mw8kI0TyKzuYgZiQgNVrTI3wCBs5Fm QpyXJiOEI9GrD3ml8mQX3LkdmgY+zju8WYiHjLk01TtZvuQ2fGDh/psvz1A+g6li6Fq5 mDHbVPKt+FzTdxaa812nkYRecY46CC5OYizlOPxRe67UVUAnl9QvNHu1SwaaxeBnipEp m1EEFHKTiajMr07H/5770X4iIRwGpsFeEUYU1MgE2Nn2WMp0ymcBQUJ68gmod/qDayGc CGrg== ARC-Authentication-Results: i=1; mx.google.com; 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 e14si603079pfj.86.2018.02.10.21.09.24; Sat, 10 Feb 2018 21:09:38 -0800 (PST) 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; 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 S1753928AbeBKFHg (ORCPT + 99 others); Sun, 11 Feb 2018 00:07:36 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41477 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752669AbeBKEdm (ORCPT ); Sat, 10 Feb 2018 23:33:42 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ekjKe-0002hK-RP; Sun, 11 Feb 2018 04:33:40 +0000 Received: from ben by deadeye with local (Exim 4.90) (envelope-from ) id 1ekjKX-0004Tb-NK; Sun, 11 Feb 2018 04:33:33 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Tyler Hicks" , "Dan Carpenter" Date: Sun, 11 Feb 2018 04:20:06 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 27/79] eCryptfs: use after free in ecryptfs_release_messaging() In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.2.99-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter commit db86be3a12d0b6e5c5b51c2ab2a48f06329cb590 upstream. We're freeing the list iterator so we should be using the _safe() version of hlist_for_each_entry(). Fixes: 88b4a07e6610 ("[PATCH] eCryptfs: Public key transport mechanism") Signed-off-by: Dan Carpenter Signed-off-by: Tyler Hicks [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings --- --- a/fs/ecryptfs/messaging.c +++ b/fs/ecryptfs/messaging.c @@ -550,17 +550,17 @@ void ecryptfs_release_messaging(void) mutex_unlock(&ecryptfs_msg_ctx_lists_mux); } if (ecryptfs_daemon_hash) { - struct hlist_node *elem; struct ecryptfs_daemon *daemon; + struct hlist_node *elem, *n; int i; mutex_lock(&ecryptfs_daemon_hash_mux); for (i = 0; i < (1 << ecryptfs_hash_bits); i++) { int rc; - hlist_for_each_entry(daemon, elem, - &ecryptfs_daemon_hash[i], - euid_chain) { + hlist_for_each_entry_safe(daemon, elem, n, + &ecryptfs_daemon_hash[i], + euid_chain) { rc = ecryptfs_exorcise_daemon(daemon); if (rc) printk(KERN_ERR "%s: Error whilst "