public inbox for fsverity@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH v2] fsverity: use WARN_ON_ONCE instead of WARN_ON
@ 2023-04-06 18:15 Eric Biggers
  2023-04-06 18:25 ` Eric Biggers
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Biggers @ 2023-04-06 18:15 UTC (permalink / raw)
  To: fsverity; +Cc: linux-fsdevel, linux-kernel, Chaitanya Kulkarni

From: Eric Biggers <ebiggers@google.com>

As per Linus's suggestion
(https://lore.kernel.org/r/CAHk-=whefxRGyNGzCzG6BVeM=5vnvgb-XhSeFJVxJyAxAF8XRA@mail.gmail.com),
use WARN_ON_ONCE instead of WARN_ON.  This barely adds any extra
overhead, and it makes it so that if any of these ever becomes reachable
(they shouldn't, but that's the point), the logs can't be flooded.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 fs/verity/enable.c       | 4 ++--
 fs/verity/hash_algs.c    | 4 ++--
 fs/verity/open.c         | 2 +-
 include/linux/fsverity.h | 6 +++---
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/verity/enable.c b/fs/verity/enable.c
index 7a0e3a84d370b..541c2a277c5c6 100644
--- a/fs/verity/enable.c
+++ b/fs/verity/enable.c
@@ -165,7 +165,7 @@ static int build_merkle_tree(struct file *filp,
 		}
 	}
 	/* The root hash was filled by the last call to hash_one_block(). */
-	if (WARN_ON(buffers[num_levels].filled != params->digest_size)) {
+	if (WARN_ON_ONCE(buffers[num_levels].filled != params->digest_size)) {
 		err = -EINVAL;
 		goto out;
 	}
@@ -277,7 +277,7 @@ static int enable_verity(struct file *filp,
 		fsverity_err(inode, "%ps() failed with err %d",
 			     vops->end_enable_verity, err);
 		fsverity_free_info(vi);
-	} else if (WARN_ON(!IS_VERITY(inode))) {
+	} else if (WARN_ON_ONCE(!IS_VERITY(inode))) {
 		err = -EINVAL;
 		fsverity_free_info(vi);
 	} else {
diff --git a/fs/verity/hash_algs.c b/fs/verity/hash_algs.c
index 13fcf31be8441..ea00dbedf756b 100644
--- a/fs/verity/hash_algs.c
+++ b/fs/verity/hash_algs.c
@@ -84,9 +84,9 @@ struct fsverity_hash_alg *fsverity_get_hash_alg(const struct inode *inode,
 	}
 
 	err = -EINVAL;
-	if (WARN_ON(alg->digest_size != crypto_ahash_digestsize(tfm)))
+	if (WARN_ON_ONCE(alg->digest_size != crypto_ahash_digestsize(tfm)))
 		goto err_free_tfm;
-	if (WARN_ON(alg->block_size != crypto_ahash_blocksize(tfm)))
+	if (WARN_ON_ONCE(alg->block_size != crypto_ahash_blocksize(tfm)))
 		goto err_free_tfm;
 
 	err = mempool_init_kmalloc_pool(&alg->req_pool, 1,
diff --git a/fs/verity/open.c b/fs/verity/open.c
index 9366b441d01ca..52048b7630dcc 100644
--- a/fs/verity/open.c
+++ b/fs/verity/open.c
@@ -83,7 +83,7 @@ int fsverity_init_merkle_tree_params(struct merkle_tree_params *params,
 	params->log_blocks_per_page = PAGE_SHIFT - log_blocksize;
 	params->blocks_per_page = 1 << params->log_blocks_per_page;
 
-	if (WARN_ON(!is_power_of_2(params->digest_size))) {
+	if (WARN_ON_ONCE(!is_power_of_2(params->digest_size))) {
 		err = -EINVAL;
 		goto out_err;
 	}
diff --git a/include/linux/fsverity.h b/include/linux/fsverity.h
index 119a3266791fd..e76605d5b36ee 100644
--- a/include/linux/fsverity.h
+++ b/include/linux/fsverity.h
@@ -233,18 +233,18 @@ static inline int fsverity_ioctl_read_metadata(struct file *filp,
 static inline bool fsverity_verify_blocks(struct folio *folio, size_t len,
 					  size_t offset)
 {
-	WARN_ON(1);
+	WARN_ON_ONCE(1);
 	return false;
 }
 
 static inline void fsverity_verify_bio(struct bio *bio)
 {
-	WARN_ON(1);
+	WARN_ON_ONCE(1);
 }
 
 static inline void fsverity_enqueue_verify_work(struct work_struct *work)
 {
-	WARN_ON(1);
+	WARN_ON_ONCE(1);
 }
 
 #endif	/* !CONFIG_FS_VERITY */

base-commit: 1238c8b91c5aca6dd13bccb1b4dc716718e7bfac
-- 
2.40.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] fsverity: use WARN_ON_ONCE instead of WARN_ON
  2023-04-06 18:15 [PATCH v2] fsverity: use WARN_ON_ONCE instead of WARN_ON Eric Biggers
@ 2023-04-06 18:25 ` Eric Biggers
  2023-04-11  8:58   ` Christian Brauner
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Biggers @ 2023-04-06 18:25 UTC (permalink / raw)
  To: fsverity; +Cc: linux-fsdevel, linux-kernel, Chaitanya Kulkarni

On Thu, Apr 06, 2023 at 11:15:42AM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
> 
> As per Linus's suggestion
> (https://lore.kernel.org/r/CAHk-=whefxRGyNGzCzG6BVeM=5vnvgb-XhSeFJVxJyAxAF8XRA@mail.gmail.com),
> use WARN_ON_ONCE instead of WARN_ON.  This barely adds any extra
> overhead, and it makes it so that if any of these ever becomes reachable
> (they shouldn't, but that's the point), the logs can't be flooded.
> 
> Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
>  fs/verity/enable.c       | 4 ++--
>  fs/verity/hash_algs.c    | 4 ++--
>  fs/verity/open.c         | 2 +-
>  include/linux/fsverity.h | 6 +++---
>  4 files changed, 8 insertions(+), 8 deletions(-)

Sorry, forgot changelog:

v2: also convert the three WARN_ON in include/linux/fsverity.h

- Eric

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] fsverity: use WARN_ON_ONCE instead of WARN_ON
  2023-04-06 18:25 ` Eric Biggers
