From patchwork Mon Nov 14 08:29:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 19596 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2032785wru; Mon, 14 Nov 2022 00:30:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf4AwuEbWhd0ilKrXe8IxQj10jYpHnwF9r9FdnKZjrqtZQ/i+DtBKxDQ8N2S0JRceAjYXcFf X-Received: by 2002:a50:9e8e:0:b0:467:4595:fc5c with SMTP id a14-20020a509e8e000000b004674595fc5cmr10168595edf.114.1668414644069; Mon, 14 Nov 2022 00:30:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668414644; cv=none; d=google.com; s=arc-20160816; b=Rbt5zhKQLy2v28Xj+WY/V9JKyMpAlvcZvSMCl515fnaaEBCAXbYF8NETiK84DXNmzw XqVRGI2YYu8t/2f9jSv1yTC7P3XLYWP/ohCl1nE1+qejtKhYl4wODA64Oal9ZeeygCGA AJr9kvei3jthZ4dMybByULwNpTCKSNV2wpryNV4gKk/+RNxFXWWbUo/ZiPSfaakQU8kZ tfh0E3C77OVKDyLZEoRwv0XnNmx2bh2rIsYSv2jNL/H+1bjxroKODdqMC9aveerTrXkx nTVqvHP3Rr+jfbh+43sIrhfR7xTNen7DFwFB8kASMG4sZJ2hEApjCd2PuTRTQKTUweAb L12A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=tUgTTBqKFuYwrBAzZpO1jGOAUEqlfA9E0Rem6opsB3E=; b=Uhuz06zNhL3+ugKjfrAfTv1VLtcIV9FWYDvses9anwd/tYtJZdb2qBX//hee1pky1Z ikqPETeleKPd9ebDmsZV3cjN9esi+PW09OFtV4e76W8Rlbu/8VixVg2JJnyuqX8wY0Hb WXNWPHq6C3W9tJXcdRnULc2gyKLhWkOjI2MdSBvGHsqOsxy8xNxIxP4niKH5U77nWqwb yItmpQUZtYoAB5t8sHkl1yalkmrXmsnbbD5A/I2B0OSrUoN2cju4psH8XwWTppSLyGc9 LHvTO6zFjJxWQk9VY+rz6bOiLxzaKIns+EeyX9RGKGtsVNMH8Op8clDsUMgyJxB3YBB2 Eyiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BSUGObCx; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kl14-20020a170907994e00b007829f6fed9dsi7012703ejc.232.2022.11.14.00.30.21; Mon, 14 Nov 2022 00:30:44 -0800 (PST) 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=@google.com header.s=20210112 header.b=BSUGObCx; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236470AbiKNI3q (ORCPT + 99 others); Mon, 14 Nov 2022 03:29:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236467AbiKNI3l (ORCPT ); Mon, 14 Nov 2022 03:29:41 -0500 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8CD11B9C2 for ; Mon, 14 Nov 2022 00:29:39 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id c188-20020a25c0c5000000b006d8eba07513so9977228ybf.17 for ; Mon, 14 Nov 2022 00:29:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=tUgTTBqKFuYwrBAzZpO1jGOAUEqlfA9E0Rem6opsB3E=; b=BSUGObCx4CoBl4EPyv/sqdhaIx0lyPbCKwJGuN9W7g/1v2YFv9G3VeL8ZFtRN30qVI it7y8tFgQ5xe97AjVd7P6AdEMjrFOxTFtTqXdJDejlWuivHSS1Van0dRG83qcQsEBMIQ wDOrS1xRqt6t4fC6IUgF/YAiSLRza4BXSkTVHVf3Q9mp+TMdnYUVmajKeWGNJDCrY630 G3xQ9DNy0yeZ2IW4yHhx/c+U0uyJ9ezELP1uY9T0vUL0hd0EdQdIgXplU7u9zzcEfiTj UcnCKgMCRUo/KNtTWV133jD+mGzd+CwzVV0ZHUgwY67ZHbo2fPsm+mimnMOZloDW5i+Z QLFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=tUgTTBqKFuYwrBAzZpO1jGOAUEqlfA9E0Rem6opsB3E=; b=tg1FqSh9w7hXvEj7kswSnrxA6IXQHED3NYXZ+N0cxIJzWQ6i7IK2C3JiWsYyRSCG9x kO8jhoJWowKwd5s0MriU9NBjxUennm1uMCiaZvcnVb2P3Ii+ugXLQAQ6+eUMFP155etX gatBPC2hDG7Trjpw853Yb3dMLukMRr5nVk6czN2CaaWyQKEgqMXtKwkUNXr2bV93prn9 XnSPToijqgUOzNCHsL0eIoBIdjUL/niOPOdFfSdKw+CLqoH9pbU+tlqU8iCmLaesRJ2m fJLP1mx5xyK/CsozqowKbGNJqTwzJ4wZCV0dtS2TMQ1KX4aUqpNKq8/jbP92j2RBQQCe axPw== X-Gm-Message-State: ANoB5plefryd52Bk2uhtUyLgwtM1A0aK7UV6zPOIXl2GoUGytZeM3qQO p9L2Z8AA3LKbrbomu3NYy4FcsstH6G8= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:947a:2eda:94df:cc80]) (user=glider job=sendgmr) by 2002:a0d:ca08:0:b0:378:f758:8a5c with SMTP id m8-20020a0dca08000000b00378f7588a5cmr12670700ywd.134.1668414579205; Mon, 14 Nov 2022 00:29:39 -0800 (PST) Date: Mon, 14 Nov 2022 09:29:35 +0100 Mime-Version: 1.0 X-Mailer: git-send-email 2.38.1.431.g37b22c650d-goog Message-ID: <20221114082935.3007497-1-glider@google.com> Subject: [PATCH] fs: ext4: initialize fsdata in pagecache_write() From: Alexander Potapenko To: glider@google.com Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, tytso@mit.edu, adilger.kernel@dilger.ca, jaegeuk@kernel.org, chao@kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Eric Biggers , syzbot+9767be679ef5016b6082@syzkaller.appspotmail.com X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749459553552802303?= X-GMAIL-MSGID: =?utf-8?q?1749459553552802303?= When aops->write_begin() does not initialize fsdata, KMSAN reports an error passing the latter to aops->write_end(). Fix this by unconditionally initializing fsdata. Also speculatively fix similar issues in affs, f2fs, hfs, hfsplus, as suggested by Eric Biggers. Cc: Eric Biggers Fixes: c93d8f885809 ("ext4: add basic fs-verity support") Reported-by: syzbot+9767be679ef5016b6082@syzkaller.appspotmail.com Signed-off-by: Alexander Potapenko --- fs/affs/file.c | 2 +- fs/ext4/verity.c | 2 +- fs/f2fs/verity.c | 2 +- fs/hfs/extent.c | 2 +- fs/hfsplus/extents.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/affs/file.c b/fs/affs/file.c index cefa222f7881c..8daeed31e1af9 100644 --- a/fs/affs/file.c +++ b/fs/affs/file.c @@ -880,7 +880,7 @@ affs_truncate(struct inode *inode) if (inode->i_size > AFFS_I(inode)->mmu_private) { struct address_space *mapping = inode->i_mapping; struct page *page; - void *fsdata; + void *fsdata = NULL; loff_t isize = inode->i_size; int res; diff --git a/fs/ext4/verity.c b/fs/ext4/verity.c index 3c640bd7ecaeb..30e3b65798b50 100644 --- a/fs/ext4/verity.c +++ b/fs/ext4/verity.c @@ -79,7 +79,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count, size_t n = min_t(size_t, count, PAGE_SIZE - offset_in_page(pos)); struct page *page; - void *fsdata; + void *fsdata = NULL; int res; res = aops->write_begin(NULL, mapping, pos, n, &page, &fsdata); diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c index c352fff88a5e6..3f4f3295f1c66 100644 --- a/fs/f2fs/verity.c +++ b/fs/f2fs/verity.c @@ -81,7 +81,7 @@ static int pagecache_write(struct inode *inode, const void *buf, size_t count, size_t n = min_t(size_t, count, PAGE_SIZE - offset_in_page(pos)); struct page *page; - void *fsdata; + void *fsdata = NULL; int res; res = aops->write_begin(NULL, mapping, pos, n, &page, &fsdata); diff --git a/fs/hfs/extent.c b/fs/hfs/extent.c index 3f7e9bef98743..6d1878b99b305 100644 --- a/fs/hfs/extent.c +++ b/fs/hfs/extent.c @@ -486,7 +486,7 @@ void hfs_file_truncate(struct inode *inode) inode->i_size); if (inode->i_size > HFS_I(inode)->phys_size) { struct address_space *mapping = inode->i_mapping; - void *fsdata; + void *fsdata = NULL; struct page *page; /* XXX: Can use generic_cont_expand? */ diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c index 721f779b4ec3e..7a542f3dbe502 100644 --- a/fs/hfsplus/extents.c +++ b/fs/hfsplus/extents.c @@ -554,7 +554,7 @@ void hfsplus_file_truncate(struct inode *inode) if (inode->i_size > hip->phys_size) { struct address_space *mapping = inode->i_mapping; struct page *page; - void *fsdata; + void *fsdata = NULL; loff_t size = inode->i_size; res = hfsplus_write_begin(NULL, mapping, size, 0,