4.19.2-stable review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 223/361 IB/rxe: Revise the ib_wr_opcode enum
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
commit 9a59739bd01f77db6fbe2955a4fce165f0f43568 upstream.
This enum has become part of the uABI, as both RXE and the ib_uverbs_post_send() command expect userspace to supply values from this enum. So it should be properly placed in include/uapi/rdma.
In userspace this enum is called 'enum ibv_wr_opcode' as part of libibverbs.h. That enum defines different values for IB_WR_LOCAL_INV, IB_WR_SEND_WITH_INV, and IB_WR_LSO. These were introduced (incorrectly, it turns out) into libiberbs in 2015.
The kernel has changed its mind on the numbering for several of the IB_WC values over the years, but has remained stable on IB_WR_LOCAL_INV and below.
Based on this we can conclude that there is no real user space user of the values beyond IB_WR_ATOMIC_FETCH_AND_ADD, as they have never worked via rdma-core. This is confirmed by inspection, only rxe uses the kernel enum and implements the latter operations. rxe has clearly never worked with these attributes from userspace. Other drivers that support these opcodes implement the functionality without calling out to the kernel.
To make IB_WR_SEND_WITH_INV and related work for RXE in userspace we choose to renumber the IB_WR enum in the kernel to match the uABI that userspace has bee using since before Soft RoCE was merged. This is an overall simpler configuration for the whole software stack, and obviously can't break anything existing.
--- include/rdma/ib_verbs.h | 34 ++++++++++++++++++++-------------- include/uapi/rdma/ib_user_verbs.h | 20 +++++++++++++++++++- 2 files changed, 39 insertions(+), 15 deletions(-)
include/rdma/ib_verbs.h +20 -14
@@ -1278,21 +1278,27 @@ struct ib_qp_attr { };enum ib_wr_opcode { -IB_WR_RDMA_WRITE , -IB_WR_RDMA_WRITE_WITH_IMM , -IB_WR_SEND , -IB_WR_SEND_WITH_IMM , -IB_WR_RDMA_READ , -IB_WR_ATOMIC_CMP_AND_SWP , -IB_WR_ATOMIC_FETCH_AND_ADD , -IB_WR_LSO , -IB_WR_SEND_WITH_INV , -IB_WR_RDMA_READ_WITH_INV , -IB_WR_LOCAL_INV , -IB_WR_REG_MR , -IB_WR_MASKED_ATOMIC_CMP_AND_SWP , -IB_WR_MASKED_ATOMIC_FETCH_AND_ADD , +/* These are shared with userspace */ +IB_WR_RDMA_WRITE =IB_UVERBS_WR_RDMA_WRITE , +IB_WR_RDMA_WRITE_WITH_IMM =IB_UVERBS_WR_RDMA_WRITE_WITH_IMM , +IB_WR_SEND =IB_UVERBS_WR_SEND , +IB_WR_SEND_WITH_IMM =IB_UVERBS_WR_SEND_WITH_IMM , +IB_WR_RDMA_READ =IB_UVERBS_WR_RDMA_READ , +IB_WR_ATOMIC_CMP_AND_SWP =IB_UVERBS_WR_ATOMIC_CMP_AND_SWP , +IB_WR_ATOMIC_FETCH_AND_ADD =IB_UVERBS_WR_ATOMIC_FETCH_AND_ADD , +IB_WR_LSO =IB_UVERBS_WR_TSO , +IB_WR_SEND_WITH_INV =IB_UVERBS_WR_SEND_WITH_INV , +IB_WR_RDMA_READ_WITH_INV =IB_UVERBS_WR_RDMA_READ_WITH_INV , +IB_WR_LOCAL_INV =IB_UVERBS_WR_LOCAL_INV , +IB_WR_MASKED_ATOMIC_CMP_AND_SWP = +IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP , +IB_WR_MASKED_ATOMIC_FETCH_AND_ADD = +IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD , + +/* These are kernel only and can not be issued by userspace */ +IB_WR_REG_MR =0x20 ,IB_WR_REG_SIG_MR , +/* reserve values for low level drivers' internal use. * These values will not be used at all in the ib core layer. */
include/uapi/rdma/ib_user_verbs.h +19 -1
@@ -763,10 +763,28 @@ struct ib_uverbs_sge {__u32 lkey; }; +enum ib_uverbs_wr_opcode { +IB_UVERBS_WR_RDMA_WRITE =0 , +IB_UVERBS_WR_RDMA_WRITE_WITH_IMM =1 , +IB_UVERBS_WR_SEND =2 , +IB_UVERBS_WR_SEND_WITH_IMM =3 , +IB_UVERBS_WR_RDMA_READ =4 , +IB_UVERBS_WR_ATOMIC_CMP_AND_SWP =5 , +IB_UVERBS_WR_ATOMIC_FETCH_AND_ADD =6 , +IB_UVERBS_WR_LOCAL_INV =7 , +IB_UVERBS_WR_BIND_MW =8 , +IB_UVERBS_WR_SEND_WITH_INV =9 , +IB_UVERBS_WR_TSO =10 , +IB_UVERBS_WR_RDMA_READ_WITH_INV =11 , +IB_UVERBS_WR_MASKED_ATOMIC_CMP_AND_SWP =12 , +IB_UVERBS_WR_MASKED_ATOMIC_FETCH_AND_ADD =13 , +/* Review enum ib_wr_opcode before modifying this */ +}; +struct ib_uverbs_send_wr {__aligned_u64 wr_id;__u32 num_sge; -__u32 opcode; +__u32 opcode;/* see enum ib_uverbs_wr_opcode */ __u32 send_flags;union {__be32 imm_data;
Greg Kroah-Hartman
maintainerPATCH 224/361 jbd2: fix use after free in jbd2_log_do_checkpoint()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit ccd3c4373eacb044eb3832966299d13d2631f66f upstream.
The code cleaning transaction's lists of checkpoint buffers has a bug where it increases bh refcount only after releasing journal->j_list_lock. Thus the following race is possible:
CPU0 CPU1jbd2_log_do_checkpoint()
jbd2_journal_try_to_free_buffers()
__journal_try_to_free_buffer(bh)
...
while (transaction->t_checkpoint_io_list)
...
if (buffer_locked(bh)) {<-- IO completes now, buffer gets unlocked -->
spin_unlock(&journal->j_list_lock);
spin_lock(&journal->j_list_lock);
__jbd2_journal_remove_checkpoint(jh);
spin_unlock(&journal->j_list_lock);
try_to_free_buffers(page);
get_bh(bh) <-- accesses freed bhFix the problem by grabbing bh reference before unlocking journal->j_list_lock.
--- fs/jbd2/checkpoint.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/jbd2/checkpoint.c +2 -2
@@ -251,8 +251,8 @@ restart: bh =jh2bh (jh);if (buffer_locked (bh)) { -spin_unlock (&journal->j_list_lock);get_bh (bh); +spin_unlock (&journal->j_list_lock);wait_on_buffer (bh);/* the journal_head may have gone by now */ BUFFER_TRACE (bh,"brelse" );
@@ -333,8 +333,8 @@ restart2: jh = transaction->t_checkpoint_io_list; bh =jh2bh (jh);if (buffer_locked (bh)) { -spin_unlock (&journal->j_list_lock);get_bh (bh); +spin_unlock (&journal->j_list_lock);wait_on_buffer (bh);/* the journal_head may have gone by now */ BUFFER_TRACE (bh,"brelse" );
Greg Kroah-Hartman
maintainerPATCH 226/361 ext4: fix EXT4_IOC_SWAP_BOOT
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 18aded17492088962ef43f00825179598b3e8c58 upstream.
The code EXT4_IOC_SWAP_BOOT ioctl hasn't been updated in a while, and it's a bit broken with respect to more modern ext4 kernels, especially metadata checksums.
Other problems fixed with this commit:
* Don't allow installing a DAX, swap file, or an encrypted file as a boot loader.
* Respect the immutable and append-only flags.
* Wait until any DIO operations are finished *before* calling truncate_inode_pages().
* Don't swap inode->i_flags, since these flags have nothing to do with the inode blocks --- and it will give the IMA/audit code heartburn when the inode is evicted.
--- fs/ext4/ioctl.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-)
fs/ext4/ioctl.c +27 -6
@@ -67,7 +67,6 @@ static void swap_inode_data(struct inode ei1 =EXT4_I (inode1); ei2 =EXT4_I (inode2); -swap (inode1->i_flags, inode2->i_flags);swap (inode1->i_version, inode2->i_version);swap (inode1->i_blocks, inode2->i_blocks);swap (inode1->i_bytes, inode2->i_bytes);
@@ -85,6 +84,21 @@ static void swap_inode_data(struct inodei_size_write (inode2, isize); } +static void reset_inode_seed (struct inode *inode) +{ +struct ext4_inode_info *ei =EXT4_I (inode); +struct ext4_sb_info *sbi =EXT4_SB (inode->i_sb); +__le32 inum =cpu_to_le32 (inode->i_ino); +__le32 gen =cpu_to_le32 (inode->i_generation); +__u32 csum; + +if (!ext4_has_metadata_csum (inode->i_sb)) +return ; + + csum =ext4_chksum (sbi, sbi->s_csum_seed, (__u8 *)&inum,sizeof (inum)); + ei->i_csum_seed =ext4_chksum (sbi, csum, (__u8 *)&gen,sizeof (gen)); +} +/** * Swap the information from the given @inode and the inode * EXT4_BOOT_LOADER_INO. It will basically swap i_data and all other
@@ -102,10 +116,13 @@ static long swap_inode_boot_loader(strucstruct inode *inode_bl;struct ext4_inode_info *ei_bl; -if (inode->i_nlink !=1 || !S_ISREG (inode->i_mode)) +if (inode->i_nlink !=1 || !S_ISREG (inode->i_mode) || +IS_SWAPFILE (inode) ||IS_ENCRYPTED (inode) || +ext4_has_inline_data (inode))return -EINVAL ; -if (!inode_owner_or_capable (inode) || !capable (CAP_SYS_ADMIN )) +if (IS_RDONLY (inode) ||IS_APPEND (inode) ||IS_IMMUTABLE (inode) || + !inode_owner_or_capable (inode) || !capable (CAP_SYS_ADMIN ))return -EPERM ; inode_bl =ext4_iget (sb,EXT4_BOOT_LOADER_INO );
@@ -120,13 +137,13 @@ static long swap_inode_boot_loader(struc* that only 1 swap_inode_boot_loader is running. */ lock_two_nondirectories (inode, inode_bl); -truncate_inode_pages (&inode->i_data,0 ); -truncate_inode_pages (&inode_bl->i_data,0 ); -/* Wait for all existing dio workers */ inode_dio_wait (inode);inode_dio_wait (inode_bl); +truncate_inode_pages (&inode->i_data,0 ); +truncate_inode_pages (&inode_bl->i_data,0 ); + handle =ext4_journal_start (inode_bl,EXT4_HT_MOVE_EXTENTS ,2 );if (IS_ERR (handle)) { err = -EINVAL ;
@@ -159,6 +176,8 @@ static long swap_inode_boot_loader(struc inode->i_generation =prandom_u32 (); inode_bl->i_generation =prandom_u32 (); +reset_inode_seed (inode); +reset_inode_seed (inode_bl);ext4_discard_preallocations (inode);
@@ -169,6 +188,7 @@ static long swap_inode_boot_loader(struc inode->i_ino, err);/* Revert all changes: */ swap_inode_data (inode, inode_bl); +ext4_mark_inode_dirty (handle, inode); }else { err =ext4_mark_inode_dirty (handle, inode_bl);if (err <0 ) {
@@ -178,6 +198,7 @@ static long swap_inode_boot_loader(struc/* Revert all changes: */ swap_inode_data (inode, inode_bl);ext4_mark_inode_dirty (handle, inode); +ext4_mark_inode_dirty (handle, inode_bl); } }ext4_journal_stop (handle);
Greg Kroah-Hartman
maintainerPATCH 227/361 ext4: initialize retries variable in ext4_da_write_inline_data_begin()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Czerner <[email protected]>
commit 625ef8a3acd111d5f496d190baf99d1a815bd03e upstream.
Variable retries is not initialized in ext4_da_write_inline_data_begin() which can lead to nondeterministic number of retries in case we hit ENOSPC. Initialize retries to zero as we do everywhere else.
--- fs/ext4/inline.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inline.c +1 -1
@@ -863,7 +863,7 @@ int ext4_da_write_inline_data_begin(struhandle_t *handle;struct page *page;struct ext4_iloc iloc; -int retries; +int retries =0 ; ret =ext4_get_inode_loc (inode, &iloc);if (ret)
Greg Kroah-Hartman
maintainerPATCH 230/361 ext4: fix use-after-free race in ext4_remount()s error path
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 33458eaba4dfe778a426df6a19b7aad2ff9f7eec upstream.
It's possible for ext4_show_quota_options() to try reading s_qf_names[i] while it is being modified by ext4_remount() --- most notably, in ext4_remount's error path when the original values of the quota file name gets restored.
--- fs/ext4/ext4.h | 3 +- fs/ext4/super.c | 73 ++++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 50 insertions(+), 26 deletions(-)
fs/ext4/ext4.h +2 -1
@@ -1401,7 +1401,8 @@ struct ext4_sb_info {u32 s_min_batch_time;struct block_device *journal_bdev;#ifdef CONFIG_QUOTA -char *s_qf_names[EXT4_MAXQUOTAS ];/* Names of quota files with journalled quota */ +/* Names of quota files with journalled quota */ +char __rcu *s_qf_names[EXT4_MAXQUOTAS ];int s_jquota_fmt;/* Format of quota to use */ #endif unsigned int s_want_extra_isize;/* New inodes should reserve # bytes */
fs/ext4/super.c +48 -25
167 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 235/361 EDAC, {i7core,sb,skx}_edac: Fix uncorrected error counting
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Luck <[email protected]>
commit 432de7fd7630c84ad24f1c2acd1e3bb4ce3741ca upstream.
The count of errors is picked up from bits 52:38 of the machine check bank status register. But this is the count of *corrected* errors. If an uncorrected error is being logged, the h/w sets this field to 0. Which means that when edac_mc_handle_error() is called, the EDAC core will carefully add zero to the appropriate uncorrected error counts.
--- drivers/edac/i7core_edac.c | 1 + drivers/edac/sb_edac.c | 1 + drivers/edac/skx_edac.c | 1 + 3 files changed, 3 insertions(+)
drivers/edac/i7core_edac.c +1 -0
@@ -1711,6 +1711,7 @@ static void i7core_mce_output_error(struu32 errnum =find_first_bit (&error,32 );if (uncorrected_error) { + core_err_cnt =1 ;if (ripv) tp_event =HW_EVENT_ERR_FATAL ;else
drivers/edac/sb_edac.c +1 -0
@@ -2888,6 +2888,7 @@ static void sbridge_mce_output_error(str recoverable =GET_BITFIELD (m->status,56 ,56 );if (uncorrected_error) { + core_err_cnt =1 ;if (ripv) { type ="FATAL" ; tp_event =HW_EVENT_ERR_FATAL ;
drivers/edac/skx_edac.c +1 -0
@@ -959,6 +959,7 @@ static void skx_mce_output_error(struct recoverable =GET_BITFIELD (m->status,56 ,56 );if (uncorrected_error) { + core_err_cnt =1 ;if (ripv) { type ="FATAL" ; tp_event =HW_EVENT_ERR_FATAL ;
Greg Kroah-Hartman
maintainerPATCH 236/361 EDAC, skx_edac: Fix logical channel intermediate decoding
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiuxu Zhuo <[email protected]>
commit 8f18973877204dc8ca4ce1004a5d28683b9a7086 upstream.
The code "lchan = (lchan << 1) | ~lchan" for logical channel intermediate decoding is wrong. The wrong intermediate decoding result is {0xffffffff, 0xfffffffe}.
Fix it by replacing '~' with '!'. The correct intermediate decoding result is {0x1, 0x2}.
--- drivers/edac/skx_edac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/edac/skx_edac.c +1 -1
@@ -668,7 +668,7 @@ sad_found:break ;case 2 : lchan = (addr >> shift) %2 ; - lchan = (lchan <<1 ) | ~lchan; + lchan = (lchan <<1 ) | !lchan;break ;case 3 : lchan = ((addr >> shift) %2 ) <<1 ;
Greg Kroah-Hartman
maintainerPATCH 237/361 ARM: dts: dra7: Fix up unaligned access setting for PCIe EP
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vignesh R <[email protected]>
commit 6d0af44a82be87c13f2320821e9fbb8b8cf5a56f upstream.
Bit positions of PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE and PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE in CTRL_CORE_SMA_SW_7 are incorrectly documented in the TRM. In fact, the bit positions are swapped. Update the DT bindings for PCIe EP to reflect the same.
--- arch/arm/boot/dts/dra7.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/dra7.dtsi +1 -1
@@ -354,7 +354,7 @@ ti,hwmods = "pcie1"; phys = <&pcie1_phy>; phy-names = "pcie-phy0"; - ti,syscon-unaligned-access = <&scm_conf1 0x14 2>; + ti,syscon-unaligned-access = <&scm_conf1 0x14 1>; status = "disabled"; }; };
Greg Kroah-Hartman
maintainerPATCH 240/361 signal/GenWQE: Fix sending of SIGKILL
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric W. Biederman <[email protected]>
commit 0ab93e9c99f8208c0a1a7b7170c827936268c996 upstream.
The genweq_add_file and genwqe_del_file by caching current without using reference counting embed the assumption that a file descriptor will never be passed from one process to another. It even embeds the assumption that the the thread that opened the file will be in
existence when the process terminates. Neither of which are
guaranteed to be true.
Therefore replace caching the task_struct of the opener with pid of the openers thread group id. All the knowledge of the opener is used for is as the target of SIGKILL and a SIGKILL will kill the entire process group.
Rename genwqe_force_sig to genwqe_terminate, remove it's unncessary signal argument, update it's ownly caller, and use kill_pid instead of force_sig.
The work force_sig does in changing signal handling state is not relevant to SIGKILL sent as SEND_SIG_PRIV. The exact same processess will be killed just with less work, and less confusion. The work done by force_sig is really only needed for handling syncrhonous exceptions.
It will still be possible to cause genwqe_device_remove to wait 8 seconds by passing a file descriptor to another process but the possible user after free is fixed.
--- drivers/misc/genwqe/card_base.h | 2 +- drivers/misc/genwqe/card_dev.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/misc/genwqe/card_base.h +1 -1
@@ -408,7 +408,7 @@ struct genwqe_file {struct file *filp;struct fasync_struct *async_queue; -struct task_struct *owner; +struct pid *opener;struct list_head list;/* entry in list of open files */ spinlock_t map_lock;/* lock for dma_mappings */
drivers/misc/genwqe/card_dev.c +5 -4
@@ -52,7 +52,7 @@ static void genwqe_add_file(struct genwq {unsigned long flags; - cfile->owner = current; + cfile->opener =get_pid (task_tgid (current));spin_lock_irqsave (&cd->file_lock, flags);list_add (&cfile->list, &cd->file_list);spin_unlock_irqrestore (&cd->file_lock, flags);
@@ -65,6 +65,7 @@ static int genwqe_del_file(struct genwqespin_lock_irqsave (&cd->file_lock, flags);list_del (&cfile->list);spin_unlock_irqrestore (&cd->file_lock, flags); +put_pid (cfile->opener);return 0 ; }
@@ -275,7 +276,7 @@ static int genwqe_kill_fasync(struct genreturn files; } -static int genwqe_force_sig (struct genwqe_dev *cd,int sig) +static int genwqe_terminate (struct genwqe_dev *cd) {unsigned int files =0 ;unsigned long flags;
@@ -283,7 +284,7 @@ static int genwqe_force_sig(struct genwqspin_lock_irqsave (&cd->file_lock, flags);list_for_each_entry (cfile, &cd->file_list, list) { -force_sig (sig, cfile->owner); +kill_pid (cfile->opener,SIGKILL ,1 ); files++; }spin_unlock_irqrestore (&cd->file_lock, flags);
@@ -1352,7 +1353,7 @@ static int genwqe_inform_and_stop_procesdev_warn (&pci_dev->dev,"[%s] send SIGKILL and wait ...\n" , __func__); - rc =genwqe_force_sig (cd,SIGKILL );/* force terminate */ + rc =genwqe_terminate (cd);if (rc) {/* Give kill_timout more seconds to end processes */ for (i = 0; (i < GENWQE_KILL_TIMEOUT) &&
Greg Kroah-Hartman
maintainerPATCH 244/361 crypto: aesni - dont use GFP_ATOMIC allocation if the request doesnt cross a page in gcm
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit a788848116454d753b13a4888e0e31ada3c4d393 upstream.
This patch fixes gcmaes_crypt_by_sg so that it won't use memory allocation if the data doesn't cross a page boundary.
Authenticated encryption may be used by dm-crypt. If the encryption or decryption fails, it would result in I/O error and filesystem corruption. The function gcmaes_crypt_by_sg is using GFP_ATOMIC allocation that can fail anytime. This patch fixes the logic so that it won't attempt the failing allocation if the data doesn't cross a page boundary.
--- arch/x86/crypto/aesni-intel_glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/crypto/aesni-intel_glue.c +1 -1
@@ -817,7 +817,7 @@ static int gcmaes_crypt_by_sg(bool enc,/* Linearize assoc, if not already linear */ if (req->src->length >= assoclen && req->src->length && (!PageHighMem (sg_page (req->src)) || - req->src->offset + req->src->length <PAGE_SIZE )) { + req->src->offset + req->src->length <=PAGE_SIZE )) {scatterwalk_start (&assoc_sg_walk, req->src); assoc =scatterwalk_map (&assoc_sg_walk); }else {
Greg Kroah-Hartman
maintainerPATCH 246/361 crypto: aegis/generic - fix for big endian systems
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 4a34e3c2f2f48f47213702a84a123af0fe21ad60 upstream.
Use the correct __le32 annotation and accessors to perform the single round of AES encryption performed inside the AEGIS transform. Otherwise, tcrypt reports:
alg: aead: Test 1 failed on encryption for aegis128-generic 00000000: 6c 25 25 4a 3c 10 1d 27 2b c1 d4 84 9a ef 7f 6e
alg: aead: Test 1 failed on encryption for aegis128l-generic 00000000: cd c6 e3 b8 a0 70 9d 8e c2 4f 6f fe 71 42 df 28
alg: aead: Test 1 failed on encryption for aegis256-generic 00000000: aa ed 07 b1 96 1d e9 e6 f2 ed b5 8e 1c 5f dc 1c
--- crypto/aegis.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
crypto/aegis.h +10 -12
@@ -21,7 +21,7 @@union aegis_block {__le64 words64[AEGIS_BLOCK_SIZE /sizeof (__le64)]; -u32 words32[AEGIS_BLOCK_SIZE /sizeof (u32)]; +__le32 words32[AEGIS_BLOCK_SIZE /sizeof (__le32)];u8 bytes[AEGIS_BLOCK_SIZE ]; };
@@ -57,24 +57,22 @@ static void crypto_aegis_aesenc(union aeconst union aegis_block *src, const union aegis_block *key) { - u32 *d = dst->words32; const u8 *s = src->bytes; -const u32 *k = key->words32;const u32 *t0 = crypto_ft_tab[0 ];const u32 *t1 = crypto_ft_tab[1 ];const u32 *t2 = crypto_ft_tab[2 ];const u32 *t3 = crypto_ft_tab[3 ];u32 d0, d1, d2, d3; - d0 = t0[s[0 ]] ^ t1[s[5 ]] ^ t2[s[10 ]] ^ t3[s[15 ]] ^ k[0 ]; - d1 = t0[s[4 ]] ^ t1[s[9 ]] ^ t2[s[14 ]] ^ t3[s[3 ]] ^ k[1 ]; - d2 = t0[s[8 ]] ^ t1[s[13 ]] ^ t2[s[2 ]] ^ t3[s[7 ]] ^ k[2 ]; - d3 = t0[s[12 ]] ^ t1[s[1 ]] ^ t2[s[6 ]] ^ t3[s[11 ]] ^ k[3 ]; - - d[0 ] = d0; - d[1 ] = d1; - d[2 ] = d2; - d[3 ] = d3; + d0 = t0[s[0 ]] ^ t1[s[5 ]] ^ t2[s[10 ]] ^ t3[s[15 ]]; + d1 = t0[s[4 ]] ^ t1[s[9 ]] ^ t2[s[14 ]] ^ t3[s[3 ]]; + d2 = t0[s[8 ]] ^ t1[s[13 ]] ^ t2[s[2 ]] ^ t3[s[7 ]]; + d3 = t0[s[12 ]] ^ t1[s[1 ]] ^ t2[s[6 ]] ^ t3[s[11 ]]; + + dst->words32[0 ] =cpu_to_le32 (d0) ^ key->words32[0 ]; + dst->words32[1 ] =cpu_to_le32 (d1) ^ key->words32[1 ]; + dst->words32[2 ] =cpu_to_le32 (d2) ^ key->words32[2 ]; + dst->words32[3 ] =cpu_to_le32 (d3) ^ key->words32[3 ]; }#endif /* _CRYPTO_AEGIS_H */
Greg Kroah-Hartman
maintainerPATCH 252/361 hugetlbfs: dirty pages as they are added to pagecache
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Kravetz <[email protected]>
commit 22146c3ce98962436e401f7b7016a6f664c9ffb5 upstream.
Some test systems were experiencing negative huge page reserve counts and incorrect file block counts. This was traced to /proc/sys/vm/drop_caches removing clean pages from hugetlbfs file pagecaches. When non-hugetlbfs explicit code removes the pages, the appropriate accounting is not performed.
This can be recreated as follows:
fallocate -l 2M /dev/hugepages/foo
echo 1 > /proc/sys/vm/drop_caches
fallocate -l 2M /dev/hugepages/foo
grep -i huge /proc/meminfo
AnonHugePages: 0 kB
ShmemHugePages: 0 kB
HugePages_Total: 2048
HugePages_Free: 2047
HugePages_Rsvd: 18446744073709551615
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 4194304 kB
ls -lsh /dev/hugepages/foo
4.0M -rw-r--r--. 1 root root 2.0M Oct 17 20:05 /dev/hugepages/foo
To address this issue, dirty pages as they are added to pagecache. This can easily be reproduced with fallocate as shown above. Read faulted pages will eventually end up being marked dirty. But there is a window where they are clean and could be impacted by code such as drop_caches. So, just dirty them all as they are added to the pagecache.
--- mm/hugetlb.c | 6 ++++++ 1 file changed, 6 insertions(+)
mm/hugetlb.c +6 -0
@@ -3690,6 +3690,12 @@ int huge_add_to_page_cache(struct page *return err;ClearPagePrivate (page); +/* +* set page dirty so that it will not be removed from cache/file +* by non-hugetlbfs specific code paths. +*/ +set_page_dirty (page); +spin_lock (&inode->i_lock); inode->i_blocks +=blocks_per_huge_page (h);spin_unlock (&inode->i_lock);
Greg Kroah-Hartman
maintainerPATCH 259/361 iio: adc: imx25-gcq: Fix leak of device_node in mx25_gcq_setup_cfgs()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Khoroshilov <[email protected]>
commit d3fa21c73c391975488818b085b894c2980ea052 upstream.
Leaving for_each_child_of_node loop we should release child device node, if it is not stored for future use.
Found by Linux Driver Verification project (linuxtesting.org).
JC: I'm not sending this as a quick fix as it's been wrong for years, but good to pick up for stable after the merge window.
--- drivers/iio/adc/fsl-imx25-gcq.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/iio/adc/fsl-imx25-gcq.c +6 -0
@@ -209,12 +209,14 @@ static int mx25_gcq_setup_cfgs(struct pl ret =of_property_read_u32 (child,"reg" , ®);if (ret) {dev_err (dev,"Failed to get reg property\n" ); +of_node_put (child);return ret; }if (reg >=MX25_NUM_CFGS ) {dev_err (dev,"reg value is greater than the number of available configuration registers\n" ); +of_node_put (child);return -EINVAL ; }
@@ -228,6 +230,7 @@ static int mx25_gcq_setup_cfgs(struct plif (IS_ERR (priv->vref[refp])) {dev_err (dev,"Error, trying to use external voltage reference without a vref-%s regulator." , mx25_gcq_refp_names[refp]); +of_node_put (child);return PTR_ERR (priv->vref[refp]); } priv->channel_vref_mv[reg] =
@@ -240,6 +243,7 @@ static int mx25_gcq_setup_cfgs(struct plbreak ;default :dev_err (dev,"Invalid positive reference %d\n" , refp); +of_node_put (child);return -EINVAL ; }
@@ -254,10 +258,12 @@ static int mx25_gcq_setup_cfgs(struct plif ((refp &MX25_ADCQ_CFG_REFP_MASK ) != refp) {dev_err (dev,"Invalid fsl,adc-refp property value\n" ); +of_node_put (child);return -EINVAL ; }if ((refn &MX25_ADCQ_CFG_REFN_MASK ) != refn) {dev_err (dev,"Invalid fsl,adc-refn property value\n" ); +of_node_put (child);return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 260/361 iio: adc: at91: fix acking DRDY irq on simple conversions
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eugen Hristev <[email protected]>
commit bc1b45326223e7e890053cf6266357adfa61942d upstream.
When doing simple conversions, the driver did not acknowledge the DRDY irq. If this irq status is not acked, it will be left pending, and as soon as a trigger is enabled, the irq handler will be called, it doesn't know why this status has occurred because no channel is pending, and then it will go int a irq loop and board will hang.
To avoid this situation, read the LCDR after a raw conversion is done.
--- drivers/iio/adc/at91_adc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/adc/at91_adc.c +2 -0
@@ -279,6 +279,8 @@ static void handle_adc_eoc_trigger(int iiio_trigger_poll (idev->trig); }else { st->last_value =at91_adc_readl (st,AT91_ADC_CHAN (st, st->chnb)); +/* Needed to ACK the DRDY interruption */ +at91_adc_readl (st,AT91_ADC_LCDR ); st->done = true;wake_up_interruptible (&st->wq_data_avail); }
Greg Kroah-Hartman
maintainerPATCH 262/361 w1: omap-hdq: fix missing bus unregister at removal
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Kemnade <[email protected]>
commit a007734618fee1bf35556c04fa498d41d42c7301 upstream.
The bus master was not removed after unloading the module or unbinding the driver. That lead to oopses like this
[ 127.842987] Unable to handle kernel paging request at virtual address bf01d04c [ 127.850646] pgd = 70e3cd9a [ 127.853698] [bf01d04c] *pgd=8f908811, *pte=00000000, *ppte=00000000 [ 127.860412] Internal error: Oops: 80000007 [#1] PREEMPT SMP ARM [ 127.866668] Modules linked in: bq27xxx_battery overlay [last unloaded: omap_hdq] [ 127.874542] CPU: 0 PID: 1022 Comm: w1_bus_master1 Not tainted 4.19.0-rc4-00001-g2d51da718324 #12 [ 127.883819] Hardware name: Generic OMAP36xx (Flattened Device Tree) [ 127.890441] PC is at 0xbf01d04c [ 127.893798] LR is at w1_search_process_cb+0x4c/0xfc [ 127.898956] pc : [<bf01d04c>] lr : [<c05f9580>] psr: a0070013 [ 127.905609] sp : cf885f48 ip : bf01d04c fp : ddf1e11c [ 127.911132] r10: cf8fe040 r9 : c05f8d00 r8 : cf8fe040 [ 127.916656] r7 : 000000f0 r6 : cf8fe02c r5 : cf8fe000 r4 : cf8fe01c [ 127.923553] r3 : c05f8d00 r2 : 000000f0 r1 : cf8fe000 r0 : dde1ef10 [ 127.930450] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none [ 127.938018] Control: 10c5387d Table: 8f8f0019 DAC: 00000051 [ 127.944091] Process w1_bus_master1 (pid: 1022, stack limit = 0x9135699f) [ 127.951171] Stack: (0xcf885f48 to 0xcf886000) [ 127.955810] 5f40: cf8fe000 00000000 cf884000 cf8fe090 000003e8 c05f8d00 [ 127.964477] 5f60: dde5fc34 c05f9700 ddf1e100 ddf1e540 cf884000 cf8fe000 c05f9694 00000000 [ 127.973114] 5f80: dde5fc34 c01499a4 00000000 ddf1e540 c0149874 00000000 00000000 00000000 [ 127.981781] 5fa0: 00000000 00000000 00000000 c01010e8 00000000 00000000 00000000 00000000 [ 127.990447] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 127.999114] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000 [ 128.007781] [<c05f9580>] (w1_search_process_cb) from [<c05f9700>] (w1_process+0x6c/0x118) [ 128.016479] [<c05f9700>] (w1_process) from [<c01499a4>] (kthread+0x130/0x148) [ 128.024047] [<c01499a4>] (kthread) from [<c01010e8>] (ret_from_fork+0x14/0x2c) [ 128.031677] Exception stack(0xcf885fb0 to 0xcf885ff8) [ 128.037017] 5fa0: 00000000 00000000 00000000 00000000 [ 128.045684] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 128.054351] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 [ 128.061340] Code: bad PC value [ 128.064697] ---[ end trace af066e33c0e14119 ]---
--- drivers/w1/masters/omap_hdq.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/w1/masters/omap_hdq.c +2 -0
@@ -763,6 +763,8 @@ static int omap_hdq_remove(struct platfo/* remove module dependency */ pm_runtime_disable (&pdev->dev); +w1_remove_master_device (&omap_w1_master); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 272/361 nfsd: correctly decrement odstate refcount in error path
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Elble <[email protected]>
commit bd8d725078867cda250fe94b9c5a067b4a64ca74 upstream.
alloc_init_deleg() both allocates an nfs4_delegation, and bumps the refcount on odstate. So after this point, we need to put_clnt_odstate() and nfs4_put_stid() to not leave the odstate refcount inappropriately bumped.
--- fs/nfsd/nfs4state.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nfsd/nfs4state.c +1 -2
@@ -4364,7 +4364,7 @@ nfs4_set_delegation(struct nfs4_client * fl =nfs4_alloc_init_lease (dp,NFS4_OPEN_DELEGATE_READ );if (!fl) - goto out_stid; + goto out_clnt_odstate; status =vfs_setlease (fp->fi_deleg_file, fl->fl_type, &fl,NULL );if (fl)
@@ -4389,7 +4389,6 @@ out_unlock:vfs_setlease (fp->fi_deleg_file,F_UNLCK ,NULL , (void **)&dp); out_clnt_odstate:put_clnt_odstate (dp->dl_clnt_odstate); -out_stid:nfs4_put_stid (&dp->dl_stid); out_delegees:put_deleg_file (fp);
Greg Kroah-Hartman
maintainerPATCH 278/361 media: ov7670: make "xclk" clock optional
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lubomir Rintel <[email protected]>
commit 786fa584eda86d6598db3b87c61dc81f68808d11 upstream.
When the "xclk" clock was added, it was made mandatory. This broke the driver on an OLPC plaform which doesn't know such clock. Make it optional.
Tested on a OLPC XO-1 laptop.
--- drivers/media/i2c/ov7670.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
drivers/media/i2c/ov7670.c +17 -10
@@ -1808,17 +1808,24 @@ static int ov7670_probe(struct i2c_clien info->pclk_hb_disable = true; } - info->clk =devm_clk_get (&client->dev,"xclk" ); -if (IS_ERR (info->clk)) -return PTR_ERR (info->clk); - ret =clk_prepare_enable (info->clk); -if (ret) -return ret; + info->clk =devm_clk_get (&client->dev,"xclk" );/* optional */ +if (IS_ERR (info->clk)) { + ret =PTR_ERR (info->clk); +if (ret == -ENOENT ) + info->clk =NULL ; +else +return ret; + } +if (info->clk) { + ret =clk_prepare_enable (info->clk); +if (ret) +return ret; - info->clock_speed =clk_get_rate (info->clk) /1000000 ; -if (info->clock_speed <10 || info->clock_speed >48 ) { - ret = -EINVAL ; - goto clk_disable; + info->clock_speed =clk_get_rate (info->clk) /1000000 ; +if (info->clock_speed <10 || info->clock_speed >48 ) { + ret = -EINVAL ; + goto clk_disable; + } } ret =ov7670_init_gpio (client, info);
Greg Kroah-Hartman
maintainerPATCH 279/361 fsnotify: Fix busy inodes during unmount
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 721fb6fbfd2132164c2e8777cc837f9b2c1794dc upstream.
Detaching of mark connector from fsnotify_put_mark() can race with unmounting of the filesystem like:
CPU1 CPU2fsnotify_put_mark()
spin_lock(&conn->lock);
...
inode = fsnotify_detach_connector_from_object(conn) spin_unlock(&conn->lock);
generic_shutdown_super()
fsnotify_unmount_inodes()
sees connector detached for inode
-> nothing to do
evict_inode()
barfs on pending inode reference
iput(inode);
Resulting in "Busy inodes after unmount" message and possible kernel oops. Make fsnotify_unmount_inodes() properly wait for outstanding inode references from detached connectors.
Note that the accounting of outstanding inode references in the superblock can cause some cacheline contention on the counter. OTOH it happens only during deletion of the last notification mark from an inode (or during unlinking of watched inode) and that is not too bad. I have measured time to create & delete inotify watch 100000 times from 64 processes in parallel (each process having its own inotify group and its own file on a shared superblock) on a 64 CPU machine. Average and standard deviation of 15 runs look like:
Avg Stddev
Vanilla 9.817400 0.276165
Fixed 9.710467 0.228294
So there's no statistically significant difference.
--- fs/notify/fsnotify.c | 3 +++ fs/notify/mark.c | 39 +++++++++++++++++++++++++++++++-------- include/linux/fs.h | 3 +++ 3 files changed, 37 insertions(+), 8 deletions(-)
fs/notify/fsnotify.c +3 -0
@@ -96,6 +96,9 @@ void fsnotify_unmount_inodes(struct supeif (iput_inode)iput (iput_inode); +/* Wait for outstanding inode references from connectors */ +wait_var_event (&sb->s_fsnotify_inode_refs, + !atomic_long_read (&sb->s_fsnotify_inode_refs)); }/*
fs/notify/mark.c +31 -8
@@ -179,17 +179,20 @@ static void fsnotify_connector_destroy_w } } -static struct inode *fsnotify_detach_connector_from_object ( -struct fsnotify_mark_connector *conn) +static void *fsnotify_detach_connector_from_object ( +struct fsnotify_mark_connector *conn, +unsigned int *type) {struct inode *inode =NULL ; + *type = conn->type;if (conn->type ==FSNOTIFY_OBJ_TYPE_DETACHED )return NULL ;if (conn->type ==FSNOTIFY_OBJ_TYPE_INODE ) { inode =fsnotify_conn_inode (conn); inode->i_fsnotify_mask =0 ; +atomic_long_inc (&inode->i_sb->s_fsnotify_inode_refs); }else if (conn->type ==FSNOTIFY_OBJ_TYPE_VFSMOUNT ) {fsnotify_conn_mount (conn)->mnt_fsnotify_mask =0 ; }
@@ -211,10 +214,29 @@ static void fsnotify_final_mark_destroy(fsnotify_put_group (group); } +/* Drop object reference originally held by a connector */ +static void fsnotify_drop_object (unsigned int type,void *objp) +{ +struct inode *inode; +struct super_block *sb; + +if (!objp) +return ; +/* Currently only inode references are passed to be dropped */ +if (WARN_ON_ONCE (type !=FSNOTIFY_OBJ_TYPE_INODE )) +return ; + inode = objp; + sb = inode->i_sb; +iput (inode); +if (atomic_long_dec_and_test (&sb->s_fsnotify_inode_refs)) +wake_up_var (&sb->s_fsnotify_inode_refs); +} +void fsnotify_put_mark (struct fsnotify_mark *mark) {struct fsnotify_mark_connector *conn; -struct inode *inode =NULL ; +void *objp =NULL ; +unsigned int type =FSNOTIFY_OBJ_TYPE_DETACHED ;bool free_conn = false;/* Catch marks that were actually never attached to object */
@@ -234,7 +256,7 @@ void fsnotify_put_mark(struct fsnotify_m conn = mark->connector;hlist_del_init_rcu (&mark->obj_list);if (hlist_empty (&conn->list)) { - inode =fsnotify_detach_connector_from_object (conn); + objp =fsnotify_detach_connector_from_object (conn, &type); free_conn = true; }else {__fsnotify_recalc_mask (conn);
@@ -242,7 +264,7 @@ void fsnotify_put_mark(struct fsnotify_m mark->connector =NULL ;spin_unlock (&conn->lock); -iput (inode); +fsnotify_drop_object (type, objp);if (free_conn) {spin_lock (&destroy_lock);
@@ -709,7 +731,8 @@ void fsnotify_destroy_marks(fsnotify_con {struct fsnotify_mark_connector *conn;struct fsnotify_mark *mark, *old_mark =NULL ; -struct inode *inode; +void *objp; +unsigned int type; conn =fsnotify_grab_connector (connp);if (!conn)
@@ -735,11 +758,11 @@ void fsnotify_destroy_marks(fsnotify_con* mark references get dropped. It would lead to strange results such * as delaying inode deletion or blocking unmount. */ - inode =fsnotify_detach_connector_from_object (conn); + objp =fsnotify_detach_connector_from_object (conn, &type);spin_unlock (&conn->lock);if (old_mark)fsnotify_put_mark (old_mark); -iput (inode); +fsnotify_drop_object (type, objp); }/*
include/linux/fs.h +3 -0
@@ -1428,6 +1428,9 @@ struct super_block {/* Number of inodes with nlink == 0 but still referenced */ atomic_long_t s_remove_count; +/* Pending fsnotify inode refs */ +atomic_long_t s_fsnotify_inode_refs; +/* Being remounted read-only */ int s_readonly_remount;
Greg Kroah-Hartman
maintainerPATCH 281/361 powerpc/msi: Fix compile error on mpc83xx
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
commit 0f99153def98134403c9149128e59d3e1786cf04 upstream.
mpic_get_primary_version() is not defined when not using MPIC. The compile error log like:
arch/powerpc/sysdev/built-in.o: In function `fsl_of_msi_probe':
fsl_msi.c:(.text+0x150c): undefined reference to `fsl_mpic_primary_get_version'
--- arch/powerpc/include/asm/mpic.h | 7 +++++++ 1 file changed, 7 insertions(+)
arch/powerpc/include/asm/mpic.h +7 -0
@@ -393,7 +393,14 @@ extern struct bus_type mpic_subsys;#define MPIC_REGSET_TSI108 MPIC_REGSET(1)/* Tsi108/109 PIC */ /* Get the version of primary MPIC */ +#ifdef CONFIG_MPIC extern u32 fsl_mpic_primary_get_version (void ); +#else +static inline u32 fsl_mpic_primary_get_version (void ) +{ +return 0 ; +} +#endif /* Allocate the controller structure and setup the linux irq descs * for the range if interrupts passed in. No HW initialization is
Greg Kroah-Hartman
maintainerPATCH 285/361 rtc: ds1307: fix ds1339 wakealarm support
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Soeren Moch <[email protected]>
commit 7dceef78f310f5351735060d78a1777c69606016 upstream.
Commit 51ed73eb998a1c79a2b0e9bed68f75a8a2c93b9b ("rtc: ds1340: Add support for trickle charger.") breaks ds1339 wakealarm support by limiting accessible registers. Fix this.
--- drivers/rtc/rtc-ds1307.c | 1 - 1 file changed, 1 deletion(-)
drivers/rtc/rtc-ds1307.c +0 -1
@@ -1384,7 +1384,6 @@ static void ds1307_clks_register(structstatic const struct regmap_config regmap_config = { .reg_bits =8 , .val_bits =8 , - .max_register =0x9 , }; static int ds1307_probe(struct i2c_client *client,
Greg Kroah-Hartman
maintainerPATCH 286/361 rtc: cmos: Fix non-ACPI undefined reference to `hpet_rtc_interrupt
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit d197a253855d2d8e507a003880aab35c4e2473db upstream.
Fix a commit 311ee9c151ad ("rtc: cmos: allow using ACPI for RTC alarm instead of HPET") `rtc-cmos' regression causing a link error:
drivers/rtc/rtc-cmos.o: In function `cmos_platform_probe':
rtc-cmos.c:(.init.text+0x33c): undefined reference to hpet_rtc_interrupt' rtc-cmos.c:(.init.text+0x3f4): undefined reference to hpet_rtc_interrupt'
with non-ACPI platforms using this driver. The cause is the change of the condition guarding the use of `hpet_rtc_interrupt'.
Previously it was a call to `is_hpet_enabled'. That function is static inline and has a hardcoded 0 result for non-ACPI platforms, which imply !HPET_EMULATE_RTC. Consequently the compiler optimized the whole block away including the reference to `hpet_rtc_interrupt', which never made it to the link stage.
Now the guarding condition is a call to `use_hpet_alarm', which is not static inline and therefore the compiler may not be able to prove that it actually always returns 0 for non-ACPI platforms. Consequently the build breaks with an unsatisfied reference, because `hpet_rtc_interrupt' is nowhere defined at link time.
Fix the problem by marking use_hpet_alarm' inline. As the inline' keyword serves as an optimization hint rather than a requirement the compiler is still free to choose whether inlining will be beneficial or not for ACPI platforms.
--- drivers/rtc/rtc-cmos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-cmos.c +1 -1
@@ -167,7 +167,7 @@ static inline int hpet_unregister_irq_ha#endif /* Don't use HPET for RTC Alarm event if ACPI Fixed event is used */ -static int use_hpet_alarm (void ) +static inline int use_hpet_alarm (void ) {return is_hpet_enabled () && !use_acpi_alarm; }
Greg Kroah-Hartman
maintainerPATCH 287/361 rtc: cmos: Remove the `use_acpi_alarm module parameter for !ACPI
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit bc51098cdd9573bfdecfd02fc8ed474419d73ea0 upstream.
Fix a problem with commit 311ee9c151ad ("rtc: cmos: allow using ACPI for RTC alarm instead of HPET") defining `use_acpi_alarm' module parameter even for non-ACPI platforms, which ignore it. Wrap the definition into #ifdef CONFIG_ACPI and use a static inline wrapper function, hardcoded to return 0 and consequently optimized away for !ACPI, following the existing pattern with HPET handling functions.
--- drivers/rtc/rtc-cmos.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
drivers/rtc/rtc-cmos.c +20 -7
@@ -50,6 +50,7 @@/* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ #include <linux/mc146818rtc.h> +#ifdef CONFIG_ACPI /* * Use ACPI SCI to replace HPET interrupt for RTC Alarm event *
@@ -61,6 +62,18 @@static bool use_acpi_alarm;module_param (use_acpi_alarm, bool,0444 ); +static inline int cmos_use_acpi_alarm (void ) +{ +return use_acpi_alarm; +} +#else /* !CONFIG_ACPI */ + +static inline int cmos_use_acpi_alarm (void ) +{ +return 0 ; +} +#endif +struct cmos_rtc {struct rtc_device *rtc;struct device *dev;
@@ -169,7 +182,7 @@ static inline int hpet_unregister_irq_ha/* Don't use HPET for RTC Alarm event if ACPI Fixed event is used */ static inline int use_hpet_alarm (void ) { -return is_hpet_enabled () && !use_acpi_alarm; +return is_hpet_enabled () && !cmos_use_acpi_alarm (); }/*----------------------------------------------------------------*/
@@ -340,7 +353,7 @@ static void cmos_irq_enable(struct cmos_if (use_hpet_alarm ())hpet_set_rtc_irq_bit (mask); -if ((mask &RTC_AIE ) && use_acpi_alarm) { +if ((mask &RTC_AIE ) &&cmos_use_acpi_alarm ()) {if (cmos->wake_on) cmos->wake_on (cmos->dev); }
@@ -358,7 +371,7 @@ static void cmos_irq_disable(struct cmosif (use_hpet_alarm ())hpet_mask_rtc_irq_bit (mask); -if ((mask &RTC_AIE ) && use_acpi_alarm) { +if ((mask &RTC_AIE ) &&cmos_use_acpi_alarm ()) {if (cmos->wake_off) cmos->wake_off (cmos->dev); }
@@ -980,7 +993,7 @@ static int cmos_suspend(struct device *d }spin_unlock_irq (&rtc_lock); -if ((tmp &RTC_AIE ) && !use_acpi_alarm) { +if ((tmp &RTC_AIE ) && !cmos_use_acpi_alarm ()) { cmos->enabled_wake =1 ;if (cmos->wake_on) cmos->wake_on (dev);
@@ -1031,7 +1044,7 @@ static void cmos_check_wkalrm(struct dev* ACPI RTC wake event is cleared after resume from STR, * ACK the rtc irq here */ -if (t_now >= cmos->alarm_expires && use_acpi_alarm) { +if (t_now >= cmos->alarm_expires &&cmos_use_acpi_alarm ()) {cmos_interrupt (0 , (void *)cmos->rtc);return ; }
@@ -1053,7 +1066,7 @@ static int __maybe_unused cmos_resume(ststruct cmos_rtc *cmos =dev_get_drvdata (dev);unsigned char tmp; -if (cmos->enabled_wake && !use_acpi_alarm) { +if (cmos->enabled_wake && !cmos_use_acpi_alarm ()) {if (cmos->wake_off) cmos->wake_off (dev);else
@@ -1132,7 +1145,7 @@ static u32 rtc_handler(void *context)* Or else, ACPI SCI is enabled during suspend/resume only, * update rtc irq in that case. */ -if (use_acpi_alarm) +if (cmos_use_acpi_alarm ())cmos_interrupt (0 , (void *)cmos->rtc);else {/* Fix me: can we use cmos_interrupt() here as well? */
Greg Kroah-Hartman
maintainerPATCH 289/361 ocxl: Fix access to the AFU Descriptor Data
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Lombard <[email protected]>
commit 6f8e45f7eb1bee5efdbe4a9cfe4a45627403c5fb upstream.
The AFU Information DVSEC capability is a means to extract common, general information about all of the AFUs associated with a Function independent of the specific functionality that each AFU provides. Write in the AFU Index field allows to access to the descriptor data for each AFU.
With the current code, we are not able to access to these specific data when the index >= 1 because we are writing to the wrong location. All requests to the data of each AFU are pointing to those of the AFU 0, which could have impacts when using a card with more than one AFU per function.
This patch fixes the access to the AFU Descriptor Data indexed by the AFU Info Index field.
--- drivers/misc/ocxl/config.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/misc/ocxl/config.c +3 -1
@@ -280,7 +280,9 @@ int ocxl_config_check_afu_index(struct pu32 val;int rc, templ_major, templ_minor, len; -pci_write_config_word (dev, fn->dvsec_afu_info_pos, afu_idx); +pci_write_config_byte (dev, + fn->dvsec_afu_info_pos +OCXL_DVSEC_AFU_INFO_AFU_IDX , + afu_idx); rc =read_afu_info (dev, fn,OCXL_DVSEC_TEMPL_VERSION , &val);if (rc)return rc;
Greg Kroah-Hartman
maintainerPATCH 297/361 media: cec: make cec_get_edid_spa_location() an inline function
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit b915bf575d5b7774d0f22d57d6c143e07dcaade2 upstream.
This function is needed by both V4L2 and CEC, so move this to cec.h as a static inline since there are no obvious shared modules between the two subsystems.
This patch, together with the following ones, fixes a dependency bug: if CEC_CORE is disabled, then building adv7604 (and other HDMI receivers) will fail because an essential function is now stubbed out.
--- drivers/media/cec/cec-edid.c | 60 ------------------------------------ include/media/cec.h | 70 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 60 deletions(-)
drivers/media/cec/cec-edid.c +0 -60
@@ -10,66 +10,6 @@#include <linux/types.h> #include <media/cec.h> -/* -* This EDID is expected to be a CEA-861 compliant, which means that there are -* at least two blocks and one or more of the extensions blocks are CEA-861 -* blocks. -* -* The returned location is guaranteed to be < size - 1. -*/ -static unsigned int cec_get_edid_spa_location (const u8 *edid,unsigned int size) -{ -unsigned int blocks = size /128 ; -unsigned int block; -u8 d; - -/* Sanity check: at least 2 blocks and a multiple of the block size */ -if (blocks <2 || size %128 ) -return 0 ; - -/* -* If there are fewer extension blocks than the size, then update -* 'blocks'. It is allowed to have more extension blocks than the size, -* since some hardware can only read e.g. 256 bytes of the EDID, even -* though more blocks are present. The first CEA-861 extension block -* should normally be in block 1 anyway. -*/ -if (edid[0x7e ] +1 < blocks) - blocks = edid[0x7e ] +1 ; - -for (block =1 ; block < blocks; block++) { -unsigned int offset = block *128 ; - -/* Skip any non-CEA-861 extension blocks */ -if (edid[offset] !=0x02 || edid[offset +1 ] !=0x03 ) -continue ; - -/* search Vendor Specific Data Block (tag 3) */ - d = edid[offset +2 ] &0x7f ; -/* Check if there are Data Blocks */ -if (d <=4 ) -continue ; -if (d >4 ) { -unsigned int i = offset +4 ; -unsigned int end = offset + d; - -/* Note: 'end' is always < 'size' */ -do { -u8 tag = edid[i] >>5 ; -u8 len = edid[i] &0x1f ; - -if (tag ==3 && len >=5 && i + len <= end && - edid[i +1 ] ==0x03 && - edid[i +2 ] ==0x0c && - edid[i +3 ] ==0x00 ) -return i +4 ; - i += len +1 ; - }while (i < end); - } - } -return 0 ; -} -u16 cec_get_edid_phys_addr (const u8 *edid,unsigned int size,unsigned int *offset) {
include/media/cec.h +70 -0
74 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 298/361 media: cec: integrate cec_validate_phys_addr() in cec-api.c
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit e81bff39489a06384822bb38ce7a59f9e365bbe9 upstream.
The cec_phys_addr_validate() function will be moved to V4L2, so use a simplified variant of that function in cec-api.c. cec now no longer calls cec_phys_addr_validate() and it can be safely moved to V4L2.
--- drivers/media/cec/cec-api.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/media/cec/cec-api.c +18 -1
@@ -101,6 +101,23 @@ static long cec_adap_g_phys_addr(structreturn 0 ; } +static int cec_validate_phys_addr (u16 phys_addr) +{ +int i; + +if (phys_addr ==CEC_PHYS_ADDR_INVALID ) +return 0 ; +for (i =0 ; i <16 ; i +=4 ) +if (phys_addr & (0xf << i)) +break ; +if (i ==16 ) +return 0 ; +for (i +=4 ; i <16 ; i +=4 ) +if ((phys_addr & (0xf << i)) ==0 ) +return -EINVAL ; +return 0 ; +} +static long cec_adap_s_phys_addr (struct cec_adapter *adap,struct cec_fh *fh,bool block,__u16 __user *parg) {
@@ -112,7 +129,7 @@ static long cec_adap_s_phys_addr(structif (copy_from_user (&phys_addr, parg,sizeof (phys_addr)))return -EFAULT ; - err =cec_phys_addr_validate (phys_addr,NULL ,NULL ); + err =cec_validate_phys_addr (phys_addr);if (err)return err;mutex_lock (&adap->lock);
Greg Kroah-Hartman
maintainerPATCH 300/361 xen: remove size limit of privcmd-buf mapping interface
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit 3941552aec1e04d63999988a057ae09a1c56ebeb upstream.
Currently the size of hypercall buffers allocated via /dev/xen/hypercall is limited to a default of 64 memory pages. For live migration of guests this might be too small as the page dirty bitmask needs to be sized according to the size of the guest. This means migrating a 8GB sized guest is already exhausting the default buffer size for the dirty bitmap.
There is no sensible way to set a sane limit, so just remove it completely. The device node's usage is limited to root anyway, so there is no additional DOS scenario added by allowing unlimited buffers.
While at it make the error path for the -ENOMEM case a little bit cleaner by setting n_pages to the number of successfully allocated pages instead of the target size.
--- drivers/xen/privcmd-buf.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-)
drivers/xen/privcmd-buf.c +4 -18
@@ -21,15 +21,9 @@MODULE_LICENSE ("GPL" ); -static unsigned int limit =64 ; -module_param (limit, uint,0644 ); -MODULE_PARM_DESC (limit,"Maximum number of pages that may be allocated by " -"the privcmd-buf device per open file" ); -struct privcmd_buf_private {struct mutex lock;struct list_head list; -unsigned int allocated; };struct privcmd_buf_vma_private {
@@ -60,13 +54,10 @@ static void privcmd_buf_vmapriv_free(str {unsigned int i; - vma_priv->file_priv->allocated -= vma_priv->n_pages; -list_del (&vma_priv->list);for (i =0 ; i < vma_priv->n_pages; i++) -if (vma_priv->pages[i]) -__free_page (vma_priv->pages[i]); +__free_page (vma_priv->pages[i]);kfree (vma_priv); }
@@ -146,8 +137,7 @@ static int privcmd_buf_mmap(struct fileunsigned int i;int ret =0 ; -if (!(vma->vm_flags &VM_SHARED ) || count > limit || - file_priv->allocated + count > limit) +if (!(vma->vm_flags &VM_SHARED ))return -EINVAL ; vma_priv = kzalloc(sizeof(*vma_priv) + count * sizeof(void *),
@@ -155,19 +145,15 @@ static int privcmd_buf_mmap(struct fileif (!vma_priv)return -ENOMEM ; - vma_priv->n_pages = count; - count =0 ; -for (i =0 ; i < vma_priv->n_pages; i++) { +for (i =0 ; i < count; i++) { vma_priv->pages[i] =alloc_page (GFP_KERNEL | __GFP_ZERO);if (!vma_priv->pages[i])break ; - count++; + vma_priv->n_pages++; }mutex_lock (&file_priv->lock); - file_priv->allocated += count; - vma_priv->file_priv = file_priv; vma_priv->users =1 ;
Greg Kroah-Hartman
maintainerPATCH 301/361 xen-blkfront: fix kernel panic with negotiate_mq error path
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manjunath Patil <[email protected]>
commit 6cc4a0863c9709c512280c64e698d68443ac8053 upstream.
info->nr_rings isn't adjusted in case of ENOMEM error from negotiate_mq(). This leads to kernel panic in error path.
Typical call stack involving panic -
#8 page_fault at ffffffff8175936f
[exception RIP: blkif_free_ring+33]
RIP: ffffffffa0149491 RSP: ffff8804f7673c08 RFLAGS: 00010292
...
#9 blkif_free at ffffffffa0149aaa [xen_blkfront]
#10 talk_to_blkback at ffffffffa014c8cd [xen_blkfront] #11 blkback_changed at ffffffffa014ea8b [xen_blkfront] #12 xenbus_otherend_changed at ffffffff81424670
#13 backend_changed at ffffffff81426dc3
#14 xenwatch_thread at ffffffff81422f29
#15 kthread at ffffffff810abe6a
#16 ret_from_fork at ffffffff81754078
--- drivers/block/xen-blkfront.c | 1 + 1 file changed, 1 insertion(+)
drivers/block/xen-blkfront.c +1 -0
@@ -1919,6 +1919,7 @@ static int negotiate_mq(struct blkfront_ GFP_KERNEL);if (!info->rinfo) {xenbus_dev_fatal (info->xbdev, -ENOMEM ,"allocating ring_info structure" ); + info->nr_rings =0 ;return -ENOMEM ; }
Greg Kroah-Hartman
maintainerPATCH 309/361 media: em28xx: fix handler for vidioc_s_input()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit 258c430456ba5f0005043762e14fc3be35983aaf upstream.
The a->index is not the name of the internal amux entry, but, instead a value from zero to the maximum number of audio inputs.
As the actual available inputs depend on each board, build it dynamically.
This is broken for a really long time. On a quick check, since at least commit 195a4ef627e1 ("V4L/DVB (6585): Convert em28xx to video_ioctl2") this was not implemented right.
--- drivers/media/usb/em28xx/em28xx-cards.c | 29 ++++++++++ drivers/media/usb/em28xx/em28xx-video.c | 86 ++++++++++++++++++++++++++++---- drivers/media/usb/em28xx/em28xx.h | 8 ++ 3 files changed, 113 insertions(+), 10 deletions(-)
drivers/media/usb/em28xx/em28xx-cards.c +29 -0
@@ -3039,6 +3039,9 @@ static int em28xx_hint_board(struct em28static void em28xx_card_setup (struct em28xx *dev) { +int i, j, idx; +bool duplicate_entry; +/* * If the device can be a webcam, seek for a sensor. * If sensor is not found, then it isn't a webcam.
@@ -3195,6 +3198,32 @@ static void em28xx_card_setup(struct em2/* Allow override tuner type by a module parameter */ if (tuner >=0 ) dev->tuner_type = tuner; + +/* +* Dynamically generate a list of valid audio inputs for this +* specific board, mapping them via enum em28xx_amux. +*/ + + idx =0 ; +for (i =0 ; i <MAX_EM28XX_INPUT ; i++) { +if (!INPUT (i)->type) +continue ; + +/* Skip already mapped audio inputs */ + duplicate_entry = false; +for (j =0 ; j < idx; j++) { +if (INPUT (i)->amux == dev->amux_map[j]) { + duplicate_entry = true; +break ; + } + } +if (duplicate_entry) +continue ; + + dev->amux_map[idx++] =INPUT (i)->amux; + } +for (; idx <MAX_EM28XX_INPUT ; idx++) + dev->amux_map[idx] =EM28XX_AMUX_UNUSED ; }void em28xx_setup_xc3028 (struct em28xx *dev,struct xc2028_ctrl *ctl)
drivers/media/usb/em28xx/em28xx-video.c +77 -9
138 lines not on this page · raw message
drivers/media/usb/em28xx/em28xx.h +7 -1
@@ -335,6 +335,9 @@ enum em28xx_usb_audio_type {/** * em28xx_amux - describes the type of audio input used by em28xx * +* @EM28XX_AMUX_UNUSED: +* Used only on em28xx dev->map field, in order to mark an entry +* as unused. * @EM28XX_AMUX_VIDEO: * On devices without AC97, this is the only value that it is currently * allowed.
@@ -369,7 +372,8 @@ enum em28xx_usb_audio_type {* same time, via the alsa mux. */ enum em28xx_amux { -EM28XX_AMUX_VIDEO , +EM28XX_AMUX_UNUSED =-1 , +EM28XX_AMUX_VIDEO =0 ,EM28XX_AMUX_LINE_IN ,/* Some less-common mixer setups */
@@ -692,6 +696,8 @@ struct em28xx {unsigned int ctl_input;// selected input unsigned int ctl_ainput;// selected audio input unsigned int ctl_aoutput;// selected audio output +enum em28xx_amux amux_map[MAX_EM28XX_INPUT ]; +int mute;int volume;
Greg Kroah-Hartman
maintainerPATCH 316/361 arm64: lse: remove -fcall-used-x0 flag
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tri Vo <[email protected]>
commit 2a6c7c367de82951c98a290a21156770f6f82c84 upstream.
x0 is not callee-saved in the PCS. So there is no need to specify -fcall-used-x0.
Clang doesn't currently support -fcall-used flags. This patch will help building the kernel with clang.
--- arch/arm64/lib/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/lib/Makefile +1 -1
@@ -12,7 +12,7 @@ lib-y := clear_user.o delay.o copy_from # when supported by the CPU. Result and argument registers are handled # correctly, based on the function prototype. lib-$(CONFIG_ARM64_LSE_ATOMICS) += atomic_ll_sc.o -CFLAGS_atomic_ll_sc.o := -fcall-used-x0 -ffixed-x1 -ffixed-x2 \ +CFLAGS_atomic_ll_sc.o := -ffixed-x1 -ffixed-x2 \ -ffixed-x3 -ffixed-x4 -ffixed-x5 -ffixed-x6 \ -ffixed-x7 -fcall-saved-x8 -fcall-saved-x9 \ -fcall-saved-x10 -fcall-saved-x11 -fcall-saved-x12 \
Greg Kroah-Hartman
maintainerPATCH 317/361 rpmsg: smd: fix memory leak on channel create
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit 940c620d6af8fca7d115de40f19870fba415efac upstream.
Currently a failed allocation of channel->name leads to an immediate return without freeing channel. Fix this by setting ret to -ENOMEM and jumping to an exit path that kfree's channel.
Detected by CoverityScan, CID#1473692 ("Resource Leak")
--- drivers/rpmsg/qcom_smd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/rpmsg/qcom_smd.c +5 -2
@@ -1122,8 +1122,10 @@ static struct qcom_smd_channel *qcom_smd channel->edge = edge; channel->name =kstrdup (name,GFP_KERNEL ); -if (!channel->name) -return ERR_PTR (-ENOMEM ); +if (!channel->name) { + ret = -ENOMEM ; + goto free_channel; + }spin_lock_init (&channel->tx_lock);spin_lock_init (&channel->recv_lock);
@@ -1173,6 +1175,7 @@ static struct qcom_smd_channel *qcom_smd free_name_and_channel:kfree (channel->name); +free_channel:kfree (channel);return ERR_PTR (ret);
Greg Kroah-Hartman
maintainerPATCH 318/361 Cramfs: fix abad comparison when wrap-arounds occur
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Pitre <[email protected]>
commit 672ca9dd13f1aca0c17516f76fc5b0e8344b3e46 upstream.
It is possible for corrupted filesystem images to produce very large block offsets that may wrap when a length is added, and wrongly pass the buffer size test.
--- fs/cramfs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cramfs/inode.c +2 -1
@@ -202,7 +202,8 @@ static void *cramfs_blkdev_read(struct scontinue ; blk_offset = (blocknr - buffer_blocknr[i]) <<PAGE_SHIFT ; blk_offset += offset; -if (blk_offset + len >BUFFER_SIZE ) +if (blk_offset >BUFFER_SIZE || + blk_offset + len >BUFFER_SIZE )continue ;return read_buffers[i] + blk_offset; }
Greg Kroah-Hartman
maintainerPATCH 321/361 soc: qcom: rmtfs-mem: Validate that scm is available
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Andersson <[email protected]>
commit 137dc5843faeacabf48fc22a8dc58c4e0b4f0927 upstream.
The scm device must be present in order for the rmtfs driver to configure memory permissions for the rmtfs memory region, so check that it is probed before continuing.
--- drivers/soc/qcom/rmtfs_mem.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/soc/qcom/rmtfs_mem.c +5 -0
@@ -212,6 +212,11 @@ static int qcom_rmtfs_mem_probe(struct pdev_err (&pdev->dev,"failed to parse qcom,vmid\n" ); goto remove_cdev; }else if (!ret) { +if (!qcom_scm_is_available ()) { + ret = -EPROBE_DEFER ; + goto remove_cdev; + } + perms[0 ].vmid =QCOM_SCM_VMID_HLOS ; perms[0 ].perm =QCOM_SCM_PERM_RW ; perms[1 ].vmid = vmid;
Greg Kroah-Hartman
maintainerPATCH 323/361 selftests/ftrace: Fix synthetic event test to delete event correctly
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu <[email protected]>
commit 0d0352d8b3d6d7ca9a710b40e194cbbaeb841c88 upstream.
Fix the synthetic event test case to remove event correctly. If redirecting command to synthetic_event file without append mode, it cleans up all existing events and execute (parse) the command. This means "delete event" always fails to find the target event.
Since previous synthetic event has a bug which doesn't return -ENOENT even if it fails to find the deleting event, this test passed. But fixing that bug, this test fails because this test itself has a bug.
This fixes that bug by trying to delete event right after adding an event, and use append mode redirection ('>>') instead of normal redirection ('>').
--- tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc | 12 +++++----- 1 file changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-synthetic-event-createremove.tc +6 -6
@@ -35,18 +35,18 @@ fi reset_trigger -echo "Test create synthetic event with an error" -echo 'wakeup_latency u64 lat pid_t pid char' > synthetic_events > /dev/null +echo "Test remove synthetic event" +echo '!wakeup_latency u64 lat pid_t pid char comm[16]' >> synthetic_events if [ -d events/synthetic/wakeup_latency ]; then - fail "Created wakeup_latency synthetic event with an invalid format" + fail "Failed to delete wakeup_latency synthetic event" fi reset_trigger -echo "Test remove synthetic event" -echo '!wakeup_latency u64 lat pid_t pid char comm[16]' > synthetic_events +echo "Test create synthetic event with an error" +echo 'wakeup_latency u64 lat pid_t pid char' > synthetic_events > /dev/null if [ -d events/synthetic/wakeup_latency ]; then - fail "Failed to delete wakeup_latency synthetic event" + fail "Created wakeup_latency synthetic event with an invalid format" fi do_reset
Greg Kroah-Hartman
maintainerPATCH 324/361 selftests/powerpc: Fix ptrace tm failure
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
commit 48dc0ef19044bfb69193302fbe3a834e3331b7ae upstream.
Test ptrace-tm-spd-gpr fails on current kernel (4.19) due to a segmentation fault that happens on the child process prior to setting cptr[2] = 1. This causes the parent process to wait forever at 'while (!pptr[2])' and the test to be killed by the test harness framework by timeout, thus, failing.
The segmentation fault happens because of a inline assembly being generated as:
0x10000355c <tm_spd_gpr+492> lfs f0, 0(0)
This is reading memory position 0x0 and causing the segmentation fault.
This code is being generated by ASM_LOAD_FPR_SINGLE_PRECISION(flt_4), where flt_4 is passed to the inline assembly block as:
[flt_4] "r" (&d)
Since the inline assembly 'r' constraint means any GPR, gpr0 is being chosen, thus causing this issue when issuing a Load Floating-Point Single instruction.
This patch simply changes the constraint to 'b', which specify that this register will be used as base, and r0 is not allowed to be used, avoiding this issue.
Other than that, removing flt_2 register from the input operands, since it is not used by the inline assembly code at all.
--- tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/powerpc/ptrace/ptrace-tm-spd-gpr.c +2 -2
@@ -67,8 +67,8 @@ trans:"3: ;" : [res] "=r" (result), [texasr] "=r" (texasr) : [gpr_1]"i"(GPR_1), [gpr_2]"i"(GPR_2), [gpr_4]"i"(GPR_4), - [sprn_texasr] "i" (SPRN_TEXASR), [flt_1] "r" (&a), - [flt_2] "r" (&b), [flt_4] "r" (&d) + [sprn_texasr] "i" (SPRN_TEXASR), [flt_1] "b" (&a), + [flt_4] "b" (&d) : "memory", "r5", "r6", "r7","r8" ,"r9" ,"r10" ,"r11" ,"r12" ,"r13" ,"r14" ,"r15" , "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
Greg Kroah-Hartman
maintainerPATCH 327/361 btrfs: Handle owner mismatch gracefully when walking up tree
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit 65c6e82becec33731f48786e5a30f98662c86b16 upstream.
[BUG]
When mounting certain crafted image, btrfs will trigger kernel BUG_ON() when trying to recover balance:
kernel BUG at fs/btrfs/extent-tree.c:8956!
invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
CPU: 1 PID: 662 Comm: mount Not tainted 4.18.0-rc1-custom+ #10 RIP: 0010:walk_up_proc+0x336/0x480 [btrfs] RSP: 0018:ffffb53540c9b890 EFLAGS: 00010202 Call Trace: walk_up_tree+0x172/0x1f0 [btrfs] btrfs_drop_snapshot+0x3a4/0x830 [btrfs] merge_reloc_roots+0xe1/0x1d0 [btrfs] btrfs_recover_relocation+0x3ea/0x420 [btrfs] open_ctree+0x1af3/0x1dd0 [btrfs] btrfs_mount_root+0x66b/0x740 [btrfs] mount_fs+0x3b/0x16a vfs_kern_mount.part.9+0x54/0x140 btrfs_mount+0x16d/0x890 [btrfs] mount_fs+0x3b/0x16a vfs_kern_mount.part.9+0x54/0x140 do_mount+0x1fd/0xda0 ksys_mount+0xba/0xd0 __x64_sys_mount+0x21/0x30 do_syscall_64+0x60/0x210 entry_SYSCALL_64_after_hwframe+0x49/0xbe
[CAUSE]
Extent tree corruption. In this particular case, reloc tree root's owner is DATA_RELOC_TREE (should be TREE_RELOC), thus its backref is corrupted and we failed the owner check in walk_up_tree().
[FIX]
It's pretty hard to take care of every extent tree corruption, but at least we can remove such BUG_ON() and exit more gracefully.
And since in this particular image, DATA_RELOC_TREE and TREE_RELOC share the same root (which is obviously invalid), we needs to make __del_reloc_root() more robust to detect such invalid sharing to avoid possible NULL dereference as root->node can be NULL in this case.
--- fs/btrfs/extent-tree.c | 18 ++++++++++++------ fs/btrfs/relocation.c | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-)
fs/btrfs/extent-tree.c +12 -6
@@ -8763,15 +8763,14 @@ static noinline int walk_up_proc(structif (eb == root->node) {if (wc->flags[level] &BTRFS_BLOCK_FLAG_FULL_BACKREF ) parent = eb->start; -else -BUG_ON (root->root_key.objectid != -btrfs_header_owner (eb)); +else if (root->root_key.objectid !=btrfs_header_owner (eb)) + goto owner_mismatch; }else {if (wc->flags[level +1 ] &BTRFS_BLOCK_FLAG_FULL_BACKREF ) parent = path->nodes[level +1 ]->start; -else -BUG_ON (root->root_key.objectid != -btrfs_header_owner (path->nodes[level +1 ])); +else if (root->root_key.objectid != +btrfs_header_owner (path->nodes[level +1 ])) + goto owner_mismatch; }btrfs_free_tree_block (trans, root, eb, parent, wc->refs[level] ==1 );
@@ -8779,6 +8778,11 @@ out: wc->refs[level] =0 ; wc->flags[level] =0 ;return 0 ; + +owner_mismatch: +btrfs_err_rl (fs_info,"unexpected tree owner, have %llu expect %llu" , +btrfs_header_owner (eb), root->root_key.objectid); +return -EUCLEAN ; } static noinline int walk_down_tree(struct btrfs_trans_handle *trans,
@@ -8832,6 +8836,8 @@ static noinline int walk_up_tree(struct ret =walk_up_proc (trans, root, path, wc);if (ret >0 )return 0 ; +if (ret <0 ) +return ret;if (path->locks[level]) { btrfs_tree_unlock_rw(path->nodes[level],
fs/btrfs/relocation.c +1 -1
@@ -1281,7 +1281,7 @@ static void __del_reloc_root(struct btrfstruct mapping_node *node =NULL ;struct reloc_control *rc = fs_info->reloc_ctl; -if (rc) { +if (rc && root->node) {spin_lock (&rc->reloc_root_tree.lock); rb_node =tree_search (&rc->reloc_root_tree.rb_root, root->node->start);
Greg Kroah-Hartman
maintainerPATCH 329/361 btrfs: fix error handling in free_log_tree
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Mahoney <[email protected]>
commit 374b0e2d6ba5da7fd1cadb3247731ff27d011f6f upstream.
When we hit an I/O error in free_log_tree->walk_log_tree during file system shutdown we can crash due to there not being a valid transaction handle.
Use btrfs_handle_fs_error when there's no transaction handle to use.
BUG: unable to handle kernel NULL pointer dereference at 0000000000000060 IP: free_log_tree+0xd2/0x140 [btrfs] PGD 0 P4D 0 Oops: 0000 [#1] SMP DEBUG_PAGEALLOC PTI Modules linked in: <modules> CPU: 2 PID: 23544 Comm: umount Tainted: G W 4.12.14-kvmsmall #9 SLE15 (unreleased) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014 task: ffff96bfd3478880 task.stack: ffffa7cf40d78000 RIP: 0010:free_log_tree+0xd2/0x140 [btrfs] RSP: 0018:ffffa7cf40d7bd10 EFLAGS: 00010282 RAX: 00000000fffffffb RBX: 00000000fffffffb RCX: 0000000000000002 RDX: 0000000000000000 RSI: ffff96c02f07d4c8 RDI: 0000000000000282 RBP: ffff96c013cf1000 R08: ffff96c02f07d4c8 R09: ffff96c02f07d4d0 R10: 0000000000000000 R11: 0000000000000002 R12: 0000000000000000 R13: ffff96c005e800c0 R14: ffffa7cf40d7bdb8 R15: 0000000000000000 FS: 00007f17856bcfc0(0000) GS:ffff96c03f600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000060 CR3: 0000000045ed6002 CR4: 00000000003606e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: ? wait_for_writer+0xb0/0xb0 [btrfs] btrfs_free_log+0x17/0x30 [btrfs] btrfs_drop_and_free_fs_root+0x9a/0xe0 [btrfs] btrfs_free_fs_roots+0xc0/0x130 [btrfs] ? wait_for_completion+0xf2/0x100 close_ctree+0xea/0x2e0 [btrfs] ? kthread_stop+0x161/0x260 generic_shutdown_super+0x6c/0x120 kill_anon_super+0xe/0x20 btrfs_kill_super+0x13/0x100 [btrfs] deactivate_locked_super+0x3f/0x70 cleanup_mnt+0x3b/0x70 task_work_run+0x78/0x90 exit_to_usermode_loop+0x77/0xa6 do_syscall_64+0x1c5/0x1e0 entry_SYSCALL_64_after_hwframe+0x42/0xb7 RIP: 0033:0x7f1784f90827 RSP: 002b:00007ffdeeb03118 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6 RAX: 0000000000000000 RBX: 0000556a60c62970 RCX: 00007f1784f90827 RDX: 0000000000000001 RSI: 0000000000000000 RDI: 0000556a60c62b50 RBP: 0000000000000000 R08: 0000000000000005 R09: 00000000ffffffff R10: 0000556a60c63900 R11: 0000000000000246 R12: 0000556a60c62b50 R13: 00007f17854a81c4 R14: 0000000000000000 R15: 0000000000000000 RIP: free_log_tree+0xd2/0x140 [btrfs] RSP: ffffa7cf40d7bd10 CR2: 0000000000000060
--- fs/btrfs/tree-log.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/btrfs/tree-log.c +6 -3
@@ -3196,9 +3196,12 @@ static void free_log_tree(struct btrfs_t }; ret =walk_log_tree (trans, log, &wc); -/* I don't think this can happen but just in case */ -if (ret) -btrfs_abort_transaction (trans, ret); +if (ret) { +if (trans) +btrfs_abort_transaction (trans, ret); +else +btrfs_handle_fs_error (log->fs_info, ret,NULL ); + }while (1 ) { ret = find_first_extent_bit(&log->dirty_log_pages,
Greg Kroah-Hartman
maintainerPATCH 330/361 btrfs: fix error handling in btrfs_dev_replace_start
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Mahoney <[email protected]>
commit 5c06147128fbbdf7a84232c5f0d808f53153defe upstream.
When we fail to start a transaction in btrfs_dev_replace_start, we leave dev_replace->replace_start set to STARTED but clear ->srcdev and ->tgtdev. Later, that can result in an Oops in btrfs_dev_replace_progress when having state set to STARTED or SUSPENDED implies that ->srcdev is valid.
Also fix error handling when the state is already STARTED or SUSPENDED while starting. That, too, will clear ->srcdev and ->tgtdev even though it doesn't own them. This should be an impossible case to hit since we should be protected by the BTRFS_FS_EXCL_OP bit being set. Let's add an ASSERT there while we're at it.
--- fs/btrfs/dev-replace.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/btrfs/dev-replace.c +5 -2
@@ -440,6 +440,7 @@ int btrfs_dev_replace_start(struct btrfsbreak ;case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED :case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED : +ASSERT (0 ); ret =BTRFS_IOCTL_DEV_REPLACE_RESULT_ALREADY_STARTED ; goto leave; }
@@ -482,6 +483,10 @@ int btrfs_dev_replace_start(struct btrfsif (IS_ERR (trans)) { ret =PTR_ERR (trans);btrfs_dev_replace_write_lock (dev_replace); + dev_replace->replace_state = +BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED ; + dev_replace->srcdev =NULL ; + dev_replace->tgtdev =NULL ; goto leave; }
@@ -503,8 +508,6 @@ int btrfs_dev_replace_start(struct btrfsreturn ret; leave: - dev_replace->srcdev =NULL ; - dev_replace->tgtdev =NULL ;btrfs_dev_replace_write_unlock (dev_replace);btrfs_destroy_dev_replace_tgtdev (tgt_device);return ret;
Greg Kroah-Hartman
maintainerPATCH 337/361 Btrfs: dont clean dirty pages during buffered writes
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Mason <[email protected]>
commit 7703bdd8d23e6ef057af3253958a793ec6066b28 upstream.
During buffered writes, we follow this basic series of steps:
again:
lock all the pages
wait for writeback on all the pages Take the extent range lock
wait for ordered extents on the whole range clean all the pages
if (copy_from_user_in_atomic() hits a fault) {
drop our locks
goto again;
}
dirty all the pages
release all the locks
The extra waiting, cleaning and locking are there to make sure we don't modify pages in flight to the drive, after they've been crc'd.
If some of the pages in the range were already dirty when the write began, and we need to goto again, we create a window where a dirty page has been cleaned and unlocked. It may be reclaimed before we're able to lock it again, which means we'll read the old contents off the drive and lose any modifications that had been pending writeback.
We don't actually need to clean the pages. All of the other locking in place makes sure we don't start IO on the pages, so we can just leave them dirty for the duration of the write.
--- fs/btrfs/file.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)
fs/btrfs/file.c +23 -6
@@ -531,6 +531,14 @@ int btrfs_dirty_pages(struct inode *inod end_of_last_block = start_pos + num_bytes -1 ; +/* +* The pages may have already been dirty, clear out old accounting so +* we can set things up properly +*/ +clear_extent_bit (&BTRFS_I (inode)->io_tree, start_pos, end_of_last_block, +EXTENT_DIRTY |EXTENT_DELALLOC | +EXTENT_DO_ACCOUNTING |EXTENT_DEFRAG ,0 ,0 , cached); +if (!btrfs_is_free_space_inode (BTRFS_I (inode))) {if (start_pos >= isize && !(BTRFS_I (inode)->flags &BTRFS_INODE_PREALLOC )) {
@@ -1500,18 +1508,27 @@ lock_and_cleanup_extent_if_need(struct b }if (ordered)btrfs_put_ordered_extent (ordered); -clear_extent_bit (&inode->io_tree, start_pos, last_pos, -EXTENT_DIRTY |EXTENT_DELALLOC | -EXTENT_DO_ACCOUNTING |EXTENT_DEFRAG , -0 ,0 , cached_state); + *lockstart = start_pos; *lockend = last_pos; ret =1 ; } +/* +* It's possible the pages are dirty right now, but we don't want +* to clean them yet because copy_from_user may catch a page fault +* and we might have to fall back to one page at a time. If that +* happens, we'll unlock these pages and we'd have a window where +* reclaim could sneak in and drop the once-dirty page on the floor +* without writing it. +* +* We have the pages locked and the extent range locked, so there's +* no way someone can start IO on any dirty pages in this range. +* +* We'll call btrfs_dirty_pages() later on, and that will flip around +* delalloc bits and dirty the pages as required. +*/ for (i =0 ; i < num_pages; i++) { -if (clear_page_dirty_for_io (pages[i])) -account_page_redirty (pages[i]);set_page_extent_mapped (pages[i]);WARN_ON (!PageLocked (pages[i])); }
Greg Kroah-Hartman
maintainerPATCH 340/361 btrfs: reset max_extent_size on clear in a bitmap
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 553cceb49681d60975d00892877d4c871bf220f9 upstream.
We need to clear the max_extent_size when we clear bits from a bitmap since it could have been from the range that contains the max_extent_size.
--- fs/btrfs/free-space-cache.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/free-space-cache.c +2 -0
@@ -1687,6 +1687,8 @@ static inline void __bitmap_clear_bits(sbitmap_clear (info->bitmap, start, count); info->bytes -= bytes; +if (info->max_extent_size > ctl->unit) + info->max_extent_size =0 ; } static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
Greg Kroah-Hartman
maintainerPATCH 353/361 btrfs: dont run delayed_iputs in commit
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 30928e9baac238a7330085a1c5747f0b5df444b4 upstream.
This could result in a really bad case where we do something like
evict
evict_refill_and_join
btrfs_commit_transaction
btrfs_run_delayed_iputs
evict
evict_refill_and_join
btrfs_commit_transaction
... forever
We have plenty of other places where we run delayed iputs that are much safer, let those do the work.
--- fs/btrfs/transaction.c | 9 --------- 1 file changed, 9 deletions(-)
fs/btrfs/transaction.c +0 -9
@@ -2280,15 +2280,6 @@ int btrfs_commit_transaction(struct btrfkmem_cache_free (btrfs_trans_handle_cachep, trans); -/* -* If fs has been frozen, we can not handle delayed iputs, otherwise -* it'll result in deadlock about SB_FREEZE_FS. -*/ -if (current != fs_info->transaction_kthread && - current != fs_info->cleaner_kthread && - !test_bit (BTRFS_FS_FROZEN , &fs_info->flags)) -btrfs_run_delayed_iputs (fs_info); -return ret; scrub_continue:
Greg Kroah-Hartman
maintainerPATCH 361/361 vga_switcheroo: Fix missing gpu_bound call at audio client registration
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit fc09ab7a767394f9ecdad84ea6e85d68b83c8e21 upstream.
The commit 37a3a98ef601 ("ALSA: hda - Enable runtime PM only for discrete GPU") added a new ops gpu_bound to be called when GPU gets bound. The patch overlooked, however, that vga_switcheroo_enable() is called only once at GPU is bound. When an audio client is registered after that point, it would miss the gpu_bound call. This leads to the unexpected lack of runtime PM in HD-audio side.
For addressing that regression, just call gpu_bound callback manually at vga_switcheroo_register_audio_client() when the GPU was already bound.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201615
--- drivers/gpu/vga/vga_switcheroo.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/vga/vga_switcheroo.c +3 -0
@@ -380,6 +380,9 @@ int vga_switcheroo_register_audio_clientmutex_unlock (&vgasr_mutex);return -EINVAL ; } +/* notify if GPU has been already bound */ +if (ops->gpu_bound) + ops->gpu_bound (pdev, id); }mutex_unlock (&vgasr_mutex);
Greg Kroah-Hartman
maintainerPATCH 13/361 bcache: fix ioctl in flash device
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tang Junhui <[email protected]>
commit dd0c91793b7c2658ea32c6b3a2247a8ceca45dc0 upstream.
When doing ioctl in flash device, it will call ioctl_dev() in super.c, then we should not to get cached device since flash only device has no backend device. This patch just move the jugement dc->io_disable to cached_dev_ioctl() to make ioctl in flash device correctly.
--- drivers/md/bcache/request.c | 3 +++ drivers/md/bcache/super.c | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/md/bcache/request.c +3 -0
@@ -1218,6 +1218,9 @@ static int cached_dev_ioctl(struct bcach { struct cached_dev *dc = container_of(d, struct cached_dev, disk); +if (dc->io_disable) +return -EIO ; +return __blkdev_driver_ioctl (dc->bdev, mode, cmd, arg); }
drivers/md/bcache/super.c +0 -4
@@ -643,10 +643,6 @@ static int ioctl_dev(struct block_device unsigned int cmd, unsigned long arg) {struct bcache_device *d = b->bd_disk->private_data; - struct cached_dev *dc = container_of(d, struct cached_dev, disk); - -if (dc->io_disable) -return -EIO ;return d->ioctl (d, mode, cmd, arg); }
Greg Kroah-Hartman
maintainerPATCH 16/361 hwmon: (pmbus) Fix page count auto-detection.
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Bazhenov <[email protected]>
commit e7c6a55606b5c46b449d76588968b4d8caae903f upstream.
Devices with compatible="pmbus" field have zero initial page count, and pmbus_clear_faults() being called before the page count auto- detection does not actually clear faults because it depends on the page count. Non-cleared faults in its turn may fail the subsequent page count auto-detection.
This patch fixes this problem by calling pmbus_clear_fault_page() for currently set page and calling pmbus_clear_faults() after the page count was detected.
--- drivers/hwmon/pmbus/pmbus.c | 2 ++ drivers/hwmon/pmbus/pmbus_core.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/hwmon/pmbus/pmbus.c +2 -0
@@ -118,6 +118,8 @@ static int pmbus_identify(struct i2c_cli }else { info->pages =1 ; } + +pmbus_clear_faults (client); }if (pmbus_check_byte_register (client,0 ,PMBUS_VOUT_MODE )) {
drivers/hwmon/pmbus/pmbus_core.c +4 -1
@@ -2015,7 +2015,10 @@ static int pmbus_init_common(struct i2c_if (ret >=0 && (ret &PB_CAPABILITY_ERROR_CHECK )) client->flags |=I2C_CLIENT_PEC ; -pmbus_clear_faults (client); +if (data->info->pages) +pmbus_clear_faults (client); +else +pmbus_clear_fault_page (client,-1 );if (info->identify) { ret = (*info->identify)(client, info);
Greg Kroah-Hartman
maintainerPATCH 17/361 jffs2: free jffs2_sb_info through jffs2_kill_sb()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hou Tao <[email protected]>
commit 92e2921f7eee63450a5f953f4b15dc6210219430 upstream.
When an invalid mount option is passed to jffs2, jffs2_parse_options() will fail and jffs2_sb_info will be freed, but then jffs2_sb_info will be used (use-after-free) and freeed (double-free) in jffs2_kill_sb().
Fix it by removing the buggy invocation of kfree() when getting invalid mount options.
--- fs/jffs2/super.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/jffs2/super.c +1 -3
@@ -285,10 +285,8 @@ static int jffs2_fill_super(struct super sb->s_fs_info = c; ret =jffs2_parse_options (c, data); -if (ret) { -kfree (c); +if (ret)return -EINVAL ; - }/* Initialize JFFS2 superblock locks, the further initialization will * be done later */
Greg Kroah-Hartman
maintainerPATCH 21/361 cpufreq: conservative: Take limits changes into account properly
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
commit da5e79bc70b84971d2b3a55fb252e34e51d81d48 upstream.
If the policy limits change between invocations of cs_dbs_update(), the requested frequency value stored in dbs_info may not be updated and the function may use a stale value of it next time. Moreover, if idle periods are takem into account by cs_dbs_update(), the requested frequency value stored in dbs_info may be below the min policy limit, which is incorrect.
To fix these problems, always update the requested frequency value in dbs_info along with the local copy of it when the previous requested frequency is beyond the policy limits and avoid decreasing the requested frequency below the min policy limit when taking idle periods into account.
--- drivers/cpufreq/cpufreq_conservative.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq_conservative.c +4 -2
@@ -80,8 +80,10 @@ static unsigned int cs_dbs_update(struct* changed in the meantime, so fall back to current frequency in that * case. */ -if (requested_freq > policy->max || requested_freq < policy->min) +if (requested_freq > policy->max || requested_freq < policy->min) { requested_freq = policy->cur; + dbs_info->requested_freq = requested_freq; + } freq_step =get_freq_step (cs_tuners, policy);
@@ -92,7 +94,7 @@ static unsigned int cs_dbs_update(structif (policy_dbs->idle_periods <UINT_MAX ) {unsigned int freq_steps = policy_dbs->idle_periods * freq_step; -if (requested_freq > freq_steps) +if (requested_freq > policy->min + freq_steps) requested_freq -= freq_steps;else requested_freq = policy->min;
Greg Kroah-Hartman
maintainerPATCH 42/361 x86/xen: Fix boot loader version reported for PVH guests
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit 357d291ce035d1b757568058f3c9898c60d125b1 upstream.
The boot loader version reported via sysfs is wrong in case of the kernel being booted via the Xen PVH boot entry. it should be 2.12 (0x020c), but it is reported to be 2.18 (0x0212).
As the current way to set the version is error prone use the more readable variant (2 << 8) | 12.
--- arch/x86/xen/enlighten_pvh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/xen/enlighten_pvh.c +1 -1
@@ -75,7 +75,7 @@ static void __init init_pvh_bootparams(v* Version 2.12 supports Xen entry point but we will use default x86/PC * environment (i.e. hardware_subarch 0). */ - pvh_bootparams.hdr.version =0x212 ; + pvh_bootparams.hdr.version = (2 <<8 ) |12 ; pvh_bootparams.hdr.type_of_loader = (9 <<4 ) |0 ;/* Xen loader */ x86_init.acpi.get_root_pointer = pvh_get_root_pointer;
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Greg Kroah-Hartman
maintainerPATCH 27/361 acpi, nfit: Fix Address Range Scrub completion tracking
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
commit d3abaf43bab8d5b0a3c6b982100d9e2be96de4ad upstream.
The Address Range Scrub implementation tried to skip running scrubs against ranges that were already scrubbed by the BIOS. Unfortunately that support also resulted in early scrub completions as evidenced by this debug output from nfit_test:
nd_region region9: ARS: range 1 short complete nd_region region3: ARS: range 1 short complete nd_region region4: ARS: range 2 ARS start (0) nd_region region4: ARS: range 2 short complete
...i.e. completions without any indications that the scrub was started.
This state of affairs was hard to see in the code due to the proliferation of state bits and mistakenly trying to track done state per-range when the completion is a global property of the bus.
So, kill the four ARS state bits (ARS_REQ, ARS_REQ_REDO, ARS_DONE, and ARS_SHORT), and replace them with just 2 request flags ARS_REQ_SHORT and ARS_REQ_LONG. The implementation will still complete and reap the results of BIOS initiated ARS, but it will not attempt to use that information to affect the completion status of scrubbing the ranges from a Linux perspective.
Instead, try to synchronously run a short ARS per range at init time and schedule a long scrub in the background. If ARS is busy with an ARS request, schedule both a short and a long scrub for when ARS returns to idle. This logic also satisfies the intent of what ARS_REQ_REDO was trying to achieve. The new rule is that the REQ flag stays set until the next successful ars_start() for that range.
With the new policy that the REQ flags are not cleared until the next start, the implementation no longer loses requests as can be seen from the following log:
nd_region region3: ARS: range 1 ARS start short (0) nd_region region9: ARS: range 1 ARS start short (0) nd_region region3: ARS: range 1 complete nd_region region4: ARS: range 2 ARS start short (0) nd_region region9: ARS: range 1 complete nd_region region9: ARS: range 1 ARS start long (0) nd_region region4: ARS: range 2 complete nd_region region3: ARS: range 1 ARS start long (0) nd_region region9: ARS: range 1 complete nd_region region3: ARS: range 1 complete nd_region region4: ARS: range 2 ARS start long (0) nd_region region4: ARS: range 2 complete
...note that the nfit_test emulated driver provides 2 buses, that is why some of the range indices are duplicated. Notice that each range now successfully completes a short and long scrub.
--- drivers/acpi/nfit/core.c | 167 ++++++++++++++++++++++++++--------------------- drivers/acpi/nfit/nfit.h | 10 +- 2 files changed, 100 insertions(+), 77 deletions(-)
drivers/acpi/nfit/core.c +95 -72
@@ -2466,7 +2466,8 @@ static int ars_get_cap(struct acpi_nfit_return cmd_rc; } -static int ars_start (struct acpi_nfit_desc *acpi_desc,struct nfit_spa *nfit_spa) +static int ars_start (struct acpi_nfit_desc *acpi_desc, +struct nfit_spa *nfit_spa,enum nfit_ars_state req_type) {int rc;int cmd_rc;
@@ -2477,7 +2478,7 @@ static int ars_start(struct acpi_nfit_dememset (&ars_start,0 ,sizeof (ars_start)); ars_start.address = spa->address; ars_start.length = spa->length; -if (test_bit (ARS_SHORT , &nfit_spa->ars_state)) +if (req_type ==ARS_REQ_SHORT ) ars_start.flags =ND_ARS_RETURN_PREV_DATA ;if (nfit_spa_type (spa) ==NFIT_SPA_PM ) ars_start.type =ND_ARS_PERSISTENT ;
@@ -2534,6 +2535,15 @@ static void ars_complete(struct acpi_nfistruct nd_region *nd_region = nfit_spa->nd_region;struct device *dev; +lockdep_assert_held (&acpi_desc->init_mutex); +/* +* Only advance the ARS state for ARS runs initiated by the +* kernel, ignore ARS results from BIOS initiated runs for scrub +* completion tracking. +*/ +if (acpi_desc->scrub_spa != nfit_spa) +return ; +if ((ars_status->address >= spa->address && ars_status->address < spa->address + spa->length) || (ars_status->address < spa->address)) {
@@ -2553,28 +2563,13 @@ static void ars_complete(struct acpi_nfi }else return ; -if (test_bit (ARS_DONE , &nfit_spa->ars_state)) -return ; - -if (!test_and_clear_bit (ARS_REQ , &nfit_spa->ars_state)) -return ; - + acpi_desc->scrub_spa =NULL ;if (nd_region) { dev =nd_region_dev (nd_region);nvdimm_region_notify (nd_region,NVDIMM_REVALIDATE_POISON ); }else dev = acpi_desc->dev; - -dev_dbg (dev,"ARS: range %d %s complete\n" , spa->range_index, -test_bit (ARS_SHORT , &nfit_spa->ars_state) - ?"short" :"long" ); -clear_bit (ARS_SHORT , &nfit_spa->ars_state); -if (test_and_clear_bit (ARS_REQ_REDO , &nfit_spa->ars_state)) { -set_bit (ARS_SHORT , &nfit_spa->ars_state); -set_bit (ARS_REQ , &nfit_spa->ars_state); -dev_dbg (dev,"ARS: processing scrub request received while in progress\n" ); - }else -set_bit (ARS_DONE , &nfit_spa->ars_state); +dev_dbg (dev,"ARS: range %d complete\n" , spa->range_index); }static int ars_status_process_records (struct acpi_nfit_desc *acpi_desc)
@@ -2855,46 +2850,55 @@ static int acpi_nfit_query_poison(structreturn 0 ; } -static int ars_register (struct acpi_nfit_desc *acpi_desc,struct nfit_spa *nfit_spa, -int *query_rc) +static int ars_register (struct acpi_nfit_desc *acpi_desc, +struct nfit_spa *nfit_spa) { -int rc = *query_rc; +int rc; -if (no_init_ars) +if (no_init_ars ||test_bit (ARS_FAILED , &nfit_spa->ars_state))return acpi_nfit_register_region (acpi_desc, nfit_spa); -set_bit (ARS_REQ , &nfit_spa->ars_state); -set_bit (ARS_SHORT , &nfit_spa->ars_state); +set_bit (ARS_REQ_SHORT , &nfit_spa->ars_state); +set_bit (ARS_REQ_LONG , &nfit_spa->ars_state); -switch (rc) { +switch (acpi_nfit_query_poison (acpi_desc)) {case 0 :case -EAGAIN : - rc =ars_start (acpi_desc, nfit_spa); -if (rc == -EBUSY ) { - *query_rc = rc; + rc =ars_start (acpi_desc, nfit_spa,ARS_REQ_SHORT ); +/* shouldn't happen, try again later */ +if (rc == -EBUSY )break ; - }else if (rc ==0 ) { - rc =acpi_nfit_query_poison (acpi_desc); - }else { +if (rc) {set_bit (ARS_FAILED , &nfit_spa->ars_state);break ; } -if (rc == -EAGAIN ) -clear_bit (ARS_SHORT , &nfit_spa->ars_state); -else if (rc ==0 ) -ars_complete (acpi_desc, nfit_spa); +clear_bit (ARS_REQ_SHORT , &nfit_spa->ars_state); + rc =acpi_nfit_query_poison (acpi_desc); +if (rc) +break ; + acpi_desc->scrub_spa = nfit_spa; +ars_complete (acpi_desc, nfit_spa); +/* +* If ars_complete() says we didn't complete the +* short scrub, we'll try again with a long +* request. +*/ + acpi_desc->scrub_spa =NULL ;break ;case -EBUSY : +case -ENOMEM :case -ENOSPC : +/* +* BIOS was using ARS, wait for it to complete (or +* resources to become available) and then perform our +* own scrubs. +*/ break ;default :set_bit (ARS_FAILED , &nfit_spa->ars_state);break ; } -if (test_and_clear_bit (ARS_DONE , &nfit_spa->ars_state)) -set_bit (ARS_REQ , &nfit_spa->ars_state); -return acpi_nfit_register_region (acpi_desc, nfit_spa); }
@@ -2916,6 +2920,8 @@ static unsigned int __acpi_nfit_scrub(ststruct device *dev = acpi_desc->dev;struct nfit_spa *nfit_spa; +lockdep_assert_held (&acpi_desc->init_mutex); +if (acpi_desc->cancel)return 0 ;
@@ -2939,21 +2945,49 @@ static unsigned int __acpi_nfit_scrub(stars_complete_all (acpi_desc);list_for_each_entry (nfit_spa, &acpi_desc->spas, list) { +enum nfit_ars_state req_type; +int rc; +if (test_bit (ARS_FAILED , &nfit_spa->ars_state))continue ; -if (test_bit (ARS_REQ , &nfit_spa->ars_state)) { -int rc =ars_start (acpi_desc, nfit_spa); -clear_bit (ARS_DONE , &nfit_spa->ars_state); - dev =nd_region_dev (nfit_spa->nd_region); -dev_dbg (dev,"ARS: range %d ARS start (%d)\n" , - nfit_spa->spa->range_index, rc); -if (rc ==0 || rc == -EBUSY ) -return 1 ; -dev_err (dev,"ARS: range %d ARS failed (%d)\n" , - nfit_spa->spa->range_index, rc); -set_bit (ARS_FAILED , &nfit_spa->ars_state); +/* prefer short ARS requests first */ +if (test_bit (ARS_REQ_SHORT , &nfit_spa->ars_state)) + req_type =ARS_REQ_SHORT ; +else if (test_bit (ARS_REQ_LONG , &nfit_spa->ars_state)) + req_type =ARS_REQ_LONG ; +else +continue ; + rc =ars_start (acpi_desc, nfit_spa, req_type); + + dev =nd_region_dev (nfit_spa->nd_region); +dev_dbg (dev,"ARS: range %d ARS start %s (%d)\n" , + nfit_spa->spa->range_index, + req_type ==ARS_REQ_SHORT ?"short" :"long" , + rc); +/* +* Hmm, we raced someone else starting ARS? Try again in +* a bit. +*/ +if (rc == -EBUSY ) +return 1 ; +if (rc ==0 ) { +dev_WARN_ONCE (dev, acpi_desc->scrub_spa, +"scrub start while range %d active\n" , + acpi_desc->scrub_spa->spa->range_index); +clear_bit (req_type, &nfit_spa->ars_state); + acpi_desc->scrub_spa = nfit_spa; +/* +* Consider this spa last for future scrub +* requests +*/ +list_move_tail (&nfit_spa->list, &acpi_desc->spas); +return 1 ; } + +dev_err (dev,"ARS: range %d ARS failed (%d)\n" , + nfit_spa->spa->range_index, rc); +set_bit (ARS_FAILED , &nfit_spa->ars_state); }return 0 ; }
@@ -3009,6 +3043,7 @@ static void acpi_nfit_init_ars(struct acstruct nd_cmd_ars_cap ars_cap;int rc; +set_bit (ARS_FAILED , &nfit_spa->ars_state);memset (&ars_cap,0 ,sizeof (ars_cap)); rc =ars_get_cap (acpi_desc, &ars_cap, nfit_spa);if (rc <0 )
@@ -3025,16 +3060,14 @@ static void acpi_nfit_init_ars(struct ac nfit_spa->clear_err_unit = ars_cap.clear_err_unit; acpi_desc->max_ars =max (nfit_spa->max_ars, acpi_desc->max_ars);clear_bit (ARS_FAILED , &nfit_spa->ars_state); -set_bit (ARS_REQ , &nfit_spa->ars_state); }static int acpi_nfit_register_regions (struct acpi_nfit_desc *acpi_desc) {struct nfit_spa *nfit_spa; -int rc, query_rc; +int rc;list_for_each_entry (nfit_spa, &acpi_desc->spas, list) { -set_bit (ARS_FAILED , &nfit_spa->ars_state);switch (nfit_spa_type (nfit_spa->spa)) {case NFIT_SPA_VOLATILE :case NFIT_SPA_PM :
@@ -3043,20 +3076,12 @@ static int acpi_nfit_register_regions(st } } -/* -* Reap any results that might be pending before starting new -* short requests. -*/ - query_rc =acpi_nfit_query_poison (acpi_desc); -if (query_rc ==0 ) -ars_complete_all (acpi_desc); -list_for_each_entry (nfit_spa, &acpi_desc->spas, list)switch (nfit_spa_type (nfit_spa->spa)) {case NFIT_SPA_VOLATILE :case NFIT_SPA_PM :/* register regions and kick off initial ARS run */ - rc =ars_register (acpi_desc, nfit_spa, &query_rc); + rc =ars_register (acpi_desc, nfit_spa);if (rc)return rc;break ;
@@ -3251,7 +3276,8 @@ static int acpi_nfit_clear_to_send(strucreturn 0 ; } -int acpi_nfit_ars_rescan (struct acpi_nfit_desc *acpi_desc,unsigned long flags) +int acpi_nfit_ars_rescan (struct acpi_nfit_desc *acpi_desc, +enum nfit_ars_state req_type) {struct device *dev = acpi_desc->dev;int scheduled =0 , busy =0 ;
@@ -3271,14 +3297,10 @@ int acpi_nfit_ars_rescan(struct acpi_nfiif (test_bit (ARS_FAILED , &nfit_spa->ars_state))continue ; -if (test_and_set_bit (ARS_REQ , &nfit_spa->ars_state)) { +if (test_and_set_bit (req_type, &nfit_spa->ars_state)) busy++; -set_bit (ARS_REQ_REDO , &nfit_spa->ars_state); - }else { -if (test_bit (ARS_SHORT , &flags)) -set_bit (ARS_SHORT , &nfit_spa->ars_state); +else scheduled++; - } }if (scheduled) {sched_ars (acpi_desc);
@@ -3464,10 +3486,11 @@ static void acpi_nfit_update_notify(strustatic void acpi_nfit_uc_error_notify (struct device *dev,acpi_handle handle) {struct acpi_nfit_desc *acpi_desc =dev_get_drvdata (dev); -unsigned long flags = (acpi_desc->scrub_mode ==HW_ERROR_SCRUB_ON ) ? -0 :1 <<ARS_SHORT ; -acpi_nfit_ars_rescan (acpi_desc, flags); +if (acpi_desc->scrub_mode ==HW_ERROR_SCRUB_ON ) +acpi_nfit_ars_rescan (acpi_desc,ARS_REQ_LONG ); +else +acpi_nfit_ars_rescan (acpi_desc,ARS_REQ_SHORT ); }void __acpi_nfit_notify (struct device *dev,acpi_handle handle,u32 event)
drivers/acpi/nfit/nfit.h +5 -5
@@ -118,10 +118,8 @@ enum nfit_dimm_notifiers { };enum nfit_ars_state { -ARS_REQ , -ARS_REQ_REDO , -ARS_DONE , -ARS_SHORT , +ARS_REQ_SHORT , +ARS_REQ_LONG ,ARS_FAILED , };
@@ -198,6 +196,7 @@ struct acpi_nfit_desc {struct device *dev;u8 ars_start_flags;struct nd_cmd_ars_status *ars_status; +struct nfit_spa *scrub_spa;struct delayed_work dwork;struct list_head list;struct kernfs_node *scrub_count_state;
@@ -252,7 +251,8 @@ struct nfit_blk {extern struct list_head acpi_descs;extern struct mutex acpi_desc_lock; -int acpi_nfit_ars_rescan (struct acpi_nfit_desc *acpi_desc,unsigned long flags); +int acpi_nfit_ars_rescan (struct acpi_nfit_desc *acpi_desc, +enum nfit_ars_state req_type);#ifdef CONFIG_X86_MCE void nfit_mce_register (void );
Greg Kroah-Hartman
maintainerPATCH 101/361 net: hns3: Set STATE_DOWN bit of hdev state when stopping net
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuyun Liang <[email protected]>
[ Upstream commit 2f7e489611bc685b8e00aba436032a8aac6cac57 ]
We clear STATE_DOWN bit of hdev state when starting net, but do not set it again when stopping net. It causes that the net is down, but hdev state is still up. STATE_DOWN bit of hdev state should be set when stopping net.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 2 ++ drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 2 ++ 2 files changed, 4 insertions(+)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +2 -0
@@ -3814,6 +3814,8 @@ static void hclge_ae_stop(struct hnae3_hstruct hclge_dev *hdev = vport->back;int i; +set_bit (HCLGE_STATE_DOWN , &hdev->state); +del_timer_sync (&hdev->service_timer);cancel_work_sync (&hdev->service_task);clear_bit (HCLGE_STATE_SERVICE_SCHED , &hdev->state);
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +2 -0
@@ -1451,6 +1451,8 @@ static void hclgevf_ae_stop(struct hnae3struct hclgevf_dev *hdev =hclgevf_ae_get_hdev (handle);int i, queue_id; +set_bit (HCLGEVF_STATE_DOWN , &hdev->state); +for (i =0 ; i < hdev->num_tqps; i++) {/* Ring disable */ queue_id =hclgevf_get_queue_id (handle->kinfo.tqp[i]);
Greg Kroah-Hartman
maintainerPATCH 196/361 OPP: Free OPP table properly on performance state irregularities
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viresh Kumar <[email protected]>
commit 2fbb8670b4ff4454f1c0de510f788d737edc4b90 upstream.
The OPP table was freed, but not the individual OPPs which is done from _dev_pm_opp_remove_table(). Fix it by calling _dev_pm_opp_remove_table() as well.
--- drivers/opp/of.c | 1 + 1 file changed, 1 insertion(+)
drivers/opp/of.c +1 -0
@@ -425,6 +425,7 @@ static int _of_add_opp_table_v2(struct ddev_err (dev,"Not all nodes have performance state set (%d: %d)\n" , count, pstate_count); ret = -ENOENT ; +_dev_pm_opp_remove_table (opp_table, dev, false); goto put_opp_table; }
Greg Kroah-Hartman
maintainerPATCH 204/361 xen: make xen_qlock_wait() nestable
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit a856531951dc8094359dfdac21d59cee5969c18e upstream.
xen_qlock_wait() isn't safe for nested calls due to interrupts. A call of xen_qlock_kick() might be ignored in case a deeper nesting level was active right before the call of xen_poll_irq():
CPU 1: CPU 2:spin_lock(lock1)
spin_lock(lock1)
-> xen_qlock_wait()
-> xen_clear_irq_pending()
Interrupt happens
spin_unlock(lock1)
-> xen_qlock_kick(CPU 2)
spin_lock_irqsave(lock2)
spin_lock_irqsave(lock2)
-> xen_qlock_wait()
-> xen_clear_irq_pending()
clears kick for lock1
-> xen_poll_irq()spin_unlock_irq_restore(lock2)
-> xen_qlock_kick(CPU 2)
wakes up
spin_unlock_irq_restore(lock2) IRET
resumes in xen_qlock_wait() -> xen_poll_irq() never wakes up
The solution is to disable interrupts in xen_qlock_wait() and not to poll for the irq in case xen_qlock_wait() is called in nmi context.
--- arch/x86/xen/spinlock.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
arch/x86/xen/spinlock.c +10 -14
@@ -39,29 +39,25 @@ static void xen_qlock_kick(int cpu)*/ static void xen_qlock_wait (u8 *byte,u8 val) { +unsigned long flags;int irq =__this_cpu_read (lock_kicker_irq);/* If kicker interrupts not initialized yet, just spin */ -if (irq ==-1 ) +if (irq ==-1 ||in_nmi ())return ; -/* If irq pending already clear it and return. */ +/* Guard against reentry. */ +local_irq_save (flags); + +/* If irq pending already clear it. */ if (xen_test_irq_pending (irq)) {xen_clear_irq_pending (irq); -return ; + }else if (READ_ONCE (*byte) == val) { +/* Block until irq becomes pending (or a spurious wakeup) */ +xen_poll_irq (irq); } -if (READ_ONCE (*byte) != val) -return ; - -/* -* If an interrupt happens here, it will leave the wakeup irq -* pending, which will cause xen_poll_irq() to return -* immediately. -*/ - -/* Block until irq becomes pending (or perhaps a spurious wakeup) */ -xen_poll_irq (irq); +local_irq_restore (flags); }static irqreturn_t dummy_handler (int irq,void *dev_id)
Greg Kroah-Hartman
maintainerPATCH 221/361 ASoC: sta32x: set ->component pointer in private struct
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Mack <[email protected]>
commit 747df19747bc9752cd40b9cce761e17a033aa5c2 upstream.
The ESD watchdog code in sta32x_watchdog() dereferences the pointer which is never assigned.
This is a regression from a1be4cead9b950 ("ASoC: sta32x: Convert to direct regmap API usage.") which went unnoticed since nobody seems to use that ESD workaround.
--- sound/soc/codecs/sta32x.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/codecs/sta32x.c +3 -0
@@ -879,6 +879,9 @@ static int sta32x_probe(struct snd_soc_cstruct sta32x_priv *sta32x =snd_soc_component_get_drvdata (component);struct sta32x_platform_data *pdata = sta32x->pdata;int i, ret =0 , thermal =0 ; + + sta32x->component = component; + ret =regulator_bulk_enable (ARRAY_SIZE (sta32x->supplies), sta32x->supplies);if (ret !=0 ) {
Greg Kroah-Hartman
maintainerPATCH 218/361 libnvdimm, region: Fail badblocks listing for inactive regions
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Williams <[email protected]>
commit 5d394eee2c102453278d81d9a7cf94c80253486a upstream.
While experimenting with region driver loading the following backtrace was triggered:
INFO: trying to register non-static key.
the code is fine but needs lockdep annotation.
turning off the locking correctness validator.
[..]
Call Trace: dump_stack+0x85/0xcb register_lock_class+0x571/0x580 ? __lock_acquire+0x2ba/0x1310 ? kernfs_seq_start+0x2a/0x80 __lock_acquire+0xd4/0x1310 ? dev_attr_show+0x1c/0x50 ? __lock_acquire+0x2ba/0x1310 ? kernfs_seq_start+0x2a/0x80 ? lock_acquire+0x9e/0x1a0 lock_acquire+0x9e/0x1a0 ? dev_attr_show+0x1c/0x50 badblocks_show+0x70/0x190 ? dev_attr_show+0x1c/0x50 dev_attr_show+0x1c/0x50
This results from a missing successful call to devm_init_badblocks() from nd_region_probe(). Block attempts to show badblocks while the region is not enabled.
--- drivers/nvdimm/region_devs.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/nvdimm/region_devs.c +9 -2
@@ -560,10 +560,17 @@ static ssize_t region_badblocks_show(str struct device_attribute *attr, char *buf) { struct nd_region *nd_region = to_nd_region(dev); +ssize_t rc; -return badblocks_show (&nd_region->bb, buf,0 ); -} +device_lock (dev); +if (dev->driver) + rc =badblocks_show (&nd_region->bb, buf,0 ); +else + rc = -ENXIO ; +device_unlock (dev); +return rc; +} static DEVICE_ATTR(badblocks, 0444, region_badblocks_show, NULL); static ssize_t resource_show(struct device *dev,
Greg Kroah-Hartman
maintainerPATCH 234/361 EDAC, amd64: Add Family 17h, models 10h-2fh support
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Jin <[email protected]>
commit 8960de4a5ca7980ed1e19e7ca5a774d3b7a55c38 upstream.
Add new device IDs for family 17h, models 10h-2fh.
This is required by amd64_edac_mod in order to properly detect PCI device functions 0 and 6.
--- drivers/edac/amd64_edac.c | 14 ++++++++++++++ drivers/edac/amd64_edac.h | 3 +++ 2 files changed, 17 insertions(+)
drivers/edac/amd64_edac.c +14 -0
@@ -2200,6 +2200,15 @@ static struct amd64_family_type family_t .dbam_to_cs = f17_base_addr_to_cs_size, } }, + [F17_M10H_CPUS ] = { + .ctl_name ="F17h_M10h" , + .f0_id =PCI_DEVICE_ID_AMD_17H_M10H_DF_F0 , + .f6_id =PCI_DEVICE_ID_AMD_17H_M10H_DF_F6 , + .ops = { + .early_channel_count = f17_early_channel_count, + .dbam_to_cs = f17_base_addr_to_cs_size, + } + }, };/*
@@ -3188,6 +3197,11 @@ static struct amd64_family_type *per_fambreak ;case 0x17 : +if (pvt->model >=0x10 && pvt->model <=0x2f ) { + fam_type = &family_types[F17_M10H_CPUS ]; + pvt->ops = &family_types[F17_M10H_CPUS ].ops; +break ; + } fam_type = &family_types[F17_CPUS ]; pvt->ops = &family_types[F17_CPUS ].ops;break ;
drivers/edac/amd64_edac.h +3 -0
@@ -115,6 +115,8 @@#define PCI_DEVICE_ID_AMD_16H_M30H_NB_F2 0x1582#define PCI_DEVICE_ID_AMD_17H_DF_F0 0x1460#define PCI_DEVICE_ID_AMD_17H_DF_F6 0x1466 +#define PCI_DEVICE_ID_AMD_17H_M10H_DF_F0 0x15e8 +#define PCI_DEVICE_ID_AMD_17H_M10H_DF_F6 0x15ee/* * Function 1 - Address Map
@@ -281,6 +283,7 @@ enum amd_families {F16_CPUS ,F16_M30H_CPUS ,F17_CPUS , +F17_M10H_CPUS , NUM_FAMILIES, };
Greg Kroah-Hartman
maintainerPATCH 211/361 mt76: mt76x2: fix multi-interface beacon configuration
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
commit 5289976ad887deb07c76df7eecf553c264aeebed upstream.
If the first virtual interface is a station (or an AP with beacons temporarily disabled), the beacon of the second interface needs to occupy hardware beacon slot 0.
For some reason the beacon index was incorrectly masked with the virtual interface beacon mask, which prevents the secondary interface from sending beacons unless the first one also does.
--- drivers/net/wireless/mediatek/mt76/mt76x2_mac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x2_mac.c +1 -2
@@ -128,8 +128,7 @@ __mt76x2_mac_set_beacon(struct mt76x2_deif (skb) { ret =mt76_write_beacon (dev, beacon_addr, skb);if (!ret) - dev->beacon_data_mask |=BIT (bcn_idx) & - dev->beacon_mask; + dev->beacon_data_mask |=BIT (bcn_idx); }else { dev->beacon_data_mask &= ~BIT (bcn_idx);for (i =0 ; i < beacon_len; i +=4 )
Greg Kroah-Hartman
maintainerPATCH 243/361 crypto: tcrypt - fix ghash-generic speed test
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Horia Geantă <[email protected]>
commit 331351f89c36bf7d03561a28b6f64fa10a9f6f3a upstream.
ghash is a keyed hash algorithm, thus setkey needs to be called. Otherwise the following error occurs:
$ modprobe tcrypt mode=318 sec=1 testing speed of async ghash-generic (ghash-generic) tcrypt: test 0 ( 16 byte blocks, 16 bytes per update, 1 updates): tcrypt: hashing failed ret=-126
--- crypto/tcrypt.c | 3 +++ 1 file changed, 3 insertions(+)
crypto/tcrypt.c +3 -0
@@ -1103,6 +1103,9 @@ static void test_ahash_speed_common(consbreak ; } +if (speed[i].klen) +crypto_ahash_setkey (tfm, tvmem[0 ], speed[i].klen); +pr_info ("test%3u " "(%5u byte blocks,%5u bytes per update,%4u updates): " , i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
Greg Kroah-Hartman
maintainerPATCH 215/361 scsi: sched/wait: Add wait_event_lock_irq_timeout for TASK_UNINTERRUPTIBLE usage
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Bellinger <[email protected]>
commit 25ab0bc334b43bbbe4eabc255006ce42a9424da2 upstream.
Short of reverting commit 00d909a10710 ("scsi: target: Make the session shutdown code also wait for commands that are being aborted") for v4.19, target-core needs a wait_event_t macro can be executed using TASK_UNINTERRUPTIBLE to function correctly with existing fabric drivers that expect to run with signals pending during session shutdown and active se_cmd I/O quiesce.
The most notable is iscsi-target/iser-target, while ibmvscsi_tgt invokes session shutdown logic from userspace via configfs attribute that could also potentially have signals pending.
So go ahead and introduce wait_event_lock_irq_timeout() to achieve this, and update + rename __wait_event_lock_irq_timeout() to make it accept 'state' as a parameter.
--- include/linux/wait.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
include/linux/wait.h +15 -5
@@ -1052,10 +1052,9 @@ do { \ __ret; \ }) -#define __wait_event_interruptible_lock_irq_timeout (wq_head, condition, \ - lock, timeout) \ +#define __wait_event_lock_irq_timeout (wq_head, condition, lock, timeout, state) \ ___wait_event(wq_head, ___wait_cond_timeout(condition), \ - TASK_INTERRUPTIBLE, 0, timeout, \ + state, 0, timeout, \ spin_unlock_irq(&lock); \ __ret = schedule_timeout(__ret); \ spin_lock_irq(&lock));
@@ -1089,8 +1088,19 @@ do { \ ({ \long __ret = timeout; \if (!___wait_cond_timeout (condition)) \ - __ret =__wait_event_interruptible_lock_irq_timeout ( \ - wq_head, condition, lock, timeout); \ + __ret =__wait_event_lock_irq_timeout ( \ + wq_head, condition, lock, timeout, \ +TASK_INTERRUPTIBLE ); \ + __ret; \ +}) + +#define wait_event_lock_irq_timeout (wq_head, condition, lock, timeout) \ +({ \ + long __ret = timeout; \ + if (!___wait_cond_timeout(condition)) \ + __ret = __wait_event_lock_irq_timeout( \ + wq_head, condition, lock, timeout, \ + TASK_UNINTERRUPTIBLE); \ __ret; \ })
Greg Kroah-Hartman
maintainerPATCH 256/361 KVM: arm64: Fix caching of host MDCR_EL2 value
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Rutland <[email protected]>
commit da5a3ce66b8bb51b0ea8a89f42aac153903f90fb upstream.
At boot time, KVM stashes the host MDCR_EL2 value, but only does this when the kernel is not running in hyp mode (i.e. is non-VHE). In these cases, the stashed value of MDCR_EL2.HPMN happens to be zero, which can lead to CONSTRAINED UNPREDICTABLE behaviour.
Since we use this value to derive the MDCR_EL2 value when switching to/from a guest, after a guest have been run, the performance counters do not behave as expected. This has been observed to result in accesses via PMXEVTYPER_EL0 and PMXEVCNTR_EL0 not affecting the relevant counters, resulting in events not being counted. In these cases, only the fixed-purpose cycle counter appears to work as expected.
Fix this by always stashing the host MDCR_EL2 value, regardless of VHE.
--- virt/kvm/arm/arm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
virt/kvm/arm/arm.c +2 -2
@@ -1295,8 +1295,6 @@ static void cpu_init_hyp_mode(void *dumm__cpu_init_hyp_mode (pgd_ptr, hyp_stack_ptr, vector_ptr);__cpu_init_stage2 (); - -kvm_arm_init_debug (); }static void cpu_hyp_reset (void )
@@ -1320,6 +1318,8 @@ static void cpu_hyp_reinit(void)cpu_init_hyp_mode (NULL ); } +kvm_arm_init_debug (); +if (vgic_present)kvm_vgic_init_cpu_hardware (); }
Greg Kroah-Hartman
maintainerPATCH 261/361 iio: adc: at91: fix wrong channel number in triggered buffer mode
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eugen Hristev <[email protected]>
commit aea835f2dc8a682942b859179c49ad1841a6c8b9 upstream.
When channels are registered, the hardware channel number is not the actual iio channel number.
This is because the driver is probed with a certain number of accessible channels. Some pins are routed and some not, depending on the description of the board in the DT.
Because of that, channels 0,1,2,3 can correspond to hardware channels 2,3,4,5 for example.
In the buffered triggered case, we need to do the translation accordingly. Fixed the channel number to stop reading the wrong channel.
--- drivers/iio/adc/at91_adc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iio/adc/at91_adc.c +3 -1
@@ -248,12 +248,14 @@ static irqreturn_t at91_adc_trigger_handstruct iio_poll_func *pf = p;struct iio_dev *idev = pf->indio_dev;struct at91_adc_state *st =iio_priv (idev); +struct iio_chan_spec const *chan;int i, j =0 ;for (i =0 ; i < idev->masklength; i++) {if (!test_bit (i, idev->active_scan_mask))continue ; - st->buffer[j] =at91_adc_readl (st,AT91_ADC_CHAN (st, i)); + chan = idev->channels + i; + st->buffer[j] =at91_adc_readl (st,AT91_ADC_CHAN (st, chan->channel)); j++; }
Greg Kroah-Hartman
maintainerPATCH 265/361 smb3: on kerberos mount if server doesnt specify auth type use krb5
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 926674de6705f0f1dbf29a62fd758d0977f535d6 upstream.
Some servers (e.g. Azure) do not include a spnego blob in the SMB3 negotiate protocol response, so on kerberos mounts ("sec=krb5") we can fail, as we expected the server to list its supported auth types (OIDs in the spnego blob in the negprot response). Change this so that on krb5 mounts we default to trying krb5 if the server doesn't list its supported protocol mechanisms.
--- fs/cifs/cifs_spnego.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/cifs/cifs_spnego.c +4 -2
@@ -147,8 +147,10 @@ cifs_get_spnego_key(struct cifs_ses *sessprintf (dp,";sec=krb5" ); else if (server->sec_mskerberos) sprintf(dp, ";sec=mskrb5"); - else - goto out; + else { +cifs_dbg (VFS ,"unknown or missing server auth type, use krb5\n" ); +sprintf (dp,";sec=krb5" ); + } dp = description +strlen (description); sprintf(dp, ";uid=0x%x",
Greg Kroah-Hartman
maintainerPATCH 270/361 NFSv4.1: Fix the r/wsize checking
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit 943cff67b842839f4f35364ba2db5c2d3f025d94 upstream.
The intention of nfs4_session_set_rwsize() was to cap the r/wsize to the buffer sizes negotiated by the CREATE_SESSION. The initial code had a bug whereby we would not check the values negotiated by nfs_probe_fsinfo() (the assumption being that CREATE_SESSION will always negotiate buffer values that are sane w.r.t. the server's preferred r/wsizes) but would only check values set by the user in the 'mount' command.
The code was changed in 4.11 to _always_ set the r/wsize, meaning that we now never use the server preferred r/wsizes. This is the regression that this patch fixes.
Also rename the function to nfs4_session_limit_rwsize() in order to avoid future confusion.
--- fs/nfs/nfs4client.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
fs/nfs/nfs4client.c +9 -7
@@ -950,10 +950,10 @@ EXPORT_SYMBOL_GPL(nfs4_set_ds_client);/* * Session has been established, and the client marked ready. -* Set the mount rsize and wsize with negotiated fore channel -* attributes which will be bound checked in nfs_server_set_fsinfo. +* Limit the mount rsize, wsize and dtsize using negotiated fore +* channel attributes. */ -static void nfs4_session_set_rwsize (struct nfs_server *server) +static void nfs4_session_limit_rwsize (struct nfs_server *server) {#ifdef CONFIG_NFS_V4_1 struct nfs4_session *sess;
@@ -966,9 +966,11 @@ static void nfs4_session_set_rwsize(stru server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead; server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead; -if (!server->rsize || server->rsize > server_resp_sz) +if (server->dtsize > server_resp_sz) + server->dtsize = server_resp_sz; +if (server->rsize > server_resp_sz) server->rsize = server_resp_sz; -if (!server->wsize || server->wsize > server_rqst_sz) +if (server->wsize > server_rqst_sz) server->wsize = server_rqst_sz;#endif /* CONFIG_NFS_V4_1 */ }
@@ -1015,12 +1017,12 @@ static int nfs4_server_common_setup(stru (unsigned long long) server->fsid.minor);nfs_display_fhandle (mntfh,"Pseudo-fs root FH" ); -nfs4_session_set_rwsize (server); - error =nfs_probe_fsinfo (server, mntfh, fattr);if (error <0 ) goto out; +nfs4_session_limit_rwsize (server); +if (server->namelen ==0 || server->namelen >NFS4_MAXNAMLEN ) server->namelen =NFS4_MAXNAMLEN ;
Greg Kroah-Hartman
maintainerPATCH 274/361 lockd: fix access beyond unterminated strings in prints
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Goldstein <[email protected]>
commit 93f38b6fae0ea8987e22d9e6c38f8dfdccd867ee upstream.
printk format used %*s instead of %.*s, so hostname_len does not limit the number of bytes accessed from hostname.
--- fs/lockd/host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/lockd/host.c +1 -1
@@ -341,7 +341,7 @@ struct nlm_host *nlmsvc_lookup_host(cons };struct lockd_net *ln =net_generic (net, lockd_net_id); -dprintk ("lockd: %s(host='%*s', vers=%u, proto=%s)\n" , __func__, +dprintk ("lockd: %s(host='%.*s', vers=%u, proto=%s)\n" , __func__, (int )hostname_len, hostname, rqstp->rq_vers, (rqstp->rq_prot ==IPPROTO_UDP ?"udp" :"tcp" ));
Greg Kroah-Hartman
maintainerPATCH 275/361 dm ioctl: harden copy_params()s copy_from_user() from malicious users
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wenwen Wang <[email protected]>
commit 800a7340ab7dd667edf95e74d8e4f23a17e87076 upstream.
In copy_params(), the struct 'dm_ioctl' is first copied from the user space buffer 'user' to 'param_kernel' and the field 'data_size' is checked against 'minimum_data_size' (size of 'struct dm_ioctl' payload up to its 'data' member). If the check fails, an error code EINVAL will be returned. Otherwise, param_kernel->data_size is used to do a second copy, which copies from the same user-space buffer to 'dmi'. After the second copy, only 'dmi->data_size' is checked against 'param_kernel->data_size'. Given that the buffer 'user' resides in the user space, a malicious user-space process can race to change the content in the buffer between the two copies. This way, the attacker can inject inconsistent data into 'dmi' (versus previously validated 'param_kernel').
Fix redundant copying of 'minimum_data_size' from user-space buffer by using the first copy stored in 'param_kernel'. Also remove the 'data_size' check after the second copy because it is now unnecessary.
--- drivers/md/dm-ioctl.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/md/dm-ioctl.c +6 -12
@@ -1720,8 +1720,7 @@ static void free_params(struct dm_ioctl }static int copy_params (struct dm_ioctl __user *user,struct dm_ioctl *param_kernel, -int ioctl_flags, -struct dm_ioctl **param,int *param_flags) +int ioctl_flags,struct dm_ioctl **param,int *param_flags) {struct dm_ioctl *dmi;int secure_data;
@@ -1762,18 +1761,13 @@ static int copy_params(struct dm_ioctl _ *param_flags |=DM_PARAMS_MALLOC ; -if (copy_from_user (dmi, user, param_kernel->data_size)) - goto bad; +/* Copy from param_kernel (which was already copied from user) */ +memcpy (dmi, param_kernel, minimum_data_size); -data_copied: -/* -* Abort if something changed the ioctl data while it was being copied. -*/ -if (dmi->data_size != param_kernel->data_size) { -DMERR ("rejecting ioctl: data size modified while processing parameters" ); +if (copy_from_user (&dmi->data, (char __user *)user + minimum_data_size, + param_kernel->data_size - minimum_data_size)) goto bad; - } - +data_copied:/* Wipe the user buffer so we do not return it to userspace */ if (secure_data &&clear_user (user, param_kernel->data_size)) goto bad;
Greg Kroah-Hartman
maintainerPATCH 247/361 crypto: speck - remove Speck
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason A. Donenfeld <[email protected]>
commit 578bdaabd015b9b164842c3e8ace9802f38e7ecc upstream.
These are unused, undesired, and have never actually been used by anybody. The original authors of this code have changed their mind about its inclusion. While originally proposed for disk encryption on low-end devices, the idea was discarded [1] in favor of something else before that could really get going. Therefore, this patch removes Speck.
[1] https://marc.info/?l=linux-crypto-vger&m=153359499015659
--- Documentation/filesystems/fscrypt.rst | 10 arch/arm/crypto/Kconfig | 6 arch/arm/crypto/Makefile | 2 arch/arm/crypto/speck-neon-core.S | 434 ------------------- arch/arm/crypto/speck-neon-glue.c | 288 ------------- arch/arm64/crypto/Kconfig | 6 arch/arm64/crypto/Makefile | 3 arch/arm64/crypto/speck-neon-core.S | 352 ---------------- arch/arm64/crypto/speck-neon-glue.c | 282 ------------ arch/m68k/configs/amiga_defconfig | 1 arch/m68k/configs/apollo_defconfig | 1 arch/m68k/configs/atari_defconfig | 1 arch/m68k/configs/bvme6000_defconfig | 1 arch/m68k/configs/hp300_defconfig | 1 arch/m68k/configs/mac_defconfig | 1 arch/m68k/configs/multi_defconfig | 1 arch/m68k/configs/mvme147_defconfig | 1 arch/m68k/configs/mvme16x_defconfig | 1 arch/m68k/configs/q40_defconfig | 1 arch/m68k/configs/sun3_defconfig | 1 arch/m68k/configs/sun3x_defconfig | 1 arch/s390/defconfig | 1 crypto/Kconfig | 14 crypto/Makefile | 1 crypto/speck.c | 307 -------------- crypto/testmgr.c | 24 - crypto/testmgr.h | 738 ---------------------------------- fs/crypto/fscrypt_private.h | 4 fs/crypto/keyinfo.c | 10 include/crypto/speck.h | 62 -- include/uapi/linux/fs.h | 4 31 files changed, 2 insertions(+), 2558 deletions(-)
Documentation/filesystems/fscrypt.rst +0 -10
@@ -191,21 +191,11 @@ Currently, the following pairs of encryp - AES-256-XTS for contents and AES-256-CTS-CBC for filenames - AES-128-CBC for contents and AES-128-CTS-CBC for filenames -- Speck128/256-XTS for contents and Speck128/256-CTS-CBC for filenames It is strongly recommended to use AES-256-XTS for contents encryption. AES-128-CBC was added only for low-powered embedded devices with crypto accelerators such as CAAM or CESA that do not support XTS. -Similarly, Speck128/256 support was only added for older or low-end -CPUs which cannot do AES fast enough -- especially ARM CPUs which have -NEON instructions but not the Cryptography Extensions -- and for which -it would not otherwise be feasible to use encryption at all. It is -not recommended to use Speck on CPUs that have AES instructions. -Speck support is only available if it has been enabled in the crypto -API via CONFIG_CRYPTO_SPECK. Also, on ARM platforms, to get -acceptable performance CONFIG_CRYPTO_SPECK_NEON must be enabled. - New encryption modes can be added relatively easily, without changes to individual filesystems. However, authenticated encryption (AE) modes are not currently supported because of the difficulty of dealing
arch/arm/crypto/Kconfig +0 -6
@@ -121,10 +121,4 @@ config CRYPTO_CHACHA20_NEON select CRYPTO_BLKCIPHER select CRYPTO_CHACHA20 -config CRYPTO_SPECK_NEON - tristate "NEON accelerated Speck cipher algorithms" - depends on KERNEL_MODE_NEON - select CRYPTO_BLKCIPHER - select CRYPTO_SPECK - endif
arch/arm/crypto/Makefile +0 -2
@@ -10,7 +10,6 @@ obj-$(CONFIG_CRYPTO_SHA1_ARM_NEON) += sh obj-$(CONFIG_CRYPTO_SHA256_ARM) += sha256-arm.o obj-$(CONFIG_CRYPTO_SHA512_ARM) += sha512-arm.o obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha20-neon.o -obj-$(CONFIG_CRYPTO_SPECK_NEON) += speck-neon.o ce-obj-$(CONFIG_CRYPTO_AES_ARM_CE) += aes-arm-ce.o ce-obj-$(CONFIG_CRYPTO_SHA1_ARM_CE) += sha1-arm-ce.o
@@ -54,7 +53,6 @@ ghash-arm-ce-y := ghash-ce-core.o ghash- crct10dif-arm-ce-y := crct10dif-ce-core.o crct10dif-ce-glue.o crc32-arm-ce-y:= crc32-ce-core.o crc32-ce-glue.o chacha20-neon-y := chacha20-neon-core.o chacha20-neon-glue.o -speck-neon-y := speck-neon-core.o speck-neon-glue.o ifdef REGENERATE_ARM_CRYPTO quiet_cmd_perl = PERL $@
arch/arm/crypto/speck-neon-core.S deleted +0 -434
434 lines not on this page · raw message
arch/arm/crypto/speck-neon-glue.c deleted +0 -288
288 lines not on this page · raw message
arch/arm64/crypto/Kconfig +0 -6
@@ -119,10 +119,4 @@ config CRYPTO_AES_ARM64_BS select CRYPTO_AES_ARM64 select CRYPTO_SIMD -config CRYPTO_SPECK_NEON - tristate "NEON accelerated Speck cipher algorithms" - depends on KERNEL_MODE_NEON - select CRYPTO_BLKCIPHER - select CRYPTO_SPECK - endif
arch/arm64/crypto/Makefile +0 -3
@@ -56,9 +56,6 @@ sha512-arm64-y := sha512-glue.o sha512-c obj-$(CONFIG_CRYPTO_CHACHA20_NEON) += chacha20-neon.o chacha20-neon-y := chacha20-neon-core.o chacha20-neon-glue.o -obj-$(CONFIG_CRYPTO_SPECK_NEON) += speck-neon.o -speck-neon-y := speck-neon-core.o speck-neon-glue.o - obj-$(CONFIG_CRYPTO_AES_ARM64) += aes-arm64.o aes-arm64-y := aes-cipher-core.o aes-cipher-glue.o
arch/arm64/crypto/speck-neon-core.S deleted +0 -352
352 lines not on this page · raw message
arch/arm64/crypto/speck-neon-glue.c deleted +0 -282
282 lines not on this page · raw message
arch/m68k/configs/amiga_defconfig +0 -1
@@ -657,7 +657,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/apollo_defconfig +0 -1
@@ -614,7 +614,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/atari_defconfig +0 -1
@@ -635,7 +635,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/bvme6000_defconfig +0 -1
@@ -606,7 +606,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/hp300_defconfig +0 -1
@@ -616,7 +616,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/mac_defconfig +0 -1
@@ -638,7 +638,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/multi_defconfig +0 -1
@@ -720,7 +720,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/mvme147_defconfig +0 -1
@@ -606,7 +606,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/mvme16x_defconfig +0 -1
@@ -606,7 +606,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/q40_defconfig +0 -1
@@ -629,7 +629,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/sun3_defconfig +0 -1
@@ -607,7 +607,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/m68k/configs/sun3x_defconfig +0 -1
@@ -608,7 +608,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_LZO=m
arch/s390/defconfig +0 -1
@@ -221,7 +221,6 @@ CONFIG_CRYPTO_SALSA20=m CONFIG_CRYPTO_SEED=m CONFIG_CRYPTO_SERPENT=m CONFIG_CRYPTO_SM4=m -CONFIG_CRYPTO_SPECK=m CONFIG_CRYPTO_TEA=m CONFIG_CRYPTO_TWOFISH=m CONFIG_CRYPTO_DEFLATE=m
crypto/Kconfig +0 -14
@@ -1590,20 +1590,6 @@ config CRYPTO_SM4 If unsure, say N. -config CRYPTO_SPECK - tristate "Speck cipher algorithm" - select CRYPTO_ALGAPI - help - Speck is a lightweight block cipher that is tuned for optimal - performance in software (rather than hardware). - - Speck may not be as secure as AES, and should only be used on systems - where AES is not fast enough. - - See also: <https://eprint.iacr.org/2013/404.pdf> - - If unsure, say N. - config CRYPTO_TEA tristate "TEA, XTEA and XETA cipher algorithms" select CRYPTO_ALGAPI
crypto/Makefile +0 -1
@@ -115,7 +115,6 @@ obj-$(CONFIG_CRYPTO_TEA) += tea.o obj-$(CONFIG_CRYPTO_KHAZAD) += khazad.o obj-$(CONFIG_CRYPTO_ANUBIS) += anubis.o obj-$(CONFIG_CRYPTO_SEED) += seed.o -obj-$(CONFIG_CRYPTO_SPECK) += speck.o obj-$(CONFIG_CRYPTO_SALSA20) += salsa20_generic.o obj-$(CONFIG_CRYPTO_CHACHA20) += chacha20_generic.o obj-$(CONFIG_CRYPTO_POLY1305) += poly1305_generic.o
crypto/speck.c deleted +0 -307
307 lines not on this page · raw message
crypto/testmgr.c +0 -24
@@ -3038,18 +3038,6 @@ static const struct alg_test_desc alg_te .cipher = __VECS(sm4_tv_template) } }, { - .alg = "ecb(speck128)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck128_tv_template) - } - }, { - .alg = "ecb(speck64)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck64_tv_template) - } - }, { .alg = "ecb(tea)", .test = alg_test_skcipher, .suite = {
@@ -3577,18 +3565,6 @@ static const struct alg_test_desc alg_te .cipher = __VECS(serpent_xts_tv_template) } }, { - .alg = "xts(speck128)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck128_xts_tv_template) - } - }, { - .alg = "xts(speck64)", - .test = alg_test_skcipher, - .suite = { - .cipher = __VECS(speck64_xts_tv_template) - } - }, { .alg = "xts(twofish)", .test = alg_test_skcipher, .suite = {
crypto/testmgr.h +0 -738
744 lines not on this page · raw message
fs/crypto/fscrypt_private.h +0 -4
@@ -83,10 +83,6 @@ static inline bool fscrypt_valid_enc_mod filenames_mode == FS_ENCRYPTION_MODE_AES_256_CTS)return true; -if (contents_mode ==FS_ENCRYPTION_MODE_SPECK128_256_XTS && - filenames_mode ==FS_ENCRYPTION_MODE_SPECK128_256_CTS ) -return true; -return false; }
fs/crypto/keyinfo.c +0 -10
@@ -174,16 +174,6 @@ static struct fscrypt_mode { .cipher_str = "cts(cbc(aes))", .keysize = 16, }, - [FS_ENCRYPTION_MODE_SPECK128_256_XTS] = { - .friendly_name = "Speck128/256-XTS", - .cipher_str = "xts(speck128)", - .keysize = 64, - }, - [FS_ENCRYPTION_MODE_SPECK128_256_CTS] = { - .friendly_name = "Speck128/256-CTS-CBC", - .cipher_str = "cts(cbc(speck128))", - .keysize = 32, - }, }; static struct fscrypt_mode *
include/crypto/speck.h deleted +0 -62
62 lines not on this page · raw message
include/uapi/linux/fs.h +2 -2
@@ -279,8 +279,8 @@ struct fsxattr {#define FS_ENCRYPTION_MODE_AES_256_CTS 4#define FS_ENCRYPTION_MODE_AES_128_CBC 5#define FS_ENCRYPTION_MODE_AES_128_CTS 6 -#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7 -#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8 +#define FS_ENCRYPTION_MODE_SPECK128_256_XTS 7/* Removed, do not use. */ +#define FS_ENCRYPTION_MODE_SPECK128_256_CTS 8/* Removed, do not use. */ struct fscrypt_policy {__u8 version;
Greg Kroah-Hartman
maintainerPATCH 253/361 mm/rmap: map_pte() was not handling private ZONE_DEVICE page properly
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ralph Campbell <[email protected]>
commit aab8d0520e6e7c2a61f71195e6ce7007a4843afb upstream.
Private ZONE_DEVICE pages use a special pte entry and thus are not present. Properly handle this case in map_pte(), it is already handled in check_pte(), the map_pte() part was lost in some rebase most probably.
Without this patch the slow migration path can not migrate back to any private ZONE_DEVICE memory to regular memory. This was found after stress testing migration back to system memory. This ultimatly can lead to the CPU constantly page fault looping on the special swap entry.
--- mm/page_vma_mapped.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
mm/page_vma_mapped.c +23 -1
@@ -21,7 +21,29 @@ static bool map_pte(struct page_vma_mappif (!is_swap_pte (*pvmw->pte))return false; }else { -if (!pte_present (*pvmw->pte)) +/* +* We get here when we are trying to unmap a private +* device page from the process address space. Such +* page is not CPU accessible and thus is mapped as +* a special swap entry, nonetheless it still does +* count as a valid regular mapping for the page (and +* is accounted as such in page maps count). +* +* So handle this special case as if it was a normal +* page mapping ie lock CPU page table and returns +* true. +* +* For more details on device private memory see HMM +* (include/linux/hmm.h or mm/hmm.c). +*/ +if (is_swap_pte (*pvmw->pte)) { +swp_entry_t entry; + +/* Handle un-addressable ZONE_DEVICE memory */ + entry =pte_to_swp_entry (*pvmw->pte); +if (!is_device_private_entry (entry)) +return false; + }else if (!pte_present (*pvmw->pte))return false; } }
Greg Kroah-Hartman
maintainerPATCH 294/361 Revert "media: dvbsky: use just one mutex for serializing device R/W ops"
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit 9afc82194de9a1ce298f0d77d7d779d585bf962c upstream.
As pointed at:
https://bugzilla.kernel.org/show_bug.cgi?id=199323
This patch causes a bad effect on RPi. I suspect that the root cause is at the USB out of tree RPi driver, with uses high priority interrupts instead of normal ones. Anyway, as this patch is mostly a cleanup, better to revert it.
This reverts commit 7d95fb746c4eece67308f1642a666ea1ebdbd2cc.
--- drivers/media/usb/dvb-usb-v2/dvbsky.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/media/usb/dvb-usb-v2/dvbsky.c +10 -6
@@ -31,6 +31,7 @@ MODULE_PARM_DESC(disable_rc, "Disable inDVB_DEFINE_MOD_OPT_ADAPTER_NR (adapter_nr);struct dvbsky_state { +struct mutex stream_mutex;u8 ibuf[DVBSKY_BUF_LEN ];u8 obuf[DVBSKY_BUF_LEN ];u8 last_lock;
@@ -67,17 +68,18 @@ static int dvbsky_usb_generic_rw(structstatic int dvbsky_stream_ctrl (struct dvb_usb_device *d,u8 onoff) { +struct dvbsky_state *state =d_to_priv (d);int ret; -static u8 obuf_pre[3 ] = {0x37 ,0 ,0 }; -static u8 obuf_post[3 ] = {0x36 ,3 ,0 }; +u8 obuf_pre[3 ] = {0x37 ,0 ,0 }; +u8 obuf_post[3 ] = {0x36 ,3 ,0 }; -mutex_lock (&d->usb_mutex); - ret =dvb_usbv2_generic_rw_locked (d, obuf_pre,3 ,NULL ,0 ); +mutex_lock (&state->stream_mutex); + ret =dvbsky_usb_generic_rw (d, obuf_pre,3 ,NULL ,0 );if (!ret && onoff) {msleep (20 ); - ret =dvb_usbv2_generic_rw_locked (d, obuf_post,3 ,NULL ,0 ); + ret =dvbsky_usb_generic_rw (d, obuf_post,3 ,NULL ,0 ); } -mutex_unlock (&d->usb_mutex); +mutex_unlock (&state->stream_mutex);return ret; }
@@ -606,6 +608,8 @@ static int dvbsky_init(struct dvb_usb_deif (ret) return ret; */ +mutex_init (&state->stream_mutex); + state->last_lock =0 ;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 303/361 media: cec: fix the Signal Free Time calculation
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit 7d867a1b765e2b70815fec4964d7822a976ed349 upstream.
The calculation of the Signal Free Time in the framework was not correct. If a message was received, then the next transmit should be considered a New Initiator and use a shorter SFT value.
This was not done with the result that if both sides where continually sending messages, they both could use the same SFT value and one side could deny the other side access to the bus.
Note that this fix does not take the corner case into account where a receive is in progress when you call adap_transmit.
--- drivers/media/cec/cec-adap.c | 26 +++++++------------------- include/media/cec.h | 2 +- 2 files changed, 8 insertions(+), 20 deletions(-)
drivers/media/cec/cec-adap.c +7 -19
@@ -513,9 +513,11 @@ int cec_thread_func(void *_adap)if (data->attempts) {/* should be >= 3 data bit periods for a retry */ signal_free_time =CEC_SIGNAL_FREE_TIME_RETRY ; - }else if (data->new_initiator) { + }else if (adap->last_initiator != +cec_msg_initiator (&data->msg)) {/* should be >= 5 data bit periods for new initiator */ signal_free_time =CEC_SIGNAL_FREE_TIME_NEW_INITIATOR ; + adap->last_initiator =cec_msg_initiator (&data->msg); }else {/* * should be >= 7 data bit periods for sending another
@@ -700,7 +702,6 @@ int cec_transmit_msg_fh(struct cec_adapt struct cec_fh *fh, bool block) {struct cec_data *data; -u8 last_initiator =0xff ; msg->rx_ts =0 ; msg->tx_ts =0 ;
@@ -810,23 +811,6 @@ int cec_transmit_msg_fh(struct cec_adapt data->adap = adap; data->blocking = block; -/* -* Determine if this message follows a message from the same -* initiator. Needed to determine the free signal time later on. -*/ -if (msg->len >1 ) { -if (!(list_empty (&adap->transmit_queue))) { -const struct cec_data *last; - - last =list_last_entry (&adap->transmit_queue, - const struct cec_data, list); - last_initiator =cec_msg_initiator (&last->msg); - }else if (adap->transmitting) { - last_initiator = -cec_msg_initiator (&adap->transmitting->msg); - } - } - data->new_initiator = last_initiator !=cec_msg_initiator (msg);init_completion (&data->c);INIT_DELAYED_WORK (&data->work, cec_wait_timeout);
@@ -1014,6 +998,8 @@ void cec_received_msg_ts(struct cec_adapmutex_lock (&adap->lock);dprintk (2 ,"%s: %*ph\n" , __func__, msg->len, msg->msg); + adap->last_initiator =0xff ; +/* Check if this message was for us (directed or broadcast). */ if (!cec_msg_is_broadcast (msg)) valid_la =cec_has_log_addr (adap, msg_dest);
@@ -1476,6 +1462,8 @@ void __cec_s_phys_addr(struct cec_adapte }mutex_lock (&adap->devnode.lock); + adap->last_initiator =0xff ; +if ((adap->needs_hpd ||list_empty (&adap->devnode.fhs)) && adap->ops->adap_enable (adap, true)) {mutex_unlock (&adap->devnode.lock);
include/media/cec.h +1 -1
@@ -63,7 +63,6 @@ struct cec_data {struct delayed_work work;struct completion c;u8 attempts; -bool new_initiator;bool blocking;bool completed; };
@@ -174,6 +173,7 @@ struct cec_adapter {bool is_configuring;bool is_configured;bool cec_pin_is_high; +u8 last_initiator;u32 monitor_all_cnt;u32 monitor_pin_cnt;u32 follower_cnt;
Greg Kroah-Hartman
maintainerPATCH 284/361 MIPS: OCTEON: fix out of bounds array access on CN68XX
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaro Koskinen <[email protected]>
commit c0fae7e2452b90c31edd2d25eb3baf0c76b400ca upstream.
The maximum number of interfaces is returned by cvmx_helper_get_number_of_interfaces(), and the value is used to access interface_port_count[]. When CN68XX support was added, we forgot to increase the array size. Fix that.
Patchwork: https://patchwork.linux-mips.org/patch/20949/
--- arch/mips/cavium-octeon/executive/cvmx-helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/cavium-octeon/executive/cvmx-helper.c +1 -1
@@ -67,7 +67,7 @@ void (*cvmx_override_pko_queue_priority)void (*cvmx_override_ipd_port_setup) (int ipd_port);/* Port count per interface */ -static int interface_port_count[5 ]; +static int interface_port_count[9 ];/** * Return the number of interfaces the chip has. Each interface
Greg Kroah-Hartman
maintainerPATCH 328/361 btrfs: locking: Add extra check in btrfs_init_new_buffer() to avoid deadlock
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit b72c3aba09a53fc7c1824250d71180ca154517a7 upstream.
[BUG]
For certain crafted image, whose csum root leaf has missing backref, if we try to trigger write with data csum, it could cause deadlock with the following kernel WARN_ON():
WARNING: CPU: 1 PID: 41 at fs/btrfs/locking.c:230 btrfs_tree_lock+0x3e2/0x400 CPU: 1 PID: 41 Comm: kworker/u4:1 Not tainted 4.18.0-rc1+ #8 Workqueue: btrfs-endio-write btrfs_endio_write_helper RIP: 0010:btrfs_tree_lock+0x3e2/0x400 Call Trace: btrfs_alloc_tree_block+0x39f/0x770 __btrfs_cow_block+0x285/0x9e0 btrfs_cow_block+0x191/0x2e0 btrfs_search_slot+0x492/0x1160 btrfs_lookup_csum+0xec/0x280 btrfs_csum_file_blocks+0x2be/0xa60 add_pending_csums+0xaf/0xf0 btrfs_finish_ordered_io+0x74b/0xc90 finish_ordered_fn+0x15/0x20 normal_work_helper+0xf6/0x500 btrfs_endio_write_helper+0x12/0x20 process_one_work+0x302/0x770 worker_thread+0x81/0x6d0 kthread+0x180/0x1d0 ret_from_fork+0x35/0x40
[CAUSE]
That crafted image has missing backref for csum tree root leaf. And when we try to allocate new tree block, since there is no EXTENT/METADATA_ITEM for csum tree root, btrfs consider it's free slot and use it.
The extent tree of the image looks like:
Normal image | This fuzzed image
----------------------------------+--------------------------------
BG 29360128 | BG 29360128 One empty slot | One empty slot 29364224: backref to UUID tree | 29364224: backref to UUID tree Two empty slots | Two empty slots 29376512: backref to CSUM tree | One empty slot (bad type) <<< 29380608: backref to D_RELOC tree | 29380608: backref to D_RELOC tree ... | ...
Since bytenr 29376512 has no METADATA/EXTENT_ITEM, when btrfs try to alloc tree block, it's an valid slot for btrfs.
And for finish_ordered_write, when we need to insert csum, we try to CoW csum tree root.
By accident, empty slots at bytenr BG_OFFSET, BG_OFFSET + 8K, BG_OFFSET + 12K is already used by tree block COW for other trees, the next empty slot is BG_OFFSET + 16K, which should be the backref for CSUM tree.
But due to the bad type, btrfs can recognize it and still consider it as an empty slot, and will try to use it for csum tree CoW.
Then in the following call trace, we will try to lock the new tree block, which turns out to be the old csum tree root which is already locked:
btrfs_search_slot() called on csum tree root, which is at 29376512 |- btrfs_cow_block()
|- btrfs_set_lock_block()
| |- Now locks tree block 29376512 (old csum tree root)
|- __btrfs_cow_block()
|- btrfs_alloc_tree_block()
|- btrfs_reserve_extent()
| Now it returns tree block 29376512, which extent tree
| shows its empty slot, but it's already hold by csum tree
|- btrfs_init_new_buffer()
|- btrfs_tree_lock()
| Triggers WARN_ON(eb->lock_owner == current->pid)
|- wait_event()
Wait lock owner to release the lock, but it's
locked by ourself, so it will deadlock[FIX]
This patch will do the lock_owner and current->pid check at btrfs_init_new_buffer().
So above deadlock can be avoided.
Since such problem can only happen in crafted image, we will still trigger kernel warning for later aborted transaction, but with a little more meaningful warning message.
--- fs/btrfs/extent-tree.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
fs/btrfs/extent-tree.c +13 -0
@@ -8119,6 +8119,19 @@ btrfs_init_new_buffer(struct btrfs_transif (IS_ERR (buf))return buf; +/* +* Extra safety check in case the extent tree is corrupted and extent +* allocator chooses to use a tree block which is already used and +* locked. +*/ +if (buf->lock_owner == current->pid) { +btrfs_err_rl (fs_info, +"tree block %llu owner %llu already locked by pid=%d, extent tree corruption detected" , + buf->start,btrfs_header_owner (buf), current->pid); +free_extent_buffer (buf); +return ERR_PTR (-EUCLEAN ); + } +btrfs_set_buffer_lockdep_class (root->root_key.objectid, buf, level);btrfs_tree_lock (buf);clean_tree_block (fs_info, buf);
Greg Kroah-Hartman
maintainerPATCH 332/361 btrfs: Ensure btrfs_trim_fs can trim the whole filesystem
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit 6ba9fc8e628becf0e3ec94083450d089b0dec5f5 upstream.
[BUG]
fstrim on some btrfs only trims the unallocated space, not trimming any space in existing block groups.
[CAUSE]
Before fstrim_range passed to btrfs_trim_fs(), it gets truncated to range [0, super->total_bytes). So later btrfs_trim_fs() will only be able to trim block groups in range [0, super->total_bytes).
While for btrfs, any bytenr aligned to sectorsize is valid, since btrfs uses its logical address space, there is nothing limiting the location where we put block groups.
For filesystem with frequent balance, it's quite easy to relocate all block groups and bytenr of block groups will start beyond super->total_bytes.
In that case, btrfs will not trim existing block groups.
[FIX]
Just remove the truncation in btrfs_ioctl_fitrim(), so btrfs_trim_fs() can get the unmodified range, which is normally set to [0, U64_MAX].
--- fs/btrfs/extent-tree.c | 10 +--------- fs/btrfs/ioctl.c | 11 +++++++---- 2 files changed, 8 insertions(+), 13 deletions(-)
fs/btrfs/extent-tree.c +1 -9
@@ -10868,21 +10868,13 @@ int btrfs_trim_fs(struct btrfs_fs_info *u64 start;u64 end;u64 trimmed =0 ; -u64 total_bytes =btrfs_super_total_bytes (fs_info->super_copy);u64 bg_failed =0 ;u64 dev_failed =0 ;int bg_ret =0 ;int dev_ret =0 ;int ret =0 ; -/* -* try to trim all FS space, our block group may start from non-zero. -*/ -if (range->len == total_bytes) - cache =btrfs_lookup_first_block_group (fs_info, range->start); -else - cache =btrfs_lookup_block_group (fs_info, range->start); - + cache =btrfs_lookup_first_block_group (fs_info, range->start);for (; cache; cache =next_block_group (fs_info, cache)) {if (cache->key.objectid >= (range->start + range->len)) {btrfs_put_block_group (cache);
fs/btrfs/ioctl.c +7 -4
@@ -491,7 +491,6 @@ static noinline int btrfs_ioctl_fitrim(sstruct fstrim_range range;u64 minlen =ULLONG_MAX ;u64 num_devices =0 ; -u64 total_bytes =btrfs_super_total_bytes (fs_info->super_copy);int ret;if (!capable (CAP_SYS_ADMIN ))
@@ -515,11 +514,15 @@ static noinline int btrfs_ioctl_fitrim(sreturn -EOPNOTSUPP ;if (copy_from_user (&range, arg,sizeof (range)))return -EFAULT ; -if (range.start > total_bytes || - range.len < fs_info->sb->s_blocksize) + +/* +* NOTE: Don't truncate the range using super->total_bytes. Bytenr of +* block group is in the logical address space, which can be any +* sectorsize aligned bytenr in the range [0, U64_MAX]. +*/ +if (range.len < fs_info->sb->s_blocksize)return -EINVAL ; - range.len =min (range.len, total_bytes - range.start); range.minlen =max (range.minlen, minlen); ret =btrfs_trim_fs (fs_info, &range);if (ret <0 )
Greg Kroah-Hartman
maintainerPATCH 334/361 btrfs: dont attempt to trim devices that dont support it
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Mahoney <[email protected]>
commit 0be88e367fd8fbdb45257615d691f4675dda062f upstream.
We check whether any device the file system is using supports discard in the ioctl call, but then we attempt to trim free extents on every device regardless of whether discard is supported. Due to the way we mask off EOPNOTSUPP, we can end up issuing the trim operations on each free range on devices that don't support it, just wasting time.
--- fs/btrfs/extent-tree.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/btrfs/extent-tree.c +4 -0
@@ -10789,6 +10789,10 @@ static int btrfs_trim_free_extents(struc *trimmed =0 ; +/* Discard not supported = nothing to do. */ +if (!blk_queue_discard (bdev_get_queue (device->bdev))) +return 0 ; +/* Not writeable = nothing to do. */ if (!test_bit (BTRFS_DEV_STATE_WRITEABLE , &device->dev_state))return 0 ;
Greg Kroah-Hartman
maintainerPATCH 341/361 btrfs: make sure we create all new block groups
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 545e3366db823dc3342ca9d7fea803f829c9062f upstream.
Allocating new chunks modifies both the extent and chunk tree, which can trigger new chunk allocations. So instead of doing list_for_each_safe, just do while (!list_empty()) so we make sure we don't exit with other pending bg's still on our list.
--- fs/btrfs/extent-tree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/btrfs/extent-tree.c +5 -2
@@ -10094,7 +10094,7 @@ error:void btrfs_create_pending_block_groups (struct btrfs_trans_handle *trans) {struct btrfs_fs_info *fs_info = trans->fs_info; -struct btrfs_block_group_cache *block_group, *tmp; +struct btrfs_block_group_cache *block_group;struct btrfs_root *extent_root = fs_info->extent_root;struct btrfs_block_group_item item;struct btrfs_key key;
@@ -10102,7 +10102,10 @@ void btrfs_create_pending_block_groups(sbool can_flush_pending_bgs = trans->can_flush_pending_bgs; trans->can_flush_pending_bgs = false; -list_for_each_entry_safe (block_group, tmp, &trans->new_bgs, bg_list) { +while (!list_empty (&trans->new_bgs)) { + block_group =list_first_entry (&trans->new_bgs, + struct btrfs_block_group_cache, + bg_list);if (ret) goto next;
Greg Kroah-Hartman
maintainerPATCH 348/361 btrfs: reset max_extent_size properly
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 21a94f7acf0f748599ea552af5d9ee7d7e41c72f upstream.
If we use up our block group before allocating a new one we'll easily get a max_extent_size that's set really really low, which will result in a lot of fragmentation. We need to make sure we're resetting the max_extent_size when we add a new chunk or add new space.
--- fs/btrfs/extent-tree.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/extent-tree.c +2 -0
@@ -4530,6 +4530,7 @@ static int do_chunk_alloc(struct btrfs_t goto out; }else { ret =1 ; + space_info->max_extent_size =0 ; } space_info->force_alloc =CHUNK_ALLOC_NO_FORCE ;
@@ -6431,6 +6432,7 @@ static int btrfs_free_reserved_bytes(str space_info->bytes_readonly += num_bytes; cache->reserved -= num_bytes; space_info->bytes_reserved -= num_bytes; + space_info->max_extent_size =0 ;if (delalloc) cache->delalloc_bytes -= num_bytes;
Greg Kroah-Hartman
maintainerPATCH 352/361 btrfs: fix insert_reserved error handling
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 80ee54bfe8a3850015585ebc84e8d207fcae6831 upstream.
We were not handling the reserved byte accounting properly for data references. Metadata was fine, if it errored out the error paths would free the bytes_reserved count and pin the extent, but it even missed one of the error cases. So instead move this handling up into run_one_delayed_ref so we are sure that both cases are properly cleaned up in case of a transaction abort.
--- fs/btrfs/extent-tree.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
fs/btrfs/extent-tree.c +4 -8
@@ -2366,6 +2366,9 @@ static int run_one_delayed_ref(struct bt insert_reserved); elseBUG (); +if (ret && insert_reserved) +btrfs_pin_extent (trans->fs_info, node->bytenr, + node->num_bytes,1 );return ret; }
@@ -7977,21 +7980,14 @@ static int alloc_reserved_tree_block(str } path =btrfs_alloc_path (); -if (!path) { -btrfs_free_and_pin_reserved_extent (fs_info, - extent_key.objectid, - fs_info->nodesize); +if (!path)return -ENOMEM ; - } path->leave_spinning =1 ; ret =btrfs_insert_empty_item (trans, fs_info->extent_root, path, &extent_key, size);if (ret) {btrfs_free_path (path); -btrfs_free_and_pin_reserved_extent (fs_info, - extent_key.objectid, - fs_info->nodesize);return ret; }
Greg Kroah-Hartman
maintainerPATCH 326/361 btrfs: qgroup: Avoid calling qgroup functions if qgroup is not enabled
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit 3628b4ca64f24a4ec55055597d0cb1c814729f8b upstream.
Some qgroup trace events like btrfs_qgroup_release_data() and btrfs_qgroup_free_delayed_ref() can still be triggered even if qgroup is not enabled.
This is caused by the lack of qgroup status check before calling some qgroup functions. Thankfully the functions can handle quota disabled case well and just do nothing for qgroup disabled case.
This patch will do earlier check before triggering related trace events.
And for enabled <-> disabled race case:
1) For enabled->disabled case
Disable will wipe out all qgroups data including reservation and excl/rfer. Even if we leak some reservation or numbers, it will still be cleared, so nothing will go wrong.
2) For disabled -> enabled case
Current btrfs_qgroup_release_data() will use extent_io tree to ensure we won't underflow reservation. And for delayed_ref we use head->qgroup_reserved to record the reserved space, so in that case head->qgroup_reserved should be 0 and we won't underflow.
--- fs/btrfs/qgroup.c | 4 ++++ fs/btrfs/qgroup.h | 2 ++ 2 files changed, 6 insertions(+)
fs/btrfs/qgroup.c +4 -0
@@ -3106,6 +3106,10 @@ static int __btrfs_qgroup_release_data(sint trace_op =QGROUP_RELEASE ;int ret; +if (!test_bit (BTRFS_FS_QUOTA_ENABLED , + &BTRFS_I (inode)->root->fs_info->flags)) +return 0 ; +/* In release case, we shouldn't have @reserved */ WARN_ON (!free && reserved);if (free && reserved)
fs/btrfs/qgroup.h +2 -0
@@ -249,6 +249,8 @@ void btrfs_qgroup_free_refroot(struct btstatic inline void btrfs_qgroup_free_delayed_ref (struct btrfs_fs_info *fs_info,u64 ref_root,u64 num_bytes) { +if (!test_bit (BTRFS_FS_QUOTA_ENABLED , &fs_info->flags)) +return ;trace_btrfs_qgroup_free_delayed_ref (fs_info, ref_root, num_bytes);btrfs_qgroup_free_refroot (fs_info, ref_root, num_bytes,BTRFS_QGROUP_RSV_DATA );
Greg Kroah-Hartman
maintainerPATCH 357/361 net: sched: Remove TCA_OPTIONS from policy
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Ahern <[email protected]>
commit e72bde6b66299602087c8c2350d36a525e75d06e upstream.
Marco reported an error with hfsc:
root@Calimero:~# tc qdisc add dev eth0 root handle 1:0 hfsc default 1 Error: Attribute failed policy validation.
Apparently a few implementations pass TCA_OPTIONS as a binary instead of nested attribute, so drop TCA_OPTIONS from the policy.
--- net/sched/sch_api.c | 1 - 1 file changed, 1 deletion(-)
net/sched/sch_api.c +0 -1
@@ -1309,7 +1309,6 @@ check_loop_fn(struct Qdisc *q, unsignedconst struct nla_policy rtm_tca_policy[TCA_MAX +1 ] = { [TCA_KIND ] = { .type =NLA_STRING }, - [TCA_OPTIONS ] = { .type =NLA_NESTED }, [TCA_RATE ] = { .type =NLA_BINARY , .len =sizeof (struct tc_estimator ) }, [TCA_STAB ] = { .type =NLA_NESTED },
Greg Kroah-Hartman
maintainerPATCH 354/361 btrfs: move the dio_sem higher up the callchain
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit c495144bc6962186feae31d687596d2472000e45 upstream.
We're getting a lockdep splat because we take the dio_sem under the log_mutex. What we really need is to protect fsync() from logging an extent map for an extent we never waited on higher up, so just guard the whole thing with dio_sem.
======================================================
WARNING: possible circular locking dependency detected 4.18.0-rc4-xfstests-00025-g5de5edbaf1d4 #411 Not tainted
------------------------------------------------------
aio-dio-invalid/30928 is trying to acquire lock:0000000092621cfd (&mm->mmap_sem){++++}, at: get_user_pages_unlocked+0x5a/0x1e0
but task is already holding lock:00000000cefe6b35 (&ei->dio_sem){++++}, at: btrfs_direct_IO+0x3be/0x400
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #5 (&ei->dio_sem){++++}:
lock_acquire+0xbd/0x220
down_write+0x51/0xb0
btrfs_log_changed_extents+0x80/0xa40
btrfs_log_inode+0xbaf/0x1000
btrfs_log_inode_parent+0x26f/0xa80
btrfs_log_dentry_safe+0x50/0x70
btrfs_sync_file+0x357/0x540
do_fsync+0x38/0x60
__ia32_sys_fdatasync+0x12/0x20
do_fast_syscall_32+0x9a/0x2f0
entry_SYSENTER_compat+0x84/0x96-> #4 (&ei->log_mutex){+.+.}:
lock_acquire+0xbd/0x220
__mutex_lock+0x86/0xa10
btrfs_record_unlink_dir+0x2a/0xa0
btrfs_unlink+0x5a/0xc0
vfs_unlink+0xb1/0x1a0
do_unlinkat+0x264/0x2b0
do_fast_syscall_32+0x9a/0x2f0
entry_SYSENTER_compat+0x84/0x96-> #3 (sb_internal#2){.+.+}:
lock_acquire+0xbd/0x220
__sb_start_write+0x14d/0x230
start_transaction+0x3e6/0x590
btrfs_evict_inode+0x475/0x640
evict+0xbf/0x1b0
btrfs_run_delayed_iputs+0x6c/0x90
cleaner_kthread+0x124/0x1a0
kthread+0x106/0x140
ret_from_fork+0x3a/0x50-> #2 (&fs_info->cleaner_delayed_iput_mutex){+.+.}:
lock_acquire+0xbd/0x220
__mutex_lock+0x86/0xa10
btrfs_alloc_data_chunk_ondemand+0x197/0x530
btrfs_check_data_free_space+0x4c/0x90
btrfs_delalloc_reserve_space+0x20/0x60
btrfs_page_mkwrite+0x87/0x520
do_page_mkwrite+0x31/0xa0
__handle_mm_fault+0x799/0xb00
handle_mm_fault+0x7c/0xe0
__do_page_fault+0x1d3/0x4a0
async_page_fault+0x1e/0x30-> #1 (sb_pagefaults){.+.+}:
lock_acquire+0xbd/0x220
__sb_start_write+0x14d/0x230
btrfs_page_mkwrite+0x6a/0x520
do_page_mkwrite+0x31/0xa0
__handle_mm_fault+0x799/0xb00
handle_mm_fault+0x7c/0xe0
__do_page_fault+0x1d3/0x4a0
async_page_fault+0x1e/0x30-> #0 (&mm->mmap_sem){++++}:
__lock_acquire+0x42e/0x7a0
lock_acquire+0xbd/0x220
down_read+0x48/0xb0
get_user_pages_unlocked+0x5a/0x1e0
get_user_pages_fast+0xa4/0x150
iov_iter_get_pages+0xc3/0x340
do_direct_IO+0xf93/0x1d70
__blockdev_direct_IO+0x32d/0x1c20
btrfs_direct_IO+0x227/0x400
generic_file_direct_write+0xcf/0x180
btrfs_file_write_iter+0x308/0x58c
aio_write+0xf8/0x1d0
io_submit_one+0x3a9/0x620
__ia32_compat_sys_io_submit+0xb2/0x270
do_int80_syscall_32+0x5b/0x1a0
entry_INT80_compat+0x88/0xa0other info that might help us debug this:
Chain exists of: &mm->mmap_sem --> &ei->log_mutex --> &ei->dio_sem Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&ei->dio_sem);
lock(&ei->log_mutex);
lock(&ei->dio_sem); lock(&mm->mmap_sem);
*** DEADLOCK ***
1 lock held by aio-dio-invalid/30928:
#0: 00000000cefe6b35 (&ei->dio_sem){++++}, at: btrfs_direct_IO+0x3be/0x400
stack backtrace: CPU: 0 PID: 30928 Comm: aio-dio-invalid Not tainted 4.18.0-rc4-xfstests-00025-g5de5edbaf1d4 #411 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2.el7 04/01/2014 Call Trace: dump_stack+0x7c/0xbb print_circular_bug.isra.37+0x297/0x2a4 check_prev_add.constprop.45+0x781/0x7a0 ? __lock_acquire+0x42e/0x7a0 validate_chain.isra.41+0x7f0/0xb00 __lock_acquire+0x42e/0x7a0 lock_acquire+0xbd/0x220 ? get_user_pages_unlocked+0x5a/0x1e0 down_read+0x48/0xb0 ? get_user_pages_unlocked+0x5a/0x1e0 get_user_pages_unlocked+0x5a/0x1e0 get_user_pages_fast+0xa4/0x150 iov_iter_get_pages+0xc3/0x340 do_direct_IO+0xf93/0x1d70 ? __alloc_workqueue_key+0x358/0x490 ? __blockdev_direct_IO+0x14b/0x1c20 __blockdev_direct_IO+0x32d/0x1c20 ? btrfs_run_delalloc_work+0x40/0x40 ? can_nocow_extent+0x490/0x490 ? kvm_clock_read+0x1f/0x30 ? can_nocow_extent+0x490/0x490 ? btrfs_run_delalloc_work+0x40/0x40 btrfs_direct_IO+0x227/0x400 ? btrfs_run_delalloc_work+0x40/0x40 generic_file_direct_write+0xcf/0x180 btrfs_file_write_iter+0x308/0x58c aio_write+0xf8/0x1d0 ? kvm_clock_read+0x1f/0x30 ? __might_fault+0x3e/0x90 io_submit_one+0x3a9/0x620 ? io_submit_one+0xe5/0x620 __ia32_compat_sys_io_submit+0xb2/0x270 do_int80_syscall_32+0x5b/0x1a0 entry_INT80_compat+0x88/0xa0
--- fs/btrfs/file.c | 12 ++++++++++++ fs/btrfs/tree-log.c | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-)
fs/btrfs/file.c +12 -0
@@ -2078,6 +2078,14 @@ int btrfs_sync_file(struct file *file, l goto out;inode_lock (inode); + +/* +* We take the dio_sem here because the tree log stuff can race with +* lockless dio writes and get an extent map logged for an extent we +* never waited on. We need it this high up for lockdep reasons. +*/ +down_write (&BTRFS_I (inode)->dio_sem); +atomic_inc (&root->log_batch);/*
@@ -2086,6 +2094,7 @@ int btrfs_sync_file(struct file *file, l*/ ret =btrfs_wait_ordered_range (inode, start, len);if (ret) { +up_write (&BTRFS_I (inode)->dio_sem);inode_unlock (inode); goto out; }
@@ -2109,6 +2118,7 @@ int btrfs_sync_file(struct file *file, l* checked called fsync. */ ret =filemap_check_wb_err (inode->i_mapping, file->f_wb_err); +up_write (&BTRFS_I (inode)->dio_sem);inode_unlock (inode); goto out; }
@@ -2127,6 +2137,7 @@ int btrfs_sync_file(struct file *file, l trans =btrfs_start_transaction (root,0 );if (IS_ERR (trans)) { ret =PTR_ERR (trans); +up_write (&BTRFS_I (inode)->dio_sem);inode_unlock (inode); goto out; }
@@ -2148,6 +2159,7 @@ int btrfs_sync_file(struct file *file, l* file again, but that will end up using the synchronization * inside btrfs_sync_log to keep things safe. */ +up_write (&BTRFS_I (inode)->dio_sem);inode_unlock (inode);/*
fs/btrfs/tree-log.c +0 -2
@@ -4393,7 +4393,6 @@ static int btrfs_log_changed_extents(strINIT_LIST_HEAD (&extents); -down_write (&inode->dio_sem);write_lock (&tree->lock); test_gen = root->fs_info->last_trans_committed; logged_start = start;
@@ -4459,7 +4458,6 @@ process: }WARN_ON (!list_empty (&extents));write_unlock (&tree->lock); -up_write (&inode->dio_sem);btrfs_release_path (path);if (!ret)
Greg Kroah-Hartman
maintainerPATCH 356/361 Btrfs: fix use-after-free when dumping free space
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 9084cb6a24bf5838a665af92ded1af8363f9e563 upstream.
We were iterating a block group's free space cache rbtree without locking first the lock that protects it (the free_space_ctl->free_space_offset rbtree is protected by the free_space_ctl->tree_lock spinlock).
KASAN reported an use-after-free problem when iterating such a rbtree due to a concurrent rbtree delete:
[ 9520.359168] ==================================================================
[ 9520.359656] BUG: KASAN: use-after-free in rb_next+0x13/0x90
[ 9520.359949] Read of size 8 at addr ffff8800b7ada500 by task btrfs-transacti/1721
[ 9520.360357]
[ 9520.360530] CPU: 4 PID: 1721 Comm: btrfs-transacti Tainted: G L 4.19.0-rc8-nbor #555
[ 9520.360990] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
[ 9520.362682] Call Trace:
[ 9520.362887] dump_stack+0xa4/0xf5
[ 9520.363146] print_address_description+0x78/0x280
[ 9520.363412] kasan_report+0x263/0x390
[ 9520.363650] ? rb_next+0x13/0x90
[ 9520.363873] __asan_load8+0x54/0x90
[ 9520.364102] rb_next+0x13/0x90
[ 9520.364380] btrfs_dump_free_space+0x146/0x160 [btrfs]
[ 9520.364697] dump_space_info+0x2cd/0x310 [btrfs]
[ 9520.364997] btrfs_reserve_extent+0x1ee/0x1f0 [btrfs]
[ 9520.365310] __btrfs_prealloc_file_range+0x1cc/0x620 [btrfs]
[ 9520.365646] ? btrfs_update_time+0x180/0x180 [btrfs]
[ 9520.365923] ? _raw_spin_unlock+0x27/0x40
[ 9520.366204] ? btrfs_alloc_data_chunk_ondemand+0x2c0/0x5c0 [btrfs]
[ 9520.366549] btrfs_prealloc_file_range_trans+0x23/0x30 [btrfs]
[ 9520.366880] cache_save_setup+0x42e/0x580 [btrfs]
[ 9520.367220] ? btrfs_check_data_free_space+0xd0/0xd0 [btrfs]
[ 9520.367518] ? lock_downgrade+0x2f0/0x2f0
[ 9520.367799] ? btrfs_write_dirty_block_groups+0x11f/0x6e0 [btrfs]
[ 9520.368104] ? kasan_check_read+0x11/0x20
[ 9520.368349] ? do_raw_spin_unlock+0xa8/0x140
[ 9520.368638] btrfs_write_dirty_block_groups+0x2af/0x6e0 [btrfs]
[ 9520.368978] ? btrfs_start_dirty_block_groups+0x870/0x870 [btrfs]
[ 9520.369282] ? do_raw_spin_unlock+0xa8/0x140
[ 9520.369534] ? _raw_spin_unlock+0x27/0x40
[ 9520.369811] ? btrfs_run_delayed_refs+0x1b8/0x230 [btrfs]
[ 9520.370137] commit_cowonly_roots+0x4b9/0x610 [btrfs]
[ 9520.370560] ? commit_fs_roots+0x350/0x350 [btrfs]
[ 9520.370926] ? btrfs_run_delayed_refs+0x1b8/0x230 [btrfs]
[ 9520.371285] btrfs_commit_transaction+0x5e5/0x10e0 [btrfs]
[ 9520.371612] ? btrfs_apply_pending_changes+0x90/0x90 [btrfs]
[ 9520.371943] ? start_transaction+0x168/0x6c0 [btrfs]
[ 9520.372257] transaction_kthread+0x21c/0x240 [btrfs]
[ 9520.372537] kthread+0x1d2/0x1f0
[ 9520.372793] ? btrfs_cleanup_transaction+0xb50/0xb50 [btrfs]
[ 9520.373090] ? kthread_park+0xb0/0xb0
[ 9520.373329] ret_from_fork+0x3a/0x50
[ 9520.373567]
[ 9520.373738] Allocated by task 1804:
[ 9520.373974] kasan_kmalloc+0xff/0x180
[ 9520.374208] kasan_slab_alloc+0x11/0x20
[ 9520.374447] kmem_cache_alloc+0xfc/0x2d0
[ 9520.374731] __btrfs_add_free_space+0x40/0x580 [btrfs]
[ 9520.375044] unpin_extent_range+0x4f7/0x7a0 [btrfs]
[ 9520.375383] btrfs_finish_extent_commit+0x15f/0x4d0 [btrfs]
[ 9520.375707] btrfs_commit_transaction+0xb06/0x10e0 [btrfs]
[ 9520.376027] btrfs_alloc_data_chunk_ondemand+0x237/0x5c0 [btrfs]
[ 9520.376365] btrfs_check_data_free_space+0x81/0xd0 [btrfs]
[ 9520.376689] btrfs_delalloc_reserve_space+0x25/0x80 [btrfs]
[ 9520.377018] btrfs_direct_IO+0x42e/0x6d0 [btrfs]
[ 9520.377284] generic_file_direct_write+0x11e/0x220
[ 9520.377587] btrfs_file_write_iter+0x472/0xac0 [btrfs]
[ 9520.377875] aio_write+0x25c/0x360
[ 9520.378106] io_submit_one+0xaa0/0xdc0
[ 9520.378343] __se_sys_io_submit+0xfa/0x2f0
[ 9520.378589] __x64_sys_io_submit+0x43/0x50
[ 9520.378840] do_syscall_64+0x7d/0x240
[ 9520.379081] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 9520.379387]
[ 9520.379557] Freed by task 1802:
[ 9520.379782] __kasan_slab_free+0x173/0x260
[ 9520.380028] kasan_slab_free+0xe/0x10
[ 9520.380262] kmem_cache_free+0xc1/0x2c0
[ 9520.380544] btrfs_find_space_for_alloc+0x4cd/0x4e0 [btrfs]
[ 9520.380866] find_free_extent+0xa99/0x17e0 [btrfs]
[ 9520.381166] btrfs_reserve_extent+0xd5/0x1f0 [btrfs]
[ 9520.381474] btrfs_get_blocks_direct+0x60b/0xbd0 [btrfs]
[ 9520.381761] __blockdev_direct_IO+0x10ee/0x58a1
[ 9520.382059] btrfs_direct_IO+0x25a/0x6d0 [btrfs]
[ 9520.382321] generic_file_direct_write+0x11e/0x220
[ 9520.382623] btrfs_file_write_iter+0x472/0xac0 [btrfs]
[ 9520.382904] aio_write+0x25c/0x360
[ 9520.383172] io_submit_one+0xaa0/0xdc0
[ 9520.383416] __se_sys_io_submit+0xfa/0x2f0
[ 9520.383678] __x64_sys_io_submit+0x43/0x50
[ 9520.383927] do_syscall_64+0x7d/0x240
[ 9520.384165] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[ 9520.384439]
[ 9520.384610] The buggy address belongs to the object at ffff8800b7ada500
which belongs to the cache btrfs_free_space of size 72
[ 9520.385175] The buggy address is located 0 bytes inside of
72-byte region [ffff8800b7ada500, ffff8800b7ada548)
[ 9520.385691] The buggy address belongs to the page:
[ 9520.385957] page:ffffea0002deb680 count:1 mapcount:0 mapping:ffff880108a1d700 index:0x0 compound_mapcount: 0
[ 9520.388030] flags: 0x8100(slab|head)
[ 9520.388281] raw: 0000000000008100 ffffea0002deb608 ffffea0002728808 ffff880108a1d700
[ 9520.388722] raw: 0000000000000000 0000000000130013 00000001ffffffff 0000000000000000
[ 9520.389169] page dumped because: kasan: bad access detected
[ 9520.389473]
[ 9520.389658] Memory state around the buggy address:
[ 9520.389943] ffff8800b7ada400: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 9520.390368] ffff8800b7ada480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 9520.390796] >ffff8800b7ada500: fb fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc
[ 9520.391223] ^
[ 9520.391461] ffff8800b7ada580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 9520.391885] ffff8800b7ada600: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 9520.392313] ==================================================================
[ 9520.392772] BTRFS critical (device vdc): entry offset 2258497536, bytes 131072, bitmap no
[ 9520.393247] BUG: unable to handle kernel NULL pointer dereference at 0000000000000011
[ 9520.393705] PGD 800000010dbab067 P4D 800000010dbab067 PUD 107551067 PMD 0
[ 9520.394059] Oops: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI
[ 9520.394378] CPU: 4 PID: 1721 Comm: btrfs-transacti Tainted: G B L 4.19.0-rc8-nbor #555
[ 9520.394858] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
[ 9520.395350] RIP: 0010:rb_next+0x3c/0x90
[ 9520.396461] RSP: 0018:ffff8801074ff780 EFLAGS: 00010292
[ 9520.396762] RAX: 0000000000000000 RBX: 0000000000000001 RCX: ffffffff81b5ac4c
[ 9520.397115] RDX: 0000000000000000 RSI: 0000000000000008 RDI: 0000000000000011
[ 9520.397468] RBP: ffff8801074ff7a0 R08: ffffed0021d64ccc R09: ffffed0021d64ccc
[ 9520.397821] R10: 0000000000000001 R11: ffffed0021d64ccb R12: ffff8800b91e0000
[ 9520.398188] R13: ffff8800a3ceba48 R14: ffff8800b627bf80 R15: 0000000000020000
[ 9520.398555] FS: 0000000000000000(0000) GS:ffff88010eb00000(0000) knlGS:0000000000000000
[ 9520.399007] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 9520.399335] CR2: 0000000000000011 CR3: 0000000106b52000 CR4: 00000000000006a0
[ 9520.399679] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 9520.400023] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 9520.400400] Call Trace:
[ 9520.400648] btrfs_dump_free_space+0x146/0x160 [btrfs]
[ 9520.400974] dump_space_info+0x2cd/0x310 [btrfs]
[ 9520.401287] btrfs_reserve_extent+0x1ee/0x1f0 [btrfs]
[ 9520.401609] __btrfs_prealloc_file_range+0x1cc/0x620 [btrfs]
[ 9520.401952] ? btrfs_update_time+0x180/0x180 [btrfs]
[ 9520.402232] ? _raw_spin_unlock+0x27/0x40
[ 9520.402522] ? btrfs_alloc_data_chunk_ondemand+0x2c0/0x5c0 [btrfs]
[ 9520.402882] btrfs_prealloc_file_range_trans+0x23/0x30 [btrfs]
[ 9520.403261] cache_save_setup+0x42e/0x580 [btrfs]
[ 9520.403570] ? btrfs_check_data_free_space+0xd0/0xd0 [btrfs]
[ 9520.403871] ? lock_downgrade+0x2f0/0x2f0
[ 9520.404161] ? btrfs_write_dirty_block_groups+0x11f/0x6e0 [btrfs]
[ 9520.404481] ? kasan_check_read+0x11/0x20
[ 9520.404732] ? do_raw_spin_unlock+0xa8/0x140
[ 9520.405026] btrfs_write_dirty_block_groups+0x2af/0x6e0 [btrfs]
[ 9520.405375] ? btrfs_start_dirty_block_groups+0x870/0x870 [btrfs]
[ 9520.405694] ? do_raw_spin_unlock+0xa8/0x140
[ 9520.405958] ? _raw_spin_unlock+0x27/0x40
[ 9520.406243] ? btrfs_run_delayed_refs+0x1b8/0x230 [btrfs]
[ 9520.406574] commit_cowonly_roots+0x4b9/0x610 [btrfs]
[ 9520.406899] ? commit_fs_roots+0x350/0x350 [btrfs]
[ 9520.407253] ? btrfs_run_delayed_refs+0x1b8/0x230 [btrfs]
[ 9520.407589] btrfs_commit_transaction+0x5e5/0x10e0 [btrfs]
[ 9520.407925] ? btrfs_apply_pending_changes+0x90/0x90 [btrfs]
[ 9520.408262] ? start_transaction+0x168/0x6c0 [btrfs]
[ 9520.408582] transaction_kthread+0x21c/0x240 [btrfs]
[ 9520.408870] kthread+0x1d2/0x1f0
[ 9520.409138] ? btrfs_cleanup_transaction+0xb50/0xb50 [btrfs]
[ 9520.409440] ? kthread_park+0xb0/0xb0
[ 9520.409682] ret_from_fork+0x3a/0x50
[ 9520.410508] Dumping ftrace buffer:
[ 9520.410764] (ftrace buffer empty)
[ 9520.411007] CR2: 0000000000000011
[ 9520.411297] ---[ end trace 01a0863445cf360a ]---
[ 9520.411568] RIP: 0010:rb_next+0x3c/0x90
[ 9520.412644] RSP: 0018:ffff8801074ff780 EFLAGS: 00010292
[ 9520.412932] RAX: 0000000000000000 RBX: 0000000000000001 RCX: ffffffff81b5ac4c
[ 9520.413274] RDX: 0000000000000000 RSI: 0000000000000008 RDI: 0000000000000011
[ 9520.413616] RBP: ffff8801074ff7a0 R08: ffffed0021d64ccc R09: ffffed0021d64ccc
[ 9520.414007] R10: 0000000000000001 R11: ffffed0021d64ccb R12: ffff8800b91e0000
[ 9520.414349] R13: ffff8800a3ceba48 R14: ffff8800b627bf80 R15: 0000000000020000
[ 9520.416074] FS: 0000000000000000(0000) GS:ffff88010eb00000(0000) knlGS:0000000000000000
[ 9520.416536] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 9520.416848] CR2: 0000000000000011 CR3: 0000000106b52000 CR4: 00000000000006a0
[ 9520.418477] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 9520.418846] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 9520.419204] Kernel panic - not syncing: Fatal exception
[ 9520.419666] Dumping ftrace buffer:
[ 9520.419930] (ftrace buffer empty)
[ 9520.420168] Kernel Offset: disabled
[ 9520.420406] ---[ end Kernel panic - not syncing: Fatal exception ]---Fix this by acquiring the respective lock before iterating the rbtree.
--- fs/btrfs/free-space-cache.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/free-space-cache.c +2 -0
@@ -2459,6 +2459,7 @@ void btrfs_dump_free_space(struct btrfs_struct rb_node *n;int count =0 ; +spin_lock (&ctl->tree_lock);for (n =rb_first (&ctl->free_space_offset); n; n =rb_next (n)) { info = rb_entry(n, struct btrfs_free_space, offset_index);if (info->bytes >= bytes && !block_group->ro)
@@ -2467,6 +2468,7 @@ void btrfs_dump_free_space(struct btrfs_ info->offset, info->bytes, (info->bitmap) ? "yes" : "no"); } +spin_unlock (&ctl->tree_lock);btrfs_info (fs_info,"block group has cluster?: %s" ,list_empty (&block_group->cluster_list) ?"no" :"yes" ); btrfs_info(fs_info,
Greg Kroah-Hartman
maintainerPATCH 360/361 bpf: wait for running BPF programs when updating map-in-map
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Colascione <[email protected]>
commit 1ae80cf31938c8f77c37a29bbe29e7f1cd492be8 upstream.
The map-in-map frequently serves as a mechanism for atomic snapshotting of state that a BPF program might record. The current implementation is dangerous to use in this way, however, since userspace has no way of knowing when all programs that might have retrieved the "old" value of the map may have completed.
This change ensures that map update operations on map-in-map map types always wait for all references to the old map to drop before returning to userspace.
--- kernel/bpf/syscall.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
kernel/bpf/syscall.c +13 -0
@@ -741,6 +741,17 @@ err_put:return err; } +static void maybe_wait_bpf_programs (struct bpf_map *map) +{ +/* Wait for any running BPF programs to complete so that +* userspace, when we return to it, knows that all programs +* that could be running use the new map value. +*/ +if (map->map_type ==BPF_MAP_TYPE_HASH_OF_MAPS || + map->map_type ==BPF_MAP_TYPE_ARRAY_OF_MAPS ) +synchronize_rcu (); +} +#define BPF_MAP_UPDATE_ELEM_LAST_FIELD flagsstatic int map_update_elem (union bpf_attr *attr)
@@ -831,6 +842,7 @@ static int map_update_elem(union bpf_att }__this_cpu_dec (bpf_prog_active);preempt_enable (); +maybe_wait_bpf_programs (map); out: free_value:kfree (value);
@@ -883,6 +895,7 @@ static int map_delete_elem(union bpf_attrcu_read_unlock ();__this_cpu_dec (bpf_prog_active);preempt_enable (); +maybe_wait_bpf_programs (map); out:kfree (key); err_put:
Greg Kroah-Hartman
maintainerPATCH 358/361 vt: fix broken display when running aptitude
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit 943210ba807ec50aafa2fa7b13bd6d36a478969b upstream.
If you run aptitude on framebuffer console, the display is corrupted. The corruption is caused by the commit d8ae7242. The patch adds "offset" to "start" when calling scr_memsetw, but it forgets to do the same addition on a subsequent call to do_update_region.
--- drivers/tty/vt/vt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/vt/vt.c +1 -1
@@ -1551,7 +1551,7 @@ static void csi_K(struct vc_data *vc, inscr_memsetw (start + offset, vc->vc_video_erase_char,2 * count); vc->vc_need_wrap =0 ;if (con_should_update (vc)) -do_update_region (vc, (unsigned long ) start, count); +do_update_region (vc, (unsigned long )(start + offset), count); }static void csi_X (struct vc_data *vc,int vpar)/* erase the following vpar positions */
Greg Kroah-Hartman
maintainerPATCH 359/361 userns: also map extents in the reverse map to kernel IDs
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jann Horn <[email protected]>
commit d2f007dbe7e4c9583eea6eb04d60001e85c6f1bd upstream.
The current logic first clones the extent array and sorts both copies, then maps the lower IDs of the forward mapping into the lower namespace, but doesn't map the lower IDs of the reverse mapping.
This means that code in a nested user namespace with >5 extents will see incorrect IDs. It also breaks some access checks, like inode_owner_or_capable() and privileged_wrt_inode_uidgid(), so a process can incorrectly appear to be capable relative to an inode.
To fix it, we have to make sure that the "lower_first" members of extents in both arrays are translated; and we have to make sure that the reverse map is sorted *after* the translation (since otherwise the translation can break the sorting).
This is CVE-2018-18955.
--- kernel/user_namespace.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
kernel/user_namespace.c +8 -4
@@ -974,10 +974,6 @@ static ssize_t map_write(struct file *fiif (!new_idmap_permitted (file, ns, cap_setid, &new_map)) goto out; - ret =sort_idmaps (&new_map); -if (ret <0 ) - goto out; - ret = -EPERM ;/* Map the lower ids from the parent user namespace to the * kernel global id space.
@@ -1004,6 +1000,14 @@ static ssize_t map_write(struct file *fi e->lower_first = lower_first; } +/* +* If we want to use binary search for lookup, this clones the extent +* array and sorts both copies. +*/ + ret =sort_idmaps (&new_map); +if (ret <0 ) + goto out; +/* Install the map */ if (new_map.nr_extents <=UID_GID_MAP_MAX_BASE_EXTENTS ) { memcpy(map->extent, new_map.extent,
Greg Kroah-Hartman
maintainerPATCH 355/361 Btrfs: fix use-after-free during inode eviction
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 421f0922a2cfb0c75acd9746454aaa576c711a65 upstream.
At inode.c:evict_inode_truncate_pages(), when we iterate over the inode's extent states, we access an extent state record's "state" field after we unlocked the inode's io tree lock. This can lead to a use-after-free issue because after we unlock the io tree that extent state record might have been freed due to being merged into another adjacent extent state record (a previous inflight bio for a read operation finished in the meanwhile which unlocked a range in the io tree and cause a merge of extent state records, as explained in the comment before the while loop added in commit 6ca0709756710 ("Btrfs: fix hang during inode eviction due to concurrent readahead")).
Fix this by keeping a copy of the extent state's flags in a local variable and using it after unlocking the io tree.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201189
--- fs/btrfs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/btrfs/inode.c +3 -1
@@ -5283,11 +5283,13 @@ static void evict_inode_truncate_pages(sstruct extent_state *cached_state =NULL ;u64 start;u64 end; +unsigned state_flags; node =rb_first (&io_tree->state); state = rb_entry(node, struct extent_state, rb_node); start = state->start; end = state->end; + state_flags = state->state;spin_unlock (&io_tree->lock);lock_extent_bits (io_tree, start, end, &cached_state);
@@ -5300,7 +5302,7 @@ static void evict_inode_truncate_pages(s* * Note, end is the bytenr of last byte, so we need + 1 here. */ -if (state->state &EXTENT_DELALLOC ) +if (state_flags &EXTENT_DELALLOC )btrfs_qgroup_free_data (inode,NULL , start, end - start +1 ); clear_extent_bit(io_tree, start, end,
Greg Kroah-Hartman
maintainerPATCH 325/361 tracing: Return -ENOENT if there is no target synthetic event
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu <[email protected]>
commit 18858511fd8a877303cc34c06efa461b26a0e070 upstream.
Return -ENOENT error if there is no target synthetic event. This notices an operation failure to user as below;
# echo 'wakeup_latency u64 lat; pid_t pid;' > synthetic_events # echo '!wakeup' >> synthetic_events sh: write error: No such file or directory
--- kernel/trace/trace_events_hist.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +3 -1
@@ -1063,8 +1063,10 @@ static int create_synth_event(int argc, event =NULL ; ret = -EEXIST ; goto out; - }else if (delete_event) + }else if (delete_event) { + ret = -ENOENT ; goto out; + }if (argc <2 ) { ret = -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 322/361 soc/tegra: pmc: Fix child-node lookup
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 1dc6bd5e39a29453bdcc17348dd2a89f1aa4004e upstream.
Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children.
To make things worse, the parent pmc node could end up being prematurely freed as of_find_node_by_name() drops a reference to its first argument.
--- drivers/soc/tegra/pmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/tegra/pmc.c +1 -1
@@ -1288,7 +1288,7 @@ static void tegra_pmc_init_tsense_reset(if (!pmc->soc->has_tsense_reset)return ; - np =of_find_node_by_name (pmc->dev->of_node,"i2c-thermtrip" ); + np =of_get_child_by_name (pmc->dev->of_node,"i2c-thermtrip" );if (!np) {dev_warn (dev,"i2c-thermtrip node not found, %s.\n" , disabled);return ;
Greg Kroah-Hartman
maintainerPATCH 347/361 Btrfs: fix deadlock when writing out free space caches
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 5ce555578e0919237fa4bda92b4670e2dd176f85 upstream.
When writing out a block group free space cache we can end deadlocking with ourselves on an extent buffer lock resulting in a warning like the following:
[245043.379979] WARNING: CPU: 4 PID: 2608 at fs/btrfs/locking.c:251 btrfs_tree_lock+0x1be/0x1d0 [btrfs]
[245043.392792] CPU: 4 PID: 2608 Comm: btrfs-transacti Tainted: G
W I 4.16.8 #1
[245043.395489] RIP: 0010:btrfs_tree_lock+0x1be/0x1d0 [btrfs]
[245043.396791] RSP: 0018:ffffc9000424b840 EFLAGS: 00010246
[245043.398093] RAX: 0000000000000a30 RBX: ffff8807e20a3d20 RCX: 0000000000000001
[245043.399414] RDX: 0000000000000001 RSI: 0000000000000002 RDI: ffff8807e20a3d20
[245043.400732] RBP: 0000000000000001 R08: ffff88041f39a700 R09: ffff880000000000
[245043.402021] R10: 0000000000000040 R11: ffff8807e20a3d20 R12: ffff8807cb220630
[245043.403296] R13: 0000000000000001 R14: ffff8807cb220628 R15: ffff88041fbdf000
[245043.404780] FS: 0000000000000000(0000) GS:ffff88082fc80000(0000) knlGS:0000000000000000
[245043.406050] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[245043.407321] CR2: 00007fffdbdb9f10 CR3: 0000000001c09005 CR4: 00000000000206e0
[245043.408670] Call Trace:
[245043.409977] btrfs_search_slot+0x761/0xa60 [btrfs]
[245043.411278] btrfs_insert_empty_items+0x62/0xb0 [btrfs]
[245043.412572] btrfs_insert_item+0x5b/0xc0 [btrfs]
[245043.413922] btrfs_create_pending_block_groups+0xfb/0x1e0 [btrfs]
[245043.415216] do_chunk_alloc+0x1e5/0x2a0 [btrfs]
[245043.416487] find_free_extent+0xcd0/0xf60 [btrfs]
[245043.417813] btrfs_reserve_extent+0x96/0x1e0 [btrfs]
[245043.419105] btrfs_alloc_tree_block+0xfb/0x4a0 [btrfs]
[245043.420378] __btrfs_cow_block+0x127/0x550 [btrfs]
[245043.421652] btrfs_cow_block+0xee/0x190 [btrfs]
[245043.422979] btrfs_search_slot+0x227/0xa60 [btrfs]
[245043.424279] ? btrfs_update_inode_item+0x59/0x100 [btrfs]
[245043.425538] ? iput+0x72/0x1e0
[245043.426798] write_one_cache_group.isra.49+0x20/0x90 [btrfs]
[245043.428131] btrfs_start_dirty_block_groups+0x102/0x420 [btrfs]
[245043.429419] btrfs_commit_transaction+0x11b/0x880 [btrfs]
[245043.430712] ? start_transaction+0x8e/0x410 [btrfs]
[245043.432006] transaction_kthread+0x184/0x1a0 [btrfs]
[245043.433341] kthread+0xf0/0x130
[245043.434628] ? btrfs_cleanup_transaction+0x4e0/0x4e0 [btrfs]
[245043.435928] ? kthread_create_worker_on_cpu+0x40/0x40
[245043.437236] ret_from_fork+0x1f/0x30
[245043.441054] ---[ end trace 15abaa2aaf36827f ]---This is because at write_one_cache_group() when we are COWing a leaf from the extent tree we end up allocating a new block group (chunk) and, because we have hit a threshold on the number of bytes reserved for system chunks, we attempt to finalize the creation of new block groups from the current transaction, by calling btrfs_create_pending_block_groups(). However here we also need to modify the extent tree in order to insert a block group item, and if the location for this new block group item happens to be in the same leaf that we were COWing earlier, we deadlock since btrfs_search_slot() tries to write lock the extent buffer that we locked before at write_one_cache_group().
We have already hit similar cases in the past and commit d9a0540a79f8 ("Btrfs: fix deadlock when finalizing block group creation") fixed some of those cases by delaying the creation of pending block groups at the known specific spots that could lead to a deadlock. This change reworks that commit to be more generic so that we don't have to add similar logic to every possible path that can lead to a deadlock. This is done by making __btrfs_cow_block() disallowing the creation of new block groups (setting the transaction's can_flush_pending_bgs to false) before it attempts to allocate a new extent buffer for either the extent, chunk or device trees, since those are the trees that pending block creation modifies. Once the new extent buffer is allocated, it allows creation of pending block groups to happen again.
This change depends on a recent patch from Josef which is not yet in Linus' tree, named "btrfs: make sure we create all new block groups" in order to avoid occasional warnings at btrfs_trans_release_chunk_metadata().
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199753
--- fs/btrfs/ctree.c | 17 +++++++++++++++++ fs/btrfs/extent-tree.c | 16 ++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-)
fs/btrfs/ctree.c +17 -0
@@ -1050,9 +1050,26 @@ static noinline int __btrfs_cow_block(stif ((root->root_key.objectid ==BTRFS_TREE_RELOC_OBJECTID ) && parent) parent_start = parent->start; +/* +* If we are COWing a node/leaf from the extent, chunk or device trees, +* make sure that we do not finish block group creation of pending block +* groups. We do this to avoid a deadlock. +* COWing can result in allocation of a new chunk, and flushing pending +* block groups (btrfs_create_pending_block_groups()) can be triggered +* when finishing allocation of a new chunk. Creation of a pending block +* group modifies the extent, chunk and device trees, therefore we could +* deadlock with ourselves since we are holding a lock on an extent +* buffer that btrfs_create_pending_block_groups() may try to COW later. +*/ +if (root == fs_info->extent_root || + root == fs_info->chunk_root || + root == fs_info->dev_root) + trans->can_flush_pending_bgs = false; + cow =btrfs_alloc_tree_block (trans, root, parent_start, root->root_key.objectid, &disk_key, level, search_start, empty_size); + trans->can_flush_pending_bgs = true;if (IS_ERR (cow))return PTR_ERR (cow);
fs/btrfs/extent-tree.c +6 -10
@@ -2911,7 +2911,6 @@ int btrfs_run_delayed_refs(struct btrfs_struct btrfs_delayed_ref_head *head;int ret;int run_all = count == (unsigned long )-1 ; -bool can_flush_pending_bgs = trans->can_flush_pending_bgs;/* We'll clean this up in btrfs_cleanup_transaction */ if (trans->aborted)
@@ -2928,7 +2927,6 @@ again:#ifdef SCRAMBLE_DELAYED_REFS delayed_refs->run_delayed_start =find_middle (&delayed_refs->root);#endif - trans->can_flush_pending_bgs = false; ret =__btrfs_run_delayed_refs (trans, count);if (ret <0 ) {btrfs_abort_transaction (trans, ret);
@@ -2959,7 +2957,6 @@ again: goto again; } out: - trans->can_flush_pending_bgs = can_flush_pending_bgs;return 0 ; }
@@ -4554,11 +4551,9 @@ out:* the block groups that were made dirty during the lifetime of the * transaction. */ -if (trans->can_flush_pending_bgs && - trans->chunk_bytes_reserved >= (u64 )SZ_2M ) { +if (trans->chunk_bytes_reserved >= (u64 )SZ_2M )btrfs_create_pending_block_groups (trans); -btrfs_trans_release_chunk_metadata (trans); - } +return ret; }
@@ -10099,9 +10094,10 @@ void btrfs_create_pending_block_groups(sstruct btrfs_block_group_item item;struct btrfs_key key;int ret =0 ; -bool can_flush_pending_bgs = trans->can_flush_pending_bgs; - trans->can_flush_pending_bgs = false; +if (!trans->can_flush_pending_bgs) +return ; +while (!list_empty (&trans->new_bgs)) { block_group = list_first_entry(&trans->new_bgs, struct btrfs_block_group_cache,
@@ -10126,7 +10122,7 @@ void btrfs_create_pending_block_groups(s next:list_del_init (&block_group->bg_list); } - trans->can_flush_pending_bgs = can_flush_pending_bgs; +btrfs_trans_release_chunk_metadata (trans); } int btrfs_make_block_group(struct btrfs_trans_handle *trans, u64 bytes_used,
Greg Kroah-Hartman
maintainerPATCH 351/361 btrfs: only free reserved extent if we didnt insert it
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 49940bdd57779c78462da7aa5a8650b2fea8c2ff upstream.
When we insert the file extent once the ordered extent completes we free the reserved extent reservation as it'll have been migrated to the bytes_used counter. However if we error out after this step we'll still clear the reserved extent reservation, resulting in a negative accounting of the reserved bytes for the block group and space info. Fix this by only doing the free if we didn't successfully insert a file extent for this extent.
--- fs/btrfs/inode.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/btrfs/inode.c +9 -1
@@ -2945,6 +2945,7 @@ static int btrfs_finish_ordered_io(strucbool truncated = false;bool range_locked = false;bool clear_new_delalloc_bytes = false; +bool clear_reserved_extent = true; if (!test_bit(BTRFS_ORDERED_NOCOW, &ordered_extent->flags) && !test_bit(BTRFS_ORDERED_PREALLOC, &ordered_extent->flags) &&
@@ -3048,10 +3049,12 @@ static int btrfs_finish_ordered_io(struc logical_len, logical_len, compress_type,0 ,0 , BTRFS_FILE_EXTENT_REG); -if (!ret) +if (!ret) { + clear_reserved_extent = false;btrfs_release_delalloc_bytes (fs_info, ordered_extent->start, ordered_extent->disk_len); + } } unpin_extent_cache(&BTRFS_I(inode)->extent_tree, ordered_extent->file_offset, ordered_extent->len,
@@ -3112,8 +3115,13 @@ out:* wrong we need to return the space for this ordered extent * back to the allocator. We only free the extent in the * truncated case if we didn't write out the extent at all. +* +* If we made it past insert_reserved_file_extent before we +* errored out then we don't need to do this as the accounting +* has already been done. */ if ((ret || !logical_len) && + clear_reserved_extent && !test_bit (BTRFS_ORDERED_NOCOW , &ordered_extent->flags) && !test_bit (BTRFS_ORDERED_PREALLOC , &ordered_extent->flags)) btrfs_free_reserved_extent(fs_info,
Greg Kroah-Hartman
maintainerPATCH 349/361 btrfs: set max_extent_size properly
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit ad22cf6ea47fa20fbe11ac324a0a15c0a9a4a2a9 upstream.
We can't use entry->bytes if our entry is a bitmap entry, we need to use entry->max_extent_size in that case. Fix up all the logic to make this consistent.
--- fs/btrfs/free-space-cache.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-)
fs/btrfs/free-space-cache.c +20 -10
@@ -1772,6 +1772,13 @@ static int search_bitmap(struct btrfs_frreturn -1 ; } +static inline u64 get_max_extent_size (struct btrfs_free_space *entry) +{ +if (entry->bitmap) +return entry->max_extent_size; +return entry->bytes; +} +/* Cache the size of the max extent in bytes */ static struct btrfs_free_space * find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes,
@@ -1793,8 +1800,8 @@ find_free_space(struct btrfs_free_space_for (node = &entry->offset_index; node; node =rb_next (node)) { entry = rb_entry(node, struct btrfs_free_space, offset_index);if (entry->bytes < *bytes) { -if (entry->bytes > *max_extent_size) - *max_extent_size = entry->bytes; + *max_extent_size =max (get_max_extent_size (entry), + *max_extent_size);continue ; }
@@ -1812,8 +1819,8 @@ find_free_space(struct btrfs_free_space_ }if (entry->bytes < *bytes + align_off) { -if (entry->bytes > *max_extent_size) - *max_extent_size = entry->bytes; + *max_extent_size =max (get_max_extent_size (entry), + *max_extent_size);continue ; }
@@ -1825,8 +1832,10 @@ find_free_space(struct btrfs_free_space_ *offset = tmp; *bytes = size;return entry; - }else if (size > *max_extent_size) { - *max_extent_size = size; + }else { + *max_extent_size = +max (get_max_extent_size (entry), + *max_extent_size); }continue ; }
@@ -2686,8 +2695,8 @@ static u64 btrfs_alloc_from_bitmap(struc err =search_bitmap (ctl, entry, &search_start, &search_bytes, true);if (err) { -if (search_bytes > *max_extent_size) - *max_extent_size = search_bytes; + *max_extent_size =max (get_max_extent_size (entry), + *max_extent_size);return 0 ; }
@@ -2724,8 +2733,9 @@ u64 btrfs_alloc_from_cluster(struct btrf entry = rb_entry(node, struct btrfs_free_space, offset_index);while (1 ) { -if (entry->bytes < bytes && entry->bytes > *max_extent_size) - *max_extent_size = entry->bytes; +if (entry->bytes < bytes) + *max_extent_size =max (get_max_extent_size (entry), + *max_extent_size);if (entry->bytes < bytes || (!entry->bitmap && entry->offset < min_start)) {
Greg Kroah-Hartman
maintainerPATCH 350/361 btrfs: dont use ctl->free_space for max_extent_size
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit fb5c39d7a887108087de6ff93d3f326b01b4ef41 upstream.
max_extent_size is supposed to be the largest contiguous range for the space info, and ctl->free_space is the total free space in the block group. We need to keep track of these separately and _only_ use the max_free_space if we don't have a max_extent_size, as that means our original request was too large to search any of the block groups for and therefore wouldn't have a max_extent_size set.
--- fs/btrfs/extent-tree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/btrfs/extent-tree.c +5 -2
@@ -7230,6 +7230,7 @@ static noinline int find_free_extent(strstruct btrfs_block_group_cache *block_group =NULL ;u64 search_start =0 ;u64 max_extent_size =0 ; +u64 max_free_space =0 ;u64 empty_cluster =0 ;struct btrfs_space_info *space_info;int loop =0 ;
@@ -7525,8 +7526,8 @@ unclustered_alloc:spin_lock (&ctl->tree_lock);if (ctl->free_space < num_bytes + empty_cluster + empty_size) { -if (ctl->free_space > max_extent_size) - max_extent_size = ctl->free_space; + max_free_space =max (max_free_space, + ctl->free_space);spin_unlock (&ctl->tree_lock); goto loop; }
@@ -7693,6 +7694,8 @@ loop: } out:if (ret == -ENOSPC ) { +if (!max_extent_size) + max_extent_size = max_free_space;spin_lock (&space_info->lock); space_info->max_extent_size = max_extent_size;spin_unlock (&space_info->lock);
Greg Kroah-Hartman
maintainerPATCH 345/361 Btrfs: fix null pointer dereference on compressed write path error
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 3527a018c00e5dbada2f9d7ed5576437b6dd5cfb upstream.
At inode.c:compress_file_range(), under the "free_pages_out" label, we can end up dereferencing the "pages" pointer when it has a NULL value. This case happens when "start" has a value of 0 and we fail to allocate memory for the "pages" pointer. When that happens we jump to the "cont" label and then enter the "if (start == 0)" branch where we immediately call the cow_file_range_inline() function. If that function returns 0 (success creating an inline extent) or an error (like -ENOMEM for example) we jump to the "free_pages_out" label and then access "pages[i]" leading to a NULL pointer dereference, since "nr_pages" has a value greater than zero at that point.
Fix this by setting "nr_pages" to 0 when we fail to allocate memory for the "pages" pointer.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=201119
--- fs/btrfs/inode.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/inode.c +1 -0
@@ -503,6 +503,7 @@ again: pages =kcalloc (nr_pages,sizeof (struct page *),GFP_NOFS );if (!pages) {/* just bail out to the uncompressed code */ + nr_pages =0 ; goto cont; }
Greg Kroah-Hartman
maintainerPATCH 346/361 Btrfs: fix assertion on fsync of regular file when using no-holes feature
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 7ed586d0a8241e81d58c656c5b315f781fa6fc97 upstream.
When using the NO_HOLES feature and logging a regular file, we were expecting that if we find an inline extent, that either its size in RAM (uncompressed and unenconded) matches the size of the file or if it does not, that it matches the sector size and it represents compressed data. This assertion does not cover a case where the length of the inline extent is smaller than the sector size and also smaller the file's size, such case is possible through fallocate. Example:
$ mkfs.btrfs -f -O no-holes /dev/sdb $ mount /dev/sdb /mnt
$ xfs_io -f -c "pwrite -S 0xb60 0 21" /mnt/foobar $ xfs_io -c "falloc 40 40" /mnt/foobar $ xfs_io -c "fsync" /mnt/foobar
In the above example we trigger the assertion because the inline extent's length is 21 bytes while the file size is 80 bytes. The fallocate() call merely updated the file's size and did not touch the existing inline extent, as expected.
So fix this by adjusting the assertion so that an inline extent length smaller than the file size is valid if the file size is smaller than the filesystem's sector size.
A test case for fstests follows soon.
--- fs/btrfs/tree-log.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/tree-log.c +2 -1
@@ -4655,7 +4655,8 @@ static int btrfs_log_trailing_hole(strucASSERT (len == i_size || (len == fs_info->sectorsize &&btrfs_file_extent_compression (leaf, extent) != -BTRFS_COMPRESS_NONE )); +BTRFS_COMPRESS_NONE ) || + (len < i_size && i_size < fs_info->sectorsize));return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 344/361 btrfs: qgroup: Dirty all qgroups before rescan
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit 9c7b0c2e8dbfbcd80a71e2cbfe02704f26c185c6 upstream.
[BUG]
In the following case, rescan won't zero out the number of qgroup 1/0:
$ mkfs.btrfs -fq $DEV $ mount $DEV /mnt
$ btrfs quota enable /mnt $ btrfs qgroup create 1/0 /mnt $ btrfs sub create /mnt/sub $ btrfs qgroup assign 0/257 1/0 /mnt
$ dd if=/dev/urandom of=/mnt/sub/file bs=1k count=1000 $ btrfs sub snap /mnt/sub /mnt/snap $ btrfs quota rescan -w /mnt $ btrfs qgroup show -pcre /mnt qgroupid rfer excl max_rfer max_excl parent child -------- ---- ---- -------- -------- ------ ----- 0/5 16.00KiB 16.00KiB none none --- --- 0/257 1016.00KiB 16.00KiB none none 1/0 --- 0/258 1016.00KiB 16.00KiB none none --- --- 1/0 1016.00KiB 16.00KiB none none --- 0/257
So far so good, but:
$ btrfs qgroup remove 0/257 1/0 /mnt WARNING: quotas may be inconsistent, rescan needed $ btrfs quota rescan -w /mnt $ btrfs qgroup show -pcre /mnt qgoupid rfer excl max_rfer max_excl parent child -------- ---- ---- -------- -------- ------ ----- 0/5 16.00KiB 16.00KiB none none --- --- 0/257 1016.00KiB 16.00KiB none none --- --- 0/258 1016.00KiB 16.00KiB none none --- --- 1/0 1016.00KiB 16.00KiB none none --- --- ^^^^^^^^^^ ^^^^^^^^ not cleared
[CAUSE]
Before rescan we call qgroup_rescan_zero_tracking() to zero out all qgroups' accounting numbers.
However we don't mark all qgroups dirty, but rely on rescan to do so.
If we have any high level qgroup without children, it won't be marked dirty during rescan, since we cannot reach that qgroup.
This will cause QGROUP_INFO items of childless qgroups never get updated in the quota tree, thus their numbers will stay the same in "btrfs qgroup show" output.
[FIX]
Just mark all qgroups dirty in qgroup_rescan_zero_tracking(), so even if we have childless qgroups, their QGROUP_INFO items will still get updated during rescan.
--- fs/btrfs/qgroup.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/qgroup.c +1 -0
@@ -2897,6 +2897,7 @@ qgroup_rescan_zero_tracking(struct btrfs qgroup->rfer_cmpr =0 ; qgroup->excl =0 ; qgroup->excl_cmpr =0 ; +qgroup_dirty (fs_info, qgroup); }spin_unlock (&fs_info->qgroup_lock); }
Greg Kroah-Hartman
maintainerPATCH 342/361 Btrfs: fix warning when replaying log after fsync of a tmpfile
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit f2d72f42d5fa3bf33761d9e47201745f624fcff5 upstream.
When replaying a log which contains a tmpfile (which necessarily has a link count of 0) we end up calling inc_nlink(), at fs/btrfs/tree-log.c:replay_one_buffer(), which produces a warning like the following:
[195191.943673] WARNING: CPU: 0 PID: 6924 at fs/inode.c:342 inc_nlink+0x33/0x40 [195191.943723] CPU: 0 PID: 6924 Comm: mount Not tainted 4.19.0-rc6-btrfs-next-38 #1 [195191.943724] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.2-0-gf9626ccb91-prebuilt.qemu-project.org 04/01/2014 [195191.943726] RIP: 0010:inc_nlink+0x33/0x40 [195191.943728] RSP: 0018:ffffb96e425e3870 EFLAGS: 00010246 [195191.943730] RAX: 0000000000000000 RBX: ffff8c0d1e6af4f0 RCX: 0000000000000006 [195191.943731] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff8c0d1e6af4f0 [195191.943731] RBP: 0000000000000097 R08: 0000000000000001 R09: 0000000000000000 [195191.943732] R10: 0000000000000000 R11: 0000000000000000 R12: ffffb96e425e3a60 [195191.943733] R13: ffff8c0d10cff0c8 R14: ffff8c0d0d515348 R15: ffff8c0d78a1b3f8 [195191.943735] FS: 00007f570ee24480(0000) GS:ffff8c0dfb200000(0000) knlGS:0000000000000000 [195191.943736] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [195191.943737] CR2: 00005593286277c8 CR3: 00000000bb8f2006 CR4: 00000000003606f0 [195191.943739] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [195191.943740] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [195191.943741] Call Trace: [195191.943778] replay_one_buffer+0x797/0x7d0 [btrfs] [195191.943802] walk_up_log_tree+0x1c1/0x250 [btrfs] [195191.943809] ? rcu_read_lock_sched_held+0x3f/0x70 [195191.943825] walk_log_tree+0xae/0x1d0 [btrfs] [195191.943840] btrfs_recover_log_trees+0x1d7/0x4d0 [btrfs] [195191.943856] ? replay_dir_deletes+0x280/0x280 [btrfs] [195191.943870] open_ctree+0x1c3b/0x22a0 [btrfs] [195191.943887] btrfs_mount_root+0x6b4/0x800 [btrfs] [195191.943894] ? rcu_read_lock_sched_held+0x3f/0x70 [195191.943899] ? pcpu_alloc+0x55b/0x7c0 [195191.943906] ? mount_fs+0x3b/0x140 [195191.943908] mount_fs+0x3b/0x140 [195191.943912] ? __init_waitqueue_head+0x36/0x50 [195191.943916] vfs_kern_mount+0x62/0x160 [195191.943927] btrfs_mount+0x134/0x890 [btrfs] [195191.943936] ? rcu_read_lock_sched_held+0x3f/0x70 [195191.943938] ? pcpu_alloc+0x55b/0x7c0 [195191.943943] ? mount_fs+0x3b/0x140 [195191.943952] ? btrfs_remount+0x570/0x570 [btrfs] [195191.943954] mount_fs+0x3b/0x140 [195191.943956] ? __init_waitqueue_head+0x36/0x50 [195191.943960] vfs_kern_mount+0x62/0x160 [195191.943963] do_mount+0x1f9/0xd40 [195191.943967] ? memdup_user+0x4b/0x70 [195191.943971] ksys_mount+0x7e/0xd0 [195191.943974] __x64_sys_mount+0x21/0x30 [195191.943977] do_syscall_64+0x60/0x1b0 [195191.943980] entry_SYSCALL_64_after_hwframe+0x49/0xbe [195191.943983] RIP: 0033:0x7f570e4e524a [195191.943986] RSP: 002b:00007ffd83589478 EFLAGS: 00000206 ORIG_RAX: 00000000000000a5 [195191.943989] RAX: ffffffffffffffda RBX: 0000563f335b2060 RCX: 00007f570e4e524a [195191.943990] RDX: 0000563f335b2240 RSI: 0000563f335b2280 RDI: 0000563f335b2260 [195191.943992] RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000020 [195191.943993] R10: 00000000c0ed0000 R11: 0000000000000206 R12: 0000563f335b2260 [195191.943994] R13: 0000563f335b2240 R14: 0000000000000000 R15: 00000000ffffffff [195191.944002] irq event stamp: 8688 [195191.944010] hardirqs last enabled at (8687): [<ffffffff9cb004c3>] console_unlock+0x503/0x640 [195191.944012] hardirqs last disabled at (8688): [<ffffffff9ca037dd>] trace_hardirqs_off_thunk+0x1a/0x1c [195191.944018] softirqs last enabled at (8638): [<ffffffff9cc0a5d1>] __set_page_dirty_nobuffers+0x101/0x150 [195191.944020] softirqs last disabled at (8634): [<ffffffff9cc26bbe>] wb_wakeup_delayed+0x2e/0x60 [195191.944022] ---[ end trace 5d6e873a9a0b811a ]---
This happens because the inode does not have the flag I_LINKABLE set, which is a runtime only flag, not meant to be persisted, set when the inode is created through open(2) if the flag O_EXCL is not passed to it. Except for the warning, there are no other consequences (like corruptions or metadata inconsistencies).
Since it's pointless to replay a tmpfile as it would be deleted in a later phase of the log replay procedure (it has a link count of 0), fix this by not logging tmpfiles and if a tmpfile is found in a log (created by a kernel without this change), skip the replay of the inode.
A test case for fstests follows soon.
--- fs/btrfs/tree-log.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-)
fs/btrfs/tree-log.c +32 -10
@@ -258,6 +258,13 @@ struct walk_control {/* what stage of the replay code we're currently in */ int stage; +/* +* Ignore any items from the inode currently being processed. Needs +* to be set every time we find a BTRFS_INODE_ITEM_KEY and we are in +* the LOG_WALK_REPLAY_INODES stage. +*/ +bool ignore_cur_inode; +/* the root we are currently replaying */ struct btrfs_root *replay_dest;
@@ -2487,6 +2494,20 @@ static int replay_one_buffer(struct btrf inode_item =btrfs_item_ptr (eb, i, struct btrfs_inode_item); +/* +* If we have a tmpfile (O_TMPFILE) that got fsync'ed +* and never got linked before the fsync, skip it, as +* replaying it is pointless since it would be deleted +* later. We skip logging tmpfiles, but it's always +* possible we are replaying a log created with a kernel +* that used to log tmpfiles. +*/ +if (btrfs_inode_nlink (eb, inode_item) ==0 ) { + wc->ignore_cur_inode = true; +continue ; + }else { + wc->ignore_cur_inode = false; + } ret =replay_xattr_deletes (wc->trans, root, log, path, key.objectid);if (ret)
@@ -2524,16 +2545,8 @@ static int replay_one_buffer(struct btrf root->fs_info->sectorsize); ret =btrfs_drop_extents (wc->trans, root, inode, from, (u64)-1 ,1 ); -/* -* If the nlink count is zero here, the iput -* will free the inode. We bump it to make -* sure it doesn't get freed until the link -* count fixup is done. -*/ if (!ret) { -if (inode->i_nlink ==0 ) -inc_nlink (inode); -/* Update link count and nbytes. */ +/* Update the inode's nbytes. */ ret =btrfs_update_inode (wc->trans, root, inode); }
@@ -2548,6 +2561,9 @@ static int replay_one_buffer(struct btrfbreak ; } +if (wc->ignore_cur_inode) +continue ; +if (key.type ==BTRFS_DIR_INDEX_KEY && wc->stage ==LOG_WALK_REPLAY_DIR_INDEX ) { ret = replay_one_dir_item(wc->trans, root, path,
@@ -5643,7 +5659,13 @@ static int btrfs_log_inode_parent(structif (ret) goto end_no_trans; -if (btrfs_inode_in_log (inode, trans->transid)) { +/* +* Skip already logged inodes or inodes corresponding to tmpfiles +* (since logging them is pointless, a link count of 0 means they +* will never be accessible). +*/ +if (btrfs_inode_in_log (inode, trans->transid) || + inode->vfs_inode.i_nlink ==0 ) { ret =BTRFS_NO_LOG_SYNC ; goto end_no_trans; }
Greg Kroah-Hartman
maintainerPATCH 343/361 Btrfs: fix wrong dentries after fsync of file that got its parent replaced
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
commit 0f375eed92b5a407657532637ed9652611a682f5 upstream.
In a scenario like the following:
mkdir /mnt/A # inode 258 mkdir /mnt/B # inode 259 touch /mnt/B/bar # inode 260
sync
mv /mnt/B/bar /mnt/A/bar
mv -T /mnt/A /mnt/B
fsync /mnt/B/bar
<power fail>
After replaying the log we end up with file bar having 2 hard links, both with the name 'bar' and one in the directory with inode number 258 and the other in the directory with inode number 259. Also, we end up with the directory inode 259 still existing and with the directory inode 258 still named as 'A', instead of 'B'. In this scenario, file 'bar' should only have one hard link, located at directory inode 258, the directory inode 259 should not exist anymore and the name for directory inode 258 should be 'B'.
This incorrect behaviour happens because when attempting to log the old parents of an inode, we skip any parents that no longer exist. Fix this by forcing a full commit if an old parent no longer exists.
A test case for fstests follows soon.
--- fs/btrfs/tree-log.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-)
fs/btrfs/tree-log.c +27 -3
@@ -5583,9 +5583,33 @@ static int btrfs_log_all_parents(struct dir_inode =btrfs_iget (fs_info->sb, &inode_key, root,NULL ); -/* If parent inode was deleted, skip it. */ -if (IS_ERR (dir_inode)) -continue ; +/* +* If the parent inode was deleted, return an error to +* fallback to a transaction commit. This is to prevent +* getting an inode that was moved from one parent A to +* a parent B, got its former parent A deleted and then +* it got fsync'ed, from existing at both parents after +* a log replay (and the old parent still existing). +* Example: +* +* mkdir /mnt/A +* mkdir /mnt/B +* touch /mnt/B/bar +* sync +* mv /mnt/B/bar /mnt/A/bar +* mv -T /mnt/A /mnt/B +* fsync /mnt/B/bar +* <power fail> +* +* If we ignore the old parent B which got deleted, +* after a log replay we would have file bar linked +* at both parents and the old parent B would still +* exist. +*/ +if (IS_ERR (dir_inode)) { + ret =PTR_ERR (dir_inode); + goto out; + }if (ctx) ctx->log_new_dentries = false;
Greg Kroah-Hartman
maintainerPATCH 331/361 btrfs: Enhance btrfs_trim_fs function to handle error better
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
commit 93bba24d4b5ad1e5cd8b43f64e66ff9d6355dd20 upstream.
Function btrfs_trim_fs() doesn't handle errors in a consistent way. If error happens when trimming existing block groups, it will skip the remaining blocks and continue to trim unallocated space for each device.
The return value will only reflect the final error from device trimming.
This patch will fix such behavior by:
1) Recording the last error from block group or device trimming The return value will also reflect the last error during trimming. Make developer more aware of the problem.
2) Continuing trimming if possible
If we failed to trim one block group or device, we could still try the next block group or device.
3) Report number of failures during block group and device trimming It would be less noisy, but still gives user a brief summary of what's going wrong.
Such behavior can avoid confusion for cases like failure to trim the first block group and then only unallocated space is trimmed.
--- fs/btrfs/extent-tree.c | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-)
fs/btrfs/extent-tree.c +38 -11
@@ -10850,6 +10850,15 @@ static int btrfs_trim_free_extents(strucreturn ret; } +/* +* Trim the whole filesystem by: +* 1) trimming the free space in each block group +* 2) trimming the unallocated space on each device +* +* This will also continue trimming even if a block group or device encounters +* an error. The return value will be the last error, or 0 if nothing bad +* happens. +*/ int btrfs_trim_fs (struct btrfs_fs_info *fs_info,struct fstrim_range *range) {struct btrfs_block_group_cache *cache =NULL ;
@@ -10860,6 +10869,10 @@ int btrfs_trim_fs(struct btrfs_fs_info *u64 end;u64 trimmed =0 ;u64 total_bytes =btrfs_super_total_bytes (fs_info->super_copy); +u64 bg_failed =0 ; +u64 dev_failed =0 ; +int bg_ret =0 ; +int dev_ret =0 ;int ret =0 ;/*
@@ -10870,7 +10883,7 @@ int btrfs_trim_fs(struct btrfs_fs_info *else cache =btrfs_lookup_block_group (fs_info, range->start); -while (cache) { +for (; cache; cache =next_block_group (fs_info, cache)) {if (cache->key.objectid >= (range->start + range->len)) {btrfs_put_block_group (cache);break ;
@@ -10884,13 +10897,15 @@ int btrfs_trim_fs(struct btrfs_fs_info *if (!block_group_cache_done (cache)) { ret =cache_block_group (cache,0 );if (ret) { -btrfs_put_block_group (cache); -break ; + bg_failed++; + bg_ret = ret; +continue ; } ret =wait_block_group_cache_done (cache);if (ret) { -btrfs_put_block_group (cache); -break ; + bg_failed++; + bg_ret = ret; +continue ; } } ret = btrfs_trim_block_group(cache,
@@ -10901,28 +10916,40 @@ int btrfs_trim_fs(struct btrfs_fs_info * trimmed += group_trimmed;if (ret) { -btrfs_put_block_group (cache); -break ; + bg_failed++; + bg_ret = ret; +continue ; } } - - cache =next_block_group (fs_info, cache); } +if (bg_failed) +btrfs_warn (fs_info, +"failed to trim %llu block group(s), last error %d" , + bg_failed, bg_ret);mutex_lock (&fs_info->fs_devices->device_list_mutex); devices = &fs_info->fs_devices->alloc_list;list_for_each_entry (device, devices, dev_alloc_list) { ret =btrfs_trim_free_extents (device, range->minlen, &group_trimmed); -if (ret) +if (ret) { + dev_failed++; + dev_ret = ret;break ; + } trimmed += group_trimmed; }mutex_unlock (&fs_info->fs_devices->device_list_mutex); +if (dev_failed) +btrfs_warn (fs_info, +"failed to trim %llu device(s), last error %d" , + dev_failed, dev_ret); range->len = trimmed; -return ret; +if (bg_ret) +return bg_ret; +return dev_ret; }/*
Greg Kroah-Hartman
maintainerPATCH 339/361 btrfs: protect space cache inode alloc with GFP_NOFS
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 84de76a2fb217dc1b6bc2965cc397d1648aa1404 upstream.
If we're allocating a new space cache inode it's likely going to be under a transaction handle, so we need to use memalloc_nofs_save() in order to avoid deadlocks, and more importantly lockdep messages that make xfstests fail.
--- fs/btrfs/free-space-cache.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/btrfs/free-space-cache.c +8 -0
@@ -10,6 +10,7 @@#include <linux/math64.h> #include <linux/ratelimit.h> #include <linux/error-injection.h> +#include <linux/sched/mm.h> #include "ctree.h" #include "free-space-cache.h" #include "transaction.h"
@@ -47,6 +48,7 @@ static struct inode *__lookup_free_spacestruct btrfs_free_space_header *header;struct extent_buffer *leaf;struct inode *inode =NULL ; +unsigned nofs_flag;int ret; key.objectid =BTRFS_FREE_SPACE_OBJECTID ;
@@ -68,7 +70,13 @@ static struct inode *__lookup_free_spacebtrfs_disk_key_to_cpu (&location, &disk_key);btrfs_release_path (path); +/* +* We are often under a trans handle at this point, so we need to make +* sure NOFS is set to keep us from deadlocking. +*/ + nofs_flag =memalloc_nofs_save (); inode =btrfs_iget (fs_info->sb, &location, root,NULL ); +memalloc_nofs_restore (nofs_flag);if (IS_ERR (inode))return inode;
Greg Kroah-Hartman
maintainerPATCH 338/361 btrfs: release metadata before running delayed refs
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit f45c752b65af46bf42963295c332865d95f97fff upstream.
We want to release the unused reservation we have since it refills the delayed refs reserve, which will make everything go smoother when running the delayed refs if we're short on our reservation.
--- fs/btrfs/transaction.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/btrfs/transaction.c +3 -3
@@ -1929,6 +1929,9 @@ int btrfs_commit_transaction(struct btrfreturn ret; } +btrfs_trans_release_metadata (trans); + trans->block_rsv =NULL ; +/* make a pass through all the delayed refs we have so far * any runnings procs may add more while we are here */
@@ -1938,9 +1941,6 @@ int btrfs_commit_transaction(struct btrfreturn ret; } -btrfs_trans_release_metadata (trans); - trans->block_rsv =NULL ; - cur_trans = trans->transaction;/*
Greg Kroah-Hartman
maintainerPATCH 335/361 btrfs: keep trim from interfering with transaction commits
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Mahoney <[email protected]>
commit fee7acc361314df6561208c2d3c0882d663dd537 upstream.
Commit 499f377f49f08 (btrfs: iterate over unused chunk space in FITRIM) fixed free space trimming, but introduced latency when it was running. This is due to it pinning the transaction using both a incremented refcount and holding the commit root sem for the duration of a single trim operation.
This was to ensure safety but it's unnecessary. We already hold the the chunk mutex so we know that the chunk we're using can't be allocated while we're trimming it.
In order to check against chunks allocated already in this transaction, we need to check the pending chunks list. To to that safely without joining the transaction (or attaching than then having to commit it) we need to ensure that the dev root's commit root doesn't change underneath us and the pending chunk lists stays around until we're done with it.
We can ensure the former by holding the commit root sem and the latter by pinning the transaction. We do this now, but the critical section covers the trim operation itself and we don't need to do that.
This patch moves the pinning and unpinning logic into helpers and unpins the transaction after performing the search and check for pending chunks.
Limiting the critical section of the transaction pinning improves the latency substantially on slower storage (e.g. image files over NFS).
--- fs/btrfs/extent-tree.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
fs/btrfs/extent-tree.c +17 -8
@@ -10772,14 +10772,16 @@ int btrfs_error_unpin_extent_range(struc* We don't want a transaction for this since the discard may take a * substantial amount of time. We don't require that a transaction be * running, but we do need to take a running transaction into account -* to ensure that we're not discarding chunks that were released in -* the current transaction. +* to ensure that we're not discarding chunks that were released or +* allocated in the current transaction. * * Holding the chunks lock will prevent other threads from allocating * or releasing chunks, but it won't prevent a running transaction * from committing and releasing the memory that the pending chunks * list head uses. For that, we need to take a reference to the -* transaction. +* transaction and hold the commit root sem. We only need to hold +* it while performing the free space search since we have already +* held back allocations. */ static int btrfs_trim_free_extents (struct btrfs_device *device,u64 minlen,u64 *trimmed)
@@ -10810,9 +10812,13 @@ static int btrfs_trim_free_extents(struc ret =mutex_lock_interruptible (&fs_info->chunk_mutex);if (ret) -return ret; +break ; -down_read (&fs_info->commit_root_sem); + ret =down_read_killable (&fs_info->commit_root_sem); +if (ret) { +mutex_unlock (&fs_info->chunk_mutex); +break ; + }spin_lock (&fs_info->trans_lock); trans = fs_info->running_transaction;
@@ -10820,13 +10826,17 @@ static int btrfs_trim_free_extents(strucrefcount_inc (&trans->use_count);spin_unlock (&fs_info->trans_lock); +if (!trans) +up_read (&fs_info->commit_root_sem); + ret =find_free_dev_extent_start (trans, device, minlen, start, &start, &len); -if (trans) +if (trans) { +up_read (&fs_info->commit_root_sem);btrfs_put_transaction (trans); + }if (ret) { -up_read (&fs_info->commit_root_sem);mutex_unlock (&fs_info->chunk_mutex);if (ret == -ENOSPC ) ret =0 ;
@@ -10834,7 +10844,6 @@ static int btrfs_trim_free_extents(struc } ret =btrfs_issue_discard (device->bdev, start, len, &bytes); -up_read (&fs_info->commit_root_sem);mutex_unlock (&fs_info->chunk_mutex);if (ret)
Greg Kroah-Hartman
maintainerPATCH 333/361 btrfs: iterate all devices during trim, instead of fs_devices::alloc_list
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Mahoney <[email protected]>
commit d4e329de5e5e21594df2e0dd59da9acee71f133b upstream.
btrfs_trim_fs iterates over the fs_devices->alloc_list while holding the device_list_mutex. The problem is that ->alloc_list is protected by the chunk mutex. We don't want to hold the chunk mutex over the trim of the entire file system. Fortunately, the ->dev_list list is protected by the dev_list mutex and while it will give us all devices, including read-only devices, we already just skip the read-only devices. Then we can continue to take and release the chunk mutex while scanning each device.
--- fs/btrfs/extent-tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/extent-tree.c +2 -2
@@ -10920,8 +10920,8 @@ int btrfs_trim_fs(struct btrfs_fs_info *"failed to trim %llu block group(s), last error %d" , bg_failed, bg_ret);mutex_lock (&fs_info->fs_devices->device_list_mutex); - devices = &fs_info->fs_devices->alloc_list; -list_for_each_entry (device, devices, dev_alloc_list) { + devices = &fs_info->fs_devices->devices; +list_for_each_entry (device, devices, dev_list) { ret =btrfs_trim_free_extents (device, range->minlen, &group_trimmed);if (ret) {
Greg Kroah-Hartman
maintainerPATCH 336/361 btrfs: wait on caching when putting the bg cache
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 3aa7c7a31c26321696b92841d5103461c6f3f517 upstream.
While testing my backport I noticed there was a panic if I ran generic/416 generic/417 generic/418 all in a row. This just happened to uncover a race where we had outstanding IO after we destroy all of our workqueues, and then we'd go to queue the endio work on those free'd workqueues.
This is because we aren't waiting for the caching threads to be done before freeing everything up, so to fix this make sure we wait on any outstanding caching that's being done before we free up the block group, so we're sure to be done with all IO by the time we get to btrfs_stop_all_workers(). This fixes the panic I was seeing consistently in testing.
------------[ cut here ]------------ kernel BUG at fs/btrfs/volumes.c:6112! SMP PTI Modules linked in: CPU: 1 PID: 27165 Comm: kworker/u4:7 Not tainted 4.16.0-02155-g3553e54a578d-dirty #875 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2.el7 04/01/2014 Workqueue: btrfs-cache btrfs_cache_helper RIP: 0010:btrfs_map_bio+0x346/0x370 RSP: 0000:ffffc900061e79d0 EFLAGS: 00010202 RAX: 0000000000000000 RBX: ffff880071542e00 RCX: 0000000000533000 RDX: ffff88006bb74380 RSI: 0000000000000008 RDI: ffff880078160000 RBP: 0000000000000001 R08: ffff8800781cd200 R09: 0000000000503000 R10: ffff88006cd21200 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: ffff8800781cd200 R15: ffff880071542e00 FS: 0000000000000000(0000) GS:ffff88007fd00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000817ffc4 CR3: 0000000078314000 CR4: 00000000000006e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: btree_submit_bio_hook+0x8a/0xd0 submit_one_bio+0x5d/0x80 read_extent_buffer_pages+0x18a/0x320 btree_read_extent_buffer_pages+0xbc/0x200 ? alloc_extent_buffer+0x359/0x3e0 read_tree_block+0x3d/0x60 read_block_for_search.isra.30+0x1a5/0x360 btrfs_search_slot+0x41b/0xa10 btrfs_next_old_leaf+0x212/0x470 caching_thread+0x323/0x490 normal_work_helper+0xc5/0x310 process_one_work+0x141/0x340 worker_thread+0x44/0x3c0 kthread+0xf8/0x130 ? process_one_work+0x340/0x340 ? kthread_bind+0x10/0x10 ret_from_fork+0x35/0x40 RIP: btrfs_map_bio+0x346/0x370 RSP: ffffc900061e79d0 ---[ end trace 827eb13e50846033 ]--- Kernel panic - not syncing: Fatal exception Kernel Offset: disabled ---[ end Kernel panic - not syncing: Fatal exception
--- fs/btrfs/extent-tree.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/extent-tree.c +1 -0
@@ -9632,6 +9632,7 @@ void btrfs_put_block_group_cache(struct block_group =btrfs_lookup_first_block_group (info, last);while (block_group) { +wait_block_group_cache_done (block_group);spin_lock (&block_group->lock);if (block_group->iref)break ;
Greg Kroah-Hartman
maintainerPATCH 320/361 arm64: dts: stratix10: Correct System Manager register size
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thor Thayer <[email protected]>
commit 74121b9aa3cd571ddfff014a9f47db36cae3cda9 upstream.
Correct the register size of the System Manager node.
--- arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi +1 -1
@@ -335,7 +335,7 @@ sysmgr: sysmgr@ffd12000 { compatible = "altr,sys-mgr", "syscon"; - reg = <0xffd12000 0x1000>; + reg = <0xffd12000 0x228>; }; /* Local timer */
Greg Kroah-Hartman
maintainerPATCH 319/361 ARM: dts: socfpga: Fix SDRAM node address for Arria10
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thor Thayer <[email protected]>
commit ce3bf934f919a7d675c5b7fa4cc233ded9c6256e upstream.
The address in the SDRAM node was incorrect. Fix this to agree with the correct address and to match the reg definition block.
--- arch/arm/boot/dts/socfpga_arria10.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/socfpga_arria10.dtsi +1 -1
@@ -613,7 +613,7 @@ status = "disabled"; }; - sdr: sdr@ffc25000 { + sdr: sdr@ffcfb100 { compatible = "altr,sdr-ctl", "syscon"; reg = <0xffcfb100 0x80>; };
Greg Kroah-Hartman
maintainerPATCH 290/361 iommu/arm-smmu: Ensure that page-table updates are visible before TLBI
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Will Deacon <[email protected]>
commit 7d321bd3542500caf125249f44dc37cb4e738013 upstream.
The IO-pgtable code relies on the driver TLB invalidation callbacks to ensure that all page-table updates are visible to the IOMMU page-table walker.
In the case that the page-table walker is cache-coherent, we cannot rely on an implicit DSB from the DMA-mapping code, so we must ensure that we execute a DSB in our tlb_add_flush() callback prior to triggering the invalidation.
--- drivers/iommu/arm-smmu.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/iommu/arm-smmu.c +6 -0
@@ -469,6 +469,9 @@ static void arm_smmu_tlb_inv_range_nosynbool stage1 = cfg->cbar !=CBAR_TYPE_S2_TRANS ;void __iomem *reg =ARM_SMMU_CB (smmu_domain->smmu, cfg->cbndx); +if (smmu_domain->smmu->features &ARM_SMMU_FEAT_COHERENT_WALK ) +wmb (); +if (stage1) { reg += leaf ?ARM_SMMU_CB_S1_TLBIVAL :ARM_SMMU_CB_S1_TLBIVA ;
@@ -510,6 +513,9 @@ static void arm_smmu_tlb_inv_vmid_nosyncstruct arm_smmu_domain *smmu_domain = cookie;void __iomem *base =ARM_SMMU_GR0 (smmu_domain->smmu); +if (smmu_domain->smmu->features &ARM_SMMU_FEAT_COHERENT_WALK ) +wmb (); +writel_relaxed (smmu_domain->cfg.vmid, base +ARM_SMMU_GR0_TLBIVMID ); }
Greg Kroah-Hartman
maintainerPATCH 288/361 power: supply: twl4030-charger: fix OF sibling-node lookup
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 9844fb2e351311210e6660a9a1c62d17424a6145 upstream.
Use the new of_get_compatible_child() helper to lookup the usb sibling node instead of using of_find_compatible_node(), which searches the entire tree from a given start node and thus can return an unrelated (non-sibling) node.
This also addresses a potential use-after-free (e.g. after probe deferral) as the tree-wide helper drops a reference to its first argument (i.e. the parent device node).
While at it, also fix the related phy-node reference leak.
--- drivers/power/supply/twl4030_charger.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/power/supply/twl4030_charger.c +3 -2
@@ -996,12 +996,13 @@ static int twl4030_bci_probe(struct platif (bci->dev->of_node) {struct device_node *phynode; - phynode =of_find_compatible_node (bci->dev->of_node->parent, -NULL ,"ti,twl4030-usb" ); + phynode =of_get_compatible_child (bci->dev->of_node->parent, +"ti,twl4030-usb" );if (phynode) { bci->usb_nb.notifier_call = twl4030_bci_usb_ncb; bci->transceiver =devm_usb_get_phy_by_node ( bci->dev, phynode, &bci->usb_nb); +of_node_put (phynode);if (IS_ERR (bci->transceiver)) { ret =PTR_ERR (bci->transceiver);if (ret == -EPROBE_DEFER )
Greg Kroah-Hartman
maintainerPATCH 315/361 media: hdmi.h: rename ADOBE_RGB to OPRGB and ADOBE_YCC to OPYCC
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit 463659a08d7999d5461fa45b35b17686189a70ca upstream.
These names have been renamed in the CTA-861 standard due to trademark issues. Replace them here as well so they are in sync with the standard.
--- drivers/media/i2c/adv7511.c | 4 ++-- drivers/media/v4l2-core/v4l2-dv-timings.c | 4 ++-- drivers/video/hdmi.c | 8 ++++---- include/linux/hdmi.h | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/media/i2c/adv7511.c +2 -2
@@ -1357,8 +1357,8 @@ static int adv7511_set_fmt(struct v4l2_sswitch (format->format.colorspace) {case V4L2_COLORSPACE_OPRGB : c =HDMI_COLORIMETRY_EXTENDED ; - ec = y ?HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601 : -HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB ; + ec = y ?HDMI_EXTENDED_COLORIMETRY_OPYCC_601 : +HDMI_EXTENDED_COLORIMETRY_OPRGB ;break ;case V4L2_COLORSPACE_SMPTE170M : c = y ?HDMI_COLORIMETRY_ITU_601 :HDMI_COLORIMETRY_NONE ;
drivers/media/v4l2-core/v4l2-dv-timings.c +2 -2
@@ -837,7 +837,7 @@ v4l2_hdmi_rx_colorimetry(const struct hdswitch (avi->colorimetry) {case HDMI_COLORIMETRY_EXTENDED :switch (avi->extended_colorimetry) { -case HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB : +case HDMI_EXTENDED_COLORIMETRY_OPRGB : c.colorspace =V4L2_COLORSPACE_OPRGB ; c.xfer_func =V4L2_XFER_FUNC_OPRGB ;break ;
@@ -908,7 +908,7 @@ v4l2_hdmi_rx_colorimetry(const struct hd c.ycbcr_enc =V4L2_YCBCR_ENC_601 ; c.xfer_func =V4L2_XFER_FUNC_SRGB ;break ; -case HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601 : +case HDMI_EXTENDED_COLORIMETRY_OPYCC_601 : c.colorspace =V4L2_COLORSPACE_OPRGB ; c.ycbcr_enc =V4L2_YCBCR_ENC_601 ; c.xfer_func =V4L2_XFER_FUNC_OPRGB ;
drivers/video/hdmi.c +4 -4
@@ -592,10 +592,10 @@ hdmi_extended_colorimetry_get_name(enumreturn "xvYCC 709" ;case HDMI_EXTENDED_COLORIMETRY_S_YCC_601 :return "sYCC 601" ; -case HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601 : -return "Adobe YCC 601" ; -case HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB : -return "Adobe RGB" ; +case HDMI_EXTENDED_COLORIMETRY_OPYCC_601 : +return "opYCC 601" ; +case HDMI_EXTENDED_COLORIMETRY_OPRGB : +return "opRGB" ;case HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM :return "BT.2020 Constant Luminance" ;case HDMI_EXTENDED_COLORIMETRY_BT2020 :
include/linux/hdmi.h +2 -2
@@ -101,8 +101,8 @@ enum hdmi_extended_colorimetry {HDMI_EXTENDED_COLORIMETRY_XV_YCC_601 ,HDMI_EXTENDED_COLORIMETRY_XV_YCC_709 ,HDMI_EXTENDED_COLORIMETRY_S_YCC_601 , -HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601 , -HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB , +HDMI_EXTENDED_COLORIMETRY_OPYCC_601 , +HDMI_EXTENDED_COLORIMETRY_OPRGB ,/* The following EC values are only defined in CEA-861-F. */ HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM,
Greg Kroah-Hartman
maintainerPATCH 314/361 media: replace ADOBERGB by OPRGB
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit db0340182444612bcadb98bdec22f651aa42266c upstream.
The CTA-861 standards have been updated to refer to opRGB instead of AdobeRGB. The official standard is in fact named opRGB, so switch to that.
The two old defines referring to ADOBERGB in the public API are put under #ifndef __KERNEL__ and a comment mentions that they are deprecated.
--- Documentation/media/videodev2.h.rst.exceptions | 6 drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c | 262 ++++++++++++------------ drivers/media/i2c/adv7511.c | 2 drivers/media/i2c/adv7604.c | 2 drivers/media/i2c/tc358743.c | 4 drivers/media/platform/vivid/vivid-core.h | 2 drivers/media/platform/vivid/vivid-ctrls.c | 6 drivers/media/platform/vivid/vivid-vid-out.c | 2 drivers/media/v4l2-core/v4l2-dv-timings.c | 8 include/uapi/linux/videodev2.h | 23 +- 10 files changed, 165 insertions(+), 152 deletions(-)
Documentation/media/videodev2.h.rst.exceptions +4 -2
@@ -56,7 +56,8 @@ replace symbol V4L2_MEMORY_USERPTR :c:ty # Documented enum v4l2_colorspace replace symbol V4L2_COLORSPACE_470_SYSTEM_BG :c:type:`v4l2_colorspace` replace symbol V4L2_COLORSPACE_470_SYSTEM_M :c:type:`v4l2_colorspace` -replace symbol V4L2_COLORSPACE_ADOBERGB :c:type:`v4l2_colorspace` +replace symbol V4L2_COLORSPACE_OPRGB :c:type:`v4l2_colorspace` +replace define V4L2_COLORSPACE_ADOBERGB :c:type:`v4l2_colorspace` replace symbol V4L2_COLORSPACE_BT2020 :c:type:`v4l2_colorspace` replace symbol V4L2_COLORSPACE_DCI_P3 :c:type:`v4l2_colorspace` replace symbol V4L2_COLORSPACE_DEFAULT :c:type:`v4l2_colorspace`
@@ -69,7 +70,8 @@ replace symbol V4L2_COLORSPACE_SRGB :c:t # Documented enum v4l2_xfer_func replace symbol V4L2_XFER_FUNC_709 :c:type:`v4l2_xfer_func` -replace symbol V4L2_XFER_FUNC_ADOBERGB :c:type:`v4l2_xfer_func` +replace symbol V4L2_XFER_FUNC_OPRGB :c:type:`v4l2_xfer_func` +replace define V4L2_XFER_FUNC_ADOBERGB :c:type:`v4l2_xfer_func` replace symbol V4L2_XFER_FUNC_DCI_P3 :c:type:`v4l2_xfer_func` replace symbol V4L2_XFER_FUNC_DEFAULT :c:type:`v4l2_xfer_func` replace symbol V4L2_XFER_FUNC_NONE :c:type:`v4l2_xfer_func`
drivers/media/common/v4l2-tpg/v4l2-tpg-colors.c +131 -131
358 lines not on this page · raw message
drivers/media/i2c/adv7511.c +1 -1
@@ -1355,7 +1355,7 @@ static int adv7511_set_fmt(struct v4l2_s state->xfer_func = format->format.xfer_func;switch (format->format.colorspace) { -case V4L2_COLORSPACE_ADOBERGB : +case V4L2_COLORSPACE_OPRGB : c =HDMI_COLORIMETRY_EXTENDED ; ec = y ?HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601 :HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB ;
drivers/media/i2c/adv7604.c +1 -1
@@ -2476,7 +2476,7 @@ static int adv76xx_log_status(struct v4l"YCbCr Bt.601 (16-235)" ,"YCbCr Bt.709 (16-235)" ,"xvYCC Bt.601" ,"xvYCC Bt.709" ,"YCbCr Bt.601 (0-255)" ,"YCbCr Bt.709 (0-255)" , -"sYCC" ,"Adobe YCC 601" ,"AdobeRGB" ,"invalid" ,"invalid" , +"sYCC" ,"opYCC 601" ,"opRGB" ,"invalid" ,"invalid" ,"invalid" ,"invalid" ,"invalid" }; static const char * const rgb_quantization_range_txt[] = {
drivers/media/i2c/tc358743.c +2 -2
@@ -1243,9 +1243,9 @@ static int tc358743_log_status(struct v4u8 vi_status3 =i2c_rd8 (sd,VI_STATUS3 );const int deep_color_mode[4 ] = {8 ,10 ,12 ,16 };static const char *const input_color_space[] = { -"RGB" ,"YCbCr 601" ,"Adobe RGB" ,"YCbCr 709" ,"NA (4)" , +"RGB" ,"YCbCr 601" ,"opRGB" ,"YCbCr 709" ,"NA (4)" ,"xvYCC 601" ,"NA(6)" ,"xvYCC 709" ,"NA(8)" ,"sYCC601" , -"NA(10)" ,"NA(11)" ,"NA(12)" ,"Adobe YCC 601" }; +"NA(10)" ,"NA(11)" ,"NA(12)" ,"opYCC 601" };v4l2_info (sd,"-----Chip status-----\n" ); v4l2_info(sd, "Chip ID: 0x%02x\n",
drivers/media/platform/vivid/vivid-core.h +1 -1
@@ -111,7 +111,7 @@ enum vivid_colorspace {VIVID_CS_170M ,VIVID_CS_709 ,VIVID_CS_SRGB , -VIVID_CS_ADOBERGB , +VIVID_CS_OPRGB ,VIVID_CS_2020 ,VIVID_CS_DCI_P3 , VIVID_CS_240M,
drivers/media/platform/vivid/vivid-ctrls.c +3 -3
@@ -348,7 +348,7 @@ static int vivid_vid_cap_s_ctrl(struct vV4L2_COLORSPACE_SMPTE170M ,V4L2_COLORSPACE_REC709 ,V4L2_COLORSPACE_SRGB , -V4L2_COLORSPACE_ADOBERGB , +V4L2_COLORSPACE_OPRGB ,V4L2_COLORSPACE_BT2020 ,V4L2_COLORSPACE_DCI_P3 , V4L2_COLORSPACE_SMPTE240M,
@@ -729,7 +729,7 @@ static const char * const vivid_ctrl_col"SMPTE 170M" ,"Rec. 709" ,"sRGB" , -"AdobeRGB" , +"opRGB" ,"BT.2020" ,"DCI-P3" , "SMPTE 240M",
@@ -752,7 +752,7 @@ static const char * const vivid_ctrl_xfe"Default" ,"Rec. 709" ,"sRGB" , -"AdobeRGB" , +"opRGB" ,"SMPTE 240M" ,"None" , "DCI-P3",
drivers/media/platform/vivid/vivid-vid-out.c +1 -1
@@ -413,7 +413,7 @@ int vivid_try_fmt_vid_out(struct file *f mp->colorspace =V4L2_COLORSPACE_SMPTE170M ; }else if (mp->colorspace !=V4L2_COLORSPACE_SMPTE170M && mp->colorspace !=V4L2_COLORSPACE_REC709 && - mp->colorspace !=V4L2_COLORSPACE_ADOBERGB && + mp->colorspace !=V4L2_COLORSPACE_OPRGB && mp->colorspace !=V4L2_COLORSPACE_BT2020 && mp->colorspace !=V4L2_COLORSPACE_SRGB ) { mp->colorspace =V4L2_COLORSPACE_REC709 ;
drivers/media/v4l2-core/v4l2-dv-timings.c +4 -4
@@ -838,8 +838,8 @@ v4l2_hdmi_rx_colorimetry(const struct hdcase HDMI_COLORIMETRY_EXTENDED :switch (avi->extended_colorimetry) {case HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB : - c.colorspace =V4L2_COLORSPACE_ADOBERGB ; - c.xfer_func =V4L2_XFER_FUNC_ADOBERGB ; + c.colorspace =V4L2_COLORSPACE_OPRGB ; + c.xfer_func =V4L2_XFER_FUNC_OPRGB ;break ;case HDMI_EXTENDED_COLORIMETRY_BT2020 : c.colorspace =V4L2_COLORSPACE_BT2020 ;
@@ -909,9 +909,9 @@ v4l2_hdmi_rx_colorimetry(const struct hd c.xfer_func =V4L2_XFER_FUNC_SRGB ;break ;case HDMI_EXTENDED_COLORIMETRY_ADOBE_YCC_601 : - c.colorspace =V4L2_COLORSPACE_ADOBERGB ; + c.colorspace =V4L2_COLORSPACE_OPRGB ; c.ycbcr_enc =V4L2_YCBCR_ENC_601 ; - c.xfer_func =V4L2_XFER_FUNC_ADOBERGB ; + c.xfer_func =V4L2_XFER_FUNC_OPRGB ;break ;case HDMI_EXTENDED_COLORIMETRY_BT2020 : c.colorspace =V4L2_COLORSPACE_BT2020 ;
include/uapi/linux/videodev2.h +17 -6
@@ -225,8 +225,8 @@ enum v4l2_colorspace {/* For RGB colorspaces such as produces by most webcams. */ V4L2_COLORSPACE_SRGB =8 , -/* AdobeRGB colorspace */ -V4L2_COLORSPACE_ADOBERGB =9 , +/* opRGB colorspace */ +V4L2_COLORSPACE_OPRGB =9 ,/* BT.2020 colorspace, used for UHDTV. */ V4L2_COLORSPACE_BT2020 = 10,
@@ -258,7 +258,7 @@ enum v4l2_xfer_func {* * V4L2_COLORSPACE_SRGB, V4L2_COLORSPACE_JPEG: V4L2_XFER_FUNC_SRGB * -* V4L2_COLORSPACE_ADOBERGB: V4L2_XFER_FUNC_ADOBERGB +* V4L2_COLORSPACE_OPRGB: V4L2_XFER_FUNC_OPRGB * * V4L2_COLORSPACE_SMPTE240M: V4L2_XFER_FUNC_SMPTE240M *
@@ -269,7 +269,7 @@ enum v4l2_xfer_func {V4L2_XFER_FUNC_DEFAULT =0 ,V4L2_XFER_FUNC_709 =1 ,V4L2_XFER_FUNC_SRGB =2 , -V4L2_XFER_FUNC_ADOBERGB =3 , +V4L2_XFER_FUNC_OPRGB =3 ,V4L2_XFER_FUNC_SMPTE240M =4 ,V4L2_XFER_FUNC_NONE =5 , V4L2_XFER_FUNC_DCI_P3 = 6,
@@ -281,7 +281,7 @@ enum v4l2_xfer_func {* This depends on the colorspace. */ #define V4L2_MAP_XFER_FUNC_DEFAULT (colsp) \ - ((colsp) == V4L2_COLORSPACE_ADOBERGB ? V4L2_XFER_FUNC_ADOBERGB : \ + ((colsp) == V4L2_COLORSPACE_OPRGB ? V4L2_XFER_FUNC_OPRGB : \ ((colsp) == V4L2_COLORSPACE_SMPTE240M ? V4L2_XFER_FUNC_SMPTE240M : \ ((colsp) == V4L2_COLORSPACE_DCI_P3 ? V4L2_XFER_FUNC_DCI_P3 : \ ((colsp) == V4L2_COLORSPACE_RAW ? V4L2_XFER_FUNC_NONE : \
@@ -295,7 +295,7 @@ enum v4l2_ycbcr_encoding {* * V4L2_COLORSPACE_SMPTE170M, V4L2_COLORSPACE_470_SYSTEM_M, * V4L2_COLORSPACE_470_SYSTEM_BG, V4L2_COLORSPACE_SRGB, -* V4L2_COLORSPACE_ADOBERGB and V4L2_COLORSPACE_JPEG: V4L2_YCBCR_ENC_601 +* V4L2_COLORSPACE_OPRGB and V4L2_COLORSPACE_JPEG: V4L2_YCBCR_ENC_601 * * V4L2_COLORSPACE_REC709 and V4L2_COLORSPACE_DCI_P3: V4L2_YCBCR_ENC_709 *
@@ -382,6 +382,17 @@ enum v4l2_quantization { (((is_rgb_or_hsv) || (colsp) == V4L2_COLORSPACE_JPEG) ? \ V4L2_QUANTIZATION_FULL_RANGE : V4L2_QUANTIZATION_LIM_RANGE)) +/* +* Deprecated names for opRGB colorspace (IEC 61966-2-5) +* +* WARNING: Please don't use these deprecated defines in your code, as +* there is a chance we have to remove them in the future. +*/ +#ifndef __KERNEL__ +#define V4L2_COLORSPACE_ADOBERGB V4L2_COLORSPACE_OPRGB +#define V4L2_XFER_FUNC_ADOBERGB V4L2_XFER_FUNC_OPRGB +#endif +enum v4l2_priority {V4L2_PRIORITY_UNSET =0 ,/* not initialized */ V4L2_PRIORITY_BACKGROUND =1 ,
Greg Kroah-Hartman
maintainerPATCH 313/361 media: media colorspaces*.rst: rename AdobeRGB to opRGB
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit a58c37978cf02f6d35d05ee4e9288cb8455f1401 upstream.
Drop all Adobe references and use the official opRGB standard instead.
--- Documentation/media/uapi/v4l/biblio.rst | 10 ---------- Documentation/media/uapi/v4l/colorspaces-defs.rst | 8 ++++---- Documentation/media/uapi/v4l/colorspaces-details.rst | 13 ++++++------- 3 files changed, 10 insertions(+), 21 deletions(-)
Documentation/media/uapi/v4l/biblio.rst +0 -10
@@ -226,16 +226,6 @@ xvYCC :author: International Electrotechnical Commission (http://www.iec.ch) -.. _adobergb: - -AdobeRGB -======== - - -:title: Adobe© RGB (1998) Color Image Encoding Version 2005-05 - -:author: Adobe Systems Incorporated (http://www.adobe.com) - .. _oprgb: opRGB
Documentation/media/uapi/v4l/colorspaces-defs.rst +4 -4
@@ -51,8 +51,8 @@ whole range, 0-255, dividing the angular - See :ref:`col-rec709`. * - ``V4L2_COLORSPACE_SRGB`` - See :ref:`col-srgb`. - * - ``V4L2_COLORSPACE_ADOBERGB`` - - See :ref:`col-adobergb`. + * - ``V4L2_COLORSPACE_OPRGB`` + - See :ref:`col-oprgb`. * - ``V4L2_COLORSPACE_BT2020`` - See :ref:`col-bt2020`. * - ``V4L2_COLORSPACE_DCI_P3``
@@ -90,8 +90,8 @@ whole range, 0-255, dividing the angular - Use the Rec. 709 transfer function. * - ``V4L2_XFER_FUNC_SRGB`` - Use the sRGB transfer function. - * - ``V4L2_XFER_FUNC_ADOBERGB`` - - Use the AdobeRGB transfer function. + * - ``V4L2_XFER_FUNC_OPRGB`` + - Use the opRGB transfer function. * - ``V4L2_XFER_FUNC_SMPTE240M`` - Use the SMPTE 240M transfer function. * - ``V4L2_XFER_FUNC_NONE``
Documentation/media/uapi/v4l/colorspaces-details.rst +6 -7
@@ -290,15 +290,14 @@ Y' is clamped to the range [0…1] and C 170M/BT.601. The Y'CbCr quantization is limited range. -.. _col-adobergb: +.. _col-oprgb: -Colorspace Adobe RGB (V4L2_COLORSPACE_ADOBERGB) +Colorspace opRGB (V4L2_COLORSPACE_OPRGB) =============================================== -The :ref:`adobergb` standard defines the colorspace used by computer -graphics that use the AdobeRGB colorspace. This is also known as the -:ref:`oprgb` standard. The default transfer function is -``V4L2_XFER_FUNC_ADOBERGB``. The default Y'CbCr encoding is +The :ref:`oprgb` standard defines the colorspace used by computer +graphics that use the opRGB colorspace. The default transfer function is +``V4L2_XFER_FUNC_OPRGB``. The default Y'CbCr encoding is ``V4L2_YCBCR_ENC_601``. The default Y'CbCr quantization is limited range.
@@ -312,7 +311,7 @@ The chromaticities of the primary colors .. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.7cm}| -.. flat-table:: Adobe RGB Chromaticities +.. flat-table:: opRGB Chromaticities :header-rows: 1 :stub-columns: 0 :widths: 1 1 2
Greg Kroah-Hartman
maintainerPATCH 308/361 media: em28xx: make v4l2-compliance happier by starting sequence on zero
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit afeaade90db4c5dab93f326d9582be1d5954a198 upstream.
The v4l2-compliance tool complains if a video doesn't start with a zero sequence number.
While this shouldn't cause any real problem for apps, let's make it happier, in order to better check the v4l2-compliance differences before and after patchsets.
This is actually an old issue. It is there since at least its videobuf2 conversion, e. g. changeset 3829fadc461 ("[media]
em28xx: convert to videobuf2"), if VB1 wouldn't suffer from the same issue.
--- drivers/media/usb/em28xx/em28xx-video.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/usb/em28xx/em28xx-video.c +2 -0
@@ -1093,6 +1093,8 @@ int em28xx_start_analog_streaming(structem28xx_videodbg ("%s\n" , __func__); + dev->v4l2->field_count =0 ; +/* * Make sure streaming is not already in progress for this type * of filehandle (e.g. video, vbi)
Greg Kroah-Hartman
maintainerPATCH 310/361 media: adv7604: when the EDID is cleared, unconfigure CEC as well
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit e7da89926f6dc6cf855f5ffdf79ef99a1b115ca7 upstream.
When there is no EDID the CEC adapter should be unconfigured as well. So call cec_phys_addr_invalidate() when this happens.
--- drivers/media/i2c/adv7604.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/i2c/adv7604.c +3 -1
@@ -2284,8 +2284,10 @@ static int adv76xx_set_edid(struct v4l2_ state->aspect_ratio.numerator =16 ; state->aspect_ratio.denominator =9 ; -if (!state->edid.present) +if (!state->edid.present) { state->edid.blocks =0 ; +cec_phys_addr_invalidate (state->cec_adap); + }v4l2_dbg (2 , debug, sd,"%s: clear EDID pad %d, edid.present = 0x%x\n" , __func__, edid->pad, state->edid.present);
Greg Kroah-Hartman
maintainerPATCH 312/361 drm/mediatek: fix OF sibling-node lookup
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit ceff2f4dcd44abf35864d9a99f85ac619e89a01d upstream.
Use the new of_get_compatible_child() helper to lookup the sibling instead of using of_find_compatible_node(), which searches the entire tree from a given start node and thus can return an unrelated (i.e. non-sibling) node.
This also addresses a potential use-after-free (e.g. after probe deferral) as the tree-wide helper drops a reference to its first argument (i.e. the parent device node).
While at it, also fix the related cec-node reference leak.
--- drivers/gpu/drm/mediatek/mtk_hdmi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/mediatek/mtk_hdmi.c +3 -2
@@ -1446,8 +1446,7 @@ static int mtk_hdmi_dt_parse_pdata(struc }/* The CEC module handles HDMI hotplug detection */ - cec_np =of_find_compatible_node (np->parent,NULL , -"mediatek,mt8173-cec" ); + cec_np =of_get_compatible_child (np->parent,"mediatek,mt8173-cec" );if (!cec_np) {dev_err (dev,"Failed to find CEC node\n" );return -EINVAL ;
@@ -1457,8 +1456,10 @@ static int mtk_hdmi_dt_parse_pdata(strucif (!cec_pdev) {dev_err (hdmi->dev,"Waiting for CEC device %pOF\n" , cec_np); +of_node_put (cec_np);return -EPROBE_DEFER ; } +of_node_put (cec_np); hdmi->cec_dev = &cec_pdev->dev;/*
Greg Kroah-Hartman
maintainerPATCH 311/361 media: adv7842: when the EDID is cleared, unconfigure CEC as well
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit ab83203e181015b099720aff43ffabc1812e0fb3 upstream.
When there is no EDID the CEC adapter should be unconfigured as well. So call cec_phys_addr_invalidate() when this happens.
--- drivers/media/i2c/adv7842.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/i2c/adv7842.c +3 -1
@@ -786,8 +786,10 @@ static int edid_write_hdmi_segment(struc/* Disable I2C access to internal EDID ram from HDMI DDC ports */ rep_write_and_or (sd,0x77 ,0xf3 ,0x00 ); -if (!state->hdmi_edid.present) +if (!state->hdmi_edid.present) { +cec_phys_addr_invalidate (state->cec_adap);return 0 ; + } pa =cec_get_edid_phys_addr (edid,256 , &spa_loc); err =cec_phys_addr_validate (pa, &pa,NULL );
Greg Kroah-Hartman
maintainerPATCH 307/361 media: em28xx: fix input name for Terratec AV 350
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit 15644bfa195bd166d0a5ed76ae2d587f719c3dac upstream.
Instead of using a register value, use an AMUX name, as otherwise VIDIOC_G_AUDIO would fail.
--- drivers/media/usb/em28xx/em28xx-cards.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/usb/em28xx/em28xx-cards.c +2 -2
@@ -2141,13 +2141,13 @@ const struct em28xx_board em28xx_boards[ .input = { { .type = EM28XX_VMUX_COMPOSITE, .vmux = TVP5150_COMPOSITE1, - .amux = EM28XX_AUDIO_SRC_LINE, + .amux = EM28XX_AMUX_LINE_IN, .gpio = terratec_av350_unmute_gpio, }, { .type = EM28XX_VMUX_SVIDEO, .vmux = TVP5150_SVIDEO, - .amux = EM28XX_AUDIO_SRC_LINE, + .amux = EM28XX_AMUX_LINE_IN, .gpio = terratec_av350_unmute_gpio, } }, },
Greg Kroah-Hartman
maintainerPATCH 306/361 media: tvp5150: avoid going past array on v4l2_querymenu()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit 5c4c4505b716cb782ad7263091edc466c4d1fbd4 upstream.
The parameters of v4l2_ctrl_new_std_menu_items() are tricky: instead of the number of possible values, it requires the number of the maximum value. In other words, the ARRAY_SIZE() value should be decremented, otherwise it will go past the array bounds, as warned by KASAN:
[ 279.839688] BUG: KASAN: global-out-of-bounds in v4l2_querymenu+0x10d/0x180 [videodev] [ 279.839709] Read of size 8 at addr ffffffffc10a4cb0 by task v4l2-compliance/16676
[ 279.839736] CPU: 1 PID: 16676 Comm: v4l2-compliance Not tainted 4.18.0-rc2+ #120 [ 279.839741] Hardware name: /NUC5i7RYB, BIOS RYBDWi35.86A.0364.2017.0511.0949 05/11/2017 [ 279.839743] Call Trace: [ 279.839758] dump_stack+0x71/0xab [ 279.839807] ? v4l2_querymenu+0x10d/0x180 [videodev] [ 279.839817] print_address_description+0x1c9/0x270 [ 279.839863] ? v4l2_querymenu+0x10d/0x180 [videodev] [ 279.839871] kasan_report+0x237/0x360 [ 279.839918] v4l2_querymenu+0x10d/0x180 [videodev] [ 279.839964] __video_do_ioctl+0x2c8/0x590 [videodev] [ 279.840011] ? copy_overflow+0x20/0x20 [videodev] [ 279.840020] ? avc_ss_reset+0xa0/0xa0 [ 279.840028] ? check_stack_object+0x21/0x60 [ 279.840036] ? __check_object_size+0xe7/0x240 [ 279.840080] video_usercopy+0xed/0x730 [videodev] [ 279.840123] ? copy_overflow+0x20/0x20 [videodev] [ 279.840167] ? v4l_enumstd+0x40/0x40 [videodev] [ 279.840177] ? __handle_mm_fault+0x9f9/0x1ba0 [ 279.840186] ? __pmd_alloc+0x2c0/0x2c0 [ 279.840193] ? __vfs_write+0xb6/0x350 [ 279.840200] ? kernel_read+0xa0/0xa0 [ 279.840244] ? video_usercopy+0x730/0x730 [videodev] [ 279.840284] v4l2_ioctl+0xa1/0xb0 [videodev] [ 279.840295] do_vfs_ioctl+0x117/0x8a0 [ 279.840303] ? selinux_file_ioctl+0x211/0x2f0 [ 279.840313] ? ioctl_preallocate+0x120/0x120 [ 279.840319] ? selinux_capable+0x20/0x20 [ 279.840332] ksys_ioctl+0x70/0x80 [ 279.840342] __x64_sys_ioctl+0x3d/0x50 [ 279.840351] do_syscall_64+0x6d/0x1c0 [ 279.840361] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 279.840367] RIP: 0033:0x7fdfb46275d7 [ 279.840369] Code: b3 66 90 48 8b 05 b1 48 2d 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 81 48 2d 00 f7 d8 64 89 01 48 [ 279.840474] RSP: 002b:00007ffee1179038 EFLAGS: 00000202 ORIG_RAX: 0000000000000010 [ 279.840483] RAX: ffffffffffffffda RBX: 00007ffee1179180 RCX: 00007fdfb46275d7 [ 279.840488] RDX: 00007ffee11790c0 RSI: 00000000c02c5625 RDI: 0000000000000003 [ 279.840493] RBP: 0000000000000002 R08: 0000000000000020 R09: 00000000009f0902 [ 279.840497] R10: 0000000000000000 R11: 0000000000000202 R12: 00007ffee117a5a0 [ 279.840501] R13: 00007ffee11790c0 R14: 0000000000000002 R15: 0000000000000000
[ 279.840515] The buggy address belongs to the variable: [ 279.840535] tvp5150_test_patterns+0x10/0xffffffffffffe360 [tvp5150]
--- drivers/media/i2c/tvp5150.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/tvp5150.c +1 -1
@@ -1534,7 +1534,7 @@ static int tvp5150_probe(struct i2c_clie 27000000, 1, 27000000);v4l2_ctrl_new_std_menu_items (&core->hdl, &tvp5150_ctrl_ops,V4L2_CID_TEST_PATTERN , -ARRAY_SIZE (tvp5150_test_patterns), +ARRAY_SIZE (tvp5150_test_patterns) -1 ,0 ,0 , tvp5150_test_patterns); sd->ctrl_handler = &core->hdl;if (core->hdl.error) {
Greg Kroah-Hartman
maintainerPATCH 283/361 powerpc/64s/hash: Do not use PPC_INVALIDATE_ERAT on CPUs before POWER9
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Piggin <[email protected]>
commit bc276ecba132caccb1fda5863a652c15def2b8c6 upstream.
PPC_INVALIDATE_ERAT is slbia IH=7 which is a new variant introduced with POWER9, and the result is undefined on earlier CPUs.
Commits 7b9f71f974 ("powerpc/64s: POWER9 machine check handler") and d4748276ae ("powerpc/64s: Improve local TLB flush for boot and MCE on POWER9") caused POWER7/8 code to use this instruction. Remove it. An ERAT flush can be made by invalidatig the SLB, but before POWER9 that requires a flush and rebolt.
--- arch/powerpc/kernel/mce_power.c | 7 +++++++ arch/powerpc/mm/hash_native_64.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-)
arch/powerpc/kernel/mce_power.c +7 -0
@@ -89,6 +89,13 @@ static void flush_and_reload_slb(void)static void flush_erat (void ) { +#ifdef CONFIG_PPC_BOOK3S_64 +if (!early_cpu_has_feature (CPU_FTR_ARCH_300 )) { +flush_and_reload_slb (); +return ; + } +#endif +/* PPC_INVALIDATE_ERAT can only be used on ISA v3 and newer */ asm volatile(PPC_INVALIDATE_ERAT : : :"memory"); }
arch/powerpc/mm/hash_native_64.c +2 -2
@@ -115,6 +115,8 @@ static void tlbiel_all_isa300(unsigned itlbiel_hash_set_isa300 (0 , is,0 ,2 ,1 ); asmvolatile ("ptesync" : : :"memory" ); + + asmvolatile (PPC_INVALIDATE_ERAT "; isync" : : :"memory" ); }void hash__tlbiel_all (unsigned int action)
@@ -140,8 +142,6 @@ void hash__tlbiel_all(unsigned int actiotlbiel_all_isa206 (POWER7_TLB_SETS , is); else WARN(1, "%s called on pre-POWER7 CPU\n", __func__); - - asmvolatile (PPC_INVALIDATE_ERAT "; isync" : : :"memory" ); } static inline unsigned long ___tlbie(unsigned long vpn, int psize,
Greg Kroah-Hartman
maintainerPATCH 305/361 media: em28xx: use a default format if TRY_FMT fails
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit f823ce2a1202d47110a7ef86b65839f0be8adc38 upstream.
Follow the V4L2 spec, as warned by v4l2-compliance:
warn: v4l2-test-formats.cpp(732): TRY_FMT cannot handle an invalid pixelformat.
warn: v4l2-test-formats.cpp(733): This may or may not be a problem. For more information see:
warn: v4l2-test-formats.cpp(734): http://www.mail-archive.com/[email protected]/msg56550.html
--- drivers/media/usb/em28xx/em28xx-video.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/media/usb/em28xx/em28xx-video.c +3 -3
@@ -1471,9 +1471,9 @@ static int vidioc_try_fmt_vid_cap(struct fmt =format_by_fourcc (f->fmt.pix.pixelformat);if (!fmt) { -em28xx_videodbg ("Fourcc format (%08x) invalid.\n" , - f->fmt.pix.pixelformat); -return -EINVAL ; + fmt = &format[0 ]; +em28xx_videodbg ("Fourcc format (%08x) invalid. Using default (%08x).\n" , + f->fmt.pix.pixelformat, fmt->fourcc); }if (dev->board.is_em2800) {
Greg Kroah-Hartman
maintainerPATCH 304/361 media: cec: forgot to cancel delayed work
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit 490d84f6d73c12f4204241cff8651eed60aae914 upstream.
If the wait for completion was interrupted, then make sure to cancel any delayed work.
This can only happen if a transmit is waiting for a reply, and you press Ctrl-C or reboot/poweroff or something like that which interrupts the thread waiting for the reply and then proceeds to delete the CEC message.
Since the delayed work wasn't canceled, once it would trigger it referred to stale data and resulted in a kernel oops.
--- drivers/media/cec/cec-adap.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/cec/cec-adap.c +2 -0
@@ -831,6 +831,8 @@ int cec_transmit_msg_fh(struct cec_adapt*/ mutex_unlock (&adap->lock);wait_for_completion_killable (&data->c); +if (!data->completed) +cancel_delayed_work_sync (&data->work);mutex_lock (&adap->lock);/* Cancel the transmit if it was interrupted */
Greg Kroah-Hartman
maintainerPATCH 302/361 media: cec: add new tx/rx status bits to detect aborts/timeouts
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit 7ec2b3b941a666a942859684281b5f6460a0c234 upstream.
If the HDMI cable is disconnected or the CEC adapter is manually unconfigured, then all pending transmits and wait-for-replies are aborted. Signal this with new status bits (CEC_RX/TX_STATUS_ABORTED).
If due to (usually) a driver bug a transmit never ends (i.e. the transmit_done was never called by the driver), then when this times out the message is marked with CEC_TX_STATUS_TIMEOUT.
This should not happen and is an indication of a driver bug.
Without a separate status bit for this it was impossible to detect this from userspace.
The 'transmit timed out' kernel message is now a warning, so this should be more prominent in the kernel log as well.
--- Documentation/media/uapi/cec/cec-ioc-receive.rst | 25 +++++++- drivers/media/cec/cec-adap.c | 68 ++++++----------------- include/uapi/linux/cec.h | 3 + 3 files changed, 45 insertions(+), 51 deletions(-)
Documentation/media/uapi/cec/cec-ioc-receive.rst +23 -2
@@ -16,10 +16,10 @@ CEC_RECEIVE, CEC_TRANSMIT - Receive or t Synopsis ======== -.. c:function:: int ioctl( int fd, CEC_RECEIVE, struct cec_msg *argp ) +.. c:function:: int ioctl( int fd, CEC_RECEIVE, struct cec_msg \*argp ) :name: CEC_RECEIVE -.. c:function:: int ioctl( int fd, CEC_TRANSMIT, struct cec_msg *argp ) +.. c:function:: int ioctl( int fd, CEC_TRANSMIT, struct cec_msg \*argp ) :name: CEC_TRANSMIT Arguments
@@ -272,6 +272,19 @@ View On' messages from initiator 0xf ('U - The transmit failed after one or more retries. This status bit is mutually exclusive with :ref:`CEC_TX_STATUS_OK <CEC-TX-STATUS-OK>`. Other bits can still be set to explain which failures were seen. + * .. _`CEC-TX-STATUS-ABORTED`: + + - ``CEC_TX_STATUS_ABORTED`` + - 0x40 + - The transmit was aborted due to an HDMI disconnect, or the adapter + was unconfigured, or a transmit was interrupted, or the driver + returned an error when attempting to start a transmit. + * .. _`CEC-TX-STATUS-TIMEOUT`: + + - ``CEC_TX_STATUS_TIMEOUT`` + - 0x80 + - The transmit timed out. This should not normally happen and this + indicates a driver problem. .. tabularcolumns:: |p{5.6cm}|p{0.9cm}|p{11.0cm}|
@@ -300,6 +313,14 @@ View On' messages from initiator 0xf ('U - The message was received successfully but the reply was ``CEC_MSG_FEATURE_ABORT``. This status is only set if this message was the reply to an earlier transmitted message. + * .. _`CEC-RX-STATUS-ABORTED`: + + - ``CEC_RX_STATUS_ABORTED`` + - 0x08 + - The wait for a reply to an earlier transmitted message was aborted + because the HDMI cable was disconnected, the adapter was unconfigured + or the :ref:`CEC_TRANSMIT <CEC_RECEIVE>` that waited for a + reply was interrupted.
drivers/media/cec/cec-adap.c +19 -49
128 lines not on this page · raw message
include/uapi/linux/cec.h +3 -0
@@ -152,10 +152,13 @@ static inline void cec_msg_set_reply_to(#define CEC_TX_STATUS_LOW_DRIVE (1 << 3)#define CEC_TX_STATUS_ERROR (1 << 4)#define CEC_TX_STATUS_MAX_RETRIES (1 << 5) +#define CEC_TX_STATUS_ABORTED (1 << 6) +#define CEC_TX_STATUS_TIMEOUT (1 << 7)#define CEC_RX_STATUS_OK (1 << 0)#define CEC_RX_STATUS_TIMEOUT (1 << 1)#define CEC_RX_STATUS_FEATURE_ABORT (1 << 2) +#define CEC_RX_STATUS_ABORTED (1 << 3)static inline int cec_msg_status_is_ok (const struct cec_msg *msg) {
Greg Kroah-Hartman
maintainerPATCH 299/361 xen: fix xen_qlock_wait()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
commit d3132b3860f6cf35ff7609a76bbcdbb814bd027c upstream.
Commit a856531951dc80 ("xen: make xen_qlock_wait() nestable") introduced a regression for Xen guests running fully virtualized (HVM or PVH mode). The Xen hypervisor wouldn't return from the poll hypercall with interrupts disabled in case of an interrupt (for PV guests it does).
So instead of disabling interrupts in xen_qlock_wait() use a nesting counter to avoid calling xen_clear_irq_pending() in case xen_qlock_wait() is nested.
--- arch/x86/xen/spinlock.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
arch/x86/xen/spinlock.c +8 -6
@@ -9,6 +9,7 @@#include <linux/log2.h> #include <linux/gfp.h> #include <linux/slab.h> +#include <linux/atomic.h> #include <asm/paravirt.h> #include <asm/qspinlock.h>
@@ -21,6 +22,7 @@ static DEFINE_PER_CPU(int, lock_kicker_irq) = -1; static DEFINE_PER_CPU(char *, irq_name); +static DEFINE_PER_CPU(atomic_t, xen_qlock_wait_nest);static bool xen_pvspin = true;static void xen_qlock_kick (int cpu)
@@ -39,25 +41,25 @@ static void xen_qlock_kick(int cpu)*/ static void xen_qlock_wait (u8 *byte,u8 val) { -unsigned long flags;int irq =__this_cpu_read (lock_kicker_irq); +atomic_t *nest_cnt =this_cpu_ptr (&xen_qlock_wait_nest);/* If kicker interrupts not initialized yet, just spin */ if (irq ==-1 ||in_nmi ())return ; -/* Guard against reentry. */ -local_irq_save (flags); +/* Detect reentry. */ +atomic_inc (nest_cnt); -/* If irq pending already clear it. */ -if (xen_test_irq_pending (irq)) { +/* If irq pending already and no nested call clear it. */ +if (atomic_read (nest_cnt) ==1 &&xen_test_irq_pending (irq)) {xen_clear_irq_pending (irq); }else if (READ_ONCE (*byte) == val) {/* Block until irq becomes pending (or a spurious wakeup) */ xen_poll_irq (irq); } -local_irq_restore (flags); +atomic_dec (nest_cnt); }static irqreturn_t dummy_handler (int irq,void *dev_id)
Greg Kroah-Hartman
maintainerPATCH 296/361 remoteproc: qcom: q6v5: Propagate EPROBE_DEFER
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Andersson <[email protected]>
commit d5269c4553a64b6882f2c019ae21b783a0984a83 upstream.
In the case that the interrupts fail to result because of the interrupt-controller not yet being registered the platform_get_irq_byname() call will fail with -EPROBE_DEFER, but passing this into devm_request_threaded_irq() will result in -EINVAL being returned, the driver is therefor not reprobed later.
--- drivers/remoteproc/qcom_q6v5.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/remoteproc/qcom_q6v5.c +12 -0
@@ -198,6 +198,9 @@ int qcom_q6v5_init(struct qcom_q6v5 *q6v } q6v5->fatal_irq =platform_get_irq_byname (pdev,"fatal" ); +if (q6v5->fatal_irq == -EPROBE_DEFER ) +return -EPROBE_DEFER ; + ret = devm_request_threaded_irq(&pdev->dev, q6v5->fatal_irq, NULL, q6v5_fatal_interrupt, IRQF_TRIGGER_RISING | IRQF_ONESHOT,
@@ -208,6 +211,9 @@ int qcom_q6v5_init(struct qcom_q6v5 *q6v } q6v5->ready_irq =platform_get_irq_byname (pdev,"ready" ); +if (q6v5->ready_irq == -EPROBE_DEFER ) +return -EPROBE_DEFER ; + ret = devm_request_threaded_irq(&pdev->dev, q6v5->ready_irq, NULL, q6v5_ready_interrupt, IRQF_TRIGGER_RISING | IRQF_ONESHOT,
@@ -218,6 +224,9 @@ int qcom_q6v5_init(struct qcom_q6v5 *q6v } q6v5->handover_irq =platform_get_irq_byname (pdev,"handover" ); +if (q6v5->handover_irq == -EPROBE_DEFER ) +return -EPROBE_DEFER ; + ret = devm_request_threaded_irq(&pdev->dev, q6v5->handover_irq, NULL, q6v5_handover_interrupt, IRQF_TRIGGER_RISING | IRQF_ONESHOT,
@@ -229,6 +238,9 @@ int qcom_q6v5_init(struct qcom_q6v5 *q6vdisable_irq (q6v5->handover_irq); q6v5->stop_irq =platform_get_irq_byname (pdev,"stop-ack" ); +if (q6v5->stop_irq == -EPROBE_DEFER ) +return -EPROBE_DEFER ; + ret = devm_request_threaded_irq(&pdev->dev, q6v5->stop_irq, NULL, q6v5_stop_interrupt, IRQF_TRIGGER_RISING | IRQF_ONESHOT,
Greg Kroah-Hartman
maintainerPATCH 295/361 kgdboc: Passing ekgdboc to command line causes panic
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: He Zhe <[email protected]>
commit 1bd54d851f50dea6af30c3e6ff4f3e9aab5558f9 upstream.
kgdboc_option_setup does not check input argument before passing it to strlen. The argument would be a NULL pointer if "ekgdboc", without its value, is set in command line and thus cause the following panic.
PANIC: early exception 0xe3 IP 10:ffffffff8fbbb620 error 0 cr2 0x0
[ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.18-rc8+ #1 [ 0.000000] RIP: 0010:strlen+0x0/0x20 ... [ 0.000000] Call Trace [ 0.000000] ? kgdboc_option_setup+0x9/0xa0 [ 0.000000] ? kgdboc_early_init+0x6/0x1b [ 0.000000] ? do_early_param+0x4d/0x82 [ 0.000000] ? parse_args+0x212/0x330 [ 0.000000] ? rdinit_setup+0x26/0x26 [ 0.000000] ? parse_early_options+0x20/0x23 [ 0.000000] ? rdinit_setup+0x26/0x26 [ 0.000000] ? parse_early_param+0x2d/0x39 [ 0.000000] ? setup_arch+0x2f7/0xbf4 [ 0.000000] ? start_kernel+0x5e/0x4c2 [ 0.000000] ? load_ucode_bsp+0x113/0x12f [ 0.000000] ? secondary_startup_64+0xa5/0xb0
This patch adds a check to prevent the panic.
--- drivers/tty/serial/kgdboc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/tty/serial/kgdboc.c +5 -0
@@ -130,6 +130,11 @@ static void kgdboc_unregister_kbd(void)static int kgdboc_option_setup (char *opt) { +if (!opt) { +pr_err ("kgdboc: config string not provided\n" ); +return -EINVAL ; + } +if (strlen (opt) >=MAX_CONFIG_LEN ) {printk (KERN_ERR "kgdboc: config string too long\n" );return -ENOSPC ;
Greg Kroah-Hartman
maintainerPATCH 293/361 media: v4l2-tpg: fix kernel oops when enabling HFLIP and OSD
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit 250854eed5d45a73d81e4137dfd85180af6f2ec3 upstream.
When the OSD is on (i.e. vivid displays text on top of the test pattern), and you enable hflip, then the driver crashes.
The cause turned out to be a division of a negative number by an unsigned value. You expect that -8 / 2U would be -4, but in reality it is 2147483644 :-(
--- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +1 -1
@@ -1770,7 +1770,7 @@ typedef struct { u16 __; u8 _; } __packe pos[7 ] = (chr & (0x01 <<0 ) ? fg : bg); \ } \ \ - pos += (tpg->hflip ?-8 :8 ) / hdiv; \ + pos += (tpg->hflip ?-8 :8 ) / (int )hdiv; \ } \ } \ }while (0 )
Greg Kroah-Hartman
maintainerPATCH 291/361 TC: Set DMA masks for devices
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maciej W. Rozycki <[email protected]>
commit 3f2aa244ee1a0d17ed5b6c86564d2c1b24d1c96b upstream.
Fix a TURBOchannel support regression with commit 205e1b7f51e4 ("dma-mapping: warn when there is no coherent_dma_mask") that caused coherent DMA allocations to produce a warning such as:
defxx: v1.11 2014/07/01 Lawrence V. Stefani and others
tc1: DEFTA at MMIO addr = 0x1e900000, IRQ = 20, Hardware addr = 08-00-2b-a3-a3-29
------------[ cut here ]------------
WARNING: CPU: 0 PID: 1 at ./include/linux/dma-mapping.h:516 dfx_dev_register+0x670/0x678
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.19.0-rc6 #2
Stack : ffffffff8009ffc0 fffffffffffffec0 0000000000000000 ffffffff80647650
0000000000000000 0000000000000000 ffffffff806f5f80 ffffffffffffffff
0000000000000000 0000000000000000 0000000000000001 ffffffff8065d4e8
98000000031b6300 ffffffff80563478 ffffffff805685b0 ffffffffffffffff
0000000000000000 ffffffff805d6720 0000000000000204 ffffffff80388df8
0000000000000000 0000000000000009 ffffffff8053efd0 ffffffff806657d0
0000000000000000 ffffffff803177f8 0000000000000000 ffffffff806d0000
9800000003078000 980000000307b9e0 000000001e900000 ffffffff80067940
0000000000000000 ffffffff805d6720 0000000000000204 ffffffff80388df8
ffffffff805176c0 ffffffff8004dc78 0000000000000000 ffffffff80067940
...
Call Trace:
[<ffffffff8004dc78>] show_stack+0xa0/0x130
[<ffffffff80067940>] __warn+0x128/0x170
---[ end trace b1d1e094f67f3bb2 ]---This is because the TURBOchannel bus driver fails to set the coherent DMA mask for devices enumerated.
Set the regular and coherent DMA masks for TURBOchannel devices then, observing that the bus protocol supports a 34-bit (16GiB) DMA address space, by interpreting the value presented in the address cycle across the 32 `ad' lines as a 32-bit word rather than byte address[1]. The architectural size of the TURBOchannel DMA address space exceeds the maximum amount of RAM any actual TURBOchannel system in existence may have, hence both masks are the same.
This removes the warning shown above.
References:
[1] "TURBOchannel Hardware Specification", EK-369AA-OD-007B, Digital
Equipment Corporation, January 1993, Section "DMA", pp. 1-15 -- 1-17
Patchwork: https://patchwork.linux-mips.org/patch/20835/
--- drivers/tc/tc.c | 8 +++++++- include/linux/tc.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/tc/tc.c +7 -1
@@ -2,7 +2,7 @@* TURBOchannel bus services. * * Copyright (c) Harald Koerfgen, 1998 -* Copyright (c) 2001, 2003, 2005, 2006 Maciej W. Rozycki +* Copyright (c) 2001, 2003, 2005, 2006, 2018 Maciej W. Rozycki * Copyright (c) 2005 James Simmons * * This file is subject to the terms and conditions of the GNU
@@ -10,6 +10,7 @@* directory of this archive for more details. */ #include <linux/compiler.h> +#include <linux/dma-mapping.h> #include <linux/errno.h> #include <linux/init.h> #include <linux/ioport.h>
@@ -92,6 +93,11 @@ static void __init tc_bus_add_devices(st tdev->dev.bus = &tc_bus_type; tdev->slot = slot; +/* TURBOchannel has 34-bit DMA addressing (16GiB space). */ + tdev->dma_mask =DMA_BIT_MASK (34 ); + tdev->dev.dma_mask = &tdev->dma_mask; + tdev->dev.coherent_dma_mask =DMA_BIT_MASK (34 ); +for (i =0 ; i <8 ; i++) { tdev->firmware[i] =readb (module + offset +TC_FIRM_VER +4 * i);
include/linux/tc.h +1 -0
@@ -84,6 +84,7 @@ struct tc_dev {device. */ struct device dev;/* Generic device interface. */ struct resource resource;/* Address space of this device. */ +u64 dma_mask;/* DMA addressable range. */ char vendor[9 ];char name[9 ];char firmware[9 ];
Greg Kroah-Hartman
maintainerPATCH 292/361 net: bcmgenet: fix OF child-node lookup
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit d397dbe606120a1ea1b11b0020c3f7a3852da5ac upstream.
Use the new of_get_compatible_child() helper to lookup the mdio child node instead of using of_find_compatible_node(), which searches the entire tree from a given start node and thus can return an unrelated (i.e. non-child) node.
This also addresses a potential use-after-free (e.g. after probe deferral) as the tree-wide helper drops a reference to its first argument (i.e. the node of the device being probed).
--- drivers/net/ethernet/broadcom/genet/bcmmii.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/broadcom/genet/bcmmii.c +1 -1
@@ -342,7 +342,7 @@ static struct device_node *bcmgenet_mii_if (!compat)return NULL ; - priv->mdio_dn =of_find_compatible_node (dn,NULL , compat); + priv->mdio_dn =of_get_compatible_child (dn, compat);kfree (compat);if (!priv->mdio_dn) {dev_err (kdev,"unable to find MDIO bus node\n" );
Greg Kroah-Hartman
maintainerPATCH 282/361 powerpc/tm: Fix HFSCR bit for no suspend case
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Neuling <[email protected]>
commit dd9a8c5a87395b6f05552c3b44e42fdc95760552 upstream.
Currently on P9N DD2.1 we end up taking infinite TM facility unavailable exceptions on the first TM usage by userspace.
In the special case of TM no suspend (P9N DD2.1), Linux is told TM is off via CPU dt-ftrs but told to (partially) use it via OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED. So HFSCR[TM] will be off from dt-ftrs but we need to turn it on for the no suspend case.
This patch fixes this by enabling HFSCR TM in this case.
--- arch/powerpc/kernel/setup_64.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
arch/powerpc/kernel/setup_64.c +12 -6
@@ -243,13 +243,19 @@ static void cpu_ready_for_interrupts(voi }/* -* Fixup HFSCR:TM based on CPU features. The bit is set by our -* early asm init because at that point we haven't updated our -* CPU features from firmware and device-tree. Here we have, -* so let's do it. +* Set HFSCR:TM based on CPU features: +* In the special case of TM no suspend (P9N DD2.1), Linux is +* told TM is off via the dt-ftrs but told to (partially) use +* it via OPAL_REINIT_CPUS_TM_SUSPEND_DISABLED. So HFSCR[TM] +* will be off from dt-ftrs but we need to turn it on for the +* no suspend case. */ -if (cpu_has_feature (CPU_FTR_HVMODE ) && !cpu_has_feature (CPU_FTR_TM_COMP )) -mtspr (SPRN_HFSCR ,mfspr (SPRN_HFSCR ) & ~HFSCR_TM ); +if (cpu_has_feature (CPU_FTR_HVMODE )) { +if (cpu_has_feature (CPU_FTR_TM_COMP )) +mtspr (SPRN_HFSCR ,mfspr (SPRN_HFSCR ) |HFSCR_TM ); +else +mtspr (SPRN_HFSCR ,mfspr (SPRN_HFSCR ) & ~HFSCR_TM ); + }/* Set IR and DR in PACA MSR */ get_paca ()->kernel_msr =MSR_KERNEL ;
Greg Kroah-Hartman
maintainerPATCH 254/361 mm/hmm: fix race between hmm_mirror_unregister() and mmu_notifier callback
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ralph Campbell <[email protected]>
commit 86a2d59841ab0b147ffc1b7b3041af87927cf312 upstream.
In hmm_mirror_unregister(), mm->hmm is set to NULL and then mmu_notifier_unregister_no_release() is called. That creates a small window where mmu_notifier can call mmu_notifier_ops with mm->hmm equal to NULL. Fix this by first unregistering mmu notifier callbacks and then setting mm->hmm to NULL.
Similarly in hmm_register(), set mm->hmm before registering mmu_notifier callbacks so callback functions always see mm->hmm set.
--- mm/hmm.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-)
mm/hmm.c +21 -15
@@ -91,16 +91,6 @@ static struct hmm *hmm_register(struct mspin_lock_init (&hmm->lock); hmm->mm = mm; -/* -* We should only get here if hold the mmap_sem in write mode ie on -* registration of first mirror through hmm_mirror_register() -*/ - hmm->mmu_notifier.ops = &hmm_mmu_notifier_ops; -if (__mmu_notifier_register (&hmm->mmu_notifier, mm)) { -kfree (hmm); -return NULL ; - } -spin_lock (&mm->page_table_lock);if (!mm->hmm) mm->hmm = hmm;
@@ -108,12 +98,27 @@ static struct hmm *hmm_register(struct m cleanup = true;spin_unlock (&mm->page_table_lock); -if (cleanup) { -mmu_notifier_unregister (&hmm->mmu_notifier, mm); -kfree (hmm); - } +if (cleanup) + goto error; + +/* +* We should only get here if hold the mmap_sem in write mode ie on +* registration of first mirror through hmm_mirror_register() +*/ + hmm->mmu_notifier.ops = &hmm_mmu_notifier_ops; +if (__mmu_notifier_register (&hmm->mmu_notifier, mm)) + goto error_mm;return mm->hmm; + +error_mm: +spin_lock (&mm->page_table_lock); +if (mm->hmm == hmm) + mm->hmm =NULL ; +spin_unlock (&mm->page_table_lock); +error: +kfree (hmm); +return NULL ; }void hmm_mm_destroy (struct mm_struct *mm)
@@ -278,12 +283,13 @@ void hmm_mirror_unregister(struct hmm_miif (!should_unregister || mm ==NULL )return ; +mmu_notifier_unregister_no_release (&hmm->mmu_notifier, mm); +spin_lock (&mm->page_table_lock);if (mm->hmm == hmm) mm->hmm =NULL ;spin_unlock (&mm->page_table_lock); -mmu_notifier_unregister_no_release (&hmm->mmu_notifier, mm);kfree (hmm); }EXPORT_SYMBOL (hmm_mirror_unregister);
Greg Kroah-Hartman
maintainerPATCH 245/361 crypto: morus/generic - fix for big endian systems
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 5a8dedfa3276e88c5865f265195d63d72aec3e72 upstream.
Omit the endian swabbing when folding the lengths of the assoc and crypt input buffers into the state to finalize the tag. This is not necessary given that the memory representation of the state is in machine native endianness already.
This fixes an error reported by tcrypt running on a big endian system:
alg: aead: Test 2 failed on encryption for morus640-generic 00000000: a8 30 ef fb e6 26 eb 23 b0 87 dd 98 57 f3 e1 4b 00000010: 21
alg: aead: Test 2 failed on encryption for morus1280-generic 00000000: 88 19 1b fb 1c 29 49 0e ee 82 2f cb 97 a6 a5 ee 00000010: 5f
--- crypto/morus1280.c | 7 ++----- crypto/morus640.c | 16 ++++------------ 2 files changed, 6 insertions(+), 17 deletions(-)
crypto/morus1280.c +2 -5
@@ -385,14 +385,11 @@ static void crypto_morus1280_final(strucstruct morus1280_block *tag_xor, u64 assoclen, u64 cryptlen) { - u64 assocbits = assoclen * 8; -u64 cryptbits = cryptlen *8 ; - struct morus1280_block tmp;unsigned int i; - tmp.words[0 ] =cpu_to_le64 (assocbits); - tmp.words[1 ] =cpu_to_le64 (cryptbits); + tmp.words[0 ] = assoclen *8 ; + tmp.words[1 ] = cryptlen *8 ; tmp.words[2 ] =0 ; tmp.words[3 ] =0 ;
crypto/morus640.c +4 -12
@@ -384,21 +384,13 @@ static void crypto_morus640_final(structstruct morus640_block *tag_xor, u64 assoclen, u64 cryptlen) { - u64 assocbits = assoclen * 8; -u64 cryptbits = cryptlen *8 ; - -u32 assocbits_lo = (u32 )assocbits; -u32 assocbits_hi = (u32)(assocbits >>32 ); -u32 cryptbits_lo = (u32 )cryptbits; -u32 cryptbits_hi = (u32)(cryptbits >>32 ); - struct morus640_block tmp;unsigned int i; - tmp.words[0 ] =cpu_to_le32 (assocbits_lo); - tmp.words[1 ] =cpu_to_le32 (assocbits_hi); - tmp.words[2 ] =cpu_to_le32 (cryptbits_lo); - tmp.words[3 ] =cpu_to_le32 (cryptbits_hi); + tmp.words[0 ] =lower_32_bits (assoclen *8 ); + tmp.words[1 ] =upper_32_bits (assoclen *8 ); + tmp.words[2 ] =lower_32_bits (cryptlen *8 ); + tmp.words[3 ] =upper_32_bits (cryptlen *8 );for (i =0 ; i <MORUS_BLOCK_WORDS ; i++) state->s[4 ].words[i] ^= state->s[0 ].words[i];
Greg Kroah-Hartman
maintainerPATCH 251/361 ima: open a new file instance if no read permissions
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Goldwyn Rodrigues <[email protected]>
commit a408e4a86b36bf98ad15b9ada531cf0e5118ac67 upstream.
Open a new file instance as opposed to changing file->f_mode when the file is not readable. This is done to accomodate overlayfs stacked file operations change. The real struct file is hidden behind the overlays struct file. So, any file->f_mode manipulations are not reflected on the real struct file. Open the file again in read mode if original file cannot be read, read and calculate the hash.
--- security/integrity/ima/ima_crypto.c | 54 ++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 20 deletions(-)
security/integrity/ima/ima_crypto.c +34 -20
@@ -210,7 +210,7 @@ static int ima_calc_file_hash_atfm(struc {loff_t i_size, offset;char *rbuf[2 ] = {NULL , }; -int rc, read =0 , rbuf_len, active =0 , ahash_rc =0 ; +int rc, rbuf_len, active =0 , ahash_rc =0 ;struct ahash_request *req;struct scatterlist sg[1 ];struct crypto_wait wait;
@@ -257,11 +257,6 @@ static int ima_calc_file_hash_atfm(struc &rbuf_size[1], 0); } -if (!(file->f_mode &FMODE_READ )) { - file->f_mode |=FMODE_READ ; - read =1 ; - } -for (offset =0 ; offset < i_size; offset += rbuf_len) {if (!rbuf[1 ] && offset) {/* Not using two buffers, and it is not the first
@@ -300,8 +295,6 @@ static int ima_calc_file_hash_atfm(struc/* wait for the last update request to complete */ rc =ahash_wait (ahash_rc, &wait); out3: -if (read) - file->f_mode &= ~FMODE_READ ;ima_free_pages (rbuf[0 ], rbuf_size[0 ]);ima_free_pages (rbuf[1 ], rbuf_size[1 ]); out2:
@@ -336,7 +329,7 @@ static int ima_calc_file_hash_tfm(struct {loff_t i_size, offset =0 ;char *rbuf; -int rc, read =0 ; +int rc;SHASH_DESC_ON_STACK (shash, tfm); shash->tfm = tfm;
@@ -357,11 +350,6 @@ static int ima_calc_file_hash_tfm(structif (!rbuf)return -ENOMEM ; -if (!(file->f_mode &FMODE_READ )) { - file->f_mode |=FMODE_READ ; - read =1 ; - } -while (offset < i_size) {int rbuf_len;
@@ -378,8 +366,6 @@ static int ima_calc_file_hash_tfm(structif (rc)break ; } -if (read) - file->f_mode &= ~FMODE_READ ;kfree (rbuf); out:if (!rc)
@@ -420,6 +406,8 @@ int ima_calc_file_hash(struct file *file {loff_t i_size;int rc; +struct file *f = file; +bool new_file_instance = false, modified_flags = false;/* * For consistency, fail file's opened with the O_DIRECT flag on
@@ -431,15 +419,41 @@ int ima_calc_file_hash(struct file *filereturn -EINVAL ; } - i_size =i_size_read (file_inode (file)); +/* Open a new file instance in O_RDONLY if we cannot read */ +if (!(file->f_mode &FMODE_READ )) { +int flags = file->f_flags & ~(O_WRONLY |O_APPEND | +O_TRUNC |O_CREAT |O_NOCTTY |O_EXCL ); + flags |=O_RDONLY ; + f =dentry_open (&file->f_path, flags, file->f_cred); +if (IS_ERR (f)) { +/* +* Cannot open the file again, lets modify f_flags +* of original and continue +*/ +pr_info_ratelimited ("Unable to reopen file for reading.\n" ); + f = file; + f->f_flags |=FMODE_READ ; + modified_flags = true; + }else { + new_file_instance = true; + } + } + + i_size =i_size_read (file_inode (f));if (ima_ahash_minsize && i_size >= ima_ahash_minsize) { - rc =ima_calc_file_ahash (file, hash); + rc =ima_calc_file_ahash (f, hash);if (!rc) -return 0 ; + goto out; } -return ima_calc_file_shash (file, hash); + rc =ima_calc_file_shash (f, hash); +out: +if (new_file_instance) +fput (f); +else if (modified_flags) + f->f_flags &= ~FMODE_READ ; +return rc; }/*
Greg Kroah-Hartman
maintainerPATCH 249/361 userfaultfd: disable irqs when taking the waitqueue lock
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
commit ae62c16e105a869524afcf8a07ee85c5ae5d0479 upstream.
userfaultfd contains howe-grown locking of the waitqueue lock, and does not disable interrupts. This relies on the fact that no one else takes it from interrupt context and violates an invariat of the normal waitqueue locking scheme. With aio poll it is easy to trigger other locks that disable interrupts (or are called from interrupt context).
--- fs/userfaultfd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/userfaultfd.c +4 -4
@@ -1026,7 +1026,7 @@ static ssize_t userfaultfd_ctx_read(strustruct userfaultfd_ctx *fork_nctx =NULL ;/* always take the fd_wqh lock before the fault_pending_wqh lock */ -spin_lock (&ctx->fd_wqh.lock); +spin_lock_irq (&ctx->fd_wqh.lock);__add_wait_queue (&ctx->fd_wqh, &wait);for (;;) {set_current_state (TASK_INTERRUPTIBLE );
@@ -1112,13 +1112,13 @@ static ssize_t userfaultfd_ctx_read(stru ret = -EAGAIN ;break ; } -spin_unlock (&ctx->fd_wqh.lock); +spin_unlock_irq (&ctx->fd_wqh.lock);schedule (); -spin_lock (&ctx->fd_wqh.lock); +spin_lock_irq (&ctx->fd_wqh.lock); }__remove_wait_queue (&ctx->fd_wqh, &wait);__set_current_state (TASK_RUNNING ); -spin_unlock (&ctx->fd_wqh.lock); +spin_unlock_irq (&ctx->fd_wqh.lock);if (!ret && msg->event ==UFFD_EVENT_FORK ) { ret =resolve_userfault_fork (ctx, fork_nctx, msg);
Greg Kroah-Hartman
maintainerPATCH 250/361 ima: fix showing large violations or runtime_measurements_count
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 1e4c8dafbb6bf72fb5eca035b861e39c5896c2b7 upstream.
The 12 character temporary buffer is not necessarily long enough to hold a 'long' value. Increase it.
--- security/integrity/ima/ima_fs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
security/integrity/ima/ima_fs.c +3 -3
@@ -42,14 +42,14 @@ static int __init default_canonical_fmt___setup ("ima_canonical_fmt" , default_canonical_fmt_setup);static int valid_policy =1 ; -#define TMPBUFLEN 12 +static ssize_t ima_show_htable_value (char __user *buf,size_t count,loff_t *ppos,atomic_long_t *val) { -char tmpbuf[TMPBUFLEN ]; +char tmpbuf[32 ];/* greater than largest 'long' string value */ ssize_t len; - len =scnprintf (tmpbuf,TMPBUFLEN ,"%li\n" ,atomic_long_read (val)); + len =scnprintf (tmpbuf,sizeof (tmpbuf),"%li\n" ,atomic_long_read (val));return simple_read_from_buffer (buf, count, ppos, tmpbuf, len); }
Greg Kroah-Hartman
maintainerPATCH 280/361 powerpc64/module elfv1: Set opd addresses after module relocation
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naveen N. Rao <[email protected]>
commit 59fe7eaf3598a89cbcd72e645b1d08afd76f7b29 upstream.
module_frob_arch_sections() is called before the module is moved to its final location. The function descriptor section addresses we are setting here are thus invalid. Fix this by processing opd section during module_finalize()
--- arch/powerpc/kernel/module.c | 8 ++++++++ arch/powerpc/kernel/module_64.c | 5 ----- 2 files changed, 8 insertions(+), 5 deletions(-)
arch/powerpc/kernel/module.c +8 -0
@@ -74,6 +74,14 @@ int module_finalize(const Elf_Ehdr *hdr, (void *)sect->sh_addr + sect->sh_size);#endif /* CONFIG_PPC64 */ +#ifdef PPC64_ELF_ABI_v1 + sect =find_section (hdr, sechdrs,".opd" ); +if (sect !=NULL ) { + me->arch.start_opd = sect->sh_addr; + me->arch.end_opd = sect->sh_addr + sect->sh_size; + } +#endif /* PPC64_ELF_ABI_v1 */ +#ifdef CONFIG_PPC_BARRIER_NOSPEC sect =find_section (hdr, sechdrs,"__spec_barrier_fixup" );if (sect !=NULL )
arch/powerpc/kernel/module_64.c +0 -5
@@ -360,11 +360,6 @@ int module_frob_arch_sections(Elf64_Ehdrelse if (strcmp (secstrings+sechdrs[i].sh_name,"__versions" )==0 )dedotify_versions ((void *)hdr + sechdrs[i].sh_offset, sechdrs[i].sh_size); -else if (!strcmp (secstrings + sechdrs[i].sh_name,".opd" )) { - me->arch.start_opd = sechdrs[i].sh_addr; - me->arch.end_opd = sechdrs[i].sh_addr + - sechdrs[i].sh_size; - }/* We don't handle .init for the moment: rename to _init */ while ((p =strstr (secstrings + sechdrs[i].sh_name,".init" )))
Greg Kroah-Hartman
maintainerPATCH 276/361 dm zoned: fix metadata block ref counting
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 33c2865f8d011a2ca9f67124ddab9dc89382e9f1 upstream.
Since the ref field of struct dmz_mblock is always used with the spinlock of struct dmz_metadata locked, there is no need to use an atomic_t type. Change the type of the ref field to an unsigne integer.
--- drivers/md/dm-zoned-metadata.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/md/dm-zoned-metadata.c +11 -9
@@ -99,7 +99,7 @@ struct dmz_mblock {struct rb_node node;struct list_head link;sector_t no; -atomic_t ref; +unsigned int ref;unsigned long state;struct page *page;void *data;
@@ -296,7 +296,7 @@ static struct dmz_mblock *dmz_alloc_mbloRB_CLEAR_NODE (&mblk->node);INIT_LIST_HEAD (&mblk->link); -atomic_set (&mblk->ref,0 ); + mblk->ref =0 ; mblk->state =0 ; mblk->no = mblk_no; mblk->data =page_address (mblk->page);
@@ -397,7 +397,7 @@ static struct dmz_mblock *dmz_fetch_mbloreturn NULL ;spin_lock (&zmd->mblk_lock); -atomic_inc (&mblk->ref); + mblk->ref++;set_bit (DMZ_META_READING , &mblk->state);dmz_insert_mblock (zmd, mblk);spin_unlock (&zmd->mblk_lock);
@@ -484,7 +484,8 @@ static void dmz_release_mblock(struct dmspin_lock (&zmd->mblk_lock); -if (atomic_dec_and_test (&mblk->ref)) { + mblk->ref--; +if (mblk->ref ==0 ) {if (test_bit (DMZ_META_ERROR , &mblk->state)) {rb_erase (&mblk->node, &zmd->mblk_rbtree);dmz_free_mblock (zmd, mblk);
@@ -511,7 +512,8 @@ static struct dmz_mblock *dmz_get_mblock mblk =dmz_lookup_mblock (zmd, mblk_no);if (mblk) {/* Cache hit: remove block from LRU list */ -if (atomic_inc_return (&mblk->ref) ==1 && + mblk->ref++; +if (mblk->ref ==1 && !test_bit (DMZ_META_DIRTY , &mblk->state))list_del_init (&mblk->link); }
@@ -753,7 +755,7 @@ int dmz_flush_metadata(struct dmz_metadaspin_lock (&zmd->mblk_lock);clear_bit (DMZ_META_DIRTY , &mblk->state); -if (atomic_read (&mblk->ref) ==0 ) +if (mblk->ref ==0 )list_add_tail (&mblk->link, &zmd->mblk_lru_list);spin_unlock (&zmd->mblk_lock); }
@@ -2308,7 +2310,7 @@ static void dmz_cleanup_metadata(struct mblk =list_first_entry (&zmd->mblk_dirty_list, struct dmz_mblock, link);dmz_dev_warn (zmd->dev,"mblock %llu still in dirty list (ref %u)" , - (u64 )mblk->no,atomic_read (&mblk->ref)); + (u64 )mblk->no, mblk->ref);list_del_init (&mblk->link);rb_erase (&mblk->node, &zmd->mblk_rbtree);dmz_free_mblock (zmd, mblk);
@@ -2326,8 +2328,8 @@ static void dmz_cleanup_metadata(struct root = &zmd->mblk_rbtree;rbtree_postorder_for_each_entry_safe (mblk, next, root, node) {dmz_dev_warn (zmd->dev,"mblock %llu ref %u still in rbtree" , - (u64 )mblk->no,atomic_read (&mblk->ref)); -atomic_set (&mblk->ref,0 ); + (u64 )mblk->no, mblk->ref); + mblk->ref =0 ;dmz_free_mblock (zmd, mblk); }
Greg Kroah-Hartman
maintainerPATCH 277/361 dm zoned: fix various dmz_get_mblock() issues
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damien Le Moal <[email protected]>
commit 3d4e738311327bc4ba1d55fbe2f1da3de4a475f9 upstream.
dmz_fetch_mblock() called from dmz_get_mblock() has a race since the allocation of the new metadata block descriptor and its insertion in the cache rbtree with the READING state is not atomic. Two different contexts requesting the same block may end up each adding two different descriptors of the same block to the cache.
Another problem for this function is that the BIO for processing the block read is allocated after the metadata block descriptor is inserted in the cache rbtree. If the BIO allocation fails, the metadata block descriptor is freed without first being removed from the rbtree.
Fix the first problem by checking again if the requested block is not in the cache right before inserting the newly allocated descriptor, atomically under the mblk_lock spinlock. The second problem is fixed by simply allocating the BIO before inserting the new block in the cache.
Finally, since dmz_fetch_mblock() also increments a block reference counter, rename the function to dmz_get_mblock_slow(). To be symmetric and clear, also rename dmz_lookup_mblock() to dmz_get_mblock_fast() and increment the block reference counter directly in that function rather than in dmz_get_mblock().
--- drivers/md/dm-zoned-metadata.c | 66 ++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 24 deletions(-)
drivers/md/dm-zoned-metadata.c +42 -24
@@ -339,10 +339,11 @@ static void dmz_insert_mblock(struct dmz }/* -* Lookup a metadata block in the rbtree. +* Lookup a metadata block in the rbtree. If the block is found, increment +* its reference count. */ -static struct dmz_mblock *dmz_lookup_mblock (struct dmz_metadata *zmd, -sector_t mblk_no) +static struct dmz_mblock *dmz_get_mblock_fast (struct dmz_metadata *zmd, +sector_t mblk_no) {struct rb_root *root = &zmd->mblk_rbtree;struct rb_node *node = root->rb_node;
@@ -350,8 +351,17 @@ static struct dmz_mblock *dmz_lookup_mblwhile (node) { mblk = container_of(node, struct dmz_mblock, node); -if (mblk->no == mblk_no) +if (mblk->no == mblk_no) { +/* +* If this is the first reference to the block, +* remove it from the LRU list. +*/ + mblk->ref++; +if (mblk->ref ==1 && + !test_bit (DMZ_META_DIRTY , &mblk->state)) +list_del_init (&mblk->link);return mblk; + } node = (mblk->no < mblk_no) ? node->rb_left : node->rb_right; }
@@ -382,32 +392,47 @@ static void dmz_mblock_bio_end_io(struct }/* -* Read a metadata block from disk. +* Read an uncached metadata block from disk and add it to the cache. */ -static struct dmz_mblock *dmz_fetch_mblock (struct dmz_metadata *zmd, -sector_t mblk_no) +static struct dmz_mblock *dmz_get_mblock_slow (struct dmz_metadata *zmd, +sector_t mblk_no) { -struct dmz_mblock *mblk; +struct dmz_mblock *mblk, *m;sector_t block = zmd->sb[zmd->mblk_primary].block + mblk_no;struct bio *bio; -/* Get block and insert it */ +/* Get a new block and a BIO to read it */ mblk =dmz_alloc_mblock (zmd, mblk_no);if (!mblk)return NULL ; -spin_lock (&zmd->mblk_lock); - mblk->ref++; -set_bit (DMZ_META_READING , &mblk->state); -dmz_insert_mblock (zmd, mblk); -spin_unlock (&zmd->mblk_lock); - bio =bio_alloc (GFP_NOIO ,1 );if (!bio) {dmz_free_mblock (zmd, mblk);return NULL ; } +spin_lock (&zmd->mblk_lock); + +/* +* Make sure that another context did not start reading +* the block already. +*/ + m =dmz_get_mblock_fast (zmd, mblk_no); +if (m) { +spin_unlock (&zmd->mblk_lock); +dmz_free_mblock (zmd, mblk); +bio_put (bio); +return m; + } + + mblk->ref++; +set_bit (DMZ_META_READING , &mblk->state); +dmz_insert_mblock (zmd, mblk); + +spin_unlock (&zmd->mblk_lock); + +/* Submit read BIO */ bio->bi_iter.bi_sector =dmz_blk2sect (block);bio_set_dev (bio, zmd->dev->bdev); bio->bi_private = mblk;
@@ -509,19 +534,12 @@ static struct dmz_mblock *dmz_get_mblock/* Check rbtree */ spin_lock (&zmd->mblk_lock); - mblk =dmz_lookup_mblock (zmd, mblk_no); -if (mblk) { -/* Cache hit: remove block from LRU list */ - mblk->ref++; -if (mblk->ref ==1 && - !test_bit (DMZ_META_DIRTY , &mblk->state)) -list_del_init (&mblk->link); - } + mblk =dmz_get_mblock_fast (zmd, mblk_no);spin_unlock (&zmd->mblk_lock);if (!mblk) {/* Cache miss: read the block from disk */ - mblk =dmz_fetch_mblock (zmd, mblk_no); + mblk =dmz_get_mblock_slow (zmd, mblk_no);if (!mblk)return ERR_PTR (-ENOMEM ); }
Greg Kroah-Hartman
maintainerPATCH 248/361 mm: /proc/pid/smaps_rollup: fix NULL pointer deref in smaps_pte_range()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlastimil Babka <[email protected]>
commit fa76da461bb0be13c8339d984dcf179151167c8f upstream.
Leonardo reports an apparent regression in 4.19-rc7:
BUG: unable to handle kernel NULL pointer dereference at 00000000000000f0 PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP PTI CPU: 3 PID: 6032 Comm: python Not tainted 4.19.0-041900rc7-lowlatency #201810071631 Hardware name: LENOVO 80UG/Toronto 4A2, BIOS 0XCN45WW 08/09/2018 RIP: 0010:smaps_pte_range+0x32d/0x540 Code: 80 00 00 00 00 74 a9 48 89 de 41 f6 40 52 40 0f 85 04 02 00 00 49 2b 30 48 c1 ee 0c 49 03 b0 98 00 00 00 49 8b 80 a0 00 00 00 <48> 8b b8 f0 00 00 00 e8 b7 ef ec ff 48 85 c0 0f 84 71 ff ff ff a8 RSP: 0018:ffffb0cbc484fb88 EFLAGS: 00010202 RAX: 0000000000000000 RBX: 0000560ddb9e9000 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000560ddb9e9 RDI: 0000000000000001 RBP: ffffb0cbc484fbc0 R08: ffff94a5a227a578 R09: ffff94a5a227a578 R10: 0000000000000000 R11: 0000560ddbbe7000 R12: ffffe903098ba728 R13: ffffb0cbc484fc78 R14: ffffb0cbc484fcf8 R15: ffff94a5a2e9cf48 FS: 00007f6dfb683740(0000) GS:ffff94a5aaf80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00000000000000f0 CR3: 000000011c118001 CR4: 00000000003606e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: __walk_page_range+0x3c2/0x6f0 walk_page_vma+0x42/0x60 smap_gather_stats+0x79/0xe0 ? gather_pte_stats+0x320/0x320 ? gather_hugetlb_stats+0x70/0x70 show_smaps_rollup+0xcd/0x1c0 seq_read+0x157/0x400 __vfs_read+0x3a/0x180 ? security_file_permission+0x93/0xc0 ? security_file_permission+0x93/0xc0 vfs_read+0x8f/0x140 ksys_read+0x55/0xc0 __x64_sys_read+0x1a/0x20 do_syscall_64+0x5a/0x110 entry_SYSCALL_64_after_hwframe+0x44/0xa9
Decoded code matched to local compilation+disassembly points to smaps_pte_entry():
} else if (unlikely(IS_ENABLED(CONFIG_SHMEM) && mss->check_shmem_swap
&& pte_none(*pte))) {
page = find_get_entry(vma->vm_file->f_mapping,
linear_page_index(vma, addr));Here, vma->vm_file is NULL. mss->check_shmem_swap should be false in that case, however for smaps_rollup, smap_gather_stats() can set the flag true for one vma and leave it true for subsequent vma's where it should be false.
To fix, reset the check_shmem_swap flag to false. There's also related bug which sets mss->swap to shmem_swapped, which in the context of smaps_rollup overwrites any value accumulated from previous vma's. Fix that as well.
Note that the report suggests a regression between 4.17.19 and 4.19-rc7, which makes the 4.19 series ending with commit 258f669e7e88 ("mm:/proc/pid/smaps_rollup: convert to single value seq_file") suspicious. But the mss was reused for rollup since 493b0e9d945f ("mm: add /proc/pid/smaps_rollup") so let's play it safe with the stable backport.
--- fs/proc/task_mmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/proc/task_mmu.c +3 -1
@@ -713,6 +713,8 @@ static void smap_gather_stats(struct vm_ smaps_walk.private = mss;#ifdef CONFIG_SHMEM +/* In case of smaps_rollup, reset the value from previous vma */ + mss->check_shmem_swap = false;if (vma->vm_file &&shmem_mapping (vma->vm_file->f_mapping)) {/* * For shared or readonly shmem mappings we know that all
@@ -728,7 +730,7 @@ static void smap_gather_stats(struct vm_if (!shmem_swapped || (vma->vm_flags &VM_SHARED ) || !(vma->vm_flags &VM_WRITE )) { - mss->swap = shmem_swapped; + mss->swap += shmem_swapped; }else { mss->check_shmem_swap = true; smaps_walk.pte_hole = smaps_pte_hole;
Greg Kroah-Hartman
maintainerPATCH 271/361 nfs: Fix a missed page unlock after pg_doio()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Coddington <[email protected]>
commit fdbd1a2e4a71adcb1ae219fcfd964930d77a7f84 upstream.
We must check pg_error and call error_cleanup after any call to pg_doio. Currently, we are skipping the unlock of a page if we encounter an error in nfs_pageio_complete() before handing off the work to the RPC layer.
--- fs/nfs/pagelist.c | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-)
fs/nfs/pagelist.c +21 -19
@@ -1111,6 +1111,20 @@ static int nfs_pageio_add_request_mirrorreturn ret; } +static void nfs_pageio_error_cleanup (struct nfs_pageio_descriptor *desc) +{ +u32 midx; +struct nfs_pgio_mirror *mirror; + +if (!desc->pg_error) +return ; + +for (midx =0 ; midx < desc->pg_mirror_count; midx++) { + mirror = &desc->pg_mirrors[midx]; + desc->pg_completion_ops->error_cleanup (&mirror->pg_list); + } +} +int nfs_pageio_add_request (struct nfs_pageio_descriptor *desc,struct nfs_page *req) {
@@ -1161,25 +1175,11 @@ int nfs_pageio_add_request(struct nfs_pareturn 1 ; out_failed: -/* -* We might have failed before sending any reqs over wire. -* Clean up rest of the reqs in mirror pg_list. -*/ -if (desc->pg_error) { -struct nfs_pgio_mirror *mirror; -void (*func)(struct list_head *); - -/* remember fatal errors */ -if (nfs_error_is_fatal (desc->pg_error)) -nfs_context_set_write_error (req->wb_context, - desc->pg_error); - - func = desc->pg_completion_ops->error_cleanup; -for (midx =0 ; midx < desc->pg_mirror_count; midx++) { - mirror = &desc->pg_mirrors[midx]; -func (&mirror->pg_list); - } - } +/* remember fatal errors */ +if (nfs_error_is_fatal (desc->pg_error)) +nfs_context_set_write_error (req->wb_context, + desc->pg_error); +nfs_pageio_error_cleanup (desc);return 0 ; }
@@ -1251,6 +1251,8 @@ void nfs_pageio_complete(struct nfs_pagefor (midx =0 ; midx < desc->pg_mirror_count; midx++)nfs_pageio_complete_mirror (desc, midx); +if (desc->pg_error <0 ) +nfs_pageio_error_cleanup (desc);if (desc->pg_ops->pg_cleanup) desc->pg_ops->pg_cleanup (desc);nfs_pageio_cleanup_mirroring (desc);
Greg Kroah-Hartman
maintainerPATCH 273/361 nfsd: Fix an Oops in free_session()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit bb6ad5572c0022e17e846b382d7413cdcf8055be upstream.
In call_xpt_users(), we delete the entry from the list, but we do not reinitialise it. This triggers the list poisoning when we later call unregister_xpt_user() in nfsd4_del_conns().
--- net/sunrpc/svc_xprt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/svc_xprt.c +1 -1
@@ -989,7 +989,7 @@ static void call_xpt_users(struct svc_xpspin_lock (&xprt->xpt_lock);while (!list_empty (&xprt->xpt_users)) { u = list_first_entry(&xprt->xpt_users, struct svc_xpt_user, list); -list_del (&u->list); +list_del_init (&u->list); u->callback (u); }spin_unlock (&xprt->xpt_lock);
Greg Kroah-Hartman
maintainerPATCH 266/361 printk: Fix panic caused by passing log_buf_len to command line
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: He Zhe <[email protected]>
commit 277fcdb2cfee38ccdbe07e705dbd4896ba0c9930 upstream.
log_buf_len_setup does not check input argument before passing it to simple_strtoull. The argument would be a NULL pointer if "log_buf_len", without its value, is set in command line and thus causes the following panic.
PANIC: early exception 0xe3 IP 10:ffffffffaaeacd0d error 0 cr2 0x0
[ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.0-rc4-yocto-standard+ #1 [ 0.000000] RIP: 0010:_parse_integer_fixup_radix+0xd/0x70 ... [ 0.000000] Call Trace: [ 0.000000] simple_strtoull+0x29/0x70 [ 0.000000] memparse+0x26/0x90 [ 0.000000] log_buf_len_setup+0x17/0x22 [ 0.000000] do_early_param+0x57/0x8e [ 0.000000] parse_args+0x208/0x320 [ 0.000000] ? rdinit_setup+0x30/0x30 [ 0.000000] parse_early_options+0x29/0x2d [ 0.000000] ? rdinit_setup+0x30/0x30 [ 0.000000] parse_early_param+0x36/0x4d [ 0.000000] setup_arch+0x336/0x99e [ 0.000000] start_kernel+0x6f/0x4ee [ 0.000000] x86_64_start_reservations+0x24/0x26 [ 0.000000] x86_64_start_kernel+0x6f/0x72 [ 0.000000] secondary_startup_64+0xa4/0xb0
This patch adds a check to prevent the panic.
--- kernel/printk/printk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
kernel/printk/printk.c +6 -1
@@ -1048,7 +1048,12 @@ static void __init log_buf_len_update(un/* save requested log_buf_len since it's too early to process it */ static int __init log_buf_len_setup (char *str) { -unsigned size =memparse (str, &str); +unsigned int size; + +if (!str) +return -EINVAL ; + + size =memparse (str, &str);log_buf_len_update (size);
Greg Kroah-Hartman
maintainerPATCH 269/361 NFC: nfcmrvl_uart: fix OF child-node lookup
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 5bf59773aaf36dd62117dc83d50e1bbf9ef432da upstream.
Use the new of_get_compatible_child() helper to lookup the nfc child node instead of using of_find_compatible_node(), which searches the entire tree from a given start node and thus can return an unrelated (i.e. non-child) node.
This also addresses a potential use-after-free (e.g. after probe deferral) as the tree-wide helper drops a reference to its first argument (i.e. the parent node).
--- drivers/nfc/nfcmrvl/uart.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/nfc/nfcmrvl/uart.c +2 -3
@@ -73,10 +73,9 @@ static int nfcmrvl_uart_parse_dt(structstruct device_node *matched_node;int ret; - matched_node =of_find_compatible_node (node,NULL ,"marvell,nfc-uart" ); + matched_node =of_get_compatible_child (node,"marvell,nfc-uart" );if (!matched_node) { - matched_node =of_find_compatible_node (node,NULL , -"mrvl,nfc-uart" ); + matched_node =of_get_compatible_child (node,"mrvl,nfc-uart" );if (!matched_node)return -ENODEV ; }
Greg Kroah-Hartman
maintainerPATCH 267/361 genirq: Fix race on spurious interrupt detection
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit 746a923b863a1065ef77324e1e43f19b1a3eab5c upstream.
Commit 1e77d0a1ed74 ("genirq: Sanitize spurious interrupt detection of threaded irqs") made detection of spurious interrupts work for threaded handlers by:
a) incrementing a counter every time the thread returns IRQ_HANDLED, and
b) checking whether that counter has increased every time the thread is woken.
However for oneshot interrupts, the commit unmasks the interrupt before incrementing the counter. If another interrupt occurs right after unmasking but before the counter is incremented, that interrupt is incorrectly considered spurious:
time
| irq_thread() | irq_thread_fn() | action->thread_fn() | irq_finalize_oneshot() | unmask_threaded_irq() /* interrupt is unmasked */ | | /* interrupt fires, incorrectly deemed spurious */ | | atomic_inc(&desc->threads_handled); /* counter is incremented */
v
This is observed with a hi3110 CAN controller receiving data at high volume (from a separate machine sending with "cangen -g 0 -i -x"): The controller signals a huge number of interrupts (hundreds of millions per day) and every second there are about a dozen which are deemed spurious.
In theory with high CPU load and the presence of higher priority tasks, the number of incorrectly detected spurious interrupts might increase beyond the 99,900 threshold and cause disablement of the interrupt.
In practice it just increments the spurious interrupt count. But that can cause people to waste time investigating it over and over.
Fix it by moving the accounting before the invocation of irq_finalize_oneshot().
[ tglx: Folded change log update ]
--- kernel/irq/manage.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/irq/manage.c +6 -2
@@ -927,6 +927,9 @@ irq_forced_thread_fn(struct irq_desc *delocal_bh_disable (); ret = action->thread_fn (action->irq, action->dev_id); +if (ret ==IRQ_HANDLED ) +atomic_inc (&desc->threads_handled); +irq_finalize_oneshot (desc, action);local_bh_enable ();return ret;
@@ -943,6 +946,9 @@ static irqreturn_t irq_thread_fn(structirqreturn_t ret; ret = action->thread_fn (action->irq, action->dev_id); +if (ret ==IRQ_HANDLED ) +atomic_inc (&desc->threads_handled); +irq_finalize_oneshot (desc, action);return ret; }
@@ -1020,8 +1026,6 @@ static int irq_thread(void *data)irq_thread_check_affinity (desc, action); action_ret =handler_fn (desc, action); -if (action_ret ==IRQ_HANDLED ) -atomic_inc (&desc->threads_handled);if (action_ret ==IRQ_WAKE_THREAD )irq_wake_secondary (desc, action);
Greg Kroah-Hartman
maintainerPATCH 268/361 tpm: fix response size validation in tpm_get_random()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Sakkinen <[email protected]>
commit 84b59f6487d82d3ab4247a099aba66d4d17e8b08 upstream.
When checking whether the response is large enough to be able to contain the received random bytes in tpm_get_random() and tpm2_get_random(), they fail to take account the header size, which should be added to the minimum size. This commit fixes this issue.
--- drivers/char/tpm/tpm-interface.c | 3 ++- drivers/char/tpm/tpm2-cmd.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm-interface.c +2 -1
@@ -1322,7 +1322,8 @@ int tpm_get_random(struct tpm_chip *chip } rlength =be32_to_cpu (tpm_cmd.header.out.length); -if (rlength < offsetof(struct tpm_getrandom_out , rng_data) + +if (rlength <TPM_HEADER_SIZE + + offsetof(struct tpm_getrandom_out , rng_data) + recd) { total = -EFAULT ;break ;
drivers/char/tpm/tpm2-cmd.c +3 -1
@@ -329,7 +329,9 @@ int tpm2_get_random(struct tpm_chip *chi &buf.data[TPM_HEADER_SIZE ]; recd =min_t (u32,be16_to_cpu (out->size), num_bytes);if (tpm_buf_length (&buf) < - offsetof(struct tpm2_get_random_out , buffer) + recd) { +TPM_HEADER_SIZE + + offsetof(struct tpm2_get_random_out , buffer) + + recd) { err = -EFAULT ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 263/361 smb3: allow stats which track session and share reconnects to be reset
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 2c887635cd6ab3af619dc2be94e5bf8f2e172b78 upstream.
Currently, "echo 0 > /proc/fs/cifs/Stats" resets all of the stats except the session and share reconnect counts. Fix it to reset those as well.
--- fs/cifs/cifs_debug.c | 3 +++ 1 file changed, 3 insertions(+)
fs/cifs/cifs_debug.c +3 -0
@@ -383,6 +383,9 @@ static ssize_t cifs_stats_proc_write(stratomic_set (&totBufAllocCount,0 );atomic_set (&totSmBufAllocCount,0 );#endif /* CONFIG_CIFS_STATS2 */ +atomic_set (&tcpSesReconnectCount,0 ); +atomic_set (&tconInfoReconnectCount,0 ); +spin_lock (&GlobalMid_Lock); GlobalMaxActiveXid =0 ; GlobalCurrentXid =0 ;
Greg Kroah-Hartman
maintainerPATCH 264/361 smb3: do not attempt cifs operation in smb3 query info error path
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 1e77a8c204c9d1b655c61751b8ad0fde22421dbb upstream.
If backupuid mount option is sent, we can incorrectly retry (on access denied on query info) with a cifs (FindFirst) operation on an smb3 mount which causes the server to force the session close.
We set backup intent on open so no need for this fallback.
See kernel bugzilla 201435
--- fs/cifs/inode.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
fs/cifs/inode.c +9 -1
@@ -777,7 +777,15 @@ cifs_get_inode_info(struct inode **inode }else if (rc == -EREMOTE ) {cifs_create_dfs_fattr (&fattr, sb); rc =0 ; - }else if (rc == -EACCES &&backup_cred (cifs_sb)) { + }else if ((rc == -EACCES ) &&backup_cred (cifs_sb) && + (strcmp (server->vals->version_string,SMB1_VERSION_STRING ) + ==0 )) { +/* +* For SMB2 and later the backup intent flag is already +* sent if needed on open and there is no path based +* FindFirst operation to use to retry with +*/ + srchinf =kzalloc (sizeof (struct cifs_search_info ),GFP_KERNEL );if (srchinf ==NULL ) {
Greg Kroah-Hartman
maintainerPATCH 258/361 iio: ad5064: Fix regulator handling
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lars-Peter Clausen <[email protected]>
commit 8911a43bc198877fad9f4b0246a866b26bb547ab upstream.
The correct way to handle errors returned by regualtor_get() and friends is to propagate the error since that means that an regulator was specified, but something went wrong when requesting it.
For handling optional regulators, e.g. when the device has an internal vref, regulator_get_optional() should be used to avoid getting the dummy regulator that the regulator core otherwise provides.
--- drivers/iio/dac/ad5064.c | 53 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 15 deletions(-)
drivers/iio/dac/ad5064.c +38 -15
@@ -808,6 +808,40 @@ static int ad5064_set_config(struct ad50return ad5064_write (st, cmd,0 , val,0 ); } +static int ad5064_request_vref (struct ad5064_state *st,struct device *dev) +{ +unsigned int i; +int ret; + +for (i =0 ; i <ad5064_num_vref (st); ++i) + st->vref_reg[i].supply =ad5064_vref_name (st, i); + +if (!st->chip_info->internal_vref) +return devm_regulator_bulk_get (dev,ad5064_num_vref (st), + st->vref_reg); + +/* +* This assumes that when the regulator has an internal VREF +* there is only one external VREF connection, which is +* currently the case for all supported devices. +*/ + st->vref_reg[0 ].consumer =devm_regulator_get_optional (dev,"vref" ); +if (!IS_ERR (st->vref_reg[0 ].consumer)) +return 0 ; + + ret =PTR_ERR (st->vref_reg[0 ].consumer); +if (ret != -ENODEV ) +return ret; + +/* If no external regulator was supplied use the internal VREF */ + st->use_internal_vref = true; + ret =ad5064_set_config (st,AD5064_CONFIG_INT_VREF_ENABLE ); +if (ret) +dev_err (dev,"Failed to enable internal vref: %d\n" , ret); + +return ret; +} +static int ad5064_probe (struct device *dev,enum ad5064_type type,const char *name,ad5064_write_func write) {
@@ -828,22 +862,11 @@ static int ad5064_probe(struct device *d st->dev = dev; st->write = write; -for (i =0 ; i <ad5064_num_vref (st); ++i) - st->vref_reg[i].supply =ad5064_vref_name (st, i); + ret =ad5064_request_vref (st, dev); +if (ret) +return ret; - ret =devm_regulator_bulk_get (dev,ad5064_num_vref (st), - st->vref_reg); -if (ret) { -if (!st->chip_info->internal_vref) -return ret; - st->use_internal_vref = true; - ret =ad5064_set_config (st,AD5064_CONFIG_INT_VREF_ENABLE ); -if (ret) { -dev_err (dev,"Failed to enable internal vref: %d\n" , - ret); -return ret; - } - }else { +if (!st->use_internal_vref) { ret =regulator_bulk_enable (ad5064_num_vref (st), st->vref_reg);if (ret)return ret;
Greg Kroah-Hartman
maintainerPATCH 257/361 kbuild: fix kernel/bounds.c W=1 warning
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 6a32c2469c3fbfee8f25bcd20af647326650a6cf upstream.
Building any configuration with 'make W=1' produces a warning:
kernel/bounds.c:16:6: warning: no previous prototype for 'foo' [-Wmissing-prototypes]
When also passing -Werror, this prevents us from building any other files. Nobody ever calls the function, but we can't make it 'static' either since we want the compiler output.
Calling it 'main' instead however avoids the warning, because gcc does not insist on having a declaration for main.
--- kernel/bounds.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/bounds.c +3 -1
@@ -13,7 +13,7 @@#include <linux/log2.h> #include <linux/spinlock_types.h> -void foo (void ) +int main (void ) {/* The enum constants to put into include/generated/bounds.h */ DEFINE (NR_PAGEFLAGS , __NR_PAGEFLAGS);
@@ -23,4 +23,6 @@ void foo(void)#endif DEFINE (SPINLOCK_SIZE ,sizeof (spinlock_t));/* End of constants */ + +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 255/361 KVM: arm/arm64: Ensure only THP is candidate for adjustment
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Punit Agrawal <[email protected]>
commit fd2ef358282c849c193aa36dadbf4f07f7dcd29b upstream.
PageTransCompoundMap() returns true for hugetlbfs and THP hugepages. This behaviour incorrectly leads to stage 2 faults for unsupported hugepage sizes (e.g., 64K hugepage with 4K pages) to be treated as THP faults.
Tighten the check to filter out hugetlbfs pages. This also leads to consistently mapping all unsupported hugepage sizes as PTE level entries at stage 2.
--- virt/kvm/arm/mmu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
virt/kvm/arm/mmu.c +7 -1
@@ -1230,8 +1230,14 @@ static bool transparent_hugepage_adjust( {kvm_pfn_t pfn = *pfnp;gfn_t gfn = *ipap >>PAGE_SHIFT ; +struct page *page =pfn_to_page (pfn); -if (PageTransCompoundMap (pfn_to_page (pfn))) { +/* +* PageTransCompoungMap() returns true for THP and +* hugetlbfs. Make sure the adjustment is done only for THP +* pages. +*/ +if (!PageHuge (page) &&PageTransCompoundMap (page)) {unsigned long mask;/* * The address we faulted on is backed by a transparent huge
Greg Kroah-Hartman
maintainerPATCH 208/361 usbip:vudc: BUG kmalloc-2048 (Not tainted): Poison overwritten
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuah Khan (Samsung OSG) <[email protected]>
commit e28fd56ad5273be67d0fae5bedc7e1680e729952 upstream.
In rmmod path, usbip_vudc does platform_device_put() twice once from platform_device_unregister() and then from put_vudc_device().
The second put results in:
BUG kmalloc-2048 (Not tainted): Poison overwritten error or
BUG: KASAN: use-after-free in kobject_put+0x1e/0x230 if KASAN is
enabled.
[ 169.042156] calling init+0x0/0x1000 [usbip_vudc] @ 1697 [ 169.042396] ============================================================================= [ 169.043678] probe of usbip-vudc.0 returned 1 after 350 usecs [ 169.044508] BUG kmalloc-2048 (Not tainted): Poison overwritten [ 169.044509] ----------------------------------------------------------------------------- ... [ 169.057849] INFO: Freed in device_release+0x2b/0x80 age=4223 cpu=3 pid=1693 [ 169.057852] kobject_put+0x86/0x1b0 [ 169.057853] 0xffffffffc0c30a96 [ 169.057855] __x64_sys_delete_module+0x157/0x240
Fix it to call platform_device_del() instead and let put_vudc_device() do the platform_device_put().
--- drivers/usb/usbip/vudc_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/usb/usbip/vudc_main.c +9 -1
@@ -73,6 +73,10 @@ static int __init init(void) cleanup:list_for_each_entry_safe (udc_dev, udc_dev2, &vudc_devices, dev_entry) {list_del (&udc_dev->dev_entry); +/* +* Just do platform_device_del() here, put_vudc_device() +* calls the platform_device_put() +*/ platform_device_del (udc_dev->pdev);put_vudc_device (udc_dev); }
@@ -89,7 +93,11 @@ static void __exit cleanup(void)list_for_each_entry_safe (udc_dev, udc_dev2, &vudc_devices, dev_entry) {list_del (&udc_dev->dev_entry); -platform_device_unregister (udc_dev->pdev); +/* +* Just do platform_device_del() here, put_vudc_device() +* calls the platform_device_put() +*/ +platform_device_del (udc_dev->pdev);put_vudc_device (udc_dev); }platform_driver_unregister (&vudc_driver);
Greg Kroah-Hartman
maintainerPATCH 217/361 libnvdimm: Hold reference on parent while scheduling async init
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Duyck <[email protected]>
commit b6eae0f61db27748606cc00dafcfd1e2c032f0a5 upstream.
Unlike asynchronous initialization in the core we have not yet associated the device with the parent, and as such the device doesn't hold a reference to the parent.
In order to resolve that we should be holding a reference on the parent until the asynchronous initialization has completed.
--- drivers/nvdimm/bus.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/nvdimm/bus.c +4 -0
@@ -488,6 +488,8 @@ static void nd_async_device_register(voiput_device (dev); }put_device (dev); +if (dev->parent) +put_device (dev->parent); }static void nd_async_device_unregister (void *d,async_cookie_t cookie)
@@ -507,6 +509,8 @@ void __nd_device_register(struct deviceif (!dev)return ; dev->bus = &nvdimm_bus_type; +if (dev->parent) +get_device (dev->parent);get_device (dev);async_schedule_domain (nd_async_device_register, dev, &nd_async_domain);
Greg Kroah-Hartman
maintainerPATCH 214/361 dmaengine: ppc4xx: fix off-by-one build failure
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Lamparter <[email protected]>
commit 27d8d2d7a9b7eb05c4484b74b749eaee7b50b845 upstream.
There are two poly_store, but one should have been poly_show.
|adma.c:4382:16: error: conflicting types for 'poly_store' | static ssize_t poly_store(struct device_driver *dev, const char *buf, | ^~~~~~~~~~ |adma.c:4363:16: note: previous definition of 'poly_store' was here | static ssize_t poly_store(struct device_driver *dev, char *buf) | ^~~~~~~~~~
--- drivers/dma/ppc4xx/adma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/ppc4xx/adma.c +1 -1
@@ -4360,7 +4360,7 @@ static ssize_t enable_store(struct devic }static DRIVER_ATTR_RW (enable); -static ssize_t poly_store (struct device_driver *dev,char *buf) +static ssize_t poly_show (struct device_driver *dev,char *buf) {ssize_t size =0 ;u32 reg;
Greg Kroah-Hartman
maintainerPATCH 216/361 scsi: target: Fix target_wait_for_sess_cmds breakage with active signals
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Bellinger <[email protected]>
commit 38fe73cc2c96fbc9942b07220f2a4f1bab37392d upstream.
With the addition of commit 00d909a10710 ("scsi: target: Make the session shutdown code also wait for commands that are being aborted") in v4.19-rc, it incorrectly assumes no signals will be pending for task_struct executing the normal session shutdown and I/O quiesce code-path.
For example, iscsi-target and iser-target issue SIGINT to all kthreads as part of session shutdown. This has been the behaviour since day one.
As-is when signals are pending with se_cmds active in se_sess->sess_cmd_list, wait_event_interruptible_lock_irq_timeout() returns a negative number and immediately kills the machine because of the do while (ret <= 0) loop that was added in commit 00d909a107 to spin while backend I/O is taking any amount of extended time (say 30 seconds) to complete.
Here's what it looks like in action with debug plus delayed backend I/O completion:
[ 4951.909951] se_sess: 000000003e7e08fa before target_wait_for_sess_cmds [ 4951.914600] target_wait_for_sess_cmds: signal_pending: 1 [ 4951.918015] wait_event_interruptible_lock_irq_timeout ret: -512 signal_pending: 1 loop count: 0 [ 4951.921639] wait_event_interruptible_lock_irq_timeout ret: -512 signal_pending: 1 loop count: 1 [ 4951.921944] wait_event_interruptible_lock_irq_timeout ret: -512 signal_pending: 1 loop count: 2 [ 4951.921944] wait_event_interruptible_lock_irq_timeout ret: -512 signal_pending: 1 loop count: 3 [ 4951.921944] wait_event_interruptible_lock_irq_timeout ret: -512 signal_pending: 1 loop count: 4 [ 4951.921944] wait_event_interruptible_lock_irq_timeout ret: -512 signal_pending: 1 loop count: 5 [ 4951.921944] wait_event_interruptible_lock_irq_timeout ret: -512 signal_pending: 1 loop count: 6 [ 4951.921944] wait_event_interruptible_lock_irq_timeout ret: -512 signal_pending: 1 loop count: 7 [ 4951.921944] wait_event_interruptible_lock_irq_timeout ret: -512 signal_pending: 1 loop count: 8 [ 4951.921944] wait_event_interruptible_lock_irq_timeout ret: -512 signal_pending: 1 loop count: 9
... followed by the usual RCU CPU stalls and deadlock.
There was never a case pre commit 00d909a107 where wait_for_complete(&se_cmd->cmd_wait_comp) was able to be interrupted, so to address this for v4.19+ moving forward go ahead and use wait_event_lock_irq_timeout() instead so new code works with all fabric drivers.
Also for commit 00d909a107, fix a minor regression in target_release_cmd_kref() to only wake_up the new se_sess->cmd_list_wq only when shutdown has actually been triggered via se_sess->sess_tearing_down.
--- drivers/target/target_core_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/target/target_core_transport.c +2 -2
@@ -2754,7 +2754,7 @@ static void target_release_cmd_kref(struif (se_sess) {spin_lock_irqsave (&se_sess->sess_cmd_lock, flags);list_del_init (&se_cmd->se_cmd_list); -if (list_empty (&se_sess->sess_cmd_list)) +if (se_sess->sess_tearing_down &&list_empty (&se_sess->sess_cmd_list))wake_up (&se_sess->cmd_list_wq);spin_unlock_irqrestore (&se_sess->sess_cmd_lock, flags); }
@@ -2907,7 +2907,7 @@ void target_wait_for_sess_cmds(struct sespin_lock_irq (&se_sess->sess_cmd_lock); do { - ret = wait_event_interruptible_lock_irq_timeout( + ret = wait_event_lock_irq_timeout( se_sess->cmd_list_wq, list_empty(&se_sess->sess_cmd_list), se_sess->sess_cmd_lock, 180 * HZ);
Greg Kroah-Hartman
maintainerPATCH 212/361 iwlwifi: mvm: check return value of rs_rate_from_ucode_rate()
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Coelho <[email protected]>
commit 3d71c3f1f50cf309bd20659422af549bc784bfff upstream.
The rs_rate_from_ucode_rate() function may return -EINVAL if the rate is invalid, but none of the callsites check for the error, potentially making us access arrays with index IWL_RATE_INVALID, which is larger than the arrays, causing an out-of-bounds access. This will trigger KASAN warnings, such as the one reported in the bugzilla issue mentioned below.
This fixes https://bugzilla.kernel.org/show_bug.cgi?id=200659
--- drivers/net/wireless/intel/iwlwifi/mvm/rs.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/rs.c +19 -5
@@ -1239,7 +1239,11 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm !(info->flags & IEEE80211_TX_STAT_AMPDU)) return; -rs_rate_from_ucode_rate (tx_resp_hwrate, info->band, &tx_resp_rate); +if (rs_rate_from_ucode_rate (tx_resp_hwrate, info->band, + &tx_resp_rate)) { +WARN_ON_ONCE (1 ); +return ; + }#ifdef CONFIG_MAC80211_DEBUGFS /* Disable last tx check if we are debugging with fixed rate but
@@ -1290,7 +1294,10 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm*/ table = &lq_sta->lq; lq_hwrate =le32_to_cpu (table->rs_table[0 ]); -rs_rate_from_ucode_rate (lq_hwrate, info->band, &lq_rate); +if (rs_rate_from_ucode_rate (lq_hwrate, info->band, &lq_rate)) { +WARN_ON_ONCE (1 ); +return ; + }/* Here we actually compare this rate to the latest LQ command */ if (lq_color !=LQ_FLAG_COLOR_GET (table->flags)) {
@@ -1392,8 +1399,12 @@ void iwl_mvm_rs_tx_status(struct iwl_mvm/* Collect data for each rate used during failed TX attempts */ for (i =0 ; i <= retries; ++i) { lq_hwrate =le32_to_cpu (table->rs_table[i]); -rs_rate_from_ucode_rate (lq_hwrate, info->band, - &lq_rate); +if (rs_rate_from_ucode_rate (lq_hwrate, info->band, + &lq_rate)) { +WARN_ON_ONCE (1 ); +return ; + } +/* * Only collect stats if retried rate is in the same RS * table as active/search.
@@ -3262,7 +3273,10 @@ static void rs_build_rates_table_from_fifor (i =0 ; i < num_rates; i++) lq_cmd->rs_table[i] = ucode_rate_le32; -rs_rate_from_ucode_rate (ucode_rate, band, &rate); +if (rs_rate_from_ucode_rate (ucode_rate, band, &rate)) { +WARN_ON_ONCE (1 ); +return ; + }if (is_mimo (&rate)) lq_cmd->mimo_delim = num_rates -1 ;
Greg Kroah-Hartman
maintainerPATCH 213/361 net/ipv4: defensive cipso option parsing
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Nuernberger <[email protected]>
commit 076ed3da0c9b2f88d9157dbe7044a45641ae369e upstream.
commit 40413955ee26 ("Cipso: cipso_v4_optptr enter infinite loop") fixed a possible infinite loop in the IP option parsing of CIPSO. The fix assumes that ip_options_compile filtered out all zero length options and that no other one-byte options beside IPOPT_END and IPOPT_NOOP exist. While this assumption currently holds true, add explicit checks for zero length and invalid length options to be safe for the future. Even though ip_options_compile should have validated the options, the introduction of new one-byte options can still confuse this code without the additional checks.
--- net/ipv4/cipso_ipv4.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
net/ipv4/cipso_ipv4.c +7 -4
@@ -1512,7 +1512,7 @@ static int cipso_v4_parsetag_loc(const s* * Description: * Parse the packet's IP header looking for a CIPSO option. Returns a pointer -* to the start of the CIPSO option on success, NULL if one if not found. +* to the start of the CIPSO option on success, NULL if one is not found. * */ unsigned char *cipso_v4_optptr (const struct sk_buff *skb)
@@ -1522,10 +1522,8 @@ unsigned char *cipso_v4_optptr(const strint optlen;int taglen; -for (optlen = iph->ihl*4 -sizeof (struct iphdr ); optlen >0 ; ) { +for (optlen = iph->ihl*4 -sizeof (struct iphdr ); optlen >1 ; ) {switch (optptr[0 ]) { -case IPOPT_CIPSO : -return optptr;case IPOPT_END :return NULL ;case IPOPT_NOOP :
@@ -1534,6 +1532,11 @@ unsigned char *cipso_v4_optptr(const strdefault : taglen = optptr[1 ]; } +if (!taglen || taglen > optlen) +return NULL ; +if (optptr[0 ] ==IPOPT_CIPSO ) +return optptr; + optlen -= taglen; optptr += taglen; }
Greg Kroah-Hartman
maintainerPATCH 242/361 crypto: lrw - Fix out-of bounds access on counter overflow
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ondrej Mosnacek <[email protected]>
commit fbe1a850b3b1522e9fc22319ccbbcd2ab05328d2 upstream.
When the LRW block counter overflows, the current implementation returns 128 as the index to the precomputed multiplication table, which has 128 entries. This patch fixes it to return the correct value (127).
--- crypto/lrw.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
crypto/lrw.c +6 -1
@@ -143,7 +143,12 @@ static inline int get_index128(be128 *blreturn x +ffz (val); } -return x; +/* +* If we get here, then x == 128 and we are incrementing the counter +* from all ones to all zeros. This means we must return index 127, i.e. +* the one corresponding to key2*{ 1,...,1 }. +*/ +return 127 ; }static int post_crypt (struct skcipher_request *req)
Greg Kroah-Hartman
maintainerPATCH 241/361 signal: Guard against negative signal numbers in copy_siginfo_from_user32
In reply to Greg Kroah-Hartman4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric W. Biederman <[email protected]>
commit a36700589b85443e28170be59fa11c8a104130a5 upstream.
While fixing an out of bounds array access in known_siginfo_layout reported by the kernel test robot it became apparent that the same bug exists in siginfo_layout and affects copy_siginfo_from_user32.
The straight forward fix that makes guards against making this mistake in the future and should keep the code size small is to just take an unsigned signal number instead of a signed signal number, as I did to fix known_siginfo_layout.
--- include/linux/signal.h | 2 +- kernel/signal.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/signal.h +1 -1
@@ -36,7 +36,7 @@ enum siginfo_layout { SIL_SYS, }; -enum siginfo_layout siginfo_layout (int sig,int si_code); +enum siginfo_layout siginfo_layout (unsigned sig,int si_code);/* * Define some primitives to manipulate sigset_t.
kernel/signal.c +1 -1
@@ -2847,7 +2847,7 @@ COMPAT_SYSCALL_DEFINE2(rt_sigpending, co }#endif -enum siginfo_layout siginfo_layout (int sig,int si_code) +enum siginfo_layout siginfo_layout (unsigned sig,int si_code) {enum siginfo_layout layout =SIL_KILL ;if ((si_code >SI_USER ) && (si_code <SI_KERNEL )) {