Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp423175pxk; Fri, 11 Sep 2020 10:27:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIERv2WBBDC9N4QasZNGFm6P7euEvGU5w5DQZgqsd2tK9WBdLwMPROZl94ZEdnc87vCpx5 X-Received: by 2002:a17:906:11d2:: with SMTP id o18mr2968197eja.420.1599845266752; Fri, 11 Sep 2020 10:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599845266; cv=none; d=google.com; s=arc-20160816; b=dC12CIr6Dcljf14sx2bo20JHrdMX1bogUBCdE5Sn838HG8ucl7Gub62XsiT3/7mRET Gyxi0YkCyGZEFymgEcEkmSHESaC7yR4piCzH6X8r5jHkbde8swjrQlNlr3laSmopv4sL vEAviUo3rRWeJoKtFIWn4VqmlYFScxt8ucBoZUoZytalYmWNDPLKDqKJZCj4tCjUDQQO Lh/VkOixLd8k3Tleu1d7xPUF9PMsbf2pPNqzfdA9yBS+u6+TOXyZ2212XTVQ7eX5UE8E sKIbZONw6+D6PP+RNRo+uTZZtx1ArZw4ffucn6VqVu0hlQqsG/zah3BNb7UPImlEefnU NnBw== 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=gMBFgYkOavw1kBVfoJSfw8QY4m/y/5rBA4Lnw/kzYEE=; b=efsapKlV7HY1VZ7hv4lvMLGygN1QDtShIgWhPLiobgcGa0p/JzpmeGanwma1yYmexg uBA1fviAGNL6kbjqmcotf52tx16ZG3evJtxNZ9E1Myt3D9ZQRK2c+Wdtt9aV/APiNQJ/ FcVka39KbGzan46RG1y9yJamZLALKj8+PjI9ctx7S7gP4krBph1V8ofStORwHFrd3T6j bAob2TLt8eupk/0VlAFvNCf2/XWpDUn33bS5bCTsAyMuLiKvyC12C2BLeaeIbbeTzr0Z +Q2NQC/nFfAw+jn8HddK+69HxtwtKocBv+XjOdto7j+HB+4h4Y4eBIFrreeNkGzUB3Ie OZBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZAascEWh; 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 j30si1906725edj.30.2020.09.11.10.27.23; Fri, 11 Sep 2020 10:27:46 -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=ZAascEWh; 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 S1726331AbgIKRYb (ORCPT + 99 others); Fri, 11 Sep 2020 13:24:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:52806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726135AbgIKNAK (ORCPT ); Fri, 11 Sep 2020 09:00: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 D31C92222A; Fri, 11 Sep 2020 12:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599828994; bh=TulE0s7oJnC/mvY51SC75yJFbCvnqjfF2xT7HJhRDWM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZAascEWhZHYwSL/+oC3CiEJv79kONiOcD2KlgKg9ndLYdJuoXOqLAMmTLwxuJVQCk okbUl87+d3uj02rcf8b4cOWAK6fLclw1FfYWFo1A4z3yrjH2tFf9paPNCtDU210W8P kwhVpC7QR3Q3REkQO/IpH3ro3/RExysmmw7SQupQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Al Viro , Sasha Levin Subject: [PATCH 4.9 24/71] fix regression in "epoll: Keep a reference on files added to the check list" Date: Fri, 11 Sep 2020 14:46:08 +0200 Message-Id: <20200911122506.144629368@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200911122504.928931589@linuxfoundation.org> References: <20200911122504.928931589@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Al Viro [ Upstream commit 77f4689de17c0887775bb77896f4cc11a39bf848 ] epoll_loop_check_proc() can run into a file already committed to destruction; we can't grab a reference on those and don't need to add them to the set for reverse path check anyway. Tested-by: Marc Zyngier Fixes: a9ed4a6560b8 ("epoll: Keep a reference on files added to the check list") Signed-off-by: Al Viro Signed-off-by: Sasha Levin --- fs/eventpoll.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index aad52e1858363..8c40d6652a9a9 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1748,9 +1748,9 @@ static int ep_loop_check_proc(void *priv, void *cookie, int call_nests) * during ep_insert(). */ if (list_empty(&epi->ffd.file->f_tfile_llink)) { - get_file(epi->ffd.file); - list_add(&epi->ffd.file->f_tfile_llink, - &tfile_check_list); + if (get_file_rcu(epi->ffd.file)) + list_add(&epi->ffd.file->f_tfile_llink, + &tfile_check_list); } } } -- 2.25.1