All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] JFFS2: fix jffs2 summary datacrc status uninitialized
@ 2021-02-23  3:49 Wagner Popov dos Santos
  2021-03-04  0:36 ` Wagner Popov dos Santos
  2021-04-07 23:05 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Wagner Popov dos Santos @ 2021-02-23  3:49 UTC (permalink / raw)
  To: u-boot

The function jffs2_1pass_read_inode() was discarding the summary
inodes and dirent because the value in datacrc flag wasn't
initialized in function jffs2_sum_process_sum_data().

This fix initializes the status of all summary records to indicate
that the CRC needs to be verified when they are loaded.

Before this fix, the behaviors produced by the undefined value of
datacrc was:
- Summary's registries were discarded when 'b->datacrc' is equal
  as 'CRC_BAD'.
- Summary's registries were not checked when b->datacrc differs of
  'CRC_BAD' and 'CRC_UNKNOWN'

So, almost all of the time the crc just isn't checked, and in some
cases the registries are discarded.

Signed-off-by: Wagner Popov dos Santos <wpopov@gmail.com>
---
 fs/jffs2/jffs2_1pass.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
index a98745c50e..c9eda54cdb 100644
--- a/fs/jffs2/jffs2_1pass.c
+++ b/fs/jffs2/jffs2_1pass.c
@@ -1276,6 +1276,7 @@ static int jffs2_sum_process_sum_data(struct part_info *part, uint32_t offset,
 							&spi->version);
 						b->ino = sum_get_unaligned32(
 							&spi->inode);
+						b->datacrc = CRC_UNKNOWN;
 					}
 
 					sp += JFFS2_SUMMARY_INODE_SIZE;
@@ -1297,6 +1298,7 @@ static int jffs2_sum_process_sum_data(struct part_info *part, uint32_t offset,
 							&spd->version);
 						b->pino = sum_get_unaligned32(
 							&spd->pino);
+						b->datacrc = CRC_UNKNOWN;
 					}
 
 					sp += JFFS2_SUMMARY_DIRENT_SIZE(
-- 
2.20.1

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

* [PATCH] JFFS2: fix jffs2 summary datacrc status uninitialized
  2021-02-23  3:49 [PATCH] JFFS2: fix jffs2 summary datacrc status uninitialized Wagner Popov dos Santos
@ 2021-03-04  0:36 ` Wagner Popov dos Santos
  2021-04-07 23:05 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Wagner Popov dos Santos @ 2021-03-04  0:36 UTC (permalink / raw)
  To: u-boot

Forgot to Cc the maintainer, doing it now, sorry for the spam.

On ter, 2021-02-23 ?s 00:49 -0300, Wagner Popov dos Santos wrote:
> The function jffs2_1pass_read_inode() was discarding the summary
> inodes and dirent because the value in datacrc flag wasn't
> initialized in function jffs2_sum_process_sum_data().
> 
> This fix initializes the status of all summary records to indicate
> that the CRC needs to be verified when they are loaded.
> 
> Before this fix, the behaviors produced by the undefined value of
> datacrc was:
> - Summary's registries were discarded when 'b->datacrc' is equal
>   as 'CRC_BAD'.
> - Summary's registries were not checked when b->datacrc differs of
>   'CRC_BAD' and 'CRC_UNKNOWN'
> 
> So, almost all of the time the crc just isn't checked, and in some
> cases the registries are discarded.
> 
> Signed-off-by: Wagner Popov dos Santos <wpopov@gmail.com>
> ---
>  fs/jffs2/jffs2_1pass.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c
> index a98745c50e..c9eda54cdb 100644
> --- a/fs/jffs2/jffs2_1pass.c
> +++ b/fs/jffs2/jffs2_1pass.c
> @@ -1276,6 +1276,7 @@ static int jffs2_sum_process_sum_data(struct part_info *part, uint32_t offset,
>  							&spi->version);
>  						b->ino = sum_get_unaligned32(
>  							&spi->inode);
> +						b->datacrc = CRC_UNKNOWN;
>  					}
>  
>  					sp += JFFS2_SUMMARY_INODE_SIZE;
> @@ -1297,6 +1298,7 @@ static int jffs2_sum_process_sum_data(struct part_info *part, uint32_t offset,
>  							&spd->version);
>  						b->pino = sum_get_unaligned32(
>  							&spd->pino);
> +						b->datacrc = CRC_UNKNOWN;
>  					}
>  
>  					sp += JFFS2_SUMMARY_DIRENT_SIZE(

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

* [PATCH] JFFS2: fix jffs2 summary datacrc status uninitialized
  2021-02-23  3:49 [PATCH] JFFS2: fix jffs2 summary datacrc status uninitialized Wagner Popov dos Santos
  2021-03-04  0:36 ` Wagner Popov dos Santos
@ 2021-04-07 23:05 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2021-04-07 23:05 UTC (permalink / raw)
  To: u-boot

On Tue, Feb 23, 2021 at 12:49:00AM -0300, Wagner Popov dos Santos wrote:

> The function jffs2_1pass_read_inode() was discarding the summary
> inodes and dirent because the value in datacrc flag wasn't
> initialized in function jffs2_sum_process_sum_data().
> 
> This fix initializes the status of all summary records to indicate
> that the CRC needs to be verified when they are loaded.
> 
> Before this fix, the behaviors produced by the undefined value of
> datacrc was:
> - Summary's registries were discarded when 'b->datacrc' is equal
>   as 'CRC_BAD'.
> - Summary's registries were not checked when b->datacrc differs of
>   'CRC_BAD' and 'CRC_UNKNOWN'
> 
> So, almost all of the time the crc just isn't checked, and in some
> cases the registries are discarded.
> 
> Signed-off-by: Wagner Popov dos Santos <wpopov@gmail.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210407/d57e35c0/attachment.sig>

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

end of thread, other threads:[~2021-04-07 23:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-23  3:49 [PATCH] JFFS2: fix jffs2 summary datacrc status uninitialized Wagner Popov dos Santos
2021-03-04  0:36 ` Wagner Popov dos Santos
2021-04-07 23:05 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.