Message ID | 20221021085325.25788-1-zbestahu@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp579383wrr; Fri, 21 Oct 2022 02:10:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4KbxunV1miGiyUZOTz1FSxoMis7gsSoa/HYwIUXhWojiDitRD7soNcqoF/RDU2VVBPudvH X-Received: by 2002:a17:902:b104:b0:184:eec6:cd4d with SMTP id q4-20020a170902b10400b00184eec6cd4dmr17858970plr.138.1666343434211; Fri, 21 Oct 2022 02:10:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666343434; cv=none; d=google.com; s=arc-20160816; b=VFzK6dj6R0ZL9vG3pQssjUzvhMYeqDhZdhJxp+MjWBahnCaxxniOYCVNsiyJrABb55 SBT5hnyFubO7qWjoOzofvLhAEzQY4JP4uco6yxTTL4CDNqpnUO/pn22kiEYSDNIeQ4LL MxCGChfUhWzDdzhoL9t96xbqENgIAbJ6/mkpQy2p+W6xkc9UKVn8gDUsGxLJokrbuKWo ulxFpgQPgtmj9Oeu3VoTzVum/mPDNsRcoSPk7ayf+a3o9l8c3vRMfJhahgiu8tyhKWbp fT/0OqBSWK93kWoWKMA4yMJDeSShbGZFqpqC79epZq6jiq813j4pUHR4IGM3uUak7Wwk CFDg== 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 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.17; Fri, 21 Oct 2022 02:10:34 -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 <rfc822;pwkd43@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; Fri, 21 Oct 2022 01:53:59 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id 204so1974626pfx.10 for <linux-kernel@vger.kernel.org>; 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 <zbestahu@gmail.com> 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 <huyue2@coolpad.com> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747287732736106583?= X-GMAIL-MSGID: =?utf-8?q?1747287732736106583?= |
Series |
[v2] erofs: fix general protection fault when reading fragment
|
|
Commit Message
Yue Hu
Oct. 21, 2022, 8:53 a.m. UTC
From: Yue Hu <huyue2@coolpad.com> 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 <huyue2@coolpad.com> --- v2: fix return value to -EFSCURRUPTED (Xiang) fs/erofs/zdata.c | 3 +++ 1 file changed, 3 insertions(+)
Comments
On Fri, Oct 21, 2022 at 04:53:25PM +0800, Yue Hu wrote: > From: Yue Hu <huyue2@coolpad.com> > > 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 <huyue2@coolpad.com> Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> Thanks, Gao Xiang > --- > 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
On 2022/10/21 16:53, Yue Hu wrote: > From: Yue Hu <huyue2@coolpad.com> > > 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 <huyue2@coolpad.com> Reviewed-by: Chao Yu <chao@kernel.org> Thanks,
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,