platform/kernel/linux-starfive.git
17 months agoudf: remove reporting loc in debug output
Tom Rix [Fri, 27 Jan 2023 16:29:06 +0000 (08:29 -0800)]
udf: remove reporting loc in debug output

clang build fails with
fs/udf/partition.c:86:28: error: variable 'loc' is uninitialized when used here [-Werror,-Wuninitialized]
                          sb, block, partition, loc, index);
                                                ^~~

loc is now only known when bh is valid. So remove reporting loc in debug
output.

Fixes: 4215db46d538 ("udf: Use udf_bread() in udf_get_pblock_virt15()")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: "kernelci.org bot" <bot@kernelci.org>
Signed-off-by: Tom Rix <trix@redhat.com>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Check consistency of Space Bitmap Descriptor
Vladislav Efanov [Thu, 2 Feb 2023 14:04:56 +0000 (17:04 +0300)]
udf: Check consistency of Space Bitmap Descriptor

Bits, which are related to Bitmap Descriptor logical blocks,
are not reset when buffer headers are allocated for them. As the
result, these logical blocks can be treated as free and
be used for other blocks.This can cause usage of one buffer header
for several types of data. UDF issues WARNING in this situation:

WARNING: CPU: 0 PID: 2703 at fs/udf/inode.c:2014
  __udf_add_aext+0x685/0x7d0 fs/udf/inode.c:2014

RIP: 0010:__udf_add_aext+0x685/0x7d0 fs/udf/inode.c:2014
Call Trace:
 udf_setup_indirect_aext+0x573/0x880 fs/udf/inode.c:1980
 udf_add_aext+0x208/0x2e0 fs/udf/inode.c:2067
 udf_insert_aext fs/udf/inode.c:2233 [inline]
 udf_update_extents fs/udf/inode.c:1181 [inline]
 inode_getblk+0x1981/0x3b70 fs/udf/inode.c:885

Found by Linux Verification Center (linuxtesting.org) with syzkaller.

[JK: Somewhat cleaned up the boundary checks]

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Vladislav Efanov <VEfanov@ispras.ru>
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Fix file counting in LVID
Jan Kara [Wed, 25 Jan 2023 18:31:38 +0000 (19:31 +0100)]
udf: Fix file counting in LVID

numFiles entry in LVID should actually contain number for non-dir file
entries, not the number of non-dir inodes. Move the counting from inode
allocation / deallocation into directory entry handling functions.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Limit file size to 4TB
Jan Kara [Wed, 25 Jan 2023 16:56:06 +0000 (17:56 +0100)]
udf: Limit file size to 4TB

UDF disk format supports in principle file sizes up to 1<<64-1. However
the file space (including holes) is described by a linked list of
extents, each of which can have at most 1GB. Thus the creation and
handling of extents gets unusably slow beyond certain point. Limit the
file size to 4TB to avoid locking up the kernel too easily.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Don't return bh from udf_expand_dir_adinicb()
Jan Kara [Tue, 24 Jan 2023 13:49:52 +0000 (14:49 +0100)]
udf: Don't return bh from udf_expand_dir_adinicb()

Nobody uses the bh returned from udf_expand_dir_adinicb(). Don't return
it.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Convert udf_expand_file_adinicb() to avoid kmap_atomic()
Jan Kara [Wed, 25 Jan 2023 09:33:37 +0000 (10:33 +0100)]
udf: Convert udf_expand_file_adinicb() to avoid kmap_atomic()

Remove the last two remaining kmap_atomic() uses in UDF in
udf_expand_file_adinicb(). The first use can be actually conveniently
replaced with udf_adinicb_readpage(), the second with memcpy_to_page().

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Convert udf_adinicb_writepage() to memcpy_to_page()
Jan Kara [Wed, 25 Jan 2023 09:23:33 +0000 (10:23 +0100)]
udf: Convert udf_adinicb_writepage() to memcpy_to_page()

Instead of mapping the page manually with kmap() atomic, use helper
memcpy_to_page(). Also delete the pointless SetPageUptodate() call.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Switch udf_adinicb_readpage() to kmap_local_page()
Jan Kara [Tue, 24 Jan 2023 11:35:45 +0000 (12:35 +0100)]
udf: Switch udf_adinicb_readpage() to kmap_local_page()

Instead of using kmap_atomic() use kmap_local_page() in
udf_adinicb_readpage().

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Move udf_adinicb_readpage() to inode.c
Jan Kara [Tue, 24 Jan 2023 11:29:57 +0000 (12:29 +0100)]
udf: Move udf_adinicb_readpage() to inode.c

udf_adinicb_readpage() is only called from aops functions, move it to
the same file as its callers and also drop the stale comment -
invalidate_lock is protecting us against races with truncate.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Mark aops implementation static
Jan Kara [Tue, 24 Jan 2023 11:25:46 +0000 (12:25 +0100)]
udf: Mark aops implementation static

Mark functions implementing aops static since they are not needed
outside of inode.c anymore.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Switch to single address_space_operations
Jan Kara [Tue, 24 Jan 2023 11:23:04 +0000 (12:23 +0100)]
udf: Switch to single address_space_operations

Now that udf_aops and udf_adiniicb_aops are functionally identical, just
drop udf_adiniicb_aops.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Add handling of in-ICB files to udf_bmap()
Jan Kara [Tue, 24 Jan 2023 11:16:38 +0000 (12:16 +0100)]
udf: Add handling of in-ICB files to udf_bmap()

Add detection of in-ICB files to udf_bmap() and return error in that
case. This will allow us o use single address_space_operations in UDF.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Convert all file types to use udf_write_end()
Jan Kara [Tue, 24 Jan 2023 11:13:57 +0000 (12:13 +0100)]
udf: Convert all file types to use udf_write_end()

Switching address_space_operations while a file is used is difficult to
do in a race-free way. To be able to use single address_space_operations
in UDF, create udf_write_end() function that is able to handle both
normal and in-ICB files.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Convert in-ICB files to use udf_write_begin()
Jan Kara [Tue, 24 Jan 2023 11:07:37 +0000 (12:07 +0100)]
udf: Convert in-ICB files to use udf_write_begin()

Switching address_space_operations while a file is used is difficult to
do in a race-free way. To be able to use single address_space_operations
in UDF, make in-ICB files use udf_write_begin().

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Convert in-ICB files to use udf_direct_IO()
Jan Kara [Tue, 24 Jan 2023 10:59:32 +0000 (11:59 +0100)]
udf: Convert in-ICB files to use udf_direct_IO()

Switching address_space_operations while a file is used is difficult to
do in a race-free way. To be able to use single address_space_operations
in UDF, make in-ICB files use udf_direct_IO().

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Convert in-ICB files to use udf_writepages()
Jan Kara [Tue, 24 Jan 2023 10:54:08 +0000 (11:54 +0100)]
udf: Convert in-ICB files to use udf_writepages()

