From patchwork Sun May 21 08:28:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 96832 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp772289vqo; Sun, 21 May 2023 01:49:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6z9lPyqyMaOBTMjluJWpOK6QEEU7Ujfl591B+zu6014avN+1TwaVx9gP7AkJcz8zeOcEA5 X-Received: by 2002:a05:6a20:8f28:b0:102:f744:a70c with SMTP id b40-20020a056a208f2800b00102f744a70cmr8557272pzk.3.1684658994242; Sun, 21 May 2023 01:49:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684658994; cv=none; d=google.com; s=arc-20160816; b=lU8NN1O4YPBfjX0Pyj/npnHF5IrgLlTBsoOekHqgOI67NGpxabvCtl7/y+8XgCNJyr R7BSnGdblAPjGUphz+94NIA0LkhK/AO7x8eLeCdAGxm5lIPqPBPgdZKNEZQ10/llh2Ko 9DBo3IV/0LhyKavkzvYNQ75O6np2A1PSbgxTQ1++Z7HiwPMj5qV46npNvkBYl6/O2GSB pWFy65YSVOnGIi5pD78/WDxK21ZuFIfy9r5oQ/O9Ep+uT5GRvtZKr2sgMEtAiuAQomDI NoIpMQl3q1pgNDMGk5ZJlU3rQEiqgsPZ1iN86uvjf+3k49gk/cL/mz2JAeIwjRMb3grM y7+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Tv9SP0tP+8DRjLTNt8sd7O2hc074o3ygEuc+rvxGi5M=; b=aR0rNuJGyyu9oKApXuxVMPMqa12gYuEnzurIsYs1I5AyALl7SvwBjz/UV+kNqEDLsJ Acww2UCjoQgR8AhHhHBFv6dWS3SHCjeLdZWbVcT0u3O0OgGvVE9sI0Awlbh4IThmTsoV r/FQdnrksKCknYzhL6Vdq3lJcM0vT9IgXLkatHTSfa2Ia/vDyEcT9KSHzz6dHGeaAPH2 wmPxdMGloPwrvhdh4WWf0bECJHbyJcZibZNzl3WxheJFi37eumFLHQ3f02hG5+6jELfU 5i4S2fIBkdrKtHeLEnK/M1e4DCfhGXrCmPs7mt1u6bgUKmprQjkQ7mgX+W7D5tbUsUGV 7Y5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b="B2np6/42"; 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=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11-20020a63ae0b000000b00534792ee482si2802760pgf.758.2023.05.21.01.49.42; Sun, 21 May 2023 01:49:54 -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=@canonical.com header.s=20210705 header.b="B2np6/42"; 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=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229947AbjEUIgA (ORCPT + 99 others); Sun, 21 May 2023 04:36:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230046AbjEUI2T (ORCPT ); Sun, 21 May 2023 04:28:19 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8B11198 for ; Sun, 21 May 2023 01:28:18 -0700 (PDT) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 78E5C3F4B8 for ; Sun, 21 May 2023 08:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684657697; bh=Tv9SP0tP+8DRjLTNt8sd7O2hc074o3ygEuc+rvxGi5M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=B2np6/42mdslIvsIz/AUbtKnejLsEHxvj1UOw6KmBS/Ta48DhDz2j4JvvklOznnLT mPkeOIyWbL4B/QRQfBBsYPkGzkaaG+XgbruvhbESXtjYopzkV56ZxCPPxsAM5f+wiV hxWbuit6wu+iTb0v/Pzmeux2by3trT85gWPFAWVf2OMZrIRmdBWJHrnJeP79aczMBF WI+BtN1iKDvpC7UNpQUik5CH4hMCxKk4Tr7Njr4Ow+WVkCqiKld0aR1tQx2+lalUmv +zNbTSZTYJd3+kMXtG+kEQl9nyGXcRoLZYIzBQ7MNQMgl96ftZjJcvRLqq9S2CQS2z svf3lys3oLPFA== Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-51392d645d5so539515a12.1 for ; Sun, 21 May 2023 01:28:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684657697; x=1687249697; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tv9SP0tP+8DRjLTNt8sd7O2hc074o3ygEuc+rvxGi5M=; b=Bz/OrGpO0o4MVfUKs6oJHS+0bSzAqZtBpqeRjnKPmS4DQmE2YnK5wM2ZeHibI4izoG 1aCdD833hs9NZNYcYXTdgs591dMEupbo0r8TM5prtXJ1HtXIFbeKy3KcASmHa1Nyb3E3 xBM0oCVlL897MbQScIDz15Xfqd+p00VHPMMfDIxnHljj08a9ctXyinjpvXkNyH33GgNU VYfs2pEtfyJ1r9vf2Vq575ukCqdxqiTckJxYBZJx7aUtEg7tHToHR6PerM+9EIV9qT+7 /IUkoS0TiFzrEaslBjX4ggjss4soWCrldpJAFJ/iE/Ey7eV/kBlgeprXZ9tStq432Woo A5ew== X-Gm-Message-State: AC+VfDzbV7tH0m6I9O60H0xAHtp8u5DYQ1mbyOJkVNFfsw/zFMYCnp4X U5X2LR+wUx3o0GzjNHFkkeEUrwJmw+mry7GM6OCYnkH/t/iDWHznquuN6/ee5d2hC9TGfWOvw18 xUv7hpa5OsuRydQ7HSY3sY9eSBAfHbJuzuyieQApgyg== X-Received: by 2002:a17:907:ea8:b0:96f:d63a:9508 with SMTP id ho40-20020a1709070ea800b0096fd63a9508mr408830ejc.33.1684657697001; Sun, 21 May 2023 01:28:17 -0700 (PDT) X-Received: by 2002:a17:907:ea8:b0:96f:d63a:9508 with SMTP id ho40-20020a1709070ea800b0096fd63a9508mr408823ejc.33.1684657696828; Sun, 21 May 2023 01:28:16 -0700 (PDT) Received: from righiandr-XPS-13-7390.homenet.telecomitalia.it (host-87-10-127-160.retail.telecomitalia.it. [87.10.127.160]) by smtp.gmail.com with ESMTPSA id z17-20020aa7cf91000000b004c2158e87e6sm1656646edx.97.2023.05.21.01.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 May 2023 01:28:16 -0700 (PDT) From: Andrea Righi To: Miklos Szeredi Cc: Amir Goldstein , linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/3] ovl: Kconfig: introduce CONFIG_OVERLAY_FS_DEBUG Date: Sun, 21 May 2023 10:28:11 +0200 Message-Id: <20230521082813.17025-2-andrea.righi@canonical.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230521082813.17025-1-andrea.righi@canonical.com> References: <20230521082813.17025-1-andrea.righi@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1766492989509899834?= X-GMAIL-MSGID: =?utf-8?q?1766492989509899834?= Provide a Kconfig option to enable extra debugging checks for overlayfs. Reviewed-by: Amir Goldstein Signed-off-by: Andrea Righi --- fs/overlayfs/Kconfig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/overlayfs/Kconfig b/fs/overlayfs/Kconfig index 6708e54b0e30..fec5020c3495 100644 --- a/fs/overlayfs/Kconfig +++ b/fs/overlayfs/Kconfig @@ -124,3 +124,12 @@ config OVERLAY_FS_METACOPY that doesn't support this feature will have unexpected results. If unsure, say N. + +config OVERLAY_FS_DEBUG + bool "Overlayfs: turn on extra debugging checks" + default n + depends on OVERLAY_FS + help + Say Y here to enable extra debugging checks in overlayfs. + + If unsure, say N. From patchwork Sun May 21 08:28:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 96831 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp772262vqo; Sun, 21 May 2023 01:49:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7qGf7/TJS+SpT51sGjLRNpcquwDkOUzz8wmXcbF6YesuBASUZQQFE5hoKL6dgxagMYY4FR X-Received: by 2002:a05:6a00:2d90:b0:643:5d7a:a898 with SMTP id fb16-20020a056a002d9000b006435d7aa898mr10622282pfb.0.1684658990230; Sun, 21 May 2023 01:49:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684658990; cv=none; d=google.com; s=arc-20160816; b=Z/55MAmYBaRrLwY9zVm3SdlIIgnlqo6TU4Q3BFDg8d9IJwtrhIzy94WoX20iCwWK6n O/Yf2rCh1CRFoYnVTwkiNOzHO7ffRrtt8z/01r+4RASz/1vrMkPb07TAzGUgx1C0HovE AA0LqWhUWqp/uIkuZw+YYuJjA1g1VRlHMh8fLsfCZbfyl31lihsczvScLLNfu/xnXKOt 8Xltx93PSC6jIYr9j3vU47mK4ztyRyRsi7bF8X9VNf73mTLePyYf5XhqtD2CxN439Eg8 9BN+HH73IN2GcCPv0EtwLuqFaat47SeC9OLbtZGvY5pMYAt9aewTX0nDCg9KS6V9X5tp VC2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=S+LqOkskBby/UL6h7yv8LPihhxKribfOUChuAoSoAt4=; b=afk4yf+NXfCbsAs+KKxe6ozXyei+/2zu3IRlhvpmkiTFGaeKDF9aovGNS8a9yli49A IKTOMAvsa52HAC7AKIPCjhrU9ikIYsgmH66Xb/SWb+BLAovT6r7Rg3x6lnOeFakh68VT TssrrGSN1Y6JFUDt7jmly/3WgE8lJvORE1QIl5pgrqNcg/TME9TBOLEf0g6/TAJpa1Jr E+fVVsngJUybTFK4Pxkfojex+xDiwOQI8A7kPaIHYdMCHDAhQfHSF6+psMqykjsd5TBe 95CNWPCc/peFspedYJxJF8TApkZrOCdtsNX8yf+/G/PX6IAxn9fJEvzKPnzOkxnjwai8 V4Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=T5Q8t77a; 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=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020aa79d04000000b0064398136d6esi3014892pfp.132.2023.05.21.01.49.34; Sun, 21 May 2023 01:49:50 -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=@canonical.com header.s=20210705 header.b=T5Q8t77a; 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=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229940AbjEUIbe (ORCPT + 99 others); Sun, 21 May 2023 04:31:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230094AbjEUI2Z (ORCPT ); Sun, 21 May 2023 04:28:25 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85D8518C for ; Sun, 21 May 2023 01:28:23 -0700 (PDT) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 065263F550 for ; Sun, 21 May 2023 08:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684657699; bh=S+LqOkskBby/UL6h7yv8LPihhxKribfOUChuAoSoAt4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T5Q8t77a/6T9ukRewCiwcuVHks0h4w34yCLyZYn2GTbjfFbBa+7GAjuHlfvQ7LNkR ioDT/8xvNZjQroJPL0Qw+Smnclp1lBMGzTE+xi3EGyGE1+E4DsA7uXvPE++1Qi+3KR kFsNbcQF+TzIFCoOWuIe9BlWgep2UMxVe0HMngl8ncewIR3tua3I/hI4lee9/WZrS2 t7oNq1S5SyyFNpBY/3xx0t7/rlQSpmBrOn+modFjI7IC3RR4D6nXcvwqO+MaZJfZiD W+cA0kaNW5aP31EErn70H3aYIzghm4fqX5dwnEb9qEmqugoM1Zzp94fLSssXV3dH/G 4rL6vYz4Z7HZQ== Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-510d8e4416cso5168596a12.3 for ; Sun, 21 May 2023 01:28:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684657697; x=1687249697; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S+LqOkskBby/UL6h7yv8LPihhxKribfOUChuAoSoAt4=; b=FpagfcgdOdTiPat1Cx/Pg/kGTakrXJUJ8rcqqr/qiTBZd2UyDnC/h3ntmb9J1m8vKi GlUsRqt+VUR3sBFFmRkRVKegn7lDUnofYc5HucPQz4xhLdI6euAB8lwf/8k068S73nci dDTx/T/a10mTxOwnMIkZniFdt7+n/nvduMCQricFJZOxQ1Ty3DX8fOulcBYuv/Lgnxoi oBXR2YbjHXx1a8cSyDQrG/7+fMXnS/6d0s6yRH8WwKu8lWmtcxPKW6anNVn0sJKFHn9Y mwyNfd1nX55AzDKCH9CVTTDBLH9UEOTGgTZGjKTgP/8WrjHFfOXjV898DMtkqTSRrh0S SlbA== X-Gm-Message-State: AC+VfDyapp1AG3Zo1IRrO/roYRbB98IVj29Ue6WklH2YQoNS1C5DusSc MN8aydPowa5PKrMl1vjZWxAhD1Dhzho/h7QMiasMvB5+0fuGCeHUNtzhXGfgcXL+ddr96y8Y8yp IF67Ki8jE0aWmdwZ2m8JCrtMihYJ7Q+Vg8S33apYx2A== X-Received: by 2002:aa7:c387:0:b0:504:a359:3fa8 with SMTP id k7-20020aa7c387000000b00504a3593fa8mr6481256edq.20.1684657697758; Sun, 21 May 2023 01:28:17 -0700 (PDT) X-Received: by 2002:aa7:c387:0:b0:504:a359:3fa8 with SMTP id k7-20020aa7c387000000b00504a3593fa8mr6481247edq.20.1684657697402; Sun, 21 May 2023 01:28:17 -0700 (PDT) Received: from righiandr-XPS-13-7390.homenet.telecomitalia.it (host-87-10-127-160.retail.telecomitalia.it. [87.10.127.160]) by smtp.gmail.com with ESMTPSA id z17-20020aa7cf91000000b004c2158e87e6sm1656646edx.97.2023.05.21.01.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 May 2023 01:28:17 -0700 (PDT) From: Andrea Righi To: Miklos Szeredi Cc: Amir Goldstein , linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/3] ovl: make consistent use of OVL_FS() Date: Sun, 21 May 2023 10:28:12 +0200 Message-Id: <20230521082813.17025-3-andrea.righi@canonical.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230521082813.17025-1-andrea.righi@canonical.com> References: <20230521082813.17025-1-andrea.righi@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1766492985246513385?= X-GMAIL-MSGID: =?utf-8?q?1766492985246513385?= Always use OVL_FS() to retrieve the corresponding struct ovl_fs from a struct super_block. Reviewed-by: Amir Goldstein Signed-off-by: Andrea Righi --- fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/export.c | 10 +++++----- fs/overlayfs/inode.c | 8 ++++---- fs/overlayfs/namei.c | 2 +- fs/overlayfs/ovl_entry.h | 2 ++ fs/overlayfs/super.c | 12 ++++++------ fs/overlayfs/util.c | 18 +++++++++--------- 7 files changed, 28 insertions(+), 26 deletions(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index f658cc8ea492..60aa615820e7 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -905,7 +905,7 @@ static int ovl_do_copy_up(struct ovl_copy_up_ctx *c) static bool ovl_need_meta_copy_up(struct dentry *dentry, umode_t mode, int flags) { - struct ovl_fs *ofs = dentry->d_sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(dentry->d_sb); if (!ofs->config.metacopy) return false; diff --git a/fs/overlayfs/export.c b/fs/overlayfs/export.c index defd4e231ad2..f5f0ef8e3ce8 100644 --- a/fs/overlayfs/export.c +++ b/fs/overlayfs/export.c @@ -182,7 +182,7 @@ static int ovl_connect_layer(struct dentry *dentry) */ static int ovl_check_encode_origin(struct dentry *dentry) { - struct ovl_fs *ofs = dentry->d_sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(dentry->d_sb); /* Upper file handle for pure upper */ if (!ovl_dentry_lower(dentry)) @@ -434,7 +434,7 @@ static struct dentry *ovl_lookup_real_inode(struct super_block *sb, struct dentry *real, const struct ovl_layer *layer) { - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); struct dentry *index = NULL; struct dentry *this = NULL; struct inode *inode; @@ -655,7 +655,7 @@ static struct dentry *ovl_get_dentry(struct super_block *sb, struct ovl_path *lowerpath, struct dentry *index) { - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); const struct ovl_layer *layer = upper ? &ofs->layers[0] : lowerpath->layer; struct dentry *real = upper ?: (index ?: lowerpath->dentry); @@ -680,7 +680,7 @@ static struct dentry *ovl_get_dentry(struct super_block *sb, static struct dentry *ovl_upper_fh_to_d(struct super_block *sb, struct ovl_fh *fh) { - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); struct dentry *dentry; struct dentry *upper; @@ -700,7 +700,7 @@ static struct dentry *ovl_upper_fh_to_d(struct super_block *sb, static struct dentry *ovl_lower_fh_to_d(struct super_block *sb, struct ovl_fh *fh) { - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); struct ovl_path origin = { }; struct ovl_path *stack = &origin; struct dentry *dentry = NULL; diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 541cf3717fc2..c27823f6e7aa 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -334,7 +334,7 @@ static const char *ovl_get_link(struct dentry *dentry, bool ovl_is_private_xattr(struct super_block *sb, const char *name) { - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); if (ofs->config.userxattr) return strncmp(name, OVL_XATTR_USER_PREFIX, @@ -689,7 +689,7 @@ int ovl_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags) { if (flags & S_ATIME) { - struct ovl_fs *ofs = inode->i_sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(inode->i_sb); struct path upperpath = { .mnt = ovl_upper_mnt(ofs), .dentry = ovl_upperdentry_dereference(OVL_I(inode)), @@ -952,7 +952,7 @@ static inline void ovl_lockdep_annotate_inode_mutex_key(struct inode *inode) static void ovl_next_ino(struct inode *inode) { - struct ovl_fs *ofs = inode->i_sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(inode->i_sb); inode->i_ino = atomic_long_inc_return(&ofs->last_ino); if (unlikely(!inode->i_ino)) @@ -1284,7 +1284,7 @@ struct inode *ovl_get_trap_inode(struct super_block *sb, struct dentry *dir) static bool ovl_hash_bylower(struct super_block *sb, struct dentry *upper, struct dentry *lower, bool index) { - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); /* No, if pure upper */ if (!lower) diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c index cfb3420b7df0..d0f196b85541 100644 --- a/fs/overlayfs/namei.c +++ b/fs/overlayfs/namei.c @@ -832,7 +832,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, { struct ovl_entry *oe; const struct cred *old_cred; - struct ovl_fs *ofs = dentry->d_sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(dentry->d_sb); struct ovl_entry *poe = dentry->d_parent->d_fsdata; struct ovl_entry *roe = dentry->d_sb->s_root->d_fsdata; struct ovl_path *stack = NULL, *origin_path = NULL; diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h index fd11fe6d6d45..b32c38fdf3c7 100644 --- a/fs/overlayfs/ovl_entry.h +++ b/fs/overlayfs/ovl_entry.h @@ -95,6 +95,8 @@ static inline struct mnt_idmap *ovl_upper_mnt_idmap(struct ovl_fs *ofs) return mnt_idmap(ovl_upper_mnt(ofs)); } +extern struct file_system_type ovl_fs_type; + static inline struct ovl_fs *OVL_FS(struct super_block *sb) { return (struct ovl_fs *)sb->s_fs_info; diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index f97ad8b40dbb..2ed0f498fce4 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -259,7 +259,7 @@ static void ovl_free_fs(struct ovl_fs *ofs) static void ovl_put_super(struct super_block *sb) { - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); ovl_free_fs(ofs); } @@ -267,7 +267,7 @@ static void ovl_put_super(struct super_block *sb) /* Sync real dirty inodes in upper filesystem (if it exists) */ static int ovl_sync_fs(struct super_block *sb, int wait) { - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); struct super_block *upper_sb; int ret; @@ -315,7 +315,7 @@ static int ovl_sync_fs(struct super_block *sb, int wait) */ static int ovl_statfs(struct dentry *dentry, struct kstatfs *buf) { - struct ovl_fs *ofs = dentry->d_sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(dentry->d_sb); struct dentry *root_dentry = dentry->d_sb->s_root; struct path path; int err; @@ -364,7 +364,7 @@ static inline int ovl_xino_def(void) static int ovl_show_options(struct seq_file *m, struct dentry *dentry) { struct super_block *sb = dentry->d_sb; - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); seq_show_option(m, "lowerdir", ofs->config.lowerdir); if (ofs->config.upperdir) { @@ -396,7 +396,7 @@ static int ovl_show_options(struct seq_file *m, struct dentry *dentry) static int ovl_remount(struct super_block *sb, int *flags, char *data) { - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); struct super_block *upper_sb; int ret = 0; @@ -2083,7 +2083,7 @@ static struct dentry *ovl_mount(struct file_system_type *fs_type, int flags, return mount_nodev(fs_type, flags, raw_data, ovl_fill_super); } -static struct file_system_type ovl_fs_type = { +struct file_system_type ovl_fs_type = { .owner = THIS_MODULE, .name = "overlay", .fs_flags = FS_USERNS_MOUNT, diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index 923d66d131c1..2425240ef139 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -18,25 +18,25 @@ int ovl_want_write(struct dentry *dentry) { - struct ovl_fs *ofs = dentry->d_sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(dentry->d_sb); return mnt_want_write(ovl_upper_mnt(ofs)); } void ovl_drop_write(struct dentry *dentry) { - struct ovl_fs *ofs = dentry->d_sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(dentry->d_sb); mnt_drop_write(ovl_upper_mnt(ofs)); } struct dentry *ovl_workdir(struct dentry *dentry) { - struct ovl_fs *ofs = dentry->d_sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(dentry->d_sb); return ofs->workdir; } const struct cred *ovl_override_creds(struct super_block *sb) { - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); return override_creds(ofs->creator_cred); } @@ -62,7 +62,7 @@ int ovl_can_decode_fh(struct super_block *sb) struct dentry *ovl_indexdir(struct super_block *sb) { - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); return ofs->indexdir; } @@ -70,7 +70,7 @@ struct dentry *ovl_indexdir(struct super_block *sb) /* Index all files on copy up. For now only enabled for NFS export */ bool ovl_index_all(struct super_block *sb) { - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); return ofs->config.nfs_export && ofs->config.index; } @@ -78,7 +78,7 @@ bool ovl_index_all(struct super_block *sb) /* Verify lower origin on lookup. For now only enabled for NFS export */ bool ovl_verify_lower(struct super_block *sb) { - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); return ofs->config.nfs_export && ofs->config.index; } @@ -152,7 +152,7 @@ enum ovl_path_type ovl_path_type(struct dentry *dentry) void ovl_path_upper(struct dentry *dentry, struct path *path) { - struct ovl_fs *ofs = dentry->d_sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(dentry->d_sb); path->mnt = ovl_upper_mnt(ofs); path->dentry = ovl_dentry_upper(dentry); @@ -415,7 +415,7 @@ bool ovl_dentry_needs_data_copy_up(struct dentry *dentry, int flags) bool ovl_redirect_dir(struct super_block *sb) { - struct ovl_fs *ofs = sb->s_fs_info; + struct ovl_fs *ofs = OVL_FS(sb); return ofs->config.redirect_dir && !ofs->noxattr; } From patchwork Sun May 21 08:28:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Righi X-Patchwork-Id: 96833 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp773027vqo; Sun, 21 May 2023 01:52:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6mQiWlqcrt2ATlP0fxs3vo9uXC2uAFZKKmKvvQd1haSSk902K4rDhSQeMO4Uy9VzL6RMew X-Received: by 2002:a05:6a20:a127:b0:101:b080:e763 with SMTP id q39-20020a056a20a12700b00101b080e763mr8156454pzk.31.1684659169486; Sun, 21 May 2023 01:52:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684659169; cv=none; d=google.com; s=arc-20160816; b=awqzvmioOt+y/czhv1FV1zoPJx32IAYcVWbegG1mbtkHli22dYNS6N6VT4wHNExVGA kcl0AO18jch32tl8aK/BXLj8Qmcm9wu4cPB1guGceb2/A2V9T3XDOHLj2ERaKjtuSG3P +WfvWTFP4U/IXbtoU0yynQXqSojEb2H6JyHAO8IXK3rUrHmyVSBgo/Du6yy4+FUw78r4 vdeiqqnhksFZJgYzTSm4Abg58rbi6lRA4N4O/orYtM8d9DtxaarEUtPxIcwZrJGnIXsu tC/L1DzDenSkd/wldqRBvsHFQmn8nIZoKljZdtufECCAceQ7/0iYeqk9FxdTBENzRaP2 pvwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JDxwondAh/OUHugni3ivKWRUI1pwMRnCsBuB/co2xpE=; b=J9Us7QMdBJzECFXnSg577GYb7iRhOG+tDBsdUVlyEwX0InxuESdvurkY2+xbZqschW YO7+5bxI0a4vs2Jmr83nje4MdtSdd94rgg871HdnEpo0+c2izFykNmWVRcr8o1hV6F67 AvNxlCYL1mtHN2J1G2IJCxZg5xFxsmUtDH6J5iy8WIcHQVdnt6oB9woFAZNeb/62ayTi Pook9F0fplQ2BnDGWRyyNhrOdR3yz/CStEgQJT7cCXmEAnbA0qQyLXZt/w2yZKsYoaL/ fOg2NMomwvFvyDKMbGI5q8lnuIm3Kdz8tXq7wcoqJEH+E3F9RWCriDmYVcRSRiWO5v9S zxGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=TgERYlQJ; 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=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q11-20020a63ae0b000000b00534792ee482si2802760pgf.758.2023.05.21.01.52.37; Sun, 21 May 2023 01:52:49 -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=@canonical.com header.s=20210705 header.b=TgERYlQJ; 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=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229795AbjEUIba (ORCPT + 99 others); Sun, 21 May 2023 04:31:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230064AbjEUI2W (ORCPT ); Sun, 21 May 2023 04:28:22 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7EA8ED for ; Sun, 21 May 2023 01:28:21 -0700 (PDT) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 888BF3F4F7 for ; Sun, 21 May 2023 08:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684657698; bh=JDxwondAh/OUHugni3ivKWRUI1pwMRnCsBuB/co2xpE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TgERYlQJWvrZw7gHn3ucr5v6Nsd0NPB6uVbqs6k+qlDRmOiBwA+YCgNvgKKN2htlj Lglx3xdXLUG+JjpvwJOL2XDX88f4LQc6C12su5kUVlO8wIOkprSj39FAH1dCBu1HJS BFD+gl1ECGerPKif+P5j6wuIlTgkCsR0R8j4T+8kDxuVs3KUuF4FpMPLnehtEcRWk4 yWHy+ZV02QDXg1le5Gulw5oES5qrEbkHF8kNaxHyRKbpb65rSsQCOH4FjYe7G2fvZC LDotCl7ELbaD99OHxLBepkHJmAq1952gy9yymZNgPUMNJtofHVujJCu/Dy6u2NAbLU KQ3EZBc0ExEZQ== Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-510b714821fso3139021a12.1 for ; Sun, 21 May 2023 01:28:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684657698; x=1687249698; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JDxwondAh/OUHugni3ivKWRUI1pwMRnCsBuB/co2xpE=; b=JadZMG4DvCfDwoJQFoTGOVrR/35faz6whgBul6CeP2erxJhd1Wsn0VPzKPNbrU3LY1 MJCDdU/wu5xcQ/DKajqdagMezILqPaHYrYAmc1KLbocBj2SfBS38vlvNyrMc7dyu1aE7 g8v5Zk85oyQuPamgxte/Fneg3xuCh8Q3/9yRoXQNg6HgXtUYPm2VkjYt5pS4FoOlZd/q ouDjoR3XcSWq+sN6Liha8pRINGXLZ8y3BW8ZZSMWRifoHxk0alcHNddo1TbmuPHU1QOM k93ywdY83CdIrhOZX/Si+vUPJLaHA7N6KpTSrnqYIdcLmof/MTcHeosykQpQ19s6Oum6 0aUg== X-Gm-Message-State: AC+VfDyeWbfAOo/Rsr5BgJBrjakxTptXb2hveb/qDX72lQNuYrCn0jaY L+rp8hiN2kOwcCJEI+vNYzHFP/g5epmZWJpNhgoCZPxSZyeX3hkGwi8XQbwamW5YJnkrpJe7PMm fgrj3xS/zACFFxQgCWnZsRznP9PR6TAVkIjglD4QAZQ== X-Received: by 2002:a50:ed09:0:b0:50c:161b:9154 with SMTP id j9-20020a50ed09000000b0050c161b9154mr6988440eds.11.1684657698395; Sun, 21 May 2023 01:28:18 -0700 (PDT) X-Received: by 2002:a50:ed09:0:b0:50c:161b:9154 with SMTP id j9-20020a50ed09000000b0050c161b9154mr6988428eds.11.1684657698143; Sun, 21 May 2023 01:28:18 -0700 (PDT) Received: from righiandr-XPS-13-7390.homenet.telecomitalia.it (host-87-10-127-160.retail.telecomitalia.it. [87.10.127.160]) by smtp.gmail.com with ESMTPSA id z17-20020aa7cf91000000b004c2158e87e6sm1656646edx.97.2023.05.21.01.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 May 2023 01:28:17 -0700 (PDT) From: Andrea Righi To: Miklos Szeredi Cc: Amir Goldstein , linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/3] ovl: validate superblock in OVL_FS() Date: Sun, 21 May 2023 10:28:13 +0200 Message-Id: <20230521082813.17025-4-andrea.righi@canonical.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230521082813.17025-1-andrea.righi@canonical.com> References: <20230521082813.17025-1-andrea.righi@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766493173360621801?= X-GMAIL-MSGID: =?utf-8?q?1766493173360621801?= When CONFIG_OVERLAY_FS_DEBUG is enabled add an explicit check to make sure that OVL_FS() is always used with a valid overlayfs superblock. Otherwise trigger a WARN_ON_ONCE(). Reviewed-by: Amir Goldstein Signed-off-by: Andrea Righi --- fs/overlayfs/ovl_entry.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h index b32c38fdf3c7..e156649d9c71 100644 --- a/fs/overlayfs/ovl_entry.h +++ b/fs/overlayfs/ovl_entry.h @@ -97,8 +97,20 @@ static inline struct mnt_idmap *ovl_upper_mnt_idmap(struct ovl_fs *ofs) extern struct file_system_type ovl_fs_type; +static inline bool is_ovl_fs_sb(struct super_block *sb) +{ + return sb->s_type == &ovl_fs_type; +} + +#ifdef CONFIG_OVERLAY_FS_DEBUG +#define OVL_VALIDATE_SB(__sb) WARN_ON_ONCE(!is_ovl_fs_sb(__sb)) +#else +#define OVL_VALIDATE_SB(__sb) +#endif + static inline struct ovl_fs *OVL_FS(struct super_block *sb) { + OVL_VALIDATE_SB(sb); return (struct ovl_fs *)sb->s_fs_info; }