Re: [PATCH v2 17/19] commands: md: Do not use memmap()

2019-02-04 Thread Andrey Smirnov
On Mon, Feb 4, 2019 at 5:57 AM Sascha Hauer wrote: > > On Mon, Jan 28, 2019 at 10:55:47PM -0800, Andrey Smirnov wrote: > > Codepaths using memmap() in md.c don't do any boundary checks, so it > > can be easily made to read past the underlying file's > > boundary. For example on i.MX8MQ based board

[PATCH 2/5] fs: set errno in ftruncate()

2019-02-04 Thread Sascha Hauer
ftruncate needs to set errno correctly on error. Signed-off-by: Sascha Hauer --- fs/fs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/fs.c b/fs/fs.c index 4ec9c7a842..c5b17e158a 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -216,8 +216,10 @@ int ftruncate(int fd, loff_t leng

[PATCH 4/5] fs: devfs: forbid truncation when cdev has no truncate operation

2019-02-04 Thread Sascha Hauer
When a cdev doesn't have a truncate callback then forbid truncation and fail with -EPERM. Before this we had always failed with -ENOSPC in this situation. We checked for f->fsdev->dev.num_resources being nonzero, but this check was absolutely meaningless. It goes back to ancient times when the reso

[PATCH 0/5] 32-bit lseek and /dev/mem fixes/improvements

2019-02-04 Thread Sascha Hauer
This series ontop of Andreys series (minus the patches that I have reverted) makes /dev/mem work for the whole 64bit address space without hopefully special casing too much. "fs: set errno in ftruncate()" and "fs: devfs: forbid truncation when cdev has no truncate operation" are not directly relate

[PATCH 5/5] misc: fix /dev/mem size

2019-02-04 Thread Sascha Hauer
The size of /dev/mem was limited to the lower half of the 64bit address range. This is unfortunate since on some architectures (MIPS64, namely) the upper half contains meaningful addresses. We can't just set /dev/mem to its real size since that's bigger than the maximum loff_t. Set the DEVFS_IS_CHA

[PATCH 1/5] fs: let truncate take a loff_t argument

2019-02-04 Thread Sascha Hauer
loff_t is the correct type for file sizes. Use it to allow to truncate to sizes bigger than 32bit. Signed-off-by: Sascha Hauer --- fs/devfs.c | 2 +- fs/efi.c | 2 +- fs/efivarfs.c| 2 +- fs/fat/fat.c | 2 +- fs/nfs.c | 2 +- fs/omap4_usbbootfs.c

[PATCH 3/5] fs: do not call truncate for FILE_SIZE_STREAM sized files

2019-02-04 Thread Sascha Hauer
open_and_lseek() increases the file size when the file is opened in write mode and scrolled past the files end. This fails badly on /dev/mem because loff_t which we use for the file size is signed variable, which is used as an unsigned variable in /dev/mem. To catch this case do not try to truncate

Re: [PATCH v2 10/19] fs: devfs: Change .lseek callbacks to return 'int'

2019-02-04 Thread Sascha Hauer
On Mon, Jan 28, 2019 at 10:55:40PM -0800, Andrey Smirnov wrote: > Returning requested offset from .lseek() callback doesn't really give > us any new information while bringing unnecessary > complications. Change all .lseek() types (both in struct struct > cdev_operations and in struct fs_driver_d)

Re: [PATCH v2 17/19] commands: md: Do not use memmap()

2019-02-04 Thread Sascha Hauer
On Mon, Jan 28, 2019 at 10:55:47PM -0800, Andrey Smirnov wrote: > Codepaths using memmap() in md.c don't do any boundary checks, so it > can be easily made to read past the underlying file's > boundary. For example on i.MX8MQ based board with 4GiB or RAM we get: > > md -b -s /dev/ram0 0xfff0 >

[PATCH] dts: Revert at91 switch to new PMC clock bindings

2019-02-04 Thread Ladislav Michl
Recent DTS update brought in switch to the new PMC clock bindings, however we do not support that yet. Revert this change until PMC clock bindings support is implemented. Fixes: 33fdc89d4cbd ("dts: update to v5.0-rc1") Signed-off-by: Ladislav Michl --- Disclaimer: Runtime tested only on at91sam9

Re: [HELP] DT isues

2019-02-04 Thread Seraphim Dolbilov
Hello friends, I'm trying to modify DT dynamically while Barebox is running, but it doesn't work the way I expect. E.g. I use of_delete_node(), but `of_dump` shows all nodes that are expected to be deleted, so the corresponding devices are available both from Barebox and Linux. So is there any w