diff options
author | Kari Argillander <kari.argillander@gmail.com> | 2021-08-26 11:56:29 +0300 |
---|---|---|
committer | Konstantin Komarov <almaz.alexandrovich@paragon-software.com> | 2021-08-27 17:05:12 +0300 |
commit | fa3cacf544636b2dc48cfb2f277a2071f14d66a2 (patch) | |
tree | b8a8c9c934e36eb965f3dca0d299519fb748104a /fs/ntfs3/fsntfs.c | |
parent | 24516d481dfc6c7728ffe36280ca8cf4640d119a (diff) | |
download | linux-stable-fa3cacf544636b2dc48cfb2f277a2071f14d66a2.tar.gz linux-stable-fa3cacf544636b2dc48cfb2f277a2071f14d66a2.tar.bz2 linux-stable-fa3cacf544636b2dc48cfb2f277a2071f14d66a2.zip |
fs/ntfs3: Use kernel ALIGN macros over driver specific
The static checkers (Smatch) were complaining because QuadAlign() was
buggy. If you try to align something higher than UINT_MAX it got
truncated to a u32.
Smatch warning was:
fs/ntfs3/attrib.c:383 attr_set_size_res()
warn: was expecting a 64 bit value instead of '~7'
So that this will not happen again we will change all these macros to
kernel made ones. This can also help some other static analyzing tools
to give us better warnings.
Patch was generated with Coccinelle script and after that some style
issue was hand fixed.
Coccinelle script:
virtual patch
@alloc depends on patch@
expression x;
@@
(
- #define QuadAlign(n) (((n) + 7u) & (~7u))
|
- QuadAlign(x)
+ ALIGN(x, 8)
|
- #define IsQuadAligned(n) (!((size_t)(n)&7u))
|
- IsQuadAligned(x)
+ IS_ALIGNED(x, 8)
|
- #define Quad2Align(n) (((n) + 15u) & (~15u))
|
- Quad2Align(x)
+ ALIGN(x, 16)
|
- #define IsQuad2Aligned(n) (!((size_t)(n)&15u))
|
- IsQuad2Aligned(x)
+ IS_ALIGNED(x, 16)
|
- #define Quad4Align(n) (((n) + 31u) & (~31u))
|
- Quad4Align(x)
+ ALIGN(x, 32)
|
- #define IsSizeTAligned(n) (!((size_t)(n) & (sizeof(size_t) - 1)))
|
- IsSizeTAligned(x)
+ IS_ALIGNED(x, sizeof(size_t))
|
- #define DwordAlign(n) (((n) + 3u) & (~3u))
|
- DwordAlign(x)
+ ALIGN(x, 4)
|
- #define IsDwordAligned(n) (!((size_t)(n)&3u))
|
- IsDwordAligned(x)
+ IS_ALIGNED(x, 4)
|
- #define WordAlign(n) (((n) + 1u) & (~1u))
|
- WordAlign(x)
+ ALIGN(x, 2)
|
- #define IsWordAligned(n) (!((size_t)(n)&1u))
|
- IsWordAligned(x)
+ IS_ALIGNED(x, 2)
|
)
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Kari Argillander <kari.argillander@gmail.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Diffstat (limited to 'fs/ntfs3/fsntfs.c')
-rw-r--r-- | fs/ntfs3/fsntfs.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c index c6599c514acf..e887921a117d 100644 --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -1944,7 +1944,7 @@ int ntfs_security_init(struct ntfs_sb_info *sbi) sbi->security.next_id = SECURITY_ID_FIRST; /* Always write new security at the end of bucket */ sbi->security.next_off = - Quad2Align(sds_size - SecurityDescriptorsBlockSize); + ALIGN(sds_size - SecurityDescriptorsBlockSize, 16); off = 0; ne = NULL; @@ -2096,7 +2096,7 @@ int ntfs_insert_security(struct ntfs_sb_info *sbi, struct NTFS_DE_SII sii_e; struct SECURITY_HDR *d_security; u32 new_sec_size = size_sd + SIZEOF_SECURITY_HDR; - u32 aligned_sec_size = Quad2Align(new_sec_size); + u32 aligned_sec_size = ALIGN(new_sec_size, 16); struct SECURITY_KEY hash_key; struct ntfs_fnd *fnd_sdh = NULL; const struct INDEX_ROOT *root_sdh; |