Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4419990pxu; Mon, 12 Oct 2020 19:48:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXQU+xtj/XDfvAVgk6Aj84VMzKQeU/MDVp382qhtz3TNrKjnZUonFrJCqIlFAljNWhtQI3 X-Received: by 2002:a17:906:1152:: with SMTP id i18mr30661180eja.101.1602557323225; Mon, 12 Oct 2020 19:48:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602557323; cv=none; d=google.com; s=arc-20160816; b=yCclQdBJ9Bux2FF9L/4gmEBy88+7O5uS7kbNi0WZMDok9CM9KlqIfNuBO5xzd47D+i JfOJPQImsgN4YDxxKW9uDjIFuCBojNV907S7EvIc+isHmpWlxk2YBFxKvb9rib2EIUvp IcizrbkcNABsNPeO2FWy4clzI+pOK23p0Jqzj88oMYCZ0aSZhPM6yQTjqJDu1anYoLk4 sf1+E2wZWIcOd1mtbRllRJ489lK/z1QLe62yxmBtJ4Cf3w6Z/H67ZE5p3LaoO68MHdQB 8HBmHPK0PK2T/bjG5XkwCOPyFRCvc3i78ufnF6/mG3h4QgFzu3WrP4D99aBvN5JOe7eB KVBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KfuaK6TgwhC0Ghks/jI08VWLQ/kZbEaoj66qhPJVfgQ=; b=GAJPcyOXjlIn5/CewKGFx0MH4ToCoTS+Rv47oAfpPuup35cUUkcdgLjJnrIoudP1X2 sGJKhHL03C84Ug/YlGsmxzvrDnugz7vypF5/7C+7fwC5fIu/0kksqv+meOMSNmh5KWD6 Q/gO233UqW/LPpSArqGtjgI3Cym/fg8HfUlkvv13rLhkfmDnz42PlqqtKCoaHRX+J5+p m3ER+VDM3qsqOWJ0wjEXGg1ESwEvUApZoRhw/rwywVr74RTO7mELi32yp6hFebHmxIGO NvkF6/xC2gr0kwks6Jq33q/2K043wtQlESfgu5XA4x7lZ2PHvQQq7bzw04WRb8W1vIE4 9zYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xKshFr3s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si20839636edi.14.2020.10.12.19.47.56; Mon, 12 Oct 2020 19:48:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xKshFr3s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390981AbgJLOF2 (ORCPT + 99 others); Mon, 12 Oct 2020 10:05:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:37732 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729949AbgJLNfK (ORCPT ); Mon, 12 Oct 2020 09:35:10 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 769FF221FE; Mon, 12 Oct 2020 13:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602509710; bh=ezOUzcrUIiadmFHTCXkiPhveMCAMHY6T5StkAf66SzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xKshFr3sbNnBY5Lh6pJ8CWdt9Y3QpaM7LYFWMJaZtJycILkqiKuIHFntDRz26DEE8 x8xz+3JFHcAok5Tta0BFPZft/6kVhsuSv9QpveLfYmsl9oc5RjkS/4t5AGHyPpxHNL //RHYz90LKJzm5cUB+k7cBga0jUokQpX+y3P6ye8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro Subject: [PATCH 4.9 21/54] ep_create_wakeup_source(): dentry name can change under you... Date: Mon, 12 Oct 2020 15:26:43 +0200 Message-Id: <20201012132630.569922401@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012132629.585664421@linuxfoundation.org> References: <20201012132629.585664421@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro commit 3701cb59d892b88d569427586f01491552f377b1 upstream. or get freed, for that matter, if it's a long (separately stored) name. Signed-off-by: Al Viro Signed-off-by: Greg Kroah-Hartman --- fs/eventpoll.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1260,7 +1260,7 @@ static int reverse_path_check(void) static int ep_create_wakeup_source(struct epitem *epi) { - const char *name; + struct name_snapshot n; struct wakeup_source *ws; if (!epi->ep->ws) { @@ -1269,8 +1269,9 @@ static int ep_create_wakeup_source(struc return -ENOMEM; } - name = epi->ffd.file->f_path.dentry->d_name.name; - ws = wakeup_source_register(name); + take_dentry_name_snapshot(&n, epi->ffd.file->f_path.dentry); + ws = wakeup_source_register(n.name); + release_dentry_name_snapshot(&n); if (!ws) return -ENOMEM;