@ 2023-04-11  8:58   ` Christian Brauner
  0 siblings, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2023-04-11  8:58 UTC (permalink / raw)
  To: Eric Biggers; +Cc: fsverity, linux-fsdevel, linux-kernel, Chaitanya Kulkarni

On Thu, Apr 06, 2023 at 11:25:25AM -0700, Eric Biggers wrote:
> On Thu, Apr 06, 2023 at 11:15:42AM -0700, Eric Biggers wrote:
> > From: Eric Biggers <ebiggers@google.com>
> > 
> > As per Linus's suggestion
> > (https://lore.kernel.org/r/CAHk-=whefxRGyNGzCzG6BVeM=5vnvgb-XhSeFJVxJyAxAF8XRA@mail.gmail.com),
> > use WARN_ON_ONCE instead of WARN_ON.  This barely adds any extra
> > overhead, and it makes it so that if any of these ever becomes reachable
> > (they shouldn't, but that's the point), the logs can't be flooded.
> > 
> > Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
> > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > ---
> >  fs/verity/enable.c       | 4 ++--
> >  fs/verity/hash_algs.c    | 4 ++--
> >  fs/verity/open.c         | 2 +-
> >  include/linux/fsverity.h | 6 +++---
> >  4 files changed, 8 insertions(+), 8 deletions(-)
> 
> Sorry, forgot changelog:
> 
> v2: also convert the three WARN_ON in include/linux/fsverity.h

Looks good to me,
Reviewed-by: Christian Brauner <brauner@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-11  8:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06 18:15 [PATCH v2] fsverity: use WARN_ON_ONCE instead of WARN_ON Eric Biggers
2023-04-06 18:25 ` Eric Biggers
2023-04-11  8:58   ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox