Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1344933imm; Tue, 2 Oct 2018 06:51:53 -0700 (PDT) X-Google-Smtp-Source: ACcGV60JeZj3coqxqwYWCtAkOVw7omWM+VoYdPLcuhnLgPSAoyIBVDw1vrSoEqSkNTiDT2M79+ZR X-Received: by 2002:a62:54c7:: with SMTP id i190-v6mr16399023pfb.155.1538488313786; Tue, 02 Oct 2018 06:51:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538488313; cv=none; d=google.com; s=arc-20160816; b=SwDDnytTmCPOKcsIfiC+M6DnSf3BF5KNeL1/VaDWOtOXVaSMQNKeJ435W3PE6Zor58 OXMRbiWPrlxZJCB393IQ+47IRG1gTcjDnjs9iTMeLFTh2AeLFXO1ajbMUTRNxBb+gpfk M1SglsovnGfuKeTaaHsQh2i1UZirneOyb+zIbAI79ihwYTRAkh2Ht6Q819MteC8bVGxA GjmdhK+6I8hz4li27fH2G8dRySfvF9sc8wRYhcdaVCsqrXjmT22Vt78Kqueh8SbbGnHn /2IIIRwvj7Km1bQV1LO1bpEuO/omG/YuKeWIQQmSBzPKFQKfKdV7BwU9xhzq8g+NP7hb sWiA== 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; bh=aBtQZ6EFdx9UbCHZqxcMhKDRGbveeeQgRlRm7ea01U0=; b=GzaP3oB3I/5bs/86AsyprTacXuG6+5MXW4NO2alGdYSD2k1YguKUqvkgkPT7hlNgvG nMAlWh3gKy//XlDvILfVCK6O6HEZd5q3NFRqoYbWVJTtrgaf9X0ynu0aQXz2bXbMm3lc mIRoSn1XwLmNrvk4SgHZ+lysTxy0IE7xhH5IBYWUy4Oc9eb2s6V+mTp1Fd3R4cdQ9K9w 8ljYmyVlrXFxxkbAKdPc8T3sN3kZjEluvXi6vjQS+e9wfm3E5x9EOfk4yxS6Y43rDfE3 hxjWSzVWVT9ERPPCrLG87OuKBqomUw3pdfksGEzPgny/W6Y9gSFkqVBUKkNQcNHrzpiG FWmg== 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 g13-v6si183699plq.373.2018.10.02.06.51.38; Tue, 02 Oct 2018 06:51:53 -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; 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 S1731935AbeJBURG (ORCPT + 99 others); Tue, 2 Oct 2018 16:17:06 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34996 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731866AbeJBURF (ORCPT ); Tue, 2 Oct 2018 16:17:05 -0400 Received: from localhost (24-104-73-23-ip-static.hfc.comcastbusiness.net [24.104.73.23]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id BE6DD5AA; Tue, 2 Oct 2018 13:33:41 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Konstantin Khorenko , Andrey Vagin , Benjamin Coddington , Jeff Layton , Sasha Levin Subject: [PATCH 4.14 079/137] fs/lock: skip lock owner pid translation in case we are in init_pid_ns Date: Tue, 2 Oct 2018 06:24:40 -0700 Message-Id: <20181002132504.067703720@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181002132458.446916963@linuxfoundation.org> References: <20181002132458.446916963@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Konstantin Khorenko [ Upstream commit 826d7bc9f013d01e92997883d2fd0c25f4af1f1c ] If the flock owner process is dead and its pid has been already freed, pid translation won't work, but we still want to show flock owner pid number when expecting /proc/$PID/fdinfo/$FD in init pidns. Reproducer: process A process A1 process A2 fork()---------> exit() open() flock() fork()---------> exit() sleep() Before the patch: ================ (root@vz7)/: cat /proc/${PID_A2}/fdinfo/3 pos: 4 flags: 02100002 mnt_id: 257 lock: (root@vz7)/: After the patch: =============== (root@vz7)/:cat /proc/${PID_A2}/fdinfo/3 pos: 4 flags: 02100002 mnt_id: 295 lock: 1: FLOCK ADVISORY WRITE ${PID_A1} b6:f8a61:529946 0 EOF Fixes: 9d5b86ac13c5 ("fs/locks: Remove fl_nspid and use fs-specific l_pid for remote locks") Signed-off-by: Konstantin Khorenko Acked-by: Andrey Vagin Reviewed-by: Benjamin Coddington Signed-off-by: Jeff Layton Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/locks.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/fs/locks.c +++ b/fs/locks.c @@ -2074,6 +2074,13 @@ static pid_t locks_translate_pid(struct return -1; if (IS_REMOTELCK(fl)) return fl->fl_pid; + /* + * If the flock owner process is dead and its pid has been already + * freed, the translation below won't work, but we still want to show + * flock owner pid number in init pidns. + */ + if (ns == &init_pid_ns) + return (pid_t)fl->fl_pid; rcu_read_lock(); pid = find_pid_ns(fl->fl_pid, &init_pid_ns);