4.19.61-stable review
Subsystems (9)
Greg Kroah-Hartman
maintainerPATCH 160/271 floppy: fix div-by-zero in setup_format_params
In reply to Greg Kroah-Hartman[ Upstream commit f3554aeb991214cbfafd17d55e2bfddb50282e32 ]
This fixes a divide by zero error in the setup_format_params function of the floppy driver.
Two consecutive ioctls can trigger the bug: The first one should set the drive geometry with such .sect and .rate values for the F_SECT_PER_TRACK to become zero. Next, the floppy format operation should be called.
A floppy disk is not required to be inserted. An unprivileged user could trigger the bug if the device is accessible.
The patch checks F_SECT_PER_TRACK for a non-zero value in the set_geometry function. The proper check should involve a reasonable upper limit for the .sect and .rate fields, but it could change the UAPI.
The patch also checks F_SECT_PER_TRACK in the setup_format_params, and cancels the formatting operation in case of zero.
The bug was found by syzkaller.
--- drivers/block/floppy.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/block/floppy.c +5 -0
@@ -2119,6 +2119,9 @@ static void setup_format_params(int track) raw_cmd->kernel_data = floppy_track_buffer; raw_cmd->length =4 *F_SECT_PER_TRACK ; +if (!F_SECT_PER_TRACK ) +return ; +/* allow for about 30ms for data transport per track */ head_shift = (F_SECT_PER_TRACK +5 ) /6 ;
@@ -3243,6 +3246,8 @@ static int set_geometry(unsigned int cmd, struct floppy_struct *g,/* sanity checking for parameters. */ if (g->sect <=0 || g->head <=0 || +/* check for zero in F_SECT_PER_TRACK */ + (unsigned char )((g->sect <<2 ) >>FD_SIZECODE (g)) ==0 || g->track <=0 || g->track >UDP ->tracks >>STRETCH (g) ||/* check if reserved bits are set */ (g->stretch & ~(FD_STRETCH |FD_SWAPSIDES |FD_SECTBASEMASK )) !=0 )
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 161/271 floppy: fix out-of-bounds read in next_valid_format
In reply to Greg Kroah-Hartman[ Upstream commit 5635f897ed83fd539df78e98ba69ee91592f9bb8 ]
This fixes a global out-of-bounds read access in the next_valid_format function of the floppy driver.
The values from autodetect field of the struct floppy_drive_params are used as indices for the floppy_type array in the next_valid_format function 'floppy_type[DP->autodetect[probed_format]].sect'.
To trigger the bug, one could use a value out of range and set the drive parameters with the FDSETDRVPRM ioctl. A floppy disk is not required to be inserted.
CAP_SYS_ADMIN is required to call FDSETDRVPRM.
The patch adds the check for values of the autodetect field to be in the '0 <= x < ARRAY_SIZE(floppy_type)' range of the floppy_type array indices.
The bug was found by syzkaller.
--- drivers/block/floppy.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/block/floppy.c +18 -0
@@ -3391,6 +3391,20 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)return 0 ; } +static bool valid_floppy_drive_params (const short autodetect[8 ]) +{ +size_t floppy_type_size =ARRAY_SIZE (floppy_type); +size_t i =0 ; + +for (i =0 ; i <8 ; ++i) { +if (autodetect[i] <0 || + autodetect[i] >= floppy_type_size) +return false; + } + +return true; +} +static int fd_locked_ioctl (struct block_device *bdev,fmode_t mode,unsigned int cmd,unsigned long param) {
@@ -3517,6 +3531,8 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned intSUPBOUND (size,strlen ((const char *)outparam) +1 );break ;case FDSETDRVPRM : +if (!valid_floppy_drive_params (inparam.dp.autodetect)) +return -EINVAL ; *UDP = inparam.dp;break ;case FDGETDRVPRM :
@@ -3714,6 +3730,8 @@ static int compat_setdrvprm(int drive,return -EPERM ;if (copy_from_user (&v, arg,sizeof (struct compat_floppy_drive_params )))return -EFAULT ; +if (!valid_floppy_drive_params (v.autodetect)) +return -EINVAL ;mutex_lock (&floppy_mutex);UDP ->cmos = v.cmos;UDP ->max_dtr = v.max_dtr;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 162/271 floppy: fix invalid pointer dereference in drive_name
In reply to Greg Kroah-Hartman[ Upstream commit 9b04609b784027968348796a18f601aed9db3789 ]
This fixes the invalid pointer dereference in the drive_name function of the floppy driver.
The native_format field of the struct floppy_drive_params is used as floppy_type array index in the drive_name function. Thus, the field should be checked the same way as the autodetect field.
To trigger the bug, one could use a value out of range and set the drive parameters with the FDSETDRVPRM ioctl. Next, FDGETDRVTYP ioctl should be used to call the drive_name. A floppy disk is not required to be inserted.
CAP_SYS_ADMIN is required to call FDSETDRVPRM.
The patch adds the check for a value of the native_format field to be in the '0 <= x < ARRAY_SIZE(floppy_type)' range of the floppy_type array indices.
The bug was found by syzkaller.
--- drivers/block/floppy.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/block/floppy.c +8 -3
@@ -3391,7 +3391,8 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)return 0 ; } -static bool valid_floppy_drive_params (const short autodetect[8 ]) +static bool valid_floppy_drive_params (const short autodetect[8 ], +int native_format) {size_t floppy_type_size =ARRAY_SIZE (floppy_type);size_t i =0 ;
@@ -3402,6 +3403,9 @@ static bool valid_floppy_drive_params(const short autodetect[8])return false; } +if (native_format <0 || native_format >= floppy_type_size) +return false; +return true; }
@@ -3531,7 +3535,8 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned intSUPBOUND (size,strlen ((const char *)outparam) +1 );break ;case FDSETDRVPRM : -if (!valid_floppy_drive_params (inparam.dp.autodetect)) +if (!valid_floppy_drive_params (inparam.dp.autodetect, + inparam.dp.native_format))return -EINVAL ; *UDP = inparam.dp;break ;
@@ -3730,7 +3735,7 @@ static int compat_setdrvprm(int drive,return -EPERM ;if (copy_from_user (&v, arg,sizeof (struct compat_floppy_drive_params )))return -EFAULT ; -if (!valid_floppy_drive_params (v.autodetect)) +if (!valid_floppy_drive_params (v.autodetect, v.native_format))return -EINVAL ;mutex_lock (&floppy_mutex);UDP ->cmos = v.cmos;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 163/271 floppy: fix out-of-bounds read in copy_buffer
In reply to Greg Kroah-Hartman[ Upstream commit da99466ac243f15fbba65bd261bfc75ffa1532b6 ]
This fixes a global out-of-bounds read access in the copy_buffer function of the floppy driver.
The FDDEFPRM ioctl allows one to set the geometry of a disk. The sect and head fields (unsigned int) of the floppy_drive structure are used to compute the max_sector (int) in the make_raw_rw_request function. It is possible to overflow the max_sector. Next, max_sector is passed to the copy_buffer function and used in one of the memcpy calls.
An unprivileged user could trigger the bug if the device is accessible, but requires a floppy disk to be inserted.
The patch adds the check for the .sect * .head multiplication for not overflowing in the set_geometry function.
The bug was found by syzkaller.
--- drivers/block/floppy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/block/floppy.c +4 -2
@@ -3244,8 +3244,10 @@ static int set_geometry(unsigned int cmd, struct floppy_struct *g,int cnt;/* sanity checking for parameters. */ - if (g->sect <= 0 || - g->head <= 0 || + if ((int)g->sect <= 0 || + (int)g->head <= 0 || + /* check for overflow in max_sector */ + (int)(g->sect * g->head) <= 0 || /* check for zero in F_SECT_PER_TRACK */ (unsigned char)((g->sect << 2) >> FD_SIZECODE(g)) == 0 || g->track <= 0 || g->track > UDP->tracks >> STRETCH(g) ||
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 164/271 xen: let alloc_xenballooned_pages() fail if not enough memory free
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
commit a1078e821b605813b63bf6bca414a85f804d5c66 upstream.
Instead of trying to allocate pages with GFP_USER in add_ballooned_pages() check the available free memory via si_mem_available(). GFP_USER is far less limiting memory exhaustion than the test via si_mem_available().
This will avoid dom0 running out of memory due to excessive foreign page mappings especially on ARM and on x86 in PVH mode, as those don't have a pre-ballooned area which can be used for foreign mappings.
As the normal ballooning suffers from the same problem don't balloon down more than si_mem_available() pages in one iteration. At the same time limit the default maximum number of retries.
This is part of XSA-300.
--- drivers/xen/balloon.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/xen/balloon.c +13 -3
@@ -527,8 +527,15 @@ static void balloon_process(struct work_ state =reserve_additional_memory (); } -if (credit <0 ) - state =decrease_reservation (-credit,GFP_BALLOON ); +if (credit <0 ) { +long n_pages; + + n_pages =min (-credit,si_mem_available ()); + state =decrease_reservation (n_pages,GFP_BALLOON ); +if (state ==BP_DONE && n_pages != -credit && + n_pages < totalreserve_pages) + state =BP_EAGAIN ; + } state =update_schedule (state);
@@ -567,6 +574,9 @@ static int add_ballooned_pages(int nr_pa } } +if (si_mem_available () < nr_pages) +return -ENOMEM ; + st =decrease_reservation (nr_pages,GFP_USER );if (st !=BP_DONE )return -ENOMEM ;
@@ -696,7 +706,7 @@ static int __init balloon_init(void) balloon_stats.schedule_delay =1 ; balloon_stats.max_schedule_delay =32 ; balloon_stats.retry_count =1 ; - balloon_stats.max_retry_count =RETRY_UNLIMITED ; + balloon_stats.max_retry_count =4 ;#ifdef CONFIG_XEN_BALLOON_MEMORY_HOTPLUG set_online_page_callback (&xen_online_page);
Greg Kroah-Hartman
maintainerPATCH 165/271 scsi: NCR5380: Reduce goto statements in NCR5380_select()
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
commit 6a162836997c10bbefb7c7ca772201cc45c0e4a6 upstream.
Replace a 'goto' statement with a simple 'return' where possible. This improves readability. No functional change.
--- drivers/scsi/NCR5380.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/scsi/NCR5380.c +12 -9
@@ -984,7 +984,7 @@ static struct scsi_cmnd *NCR5380_select(if (!hostdata->selecting) {/* Command was aborted */ NCR5380_write (MODE_REG ,MR_BASE ); - goto out; +return NULL ; }if (err <0 ) {NCR5380_write (MODE_REG ,MR_BASE );
@@ -1033,7 +1033,7 @@ static struct scsi_cmnd *NCR5380_select(if (!hostdata->selecting) {NCR5380_write (MODE_REG ,MR_BASE );NCR5380_write (INITIATOR_COMMAND_REG ,ICR_BASE ); - goto out; +return NULL ; }dsprintk (NDEBUG_ARBITRATION , instance,"won arbitration\n" );
@@ -1116,13 +1116,16 @@ static struct scsi_cmnd *NCR5380_select(spin_lock_irq (&hostdata->lock);NCR5380_write (INITIATOR_COMMAND_REG ,ICR_BASE );NCR5380_write (SELECT_ENABLE_REG , hostdata->id_mask); +/* Can't touch cmd if it has been reclaimed by the scsi ML */ -if (hostdata->selecting) { - cmd->result =DID_BAD_TARGET <<16 ; -complete_cmd (instance, cmd); -dsprintk (NDEBUG_SELECTION , instance,"target did not respond within 250ms\n" ); - cmd =NULL ; - } +if (!hostdata->selecting) +return NULL ; + + cmd->result =DID_BAD_TARGET <<16 ; +complete_cmd (instance, cmd); +dsprintk (NDEBUG_SELECTION , instance, +"target did not respond within 250ms\n" ); + cmd =NULL ; goto out; }
@@ -1155,7 +1158,7 @@ static struct scsi_cmnd *NCR5380_select( }if (!hostdata->selecting) {do_abort (instance); - goto out; +return NULL ; } dsprintk(NDEBUG_SELECTION, instance, "target %d selected, going into MESSAGE OUT phase.\n",
Greg Kroah-Hartman
maintainerPATCH 166/271 scsi: NCR5380: Always re-enable reselection interrupt
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
commit 57f31326518e98ee4cabf9a04efe00ed57c54147 upstream.
The reselection interrupt gets disabled during selection and must be re-enabled when hostdata->connected becomes NULL. If it isn't re-enabled a disconnected command may time-out or the target may wedge the bus while trying to reselect the host. This can happen after a command is aborted.
Fix this by enabling the reselection interrupt in NCR5380_main() after calls to NCR5380_select() and NCR5380_information_transfer() return.
--- drivers/scsi/NCR5380.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/scsi/NCR5380.c +2 -10
@@ -710,6 +710,8 @@ static void NCR5380_main(struct work_strNCR5380_information_transfer (instance); done =0 ; } +if (!hostdata->connected) +NCR5380_write (SELECT_ENABLE_REG , hostdata->id_mask);spin_unlock_irq (&hostdata->lock);if (!done)cond_resched ();
@@ -1106,8 +1108,6 @@ static struct scsi_cmnd *NCR5380_select(spin_lock_irq (&hostdata->lock);NCR5380_write (INITIATOR_COMMAND_REG ,ICR_BASE );NCR5380_reselect (instance); -if (!hostdata->connected) -NCR5380_write (SELECT_ENABLE_REG , hostdata->id_mask);shost_printk (KERN_ERR , instance,"reselection after won arbitration?\n" ); goto out; }
@@ -1115,7 +1115,6 @@ static struct scsi_cmnd *NCR5380_select(if (err <0 ) {spin_lock_irq (&hostdata->lock);NCR5380_write (INITIATOR_COMMAND_REG ,ICR_BASE ); -NCR5380_write (SELECT_ENABLE_REG , hostdata->id_mask);/* Can't touch cmd if it has been reclaimed by the scsi ML */ if (!hostdata->selecting)
@@ -1153,7 +1152,6 @@ static struct scsi_cmnd *NCR5380_select(if (err <0 ) {shost_printk (KERN_ERR , instance,"select: REQ timeout\n" );NCR5380_write (INITIATOR_COMMAND_REG ,ICR_BASE ); -NCR5380_write (SELECT_ENABLE_REG , hostdata->id_mask); goto out; }if (!hostdata->selecting) {
@@ -1820,9 +1818,6 @@ static void NCR5380_information_transfer*/ NCR5380_write (TARGET_COMMAND_REG ,0 ); -/* Enable reselect interrupts */ -NCR5380_write (SELECT_ENABLE_REG , hostdata->id_mask); -maybe_release_dma_irq (instance);return ;case MESSAGE_REJECT :
@@ -1854,8 +1849,6 @@ static void NCR5380_information_transfer*/ NCR5380_write (TARGET_COMMAND_REG ,0 ); -/* Enable reselect interrupts */ -NCR5380_write (SELECT_ENABLE_REG , hostdata->id_mask);#ifdef SUN3_SCSI_VME dregs->csr |=CSR_DMA_ENABLE ;#endif
@@ -1957,7 +1950,6 @@ static void NCR5380_information_transfer cmd->result =DID_ERROR <<16 ;complete_cmd (instance, cmd);maybe_release_dma_irq (instance); -NCR5380_write (SELECT_ENABLE_REG , hostdata->id_mask);return ; } msgout =NOP ;
Greg Kroah-Hartman
maintainerPATCH 167/271 Revert "scsi: ncr5380: Increase register polling limit"
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
commit 25fcf94a2fa89dd3e73e965ebb0b38a2a4f72aa4 upstream.
This reverts commit 4822827a69d7cd3bc5a07b7637484ebd2cf88db6.
The purpose of that commit was to suppress a timeout warning message which appeared to be caused by target latency. But suppressing the warning is undesirable as the warning may indicate a messed up transfer count.
Another problem with that commit is that 15 ms is too long to keep interrupts disabled as interrupt latency can cause system clock drift and other problems.
--- drivers/scsi/NCR5380.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/NCR5380.h +1 -1
@@ -235,7 +235,7 @@ struct NCR5380_cmd {#define NCR5380_PIO_CHUNK_SIZE 256/* Time limit (ms) to poll registers when IRQs are disabled, e.g. during PDMA */ -#define NCR5380_REG_POLL_TIME 15 +#define NCR5380_REG_POLL_TIME 10static inline struct scsi_cmnd *NCR5380_to_scmd (struct NCR5380_cmd *ncmd_ptr) {
Greg Kroah-Hartman
maintainerPATCH 168/271 scsi: core: Fix race on creating sense cache
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
commit f9b0530fa02e0c73f31a49ef743e8f44eb8e32cc upstream.
When scsi_init_sense_cache(host) is called concurrently from different hosts, each code path may find that no cache has been created and allocate a new one. The lack of locking can lead to potentially overriding a cache allocated by a different host.
Fix the issue by moving 'mutex_lock(&scsi_sense_cache_mutex)' before scsi_select_sense_cache().
--- drivers/scsi/scsi_lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/scsi_lib.c +3 -3
@@ -71,11 +71,11 @@ int scsi_init_sense_cache(struct Scsi_Hostruct kmem_cache *cache;int ret =0 ; +mutex_lock (&scsi_sense_cache_mutex); cache =scsi_select_sense_cache (shost->unchecked_isa_dma);if (cache) -return 0 ; + goto exit; -mutex_lock (&scsi_sense_cache_mutex);if (shost->unchecked_isa_dma) { scsi_sense_isadma_cache = kmem_cache_create("scsi_sense_cache(DMA)",
@@ -91,7 +91,7 @@ int scsi_init_sense_cache(struct Scsi_Hoif (!scsi_sense_cache) ret = -ENOMEM ; } - + exit:mutex_unlock (&scsi_sense_cache_mutex);return ret; }
Greg Kroah-Hartman
maintainerPATCH 169/271 scsi: megaraid_sas: Fix calculation of target ID
In reply to Greg Kroah-HartmanFrom: Shivasharan S <[email protected]>
commit c8f96df5b8e633056b7ebf5d52a9d6fb1b156ce3 upstream.
In megasas_get_target_prop(), driver is incorrectly calculating the target ID for devices with channel 1 and 3. Due to this, firmware will either fail the command (if there is no device with the target id sent from driver) or could return the properties for a target which was not intended. Devices could end up with the wrong queue depth due to this.
Fix target id calculation for channel 1 and 3.
--- drivers/scsi/megaraid/megaraid_sas_base.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/megaraid/megaraid_sas_base.c +2 -1
@@ -5862,7 +5862,8 @@ megasas_get_target_prop(struct megasas_iint ret;struct megasas_cmd *cmd;struct megasas_dcmd_frame *dcmd; -u16 targetId = (sdev->channel %2 ) + sdev->id; +u16 targetId = ((sdev->channel %2 ) *MEGASAS_MAX_DEV_PER_CHANNEL ) + + sdev->id; cmd =megasas_get_cmd (instance);
Greg Kroah-Hartman
maintainerPATCH 170/271 scsi: mac_scsi: Increase PIO/PDMA transfer length threshold
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
commit 7398cee4c3e6aea1ba07a6449e5533ecd0b92cdd upstream.
Some targets introduce delays when handshaking the response to certain commands. For example, a disk may send a 96-byte response to an INQUIRY command (or a 24-byte response to a MODE SENSE command) too slowly.
Apparently the first 12 or 14 bytes are handshaked okay but then the system bus error timeout is reached while transferring the next word.
Since the scsi bus phase hasn't changed, the driver then sets the target borken flag to prevent further PDMA transfers. The driver also logs the warning, "switching to slow handshake".
Raise the PDMA threshold to 512 bytes so that PIO transfers will be used for these commands. This default is sufficiently low that PDMA will still be used for READ and WRITE commands.
The existing threshold (16 bytes) was chosen more or less at random. However, best performance requires the threshold to be as low as possible. Those systems that don't need the PIO workaround at all may benefit from mac_scsi.setup_use_pdma=1
--- drivers/scsi/mac_scsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mac_scsi.c +2 -2
@@ -52,7 +52,7 @@ static int setup_cmd_per_lun = -1;module_param (setup_cmd_per_lun, int,0 );static int setup_sg_tablesize =-1 ;module_param (setup_sg_tablesize, int,0 ); -static int setup_use_pdma =-1 ; +static int setup_use_pdma =512 ;module_param (setup_use_pdma, int,0 );static int setup_hostid =-1 ;module_param (setup_hostid, int,0 );
@@ -305,7 +305,7 @@ static int macscsi_dma_xfer_len(struct N struct scsi_cmnd *cmd) {if (hostdata->flags &FLAG_NO_PSEUDO_DMA || - cmd->SCp.this_residual <16 ) + cmd->SCp.this_residual < setup_use_pdma)return 0 ;return cmd->SCp.this_residual;
Greg Kroah-Hartman
maintainerPATCH 171/271 scsi: mac_scsi: Fix pseudo DMA implementation, take 2
In reply to Greg Kroah-HartmanFrom: Finn Thain <[email protected]>
commit 78ff751f8e6a9446e9fb26b2bff0b8d3f8974cbd upstream.
A system bus error during a PDMA transfer can mess up the calculation of the transfer residual (the PDMA handshaking hardware lacks a byte counter). This results in data corruption.
The algorithm in this patch anticipates a bus error by starting each transfer with a MOVE.B instruction. If a bus error is caught the transfer will be retried. If a bus error is caught later in the transfer (for a MOVE.W instruction) the transfer gets failed and subsequent requests for that target will use PIO instead of PDMA.
This avoids the "!REQ and !ACK" error so the severity level of that message is reduced to KERN_DEBUG.
--- drivers/scsi/mac_scsi.c | 369 ++++++++++++++++++++++++++++-------------------- 1 file changed, 217 insertions(+), 152 deletions(-)
drivers/scsi/mac_scsi.c +217 -152
@@ -3,6 +3,8 @@* * Copyright 1998, Michael Schmitz <[email protected]> * +* Copyright 2019 Finn Thain +* * derived in part from: */ /*
@@ -11,6 +13,7 @@* Copyright 1995, Russell King */ +#include <linux/delay.h> #include <linux/types.h> #include <linux/module.h> #include <linux/ioport.h>
@@ -89,101 +92,217 @@ static int __init mac_scsi_setup(char *s__setup ("mac5380=" , mac_scsi_setup);#endif /* !MODULE */ -/* Pseudo DMA asm originally by Ove Edlund */ +/* +* According to "Inside Macintosh: Devices", Mac OS requires disk drivers to +* specify the number of bytes between the delays expected from a SCSI target. +* This allows the operating system to "prevent bus errors when a target fails +* to deliver the next byte within the processor bus error timeout period." +* Linux SCSI drivers lack knowledge of the timing behaviour of SCSI targets +* so bus errors are unavoidable. +* +* If a MOVE.B instruction faults, we assume that zero bytes were transferred +* and simply retry. That assumption probably depends on target behaviour but +* seems to hold up okay. The NOP provides synchronization: without it the +* fault can sometimes occur after the program counter has moved past the +* offending instruction. Post-increment addressing can't be used. +*/ + +#define MOVE_BYTE (operands) \ + asm volatile ( \ + "1: moveb " operands " \n" \ + "11: nop \n" \ + " addq #1,%0 \n" \ + " subq #1,%1 \n" \ + "40: \n" \ + " \n" \ + ".section .fixup,\"ax\" \n" \ + ".even \n" \ + "90: movel #1, %2 \n" \ + " jra 40b \n" \ + ".previous \n" \ + " \n" \ + ".section __ex_table,\"a\" \n" \ + ".align 4 \n" \ + ".long 1b,90b \n" \ + ".long 11b,90b \n" \ + ".previous \n" \ + : "+a" (addr), "+r" (n), "+r" (result) : "a" (io)) -#define CP_IO_TO_MEM (s,d,n) \ -__asm__ __volatile__ \ - (" cmp.w #4,%2\n" \ - " bls 8f\n" \ - " move.w %1,%%d0\n" \ - " neg.b %%d0\n" \ - " and.w #3,%%d0\n" \ - " sub.w %%d0,%2\n" \ - " bra 2f\n" \ - " 1: move.b (%0),(%1)+\n" \ - " 2: dbf %%d0,1b\n" \ - " move.w %2,%%d0\n" \ - " lsr.w #5,%%d0\n" \ - " bra 4f\n" \ - " 3: move.l (%0),(%1)+\n" \ - "31: move.l (%0),(%1)+\n" \ - "32: move.l (%0),(%1)+\n" \ - "33: move.l (%0),(%1)+\n" \ - "34: move.l (%0),(%1)+\n" \ - "35: move.l (%0),(%1)+\n" \ - "36: move.l (%0),(%1)+\n" \ - "37: move.l (%0),(%1)+\n" \ - " 4: dbf %%d0,3b\n" \ - " move.w %2,%%d0\n" \ - " lsr.w #2,%%d0\n" \ - " and.w #7,%%d0\n" \ - " bra 6f\n" \ - " 5: move.l (%0),(%1)+\n" \ - " 6: dbf %%d0,5b\n" \ - " and.w #3,%2\n" \ - " bra 8f\n" \ - " 7: move.b (%0),(%1)+\n" \ - " 8: dbf %2,7b\n" \ - " moveq.l #0, %2\n" \ - " 9: \n" \ - ".section .fixup,\"ax\"\n" \ - " .even\n" \ - "91: moveq.l #1, %2\n" \ - " jra 9b\n" \ - "94: moveq.l #4, %2\n" \ - " jra 9b\n" \ - ".previous\n" \ - ".section __ex_table,\"a\"\n" \ - " .align 4\n" \ - " .long 1b,91b\n" \ - " .long 3b,94b\n" \ - " .long 31b,94b\n" \ - " .long 32b,94b\n" \ - " .long 33b,94b\n" \ - " .long 34b,94b\n" \ - " .long 35b,94b\n" \ - " .long 36b,94b\n" \ - " .long 37b,94b\n" \ - " .long 5b,94b\n" \ - " .long 7b,91b\n" \ - ".previous" \ - : "=a"(s), "=a"(d), "=d"(n) \ - : "0"(s), "1"(d), "2"(n) \ - : "d0") +/* +* If a MOVE.W (or MOVE.L) instruction faults, it cannot be retried because +* the residual byte count would be uncertain. In that situation the MOVE_WORD +* macro clears n in the fixup section to abort the transfer. +*/ + +#define MOVE_WORD (operands) \ + asm volatile ( \ + "1: movew " operands " \n" \ + "11: nop \n" \ + " subq #2,%1 \n" \ + "40: \n" \ + " \n" \ + ".section .fixup,\"ax\" \n" \ + ".even \n" \ + "90: movel #0, %1 \n" \ + " movel #2, %2 \n" \ + " jra 40b \n" \ + ".previous \n" \ + " \n" \ + ".section __ex_table,\"a\" \n" \ + ".align 4 \n" \ + ".long 1b,90b \n" \ + ".long 11b,90b \n" \ + ".previous \n" \ + : "+a" (addr), "+r" (n), "+r" (result) : "a" (io)) + +#define MOVE_16_WORDS (operands) \ + asm volatile ( \ + "1: movew " operands " \n" \ + "2: movew " operands " \n" \ + "3: movew " operands " \n" \ + "4: movew " operands " \n" \ + "5: movew " operands " \n" \ + "6: movew " operands " \n" \ + "7: movew " operands " \n" \ + "8: movew " operands " \n" \ + "9: movew " operands " \n" \ + "10: movew " operands " \n" \ + "11: movew " operands " \n" \ + "12: movew " operands " \n" \ + "13: movew " operands " \n" \ + "14: movew " operands " \n" \ + "15: movew " operands " \n" \ + "16: movew " operands " \n" \ + "17: nop \n" \ + " subl #32,%1 \n" \ + "40: \n" \ + " \n" \ + ".section .fixup,\"ax\" \n" \ + ".even \n" \ + "90: movel #0, %1 \n" \ + " movel #2, %2 \n" \ + " jra 40b \n" \ + ".previous \n" \ + " \n" \ + ".section __ex_table,\"a\" \n" \ + ".align 4 \n" \ + ".long 1b,90b \n" \ + ".long 2b,90b \n" \ + ".long 3b,90b \n" \ + ".long 4b,90b \n" \ + ".long 5b,90b \n" \ + ".long 6b,90b \n" \ + ".long 7b,90b \n" \ + ".long 8b,90b \n" \ + ".long 9b,90b \n" \ + ".long 10b,90b \n" \ + ".long 11b,90b \n" \ + ".long 12b,90b \n" \ + ".long 13b,90b \n" \ + ".long 14b,90b \n" \ + ".long 15b,90b \n" \ + ".long 16b,90b \n" \ + ".long 17b,90b \n" \ + ".previous \n" \ + : "+a" (addr), "+r" (n), "+r" (result) : "a" (io)) + +#define MAC_PDMA_DELAY 32 + +static inline int mac_pdma_recv (void __iomem *io,unsigned char *start,int n) +{ +unsigned char *addr = start; +int result =0 ; + +if (n >=1 ) { +MOVE_BYTE ("%3@,%0@" ); +if (result) + goto out; + } +if (n >=1 && ((unsigned long )addr &1 )) { +MOVE_BYTE ("%3@,%0@" ); +if (result) + goto out; + } +while (n >=32 ) +MOVE_16_WORDS ("%3@,%0@+" ); +while (n >=2 ) +MOVE_WORD ("%3@,%0@+" ); +if (result) +return start - addr;/* Negated to indicate uncertain length */ +if (n ==1 ) +MOVE_BYTE ("%3@,%0@" ); +out: +return addr - start; +} + +static inline int mac_pdma_send (unsigned char *start,void __iomem *io,int n) +{ +unsigned char *addr = start; +int result =0 ; + +if (n >=1 ) { +MOVE_BYTE ("%0@,%3@" ); +if (result) + goto out; + } +if (n >=1 && ((unsigned long )addr &1 )) { +MOVE_BYTE ("%0@,%3@" ); +if (result) + goto out; + } +while (n >=32 ) +MOVE_16_WORDS ("%0@+,%3@" ); +while (n >=2 ) +MOVE_WORD ("%0@+,%3@" ); +if (result) +return start - addr;/* Negated to indicate uncertain length */ +if (n ==1 ) +MOVE_BYTE ("%0@,%3@" ); +out: +return addr - start; +}static inline int macscsi_pread (struct NCR5380_hostdata *hostdata,unsigned char *dst,int len) {u8 __iomem *s = hostdata->pdma_io + (INPUT_DATA_REG <<4 );unsigned char *d = dst; -int n = len; -int transferred; + + hostdata->pdma_residual = len;while (!NCR5380_poll_politely (hostdata,BUS_AND_STATUS_REG ,BASR_DRQ |BASR_PHASE_MATCH ,BASR_DRQ |BASR_PHASE_MATCH ,HZ /64 )) { -CP_IO_TO_MEM (s, d, n); +int bytes; + + bytes =mac_pdma_recv (s, d,min (hostdata->pdma_residual,512 )); - transferred = d - dst - n; - hostdata->pdma_residual = len - transferred; +if (bytes >0 ) { + d += bytes; + hostdata->pdma_residual -= bytes; + } -/* No bus error. */ -if (n ==0 ) +if (hostdata->pdma_residual ==0 )return 0 ; -/* Target changed phase early? */ if (NCR5380_poll_politely2 (hostdata,STATUS_REG ,SR_REQ ,SR_REQ , -BUS_AND_STATUS_REG ,BASR_ACK ,BASR_ACK ,HZ /64 ) <0 ) -scmd_printk (KERN_ERR , hostdata->connected, +BUS_AND_STATUS_REG ,BASR_ACK , +BASR_ACK ,HZ /64 ) <0 ) +scmd_printk (KERN_DEBUG , hostdata->connected,"%s: !REQ and !ACK\n" , __func__);if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH ))return 0 ; +if (bytes ==0 ) +udelay (MAC_PDMA_DELAY ); + +if (bytes >=0 ) +continue ; +dsprintk (NDEBUG_PSEUDO_DMA , hostdata->host, -"%s: bus error (%d/%d)\n" , __func__, transferred, len); +"%s: bus error (%d/%d)\n" , __func__, d - dst, len);NCR5380_dprint (NDEBUG_PSEUDO_DMA , hostdata->host); - d = dst + transferred; - n = len - transferred; +return -1 ; } scmd_printk(KERN_ERR, hostdata->connected,
@@ -192,93 +311,27 @@ static inline int macscsi_pread(struct Nreturn -1 ; } - -#define CP_MEM_TO_IO (s,d,n) \ -__asm__ __volatile__ \ - (" cmp.w #4,%2\n" \ - " bls 8f\n" \ - " move.w %0,%%d0\n" \ - " neg.b %%d0\n" \ - " and.w #3,%%d0\n" \ - " sub.w %%d0,%2\n" \ - " bra 2f\n" \ - " 1: move.b (%0)+,(%1)\n" \ - " 2: dbf %%d0,1b\n" \ - " move.w %2,%%d0\n" \ - " lsr.w #5,%%d0\n" \ - " bra 4f\n" \ - " 3: move.l (%0)+,(%1)\n" \ - "31: move.l (%0)+,(%1)\n" \ - "32: move.l (%0)+,(%1)\n" \ - "33: move.l (%0)+,(%1)\n" \ - "34: move.l (%0)+,(%1)\n" \ - "35: move.l (%0)+,(%1)\n" \ - "36: move.l (%0)+,(%1)\n" \ - "37: move.l (%0)+,(%1)\n" \ - " 4: dbf %%d0,3b\n" \ - " move.w %2,%%d0\n" \ - " lsr.w #2,%%d0\n" \ - " and.w #7,%%d0\n" \ - " bra 6f\n" \ - " 5: move.l (%0)+,(%1)\n" \ - " 6: dbf %%d0,5b\n" \ - " and.w #3,%2\n" \ - " bra 8f\n" \ - " 7: move.b (%0)+,(%1)\n" \ - " 8: dbf %2,7b\n" \ - " moveq.l #0, %2\n" \ - " 9: \n" \ - ".section .fixup,\"ax\"\n" \ - " .even\n" \ - "91: moveq.l #1, %2\n" \ - " jra 9b\n" \ - "94: moveq.l #4, %2\n" \ - " jra 9b\n" \ - ".previous\n" \ - ".section __ex_table,\"a\"\n" \ - " .align 4\n" \ - " .long 1b,91b\n" \ - " .long 3b,94b\n" \ - " .long 31b,94b\n" \ - " .long 32b,94b\n" \ - " .long 33b,94b\n" \ - " .long 34b,94b\n" \ - " .long 35b,94b\n" \ - " .long 36b,94b\n" \ - " .long 37b,94b\n" \ - " .long 5b,94b\n" \ - " .long 7b,91b\n" \ - ".previous" \ - : "=a"(s), "=a"(d), "=d"(n) \ - : "0"(s), "1"(d), "2"(n) \ - : "d0") -static inline int macscsi_pwrite (struct NCR5380_hostdata *hostdata,unsigned char *src,int len) {unsigned char *s = src;u8 __iomem *d = hostdata->pdma_io + (OUTPUT_DATA_REG <<4 ); -int n = len; -int transferred; + + hostdata->pdma_residual = len;while (!NCR5380_poll_politely (hostdata,BUS_AND_STATUS_REG ,BASR_DRQ |BASR_PHASE_MATCH ,BASR_DRQ |BASR_PHASE_MATCH ,HZ /64 )) { -CP_MEM_TO_IO (s, d, n); +int bytes; - transferred = s - src - n; - hostdata->pdma_residual = len - transferred; + bytes =mac_pdma_send (s, d,min (hostdata->pdma_residual,512 )); -/* Target changed phase early? */ -if (NCR5380_poll_politely2 (hostdata,STATUS_REG ,SR_REQ ,SR_REQ , -BUS_AND_STATUS_REG ,BASR_ACK ,BASR_ACK ,HZ /64 ) <0 ) -scmd_printk (KERN_ERR , hostdata->connected, -"%s: !REQ and !ACK\n" , __func__); -if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH )) -return 0 ; +if (bytes >0 ) { + s += bytes; + hostdata->pdma_residual -= bytes; + } -/* No bus error. */ -if (n ==0 ) { +if (hostdata->pdma_residual ==0 ) {if (NCR5380_poll_politely (hostdata,TARGET_COMMAND_REG ,TCR_LAST_BYTE_SENT ,TCR_LAST_BYTE_SENT ,HZ /64 ) <0 )
@@ -287,17 +340,29 @@ static inline int macscsi_pwrite(structreturn 0 ; } +if (NCR5380_poll_politely2 (hostdata,STATUS_REG ,SR_REQ ,SR_REQ , +BUS_AND_STATUS_REG ,BASR_ACK , +BASR_ACK ,HZ /64 ) <0 ) +scmd_printk (KERN_DEBUG , hostdata->connected, +"%s: !REQ and !ACK\n" , __func__); +if (!(NCR5380_read (BUS_AND_STATUS_REG ) &BASR_PHASE_MATCH )) +return 0 ; + +if (bytes ==0 ) +udelay (MAC_PDMA_DELAY ); + +if (bytes >=0 ) +continue ; +dsprintk (NDEBUG_PSEUDO_DMA , hostdata->host, -"%s: bus error (%d/%d)\n" , __func__, transferred, len); +"%s: bus error (%d/%d)\n" , __func__, s - src, len);NCR5380_dprint (NDEBUG_PSEUDO_DMA , hostdata->host); - s = src + transferred; - n = len - transferred; +return -1 ; }scmd_printk (KERN_ERR , hostdata->connected,"%s: phase mismatch or !DRQ\n" , __func__);NCR5380_dprint (NDEBUG_PSEUDO_DMA , hostdata->host); -return -1 ; }
Greg Kroah-Hartman
maintainerPATCH 172/271 crypto: ghash - fix unaligned memory access in ghash_setkey()
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 5c6bc4dfa515738149998bb0db2481a4fdead979 upstream.
Changing ghash_mod_init() to be subsys_initcall made it start running before the alignment fault handler has been installed on ARM. In kernel builds where the keys in the ghash test vectors happened to be misaligned in the kernel image, this exposed the longstanding bug that ghash_setkey() is incorrectly casting the key buffer (which can have any alignment) to be128 for passing to gf128mul_init_4k_lle().
Fix this by memcpy()ing the key to a temporary buffer.
Don't fix it by setting an alignmask on the algorithm instead because that would unnecessarily force alignment of the data too.
--- crypto/ghash-generic.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
crypto/ghash-generic.c +7 -1
@@ -34,6 +34,7 @@ static int ghash_setkey(struct crypto_sh const u8 *key, unsigned int keylen) {struct ghash_ctx *ctx =crypto_shash_ctx (tfm); +be128 k;if (keylen !=GHASH_BLOCK_SIZE ) {crypto_shash_set_flags (tfm,CRYPTO_TFM_RES_BAD_KEY_LEN );
@@ -42,7 +43,12 @@ static int ghash_setkey(struct crypto_shif (ctx->gf128)gf128mul_free_4k (ctx->gf128); - ctx->gf128 =gf128mul_init_4k_lle ((be128 *)key); + +BUILD_BUG_ON (sizeof (k) !=GHASH_BLOCK_SIZE ); +memcpy (&k, key,GHASH_BLOCK_SIZE );/* avoid violating alignment rules */ + ctx->gf128 =gf128mul_init_4k_lle (&k); +memzero_explicit (&k,GHASH_BLOCK_SIZE ); +if (!ctx->gf128)return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 173/271 crypto: ccp - Validate the the error value used to index error messages
In reply to Greg Kroah-HartmanFrom: Hook, Gary <[email protected]>
commit 52393d617af7b554f03531e6756facf2ea687d2e upstream.
The error code read from the queue status register is only 6 bits wide, but we need to verify its value is within range before indexing the error messages.
--- drivers/crypto/ccp/ccp-dev.c | 96 ++++++++++++++++++++++--------------------- drivers/crypto/ccp/ccp-dev.h | 2 2 files changed, 52 insertions(+), 46 deletions(-)
drivers/crypto/ccp/ccp-dev.c +51 -45
@@ -35,56 +35,62 @@ struct ccp_tasklet_data { };/* Human-readable error strings */ +#define CCP_MAX_ERROR_CODE 64static char *ccp_error_codes[] = {"" , -"ERR 01: ILLEGAL_ENGINE" , -"ERR 02: ILLEGAL_KEY_ID" , -"ERR 03: ILLEGAL_FUNCTION_TYPE" , -"ERR 04: ILLEGAL_FUNCTION_MODE" , -"ERR 05: ILLEGAL_FUNCTION_ENCRYPT" , -"ERR 06: ILLEGAL_FUNCTION_SIZE" , -"ERR 07: Zlib_MISSING_INIT_EOM" , -"ERR 08: ILLEGAL_FUNCTION_RSVD" , -"ERR 09: ILLEGAL_BUFFER_LENGTH" , -"ERR 10: VLSB_FAULT" , -"ERR 11: ILLEGAL_MEM_ADDR" , -"ERR 12: ILLEGAL_MEM_SEL" , -"ERR 13: ILLEGAL_CONTEXT_ID" , -"ERR 14: ILLEGAL_KEY_ADDR" , -"ERR 15: 0xF Reserved" , -"ERR 16: Zlib_ILLEGAL_MULTI_QUEUE" , -"ERR 17: Zlib_ILLEGAL_JOBID_CHANGE" , -"ERR 18: CMD_TIMEOUT" , -"ERR 19: IDMA0_AXI_SLVERR" , -"ERR 20: IDMA0_AXI_DECERR" , -"ERR 21: 0x15 Reserved" , -"ERR 22: IDMA1_AXI_SLAVE_FAULT" , -"ERR 23: IDMA1_AIXI_DECERR" , -"ERR 24: 0x18 Reserved" , -"ERR 25: ZLIBVHB_AXI_SLVERR" , -"ERR 26: ZLIBVHB_AXI_DECERR" , -"ERR 27: 0x1B Reserved" , -"ERR 27: ZLIB_UNEXPECTED_EOM" , -"ERR 27: ZLIB_EXTRA_DATA" , -"ERR 30: ZLIB_BTYPE" , -"ERR 31: ZLIB_UNDEFINED_SYMBOL" , -"ERR 32: ZLIB_UNDEFINED_DISTANCE_S" , -"ERR 33: ZLIB_CODE_LENGTH_SYMBOL" , -"ERR 34: ZLIB _VHB_ILLEGAL_FETCH" , -"ERR 35: ZLIB_UNCOMPRESSED_LEN" , -"ERR 36: ZLIB_LIMIT_REACHED" , -"ERR 37: ZLIB_CHECKSUM_MISMATCH0" , -"ERR 38: ODMA0_AXI_SLVERR" , -"ERR 39: ODMA0_AXI_DECERR" , -"ERR 40: 0x28 Reserved" , -"ERR 41: ODMA1_AXI_SLVERR" , -"ERR 42: ODMA1_AXI_DECERR" , -"ERR 43: LSB_PARITY_ERR" , +"ILLEGAL_ENGINE" , +"ILLEGAL_KEY_ID" , +"ILLEGAL_FUNCTION_TYPE" , +"ILLEGAL_FUNCTION_MODE" , +"ILLEGAL_FUNCTION_ENCRYPT" , +"ILLEGAL_FUNCTION_SIZE" , +"Zlib_MISSING_INIT_EOM" , +"ILLEGAL_FUNCTION_RSVD" , +"ILLEGAL_BUFFER_LENGTH" , +"VLSB_FAULT" , +"ILLEGAL_MEM_ADDR" , +"ILLEGAL_MEM_SEL" , +"ILLEGAL_CONTEXT_ID" , +"ILLEGAL_KEY_ADDR" , +"0xF Reserved" , +"Zlib_ILLEGAL_MULTI_QUEUE" , +"Zlib_ILLEGAL_JOBID_CHANGE" , +"CMD_TIMEOUT" , +"IDMA0_AXI_SLVERR" , +"IDMA0_AXI_DECERR" , +"0x15 Reserved" , +"IDMA1_AXI_SLAVE_FAULT" , +"IDMA1_AIXI_DECERR" , +"0x18 Reserved" , +"ZLIBVHB_AXI_SLVERR" , +"ZLIBVHB_AXI_DECERR" , +"0x1B Reserved" , +"ZLIB_UNEXPECTED_EOM" , +"ZLIB_EXTRA_DATA" , +"ZLIB_BTYPE" , +"ZLIB_UNDEFINED_SYMBOL" , +"ZLIB_UNDEFINED_DISTANCE_S" , +"ZLIB_CODE_LENGTH_SYMBOL" , +"ZLIB _VHB_ILLEGAL_FETCH" , +"ZLIB_UNCOMPRESSED_LEN" , +"ZLIB_LIMIT_REACHED" , +"ZLIB_CHECKSUM_MISMATCH0" , +"ODMA0_AXI_SLVERR" , +"ODMA0_AXI_DECERR" , +"0x28 Reserved" , +"ODMA1_AXI_SLVERR" , +"ODMA1_AXI_DECERR" , }; -void ccp_log_error (struct ccp_device *d,int e) +void ccp_log_error (struct ccp_device *d,unsigned int e) { -dev_err (d->dev,"CCP error: %s (0x%x)\n" , ccp_error_codes[e], e); +if (WARN_ON (e >=CCP_MAX_ERROR_CODE )) +return ; + +if (e <ARRAY_SIZE (ccp_error_codes)) +dev_err (d->dev,"CCP error %d: %s\n" , e, ccp_error_codes[e]); +else +dev_err (d->dev,"CCP error %d: Unknown Error\n" , e); }/* List of CCPs, CCP count, read-write access lock, and access functions
drivers/crypto/ccp/ccp-dev.h +1 -1
@@ -632,7 +632,7 @@ struct ccp5_desc {void ccp_add_device (struct ccp_device *ccp);void ccp_del_device (struct ccp_device *ccp); -extern void ccp_log_error (struct ccp_device *,int ); +extern void ccp_log_error (struct ccp_device *,unsigned int );struct ccp_device *ccp_alloc_struct (struct sp_device *sp);bool ccp_queues_suspended (struct ccp_device *ccp);
Greg Kroah-Hartman
maintainerPATCH 174/271 crypto: arm64/sha1-ce - correct digest for empty data in finup
In reply to Greg Kroah-HartmanFrom: Elena Petrova <[email protected]>
commit 1d4aaf16defa86d2665ae7db0259d6cb07e2091f upstream.
The sha1-ce finup implementation for ARM64 produces wrong digest for empty input (len=0). Expected: da39a3ee..., result: 67452301... (initial value of SHA internal state). The error is in sha1_ce_finup:
for empty data finalize will be 1, so the code is relying on sha1_ce_transform to make the final round. However, in sha1_base_do_update, the block function will not be called when len == 0.
Fix it by setting finalize to 0 if data is empty.
--- arch/arm64/crypto/sha1-ce-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/crypto/sha1-ce-glue.c +1 -1
@@ -54,7 +54,7 @@ static int sha1_ce_finup(struct shash_de unsigned int len, u8 *out) { struct sha1_ce_state *sctx = shash_desc_ctx(desc); -bool finalize = !sctx->sst.count && !(len %SHA1_BLOCK_SIZE ); +bool finalize = !sctx->sst.count && !(len %SHA1_BLOCK_SIZE ) && len;if (!may_use_simd ())return crypto_sha1_finup (desc, data, len, out);
Greg Kroah-Hartman
maintainerPATCH 175/271 crypto: arm64/sha2-ce - correct digest for empty data in finup
In reply to Greg Kroah-HartmanFrom: Elena Petrova <[email protected]>
commit 6bd934de1e393466b319d29c4427598fda096c57 upstream.
The sha256-ce finup implementation for ARM64 produces wrong digest for empty input (len=0). Expected: the actual digest, result: initial value of SHA internal state. The error is in sha256_ce_finup:
for empty data finalize will be 1, so the code is relying on sha2_ce_transform to make the final round. However, in sha256_base_do_update, the block function will not be called when len == 0.
Fix it by setting finalize to 0 if data is empty.
--- arch/arm64/crypto/sha2-ce-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/crypto/sha2-ce-glue.c +1 -1
@@ -59,7 +59,7 @@ static int sha256_ce_finup(struct shash_ unsigned int len, u8 *out) { struct sha256_ce_state *sctx = shash_desc_ctx(desc); -bool finalize = !sctx->sst.count && !(len %SHA256_BLOCK_SIZE ); +bool finalize = !sctx->sst.count && !(len %SHA256_BLOCK_SIZE ) && len;if (!may_use_simd ()) {if (len)
Greg Kroah-Hartman
maintainerPATCH 176/271 crypto: chacha20poly1305 - fix atomic sleep when using async algorithm
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 7545b6c2087f4ef0287c8c9b7eba6a728c67ff8e upstream.
Clear the CRYPTO_TFM_REQ_MAY_SLEEP flag when the chacha20poly1305 operation is being continued from an async completion callback, since sleeping may not be allowed in that context.
This is basically the same bug that was recently fixed in the xts and lrw templates. But, it's always been broken in chacha20poly1305 too. This was found using syzkaller in combination with the updated crypto self-tests which actually test the MAY_SLEEP flag now.
Reproducer:
python -c 'import socket; socket.socket(socket.AF_ALG, 5, 0).bind(
("aead", "rfc7539(cryptd(chacha20-generic),poly1305-generic)"))'Kernel output:
BUG: sleeping function called from invalid context at include/crypto/algapi.h:426
in_atomic(): 1, irqs_disabled(): 0, pid: 1001, name: kworker/2:2
[...]
CPU: 2 PID: 1001 Comm: kworker/2:2 Not tainted 5.2.0-rc2 #5
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-20181126_142135-anatol 04/01/2014
Workqueue: crypto cryptd_queue_worker
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x4d/0x6a lib/dump_stack.c:113
___might_sleep kernel/sched/core.c:6138 [inline]
___might_sleep.cold.19+0x8e/0x9f kernel/sched/core.c:6095
crypto_yield include/crypto/algapi.h:426 [inline]
crypto_hash_walk_done+0xd6/0x100 crypto/ahash.c:113
shash_ahash_update+0x41/0x60 crypto/shash.c:251
shash_async_update+0xd/0x10 crypto/shash.c:260
crypto_ahash_update include/crypto/hash.h:539 [inline]
poly_setkey+0xf6/0x130 crypto/chacha20poly1305.c:337
poly_init+0x51/0x60 crypto/chacha20poly1305.c:364
async_done_continue crypto/chacha20poly1305.c:78 [inline]
poly_genkey_done+0x15/0x30 crypto/chacha20poly1305.c:369
cryptd_skcipher_complete+0x29/0x70 crypto/cryptd.c:279
cryptd_skcipher_decrypt+0xcd/0x110 crypto/cryptd.c:339
cryptd_queue_worker+0x70/0xa0 crypto/cryptd.c:184
process_one_work+0x1ed/0x420 kernel/workqueue.c:2269
worker_thread+0x3e/0x3a0 kernel/workqueue.c:2415
kthread+0x11f/0x140 kernel/kthread.c:255
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352--- crypto/chacha20poly1305.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
crypto/chacha20poly1305.c +19 -11
@@ -67,6 +67,8 @@ struct chachapoly_req_ctx {unsigned int cryptlen;/* Actual AD, excluding IV */ unsigned int assoclen; +/* request flags, with MAY_SLEEP cleared if needed */ +u32 flags;union {struct poly_req poly;struct chacha_req chacha;
@@ -76,8 +78,12 @@ struct chachapoly_req_ctx {static inline void async_done_continue (struct aead_request *req,int err,int (*cont)(struct aead_request *)) { -if (!err) +if (!err) { +struct chachapoly_req_ctx *rctx =aead_request_ctx (req); + + rctx->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP ; err =cont (req); + }if (err != -EINPROGRESS && err != -EBUSY )aead_request_complete (req, err);
@@ -144,7 +150,7 @@ static int chacha_decrypt(struct aead_re dst =scatterwalk_ffwd (rctx->dst, req->dst, req->assoclen); } -skcipher_request_set_callback (&creq->req,aead_request_flags (req), +skcipher_request_set_callback (&creq->req, rctx->flags, chacha_decrypt_done, req);skcipher_request_set_tfm (&creq->req, ctx->chacha); skcipher_request_set_crypt(&creq->req, src, dst,
@@ -188,7 +194,7 @@ static int poly_tail(struct aead_requestmemcpy (&preq->tail.cryptlen, &len,sizeof (len));sg_set_buf (preq->src, &preq->tail,sizeof (preq->tail)); -ahash_request_set_callback (&preq->req,aead_request_flags (req), +ahash_request_set_callback (&preq->req, rctx->flags, poly_tail_done, req);ahash_request_set_tfm (&preq->req, ctx->poly); ahash_request_set_crypt(&preq->req, preq->src,
@@ -219,7 +225,7 @@ static int poly_cipherpad(struct aead_resg_init_table (preq->src,1 );sg_set_buf (preq->src, &preq->pad, padlen); -ahash_request_set_callback (&preq->req,aead_request_flags (req), +ahash_request_set_callback (&preq->req, rctx->flags, poly_cipherpad_done, req);ahash_request_set_tfm (&preq->req, ctx->poly);ahash_request_set_crypt (&preq->req, preq->src,NULL , padlen);
@@ -250,7 +256,7 @@ static int poly_cipher(struct aead_requesg_init_table (rctx->src,2 ); crypt =scatterwalk_ffwd (rctx->src, crypt, req->assoclen); -ahash_request_set_callback (&preq->req,aead_request_flags (req), +ahash_request_set_callback (&preq->req, rctx->flags, poly_cipher_done, req);ahash_request_set_tfm (&preq->req, ctx->poly);ahash_request_set_crypt (&preq->req, crypt,NULL , rctx->cryptlen);
@@ -280,7 +286,7 @@ static int poly_adpad(struct aead_requessg_init_table (preq->src,1 );sg_set_buf (preq->src, preq->pad, padlen); -ahash_request_set_callback (&preq->req,aead_request_flags (req), +ahash_request_set_callback (&preq->req, rctx->flags, poly_adpad_done, req);ahash_request_set_tfm (&preq->req, ctx->poly);ahash_request_set_crypt (&preq->req, preq->src,NULL , padlen);
@@ -304,7 +310,7 @@ static int poly_ad(struct aead_request *struct poly_req *preq = &rctx->u.poly;int err; -ahash_request_set_callback (&preq->req,aead_request_flags (req), +ahash_request_set_callback (&preq->req, rctx->flags, poly_ad_done, req);ahash_request_set_tfm (&preq->req, ctx->poly);ahash_request_set_crypt (&preq->req, req->src,NULL , rctx->assoclen);
@@ -331,7 +337,7 @@ static int poly_setkey(struct aead_requesg_init_table (preq->src,1 );sg_set_buf (preq->src, rctx->key,sizeof (rctx->key)); -ahash_request_set_callback (&preq->req,aead_request_flags (req), +ahash_request_set_callback (&preq->req, rctx->flags, poly_setkey_done, req);ahash_request_set_tfm (&preq->req, ctx->poly);ahash_request_set_crypt (&preq->req, preq->src,NULL ,sizeof (rctx->key));
@@ -355,7 +361,7 @@ static int poly_init(struct aead_requeststruct poly_req *preq = &rctx->u.poly;int err; -ahash_request_set_callback (&preq->req,aead_request_flags (req), +ahash_request_set_callback (&preq->req, rctx->flags, poly_init_done, req);ahash_request_set_tfm (&preq->req, ctx->poly);
@@ -393,7 +399,7 @@ static int poly_genkey(struct aead_requechacha_iv (creq->iv, req,0 ); -skcipher_request_set_callback (&creq->req,aead_request_flags (req), +skcipher_request_set_callback (&creq->req, rctx->flags, poly_genkey_done, req);skcipher_request_set_tfm (&creq->req, ctx->chacha); skcipher_request_set_crypt(&creq->req, creq->src, creq->src,
@@ -433,7 +439,7 @@ static int chacha_encrypt(struct aead_re dst =scatterwalk_ffwd (rctx->dst, req->dst, req->assoclen); } -skcipher_request_set_callback (&creq->req,aead_request_flags (req), +skcipher_request_set_callback (&creq->req, rctx->flags, chacha_encrypt_done, req);skcipher_request_set_tfm (&creq->req, ctx->chacha); skcipher_request_set_crypt(&creq->req, src, dst,
@@ -451,6 +457,7 @@ static int chachapoly_encrypt(struct aeastruct chachapoly_req_ctx *rctx =aead_request_ctx (req); rctx->cryptlen = req->cryptlen; + rctx->flags =aead_request_flags (req);/* encrypt call chain: * - chacha_encrypt/done()
@@ -472,6 +479,7 @@ static int chachapoly_decrypt(struct aeastruct chachapoly_req_ctx *rctx =aead_request_ctx (req); rctx->cryptlen = req->cryptlen -POLY1305_DIGEST_SIZE ; + rctx->flags =aead_request_flags (req);/* decrypt call chain: * - poly_genkey/done()
Greg Kroah-Hartman
maintainerPATCH 177/271 crypto: crypto4xx - fix AES CTR blocksize value
In reply to Greg Kroah-HartmanFrom: Christian Lamparter <[email protected]>
commit bfa2ba7d9e6b20aca82b99e6842fe18842ae3a0f upstream.
This patch fixes a issue with crypto4xx's ctr(aes) that was discovered by libcapi's kcapi-enc-test.sh test.
The some of the ctr(aes) encryptions test were failing on the non-power-of-two test:
kcapi-enc - Error: encryption failed with error 0
kcapi-enc - Error: decryption failed with error 0
[FAILED: 32-bit - 5.1.0-rc1+] 15 bytes: STDIN / STDOUT enc test (128 bits):
original file (1d100e..cc96184c) and generated file (e3b0c442..1b7852b855) [FAILED: 32-bit - 5.1.0-rc1+] 15 bytes: STDIN / STDOUT enc test (128 bits) (openssl generated CT): original file (e3b0..5) and generated file (3..8e) [PASSED: 32-bit - 5.1.0-rc1+] 15 bytes: STDIN / STDOUT enc test (128 bits) (openssl generated PT)
[FAILED: 32-bit - 5.1.0-rc1+] 15 bytes: STDIN / STDOUT enc test (password):
original file (1d1..84c) and generated file (e3b..852b855)
But the 16, 32, 512, 65536 tests always worked.
Thankfully, this isn't a hidden hardware problem like previously, instead this turned out to be a copy and paste issue.
With this patch, all the tests are passing with and kcapi-enc-test.sh gives crypto4xx's a clean bill of health:
"Number of failures: 0" :).
--- drivers/crypto/amcc/crypto4xx_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/amcc/crypto4xx_core.c +2 -2
@@ -1186,7 +1186,7 @@ static struct crypto4xx_alg_common crypt .cra_flags = CRYPTO_ALG_NEED_FALLBACK |CRYPTO_ALG_ASYNC | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = AES_BLOCK_SIZE, + .cra_blocksize = 1, .cra_ctxsize = sizeof(struct crypto4xx_ctx), .cra_module = THIS_MODULE, },
@@ -1206,7 +1206,7 @@ static struct crypto4xx_alg_common crypt .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY, .cra_flags =CRYPTO_ALG_ASYNC | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = AES_BLOCK_SIZE, + .cra_blocksize = 1, .cra_ctxsize = sizeof(struct crypto4xx_ctx), .cra_module = THIS_MODULE, },
Greg Kroah-Hartman
maintainerPATCH 178/271 crypto: crypto4xx - fix blocksize for cfb and ofb
In reply to Greg Kroah-HartmanFrom: Christian Lamparter <[email protected]>
commit 70c4997f34b6c6888b3ac157adec49e01d0df2d5 upstream.
While the hardware consider them to be blockciphers, the reference implementation defines them as streamciphers.
Do the right thing and set the blocksize to 1. This was found by CONFIG_CRYPTO_MANAGER_EXTRA_TESTS.
This fixes the following issues:
skcipher: blocksize for ofb-aes-ppc4xx (16) doesn't match generic impl (1)
skcipher: blocksize for cfb-aes-ppc4xx (16) doesn't match generic impl (1)
--- drivers/crypto/amcc/crypto4xx_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/amcc/crypto4xx_core.c +2 -2
@@ -1226,7 +1226,7 @@ static struct crypto4xx_alg_common crypt .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY, .cra_flags =CRYPTO_ALG_ASYNC | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = AES_BLOCK_SIZE, + .cra_blocksize = 1, .cra_ctxsize = sizeof(struct crypto4xx_ctx), .cra_module = THIS_MODULE, },
@@ -1245,7 +1245,7 @@ static struct crypto4xx_alg_common crypt .cra_priority = CRYPTO4XX_CRYPTO_PRIORITY, .cra_flags =CRYPTO_ALG_ASYNC | CRYPTO_ALG_KERN_DRIVER_ONLY, - .cra_blocksize = AES_BLOCK_SIZE, + .cra_blocksize = 1, .cra_ctxsize = sizeof(struct crypto4xx_ctx), .cra_module = THIS_MODULE, },
Greg Kroah-Hartman
maintainerPATCH 179/271 crypto: crypto4xx - block ciphers should only accept complete blocks
In reply to Greg Kroah-HartmanFrom: Christian Lamparter <[email protected]>
commit 0f7a81374060828280fcfdfbaa162cb559017f9f upstream.
The hardware automatically zero pads incomplete block ciphers blocks without raising any errors. This is a screw-up. This was noticed by CONFIG_CRYPTO_MANAGER_EXTRA_TESTS tests that sent a incomplete blocks and expect them to fail.
This fixes:
cbc-aes-ppc4xx encryption unexpectedly succeeded on test vector "random: len=2409 klen=32"; expected_error=-22, cfg="random:may_sleep use_digest src_divs=[96.90%@+2295, 2.34%@+4066, 0.32%@alignmask+12, 0.34%@+4087, 0.9%@alignmask+1787, 0.1%@+3767] iv_offset=6"
ecb-aes-ppc4xx encryption unexpectedly succeeded on test vector "random: len=1011 klen=32"; expected_error=-22, cfg="random:may_sleep use_digest src_divs=[100.0%@alignmask+20] dst_divs=[3.12%@+3001, 96.88%@+4070]"
--- drivers/crypto/amcc/crypto4xx_alg.c | 36 ++++++++++++++++++++++++----------- drivers/crypto/amcc/crypto4xx_core.c | 16 +++++++-------- drivers/crypto/amcc/crypto4xx_core.h | 10 +++++---- 3 files changed, 39 insertions(+), 23 deletions(-)
drivers/crypto/amcc/crypto4xx_alg.c +25 -11
@@ -76,12 +76,16 @@ static void set_dynamic_sa_command_1(str }static inline int crypto4xx_crypt (struct skcipher_request *req, -const unsigned int ivlen,bool decrypt) +const unsigned int ivlen,bool decrypt, +bool check_blocksize) {struct crypto_skcipher *cipher =crypto_skcipher_reqtfm (req);struct crypto4xx_ctx *ctx =crypto_skcipher_ctx (cipher);__le32 iv[AES_IV_SIZE ]; +if (check_blocksize && !IS_ALIGNED (req->cryptlen,AES_BLOCK_SIZE )) +return -EINVAL ; +if (ivlen)crypto4xx_memcpy_to_le32 (iv, req->iv, ivlen);
@@ -90,24 +94,34 @@ static inline int crypto4xx_crypt(struct ctx->sa_len, 0, NULL); } -int crypto4xx_encrypt_noiv (struct skcipher_request *req) +int crypto4xx_encrypt_noiv_block (struct skcipher_request *req) +{ +return crypto4xx_crypt (req,0 , false, true); +} + +int crypto4xx_encrypt_iv_stream (struct skcipher_request *req) +{ +return crypto4xx_crypt (req,AES_IV_SIZE , false, false); +} + +int crypto4xx_decrypt_noiv_block (struct skcipher_request *req) { -return crypto4xx_crypt (req,0 , false); +return crypto4xx_crypt (req,0 , true, true); } -int crypto4xx_encrypt_iv (struct skcipher_request *req) +int crypto4xx_decrypt_iv_stream (struct skcipher_request *req) { -return crypto4xx_crypt (req,AES_IV_SIZE , false); +return crypto4xx_crypt (req,AES_IV_SIZE , true, false); } -int crypto4xx_decrypt_noiv (struct skcipher_request *req) +int crypto4xx_encrypt_iv_block (struct skcipher_request *req) { -return crypto4xx_crypt (req,0 , true); +return crypto4xx_crypt (req,AES_IV_SIZE , false, true); } -int crypto4xx_decrypt_iv (struct skcipher_request *req) +int crypto4xx_decrypt_iv_block (struct skcipher_request *req) { -return crypto4xx_crypt (req,AES_IV_SIZE , true); +return crypto4xx_crypt (req,AES_IV_SIZE , true, true); }/**
@@ -278,8 +292,8 @@ crypto4xx_ctr_crypt(struct skcipher_requreturn ret; } -return encrypt ?crypto4xx_encrypt_iv (req) - :crypto4xx_decrypt_iv (req); +return encrypt ?crypto4xx_encrypt_iv_stream (req) + :crypto4xx_decrypt_iv_stream (req); } static int crypto4xx_sk_setup_fallback(struct crypto4xx_ctx *ctx,
drivers/crypto/amcc/crypto4xx_core.c +8 -8
@@ -1153,8 +1153,8 @@ static struct crypto4xx_alg_common crypt .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_IV_SIZE, .setkey = crypto4xx_setkey_aes_cbc, - .encrypt = crypto4xx_encrypt_iv, - .decrypt = crypto4xx_decrypt_iv, + .encrypt = crypto4xx_encrypt_iv_block, + .decrypt = crypto4xx_decrypt_iv_block, .init = crypto4xx_sk_init, .exit = crypto4xx_sk_exit, } },
@@ -1173,8 +1173,8 @@ static struct crypto4xx_alg_common crypt .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_IV_SIZE, .setkey = crypto4xx_setkey_aes_cfb, - .encrypt = crypto4xx_encrypt_iv, - .decrypt = crypto4xx_decrypt_iv, + .encrypt = crypto4xx_encrypt_iv_stream, + .decrypt = crypto4xx_decrypt_iv_stream, .init = crypto4xx_sk_init, .exit = crypto4xx_sk_exit, } },
@@ -1233,8 +1233,8 @@ static struct crypto4xx_alg_common crypt .min_keysize = AES_MIN_KEY_SIZE, .max_keysize = AES_MAX_KEY_SIZE, .setkey = crypto4xx_setkey_aes_ecb, - .encrypt = crypto4xx_encrypt_noiv, - .decrypt = crypto4xx_decrypt_noiv, + .encrypt = crypto4xx_encrypt_noiv_block, + .decrypt = crypto4xx_decrypt_noiv_block, .init = crypto4xx_sk_init, .exit = crypto4xx_sk_exit, } },
@@ -1253,8 +1253,8 @@ static struct crypto4xx_alg_common crypt .max_keysize = AES_MAX_KEY_SIZE, .ivsize = AES_IV_SIZE, .setkey = crypto4xx_setkey_aes_ofb, - .encrypt = crypto4xx_encrypt_iv, - .decrypt = crypto4xx_decrypt_iv, + .encrypt = crypto4xx_encrypt_iv_stream, + .decrypt = crypto4xx_decrypt_iv_stream, .init = crypto4xx_sk_init, .exit = crypto4xx_sk_exit, } },
drivers/crypto/amcc/crypto4xx_core.h +6 -4
@@ -179,10 +179,12 @@ int crypto4xx_setkey_rfc3686(struct cryp const u8 *key, unsigned int keylen);int crypto4xx_encrypt_ctr (struct skcipher_request *req);int crypto4xx_decrypt_ctr (struct skcipher_request *req); -int crypto4xx_encrypt_iv (struct skcipher_request *req); -int crypto4xx_decrypt_iv (struct skcipher_request *req); -int crypto4xx_encrypt_noiv (struct skcipher_request *req); -int crypto4xx_decrypt_noiv (struct skcipher_request *req); +int crypto4xx_encrypt_iv_stream (struct skcipher_request *req); +int crypto4xx_decrypt_iv_stream (struct skcipher_request *req); +int crypto4xx_encrypt_iv_block (struct skcipher_request *req); +int crypto4xx_decrypt_iv_block (struct skcipher_request *req); +int crypto4xx_encrypt_noiv_block (struct skcipher_request *req); +int crypto4xx_decrypt_noiv_block (struct skcipher_request *req);int crypto4xx_rfc3686_encrypt (struct skcipher_request *req);int crypto4xx_rfc3686_decrypt (struct skcipher_request *req);int crypto4xx_sha1_alg_init (struct crypto_tfm *tfm);
Greg Kroah-Hartman
maintainerPATCH 180/271 crypto: ccp - memset structure fields to zero before reuse
In reply to Greg Kroah-HartmanFrom: Hook, Gary <[email protected]>
commit 20e833dc36355ed642d00067641a679c618303fa upstream.
The AES GCM function reuses an 'op' data structure, which members contain values that must be cleared for each (re)use.
This fix resolves a crypto self-test failure:
alg: aead: gcm-aes-ccp encryption test failed (wrong result) on test vector 2, cfg="two even aligned splits"
--- drivers/crypto/ccp/ccp-ops.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/crypto/ccp/ccp-ops.c +11 -1
@@ -625,6 +625,7 @@ static int ccp_run_aes_gcm_cmd(struct ccunsigned long long *final;unsigned int dm_offset; +unsigned int jobid;unsigned int ilen;bool in_place = true;/* Default value */ int ret;
@@ -663,9 +664,11 @@ static int ccp_run_aes_gcm_cmd(struct cc p_tag =scatterwalk_ffwd (sg_tag, p_inp, ilen); } + jobid =CCP_NEW_JOBID (cmd_q->ccp); +memset (&op,0 ,sizeof (op)); op.cmd_q = cmd_q; - op.jobid =CCP_NEW_JOBID (cmd_q->ccp); + op.jobid = jobid; op.sb_key = cmd_q->sb_key;/* Pre-allocated */ op.sb_ctx = cmd_q->sb_ctx;/* Pre-allocated */ op.init =1 ;
@@ -816,6 +819,13 @@ static int ccp_run_aes_gcm_cmd(struct cc final[0 ] =cpu_to_be64 (aes->aad_len *8 ); final[1 ] =cpu_to_be64 (ilen *8 ); +memset (&op,0 ,sizeof (op)); + op.cmd_q = cmd_q; + op.jobid = jobid; + op.sb_key = cmd_q->sb_key;/* Pre-allocated */ + op.sb_ctx = cmd_q->sb_ctx;/* Pre-allocated */ + op.init =1 ; + op.u.aes.type = aes->type; op.u.aes.mode =CCP_AES_MODE_GHASH ; op.u.aes.action =CCP_AES_GHASHFINAL ; op.src.type =CCP_MEMTYPE_SYSTEM ;
Greg Kroah-Hartman
maintainerPATCH 181/271 crypto: ccp/gcm - use const time tag comparison.
In reply to Greg Kroah-HartmanFrom: Cfir Cohen <[email protected]>
commit 538a5a072e6ef04377b180ee9b3ce5bae0a85da4 upstream.
Avoid leaking GCM tag through timing side channel.
--- drivers/crypto/ccp/ccp-ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/ccp/ccp-ops.c +2 -1
@@ -853,7 +853,8 @@ static int ccp_run_aes_gcm_cmd(struct ccif (ret) goto e_tag; - ret =memcmp (tag.address, final_wa.address,AES_BLOCK_SIZE ); + ret =crypto_memneq (tag.address, final_wa.address, +AES_BLOCK_SIZE ) ? -EBADMSG :0 ;ccp_dm_free (&tag); }
Greg Kroah-Hartman
maintainerPATCH 182/271 crypto: crypto4xx - fix a potential double free in ppc4xx_trng_probe
In reply to Greg Kroah-HartmanFrom: Wen Yang <[email protected]>
commit 95566aa75cd6b3b404502c06f66956b5481194b3 upstream.
There is a possible double free issue in ppc4xx_trng_probe():
85: dev->trng_base = of_iomap(trng, 0);
86: of_node_put(trng); ---> released here
87: if (!dev->trng_base)
88: goto err_out;
...
110: ierr_out:
111: of_node_put(trng); ---> double released here
...
This issue was detected by using the Coccinelle software. We fix it by removing the unnecessary of_node_put().
--- drivers/crypto/amcc/crypto4xx_trng.c | 1 - 1 file changed, 1 deletion(-)
drivers/crypto/amcc/crypto4xx_trng.c +0 -1
@@ -111,7 +111,6 @@ void ppc4xx_trng_probe(struct crypto4xx_return ; err_out: -of_node_put (trng);iounmap (dev->trng_base);kfree (rng); dev->trng_base =NULL ;
Greg Kroah-Hartman
maintainerPATCH 183/271 Revert "bcache: set CACHE_SET_IO_DISABLE in bch_cached_dev_error()"
In reply to Greg Kroah-HartmanFrom: Coly Li <[email protected]>
commit 695277f16b3a102fcc22c97fdf2de77c7b19f0b3 upstream.
This reverts commit 6147305c73e4511ca1a975b766b97a779d442567.
Although this patch helps the failed bcache device to stop faster when too many I/O errors detected on corresponding cached device, setting CACHE_SET_IO_DISABLE bit to cache set c->flags was not a good idea. This operation will disable all I/Os on cache set, which means other attached bcache devices won't work neither.
Without this patch, the failed bcache device can also be stopped eventually if internal I/O accomplished (e.g. writeback). Therefore here I revert it.
--- drivers/md/bcache/super.c | 17 ----------------- 1 file changed, 17 deletions(-)
drivers/md/bcache/super.c +0 -17
@@ -1423,8 +1423,6 @@ int bch_flash_dev_create(struct cache_sebool bch_cached_dev_error (struct cached_dev *dc) { -struct cache_set *c; -if (!dc ||test_bit (BCACHE_DEV_CLOSING , &dc->disk.flags))return false;
@@ -1435,21 +1433,6 @@ bool bch_cached_dev_error(struct cached_pr_err ("stop %s: too many IO errors on backing device %s\n" , dc->disk.disk->disk_name, dc->backing_dev_name); -/* -* If the cached device is still attached to a cache set, -* even dc->io_disable is true and no more I/O requests -* accepted, cache device internal I/O (writeback scan or -* garbage collection) may still prevent bcache device from -* being stopped. So here CACHE_SET_IO_DISABLE should be -* set to c->flags too, to make the internal I/O to cache -* device rejected and stopped immediately. -* If c is NULL, that means the bcache device is not attached -* to any cache set, then no CACHE_SET_IO_DISABLE bit to set. -*/ - c = dc->disk.c; -if (c &&test_and_set_bit (CACHE_SET_IO_DISABLE , &c->flags)) -pr_info ("CACHE_SET_IO_DISABLE already set" ); -bcache_device_stop (&dc->disk);return true; }
Greg Kroah-Hartman
maintainerPATCH 184/271 bcache: Revert "bcache: fix high CPU occupancy during journal"
In reply to Greg Kroah-HartmanFrom: Coly Li <[email protected]>
commit 249a5f6da57c28a903c75d81505d58ec8c10030d upstream.
This reverts commit c4dc2497d50d9c6fb16aa0d07b6a14f3b2adb1e0.
This patch enlarges a race between normal btree flush code path and flush_btree_write(), which causes deadlock when journal space is exhausted. Reverts this patch makes the race window from 128 btree nodes to only 1 btree nodes.
--- drivers/md/bcache/bcache.h | 2 - drivers/md/bcache/journal.c | 47 ++++++++++++++------------------------------ drivers/md/bcache/util.h | 2 - 3 files changed, 15 insertions(+), 36 deletions(-)
drivers/md/bcache/bcache.h +0 -2
@@ -708,8 +708,6 @@ struct cache_set {#define BUCKET_HASH_BITS 12struct hlist_head bucket_hash[1 <<BUCKET_HASH_BITS ]; - - DECLARE_HEAP(struct btree *, flush_btree); };struct bbio {
drivers/md/bcache/journal.c +15 -32
70 lines not on this page · raw message
drivers/md/bcache/util.h +0 -2
@@ -113,8 +113,6 @@ do { \#define heap_full (h) ((h)->used == (h)->size) -#define heap_empty (h) ((h)->used == 0) -#define DECLARE_FIFO (type, name) \ struct { \ size_t front, back, size, mask; \
Greg Kroah-Hartman
maintainerPATCH 185/271 bcache: Revert "bcache: free heap cache_set->flush_btree in bch_journal_free"
In reply to Greg Kroah-HartmanFrom: Coly Li <[email protected]>
commit ba82c1ac1667d6efb91a268edb13fc9cdaecec9b upstream.
This reverts commit 6268dc2c4703aabfb0b35681be709acf4c2826c6.
This patch depends on commit c4dc2497d50d ("bcache: fix high CPU occupancy during journal") which is reverted in previous patch. So revert this one too.
--- drivers/md/bcache/journal.c | 1 - 1 file changed, 1 deletion(-)
drivers/md/bcache/journal.c +0 -1
@@ -842,7 +842,6 @@ void bch_journal_free(struct cache_set *free_pages ((unsigned long ) c->journal.w[1 ].data,JSET_BITS );free_pages ((unsigned long ) c->journal.w[0 ].data,JSET_BITS );free_fifo (&c->journal.pin); -free_heap (&c->flush_btree); }int bch_journal_alloc (struct cache_set *c)
Greg Kroah-Hartman
maintainerPATCH 186/271 bcache: ignore read-ahead request failure on backing device
In reply to Greg Kroah-HartmanFrom: Coly Li <[email protected]>
commit 578df99b1b0531d19af956530fe4da63d01a1604 upstream.
When md raid device (e.g. raid456) is used as backing device, read-ahead requests on a degrading and recovering md raid device might be failured immediately by md raid code, but indeed this md raid array can still be read or write for normal I/O requests. Therefore such failed read-ahead request are not real hardware failure. Further more, after degrading and recovering accomplished, read-ahead requests will be handled by md raid array again.
For such condition, I/O failures of read-ahead requests don't indicate real health status (because normal I/O still be served), they should not be counted into I/O error counter dc->io_errors.
Since there is no simple way to detect whether the backing divice is a md raid device, this patch simply ignores I/O failures for read-ahead bios on backing device, to avoid bogus backing device failure on a degrading md raid array.
--- drivers/md/bcache/io.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/md/bcache/io.c +12 -0
@@ -58,6 +58,18 @@ void bch_count_backing_io_errors(structWARN_ONCE (!dc,"NULL pointer of struct cached_dev" ); +/* +* Read-ahead requests on a degrading and recovering md raid +* (e.g. raid6) device might be failured immediately by md +* raid code, which is not a real hardware media failure. So +* we shouldn't count failed REQ_RAHEAD bio to dc->io_errors. +*/ +if (bio->bi_opf &REQ_RAHEAD ) { +pr_warn_ratelimited ("%s: Read-ahead I/O failed on backing device, ignore" , + dc->backing_dev_name); +return ; + } + errors =atomic_add_return (1 , &dc->io_errors);if (errors < dc->error_limit) pr_err("%s: IO error on backing device, unrecoverable",
Greg Kroah-Hartman
maintainerPATCH 187/271 bcache: fix mistaken sysfs entry for io_error counter
In reply to Greg Kroah-HartmanFrom: Coly Li <[email protected]>
commit 5461999848e0462c14f306a62923d22de820a59c upstream.
In bch_cached_dev_files[] from driver/md/bcache/sysfs.c, sysfs_errors is incorrectly inserted in. The correct entry should be sysfs_io_errors.
This patch fixes the problem and now I/O errors of cached device can be read from /sys/block/bcache<N>/bcache/io_errors.
--- drivers/md/bcache/sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/bcache/sysfs.c +2 -2
@@ -175,7 +175,7 @@ SHOW(__bch_cached_dev)var_print (writeback_percent);sysfs_hprint (writeback_rate, wb ?atomic_long_read (&dc->writeback_rate.rate) <<9 :0 ); -sysfs_hprint (io_errors,atomic_read (&dc->io_errors)); +sysfs_printf (io_errors,"%i" ,atomic_read (&dc->io_errors));sysfs_printf (io_error_limit,"%i" , dc->error_limit);sysfs_printf (io_disable,"%i" , dc->io_disable);var_print (writeback_rate_update_seconds);
@@ -426,7 +426,7 @@ static struct attribute *bch_cached_dev_ &sysfs_writeback_rate_p_term_inverse, &sysfs_writeback_rate_minimum, &sysfs_writeback_rate_debug, - &sysfs_errors, + &sysfs_io_errors, &sysfs_io_error_limit, &sysfs_io_disable, &sysfs_dirty_data,
Greg Kroah-Hartman
maintainerPATCH 188/271 bcache: destroy dc->writeback_write_wq if failed to create dc->writeback_thread
In reply to Greg Kroah-HartmanFrom: Coly Li <[email protected]>
commit f54d801dda14942dbefa00541d10603015b7859c upstream.
Commit 9baf30972b55 ("bcache: fix for gc and write-back race") added a new work queue dc->writeback_write_wq, but forgot to destroy it in the error condition when creating dc->writeback_thread failed.
This patch destroys dc->writeback_write_wq if kthread_create() returns error pointer to dc->writeback_thread, then a memory leak is avoided.
--- drivers/md/bcache/writeback.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/bcache/writeback.c +1 -0
@@ -807,6 +807,7 @@ int bch_cached_dev_writeback_start(struc "bcache_writeback");if (IS_ERR (dc->writeback_thread)) {cached_dev_put (dc); +destroy_workqueue (dc->writeback_write_wq);return PTR_ERR (dc->writeback_thread); }
Greg Kroah-Hartman
maintainerPATCH 189/271 Input: gtco - bounds check collection indent level
In reply to Greg Kroah-HartmanFrom: Grant Hernandez <[email protected]>
commit 2a017fd82c5402b3c8df5e3d6e5165d9e6147dc1 upstream.
The GTCO tablet input driver configures itself from an HID report sent via USB during the initial enumeration process. Some debugging messages are generated during the parsing. A debugging message indentation counter is not bounds checked, leading to the ability for a specially crafted HID report to cause '-' and null bytes be written past the end of the indentation array. As long as the kernel has CONFIG_DYNAMIC_DEBUG enabled, this code will not be optimized out. This was discovered during code review after a previous syzkaller bug was found in this driver.
--- drivers/input/tablet/gtco.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/input/tablet/gtco.c +17 -3
@@ -78,6 +78,7 @@ Scott Hill [email protected]/* Max size of a single report */ #define REPORT_MAX_SIZE 10 +#define MAX_COLLECTION_LEVELS 10/* Bitmask whether pen is in range */
@@ -223,8 +224,7 @@ static void parse_hid_report_descriptor(char maintype ='x' ;char globtype[12 ];int indent =0 ; -char indentstr[10 ] ="" ; - +char indentstr[MAX_COLLECTION_LEVELS +1 ] = {0 };dev_dbg (ddev,"======>>>>>>PARSE<<<<<<======\n" );
@@ -350,6 +350,13 @@ static void parse_hid_report_descriptor(case TAG_MAIN_COL_START : maintype ='S' ; +if (indent ==MAX_COLLECTION_LEVELS ) { +dev_err (ddev,"Collection level %d would exceed limit of %d\n" , + indent +1 , +MAX_COLLECTION_LEVELS ); +break ; + } +if (data ==0 ) {dev_dbg (ddev,"======>>>>>> Physical\n" );strcpy (globtype,"Physical" );
@@ -369,8 +376,15 @@ static void parse_hid_report_descriptor(break ;case TAG_MAIN_COL_END : -dev_dbg (ddev,"<<<<<<======\n" ); maintype ='E' ; + +if (indent ==0 ) { +dev_err (ddev,"Collection level already at zero\n" ); +break ; + } + +dev_dbg (ddev,"<<<<<<======\n" ); + indent--;for (x =0 ; x < indent; x++) indentstr[x] ='-' ;
Greg Kroah-Hartman
maintainerPATCH 190/271 Input: alps - dont handle ALPS cs19 trackpoint-only device
In reply to Greg Kroah-HartmanFrom: Hui Wang <[email protected]>
commit 7e4935ccc3236751e5fe4bd6846f86e46bb2e427 upstream.
On a latest Lenovo laptop, the trackpoint and 3 buttons below it don't work at all, when we move the trackpoint or press those 3 buttons, the kernel will print out:
"Rejected trackstick packet from non DualPoint device"
This device is identified as an alps touchpad but the packet has trackpoint format, so the alps.c drops the packet and prints out the message above.
According to XiaoXiao's explanation, this device is named cs19 and is trackpoint-only device, its firmware is only for trackpoint, it is independent of touchpad and is a device completely different from DualPoint ones.
To drive this device with mininal changes to the existing driver, we just let the alps driver not handle this device, then the trackpoint.c will be the driver of this device if the trackpoint driver is enabled. (if not, this device will fallback to a bare PS/2 device)
With the trackpoint.c, this trackpoint and 3 buttons all work well, they have all features that the trackpoint should have, like scrolling-screen, drag-and-drop and frame-selection.
--- drivers/input/mouse/alps.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/input/mouse/alps.c +32 -0
@@ -24,6 +24,7 @@#include "psmouse.h" #include "alps.h" +#include "trackpoint.h" /* * Definitions for ALPS version 3 and 4 command mode protocol
@@ -2864,6 +2865,23 @@ static const struct alps_protocol_info *return NULL ; } +static bool alps_is_cs19_trackpoint (struct psmouse *psmouse) +{ +u8 param[2 ] = {0 }; + +if (ps2_command (&psmouse->ps2dev, + param,MAKE_PS2_CMD (0 ,2 ,TP_READ_ID ))) +return false; + +/* +* param[0] contains the trackpoint device variant_id while +* param[1] contains the firmware_id. So far all alps +* trackpoint-only devices have their variant_ids equal +* TP_VARIANT_ALPS and their firmware_ids are in 0x20~0x2f range. +*/ +return param[0 ] ==TP_VARIANT_ALPS && (param[1 ] &0x20 ); +} +static int alps_identify (struct psmouse *psmouse,struct alps_data *priv) {const struct alps_protocol_info *protocol;
@@ -3165,6 +3183,20 @@ int alps_detect(struct psmouse *psmouse,return error;/* +* ALPS cs19 is a trackpoint-only device, and uses different +* protocol than DualPoint ones, so we return -EINVAL here and let +* trackpoint.c drive this device. If the trackpoint driver is not +* enabled, the device will fall back to a bare PS/2 mouse. +* If ps2_command() fails here, we depend on the immediately +* followed psmouse_reset() to reset the device to normal state. +*/ +if (alps_is_cs19_trackpoint (psmouse)) { +psmouse_dbg (psmouse, +"ALPS CS19 trackpoint-only device detected, ignoring\n" ); +return -EINVAL ; + } + +/* * Reset the device to make sure it is fully operational: * on some laptops, like certain Dell Latitudes, we may * fail to properly detect presence of trackstick if device
Greg Kroah-Hartman
maintainerPATCH 191/271 Input: synaptics - whitelist Lenovo T580 SMBus intertouch
In reply to Greg Kroah-HartmanFrom: Nick Black <[email protected]>
commit 1976d7d200c5a32e72293a2ada36b7b7c9d6dd6e upstream.
Adds the Lenovo T580 to the SMBus intertouch list for Synaptics touchpads. I've tested with this for a week now, and it seems a great improvement. It's also nice to have the complaint gone from dmesg.
--- drivers/input/mouse/synaptics.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/mouse/synaptics.c +1 -0
@@ -179,6 +179,7 @@ static const char * const smbus_pnp_ids["LEN0093" ,/* T480 */ "LEN0096" ,/* X280 */ "LEN0097" ,/* X280 -> ALPS trackpoint */ +"LEN009b" ,/* T580 */ "LEN200f" ,/* T450s */ "LEN2054" ,/* E480 */ "LEN2055", /* E580 */
Greg Kroah-Hartman
maintainerPATCH 192/271 Input: alps - fix a mismatch between a condition check and its comment
In reply to Greg Kroah-HartmanFrom: Hui Wang <[email protected]>
commit 771a081e44a9baa1991ef011cc453ef425591740 upstream.
In the function alps_is_cs19_trackpoint(), we check if the param[1] is in the 0x20~0x2f range, but the code we wrote for this checking is not correct:
(param[1] & 0x20) does not mean param[1] is in the range of 0x20~0x2f, it also means the param[1] is in the range of 0x30~0x3f, 0x60~0x6f...
Now fix it with a new condition checking ((param[1] & 0xf0) == 0x20).
--- drivers/input/mouse/alps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/mouse/alps.c +1 -1
@@ -2879,7 +2879,7 @@ static bool alps_is_cs19_trackpoint(stru* trackpoint-only devices have their variant_ids equal * TP_VARIANT_ALPS and their firmware_ids are in 0x20~0x2f range. */ -return param[0 ] ==TP_VARIANT_ALPS && (param[1 ] &0x20 ); +return param[0 ] ==TP_VARIANT_ALPS && ((param[1 ] &0xf0 ) ==0x20 ); }static int alps_identify (struct psmouse *psmouse,struct alps_data *priv)
Greg Kroah-Hartman
maintainerPATCH 193/271 regulator: s2mps11: Fix buck7 and buck8 wrong voltages
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit 16da0eb5ab6ef2dd1d33431199126e63db9997cc upstream.
On S2MPS11 device, the buck7 and buck8 regulator voltages start at 750 mV, not 600 mV. Using wrong minimal value caused shifting of these regulator values by 150 mV (e.g. buck7 usually configured to v1.35 V was reported as 1.2 V).
On most of the boards these regulators are left in default state so this was only affecting reported voltage. However if any driver wanted to change them, then effectively it would set voltage 150 mV higher than intended.
--- drivers/regulator/s2mps11.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/s2mps11.c +2 -2
@@ -373,8 +373,8 @@ static const struct regulator_desc s2mpsregulator_desc_s2mps11_buck1_4 (4 ), regulator_desc_s2mps11_buck5,regulator_desc_s2mps11_buck67810 (6 ,MIN_600_MV ,STEP_6_25_MV ), -regulator_desc_s2mps11_buck67810 (7 ,MIN_600_MV ,STEP_12_5_MV ), -regulator_desc_s2mps11_buck67810 (8 ,MIN_600_MV ,STEP_12_5_MV ), +regulator_desc_s2mps11_buck67810 (7 ,MIN_750_MV ,STEP_12_5_MV ), +regulator_desc_s2mps11_buck67810 (8 ,MIN_750_MV ,STEP_12_5_MV ), regulator_desc_s2mps11_buck9, regulator_desc_s2mps11_buck67810(10, MIN_750_MV, STEP_12_5_MV), };
Greg Kroah-Hartman
maintainerPATCH 194/271 arm64: tegra: Update Jetson TX1 GPU regulator timings
In reply to Greg Kroah-HartmanFrom: Jon Hunter <[email protected]>
commit ece6031ece2dd64d63708cfe1088016cee5b10c0 upstream.
The GPU regulator enable ramp delay for Jetson TX1 is set to 1ms which not sufficient because the enable ramp delay has been measured to be greater than 1ms. Furthermore, the downstream kernels released by NVIDIA for Jetson TX1 are using a enable ramp delay 2ms and a settling delay of 160us. Update the GPU regulator enable ramp delay for Jetson TX1 to be 2ms and add a settling delay of 160us.
--- arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/nvidia/tegra210-p2180.dtsi +2 -1
@@ -330,7 +330,8 @@ regulator-max-microvolt = <1320000>; enable-gpios = <&pmic 6 GPIO_ACTIVE_HIGH>; regulator-ramp-delay = <80>; - regulator-enable-ramp-delay = <1000>; + regulator-enable-ramp-delay = <2000>; + regulator-settling-time-us = <160>; }; }; };
Greg Kroah-Hartman
maintainerPATCH 195/271 iwlwifi: pcie: dont service an interrupt that was masked
In reply to Greg Kroah-HartmanFrom: Emmanuel Grumbach <[email protected]>
commit 3b57a10ca14c619707398dc58fe5ece18c95b20b upstream.
Sometimes the register status can include interrupts that were masked. We can, for example, get the RF-Kill bit set in the interrupt status register although this interrupt was masked. Then if we get the ALIVE interrupt (for example) that was not masked, we need to *not* service the RF-Kill interrupt.
Fix this in the MSI-X interrupt handler.
--- drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
drivers/net/wireless/intel/iwlwifi/pcie/rx.c +21 -6
@@ -2060,10 +2060,18 @@ irqreturn_t iwl_pcie_irq_msix_handler(inreturn IRQ_NONE ; } -if (iwl_have_debug_level (IWL_DL_ISR )) -IWL_DEBUG_ISR (trans,"ISR inta_fh 0x%08x, enabled 0x%08x\n" , - inta_fh, +if (iwl_have_debug_level (IWL_DL_ISR )) { +IWL_DEBUG_ISR (trans, +"ISR inta_fh 0x%08x, enabled (sw) 0x%08x (hw) 0x%08x\n" , + inta_fh, trans_pcie->fh_mask,iwl_read32 (trans,CSR_MSIX_FH_INT_MASK_AD )); +if (inta_fh & ~trans_pcie->fh_mask) +IWL_DEBUG_ISR (trans, +"We got a masked interrupt (0x%08x)\n" , + inta_fh & ~trans_pcie->fh_mask); + } + + inta_fh &= trans_pcie->fh_mask;if ((trans_pcie->shared_vec_mask &IWL_SHARED_IRQ_NON_RX ) && inta_fh &MSIX_FH_INT_CAUSES_Q0 ) {
@@ -2103,11 +2111,18 @@ irqreturn_t iwl_pcie_irq_msix_handler(in }/* After checking FH register check HW register */ -if (iwl_have_debug_level (IWL_DL_ISR )) +if (iwl_have_debug_level (IWL_DL_ISR )) {IWL_DEBUG_ISR (trans, -"ISR inta_hw 0x%08x, enabled 0x%08x\n" , - inta_hw, +"ISR inta_hw 0x%08x, enabled (sw) 0x%08x (hw) 0x%08x\n" , + inta_hw, trans_pcie->hw_mask,iwl_read32 (trans,CSR_MSIX_HW_INT_MASK_AD )); +if (inta_hw & ~trans_pcie->hw_mask) +IWL_DEBUG_ISR (trans, +"We got a masked interrupt 0x%08x\n" , + inta_hw & ~trans_pcie->hw_mask); + } + + inta_hw &= trans_pcie->hw_mask;/* Alive notification via Rx interrupt will do the real work */ if (inta_hw &MSIX_HW_INT_CAUSES_REG_ALIVE ) {
Greg Kroah-Hartman
maintainerPATCH 196/271 iwlwifi: pcie: fix ALIVE interrupt handling for gen2 devices w/o MSI-X
In reply to Greg Kroah-HartmanFrom: Emmanuel Grumbach <[email protected]>
commit ec46ae30245ecb41d73f8254613db07c653fb498 upstream.
We added code to restock the buffer upon ALIVE interrupt when MSI-X is disabled. This was added as part of the context info code. This code was added only if the ISR debug level is set which is very unlikely to be related.
Move this code to run even when the ISR debug level is not set.
Note that gen2 devices work with MSI-X in most cases so that this path is seldom used.
--- drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 34 ++++++++++++--------------- 1 file changed, 16 insertions(+), 18 deletions(-)
drivers/net/wireless/intel/iwlwifi/pcie/rx.c +16 -18
@@ -1778,25 +1778,23 @@ irqreturn_t iwl_pcie_irq_handler(int irq goto out; } -if (iwl_have_debug_level (IWL_DL_ISR )) { -/* NIC fires this, but we don't use it, redundant with WAKEUP */ -if (inta &CSR_INT_BIT_SCD ) { -IWL_DEBUG_ISR (trans, -"Scheduler finished to transmit the frame/frames.\n" ); - isr_stats->sch++; - } +/* NIC fires this, but we don't use it, redundant with WAKEUP */ +if (inta &CSR_INT_BIT_SCD ) { +IWL_DEBUG_ISR (trans, +"Scheduler finished to transmit the frame/frames.\n" ); + isr_stats->sch++; + } -/* Alive notification via Rx interrupt will do the real work */ -if (inta &CSR_INT_BIT_ALIVE ) { -IWL_DEBUG_ISR (trans,"Alive interrupt\n" ); - isr_stats->alive++; -if (trans->cfg->gen2) { -/* -* We can restock, since firmware configured -* the RFH -*/ -iwl_pcie_rxmq_restock (trans, trans_pcie->rxq); - } +/* Alive notification via Rx interrupt will do the real work */ +if (inta &CSR_INT_BIT_ALIVE ) { +IWL_DEBUG_ISR (trans,"Alive interrupt\n" ); + isr_stats->alive++; +if (trans->cfg->gen2) { +/* +* We can restock, since firmware configured +* the RFH +*/ +iwl_pcie_rxmq_restock (trans, trans_pcie->rxq); } }
Greg Kroah-Hartman
maintainerPATCH 197/271 iwlwifi: dont WARN when calling iwl_get_shared_mem_conf with RF-Kill
In reply to Greg Kroah-HartmanFrom: Emmanuel Grumbach <[email protected]>
commit 0d53cfd0cca3c729a089c39eef0e7d8ae7662974 upstream.
iwl_mvm_send_cmd returns 0 when the command won't be sent because RF-Kill is asserted. Do the same when we call iwl_get_shared_mem_conf since it is not sent through iwl_mvm_send_cmd but directly calls the transport layer.
--- drivers/net/wireless/intel/iwlwifi/fw/smem.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/smem.c +9 -3
@@ -8,7 +8,7 @@* Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH -* Copyright(c) 2018 Intel Corporation +* Copyright(c) 2018 - 2019 Intel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as
@@ -31,7 +31,7 @@* Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH -* Copyright(c) 2018 Intel Corporation +* Copyright(c) 2018 - 2019 Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without
@@ -134,6 +134,7 @@ void iwl_get_shared_mem_conf(struct iwl_ .len = { 0, }, };struct iwl_rx_packet *pkt; +int ret;if (fw_has_capa (&fwrt->fw->ucode_capa,IWL_UCODE_TLV_CAPA_EXTEND_SHARED_MEM_CFG ))
@@ -141,8 +142,13 @@ void iwl_get_shared_mem_conf(struct iwl_else cmd.id =SHARED_MEM_CFG ; -if (WARN_ON (iwl_trans_send_cmd (fwrt->trans, &cmd))) + ret =iwl_trans_send_cmd (fwrt->trans, &cmd); + +if (ret) { +WARN (ret != -ERFKILL , +"Could not send the SMEM command: %d\n" , ret);return ; + } pkt = cmd.resp_pkt;if (fwrt->trans->cfg->device_family >=IWL_DEVICE_FAMILY_22000 )
Greg Kroah-Hartman
maintainerPATCH 198/271 iwlwifi: fix RF-Kill interrupt while FW load for gen2 devices
In reply to Greg Kroah-HartmanFrom: Emmanuel Grumbach <[email protected]>
commit ed3e4c6d3cd8f093a3636cb05492429fe2af228d upstream.
Newest devices have a new firmware load mechanism. This mechanism is called the context info. It means that the driver doesn't need to load the sections of the firmware. The driver rather prepares a place in DRAM, with pointers to the relevant sections of the firmware, and the firmware loads itself.
At the end of the process, the firmware sends the ALIVE interrupt. This is different from the previous scheme in which the driver expected the FH_TX interrupt after each section being transferred over the DMA.
In order to support this new flow, we enabled all the interrupts. This broke the assumption that we have in the code that the RF-Kill interrupt can't interrupt the firmware load flow.
Change the context info flow to enable only the ALIVE interrupt, and re-enable all the other interrupts only after the firmware is alive. Then, we won't see the RF-Kill interrupt until then. Getting the RF-Kill interrupt while loading the firmware made us kill the firmware while it is loading and we ended up dumping garbage instead of the firmware state.
Re-enable the ALIVE | RX interrupts from the ISR when we get the ALIVE interrupt to be able to get the RX interrupt that comes immediately afterwards for the ALIVE notification. This is needed for non MSI-X only.
--- drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c | 2 - drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c | 2 - drivers/net/wireless/intel/iwlwifi/pcie/internal.h | 27 +++++++++++++++ drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 5 ++ drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c | 9 +++++ 5 files changed, 43 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info-gen3.c +1 -1
@@ -164,7 +164,7 @@ int iwl_pcie_ctxt_info_gen3_init(structmemcpy (iml_img, trans->iml, trans->iml_len); -iwl_enable_interrupts (trans); +iwl_enable_fw_load_int_ctx_info (trans);/* kick FW self load */ iwl_write64(trans, CSR_CTXT_INFO_ADDR,
drivers/net/wireless/intel/iwlwifi/pcie/ctxt-info.c +1 -1
@@ -206,7 +206,7 @@ int iwl_pcie_ctxt_info_init(struct iwl_t trans_pcie->ctxt_info = ctxt_info; -iwl_enable_interrupts (trans); +iwl_enable_fw_load_int_ctx_info (trans);/* Configure debug, if exists */ if (trans->dbg_dest_tlv)
drivers/net/wireless/intel/iwlwifi/pcie/internal.h +27 -0
@@ -896,6 +896,33 @@ static inline void iwl_enable_fw_load_in } } +static inline void iwl_enable_fw_load_int_ctx_info (struct iwl_trans *trans) +{ +struct iwl_trans_pcie *trans_pcie =IWL_TRANS_GET_PCIE_TRANS (trans); + +IWL_DEBUG_ISR (trans,"Enabling ALIVE interrupt only\n" ); + +if (!trans_pcie->msix_enabled) { +/* +* When we'll receive the ALIVE interrupt, the ISR will call +* iwl_enable_fw_load_int_ctx_info again to set the ALIVE +* interrupt (which is not really needed anymore) but also the +* RX interrupt which will allow us to receive the ALIVE +* notification (which is Rx) and continue the flow. +*/ + trans_pcie->inta_mask =CSR_INT_BIT_ALIVE |CSR_INT_BIT_FH_RX ; +iwl_write32 (trans,CSR_INT_MASK , trans_pcie->inta_mask); + }else { +iwl_enable_hw_int_msk_msix (trans, +MSIX_HW_INT_CAUSES_REG_ALIVE ); +/* +* Leave all the FH causes enabled to get the ALIVE +* notification. +*/ +iwl_enable_fh_int_msk_msix (trans, trans_pcie->fh_init_mask); + } +} +static inline u16 iwl_pcie_get_cmd_index (const struct iwl_txq *q,u32 index) {return index & (q->n_window -1 );
drivers/net/wireless/intel/iwlwifi/pcie/rx.c +5 -0
@@ -1796,6 +1796,8 @@ irqreturn_t iwl_pcie_irq_handler(int irq*/ iwl_pcie_rxmq_restock (trans, trans_pcie->rxq); } + + handled |=CSR_INT_BIT_ALIVE ; }/* Safely ignore these bits for debug checks below */
@@ -1914,6 +1916,9 @@ irqreturn_t iwl_pcie_irq_handler(int irq/* Re-enable RF_KILL if it occurred */ else if (handled & CSR_INT_BIT_RF_KILL) iwl_enable_rfkill_int(trans); +/* Re-enable the ALIVE / Rx interrupt if it occurred */ + else if (handled & (CSR_INT_BIT_ALIVE | CSR_INT_BIT_FH_RX)) +iwl_enable_fw_load_int_ctx_info (trans);spin_unlock (&trans_pcie->irq_lock); out:
drivers/net/wireless/intel/iwlwifi/pcie/trans-gen2.c +9 -0
@@ -289,6 +289,15 @@ void iwl_trans_pcie_gen2_fw_alive(struct* paging memory cannot be freed included since FW will still use it */ iwl_pcie_ctxt_info_free (trans); + +/* +* Re-enable all the interrupts, including the RF-Kill one, now that +* the firmware is alive. +*/ +iwl_enable_interrupts (trans); +mutex_lock (&trans_pcie->mutex); +iwl_pcie_check_hw_rf_kill (trans); +mutex_unlock (&trans_pcie->mutex); } int iwl_trans_pcie_gen2_start_fw(struct iwl_trans *trans,
Greg Kroah-Hartman
maintainerPATCH 199/271 NFSv4: Handle the special Linux file open access mode
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit 44942b4e457beda00981f616402a1a791e8c616e upstream.
According to the open() manpage, Linux reserves the access mode 3 to mean "check for read and write permission on the file and return a file descriptor that can't be used for reading or writing."
Currently, the NFSv4 code will ask the server to open the file, and will use an incorrect share access mode of 0. Since it has an incorrect share access mode, the client later forgets to send a corresponding close, meaning it can leak stateids on the server.
--- fs/nfs/inode.c | 1 + fs/nfs/nfs4file.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
fs/nfs/inode.c +1 -0
@@ -1100,6 +1100,7 @@ int nfs_open(struct inode *inode, structnfs_fscache_open_file (inode, filp);return 0 ; } +EXPORT_SYMBOL_GPL (nfs_open);/* * This function is called whenever some part of NFS notices that
fs/nfs/nfs4file.c +1 -1
@@ -49,7 +49,7 @@ nfs4_file_open(struct inode *inode, strureturn err;if ((openflags &O_ACCMODE ) ==3 ) - openflags--; +return nfs_open (inode, filp);/* We can't create new files here */ openflags &= ~(O_CREAT |O_EXCL );
Greg Kroah-Hartman
maintainerPATCH 200/271 pnfs/flexfiles: Fix PTR_ERR() dereferences in ff_layout_track_ds_error
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit 8e04fdfadda75a849c649f7e50fe7d97772e1fcb upstream.
mirror->mirror_ds can be NULL if uninitialised, but can contain a PTR_ERR() if call to GETDEVICEINFO failed.
--- fs/nfs/flexfilelayout/flexfilelayoutdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/flexfilelayout/flexfilelayoutdev.c +1 -1
@@ -307,7 +307,7 @@ int ff_layout_track_ds_error(struct nfs4if (status ==0 )return 0 ; -if (mirror->mirror_ds ==NULL ) +if (IS_ERR_OR_NULL (mirror->mirror_ds))return -EINVAL ; dserr =kmalloc (sizeof (*dserr), gfp_flags);
Greg Kroah-Hartman
maintainerPATCH 201/271 pNFS: Fix a typo in pnfs_update_layout
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit 400417b05f3ec0531544ca5f94e64d838d8b8849 upstream.
We're supposed to wait for the outstanding layout count to go to zero, but that got lost somehow.
--- fs/nfs/pnfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/pnfs.c +1 -1
@@ -1866,7 +1866,7 @@ lookup_again: atomic_read(&lo->plh_outstanding) != 0) {spin_unlock (&ino->i_lock); lseg =ERR_PTR (wait_var_event_killable (&lo->plh_outstanding, -atomic_read (&lo->plh_outstanding))); + !atomic_read (&lo->plh_outstanding)));if (IS_ERR (lseg) || !list_empty (&lo->plh_segs)) goto out_put_layout_hdr;pnfs_put_layout_hdr (lo);
Greg Kroah-Hartman
maintainerPATCH 202/271 pnfs: Fix a problem where we gratuitously start doing I/O through the MDS
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
commit 58bbeab425c6c5e318f5b6ae31d351331ddfb34b upstream.
If the client has to stop in pnfs_update_layout() to wait for another layoutget to complete, it currently exits and defaults to I/O through the MDS if the layoutget was successful.
--- fs/nfs/pnfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/pnfs.c +1 -1
@@ -1867,7 +1867,7 @@ lookup_again:spin_unlock (&ino->i_lock); lseg =ERR_PTR (wait_var_event_killable (&lo->plh_outstanding, !atomic_read (&lo->plh_outstanding))); -if (IS_ERR (lseg) || !list_empty (&lo->plh_segs)) +if (IS_ERR (lseg)) goto out_put_layout_hdr;pnfs_put_layout_hdr (lo); goto lookup_again;
Greg Kroah-Hartman
maintainerPATCH 203/271 lib/scatterlist: Fix mapping iterator when sg->offset is greater than PAGE_SIZE
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit aeb87246537a83c2aff482f3f34a2e0991e02cbc upstream.
All mapping iterator logic is based on the assumption that sg->offset is always lower than PAGE_SIZE.
But there are situations where sg->offset is such that the SG item is on the second page. In that case sg_copy_to_buffer() fails properly copying the data into the buffer. One of the reason is that the data will be outside the kmapped area used to access that data.
This patch fixes the issue by adjusting the mapping iterator offset and pgoffset fields such that offset is always lower than PAGE_SIZE.
--- lib/scatterlist.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
lib/scatterlist.c +5 -4
@@ -652,17 +652,18 @@ static bool sg_miter_get_next_page(struc {if (!miter->__remaining) {struct scatterlist *sg; -unsigned long pgoffset;if (!__sg_page_iter_next (&miter->piter))return false; sg = miter->piter.sg; - pgoffset = miter->piter.sg_pgoffset; - miter->__offset = pgoffset ?0 : sg->offset; + miter->__offset = miter->piter.sg_pgoffset ?0 : sg->offset; + miter->piter.sg_pgoffset += miter->__offset >>PAGE_SHIFT ; + miter->__offset &=PAGE_SIZE -1 ; miter->__remaining = sg->offset + sg->length - - (pgoffset <<PAGE_SHIFT ) - miter->__offset; + (miter->piter.sg_pgoffset <<PAGE_SHIFT ) - + miter->__offset; miter->__remaining = min_t(unsigned long, miter->__remaining,PAGE_SIZE - miter->__offset); }
Greg Kroah-Hartman
maintainerPATCH 204/271 ASoC: dapm: Adapt for debugfs API change
In reply to Greg Kroah-HartmanFrom: Mark Brown <[email protected]>
commit ceaea851b9ea75f9ea2bbefb53ff0d4b27cd5a6e upstream.
Back in ff9fb72bc07705c (debugfs: return error values, not NULL) the debugfs APIs were changed to return error pointers rather than NULL pointers on error, breaking the error checking in ASoC. Update the code to use IS_ERR() and log the codes that are returned as part of the error messages.
--- sound/soc/soc-dapm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
sound/soc/soc-dapm.c +10 -8
@@ -2139,23 +2139,25 @@ void snd_soc_dapm_debugfs_init(struct sn {struct dentry *d; -if (!parent) +if (!parent ||IS_ERR (parent))return ; dapm->debugfs_dapm =debugfs_create_dir ("dapm" , parent); -if (!dapm->debugfs_dapm) { +if (IS_ERR (dapm->debugfs_dapm)) {dev_warn (dapm->dev, -"ASoC: Failed to create DAPM debugfs directory\n" ); +"ASoC: Failed to create DAPM debugfs directory %ld\n" , +PTR_ERR (dapm->debugfs_dapm));return ; } d =debugfs_create_file ("bias_level" ,0444 , dapm->debugfs_dapm, dapm, &dapm_bias_fops); -if (!d) +if (IS_ERR (d))dev_warn (dapm->dev, -"ASoC: Failed to create bias level debugfs file\n" ); +"ASoC: Failed to create bias level debugfs file: %ld\n" , +PTR_ERR (d)); }static void dapm_debugfs_add_widget (struct snd_soc_dapm_widget *w)
@@ -2169,10 +2171,10 @@ static void dapm_debugfs_add_widget(stru d =debugfs_create_file (w->name,0444 , dapm->debugfs_dapm, w, &dapm_widget_power_fops); -if (!d) +if (IS_ERR (d))dev_warn (w->dapm->dev, -"ASoC: Failed to create %s debugfs file\n" , - w->name); +"ASoC: Failed to create %s debugfs file: %ld\n" , + w->name,PTR_ERR (d)); }static void dapm_debugfs_cleanup (struct snd_soc_dapm_context *dapm)
Greg Kroah-Hartman
maintainerPATCH 205/271 raid5-cache: Need to do start() part job after adding journal device
In reply to Greg Kroah-HartmanFrom: Xiao Ni <[email protected]>
commit d9771f5ec46c282d518b453c793635dbdc3a2a94 upstream.
commit d5d885fd514f ("md: introduce new personality funciton start()") splits the init job to two parts. The first part run() does the jobs that do not require the md threads. The second part start() does the jobs that require the md threads.
Now it just does run() in adding new journal device. It needs to do the second part start() too.
--- drivers/md/raid5.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/md/raid5.c +9 -2
@@ -7670,7 +7670,7 @@ abort:static int raid5_add_disk (struct mddev *mddev,struct md_rdev *rdev) {struct r5conf *conf = mddev->private; -int err = -EEXIST ; +int ret, err = -EEXIST ;int disk;struct disk_info *p;int first =0 ;
@@ -7685,7 +7685,14 @@ static int raid5_add_disk(struct mddev ** The array is in readonly mode if journal is missing, so no * write requests running. We should be safe */ -log_init (conf, rdev, false); + ret =log_init (conf, rdev, false); +if (ret) +return ret; + + ret =r5l_start (conf->log); +if (ret) +return ret; +return 0 ; }if (mddev->recovery_disabled == conf->recovery_disabled)
Greg Kroah-Hartman
maintainerPATCH 206/271 ALSA: seq: Break too long mutex context in the write loop
In reply to Greg Kroah-HartmanFrom: Takashi Iwai <[email protected]>
commit ede34f397ddb063b145b9e7d79c6026f819ded13 upstream.
The fix for the racy writes and ioctls to sequencer widened the application of client->ioctl_mutex to the whole write loop. Although it does unlock/relock for the lengthy operation like the event dup, the loop keeps the ioctl_mutex for the whole time in other situations. This may take quite long time if the user-space would give a huge buffer, and this is a likely cause of some weird behavior spotted by syzcaller fuzzer.
This patch puts a simple workaround, just adding a mutex break in the loop when a large number of events have been processed. This shouldn't hit any performance drop because the threshold is set high enough for usual operations.
--- sound/core/seq/seq_clientmgr.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
sound/core/seq/seq_clientmgr.c +10 -1
@@ -1004,7 +1004,7 @@ static ssize_t snd_seq_write(struct file {struct snd_seq_client *client = file->private_data;int written =0 , len; -int err; +int err, handled;struct snd_seq_event event;if (!(snd_seq_file_flags (file) &SNDRV_SEQ_LFLG_OUTPUT ))
@@ -1017,6 +1017,8 @@ static ssize_t snd_seq_write(struct fileif (!client->accept_output || client->pool ==NULL )return -ENXIO ; + repeat: + handled =0 ;/* allocate the pool now if the pool is not allocated yet */ mutex_lock (&client->ioctl_mutex);if (client->pool->size >0 && !snd_seq_write_pool_allocated (client)) {
@@ -1076,12 +1078,19 @@ static ssize_t snd_seq_write(struct file 0, 0, &client->ioctl_mutex);if (err <0 )break ; + handled++; __skip_event:/* Update pointers and counts */ count -= len; buf += len; written += len; + +/* let's have a coffee break if too many events are queued */ +if (++handled >=200 ) { +mutex_unlock (&client->ioctl_mutex); + goto repeat; + } } out:
Greg Kroah-Hartman
maintainerPATCH 207/271 ALSA: hda/realtek - Fixed Headphone Mic cant record on Dell platform
In reply to Greg Kroah-HartmanFrom: Kailang Yang <[email protected]>
commit fbc571290d9f7bfe089c50f4ac4028dd98ebfe98 upstream.
It assigned to wrong model. So, The headphone Mic can't work.
--- sound/pci/hda/patch_realtek.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
sound/pci/hda/patch_realtek.c +4 -1
@@ -7518,9 +7518,12 @@ static const struct snd_hda_pin_quirk al {0x12, 0x90a60130}, {0x17, 0x90170110}, {0x21, 0x03211020}), - SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, + SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, {0x14, 0x90170110}, {0x21, 0x04211020}), + SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL4_MIC_NO_PRESENCE, + {0x14, 0x90170110}, + {0x21, 0x04211030}), SND_HDA_PIN_QUIRK(0x10ec0295, 0x1028, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, ALC295_STANDARD_PINS, {0x17, 0x21014020},
Greg Kroah-Hartman
maintainerPATCH 208/271 ALSA: hda/realtek: apply ALC891 headset fixup to one Dell machine
In reply to Greg Kroah-HartmanFrom: Hui Wang <[email protected]>
commit 4b4e0e32e4b09274dbc9d173016c1a026f44608c upstream.
Without this patch, the headset-mic and headphone-mic don't work.
--- sound/pci/hda/patch_realtek.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/pci/hda/patch_realtek.c +5 -0
@@ -8657,6 +8657,11 @@ static const struct snd_hda_pin_quirk al {0x18, 0x01a19030}, {0x1a, 0x01813040}, {0x21, 0x01014020}), + SND_HDA_PIN_QUIRK(0x10ec0867, 0x1028, "Dell", ALC891_FIXUP_DELL_MIC_NO_PRESENCE, + {0x16, 0x01813030}, + {0x17, 0x02211010}, + {0x18, 0x01a19040}, + {0x21, 0x01014020}), SND_HDA_PIN_QUIRK(0x10ec0662, 0x1028, "Dell", ALC662_FIXUP_DELL_MIC_NO_PRESENCE, {0x14, 0x01014010}, {0x18, 0x01a19020},
Greg Kroah-Hartman
maintainerPATCH 209/271 media: v4l2: Test type instead of cfg->type in v4l2_ctrl_new_custom()
In reply to Greg Kroah-HartmanFrom: Boris Brezillon <[email protected]>
commit 07d89227a983df957a6a7c56f7c040cde9ac571f upstream.
cfg->type can be overridden by v4l2_ctrl_fill() and the new value is stored in the local type var. Fix the tests to use this local var.
--- drivers/media/v4l2-core/v4l2-ctrls.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/media/v4l2-core/v4l2-ctrls.c +4 -5
@@ -2249,16 +2249,15 @@ struct v4l2_ctrl *v4l2_ctrl_new_custom(sv4l2_ctrl_fill (cfg->id, &name, &type, &min, &max, &step, &def, &flags); - is_menu = (cfg->type ==V4L2_CTRL_TYPE_MENU || - cfg->type ==V4L2_CTRL_TYPE_INTEGER_MENU ); + is_menu = (type ==V4L2_CTRL_TYPE_MENU || + type ==V4L2_CTRL_TYPE_INTEGER_MENU );if (is_menu)WARN_ON (step);else WARN_ON (cfg->menu_skip_mask); -if (cfg->type ==V4L2_CTRL_TYPE_MENU && qmenu ==NULL ) +if (type ==V4L2_CTRL_TYPE_MENU && !qmenu) { qmenu =v4l2_ctrl_get_menu (cfg->id); -else if (cfg->type ==V4L2_CTRL_TYPE_INTEGER_MENU && - qmenu_int ==NULL ) { + }else if (type ==V4L2_CTRL_TYPE_INTEGER_MENU && !qmenu_int) {handler_set_err (hdl, -EINVAL );return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 210/271 media: coda: Remove unbalanced and unneeded mutex unlock
In reply to Greg Kroah-HartmanFrom: Ezequiel Garcia <[email protected]>
commit 766b9b168f6c75c350dd87c3e0bc6a9b322f0013 upstream.
The mutex unlock in the threaded interrupt handler is not paired with any mutex lock. Remove it.
This bug has been here for a really long time, so it applies to any stable repo.
--- drivers/media/platform/coda/coda-bit.c | 1 - 1 file changed, 1 deletion(-)
drivers/media/platform/coda/coda-bit.c +0 -1
@@ -2309,7 +2309,6 @@ irqreturn_t coda_irq_handler(int irq, voif (ctx ==NULL ) {v4l2_err (&dev->v4l2_dev,"Instance released before the end of transaction\n" ); -mutex_unlock (&dev->coda_mutex);return IRQ_HANDLED ; }
Greg Kroah-Hartman
maintainerPATCH 211/271 media: videobuf2-core: Prevent size alignment wrapping buffer size to 0
In reply to Greg Kroah-HartmanFrom: Sakari Ailus <[email protected]>
commit defcdc5d89ced780fb45196d539d6570ec5b1ba5 upstream.
PAGE_ALIGN() may wrap the buffer size around to 0. Prevent this by checking that the aligned value is not smaller than the unaligned one.
Note on backporting to stable: the file used to be under drivers/media/v4l2-core, it was moved to the current location after 4.14.
--- drivers/media/common/videobuf2/videobuf2-core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/common/videobuf2/videobuf2-core.c +4 -0
@@ -207,6 +207,10 @@ static int __vb2_buf_mem_alloc(struct vbfor (plane =0 ; plane < vb->num_planes; ++plane) {unsigned long size =PAGE_ALIGN (vb->planes[plane].length); +/* Did it wrap around? */ +if (size < vb->planes[plane].length) + goto free; + mem_priv =call_ptr_memop (vb, alloc, q->alloc_devs[plane] ? : q->dev, q->dma_attrs, size, q->dma_dir, q->gfp_flags);
Greg Kroah-Hartman
maintainerPATCH 212/271 media: videobuf2-dma-sg: Prevent size from overflowing
In reply to Greg Kroah-HartmanFrom: Sakari Ailus <[email protected]>
commit 14f28f5cea9e3998442de87846d1907a531b6748 upstream.
buf->size is an unsigned long; casting that to int will lead to an overflow if buf->size exceeds INT_MAX.
Fix this by changing the type to unsigned long instead. This is possible as the buf->size is always aligned to PAGE_SIZE, and therefore the size will never have values lesser than 0.
Note on backporting to stable: the file used to be under drivers/media/v4l2-core, it was moved to the current location after 4.14.
--- drivers/media/common/videobuf2/videobuf2-dma-sg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/common/videobuf2/videobuf2-dma-sg.c +1 -1
@@ -59,7 +59,7 @@ static int vb2_dma_sg_alloc_compacted(st gfp_t gfp_flags) {unsigned int last_page =0 ; -int size = buf->size; +unsigned long size = buf->size;while (size >0 ) {struct page *pages;
Greg Kroah-Hartman
maintainerPATCH 213/271 KVM: x86/vPMU: refine kvm_pmu err msg when event creation failed
In reply to Greg Kroah-HartmanFrom: Like Xu <[email protected]>
commit 6fc3977ccc5d3c22e851f2dce2d3ce2a0a843842 upstream.
If a perf_event creation fails due to any reason of the host perf subsystem, it has no chance to log the corresponding event for guest which may cause abnormal sampling data in guest result. In debug mode, this message helps to understand the state of vPMC and we may not limit the number of occurrences but not in a spamming style.
--- arch/x86/kvm/pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/pmu.c +2 -2
@@ -131,8 +131,8 @@ static void pmc_reprogram_counter(struct intr ? kvm_perf_overflow_intr : kvm_perf_overflow, pmc);if (IS_ERR (event)) { -printk_once ("kvm_pmu: event creation failed %ld\n" , -PTR_ERR (event)); +pr_debug_ratelimited ("kvm_pmu: event creation failed %ld for pmc->idx = %d\n" , +PTR_ERR (event), pmc->idx);return ; }
Greg Kroah-Hartman
maintainerPATCH 214/271 arm64: tegra: Fix AGIC register range
In reply to Greg Kroah-HartmanFrom: Jon Hunter <[email protected]>
commit ba24eee6686f6ed3738602b54d959253316a9541 upstream.
The Tegra AGIC interrupt controller is an ARM GIC400 interrupt controller. Per the ARM GIC device-tree binding, the first address region is for the GIC distributor registers and the second address region is for the GIC CPU interface registers. The address space for the distributor registers is 4kB, but currently this is incorrectly defined as 8kB for the Tegra AGIC and overlaps with the CPU interface registers. Correct the address space for the distributor to be 4kB.
--- arch/arm64/boot/dts/nvidia/tegra210.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/nvidia/tegra210.dtsi +1 -1
@@ -1119,7 +1119,7 @@ compatible = "nvidia,tegra210-agic"; #interrupt-cells = <3>; interrupt-controller; - reg = <0x702f9000 0x2000>, + reg = <0x702f9000 0x1000>, <0x702fa000 0x2000>; interrupts = <GIC_SPI 102 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>; clocks = <&tegra_car TEGRA210_CLK_APE>;
Greg Kroah-Hartman
maintainerPATCH 215/271 fs/proc/proc_sysctl.c: fix the default values of i_uid/i_gid on /proc/sys inodes.
In reply to Greg Kroah-HartmanFrom: Radoslaw Burny <[email protected]>
commit 5ec27ec735ba0477d48c80561cc5e856f0c5dfaf upstream.
Normally, the inode's i_uid/i_gid are translated relative to s_user_ns, but this is not a correct behavior for proc. Since sysctl permission check in test_perm is done against GLOBAL_ROOT_[UG]ID, it makes more sense to use these values in u_[ug]id of proc inodes. In other words:
although uid/gid in the inode is not read during test_perm, the inode logically belongs to the root of the namespace. I have confirmed this with Eric Biederman at LPC and in this thread:
https://lore.kernel.org/lkml/[email protected]
Consequences
============
Since the i_[ug]id values of proc nodes are not used for permissions checks, this change usually makes no functional difference. However, it causes an issue in a setup where:
* a namespace container is created without root user in container - hence the i_[ug]id of proc nodes are set to INVALID_[UG]ID
* container creator tries to configure it by writing /proc/sys files, e.g. writing /proc/sys/kernel/shmmax to configure shared memory limit
Kernel does not allow to open an inode for writing if its i_[ug]id are invalid, making it impossible to write shmmax and thus - configure the container.
Using a container with no root mapping is apparently rare, but we do use this configuration at Google. Also, we use a generic tool to configure the container limits, and the inability to write any of them causes a failure.
History
=======
The invalid uids/gids in inodes first appeared due to 81754357770e (fs:
Update i_[ug]id_(read|write) to translate relative to s_user_ns). However, AFAIK, this did not immediately cause any issues. The inability to write to these "invalid" inodes was only caused by a later commit 0bd23d09b874 (vfs: Don't modify inodes with a uid or gid unknown to the vfs).
Tested: Used a repro program that creates a user namespace without any mapping and stat'ed /proc/$PID/root/proc/sys/kernel/shmmax from outside. Before the change, it shows the overflow uid, with the change it's 0. The overflow uid indicates that the uid in the inode is not correct and thus it is not possible to open the file for writing.
--- fs/proc/proc_sysctl.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/proc/proc_sysctl.c +4 -0
@@ -498,6 +498,10 @@ static struct inode *proc_sys_make_inodeif (root->set_ownership) root->set_ownership (head, table, &inode->i_uid, &inode->i_gid); +else { + inode->i_uid =GLOBAL_ROOT_UID ; + inode->i_gid =GLOBAL_ROOT_GID ; + }return inode; }
Greg Kroah-Hartman
maintainerPATCH 216/271 kconfig: fix missing choice values in auto.conf
In reply to Greg Kroah-HartmanFrom: Masahiro Yamada <[email protected]>
commit 8e2442a5f86e1f77b86401fce274a7f622740bc4 upstream.
Since commit 00c864f8903d ("kconfig: allow all config targets to write auto.conf if missing"), Kconfig creates include/config/auto.conf in the defconfig stage when it is missing.
Joonas Kylmälä reported incorrect auto.conf generation under some circumstances.
To reproduce it, apply the following diff:
| --- a/arch/arm/configs/imx_v6_v7_defconfig | +++ b/arch/arm/configs/imx_v6_v7_defconfig | @@ -345,14 +345,7 @@ CONFIG_USB_CONFIGFS_F_MIDI=y | CONFIG_USB_CONFIGFS_F_HID=y | CONFIG_USB_CONFIGFS_F_UVC=y | CONFIG_USB_CONFIGFS_F_PRINTER=y | -CONFIG_USB_ZERO=m | -CONFIG_USB_AUDIO=m | -CONFIG_USB_ETH=m | -CONFIG_USB_G_NCM=m | -CONFIG_USB_GADGETFS=m | -CONFIG_USB_FUNCTIONFS=m | -CONFIG_USB_MASS_STORAGE=m | -CONFIG_USB_G_SERIAL=m | +CONFIG_USB_FUNCTIONFS=y | CONFIG_MMC=y | CONFIG_MMC_SDHCI=y | CONFIG_MMC_SDHCI_PLTFM=y
And then, run:
$ make ARCH=arm mrproper imx_v6_v7_defconfig
You will see CONFIG_USB_FUNCTIONFS=y is correctly contained in the .config, but not in the auto.conf.
Please note drivers/usb/gadget/legacy/Kconfig is included from a choice block in drivers/usb/gadget/Kconfig. So USB_FUNCTIONFS is a choice value.
This is probably a similar situation described in commit beaaddb62540 ("kconfig: tests: test defconfig when two choices interact").
When sym_calc_choice() is called, the choice symbol forgets the SYMBOL_DEF_USER unless all of its choice values are explicitly set by the user.
The choice symbol is given just one chance to recall it because set_all_choice_values() is called if SYMBOL_NEED_SET_CHOICE_VALUES is set.
When sym_calc_choice() is called again, the choice symbol forgets it forever, since SYMBOL_NEED_SET_CHOICE_VALUES is a one-time aid. Hence, we cannot call sym_clear_all_valid() again and again.
It is crazy to repeat set and unset of internal flags. However, we cannot simply get rid of "sym->flags &= flags | ~SYMBOL_DEF_USER;" Doing so would re-introduce the problem solved by commit 5d09598d488f ("kconfig: fix new choices being skipped upon config update").
To work around the issue, conf_write_autoconf() stopped calling sym_clear_all_valid().
conf_write() must be changed accordingly. Currently, it clears SYMBOL_WRITE after the symbol is written into the .config file. This is needed to prevent it from writing the same symbol multiple times in case the symbol is declared in two or more locations. I added the new flag SYMBOL_WRITTEN, to track the symbols that have been written.
Anyway, this is a cheesy workaround in order to suppress the issue as far as defconfig is concerned.
Handling of choices is totally broken. sym_clear_all_valid() is called every time a user touches a symbol from the GUI interface. To reproduce it, just add a new symbol drivers/usb/gadget/legacy/Kconfig, then touch around unrelated symbols from menuconfig. USB_FUNCTIONFS will disappear from the .config file.
I added the Fixes tag since it is more fatal than before. But, this has been broken since long long time before, and still it is. We should take a closer look to fix this correctly somehow.
--- scripts/kconfig/confdata.c | 7 +++---- scripts/kconfig/expr.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-)
scripts/kconfig/confdata.c +3 -4
@@ -834,11 +834,12 @@ int conf_write(const char *name)"#\n" "# %s\n" "#\n", str); - }else if (!(sym->flags &SYMBOL_CHOICE )) { + }else if (!(sym->flags &SYMBOL_CHOICE ) && + !(sym->flags &SYMBOL_WRITTEN )) {sym_calc_value (sym);if (!(sym->flags &SYMBOL_WRITE )) goto next; - sym->flags &= ~SYMBOL_WRITE ; + sym->flags |=SYMBOL_WRITTEN ;conf_write_symbol (out, sym, &kconfig_printer_cb,NULL ); }
@@ -1024,8 +1025,6 @@ int conf_write_autoconf(int overwrite)if (!overwrite &&is_present (autoconf_name))return 0 ; -sym_clear_all_valid (); -conf_write_dep ("include/config/auto.conf.cmd" );if (conf_split_config ())
scripts/kconfig/expr.h +1 -0
@@ -141,6 +141,7 @@ struct symbol {#define SYMBOL_OPTIONAL 0x0100/* choice is optional - values can be 'n' */ #define SYMBOL_WRITE 0x0200/* write symbol to file (KCONFIG_CONFIG) */ #define SYMBOL_CHANGED 0x0400/* ? */ +#define SYMBOL_WRITTEN 0x0800/* track info to avoid double-write to .config */ #define SYMBOL_NO_WRITE 0x1000/* Symbol for internal use only; it will not be written */ #define SYMBOL_CHECKED 0x2000/* used during dependency checking */ #define SYMBOL_WARNED 0x8000/* warning has been issued */
Greg Kroah-Hartman
maintainerPATCH 217/271 drm/nouveau/i2c: Enable i2c pads & busses during preinit
In reply to Greg Kroah-HartmanFrom: Lyude Paul <[email protected]>
commit 7cb95eeea6706c790571042a06782e378b2561ea upstream.
It turns out that while disabling i2c bus access from software when the GPU is suspended was a step in the right direction with:
commit 342406e4fbba ("drm/nouveau/i2c: Disable i2c bus access after ->fini()")
We also ended up accidentally breaking the vbios init scripts on some older Tesla GPUs, as apparently said scripts can actually use the i2c bus. Since these scripts are executed before initializing any subdevices, we end up failing to acquire access to the i2c bus which has left a number of cards with their fan controllers uninitialized. Luckily this doesn't break hardware - it just means the fan gets stuck at 100%.
This also means that we've always been using our i2c busses before initializing them during the init scripts for older GPUs, we just didn't notice it until we started preventing them from being used until init. It's pretty impressive this never caused us any issues before!
So, fix this by initializing our i2c pad and busses during subdev pre-init. We skip initializing aux busses during pre-init, as those are guaranteed to only ever be used by nouveau for DP aux transactions.
--- drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/gpu/drm/nouveau/nvkm/subdev/i2c/base.c +20 -0
@@ -185,6 +185,25 @@ nvkm_i2c_fini(struct nvkm_subdev *subdev }static int +nvkm_i2c_preinit (struct nvkm_subdev *subdev) +{ +struct nvkm_i2c *i2c =nvkm_i2c (subdev); +struct nvkm_i2c_bus *bus; +struct nvkm_i2c_pad *pad; + +/* +* We init our i2c busses as early as possible, since they may be +* needed by the vbios init scripts on some cards +*/ +list_for_each_entry (pad, &i2c->pad, head) +nvkm_i2c_pad_init (pad); +list_for_each_entry (bus, &i2c->bus, head) +nvkm_i2c_bus_init (bus); + +return 0 ; +} + +static int nvkm_i2c_init (struct nvkm_subdev *subdev) {struct nvkm_i2c *i2c =nvkm_i2c (subdev);
@@ -238,6 +257,7 @@ nvkm_i2c_dtor(struct nvkm_subdev *subdevstatic const struct nvkm_subdev_func nvkm_i2c = { .dtor = nvkm_i2c_dtor, + .preinit = nvkm_i2c_preinit, .init = nvkm_i2c_init, .fini = nvkm_i2c_fini, .intr = nvkm_i2c_intr,
Greg Kroah-Hartman
maintainerPATCH 218/271 padata: use smp_mb in padata_reorder to avoid orphaned padata jobs
In reply to Greg Kroah-HartmanFrom: Daniel Jordan <[email protected]>
commit cf144f81a99d1a3928f90b0936accfd3f45c9a0a upstream.
Testing padata with the tcrypt module on a 5.2 kernel...
# modprobe tcrypt alg="pcrypt(rfc4106(gcm(aes)))" type=3
# modprobe tcrypt mode=211 sec=1...produces this splat:
INFO: task modprobe:10075 blocked for more than 120 seconds.
Not tainted 5.2.0-base+ #16
modprobe D 0 10075 10064 0x80004080
Call Trace:
? __schedule+0x4dd/0x610
? ring_buffer_unlock_commit+0x23/0x100
schedule+0x6c/0x90
schedule_timeout+0x3b/0x320
? trace_buffer_unlock_commit_regs+0x4f/0x1f0
wait_for_common+0x160/0x1a0
? wake_up_q+0x80/0x80
{ crypto_wait_req } # entries in braces added by hand
{ do_one_aead_op }
{ test_aead_jiffies }
test_aead_speed.constprop.17+0x681/0xf30 [tcrypt]
do_test+0x4053/0x6a2b [tcrypt]
? 0xffffffffa00f4000
tcrypt_mod_init+0x50/0x1000 [tcrypt]
...The second modprobe command never finishes because in padata_reorder, CPU0's load of reorder_objects is executed before the unlocking store in spin_unlock_bh(pd->lock), causing CPU0 to miss CPU1's increment:
CPU0 CPU1
padata_reorder padata_do_serial
LOAD reorder_objects // 0
INC reorder_objects // 1 padata_reorder
TRYLOCK pd->lock // failed
UNLOCK pd->lock
CPU0 deletes the timer before returning from padata_reorder and since no other job is submitted to padata, modprobe waits indefinitely.
Add a pair of full barriers to guarantee proper ordering:
CPU0 CPU1
padata_reorder padata_do_serial
UNLOCK pd->lock
smp_mb()
LOAD reorder_objects
INC reorder_objects
smp_mb__after_atomic()
padata_reorder
TRYLOCK pd->locksmp_mb__after_atomic is needed so the read part of the trylock operation
comes after the INC, as Andrea points out. Thanks also to Andrea for
help with writing a litmus test.
--- kernel/padata.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
kernel/padata.c +12 -0
@@ -267,7 +267,12 @@ static void padata_reorder(struct parall* The next object that needs serialization might have arrived to * the reorder queues in the meantime, we will be called again * from the timer function if no one else cares for it. +* +* Ensure reorder_objects is read after pd->lock is dropped so we see +* an increment from another task in padata_do_serial. Pairs with +* smp_mb__after_atomic in padata_do_serial. */ +smp_mb ();if (atomic_read (&pd->reorder_objects) && !(pinst->flags &PADATA_RESET ))mod_timer (&pd->timer, jiffies +HZ );
@@ -387,6 +392,13 @@ void padata_do_serial(struct padata_privlist_add_tail (&padata->list, &pqueue->reorder.list);spin_unlock (&pqueue->reorder.lock); +/* +* Ensure the atomic_inc of reorder_objects above is ordered correctly +* with the trylock of pd->lock in padata_reorder. Pairs with smp_mb +* in padata_reorder. +*/ +smp_mb__after_atomic (); +put_cpu ();/* If we're running on the wrong CPU, call padata_reorder() via a
Greg Kroah-Hartman
maintainerPATCH 219/271 dm zoned: fix zone state management race
In reply to Greg Kroah-HartmanFrom: Damien Le Moal <[email protected]>
commit 3b8cafdd5436f9298b3bf6eb831df5eef5ee82b6 upstream.
dm-zoned uses the zone flag DMZ_ACTIVE to indicate that a zone of the backend device is being actively read or written and so cannot be reclaimed. This flag is set as long as the zone atomic reference counter is not 0. When this atomic is decremented and reaches 0 (e.g. on BIO completion), the active flag is cleared and set again whenever the zone is reused and BIO issued with the atomic counter incremented. These 2 operations (atomic inc/dec and flag set/clear) are however not always executed atomically under the target metadata mutex lock and this causes the warning:
WARN_ON(!test_bit(DMZ_ACTIVE, &zone->flags));
in dmz_deactivate_zone() to be displayed. This problem is regularly triggered with xfstests generic/209, generic/300, generic/451 and xfs/077 with XFS being used as the file system on the dm-zoned target device. Similarly, xfstests ext4/303, ext4/304, generic/209 and generic/300 trigger the warning with ext4 use.
This problem can be easily fixed by simply removing the DMZ_ACTIVE flag and managing the "ACTIVE" state by directly looking at the reference counter value. To do so, the functions dmz_activate_zone() and dmz_deactivate_zone() are changed to inline functions respectively calling atomic_inc() and atomic_dec(), while the dmz_is_active() macro is changed to an inline function calling atomic_read().
--- drivers/md/dm-zoned-metadata.c | 24 ------------------------ drivers/md/dm-zoned.h | 28 ++++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 28 deletions(-)
drivers/md/dm-zoned-metadata.c +0 -24
@@ -1594,30 +1594,6 @@ struct dm_zone *dmz_get_zone_for_reclaim }/* -* Activate a zone (increment its reference count). -*/ -void dmz_activate_zone (struct dm_zone *zone) -{ -set_bit (DMZ_ACTIVE , &zone->flags); -atomic_inc (&zone->refcount); -} - -/* -* Deactivate a zone. This decrement the zone reference counter -* and clears the active state of the zone once the count reaches 0, -* indicating that all BIOs to the zone have completed. Returns -* true if the zone was deactivated. -*/ -void dmz_deactivate_zone (struct dm_zone *zone) -{ -if (atomic_dec_and_test (&zone->refcount)) { -WARN_ON (!test_bit (DMZ_ACTIVE , &zone->flags)); -clear_bit_unlock (DMZ_ACTIVE , &zone->flags); -smp_mb__after_atomic (); - } -} - -/* * Get the zone mapping a chunk, if the chunk is mapped already. * If no mapping exist and the operation is WRITE, a zone is * allocated and used to map the chunk.
drivers/md/dm-zoned.h +24 -4
@@ -115,7 +115,6 @@ enum {DMZ_BUF ,/* Zone internal state */ -DMZ_ACTIVE ,DMZ_RECLAIM , DMZ_SEQ_WRITE_ERR, };
@@ -128,7 +127,6 @@ enum {#define dmz_is_empty (z) ((z)->wp_block == 0)#define dmz_is_offline (z) test_bit(DMZ_OFFLINE, &(z)->flags)#define dmz_is_readonly (z) test_bit(DMZ_READ_ONLY, &(z)->flags) -#define dmz_is_active (z) test_bit(DMZ_ACTIVE, &(z)->flags)#define dmz_in_reclaim (z) test_bit(DMZ_RECLAIM, &(z)->flags)#define dmz_seq_write_err (z) test_bit(DMZ_SEQ_WRITE_ERR, &(z)->flags)
@@ -188,8 +186,30 @@ void dmz_unmap_zone(struct dmz_metadataunsigned int dmz_nr_rnd_zones (struct dmz_metadata *zmd);unsigned int dmz_nr_unmap_rnd_zones (struct dmz_metadata *zmd); -void dmz_activate_zone (struct dm_zone *zone); -void dmz_deactivate_zone (struct dm_zone *zone); +/* +* Activate a zone (increment its reference count). +*/ +static inline void dmz_activate_zone (struct dm_zone *zone) +{ +atomic_inc (&zone->refcount); +} + +/* +* Deactivate a zone. This decrement the zone reference counter +* indicating that all BIOs to the zone have completed when the count is 0. +*/ +static inline void dmz_deactivate_zone (struct dm_zone *zone) +{ +atomic_dec (&zone->refcount); +} + +/* +* Test if a zone is active, that is, has a refcount > 0. +*/ +static inline bool dmz_is_active (struct dm_zone *zone) +{ +return atomic_read (&zone->refcount); +}int dmz_lock_zone_reclaim (struct dm_zone *zone);void dmz_unlock_zone_reclaim (struct dm_zone *zone);
Greg Kroah-Hartman
maintainerPATCH 220/271 xen/events: fix binding user event channels to cpus
In reply to Greg Kroah-HartmanFrom: Juergen Gross <[email protected]>
commit bce5963bcb4f9934faa52be323994511d59fd13c upstream.
When binding an interdomain event channel to a vcpu via IOCTL_EVTCHN_BIND_INTERDOMAIN not only the event channel needs to be bound, but the affinity of the associated IRQi must be changed, too. Otherwise the IRQ and the event channel won't be moved to another vcpu in case the original vcpu they were bound to is going offline.
--- drivers/xen/events/events_base.c | 12 ++++++++++-- drivers/xen/evtchn.c | 2 +- include/xen/events.h | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-)
drivers/xen/events/events_base.c +10 -2
@@ -1293,7 +1293,7 @@ void rebind_evtchn_irq(int evtchn, int i }/* Rebind an evtchn so that it gets delivered to a specific cpu */ -int xen_rebind_evtchn_to_cpu (int evtchn,unsigned tcpu) +static int xen_rebind_evtchn_to_cpu (int evtchn,unsigned int tcpu) {struct evtchn_bind_vcpu bind_vcpu;int masked;
@@ -1327,7 +1327,6 @@ int xen_rebind_evtchn_to_cpu(int evtchn,return 0 ; } -EXPORT_SYMBOL_GPL (xen_rebind_evtchn_to_cpu);static int set_affinity_irq (struct irq_data *data,const struct cpumask *dest,bool force)
@@ -1341,6 +1340,15 @@ static int set_affinity_irq(struct irq_dreturn ret; } +/* To be called with desc->lock held. */ +int xen_set_affinity_evtchn (struct irq_desc *desc,unsigned int tcpu) +{ +struct irq_data *d =irq_desc_get_irq_data (desc); + +return set_affinity_irq (d,cpumask_of (tcpu), false); +} +EXPORT_SYMBOL_GPL (xen_set_affinity_evtchn); +static void enable_dynirq (struct irq_data *data) {int evtchn =evtchn_from_irq (data->irq);
drivers/xen/evtchn.c +1 -1
@@ -447,7 +447,7 @@ static void evtchn_bind_interdom_next_vcthis_cpu_write (bind_last_selected_cpu, selected_cpu);/* unmask expects irqs to be disabled */ -xen_rebind_evtchn_to_cpu (evtchn, selected_cpu); +xen_set_affinity_evtchn (desc, selected_cpu);raw_spin_unlock_irqrestore (&desc->lock, flags); }
include/xen/events.h +2 -1
@@ -3,6 +3,7 @@#define _XEN_EVENTS_H#include <linux/interrupt.h> +#include <linux/irq.h> #ifdef CONFIG_PCI_MSI #include <linux/msi.h> #endif
@@ -59,7 +60,7 @@ void evtchn_put(unsigned int evtchn);void xen_send_IPI_one (unsigned int cpu,enum ipi_vector vector);void rebind_evtchn_irq (int evtchn,int irq); -int xen_rebind_evtchn_to_cpu (int evtchn,unsigned tcpu); +int xen_set_affinity_evtchn (struct irq_desc *desc,unsigned int tcpu);static inline void notify_remote_via_evtchn (int port) {
Greg Kroah-Hartman
maintainerPATCH 221/271 9p/xen: Add cleanup path in p9_trans_xen_init
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
commit 80a316ff16276b36d0392a8f8b2f63259857ae98 upstream.
If xenbus_register_frontend() fails in p9_trans_xen_init, we should call v9fs_unregister_trans() to do cleanup.
--- net/9p/trans_xen.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/9p/trans_xen.c +7 -1
@@ -530,13 +530,19 @@ static struct xenbus_driver xen_9pfs_frostatic int p9_trans_xen_init (void ) { +int rc; +if (!xen_domain ())return -ENODEV ;pr_info ("Initialising Xen transport for 9pfs\n" );v9fs_register_trans (&p9_xen_trans); -return xenbus_register_frontend (&xen_9pfs_front_driver); + rc =xenbus_register_frontend (&xen_9pfs_front_driver); +if (rc) +v9fs_unregister_trans (&p9_xen_trans); + +return rc; }module_init (p9_trans_xen_init);
Greg Kroah-Hartman
maintainerPATCH 222/271 9p/virtio: Add cleanup path in p9_virtio_init
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
commit d4548543fc4ece56c6f04b8586f435fb4fd84c20 upstream.
KASAN report this:
BUG: unable to handle kernel paging request at ffffffffa0097000 PGD 3870067 P4D 3870067 PUD 3871063 PMD 2326e2067 PTE 0 Oops: 0000 [#1 CPU: 0 PID: 5340 Comm: modprobe Not tainted 5.1.0-rc7+ #25 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014 RIP: 0010:__list_add_valid+0x10/0x70 Code: c3 48 8b 06 55 48 89 e5 5d 48 39 07 0f 94 c0 0f b6 c0 c3 90 90 90 90 90 90 90 55 48 89 d0 48 8b 52 08 48 89 e5 48 39 f2 75 19 <48> 8b 32 48 39 f0 75 3a
RSP: 0018:ffffc90000e23c68 EFLAGS: 00010246 RAX: ffffffffa00ad000 RBX: ffffffffa009d000 RCX: 0000000000000000 RDX: ffffffffa0097000 RSI: ffffffffa0097000 RDI: ffffffffa009d000 RBP: ffffc90000e23c68 R08: 0000000000000001 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: ffffffffa0097000 R13: ffff888231797180 R14: 0000000000000000 R15: ffffc90000e23e78 FS: 00007fb215285540(0000) GS:ffff888237a00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffffa0097000 CR3: 000000022f144000 CR4: 00000000000006f0 Call Trace: v9fs_register_trans+0x2f/0x60 [9pnet ? 0xffffffffa0087000 p9_virtio_init+0x25/0x1000 [9pnet_virtio do_one_initcall+0x6c/0x3cc ? kmem_cache_alloc_trace+0x248/0x3b0 do_init_module+0x5b/0x1f1 load_module+0x1db1/0x2690 ? m_show+0x1d0/0x1d0 __do_sys_finit_module+0xc5/0xd0 __x64_sys_finit_module+0x15/0x20 do_syscall_64+0x6b/0x1d0 entry_SYSCALL_64_after_hwframe+0x49/0xbe RIP: 0033:0x7fb214d8e839 Code: 00 f3 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01
RSP: 002b:00007ffc96554278 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
RAX: ffffffffffffffda RBX: 000055e67eed2aa0 RCX: 00007fb214d8e839
RDX: 0000000000000000 RSI: 000055e67ce95c2e RDI: 0000000000000003
RBP: 000055e67ce95c2e R08: 0000000000000000 R09: 000055e67eed2aa0
R10: 0000000000000003 R11: 0000000000000246 R12: 0000000000000000
R13: 000055e67eeda500 R14: 0000000000040000 R15: 000055e67eed2aa0
Modules linked in: 9pnet_virtio(+) 9pnet gre rfkill vmw_vsock_virtio_transport_common vsock [last unloaded: 9pnet_virtio CR2: ffffffffa0097000 ---[ end trace 4a52bb13ff07b761
If register_virtio_driver() fails in p9_virtio_init, we should call v9fs_unregister_trans() to do cleanup.
--- net/9p/trans_virtio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/9p/trans_virtio.c +7 -1
@@ -782,10 +782,16 @@ static struct p9_trans_module p9_virtio_/* The standard init function */ static int __init p9_virtio_init (void ) { +int rc; +INIT_LIST_HEAD (&virtio_chan_list);v9fs_register_trans (&p9_virtio_trans); -return register_virtio_driver (&p9_virtio_drv); + rc =register_virtio_driver (&p9_virtio_drv); +if (rc) +v9fs_unregister_trans (&p9_virtio_trans); + +return rc; } static void __exit p9_virtio_cleanup(void)
Greg Kroah-Hartman
maintainerPATCH 223/271 x86/boot: Fix memory leak in default_get_smp_config()
In reply to Greg Kroah-HartmanFrom: David Rientjes <[email protected]>
commit e74bd96989dd42a51a73eddb4a5510a6f5e42ac3 upstream.
When default_get_smp_config() is called with early == 1 and mpf->feature1 is non-zero, mpf is leaked because the return path does not do early_memunmap().
Fix this and share a common exit routine.
--- arch/x86/kernel/mpparse.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
arch/x86/kernel/mpparse.c +4 -6
@@ -547,17 +547,15 @@ void __init default_get_smp_config(unsig* local APIC has default address */ mp_lapic_addr =APIC_DEFAULT_PHYS_BASE ; -return ; + goto out; }pr_info ("Default MP configuration #%d\n" , mpf->feature1);construct_default_ISA_mptable (mpf->feature1); }else if (mpf->physptr) { -if (check_physptr (mpf, early)) { -early_memunmap (mpf,sizeof (*mpf)); -return ; - } +if (check_physptr (mpf, early)) + goto out; }else BUG ();
@@ -566,7 +564,7 @@ void __init default_get_smp_config(unsig/* * Only use the first configuration found. */ - +out:early_memunmap (mpf,sizeof (*mpf)); }
Greg Kroah-Hartman
maintainerPATCH 224/271 perf/x86/intel: Fix spurious NMI on fixed counter
In reply to Greg Kroah-HartmanFrom: Kan Liang <[email protected]>
commit e4557c1a46b0d32746bd309e1941914b5a6912b4 upstream.
If a user first sample a PEBS event on a fixed counter, then sample a non-PEBS event on the same fixed counter on Icelake, it will trigger spurious NMI. For example:
perf record -e 'cycles:p' -a
perf record -e 'cycles' -a
The error message for spurious NMI:
[June 21 15:38] Uhhuh. NMI received for unknown reason 30 on CPU 2.
[ +0.000000] Do you have a strange power saving mode enabled?
[ +0.000000] Dazed and confused, but trying to continue
The bug was introduced by the following commit:
commit 6f55967ad9d9 ("perf/x86/intel: Fix race in intel_pmu_disable_event()")
The commit moves the intel_pmu_pebs_disable() after intel_pmu_disable_fixed(), which returns immediately. The related bit of PEBS_ENABLE MSR will never be cleared for the fixed counter. Then a non-PEBS event runs on the fixed counter, but the bit on PEBS_ENABLE is still set, which triggers spurious NMIs.
Check and disable PEBS for fixed counters after intel_pmu_disable_fixed().
--- arch/x86/events/intel/core.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
arch/x86/events/intel/core.c +3 -5
@@ -2074,12 +2074,10 @@ static void intel_pmu_disable_event(stru cpuc->intel_ctrl_host_mask &= ~(1ull << hwc->idx); cpuc->intel_cp_status &= ~(1ull << hwc->idx); -if (unlikely (hwc->config_base ==MSR_ARCH_PERFMON_FIXED_CTR_CTRL )) { +if (unlikely (hwc->config_base ==MSR_ARCH_PERFMON_FIXED_CTR_CTRL ))intel_pmu_disable_fixed (hwc); -return ; - } - -x86_pmu_disable_event (event); +else +x86_pmu_disable_event (event);/* * Needs to be called after x86_pmu_disable_event,
Greg Kroah-Hartman
maintainerPATCH 225/271 perf/x86/amd/uncore: Do not set ThreadMask and SliceMask for non-L3 PMCs
In reply to Greg Kroah-HartmanFrom: Kim Phillips <[email protected]>
commit 16f4641166b10e199f0d7b68c2c5f004fef0bda3 upstream.
The following commit:
d7cbbe49a930 ("perf/x86/amd/uncore: Set ThreadMask and SliceMask for L3 Cache perf events")
enables L3 PMC events for all threads and slices by writing 1's in 'ChL3PmcCfg' (L3 PMC PERF_CTL) register fields.
Those bitfields overlap with high order event select bits in the Data Fabric PMC control register, however.
So when a user requests raw Data Fabric events (-e amd_df/event=0xYYY/), the two highest order bits get inadvertently set, changing the counter select to events that don't exist, and for which no counts are read.
This patch changes the logic to write the L3 masks only when dealing with L3 PMC counters.
AMD Family 16h and below Northbridge (NB) counters were not affected.
--- arch/x86/events/amd/uncore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/amd/uncore.c +1 -1
@@ -214,7 +214,7 @@ static int amd_uncore_event_init(struct* SliceMask and ThreadMask need to be set for certain L3 events in * Family 17h. For other events, the two fields do not affect the count. */ -if (l3_mask) +if (l3_mask &&is_llc_event (event)) hwc->config |= (AMD64_L3_SLICE_MASK |AMD64_L3_THREAD_MASK );if (event->cpu <0 )
Greg Kroah-Hartman
maintainerPATCH 226/271 perf/x86/amd/uncore: Set the thread mask for F17h L3 PMCs
In reply to Greg Kroah-HartmanFrom: Kim Phillips <[email protected]>
commit 2f217d58a8a086d3399fecce39fb358848e799c4 upstream.
Fill in the L3 performance event select register ThreadMask bitfield, to enable per hardware thread accounting.
--- arch/x86/events/amd/uncore.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
arch/x86/events/amd/uncore.c +11 -4
@@ -210,15 +210,22 @@ static int amd_uncore_event_init(struct hwc->config = event->attr.config &AMD64_RAW_EVENT_MASK_NB ; hwc->idx =-1 ; +if (event->cpu <0 ) +return -EINVAL ; +/* * SliceMask and ThreadMask need to be set for certain L3 events in * Family 17h. For other events, the two fields do not affect the count. */ -if (l3_mask &&is_llc_event (event)) - hwc->config |= (AMD64_L3_SLICE_MASK |AMD64_L3_THREAD_MASK ); +if (l3_mask &&is_llc_event (event)) { +int thread =2 * (cpu_data (event->cpu).cpu_core_id %4 ); -if (event->cpu <0 ) -return -EINVAL ; +if (smp_num_siblings >1 ) + thread +=cpu_data (event->cpu).apicid &1 ; + + hwc->config |= (1ULL << (AMD64_L3_THREAD_SHIFT + thread) & +AMD64_L3_THREAD_MASK ) |AMD64_L3_SLICE_MASK ; + } uncore =event_to_amd_uncore (event);if (!uncore)
Greg Kroah-Hartman
maintainerPATCH 227/271 drm/edid: parse CEA blocks embedded in DisplayID
In reply to Greg Kroah-HartmanFrom: Andres Rodriguez <[email protected]>
commit e28ad544f462231d3fd081a7316339359efbb481 upstream.
DisplayID blocks allow embedding of CEA blocks. The payloads are identical to traditional top level CEA extension blocks, but the header is slightly different.
This change allows the CEA parser to find a CEA block inside a DisplayID block. Additionally, it adds support for parsing the embedded CTA header. No further changes are necessary due to payload parity.
This change fixes audio support for the Valve Index HMD.
--- drivers/gpu/drm/drm_edid.c | 81 ++++++++++++++++++++++++++++++++++++++------ include/drm/drm_displayid.h | 10 +++++ 2 files changed, 80 insertions(+), 11 deletions(-)
drivers/gpu/drm/drm_edid.c +70 -11
@@ -1349,6 +1349,7 @@ MODULE_PARM_DESC(edid_fixup,static void drm_get_displayid (struct drm_connector *connector,struct edid *edid); +static int validate_displayid (u8 *displayid,int length,int idx);static int drm_edid_block_checksum (const u8 *raw_edid) {
@@ -2932,16 +2933,46 @@ static u8 *drm_find_edid_extension(constreturn edid_ext; } -static u8 *drm_find_cea_extension (const struct edid *edid) -{ -return drm_find_edid_extension (edid,CEA_EXT ); -}static u8 *drm_find_displayid_extension (const struct edid *edid) {return drm_find_edid_extension (edid,DISPLAYID_EXT ); } +static u8 *drm_find_cea_extension (const struct edid *edid) +{ +int ret; +int idx =1 ; +int length =EDID_LENGTH ; +struct displayid_block *block; +u8 *cea; +u8 *displayid; + +/* Look for a top level CEA extension block */ + cea =drm_find_edid_extension (edid,CEA_EXT ); +if (cea) +return cea; + +/* CEA blocks can also be found embedded in a DisplayID block */ + displayid =drm_find_displayid_extension (edid); +if (!displayid) +return NULL ; + + ret =validate_displayid (displayid, length, idx); +if (ret) +return NULL ; + + idx +=sizeof (struct displayid_hdr ); +for_each_displayid_db (displayid, block, idx, length) { +if (block->tag ==DATA_BLOCK_CTA ) { + cea = (u8 *)block; +break ; + } + } + +return cea; +} +/* * Calculate the alternate clock for the CEA mode * (60Hz vs. 59.94Hz etc.)
@@ -3665,13 +3696,38 @@ cea_revision(const u8 *cea)static int cea_db_offsets (const u8 *cea,int *start,int *end) { -/* Data block offset in CEA extension block */ - *start =4 ; - *end = cea[2 ]; -if (*end ==0 ) - *end =127 ; -if (*end <4 || *end >127 ) -return -ERANGE ; +/* DisplayID CTA extension blocks and top-level CEA EDID +* block header definitions differ in the following bytes: +* 1) Byte 2 of the header specifies length differently, +* 2) Byte 3 is only present in the CEA top level block. +* +* The different definitions for byte 2 follow. +* +* DisplayID CTA extension block defines byte 2 as: +* Number of payload bytes +* +* CEA EDID block defines byte 2 as: +* Byte number (decimal) within this block where the 18-byte +* DTDs begin. If no non-DTD data is present in this extension +* block, the value should be set to 04h (the byte after next). +* If set to 00h, there are no DTDs present in this block and +* no non-DTD data. +*/ +if (cea[0 ] ==DATA_BLOCK_CTA ) { + *start =3 ; + *end = *start + cea[2 ]; + }else if (cea[0 ] ==CEA_EXT ) { +/* Data block offset in CEA extension block */ + *start =4 ; + *end = cea[2 ]; +if (*end ==0 ) + *end =127 ; +if (*end <4 || *end >127 ) +return -ERANGE ; + }else { +return -ENOTSUPP ; + } +return 0 ; }
@@ -5218,6 +5274,9 @@ static int drm_parse_display_id(struct dcase DATA_BLOCK_TYPE_1_DETAILED_TIMING :/* handled in mode gathering code. */ break ; +case DATA_BLOCK_CTA : +/* handled in the cea parser code. */ +break ;default :DRM_DEBUG_KMS ("found DisplayID tag 0x%x, unhandled\n" , block->tag);break ;
include/drm/drm_displayid.h +10 -0
@@ -40,6 +40,7 @@#define DATA_BLOCK_DISPLAY_INTERFACE 0x0f#define DATA_BLOCK_STEREO_DISPLAY_INTERFACE 0x10#define DATA_BLOCK_TILED_DISPLAY 0x12 +#define DATA_BLOCK_CTA 0x81#define DATA_BLOCK_VENDOR_SPECIFIC 0x7f
@@ -90,4 +91,13 @@ struct displayid_detailed_timing_block {struct displayid_block base; struct displayid_detailed_timings_1 timings[0]; }; + +#define for_each_displayid_db (displayid, block, idx, length) \ + for ((block) = (struct displayid_block *)&(displayid)[idx]; \ + (idx) + sizeof(struct displayid_block) <= (length) && \ + (idx) + sizeof(struct displayid_block) + (block)->num_bytes <= (length) && \ + (block)->num_bytes > 0; \ + (idx) += (block)->num_bytes + sizeof(struct displayid_block), \ + (block) = (struct displayid_block *)&(displayid)[idx]) +#endif
Greg Kroah-Hartman
maintainerPATCH 228/271 intel_th: pci: Add Ice Lake NNPI support
In reply to Greg Kroah-HartmanFrom: Alexander Shishkin <[email protected]>
commit 4aa5aed2b6f267592705a526f57518a5d715b769 upstream.
This adds Ice Lake NNPI support to the Intel(R) Trace Hub.
--- drivers/hwtracing/intel_th/pci.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/hwtracing/intel_th/pci.c +5 -0
@@ -170,6 +170,11 @@ static const struct pci_device_id intel_ PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x02a6), .driver_data = (kernel_ulong_t)&intel_th_2x, }, + { +/* Ice Lake NNPI */ + PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x45c5), + .driver_data = (kernel_ulong_t)&intel_th_2x, + }, { 0 }, };
Greg Kroah-Hartman
maintainerPATCH 229/271 PCI: hv: Fix a use-after-free bug in hv_eject_device_work()
In reply to Greg Kroah-HartmanFrom: Dexuan Cui <[email protected]>
commit 4df591b20b80cb77920953812d894db259d85bd7 upstream.
Fix a use-after-free in hv_eject_device_work().
--- drivers/pci/controller/pci-hyperv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/pci/controller/pci-hyperv.c +9 -6
@@ -1880,6 +1880,7 @@ static void hv_pci_devices_present(strucstatic void hv_eject_device_work (struct work_struct *work) {struct pci_eject_response *ejct_pkt; +struct hv_pcibus_device *hbus;struct hv_pci_dev *hpdev;struct pci_dev *pdev;unsigned long flags;
@@ -1890,6 +1891,7 @@ static void hv_eject_device_work(struct } ctxt; hpdev = container_of(work, struct hv_pci_dev, wrk); + hbus = hpdev->hbus;WARN_ON (hpdev->state != hv_pcichild_ejecting);
@@ -1900,8 +1902,7 @@ static void hv_eject_device_work(struct* because hbus->pci_bus may not exist yet. */ wslot =wslot_to_devfn (hpdev->desc.win_slot.slot); - pdev =pci_get_domain_bus_and_slot (hpdev->hbus->sysdata.domain,0 , - wslot); + pdev =pci_get_domain_bus_and_slot (hbus->sysdata.domain,0 , wslot);if (pdev) {pci_lock_rescan_remove ();pci_stop_and_remove_bus_device (pdev);
@@ -1909,9 +1910,9 @@ static void hv_eject_device_work(structpci_unlock_rescan_remove (); } -spin_lock_irqsave (&hpdev->hbus->device_list_lock, flags); +spin_lock_irqsave (&hbus->device_list_lock, flags);list_del (&hpdev->list_entry); -spin_unlock_irqrestore (&hpdev->hbus->device_list_lock, flags); +spin_unlock_irqrestore (&hbus->device_list_lock, flags);if (hpdev->pci_slot)pci_destroy_slot (hpdev->pci_slot);
@@ -1920,7 +1921,7 @@ static void hv_eject_device_work(struct ejct_pkt = (struct pci_eject_response *)&ctxt.pkt.message; ejct_pkt->message_type.type =PCI_EJECTION_COMPLETE ; ejct_pkt->wslot.slot = hpdev->desc.win_slot.slot; -vmbus_sendpacket (hpdev->hbus->hdev->channel, ejct_pkt, +vmbus_sendpacket (hbus->hdev->channel, ejct_pkt,sizeof (*ejct_pkt), (unsigned long )&ctxt.pkt,VM_PKT_DATA_INBAND ,0 );
@@ -1929,7 +1930,9 @@ static void hv_eject_device_work(struct/* For the two refs got in new_pcichild_device() */ put_pcichild (hpdev);put_pcichild (hpdev); -put_hvpcibus (hpdev->hbus); +/* hpdev has been freed. Do not use it any more. */ + +put_hvpcibus (hbus); }/**
Greg Kroah-Hartman
maintainerPATCH 230/271 PCI: Do not poll for PME if the device is in D3cold
In reply to Greg Kroah-HartmanFrom: Mika Westerberg <[email protected]>
commit 000dd5316e1c756a1c028f22e01d06a38249dd4d upstream.
PME polling does not take into account that a device that is directly connected to the host bridge may go into D3cold as well. This leads to a situation where the PME poll thread reads from a config space of a device that is in D3cold and gets incorrect information because the config space is not accessible.
Here is an example from Intel Ice Lake system where two PCIe root ports are in D3cold (I've instrumented the kernel to log the PMCSR register contents):
[ 62.971442] pcieport 0000:00:07.1: Check PME status, PMCSR=0xffff [ 62.971504] pcieport 0000:00:07.0: Check PME status, PMCSR=0xffff
Since 0xffff is interpreted so that PME is pending, the root ports will be runtime resumed. This repeats over and over again essentially blocking all runtime power management.
Prevent this from happening by checking whether the device is in D3cold before its PME status is read.
--- drivers/pci/pci.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/pci/pci.c +7 -0
@@ -2004,6 +2004,13 @@ static void pci_pme_list_scan(struct wor*/ if (bridge && bridge->current_state !=PCI_D0 )continue ; +/* +* If the device is in D3cold it should not be +* polled either. +*/ +if (pme_dev->dev->current_state == PCI_D3cold) +continue ; +pci_pme_wakeup (pme_dev->dev,NULL ); }else {list_del (&pme_dev->list);
Greg Kroah-Hartman
maintainerPATCH 231/271 PCI: qcom: Ensure that PERST is asserted for at least 100 ms
In reply to Greg Kroah-HartmanFrom: Niklas Cassel <[email protected]>
commit 64adde31c8e996a6db6f7a1a4131180e363aa9f2 upstream.
Currently, there is only a 1 ms sleep after asserting PERST.
Reading the datasheets for different endpoints, some require PERST to be asserted for 10 ms in order for the endpoint to perform a reset, others require it to be asserted for 50 ms.
Several SoCs using this driver uses PCIe Mini Card, where we don't know what endpoint will be plugged in.
The PCI Express Card Electromechanical Specification r2.0, section 2.2, "PERST# Signal" specifies:
"On power up, the deassertion of PERST# is delayed 100 ms (TPVPERL) from the power rails achieving specified operating limits."
Add a sleep of 100 ms before deasserting PERST, in order to ensure that we are compliant with the spec.
--- drivers/pci/controller/dwc/pcie-qcom.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/controller/dwc/pcie-qcom.c +2 -0
@@ -178,6 +178,8 @@ static void qcom_ep_reset_assert(structstatic void qcom_ep_reset_deassert (struct qcom_pcie *pcie) { +/* Ensure that PERST has been asserted for at least 100 ms */ +msleep (100 );gpiod_set_value_cansleep (pcie->reset,0 );usleep_range (PERST_DELAY_US ,PERST_DELAY_US +500 ); }
Greg Kroah-Hartman
maintainerPATCH 232/271 Btrfs: fix data loss after inode eviction, renaming it, and fsync it
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit d1d832a0b51dd9570429bb4b81b2a6c1759e681a upstream.
When we log an inode, regardless of logging it completely or only that it exists, we always update it as logged (logged_trans and last_log_commit fields of the inode are updated). This is generally fine and avoids future attempts to log it from having to do repeated work that brings no value.
However, if we write data to a file, then evict its inode after all the dealloc was flushed (and ordered extents completed), rename the file and fsync it, we end up not logging the new extents, since the rename may result in logging that the inode exists in case the parent directory was logged before. The following reproducer shows and explains how this can happen:
$ mkfs.btrfs -f /dev/sdb $ mount /dev/sdb /mnt
$ mkdir /mnt/dir $ touch /mnt/dir/foo $ touch /mnt/dir/bar
# Do a direct IO write instead of a buffered write because with a
# buffered write we would need to make sure dealloc gets flushed and # complete before we do the inode eviction later, and we can not do that # from user space with call to things such as sync(2) since that results # in a transaction commit as well. $ xfs_io -d -c "pwrite -S 0xd3 0 4K" /mnt/dir/bar
# Keep the directory dir in use while we evict inodes. We want our file # bar's inode to be evicted but we don't want our directory's inode to
# be evicted (if it were evicted too, we would not be able to reproduce # the issue since the first fsync below, of file foo, would result in a # transaction commit. $ ( cd /mnt/dir; while true; do :; done ) & $ pid=$!
# Wait a bit to give time for the background process to chdir.
$ sleep 0.1
# Evict all inodes, except the inode for the directory dir because it is
# currently in use by our background process. $ echo 2 > /proc/sys/vm/drop_caches
# fsync file foo, which ends up persisting information about the parent # directory because it is a new inode. $ xfs_io -c fsync /mnt/dir/foo
# Rename bar, this results in logging that this inode exists (inode item, # names, xattrs) because the parent directory is in the log.
$ mv /mnt/dir/bar /mnt/dir/baz
# Now fsync baz, which ends up doing absolutely nothing because of the
# rename operation which logged that the inode exists only. $ xfs_io -c fsync /mnt/dir/baz
<power failure>
$ mount /dev/sdb /mnt $ od -t x1 -A d /mnt/dir/baz 0000000
--> Empty file, data we wrote is missing.
Fix this by not updating last_sub_trans of an inode when we are logging only that it exists and the inode was not yet logged since it was loaded from disk (full_sync bit set), this is enough to make btrfs_inode_in_log() return false for this scenario and make us log the inode. The logged_trans of the inode is still always setsince that alone is used to track if names need to be deleted as part of unlink operations.
--- fs/btrfs/tree-log.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
fs/btrfs/tree-log.c +11 -1
@@ -5250,9 +5250,19 @@ log_extents: } } +/* +* Don't update last_log_commit if we logged that an inode exists after +* it was loaded to memory (full_sync bit set). +* This is to prevent data loss when we do a write to the inode, then +* the inode gets evicted after all delalloc was flushed, then we log +* it exists (due to a rename for example) and then fsync it. This last +* fsync would do nothing (not logging the extents previously written). +*/ spin_lock (&inode->lock); inode->logged_trans = trans->transid; - inode->last_log_commit = inode->last_sub_trans; +if (inode_only !=LOG_INODE_EXISTS || + !test_bit (BTRFS_INODE_NEEDS_FULL_SYNC , &inode->runtime_flags)) + inode->last_log_commit = inode->last_sub_trans;spin_unlock (&inode->lock); out_unlock:mutex_unlock (&inode->log_mutex);
Greg Kroah-Hartman
maintainerPATCH 233/271 Btrfs: fix fsync not persisting dentry deletions due to inode evictions
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 803f0f64d17769071d7287d9e3e3b79a3e1ae937 upstream.
In order to avoid searches on a log tree when unlinking an inode, we check if the inode being unlinked was logged in the current transaction, as well as the inode of its parent directory. When any of the inodes are logged, we proceed to delete directory items and inode reference items from the log, to ensure that if a subsequent fsync of only the inode being unlinked or only of the parent directory when the other is not fsync'ed as well, does not result in the entry still existing after a power failure.
That check however is not reliable when one of the inodes involved (the one being unlinked or its parent directory's inode) is evicted, since the logged_trans field is transient, that is, it is not stored on disk, so it is lost when the inode is evicted and loaded into memory again (which is set to zero on load). As a consequence the checks currently being done by btrfs_del_dir_entries_in_log() and btrfs_del_inode_ref_in_log() always return true if the inode was evicted before, regardless of the inode having been logged or not before (and in the current transaction), this results in the dentry being unlinked still existing after a log replay if after the unlink operation only one of the inodes involved is fsync'ed.
Example:
$ mkfs.btrfs -f /dev/sdb $ mount /dev/sdb /mnt
$ mkdir /mnt/dir $ touch /mnt/dir/foo $ xfs_io -c fsync /mnt/dir/foo
# Keep an open file descriptor on our directory while we evict inodes. # We just want to evict the file's inode, the directory's inode must not
# be evicted. $ ( cd /mnt/dir; while true; do :; done ) & $ pid=$!
# Wait a bit to give time to background process to chdir to our test
# directory. $ sleep 0.5
# Trigger eviction of the file's inode.
$ echo 2 > /proc/sys/vm/drop_caches
# Unlink our file and fsync the parent directory. After a power failure
# we don't expect to see the file anymore, since we fsync'ed the parent # directory. $ rm -f $SCRATCH_MNT/dir/foo $ xfs_io -c fsync /mnt/dir
<power failure>
$ mount /dev/sdb /mnt $ ls /mnt/dir foo $ --> file still there, unlink not persisted despite explicit fsync on dir
Fix this by checking if the inode has the full_sync bit set in its runtime flags as well, since that bit is set everytime an inode is loaded from disk, or for other less common cases such as after a shrinking truncate or failure to allocate extent maps for holes, and gets cleared after the first fsync. Also consider the inode as possibly logged only if it was last modified in the current transaction (besides having the full_fsync flag set).
--- fs/btrfs/tree-log.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
fs/btrfs/tree-log.c +26 -2
@@ -3263,6 +3263,30 @@ int btrfs_free_log_root_tree(struct btrf }/* +* Check if an inode was logged in the current transaction. We can't always rely +* on an inode's logged_trans value, because it's an in-memory only field and +* therefore not persisted. This means that its value is lost if the inode gets +* evicted and loaded again from disk (in which case it has a value of 0, and +* certainly it is smaller then any possible transaction ID), when that happens +* the full_sync flag is set in the inode's runtime flags, so on that case we +* assume eviction happened and ignore the logged_trans value, assuming the +* worst case, that the inode was logged before in the current transaction. +*/ +static bool inode_logged (struct btrfs_trans_handle *trans, +struct btrfs_inode *inode) +{ +if (inode->logged_trans == trans->transid) +return true; + +if (inode->last_trans == trans->transid && +test_bit (BTRFS_INODE_NEEDS_FULL_SYNC , &inode->runtime_flags) && + !test_bit (BTRFS_FS_LOG_RECOVERING , &trans->fs_info->flags)) +return true; + +return false; +} + +/* * If both a file and directory are logged, and unlinks or renames are * mixed in, we have a few interesting corners: *
@@ -3296,7 +3320,7 @@ int btrfs_del_dir_entries_in_log(structint bytes_del =0 ;u64 dir_ino =btrfs_ino (dir); -if (dir->logged_trans < trans->transid) +if (!inode_logged (trans, dir))return 0 ; ret =join_running_log_trans (root);
@@ -3401,7 +3425,7 @@ int btrfs_del_inode_ref_in_log(struct btu64 index;int ret; -if (inode->logged_trans < trans->transid) +if (!inode_logged (trans, inode))return 0 ; ret =join_running_log_trans (root);
Greg Kroah-Hartman
maintainerPATCH 234/271 Btrfs: add missing inode version, ctime and mtime updates when punching hole
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 179006688a7e888cbff39577189f2e034786d06a upstream.
If the range for which we are punching a hole covers only part of a page, we end up updating the inode item but we skip the update of the inode's iversion, mtime and ctime. Fix that by ensuring we update those properties of the inode.
A patch for fstests test case generic/059 that tests this as been sent along with this fix.
--- fs/btrfs/file.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/btrfs/file.c +5 -0
@@ -2732,6 +2732,11 @@ out_only_mutex:* for detecting, at fsync time, if the inode isn't yet in the * log tree or it's there but not up to date. */ +struct timespec64 now =current_time (inode); + +inode_inc_iversion (inode); + inode->i_mtime = now; + inode->i_ctime = now; trans =btrfs_start_transaction (root,1 );if (IS_ERR (trans)) { err =PTR_ERR (trans);
Greg Kroah-Hartman
maintainerPATCH 235/271 IB/mlx5: Report correctly tag matching rendezvous capability
In reply to Greg Kroah-HartmanFrom: Danit Goldberg <[email protected]>
commit 89705e92700170888236555fe91b45e4c1bb0985 upstream.
Userspace expects the IB_TM_CAP_RC bit to indicate that the device supports RC transport tag matching with rendezvous offload. However the firmware splits this into two capabilities for eager and rendezvous tag matching.
Only if the FW supports both modes should userspace be told the tag matching capability is available.
--- drivers/infiniband/hw/mlx5/main.c | 8 ++++++-- include/rdma/ib_verbs.h | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/main.c +6 -2
@@ -939,15 +939,19 @@ static int mlx5_ib_query_device(struct i }if (MLX5_CAP_GEN (mdev, tag_matching)) { - props->tm_caps.max_rndv_hdr_size =MLX5_TM_MAX_RNDV_MSG_SIZE ; props->tm_caps.max_num_tags = (1 <<MLX5_CAP_GEN (mdev, log_tag_matching_list_sz)) -1 ; - props->tm_caps.flags =IB_TM_CAP_RC ; props->tm_caps.max_ops =1 <<MLX5_CAP_GEN (mdev, log_max_qp_sz); props->tm_caps.max_sge =MLX5_TM_MAX_SGE ; } +if (MLX5_CAP_GEN (mdev, tag_matching) && +MLX5_CAP_GEN (mdev, rndv_offload_rc)) { + props->tm_caps.flags =IB_TM_CAP_RNDV_RC ; + props->tm_caps.max_rndv_hdr_size =MLX5_TM_MAX_RNDV_MSG_SIZE ; + } +if (MLX5_CAP_GEN (dev->mdev, cq_moderation)) { props->cq_caps.max_cq_moderation_count =MLX5_MAX_CQ_COUNT ;
include/rdma/ib_verbs.h +2 -2
@@ -290,8 +290,8 @@ struct ib_rss_caps { };enum ib_tm_cap_flags { -/* Support tag matching on RC transport */ -IB_TM_CAP_RC =1 <<0 , +/* Support tag matching with rendezvous offload for RC transport */ +IB_TM_CAP_RNDV_RC =1 <<0 , };struct ib_tm_caps {
Greg Kroah-Hartman
maintainerPATCH 236/271 HID: wacom: generic: only switch the mode on devices with LEDs
In reply to Greg Kroah-HartmanFrom: Aaron Armstrong Skomra <[email protected]>
commit d8e9806005f28bbb49899dab2068e3359e22ba35 upstream.
Currently, the driver will attempt to set the mode on all devices with a center button, but some devices with a center button lack LEDs, and attempting to set the LEDs on devices without LEDs results in the kernel error message of the form:
"leds input8::wacom-0.1: Setting an LED's brightness failed (-32)"
This is because the generic codepath erroneously assumes that the BUTTON_CENTER usage indicates that the device has LEDs, the previously ignored TOUCH_RING_SETTING usage is a more accurate indication of the existence of LEDs on the device.
--- drivers/hid/wacom_sys.c | 3 +++ drivers/hid/wacom_wac.c | 2 -- drivers/hid/wacom_wac.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/hid/wacom_sys.c +3 -0
@@ -275,6 +275,9 @@ static void wacom_feature_mapping(structwacom_hid_usage_quirk (hdev, field, usage);switch (equivalent_usage) { +case WACOM_HID_WD_TOUCH_RING_SETTING : + wacom->generic_has_leds = true; +break ;case HID_DG_CONTACTMAX :/* leave touch_max as is if predefined */ if (!features->touch_max) {
drivers/hid/wacom_wac.c +0 -2
@@ -1928,8 +1928,6 @@ static void wacom_wac_pad_usage_mapping( features->device_type |=WACOM_DEVICETYPE_PAD ;break ;case WACOM_HID_WD_BUTTONCENTER : - wacom->generic_has_leds = true; -/* fall through */ case WACOM_HID_WD_BUTTONHOME :case WACOM_HID_WD_BUTTONUP :case WACOM_HID_WD_BUTTONDOWN :
drivers/hid/wacom_wac.h +1 -0
@@ -145,6 +145,7 @@#define WACOM_HID_WD_OFFSETBOTTOM (WACOM_HID_UP_WACOMDIGITIZER | 0x0d33)#define WACOM_HID_WD_DATAMODE (WACOM_HID_UP_WACOMDIGITIZER | 0x1002)#define WACOM_HID_WD_DIGITIZERINFO (WACOM_HID_UP_WACOMDIGITIZER | 0x1013) +#define WACOM_HID_WD_TOUCH_RING_SETTING (WACOM_HID_UP_WACOMDIGITIZER | 0x1032)#define WACOM_HID_UP_G9 0xff090000#define WACOM_HID_G9_PEN (WACOM_HID_UP_G9 | 0x02)#define WACOM_HID_G9_TOUCHSCREEN (WACOM_HID_UP_G9 | 0x11)
Greg Kroah-Hartman
maintainerPATCH 237/271 HID: wacom: generic: Correct pad syncing
In reply to Greg Kroah-HartmanFrom: Aaron Armstrong Skomra <[email protected]>
commit d4b8efeb46d99a5d02e7f88ac4eaccbe49370770 upstream.
Only sync the pad once per report, not once per collection. Also avoid syncing the pad on battery reports.
--- drivers/hid/wacom_wac.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/hid/wacom_wac.c +8 -7
@@ -2119,14 +2119,12 @@ static void wacom_wac_pad_report(structbool active = wacom_wac->hid_data.inrange_state !=0 ;/* report prox for expresskey events */ -if ((wacom_equivalent_usage (field->physical) ==HID_DG_TABLETFUNCTIONKEY ) && - wacom_wac->hid_data.pad_input_event_flag) { +if (wacom_wac->hid_data.pad_input_event_flag) {input_event (input,EV_ABS ,ABS_MISC , active ?PAD_DEVICE_ID :0 );input_sync (input);if (!active) wacom_wac->hid_data.pad_input_event_flag = false; } - } static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
@@ -2723,9 +2721,7 @@ static int wacom_wac_collection(struct hif (report->type !=HID_INPUT_REPORT )return -1 ; -if (WACOM_PAD_FIELD (field) && wacom->wacom_wac.pad_input) -wacom_wac_pad_report (hdev, report, field); -else if (WACOM_PEN_FIELD (field) && wacom->wacom_wac.pen_input) +if (WACOM_PEN_FIELD (field) && wacom->wacom_wac.pen_input)wacom_wac_pen_report (hdev, report);else if (WACOM_FINGER_FIELD (field) && wacom->wacom_wac.touch_input)wacom_wac_finger_report (hdev, report);
@@ -2739,7 +2735,7 @@ void wacom_wac_report(struct hid_devicestruct wacom_wac *wacom_wac = &wacom->wacom_wac;struct hid_field *field;bool pad_in_hid_field = false, pen_in_hid_field = false, - finger_in_hid_field = false; + finger_in_hid_field = false, true_pad = false;int r;int prev_collection =-1 ;
@@ -2755,6 +2751,8 @@ void wacom_wac_report(struct hid_device pen_in_hid_field = true;if (WACOM_FINGER_FIELD (field)) finger_in_hid_field = true; +if (wacom_equivalent_usage (field->physical) ==HID_DG_TABLETFUNCTIONKEY ) + true_pad = true; }wacom_wac_battery_pre_report (hdev, report);
@@ -2778,6 +2776,9 @@ void wacom_wac_report(struct hid_device }wacom_wac_battery_report (hdev, report); + +if (true_pad && wacom->wacom_wac.pad_input) +wacom_wac_pad_report (hdev, report, field); }static int wacom_bpt_touch (struct wacom_wac *wacom)
Greg Kroah-Hartman
maintainerPATCH 238/271 HID: wacom: correct touch resolution x/y typo
In reply to Greg Kroah-HartmanFrom: Aaron Armstrong Skomra <[email protected]>
commit 68c20cc2164cc5c7c73f8012ae6491afdb1f7f72 upstream.
This affects the 2nd-gen Intuos Pro Medium and Large when using their Bluetooth connection.
--- drivers/hid/wacom_wac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/wacom_wac.c +1 -1
@@ -3734,7 +3734,7 @@ int wacom_setup_touch_input_capabilities 0, 5920, 4, 0); }input_abs_set_res (input_dev,ABS_MT_POSITION_X ,40 ); -input_abs_set_res (input_dev,ABS_MT_POSITION_X ,40 ); +input_abs_set_res (input_dev,ABS_MT_POSITION_Y ,40 );/* fall through */
Greg Kroah-Hartman
maintainerPATCH 239/271 libnvdimm/pfn: fix fsdax-mode namespace info-block zero-fields
In reply to Greg Kroah-HartmanFrom: Dan Williams <[email protected]>
commit 7e3e888dfc138089f4c15a81b418e88f0978f744 upstream.
At namespace creation time there is the potential for the "expected to be zero" fields of a 'pfn' info-block to be filled with indeterminate data. While the kernel buffer is zeroed on allocation it is immediately overwritten by nd_pfn_validate() filling it with the current contents of the on-media info-block location. For fields like, 'flags' and the 'padding' it potentially means that future implementations can not rely on those fields being zero.
In preparation to stop using the 'start_pad' and 'end_trunc' fields for section alignment, arrange for fields that are not explicitly initialized to be guaranteed zero. Bump the minor version to indicate it is safe to assume the 'padding' and 'flags' are zero. Otherwise, this corruption is expected to benign since all other critical fields are explicitly initialized.
Note The cc: stable is about spreading this new policy to as many kernels as possible not fixing an issue in those kernels. It is not until the change titled "libnvdimm/pfn: Stop padding pmem namespaces to section alignment" where this improper initialization becomes a problem. So if someone decides to backport "libnvdimm/pfn: Stop padding pmem namespaces to section alignment" (which is not tagged for stable), make sure this pre-requisite is flagged.
--- drivers/nvdimm/dax_devs.c | 2 +- drivers/nvdimm/pfn.h | 1 + drivers/nvdimm/pfn_devs.c | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-)
drivers/nvdimm/dax_devs.c +1 -1
@@ -126,7 +126,7 @@ int nd_dax_probe(struct device *dev, strnvdimm_bus_unlock (&ndns->dev);if (!dax_dev)return -ENOMEM ; - pfn_sb =devm_kzalloc (dev,sizeof (*pfn_sb),GFP_KERNEL ); + pfn_sb =devm_kmalloc (dev,sizeof (*pfn_sb),GFP_KERNEL ); nd_pfn->pfn_sb = pfn_sb; rc =nd_pfn_validate (nd_pfn,DAX_SIG );dev_dbg (dev,"dax: %s\n" , rc ==0 ?dev_name (dax_dev) :"<none>" );
drivers/nvdimm/pfn.h +1 -0
@@ -36,6 +36,7 @@ struct nd_pfn_sb {__le32 end_trunc;/* minor-version-2 record the base alignment of the mapping */ __le32 align; +/* minor-version-3 guarantee the padding and flags are zero */ u8 padding[4000 ];__le64 checksum; };
drivers/nvdimm/pfn_devs.c +15 -3
@@ -361,6 +361,15 @@ struct device *nd_pfn_create(struct nd_rreturn dev; } +/** +* nd_pfn_validate - read and validate info-block +* @nd_pfn: fsdax namespace runtime state / properties +* @sig: 'devdax' or 'fsdax' signature +* +* Upon return the info-block buffer contents (->pfn_sb) are +* indeterminate when validation fails, and a coherent info-block +* otherwise. +*/ int nd_pfn_validate (struct nd_pfn *nd_pfn,const char *sig) {u64 checksum, offset;
@@ -506,7 +515,7 @@ int nd_pfn_probe(struct device *dev, strnvdimm_bus_unlock (&ndns->dev);if (!pfn_dev)return -ENOMEM ; - pfn_sb =devm_kzalloc (dev,sizeof (*pfn_sb),GFP_KERNEL ); + pfn_sb =devm_kmalloc (dev,sizeof (*pfn_sb),GFP_KERNEL ); nd_pfn =to_nd_pfn (pfn_dev); nd_pfn->pfn_sb = pfn_sb; rc =nd_pfn_validate (nd_pfn,PFN_SIG );
@@ -638,7 +647,7 @@ static int nd_pfn_init(struct nd_pfn *ndu64 checksum;int rc; - pfn_sb =devm_kzalloc (&nd_pfn->dev,sizeof (*pfn_sb),GFP_KERNEL ); + pfn_sb =devm_kmalloc (&nd_pfn->dev,sizeof (*pfn_sb),GFP_KERNEL );if (!pfn_sb)return -ENOMEM ;
@@ -647,11 +656,14 @@ static int nd_pfn_init(struct nd_pfn *nd sig =DAX_SIG ; else sig =PFN_SIG ; + rc =nd_pfn_validate (nd_pfn, sig);if (rc != -ENODEV )return rc;/* no info block, do init */ ; +memset (pfn_sb,0 ,sizeof (*pfn_sb)); + nd_region =to_nd_region (nd_pfn->dev.parent);if (nd_region->ro) { dev_info(&nd_pfn->dev,
@@ -705,7 +717,7 @@ static int nd_pfn_init(struct nd_pfn *ndmemcpy (pfn_sb->uuid, nd_pfn->uuid,16 );memcpy (pfn_sb->parent_uuid,nd_dev_to_uuid (&ndns->dev),16 ); pfn_sb->version_major =cpu_to_le16 (1 ); - pfn_sb->version_minor =cpu_to_le16 (2 ); + pfn_sb->version_minor =cpu_to_le16 (3 ); pfn_sb->start_pad =cpu_to_le32 (start_pad); pfn_sb->end_trunc =cpu_to_le32 (end_trunc); pfn_sb->align =cpu_to_le32 (nd_pfn->align);
Greg Kroah-Hartman
maintainerPATCH 240/271 coda: pass the host file in vma->vm_file on mmap
In reply to Greg Kroah-HartmanFrom: Jan Harkes <[email protected]>
commit 7fa0a1da3dadfd9216df7745a1331fdaa0940d1c upstream.
Patch series "Coda updates".
The following patch series is a collection of various fixes for Coda, most of which were collected from linux-fsdevel or linux-kernel but which have as yet not found their way upstream.
This patch (of 22):
Various file systems expect that vma->vm_file points at their own file handle, several use file_inode(vma->vm_file) to get at their inode or use vma->vm_file->private_data. However the way Coda wrapped mmap on a host file broke this assumption, vm_file was still pointing at the Coda file and the host file systems would scribble over Coda's inode and private file data.
This patch fixes the incorrect expectation and wraps vm_ops->open and vm_ops->close to allow Coda to track when the vm_area_struct is destroyed so we still release the reference on the Coda file handle at the right time.
--- fs/coda/file.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-)
fs/coda/file.c +68 -2
@@ -27,6 +27,13 @@#include "coda_linux.h" #include "coda_int.h" +struct coda_vm_ops { +atomic_t refcnt; +struct file *coda_file; +const struct vm_operations_struct *host_vm_ops; +struct vm_operations_struct vm_ops; +}; +static ssize_t coda_file_read_iter (struct kiocb *iocb,struct iov_iter *to) {
@@ -61,6 +68,34 @@ coda_file_write_iter(struct kiocb *iocb,return ret; } +static void +coda_vm_open (struct vm_area_struct *vma) +{ +struct coda_vm_ops *cvm_ops = + container_of(vma->vm_ops, struct coda_vm_ops, vm_ops); + +atomic_inc (&cvm_ops->refcnt); + +if (cvm_ops->host_vm_ops && cvm_ops->host_vm_ops->open) + cvm_ops->host_vm_ops->open (vma); +} + +static void +coda_vm_close (struct vm_area_struct *vma) +{ +struct coda_vm_ops *cvm_ops = + container_of(vma->vm_ops, struct coda_vm_ops, vm_ops); + +if (cvm_ops->host_vm_ops && cvm_ops->host_vm_ops->close) + cvm_ops->host_vm_ops->close (vma); + +if (atomic_dec_and_test (&cvm_ops->refcnt)) { + vma->vm_ops = cvm_ops->host_vm_ops; +fput (cvm_ops->coda_file); +kfree (cvm_ops); + } +} +static int coda_file_mmap (struct file *coda_file,struct vm_area_struct *vma) {
@@ -68,6 +103,8 @@ coda_file_mmap(struct file *coda_file, sstruct coda_inode_info *cii;struct file *host_file;struct inode *coda_inode, *host_inode; +struct coda_vm_ops *cvm_ops; +int ret; cfi =CODA_FTOC (coda_file);BUG_ON (!cfi || cfi->cfi_magic !=CODA_MAGIC );
@@ -76,6 +113,13 @@ coda_file_mmap(struct file *coda_file, sif (!host_file->f_op->mmap)return -ENODEV ; +if (WARN_ON (coda_file != vma->vm_file)) +return -EIO ; + + cvm_ops =kmalloc (sizeof (struct coda_vm_ops ),GFP_KERNEL ); +if (!cvm_ops) +return -ENOMEM ; + coda_inode =file_inode (coda_file); host_inode =file_inode (host_file);
@@ -89,6 +133,7 @@ coda_file_mmap(struct file *coda_file, s* the container file on us! */ else if (coda_inode->i_mapping != host_inode->i_mapping) {spin_unlock (&cii->c_lock); +kfree (cvm_ops);return -EBUSY ; }
@@ -97,7 +142,29 @@ coda_file_mmap(struct file *coda_file, s cfi->cfi_mapcount++;spin_unlock (&cii->c_lock); -return call_mmap (host_file, vma); + vma->vm_file =get_file (host_file); + ret =call_mmap (vma->vm_file, vma); + +if (ret) { +/* if call_mmap fails, our caller will put coda_file so we +* should drop the reference to the host_file that we got. +*/ +fput (host_file); +kfree (cvm_ops); + }else { +/* here we add redirects for the open/close vm_operations */ + cvm_ops->host_vm_ops = vma->vm_ops; +if (vma->vm_ops) + cvm_ops->vm_ops = *vma->vm_ops; + + cvm_ops->vm_ops.open = coda_vm_open; + cvm_ops->vm_ops.close = coda_vm_close; + cvm_ops->coda_file = coda_file; +atomic_set (&cvm_ops->refcnt,1 ); + + vma->vm_ops = &cvm_ops->vm_ops; + } +return ret; }int coda_open (struct inode *coda_inode,struct file *coda_file)
@@ -207,4 +274,3 @@ const struct file_operations coda_file_o .fsync = coda_fsync, .splice_read = generic_file_splice_read, }; -
Greg Kroah-Hartman
maintainerPATCH 241/271 include/asm-generic/bug.h: fix "cut here" for WARN_ON for __WARN_TAINT architectures
In reply to Greg Kroah-HartmanFrom: Drew Davenport <[email protected]>
commit 6b15f678fb7d5ef54e089e6ace72f007fe6e9895 upstream.
For architectures using __WARN_TAINT, the WARN_ON macro did not print out the "cut here" string. The other WARN_XXX macros would print "cut here" inside __warn_printk, which is not called for WARN_ON since it doesn't have a message to print.
--- include/asm-generic/bug.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
include/asm-generic/bug.h +4 -2
@@ -104,8 +104,10 @@ extern void warn_slowpath_null(const cha warn_slowpath_fmt_taint(__FILE__, __LINE__, taint, arg)#else extern __printf(1, 2) void __warn_printk(const char *fmt, ...); -#define __WARN () __WARN_TAINT(TAINT_WARN) -#define __WARN_printf(arg...) do { __warn_printk(arg); __WARN(); } while (0) +#define __WARN () do { \ + printk(KERN_WARNING CUT_HERE); __WARN_TAINT(TAINT_WARN); \ +} while (0) +#define __WARN_printf(arg...) __WARN_printf_taint(TAINT_WARN, arg) #define __WARN_printf_taint(taint, arg...) \ do { __warn_printk(arg); __WARN_TAINT(taint); } while (0)#endif
Greg Kroah-Hartman
maintainerPATCH 242/271 xfs: fix pagecache truncation prior to reflink
In reply to Greg Kroah-Hartmancommit 4918ef4ea008cd2ff47eb852894e3f9b9047f4f3 upstream.
Prior to remapping blocks, it is necessary to remove pages from the destination file's page cache. Unfortunately, the truncation is not aggressive enough -- if page size > block size, we'll end up zeroing subpage blocks instead of removing them. So, round the start offset down and the end offset up to page boundaries. We already wrote all the dirty data so the larger range shouldn't be a problem.
--- fs/xfs/xfs_reflink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/xfs/xfs_reflink.c +3 -2
@@ -1369,8 +1369,9 @@ xfs_reflink_remap_prep( goto out_unlock;/* Zap any page cache for the destination file's range. */ -truncate_inode_pages_range (&inode_out->i_data, pos_out, -PAGE_ALIGN (pos_out + *len) -1 ); +truncate_inode_pages_range (&inode_out->i_data, +round_down (pos_out,PAGE_SIZE ), +round_up (pos_out + *len,PAGE_SIZE ) -1 );/* If we're altering the file contents... */ if (!is_dedupe) {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 243/271 xfs: flush removing page cache in xfs_reflink_remap_prep
In reply to Greg Kroah-Hartmancommit 2c307174ab77e34645e75e12827646e044d273c3 upstream.
On a sub-page block size filesystem, fsx is failing with a data corruption after a series of operations involving copying a file with the destination offset beyond EOF of the destination of the file:
8093(157 mod 256): TRUNCATE DOWN from 0x7a120 to 0x50000 ******WWWW
8094(158 mod 256): INSERT 0x25000 thru 0x25fff (0x1000 bytes)
8095(159 mod 256): COPY 0x18000 thru 0x1afff (0x3000 bytes) to 0x2f400
8096(160 mod 256): WRITE 0x5da00 thru 0x651ff (0x7800 bytes) HOLE
8097(161 mod 256): COPY 0x2000 thru 0x5fff (0x4000 bytes) to 0x6fc00
The second copy here is beyond EOF, and it is to sub-page (4k) but block aligned (1k) offset. The clone runs the EOF zeroing, landing in a pre-existing post-eof delalloc extent. This zeroes the post-eof extents in the page cache just fine, dirtying the pages correctly.
The problem is that xfs_reflink_remap_prep() now truncates the page cache over the range that it is copying it to, and rounds that down to cover the entire start page. This removes the dirty page over the delalloc extent from the page cache without having written it back. Hence later, when the page cache is flushed, the page at offset 0x6f000 has not been written back and hence exposes stale data, which fsx trips over less than 10 operations later.
Fix this by changing xfs_reflink_remap_prep() to use xfs_flush_unmap_range().
--- fs/xfs/xfs_bmap_util.c | 2 +- fs/xfs/xfs_bmap_util.h | 2 ++ fs/xfs/xfs_reflink.c | 17 +++++++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-)
fs/xfs/xfs_bmap_util.c +1 -1
@@ -1080,7 +1080,7 @@ xfs_adjust_extent_unmap_boundaries(return 0 ; } -static int +int xfs_flush_unmap_range( struct xfs_inode *ip, xfs_off_t offset,
fs/xfs/xfs_bmap_util.h +2 -0
@@ -76,6 +76,8 @@ int xfs_swap_extents(struct xfs_inode *ip, struct xfs_inode *tip,xfs_daddr_t xfs_fsb_to_db (struct xfs_inode *ip,xfs_fsblock_t fsb);xfs_extnum_t xfs_bmap_count_leaves (struct xfs_ifork *ifp,xfs_filblks_t *count); +int xfs_flush_unmap_range (struct xfs_inode *ip,xfs_off_t offset, +xfs_off_t len);int xfs_bmap_count_blocks (struct xfs_trans *tp,struct xfs_inode *ip,int whichfork,xfs_extnum_t *nextents,xfs_filblks_t *count);
fs/xfs/xfs_reflink.c +13 -4
@@ -1368,10 +1368,19 @@ xfs_reflink_remap_prep(if (ret) goto out_unlock; -/* Zap any page cache for the destination file's range. */ -truncate_inode_pages_range (&inode_out->i_data, -round_down (pos_out,PAGE_SIZE ), -round_up (pos_out + *len,PAGE_SIZE ) -1 ); +/* +* If pos_out > EOF, we may have dirtied blocks between EOF and +* pos_out. In that case, we need to extend the flush and unmap to cover +* from EOF to the end of the copy length. +*/ +if (pos_out >XFS_ISIZE (dest)) { +loff_t flen = *len + (pos_out -XFS_ISIZE (dest)); + ret =xfs_flush_unmap_range (dest,XFS_ISIZE (dest), flen); + }else { + ret =xfs_flush_unmap_range (dest, pos_out, *len); + } +if (ret) + goto out_unlock;/* If we're altering the file contents... */ if (!is_dedupe) {
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 244/271 xfs: dont overflow xattr listent buffer
In reply to Greg Kroah-Hartmancommit 3b50086f0c0d78c144d9483fa292c1509c931b70 upstream.
For VFS listxattr calls, xfs_xattr_put_listent calls __xfs_xattr_put_listent twice if it sees an attribute "trusted.SGI_ACL_FILE": once for that name, and again for "system.posix_acl_access". Unfortunately, if we happen to run out of buffer space while emitting the first name, we set count to -1 (so that we can feed ERANGE to the caller). The second invocation doesn't check that the context parameters make sense and overwrites the byte before the buffer, triggering a KASAN report:
==================================================================
BUG: KASAN: slab-out-of-bounds in strncpy+0xb3/0xd0 Write of size 1 at addr ffff88807fbd317f by task syz/1113 CPU: 3 PID: 1113 Comm: syz Not tainted 5.0.0-rc6-xfsx #rc6 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.10.2-1ubuntu1 04/01/2014 Call Trace: dump_stack+0xcc/0x180 print_address_description+0x6c/0x23c kasan_report.cold.3+0x1c/0x35 strncpy+0xb3/0xd0 __xfs_xattr_put_listent+0x1a9/0x2c0 [xfs] xfs_attr_list_int_ilocked+0x11af/0x1800 [xfs] xfs_attr_list_int+0x20c/0x2e0 [xfs] xfs_vn_listxattr+0x225/0x320 [xfs] listxattr+0x11f/0x1b0 path_listxattr+0xbd/0x130 do_syscall_64+0x139/0x560
While we're at it we add an assert to the other put_listent to avoid this sort of thing ever happening to the attrlist_by_handle code.
--- fs/xfs/xfs_attr_list.c | 1 + fs/xfs/xfs_xattr.c | 3 +++ 2 files changed, 4 insertions(+)
fs/xfs/xfs_attr_list.c +1 -0
@@ -555,6 +555,7 @@ xfs_attr_put_listent(attrlist_ent_t *aep;int arraytop; +ASSERT (!context->seen_enough);ASSERT (!(context->flags &ATTR_KERNOVAL ));ASSERT (context->count >=0 );ASSERT (context->count < (ATTR_MAX_VALUELEN /8 ));
fs/xfs/xfs_xattr.c +3 -0
@@ -129,6 +129,9 @@ __xfs_xattr_put_listent(char *offset;int arraytop; +if (context->count <0 || context->seen_enough) +return ; +if (!context->alist) goto compute_size;
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 245/271 xfs: rename m_inotbt_nores to m_finobt_nores
In reply to Greg Kroah-Hartmancommit e1f6ca11381588e3ef138c10de60eeb34cb8466a upstream.
Rename this flag variable to imply more strongly that it's related to the free inode btree (finobt) operation. No functional changes.
--- fs/xfs/libxfs/xfs_ag_resv.c | 2 +- fs/xfs/libxfs/xfs_ialloc_btree.c | 4 ++-- fs/xfs/xfs_inode.c | 2 +- fs/xfs/xfs_mount.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_ag_resv.c +1 -1
@@ -281,7 +281,7 @@ xfs_ag_resv_init(*/ ask = used =0 ; - mp->m_inotbt_nores = true; + mp->m_finobt_nores = true; error =xfs_refcountbt_calc_reserves (mp, tp, agno, &ask, &used);
fs/xfs/libxfs/xfs_ialloc_btree.c +2 -2
@@ -124,7 +124,7 @@ xfs_finobt_alloc_block( union xfs_btree_ptr *new, int *stat) { -if (cur->bc_mp->m_inotbt_nores) +if (cur->bc_mp->m_finobt_nores)return xfs_inobt_alloc_block (cur, start, new, stat);return __xfs_inobt_alloc_block (cur, start, new, stat,XFS_AG_RESV_METADATA );
@@ -157,7 +157,7 @@ xfs_finobt_free_block( struct xfs_btree_cur *cur, struct xfs_buf *bp) { -if (cur->bc_mp->m_inotbt_nores) +if (cur->bc_mp->m_finobt_nores)return xfs_inobt_free_block (cur, bp);return __xfs_inobt_free_block (cur, bp,XFS_AG_RESV_METADATA ); }
fs/xfs/xfs_inode.c +1 -1
@@ -1754,7 +1754,7 @@ xfs_inactive_ifree(* now remains allocated and sits on the unlinked list until the fs is * repaired. */ -if (unlikely (mp->m_inotbt_nores)) { +if (unlikely (mp->m_finobt_nores)) { error =xfs_trans_alloc (mp, &M_RES (mp)->tr_ifree,XFS_IFREE_SPACE_RES (mp),0 ,XFS_TRANS_RESERVE , &tp);
fs/xfs/xfs_mount.h +1 -1
@@ -127,7 +127,7 @@ typedef struct xfs_mount {struct mutex m_growlock;/* growfs mutex */ int m_fixedfsid[2 ];/* unchanged for life of FS */ uint64_t m_flags;/* global mount flags */ -bool m_inotbt_nores;/* no per-AG finobt resv. */ +bool m_finobt_nores;/* no per-AG finobt resv. */ int m_ialloc_inos;/* inodes in inode allocation */ int m_ialloc_blks;/* blocks in inode allocation */ int m_ialloc_min_blks;/* min blocks in sparse inode
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 246/271 xfs: dont ever put nlink > 0 inodes on the unlinked list
In reply to Greg Kroah-Hartmancommit c4a6bf7f6cc7eb4cce120fb7eb1e1fb8b2d65e09 upstream.
When XFS creates an O_TMPFILE file, the inode is created with nlink = 1, put on the unlinked list, and then the VFS sets nlink = 0 in d_tmpfile. If we crash before anything logs the inode (it's dirty incore but the vfs doesn't tell us it's dirty so we never log that change), the iunlink processing part of recovery will then explode with a pile of:
XFS: Assertion failed: VFS_I(ip)->i_nlink == 0, file:fs/xfs/xfs_log_recover.c, line: 5072
Worse yet, since nlink is nonzero, the inodes also don't get cleaned up and they just leak until the next xfs_repair run.
Therefore, change xfs_iunlink to require that inodes being put on the unlinked list have nlink == 0, change the tmpfile callers to instantiate nodes that way, and set the nlink to 1 just prior to calling d_tmpfile. Fix the comment for xfs_iunlink while we're at it.
--- fs/xfs/xfs_inode.c | 16 ++++++---------- fs/xfs/xfs_iops.c | 13 +++++++++++-- 2 files changed, 17 insertions(+), 12 deletions(-)
fs/xfs/xfs_inode.c +6 -10
@@ -1332,7 +1332,7 @@ xfs_create_tmpfile(if (error) goto out_trans_cancel; - error =xfs_dir_ialloc (&tp, dp, mode,1 ,0 , prid, &ip); + error =xfs_dir_ialloc (&tp, dp, mode,0 ,0 , prid, &ip);if (error) goto out_trans_cancel;
@@ -1907,11 +1907,8 @@ xfs_inactive( }/* -* This is called when the inode's link count goes to 0 or we are creating a -* tmpfile via O_TMPFILE. In the case of a tmpfile, @ignore_linkcount will be -* set to true as the link count is dropped to zero by the VFS after we've -* created the file successfully, so we have to add it to the unlinked list -* while the link count is non-zero. +* This is called when the inode's link count has gone to 0 or we are creating +* a tmpfile via O_TMPFILE. The inode @ip must have nlink == 0. * * We place the on-disk inode on a list in the AGI. It will be pulled from this * list when the inode is freed.
@@ -1931,6 +1928,7 @@ xfs_iunlink(int offset;int error; +ASSERT (VFS_I (ip)->i_nlink ==0 );ASSERT (VFS_I (ip)->i_mode !=0 );/*
@@ -2837,11 +2835,9 @@ xfs_rename_alloc_whiteout(/* * Prepare the tmpfile inode as if it were created through the VFS. -* Otherwise, the link increment paths will complain about nlink 0->1. -* Drop the link count as done by d_tmpfile(), complete the inode setup -* and flag it as linkable. +* Complete the inode setup and flag it as linkable. nlink is already +* zero, so we can skip the drop_nlink. */ -drop_nlink (VFS_I (tmpfile));xfs_setup_iops (tmpfile);xfs_finish_inode_setup (tmpfile);VFS_I (tmpfile)->i_state |=I_LINKABLE ;
fs/xfs/xfs_iops.c +11 -2
@@ -191,9 +191,18 @@ xfs_generic_create(xfs_setup_iops (ip); -if (tmpfile) +if (tmpfile) { +/* +* The VFS requires that any inode fed to d_tmpfile must have +* nlink == 1 so that it can decrement the nlink in d_tmpfile. +* However, we created the temp file with nlink == 0 because +* we're not allowed to put an inode with nlink > 0 on the +* unlinked list. Therefore we have to set nlink to 1 so that +* d_tmpfile can immediately set it back to zero. +*/ +set_nlink (inode,1 );d_tmpfile (dentry, inode); -else + }else d_instantiate (dentry, inode);xfs_finish_inode_setup (ip);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 247/271 xfs: reserve blocks for ifree transaction during log recovery
In reply to Greg Kroah-Hartmancommit 15a268d9f263ed3a0601a1296568241a5a3da7aa upstream.
Log recovery frees all the inodes stored in the unlinked list, which can cause expansion of the free inode btree. The ifree code skips block reservations if it thinks there's a per-AG space reservation, but we don't set up the reservation until after log recovery, which means that a finobt expansion blows up in xfs_trans_mod_sb when we exceed the transaction's block reservation.
To fix this, we set the "no finobt reservation" flag to true when we create the xfs_mount and only set it to false if we confirm that every AG had enough free space to put aside for the finobt.
--- fs/xfs/xfs_fsops.c | 1 + fs/xfs/xfs_super.c | 7 +++++++ 2 files changed, 8 insertions(+)
fs/xfs/xfs_fsops.c +1 -0
@@ -534,6 +534,7 @@ xfs_fs_reserve_ag_blocks(int error =0 ;int err2; + mp->m_finobt_nores = false;for (agno =0 ; agno < mp->m_sb.sb_agcount; agno++) { pag =xfs_perag_get (mp, agno); err2 =xfs_ag_resv_init (pag,NULL );
fs/xfs/xfs_super.c +7 -0
@@ -1561,6 +1561,13 @@ xfs_mount_alloc(INIT_DELAYED_WORK (&mp->m_eofblocks_work, xfs_eofblocks_worker);INIT_DELAYED_WORK (&mp->m_cowblocks_work, xfs_cowblocks_worker); mp->m_kobj.kobject.kset = xfs_kset; +/* +* We don't create the finobt per-ag space reservation until after log +* recovery, so we must set this to true so that an ifree transaction +* started during log recovery will not depend on space reservations +* for finobt expansion. +*/ + mp->m_finobt_nores = true;return mp; }
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 248/271 xfs: fix reporting supported extra file attributes for statx()
In reply to Greg Kroah-Hartmancommit 1b9598c8fb9965fff901c4caa21fed9644c34df3 upstream.
statx(2) notes that any attribute that is not indicated as supported by stx_attributes_mask has no usable value. Commit 5f955f26f3d42d ("xfs: report crtime and attribute flags to statx") added support for informing userspace of extra file attributes but forgot to list these flags as supported making reporting them rather useless for the pedantic userspace author.
$ git describe --contains 5f955f26f3d42d04aba65590a32eb70eedb7f37d v4.11-rc6~5^2^2~2
--- fs/xfs/xfs_iops.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/xfs/xfs_iops.c +8 -0
@@ -531,6 +531,10 @@ xfs_vn_getattr( } } +/* +* Note: If you add another clause to set an attribute flag, please +* update attributes_mask below. +*/ if (ip->i_d.di_flags &XFS_DIFLAG_IMMUTABLE ) stat->attributes |=STATX_ATTR_IMMUTABLE ;if (ip->i_d.di_flags &XFS_DIFLAG_APPEND )
@@ -538,6 +542,10 @@ xfs_vn_getattr(if (ip->i_d.di_flags &XFS_DIFLAG_NODUMP ) stat->attributes |=STATX_ATTR_NODUMP ; + stat->attributes_mask |= (STATX_ATTR_IMMUTABLE | +STATX_ATTR_APPEND | +STATX_ATTR_NODUMP ); +switch (inode->i_mode &S_IFMT ) {case S_IFBLK :case S_IFCHR :
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 249/271 xfs: serialize unaligned dio writes against all other dio writes
In reply to Greg Kroah-Hartmancommit 2032a8a27b5cc0f578d37fa16fa2494b80a0d00a upstream.
XFS applies more strict serialization constraints to unaligned direct writes to accommodate things like direct I/O layer zeroing, unwritten extent conversion, etc. Unaligned submissions acquire the exclusive iolock and wait for in-flight dio to complete to ensure multiple submissions do not race on the same block and cause data corruption.
This generally works in the case of an aligned dio followed by an unaligned dio, but the serialization is lost if I/Os occur in the opposite order. If an unaligned write is submitted first and immediately followed by an overlapping, aligned write, the latter submits without the typical unaligned serialization barriers because there is no indication of an unaligned dio still in-flight. This can lead to unpredictable results.
To provide proper unaligned dio serialization, require that such direct writes are always the only dio allowed in-flight at one time for a particular inode. We already acquire the exclusive iolock and drain pending dio before submitting the unaligned dio. Wait once more after the dio submission to hold the iolock across the I/O and prevent further submissions until the unaligned I/O completes. This is heavy handed, but consistent with the current pre-submission serialization for unaligned direct writes.
--- fs/xfs/xfs_file.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
fs/xfs/xfs_file.c +17 -10
@@ -529,18 +529,17 @@ xfs_file_dio_aio_write( count =iov_iter_count (from);/* -* If we are doing unaligned IO, wait for all other IO to drain, -* otherwise demote the lock if we had to take the exclusive lock -* for other reasons in xfs_file_aio_write_checks. +* If we are doing unaligned IO, we can't allow any other overlapping IO +* in-flight at the same time or we risk data corruption. Wait for all +* other IO to drain before we submit. If the IO is aligned, demote the +* iolock if we had to take the exclusive lock in +* xfs_file_aio_write_checks() for other reasons. */ if (unaligned_io) { -/* If we are going to wait for other DIO to finish, bail */ -if (iocb->ki_flags &IOCB_NOWAIT ) { -if (atomic_read (&inode->i_dio_count)) -return -EAGAIN ; - }else { -inode_dio_wait (inode); - } +/* unaligned dio always waits, bail */ +if (iocb->ki_flags &IOCB_NOWAIT ) +return -EAGAIN ; +inode_dio_wait (inode); }else if (iolock ==XFS_IOLOCK_EXCL ) {xfs_ilock_demote (ip,XFS_IOLOCK_EXCL ); iolock =XFS_IOLOCK_SHARED ;
@@ -548,6 +547,14 @@ xfs_file_dio_aio_write(trace_xfs_file_direct_write (ip, count, iocb->ki_pos); ret =iomap_dio_rw (iocb, from, &xfs_iomap_ops, xfs_dio_write_end_io); + +/* +* If unaligned, this is the only IO in-flight. If it has not yet +* completed, wait on it before we release the iolock to prevent +* subsequent overlapping IO. +*/ +if (ret == -EIOCBQUEUED && unaligned_io) +inode_dio_wait (inode); out:xfs_iunlock (ip, iolock);
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 250/271 xfs: abort unaligned nowait directio early
In reply to Greg Kroah-Hartmancommit 1fdeaea4d92c69fb9f871a787af6ad00f32eeea7 upstream.
Dave Chinner noticed that xfs_file_dio_aio_write returns EAGAIN without dropping the IOLOCK when its deciding not to wait, which means that we leak the IOLOCK there. Since we now make unaligned directio always wait, we have the opportunity to bail out before trying to take the lock, which should reduce the overhead of this never-gonna-work case considerably while also solving the dropped lock problem.
--- fs/xfs/xfs_file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/xfs/xfs_file.c +3 -3
@@ -517,6 +517,9 @@ xfs_file_dio_aio_write( }if (iocb->ki_flags &IOCB_NOWAIT ) { +/* unaligned dio always waits, bail */ +if (unaligned_io) +return -EAGAIN ;if (!xfs_ilock_nowait (ip, iolock))return -EAGAIN ; }else {
@@ -536,9 +539,6 @@ xfs_file_dio_aio_write(* xfs_file_aio_write_checks() for other reasons. */ if (unaligned_io) { -/* unaligned dio always waits, bail */ -if (iocb->ki_flags &IOCB_NOWAIT ) -return -EAGAIN ;inode_dio_wait (inode); }else if (iolock ==XFS_IOLOCK_EXCL ) {xfs_ilock_demote (ip,XFS_IOLOCK_EXCL );
Signature · 1 line
2.20.1
Greg Kroah-Hartman
maintainerPATCH 251/271 gpu: ipu-v3: ipu-ic: Fix saturation bit offset in TPMEM
In reply to Greg Kroah-HartmanFrom: Steve Longerbeam <[email protected]>
commit 3d1f62c686acdedf5ed9642b763f3808d6a47d1e upstream.
The saturation bit was being set at bit 9 in the second 32-bit word of the TPMEM CSC. This isn't correct, the saturation bit is bit 42, which is bit 10 of the second word.
--- drivers/gpu/ipu-v3/ipu-ic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/ipu-v3/ipu-ic.c +1 -1
@@ -257,7 +257,7 @@ static int init_csc(struct ipu_ic *ic,writel (param, base++); param = ((a[0 ] &0x1fe0 ) >>5 ) | (params->scale <<8 ) | - (params->sat <<9 ); + (params->sat <<10 );writel (param, base++); param = ((a[1] & 0x1f) << 27) | ((c[0][1] & 0x1ff) << 18) |
Greg Kroah-Hartman
maintainerPATCH 252/271 crypto: caam - limit output IV to CBC to work around CTR mode DMA issue
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit ed527b13d800dd515a9e6c582f0a73eca65b2e1b upstream.
The CAAM driver currently violates an undocumented and slightly controversial requirement imposed by the crypto stack that a buffer referred to by the request structure via its virtual address may not be modified while any scatterlists passed via the same request structure are mapped for inbound DMA.
This may result in errors like
alg: aead: decryption failed on test 1 for gcm_base(ctr-aes-caam,ghash-generic): ret=74
alg: aead: Failed to load transform for gcm(aes): -2
on non-cache coherent systems, due to the fact that the GCM driver passes an IV buffer by virtual address which shares a cacheline with the auth_tag buffer passed via a scatterlist, resulting in corruption of the auth_tag when the IV is updated while the DMA mapping is live.
Since the IV that is returned to the caller is only valid for CBC mode, and given that the in-kernel users of CBC (such as CTS) don't trigger the same issue as the GCM driver, let's just disable the output IV generation for all modes except CBC for the time being.
--- drivers/crypto/caam/caamalg.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/crypto/caam/caamalg.c +9 -6
@@ -887,6 +887,7 @@ static void ablkcipher_encrypt_done(strustruct ablkcipher_request *req = context;struct ablkcipher_edesc *edesc;struct crypto_ablkcipher *ablkcipher =crypto_ablkcipher_reqtfm (req); +struct caam_ctx *ctx =crypto_ablkcipher_ctx (ablkcipher);int ivsize =crypto_ablkcipher_ivsize (ablkcipher);#ifdef DEBUG
@@ -911,10 +912,11 @@ static void ablkcipher_encrypt_done(stru/* * The crypto API expects us to set the IV (req->info) to the last -* ciphertext block. This is used e.g. by the CTS mode. +* ciphertext block when running in CBC mode. */ -scatterwalk_map_and_copy (req->info, req->dst, req->nbytes - ivsize, - ivsize,0 ); +if ((ctx->cdata.algtype &OP_ALG_AAI_MASK ) ==OP_ALG_AAI_CBC ) +scatterwalk_map_and_copy (req->info, req->dst, req->nbytes - + ivsize, ivsize,0 );/* In case initial IV was generated, copy it in GIVCIPHER request */ if (edesc->iv_dir ==DMA_FROM_DEVICE ) {
@@ -1651,10 +1653,11 @@ static int ablkcipher_decrypt(struct abl/* * The crypto API expects us to set the IV (req->info) to the last -* ciphertext block. +* ciphertext block when running in CBC mode. */ -scatterwalk_map_and_copy (req->info, req->src, req->nbytes - ivsize, - ivsize,0 ); +if ((ctx->cdata.algtype &OP_ALG_AAI_MASK ) ==OP_ALG_AAI_CBC ) +scatterwalk_map_and_copy (req->info, req->src, req->nbytes - + ivsize, ivsize,0 );/* Create and submit job descriptor*/ init_ablkcipher_job (ctx->sh_desc_dec, ctx->sh_desc_dec_dma, edesc, req);
Greg Kroah-Hartman
maintainerPATCH 253/271 parisc: Ensure userspace privilege for ptraced processes in regset functions
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
commit 34c32fc603311a72cb558e5e337555434f64c27b upstream.
On parisc the privilege level of a process is stored in the lowest two bits of the instruction pointers (IAOQ0 and IAOQ1). On Linux we use privilege level 0 for the kernel and privilege level 3 for user-space. So userspace should not be allowed to modify IAOQ0 or IAOQ1 of a ptraced process to change it's privilege level to e.g. 0 to try to gain kernel privileges.
This patch prevents such modifications in the regset support functions by always setting the two lowest bits to one (which relates to privilege level 3 for user-space) if IAOQ0 or IAOQ1 are modified via ptrace regset calls.
--- arch/parisc/kernel/ptrace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/parisc/kernel/ptrace.c +2 -1
@@ -496,7 +496,8 @@ static void set_reg(struct pt_regs *regsreturn ;case RI (iaoq[0 ]):case RI (iaoq[1 ]): - regs->iaoq[num -RI (iaoq[0 ])] = val; +/* set 2 lowest bits to ensure userspace privilege: */ + regs->iaoq[num -RI (iaoq[0 ])] = val |3 ;return ;case RI (sar): regs->sar = val;return ;
Greg Kroah-Hartman
maintainerPATCH 254/271 parisc: Fix kernel panic due invalid values in IAOQ0 or IAOQ1
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
commit 10835c854685393a921b68f529bf740fa7c9984d upstream.
On parisc the privilege level of a process is stored in the lowest two bits of the instruction pointers (IAOQ0 and IAOQ1). On Linux we use privilege level 0 for the kernel and privilege level 3 for user-space. So userspace should not be allowed to modify IAOQ0 or IAOQ1 of a ptraced process to change it's privilege level to e.g. 0 to try to gain kernel privileges.
This patch prevents such modifications by always setting the two lowest bits to one (which relates to privilege level 3 for user-space) if IAOQ0 or IAOQ1 are modified via ptrace calls in the native and compat ptrace paths.
--- arch/parisc/kernel/ptrace.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-)
arch/parisc/kernel/ptrace.c +18 -10
@@ -167,6 +167,9 @@ long arch_ptrace(struct task_struct *chiif ((addr & (sizeof (unsigned long )-1 )) || addr >=sizeof (struct pt_regs ))break ; +if (addr ==PT_IAOQ0 || addr ==PT_IAOQ1 ) { + data |=3 ;/* ensure userspace privilege */ + } if ((addr >= PT_GR1 && addr <= PT_GR31) || addr == PT_IAOQ0 || addr == PT_IAOQ1 || (addr >= PT_FR0 && addr <= PT_FR31 + 4) ||
@@ -228,16 +231,18 @@ long arch_ptrace(struct task_struct *chistatic compat_ulong_t translate_usr_offset (compat_ulong_t offset) { -if (offset <0 ) -return sizeof (struct pt_regs ); -else if (offset <=32 *4 )/* gr[0..31] */ -return offset *2 +4 ; -else if (offset <=32 *4 +32 *8 )/* gr[0..31] + fr[0..31] */ -return offset +32 *4 ; -else if (offset <sizeof (struct pt_regs )/2 +32 *4 ) -return offset *2 +4 -32 *8 ; +compat_ulong_t pos; + +if (offset <32 *4 )/* gr[0..31] */ + pos = offset *2 +4 ; +else if (offset <32 *4 +32 *8 )/* fr[0] ... fr[31] */ + pos = (offset -32 *4 ) +PT_FR0 ; +else if (offset <sizeof (struct pt_regs )/2 +32 *4 )/* sr[0] ... ipsw */ + pos = (offset -32 *4 -32 *8 ) *2 +PT_SR0 +4 ;else -return sizeof (struct pt_regs ); + pos =sizeof (struct pt_regs ); + +return pos; } long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
@@ -281,9 +286,12 @@ long compat_arch_ptrace(struct task_stru addr =translate_usr_offset (addr);if (addr >=sizeof (struct pt_regs ))break ; +if (addr ==PT_IAOQ0 +4 || addr ==PT_IAOQ1 +4 ) { + data |=3 ;/* ensure userspace privilege */ + }if (addr >=PT_FR0 && addr <=PT_FR31 +4 ) {/* Special case, fp regs are 64 bits anyway */ - *(__u64 *) ((char *)task_regs (child) + addr) = data; + *(__u32 *) ((char *)task_regs (child) + addr) = data; ret =0 ; } else if ((addr >= PT_GR1+4 && addr <= PT_GR31+4) ||
Greg Kroah-Hartman
maintainerPATCH 255/271 powerpc/32s: fix suspend/resume when IBATs 4-7 are used
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
commit 6ecb78ef56e08d2119d337ae23cb951a640dc52d upstream.
Previously, only IBAT1 and IBAT2 were used to map kernel linear mem. Since commit 63b2bc619565 ("powerpc/mm/32s: Use BATs for STRICT_KERNEL_RWX"), we may have all 8 BATs used for mapping kernel text. But the suspend/restore functions only save/restore BATs 0 to 3, and clears BATs 4 to 7.
Make suspend and restore functions respectively save and reload the 8 BATs on CPUs having MMU_FTR_USE_HIGH_BATS feature.
--- arch/powerpc/kernel/swsusp_32.S | 73 ++++++++++++++++++++++++++++---- arch/powerpc/platforms/powermac/sleep.S | 68 +++++++++++++++++++++++++++-- 2 files changed, 128 insertions(+), 13 deletions(-)
arch/powerpc/kernel/swsusp_32.S +65 -8
@@ -25,11 +25,19 @@ #define SL_IBAT2 0x48 #define SL_DBAT3 0x50 #define SL_IBAT3 0x58 -#define SL_TB 0x60 -#define SL_R2 0x68 -#define SL_CR 0x6c -#define SL_LR 0x70 -#define SL_R12 0x74 /* r12 to r31 */ +#define SL_DBAT4 0x60 +#define SL_IBAT4 0x68 +#define SL_DBAT5 0x70 +#define SL_IBAT5 0x78 +#define SL_DBAT6 0x80 +#define SL_IBAT6 0x88 +#define SL_DBAT7 0x90 +#define SL_IBAT7 0x98 +#define SL_TB 0xa0 +#define SL_R2 0xa8 +#define SL_CR 0xac +#define SL_LR 0xb0 +#define SL_R12 0xb4 /* r12 to r31 */ #define SL_SIZE (SL_R12 + 80) .section .data
@@ -114,6 +122,41 @@ _GLOBAL(swsusp_arch_suspend) mfibatl r4,3 stw r4,SL_IBAT3+4(r11) +BEGIN_MMU_FTR_SECTION + mfspr r4,SPRN_DBAT4U + stw r4,SL_DBAT4(r11) + mfspr r4,SPRN_DBAT4L + stw r4,SL_DBAT4+4(r11) + mfspr r4,SPRN_DBAT5U + stw r4,SL_DBAT5(r11) + mfspr r4,SPRN_DBAT5L + stw r4,SL_DBAT5+4(r11) + mfspr r4,SPRN_DBAT6U + stw r4,SL_DBAT6(r11) + mfspr r4,SPRN_DBAT6L + stw r4,SL_DBAT6+4(r11) + mfspr r4,SPRN_DBAT7U + stw r4,SL_DBAT7(r11) + mfspr r4,SPRN_DBAT7L + stw r4,SL_DBAT7+4(r11) + mfspr r4,SPRN_IBAT4U + stw r4,SL_IBAT4(r11) + mfspr r4,SPRN_IBAT4L + stw r4,SL_IBAT4+4(r11) + mfspr r4,SPRN_IBAT5U + stw r4,SL_IBAT5(r11) + mfspr r4,SPRN_IBAT5L + stw r4,SL_IBAT5+4(r11) + mfspr r4,SPRN_IBAT6U + stw r4,SL_IBAT6(r11) + mfspr r4,SPRN_IBAT6L + stw r4,SL_IBAT6+4(r11) + mfspr r4,SPRN_IBAT7U + stw r4,SL_IBAT7(r11) + mfspr r4,SPRN_IBAT7L + stw r4,SL_IBAT7+4(r11) +END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) + #if 0 /* Backup various CPU config stuffs */ bl __save_cpu_setup
@@ -279,27 +322,41 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) mtibatu 3,r4 lwz r4,SL_IBAT3+4(r11) mtibatl 3,r4 -#endif - BEGIN_MMU_FTR_SECTION - li r4,0 + lwz r4,SL_DBAT4(r11) mtspr SPRN_DBAT4U,r4 + lwz r4,SL_DBAT4+4(r11) mtspr SPRN_DBAT4L,r4 + lwz r4,SL_DBAT5(r11) mtspr SPRN_DBAT5U,r4 + lwz r4,SL_DBAT5+4(r11) mtspr SPRN_DBAT5L,r4 + lwz r4,SL_DBAT6(r11) mtspr SPRN_DBAT6U,r4 + lwz r4,SL_DBAT6+4(r11) mtspr SPRN_DBAT6L,r4 + lwz r4,SL_DBAT7(r11) mtspr SPRN_DBAT7U,r4 + lwz r4,SL_DBAT7+4(r11) mtspr SPRN_DBAT7L,r4 + lwz r4,SL_IBAT4(r11) mtspr SPRN_IBAT4U,r4 + lwz r4,SL_IBAT4+4(r11) mtspr SPRN_IBAT4L,r4 + lwz r4,SL_IBAT5(r11) mtspr SPRN_IBAT5U,r4 + lwz r4,SL_IBAT5+4(r11) mtspr SPRN_IBAT5L,r4 + lwz r4,SL_IBAT6(r11) mtspr SPRN_IBAT6U,r4 + lwz r4,SL_IBAT6+4(r11) mtspr SPRN_IBAT6L,r4 + lwz r4,SL_IBAT7(r11) mtspr SPRN_IBAT7U,r4 + lwz r4,SL_IBAT7+4(r11) mtspr SPRN_IBAT7L,r4 END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS) +#endif /* Flush all TLBs */ lis r4,0x1000
arch/powerpc/platforms/powermac/sleep.S +63 -5
101 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 256/271 powerpc/watchpoint: Restore NV GPRs while returning from exception
In reply to Greg Kroah-HartmanFrom: Ravi Bangoria <[email protected]>
commit f474c28fbcbe42faca4eb415172c07d76adcb819 upstream.
powerpc hardware triggers watchpoint before executing the instruction. To make trigger-after-execute behavior, kernel emulates the instruction. If the instruction is 'load something into non-volatile register', exception handler should restore emulated register state while returning back, otherwise there will be register state corruption. eg, adding a watchpoint on a list can corrput the list:
# cat /proc/kallsyms | grep kthread_create_list c00000000121c8b8 d kthread_create_list
Add watchpoint on kthread_create_list->prev:
# perf record -e mem:0xc00000000121c8c0
Run some workload such that new kthread gets invoked. eg, I just logged out from console:
list_add corruption. next->prev should be prev (c000000001214e00), \ but was c00000000121c8b8. (next=c00000000121c8b8). WARNING: CPU: 59 PID: 309 at lib/list_debug.c:25 __list_add_valid+0xb4/0xc0 CPU: 59 PID: 309 Comm: kworker/59:0 Kdump: loaded Not tainted 5.1.0-rc7+ #69 ... NIP __list_add_valid+0xb4/0xc0 LR __list_add_valid+0xb0/0xc0 Call Trace: __list_add_valid+0xb0/0xc0 (unreliable) __kthread_create_on_node+0xe0/0x260 kthread_create_on_node+0x34/0x50 create_worker+0xe8/0x260 worker_thread+0x444/0x560 kthread+0x160/0x1a0 ret_from_kernel_thread+0x5c/0x70
List corruption happened because it uses 'load into non-volatile register' instruction:
Snippet from __kthread_create_on_node:
c000000000136be8: addis r29,r2,-19
c000000000136bec: ld r29,31424(r29)
if (!__list_add_valid(new, prev, next))
c000000000136bf0: mr r3,r30
c000000000136bf4: mr r5,r28
c000000000136bf8: mr r4,r29
c000000000136bfc: bl c00000000059a2f8 <__list_add_valid+0x8>Register state from WARN_ON():
GPR00: c00000000059a3a0 c000007ff23afb50 c000000001344e00 0000000000000075
GPR04: 0000000000000000 0000000000000000 0000001852af8bc1 0000000000000000
GPR08: 0000000000000001 0000000000000007 0000000000000006 00000000000004aa
GPR12: 0000000000000000 c000007ffffeb080 c000000000137038 c000005ff62aaa00
GPR16: 0000000000000000 0000000000000000 c000007fffbe7600 c000007fffbe7370
GPR20: c000007fffbe7320 c000007fffbe7300 c000000001373a00 0000000000000000
GPR24: fffffffffffffef7 c00000000012e320 c000007ff23afcb0 c000000000cb8628
GPR28: c00000000121c8b8 c000000001214e00 c000007fef5b17e8 c000007fef5b17c0
Watchpoint hit at 0xc000000000136bec.
addis r29,r2,-19
=> r29 = 0xc000000001344e00 + (-19 << 16)
=> r29 = 0xc000000001214e00
ld r29,31424(r29)
=> r29 = *(0xc000000001214e00 + 31424)
=> r29 = *(0xc00000000121c8c0)
0xc00000000121c8c0 is where we placed a watchpoint and thus this instruction was emulated by emulate_step. But because handle_dabr_fault did not restore emulated register state, r29 still contains stale value in above register state.
--- arch/powerpc/kernel/exceptions-64s.S | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/powerpc/kernel/exceptions-64s.S +7 -2
@@ -1745,7 +1745,7 @@ handle_page_fault: addi r3,r1,STACK_FRAME_OVERHEAD bl do_page_fault cmpdi r3,0 - beq+ 12f + beq+ ret_from_except_lite bl save_nvgprs mr r5,r3 addi r3,r1,STACK_FRAME_OVERHEAD
@@ -1760,7 +1760,12 @@ handle_dabr_fault: ld r5,_DSISR(r1) addi r3,r1,STACK_FRAME_OVERHEAD bl do_break -12: b ret_from_except_lite + /* + * do_break() may have changed the NV GPRS while handling a breakpoint. + * If so, we need to restore them with their updated values. Don't use + * ret_from_except_lite here. + */ + b ret_from_except #ifdef CONFIG_PPC_BOOK3S_64
Greg Kroah-Hartman
maintainerPATCH 257/271 powerpc/powernv/npu: Fix reference leak
In reply to Greg Kroah-HartmanFrom: Greg Kurz <[email protected]>
commit 02c5f5394918b9b47ff4357b1b18335768cd867d upstream.
Since 902bdc57451c, get_pci_dev() calls pci_get_domain_bus_and_slot(). This has the effect of incrementing the reference count of the PCI device, as explained in drivers/pci/search.c:
* Given a PCI domain, bus, and slot/function number, the desired PCI
* device is located in the list of PCI devices. If the device is
* found, its reference count is increased and this function returns a
* pointer to its data structure. The caller must decrement the
* reference count by calling pci_dev_put(). If no device is found,
* %NULL is returned.
Nothing was done to call pci_dev_put() and the reference count of GPU and NPU PCI devices rockets up.
A natural way to fix this would be to teach the callers about the change, so that they call pci_dev_put() when done with the pointer. This turns out to be quite intrusive, as it affects many paths in npu-dma.c, pci-ioda.c and vfio_pci_nvlink2.c. Also, the issue appeared in 4.16 and some affected code got moved around since then: it would be problematic to backport the fix to stable releases.
All that code never cared for reference counting anyway. Call pci_dev_put() from get_pci_dev() to revert to the previous behavior.
--- arch/powerpc/platforms/powernv/npu-dma.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
arch/powerpc/platforms/powernv/npu-dma.c +14 -1
@@ -56,9 +56,22 @@ static struct dentry *atsd_threshold_denstatic struct pci_dev *get_pci_dev (struct device_node *dn) {struct pci_dn *pdn =PCI_DN (dn); +struct pci_dev *pdev; -return pci_get_domain_bus_and_slot (pci_domain_nr (pdn->phb->bus), + pdev =pci_get_domain_bus_and_slot (pci_domain_nr (pdn->phb->bus), pdn->busno, pdn->devfn); + +/* +* pci_get_domain_bus_and_slot() increased the reference count of +* the PCI device, but callers don't need that actually as the PE +* already holds a reference to the device. Since callers aren't +* aware of the reference count change, call pci_dev_put() now to +* avoid leaks. +*/ +if (pdev) +pci_dev_put (pdev); + +return pdev; }/* Given a NPU device get the associated PCI device. */
Greg Kroah-Hartman
maintainerPATCH 258/271 powerpc/pseries: Fix oops in hotplug memory notifier
In reply to Greg Kroah-HartmanFrom: Nathan Lynch <[email protected]>
commit 0aa82c482ab2ece530a6f44897b63b274bb43c8e upstream.
During post-migration device tree updates, we can oops in pseries_update_drconf_memory() if the source device tree has an ibm,dynamic-memory-v2 property and the destination has a ibm,dynamic_memory (v1) property. The notifier processes an "update" for the ibm,dynamic-memory property but it's really an add in this scenario. So make sure the old property object is there before dereferencing it.
--- arch/powerpc/platforms/pseries/hotplug-memory.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/platforms/pseries/hotplug-memory.c +3 -0
@@ -1012,6 +1012,9 @@ static int pseries_update_drconf_memory(if (!memblock_size)return -EINVAL ; +if (!pr->old_prop) +return 0 ; + p = (__be32 *) pr->old_prop->value;if (!p)return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 259/271 mmc: sdhci-msm: fix mutex while in spinlock
In reply to Greg Kroah-HartmanFrom: Jorge Ramirez-Ortiz <[email protected]>
commit 5e6b6651d22de109ebf48ca00d0373bc2c0cc080 upstream.
mutexes can sleep and therefore should not be taken while holding a spinlock. move clk_get_rate (can sleep) outside the spinlock protected region.
--- drivers/mmc/host/sdhci-msm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/mmc/host/sdhci-msm.c +6 -3
@@ -582,11 +582,14 @@ static int msm_init_cm_dll(struct sdhci_struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_msm_host *msm_host =sdhci_pltfm_priv (pltfm_host);int wait_cnt =50 ; -unsigned long flags; +unsigned long flags, xo_clk =0 ;u32 config;const struct sdhci_msm_offset *msm_offset = msm_host->offset; +if (msm_host->use_14lpp_dll_reset && !IS_ERR_OR_NULL (msm_host->xo_clk)) + xo_clk =clk_get_rate (msm_host->xo_clk); +spin_lock_irqsave (&host->lock, flags);/*
@@ -634,10 +637,10 @@ static int msm_init_cm_dll(struct sdhci_ config &=CORE_FLL_CYCLE_CNT ;if (config) mclk_freq =DIV_ROUND_CLOSEST_ULL ((host->clock *8 ), -clk_get_rate (msm_host->xo_clk)); + xo_clk);else mclk_freq =DIV_ROUND_CLOSEST_ULL ((host->clock *4 ), -clk_get_rate (msm_host->xo_clk)); + xo_clk); config =readl_relaxed (host->ioaddr + msm_offset->core_dll_config_2);
Greg Kroah-Hartman
maintainerPATCH 260/271 eCryptfs: fix a couple type promotion bugs
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
commit 0bdf8a8245fdea6f075a5fede833a5fcf1b3466c upstream.
ECRYPTFS_SIZE_AND_MARKER_BYTES is type size_t, so if "rc" is negative that gets type promoted to a high positive value and treated as success.
--- fs/ecryptfs/crypto.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
fs/ecryptfs/crypto.c +8 -4
@@ -1018,8 +1018,10 @@ int ecryptfs_read_and_validate_header_re rc =ecryptfs_read_lower (file_size,0 ,ECRYPTFS_SIZE_AND_MARKER_BYTES , inode); -if (rc <ECRYPTFS_SIZE_AND_MARKER_BYTES ) -return rc >=0 ? -EINVAL : rc; +if (rc <0 ) +return rc; +else if (rc <ECRYPTFS_SIZE_AND_MARKER_BYTES ) +return -EINVAL ; rc =ecryptfs_validate_marker (marker);if (!rc)ecryptfs_i_size_init (file_size, inode);
@@ -1381,8 +1383,10 @@ int ecryptfs_read_and_validate_xattr_regecryptfs_inode_to_lower (inode),ECRYPTFS_XATTR_NAME , file_size, ECRYPTFS_SIZE_AND_MARKER_BYTES); -if (rc <ECRYPTFS_SIZE_AND_MARKER_BYTES ) -return rc >=0 ? -EINVAL : rc; +if (rc <0 ) +return rc; +else if (rc <ECRYPTFS_SIZE_AND_MARKER_BYTES ) +return -EINVAL ; rc =ecryptfs_validate_marker (marker);if (!rc)ecryptfs_i_size_init (file_size, inode);
Greg Kroah-Hartman
maintainerPATCH 261/271 mtd: rawnand: mtk: Correct low level time calculation of r/w cycle
In reply to Greg Kroah-HartmanFrom: Xiaolei Li <[email protected]>
commit e1884ffddacc0424d7e785e6f8087bd12f7196db upstream.
At present, the flow of calculating AC timing of read/write cycle in SDR mode is that:
At first, calculate high hold time which is valid for both read and write cycle using the max value between tREH_min and tWH_min. Secondly, calculate WE# pulse width using tWP_min.
Thridly, calculate RE# pulse width using the bigger one between tREA_max and tRP_min.
But NAND SPEC shows that Controller should also meet write/read cycle time. That is write cycle time should be more than tWC_min and read cycle should be more than tRC_min. Obviously, we do not achieve that now.
This patch corrects the low level time calculation to meet minimum read/write cycle time required. After getting the high hold time, WE# low level time will be promised to meet tWP_min and tWC_min requirement, and RE# low level time will be promised to meet tREA_max, tRP_min and tRC_min requirement.
--- drivers/mtd/nand/raw/mtk_nand.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/mtk_nand.c +21 -3
@@ -509,7 +509,8 @@ static int mtk_nfc_setup_data_interface( {struct mtk_nfc *nfc =nand_get_controller_data (mtd_to_nand (mtd));const struct nand_sdr_timings *timings; -u32 rate, tpoecs, tprecs, tc2r, tw2r, twh, twst, trlt; +u32 rate, tpoecs, tprecs, tc2r, tw2r, twh, twst =0 , trlt =0 ; +u32 thold; timings =nand_get_sdr_timings (conf);if (IS_ERR (timings))
@@ -545,11 +546,28 @@ static int mtk_nfc_setup_data_interface( twh =DIV_ROUND_UP (twh * rate,1000000 ) -1 ; twh &=0xf ; - twst = timings->tWP_min /1000 ; +/* Calculate real WE#/RE# hold time in nanosecond */ + thold = (twh +1 ) *1000000 / rate; +/* nanosecond to picosecond */ + thold *=1000 ; + +/* +* WE# low level time should be expaned to meet WE# pulse time +* and WE# cycle time at the same time. +*/ +if (thold < timings->tWC_min) + twst = timings->tWC_min - thold; + twst =max (timings->tWP_min, twst) /1000 ; twst =DIV_ROUND_UP (twst * rate,1000000 ) -1 ; twst &=0xf ; - trlt =max (timings->tREA_max, timings->tRP_min) /1000 ; +/* +* RE# low level time should be expaned to meet RE# pulse time, +* RE# access time and RE# cycle time at the same time. +*/ +if (thold < timings->tRC_min) + trlt = timings->tRC_min - thold; + trlt =max3 (trlt, timings->tREA_max, timings->tRP_min) /1000 ; trlt =DIV_ROUND_UP (trlt * rate,1000000 ) -1 ; trlt &=0xf ;
Greg Kroah-Hartman
maintainerPATCH 262/271 mtd: spinand: read returns badly if the last page has bitflips
In reply to Greg Kroah-HartmanFrom: liaoweixiong <[email protected]>
commit b83408b580eccf8d2797cd6cb9ae42c2a28656a7 upstream.
In case of the last page containing bitflips (ret > 0), spinand_mtd_read() will return that number of bitflips for the last page while it should instead return max_bitflips like it does when the last page read returns with 0.
--- drivers/mtd/nand/spi/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/spi/core.c +1 -1
@@ -572,12 +572,12 @@ static int spinand_mtd_read(struct mtd_iif (ret == -EBADMSG ) { ecc_failed = true; mtd->ecc_stats.failed++; - ret =0 ; }else { mtd->ecc_stats.corrected += ret; max_bitflips = max_t(unsigned int, max_bitflips, ret); } + ret =0 ; ops->retlen += iter.req.datalen; ops->oobretlen += iter.req.ooblen; }
Greg Kroah-Hartman
maintainerPATCH 263/271 intel_th: msu: Fix single mode with disabled IOMMU
In reply to Greg Kroah-HartmanFrom: Alexander Shishkin <[email protected]>
commit 918b8646497b5dba6ae82d4a7325f01b258972b9 upstream.
Commit 4e0eaf239fb3 ("intel_th: msu: Fix single mode with IOMMU") switched the single mode code to use dma mapping pages obtained from the page allocator, but with IOMMU disabled, that may lead to using SWIOTLB bounce buffers and without additional sync'ing, produces empty trace buffers.
Fix this by using a DMA32 GFP flag to the page allocation in single mode, as the device supports full 32-bit DMA addressing.
--- drivers/hwtracing/intel_th/msu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/intel_th/msu.c +1 -1
@@ -632,7 +632,7 @@ static int msc_buffer_contig_alloc(struc goto err_out; ret = -ENOMEM ; - page =alloc_pages (GFP_KERNEL | __GFP_ZERO, order); + page =alloc_pages (GFP_KERNEL | __GFP_ZERO |GFP_DMA32 , order);if (!page) goto err_free_sgt;
Greg Kroah-Hartman
maintainerPATCH 264/271 Bluetooth: Add SMP workaround Microsoft Surface Precision Mouse bug
In reply to Greg Kroah-HartmanFrom: Szymon Janc <[email protected]>
commit 1d87b88ba26eabd4745e158ecfd87c93a9b51dc2 upstream.
Microsoft Surface Precision Mouse provides bogus identity address when pairing. It connects with Static Random address but provides Public Address in SMP Identity Address Information PDU. Address has same value but type is different. Workaround this by dropping IRK if ID address discrepancy is detected.
Quoted 1 line
HCI Event: LE Meta Event (
0x3e) plen 19
LE Connection Complete (0x01)
Status: Success (0x00)
Handle: 75
Role: Master (0x00)
Peer address type: Random (0x01)
Peer address: E0:52:33:93:3B:21 (Static)
Connection interval: 50.00 msec (0x0028)
Connection latency: 0 (0x0000)
Supervision timeout: 420 msec (0x002a)
Master clock accuracy: 0x00....
Quoted 1 line
ACL Data RX: Handle 75 flags
0x02dlen 12
SMP: Identity Address Information (0x09) len 7
Address type: Public (0x00)
Address: E0:52:33:93:3B:21Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199461
--- net/bluetooth/smp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
net/bluetooth/smp.c +13 -0
@@ -2580,6 +2580,19 @@ static int smp_cmd_ident_addr_info(struc goto distribute; } +/* Drop IRK if peer is using identity address during pairing but is +* providing different address as identity information. +* +* Microsoft Surface Precision Mouse is known to have this bug. +*/ +if (hci_is_identity_address (&hcon->dst, hcon->dst_type) && + (bacmp (&info->bdaddr, &hcon->dst) || + info->addr_type != hcon->dst_type)) { +bt_dev_err (hcon->hdev, +"ignoring IRK with invalid identity address" ); + goto distribute; + } +bacpy (&smp->id_addr, &info->bdaddr); smp->id_addr_type = info->addr_type;
Greg Kroah-Hartman
maintainerPATCH 265/271 usb: Handle USB3 remote wakeup for LPM enabled devices correctly
In reply to Greg Kroah-HartmanFrom: Lee, Chiasheng <[email protected]>
commit e244c4699f859cf7149b0781b1894c7996a8a1df upstream.
With Link Power Management (LPM) enabled USB3 links transition to low power U1/U2 link states from U0 state automatically.
Current hub code detects USB3 remote wakeups by checking if the software state still shows suspended, but the link has transitioned from suspended U3 to enabled U0 state.
As it takes some time before the hub thread reads the port link state after a USB3 wake notification, the link may have transitioned from U0 to U1/U2, and wake is not detected by hub code.
Fix this by handling U1/U2 states in the same way as U0 in USB3 wakeup handling
This patch should be added to stable kernels since 4.13 where LPM was kept enabled during suspend/resume
--- drivers/usb/core/hub.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/core/hub.c +5 -2
@@ -3575,6 +3575,7 @@ static int hub_handle_remote_wakeup(strustruct usb_device *hdev;struct usb_device *udev;int connect_change =0 ; +u16 link_state;int ret; hdev = hub->hdev;
@@ -3584,9 +3585,11 @@ static int hub_handle_remote_wakeup(strureturn 0 ;usb_clear_port_feature (hdev, port,USB_PORT_FEAT_C_SUSPEND ); }else { + link_state = portstatus &USB_PORT_STAT_LINK_STATE ;if (!udev || udev->state !=USB_STATE_SUSPENDED || - (portstatus &USB_PORT_STAT_LINK_STATE ) != -USB_SS_PORT_LS_U0 ) + (link_state !=USB_SS_PORT_LS_U0 && + link_state !=USB_SS_PORT_LS_U1 && + link_state !=USB_SS_PORT_LS_U2 ))return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 266/271 blk-throttle: fix zero wait time for iops throttled group
In reply to Greg Kroah-HartmanFrom: Konstantin Khlebnikov <[email protected]>
commit 3a10f999ffd464d01c5a05592a15470a3c4bbc36 upstream.
After commit 991f61fe7e1d ("Blk-throttle: reduce tail io latency when iops limit is enforced") wait time could be zero even if group is throttled and cannot issue requests right now. As a result throtl_select_dispatch() turns into busy-loop under irq-safe queue spinlock.
Fix is simple: always round up target time to the next throttle slice.
--- block/blk-throttle.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
block/blk-throttle.c +3 -6
@@ -892,13 +892,10 @@ static bool tg_with_in_iops_limit(structunsigned long jiffy_elapsed, jiffy_wait, jiffy_elapsed_rnd;u64 tmp; - jiffy_elapsed = jiffy_elapsed_rnd = jiffies - tg->slice_start[rw]; + jiffy_elapsed = jiffies - tg->slice_start[rw]; -/* Slice has just started. Consider one slice interval */ -if (!jiffy_elapsed) - jiffy_elapsed_rnd = tg->td->throtl_slice; - - jiffy_elapsed_rnd =roundup (jiffy_elapsed_rnd, tg->td->throtl_slice); +/* Round up to the next throttle slice, wait time must be nonzero */ + jiffy_elapsed_rnd =roundup (jiffy_elapsed +1 , tg->td->throtl_slice);/* * jiffy_elapsed_rnd should not be a big value as minimum iops can be
Greg Kroah-Hartman
maintainerPATCH 267/271 blk-iolatency: clear use_delay when io.latency is set to zero
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit 5de0073fcd50cc1f150895a7bb04d3cf8067b1d7 upstream.
If use_delay was non-zero when the latency target of a cgroup was set to zero, it will stay stuck until io.latency is enabled on the cgroup again. This keeps readahead disabled for the cgroup impacting performance negatively.
--- block/blk-iolatency.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
block/blk-iolatency.c +3 -1
@@ -746,8 +746,10 @@ static int iolatency_set_min_lat_nsec(stif (!oldval && val)return 1 ; -if (oldval && !val) +if (oldval && !val) { +blkcg_clear_delay (blkg);return -1 ; + }return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 268/271 blkcg: update blkcg_print_stat() to handle larger outputs
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit f539da82f2158916e154d206054e0efd5df7ab61 upstream.
Depending on the number of devices, blkcg stats can go over the default seqfile buf size. seqfile normally retries with a larger buffer but since the ->pd_stat() addition, blkcg_print_stat() doesn't tell seqfile that overflow has happened and the output gets printed truncated. Fix it by calling seq_commit() w/ -1 on possible overflows.
--- block/blk-cgroup.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
block/blk-cgroup.c +6 -2
@@ -1016,8 +1016,12 @@ static int blkcg_print_stat(struct seq_f } next:if (has_stats) { - off +=scnprintf (buf+off, size-off,"\n" ); -seq_commit (sf, off); +if (off < size -1 ) { + off +=scnprintf (buf+off, size-off,"\n" ); +seq_commit (sf, off); + }else { +seq_commit (sf,-1 ); + } } }
Greg Kroah-Hartman
maintainerPATCH 269/271 net: mvmdio: allow up to four clocks to be specified for orion-mdio
In reply to Greg Kroah-HartmanFrom: Josua Mayer <[email protected]>
commit 4aabed699c400810981d3dda170f05fa4d782905 upstream.
Allow up to four clocks to be specified and enabled for the orion-mdio interface, which are required by the Armada 8k and defined in armada-cp110.dtsi.
Fixes a hang in probing the mvmdio driver that was encountered on the Clearfog GT 8K with all drivers built as modules, but also affects other boards such as the MacchiatoBIN.
--- drivers/net/ethernet/marvell/mvmdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/mvmdio.c +1 -1
@@ -64,7 +64,7 @@struct orion_mdio_dev {void __iomem *regs; -struct clk *clk[3 ]; +struct clk *clk[4 ];/* * If we have access to the error interrupt pin (which is * somewhat misnamed as it not only reflects internal errors
Greg Kroah-Hartman
maintainerPATCH 270/271 dt-bindings: allow up to four clocks for orion-mdio
In reply to Greg Kroah-HartmanFrom: Josua Mayer <[email protected]>
commit 80785f5a22e9073e2ded5958feb7f220e066d17b upstream.
Armada 8040 needs four clocks to be enabled for MDIO accesses to work. Update the binding to allow the extra clock to be specified.
--- Documentation/devicetree/bindings/net/marvell-orion-mdio.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/net/marvell-orion-mdio.txt +1 -1
@@ -16,7 +16,7 @@ Required properties: Optional properties: - interrupts: interrupt line number for the SMI error/done interrupt -- clocks: phandle for up to three required clocks for the MDIO instance +- clocks: phandle for up to four required clocks for the MDIO instance The child nodes of the MDIO driver are the individual PHY devices connected to this MDIO bus. They must have a "reg" property given the
Greg Kroah-Hartman
maintainerPATCH 271/271 dm bufio: fix deadlock with loop device
In reply to Greg Kroah-HartmanFrom: Junxiao Bi <[email protected]>
commit bd293d071ffe65e645b4d8104f9d8fe15ea13862 upstream.
When thin-volume is built on loop device, if available memory is low, the following deadlock can be triggered:
One process P1 allocates memory with GFP_FS flag, direct alloc fails, memory reclaim invokes memory shrinker in dm_bufio, dm_bufio_shrink_scan() runs, mutex dm_bufio_client->lock is acquired, then P1 waits for dm_buffer IO to complete in __try_evict_buffer().
But this IO may never complete if issued to an underlying loop device that forwards it using direct-IO, which allocates memory using GFP_KERNEL (see: do_blockdev_direct_IO()). If allocation fails, memory reclaim will invoke memory shrinker in dm_bufio, dm_bufio_shrink_scan() will be invoked, and since the mutex is already held by P1 the loop thread will hang, and IO will never complete. Resulting in ABBA deadlock.
--- drivers/md/dm-bufio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/md/dm-bufio.c +1 -3
@@ -1602,9 +1602,7 @@ dm_bufio_shrink_scan(struct shrinker *shunsigned long freed; c = container_of(shrink, struct dm_bufio_client, shrinker); -if (sc->gfp_mask & __GFP_FS) -dm_bufio_lock (c); -else if (!dm_bufio_trylock (c)) +if (!dm_bufio_trylock (c))return SHRINK_STOP ; freed =__scan (c, sc->nr_to_scan, sc->gfp_mask);
Jon Hunter
maintainerQuoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.61 release. There are 271 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri 26 Jul 2019 07:13:35 PM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.61-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.19.y
and the diffstat can be found below.thanks,
greg k-h
All tests are passing for Tegra ...
Test results for stable-v4.19:
12 builds: 12 pass, 0 fail
22 boots: 22 pass, 0 fail
32 tests: 32 pass, 0 failLinux version: 4.19.61-rc1-g872cde3ebfc9
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra20-ventana,
tegra210-p2371-2180, tegra30-cardhu-a04Cheers
Jon
Signature · 1 line
nvpublic
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.61 release. There are 271 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri 26 Jul 2019 07:13:35 PM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.61-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.19.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.61 release. There are 271 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri 26 Jul 2019 07:13:35 PM UTC. Anything received after that time might be too late.
Build results:
total: 156 pass: 156 fail: 0 Qemu test results: total: 364 pass: 364 fail: 0
Guenter
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.19.61 release. There are 271 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri 26 Jul 2019 07:13:35 PM UTC. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.61-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-4.19.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted with no regressions on my system.
Cheers,
Kelsey
Built and booted on my x86_64 system. No dmesg regressions.
Thank you
Bharath