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 F29BAC433F5 for ; Tue, 4 Jan 2022 20:08:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232034AbiADUIU (ORCPT ); Tue, 4 Jan 2022 15:08:20 -0500 Received: from outgoing-stata.csail.mit.edu ([128.30.2.210]:36136 "EHLO outgoing-stata.csail.mit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232214AbiADUIU (ORCPT ); Tue, 4 Jan 2022 15:08:20 -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 1n4q6S-000PQL-No; Tue, 04 Jan 2022 15:08:16 -0500 Received: from crash.local (localhost [127.0.0.1]) by crash.local (Postfix) with ESMTP id 1E5FE14524D2B; Tue, 4 Jan 2022 15:08:16 -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 decode_read_plus_hole() insufficient length sanity check MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Tue, 04 Jan 2022 15:08:15 -0500 Message-ID: <5348.1641326895@crash.local> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org --=-=-= Content-Type: text/plain decode_read_plus_hole() reads a 64-bit length from the server's RPC reply. There's a sanity-check: if (length + res->count > args->count) { but it doesn't work if length is big enough that the sum wraps, e.g. 0xffffffffffffffff. In that case, eventually the loop in xdr_buf_pages_zero() calls memset() on the wrong memory. I've attached a demo: # uname -a Linux (none) 5.16.0-rc7-00108-g800829388818-dirty #23 SMP Tue Jan 4 19:38:52 UTC 2022 riscv64 riscv64 riscv64 GNU/Linux # cc nfs_20.c # ./a.out ... [ 74.362358] Unable to handle kernel paging request at virtual address 92492d8ddff40000 [ 74.612471] status: 0000000200000121 badaddr: 92492d8ddff40000 cause: 000000000000000f [ 74.626913] [] __memset+0x60/0xfc [ 74.637735] [] nfs4_xdr_dec_read_plus+0x2d6/0x3fa [ 74.650614] [] rpcauth_unwrap_resp_decode+0x12/0x1a [ 74.663084] [] rpcauth_unwrap_resp+0x12/0x1a [ 74.675822] [] call_decode+0x112/0x176 [ 74.686253] [] __rpc_execute+0x7e/0x21a [ 74.696694] [] rpc_async_schedule+0x24/0x46 [ 74.709450] [] process_one_work+0x13e/0x28a [ 74.722182] [] worker_thread+0x7c/0x320 [ 74.732607] [] kthread+0x124/0x136 [ 74.743073] [] ret_from_exception+0x0/0xc [ 74.764059] ---[ end trace ca32aa753f3ddad2 ]--- --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=nfs_20.c Content-Transfer-Encoding: base64 I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPHN0ZGxpYi5o PgojZGVmaW5lIF9HTlVfU09VUkNFCiNpbmNsdWRlIDx1bmlzdGQuaD4KI2luY2x1ZGUgPHN5cy9z b2NrZXQuaD4KI2luY2x1ZGUgPHN5cy9maWxlLmg+CiNpbmNsdWRlIDxzeXMvaW9jdGwuaD4KI2lu Y2x1ZGUgPG5ldGluZXQvaW4uaD4KI2luY2x1ZGUgPHN5cy93YWl0Lmg+CiNpbmNsdWRlIDxzeXMv cmVzb3VyY2UuaD4KI2luY2x1ZGUgPHN5cy9wYXJhbS5oPgojaW5jbHVkZSA8c3lzL21vdW50Lmg+ CiNpbmNsdWRlIDxzeXMvdHlwZXMuaD4KI2luY2x1ZGUgPHN5cy9zdGF0Lmg+CiNpbmNsdWRlIDxz eXMvdmZzLmg+CiNpbmNsdWRlIDxkaXJlbnQuaD4KI2luY2x1ZGUgPGFzc2VydC5oPgojaW5jbHVk ZSA8ZmNudGwuaD4KI2luY2x1ZGUgPGVycm5vLmg+CgppbnQgc3ltX29wID0gNjg7CmludCBzeW1f c2tpcCA9IDA7CmludCBzeW1fdHlwZSA9IDA7IC8vIGFsbCBmYXR0cjQgZmlsZSB0eXBlcwppbnQg c3ltX2ZoID0gMDsgLy8gYWxsIGZpbGUgaGFuZGxlcwppbnQgc3ltX2JpdG1hcHMgPSAwOwppbnQg c3ltX29wYXF1ZV9sZW4gPSAwOwoKaW50IG9wY291bnRzWzI1Nl07CmxvbmcgbG9uZyBuZXh0X2Nv b2tpZSA9IDM7CmludCBjdXJyZW50X2ZoID0gMDsKaW50IGNvbXBvdW5kX3N0YXR1czsKaW50IHNl bmRfYmFjazsKCi8vIG1hcCBmaWxlL2RpciBuYW1lcyB0byBmaWxlIGhhbmRsZQpjaGFyICpmaG5h bWVzWzEwMF0gPSB7CiAgICAgICAgICAgICAgICIiLAogICAgICAgICAgICAgICAidG1wIiwKICAg ICAgICAgICAgICAgIngiLAogICAgICAgICAgICAgICAieSIsCiAgICAgICAgICAgICAgICJ6IiwK ICAgICAgICAgICAgICAgInp6eiIsCiAgICAgICAgICAgICAgIDAKfTsKCmludApuYW1lMmZoKGNo YXIgKm5hbWUsIGludCBjcmVhdGUpCnsKICBmb3IoaW50IGkgPSAwOyBmaG5hbWVzW2ldOyBpKysp ewogICAgaWYoc3RyY21wKG5hbWUsIGZobmFtZXNbaV0pID09IDApCiAgICAgIHJldHVybiBpOwog IH0KICBpZihjcmVhdGUpewogICAgZm9yKGludCBpID0gMDsgOyBpKyspewogICAgICBpZihmaG5h bWVzW2ldID09IDApewogICAgICAgIGZobmFtZXNbaV0gPSBtYWxsb2MoMTAwKTsKICAgICAgICBz dHJjcHkoZmhuYW1lc1tpXSwgbmFtZSk7CiAgICAgICAgcmV0dXJuIGk7CiAgICAgIH0KICAgIH0K ICB9CiAgcmV0dXJuIC0xOwp9CgojZGV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sZWFzZSB0aW1lCiAgICAg IH0gZWxzZSBpZihhID09IDExKXsKICAgICAgICBwdXQzMigwKTsgLy8gcmRhdHRyX2Vycm9yCiAg ICAgIH0gZWxzZSBpZihhID09IDEyKXsKICAgICAgICAvLyBBQ0wKICAgICAgICBpbnQgbiA9IDI7 CiAgICAgICAgcHV0MzIobik7CiAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKyl7CiAg ICAgICAgICBwdXQzMigwKTsgLy8gdHlwZQogICAgICAgICAgcHV0MzIoMCk7IC8vIGZsYWcKICAg ICAgICAgIHB1dDMyKDApOyAvLyBtYXNrCiAgICAgICAgICBjaGFyIHdob1s5XTsKICAgICAgICAg IG1lbXNldCh3aG8sIDAsIHNpemVvZih3aG8pKTsKICAgICAgICAgIHN0cmNweSh3aG8sICJub2Jv ZHkiKTsKICAgICAgICAgIHB1dF9vcGFxdWUoc3RybGVuKHdobyksIHdobyk7CiAgICAgICAgfQog ICAgICB9IGVsc2UgaWYoYSA9PSAxMyl7CiAgICAgICAgcHV0MzIoMHhmKTsgLy8gYWNsc3VwcG9y dAogICAgICB9IGVsc2UgaWYoYSA9PSAxNSl7CiAgICAgICAgcHV0MzIoMSk7IC8vIGNhbnNldHRp bWUKICAgICAgfSBlbHNlIGlmKGEgPT0gMTYpewogICAgICAgIHB1dDMyKDApOyAvLyBjYXNlIGlu c2Vuc2l0aXZlCiAgICAgIH0gZWxzZSBpZihhID09IDE3KXsKICAgICAgICBwdXQzMigxKTsgLy8g Y2FzZSBwcmVzZXJ2aW5nCiAgICAgIH0gZWxzZSBpZihhID09IDE4KXsKICAgICAgICBwdXQzMigw KTsgLy8gY2hvd25fcmVzdHJpY3RlZAogICAgICB9IGVsc2UgaWYoYSA9PSAxOSl7CiAgICAgICAg Ly8gZmlsZWhhbmRsZQogICAgICAgIGludCB4ZmggPSBmaDsKICAgICAgICBpZihzeW1fZmgpIHhm aCBePSBhYVthYWkrK107CiAgICAgICAgcHV0X29wYXF1ZSg0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ICAgLy8gTEFZT1VUX0JMS1NJWkUKICAgICAgICBwdXQzMigxMDI0KTsKICAgICAgfSBlbHNlIGlm KGEgPT0gNzcpewogICAgICAgIC8vIENMT05FX0JMS1NJWkUKICAgICAgICBwdXQzMigxMDI0KTsK ICAgICAgfSBlbHNlIGlmKGEgPT0gNzkpewogICAgICAgIC8vIENIQU5HRV9BVFRSX1RZUEUKICAg ICAgICBwdXQzMig0KTsgLy8gPz8/CiAgICAgIH0gZWxzZSBpZihhID09IDgyKXsKICAgICAgICAv LyBDSEFOR0VfQVRUUl9UWVBFCiAgICAgICAgcHV0MzIoNCk7IC8vID8/PwogICAgICB9IGVsc2Ug aWYoYSA9PSA3NSl7CiAgICAgICAgLy8gRkFUVFI0X1NVUFBBVFRSX0VYQ0xDUkVBVAogICAgICAg IHB1dDMyKDIpOyAvLyBiaXRtYXAgbGVuZ3RoCiAgICAgICAgcHV0MzIoMHhmZmZmZmZmZik7CiAg ICAgICAgcHV0MzIoMHhmZmZmZmZmZik7CiAgICAgIH0gZWxzZSB7CiAgICAgICAgaWYoc3ltX2Jp dG1hcHMpewogICAgICAgICAgd29yZHNbYS8zMl0gJj0gfigxIDw8IChhICUgMzIpKTsKICAgICAg ICAgICooaW50Kikob2J1ZiArIHdvcmQwaSArIDQqKGEvMzIpKSA9IGh0b25sKHdvcmRzW2EvMzJd KTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgcHJpbnRmKCJ1bmtub3duIHJlcXVlc3RlZCBh dHRyICVkXG4iLCBhKTsKICAgICAgICAgIHB1dDY0KDApOyAvLyBYWFgKICAgICAgICB9CiAgICAg IH0KICAgIH0KICB9CiNpZiAwCiAgZm9yKGludCBpID0gMDsgaSA8IDE2OyBpKyspCiAgICBwdXQz MigweGZmZmZmZmZmKTsKI2VuZGlmCiAgKihpbnQqKShvYnVmK2xlbmkpID0gaHRvbmwob2kgLSBs ZW5pIC0gNCk7Cn0KCnZvaWQKcGFyc2Vfb3BfZ2V0YXR0cigpCnsK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9vcF9n ZXRmaCgpOwogICAgfSBlbHNlIGlmKG9wID09IDkpewogICAgICBwYXJzZV9vcF9nZXRhdHRyKCk7 CiAgICB9IGVsc2UgaWYob3AgPT0gMjIpewogICAgICBwYXJzZV9vcF9wdXRmaCgpOwogICAgfSBl bHNlIGlmKG9wID09IDMpewogICAgICBwYXJzZV9vcF9hY2Nlc3MoKTsKICAgIH0gZWxzZSBpZihv cCA9PSAxNSl7CiAgICAgIHBhcnNlX29wX2xvb2t1cCgpOwogICAgfSBlbHNlIGlmKG9wID09IDE2 KXsKICAgICAgcGFyc2Vfb3BfbG9va3VwcCgpOwogICAgfSBlbHNlIGlmKG9wID09IDI2KXsKICAg ICAgcGFyc2Vfb3BfcmVhZGRpcigpOwogICAgfSBlbHNlIGlmKG9wID09IDE4KXsKICAgICAgcGFy c2Vfb3Bfb3BlbigpOwogICAgfSBlbHNlIGlmKG9wID09IDQ1KXsKICAgICAgcGFyc2Vfb3BfZnJl ZV9zdGF0ZWlkKCk7CiAgICB9IGVsc2UgaWYob3AgPT0gMTIpewogICAgICBwYXJzZV9vcF9sb2Nr KCk7CiAgICB9IGVsc2UgaWYob3AgPT0gMTQpewogICAgICBwYXJzZV9vcF9sb2NrdSgpOwogICAg fSBlbHNlIGlmKG9wID09IDYpewogICAgICBwYXJzZV9vcF9jcmVhdGUoKTsKICAgIH0gZWxzZSBp ZihvcCA9PSAyOCl7CiAgICAgIHBhcnNlX29wX3JlbW92ZSgpOwogICAgfSBlbHNlIGlmKG9wID09 IDQpewogICAgICBwYXJzZV9vcF9jbG9zZSgpOwogICAgfSBlbHNlIGlmKG9wID09IDM0KXsKICAg ICAgcGFyc2Vfb3Bfc2V0YXR0cigpOwogICAgfSBlbHNlIGlmKG9wID09IDUwKXsKICAgICAgcGFy c2Vfb3BfbGF5b3V0Z2V0KCk7CiAgICB9IGVsc2UgaWYob3AgPT0gMzgpewogICAgICBwYXJzZV9v cF93cml0ZSgpOwogICAgfSBlbHNlIGlmKG9wID09ID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iAgc2V0bGluZWJ1Zihz dGRvdXQpOwogIHN0cnVjdCBybGltaXQgcjsKICByLnJsaW1fY3VyID0gci5ybGltX21heCA9IDA7 CiAgc2V0cmxpbWl0KFJMSU1JVF9DT1JFLCAmcik7CgogIGludCBzID0gc29ja2V0KEFGX0lORVQs IFNPQ0tfU1RSRUFNLCAwKTsKICBzdHJ1Y3Qgc29ja2FkZHJfaW4gc2luOwogIG1lbXNldCgmc2lu LCAwLCBzaXplb2Yoc2luKSk7CiAgc2luLnNpbl9mYW1pbHkgPSBBRl9JTkVUOwogIHNpbi5zaW5f cG9ydCA9IGh0b25zKDIwNDkpOwogIGludCB5ZXMgPSAxOwogIHNldHNvY2tvcHQocywgU09MX1NP Q0tFVCwgU09fUkVVU0VBRERSLCAmeWVzLCBzaXplb2YoeWVzKSk7CiAgaWYoYmluZChzLCAoc3Ry dWN0IHNvY2thZGRyICopJnNpbiwgc2l6ZW9mKHNpbikpIDwgMCl7CiAgICBwZXJyb3IoImJpbmQi KTsgZXhpdCgxKTsKICB9CiAgbGlzdGVuKHMsIDEwKTsKICBzeW5jKCk7CgogIGludCBwaWQxID0g Zm9yaygpOwogIGlmKHBpZDEgPT0gMCl7CiAgICBjbG9zZShzKTsKICAgIHNsZWVwKDEpOwogICAg aWYoc3lzdGVtKCJlY2hvIC1uIG1vdW50OiA7IG1vdW50IC1vIG5vbG9jayxub2RldiAxMjcuMC4w LjE6L3RtcCAvbW50IikgPT0gMCl7CiAgICAgIGlmKDApewogICAgICAgIHByaW50Zigic3RhdGZz OiAiKTsgZmZsdXNoKHN0ZG91dCk7CiAgICAgICAgc3RydWN0IHN0YXRmcyBzYjsKICAgICAgICBp bnQgcmV0ID0gc3RhdGZzKCIvbW50Ly4iLCAmc2IpOwogICAgICAgIHByaW50Zigic3RhdGZzIC0+ ICVkXG4iLCByZXQpOwogICAgICB9CiAgICAgIGlmKDApewogICAgICAgIGludCBmZCA9IG9wZW4o Ii9tbnQiLCAwKTsKICAgICAgICBpZihmZCA8IDApIHsgcGVycm9yKCIvbW50Iik7IGV4aXQoMSk7 IH0KICAgICAgICBvZmZfdCBiYXNlID0gMDsKICAgICAgICBjaGFyIGJ1Zls0MDk2XTsKICAgICAg ICBzc2l6ZV90IHJldCA9IGdldGRpcmVudHJpZXMoZmQsIGJ1Ziwgc2l6ZW9mKGJ1ZiksICZiYXNl KTsKICAgICAgICBwcmludGYoImdldGRpcmVudHJpZXMgcmV0ICVsZCBlcnJubyAlZFxuIiwgcmV0 LCBlcnJubyk7CiAgICAgICAgaWYocmV0IDwgMCkgcGVycm9yKCJnZXRkaXJlbnRyaWVzIik7CiAg ICAgICAgY2xvc2UoZmQpOwogICAgICB9CiAgICAgIGlmKDApewogICAgICAgIGludCBmZCA9IG9w ZW4oIi9tbnQveCIsIDApOwogICAgICAgIHByaW50Zigib3BlbiAvbW50L3ggLT4gJWQgZXJybm8g JWRcbiIsIGZkLCBlcnJubyk7CiAgICAgICAgaWYoZmQgPCAwKSBwZXJyb3IoIi9tbnQveCIpOwog ICAgICAgIGNsb3NlKGZkKTsKICAgICAgfQogICAgICBpZigxKXsKICAgICAgICBpbnQgZmQgPSBv cGVuKCIvbW50L25ldyIsIE9fUkRXUnxPX0NSRUFULCAwNjY2KTsKICAgICAgICBwcmludGYoImNy ZWF0IC9tbnQvbmV3IC0+ICVkIGVycm5vICVkXG4iLCBmZCwgZXJybm8pOwogICAgICAgIGlmKGZk IDwgMCkgcGVycm9yKCIvbW50L25ldyIpOwogICAgICAgIGlmKHdyaXRlKGZkLCAieCIsIDEpIDwg MCkgcGVycm9yKCJ3cml0ZSIpOwogICAgICAgIGxzZWVrKGZkLCAwTCwgMCk7CiAgICAgICAgY2hh ciBidWZbNTEyXTsKICAgICAgICB2b2xhdGlsZSBpbnQganVuayA9IHJlYWQoZmQsIGJ1Ziwgc2l6 ZW9mKGJ1ZikpOwogICAgICAgICh2b2lkKSBqdW5rOwogICAgICAgIC8vbWtkaXIoIi9tbnQvbmV3 L25ld25ldyIsIDA3NzcpOwogICAgICAgIC8vaWYodW5saW5rKCIvbW50L25ldyIpIDwgMCkgcGVy cm9yKCJ1bmxpbmsiKTsKICAgICAgICAvL2Nsb3NlKGZkKTsKICAgICAgICBpZihmbG9jayhmZCwg TE9DS19FWCkgPCAwKSBwZXJyb3IoImZsb2NrIik7CiAgICAgICAgc2xlZXAoMSk7CiAgICAgIH0K ICAgICAgaWYoMCl7CiAgICAgICAgaW50IHJldCA9IG1rZGlyKCIvbW50L2QiLCAwNzc3KTsKICAg ICAgICBwcmludGYoIm1rZGlyIC9tbnQvZCAtPiAlZCBlcnJubyAlZFxuIiwgcmV0LCBlcnJubyk7 CiAgICAgICAgaWYocmV0IDwgMCkgcGVycm9yKCJta2RpciAvbW50L2QiKTsKICAgICAgICBpZihj aGRpcigiL21udC9kIikgPT0gMCl7CiAgICAgICAgICBwcmludGYoImNoZGlyIHN1Y2NlZWRlZFxu Iik7CiAgICAgICAgICBpZihjcmVhdCgibmV3bmV3bmV3IiwgMDY2NikgPCAwKSBwZXJyb3IoImNy ZWF0ZSBuZXduZXduZXciKTsKICAgICAgICAgIHVubGluaygibmV3bmV3bmV3Iik7CiAgICAgICAg fSBlbHNlIHsKICAgICAgICAgIHBlcnJvcigiY2hkaXIgL21udC9kIik7CiAgICAgICAgfQogICAg ICAgIGNyZWF0KCIvbW50L2QvbmV3bmV3IiwgMDY2Nik7CiAgICAgICAgcm1kaXIoIi9tbnQvZCIp OwogICAgICB9CiAgICAgIGlmKDApewogICAgICAgIHN5cygic2V0ZmFjbCAtbSBvd25lckA6cnd4 cDo6YWxsb3cgL21udC94Iik7CiAgICAgICAgc3lzKCJnZXRmYWNsIC9tbnQveCIpOwogICAgICB9 CiAgICAgIGlmKDApewogICAgICAgIGludCBmZCA9IG9wZW4oIi9tbnQvbmV3IiwgT19SRFdSfE9f Q1JFQVQsIDA2NjYpOwogICAgICAgIGlmKGZkIDwgMCkgcGVycm9yKCJvcGVuIC9tbnQvbmV3Iik7 CiAgICAgICAgY2hhciBidWZbMzJdOwogICAgICAgIG1lbXNldChidWYsIDEsIHNpemVvZihidWYp KTsKICAgICAgICBpZih3cml0ZShmZCwgYnVmLCBzaXplb2YoYnVmKSkgPCAwKSBwZXJyb3IoIndy aXRlIik7CiAgICAgICAgbHNlZWsoZmQsIChvZmZfdCkwLCAwKTsKICAgICAgICBpbnQgZmQyID0g Y3JlYXQoIi9tbnQvbmV3bmV3IiwgMDY2Nik7CiAgICAgICAgaWYoZmQyIDwgMCkgcGVycm9yKCJj cmVhdCAvbW50L25ld25ldyIpOwogICAgICAgIG9mZl90IG8xID0gMDsKICAgICAgICBvZmZfdCBv MiA9IDA7CiAgICAgICAgaWYoY29weV9maWxlX3JhbmdlKGZkLCAmbzEsIGZkMiwgJm8yLCAxNiwg MCkgPCAwKSBwZXJyb3IoImNvcHlfZmlsZV9yYW5nZSIpOwogICAgICB9CiAgICAgIGlmKDApewog ICAgICAgIHN5cygiZWNobyAtbiBsczogOyBscyAtbCAvbW50Iik7CiAgICAgICAgc3lzKCJlY2hv IC1uIGxzOiA7IGxzIC1sIC9tbnQvLiAvbW50L3oiKTsKICAgICAgICBzeXMoImVjaG8gLW4gZWNo bzogOyBlY2hvIGhpID4gL21udC94Iik7CiAgICAgICAgc3lzKCJlY2hvIC1uIGRkOiA7IGRkIGlm PS9tbnQveSBvZj0vZGV2L251bGwgYnM9NTEyIGNvdW50PTEiKTsKICAgICAgICBzeXMoImVjaG8g LW4gdW1vdW50OiA7IHVtb3VudCAvbW50Iik7CiAgICAgIH0KICAgIH0KICAgIGV4aXQoMCk7CiAg fQoKICBpbnQgcGlkMiA9IGZvcmsoKTsKICBpZihwaWQyID09IDApewoKICAgIHdoaWxlKDEpewog ICAgICBzb2NrbGVuX3Qgc2lubGVuID0gc2l6ZW9mKHNpbik7CiAgICAgIHByaW50ZigiY2FsbGlu ZyBhY2NlcHRcbiIpOwogICAgICBpbnQgczEgPSBhY2NlcHQocywgKHN0cnVjdCBzb2NrYWRkciAq KSAmc2luLCAmc2lubGVuKTsKICAgICAgcHJpbnRmKCJhY2NlcHQgcmV0dXJuZWQgJWRcbiIsIHMx KTsKICAgICAgaWYoczEgPCAwKSB7IHBlcnJvcigiYWNjZXB0Iik7IGV4aXQoMSk7IH0KICAgICAg CiAgICAgIHdoaWxlKDEpewogICAgICAgIGlmKHJlYWRuKHMxLCAmaWxlbiwgNCkgPCAwKSBicmVh azsKICAgICAgICBpbGVuID0gbnRvaGwoaWxlbik7CiAgICAgICAgaWxlbiAmPSAweDdmZmZmZmZm OwogICAgICAgIGlmKHJlYWRuKHMxLCBpYnVmLCBpbGVuKSA8IDApIGJyZWFrOwogICAgICAgIG9p ID0gaWkgPSAwOwogICAgICAgIHB1dDMyKDApOyAvLyBwbGFjZS1ob2xkZXIgZm9yIGxlbmd0aAog ICAgICAgIHBhcnNlX3JwYygpOwojaWYgMQogICAgICAgIGlmKHN5bXN0YXJ0ICE9IC0xKXsKICAg ICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCAxNjsgaSsrKQogICAgICAgICAgICBwdXQzMigweGZm ZmZmZmZmKTsKICAgICAgICB9CiNlbmRpZgogICAgICAgICooaW50Kikob2J1ZiswKSA9IGh0b25s KChvaSAtIDQpIHwgMHg4MDAwMDAwMCk7CiAgICAgICAgaWYoYWFpID4gTkFBKXsKICAgICAgICAg IHByaW50Zigib29wcyBhYWkgJWQgTkFBICVkXG4iLCBhYWksIE5BQSk7CiAgICAgICAgICBleGl0 KDEpOwogICAgICAgIH0KICAgICAgICBpZihzeW1zdGFydCAhPSAtMSl7CiAgICAgICAgICBmb3Io aW50IGkgPSBzeW1zdGFydDsgaSA8IG9pICYmIGFhaSA8IE5BQTsgaSArPSA4KQogICAgICAgICAg ICAqKHVuc2lnbmVkIGxvbmcgbG9uZyAqKShvYnVmICsgaSkgXj0gYWFbYWFpKytdOwogICAgICAg ICAgc3ltc3RhcnQgPSAtMTsKICAgICAgICB9CiAgICAgICAgaWYob2kgPiAwKXsKICAgICAgICAg IGlmKHdyaXRlKHMxLCBvYnVmLCBvaSk8PTApIHBlcnJvcigid3JpdGUiKTsKICAgICAgICB9Cgog ICAgICAgIGlmKHNlbmRfYmFjayl7CiAgICAgICAgICBzZW5kX2JhY2sgPSAwOwogICAgICAgICAg b2kgPSAwOwogICAgICAgICAgcHV0MzIoMCk7IC8vIGR1bW15IGxlbmd0aAogICAgICAgICAgcHV0 X3JwY19oZWFkZXIoMHg0MDAwMDAwMCwgMSk7CgogICAgICAgICAgLy8gQ0JfQ09NUE9VTkQKICAg ICAgICAgIHB1dF9vcGFxdWUoMCwgIiIpOyAvLyBjb21wb3VuZCB0YWcKICAgICAgICAgIHB1dDMy KDIpOyAvLyBtaW5vciB2ZXJzaW9uCiAgICAgICAgICBwdXQzMigwKTsgLy8gY2FsbGJhY2tfaWRl bnQKICAgICAgICAgIHB1dDMyKDIpOyAvLyBvcGVyYXRpb25zIGluIHRoZSBjb21wb3VuZAoKICAg ICAgICAgIC8vIENCX1NFUVVFTkNFCiAgICAgICAgICBwdXQzMigxMSk7CiAgICAgICAgICBmb3Io aW50IGkgPSAwOyBpIDwgNDsgaSsrKQogICAgICAgICAgICBwdXQzMigxKTsgLy8gc2Vzc2lvbmlk CiAgICAgICAgICBwdXQzMigxKTsgLy8gc2VxdWVuY2VpZCA/Pz8KICAgICAgICAgIHB1dDMyKDAp OyAvLyBzbG90aWQKICAgICAgICAgIHB1dDMyKDApOyAvLyBoaWdoZXN0X3Nsb3RpZAogICAgICAg ICAgcHV0MzIoMCk7IC8vIGNhY2hldGhpcwogICAgICAgICAgcHV0MzIoMCk7IC8vIGNzYV9yZWZl cnJpbmdfY2FsbF9saXN0czw+CiAgICAgICAgICAKICAgICAgICAgIGludCB4b2kgPSBvaTsKICAg ICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCAzMjsgaSsrKQogICAgICAgICAgICBwdXQzMigweGZm ZmZmZmZmKTsKICAgICAgICAgIGZvcihpbnQgaSA9IHhvaTsgaSA8IG9pICYmIGFhaSA8IE5BQTsg aSArPSA4KQogICAgICAgICAgICAqKHVuc2lnbmVkIGxvbmcgbG9uZyAqKShvYnVmICsgaSkgXj0g YWFbYWFpKytdOwogICAgICAgICAgKihpbnQqKShvYnVmKzApID0gaHRvbmwoKG9pIC0gNCkgfCAw eDgwMDAwMDAwKTsKICAgICAgICAgIGlmKHdyaXRlKHMxLCBvYnVmLCBvaSk8PTApIHBlcnJvcigi d3JpdGUiKTsKICAgICAgICB9CiAgICAgIH0KICAgICAgY2xvc2UoczEpOwogICAgfQogICAgZXhp dCgxKTsKICB9CiAgY2xvc2Uocyk7CiAgc2xlZXAoMjApOwogIGlmKHN5c3RlbSgiZG1lc2cgfCBn cmVwICd1bmhhbmRsZWQgc2lnJyIpID09IDApewogICBwcmludGYoInVuaGFuZGxlZCBzaWduYWxc biIpOyB3aGlsZSgxKXt9CiAgfQp9Cg== --=-=-=--