Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1658083rdg; Sat, 12 Aug 2023 10:15:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF77itsx/VfVWgBUa1PSiWXTKf7Iufs6Jk3Epg0vBcJbdj2hlvzo1py3vgbQTdSvw9oDruG X-Received: by 2002:a17:907:7886:b0:993:d7ff:afe7 with SMTP id ku6-20020a170907788600b00993d7ffafe7mr4599123ejc.13.1691860506010; Sat, 12 Aug 2023 10:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691860505; cv=none; d=google.com; s=arc-20160816; b=u1RGY8ITGDsdOqf8D0/7tOdvsEBvJGCErtIZdS7182FNsLRzEJmn2rYYgR1BOptV3t hFy50AFm9biiINeiiMc6ZQ/HqbKLSB/CcZ7LD7q/zuo/lYb1bxpkEfmSM2aMVMv6f8uu YwLcmbKWIcwkASWzqKyZ6l/IkP6l5nXwOpijQJx/iQY/MI5gpzkpbtnP+1fYk7LuhrWP BLmBYbI5UgzehNhixfBCB5XFrAbyBzXsKB51c0sTun07Gn1Bv47dtLaLez5xq7hEGCj9 Hpj7cUISAemiamP2ec+yVwJRCA62YOfwNc554vIKs9OYfWROsR2fDhE72gkTuRqlVjSO uEhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=kpQF2jb9S26eRaRt+HxIZRVdjuYf869tDcD3W/2sESQ=; fh=xm+R0SS1y3uN+W6je+0Ep0yjZ1XLjdijMDfz3sCQxjw=; b=ZOtnBd9nGrfW8glz/VUywNfxmO2BrmcxBBUKAlf5RxPhG+tKk9Fa1StceNT8FOX0TR dvIXkeGBjldcfWibXNwlWpFttEZD5BDUVoc7GyKkIcQwH0nQBFz0QlxmfMPnp07q4IQm qk07WIw17iOpV7fUB88hBa5F91LvTILu/UeL0mEhfM2CNtSN2bmA5sFICzQGIxS9xmPm H9vhc0em/I9B04TbkdTQZh2o/tenHxOzOblIGs0X8rbQsvwhMt6kzXOccfiAFU4lcPJu EfSkbCHlQWlfBsu6Rqy2jZAL/VUudb5WCOQsbsxFXCpzhIHYgd8A3VX8+Ub8v/d7GIqZ 3/FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=cBvxQ9L8; 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 i14-20020a170906264e00b00992fef51a60si4915957ejc.525.2023.08.12.10.14.41; Sat, 12 Aug 2023 10:15:05 -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=20221208 header.b=cBvxQ9L8; 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 S229838AbjHLQ0M (ORCPT + 99 others); Sat, 12 Aug 2023 12:26:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229451AbjHLQ0L (ORCPT ); Sat, 12 Aug 2023 12:26:11 -0400 Received: from mail-vs1-xe2d.google.com (mail-vs1-xe2d.google.com [IPv6:2607:f8b0:4864:20::e2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FF991BEC; Sat, 12 Aug 2023 09:26:14 -0700 (PDT) Received: by mail-vs1-xe2d.google.com with SMTP id ada2fe7eead31-44768e056e1so1235785137.1; Sat, 12 Aug 2023 09:26:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691857573; x=1692462373; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kpQF2jb9S26eRaRt+HxIZRVdjuYf869tDcD3W/2sESQ=; b=cBvxQ9L83Yt5nefPpuvc0YUpLvWPtYQbXXa+ZaxS2i67igSA6xiM+Wk1iyK5oYvHDC RkvpXNf24mb77xD29WDqaDw9dtqVZbXtdWh6OsMDW6igCElVVu5r0LqU8myR1wimnnU5 KAorAKstgaQvAisdQ9EutXqr9ujnamX/Rwi526rmDqRvjWPue2V2Q4t7DpVc0OfD+cbv ofOYIsWz2S77qo74unKyDDwXDPqjv8akSK4601Oji+LfZrVJcufI42Gh35t9vOBDYpsg NMZH/dLdLQO+kVYWNl7Wrv07hGFHtkMreZy+Y/AxKqkCl40DMqaE+2St2vXcPtoPYpQ3 6G7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691857573; x=1692462373; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kpQF2jb9S26eRaRt+HxIZRVdjuYf869tDcD3W/2sESQ=; b=P7HsuHDimNnqgmUeFZnuDrUUlHUM8Qmui79mLbP3VWo1VA51x5kP2ps+BWI3NvVj1Q 9Ki4xvUgKGUtdRB73a9vjADPi0RimPwBePljIE/NHJ7PCFrCGbYtgDlkw3DKG8SZjnqF gt34hS8qKqqJQltVxLyXSpc29xryc3+pQZXtsESkbAnkJV8ePumKqBA5QS+mRKbId4gx Ff1wKHCO9+dKhuH7bgoSSi8TNTJ8/pirUkzJeaV9reAyqqDb38gUTmt7PpXX2hxAHCsl uURYb0rcA4pjKEQJa6Iqm20IuEXHGDEcoa748ZM8/weTFU8sP06zBenxa4Dj+sXkE6wa yv+w== X-Gm-Message-State: AOJu0YycneOlchGtY5P4uCQXmsedhfl5ghhgeuW2xusIU5Y2SAEZgkUq Y3h5E6JyXXyYA4uf+sgQcVOikp28TbUCy6QSpqGqsGEm7uk= X-Received: by 2002:a67:db81:0:b0:443:7170:b048 with SMTP id f1-20020a67db81000000b004437170b048mr4486829vsk.27.1691857572983; Sat, 12 Aug 2023 09:26:12 -0700 (PDT) MIME-Version: 1.0 References: <20230521082813.17025-1-andrea.righi@canonical.com> <20230521082813.17025-4-andrea.righi@canonical.com> In-Reply-To: From: Amir Goldstein Date: Sat, 12 Aug 2023 19:26:01 +0300 Message-ID: Subject: Re: [PATCH v3 3/3] ovl: validate superblock in OVL_FS() To: Miklos Szeredi , Andrea Righi Cc: linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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_BLOCKED,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 On Fri, Aug 11, 2023 at 12:14=E2=80=AFPM Amir Goldstein wrote: > > On Mon, Jul 24, 2023 at 5:43=E2=80=AFPM Miklos Szeredi wrote: > > > > On Sun, 21 May 2023 at 10:28, Andrea Righi = wrote: > > > > > > 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_idma= p(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 =3D=3D &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); > > > > This could be written simply and naturally: > > > > if (IS_ENABLED(CONFIG_OVERLAY_FS_DEBUG)) > > WARN_ON_ONCE(sb->s_type !=3D &ovl_fs_type) > > > > Andrea, > > There is an inherent challenge with a cleanup series like this one > that touches many functions to avoid merge conflicts with other > devel branches. I did not try, but I expect there are conflicts > with the current overlayfs-next branch. > > I also see at least one new direct reference of sb->s_fs_info > in ovl_maybe_validate_verity(). > > Please make sure to base your next submission on overlayfs-next > branch from git://git.kernel.org/pub/scm/linux/kernel/git/overlayfs/vfs.g= it. > > Once you do that, we could apply your patches to overlayfs-next > so they won't get stale again. Nevermind, I had rebased overlayfs-next, so already applied your patches with the needed conflict resolutions and addressed Miklos' comment. Thanks, Amir.