Switching address_space_operations while a file is used is difficult to
do in a race-free way. To be able to use single address_space_operations
in UDF, make in-ICB files use udf_writepages().

Reported-by: syzbot+c27475eb921c46bbdc62@syzkaller.appspotmail.com
Reported-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Unify .read_folio for normal and in-ICB files
Jan Kara [Tue, 24 Jan 2023 10:40:28 +0000 (11:40 +0100)]
udf: Unify .read_folio for normal and in-ICB files

Switching address_space_operations while a file is used is difficult to
do in a race-free way. To be able to use single address_space_operations
in UDF, make udf_read_folio() handle both normal and in-ICB files.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Fix off-by-one error when discarding preallocation
Jan Kara [Mon, 23 Jan 2023 13:29:15 +0000 (14:29 +0100)]
udf: Fix off-by-one error when discarding preallocation

The condition determining whether the preallocation can be used had
an off-by-one error so we didn't discard preallocation when new
allocation was just following it. This can then confuse code in
inode_getblk().

CC: stable@vger.kernel.org
Fixes: 16d055656814 ("udf: Discard preallocation before extending file with a hole")
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Fix file corruption when appending just after end of preallocated extent
Jan Kara [Mon, 23 Jan 2023 13:18:47 +0000 (14:18 +0100)]
udf: Fix file corruption when appending just after end of preallocated extent

When we append new block just after the end of preallocated extent, the
code in inode_getblk() wrongly determined we're going to use the
preallocated extent which resulted in adding block into a wrong logical
offset in the file. Sequence like this manifests it:

xfs_io -f -c "pwrite 0x2cacf 0xd122" -c "truncate 0x2dd6f" \
  -c "pwrite 0x27fd9 0x69a9" -c "pwrite 0x32981 0x7244" <file>

The code that determined the use of preallocated extent is actually
stale because udf_do_extend_file() does not create preallocation anymore
so after calling that function we are sure there's no usable
preallocation. Just remove the faulty condition.

CC: stable@vger.kernel.org
Fixes: 16d055656814 ("udf: Discard preallocation before extending file with a hole")
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Do not allocate blocks on page writeback
Jan Kara [Wed, 18 Jan 2023 14:09:49 +0000 (15:09 +0100)]
udf: Do not allocate blocks on page writeback

Now when we allocate blocks on write page fault there should be no block
allocation happening on page writeback. So just ignore the 'create' flag
passed to udf_get_block(). Note that we can spot dirty buffers without
underlying blocks allocated in writeback when we race with expanding
truncate. However in that case these buffers do not contain valid data
so we can safely ignore them and we would just create ourselves problem
when to trim the tail extent.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agofs: gracefully handle ->get_block not mapping bh in __mpage_writepage
Jan Kara [Wed, 25 Jan 2023 13:59:14 +0000 (14:59 +0100)]
fs: gracefully handle ->get_block not mapping bh in __mpage_writepage

When filesystem's ->get_block function does not map the buffer head when
called from __mpage_writepage(), the function will happily go and pass
bogus bdev and block number to bio allocation routines which leads to
crashes sooner or later. E.g. UDF can do this because it doesn't want to
allocate blocks from ->writepages callbacks. It allocates blocks on
write or page fault but writeback can still spot dirty buffers without
underlying blocks allocated e.g. if blocksize < pagesize, the tail page
is dirtied (which means all its buffers are dirtied), and truncate
extends the file so that some buffer starts to be within i_size.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Allocate blocks on write page fault
Jan Kara [Thu, 19 Jan 2023 09:51:21 +0000 (10:51 +0100)]
udf: Allocate blocks on write page fault

Currently if file with holes is mapped, udf allocates blocks for dirtied
pages during page writeback. This however creates problems when to
truncate final extent to proper size and currently we leave the last
extent untruncated which violates UDF standard. So allocate blocks on
write page fault instead. In that case the last extent gets truncated
the file is closed and everything is happy.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Protect truncate and file type conversion with invalidate_lock
Jan Kara [Thu, 19 Jan 2023 11:46:09 +0000 (12:46 +0100)]
udf: Protect truncate and file type conversion with invalidate_lock

Protect truncate and file type conversion in udf_file_write_iter() with
invalidate lock. That will allow us to serialize these paths with page
faults so that the page fault can determine the file type in a racefree
way.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Simplify error handling in udf_file_write_iter()
Jan Kara [Thu, 19 Jan 2023 11:44:34 +0000 (12:44 +0100)]
udf: Simplify error handling in udf_file_write_iter()

When udf_expand_file_adinicb() fails, we can now use the standard exit
path instead of implementing our own.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Push i_data_sem locking into udf_extend_file()
Jan Kara [Thu, 19 Jan 2023 11:37:04 +0000 (12:37 +0100)]
udf: Push i_data_sem locking into udf_extend_file()

Push i_data_sem locking into udf_extend_file(). It somewhat simplifies
the code around it.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Push i_data_sem locking into udf_expand_file_adinicb()
Jan Kara [Thu, 19 Jan 2023 11:28:37 +0000 (12:28 +0100)]
udf: Push i_data_sem locking into udf_expand_file_adinicb()

The checks we do in udf_setsize() and udf_file_write_iter() are safe to
do only with i_rwsem locked as it stabilizes both file type and file
size. Hence we don't need to lock i_data_sem before we enter
udf_expand_file_adinicb() which simplifies the locking somewhat.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Protect rename against modification of moved directory
Jan Kara [Wed, 18 Jan 2023 18:42:35 +0000 (19:42 +0100)]
udf: Protect rename against modification of moved directory

When we are renaming a directory to a different directory, we need to
update '..' entry in the moved directory. However nothing prevents moved
directory from being modified and even converted from the in-ICB format
to the normal format which results in a crash. Fix the problem by
locking the moved directory.

Reported-by: syzbot+aebf90eea2671c43112a@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Fold udf_getblk() into udf_bread()
Jan Kara [Wed, 18 Jan 2023 14:33:41 +0000 (15:33 +0100)]
udf: Fold udf_getblk() into udf_bread()

udf_getblk() has a single call site. Fold it there.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Use udf_map_block() in udf_getblk()
Jan Kara [Wed, 18 Jan 2023 14:30:06 +0000 (15:30 +0100)]
udf: Use udf_map_block() in udf_getblk()

Use the new function udf_map_block() in udf_getblk().

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Add flag to disable block preallocation
Jan Kara [Wed, 18 Jan 2023 14:18:41 +0000 (15:18 +0100)]
udf: Add flag to disable block preallocation

In some cases we don't want to create block preallocation when
allocating blocks. Add a flag to udf_map_rq controlling the behavior.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Pass mapping request into inode_getblk()
Jan Kara [Wed, 18 Jan 2023 13:57:34 +0000 (14:57 +0100)]
udf: Pass mapping request into inode_getblk()

Pass struct udf_map_rq into inode_getblk() instead of unfolding it and
the putting the results back.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Fold udf_block_map() into udf_map_block()
Jan Kara [Wed, 18 Jan 2023 13:38:35 +0000 (14:38 +0100)]
udf: Fold udf_block_map() into udf_map_block()

