diff options
author | Tetsuhiro Kohada <kohada.t2@gmail.com> | 2020-05-31 11:30:17 +0200 |
---|---|---|
committer | Namjae Jeon <namjae.jeon@samsung.com> | 2020-06-09 09:49:19 +0200 |
commit | 476189c0ef3b658de3f6b89fd0fdeb6dc451b564 (patch) | |
tree | b584a3bad9243822b5efcffd28b2872bd741bce0 /fs/exfat/misc.c | |
parent | exfat: separate the boot sector analysis (diff) | |
download | linux-476189c0ef3b658de3f6b89fd0fdeb6dc451b564.tar.xz linux-476189c0ef3b658de3f6b89fd0fdeb6dc451b564.zip |
exfat: add boot region verification
Add Boot-Regions verification specified in exFAT specification.
Note that the checksum type is strongly related to the raw structure,
so the'u32 'type is used to clarify the number of bits.
Signed-off-by: Tetsuhiro Kohada <kohada.t2@gmail.com>
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Diffstat (limited to 'fs/exfat/misc.c')
-rw-r--r-- | fs/exfat/misc.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/exfat/misc.c b/fs/exfat/misc.c index ab7f88b1f6d3..b82d2dd5bd7c 100644 --- a/fs/exfat/misc.c +++ b/fs/exfat/misc.c @@ -151,6 +151,20 @@ unsigned short exfat_calc_chksum_2byte(void *data, int len, return chksum; } +u32 exfat_calc_chksum32(void *data, int len, u32 chksum, int type) +{ + int i; + u8 *c = (u8 *)data; + + for (i = 0; i < len; i++, c++) { + if (unlikely(type == CS_BOOT_SECTOR && + (i == 106 || i == 107 || i == 112))) + continue; + chksum = ((chksum << 31) | (chksum >> 1)) + *c; + } + return chksum; +} + void exfat_update_bh(struct super_block *sb, struct buffer_head *bh, int sync) { set_bit(EXFAT_SB_DIRTY, &EXFAT_SB(sb)->s_state); |