Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2303558rwi; Fri, 21 Oct 2022 02:11:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5kEM5UEydTa6c0ir/suztWCao3qns31p+jo4DE8wmMZBYm7oEydp0Apxq6b4d6z9Ba0GIC X-Received: by 2002:a17:902:7c97:b0:17f:5abf:9450 with SMTP id y23-20020a1709027c9700b0017f5abf9450mr17721099pll.19.1666343462073; Fri, 21 Oct 2022 02:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666343462; cv=none; d=google.com; s=arc-20160816; b=mHr6qWYQff2OMiIRuuv1C1GHh1lbIL67chrQ1ehDjBLLwyS5IDK/MrxgWsVvhCAXH+ 5NN8AxLpXuxheVAYyPuvloQoAsn53McDUXE4JJpoEMcl+aWX9zdlX/wfC8TBOIUUVWTh xbl5AjinTtlCCFoOmUQRL5KstaLuu/QzCrEAv9/VIK1lqyvmYVW6tVpYiCTqBxMHLXwe bX1ZbKCak7q2XJGbPw2CIeTOJ7/pDh0gi/Xxeeq3OKaL54dfsHmwKxN1/IEng3ZEvNW7 lqXQzRGo7dGuJGVb4fBma1Qq1gqt2tsiJNpNramCxv6d9d+Ku/F2saonfW0PMO5yFkyh 84dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=SiebFKtnsrtXianXD3JL4DWupXndbhs034Yj5s+RxrE=; b=yZZ0ddGSBE8VXqtMVpG7VqxgLx3a2YVVxTAiWrRjJWu4qZuOEu2ecgipuvXvV8AO+w Xhb3OQYVs9gQoWbhF2wHRGMcr4aGBCXN/fvD80NPIdO+IVt/6xQhPO+XsA0WlsWbWKxa rA6doPgjiU4XYU7ASBBEYgFuXiTt0YCmma0w/Vtn3KcW55dAhfBcCViF0DgbRLL5sGON 7fWu/CyMwmU2eWWoW6m0HD1RaUMLaoHHI6hsCSZF8VKFKzNUnO+vgOofLclD7QhsKErc My/mRG8A9FFtNRnbOeeuKj4ukSalBv4ojWQBRb54LO9UCzvaxvZrn9RDbaUs4XdQYZAM ibTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="mE/t/bt4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b13-20020a6541cd000000b0046b0e17b795si22555936pgq.567.2022.10.21.02.10.50; Fri, 21 Oct 2022 02:11:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="mE/t/bt4"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230384AbiJUIyO (ORCPT + 99 others); Fri, 21 Oct 2022 04:54:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230388AbiJUIyB (ORCPT ); Fri, 21 Oct 2022 04:54:01 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2A332505C4 for ; Fri, 21 Oct 2022 01:53:59 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id 204so1974626pfx.10 for ; Fri, 21 Oct 2022 01:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SiebFKtnsrtXianXD3JL4DWupXndbhs034Yj5s+RxrE=; b=mE/t/bt4w+oJh8KFnimQ8O2wcibAG6Lq3MlVWFEZkbXium8WqHvJK8sRDFWRd2L56i Vww8d7O6Y+mXOTNtkt5RsIINWwXUrmRcqWwtFr+9RtjrLh7MVAqU6AsUt42/xnn8P8P2 Z2eem93rUGdCRpOZ924FyFlwYXcNzfPJOiaOWxIsB3Q1PMcUvL/WVcVAjHceHCQR+e49 b8/dOE3JfEktAlN6cTb8MVewHWDPk7XAIbRhsxoFnMJcb+4EESvvy/tjxQ94eJGxVfNs yT6C0fKFi57J9cjZl5Kv2BAwMxF3KEJqdIqD15JSWZmIy+iDgR3d/FT2k0AqofMHi//0 +T2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SiebFKtnsrtXianXD3JL4DWupXndbhs034Yj5s+RxrE=; b=L1M9Lpob4fUd0q/LJCIVDWN/PtXlRcHuNwUSVAyXrL0+/2ncg+u1Ww725JZaKNgFfp w35wraLodxNWQgT2AIQgWZ/Z9a0KK4RbHSF2euGTbRTtj8W0MHb4ffVHsQlUqQYnwMKd YMzXUPi3pHfWm6ElUEn/GcBgc4WceXf7qXLf8oh1PS7r2u/ejF+EJUi5l+dvCYrNsjj5 gyXFSHGNLwfh2U5BOpbHj/du/Y9ZB4zFDJoBjEn+iVxdZKCfEEYEluKfhosReasEpdu5 KW8ob2Q1Vs57fPC2X+fEqUpENaczoH/BpfVOAmrAXC1k0gySg+lE6avVh+1+T90FbIPW X2Jw== X-Gm-Message-State: ACrzQf0VGx3FjK9oqSa2ymQ2t9k0CdUAI3WFM8G2xmNbeQrAmzgsqR/w wstRbKewlWlfdAALg+5ly1o= X-Received: by 2002:a63:1c47:0:b0:44c:2476:12ff with SMTP id c7-20020a631c47000000b0044c247612ffmr15899522pgm.50.1666342439140; Fri, 21 Oct 2022 01:53:59 -0700 (PDT) Received: from localhost.localdomain ([156.236.96.165]) by smtp.gmail.com with ESMTPSA id o16-20020a634e50000000b0046ae5cfc3d5sm12658609pgl.61.2022.10.21.01.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Oct 2022 01:53:58 -0700 (PDT) From: Yue Hu To: xiang@kernel.org, chao@kernel.org Cc: linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, syzbot+3faecbfd845a895c04cb@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com, zhangwen@coolpad.com, Yue Hu Subject: [PATCH v2] erofs: fix general protection fault when reading fragment Date: Fri, 21 Oct 2022 16:53:25 +0800 Message-Id: <20221021085325.25788-1-zbestahu@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yue Hu As syzbot reported [1], the fragment feature sb flag is not set, so packed_inode != NULL needs to be checked in z_erofs_read_fragment(). [1] https://lore.kernel.org/all/0000000000002e7a8905eb841ddd@google.com/ Reported-by: syzbot+3faecbfd845a895c04cb@syzkaller.appspotmail.com Fixes: 08a0c9ef3e7e ("erofs: support on-disk compressed fragments data") Signed-off-by: Yue Hu --- v2: fix return value to -EFSCURRUPTED (Xiang) fs/erofs/zdata.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c index cce56dde135c..55c13cd6934b 100644 --- a/fs/erofs/zdata.c +++ b/fs/erofs/zdata.c @@ -659,6 +659,9 @@ static int z_erofs_read_fragment(struct inode *inode, erofs_off_t pos, u8 *src, *dst; unsigned int i, cnt; + if (!packed_inode) + return -EFSCORRUPTED; + pos += EROFS_I(inode)->z_fragmentoff; for (i = 0; i < len; i += cnt) { cnt = min_t(unsigned int, len - i, -- 2.17.1