udf_block_map() has now only a single caller. Fold it there.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Convert udf_symlink_filler() to use udf_bread()
Jan Kara [Wed, 18 Jan 2023 13:32:45 +0000 (14:32 +0100)]
udf: Convert udf_symlink_filler() to use udf_bread()

Convert udf_symlink_filler() to use udf_bread() instead of mapping and
reading buffer head manually.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Do not call udf_block_map() on ICB files
Jan Kara [Wed, 18 Jan 2023 13:26:04 +0000 (14:26 +0100)]
udf: Do not call udf_block_map() on ICB files

Currently udf_symlink_filler() called udf_block_map() even on files
which have data stored inside the ICB. This is invalid as we cannot map
blocks for such files (although so far the error got silently ignored).
The call happened because we could not call block mapping function once
we've acquired i_data_sem and determined whether the file has data
stored in the ICB. For symlinks the situation is luckily simple as they
get never modified so file type never changes once it is set. Hence we
can check the file type even without i_data_sem. Just drop the
i_data_sem locking and move block mapping to where it is needed.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Use udf_bread() in udf_load_vat()
Jan Kara [Wed, 18 Jan 2023 13:08:10 +0000 (14:08 +0100)]
udf: Use udf_bread() in udf_load_vat()

Use udf_bread() instead of mapping and loadign buffer head manually in
udf_load_vat().

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Use udf_bread() in udf_get_pblock_virt15()
Jan Kara [Wed, 18 Jan 2023 12:41:12 +0000 (13:41 +0100)]
udf: Use udf_bread() in udf_get_pblock_virt15()

Use udf_bread() instead of mapping and reading buffer head manually in
udf_get_pblock_virt15().

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Factor out block mapping into udf_map_block()
Jan Kara [Wed, 18 Jan 2023 11:29:22 +0000 (12:29 +0100)]
udf: Factor out block mapping into udf_map_block()

Create new block mapping function udf_map_block() that takes new
udf_map_rq structure describing mapping request. We will convert other
places to use this function for block mapping.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Move incrementing of goal block directly into inode_getblk()
Jan Kara [Wed, 18 Jan 2023 11:05:58 +0000 (12:05 +0100)]
udf: Move incrementing of goal block directly into inode_getblk()

inode_getblk() sets goal block for the next allocation to the currently
allocated block. This is obviously one less than what the goal block
should be which we fixup in udf_get_block(). Just set the right goal
block directly in inode_getblk().

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Drop VARCONV support
Jan Kara [Wed, 18 Jan 2023 12:27:07 +0000 (13:27 +0100)]
udf: Drop VARCONV support

UDF was supporting a strange mode where the media was containing 7
blocks of unknown data for every 32 blocks of the filesystem. I have yet
to see the media that would need such conversion (maybe it comes from
packet writing times) and the conversions have been inconsistent in the
code. In particular any write will write to a wrong block and corrupt
the media. This is an indication and no user actually needs this so
let's just drop the support instead of trying to fix it.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Unify types in anchor block detection
Jan Kara [Wed, 18 Jan 2023 12:55:31 +0000 (13:55 +0100)]
udf: Unify types in anchor block detection

When detecting last recorded block and from it derived anchor block
position, we were mixing unsigned long, u32, and sector_t types. Since
udf supports only 32-bit block numbers this is harmless but sometimes
makes things awkward. Convert everything to udf_pblk_t and also handle
the situation when block device size would not fit into udf_pblk_t.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Fix directory iteration for longer tail extents
Jan Kara [Wed, 25 Jan 2023 10:43:03 +0000 (11:43 +0100)]
udf: Fix directory iteration for longer tail extents

When directory's last extent has more that one block and its length is
not multiple of a block side, the code wrongly decided to move to the
next extent instead of processing the last partial block. This led to
directory corruption. Fix the rounding issue.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Propagate errors from udf_advance_blk()
Jan Kara [Wed, 25 Jan 2023 10:46:19 +0000 (11:46 +0100)]
udf: Propagate errors from udf_advance_blk()

When we spot directory corruption when trying to load next directory
extent, we didn't propagate the error up properly, leading to possibly
indefinite looping on corrupted directories. Fix the problem by
propagating the error properly.

Signed-off-by: Jan Kara <jack@suse.cz>
17 months agoudf: Zero udf name padding
Jan Kara [Wed, 25 Jan 2023 15:49:00 +0000 (16:49 +0100)]
udf: Zero udf name padding

Padding of name in the directory entry needs to be zeroed out. Fix it.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoext2: propagate errors from ext2_prepare_chunk
Christoph Hellwig [Mon, 16 Jan 2023 08:52:05 +0000 (09:52 +0100)]
ext2: propagate errors from ext2_prepare_chunk

Propagate errors from ext2_prepare_chunk to the callers and handle them
there.  While touching the prototype also turn update_times into a bool
from the current int used as bool.

[JK: fixed up error recovery path in ext2_rename()]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Message-Id: <20230116085205.2342975-1-hch@lst.de>

18 months agoudf: remove redundant variable netype
Colin Ian King [Thu, 5 Jan 2023 13:49:25 +0000 (13:49 +0000)]
udf: remove redundant variable netype

The variable netype is assigned a value that is never read, the assignment
is redundant the variable can be removed.

Message-Id: <20230105134925.45599-1-colin.i.king@gmail.com>
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Detect system inodes linked into directory hierarchy
Jan Kara [Tue, 3 Jan 2023 09:03:35 +0000 (10:03 +0100)]
udf: Detect system inodes linked into directory hierarchy

When UDF filesystem is corrupted, hidden system inodes can be linked
into directory hierarchy which is an avenue for further serious
corruption of the filesystem and kernel confusion as noticed by syzbot
fuzzed images. Refuse to access system inodes linked into directory
hierarchy and vice versa.

CC: stable@vger.kernel.org
Reported-by: syzbot+38695a20b8addcbc1084@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Preserve link count of system files
Jan Kara [Tue, 3 Jan 2023 08:56:56 +0000 (09:56 +0100)]
udf: Preserve link count of system files

System files in UDF filesystem have link count 0. To not confuse VFS we
fudge the link count to be 1 when reading such inodes however we forget
to restore the link count of 0 when writing such inodes. Fix that.

CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Do not update file length for failed writes to inline files
Jan Kara [Mon, 2 Jan 2023 19:14:47 +0000 (20:14 +0100)]
udf: Do not update file length for failed writes to inline files

When write to inline file fails (or happens only partly), we still
updated length of inline data as if the whole write succeeded. Fix the
update of length of inline data to happen only if the write succeeds.

Reported-by: syzbot+0937935b993956ba28ab@syzkaller.appspotmail.com
CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Fix spelling mistake "lenght" -> "length"
Colin Ian King [Fri, 30 Dec 2022 23:14:52 +0000 (23:14 +0000)]
udf: Fix spelling mistake "lenght" -> "length"

