Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8A51C433EF for ; Mon, 3 Jan 2022 19:03:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235964AbiACTDE (ORCPT ); Mon, 3 Jan 2022 14:03:04 -0500 Received: from outgoing-stata.csail.mit.edu ([128.30.2.210]:47823 "EHLO outgoing-stata.csail.mit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235959AbiACTDD (ORCPT ); Mon, 3 Jan 2022 14:03:03 -0500 Received: from c-73-149-22-248.hsd1.ma.comcast.net ([73.149.22.248] helo=crash.local) by outgoing-stata.csail.mit.edu with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1n4Sbk-00090s-Ey; Mon, 03 Jan 2022 14:03:00 -0500 Received: from crash.local (localhost [127.0.0.1]) by crash.local (Postfix) with ESMTP id 0A385145197B2; Mon, 3 Jan 2022 14:03:00 -0500 (EST) to: Trond Myklebust , Anna Schumaker cc: linux-nfs@vger.kernel.org From: rtm@csail.mit.edu Reply-To: rtm@csail.mit.edu Subject: _nfs4_open_and_get_state() should check IS_ERR() from d_splice_alias() MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Mon, 03 Jan 2022 14:02:59 -0500 Message-ID: <98916.1641236579@crash.local> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org --=-=-= Content-Type: text/plain _nfs4_open_and_get_state() says: if (!alias) alias = d_splice_alias(igrab(state->inode), dentry); /* d_splice_alias() can't fail here - it's a non-directory */ if (alias) { dput(ctx->dentry); ctx->dentry = dentry = alias; ...; nfs_set_verifier(dentry, dir_verifier); d_splice_alias() can return an ERR_PTR(), causing nfs_set_verifier() to page-fault on &dentry->d_lock; I've attached a demo. # uname -a Linux (none) 5.16.0-rc7-00108-g800829388818-dirty #12 SMP Mon Jan 3 18:38:50 UTC 2022 riscv64 riscv64 riscv64 GNU/Linux # cc nfs_18.c # ./a.out ... [ 71.811841] VFS: Lookup of 'x' in nfs4 0:16 would have caused loop [ 71.825707] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000034 [ 72.064187] status: 0000000200000121 badaddr: 0000000000000034 cause: 000000000000000d [ 72.079110] [] do_raw_spin_lock+0xa/0xd8 [ 72.090221] [] _raw_spin_lock+0x1a/0x22 [ 72.101284] [] nfs_set_verifier+0x20/0x6a [ 72.112387] [] nfs4_do_open.constprop.0+0x30e/0x874 [ 72.125597] [] nfs4_atomic_open+0xc/0x1c [ 72.136676] [] nfs_atomic_open+0x1a0/0x35e [ 72.150205] [] path_openat+0x59e/0xadc [ 72.161311] [] do_filp_open+0x70/0xea [ 72.172464] [] do_sys_openat2+0x86/0x11a [ 72.183523] [] sys_openat+0x40/0x80 [ 72.194578] [] ret_from_syscall+0x0/0x2 [ 72.213692] ---[ end trace 107b62634b79d2f7 ]--- --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=nfs_18.c Content-Transfer-Encoding: base64 I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPHN0ZGxpYi5o PgojZGVmaW5lIF9HTlVfU09VUkNFCiNpbmNsdWRlIDx1bmlzdGQuaD4KI2luY2x1ZGUgPHN5cy9z b2NrZXQuaD4KI2luY2x1ZGUgPHN5cy9maWxlLmg+CiNpbmNsdWRlIDxzeXMvaW9jdGwuaD4KI2lu Y2x1ZGUgPG5ldGluZXQvaW4uaD4KI2luY2x1ZGUgPHN5cy93YWl0Lmg+CiNpbmNsdWRlIDxzeXMv cmVzb3VyY2UuaD4KI2luY2x1ZGUgPHN5cy9wYXJhbS5oPgojaW5jbHVkZSA8c3lzL21vdW50Lmg+ CiNpbmNsdWRlIDxzeXMvdHlwZXMuaD4KI2luY2x1ZGUgPHN5cy9zdGF0Lmg+CiNpbmNsdWRlIDxz eXMvdmZzLmg+CiNpbmNsdWRlIDxkaXJlbnQuaD4KI2luY2x1ZGUgPGFzc2VydC5oPgojaW5jbHVk ZSA8ZmNudGwuaD4KI2luY2x1ZGUgPGVycm5vLmg+CgppbnQgc3ltX29wID0gMTg7CmludCBzeW1f c2tpcCA9IDA7CmludCBzeW1fdHlwZSA9IDA7IC8vIGFsbCBmYXR0cjQgZmlsZSB0eXBlcwppbnQg c3ltX2ZoID0gMDsgLy8gYWxsIGZpbGUgaGFuZGxlcwppbnQgc3ltX2JpdG1hcHMgPSAwOwppbnQg c3ltX29wYXF1ZV9sZW4gPSAwOwoKaW50IG9wY291bnRzWzI1Nl07CmxvbmcgbG9uZyBuZXh0X2Nv b2tpZSA9IDM7CmludCBjdXJyZW50X2ZoID0gMDsKaW50IGNvbXBvdW5kX3N0YXR1czsKaW50IHNl bmRfYmFjazsKCi8vIG1hcCBmaWxlL2RpciBuYW1lcyB0byBmaWxlIGhhbmRsZQpjaGFyICpmaG5h bWVzWzEwMF0gPSB7CiAgICAgICAgICAgICAgICIiLAogICAgICAgICAgICAgICAidG1wIiwKICAg ICAgICAgICAgICAgIngiLAogICAgICAgICAgICAgICAieSIsCiAgICAgICAgICAgICAgICJ6IiwK ICAgICAgICAgICAgICAgInp6eiIsCiAgICAgICAgICAgICAgIDAKfTsKCmludApuYW1lMmZoKGNo YXIgKm5hbWUsIGludCBjcmVhdGUpCnsKICBmb3IoaW50IGkgPSAwOyBmaG5hbWVzW2ldOyBpKysp ewogICAgaWYoc3RyY21wKG5hbWUsIGZobmFtZXNbaV0pID09IDApCiAgICAgIHJldHVybiBpOwog IH0KICBpZihjcmVhdGUpewogICAgZm9yKGludCBpID0gMDsgOyBpKyspewogICAgICBpZihmaG5h bWVzW2ldID09IDApewogICAgICAgIGZobmFtZXNbaV0gPSBtYWxsb2MoMTAwKTsKICAgICAgICBz dHJjcHkoZ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gMDsg YSA8IGJpdHdvcmRzKjMyOyBhKyspewogICAgaWYod29yZHNbYS8zMl0gJiAoMSA8PCAoYSAlIDMy KSkpewogICAgICBpZihhID09IDApewogICAgICAgIHB1dDMyKDMpOyAvLyAjIGJpdG1hcCB3b3Jk cyBvZiBzdXBwb3J0ZWQgYXR0cnMKICAgICAgICBwdXQzMigweGZmZmZmZmZmKTsKICAgICAgICBw dXQzMigweGZmZmZmZmZmKTsKICAgICAgICBwdXQzMigweGZmZmZmZmZmKTsKICAgICAgfSBlbHNl IGlmKGEgPT0gMSl7CiAgICAgICAgaW50IHR5cGUgPSAxOwogICAgICAgIGlmKGZoID09IDAgfHwg ZmggPT0gMSkKICAgICAgICAgIHR5cGUgPSAyOwogICAgICAgIGlmKHN5bV90eXBlKSB0eXBlIF49 IGFhW2FhaSsrXTsKICAgICAgICBwdXQzMih0eXBlKTsgLy8gTkY0RElSPTIgb3IgTkY0UkVHPTEK ICAgICAgfSBlbHNlIGlmKGEgPT0gMil7CiAgICAgICAgcHV0MzIoMCk7IC8vIGZoX2V4cGlyZV90 eXBlCiAgICAgIH0gZWxzZSBpZihhID09IDMpewogICAgICAgIHB1dDY0KDApOyAvLyBjaGFuZ2UK ICAgICAgfSBlbHNlIGlmKGEgPT0gNCl7CiAgICAgICAgcHV0NjQoNDA5NioxMCk7IC8vIHNpemUK ICAgICAgfSBlbHNlIGlmKGEgPT0gNSl7CiAgICAgICAgcHV0MzIoMSk7IC8vIGxpbmsgc3VwcG9y dAogICAgICB9IGVsc2UgaWYoYSA9PSA2KXsKICAgICAgICBwdXQzMigxKTsgLy8gc3ltbGluayBz dXBwb3J0CiAgICAgIH0gZWxzZSBpZihhID09IDgpewogICAgICAgIHB1dDY0KDEpOyAvLyBmc2lk IG1ham9yCiAgICAgICAgcHV0NjQoMSk7IC8vIGZzaWQgbWlub3IKICAgICAgfSBlbHNlIGlmKGEg PT0gMTApewogICAgICAgIHB1dDMyKDEwKTsgLy8gbGVhc2UgdGltZQogICAgICB9IGVsc2UgaWYo YSA9PSAxMSl7CiAgICAgICAgcHV0MzIoMCk7IC8vIHJkYXR0cl9lcnJvcgogICAgICB9IGVsc2Ug aWYoYSA9PSAxMil7CiAgICAgICAgLy8gQUNMCiAgICAgICAgaW50IG4gPSAyOwogICAgICAgIHB1 dDMyKG4pOwogICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspewogICAgICAgICAgcHV0 MzIoMCk7IC8vIHR5cGUKICAgICAgICAgIHB1dDMyKDApOyAvLyBmbGFnCiAgICAgICAgICBwdXQz MigwKTsgLy8gbWFzawogICAgICAgICAgY2hhciB3aG9bOV07CiAgICAgICAgICBtZW1zZXQod2hv LCAwLCBzaXplb2Yod2hvKSk7CiAgICAgICAgICBzdHJjcHkod2hvLCAibm9ib2R5Iik7CiAgICAg ICAgICBwdXRfb3BhcXVlKHN0cmxlbih3aG8pLCB3aG8pOwogICAgICAgIH0KICAgICAgfSBlbHNl IGlmKGEgPT0gMTMpewogICAgICAgIHB1dDMyKDB4Zik7IC8vIGFjbHN1cHBvcnQKICAgICAgfSBl bHNlIGlmKGEgPT0gMTUpewogICAgICAgIHB1dDMyKDEpOyAvLyBjYW5zZXR0aW1lCiAgICAgIH0g ZWxzZSBpZihhID09IDE2KXsKICAgICAgICBwdXQzMigwKTsgLy8gY2FzZSBpbnNlbnNpdGl2ZQog ICAgICB9IGVsc2UgaWYoYSA9PSAxNyl7CiAgICAgICAgcHV0MzIoMSk7IC8vIGNhc2UgcHJlc2Vy dmluZwogICAgICB9IGVsc2UgaWYoYSA9PSAxOCl7CiAgICAgICAgcHV0MzIoMCk7IC8vIGNob3du X3Jlc3RyaWN0ZWQKICAgICAgfSBlbHNlIGlmKGEgPT0gMTkpewogICAgICAgIC8vIGZpbGVoYW5k bGUKICAgICAgICBpbnQgeGZoID0gZmg7CiAgICAgICAgaWYoc3ltX2ZoKSB4ZmggXj0gYWFbYWFp KytdOwogICAgICAgIHB1dF9vcGFxdWUoNCwgKG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WQpCnsKICB2b2xhdGlsZSBpbnQgeCA9IHN5c3RlbShj bWQpOwogICh2b2lkKSB4Owp9CgppbnQKbWFpbigpewogIHNldGxpbmVidWYoc3Rkb3V0KTsKICBz dHJ1Y3QgcmxpbWl0IHI7CiAgci5ybGltX2N1ciA9IHIucmxpbV9tYXggPSAwOwogIHNldHJsaW1p dChSTElNSVRfQ09SRSwgJnIpOwoKICBpbnQgcyA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NUUkVB TSwgMCk7CiAgc3RydWN0IHNvY2thZGRyX2luIHNpbjsKICBtZW1zZXQoJnNpbiwgMCwgc2l6ZW9m KHNpbikpOwogIHNpbi5zaW5fZmFtaWx5ID0gQUZfSU5FVDsKICBzaW4uc2luX3BvcnQgPSBodG9u cygyMDQ5KTsKICBpbnQgeWVzID0gMTsKICBzZXRzb2Nrb3B0KHMsIFNPTF9TT0NLRVQsIFNPX1JF VVNFQUREUiwgJnllcywgc2l6ZW9mKHllcykpOwogIGlmKGJpbmQocywgKHN0cnVjdCBzb2NrYWRk ciAqKSZzaW4sIHNpemVvZihzaW4pKSA8IDApewogICAgcGVycm9yKCJiaW5kIik7IGV4aXQoMSk7 CiAgfQogIGxpc3RlbihzLCAxMCk7CiAgc3luYygpOwoKICBpbnQgcGlkMSA9IGZvcmsoKTsKICBp ZihwaWQxID09IDApewogICAgY2xvc2Uocyk7CiAgICBzbGVlcCgxKTsKICAgIGlmKHN5c3RlbSgi ZWNobyAtbiBtb3VudDogOyBtb3VudCAtbyBub2xvY2ssbm9kZXYgMTI3LjAuMC4xOi90bXAgL21u dCIpID09IDApewogICAgICBpZigwKXsKICAgICAgICBwcmludGYoInN0YXRmczogIik7IGZmbHVz aChzdGRvdXQpOwogICAgICAgIHN0cnVjdCBzdGF0ZnMgc2I7CiAgICAgICAgaW50IHJldCA9IHN0 YXRmcygiL21udC8uIiwgJnNiKTsKICAgICAgICBwcmludGYoInN0YXRmcyAtPiAlZFxuIiwgcmV0 KTsKICAgICAgfQogICAgICBpZigwKXsKICAgICAgICBpbnQgZmQgPSBvcGVuKCIvbW50IiwgMCk7 CiAgICAgICAgaWYoZmQgPCAwKSB7IHBlcnJvcigiL21udCIpOyBleGl0KDEpOyB9CiAgICAgICAg b2ZmX3QgYmFzZSA9IDA7CiAgICAgICAgY2hhciBidWZbNDA5Nl07CiAgICAgICAgc3NpemVfdCBy ZXQgPSBnZXRkaXJlbnRyaWVzKGZkLCBidWYsIHNpemVvZihidWYpLCAmYmFzZSk7CiAgICAgICAg cHJpbnRmKCJnZXRkaXJlbnRyaWVzIHJldCAlbGQgZXJybm8gJWRcbiIsIHJldCwgZXJybm8pOwog ICAgICAgIGlmKHJldCA8IDApIHBlcnJvcigiZ2V0ZGlyZW50cmllcyIpOwogICAgICAgIGNsb3Nl KGZkKTsKICAgICAgfQogICAgICBpZigxKXsKICAgICAgICBpbnQgZmQgPSBvcGVuKCIvbW50L3gi LCAwKTsKICAgICAgICBwcmludGYoIm9wZW4gL21udC94IC0+ICVkIGVycm5vICVkXG4iLCBmZCwg ZXJybm8pOwogICAgICAgIGlmKGZkIDwgMCkgcGVycm9yKCIvbW50L3giKTsKICAgICAgICBjbG9z ZShmZCk7CiAgICAgIH0KICAgICAgaWYoMCl7CiAgICAgICAgaW50IGZkID0gb3BlbigiL21udC9u ZXciLCBPX1JEV1J8T19DUkVBVCwgMDY2Nik7CiAgICAgICAgcHJpbnRmKCJjcmVhdCAvbW50L25l dyAtPiAlZCBlcnJubyAlZFxuIiwgZmQsIGVycm5vKTsKICAgICAgICBpZihmZCA8IDApIHBlcnJv cigiL21udC9uZXciKTsKICAgICAgICBpZih3cml0ZShmZCwgIngiLCAxKSA8IDApIHBlcnJvcigi d3JpdGUiKTsKICAgICAgICBsc2VlayhmZCwgMEwsIDApOwogICAgICAgIGNoYXIgYnVmWzUxMl07 CiAgICAgICAgdm9sYXRpbGUgaW50IGp1bmsgPSByZWFkKGZkLCBidWYsIHNpemVvZihidWYpKTsK ICAgICAgICAodm9pZCkganVuazsKICAgICAgICAvL21rZGlyKCIvbW50L25ldy9uZXduZXciLCAw Nzc3KTsKICAgICAgICAvL2lmKHVubGluaygiL21udC9uZXciKSA8IDApIHBlcnJvcigidW5saW5r Iik7CiAgICAgICAgLy9jbG9zZShmZCk7CiAgICAgICAgaWYoZmxvY2soZmQsIExPQ0tfRVgpIDwg MCkgcGVycm9yKCJmbG9jayIpOwogICAgICAgIHNsZWVwKDEpOwogICAgICB9CiAgICAgIGlmKDAp ewogICAgICAgIGludCByZXQgPSBta2RpcigiL21udC9kIiwgMDc3Nyk7CiAgICAgICAgcHJpbnRm KCJta2RpciAvbW50L2QgLT4gJWQgZXJybm8gJWRcbiIsIHJldCwgZXJybm8pOwogICAgICAgIGlm KHJldCA8IDApIHBlcnJvcigibWtkaXIgL21udC9kIik7CiAgICAgICAgaWYoY2hkaXIoIi9tbnQv ZCIpID09IDApewogICAgICAgICAgcHJpbnRmKCJjaGRpciBzdWNjZWVkZWRcbiIpOwogICAgICAg ICAgaWYoY3JlYXQoIm5ld25ld25ldyIsIDA2NjYpIDwgMCkgcGVycm9yKCJjcmVhdGUgbmV3bmV3 bmV3Iik7CiAgICAgICAgICB1bmxpbmsoIm5ld25ld25ldyIpOwogICAgICAgIH0gZWxzZSB7CiAg ICAgICAgICBwZXJyb3IoImNoZGlyIC9tbnQvZCIpOwogICAgICAgIH0KICAgICAgICBjcmVhdCgi L21udC9kL25ld25ldyIsIDA2NjYpOwogICAgICAgIHJtZGlyKCIvbW50L2QiKTsKICAgICAgfQog ICAgICBpZigwKXsKICAgICAgICBzeXMoInNldGZhY2wgLW0gb3duZXJAOnJ3eHA6OmFsbG93IC9t bnQveCIpOwogICAgICAgIHN5cygiZ2V0ZmFjbCAvbW50L3giKTsKICAgICAgfQogICAgICBpZigw KXsKICAgICAgICBpbnQgZmQgPSBvcGVuKCIvbW50L25ldyIsIE9fUkRXUnxPX0NSRUFULCAwNjY2 KTsKICAgICAgICBpZihmZCA8IDApIHBlcnJvcigib3BlbiAvbW50L25ldyIpOwogICAgICAgIGNo YXIgYnVmWzMyXTsKICAgICAgICBtZW1zZXQoYnVmLCAxLCBzaXplb2YoYnVmKSk7CiAgICAgICAg aWYod3JpdGUoZmQsIGJ1Ziwgc2l6ZW9mKGJ1ZikpIDwgMCkgcGVycm9yKCJ3cml0ZSIpOwogICAg ICAgIGxzZWVrKGZkLCAob2ZmX3QpMCwgMCk7CiAgICAgICAgaW50IGZkMiA9IGNyZWF0KCIvbW50 L25ld25ldyIsIDA2NjYpOwogICAgICAgIGlmKGZkMiA8IDApIHBlcnJvcigiY3JlYXQgL21udC9u ZXduZXciKTsKICAgICAgICBvZmZfdCBvMSA9IDA7CiAgICAgICAgb2ZmX3QgbzIgPSAwOwogICAg ICAgIGlmKGNvcHlfZmlsZV9yYW5nZShmZCwgJm8xLCBmZDIsICZvMiwgMTYsIDApIDwgMCkgcGVy cm9yKCJjb3B5X2ZpbGVfcmFuZ2UiKTsKICAgICAgfQogICAgICBpZigwKXsKICAgICAgICBzeXMo ImVjaG8gLW4gbHM6IDsgbHMgLWwgL21udCIpOwogICAgICAgIHN5cygiZWNobyAtbiBsczogOyBs cyAtbCAvbW50Ly4gL21udC96Iik7CiAgICAgICAgc3lzKCJlY2hvIC1uIGVjaG86IDsgZWNobyBo aSA+IC9tbnQveCIpOwogICAgICAgIHN5cygiZWNobyAtbiBkZDogOyBkZCBpZj0vbW50L3kgb2Y9 L2Rldi9udWxsIGJzPTUxMiBjb3VudD0xIik7CiAgICAgICAgc3lzKCJlY2hvIC1uIHVtb3VudDog OyB1bW91bnQgL21udCIpOwogICAgICB9CiAgICB9CiAgICBleGl0KDApOwogIH0KCiAgaW50IHBp ZDIgPSBmb3JrKCk7CiAgaWYocGlkMiA9PSAwKXsKCiAgICB3aGlsZSgxKXsKICAgICAgc29ja2xl bl90IHNpbmxlbiA9IHNpemVvZihzaW4pOwogICAgICBwcmludGYoImNhbGxpbmcgYWNjZXB0XG4i KTsKICAgICAgaW50IHMxID0gYWNjZXB0KHMsIChzdHJ1Y3Qgc29ja2FkZHIgKikgJnNpbiwgJnNp bmxlbik7CiAgICAgIHByaW50ZigiYWNjZXB0IHJldHVybmVkICVkXG4iLCBzMSk7CiAgICAgIGlm KHMxIDwgMCkgeyBwZXJyb3IoImFjY2VwdCIpOyBleGl0KDEpOyB9CiAgICAgIAogICAgICB3aGls ZSgxKXsKICAgICAgICBpZihyZWFkbihzMSwgJmlsZW4sIDQpIDwgMCkgYnJlYWs7CiAgICAgICAg aWxlbiA9IG50b2hsKGlsZW4pOwogICAgICAgIGlsZW4gJj0gMHg3ZmZmZmZmZjsKICAgICAgICBp ZihyZWFkbihzMSwgaWJ1ZiwgaWxlbikgPCAwKSBicmVhazsKICAgICAgICBvaSA9IGlpID0gMDsK ICAgICAgICBwdXQzMigwKTsgLy8gcGxhY2UtaG9sZGVyIGZvciBsZW5ndGgKICAgICAgICBwYXJz ZV9ycGMoKTsKI2lmIDEKICAgICAgICBpZihzeW1zdGFydCAhPSAtMSl7CiAgICAgICAgICBmb3Io aW50IGkgPSAwOyBpIDwgMTY7IGkrKykKICAgICAgICAgICAgcHV0MzIoMHhmZmZmZmZmZik7CiAg ICAgICAgfQojZW5kaWYKICAgICAgICAqKGludCopKG9idWYrMCkgPSBodG9ubCgob2kgLSA0KSB8 IDB4ODAwMDAwMDApOwogICAgICAgIGlmKGFhaSA+IE5BQSl7CiAgICAgICAgICBwcmludGYoIm9v cHMgYWFpICVkIE5BQSAlZFxuIiwgYWFpLCBOQUEpOwogICAgICAgICAgZXhpdCgxKTsKICAgICAg ICB9CiAgICAgICAgaWYoc3ltc3RhcnQgIT0gLTEpewogICAgICAgICAgZm9yKGludCBpID0gc3lt c3RhcnQ7IGkgPCBvaSAmJiBhYWkgPCBOQUE7IGkgKz0gOCkKICAgICAgICAgICAgKih1bnNpZ25l ZCBsb25nIGxvbmcgKikob2J1ZiArIGkpIF49IGFhW2FhaSsrXTsKICAgICAgICAgIHN5bXN0YXJ0 ID0gLTE7CiAgICAgICAgfQogICAgICAgIGlmKG9pID4gMCl7CiAgICAgICAgICBpZih3cml0ZShz MSwgb2J1Ziwgb2kpPD0wKSBwZXJyb3IoIndyaXRlIik7CiAgICAgICAgfQoKICAgICAgICBpZihz ZW5kX2JhY2spewogICAgICAgICAgc2VuZF9iYWNrID0gMDsKICAgICAgICAgIG9pID0gMDsKICAg ICAgICAgIHB1dDMyKDApOyAvLyBkdW1teSBsZW5ndGgKICAgICAgICAgIHB1dF9ycGNfaGVhZGVy KDB4NDAwMDAwMDAsIDEpOwoKICAgICAgICAgIC8vIENCX0NPTVBPVU5ECiAgICAgICAgICBwdXRf b3BhcXVlKDAsICIiKTsgLy8gY29tcG91bmQgdGFnCiAgICAgICAgICBwdXQzMigyKTsgLy8gbWlu b3IgdmVyc2lvbgogICAgICAgICAgcHV0MzIoMCk7IC8vIGNhbGxiYWNrX2lkZW50CiAgICAgICAg ICBwdXQzMigyKTsgLy8gb3BlcmF0aW9ucyBpbiB0aGUgY29tcG91bmQKCiAgICAgICAgICAvLyBD Ql9TRVFVRU5DRQogICAgICAgICAgcHV0MzIoMTEpOwogICAgICAgICAgZm9yKGludCBpID0gMDsg aSA8IDQ7IGkrKykKICAgICAgICAgICAgcHV0MzIoMSk7IC8vIHNlc3Npb25pZAogICAgICAgICAg cHV0MzIoMSk7IC8vIHNlcXVlbmNlaWQgPz8/CiAgICAgICAgICBwdXQzMigwKTsgLy8gc2xvdGlk CiAgICAgICAgICBwdXQzMigwKTsgLy8gaGlnaGVzdF9zbG90aWQKICAgICAgICAgIHB1dDMyKDAp OyAvLyBjYWNoZXRoaXMKICAgICAgICAgIHB1dDMyKDApOyAvLyBjc2FfcmVmZXJyaW5nX2NhbGxf bGlzdHM8PgogICAgICAgICAgCiAgICAgICAgICBpbnQgeG9pID0gb2k7CiAgICAgICAgICBmb3Io aW50IGkgPSAwOyBpIDwgMzI7IGkrKykKICAgICAgICAgICAgcHV0MzIoMHhmZmZmZmZmZik7CiAg ICAgICAgICBmb3IoaW50IGkgPSB4b2k7IGkgPCBvaSAmJiBhYWkgPCBOQUE7IGkgKz0gOCkKICAg ICAgICAgICAgKih1bnNpZ25lZCBsb25nIGxvbmcgKikob2J1ZiArIGkpIF49IGFhW2FhaSsrXTsK ICAgICAgICAgICooaW50Kikob2J1ZiswKSA9IGh0b25sKChvaSAtIDQpIHwgMHg4MDAwMDAwMCk7 CiAgICAgICAgICBpZih3cml0ZShzMSwgb2J1Ziwgb2kpPD0wKSBwZXJyb3IoIndyaXRlIik7CiAg ICAgICAgfQogICAgICB9CiAgICAgIGNsb3NlKHMxKTsKICAgIH0KICAgIGV4aXQoMSk7CiAgfQog IGNsb3NlKHMpOwogIHNsZWVwKDIwKTsKICBpZihzeXN0ZW0oImRtZXNnIHwgZ3JlcCAndW5oYW5k bGVkIHNpZyciKSA9PSAwKXsKICAgcHJpbnRmKCJ1bmhhbmRsZWQgc2lnbmFsXG4iKTsgd2hpbGUo MSl7fQogIH0KfQo= --=-=-=--