linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Gaosheng Cui <cuigaosheng1@huawei.com>
Cc: hch@infradead.org, viro@zeniv.linux.org.uk, dhowells@redhat.com,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2] fs: fix undefined behavior in bit shift for SB_NOUSER
Date: Mon, 31 Oct 2022 13:53:29 +0000	[thread overview]
Message-ID: <Y1/TWdY//yUgXGck@casper.infradead.org> (raw)
In-Reply-To: <20221031134811.178127-1-cuigaosheng1@huawei.com>

On Mon, Oct 31, 2022 at 09:48:11PM +0800, Gaosheng Cui wrote:
> +++ b/include/linux/fs.h
> @@ -1384,19 +1384,19 @@ extern int send_sigurg(struct fown_struct *fown);
>  #define SB_NOATIME	1024	/* Do not update access times. */
>  #define SB_NODIRATIME	2048	/* Do not update directory access times */
>  #define SB_SILENT	32768

Shouldn't those ^^^ also be marked as unsigned?  And it's confusing to
have the style change halfway through the sequence; can you convert them
to (1U << n) as well?

> -#define SB_POSIXACL	(1<<16)	/* VFS does not apply the umask */
> -#define SB_INLINECRYPT	(1<<17)	/* Use blk-crypto for encrypted files */
> -#define SB_KERNMOUNT	(1<<22) /* this is a kern_mount call */
> -#define SB_I_VERSION	(1<<23) /* Update inode I_version field */
> -#define SB_LAZYTIME	(1<<25) /* Update the on-disk [acm]times lazily */
> +#define SB_POSIXACL	(1U << 16) /* VFS does not apply the umask */
> +#define SB_INLINECRYPT	(1U << 17) /* Use blk-crypto for encrypted files */
> +#define SB_KERNMOUNT	(1U << 22) /* this is a kern_mount call */
> +#define SB_I_VERSION	(1U << 23) /* Update inode I_version field */
> +#define SB_LAZYTIME	(1U << 25) /* Update the on-disk [acm]times lazily */
>  
>  /* These sb flags are internal to the kernel */
> -#define SB_SUBMOUNT     (1<<26)
> -#define SB_FORCE    	(1<<27)
> -#define SB_NOSEC	(1<<28)
> -#define SB_BORN		(1<<29)
> -#define SB_ACTIVE	(1<<30)
> -#define SB_NOUSER	(1<<31)
> +#define SB_SUBMOUNT	(1U << 26)
> +#define SB_FORCE	(1U << 27)
> +#define SB_NOSEC	(1U << 28)
> +#define SB_BORN		(1U << 29)
> +#define SB_ACTIVE	(1U << 30)
> +#define SB_NOUSER	(1U << 31)
>  
>  /* These flags relate to encoding and casefolding */
>  #define SB_ENC_STRICT_MODE_FL	(1 << 0)
> -- 
> 2.25.1
> 

  parent reply	other threads:[~2022-10-31 13:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31 13:48 [PATCH v2] fs: fix undefined behavior in bit shift for SB_NOUSER Gaosheng Cui
2022-10-31 13:50 ` Christoph Hellwig
2022-10-31 13:53 ` Matthew Wilcox [this message]
2022-10-31 14:05   ` Christoph Hellwig
2022-10-31 14:36   ` cuigaosheng
  -- strict thread matches above, loose matches on Subject: below --
2023-04-24  3:00 [PATCH] " Hao Ge
2023-04-24  4:51 ` [PATCH V2] " Hao Ge
2023-04-24  5:01   ` Al Viro
2023-04-24  5:43     ` Hao Ge

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y1/TWdY//yUgXGck@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=cuigaosheng1@huawei.com \
    --cc=dhowells@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).