There is a spelling mistake in a udf_err message. Fix it.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Message-Id: <20221230231452.5821-1-colin.i.king@gmail.com>

18 months agofs/ext2: Replace kmap_atomic() with kmap_local_page()
Fabio M. De Francesco [Sat, 31 Dec 2022 17:42:05 +0000 (18:42 +0100)]
fs/ext2: Replace kmap_atomic() with kmap_local_page()

kmap_atomic() is deprecated in favor of kmap_local_page(). Therefore,
replace kmap_atomic() with kmap_local_page().

kmap_atomic() is implemented like a kmap_local_page() which also disables
page-faults and preemption (the latter only for !PREEMPT_RT kernels).

However, the code within the mapping and un-mapping in ext2_make_empty()
does not depend on the above-mentioned side effects.

Therefore, a mere replacement of the old API with the new one is all it
is required (i.e., there is no need to explicitly add any calls to
pagefault_disable() and/or preempt_disable()).

Suggested-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Message-Id: <20221231174205.8492-1-fmdefrancesco@gmail.com>

18 months agoudf: Keep i_lenExtents consistent with the total length of extents
Jan Kara [Wed, 21 Dec 2022 16:53:28 +0000 (17:53 +0100)]
udf: Keep i_lenExtents consistent with the total length of extents

When rounding the last extent to blocksize in inode_getblk() we forgot
to update also i_lenExtents to match the new extent length. This
inconsistency can later confuse some assertion checks.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Move setting of i_lenExtents into udf_do_extend_file()
Jan Kara [Wed, 21 Dec 2022 11:18:23 +0000 (12:18 +0100)]
udf: Move setting of i_lenExtents into udf_do_extend_file()

When expanding file for a write into a hole, we were not updating total
length of inode's extents properly. Move the update of i_lenExtents into
udf_do_extend_file() so that both expanding of file by truncate and
expanding of file by writing beyond EOF properly update the length of
extents. As a bonus, we also correctly update the length of extents when
only part of extents can be written.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Allocate name buffer in directory iterator on heap
Jan Kara [Tue, 20 Dec 2022 11:38:45 +0000 (12:38 +0100)]
udf: Allocate name buffer in directory iterator on heap

Currently we allocate name buffer in directory iterators (struct
udf_fileident_iter) on stack. These structures are relatively large
(some 360 bytes on 64-bit architectures). For udf_rename() which needs
to keep three of these structures in parallel the stack usage becomes
rather heavy - 1536 bytes in total. Allocate the name buffer in the
iterator from heap to avoid excessive stack usage.

Link: https://lore.kernel.org/all/202212200558.lK9x1KW0-lkp@intel.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Handle error when adding extent to a file
Jan Kara [Mon, 19 Dec 2022 19:10:35 +0000 (20:10 +0100)]
udf: Handle error when adding extent to a file

When adding extent to a file fails, so far we've silently squelshed the
error. Make sure to propagate it up properly.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Handle error when adding extent to symlink
Jan Kara [Mon, 19 Dec 2022 18:54:12 +0000 (19:54 +0100)]
udf: Handle error when adding extent to symlink

When adding extent describing symlink data fails, make sure to handle
the error properly, propagate it up and free the already allocated
block.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Handle error when expanding directory
Jan Kara [Mon, 19 Dec 2022 18:50:14 +0000 (19:50 +0100)]
udf: Handle error when expanding directory

When there is an error when adding extent to the directory to expand it,
make sure to propagate the error up properly. This is not expected to
happen currently but let's make the code more futureproof.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Do not bother merging very long extents
Jan Kara [Fri, 16 Dec 2022 11:37:51 +0000 (12:37 +0100)]
udf: Do not bother merging very long extents

When merging very long extents we try to push as much length as possible
to the first extent. However this is unnecessarily complicated and not
really worth the trouble. Furthermore there was a bug in the logic
resulting in corrupting extents in the file as syzbot reproducer shows.
So just don't bother with the merging of extents that are too long
together.

CC: stable@vger.kernel.org
Reported-by: syzbot+60f291a24acecb3c2bd5@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Truncate added extents on failed expansion
Jan Kara [Thu, 15 Dec 2022 13:24:03 +0000 (14:24 +0100)]
udf: Truncate added extents on failed expansion

When a file expansion failed because we didn't have enough space for
indirect extents make sure we truncate extents created so far so that we
don't leave extents beyond EOF.

CC: stable@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Remove old directory iteration code
Jan Kara [Thu, 6 Oct 2022 14:44:53 +0000 (16:44 +0200)]
udf: Remove old directory iteration code

Remove old directory iteration code that is now unused.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Convert udf_rename() to new directory iteration code
Jan Kara [Thu, 6 Oct 2022 14:41:23 +0000 (16:41 +0200)]
udf: Convert udf_rename() to new directory iteration code

Convert udf_rename() to use new directory iteration code.

Reported-by: syzbot+0eaad3590d65102b9391@syzkaller.appspotmail.com
Reported-by: syzbot+b7fc73213bc2361ab650@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Convert udf_link() to new directory iteration code
Jan Kara [Thu, 6 Oct 2022 12:59:11 +0000 (14:59 +0200)]
udf: Convert udf_link() to new directory iteration code

Convert udf_link() to use new directory iteration code for adding entry
into the directory.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Convert udf_mkdir() to new directory iteration code
Jan Kara [Thu, 6 Oct 2022 12:22:33 +0000 (14:22 +0200)]
udf: Convert udf_mkdir() to new directory iteration code

Convert udf_mkdir() to new directory iteration code.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Convert udf_add_nondir() to new directory iteration
Jan Kara [Thu, 6 Oct 2022 12:08:59 +0000 (14:08 +0200)]
udf: Convert udf_add_nondir() to new directory iteration

Convert udf_add_nondir() to new directory iteration code.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Implement adding of dir entries using new iteration code
Jan Kara [Thu, 6 Oct 2022 11:25:16 +0000 (13:25 +0200)]
udf: Implement adding of dir entries using new iteration code

Implement function udf_fiiter_add_entry() adding new directory entries
using new directory iteration code.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Convert udf_unlink() to new directory iteration code
Jan Kara [Wed, 5 Oct 2022 17:36:49 +0000 (19:36 +0200)]
udf: Convert udf_unlink() to new directory iteration code

Convert udf_unlink() to new directory iteration code.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Convert udf_rmdir() to new directory iteration code
Jan Kara [Wed, 5 Oct 2022 17:33:23 +0000 (19:33 +0200)]
udf: Convert udf_rmdir() to new directory iteration code

Convert udf_rmdir() to use new directory iteration code.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Provide function to mark entry as deleted using new directory iteration code
Jan Kara [Wed, 5 Oct 2022 17:26:59 +0000 (19:26 +0200)]
udf: Provide function to mark entry as deleted using new directory iteration code

