Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3494018imm; Sun, 16 Sep 2018 20:20:35 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZoJaPFTpwASsVKrOWqlOh+2VDiKf/xst8PcF8V9+k1Da3V0wEQAuZJZpRdRXihJDqKXEAq X-Received: by 2002:a62:c581:: with SMTP id j123-v6mr8710798pfg.84.1537154435070; Sun, 16 Sep 2018 20:20:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537154435; cv=none; d=google.com; s=arc-20160816; b=fLJ08jXCM0ILPKxiGE1zy54w/wP2j0S/6+miYuw3uGL8nr86AzdGVRGVugF68WaWpY bXgmXdNBmIUCbetnKvIxJcMuFEzmWhhkO8RRpgA2nrmsYh251X8VeXRp5xgE9ptXD85L 2pv5Trf9hZWgTbZsKoDvmjG03kAwFrJ8IPQreWvxoOMUIrqV083SYs6jraY/25nGUGhC dHCY6T7+t4ZQEv6PfhRKoZl9vG+0HfovZwD9whHU5SsrIl9zfUTsMBY8Ws3RTMdwXqqS 4ZobaOBLp8xi94cPtErBG/HTcky3lCLNfPhYrnpZvKd9fbQ6rsAAUaPi5541ApEKAqAp GfyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=DrvTibS4sTRZNHnbIJFyuaI3UaJmEoH5NO6xC+mnGbw=; b=C4oatxMrlOZ8XzbakwZNRQsQgZabpO0OE5fQBiWzH9gqakLDvPKKjuAB/3GbI796ah 6H2u+PUVuk40smVd2gLq71Up1i8yxA5DwBLQ1De70RqlH71XqjBsggYzlp+F7GMg8/yW Zy2yDJdSatZ3dKcXwM79YbOjlDEV9QBI647mPk6sHXUMBOIK/Pv7fWRSuLUr32nGVGj0 0rU/2FosTdXhKfiZDp48/80bJHSFKwL5yjklFPoogvlVqh4pjD35zZPQXfHNPCmxO1Xc NPyxP8xssqM1tZgathNUh830BWISqo6M79oLHcxd2MgjyDesbzhCta9eFEh+M1jQ45NW Knwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=gAMXkWZu; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l67-v6si14368176pfl.167.2018.09.16.20.20.20; Sun, 16 Sep 2018 20:20:35 -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=@microsoft.com header.s=selector1 header.b=gAMXkWZu; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730555AbeIQIaa (ORCPT + 99 others); Mon, 17 Sep 2018 04:30:30 -0400 Received: from mail-eopbgr690116.outbound.protection.outlook.com ([40.107.69.116]:54124 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730540AbeIQIaa (ORCPT ); Mon, 17 Sep 2018 04:30:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DrvTibS4sTRZNHnbIJFyuaI3UaJmEoH5NO6xC+mnGbw=; b=gAMXkWZucAr55P0iBXrwlVaK++DSVgF5Qd8CTP9vNrdbk2mhBEOx0wqoarghMHlK9D6c/BBz2m+8j/hzDVGm0ahKsNDvMxOm0qnSsQ+a8/l7QavLN8LvyQiklP6QROmoF8oE5gi3vA81lGkhRB98UOvODei8p0wD/81cdnSrDtc= Received: from CY4PR21MB0776.namprd21.prod.outlook.com (10.173.192.22) by CY4PR21MB0133.namprd21.prod.outlook.com (10.173.189.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.11; Mon, 17 Sep 2018 03:05:03 +0000 Received: from CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::54e2:88e0:b622:b36]) by CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::54e2:88e0:b622:b36%5]) with mapi id 15.20.1185.003; Mon, 17 Sep 2018 03:05:03 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Konstantin Khorenko , Jeff Layton , Sasha Levin Subject: [PATCH AUTOSEL 4.14 83/87] fs/lock: skip lock owner pid translation in case we are in init_pid_ns Thread-Topic: [PATCH AUTOSEL 4.14 83/87] fs/lock: skip lock owner pid translation in case we are in init_pid_ns Thread-Index: AQHUTjL7B20MhIK0pUijYZhbcu8PdA== Date: Mon, 17 Sep 2018 03:03:17 +0000 Message-ID: <20180917030220.245686-83-alexander.levin@microsoft.com> References: <20180917030220.245686-1-alexander.levin@microsoft.com> In-Reply-To: <20180917030220.245686-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4PR21MB0133;6:wFGSzJd1vrpXezb9eV4JSPQhLSGOmS7sZwDYrNsa3LjiqRBssmcAcrQMElmRCQ42RWAfEZcx6eaFVRq+Uj9gqnND26xKg9Bs3O+IWTvsibOTFe3T8OOH+tjf1YIbvx1TwdNY0toldBi09yYpEb0reWcoCBTBWhkN9W5yDf6KJUTwAkKC7xUVdlNCEZ6WMoFfjCz2NR8GOTfHfA2Fy3pqiZ6jNwT4Sgal+20GsY1EL4Lb+uoN99cRvw/L53cD3AHhtXi7Zj5QZS4vjMmObJbVl8jf4esUw7icCI7epAf0jN5MKf0Kpz24/3mSsHdxx8o542ox/7rMPSoJOUVhtStERlhaCNeno8zuKZciHSQP2z0SNikWv18m3oBv1N41JQfkWxFs/eB8AqL8qzlpLj8AXVWyHq+auNr22mYzACu+u7tjFsuRU5vKgi773hwPLu6AuheovoTGZR+AHLoU1atPMw==;5:Q+n8SEpAJN+AijATUVOtTZNZllRHrigTIA2S1PFTH5MsYvbLqiPLCn6sspaYxoh3rz9MJhtQDYbwTVfDItuFUku9PMhRhBBNEjQCWYQ7QKY6Pw4ZQugmvo7jYhMWnsGc5Syzvbj9t0O9F0PQ2s/k58lMTdPkZvR1rMTF92HFJyk=;7:zpCuum+IdO73HjV5Z/GgLtSgBIz5hNRItyk/qSSsjLiJ+WOOcEhnLyD2luHNUC8l79APdc7C1HyLxiokj+DK8BCV5fZyClc+h1xRUsPX8L8cnwxh9hMmtlzOrFMMp9zZMYqow+MtcErDO/dSlMpkJa141Ja9ylvY0qz/R58Ijmmxu/J/qB6FvHgPzhCCCBnNLptgfkXQMcIXxmv3fqAahlsYtwukv0qapif1TbSXaq2jEbG4BwkTgH8DBBW2ul8r x-ms-office365-filtering-correlation-id: 385e2e64-5b73-47d5-e976-08d61c4a5d2e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7193020);SRVR:CY4PR21MB0133; x-ms-traffictypediagnostic: CY4PR21MB0133: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231355)(944501410)(52105095)(2018427008)(3002001)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201708071742011)(7699050)(76991041);SRVR:CY4PR21MB0133;BCL:0;PCL:0;RULEID:;SRVR:CY4PR21MB0133; x-forefront-prvs: 0798146F16 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(136003)(396003)(39860400002)(376002)(346002)(189003)(199004)(102836004)(53936002)(8676002)(486006)(476003)(3846002)(6116002)(76176011)(10290500003)(97736004)(217873002)(256004)(5660300001)(107886003)(6506007)(478600001)(110136005)(2501003)(10090500001)(14444005)(305945005)(7736002)(446003)(11346002)(36756003)(2906002)(1076002)(22452003)(5250100002)(2616005)(26005)(316002)(106356001)(25786009)(68736007)(86362001)(575784001)(14454004)(72206003)(105586002)(99286004)(6486002)(6436002)(6512007)(86612001)(6666003)(81166006)(81156014)(186003)(2900100001)(54906003)(8936002)(4326008)(66066001)(414714003);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR21MB0133;H:CY4PR21MB0776.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: UQ5Ap9a+fElkDoIGWPp/aYWUU69pHU0kfdNiBmBAhuzoO/Ha6nWaHmgF7iMiC0qpzEjZPgBFHQZHBWYZKiXEswAICLKrL6Ux253PzzoprE9gPZd/TSTLCwVXXwQXPaTJt6U6LWFcvsftw01YQ4YyjH1JRA0eNO2yn978gPlS7vwBL0Z1OuBRp1SQYU+RwIYLSlEgjVe9AKNZ68rrf4zLUA1BYADnoVCdl3pN74uWlfA80qWgIKjcnhhs9Frr1KVxuOg+XGD69Lw7ReBWs0H1ll9Fs+nITDVcjyN9t4GuwYfh+cA4l1//2J4UcLz4vo1Eh2mcwsOKbrJel7sdisIPJhRAYaCPfL3076OCnnmYrTc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 385e2e64-5b73-47d5-e976-08d61c4a5d2e X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Sep 2018 03:03:17.6027 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0133 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (root@vz7)/: cat /proc/${PID_A2}/fdinfo/3 pos: 4 flags: 02100002 mnt_id: 257 lock: (root@vz7)/: After the patch: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (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 f= or 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 --- fs/locks.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/locks.c b/fs/locks.c index 1bd71c4d663a..665e3ce9ab47 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -2074,6 +2074,13 @@ static pid_t locks_translate_pid(struct file_lock *f= l, struct pid_namespace *ns) 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 =3D=3D &init_pid_ns) + return (pid_t)fl->fl_pid; =20 rcu_read_lock(); pid =3D find_pid_ns(fl->fl_pid, &init_pid_ns); --=20 2.17.1