30 May, 2019

1 commit


24 May, 2019

1 commit

  • The FAT16/12 has rootdir area before data area, and the clusters for
    rootdir are not mantained by FAT table. So we don't need to find empty
    cluster for next rootdir space, just use next dir cluster. And the FAT
    table don't need to update for this new dir cluster.

    Signed-off-by: Ye Li
    Acked-by: Peng Fan
    (cherry picked from commit 9e0a33cacc0a7926d46c0ca184498ae88278816e)

    Ye Li
     

23 Mar, 2019

1 commit

  • U-Boot doesn't support metadata_csum feature. Writing to filesystem with
    metadata_csum feature makes the filesystem corrupted and unbootable by
    Linux:

    [ 2.527495] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 0 failed (52188!=0)
    [ 2.537421] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 1 failed (5262!=0)
    ...
    [ 2.653308] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 14 failed (42611!=0)
    [ 2.662179] EXT4-fs (mmcblk0p2): ext4_check_descriptors: Checksum for group 15 failed (21527!=0)
    [ 2.687920] JBD2: journal checksum error
    [ 2.691982] EXT4-fs (mmcblk0p2): error loading journal
    [ 2.698292] VFS: Cannot open root device "mmcblk0p2" or unknown-block(179,2): error -74

    Don't write to filesystem with meatadata_csum feature to not corrupt the
    filesystem.

    Signed-off-by: Sébastien Szymanski

    Sébastien Szymanski
     

01 Mar, 2019