Provide function udf_fiiter_delete_entry() to mark directory entry as
deleted using new directory iteration code.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Convert empty_dir() to new directory iteration code
Jan Kara [Wed, 5 Oct 2022 17:10:02 +0000 (19:10 +0200)]
udf: Convert empty_dir() to new directory iteration code

Convert empty_dir() to new directory iteration code.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Convert udf_get_parent() to new directory iteration code
Jan Kara [Wed, 5 Oct 2022 16:48:45 +0000 (18:48 +0200)]
udf: Convert udf_get_parent() to new directory iteration code

Convert udf_get_parent() to use udf_fiiter_find_entry().

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Convert udf_lookup() to use new directory iteration code
Jan Kara [Wed, 5 Oct 2022 16:36:21 +0000 (18:36 +0200)]
udf: Convert udf_lookup() to use new directory iteration code

Convert udf_lookup() to use udf_fiiter_find_entry() for looking up
directory entries.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Implement searching for directory entry using new iteration code
Jan Kara [Wed, 5 Oct 2022 16:28:33 +0000 (18:28 +0200)]
udf: Implement searching for directory entry using new iteration code

Implement searching for directory entry - udf_fiiter_find_entry() -
using new directory iteration code.

Reported-by: syzbot+69c9fdccc6dd08961d34@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Move udf_expand_dir_adinicb() to its callsite
Jan Kara [Wed, 5 Oct 2022 16:10:37 +0000 (18:10 +0200)]
udf: Move udf_expand_dir_adinicb() to its callsite

There is just one caller of udf_expand_dir_adinicb(). Move the function
to its caller into namei.c as it is more about directory handling than
anything else anyway.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Convert udf_expand_dir_adinicb() to new directory iteration
Jan Kara [Wed, 5 Oct 2022 15:59:12 +0000 (17:59 +0200)]
udf: Convert udf_expand_dir_adinicb() to new directory iteration

Convert udf_expand_dir_adinicb() to new directory iteration code.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Convert udf_readdir() to new directory iteration
Jan Kara [Tue, 4 Oct 2022 13:00:15 +0000 (15:00 +0200)]
udf: Convert udf_readdir() to new directory iteration

Convert udf_readdir() to new directory iteration functions.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: New directory iteration code
Jan Kara [Mon, 3 Oct 2022 21:33:22 +0000 (23:33 +0200)]
udf: New directory iteration code

Add new support code for iterating directory entries. The code is also
more carefully verifying validity of on-disk directory entries to avoid
crashes on malicious media.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoudf: Define EFSCORRUPTED error code
Jan Kara [Thu, 29 Sep 2022 14:34:45 +0000 (16:34 +0200)]
udf: Define EFSCORRUPTED error code

Similarly to other filesystems define EFSCORRUPTED error code for
reporting internal filesystem corruption.

Signed-off-by: Jan Kara <jack@suse.cz>
18 months agoMerge tag 'xfs-6.2-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Linus Torvalds [Sun, 8 Jan 2023 18:11:45 +0000 (12:11 -0600)]
Merge tag 'xfs-6.2-fixes-2' of git://git./fs/xfs/xfs-linux

Pull xfs fixes from Darrick Wong:

 - Remove some incorrect assertions

 - Fix compiler warnings about variables that could be static

 - Fix an off by one error when computing the maximum btree height that
   can cause repair failures

 - Fix the bulkstat-single ioctl not returning the root inode when asked
   to do that

 - Convey NOFS state to inodegc workers to avoid recursion in reclaim

 - Fix unnecessary variable initializations

 - Fix a bug that could result in corruption of the busy extent tree

* tag 'xfs-6.2-fixes-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
  xfs: fix extent busy updating
  xfs: xfs_qm: remove unnecessary ‘0’ values from error
  xfs: Fix deadlock on xfs_inodegc_worker
  xfs: get root inode correctly at bulkstat
  xfs: fix off-by-one error in xfs_btree_space_to_height
  xfs: make xfs_iomap_page_ops static
  xfs: don't assert if cmap covers imap after cycling lock

18 months agoLinux 6.2-rc3
Linus Torvalds [Sun, 8 Jan 2023 17:49:43 +0000 (11:49 -0600)]
Linux 6.2-rc3

18 months agoMerge tag 'powerpc-6.2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
Linus Torvalds [Sun, 8 Jan 2023 13:55:08 +0000 (06:55 -0700)]
Merge tag 'powerpc-6.2-2' of git://git./linux/kernel/git/powerpc/linux

Pull powerpc fixes from Michael Ellerman:

 - Three fixes for various bogosity in our linker script, revealed
   by the recent commit which changed discard behaviour with some
   toolchains.

* tag 'powerpc-6.2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
  powerpc/vmlinux.lds: Don't discard .comment
  powerpc/vmlinux.lds: Don't discard .rela* for relocatable builds
  powerpc/vmlinux.lds: Define RUNTIME_DISCARD_EXIT

18 months agoMerge tag 'fixes-2023-01-08' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt...
Linus Torvalds [Sun, 8 Jan 2023 10:54:24 +0000 (02:54 -0800)]
Merge tag 'fixes-2023-01-08' of git://git./linux/kernel/git/rppt/memblock

Pull memblock fixes from Mike Rapoport:
 "Small fixes in kernel-doc and tests:

   - Fix kernel-doc for memblock_phys_free() to use correct names for
     the counterpart allocation methods

   - Fix compilation error in memblock tests"

* tag 'fixes-2023-01-08' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock:
  memblock: Fix doc for memblock_phys_free
  memblock tests: Fix compilation error.

18 months agoMerge tag 'nfs-for-6.2-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Linus Torvalds [Sat, 7 Jan 2023 18:38:11 +0000 (10:38 -0800)]
Merge tag 'nfs-for-6.2-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs

Pull NFS client fixes from Trond Myklebust:

 - Fix a race in the RPCSEC_GSS upcall code that causes hung RPC calls

 - Fix a broken coalescing test in the pNFS file layout driver

 - Ensure that the access cache rcu path also applies the login test

 - Fix up for a sparse warning

* tag 'nfs-for-6.2-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs:
  NFS: Fix up a sparse warning
  NFS: Judge the file access cache's timestamp in rcu path
  pNFS/filelayout: Fix coalescing test for single DS
  SUNRPC: ensure the matching upcall is in-flight upon downcall

18 months agoMerge tag '6.2-rc2-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6
Linus Torvalds [Sat, 7 Jan 2023 18:26:34 +0000 (10:26 -0800)]
Merge tag '6.2-rc2-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs fixes from Steve French:
 "cifs/smb3 client fixes:

   - two multichannel fixes

   - three reconnect fixes

   - unmap fix"

* tag '6.2-rc2-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
  cifs: fix interface count calculation during refresh
  cifs: refcount only the selected iface during interface update
  cifs: protect access of TCP_Server_Info::{dstaddr,hostname}
  cifs: fix race in assemble_neg_contexts()
  cifs: ignore ipc reconnect failures during dfs failover
  cifs: Fix kmap_local_page() unmapping

