From owner-freebsd-current@freebsd.org Sun Mar 19 20:52:54 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1430FD13F3E for ; Sun, 19 Mar 2017 20:52:54 +0000 (UTC) (envelope-from rmacklem@uoguelph.ca) Received: from CAN01-QB1-obe.outbound.protection.outlook.com (mail-eopbgr660053.outbound.protection.outlook.com [40.107.66.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "Microsoft IT SSL SHA2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B321C1997; Sun, 19 Mar 2017 20:52:53 +0000 (UTC) (envelope-from rmacklem@uoguelph.ca) Received: from YTXPR01MB0189.CANPRD01.PROD.OUTLOOK.COM (10.165.218.133) by YTXPR01MB0189.CANPRD01.PROD.OUTLOOK.COM (10.165.218.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11; Sun, 19 Mar 2017 20:52:50 +0000 Received: from YTXPR01MB0189.CANPRD01.PROD.OUTLOOK.COM ([10.165.218.133]) by YTXPR01MB0189.CANPRD01.PROD.OUTLOOK.COM ([10.165.218.133]) with mapi id 15.01.0977.018; Sun, 19 Mar 2017 20:52:50 +0000 From: Rick Macklem To: Konstantin Belousov CC: Dimitry Andric , Ian Lepore , "Gergely Czuczy" , FreeBSD Current Subject: Re: process killed: text file modification Thread-Topic: process killed: text file modification Thread-Index: AQHSnqPLfXcZwdtVHkecT5jK6Yv9dKGYQJIXgAAZ/baAAFsxgIAAVqF+gAAJQ4CAAFvPgIAAF1PPgABnggCAArMZZA== Date: Sun, 19 Mar 2017 20:52:50 +0000 Message-ID: References: <5ac94b9a-7ced-9eff-d746-7dddaaeca516@harmless.hu> <1489340839.40576.82.camel@freebsd.org> <20170317083605.GQ16105@kib.kiev.ua> <20170317141917.GS16105@kib.kiev.ua> , <20170318032150.GW16105@kib.kiev.ua> In-Reply-To: <20170318032150.GW16105@kib.kiev.ua> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: FreeBSD.org; dkim=none (message not signed) header.d=none;FreeBSD.org; dmarc=none action=none header.from=uoguelph.ca; x-microsoft-exchange-diagnostics: 1; YTXPR01MB0189; 7:s+Iv45gHx4CQWzDZjy5mhIG8H9z0Zi3ftLg8yW8CxqkanztdUdVZU1krJwSmlpvCwo9BB+lgkm670G8vjm/fdmQYw+vx8iOCrI9lVMFRgH9G/F/3CuXx1bUt+X6kQJUudtsbEN6c1SgmW0mPPYZF468FJAwwYdry/YWhqUMxHZVwNrOU9TCImUVbctULfIISY+nIEoZ8pifEEVtmI/6Z7N0le8CuGfnjnkMZvJnJjKlPATLowlYaAcbqX8bn3W43XDqO8zCQYWKPHc93pKtl6N47vMqDvey7Ctx5PukMwNyE+HDd/pzBkpk7HcgUBinRanAEdDtRV6Kctq1irVslMQ== x-ms-office365-filtering-correlation-id: 0b85209a-db9d-4891-c5a8-08d46f09e851 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075); SRVR:YTXPR01MB0189; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(158342451672863)(17755550239193); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040375)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041248)(20161123558025)(20161123564025)(20161123555025)(20161123560025)(20161123562025)(6072148); SRVR:YTXPR01MB0189; BCL:0; PCL:0; RULEID:; SRVR:YTXPR01MB0189; x-forefront-prvs: 025100C802 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39450400003)(24454002)(39060400002)(54356999)(54906002)(6246003)(33656002)(86362001)(9686003)(81166006)(6506006)(55016002)(110136004)(77096006)(8676002)(122556002)(8936002)(5660300001)(38730400002)(76176999)(93886004)(305945005)(74316002)(53936002)(7696004)(3280700002)(6916009)(3660700001)(2950100002)(50986999)(2906002)(229853002)(1411001)(4326008)(6436002)(102836003)(189998001)(2900100001)(74482002); DIR:OUT; SFP:1101; SCL:1; SRVR:YTXPR01MB0189; H:YTXPR01MB0189.CANPRD01.PROD.OUTLOOK.COM; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: uoguelph.ca X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Mar 2017 20:52:50.6442 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: be62a12b-2cad-49a1-a5fa-85f4f3156a7d X-MS-Exchange-Transport-CrossTenantHeadersStamped: YTXPR01MB0189 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Mar 2017 20:52:54 -0000 Kostik wrote: [stuff snipped] >> >> Dirty pages are flushed by writes, so if we have a set of dirty pages= and >> >> async vm_object_page_clean() is called on the vnode' vm_object, we ge= t >> >> a bunch of delayed-write AKA dirty buffers. This is possible even af= ter >> >> VOP_CLOSE() was done, e.g. by syncer performing regular run involving >> >> vfs_msync(). >> When I was talking about ncl_flush() above, I was referring to buffer ca= che >> buffers written by a write(2) syscall, not the case of mmap'd pages. > But dirty buffers can appear on the vnode queue due to dirty pages msynci= ng > by syncer, for instance. Ok, just to clarify this, in case I don't understand it... - You aren't saying that anything will be added to v_bufobj.bo_dirty.bv_hd = by vfs_msync() or similar, after VOP_CLOSE(), right? --> ncl_flush() { was called nfs_flush() in the old NFS client } only deals= with "struct buf's" hanging off v_bufobj.bo_dirty.bv_hd, so I don't see a u= se for it in the patch. As for pages added to v_bufobj.bo_object...the patch assumes that the proce= ss that was writing the executable file mmap'd is done { normally exited } bef= ore the exec() syscall occurs. If it is still dirtying pages when the exec() oc= curs, then failing with "Text file modified" seems correct to me. As you mentioned, an= other client can do this to the file anyhow. My understanding is that vm_object_page_clean() will get all the dirty page= s written back to the server at that point and if that is done in VOP_SET_TEXT() as t= his patch does, what more can the NFS client do? [more stuff snipped] > Syncer does not open the vnode inside the vfs_msync() operations. Ok, but this doesn't put "struct buf's" on v_bufobj.bo_dirty.bv_hd. Am I ri= ght? (When I said "buffers". I meant "struct buf's" under bo_dirty, not stuff un= der v_bufobj.bo_object.) > We do track writeability to the file, and do not allow execution if there= is > an active writer, be it a file descriptor opened for write, or a writeabl= e > mapping. And in reverse, if the file is executed (VV_TEXT is set), then > we disallow opening the file for write. Yes, and that was why I figured doing this in VOP_SET_TEXT(), just before setting VV_TEXT, was the right place to do it. [more stuff snipped] > > Thanks for testing the patch. Now, if others can test it...rick > Again, hopefully others (especially the original reporter) will be able to test the patch, rick