Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5954649rwb; Sun, 11 Dec 2022 16:08:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Jb2J8DSDXZ4ryx3haQzOVatx1ogJ2bDIc/NVCW4oOW0Awo3WDz6CEXbILySppwZdEBy5F X-Received: by 2002:a17:907:2b15:b0:7c1:5b5e:4d86 with SMTP id gc21-20020a1709072b1500b007c15b5e4d86mr3989719ejc.36.1670803734153; Sun, 11 Dec 2022 16:08:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670803734; cv=none; d=google.com; s=arc-20160816; b=xeioecRzgRdRSLAq7QgpUMLq/9+fuDGzzukdAHJyJDgW6TjsJJXTjZ/yFM7sJFPN8p OlKDXv6DQr0f4UZIfqYHeBfi/X8erKhhgRCvAmgI8hGVuYjq535O/dCDlYmxZIBZ7u4b ZR3Bh0nV+ojPl7s9Q3oDah39VFpy5CxQ8UFzGUfVr/2TdLi0vynIuxoNGVu6FgZhVDrO FU3xy0UzcmBdJYBeQriLs0OXLF/gfy2m/roPCePr8ATRWAhXTIcCHk08UN+zLp5oIt/S K1W6crN+1W1JyAXsqyCj8ufdE7pucrfGrY7SOAY3WBXfJiWNEedvvd1Y/ZDlzaXKtvWc mIxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=8nBoLihTgg1o/rDSJVfWlE6H3OQKZQg483QB0jOBInM=; b=IKscZSdOBT8m80dFaPvS14w0vvecvUcw8rjA5w0gpwwPWRHWJ9vVS1tj/rviCajprw wXAM8PUwmGK046NiwfBSkZHxEJaR+jObgUk3A7Lo0P1pHyWdsbGNx0b4RT5MoMXvucZa al6mw+7Ta5zruWB7f7g6WHbGem8oPBQo1l5ZMYi6MCn+p7TssqpMlCXXlcLNvyf2vqVe Xf66zGMd+fhMSj4P6moop9/W+yGg4Y+Q0zSIXjLyVFbSnfC14re8nd0XWC5AeotjqOap R/9JlDZJxvwwFV1872Q4rNL7ViBdl3HQBNiK/rB0kS91dp+b46yJsGCKaqmy/o3rSP0h cgMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=kjwwvm5M; 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=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w12-20020a05640234cc00b004619867344csi7026215edc.0.2022.12.11.16.08.36; Sun, 11 Dec 2022 16:08:54 -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=@linux.org.uk header.s=zeniv-20220401 header.b=kjwwvm5M; 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=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230421AbiLKWjv (ORCPT + 75 others); Sun, 11 Dec 2022 17:39:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbiLKWjt (ORCPT ); Sun, 11 Dec 2022 17:39:49 -0500 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54DA9BC8C; Sun, 11 Dec 2022 14:39:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=8nBoLihTgg1o/rDSJVfWlE6H3OQKZQg483QB0jOBInM=; b=kjwwvm5M60+cg0oPps1CyCFMZg yZlvn9jd9UvZ1BDnQBT2eWKlmGe4+WBof3Gm8TFX1yFX55h4wee8uvV4W2/5DPyM4h49PIDBDfO8y QoT23IkV3uF7MDmKI6yCmi3DX7EyGb2tajw7X9+UjTi93b45riAUqnmUQ/E2tZhaE5/84cgzenHIv 8FTmXSuXPkNqWKVDeDJ37yPbkEo5hNJpjk1HTKJ8Yfo3OnLe8+qh38QjjF8/OqsWrefQbVBq3To0t 1uwqfzXO/PuKd1LzhOxsSPpP0hQBSilro3U/uIDxeGjkNnjCTkgQ++0IJl6H9hmftJnkae+2PgbNw tJxk+xzg==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1p4Uz2-00B6vV-37; Sun, 11 Dec 2022 22:39:45 +0000 Date: Sun, 11 Dec 2022 22:39:44 +0000 From: Al Viro To: "Fabio M. De Francesco" Cc: Evgeniy Dushistov , Ira Weiny , linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 3/3] fs/ufs: Replace kmap() with kmap_local_page() Message-ID: References: <20221211213111.30085-1-fmdefrancesco@gmail.com> <20221211213111.30085-4-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221211213111.30085-4-fmdefrancesco@gmail.com> Sender: Al Viro X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE 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 On Sun, Dec 11, 2022 at 10:31:11PM +0100, Fabio M. De Francesco wrote: > +/* > + * Calls to ufs_get_page()/ufs_put_page() must be nested according to the > + * rules documented in kmap_local_page()/kunmap_local(). > + * > + * NOTE: ufs_find_entry() and ufs_dotdot() act as calls to ufs_get_page() > + * and must be treated accordingly for nesting purposes. > + */ > static void *ufs_get_page(struct inode *dir, unsigned long n, struct page **page) > { > + char *kaddr; > + > struct address_space *mapping = dir->i_mapping; > *page = read_mapping_page(mapping, n, NULL); > if (!IS_ERR(*page)) { > - kmap(*page); > + kmap_local_page(*page); > if (unlikely(!PageChecked(*page))) { > - if (!ufs_check_page(*page)) > + if (!ufs_check_page(*page, kaddr)) Er... Building the patched tree is occasionally useful. Here kaddr is obviously uninitialized and compiler would've probably caught that. And return value of kmap_local_page() is lost, which is related to the previous issue ;-) > goto fail; > } > } > - return page; > + return *page; Hell, no. Callers expect the pointer to the first byte of your page. What it should return is kaddr. > @@ -388,7 +406,8 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) > mark_inode_dirty(dir); > /* OFFSET_CACHE */ > out_put: > - ufs_put_page(page); > + ufs_put_page(page, kaddr); > + return 0; > out_unlock: > unlock_page(page); > goto out_put; That can't be right. Places like if (err) goto out_unlock; do not expect err to be lost. You end up returning 0 now. Something strange happened here (in the previous commit, perhaps?)