18 months agoMerge tag 'devicetree-fixes-for-6.2-1' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Sat, 7 Jan 2023 18:20:33 +0000 (10:20 -0800)]
Merge tag 'devicetree-fixes-for-6.2-1' of git://git./linux/kernel/git/robh/linux

Pull devicetree fixes from Rob Herring:

 - Fix DT memory scanning for some MIPS boards when memory is not
   specified in DT

 - Redo CONFIG_CMDLINE* handling for missing /chosen node. The first
   attempt broke PS3 (and possibly other PPC platforms).

 - Fix constraints in QCom Soundwire schema

* tag 'devicetree-fixes-for-6.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux:
  of: fdt: Honor CONFIG_CMDLINE* even without /chosen node, take 2
  Revert "of: fdt: Honor CONFIG_CMDLINE* even without /chosen node"
  dt-bindings: soundwire: qcom,soundwire: correct sizes related to number of ports
  of/fdt: run soc memory setup when early_init_dt_scan_memory fails

18 months agoMerge tag 'usb-6.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Linus Torvalds [Sat, 7 Jan 2023 18:12:42 +0000 (10:12 -0800)]
Merge tag 'usb-6.2-rc3' of git://git./linux/kernel/git/gregkh/usb

Pull USB fixes from Greg KH:
 "Here are some small USB driver fixes for 6.2-rc3 that resolve some
  reported issues. They include:

   - of-reported ulpi problem, so the offending commit is reverted

   - dwc3 driver bugfixes for recent changes

   - fotg210 fixes

  Most of these have been in linux-next for a while, the last few were
  on the mailing list for a long time and passed all the 0-day bot
  testing so all should be fine with them as well"

* tag 'usb-6.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
  usb: dwc3: gadget: Ignore End Transfer delay on teardown
  usb: dwc3: xilinx: include linux/gpio/consumer.h
  usb: fotg210-udc: fix error return code in fotg210_udc_probe()
  usb: fotg210: fix OTG-only build
  Revert "usb: ulpi: defer ulpi_register on ulpi_read_id timeout"

18 months agoMerge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Linus Torvalds [Sat, 7 Jan 2023 18:06:47 +0000 (10:06 -0800)]
Merge tag 'for-linus' of git://git./linux/kernel/git/rdma/rdma

Pull rdma fixes from Jason Gunthorpe:
 "Most noticeable is that Yishai found a big data corruption regression
  due to a change in the scatterlist:

   - Do not wrongly combine non-contiguous pages in scatterlist

   - Fix compilation warnings on gcc 13

   - Oops when using some mlx5 stats

   - Bad enforcement of atomic responder resources in mlx5"

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma:
  lib/scatterlist: Fix to merge contiguous pages into the last SG properly
  RDMA/mlx5: Fix validation of max_rd_atomic caps for DC
  RDMA/mlx5: Fix mlx5_ib_get_hw_stats when used for device
  RDMA/srp: Move large values to a new enum for gcc13

18 months agoMerge tag 'kbuild-fixes-v6.2-2' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Sat, 7 Jan 2023 17:49:52 +0000 (09:49 -0800)]
Merge tag 'kbuild-fixes-v6.2-2' of git://git./linux/kernel/git/masahiroy/linux-kbuild

Pull Kbuild fixes from Masahiro Yamada:

 - Fix single *.ko build

 - Fix module builds when vmlinux.o or Module.symver is missing

* tag 'kbuild-fixes-v6.2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
  kbuild: readd -w option when vmlinux.o or Module.symver is missing
  kbuild: fix single *.ko build

18 months agoMerge tag 'drm-fixes-2023-01-06' of git://anongit.freedesktop.org/drm/drm
Linus Torvalds [Fri, 6 Jan 2023 23:54:25 +0000 (15:54 -0800)]
Merge tag 'drm-fixes-2023-01-06' of git://anongit.freedesktop.org/drm/drm

Pull drm fixes from Daniel Vetter:
 "Still not much, but more than last week. Dave should be back next week
  from the beaching.

  drivers:
   - i915-gvt fixes
   - amdgpu/kfd fixes
   - panfrost bo refcounting fix
   - meson afbc corruption fix
   - imx plane width fix

  core:
   - drm/sched fixes
   - drm/mm kunit test fix
   - dma-buf export error handling fixes"

* tag 'drm-fixes-2023-01-06' of git://anongit.freedesktop.org/drm/drm:
  Revert "drm/amd/display: Enable Freesync Video Mode by default"
  drm/i915/gvt: fix double free bug in split_2MB_gtt_entry
  drm/i915/gvt: use atomic operations to change the vGPU status
  drm/i915/gvt: fix vgpu debugfs clean in remove
  drm/i915/gvt: fix gvt debugfs destroy
  drm/i915: unpin on error in intel_vgpu_shadow_mm_pin()
  drm/amd/display: Uninitialized variables causing 4k60 UCLK to stay at DPM1 and not DPM0
  drm/amdkfd: Fix kernel warning during topology setup
  drm/scheduler: Fix lockup in drm_sched_entity_kill()
  drm/imx: ipuv3-plane: Fix overlay plane width
  drm/scheduler: Fix lockup in drm_sched_entity_kill()
  drm/virtio: Fix memory leak in virtio_gpu_object_create()
  drm/meson: Reduce the FIFO lines held when AFBC is not used
  drm/tests: reduce drm_mm_test stack usage
  drm/panfrost: Fix GEM handle creation ref-counting
  drm/plane-helper: Add the missing declaration of drm_atomic_state
  dma-buf: fix dma_buf_export init order v2

18 months agotpm: Allow system suspend to continue when TPM suspend fails
Jason A. Donenfeld [Fri, 6 Jan 2023 03:01:56 +0000 (04:01 +0100)]
tpm: Allow system suspend to continue when TPM suspend fails

TPM 1 is sometimes broken across system suspends, due to races or
locking issues or something else that haven't been diagnosed or fixed
yet, most likely having to do with concurrent reads from the TPM's
hardware random number generator driver. These issues prevent the system
from actually suspending, with errors like:

  tpm tpm0: A TPM error (28) occurred continue selftest
  ...
  tpm tpm0: A TPM error (28) occurred attempting get random
  ...
  tpm tpm0: Error (28) sending savestate before suspend
  tpm_tis 00:08: PM: __pnp_bus_suspend(): tpm_pm_suspend+0x0/0x80 returns 28
  tpm_tis 00:08: PM: dpm_run_callback(): pnp_bus_suspend+0x0/0x10 returns 28
  tpm_tis 00:08: PM: failed to suspend: error 28
  PM: Some devices failed to suspend, or early wake event detected

