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 73DC2C433F5 for ; Mon, 3 Jan 2022 18:34:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235628AbiACSeE (ORCPT ); Mon, 3 Jan 2022 13:34:04 -0500 Received: from outgoing-stata.csail.mit.edu ([128.30.2.210]:47543 "EHLO outgoing-stata.csail.mit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbiACSeE (ORCPT ); Mon, 3 Jan 2022 13:34:04 -0500 X-Greylist: delayed 748 seconds by postgrey-1.27 at vger.kernel.org; Mon, 03 Jan 2022 13:34:04 EST 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 1n4Rxd-0006Ky-Hi; Mon, 03 Jan 2022 13:21:33 -0500 Received: from crash.local (localhost [127.0.0.1]) by crash.local (Postfix) with ESMTP id 0DCCA14519391; Mon, 3 Jan 2022 13:21:33 -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: NFS v4 client can dereference uninitialized pointer in devicenotify callback MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Mon, 03 Jan 2022 13:21:32 -0500 Message-ID: <98728.1641234092@crash.local> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org --=-=-= Content-Type: text/plain decode_devicenotify_args() says: if (n <= 0) goto out; ...; args->devs = kmalloc_array(n, sizeof(*args->devs), GFP_KERNEL); If the server sends n <= 0 in the callback RPC, the function returns with status=0 (no error) but args->devs is not initialized. Subsequently nfs4_callback_devicenotify() says: kfree(args->devs) which dereferences a wild pointer. I've attached a demo program: # uname -a Linux (none) 5.16.0-rc7-00108-g800829388818-dirty #10 SMP Mon Jan 3 17:30:59 UTC 2022 riscv64 riscv64 riscv64 GNU/Linux # cc nfs_17.c # ./a.out ... [ 74.542294] Unable to handle kernel paging request at virtual address 00037fe02133aa08 [ 74.768159] status: 0000000200000121 badaddr: 00037fe02133aa08 cause: 000000000000000d [ 74.781690] [] kfree+0x50/0x290 [ 74.792101] [] nfs4_callback_devicenotify+0xac/0xd6 [ 74.804090] [] nfs4_callback_compound+0x342/0x526 [ 74.816500] [] nfs_callback_dispatch+0xd0/0xe4 [ 74.828874] [] svc_process_common+0x2f4/0x56c [ 74.841161] [] bc_svc_process+0xde/0x1a4 [ 74.851179] [] nfs41_callback_svc+0x106/0x188 [ 74.863615] [] kthread+0x124/0x136 [ 74.873686] [] ret_from_exception+0x0/0xc [ 74.892645] ---[ end trace e784fbe07231bbd1 ]--- --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=nfs_17.c Content-Transfer-Encoding: base64 I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPHN0ZGxpYi5o PgojZGVmaW5lIF9HTlVfU09VUkNFCiNpbmNsdWRlIDx1bmlzdGQuaD4KI2luY2x1ZGUgPHN5cy9z b2NrZXQuaD4KI2luY2x1ZGUgPHN5cy9maWxlLmg+CiNpbmNsdWRlIDxzeXMvaW9jdGwuaD4KI2lu Y2x1ZGUgPG5ldGluZXQvaW4uaD4KI2luY2x1ZGUgPHN5cy93YWl0Lmg+CiNpbmNsdWRlIDxzeXMv cmVzb3VyY2UuaD4KI2luY2x1ZGUgPHN5cy9wYXJhbS5oPgojaW5jbHVkZSA8c3lzL21vdW50Lmg+ CiNpbmNsdWRlIDxzeXMvdHlwZXMuaD4KI2luY2x1ZGUgPHN5cy9zdGF0Lmg+CiNpbmNsdWRlIDxz eXMvdmZzLmg+CiNpbmNsdWRlIDxkaXJlbnQuaD4KI2luY2x1ZGUgPGFzc2VydC5oPgojaW5jbHVk ZSA8ZmNudGwuaD4KI2luY2x1ZGUgPGVycm5vLmg+CgoKaW50IHN5bV9vcCA9IC0xOwppbnQgc3lt X3NraXAgPSAwOwppbnQgc3ltX3R5cGUgPSAwOyAvLyBhbGwgZmF0dHI0IGZpbGUgdHlwZXMKaW50 IHN5bV9maCA9IDA7IC8vIGFsbCBmaWxlIGhhbmRsZXMKaW50IHN5bV9iaXRtYXBzID0gMDsKaW50 IHN5bV9vcGFxdWVfbGVuID0gMDsKCmludCBvcGNvdW50c1syNTZdOwpsb25nIGxvbmcgbmV4dF9j b29raWUgPSAzOwppbnQgY3VycmVudF9maCA9IDA7CmludCBjb21wb3VuZF9zdGF0dXM7CmludCBz ZW5kX2JhY2s7CgovLyBtYXAgZmlsZS9kaXIgbmFtZXMgdG8gZmlsZSBoYW5kbGUKY2hhciAqZmhu YW1lc1sxMDBdID0gewogICAgICAgICAgICAgICAiIiwKICAgICAgICAgICAgICAgInRtcCIsCiAg ICAgICAgICAgICAgICJ4IiwKICAgICAgICAgICAgICAgInkiLAogICAgICAgICAgICAgICAieiIs CiAgICAgICAgICAgICAgICJ6enoiLAogICAgICAgICAgICAgICAwCn07CgppbnQKbmFtZTJmaChj aGFyICpuYW1lLCBpbnQgY3JlYXRlKQp7CiAgZm9yKGludCBpID0gMDsgZmhuYW1lc1tpXTsgaSsr KXsKICAgIGlmKHN0cmNtcChuYW1lLCBmaG5hbWVzW2ldKSA9PSAwKQogICAgICByZXR1cm4gaTsK ICB9CiAgaWYoY3JlYXRlKXsKICAgIGZvcihpbnQgaSA9IDA7IDsgaSsrKXsKICAgICAgaWYoZmhu YW1lc1tpXSA9PSAwKXsKICAgICAgICBmaG5hbWVzW2ldID0gbWFsbG9jKDEwMCk7CiAgICAgICAg c3RyY3B5KGZobmFtZXNbaV0sIG5hbWUpOwogICAgICAgIHJldHVybiBpOwogICAgICB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S8zMl0gJiAoMSA8PCAoYSAl IDMyKSkpewogICAgICBpZihhID09IDApewogICAgICAgIHB1dDMyKDMpOyAvLyAjIGJpdG1hcCB3 b3JkcyBvZiBzdXBwb3J0ZWQgYXR0cnMKICAgICAgICBwdXQzMigweGZmZmZmZmZmKTsKICAgICAg ICBwdXQzMigweGZmZmZmZmZmKTsKICAgICAgICBwdXQzMigweGZmZmZmZmZmKTsKICAgICAgfSBl bHNlIGlmKGEgPT0gMSl7CiAgICAgICAgaW50IHR5cGUgPSAxOwogICAgICAgIGlmKGZoID09IDAg fHwgZmggPT0gMSkKICAgICAgICAgIHR5cGUgPSAyOwogICAgICAgIGlmKHN5bV90eXBlKSB0eXBl IF49IGFhW2FhaSsrXTsKICAgICAgICBwdXQzMih0eXBlKTsgLy8gTkY0RElSPTIgb3IgTkY0UkVH PTEKICAgICAgfSBlbHNlIGlmKGEgPT0gMil7CiAgICAgICAgcHV0MzIoMCk7IC8vIGZoX2V4cGly ZV90eXBlCiAgICAgIH0gZWxzZSBpZihhID09IDMpewogICAgICAgIHB1dDY0KDApOyAvLyBjaGFu Z2UKICAgICAgfSBlbHNlIGlmKGEgPT0gNCl7CiAgICAgICAgcHV0NjQoNDA5NioxMCk7IC8vIHNp emUKICAgICAgfSBlbHNlIGlmKGEgPT0gNSl7CiAgICAgICAgcHV0MzIoMSk7IC8vIGxpbmsgc3Vw cG9ydAogICAgICB9IGVsc2UgaWYoYSA9PSA2KXsKICAgICAgICBwdXQzMigxKTsgLy8gc3ltbGlu ayBzdXBwb3J0CiAgICAgIH0gZWxzZSBpZihhID09IDgpewogICAgICAgIHB1dDY0KDEpOyAvLyBm c2lkIG1ham9yCiAgICAgICAgcHV0NjQoMSk7IC8vIGZzaWQgbWlub3IKICAgICAgfSBlbHNlIGlm KGEgPT0gMTApewogICAgICAgIHB1dDMyKDEwKTsgLy8gbGVhc2UgdGltZQogICAgICB9IGVsc2Ug aWYoYSA9PSAxMSl7CiAgICAgICAgcHV0MzIoMCk7IC8vIHJkYXR0cl9lcnJvcgogICAgICB9IGVs c2UgaWYoYSA9PSAxMil7CiAgICAgICAgLy8gQUNMCiAgICAgICAgaW50IG4gPSAyOwogICAgICAg IHB1dDMyKG4pOwogICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspewogICAgICAgICAg cHV0MzIoMCk7IC8vIHR5cGUKICAgICAgICAgIHB1dDMyKDApOyAvLyBmbGFnCiAgICAgICAgICBw dXQzMigwKTsgLy8gbWFzawogICAgICAgICAgY2hhciB3aG9bOV07CiAgICAgICAgICBtZW1zZXQo d2hvLCAwLCBzaXplb2Yod2hvKSk7CiAgICAgICAgICBzdHJjcHkod2hvLCAibm9ib2R5Iik7CiAg ICAgICAgICBwdXRfb3BhcXVlKHN0cmxlbih3aG8pLCB3aG8pOwogICAgICAgIH0KICAgICAgfSBl bHNlIGlmKGEgPT0gMTMpewogICAgICAgIHB1dDMyKDB4Zik7IC8vIGFjbHN1cHBvcnQKICAgICAg fSBlbHNlIGlmKGEgPT0gMTUpewogICAgICAgIHB1dDMyKDEpOyAvLyBjYW5zZXR0aW1lCiAgICAg IH0gZWxzZSBpZihhID09IDE2KXsKICAgICAgICBwdXQzMigwKTsgLy8gY2FzZSBpbnNlbnNpdGl2 ZQogICAgICB9IGVsc2UgaWYoYSA9PSAxNyl7CiAgICAgICAgcHV0MzIoMSk7IC8vIGNhc2UgcHJl c2VydmluZwogICAgICB9IGVsc2UgaWYoYSA9PSAxOCl7CiAgICAgICAgcHV0MzIoMCk7IC8vIGNo b3duX3Jlc3RyaWN0ZWQKICAgICAgfSBlbHNlIGlmKGEgPT0gMTkpewogICAgICAgIC8vIGZpbGVo YW5kbGUKICAgICAgICBpbnQgeGZoID0gZmg7CiAgICAgICAgaWYoc3ltX2ZoKSB4ZmggXj0gYWFb YWFpKytdOwogICAgICAgIHB1dF9vcGFxdWUoNCwgKGNoYXIqKSZ4ZmgpOyAvLyBmaAogICAgICB9 IGVsc2UgaWYoYSA9PSA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PT0gMzEpewogICAgICAgIHB1dDY0 KDEwKjQwOTYpOyAvLyBtYXggd3JpdGUKICAgICAgfSBlbHNlIGlmKGEgPT0gMzMpewogICAgICAg IHB1dDMyKDA3NzcpOyAvLyBtb2RlCiAgICAgIH0gZWxzZSBpZihhID09IDM0KXsKICAgICAgICBw dXQzMigxKTsgLy8gbm9fdHJ1bmMKICAgICAgfSBlbHNlIGlmKGEgPT0gMzUpewogICAgICAgIHB1 dDMyKDMpOyAvLyBudW1saW5rcwogICAgICB9IGVsc2UgaWYoYSA9PSAzNil7CiAgICAgICAgLy8g cHV0X29wYXF1ZSg2LCAib3RoZXIiKTsgLy8gb3duZXIKICAgICAgICBwdXRfb3BhcXVlKDYsICJu b2JvZHkiKTsgLy8gb3duZXIKICAgICAgICAvLyBwdXRfb3BhcXVlKDUsICI2NTUzNCIpOyAvLyBv d25lcgogICAgICB9IGVsc2UgaWYoYSA9PSAzNyl7CiAgICAgICAgLy8gcHV0X29wYXF1ZSg2LCAi b3RoZXIiKTsgLy8gb3duZXJfZ3JvdXAKICAgICAgICBwdXRfb3BhcXVlKDYsICJub2JvZHkiKTsg Ly8gb3duZXJfZ3JvdXAKICAgICAgICAvLyBwdXRfb3BhcXVlKDUsICI2NTUzNCIpOyAvLyBvd25l cl9ncm91cAogICAgICB9IGVsc2UgaWYoYSA9PSA0MSl7CiAgICAgICAgcHV0MzIoMCk7IC8vIHJh d2RldiBtYWpvcgogICAgICAgIHB1dDMyKDApOyAvLyByYXdkZXYgbWlub3IKICAgICAgfSBlbHNl IGlmKGEgPT0gNDIpewogICAgICAgIHB1dDY0KDEwKjEwMjQqMTAyNCk7IC8vIHNwYWNlX2F2YWls CiAgICAgIH0gZWxzZSBpZihhID09IDQzKXsKICAgICAgICBwdXQ2NCgxMCoxMDI0KjEwMjQpOyAv LyBzcGFjZV9mcmVlCiAgICAgIH0gZWxzZSBpZihhID09IDQ0KXsKICAgICAgICBwdXQ2NCgyMCox MDI0KjEwMjQpOyAvLyBz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GxpbmVidWYoc3Rkb3V0KTsK ICBzdHJ1Y3QgcmxpbWl0IHI7CiAgci5ybGltX2N1ciA9IHIucmxpbV9tYXggPSAwOwogIHNldHJs aW1pdChSTElNSVRfQ09SRSwgJnIpOwoKICBpbnQgcyA9IHNvY2tldChBRl9JTkVULCBTT0NLX1NU UkVBTSwgMCk7CiAgc3RydWN0IHNvY2thZGRyX2luIHNpbjsKICBtZW1zZXQoJnNpbiwgMCwgc2l6 ZW9mKHNpbikpOwogIHNpbi5zaW5fZmFtaWx5ID0gQUZfSU5FVDsKICBzaW4uc2luX3BvcnQgPSBo dG9ucygyMDQ5KTsKICBpbnQgeWVzID0gMTsKICBzZXRzb2Nrb3B0KHMsIFNPTF9TT0NLRVQsIFNP X1JFVVNFQUREUiwgJnllcywgc2l6ZW9mKHllcykpOwogIGlmKGJpbmQocywgKHN0cnVjdCBzb2Nr YWRkciAqKSZzaW4sIHNpemVvZihzaW4pKSA8IDApewogICAgcGVycm9yKCJiaW5kIik7IGV4aXQo MSk7CiAgfQogIGxpc3RlbihzLCAxMCk7CiAgc3luYygpOwoKICBpbnQgcGlkMSA9IGZvcmsoKTsK ICBpZihwaWQxID09IDApewogICAgY2xvc2Uocyk7CiAgICBzbGVlcCgxKTsKICAgIGlmKHN5c3Rl bSgiZWNobyAtbiBtb3VudDogOyBtb3VudCAtbyBub2xvY2ssbm9kZXYgMTI3LjAuMC4xOi90bXAg L21udCIpID09IDApewogICAgICBpZigwKXsKICAgICAgICBwcmludGYoInN0YXRmczogIik7IGZm bHVzaChzdGRvdXQpOwogICAgICAgIHN0cnVjdCBzdGF0ZnMgc2I7CiAgICAgICAgaW50IHJldCA9 IHN0YXRmcygiL21udC8uIiwgJnNiKTsKICAgICAgICBwcmludGYoInN0YXRmcyAtPiAlZFxuIiwg cmV0KTsKICAgICAgfQogICAgICBpZigwKXsKICAgICAgICBpbnQgZmQgPSBvcGVuKCIvbW50Iiwg MCk7CiAgICAgICAgaWYoZmQgPCAwKSB7IHBlcnJvcigiL21udCIpOyBleGl0KDEpOyB9CiAgICAg ICAgb2ZmX3QgYmFzZSA9IDA7CiAgICAgICAgY2hhciBidWZbNDA5Nl07CiAgICAgICAgc3NpemVf dCByZXQgPSBnZXRkaXJlbnRyaWVzKGZkLCBidWYsIHNpemVvZihidWYpLCAmYmFzZSk7CiAgICAg ICAgcHJpbnRmKCJnZXRkaXJlbnRyaWVzIHJldCAlbGQgZXJybm8gJWRcbiIsIHJldCwgZXJybm8p OwogICAgICAgIGlmKHJldCA8IDApIHBlcnJvcigiZ2V0ZGlyZW50cmllcyIpOwogICAgICAgIGNs b3NlKGZkKTsKICAgICAgfQogICAgICBpZigwKXsKICAgICAgICBpbnQgZmQgPSBvcGVuKCIvbW50 L3giLCAwKTsKICAgICAgICBwcmludGYoIm9wZW4gL21udC94IC0+ICVkIGVycm5vICVkXG4iLCBm ZCwgZXJybm8pOwogICAgICAgIGlmKGZkIDwgMCkgcGVycm9yKCIvbW50L3giKTsKICAgICAgICBj bG9zZShmZCk7CiAgICAgIH0KICAgICAgaWYoMCl7CiAgICAgICAgaW50IGZkID0gb3BlbigiL21u dC9uZXciLCBPX1JEV1J8T19DUkVBVCwgMDY2Nik7CiAgICAgICAgcHJpbnRmKCJjcmVhdCAvbW50 L25ldyAtPiAlZCBlcnJubyAlZFxuIiwgZmQsIGVycm5vKTsKICAgICAgICBpZihmZCA8IDApIHBl cnJvcigiL21udC9uZXciKTsKICAgICAgICBpZih3cml0ZShmZCwgIngiLCAxKSA8IDApIHBlcnJv cigid3JpdGUiKTsKICAgICAgICBsc2VlayhmZCwgMEwsIDApOwogICAgICAgIGNoYXIgYnVmWzUx Ml07CiAgICAgICAgdm9sYXRpbGUgaW50IGp1bmsgPSByZWFkKGZkLCBidWYsIHNpemVvZihidWYp KTsKICAgICAgICAodm9pZCkganVuazsKICAgICAgICAvL21rZGlyKCIvbW50L25ldy9uZXduZXci LCAwNzc3KTsKICAgICAgICAvL2lmKHVubGluaygiL21udC9uZXciKSA8IDApIHBlcnJvcigidW5s aW5rIik7CiAgICAgICAgLy9jbG9zZShmZCk7CiAgICAgICAgaWYoZmxvY2soZmQsIExPQ0tfRVgp IDwgMCkgcGVycm9yKCJmbG9jayIpOwogICAgICAgIHNsZWVwKDEpOwogICAgICB9CiAgICAgIGlm KDEpewogICAgICAgIGludCBmZCA9IG9wZW4oIi9tbnQvbmV3IiwgT19SRFdSfE9fQ1JFQVQsIDA2 NjYpOwogICAgICAgIHByaW50ZigiY3JlYXQgL21udC9uZXcgLT4gJWQgZXJybm8gJWRcbiIsIGZk LCBlcnJubyk7CiAgICAgICAgaWYoZmQgPCAwKSBwZXJyb3IoIi9tbnQvbmV3Iik7CiAgICAgICAg aWYoZmxvY2soZmQsIExPQ0tfRVgpIDwgMCkgcGVycm9yKCJmbG9jayIpOwogICAgICAgIHNsZWVw KDEpOwogICAgICB9CiAgICAgIGlmKDApewogICAgICAgIGludCByZXQgPSBta2RpcigiL21udC9k IiwgMDc3Nyk7CiAgICAgICAgcHJpbnRmKCJta2RpciAvbW50L2QgLT4gJWQgZXJybm8gJWRcbiIs IHJldCwgZXJybm8pOwogICAgICAgIGlmKHJldCA8IDApIHBlcnJvcigibWtkaXIgL21udC9kIik7 CiAgICAgICAgaWYoY2hkaXIoIi9tbnQvZCIpID09IDApewogICAgICAgICAgcHJpbnRmKCJjaGRp ciBzdWNjZWVkZWRcbiIpOwogICAgICAgICAgaWYoY3JlYXQoIm5ld25ld25ldyIsIDA2NjYpIDwg MCkgcGVycm9yKCJjcmVhdGUgbmV3bmV3bmV3Iik7CiAgICAgICAgICB1bmxpbmsoIm5ld25ld25l dyIpOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICBwZXJyb3IoImNoZGlyIC9tbnQvZCIpOwog ICAgICAgIH0KICAgICAgICBjcmVhdCgiL21udC9kL25ld25ldyIsIDA2NjYpOwogICAgICAgIHJt ZGlyKCIvbW50L2QiKTsKICAgICAgfQogICAgICBpZigwKXsKICAgICAgICBzeXMoInNldGZhY2wg LW0gb3duZXJAOnJ3eHA6OmFsbG93IC9tbnQveCIpOwogICAgICAgIHN5cygiZ2V0ZmFjbCAvbW50 L3giKTsKICAgICAgfQogICAgICBpZigwKXsKICAgICAgICBpbnQgZmQgPSBvcGVuKCIvbW50L25l dyIsIE9fUkRXUnxPX0NSRUFULCAwNjY2KTsKICAgICAgICBpZihmZCA8IDApIHBlcnJvcigib3Bl biAvbW50L25ldyIpOwogICAgICAgIGNoYXIgYnVmWzMyXTsKICAgICAgICBtZW1zZXQoYnVmLCAx LCBzaXplb2YoYnVmKSk7CiAgICAgICAgaWYod3JpdGUoZmQsIGJ1Ziwgc2l6ZW9mKGJ1ZikpIDwg MCkgcGVycm9yKCJ3cml0ZSIpOwogICAgICAgIGxzZWVrKGZkLCAob2ZmX3QpMCwgMCk7CiAgICAg ICAgaW50IGZkMiA9IGNyZWF0KCIvbW50L25ld25ldyIsIDA2NjYpOwogICAgICAgIGlmKGZkMiA8 IDApIHBlcnJvcigiY3JlYXQgL21udC9uZXduZXciKTsKICAgICAgICBvZmZfdCBvMSA9IDA7CiAg ICAgICAgb2ZmX3QgbzIgPSAwOwogICAgICAgIGlmKGNvcHlfZmlsZV9yYW5nZShmZCwgJm8xLCBm ZDIsICZvMiwgMTYsIDApIDwgMCkgcGVycm9yKCJjb3B5X2ZpbGVfcmFuZ2UiKTsKICAgICAgfQog ICAgICBpZigwKXsKICAgICAgICBzeXMoImVjaG8gLW4gbHM6IDsgbHMgLWwgL21udCIpOwogICAg ICAgIHN5cygiZWNobyAtbiBsczogOyBscyAtbCAvbW50Ly4gL21udC96Iik7CiAgICAgICAgc3lz KCJlY2hvIC1uIGVjaG86IDsgZWNobyBoaSA+IC9tbnQveCIpOwogICAgICAgIHN5cygiZWNobyAt biBkZDogOyBkZCBpZj0vbW50L3kgb2Y9L2Rldi9udWxsIGJzPTUxMiBjb3VudD0xIik7CiAgICAg ICAgc3lzKCJlY2hvIC1uIHVtb3VudDogOyB1bW91bnQgL21udCIpOwogICAgICB9CiAgICB9CiAg ICBleGl0KDApOwogIH0KCiAgaW50IHBpZDIgPSBmb3JrKCk7CiAgaWYocGlkMiA9PSAwKXsKCiAg ICB3aGlsZSgxKXsKICAgICAgc29ja2xlbl90IHNpbmxlbiA9IHNpemVvZihzaW4pOwogICAgICBw cmludGYoImNhbGxpbmcgYWNjZXB0XG4iKTsKICAgICAgaW50IHMxID0gYWNjZXB0KHMsIChzdHJ1 Y3Qgc29ja2FkZHIgKikgJnNpbiwgJnNpbmxlbik7CiAgICAgIHByaW50ZigiYWNjZXB0IHJldHVy bmVkICVkXG4iLCBzMSk7CiAgICAgIGlmKHMxIDwgMCkgeyBwZXJyb3IoImFjY2VwdCIpOyBleGl0 KDEpOyB9CiAgICAgIAogICAgICB3aGlsZSgxKXsKICAgICAgICBpZihyZWFkbihzMSwgJmlsZW4s IDQpIDwgMCkgYnJlYWs7CiAgICAgICAgaWxlbiA9IG50b2hsKGlsZW4pOwogICAgICAgIGlsZW4g Jj0gMHg3ZmZmZmZmZjsKICAgICAgICBpZihyZWFkbihzMSwgaWJ1ZiwgaWxlbikgPCAwKSBicmVh azsKICAgICAgICBvaSA9IGlpID0gMDsKICAgICAgICBwdXQzMigwKTsgLy8gcGxhY2UtaG9sZGVy IGZvciBsZW5ndGgKICAgICAgICBwYXJzZV9ycGMoKTsKI2lmIDEKICAgICAgICBpZihzeW1zdGFy dCAhPSAtMSl7CiAgICAgICAgICBmb3IoaW50IGkgPSAwOyBpIDwgMTY7IGkrKykKICAgICAgICAg ICAgcHV0MzIoMHhmZmZmZmZmZik7CiAgICAgICAgfQojZW5kaWYKICAgICAgICAqKGludCopKG9i dWYrMCkgPSBodG9ubCgob2kgLSA0KSB8IDB4ODAwMDAwMDApOwogICAgICAgIGlmKGFhaSA+IE5B QSl7CiAgICAgICAgICBwcmludGYoIm9vcHMgYWFpICVkIE5BQSAlZFxuIiwgYWFpLCBOQUEpOwog ICAgICAgICAgZXhpdCgxKTsKICAgICAgICB9CiAgICAgICAgaWYoc3ltc3RhcnQgIT0gLTEpewog ICAgICAgICAgZm9yKGludCBpID0gc3ltc3RhcnQ7IGkgPCBvaSAmJiBhYWkgPCBOQUE7IGkgKz0g OCkKICAgICAgICAgICAgKih1bnNpZ25lZCBsb25nIGxvbmcgKikob2J1ZiArIGkpIF49IGFhW2Fh aSsrXTsKICAgICAgICAgIHN5bXN0YXJ0ID0gLTE7CiAgICAgICAgfQogICAgICAgIGlmKG9pID4g MCl7CiAgICAgICAgICBpZih3cml0ZShzMSwgb2J1Ziwgb2kpPD0wKSBwZXJyb3IoIndyaXRlIik7 CiAgICAgICAgfQoKICAgICAgICBpZihzZW5kX2JhY2spewogICAgICAgICAgc2VuZF9iYWNrID0g MDsKICAgICAgICAgIG9pID0gMDsKICAgICAgICAgIHB1dDMyKDApOyAvLyBkdW1teSBsZW5ndGgK ICAgICAgICAgIHB1dF9ycGNfaGVhZGVyKDB4NDAwMDAwMDAsIDEpOwoKICAgICAgICAgIC8vIENC X0NPTVBPVU5ECiAgICAgICAgICBwdXRfb3BhcXVlKDAsICIiKTsgLy8gY29tcG91bmQgdGFnCiAg ICAgICAgICBwdXQzMigyKTsgLy8gbWlub3IgdmVyc2lvbgogICAgICAgICAgcHV0MzIoMCk7IC8v IGNhbGxiYWNrX2lkZW50CiAgICAgICAgICBwdXQzMigyKTsgLy8gb3BlcmF0aW9ucyBpbiB0aGUg Y29tcG91bmQKCiAgICAgICAgICAvLyBDQl9TRVFVRU5DRQogICAgICAgICAgcHV0MzIoMTEpOwog ICAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IDQ7IGkrKykKICAgICAgICAgICAgcHV0MzIoMSk7 IC8vIHNlc3Npb25pZAogICAgICAgICAgcHV0MzIoMSk7IC8vIHNlcXVlbmNlaWQgPz8/CiAgICAg ICAgICBwdXQzMigwKTsgLy8gc2xvdGlkCiAgICAgICAgICBwdXQzMigwKTsgLy8gaGlnaGVzdF9z bG90aWQKICAgICAgICAgIHB1dDMyKDApOyAvLyBjYWNoZXRoaXMKICAgICAgICAgIHB1dDMyKDAp OyAvLyBjc2FfcmVmZXJyaW5nX2NhbGxfbGlzdHM8PgogICAgICAgICAgCiAgICAgICAgICBpbnQg eG9pID0gb2k7CiAgICAgICAgICBmb3IoaW50IGkgPSAwOyBpIDwgMzI7IGkrKykKICAgICAgICAg ICAgcHV0MzIoMHhmZmZmZmZmZik7CiAgICAgICAgICBmb3IoaW50IGkgPSB4b2k7IGkgPCBvaSAm JiBhYWkgPCBOQUE7IGkgKz0gOCkKICAgICAgICAgICAgKih1bnNpZ25lZCBsb25nIGxvbmcgKiko b2J1ZiArIGkpIF49IGFhW2FhaSsrXTsKICAgICAgICAgICooaW50Kikob2J1ZiswKSA9IGh0b25s KChvaSAtIDQpIHwgMHg4MDAwMDAwMCk7CiAgICAgICAgICBpZih3cml0ZShzMSwgb2J1Ziwgb2kp PD0wKSBwZXJyb3IoIndyaXRlIik7CiAgICAgICAgfQogICAgICB9CiAgICAgIGNsb3NlKHMxKTsK ICAgIH0KICAgIGV4aXQoMSk7CiAgfQogIGNsb3NlKHMpOwogIHNsZWVwKDIwKTsKICBpZihzeXN0 ZW0oImRtZXNnIHwgZ3JlcCAndW5oYW5kbGVkIHNpZyciKSA9PSAwKXsKICAgcHJpbnRmKCJ1bmhh bmRsZWQgc2lnbmFsXG4iKTsgd2hpbGUoMSl7fQogIH0KfQo= --=-=-=--