1 commit

  • When compiling with DEBUG=1 an error
    fs/fat/fat_write.c:831: undefined reference to `__aeabi_ldivmod'
    occurred.

    We should use do_div() instead of the modulus operator.

    filesize and cur_pos cannot be negative. So let's use u64 to avoid
    warnings.

    Fixes: cb8af8af5ba0 ("fs: fat: support write with non-zero offset")
    Signed-off-by: Heinrich Schuchardt

    Heinrich Schuchardt
     

19 Feb, 2019

2 commits


09 Feb, 2019

1 commit

  • Unlike other generic FS accessors, fs_get_info() does not call fs_close()
    at the end of it's operation. Thus, using fs_get_info() in do_fs_type()
    without calling fs_close() causes potential memory leak by creating new
    filesystem structures on each call of do_fs_type().

    The test case to trigger this problem is as follows. It is required to
    have ext4 filesystem on the first partition of the SDMMC device, since
    ext4 requires stateful mount and causes memory allocation.
    => while true ; do mmc rescan ; fstype mmc 1 ; done
    Eventually, the mounting of ext4 will fail due to malloc failures
    and the filesystem will not be correctly detected.

    This patch fixes the problem by adding the missing fs_close().

    Signed-off-by: Marek Vasut
    Cc: Simon Glass
    Cc: Tom Rini

    Marek Vasut
     

02 Feb, 2019

1 commit

  • This fixes the automatic lmb initialization and reservation for boards
    with more than one DRAM bank.

    This fixes the CVE-2018-18439 and -18440 fixes that only allowed to load
    files into the firs DRAM bank from fs and via tftp.

    Found-by: Heinrich Schuchardt
    Signed-off-by: Simon Goldschmidt
    Tested-by: Heinrich Schuchardt
    Reviewed-by: Simon Glass

    Simon Goldschmidt
     

01 Feb, 2019

4 commits


17 Jan, 2019

1 commit


11 Jan, 2019

1 commit

  • This particular commit is causing a regression on stih410-b2260 and
    other platforms when reading from FAT16. Noting that I had rebased the
    original fix from Thomas onto then-current master, there is also
    question from Akashi-san if the change is still needed after other FAT
    fixes that have gone in.

    This reverts commit a68b0e11ea774492713a65d9fd5bb525fcaefff3.

    Reported-by: Patrice Chotard
    Cc: AKASHI Takahiro
    Cc: Thomas RIENOESSL
    Signed-off-by: Tom Rini

    Tom Rini
     

31 Dec, 2018

2 commits

  • The call to file_cbfs_fill_cache() is given with the parameter
    'start' pointing to the offset by the CBFS base address, but
    with the parameter 'size' that equals to the whole CBFS size.
    During CBFS walking through, it checks files one by one and
    after it pass over the end of the CBFS which is 4GiB boundary
    it tries to check files from address 0 and so on, until the
    overall size the codes checked hits to the given 'size'.

    Fix this by passing 'start' pointing to the CBFS base address.

    Signed-off-by: Bin Meng
    Reviewed-by: Simon Glass

    Bin Meng
     
  • cbfs_fileheader.len indicates the content size of the file in the
    cbfs, and it has nothing to do with cbfs_fileheader.offset which
    is the starting address of the file in the cbfs.

    Remove such check in file_cbfs_next_file(). Before this change
    'cbfsinit' failed with 'Bad CBFS file'. After this change all cbfs
    commands are working as expected.

    Signed-off-by: Christian Gmeiner
    [bmeng: keep the necessary header sanity check]
    Signed-off-by: Bin Meng
    Reviewed-by: Simon Glass

    Christian Gmeiner
     

07 Dec, 2018

2 commits

  • The long name apparently can be accumulated using multiple
    13-byte slots. Unfortunately we never checked how many we
    can actually fit in the buffer we are reading to.

    Signed-off-by: Patrick Wildt

    Patrick Wildt
     
  • The cluster size specifies how many sectors make up a cluster. A
    cluster size of zero makes no sense, as it would mean that the
    cluster is made up of no sectors. This will later lead into a
    division by zero in sect_to_clust(), so better take care of that
    early.

    The MAX_CLUSTSIZE define can reduced using a define to make some
    room in low-memory system. Unfortunately if the code reads a
    filesystem with a bigger cluster size it will overflow the buffer.

    Signed-off-by: Patrick Wildt

    Patrick Wildt
     

03 Dec, 2018

1 commit

  • As in the case of fs_set_blk_dev(), fs_set_blk_dev_with_part() should
    maintain and update fs_dev_part whenever called.

    Without this patch, a problem will come up when an efi binary associated
    with efi's BOOTxxxx variable is invoked via "bootefi bootmgr".

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     

21 Nov, 2018

1 commit


17 Nov, 2018

1 commit


07 Nov, 2018

1 commit

  • Add local size_t variable to crypto_comp_decompress as intermediate
    storage for destination length to avoid memory corruption and incorrect
    results on 64 bit targets.

    This is what linux does for the various lz compression implementations.

    Signed-off-by: Paul Davey
    Cc: Heiko Schocher
    Tested-by: Heiko Schocher

    Paul Davey
     

16 Oct, 2018

1 commit


09 Oct, 2018

1 commit

  • When traversing slots in a btree (via btrfs_path) with btrfs_next_slot(),
    we didn't correctly identify that the last slot in the leaf was reached
    and we should jump to the next leaf.

    This could lead to any kind of runtime errors or corruptions, like:
    * file data not being read at all, or is read partially
    * file is read but is corrupted
    * (any) metadata being corrupted or not read at all, etc

    The easiest way to reproduce this is to read a large enough file that
    its EXTENT_DATA items don't fit into a single leaf.

    Signed-off-by: Yevgeny Popovych
    Cc: Marek Behun
    Tested-by: Marek Behún

    Yevgeny Popovych
     

07 Oct, 2018

2 commits


01 Oct, 2018

1 commit

  • The btrfs implementation passes cache-unaligned buffers into the
    block layer, which triggers cache alignment problems down in the
    block device drivers. Align the buffers to prevent this.

    Signed-off-by: Marek Vasut
    Cc: Marek Behun

    Marek Vasut
     

24 Sep, 2018

13 commits

  • The FAT driver supports unaligned reads and writes and EFI applications
    will make use of these. So a misaligned buffer is only worth a debug
    message.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • In this patch, unlink support is added to FAT file system.
    A directory can be deleted only if it is empty.

    In this implementation, only a directory entry for a short file name
    will be removed. So entries for a long file name can and should be
    reclaimed with fsck.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • "unlink" interface is added to file operations.
    This is a preparatory change as unlink support for FAT file system
    will be added in next patch.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • In this patch, mkdir support is added to FAT file system.
    A newly created directory contains only "." and ".." entries.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • The starting cluster number of directory is needed to initialize ".."
    (parent directory) entry when creating a new directory.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • "mkdir" interface is added to file operations.
    This is a preparatory change as mkdir support for FAT file system
    will be added in next patch.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • In this patch, all the necessary code for allowing for a file offset
    at write is implemented. What plays a major roll here is get_set_cluster(),
    which, in contrast to its counterpart, set_cluster(), only operates on
    already-allocated clusters, overwriting with data.

    So, with a file offset specified, set_contents() seeks and writes data
    with set_get_cluster() until the end of a file, and, once it reaches
    there, continues writing with set_cluster() for the rest.

    Please note that a file will be trimmed as a result of write operation if
    write ends before reaching file's end. This is an intended behavior
    in order to maintain compatibility with the current interface.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • The current write implementation is quite simple: remove existing clusters
    and then allocating new ones and filling them with data. This, inevitably,
    enforces always writing from the beginning of a file.

    As the first step to lift this restriction, fat_file_write() and
    set_contents() are modified to accept an additional parameter, file offset
    and further re-factored so that, in the next patch, all the necessary code
    will be put into set_contents().

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • In this patch, write implementation is overhauled and rewritten by
    making full use of directory iterator. The obvious bonus is that we are
    now able to write to a file with a directory path, like /A/B/C/FILE.

    Please note that, as there is no notion of "current directory" on u-boot,
    a file name specified must contain an absolute directory path. Otherwise,
    "/" (root directory) is assumed.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • It would be good that FAT write function return error code instead of
    just returning -1 as fat_read_file() does.
    This patch attempts to address this issue although it is 'best effort
    (or estimate)' for now.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • FAT file system's long file name support is a bit complicated and has some
    restrictions on its naming. We should be careful about it especially for
    write as it may easily end up with wrong file system.

    normalize_longname() check for the rules and normalize a file name
    if necessary. Please note, however, that this function is yet to be
    extended to fully comply with the standard.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • This reverts commit 0dc1bfb7302d220a48364263d5632d6d572b069b.
    The succeeding patch series will supersede it.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • In my attempt to re-work write operation, it was revealed that iterator's
    "clust" does not always point to a cluster to which a current directory
    entry ("dent") belongs.
    This patch assures that it is always true by adding "next_clust" which is
    used solely for dereferencing a cluster chain.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro