Commit Graph

35325 Commits

Author SHA1 Message Date
Chris Johns
6b2c5b5da1 testsuite: Fix gcc 12 warnings 2022-06-21 10:21:13 +10:00
Sebastian Huber
775314d57f jffs2: Update baseline version to Linux v5.9 2022-06-20 13:25:32 +02:00
Gustavo A. R. Silva
413a00db20 treewide: Use fallthrough pseudo-keyword
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

[1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2022-06-20 13:25:32 +02:00
Zhe Li
998ec9f545 jffs2: fix jffs2 mounting failure
Thanks for the advice mentioned in the email.
This is my v3 patch for this problem.

Mounting jffs2 on nand flash will get message "failed: I/O error"
with the steps listed below.
1.umount jffs2
2.erase nand flash
3.mount jffs2 on it (this mounting operation will be successful)
4.do chown or chmod to the mount point directory
5.umount jffs2
6.mount jffs2 on nand flash
After step 6, we will get message "mount ... failed: I/O error".

Typical image of this problem is like:
Empty space found from 0x00000000 to 0x008a0000
Inode node at xx, totlen 0x00000044, #ino 1, version 1, isize 0...

The reason for this mounting failure is that at the end of function
jffs2_scan_medium(), jffs2 will check the used_size and some info
of nr_blocks.If conditions are met, it will return -EIO.

The detail is that, in the steps listed above, step 4 will write
jffs2_raw_inode into flash without jffs2_raw_dirent, which will
cause that there are some jffs2_raw_inode but no jffs2_raw_dirent
on flash. This will meet the condition at the end of function
jffs2_scan_medium() and return -EIO if we umount jffs2 and mount it
again.

We notice that jffs2 add the value of c->unchecked_size if we find
an inode node while mounting. And jffs2 will never add the value of
c->unchecked_size in other situations. So this patch add one more
condition about c->unchecked_size of the judgement to fix this problem.

Signed-off-by: Zhe Li <lizhe67@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
2022-06-20 13:25:32 +02:00
Kees Cook
e839daff5b treewide: Remove uninitialized_var() usage
Using uninitialized_var() is dangerous as it papers over real bugs[1]
(or can in the future), and suppresses unrelated compiler warnings
(e.g. "unused variable"). If the compiler thinks it is uninitialized,
either simply initialize the variable or make compiler changes.

In preparation for removing[2] the[3] macro[4], remove all remaining
needless uses with the following script:

git grep '\buninitialized_var\b' | cut -d: -f1 | sort -u | \
	xargs perl -pi -e \
		's/\buninitialized_var\(([^\)]+)\)/\1/g;
		 s:\s*/\* (GCC be quiet|to make compiler happy) \*/$::g;'

drivers/video/fbdev/riva/riva_hw.c was manually tweaked to avoid
pathological white-space.

No outstanding warnings were found building allmodconfig with GCC 9.3.0
for x86_64, i386, arm64, arm, powerpc, powerpc64le, s390x, mips, sparc64,
alpha, and m68k.

[1] https://lore.kernel.org/lkml/20200603174714.192027-1-glider@google.com/
[2] https://lore.kernel.org/lkml/CA+55aFw+Vbj0i=1TGqCR5vQkCzWJ0QxK6CernOU6eedsudAixw@mail.gmail.com/
[3] https://lore.kernel.org/lkml/CA+55aFwgbgqhbp1fkxvRKEpzyR5J8n1vKT1VZdz9knmPuXhOeg@mail.gmail.com/
[4] https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/

Reviewed-by: Leon Romanovsky <leonro@mellanox.com> # drivers/infiniband and mlx4/mlx5
Acked-by: Jason Gunthorpe <jgg@mellanox.com> # IB
Acked-by: Kalle Valo <kvalo@codeaurora.org> # wireless drivers
Reviewed-by: Chao Yu <yuchao0@huawei.com> # erofs
Signed-off-by: Kees Cook <keescook@chromium.org>
2022-06-20 13:25:32 +02:00
Gustavo A. R. Silva
109815a82e jffs2: Replace zero-length array with flexible-array
There is a regular need in the kernel to provide a way to declare having a
dynamically sized set of trailing elements in a structure. Kernel code should
always use “flexible array members”[1] for these cases. The older style of
one-element or zero-length arrays should no longer be used[2].

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://github.com/KSPP/linux/issues/21

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
2022-06-20 13:25:32 +02:00
Joel Stanley
44cd706c96 Revert "jffs2: Fix possible null-pointer dereferences in jffs2_add_frag_to_fragtree()"
This reverts commit f2538f999345405f7d2e1194c0c8efa4e11f7b3a. The patch
stopped JFFS2 from being able to mount an existing filesystem with the
following errors:

 jffs2: error: (77) jffs2_build_inode_fragtree: Add node to tree failed -22
 jffs2: error: (77) jffs2_do_read_inode_internal: Failed to build final fragtree for inode #5377: error -22

Fixes: f2538f999345 ("jffs2: Fix possible null-pointer dereferences...")
Cc: stable@vger.kernel.org
Suggested-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Richard Weinberger <richard@nod.at>
2022-06-20 13:25:32 +02:00
Wenwen Wang
e1a5720264 jffs2: Fix memory leak in jffs2_scan_eraseblock() error path
In jffs2_scan_eraseblock(), 'sumptr' is allocated through kmalloc() if
'sumlen' is larger than 'buf_size'. However, it is not deallocated in the
following execution if jffs2_fill_scan_buf() fails, leading to a memory
leak bug. To fix this issue, free 'sumptr' before returning the error.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
Signed-off-by: Richard Weinberger <richard@nod.at>
2022-06-20 13:25:32 +02:00
Christoph Hellwig
cdac3ca64a jffs2: Remove jffs2_gc_fetch_page and jffs2_gc_release_page
Merge these two helpers into the only callers to get rid of some
amazingly bad calling conventions.

Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
2022-06-20 13:25:32 +02:00
Jia-Ju Bai
9d9bfe5948 jffs2: Fix possible null-pointer dereferences in jffs2_add_frag_to_fragtree()
In jffs2_add_frag_to_fragtree(), there is an if statement on line 223 to
check whether "this" is NULL:
    if (this)

When "this" is NULL, it is used at several places, such as on line 249:
    if (this->node)
and on line 260:
    if (newfrag->ofs > this->ofs)

Thus possible null-pointer dereferences may occur.

To fix these bugs, -EINVAL is returned when "this" is NULL.

These bugs are found by a static analysis tool STCheck written by us.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
2022-06-20 13:25:32 +02:00
Masahiro Yamada
b33c3d4b67 jffs2: Remove C++ style comments from uapi header
Linux kernel tolerates C++ style comments these days. Actually, the
SPDX License tags for .c files start with //.

On the other hand, uapi headers are written in more strict C, where
the C++ comment style is forbidden.

I simply dropped these lines instead of fixing the comment style.

This code has been always commented out since it was added around
Linux 2.4.9 (i.e. commented out for more than 17 years).

'Maybe later...' will never happen.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
2022-06-20 13:25:32 +02:00
Al Viro
22e83b00f5 jffs2: fix use-after-free on symlink traversal
free the symlink body after the same RCU delay we have for freeing the
struct inode itself, so that traversal during RCU pathwalk wouldn't step
into freed memory.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2022-06-20 13:25:32 +02:00
Matthew Wilcox
55529cf3d0 Convert jffs2 acl to struct_size
Need to tell the compiler that the acl entries follow the acl header.

Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
2022-06-20 13:25:32 +02:00
Sebastian Huber
f44ecd0ea9 jffs2: Use RTEMS_CONTAINER_OF 2022-06-20 13:25:32 +02:00
Chris Johns
e70384d3f4 aarch64/gicv3: Remove accesses to secure registers
RTEMS runs at EL1 and the removed register accesses are for
EL3 or the TF-A. This change aligns our driver with the Linux
and FreeBSD ones.
2022-06-16 10:21:46 +10:00
Chris Johns
4f6c90f40d bsps/versal: Support a 64bit RAM base
Set the constraint to be 64bits to allow the complete address range.
2022-06-16 10:21:46 +10:00
Chris Johns
bfc99a6e70 bsp/aarch64: Flush the cache before invalidating it
- Any page tables need to be flushed if the cache is enabled.
  Disabling the cache may only be available in secure mode.
2022-06-16 10:21:46 +10:00
Joel Sherrill
d6ebf4067e bsps/shared/*: Change license to BSD-2
Updates #3053.
2022-06-15 12:35:18 -05:00
Chris Johns
cb52e37464 bsps/arm: MP core timer setting off by one 2022-06-15 13:15:15 +10:00
Chris Johns
acc32a8e5c cpukit: Fixes for GCC 12 warnings
Updates #6442
2022-06-15 13:01:03 +10:00
Chris Johns
0cf0914efe cpukit: Change _COMPILING_NEWLIB to _LIBC for helper functions decls
Updates #4662
2022-06-15 13:00:48 +10:00
Chris Johns
5262b9c2ab score/cpu: Silence ARM and AARCH64 GCC 12 false trigger array warning
The false trigger is covered in:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578

GCC 11 and 12 has been patched for constant pointer casts above
4K. This code casts a constant pointer within the first 4K
page. As a result the patch disables the warning.

Updates #4662
2022-06-15 12:57:28 +10:00
Joel Sherrill
1f23640a9b sptests/spglobalcon01/init.cc: Change license to BSD-2
Updates #3053.
2022-06-14 10:31:39 -05:00
Joel Sherrill
3a22252782 samples/iostream/init.cc: Change license to BSD-2
Updates #3053.
2022-06-14 10:31:39 -05:00
Joel Sherrill
59a79edb95 sptests/*/*.doc: Change license to BSD-2
Updates #3053.
2022-06-14 10:31:39 -05:00
Joel Sherrill
7c6ff958e9 mptests/*/*.doc: Change license to BSD-2
Updates #3053.
2022-06-14 10:31:39 -05:00
Joel Sherrill
031f8fbcdc smptests/*/*.doc: Change license to BSD-2
Updates #3053.
2022-06-14 10:31:39 -05:00
Joel Sherrill
dcbba7c0e6 psxtmtests/*/*.doc: Change license to BSD-2
Updates #3053.
2022-06-14 10:31:39 -05:00
Joel Sherrill
731607b3b3 samples/*/*.doc: Change license to BSD-2
Updates #3053.
2022-06-14 10:31:39 -05:00
Joel Sherrill
f98b739119 smptests/*/*.py: Change license to BSD-2
Manually adjusted location of SPDX annotation so #! remains first line.

Updates #3053.
2022-06-14 10:31:39 -05:00
Christian Mauderer
b60d8327ac bsps/atsam: Fix type of options (part 2)
The patch "bsps/atsam: Fix type of options" missed to adapt some parts
of the yml. With that a custom value works well. But if no value is set,
configure doesn't fall back to the default value but instead just causes
an error. This patch fixes that.
2022-06-14 08:14:39 +02:00
Chris Johns
66dc06efce bsp/aarch64: Fix array warning
Updates #4664
2022-06-11 12:08:49 +10:00
Karel Gardas
ae2367c505 bsps/stm32h7: remove external memory initialization from nucleo-h743zi BSP
Nucleo board does not provide any external memory so code does not have
any function here anyway.

Sponsored-By:	Precidata
2022-06-10 11:17:17 +02:00
Karel Gardas
e5e1c00491 bsps/stm32h7: move BSP start hooks into boards subdirectories
The idea here is to prepare for better per-board specialization
of the hooks function code.

Sponsored-By:	Precidata
2022-06-10 11:17:17 +02:00
Karel Gardas
d7f3918d13 bsps/arm: fix installation of core_cm4.h 2022-06-10 11:15:08 +02:00
Gabriel Moyano
11621c9c52 kern_tc.c: Update pps_event() for uniprocessor configurations
Since pps->capgen equal to zero is not a special value in uniprocessor configurations, there is no need to check for this condition.

Update #2349
2022-06-10 11:12:03 +02:00
Christian Mauderer
7ba1503661 bsps/imx: Enable clock of ETH2 2022-06-09 09:04:40 +02:00
Matt Joyce
4152157e10 Newlib01: Add tests for rand() and lrand48()
Check that the state of rand() and lrand48() is thread-specific,
that they are properly initialized, and return the expected
sequence of pseudo-random numbers for default seed values.
2022-06-09 08:10:19 +02:00
Chris Johns
80aea6aee1 testsuite/libtests: Add exit03 to test exit() with C++
Updates #4661
2022-06-09 11:41:21 +10:00
Sebastian Huber
75af80a682 arm/lpc32xx: Implement new interrupt directives 2022-06-08 10:25:41 +02:00
Sebastian Huber
8d6190129a bsp/lpc32xx: bsp_interrupt_vector_enable()
The interrupt enables are used to implement a priority scheme in
bsp_interrupt_dispatch().  Enable interrupts through
bsp_interrupt_vector_enable() only if they are not already enabled to
not interfere with the priority scheme while
bsp_interrupt_vector_enable() is called during interrupt dispatching.
2022-06-08 10:25:41 +02:00
Sebastian Huber
4d0d7d5413 bsp/lpc32xx: bsp_interrupt_is_valid_vector()
Provide custom bsp_interrupt_is_valid_vector() implementation since
several interrupt vectors are reserved.
2022-06-08 10:25:41 +02:00
Sebastian Huber
88a53ca682 bsp/lpc32xx: Use standard timer 2 for tm27.h
This helps to run the validation tests of the Interrupt Manager
directives.
2022-06-08 10:25:37 +02:00
Sebastian Huber
5dc5ab5650 arm/lpc32xx: Hide MLC details 2022-06-08 09:33:20 +02:00
Sebastian Huber
bb29f8b5ff bsp/lpc32xx: Fix FIQ interrupt support
Do not sporadically service interrupts configured as FIQ by the IRQ
interrupt dispatch.
2022-06-08 09:33:20 +02:00
Sebastian Huber
9a69e43083 validation: Fix CallWithinISR()
Some BSPs require that Clear_tm27_intr() is called in the interrupt
service routine.

Update #3269.
2022-06-08 09:33:20 +02:00
Sebastian Huber
c93f0f01e5 arm: Fix PMSA regions for contiguous sections
Sections with identical attributes may be contiguous with a respective
begin and end address which is not on a minimum region boundary.  The
begin address is aligned down to the region base address.  The end
address is aligned up to the region end address.  Account for this in
the check for contiguous sections.

Update #4202.
2022-06-08 09:10:20 +02:00
Sebastian Huber
0b9497a6dd arm: Fix PMSA region mapping with 0x0 end address
A section may span up to the end of the address range.  In this case the
end address is zero.  Use the base address to check if a region should
be before another region.

Update #4202.
2022-06-08 09:10:12 +02:00
Sebastian Huber
ed51fad53a build: Assert value properties only if not None 2022-06-08 09:08:26 +02:00
Christian Mauderer
8beb1d2fb0 bsps/atsam: Fix type of options
ATSAM_CONSOLE_DEVICE_INDEX and ATSAM_CONSOLE_DEVICE_TYPE have to be
integers like suggested by their description. Otherwise it's not
possible to select (for example) USART2 as console device.
2022-06-07 08:31:26 +02:00