This issue was partially fixed by 23393c646142 ("char: tpm: Protect
tpm_pm_suspend with locks"), in a last minute 6.1 commit that Linus took
directly because the TPM maintainers weren't available. However, it
seems like this just addresses the most common cases of the bug, rather
than addressing it entirely. So there are more things to fix still,
apparently.

In lieu of actually fixing the underlying bug, just allow system suspend
to continue, so that laptops still go to sleep fine. Later, this can be
reverted when the real bug is fixed.

Link: https://lore.kernel.org/lkml/7cbe96cf-e0b5-ba63-d1b4-f63d2e826efa@suse.cz/
Cc: stable@vger.kernel.org # 6.1+
Reported-by: Vlastimil Babka <vbabka@suse.cz>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Luigi Semenzato <semenzato@chromium.org>
Cc: Peter Huewe <peterhuewe@gmx.de>
Cc: Jarkko Sakkinen <jarkko@kernel.org>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Johannes Altmanninger <aclopte@gmail.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
18 months agohfs/hfsplus: avoid WARN_ON() for sanity check, use proper error handling
Linus Torvalds [Wed, 4 Jan 2023 19:06:28 +0000 (11:06 -0800)]
hfs/hfsplus: avoid WARN_ON() for sanity check, use proper error handling

Commit 55d1cbbbb29e ("hfs/hfsplus: use WARN_ON for sanity check") fixed
a build warning by turning a comment into a WARN_ON(), but it turns out
that syzbot then complains because it can trigger said warning with a
corrupted hfs image.

The warning actually does warn about a bad situation, but we are much
better off just handling it as the error it is.  So rather than warn
about us doing bad things, stop doing the bad things and return -EIO.

While at it, also fix a memory leak that was introduced by an earlier
fix for a similar syzbot warning situation, and add a check for one case
that historically wasn't handled at all (ie neither comment nor
subsequent WARN_ON).

Reported-by: syzbot+7bb7cd3595533513a9e7@syzkaller.appspotmail.com
Fixes: 55d1cbbbb29e ("hfs/hfsplus: use WARN_ON for sanity check")
Fixes: 8d824e69d9f3 ("hfs: fix OOB Read in __hfs_brec_find")
Link: https://lore.kernel.org/lkml/000000000000dbce4e05f170f289@google.com/
Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Viacheslav Dubeyko <slava@dubeyko.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
18 months agoMerge tag 'block-2023-01-06' of git://git.kernel.dk/linux
Linus Torvalds [Fri, 6 Jan 2023 21:12:42 +0000 (13:12 -0800)]
Merge tag 'block-2023-01-06' of git://git.kernel.dk/linux

Pull block fixes from Jens Axboe:
 "The big change here is obviously the revert of the pktcdvd driver
  removal. Outside of that, just minor tweaks. In detail:

   - Re-instate the pktcdvd driver, which necessitates adding back
     bio_copy_data_iter() and the fops->devnode() hook for now (me)

   - Fix for splitting of a bio marked as NOWAIT, causing either nowait
     reads or writes to error with EAGAIN even if parts of the IO
     completed (me)

   - Fix for ublk, punting management commands to io-wq as they can all
     easily block for extended periods of time (Ming)

   - Removal of SRCU dependency for the block layer (Paul)"

* tag 'block-2023-01-06' of git://git.kernel.dk/linux:
  block: Remove "select SRCU"
  Revert "pktcdvd: remove driver."
  Revert "block: remove devnode callback from struct block_device_operations"
  Revert "block: bio_copy_data_iter"
  ublk: honor IO_URING_F_NONBLOCK for handling control command
  block: don't allow splitting of a REQ_NOWAIT bio
  block: handle bio_split_to_limits() NULL return

18 months agoMerge tag 'io_uring-2023-01-06' of git://git.kernel.dk/linux
Linus Torvalds [Fri, 6 Jan 2023 21:05:13 +0000 (13:05 -0800)]
Merge tag 'io_uring-2023-01-06' of git://git.kernel.dk/linux

Pull io_uring fixes from Jens Axboe:
 "A few minor fixes that should go into the 6.2 release:

   - Fix for a memory leak in io-wq worker creation, if we ultimately
     end up canceling the worker creation before it gets created (me)

   - lockdep annotations for the CQ locking (Pavel)

   - A regression fix for CQ timeout handling (Pavel)

   - Ring pinning around deferred task_work fix (Pavel)

   - A trivial member move in struct io_ring_ctx, saving us some memory
     (me)"

* tag 'io_uring-2023-01-06' of git://git.kernel.dk/linux:
  io_uring: fix CQ waiting timeout handling
  io_uring: move 'poll_multi_queue' bool in io_ring_ctx
  io_uring: lockdep annotate CQ locking
  io_uring: pin context while queueing deferred tw
  io_uring/io-wq: free worker if task_work creation is canceled

18 months agoMerge tag 'tif-notify-signal-2023-01-06' of git://git.kernel.dk/linux
Linus Torvalds [Fri, 6 Jan 2023 20:54:51 +0000 (12:54 -0800)]
Merge tag 'tif-notify-signal-2023-01-06' of git://git.kernel.dk/linux

Pull arm TIF_NOTIFY_SIGNAL fixup from Jens Axboe:
 "Hui Tang reported a performance regressions with _TIF_WORK_MASK in
  newer kernels, which he tracked to a change that went into 5.11. After
  this change, we'll call do_work_pending() more often than we need to,
  because we're now testing bits 0..15 rather than just 0..7.

  Shuffle the bits around to avoid this"

* tag 'tif-notify-signal-2023-01-06' of git://git.kernel.dk/linux:
  ARM: renumber bits related to _TIF_WORK_MASK

18 months agoMerge tag 'ceph-for-6.2-rc3' of https://github.com/ceph/ceph-client
Linus Torvalds [Fri, 6 Jan 2023 20:11:41 +0000 (12:11 -0800)]
Merge tag 'ceph-for-6.2-rc3' of https://github.com/ceph/ceph-client

Pull ceph fixes from Ilya Dryomov:
 "Two file locking fixes from Xiubo"

* tag 'ceph-for-6.2-rc3' of https://github.com/ceph/ceph-client:
  ceph: avoid use-after-free in ceph_fl_release_lock()
  ceph: switch to vfs_inode_has_locks() to fix file lock bug

18 months agoMerge tag 'fixes_for_v6.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/jack...
Linus Torvalds [Fri, 6 Jan 2023 20:07:00 +0000 (12:07 -0800)]
Merge tag 'fixes_for_v6.2-rc3' of git://git./linux/kernel/git/jack/linux-fs

Pull UDF fixes from Jan Kara:
 "Two fixups of the UDF changes that went into 6.2-rc1"

* tag 'fixes_for_v6.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
  udf: initialize newblock to 0
  udf: Fix extension of the last extent in the file

18 months agoMerge tag 'for-6.2-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
Linus Torvalds [Fri, 6 Jan 2023 20:01:49 +0000 (12:01 -0800)]
Merge tag 'for-6.2-rc2-tag' of git://git./linux/kernel/git/kdave/linux

Pull btrfs fixes from David Sterba:
 "A few more regression and regular fixes:

   - regressions:
       - fix assertion condition using = instead of ==
       - fix false alert on bad tree level check
       - fix off-by-one error in delalloc search during lseek

   - fix compat ro feature check at read-write remount

   - handle case when read-repair happens with ongoing device replace

   - updated error messages"

* tag 'for-6.2-rc2-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
  btrfs: fix compat_ro checks against remount
  btrfs: always report error in run_one_delayed_ref()
  btrfs: handle case when repair happens with dev-replace
  btrfs: fix off-by-one in delalloc search during lseek
  btrfs: fix false alert on bad tree level check
  btrfs: add error message for metadata level mismatch
  btrfs: fix ASSERT em->len condition in btrfs_get_extent

18 months agoMerge tag 'riscv-for-linus-6.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel...
Linus Torvalds [Fri, 6 Jan 2023 19:33:42 +0000 (11:33 -0800)]
Merge tag 'riscv-for-linus-6.2-rc3' of git://git./linux/kernel/git/riscv/linux

Pull RISC-V fixes from Palmer Dabbelt:

 - use the correct mask for c.jr/c.jalr when decoding instructions

 - build fix for get_user() to avoid a sparse warning

* tag 'riscv-for-linus-6.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  riscv: uaccess: fix type of 0 variable on error in get_user()
  riscv, kprobes: Stricter c.jr/c.jalr decoding

18 months agoMerge tag 'perf-tools-fixes-for-v6.2-1-2023-01-06' of git://git.kernel.org/pub/scm...
Linus Torvalds [Fri, 6 Jan 2023 19:23:58 +0000 (11:23 -0800)]
Merge tag 'perf-tools-fixes-for-v6.2-1-2023-01-06' of git://git./linux/kernel/git/acme/linux

Pull perf tools fixes from Arnaldo Carvalho de Melo:

 - Fix segfault when trying to process tracepoints present in a
   perf.data file and not linked with libtraceevent.

 - Fix build on uClibc systems by adding missing sys/types.h include,
   that was being obtained indirectly which stopped being the case when
   tools/lib/traceevent was removed.

 - Don't show commands in 'perf help' that depend on linking with
   libtraceevent when not building with that library, which is now a
   possibility since we no longer ship a copy in tools/lib/traceevent.

 - Fix failure in 'perf test' entry testing the combination of 'perf
   probe' user space function + 'perf record' + 'perf script' where it
   expects a backtrace leading to glibc's inet_pton() from 'ping' that
   now happens more than once with glibc 2.35 for IPv6 addreses.

 - Fix for the inet_pton perf test on s/390 where
   'text_to_binary_address' now appears on the backtrace.

 - Fix build error on riscv due to missing header for 'struct
   perf_sample'.

 - Fix 'make -C tools perf_install' install variant by not propagating
   the 'subdir' to submakes for the 'install_headers' targets.

 - Fix handling of unsupported cgroup events when using BPF counters in
   'perf stat'.

 - Count all cgroups, not just the last one when using 'perf stat' and
   combining --for-each-cgroup with --bpf-counters.

   This makes the output using BPF counters match the output without
   using it, which was the intention all along, the output should be the
   same using --bpf-counters or not.

 - Fix 'perf lock contention' core dump related to not finding the
   "__sched_text_end" symbol on s/390.

 - Fix build failure when HEAD is signed: exclude the signature from the
   version string.

 - Add missing closedir() calls to in perf_data__open_dir(), plugging a
   fd leak.

* tag 'perf-tools-fixes-for-v6.2-1-2023-01-06' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
  perf tools: Fix build on uClibc systems by adding missing sys/types.h include
  perf stat: Fix handling of --for-each-cgroup with --bpf-counters to match non BPF mode
  perf stat: Fix handling of unsupported cgroup events when using BPF counters
  perf test record_probe_libc_inet_pton: Fix test on s/390 where 'text_to_binary_address' now appears on the backtrace
  perf lock contention: Fix core dump related to not finding the "__sched_text_end" symbol on s/390
  perf build: Don't propagate subdir to submakes for install_headers
  perf test record_probe_libc_inet_pton: Fix failure due to extra inet_pton() backtrace in glibc >= 2.35
  perf tools: Fix segfault when trying to process tracepoints in perf.data and not linked with libtraceevent
  perf tools: Don't include signature in version strings
  perf help: Use HAVE_LIBTRACEEVENT to filter out unsupported commands
  perf tools riscv: Fix build error on riscv due to missing header for 'struct perf_sample'
  perf tools: Fix resources leak in perf_data__open_dir()

18 months agoMerge tag 'perf-urgent-2023-01-06' of git://git.kernel.org/pub/scm/linux/kernel/git...
Linus Torvalds [Fri, 6 Jan 2023 19:20:12 +0000 (11:20 -0800)]
Merge tag 'perf-urgent-2023-01-06' of git://git./linux/kernel/git/tip/tip

Pull perf fix from Ingo Molnar:
 "Intel RAPL updates for new model IDs"

* tag 'perf-urgent-2023-01-06' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  perf/x86/rapl: Add support for Intel Emerald Rapids
  perf/x86/rapl: Add support for Intel Meteor Lake
  perf/x86/rapl: Treat Tigerlake like Icelake

18 months agoMerge tag 'v6.2-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Linus Torvalds [Fri, 6 Jan 2023 19:14:11 +0000 (11:14 -0800)]
Merge tag 'v6.2-p2' of git://git./linux/kernel/git/herbert/crypto-2.6

Pull crypto fixes from Herbert Xu:
 "This fixes a CFI crash in arm64/sm4 as well as a regression in the
  caam driver"

* tag 'v6.2-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
  crypto: arm64/sm4 - fix possible crash with CFI enabled
  crypto: caam - fix CAAM io mem access in blob_gen

18 months agousb: dwc3: gadget: Ignore End Transfer delay on teardown
Thinh Nguyen [Fri, 9 Dec 2022 00:50:35 +0000 (16:50 -0800)]
usb: dwc3: gadget: Ignore End Transfer delay on teardown

If we delay sending End Transfer for Setup TRB to be prepared, we need
to check if the End Transfer was in preparation for a driver
teardown/soft-disconnect. In those cases, just send the End Transfer
command without delay.

In the case of soft-disconnect, there's a very small chance the command
may not go through immediately. But should it happen, the Setup TRB will
be prepared during the polling of the controller halted state, allowing
the command to go through then.

In the case of disabling endpoint due to reconfiguration (e.g.
set_interface(alt-setting) or usb reset), then it's driven by the host.
Typically the host wouldn't immediately cancel the control request and
send another control transfer to trigger the End Transfer command
timeout.

Fixes: 4db0fbb60136 ("usb: dwc3: gadget: Don't delay End Transfer on delayed_status")
Cc: stable@vger.kernel.org
Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Link: https://lore.kernel.org/r/f1617a323e190b9cc408fb8b65456e32b5814113.1670546756.git.Thinh.Nguyen@synopsys.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>