5.10.180-rc1 review
Subsystems (8)
Greg Kroah-Hartman
maintainerPATCH 146/381 scsi: target: Rename cmd.bad_sector to cmd.sense_info
In reply to Greg Kroah-HartmanFrom: David Disseldorp <[email protected]>
[ Upstream commit 8dd992fb67f33a0777fb4bee1e22a5ee5530f024 ]
cmd.bad_sector currently gets packed into the sense INFORMATION field for TCM_LOGICAL_BLOCK_{GUARD,APP_TAG,REF_TAG}_CHECK_FAILED errors, which carry an .add_sector_info flag in the sense_detail_table to ensure this.
In preparation for propagating a byte offset on COMPARE AND WRITE TCM_MISCOMPARE_VERIFY error, rename cmd.bad_sector to cmd.sense_info and sense_detail.add_sector_info to sense_detail.add_sense_info so that it better reflects the sense INFORMATION field destination.
[ddiss: update previously overlooked ib_isert]
Stable-dep-of: 673db054d7a2 ("scsi: target: Fix multiple LUN_RESET handling")
--- drivers/infiniband/ulp/isert/ib_isert.c | 4 ++-- drivers/target/target_core_sbc.c | 2 +- drivers/target/target_core_transport.c | 12 ++++++------ include/target/target_core_base.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/infiniband/ulp/isert/ib_isert.c +2 -2
@@ -1553,12 +1553,12 @@ isert_check_pi_status(struct se_cmd *se_cmd, struct ib_mr *sig_mr) } sec_offset_err = mr_status.sig_err.sig_err_offset;do_div (sec_offset_err, block_size); - se_cmd->bad_sector = sec_offset_err + se_cmd->t_task_lba; + se_cmd->sense_info = sec_offset_err + se_cmd->t_task_lba;isert_err ("PI error found type %d at sector 0x%llx " "expected 0x%x vs actual 0x%x\n" , mr_status.sig_err.err_type, - (unsigned long long )se_cmd->bad_sector, + (unsigned long long )se_cmd->sense_info, mr_status.sig_err.expected, mr_status.sig_err.actual); ret =1 ;
drivers/target/target_core_sbc.c +1 -1
@@ -1438,7 +1438,7 @@ sbc_dif_verify(struct se_cmd *cmd, sector_t start, unsigned int sectors,if (rc) {kunmap_atomic (daddr - dsg->offset);kunmap_atomic (paddr - psg->offset); - cmd->bad_sector = sector; + cmd->sense_info = sector;return rc; } next:
drivers/target/target_core_transport.c +6 -6
@@ -3135,7 +3135,7 @@ struct sense_detail {u8 key;u8 asc;u8 ascq; -bool add_sector_info; +bool add_sense_info; };static const struct sense_detail sense_detail_table[] = {
@@ -3238,19 +3238,19 @@ static const struct sense_detail sense_detail_table[] = { .key = ABORTED_COMMAND, .asc = 0x10, .ascq = 0x01, /* LOGICAL BLOCK GUARD CHECK FAILED */ - .add_sector_info = true, + .add_sense_info = true, }, [TCM_LOGICAL_BLOCK_APP_TAG_CHECK_FAILED] = { .key = ABORTED_COMMAND, .asc = 0x10, .ascq = 0x02, /* LOGICAL BLOCK APPLICATION TAG CHECK FAILED */ - .add_sector_info = true, + .add_sense_info = true, }, [TCM_LOGICAL_BLOCK_REF_TAG_CHECK_FAILED] = { .key = ABORTED_COMMAND, .asc = 0x10, .ascq = 0x03, /* LOGICAL BLOCK REFERENCE TAG CHECK FAILED */ - .add_sector_info = true, + .add_sense_info = true, }, [TCM_COPY_TARGET_DEVICE_NOT_REACHABLE] = { .key = COPY_ABORTED,
@@ -3330,10 +3330,10 @@ static void translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason) cmd->scsi_status =SAM_STAT_CHECK_CONDITION ; cmd->scsi_sense_length =TRANSPORT_SENSE_BUFFER ;scsi_build_sense_buffer (desc_format, buffer, key, asc, ascq); -if (sd->add_sector_info) +if (sd->add_sense_info)WARN_ON_ONCE (scsi_set_sense_information (buffer, cmd->scsi_sense_length, - cmd->bad_sector) <0 ); + cmd->sense_info) <0 ); }int
include/target/target_core_base.h +1 -1
@@ -540,7 +540,7 @@ struct se_cmd {struct scatterlist *t_prot_sg;unsigned int t_prot_nents;sense_reason_t pi_err; -sector_t bad_sector; +u64 sense_info;int cpuid; };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 147/381 scsi: target: Make state_list per CPU
In reply to Greg Kroah-HartmanFrom: Mike Christie <[email protected]>
[ Upstream commit 1526d9f10c6184031e42afad0adbdde1213e8ad1 ]
Do a state_list/execute_task_lock per CPU, so we can do submissions from different CPUs without contention with each other.
Note: tcm_fc was passing TARGET_SCF_USE_CPUID, but never set cpuid. The assumption is that it wanted to set the cpuid to the CPU it was submitting from so it will get this behavior with this patch.
[mkp: s/printk/pr_err/ + resolve COMPARE AND WRITE patch conflict]
Stable-dep-of: 673db054d7a2 ("scsi: target: Fix multiple LUN_RESET handling")
--- drivers/target/target_core_device.c | 16 ++- drivers/target/target_core_tmr.c | 166 +++++++++++++------------ drivers/target/target_core_transport.c | 27 ++-- drivers/target/tcm_fc/tfc_cmd.c | 2 +- include/target/target_core_base.h | 13 +- 5 files changed, 126 insertions(+), 98 deletions(-)
drivers/target/target_core_device.c +14 -2
@@ -724,11 +724,24 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) {struct se_device *dev;struct se_lun *xcopy_lun; +int i; dev = hba->backend->ops->alloc_device (hba, name);if (!dev)return NULL ; + dev->queues =kcalloc (nr_cpu_ids,sizeof (*dev->queues),GFP_KERNEL ); +if (!dev->queues) { + dev->transport->free_device (dev); +return NULL ; + } + + dev->queue_cnt = nr_cpu_ids; +for (i =0 ; i < dev->queue_cnt; i++) { +INIT_LIST_HEAD (&dev->queues[i].state_list); +spin_lock_init (&dev->queues[i].lock); + } + dev->se_hba = hba; dev->transport = hba->backend->ops; dev->transport_flags = dev->transport->transport_flags_default;
@@ -738,9 +751,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)INIT_LIST_HEAD (&dev->dev_sep_list);INIT_LIST_HEAD (&dev->dev_tmr_list);INIT_LIST_HEAD (&dev->delayed_cmd_list); -INIT_LIST_HEAD (&dev->state_list);INIT_LIST_HEAD (&dev->qf_cmd_list); -spin_lock_init (&dev->execute_task_lock);spin_lock_init (&dev->delayed_cmd_lock);spin_lock_init (&dev->dev_reservation_lock);spin_lock_init (&dev->se_port_lock);
@@ -1014,6 +1025,7 @@ void target_free_device(struct se_device *dev)if (dev->transport->free_prot) dev->transport->free_prot (dev); +kfree (dev->queues); dev->transport->free_device (dev); }
drivers/target/target_core_tmr.c +87 -79
186 lines not on this page · raw message
drivers/target/target_core_transport.c +13 -14
@@ -650,12 +650,12 @@ static void target_remove_from_state_list(struct se_cmd *cmd)if (!dev)return ; -spin_lock_irqsave (&dev->execute_task_lock, flags); +spin_lock_irqsave (&dev->queues[cmd->cpuid].lock, flags);if (cmd->state_active) {list_del (&cmd->state_list); cmd->state_active = false; } -spin_unlock_irqrestore (&dev->execute_task_lock, flags); +spin_unlock_irqrestore (&dev->queues[cmd->cpuid].lock, flags); }/*
@@ -866,10 +866,7 @@ void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status)INIT_WORK (&cmd->work, success ? target_complete_ok_work : target_complete_failure_work); -if (cmd->se_cmd_flags &SCF_USE_CPUID ) -queue_work_on (cmd->cpuid, target_completion_wq, &cmd->work); -else -queue_work (target_completion_wq, &cmd->work); +queue_work_on (cmd->cpuid, target_completion_wq, &cmd->work); }EXPORT_SYMBOL (target_complete_cmd);
@@ -904,12 +901,13 @@ static void target_add_to_state_list(struct se_cmd *cmd)struct se_device *dev = cmd->se_dev;unsigned long flags; -spin_lock_irqsave (&dev->execute_task_lock, flags); +spin_lock_irqsave (&dev->queues[cmd->cpuid].lock, flags);if (!cmd->state_active) { -list_add_tail (&cmd->state_list, &dev->state_list); +list_add_tail (&cmd->state_list, + &dev->queues[cmd->cpuid].state_list); cmd->state_active = true; } -spin_unlock_irqrestore (&dev->execute_task_lock, flags); +spin_unlock_irqrestore (&dev->queues[cmd->cpuid].lock, flags); }/*
@@ -1397,6 +1395,9 @@ void transport_init_se_cmd( cmd->sense_buffer = sense_buffer; cmd->orig_fe_lun = unpacked_lun; +if (!(cmd->se_cmd_flags &SCF_USE_CPUID )) + cmd->cpuid =smp_processor_id (); + cmd->state_active = false; }EXPORT_SYMBOL (transport_init_se_cmd);
@@ -1614,6 +1615,9 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sessBUG_ON (!se_tpg);BUG_ON (se_cmd->se_tfo || se_cmd->se_sess);BUG_ON (in_interrupt ()); + +if (flags &TARGET_SCF_USE_CPUID ) + se_cmd->se_cmd_flags |=SCF_USE_CPUID ;/* * Initialize se_cmd for target operation. From this point * exceptions are handled by sending exception status via
@@ -1623,11 +1627,6 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess data_length, data_dir, task_attr, sense, unpacked_lun); -if (flags &TARGET_SCF_USE_CPUID ) - se_cmd->se_cmd_flags |=SCF_USE_CPUID ; -else - se_cmd->cpuid =WORK_CPU_UNBOUND ; -if (flags &TARGET_SCF_UNKNOWN_SIZE ) se_cmd->unknown_data_length =1 ;/*
drivers/target/tcm_fc/tfc_cmd.c +1 -1
@@ -551,7 +551,7 @@ static void ft_send_work(struct work_struct *work)if (target_submit_cmd (&cmd->se_cmd, cmd->sess->se_sess, fcp->fc_cdb, &cmd->ft_sense_buffer[0 ],scsilun_to_int (&fcp->fc_lun),ntohl (fcp->fc_dl), task_attr, data_dir, -TARGET_SCF_ACK_KREF |TARGET_SCF_USE_CPUID )) +TARGET_SCF_ACK_KREF )) goto err;pr_debug ("r_ctl %x target_submit_cmd %p\n" , fh->fh_r_ctl, cmd);
include/target/target_core_base.h +11 -2
@@ -541,6 +541,10 @@ struct se_cmd {unsigned int t_prot_nents;sense_reason_t pi_err;u64 sense_info; +/* +* CPU LIO will execute the cmd on. Defaults to the CPU the cmd is +* initialized on. Drivers can override. +*/ int cpuid; };
@@ -761,6 +765,11 @@ struct se_dev_stat_grps {struct config_group scsi_lu_group; }; +struct se_device_queue { +struct list_head state_list; +spinlock_t lock; +}; +struct se_device {/* RELATIVE TARGET PORT IDENTIFER Counter */ u16 dev_rpti_counter;
@@ -794,7 +803,6 @@ struct se_device {atomic_t dev_qf_count;u32 export_count;spinlock_t delayed_cmd_lock; -spinlock_t execute_task_lock;spinlock_t dev_reservation_lock;unsigned int dev_reservation_flags;#define DRF_SPC2_RESERVATIONS 0x00000001
@@ -814,7 +822,6 @@ struct se_device {struct work_struct qf_work_queue;struct work_struct delayed_cmd_work;struct list_head delayed_cmd_list; -struct list_head state_list;struct list_head qf_cmd_list;/* Pointer to associated SE HBA */ struct se_hba *se_hba;
@@ -841,6 +848,8 @@ struct se_device {/* For se_lun->lun_se_dev RCU read-side critical access */ u32 hba_index;struct rcu_head rcu_head; +int queue_cnt; +struct se_device_queue *queues; };struct se_hba {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 148/381 scsi: target: Fix multiple LUN_RESET handling
In reply to Greg Kroah-HartmanFrom: Mike Christie <[email protected]>
[ Upstream commit 673db054d7a2b5a470d7a25baf65956d005ad729 ]
This fixes a bug where an initiator thinks a LUN_RESET has cleaned up running commands when it hasn't. The bug was added in commit 51ec502a3266 ("target: Delete tmr from list before processing").
The problem occurs when:
1. We have N I/O cmds running in the target layer spread over 2 sessions.
2. The initiator sends a LUN_RESET for each session.
3. session1's LUN_RESET loops over all the running commands from both sessions and moves them to its local drain_task_list.
4. session2's LUN_RESET does not see the LUN_RESET from session1 because the commit above has it remove itself. session2 also does not see any commands since the other reset moved them off the state lists.
5. sessions2's LUN_RESET will then complete with a successful response.
6. sessions2's inititor believes the running commands on its session are now cleaned up due to the successful response and cleans up the running commands from its side. It then restarts them.
7. The commands do eventually complete on the backend and the target starts to return aborted task statuses for them. The initiator will either throw a invalid ITT error or might accidentally lookup a new task if the ITT has been reallocated already.
Fix the bug by reverting the patch, and serialize the execution of LUN_RESETs and Preempt and Aborts.
Also prevent us from waiting on LUN_RESETs in core_tmr_drain_tmr_list, because it turns out the original patch fixed a bug that was not mentioned. For LUN_RESET1 core_tmr_drain_tmr_list can see a second LUN_RESET and wait on it. Then the second reset will run core_tmr_drain_tmr_list and see the first reset and wait on it resulting in a deadlock.
--- drivers/target/target_core_device.c | 1 + drivers/target/target_core_tmr.c | 26 +++++++++++++++++++++++--- include/target/target_core_base.h | 1 + 3 files changed, 25 insertions(+), 3 deletions(-)
drivers/target/target_core_device.c +1 -0
@@ -770,6 +770,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)spin_lock_init (&dev->t10_alua.lba_map_lock);INIT_WORK (&dev->delayed_cmd_work, target_do_delayed_work); +mutex_init (&dev->lun_reset_mutex); dev->t10_wwn.t10_dev = dev; dev->t10_alua.t10_dev = dev;
drivers/target/target_core_tmr.c +23 -3
@@ -202,14 +202,23 @@ static void core_tmr_drain_tmr_list(* LUN_RESET tmr.. */ spin_lock_irqsave (&dev->se_tmr_lock, flags); -if (tmr) -list_del_init (&tmr->tmr_list);list_for_each_entry_safe (tmr_p, tmr_pp, &dev->dev_tmr_list, tmr_list) { +if (tmr_p == tmr) +continue ; + cmd = tmr_p->task_cmd;if (!cmd) {pr_err ("Unable to locate struct se_cmd for TMR\n" );continue ; } + +/* +* We only execute one LUN_RESET at a time so we can't wait +* on them below. +*/ +if (tmr_p->function ==TMR_LUN_RESET ) +continue ; +/* * If this function was called with a valid pr_res_key * parameter (eg: for PROUT PREEMPT_AND_ABORT service action
@@ -390,14 +399,25 @@ int core_tmr_lun_reset( tmr_nacl->initiatorname); } } + + +/* +* We only allow one reset or preempt and abort to execute at a time +* to prevent one call from claiming all the cmds causing a second +* call from returning while cmds it should have waited on are still +* running. +*/ +mutex_lock (&dev->lun_reset_mutex); +pr_debug ("LUN_RESET: %s starting for [%s], tas: %d\n" , (preempt_and_abort_list) ?"Preempt" :"TMR" , dev->transport->name, tas); -core_tmr_drain_tmr_list (dev, tmr, preempt_and_abort_list);core_tmr_drain_state_list (dev, prout_cmd, tmr_sess, tas, preempt_and_abort_list); +mutex_unlock (&dev->lun_reset_mutex); +/* * Clear any legacy SPC-2 reservation when called during * LOGICAL UNIT RESET
include/target/target_core_base.h +1 -0
@@ -850,6 +850,7 @@ struct se_device {struct rcu_head rcu_head;int queue_cnt;struct se_device_queue *queues; +struct mutex lun_reset_mutex; };struct se_hba {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 149/381 scsi: target: iscsit: Fix TAS handling during conn cleanup
In reply to Greg Kroah-HartmanFrom: Mike Christie <[email protected]>
[ Upstream commit cc79da306ebb2edb700c3816b90219223182ac3c ]
Fix a bug added in commit f36199355c64 ("scsi: target: iscsi: Fix cmd abort fabric stop race").
If CMD_T_TAS is set on the se_cmd we must call iscsit_free_cmd() to do the last put on the cmd and free it, because the connection is down and we will not up sending the response and doing the put from the normal I/O path.
Add a check for CMD_T_TAS in iscsit_release_commands_from_conn() so we now detect this case and run iscsit_free_cmd().
--- drivers/target/iscsi/iscsi_target.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/target/iscsi/iscsi_target.c +9 -7
@@ -4084,9 +4084,12 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)list_for_each_entry_safe (cmd, cmd_tmp, &tmp_list, i_conn_node) {struct se_cmd *se_cmd = &cmd->se_cmd; -if (se_cmd->se_tfo !=NULL ) { -spin_lock_irq (&se_cmd->t_state_lock); -if (se_cmd->transport_state &CMD_T_ABORTED ) { +if (!se_cmd->se_tfo) +continue ; + +spin_lock_irq (&se_cmd->t_state_lock); +if (se_cmd->transport_state &CMD_T_ABORTED ) { +if (!(se_cmd->transport_state &CMD_T_TAS ))/* * LIO's abort path owns the cleanup for this, * so put it back on the list and let
@@ -4094,11 +4097,10 @@ static void iscsit_release_commands_from_conn(struct iscsi_conn *conn)*/ list_move_tail (&cmd->i_conn_node, &conn->conn_cmd_list); - }else { - se_cmd->transport_state |=CMD_T_FABRIC_STOP ; - } -spin_unlock_irq (&se_cmd->t_state_lock); + }else { + se_cmd->transport_state |=CMD_T_FABRIC_STOP ; } +spin_unlock_irq (&se_cmd->t_state_lock); }spin_unlock_bh (&conn->cmd_lock);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 150/381 scsi: megaraid: Fix mega_cmd_done() CMDID_INT_CMDS
In reply to Greg Kroah-HartmanFrom: Danila Chernetsov <[email protected]>
[ Upstream commit 75cb113cd43f06aaf4f1bda0069cfd5b98e909eb ]
When cmdid == CMDID_INT_CMDS, the 'cmds' pointer is NULL but is dereferenced below.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/scsi/megaraid.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/megaraid.c +1 -0
@@ -1443,6 +1443,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)*/ if (cmdid ==CMDID_INT_CMDS ) { scb = &adapter->int_scb; + cmd = scb->cmd;list_del_init (&scb->list); scb->state =SCB_FREE ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 151/381 f2fs: handle dqget error in f2fs_transfer_project_quota()
In reply to Greg Kroah-HartmanFrom: Yangtao Li <[email protected]>
[ Upstream commit 8051692f5f23260215bfe9a72e712d93606acc5f ]
We should set the error code when dqget() failed.
--- fs/f2fs/file.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
fs/f2fs/file.c +8 -7
@@ -3013,15 +3013,16 @@ int f2fs_transfer_project_quota(struct inode *inode, kprojid_t kprojid)struct dquot *transfer_to[MAXQUOTAS ] = {};struct f2fs_sb_info *sbi =F2FS_I_SB (inode);struct super_block *sb = sbi->sb; -int err =0 ; +int err; transfer_to[PRJQUOTA ] =dqget (sb,make_kqid_projid (kprojid)); -if (!IS_ERR (transfer_to[PRJQUOTA ])) { - err =__dquot_transfer (inode, transfer_to); -if (err) -set_sbi_flag (sbi,SBI_QUOTA_NEED_REPAIR ); -dqput (transfer_to[PRJQUOTA ]); - } +if (IS_ERR (transfer_to[PRJQUOTA ])) +return PTR_ERR (transfer_to[PRJQUOTA ]); + + err =__dquot_transfer (inode, transfer_to); +if (err) +set_sbi_flag (sbi,SBI_QUOTA_NEED_REPAIR ); +dqput (transfer_to[PRJQUOTA ]);return err; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 152/381 f2fs: enforce single zone capacity
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit b771aadc6e4c221a468fe4a2dfcfffec01a06722 ]
In order to simplify the complicated per-zone capacity, let's support only one capacity for entire zoned device.
Stable-dep-of: 0b37ed21e336 ("f2fs: apply zone capacity to all zone type")
--- fs/f2fs/f2fs.h | 2 +- fs/f2fs/segment.c | 19 ++++++------------- fs/f2fs/segment.h | 3 +++ fs/f2fs/super.c | 33 ++++++++++++--------------------- 4 files changed, 22 insertions(+), 35 deletions(-)
fs/f2fs/f2fs.h +1 -1
@@ -1153,7 +1153,6 @@ struct f2fs_dev_info {#ifdef CONFIG_BLK_DEV_ZONED unsigned int nr_blkz;/* Total number of zones */ unsigned long *blkz_seq;/* Bitmap indicating sequential zones */ -block_t *zone_capacity_blocks;/* Array of zone capacity in blks */ #endif };
@@ -1422,6 +1421,7 @@ struct f2fs_sb_info {unsigned int meta_ino_num;/* meta inode number*/ unsigned int log_blocks_per_seg;/* log2 blocks per segment */ unsigned int blocks_per_seg;/* blocks per segment */ +unsigned int unusable_blocks_per_sec;/* unusable blocks per section */ unsigned int segs_per_sec;/* segments per section */ unsigned int secs_per_zone;/* sections per zone */ unsigned int total_sections;/* total section count */
fs/f2fs/segment.c +6 -13
@@ -4982,7 +4982,7 @@ static unsigned int get_zone_idx(struct f2fs_sb_info *sbi, unsigned int secno,static inline unsigned int f2fs_usable_zone_segs_in_sec (struct f2fs_sb_info *sbi,unsigned int segno) { -unsigned int dev_idx, zone_idx, unusable_segs_in_sec; +unsigned int dev_idx, zone_idx; dev_idx =f2fs_target_device_index (sbi,START_BLOCK (sbi, segno)); zone_idx =get_zone_idx (sbi,GET_SEC_FROM_SEG (sbi, segno), dev_idx);
@@ -4991,18 +4991,12 @@ static inline unsigned int f2fs_usable_zone_segs_in_sec(if (is_conv_zone (sbi, zone_idx, dev_idx))return sbi->segs_per_sec; -/* -* If the zone_capacity_blocks array is NULL, then zone capacity -* is equal to the zone size for all zones -*/ -if (!FDEV (dev_idx).zone_capacity_blocks) +if (!sbi->unusable_blocks_per_sec)return sbi->segs_per_sec;/* Get the segment count beyond zone capacity block */ - unusable_segs_in_sec = (sbi->blocks_per_blkz - -FDEV (dev_idx).zone_capacity_blocks[zone_idx]) >> - sbi->log_blocks_per_seg; -return sbi->segs_per_sec - unusable_segs_in_sec; +return sbi->segs_per_sec - (sbi->unusable_blocks_per_sec >> + sbi->log_blocks_per_seg); }/*
@@ -5031,12 +5025,11 @@ static inline unsigned int f2fs_usable_zone_blks_in_seg(if (is_conv_zone (sbi, zone_idx, dev_idx))return sbi->blocks_per_seg; -if (!FDEV (dev_idx).zone_capacity_blocks) +if (!sbi->unusable_blocks_per_sec)return sbi->blocks_per_seg; sec_start_blkaddr =START_BLOCK (sbi,GET_SEG_FROM_SEC (sbi, secno)); - sec_cap_blkaddr = sec_start_blkaddr + -FDEV (dev_idx).zone_capacity_blocks[zone_idx]; + sec_cap_blkaddr = sec_start_blkaddr +CAP_BLKS_PER_SEC (sbi);/* * If segment starts before zone capacity and spans beyond
fs/f2fs/segment.h +3 -0
@@ -101,6 +101,9 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi, GET_SEGNO_FROM_SEG0(sbi, blk_addr)))#define BLKS_PER_SEC (sbi) \ ((sbi)->segs_per_sec * (sbi)->blocks_per_seg) +#define CAP_BLKS_PER_SEC (sbi) \ + ((sbi)->segs_per_sec * (sbi)->blocks_per_seg - \ + (sbi)->unusable_blocks_per_sec)#define GET_SEC_FROM_SEG (sbi, segno) \ (((segno) == -1) ? -1: (segno) / (sbi)->segs_per_sec)#define GET_SEG_FROM_SEC (sbi, secno) \
fs/f2fs/super.c +12 -21
@@ -1242,7 +1242,6 @@ static void destroy_device_list(struct f2fs_sb_info *sbi)blkdev_put (FDEV (i).bdev,FMODE_EXCL );#ifdef CONFIG_BLK_DEV_ZONED kvfree (FDEV (i).blkz_seq); -kfree (FDEV (i).zone_capacity_blocks);#endif }kvfree (sbi->devs);
@@ -3199,24 +3198,29 @@ static int init_percpu_info(struct f2fs_sb_info *sbi)#ifdef CONFIG_BLK_DEV_ZONED struct f2fs_report_zones_args { +struct f2fs_sb_info *sbi;struct f2fs_dev_info *dev; -bool zone_cap_mismatch; };static int f2fs_report_zone_cb (struct blk_zone *zone,unsigned int idx,void *data) {struct f2fs_report_zones_args *rz_args = data; +block_t unusable_blocks = (zone->len - zone->capacity) >> +F2FS_LOG_SECTORS_PER_BLOCK ;if (zone->type ==BLK_ZONE_TYPE_CONVENTIONAL )return 0 ;set_bit (idx, rz_args->dev->blkz_seq); - rz_args->dev->zone_capacity_blocks[idx] = zone->capacity >> -F2FS_LOG_SECTORS_PER_BLOCK ; -if (zone->len != zone->capacity && !rz_args->zone_cap_mismatch) - rz_args->zone_cap_mismatch = true; - +if (!rz_args->sbi->unusable_blocks_per_sec) { + rz_args->sbi->unusable_blocks_per_sec = unusable_blocks; +return 0 ; + } +if (rz_args->sbi->unusable_blocks_per_sec != unusable_blocks) { +f2fs_err (rz_args->sbi,"F2FS supports single zone capacity\n" ); +return -EINVAL ; + }return 0 ; }
@@ -3250,26 +3254,13 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)if (!FDEV (devi).blkz_seq)return -ENOMEM ; -/* Get block zones type and zone-capacity */ -FDEV (devi).zone_capacity_blocks =f2fs_kzalloc (sbi, -FDEV (devi).nr_blkz *sizeof (block_t), -GFP_KERNEL ); -if (!FDEV (devi).zone_capacity_blocks) -return -ENOMEM ; - + rep_zone_arg.sbi = sbi; rep_zone_arg.dev = &FDEV (devi); - rep_zone_arg.zone_cap_mismatch = false; ret =blkdev_report_zones (bdev,0 ,BLK_ALL_ZONES , f2fs_report_zone_cb, &rep_zone_arg);if (ret <0 )return ret; - -if (!rep_zone_arg.zone_cap_mismatch) { -kfree (FDEV (devi).zone_capacity_blocks); -FDEV (devi).zone_capacity_blocks =NULL ; - } - return 0; }#endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 153/381 f2fs: apply zone capacity to all zone type
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit 0b37ed21e3367539b79284e0b0af2246ffcf0dca ]
If we manage the zone capacity per zone type, it'll break the GC assumption. And, the current logic complains valid block count mismatch. Let's apply zone capacity to all zone type, if specified.
--- fs/f2fs/segment.c | 65 +++-------------------------------------------- fs/f2fs/segment.h | 3 +++ 2 files changed, 7 insertions(+), 61 deletions(-)
fs/f2fs/segment.c +4 -61
@@ -4957,48 +4957,6 @@ int f2fs_check_write_pointer(struct f2fs_sb_info *sbi)return 0 ; } -static bool is_conv_zone (struct f2fs_sb_info *sbi,unsigned int zone_idx, -unsigned int dev_idx) -{ -if (!bdev_is_zoned (FDEV (dev_idx).bdev)) -return true; -return !test_bit (zone_idx,FDEV (dev_idx).blkz_seq); -} - -/* Return the zone index in the given device */ -static unsigned int get_zone_idx (struct f2fs_sb_info *sbi,unsigned int secno, -int dev_idx) -{ -block_t sec_start_blkaddr =START_BLOCK (sbi,GET_SEG_FROM_SEC (sbi, secno)); - -return (sec_start_blkaddr -FDEV (dev_idx).start_blk) >> - sbi->log_blocks_per_blkz; -} - -/* -* Return the usable segments in a section based on the zone's -* corresponding zone capacity. Zone is equal to a section. -*/ -static inline unsigned int f2fs_usable_zone_segs_in_sec ( -struct f2fs_sb_info *sbi,unsigned int segno) -{ -unsigned int dev_idx, zone_idx; - - dev_idx =f2fs_target_device_index (sbi,START_BLOCK (sbi, segno)); - zone_idx =get_zone_idx (sbi,GET_SEC_FROM_SEG (sbi, segno), dev_idx); - -/* Conventional zone's capacity is always equal to zone size */ -if (is_conv_zone (sbi, zone_idx, dev_idx)) -return sbi->segs_per_sec; - -if (!sbi->unusable_blocks_per_sec) -return sbi->segs_per_sec; - -/* Get the segment count beyond zone capacity block */ -return sbi->segs_per_sec - (sbi->unusable_blocks_per_sec >> - sbi->log_blocks_per_seg); -} -/* * Return the number of usable blocks in a segment. The number of blocks * returned is always equal to the number of blocks in a segment for
@@ -5011,23 +4969,13 @@ static inline unsigned int f2fs_usable_zone_blks_in_seg( struct f2fs_sb_info *sbi, unsigned int segno) {block_t seg_start, sec_start_blkaddr, sec_cap_blkaddr; -unsigned int zone_idx, dev_idx, secno; - - secno =GET_SEC_FROM_SEG (sbi, segno); - seg_start =START_BLOCK (sbi, segno); - dev_idx =f2fs_target_device_index (sbi, seg_start); - zone_idx =get_zone_idx (sbi, secno, dev_idx); - -/* -* Conventional zone's capacity is always equal to zone size, -* so, blocks per segment is unchanged. -*/ -if (is_conv_zone (sbi, zone_idx, dev_idx)) -return sbi->blocks_per_seg; +unsigned int secno;if (!sbi->unusable_blocks_per_sec)return sbi->blocks_per_seg; + secno =GET_SEC_FROM_SEG (sbi, segno); + seg_start =START_BLOCK (sbi, segno); sec_start_blkaddr =START_BLOCK (sbi,GET_SEG_FROM_SEC (sbi, secno)); sec_cap_blkaddr = sec_start_blkaddr +CAP_BLKS_PER_SEC (sbi);
@@ -5061,11 +5009,6 @@ static inline unsigned int f2fs_usable_zone_blks_in_seg(struct f2fs_sb_info *sbi return 0; } -static inline unsigned int f2fs_usable_zone_segs_in_sec (struct f2fs_sb_info *sbi, -unsigned int segno) -{ -return 0 ; -}#endif unsigned int f2fs_usable_blks_in_seg (struct f2fs_sb_info *sbi,unsigned int segno)
@@ -5080,7 +5023,7 @@ unsigned int f2fs_usable_segs_in_sec(struct f2fs_sb_info *sbi, unsigned int segno) {if (f2fs_sb_has_blkzoned (sbi)) -return f2fs_usable_zone_segs_in_sec (sbi, segno); +return CAP_SEGS_PER_SEC (sbi);return sbi->segs_per_sec; }
fs/f2fs/segment.h +3 -0
@@ -104,6 +104,9 @@ static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi,#define CAP_BLKS_PER_SEC (sbi) \ ((sbi)->segs_per_sec * (sbi)->blocks_per_seg - \ (sbi)->unusable_blocks_per_sec) +#define CAP_SEGS_PER_SEC (sbi) \ + ((sbi)->segs_per_sec - ((sbi)->unusable_blocks_per_sec >>\ + (sbi)->log_blocks_per_seg))#define GET_SEC_FROM_SEG (sbi, segno) \ (((segno) == -1) ? -1: (segno) / (sbi)->segs_per_sec)#define GET_SEG_FROM_SEC (sbi, secno) \
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 154/381 f2fs: compress: fix to call f2fs_wait_on_page_writeback() in f2fs_write_raw_pages()
In reply to Greg Kroah-HartmanFrom: Yangtao Li <[email protected]>
[ Upstream commit babedcbac164cec970872b8097401ca913a80e61 ]
BUG_ON() will be triggered when writing files concurrently, because the same page is writtenback multiple times.
1597 void folio_end_writeback(struct folio *folio)
1598 {
......
1618 if (!__folio_end_writeback(folio))
1619 BUG();
......1625 }
kernel BUG at mm/filemap.c:1619!
Call Trace: <TASK> f2fs_write_end_io+0x1a0/0x370 blk_update_request+0x6c/0x410 blk_mq_end_request+0x15/0x130 blk_complete_reqs+0x3c/0x50 __do_softirq+0xb8/0x29b ? sort_range+0x20/0x20 run_ksoftirqd+0x19/0x20 smpboot_thread_fn+0x10b/0x1d0 kthread+0xde/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x22/0x30 </TASK>
Below is the concurrency scenario:
[Process A] [Process B] [Process C]f2fs_write_raw_pages()
- redirty_page_for_writepage()
- unlock page()
f2fs_do_write_data_page()
- lock_page()
- clear_page_dirty_for_io()
- set_page_writeback() [1st writeback]
.....
- unlock page()
generic_perform_write()
- f2fs_write_begin()
- wait_for_stable_page()
- f2fs_write_end()
- set_page_dirty()
- lock_page()
- f2fs_do_write_data_page()
- set_page_writeback() [2st writeback]
This problem was introduced by the previous commit 7377e853967b ("f2fs:
compress: fix potential deadlock of compress file"). All pagelocks were released in f2fs_write_raw_pages(), but whether the page was in the writeback state was ignored in the subsequent writing process. Let's fix it by waiting for the page to writeback before writing.
--- fs/f2fs/compress.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/f2fs/compress.c +6 -0
@@ -1391,6 +1391,12 @@ static int f2fs_write_raw_pages(struct compress_ctx *cc,if (!PageDirty (cc->rpages[i])) goto continue_unlock; +if (PageWriteback (cc->rpages[i])) { +if (wbc->sync_mode ==WB_SYNC_NONE ) + goto continue_unlock; +f2fs_wait_on_page_writeback (cc->rpages[i],DATA , true, true); + } +if (!clear_page_dirty_for_io (cc->rpages[i])) goto continue_unlock;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 155/381 crypto: caam - Clear some memory in instantiate_rng
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 9c19fb86a8cb2ee82a832c95e139f29ea05c4d08 ]
According to the comment at the end of the 'for' loop just a few lines below, it looks needed to clear 'desc'.
So it should also be cleared for the first iteration.
Move the memset() to the beginning of the loop to be safe.
--- drivers/crypto/caam/ctrl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/crypto/caam/ctrl.c +4 -2
@@ -284,6 +284,10 @@ static int instantiate_rng(struct device *ctrldev, int state_handle_mask,const u32 rdsta_if =RDSTA_IF0 << sh_idx;const u32 rdsta_pr =RDSTA_PR0 << sh_idx;const u32 rdsta_mask = rdsta_if | rdsta_pr; + +/* Clear the contents before using the descriptor */ +memset (desc,0x00 ,CAAM_CMD_SZ *7 ); +/* * If the corresponding bit is set, this state handle * was initialized by somebody else, so it's left alone.
@@ -327,8 +331,6 @@ static int instantiate_rng(struct device *ctrldev, int state_handle_mask, }dev_info (ctrldev,"Instantiated RNG4 SH%d\n" , sh_idx); -/* Clear the contents before recreating the descriptor */ -memset (desc,0x00 ,CAAM_CMD_SZ *7 ); }kfree (desc);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 156/381 crypto: sa2ul - Select CRYPTO_DES
In reply to Greg Kroah-HartmanFrom: Suman Anna <[email protected]>
[ Upstream commit 8832023efd20966e29944dac92118dfbf1fa1bc0 ]
The SA2UL Crypto driver provides support for couple of
DES3 algos "cbc(des3_ede)" and "ecb(des3_ede)", and enabling the crypto selftest throws the following errors (as seen on
K3 J721E SoCs):
saul-crypto 4e00000.crypto: Error allocating fallback algo cbc(des3_ede)
alg: skcipher: failed to allocate transform for cbc-des3-sa2ul: -2 saul-crypto 4e00000.crypto: Error allocating fallback algo ecb(des3_ede)
alg: skcipher: failed to allocate transform for ecb-des3-sa2ul: -2
Fix this by selecting CRYPTO_DES which was missed while adding base driver support.
--- drivers/crypto/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/Kconfig +1 -0
@@ -897,6 +897,7 @@ config CRYPTO_DEV_SA2UL select CRYPTO_AES_ARM64 select CRYPTO_ALGAPI select CRYPTO_AUTHENC + select CRYPTO_DES select CRYPTO_SHA1 select CRYPTO_SHA256 select CRYPTO_SHA512
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 157/381 wifi: rtlwifi: fix incorrect error codes in rtl_debugfs_set_write_rfreg()
In reply to Greg Kroah-HartmanFrom: Wei Chen <[email protected]>
[ Upstream commit 905a9241e4e8c15d2c084fee916280514848fe35 ]
If there is a failure during copy_from_user or user-provided data buffer is invalid, rtl_debugfs_set_write_rfreg should return negative error code instead of a positive value count.
Fix this bug by returning correct error code. Moreover, the check of buffer against null is removed since it will be handled by copy_from_user.
--- drivers/net/wireless/realtek/rtlwifi/debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/realtek/rtlwifi/debug.c +3 -3
@@ -375,8 +375,8 @@ static ssize_t rtl_debugfs_set_write_rfreg(struct file *filp, tmp_len = (count >sizeof (tmp) -1 ?sizeof (tmp) -1 : count); -if (!buffer ||copy_from_user (tmp, buffer, tmp_len)) -return count; +if (copy_from_user (tmp, buffer, tmp_len)) +return -EFAULT ; tmp[tmp_len] ='\0' ;
@@ -386,7 +386,7 @@ static ssize_t rtl_debugfs_set_write_rfreg(struct file *filp,if (num !=4 ) {rtl_dbg (rtlpriv,COMP_ERR ,DBG_DMESG ,"Format is <path> <addr> <mask> <data>\n" ); -return count; +return -EINVAL ; }rtl_set_rfreg (hw, path, addr, bitmask, data);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 158/381 wifi: rtlwifi: fix incorrect error codes in rtl_debugfs_set_write_reg()
In reply to Greg Kroah-HartmanFrom: Wei Chen <[email protected]>
[ Upstream commit 5dbe1f8eb8c5ac69394400a5b86fd81775e96c43 ]
If there is a failure during copy_from_user or user-provided data buffer is invalid, rtl_debugfs_set_write_reg should return negative error code instead of a positive value count.
Fix this bug by returning correct error code. Moreover, the check of buffer against null is removed since it will be handled by copy_from_user.
--- drivers/net/wireless/realtek/rtlwifi/debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/realtek/rtlwifi/debug.c +3 -3
@@ -278,8 +278,8 @@ static ssize_t rtl_debugfs_set_write_reg(struct file *filp, tmp_len = (count >sizeof (tmp) -1 ?sizeof (tmp) -1 : count); -if (!buffer ||copy_from_user (tmp, buffer, tmp_len)) -return count; +if (copy_from_user (tmp, buffer, tmp_len)) +return -EFAULT ; tmp[tmp_len] ='\0' ;
@@ -287,7 +287,7 @@ static ssize_t rtl_debugfs_set_write_reg(struct file *filp, num =sscanf (tmp,"%x %x %x" , &addr, &val, &len);if (num !=3 ) -return count; +return -EINVAL ;switch (len) {case 1 :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 159/381 net: qrtr: correct types of trace event parameters
In reply to Greg Kroah-HartmanFrom: Simon Horman <[email protected]>
[ Upstream commit 054fbf7ff8143d35ca7d3bb5414bb44ee1574194 ]
The arguments passed to the trace events are of type unsigned int, however the signature of the events used __le32 parameters.
I may be missing the point here, but sparse flagged this and it does seem incorrect to me.
net/qrtr/ns.c: note: in included file (through include/trace/trace_events.h, include/trace/define_trace.h, include/trace/events/qrtr.h):
./include/trace/events/qrtr.h:11:1: warning: cast to restricted __le32
./include/trace/events/qrtr.h:11:1: warning: restricted __le32 degrades to integer ./include/trace/events/qrtr.h:11:1: warning: restricted __le32 degrades to integer
... (a lot more similar warnings)
net/qrtr/ns.c:115:47: expected restricted __le32 [usertype] service
net/qrtr/ns.c:115:47: got unsigned int service
net/qrtr/ns.c:115:61: warning: incorrect type in argument 2 (different base types)
... (a lot more similar warnings)
--- include/trace/events/qrtr.h | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-)
include/trace/events/qrtr.h +18 -15
@@ -10,15 +10,16 @@ TRACE_EVENT(qrtr_ns_service_announce_new, - TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port), + TP_PROTO(unsigned int service, unsigned int instance, + unsigned int node, unsigned int port), TP_ARGS(service, instance, node, port), TP_STRUCT__entry( - __field(__le32, service) - __field(__le32, instance) - __field(__le32, node) - __field(__le32, port) + __field(unsigned int, service) + __field(unsigned int, instance) + __field(unsigned int, node) + __field(unsigned int, port) ), TP_fast_assign(
@@ -36,15 +37,16 @@ TRACE_EVENT(qrtr_ns_service_announce_new, TRACE_EVENT(qrtr_ns_service_announce_del, - TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port), + TP_PROTO(unsigned int service, unsigned int instance, + unsigned int node, unsigned int port), TP_ARGS(service, instance, node, port), TP_STRUCT__entry( - __field(__le32, service) - __field(__le32, instance) - __field(__le32, node) - __field(__le32, port) + __field(unsigned int, service) + __field(unsigned int, instance) + __field(unsigned int, node) + __field(unsigned int, port) ), TP_fast_assign(
@@ -62,15 +64,16 @@ TRACE_EVENT(qrtr_ns_service_announce_del, TRACE_EVENT(qrtr_ns_server_add, - TP_PROTO(__le32 service, __le32 instance, __le32 node, __le32 port), + TP_PROTO(unsigned int service, unsigned int instance, + unsigned int node, unsigned int port), TP_ARGS(service, instance, node, port), TP_STRUCT__entry( - __field(__le32, service) - __field(__le32, instance) - __field(__le32, node) - __field(__le32, port) + __field(unsigned int, service) + __field(unsigned int, instance) + __field(unsigned int, node) + __field(unsigned int, port) ), TP_fast_assign(
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 160/381 selftests/bpf: Wait for receive in cg_storage_multi test
In reply to Greg Kroah-HartmanFrom: YiFei Zhu <[email protected]>
[ Upstream commit 5af607a861d43ffff830fc1890033e579ec44799 ]
In some cases the loopback latency might be large enough, causing the assertion on invocations to be run before ingress prog getting executed. The assertion would fail and the test would flake.
This can be reliably reproduced by arbitrarily increasing the loopback latency (thanks to [1]):
tc qdisc add dev lo root handle 1: htb default 12
tc class add dev lo parent 1:1 classid 1:12 htb rate 20kbps ceil 20kbps tc qdisc add dev lo parent 1:12 netem delay 100ms
Fix this by waiting on the receive end, instead of instantly returning to the assert. The call to read() will wait for the default SO_RCVTIMEO timeout of 3 seconds provided by start_server().
[1] https://gist.github.com/kstevens715/4598301
--- tools/testing/selftests/bpf/prog_tests/cg_storage_multi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/cg_storage_multi.c +6 -2
@@ -56,8 +56,9 @@ static bool assert_storage_noexist(struct bpf_map *map, const void *key)static bool connect_send (const char *cgroup_path) { -bool res = true;int server_fd =-1 , client_fd =-1 ; +char message[] ="message" ; +bool res = true;if (join_cgroup (cgroup_path)) goto out_clean;
@@ -70,7 +71,10 @@ static bool connect_send(const char *cgroup_path)if (client_fd <0 ) goto out_clean; -if (send (client_fd,"message" ,strlen ("message" ),0 ) <0 ) +if (send (client_fd, &message,sizeof (message),0 ) <0 ) + goto out_clean; + +if (read (server_fd, &message,sizeof (message)) <0 ) goto out_clean; res = false;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 161/381 bpftool: Fix bug for long instructions in program CFG dumps
In reply to Greg Kroah-HartmanFrom: Quentin Monnet <[email protected]>
[ Upstream commit 67cf52cdb6c8fa6365d29106555dacf95c9fd374 ]
When dumping the control flow graphs for programs using the 16-byte long load instruction, we need to skip the second part of this instruction when looking for the next instruction to process. Otherwise, we end up printing "BUG_ld_00" from the kernel disassembler in the CFG.
--- tools/bpf/bpftool/xlated_dumper.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/bpf/bpftool/xlated_dumper.c +7 -0
@@ -363,8 +363,15 @@ void dump_xlated_for_graph(struct dump_data *dd, void *buf_start, void *buf_end,struct bpf_insn *insn_start = buf_start;struct bpf_insn *insn_end = buf_end;struct bpf_insn *cur = insn_start; +bool double_insn = false;for (; cur <= insn_end; cur++) { +if (double_insn) { + double_insn = false; +continue ; + } + double_insn = cur->code == (BPF_LD |BPF_IMM |BPF_DW ); +printf ("% 4d: " , (int )(cur - insn_start + start_idx));print_bpf_insn (&cbs, cur, true);if (cur != insn_end)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 162/381 crypto: drbg - make drbg_prepare_hrng() handle jent instantiation errors
In reply to Greg Kroah-HartmanFrom: Nicolai Stange <[email protected]>
[ Upstream commit 559edd47cce4cc407d606b4d7f376822816fd4b8 ]
Now that drbg_prepare_hrng() doesn't do anything but to instantiate a jitterentropy crypto_rng instance, it looks a little odd to have the related error handling at its only caller, drbg_instantiate().
Move the handling of jitterentropy allocation failures from drbg_instantiate() close to the allocation itself in drbg_prepare_hrng().
There is no change in behaviour.
Stable-dep-of: 686cd976b6dd ("crypto: drbg - Only fail when jent is unavailable in FIPS mode")
--- crypto/drbg.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
crypto/drbg.c +8 -8
@@ -1515,6 +1515,14 @@ static int drbg_prepare_hrng(struct drbg_state *drbg)return 0 ; drbg->jent =crypto_alloc_rng ("jitterentropy_rng" ,0 ,0 ); +if (IS_ERR (drbg->jent)) { +const int err =PTR_ERR (drbg->jent); + + drbg->jent =NULL ; +if (fips_enabled || err != -ENOENT ) +return err; +pr_info ("DRBG: Continuing without Jitter RNG\n" ); + }return 0 ; }
@@ -1570,14 +1578,6 @@ static int drbg_instantiate(struct drbg_state *drbg, struct drbg_string *pers,if (ret) goto free_everything; -if (IS_ERR (drbg->jent)) { - ret =PTR_ERR (drbg->jent); - drbg->jent =NULL ; -if (fips_enabled || ret != -ENOENT ) - goto free_everything; -pr_info ("DRBG: Continuing without Jitter RNG\n" ); - } - reseed = false; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 163/381 crypto: drbg - Only fail when jent is unavailable in FIPS mode
In reply to Greg Kroah-HartmanFrom: Herbert Xu <[email protected]>
[ Upstream commit 686cd976b6ddedeeb1a1fb09ba53a891d3cc9a03 ]
When jent initialisation fails for any reason other than ENOENT, the entire drbg fails to initialise, even when we're not in FIPS mode. This is wrong because we can still use the kernel RNG when we're not in FIPS mode.
Change it so that it only fails when we are in FIPS mode.
--- crypto/drbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/drbg.c +1 -1
@@ -1519,7 +1519,7 @@ static int drbg_prepare_hrng(struct drbg_state *drbg)const int err =PTR_ERR (drbg->jent); drbg->jent =NULL ; -if (fips_enabled || err != -ENOENT ) +if (fips_enabled)return err;pr_info ("DRBG: Continuing without Jitter RNG\n" ); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 164/381 xsk: Fix unaligned descriptor validation
In reply to Greg Kroah-HartmanFrom: Kal Conley <[email protected]>
[ Upstream commit d769ccaf957fe7391f357c0a923de71f594b8a2b ]
Make sure unaligned descriptors that straddle the end of the UMEM are considered invalid. Currently, descriptor validation is broken for zero-copy mode which only checks descriptors at page granularity. For example, descriptors in zero-copy mode that overrun the end of the UMEM but not a page boundary are (incorrectly) considered valid. The UMEM boundary check needs to happen before the page boundary and contiguity checks in xp_desc_crosses_non_contig_pg(). Do this check in xp_unaligned_validate_desc() instead like xp_check_unaligned() already does.
--- include/net/xsk_buff_pool.h | 9 ++------- net/xdp/xsk_queue.h | 1 + 2 files changed, 3 insertions(+), 7 deletions(-)
include/net/xsk_buff_pool.h +2 -7
@@ -150,13 +150,8 @@ static inline bool xp_desc_crosses_non_contig_pg(struct xsk_buff_pool *pool,if (likely (!cross_pg))return false; -if (pool->dma_pages_cnt) { -return !(pool->dma_pages[addr >>PAGE_SHIFT ] & -XSK_NEXT_PG_CONTIG_MASK ); - } - -/* skb path */ -return addr + len > pool->addrs_cnt; +return pool->dma_pages_cnt && + !(pool->dma_pages[addr >>PAGE_SHIFT ] &XSK_NEXT_PG_CONTIG_MASK ); }static inline u64 xp_aligned_extract_addr (struct xsk_buff_pool *pool,u64 addr)
net/xdp/xsk_queue.h +1 -0
@@ -155,6 +155,7 @@ static inline bool xp_unaligned_validate_desc(struct xsk_buff_pool *pool,return false;if (base_addr >= pool->addrs_cnt || addr >= pool->addrs_cnt || + addr + desc->len > pool->addrs_cnt ||xp_desc_crosses_non_contig_pg (pool, addr, desc->len))return false;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 165/381 f2fs: fix to avoid use-after-free for cached IPU bio
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit 5cdb422c839134273866208dad5360835ddb9794 ]
xfstest generic/019 reports a bug:
kernel BUG at mm/filemap.c:1619!
RIP: 0010:folio_end_writeback+0x8a/0x90 Call Trace: end_page_writeback+0x1c/0x60 f2fs_write_end_io+0x199/0x420 bio_endio+0x104/0x180 submit_bio_noacct+0xa5/0x510 submit_bio+0x48/0x80 f2fs_submit_write_bio+0x35/0x300 f2fs_submit_merged_ipu_write+0x2a0/0x2b0 f2fs_write_single_data_page+0x838/0x8b0 f2fs_write_cache_pages+0x379/0xa30 f2fs_write_data_pages+0x30c/0x340 do_writepages+0xd8/0x1b0 __writeback_single_inode+0x44/0x370 writeback_sb_inodes+0x233/0x4d0 __writeback_inodes_wb+0x56/0xf0 wb_writeback+0x1dd/0x2d0 wb_workfn+0x367/0x4a0 process_one_work+0x21d/0x430 worker_thread+0x4e/0x3c0 kthread+0x103/0x130 ret_from_fork+0x2c/0x50
The root cause is: after cp_error is set, f2fs_submit_merged_ipu_write() in f2fs_write_single_data_page() tries to flush IPU bio in cache, however f2fs_submit_merged_ipu_write() missed to check validity of @bio parameter, result in submitting random cached bio which belong to other IO context, then it will cause use-after-free issue, fix it by adding additional validity check.
--- fs/f2fs/data.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/f2fs/data.c +4 -1
@@ -849,6 +849,8 @@ void f2fs_submit_merged_ipu_write(struct f2fs_sb_info *sbi,bool found = false;struct bio *target = bio ? *bio :NULL ; +f2fs_bug_on (sbi, !target && !page); +for (temp =HOT ; temp <NR_TEMP_TYPE && !found; temp++) {struct f2fs_bio_info *io = sbi->write_io[DATA ] + temp;struct list_head *head = &io->bio_list;
@@ -2917,7 +2919,8 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,if (unlikely (f2fs_cp_error (sbi))) {f2fs_submit_merged_write (sbi,DATA ); -f2fs_submit_merged_ipu_write (sbi, bio,NULL ); +if (bio && *bio) +f2fs_submit_merged_ipu_write (sbi, bio,NULL ); submitted =NULL ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 166/381 scsi: lpfc: Fix ioremap issues in lpfc_sli4_pci_mem_setup()
In reply to Greg Kroah-HartmanFrom: Shuchang Li <[email protected]>
[ Upstream commit 91a0c0c1413239d0548b5aac4c82f38f6d53a91e ]
When if_type equals zero and pci_resource_start(pdev, PCI_64BIT_BAR4) returns false, drbl_regs_memmap_p is not remapped. This passes a NULL pointer to iounmap(), which can trigger a WARN() on certain arches.
When if_type equals six and pci_resource_start(pdev, PCI_64BIT_BAR4) returns true, drbl_regs_memmap_p may has been remapped and ctrl_regs_memmap_p is not remapped. This is a resource leak and passes a NULL pointer to iounmap().
To fix these issues, we need to add null checks before iounmap(), and change some goto labels.
--- drivers/scsi/lpfc/lpfc_init.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/lpfc/lpfc_init.c +6 -4
@@ -10477,7 +10477,7 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba) goto out_iounmap_all; }else { error = -ENOMEM ; - goto out_iounmap_all; + goto out_iounmap_ctrl; } }
@@ -10495,7 +10495,7 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)dev_err (&pdev->dev,"ioremap failed for SLI4 HBA dpp registers.\n" ); error = -ENOMEM ; - goto out_iounmap_ctrl; + goto out_iounmap_all; } phba->pci_bar4_memmap_p = phba->sli4_hba.dpp_regs_memmap_p; }
@@ -10520,9 +10520,11 @@ lpfc_sli4_pci_mem_setup(struct lpfc_hba *phba)return 0 ; out_iounmap_all: -iounmap (phba->sli4_hba.drbl_regs_memmap_p); +if (phba->sli4_hba.drbl_regs_memmap_p) +iounmap (phba->sli4_hba.drbl_regs_memmap_p); out_iounmap_ctrl: -iounmap (phba->sli4_hba.ctrl_regs_memmap_p); +if (phba->sli4_hba.ctrl_regs_memmap_p) +iounmap (phba->sli4_hba.ctrl_regs_memmap_p); out_iounmap_conf:iounmap (phba->sli4_hba.conf_regs_memmap_p);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 167/381 net: ethernet: stmmac: dwmac-rk: fix optional phy regulator handling
In reply to Greg Kroah-HartmanFrom: Sebastian Reichel <[email protected]>
[ Upstream commit db21973263f8c56750cb610f1d5e8bee00a513b9 ]
The usual devm_regulator_get() call already handles "optional" regulators by returning a valid dummy and printing a warning that the dummy regulator should be described properly. This code open coded the same behaviour, but masked any errors that are not -EPROBE_DEFER and is quite noisy.
This change effectively unmasks and propagates regulators errors not involving -ENODEV, downgrades the error print to warning level if no regulator is specified and captures the probe defer message for /sys/kernel/debug/devices_deferred.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c +4 -10
@@ -1194,9 +1194,6 @@ static int phy_power_on(struct rk_priv_data *bsp_priv, bool enable)int ret;struct device *dev = &bsp_priv->pdev->dev; -if (!ldo) -return 0 ; -if (enable) { ret =regulator_enable (ldo);if (ret)
@@ -1227,14 +1224,11 @@ static struct rk_priv_data *rk_gmac_setup(struct platform_device *pdev,of_get_phy_mode (dev->of_node, &bsp_priv->phy_iface); bsp_priv->ops = ops; - bsp_priv->regulator =devm_regulator_get_optional (dev,"phy" ); + bsp_priv->regulator =devm_regulator_get (dev,"phy" );if (IS_ERR (bsp_priv->regulator)) { -if (PTR_ERR (bsp_priv->regulator) == -EPROBE_DEFER ) { -dev_err (dev,"phy regulator is not available yet, deferred probing\n" ); -return ERR_PTR (-EPROBE_DEFER ); - } -dev_err (dev,"no regulator found\n" ); - bsp_priv->regulator =NULL ; + ret =PTR_ERR (bsp_priv->regulator); +dev_err_probe (dev, ret,"failed to get phy regulator\n" ); +return ERR_PTR (ret); } ret =of_property_read_string (dev->of_node,"clock_in_out" , &strings);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 168/381 bpf, sockmap: fix deadlocks in the sockhash and sockmap
In reply to Greg Kroah-HartmanFrom: Xin Liu <[email protected]>
[ Upstream commit ed17aa92dc56b6d8883e4b7a8f1c6fbf5ed6cd29 ]
When huang uses sched_switch tracepoint, the tracepoint does only one thing in the mounted ebpf program, which deletes the fixed elements in sockhash ([0])
It seems that elements in sockhash are rarely actively deleted by users or ebpf program. Therefore, we do not pay much attention to their deletion. Compared with hash maps, sockhash only provides spin_lock_bh protection. This causes it to appear to have self-locking behavior in the interrupt context.
[0]:https://lore.kernel.org/all/CABcoxUayum5oOqFMMqAeWuS8+EzojquSOSyDA3J_2omY=2EeAg@mail.gmail.com/
--- net/core/sock_map.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/core/sock_map.c +6 -4
@@ -423,8 +423,9 @@ static int __sock_map_delete(struct bpf_stab *stab, struct sock *sk_test, {struct sock *sk;int err =0 ; +unsigned long flags; -raw_spin_lock_bh (&stab->lock); +raw_spin_lock_irqsave (&stab->lock, flags); sk = *psk;if (!sk_test || sk_test == sk) sk =xchg (psk,NULL );
@@ -434,7 +435,7 @@ static int __sock_map_delete(struct bpf_stab *stab, struct sock *sk_test,else err = -EINVAL ; -raw_spin_unlock_bh (&stab->lock); +raw_spin_unlock_irqrestore (&stab->lock, flags);return err; }
@@ -956,11 +957,12 @@ static int sock_hash_delete_elem(struct bpf_map *map, void *key)struct bpf_shtab_bucket *bucket;struct bpf_shtab_elem *elem;int ret = -ENOENT ; +unsigned long flags; hash =sock_hash_bucket_hash (key, key_size); bucket =sock_hash_select_bucket (htab, hash); -raw_spin_lock_bh (&bucket->lock); +raw_spin_lock_irqsave (&bucket->lock, flags); elem =sock_hash_lookup_elem_raw (&bucket->head, hash, key, key_size);if (elem) {hlist_del_rcu (&elem->node);
@@ -968,7 +970,7 @@ static int sock_hash_delete_elem(struct bpf_map *map, void *key)sock_hash_free_elem (htab, elem); ret =0 ; } -raw_spin_unlock_bh (&bucket->lock); +raw_spin_unlock_irqrestore (&bucket->lock, flags);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 169/381 nvme: handle the persistent internal error AER
In reply to Greg Kroah-HartmanFrom: Michael Kelley <[email protected]>
[ Upstream commit 2c61c97fb12b806e1c8eb15f04c277ad097ec95e ]
In the NVM Express Revision 1.4 spec, Figure 145 describes possible values for an AER with event type "Error" (value 000b). For a Persistent Internal Error (value 03h), the host should perform a controller reset.
Add support for this error using code that already exists for doing a controller reset. As part of this support, introduce two utility functions for parsing the AER type and subtype.
This new support was tested in a lab environment where we can generate the persistent internal error on demand, and observe both the Linux side and NVMe controller side to see that the controller reset has been done.
Stable-dep-of: 6622b76fe922 ("nvme: fix async event trace event")
--- drivers/nvme/host/core.c | 31 +++++++++++++++++++++++++++++-- include/linux/nvme.h | 4 ++++ 2 files changed, 33 insertions(+), 2 deletions(-)
drivers/nvme/host/core.c +29 -2
@@ -4416,9 +4416,19 @@ static void nvme_fw_act_work(struct work_struct *work)nvme_get_fw_slot_info (ctrl); } +static u32 nvme_aer_type (u32 result) +{ +return result &0x7 ; +} + +static u32 nvme_aer_subtype (u32 result) +{ +return (result &0xff00 ) >>8 ; +} +static void nvme_handle_aen_notice (struct nvme_ctrl *ctrl,u32 result) { -u32 aer_notice_type = (result &0xff00 ) >>8 ; +u32 aer_notice_type =nvme_aer_subtype (result);trace_nvme_async_event (ctrl, aer_notice_type);
@@ -4451,11 +4461,19 @@ static void nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result) } } +static void nvme_handle_aer_persistent_error (struct nvme_ctrl *ctrl) +{ +trace_nvme_async_event (ctrl,NVME_AER_ERROR ); +dev_warn (ctrl->device,"resetting controller due to AER\n" ); +nvme_reset_ctrl (ctrl); +} +void nvme_complete_async_event (struct nvme_ctrl *ctrl,__le16 status,volatile union nvme_result *res) {u32 result =le32_to_cpu (res->u32); -u32 aer_type = result &0x07 ; +u32 aer_type =nvme_aer_type (result); +u32 aer_subtype =nvme_aer_subtype (result);if (le16_to_cpu (status) >>1 !=NVME_SC_SUCCESS )return ;
@@ -4465,6 +4483,15 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,nvme_handle_aen_notice (ctrl, result);break ;case NVME_AER_ERROR : +/* +* For a persistent internal error, don't run async_event_work +* to submit a new AER. The controller reset will do it. +*/ +if (aer_subtype ==NVME_AER_ERROR_PERSIST_INT_ERR ) { +nvme_handle_aer_persistent_error (ctrl); +return ; + } + fallthrough;case NVME_AER_SMART :case NVME_AER_CSS :case NVME_AER_VS :
include/linux/nvme.h +4 -0
@@ -602,6 +602,10 @@ enum { NVME_AER_VS = 7, }; +enum { +NVME_AER_ERROR_PERSIST_INT_ERR =0x03 , +}; +enum {NVME_AER_NOTICE_NS_CHANGED =0x00 ,NVME_AER_NOTICE_FW_ACT_STARTING =0x01 ,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 170/381 nvme: fix async event trace event
In reply to Greg Kroah-HartmanFrom: Keith Busch <[email protected]>
[ Upstream commit 6622b76fe922b94189499a90ccdb714a4a8d0773 ]
Mixing AER Event Type and Event Info has masking clashes. Just print the event type, but also include the event info of the AER result in the trace.
--- drivers/nvme/host/core.c | 5 +---- drivers/nvme/host/trace.h | 15 ++++++--------- 2 files changed, 7 insertions(+), 13 deletions(-)
drivers/nvme/host/core.c +1 -4
@@ -4430,8 +4430,6 @@ static void nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result) {u32 aer_notice_type =nvme_aer_subtype (result); -trace_nvme_async_event (ctrl, aer_notice_type); -switch (aer_notice_type) {case NVME_AER_NOTICE_NS_CHANGED :set_bit (NVME_AER_NOTICE_NS_CHANGED , &ctrl->events);
@@ -4463,7 +4461,6 @@ static void nvme_handle_aen_notice(struct nvme_ctrl *ctrl, u32 result)static void nvme_handle_aer_persistent_error (struct nvme_ctrl *ctrl) { -trace_nvme_async_event (ctrl,NVME_AER_ERROR );dev_warn (ctrl->device,"resetting controller due to AER\n" );nvme_reset_ctrl (ctrl); }
@@ -4478,6 +4475,7 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,if (le16_to_cpu (status) >>1 !=NVME_SC_SUCCESS )return ; +trace_nvme_async_event (ctrl, result);switch (aer_type) {case NVME_AER_NOTICE :nvme_handle_aen_notice (ctrl, result);
@@ -4495,7 +4493,6 @@ void nvme_complete_async_event(struct nvme_ctrl *ctrl, __le16 status,case NVME_AER_SMART :case NVME_AER_CSS :case NVME_AER_VS : -trace_nvme_async_event (ctrl, aer_type); ctrl->aen_result = result;break ;default :
drivers/nvme/host/trace.h +6 -9
@@ -127,15 +127,12 @@ TRACE_EVENT(nvme_async_event, ),TP_printk ("nvme%d: NVME_AEN=%#08x [%s]" , __entry->ctrl_id, __entry->result, -__print_symbolic (__entry->result, -aer_name (NVME_AER_NOTICE_NS_CHANGED ), -aer_name (NVME_AER_NOTICE_ANA ), -aer_name (NVME_AER_NOTICE_FW_ACT_STARTING ), -aer_name (NVME_AER_NOTICE_DISC_CHANGED ), -aer_name (NVME_AER_ERROR ), -aer_name (NVME_AER_SMART ), -aer_name (NVME_AER_CSS ), -aer_name (NVME_AER_VS )) +__print_symbolic (__entry->result &0x7 , +aer_name (NVME_AER_ERROR ), +aer_name (NVME_AER_SMART ), +aer_name (NVME_AER_NOTICE ), +aer_name (NVME_AER_CSS ), +aer_name (NVME_AER_VS )) ) );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 171/381 nvme-fcloop: fix "inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage"
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit 4f86a6ff6fbd891232dda3ca97fd1b9630b59809 ]
fcloop_fcp_op() could be called from flush request's ->end_io(flush_end_io) in which the spinlock of fq->mq_flush_lock is grabbed with irq saved/disabled.
So fcloop_fcp_op() can't call spin_unlock_irq(&tfcp_req->reqlock) simply which enables irq unconditionally.
Fixes the warning by switching to spin_lock_irqsave()/spin_unlock_irqrestore()
--- drivers/nvme/target/fcloop.c | 48 ++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 21 deletions(-)
drivers/nvme/target/fcloop.c +27 -21
@@ -570,10 +570,11 @@ fcloop_fcp_recv_work(struct work_struct *work)struct fcloop_fcpreq *tfcp_req = container_of(work, struct fcloop_fcpreq, fcp_rcv_work);struct nvmefc_fcp_req *fcpreq = tfcp_req->fcpreq; +unsigned long flags;int ret =0 ;bool aborted = false; -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags);switch (tfcp_req->inistate) {case INI_IO_START : tfcp_req->inistate =INI_IO_ACTIVE ;
@@ -582,11 +583,11 @@ fcloop_fcp_recv_work(struct work_struct *work) aborted = true;break ;default : -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);WARN_ON (1 );return ; } -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);if (unlikely (aborted)) ret = -ECANCELED ;
@@ -607,8 +608,9 @@ fcloop_fcp_abort_recv_work(struct work_struct *work) container_of(work, struct fcloop_fcpreq, abort_rcv_work);struct nvmefc_fcp_req *fcpreq;bool completed = false; +unsigned long flags; -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags); fcpreq = tfcp_req->fcpreq;switch (tfcp_req->inistate) {case INI_IO_ABORTED :
@@ -617,11 +619,11 @@ fcloop_fcp_abort_recv_work(struct work_struct *work) completed = true;break ;default : -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);WARN_ON (1 );return ; } -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);if (unlikely (completed)) {/* remove reference taken in original abort downcall */
@@ -633,9 +635,9 @@ fcloop_fcp_abort_recv_work(struct work_struct *work)nvmet_fc_rcv_fcp_abort (tfcp_req->tport->targetport, &tfcp_req->tgt_fcp_req); -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags); tfcp_req->fcpreq =NULL ; -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);fcloop_call_host_done (fcpreq, tfcp_req, -ECANCELED );/* call_host_done releases reference for abort downcall */
@@ -651,11 +653,12 @@ fcloop_tgt_fcprqst_done_work(struct work_struct *work)struct fcloop_fcpreq *tfcp_req = container_of(work, struct fcloop_fcpreq, tio_done_work);struct nvmefc_fcp_req *fcpreq; +unsigned long flags; -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags); fcpreq = tfcp_req->fcpreq; tfcp_req->inistate =INI_IO_COMPLETED ; -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);fcloop_call_host_done (fcpreq, tfcp_req, tfcp_req->status); }
@@ -759,13 +762,14 @@ fcloop_fcp_op(struct nvmet_fc_target_port *tgtport,u32 rsplen =0 , xfrlen =0 ;int fcp_err =0 , active, aborted;u8 op = tgt_fcpreq->op; +unsigned long flags; -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags); fcpreq = tfcp_req->fcpreq; active = tfcp_req->active; aborted = tfcp_req->aborted; tfcp_req->active = true; -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);if (unlikely (active))/* illegal - call while i/o active */
@@ -773,9 +777,9 @@ fcloop_fcp_op(struct nvmet_fc_target_port *tgtport,if (unlikely (aborted)) {/* target transport has aborted i/o prior */ -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags); tfcp_req->active = false; -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags); tgt_fcpreq->transferred_length =0 ; tgt_fcpreq->fcp_error = -ECANCELED ; tgt_fcpreq->done (tgt_fcpreq);
@@ -832,9 +836,9 @@ fcloop_fcp_op(struct nvmet_fc_target_port *tgtport,break ; } -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags); tfcp_req->active = false; -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags); tgt_fcpreq->transferred_length = xfrlen; tgt_fcpreq->fcp_error = fcp_err;
@@ -848,15 +852,16 @@ fcloop_tgt_fcp_abort(struct nvmet_fc_target_port *tgtport, struct nvmefc_tgt_fcp_req *tgt_fcpreq) {struct fcloop_fcpreq *tfcp_req =tgt_fcp_req_to_fcpreq (tgt_fcpreq); +unsigned long flags;/* * mark aborted only in case there were 2 threads in transport * (one doing io, other doing abort) and only kills ops posted * after the abort request */ -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags); tfcp_req->aborted = true; -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags); tfcp_req->status =NVME_SC_INTERNAL ;
@@ -898,6 +903,7 @@ fcloop_fcp_abort(struct nvme_fc_local_port *localport,struct fcloop_ini_fcpreq *inireq = fcpreq->private;struct fcloop_fcpreq *tfcp_req;bool abortio = true; +unsigned long flags;spin_lock (&inireq->inilock); tfcp_req = inireq->tfcp_req;
@@ -910,7 +916,7 @@ fcloop_fcp_abort(struct nvme_fc_local_port *localport,return ;/* break initiator/target relationship for io */ -spin_lock_irq (&tfcp_req->reqlock); +spin_lock_irqsave (&tfcp_req->reqlock, flags);switch (tfcp_req->inistate) {case INI_IO_START :case INI_IO_ACTIVE :
@@ -920,11 +926,11 @@ fcloop_fcp_abort(struct nvme_fc_local_port *localport, abortio = false;break ;default : -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);WARN_ON (1 );return ; } -spin_unlock_irq (&tfcp_req->reqlock); +spin_unlock_irqrestore (&tfcp_req->reqlock, flags);if (abortio)/* leave the reference while the work item is scheduled */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 172/381 bpf, sockmap: Revert buggy deadlock fix in the sockhash and sockmap
In reply to Greg Kroah-HartmanFrom: Daniel Borkmann <[email protected]>
[ Upstream commit 8c5c2a4898e3d6bad86e29d471e023c8a19ba799 ]
syzbot reported a splat and bisected it to recent commit ed17aa92dc56 ("bpf,
sockmap: fix deadlocks in the sockhash and sockmap"):
[...]
WARNING: CPU: 1 PID: 9280 at kernel/softirq.c:376 __local_bh_enable_ip+0xbe/0x130 kernel/softirq.c:376 Modules linked in: CPU: 1 PID: 9280 Comm: syz-executor.1 Not tainted 6.2.0-syzkaller-13249-gd319f344561d #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/30/2023 RIP: 0010:__local_bh_enable_ip+0xbe/0x130 kernel/softirq.c:376 [...] Call Trace: <TASK> spin_unlock_bh include/linux/spinlock.h:395 [inline] sock_map_del_link+0x2ea/0x510 net/core/sock_map.c:165 sock_map_unref+0xb0/0x1d0 net/core/sock_map.c:184 sock_hash_delete_elem+0x1ec/0x2a0 net/core/sock_map.c:945 map_delete_elem kernel/bpf/syscall.c:1536 [inline] __sys_bpf+0x2edc/0x53e0 kernel/bpf/syscall.c:5053 __do_sys_bpf kernel/bpf/syscall.c:5166 [inline] __se_sys_bpf kernel/bpf/syscall.c:5164 [inline] __x64_sys_bpf+0x79/0xc0 kernel/bpf/syscall.c:5164 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7fe8f7c8c169 </TASK> [...]
Revert for now until we have a proper solution.
--- net/core/sock_map.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
net/core/sock_map.c +4 -6
@@ -423,9 +423,8 @@ static int __sock_map_delete(struct bpf_stab *stab, struct sock *sk_test, {struct sock *sk;int err =0 ; -unsigned long flags; -raw_spin_lock_irqsave (&stab->lock, flags); +raw_spin_lock_bh (&stab->lock); sk = *psk;if (!sk_test || sk_test == sk) sk =xchg (psk,NULL );
@@ -435,7 +434,7 @@ static int __sock_map_delete(struct bpf_stab *stab, struct sock *sk_test,else err = -EINVAL ; -raw_spin_unlock_irqrestore (&stab->lock, flags); +raw_spin_unlock_bh (&stab->lock);return err; }
@@ -957,12 +956,11 @@ static int sock_hash_delete_elem(struct bpf_map *map, void *key)struct bpf_shtab_bucket *bucket;struct bpf_shtab_elem *elem;int ret = -ENOENT ; -unsigned long flags; hash =sock_hash_bucket_hash (key, key_size); bucket =sock_hash_select_bucket (htab, hash); -raw_spin_lock_irqsave (&bucket->lock, flags); +raw_spin_lock_bh (&bucket->lock); elem =sock_hash_lookup_elem_raw (&bucket->head, hash, key, key_size);if (elem) {hlist_del_rcu (&elem->node);
@@ -970,7 +968,7 @@ static int sock_hash_delete_elem(struct bpf_map *map, void *key)sock_hash_free_elem (htab, elem); ret =0 ; } -raw_spin_unlock_irqrestore (&bucket->lock, flags); +raw_spin_unlock_bh (&bucket->lock);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 173/381 md/raid10: fix leak of r10bio->remaining for recovery
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit 26208a7cffd0c7cbf14237ccd20c7270b3ffeb7e ]
raid10_sync_request() will add 'r10bio->remaining' for both rdev and replacement rdev. However, if the read io fails, recovery_request_write() returns without issuing the write io, in this case, end_sync_request() is only called once and 'remaining' is leaked, cause an io hang.
Fix the problem by decreasing 'remaining' according to if 'bio' and 'repl_bio' is valid.
--- drivers/md/raid10.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/md/raid10.c +13 -10
@@ -2212,11 +2212,22 @@ static void recovery_request_write(struct mddev *mddev, struct r10bio *r10_bio) {struct r10conf *conf = mddev->private;int d; -struct bio *wbio, *wbio2; +struct bio *wbio = r10_bio->devs[1 ].bio; +struct bio *wbio2 = r10_bio->devs[1 ].repl_bio; + +/* Need to test wbio2->bi_end_io before we call +* submit_bio_noacct as if the former is NULL, +* the latter is free to free wbio2. +*/ +if (wbio2 && !wbio2->bi_end_io) + wbio2 =NULL ;if (!test_bit (R10BIO_Uptodate, &r10_bio->state)) {fix_recovery_read_error (r10_bio); -end_sync_request (r10_bio); +if (wbio->bi_end_io) +end_sync_request (r10_bio); +if (wbio2) +end_sync_request (r10_bio);return ; }
@@ -2225,14 +2236,6 @@ static void recovery_request_write(struct mddev *mddev, struct r10bio *r10_bio)* and submit the write request */ d = r10_bio->devs[1 ].devnum; - wbio = r10_bio->devs[1 ].bio; - wbio2 = r10_bio->devs[1 ].repl_bio; -/* Need to test wbio2->bi_end_io before we call -* submit_bio_noacct as if the former is NULL, -* the latter is free to free wbio2. -*/ -if (wbio2 && !wbio2->bi_end_io) - wbio2 =NULL ;if (wbio->bi_end_io) {atomic_inc (&conf->mirrors[d].rdev->nr_pending);md_sync_acct (conf->mirrors[d].rdev->bdev,bio_sectors (wbio));
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 174/381 md/raid10: fix memleak for conf->bio_split
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit c9ac2acde53f5385de185bccf6aaa91cf9ac1541 ]
In the error path of raid10_run(), 'conf' need be freed, however, 'conf->bio_split' is missed and memory will be leaked.
Since there are 3 places to free 'conf', factor out a helper to fix the problem.
--- drivers/md/raid10.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-)
drivers/md/raid10.c +17 -20
@@ -3618,6 +3618,20 @@ static int setup_geo(struct geom *geo, struct mddev *mddev, enum geo_type new)return nc*fc; } +static void raid10_free_conf (struct r10conf *conf) +{ +if (!conf) +return ; + +mempool_exit (&conf->r10bio_pool); +kfree (conf->mirrors); +kfree (conf->mirrors_old); +kfree (conf->mirrors_new); +safe_put_page (conf->tmppage); +bioset_exit (&conf->bio_split); +kfree (conf); +} +static struct r10conf *setup_conf (struct mddev *mddev) {struct r10conf *conf =NULL ;
@@ -3700,13 +3714,7 @@ static struct r10conf *setup_conf(struct mddev *mddev)return conf; out: -if (conf) { -mempool_exit (&conf->r10bio_pool); -kfree (conf->mirrors); -safe_put_page (conf->tmppage); -bioset_exit (&conf->bio_split); -kfree (conf); - } +raid10_free_conf (conf);return ERR_PTR (err); }
@@ -3912,10 +3920,7 @@ static int raid10_run(struct mddev *mddev) out_free_conf:md_unregister_thread (&mddev->thread); -mempool_exit (&conf->r10bio_pool); -safe_put_page (conf->tmppage); -kfree (conf->mirrors); -kfree (conf); +raid10_free_conf (conf); mddev->private =NULL ; out:return -EIO ;
@@ -3923,15 +3928,7 @@ static int raid10_run(struct mddev *mddev)static void raid10_free (struct mddev *mddev,void *priv) { -struct r10conf *conf = priv; - -mempool_exit (&conf->r10bio_pool); -safe_put_page (conf->tmppage); -kfree (conf->mirrors); -kfree (conf->mirrors_old); -kfree (conf->mirrors_new); -bioset_exit (&conf->bio_split); -kfree (conf); +raid10_free_conf (priv); }static void raid10_quiesce (struct mddev *mddev,int quiesce)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 175/381 md/raid10: fix memleak of md thread
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
[ Upstream commit f0ddb83da3cbbf8a1f9087a642c448ff52ee9abd ]
In raid10_run(), if setup_conf() succeed and raid10_run() failed before setting 'mddev->thread', then in the error path 'conf->thread' is not freed.
Fix the problem by setting 'mddev->thread' right after setup_conf().
--- drivers/md/raid10.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/md/raid10.c +3 -3
@@ -3752,6 +3752,9 @@ static int raid10_run(struct mddev *mddev)if (!conf) goto out; + mddev->thread = conf->thread; + conf->thread =NULL ; +if (mddev_is_clustered (conf->mddev)) {int fc, fo;
@@ -3764,9 +3767,6 @@ static int raid10_run(struct mddev *mddev) } } - mddev->thread = conf->thread; - conf->thread =NULL ; -if (mddev->queue) {blk_queue_max_discard_sectors (mddev->queue, mddev->chunk_sectors);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 176/381 wifi: iwlwifi: yoyo: Fix possible division by zero
In reply to Greg Kroah-HartmanFrom: Daniel Gabay <[email protected]>
[ Upstream commit ba30415118eee374a08b39a0460a1d1e52c24a25 ]
Don't allow buffer allocation TLV with zero req_size since it leads later to division by zero in iwl_dbg_tlv_alloc_fragments(). Also, NPK/SRAM locations are allowed to have zero buffer req_size, don't discard them.
--- drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c +6 -0
@@ -191,6 +191,12 @@ static int iwl_dbg_tlv_alloc_buf_alloc(struct iwl_trans *trans, alloc_id != IWL_FW_INI_ALLOCATION_ID_INTERNAL) goto err; +if (buf_location ==IWL_FW_INI_LOCATION_DRAM_PATH && + alloc->req_size ==0 ) { +IWL_ERR (trans,"WRT: Invalid DRAM buffer allocation requested size (0)\n" ); +return -EINVAL ; + } + trans->dbg.fw_mon_cfg[alloc_id] = *alloc;return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 177/381 wifi: iwlwifi: fw: move memset before early return
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
[ Upstream commit 8ce437dd5b2e4adef13aa4ecce07392f9966b1ab ]
Clang static analysis reports this representative issue dbg.c:1455:6: warning: Branch condition evaluates to a garbage value
if (!rxf_data.size)
^~~~~~~~~~~~~~
This check depends on iwl_ini_get_rxf_data() to clear rxf_data but the function can return early without doing the clear. So move the memset before the early return.
--- drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/intel/iwlwifi/fw/dbg.c +2 -2
@@ -1372,13 +1372,13 @@ static void iwl_ini_get_rxf_data(struct iwl_fw_runtime *fwrt,if (!data)return ; +memset (data,0 ,sizeof (*data)); +/* make sure only one bit is set in only one fid */ if (WARN_ONCE (hweight_long (fid1) +hweight_long (fid2) !=1 ,"fid1=%x, fid2=%x\n" , fid1, fid2))return ; -memset (data,0 ,sizeof (*data)); -if (fid1) { fifo_idx =ffs (fid1) -1 ; if (WARN_ONCE(fifo_idx >= MAX_NUM_LMAC, "fifo_idx=%d\n",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 178/381 jdb2: Dont refuse invalidation of already invalidated buffers
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
[ Upstream commit bd159398a2d2234de07d310132865706964aaaa7 ]
When invalidating buffers under the partial tail page, jbd2_journal_invalidate_folio() returns -EBUSY if the buffer is part of the committing transaction as we cannot safely modify buffer state. However if the buffer is already invalidated (due to previous invalidation attempts from ext4_wait_for_tail_page_commit()), there's nothing to do and there's no point in returning -EBUSY. This fixes occasional warnings from ext4_journalled_invalidate_folio() triggered by generic/051 fstest when blocksize < pagesize.
--- fs/jbd2/transaction.c | 3 +++ 1 file changed, 3 insertions(+)
fs/jbd2/transaction.c +3 -0
@@ -2378,6 +2378,9 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh,spin_unlock (&jh->b_state_lock);write_unlock (&journal->j_state_lock);jbd2_journal_put_journal_head (jh); +/* Already zapped buffer? Nothing to do... */ +if (!bh->b_bdev) +return 0 ;return -EBUSY ; }/*
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 179/381 wifi: iwlwifi: make the loop for card preparation effective
In reply to Greg Kroah-HartmanFrom: Emmanuel Grumbach <[email protected]>
[ Upstream commit 28965ec0b5d9112585f725660e2ff13218505ace ]
Since we didn't reset t to 0, only the first iteration of the loop did checked the ready bit several times.
Quoted 1 line
From the second iteration and on, we just tested the bit once and
continued to the next iteration.
--- drivers/net/wireless/intel/iwlwifi/pcie/trans.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/pcie/trans.c +2 -1
@@ -620,7 +620,6 @@ static int iwl_pcie_set_hw_ready(struct iwl_trans *trans)int iwl_pcie_prepare_card_hw (struct iwl_trans *trans) {int ret; -int t =0 ;int iter;IWL_DEBUG_INFO (trans,"iwl_trans_prepare_card_hw enter\n" );
@@ -635,6 +634,8 @@ int iwl_pcie_prepare_card_hw(struct iwl_trans *trans)usleep_range (1000 ,2000 );for (iter =0 ; iter <10 ; iter++) { +int t =0 ; +/* If HW is not ready, prepare the conditions to check again */ iwl_set_bit (trans,CSR_HW_IF_CONFIG_REG ,CSR_HW_IF_CONFIG_REG_PREPARE );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 180/381 wifi: iwlwifi: mvm: check firmware response size
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 13513cec93ac9902d0b896976d8bab3758a9881c ]
Check the firmware response size for responses to the memory read/write command in debugfs before using it.
--- drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +10 -0
@@ -1885,6 +1885,11 @@ static ssize_t iwl_dbgfs_mem_read(struct file *file, char __user *user_buf,if (ret <0 )return ret; +if (iwl_rx_packet_payload_len (hcmd.resp_pkt) <sizeof (*rsp)) { + ret = -EIO ; + goto out; + } + rsp = (void *)hcmd.resp_pkt->data;if (le32_to_cpu (rsp->status) !=DEBUG_MEM_STATUS_SUCCESS ) { ret = -ENXIO ;
@@ -1962,6 +1967,11 @@ static ssize_t iwl_dbgfs_mem_write(struct file *file,if (ret <0 )return ret; +if (iwl_rx_packet_payload_len (hcmd.resp_pkt) <sizeof (*rsp)) { + ret = -EIO ; + goto out; + } + rsp = (void *)hcmd.resp_pkt->data;if (rsp->status !=DEBUG_MEM_STATUS_SUCCESS ) { ret = -ENXIO ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 181/381 wifi: iwlwifi: fw: fix memory leak in debugfs
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
[ Upstream commit 3d90d2f4a018fe8cfd65068bc6350b6222be4852 ]
Fix a memory leak that occurs when reading the fw_info file all the way, since we return NULL indicating no more data, but don't free the status tracking object.
--- drivers/net/wireless/intel/iwlwifi/fw/debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/fw/debugfs.c +3 -1
@@ -344,8 +344,10 @@ static void *iwl_dbgfs_fw_info_seq_next(struct seq_file *seq,const struct iwl_fw *fw = priv->fwrt->fw; *pos = ++state->pos; -if (*pos >= fw->ucode_capa.n_cmd_versions) +if (*pos >= fw->ucode_capa.n_cmd_versions) { +kfree (state);return NULL ; + }return state; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 182/381 ixgbe: Allow flow hash to be set via ethtool
In reply to Greg Kroah-HartmanFrom: Joe Damato <[email protected]>
[ Upstream commit 4f3ed1293feb9502dc254b05802faf1ad3317ac6 ]
ixgbe currently returns EINVAL whenever the flowhash it set by ethtool because the ethtool code in the kernel passes a non-zero value for hfunc that ixgbe should allow.
When ethtool is called with ETHTOOL_SRXFHINDIR, ethtool_set_rxfh_indir will call ixgbe's set_rxfh function with ETH_RSS_HASH_NO_CHANGE. This value should be accepted.
When ethtool is called with ETHTOOL_SRSSH, ethtool_set_rxfh will call ixgbe's set_rxfh function with rxfh.hfunc, which appears to be hardcoded in ixgbe to always be ETH_RSS_HASH_TOP. This value should also be accepted.
Before this patch:
$ sudo ethtool -L eth1 combined 10 $ sudo ethtool -X eth1 default Cannot set RX flow hash configuration: Invalid argument
After this patch:
$ sudo ethtool -L eth1 combined 10
$ sudo ethtool -X eth1 default
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 10 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 0 1 2 3 4 5
16: 6 7 8 9 0 1 2 3
24: 4 5 6 7 8 9 0 1
...--- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +2 -2
@@ -3107,8 +3107,8 @@ static int ixgbe_set_rxfh(struct net_device *netdev, const u32 *indir,int i;u32 reta_entries =ixgbe_rss_indir_tbl_entries (adapter); -if (hfunc) -return -EINVAL ; +if (hfunc !=ETH_RSS_HASH_NO_CHANGE && hfunc !=ETH_RSS_HASH_TOP ) +return -EOPNOTSUPP ;/* Fill out the redirection table */ if (indir) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 183/381 ixgbe: Enable setting RSS table to default values
In reply to Greg Kroah-HartmanFrom: Joe Damato <[email protected]>
[ Upstream commit e85d3d55875f7a1079edfbc4e4e98d6f8aea9ac7 ]
ethtool uses ETHTOOL_GRXRINGS to compute how many queues are supported by RSS. The driver should return the smaller of either:
- The maximum number of RSS queues the device supports, OR
- The number of RX queues configured
Prior to this change, running ethtool -X $iface default fails if the number of queues configured is larger than the number supported by RSS, even though changing the queue count correctly resets the flowhash to use all supported queues.
Other drivers (for example, i40e) will succeed but the flow hash will reset to support the maximum number of queues supported by RSS, even if that amount is smaller than the configured amount.
Prior to this change:
$ sudo ethtool -L eth1 combined 20
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 20 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 10 11 12 13 14 15
16: 0 1 2 3 4 5 6 7
24: 8 9 10 11 12 13 14 15
32: 0 1 2 3 4 5 6 7
...You can see that the flowhash was correctly set to use the maximum number of queues supported by the driver (16).
However, asking the NIC to reset to "default" fails:
$ sudo ethtool -X eth1 default Cannot set RX flow hash configuration: Invalid argument
After this change, the flowhash can be reset to default which will use all of the available RSS queues (16) or the configured queue count, whichever is smaller.
Starting with eth1 which has 10 queues and a flowhash distributing to all 10 queues:
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 10 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 0 1 2 3 4 5
16: 6 7 8 9 0 1 2 3
...Increasing the queue count to 48 resets the flowhash to distribute to 16 queues, as it did before this patch:
$ sudo ethtool -L eth1 combined 48
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 16 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 10 11 12 13 14 15
16: 0 1 2 3 4 5 6 7
...Due to the other bugfix in this series, the flowhash can be set to use queues 0-5:
$ sudo ethtool -X eth1 equal 5
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 16 RX ring(s):
0: 0 1 2 3 4 0 1 2
8: 3 4 0 1 2 3 4 0
16: 1 2 3 4 0 1 2 3
...Due to this bugfix, the flowhash can be reset to default and use 16 queues:
$ sudo ethtool -X eth1 default
$ sudo ethtool -x eth1
RX flow hash indirection table for eth1 with 16 RX ring(s):
0: 0 1 2 3 4 5 6 7
8: 8 9 10 11 12 13 14 15
16: 0 1 2 3 4 5 6 7
...--- .../net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +10 -9
@@ -2641,6 +2641,14 @@ static int ixgbe_get_rss_hash_opts(struct ixgbe_adapter *adapter,return 0 ; } +static int ixgbe_rss_indir_tbl_max (struct ixgbe_adapter *adapter) +{ +if (adapter->hw.mac.type < ixgbe_mac_X550) +return 16 ; +else +return 64 ; +} +static int ixgbe_get_rxnfc (struct net_device *dev,struct ethtool_rxnfc *cmd,u32 *rule_locs) {
@@ -2649,7 +2657,8 @@ static int ixgbe_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,switch (cmd->cmd) {case ETHTOOL_GRXRINGS : - cmd->data = adapter->num_rx_queues; + cmd->data =min_t (int, adapter->num_rx_queues, +ixgbe_rss_indir_tbl_max (adapter)); ret =0 ;break ;case ETHTOOL_GRXCLSRLCNT :
@@ -3051,14 +3060,6 @@ static int ixgbe_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)return ret; } -static int ixgbe_rss_indir_tbl_max (struct ixgbe_adapter *adapter) -{ -if (adapter->hw.mac.type < ixgbe_mac_X550) -return 16 ; -else -return 64 ; -} -static u32 ixgbe_get_rxfh_key_size (struct net_device *netdev) {return IXGBE_RSS_KEY_SIZE ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 184/381 bpf: Dont EFAULT for getsockopt with optval=NULL
In reply to Greg Kroah-HartmanFrom: Stanislav Fomichev <[email protected]>
[ Upstream commit 00e74ae0863827d944e36e56a4ce1e77e50edb91 ]
Some socket options do getsockopt with optval=NULL to estimate the size of the final buffer (which is returned via optlen). This breaks BPF getsockopt assumptions about permitted optval buffer size. Let's enforce these assumptions only when non-NULL optval is provided.
--- kernel/bpf/cgroup.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
kernel/bpf/cgroup.c +6 -3
@@ -1516,7 +1516,7 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, goto out; } -if (ctx.optlen > max_optlen || ctx.optlen <0 ) { +if (optval && (ctx.optlen > max_optlen || ctx.optlen <0 )) { ret = -EFAULT ; goto out; }
@@ -1530,8 +1530,11 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, }if (ctx.optlen !=0 ) { -if (copy_to_user (optval, ctx.optval, ctx.optlen) || -put_user (ctx.optlen, optlen)) { +if (optval &©_to_user (optval, ctx.optval, ctx.optlen)) { + ret = -EFAULT ; + goto out; + } +if (put_user (ctx.optlen, optlen)) { ret = -EFAULT ; goto out; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 185/381 netfilter: nf_tables: dont write table validation state without mutex
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit 9a32e9850686599ed194ccdceb6cd3dd56b2d9b9 ]
The ->cleanup callback needs to be removed, this doesn't work anymore as the transaction mutex is already released in the ->abort function.
Just do it after a successful validation pass, this either happens from commit or abort phases where transaction mutex is held.
--- include/linux/netfilter/nfnetlink.h | 1 - net/netfilter/nf_tables_api.c | 8 ++------ net/netfilter/nfnetlink.c | 2 -- 3 files changed, 2 insertions(+), 9 deletions(-)
include/linux/netfilter/nfnetlink.h +0 -1
@@ -39,7 +39,6 @@ struct nfnetlink_subsystem {int (*commit)(struct net *net,struct sk_buff *skb);int (*abort)(struct net *net,struct sk_buff *skb,enum nfnl_abort_action action); -void (*cleanup)(struct net *net);bool (*valid_genid)(struct net *net,u32 genid); };
net/netfilter/nf_tables_api.c +2 -6
@@ -7442,6 +7442,8 @@ static int nf_tables_validate(struct net *net)if (nft_table_validate (net, table) <0 )return -EAGAIN ; } + +nft_validate_state_update (net,NFT_VALIDATE_SKIP );break ; }
@@ -8273,11 +8275,6 @@ static int __nf_tables_abort(struct net *net, enum nfnl_abort_action action)return 0 ; } -static void nf_tables_cleanup (struct net *net) -{ -nft_validate_state_update (net,NFT_VALIDATE_SKIP ); -} -static int nf_tables_abort (struct net *net,struct sk_buff *skb,enum nfnl_abort_action action) {
@@ -8309,7 +8306,6 @@ static const struct nfnetlink_subsystem nf_tables_subsys = { .cb = nf_tables_cb, .commit = nf_tables_commit, .abort = nf_tables_abort, - .cleanup = nf_tables_cleanup, .valid_genid = nf_tables_valid_genid, .owner = THIS_MODULE, };
net/netfilter/nfnetlink.c +0 -2
@@ -530,8 +530,6 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh, goto replay_abort; } } -if (ss->cleanup) - ss->cleanup (net);nfnl_err_deliver (&err_list, oskb);kfree_skb (skb);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 186/381 net/sched: sch_fq: fix integer overflow of "credit"
In reply to Greg Kroah-HartmanFrom: Davide Caratti <[email protected]>
[ Upstream commit 7041101ff6c3073fd8f2e99920f535b111c929cb ]
if sch_fq is configured with "initial quantum" having values greater than INT_MAX, the first assignment of "credit" does signed integer overflow to a very negative value.
In this situation, the syzkaller script provided by Cristoph triggers the CPU soft-lockup warning even with few sockets. It's not an infinite loop, but "credit" wasn't probably meant to be minus 2Gb for each new flow. Capping "initial quantum" to INT_MAX proved to fix the issue.
v2: validation of "initial quantum" is done in fq_policy, instead of open
coding in fq_change() _ suggested by Jakub Kicinski
--- net/sched/sch_fq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/sched/sch_fq.c +5 -1
@@ -779,13 +779,17 @@ static int fq_resize(struct Qdisc *sch, u32 log)return 0 ; } +static struct netlink_range_validation iq_range = { + .max =INT_MAX , +}; +static const struct nla_policy fq_policy[TCA_FQ_MAX +1 ] = { [TCA_FQ_UNSPEC ] = { .strict_start_type =TCA_FQ_TIMER_SLACK }, [TCA_FQ_PLIMIT ] = { .type =NLA_U32 }, [TCA_FQ_FLOW_PLIMIT ] = { .type =NLA_U32 }, [TCA_FQ_QUANTUM ] = { .type =NLA_U32 }, - [TCA_FQ_INITIAL_QUANTUM ] = { .type =NLA_U32 }, + [TCA_FQ_INITIAL_QUANTUM ] =NLA_POLICY_FULL_RANGE (NLA_U32 , &iq_range), [TCA_FQ_RATE_ENABLE ] = { .type =NLA_U32 }, [TCA_FQ_FLOW_DEFAULT_RATE ] = { .type =NLA_U32 }, [TCA_FQ_FLOW_MAX_RATE ] = { .type =NLA_U32 },
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 187/381 ipv4: Fix potential uninit variable access bug in __ip_make_skb()
In reply to Greg Kroah-HartmanFrom: Ziyang Xuan <[email protected]>
[ Upstream commit 99e5acae193e369b71217efe6f1dad42f3f18815 ]
Like commit ea30388baebc ("ipv6: Fix an uninit variable access bug in __ip6_make_skb()"). icmphdr does not in skb linear region under the scenario of SOCK_RAW socket. Access icmp_hdr(skb)->type directly will trigger the uninit variable access bug.
Use a local variable icmp_type to carry the correct value in different scenarios.
--- net/ipv4/ip_output.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
net/ipv4/ip_output.c +13 -3
@@ -1564,9 +1564,19 @@ struct sk_buff *__ip_make_skb(struct sock *sk, cork->dst =NULL ;skb_dst_set (skb, &rt->dst); -if (iph->protocol ==IPPROTO_ICMP ) -icmp_out_count (net, ((struct icmphdr *) -skb_transport_header (skb))->type); +if (iph->protocol ==IPPROTO_ICMP ) { +u8 icmp_type; + +/* For such sockets, transhdrlen is zero when do ip_append_data(), +* so icmphdr does not in skb linear region and can not get icmp_type +* by icmp_hdr(skb)->type. +*/ +if (sk->sk_type ==SOCK_RAW && !inet_sk (sk)->hdrincl) + icmp_type = fl4->fl4_icmp_type; +else + icmp_type =icmp_hdr (skb)->type; +icmp_out_count (net, icmp_type); + }ip_cork_release (cork); out:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 188/381 Revert "Bluetooth: btsdio: fix use after free bug in btsdio_remove due to unfinished work"
In reply to Greg Kroah-HartmanFrom: Liu Jian <[email protected]>
[ Upstream commit db2bf510bd5d57f064d9e1db395ed86a08320c54 ]
This reverts commit 1e9ac114c4428fdb7ff4635b45d4f46017e8916f.
This patch introduces a possible null-ptr-def problem. Revert it. And the fixed bug by this patch have resolved by commit 73f7b171b7c0 ("Bluetooth:
btsdio: fix use after free bug in btsdio_remove due to race condition").
--- drivers/bluetooth/btsdio.c | 1 - 1 file changed, 1 deletion(-)
drivers/bluetooth/btsdio.c +0 -1
@@ -352,7 +352,6 @@ static void btsdio_remove(struct sdio_func *func)BT_DBG ("func %p" , func); -cancel_work_sync (&data->work);if (!data)return ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 189/381 netlink: Use copy_to_user() for optval in netlink_getsockopt().
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit d913d32cc2707e9cd24fe6fa6d7d470e9c728980 ]
Brad Spencer provided a detailed report [0] that when calling getsockopt() for AF_NETLINK, some SOL_NETLINK options set only 1 byte even though such options require at least sizeof(int) as length.
The options return a flag value that fits into 1 byte, but such behaviour confuses users who do not initialise the variable before calling getsockopt() and do not strictly check the returned value as char.
Currently, netlink_getsockopt() uses put_user() to copy data to optlen and optval, but put_user() casts the data based on the pointer, char *optval. As a result, only 1 byte is set to optval.
To avoid this behaviour, we need to use copy_to_user() or cast optval for put_user().
Note that this changes the behaviour on big-endian systems, but we document that the size of optval is int in the man page.
$ man 7 netlink
...
Socket options
To set or get a netlink socket option, call getsockopt(2) to read
or setsockopt(2) to write the option with the option level argument
set to SOL_NETLINK. Unless otherwise noted, optval is a pointer to
an int.--- net/netlink/af_netlink.c | 75 ++++++++++++---------------------------- 1 file changed, 23 insertions(+), 52 deletions(-)
net/netlink/af_netlink.c +23 -52
@@ -1744,7 +1744,8 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname, {struct sock *sk = sock->sk;struct netlink_sock *nlk =nlk_sk (sk); -int len, val, err; +unsigned int flag; +int len, val;if (level !=SOL_NETLINK )return -ENOPROTOOPT ;
@@ -1756,39 +1757,17 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname,switch (optname) {case NETLINK_PKTINFO : -if (len <sizeof (int )) -return -EINVAL ; - len =sizeof (int ); - val = nlk->flags &NETLINK_F_RECV_PKTINFO ?1 :0 ; -if (put_user (len, optlen) || -put_user (val, optval)) -return -EFAULT ; - err =0 ; + flag =NETLINK_F_RECV_PKTINFO ;break ;case NETLINK_BROADCAST_ERROR : -if (len <sizeof (int )) -return -EINVAL ; - len =sizeof (int ); - val = nlk->flags &NETLINK_F_BROADCAST_SEND_ERROR ?1 :0 ; -if (put_user (len, optlen) || -put_user (val, optval)) -return -EFAULT ; - err =0 ; + flag =NETLINK_F_BROADCAST_SEND_ERROR ;break ;case NETLINK_NO_ENOBUFS : -if (len <sizeof (int )) -return -EINVAL ; - len =sizeof (int ); - val = nlk->flags &NETLINK_F_RECV_NO_ENOBUFS ?1 :0 ; -if (put_user (len, optlen) || -put_user (val, optval)) -return -EFAULT ; - err =0 ; + flag =NETLINK_F_RECV_NO_ENOBUFS ;break ;case NETLINK_LIST_MEMBERSHIPS : { -int pos, idx, shift; +int pos, idx, shift, err =0 ; - err =0 ;netlink_lock_table ();for (pos =0 ; pos *8 < nlk->ngroups; pos +=sizeof (u32)) {if (len - pos <sizeof (u32))
@@ -1805,40 +1784,32 @@ static int netlink_getsockopt(struct socket *sock, int level, int optname,if (put_user (ALIGN (nlk->ngroups /8 ,sizeof (u32)), optlen)) err = -EFAULT ;netlink_unlock_table (); -break ; +return err; }case NETLINK_CAP_ACK : -if (len <sizeof (int )) -return -EINVAL ; - len =sizeof (int ); - val = nlk->flags &NETLINK_F_CAP_ACK ?1 :0 ; -if (put_user (len, optlen) || -put_user (val, optval)) -return -EFAULT ; - err =0 ; + flag =NETLINK_F_CAP_ACK ;break ;case NETLINK_EXT_ACK : -if (len <sizeof (int )) -return -EINVAL ; - len =sizeof (int ); - val = nlk->flags &NETLINK_F_EXT_ACK ?1 :0 ; -if (put_user (len, optlen) ||put_user (val, optval)) -return -EFAULT ; - err =0 ; + flag =NETLINK_F_EXT_ACK ;break ;case NETLINK_GET_STRICT_CHK : -if (len <sizeof (int )) -return -EINVAL ; - len =sizeof (int ); - val = nlk->flags &NETLINK_F_STRICT_CHK ?1 :0 ; -if (put_user (len, optlen) ||put_user (val, optval)) -return -EFAULT ; - err =0 ; + flag =NETLINK_F_STRICT_CHK ;break ;default : - err = -ENOPROTOOPT ; +return -ENOPROTOOPT ; } -return err; + +if (len <sizeof (int )) +return -EINVAL ; + + len =sizeof (int ); + val = nlk->flags & flag ?1 :0 ; + +if (put_user (len, optlen) || +copy_to_user (optval, &val, len)) +return -EFAULT ; + +return 0 ; }static void netlink_cmsg_recv_pktinfo (struct msghdr *msg,struct sk_buff *skb)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 190/381 net: amd: Fix link leak when verifying config failed
In reply to Greg Kroah-HartmanFrom: Gencen Gan <[email protected]>
[ Upstream commit d325c34d9e7e38d371c0a299d415e9b07f66a1fb ]
After failing to verify configuration, it returns directly without releasing link, which may cause memory leak.
Paolo Abeni thinks that the whole code of this driver is quite "suboptimal" and looks unmainatained since at least ~15y, so he suggests that we could simply remove the whole driver, please take it into consideration.
Simon Horman suggests that the fix label should be set to "Linux-2.6.12-rc2" considering that the problem has existed since the driver was introduced and the commit above doesn't seem to exist in net/net-next.
--- drivers/net/ethernet/amd/nmclan_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/amd/nmclan_cs.c +1 -1
@@ -650,7 +650,7 @@ static int nmclan_config(struct pcmcia_device *link) }else {pr_notice ("mace id not found: %x %x should be 0x40 0x?9\n" , sig[0 ], sig[1 ]); -return -ENODEV ; + goto failed; } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 191/381 tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.
In reply to Greg Kroah-HartmanFrom: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 50749f2dd6854a41830996ad302aef2ffaf011d8 ]
syzkaller reported [0] memory leaks of an UDP socket and ZEROCOPY skbs. We can reproduce the problem with these sequences:
sk = socket(AF_INET, SOCK_DGRAM, 0) sk.setsockopt(SOL_SOCKET, SO_TIMESTAMPING, SOF_TIMESTAMPING_TX_SOFTWARE) sk.setsockopt(SOL_SOCKET, SO_ZEROCOPY, 1)
sk.sendto(b'', MSG_ZEROCOPY, ('127.0.0.1', 53))
sk.close()
sendmsg() calls msg_zerocopy_alloc(), which allocates a skb, sets skb->cb->ubuf.refcnt to 1, and calls sock_hold(). Here, struct ubuf_info_msgzc indirectly holds a refcnt of the socket. When the skb is sent, __skb_tstamp_tx() clones it and puts the clone into the socket's error queue with the TX timestamp.
When the original skb is received locally, skb_copy_ubufs() calls skb_unclone(), and pskb_expand_head() increments skb->cb->ubuf.refcnt. This additional count is decremented while freeing the skb, but struct ubuf_info_msgzc still has a refcnt, so __msg_zerocopy_callback() is not called.
The last refcnt is not released unless we retrieve the TX timestamped skb by recvmsg(). Since we clear the error queue in inet_sock_destruct() after the socket's refcnt reaches 0, there is a circular dependency. If we close() the socket holding such skbs, we never call sock_put() and leak the count, sk, and skb.
TCP has the same problem, and commit e0c8bccd40fc ("net: stream:
purge sk_error_queue in sk_stream_kill_queues()") tried to fix it by calling skb_queue_purge() during close(). However, there is a small chance that skb queued in a qdisc or device could be put into the error queue after the skb_queue_purge() call.
In __skb_tstamp_tx(), the cloned skb should not have a reference to the ubuf to remove the circular dependency, but skb_clone() does not call skb_copy_ubufs() for zerocopy skb. So, we need to call skb_orphan_frags_rx() for the cloned skb to call skb_copy_ubufs().
[0]:
BUG: memory leak
unreferenced object 0xffff88800c6d2d00 (size 1152):
comm "syz-executor392", pid 264, jiffies 4294785440 (age 13.044s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 cd af e8 81 00 00 00 00 ................
02 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00 ...@............
backtrace:
[<0000000055636812>] sk_prot_alloc+0x64/0x2a0 net/core/sock.c:2024
[<0000000054d77b7a>] sk_alloc+0x3b/0x800 net/core/sock.c:2083
[<0000000066f3c7e0>] inet_create net/ipv4/af_inet.c:319 [inline]
[<0000000066f3c7e0>] inet_create+0x31e/0xe40 net/ipv4/af_inet.c:245
[<000000009b83af97>] __sock_create+0x2ab/0x550 net/socket.c:1515
[<00000000b9b11231>] sock_create net/socket.c:1566 [inline]
[<00000000b9b11231>] __sys_socket_create net/socket.c:1603 [inline]
[<00000000b9b11231>] __sys_socket_create net/socket.c:1588 [inline]
[<00000000b9b11231>] __sys_socket+0x138/0x250 net/socket.c:1636
[<000000004fb45142>] __do_sys_socket net/socket.c:1649 [inline]
[<000000004fb45142>] __se_sys_socket net/socket.c:1647 [inline]
[<000000004fb45142>] __x64_sys_socket+0x73/0xb0 net/socket.c:1647
[<0000000066999e0e>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<0000000066999e0e>] do_syscall_64+0x38/0x90 arch/x86/entry/common.c:80
[<0000000017f238c1>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
BUG: memory leak
unreferenced object 0xffff888017633a00 (size 240):
comm "syz-executor392", pid 264, jiffies 4294785440 (age 13.044s)
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 2d 6d 0c 80 88 ff ff .........-m.....
backtrace:
[<000000002b1c4368>] __alloc_skb+0x229/0x320 net/core/skbuff.c:497
[<00000000143579a6>] alloc_skb include/linux/skbuff.h:1265 [inline]
[<00000000143579a6>] sock_omalloc+0xaa/0x190 net/core/sock.c:2596
[<00000000be626478>] msg_zerocopy_alloc net/core/skbuff.c:1294 [inline]
[<00000000be626478>] msg_zerocopy_realloc+0x1ce/0x7f0 net/core/skbuff.c:1370
[<00000000cbfc9870>] __ip_append_data+0x2adf/0x3b30 net/ipv4/ip_output.c:1037
[<0000000089869146>] ip_make_skb+0x26c/0x2e0 net/ipv4/ip_output.c:1652
[<00000000098015c2>] udp_sendmsg+0x1bac/0x2390 net/ipv4/udp.c:1253
[<0000000045e0e95e>] inet_sendmsg+0x10a/0x150 net/ipv4/af_inet.c:819
[<000000008d31bfde>] sock_sendmsg_nosec net/socket.c:714 [inline]
[<000000008d31bfde>] sock_sendmsg+0x141/0x190 net/socket.c:734
[<0000000021e21aa4>] __sys_sendto+0x243/0x360 net/socket.c:2117
[<00000000ac0af00c>] __do_sys_sendto net/socket.c:2129 [inline]
[<00000000ac0af00c>] __se_sys_sendto net/socket.c:2125 [inline]
[<00000000ac0af00c>] __x64_sys_sendto+0xe1/0x1c0 net/socket.c:2125
[<0000000066999e0e>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<0000000066999e0e>] do_syscall_64+0x38/0x90 arch/x86/entry/common.c:80
[<0000000017f238c1>] entry_SYSCALL_64_after_hwframe+0x63/0xcd--- net/core/skbuff.c | 3 +++ 1 file changed, 3 insertions(+)
net/core/skbuff.c +3 -0
@@ -4750,6 +4750,9 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb, skb =alloc_skb (0 ,GFP_ATOMIC ); }else { skb =skb_clone (orig_skb,GFP_ATOMIC ); + +if (skb_orphan_frags_rx (skb,GFP_ATOMIC )) +return ; }if (!skb)return ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 192/381 ipmi: ASPEED_BT_IPMI_BMC: select REGMAP_MMIO instead of depending on it
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 2a587b9ad052e7e92e508aea90c1e2ae433c1908 ]
REGMAP is a hidden (not user visible) symbol. Users cannot set it directly thru "make *config", so drivers should select it instead of depending on it if they need it.
Consistently using "select" or "depends on" can also help reduce Kconfig circular dependency issues.
Therefore, change the use of "depends on REGMAP_MMIO" to "select REGMAP_MMIO", which will also set REGMAP.
Message-Id: <[email protected]>
--- drivers/char/ipmi/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/char/ipmi/Kconfig +2 -1
@@ -126,7 +126,8 @@ config NPCM7XX_KCS_IPMI_BMC config ASPEED_BT_IPMI_BMC depends on ARCH_ASPEED || COMPILE_TEST - depends on REGMAP && REGMAP_MMIO && MFD_SYSCON + depends on MFD_SYSCON + select REGMAP_MMIO tristate "BT IPMI bmc driver" help Provides a driver for the BT (Block Transfer) IPMI interface
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 193/381 pstore: Revert pmsg_lock back to a normal mutex
In reply to Greg Kroah-HartmanFrom: John Stultz <[email protected]>
[ Upstream commit 5239a89b06d6b199f133bf0ffea421683187f257 ]
This reverts commit 76d62f24db07f22ccf9bc18ca793c27d4ebef721.
So while priority inversion on the pmsg_lock is an occasional problem that an rt_mutex would help with, in uses where logging is writing to pmsg heavily from multiple threads, the pmsg_lock can be heavily contended.
After this change landed, it was reported that cases where the mutex locking overhead was commonly adding on the order of 10s of usecs delay had suddenly jumped to ~msec delay with rtmutex.
It seems the slight differences in the locks under this level of contention causes the normal mutexes to utilize the spinning optimizations, while the rtmutexes end up in the sleeping slowpath (which allows additional threads to pile on trying to take the lock).
In this case, it devolves to a worse case senerio where the lock acquisition and scheduling overhead dominates, and each thread is waiting on the order of ~ms to do ~us of work.
Obviously, having tons of threads all contending on a single lock for logging is non-optimal, so the proper fix is probably reworking pstore pmsg to have per-cpu buffers so we don't have contention.
Additionally, Steven Rostedt has provided some furhter optimizations for rtmutexes that improves the rtmutex spinning path, but at least in my testing, I still see the test tripping into the sleeping path on rtmutexes while utilizing the spinning path with mutexes.
But in the short term, lets revert the change to the rt_mutex and go back to normal mutexes to avoid a potentially major performance regression. And we can work on optimizations to both rtmutexes and finer-grained locking for pstore pmsg in the future.
--- fs/pstore/pmsg.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
fs/pstore/pmsg.c +3 -4
@@ -7,10 +7,9 @@#include <linux/device.h> #include <linux/fs.h> #include <linux/uaccess.h> -#include <linux/rtmutex.h> #include "internal.h" -static DEFINE_RT_MUTEX (pmsg_lock); +static DEFINE_MUTEX (pmsg_lock);static ssize_t write_pmsg (struct file *file,const char __user *buf,size_t count,loff_t *ppos)
@@ -29,9 +28,9 @@ static ssize_t write_pmsg(struct file *file, const char __user *buf,if (!access_ok (buf, count))return -EFAULT ; -rt_mutex_lock (&pmsg_lock); +mutex_lock (&pmsg_lock); ret = psinfo->write_user (&record, buf); -rt_mutex_unlock (&pmsg_lock); +mutex_unlock (&pmsg_lock);return ret ? ret : count; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 194/381 usb: host: xhci-rcar: remove leftover quirk handling
In reply to Greg Kroah-HartmanFrom: Wolfram Sang <[email protected]>
[ Upstream commit 5d67f4861884762ebc2bddb5d667444e45f25782 ]
Loading V3 firmware does not need a quirk anymore, remove the leftover code.
--- drivers/usb/host/xhci-rcar.c | 3 --- 1 file changed, 3 deletions(-)
drivers/usb/host/xhci-rcar.c +0 -3
@@ -75,7 +75,6 @@ MODULE_FIRMWARE(XHCI_RCAR_FIRMWARE_NAME_V3);/* For soc_device_attribute */ #define RCAR_XHCI_FIRMWARE_V2 BIT(0)/* FIRMWARE V2 */ -#define RCAR_XHCI_FIRMWARE_V3 BIT(1)/* FIRMWARE V3 */ static const struct soc_device_attribute rcar_quirks_match[] = { {
@@ -147,8 +146,6 @@ static int xhci_rcar_download_firmware(struct usb_hcd *hcd)if (quirks &RCAR_XHCI_FIRMWARE_V2 ) firmware_name =XHCI_RCAR_FIRMWARE_NAME_V2 ; -else if (quirks &RCAR_XHCI_FIRMWARE_V3 ) - firmware_name =XHCI_RCAR_FIRMWARE_NAME_V3 ;else firmware_name = priv->firmware_name;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 195/381 usb: dwc3: gadget: Change condition for processing suspend event
In reply to Greg Kroah-HartmanFrom: Prashanth K <[email protected]>
[ Upstream commit 4decf4060ecfee1f7a710999fcd421645ac0c419 ]
Currently we process the suspend interrupt event only if the device is in configured state. Consider a case where device is not configured and got suspend interrupt, in that case our gadget will still use 100mA as composite_suspend didn't happen. But battery charging specification (BC1.2) expects a downstream device to draw less than 2.5mA when unconnected OR suspended.
Fix this by removing the condition for processing suspend event, and thus composite_resume would set vbus draw to 2.
--- drivers/usb/dwc3/gadget.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/usb/dwc3/gadget.c +2 -9
@@ -3726,15 +3726,8 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc,break ;case DWC3_DEVICE_EVENT_EOPF :/* It changed to be suspend event for version 2.30a and above */ - if (!DWC3_VER_IS_PRIOR(DWC3, 230A)) { -/* -* Ignore suspend event until the gadget enters into -* USB_STATE_CONFIGURED state. -*/ -if (dwc->gadget->state >=USB_STATE_CONFIGURED ) -dwc3_gadget_suspend_interrupt (dwc, - event->event_info); - } + if (!DWC3_VER_IS_PRIOR(DWC3, 230A)) +dwc3_gadget_suspend_interrupt (dwc, event->event_info);break ;case DWC3_DEVICE_EVENT_SOF :case DWC3_DEVICE_EVENT_ERRATIC_ERROR :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 196/381 fpga: bridge: fix kernel-doc parameter description
In reply to Greg Kroah-HartmanFrom: Marco Pagani <[email protected]>
[ Upstream commit 7ef1a2c1c9dffa177ecc3ea50b7f5ee63a621137 ]
Fix the kernel-doc description for the "struct fpga_image_info *info" parameter of the fpga_bridge_get() function.
--- drivers/fpga/fpga-bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/fpga-bridge.c +1 -1
@@ -115,7 +115,7 @@ static int fpga_bridge_dev_match(struct device *dev, const void *data)/** * fpga_bridge_get - get an exclusive reference to a fpga bridge * @dev: parent device that fpga bridge was registered with -* @info: fpga manager info +* @info: fpga image specific information * * Given a device, get an exclusive reference to a fpga bridge. *
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 197/381 iio: light: max44009: add missing OF device matching
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit b29c49026c3c05a11f845dba17cad0b3ba06836d ]
The driver currently matches only via i2c_device_id, but also has of_device_id table:
drivers/iio/light/max44009.c:545:34: error: ‘max44009_of_match’ defined but not used [-Werror=unused-const-variable=]
--- drivers/iio/light/max44009.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/iio/light/max44009.c +7 -6
@@ -528,6 +528,12 @@ static int max44009_probe(struct i2c_client *client,return devm_iio_device_register (&client->dev, indio_dev); } +static const struct of_device_id max44009_of_match[] = { + { .compatible ="maxim,max44009" }, + { } +}; +MODULE_DEVICE_TABLE (of, max44009_of_match); +static const struct i2c_device_id max44009_id[] = { {"max44009" ,0 }, { }
@@ -537,18 +543,13 @@ MODULE_DEVICE_TABLE(i2c, max44009_id);static struct i2c_driver max44009_driver = { .driver = { .name =MAX44009_DRV_NAME , + .of_match_table = max44009_of_match, }, .probe = max44009_probe, .id_table = max44009_id, };module_i2c_driver (max44009_driver); -static const struct of_device_id max44009_of_match[] = { - { .compatible ="maxim,max44009" }, - { } -}; -MODULE_DEVICE_TABLE (of, max44009_of_match); -MODULE_AUTHOR ("Robert Eshleman <[email protected]>" );MODULE_LICENSE ("GPL v2" );MODULE_DESCRIPTION ("MAX44009 ambient light sensor driver" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 198/381 spi: spi-imx: using pm_runtime_resume_and_get instead of pm_runtime_get_sync
In reply to Greg Kroah-HartmanFrom: Minghao Chi <[email protected]>
[ Upstream commit 7d34ff58f35c82207698f43af79817a05e1342e5 ]
Using pm_runtime_resume_and_get() to replace pm_runtime_get_sync and pm_runtime_put_noidle. This change is just to simplify the code, no actual functional changes.
Stable-dep-of: 11951c9e3f36 ("spi: imx: Don't skip cleanup in remove's error path")
--- drivers/spi/spi-imx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/spi/spi-imx.c +2 -4
@@ -1554,9 +1554,8 @@ spi_imx_prepare_message(struct spi_master *master, struct spi_message *msg)struct spi_imx_data *spi_imx =spi_master_get_devdata (master);int ret; - ret =pm_runtime_get_sync (spi_imx->dev); + ret =pm_runtime_resume_and_get (spi_imx->dev);if (ret <0 ) { -pm_runtime_put_noidle (spi_imx->dev);dev_err (spi_imx->dev,"failed to enable clock\n" );return ret; }
@@ -1765,9 +1764,8 @@ static int spi_imx_remove(struct platform_device *pdev)spi_bitbang_stop (&spi_imx->bitbang); - ret =pm_runtime_get_sync (spi_imx->dev); + ret =pm_runtime_resume_and_get (spi_imx->dev);if (ret <0 ) { -pm_runtime_put_noidle (spi_imx->dev);dev_err (spi_imx->dev,"failed to enable clock\n" );return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 199/381 spi: imx: Dont skip cleanup in removes error path
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 11951c9e3f364d7ae3b568a0e52c8335d43066b5 ]
Returning early in a platform driver's remove callback is wrong. In this case the dma resources are not released in the error path. this is never retried later and so this is a permanent leak. To fix this, only skip hardware disabling if waking the device fails.
--- drivers/spi/spi-imx.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/spi/spi-imx.c +5 -7
@@ -1764,13 +1764,11 @@ static int spi_imx_remove(struct platform_device *pdev)spi_bitbang_stop (&spi_imx->bitbang); - ret =pm_runtime_resume_and_get (spi_imx->dev); -if (ret <0 ) { -dev_err (spi_imx->dev,"failed to enable clock\n" ); -return ret; - } - -writel (0 , spi_imx->base +MXC_CSPICTRL ); + ret =pm_runtime_get_sync (spi_imx->dev); +if (ret >=0 ) +writel (0 , spi_imx->base +MXC_CSPICTRL ); +else +dev_warn (spi_imx->dev,"failed to enable clock, skip hw disable\n" );pm_runtime_dont_use_autosuspend (spi_imx->dev);pm_runtime_put_sync (spi_imx->dev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 200/381 usb: gadget: udc: renesas_usb3: Fix use after free bug in renesas_usb3_remove due to race condition
In reply to Greg Kroah-HartmanFrom: Zheng Wang <[email protected]>
[ Upstream commit 2b947f8769be8b8181dc795fd292d3e7120f5204 ]
In renesas_usb3_probe, role_work is bound with renesas_usb3_role_work. renesas_usb3_start will be called to start the work.
If we remove the driver which will call usbhs_remove, there may be an unfinished work. The possible sequence is as follows:
CPU0 CPU1
renesas_usb3_role_workrenesas_usb3_removeusb_role_switch_unregisterdevice_unregister
kfree(sw)
//free usb3->role_sw
usb_role_switch_set_role
//use usb3->role_swThe usb3->role_sw could be freed under such circumstance and then used in usb_role_switch_set_role.
This bug was found by static analysis. And note that removing a driver is a root-only operation, and should never happen in normal case. But the root user may directly remove the device which will also trigger the remove function.
Fix it by canceling the work before cleanup in the renesas_usb3_remove.
--- drivers/usb/gadget/udc/renesas_usb3.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/udc/renesas_usb3.c +1 -0
@@ -2568,6 +2568,7 @@ static int renesas_usb3_remove(struct platform_device *pdev)debugfs_remove_recursive (usb3->dentry);device_remove_file (&pdev->dev, &dev_attr_role); +cancel_work_sync (&usb3->role_work);usb_role_switch_unregister (usb3->role_sw);usb_del_gadget_udc (&usb3->gadget);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 201/381 PCI: imx6: Install the fault handler only on compatible match
In reply to Greg Kroah-HartmanFrom: H. Nikolaus Schaller <[email protected]>
[ Upstream commit 5f5ac460dfe7f4e11f99de9870f240e39189cf72 ]
commit bb38919ec56e ("PCI: imx6: Add support for i.MX6 PCIe controller") added a fault hook to this driver in the probe function. So it was only installed if needed.
commit bde4a5a00e76 ("PCI: imx6: Allow probe deferral by reset GPIO") moved it from probe to driver init which installs the hook unconditionally as soon as the driver is compiled into a kernel.
When this driver is compiled as a module, the hook is not registered until after the driver has been matched with a .compatible and loaded.
commit 415b6185c541 ("PCI: imx6: Fix config read timeout handling") extended the fault handling code.
commit 2d8ed461dbc9 ("PCI: imx6: Add support for i.MX8MQ") added some protection for non-ARM architectures, but this does not protect non-i.MX ARM architectures.
Since fault handlers can be triggered on any architecture for different reasons, there is no guarantee that they will be triggered only for the assumed situation, leading to improper error handling (i.MX6-specific imx6q_pcie_abort_handler) on foreign systems.
I had seen strange L3 imprecise external abort messages several times on OMAP4 and OMAP5 devices and couldn't make sense of them until I realized they were related to this unused imx6q driver because I had CONFIG_PCI_IMX6=y.
Note that CONFIG_PCI_IMX6=y is useful for kernel binaries that are designed to run on different ARM SoC and be differentiated only by device tree binaries. So turning off CONFIG_PCI_IMX6 is not a solution.
Therefore we check the compatible in the init function before registering the fault handler.
--- drivers/pci/controller/dwc/pci-imx6.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/pci/controller/dwc/pci-imx6.c +7 -0
@@ -1272,6 +1272,13 @@ DECLARE_PCI_FIXUP_CLASS_HEADER(PCI_VENDOR_ID_SYNOPSYS, 0xabcd,static int __init imx6_pcie_init (void ) {#ifdef CONFIG_ARM +struct device_node *np; + + np =of_find_matching_node (NULL , imx6_pcie_of_match); +if (!np) +return -ENODEV ; +of_node_put (np); +/* * Since probe() can be deferred we need to make sure that * hook_fault_code is not called after __init memory is freed
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 202/381 ASoC: es8316: Use IRQF_NO_AUTOEN when requesting the IRQ
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit 1cf2aa665901054b140eb71748661ceae99b6b5a ]
Use the new IRQF_NO_AUTOEN flag when requesting the IRQ, rather then disabling it immediately after requesting it.
This fixes a possible race where the IRQ might trigger between requesting and disabling it; and this also leads to a small code cleanup.
Stable-dep-of: 39db65a0a17b ("ASoC: es8316: Handle optional IRQ assignment")
--- sound/soc/codecs/es8316.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
sound/soc/codecs/es8316.c +2 -5
@@ -808,12 +808,9 @@ static int es8316_i2c_probe(struct i2c_client *i2c_client,mutex_init (&es8316->lock); ret =devm_request_threaded_irq (dev, es8316->irq,NULL , es8316_irq, -IRQF_TRIGGER_HIGH |IRQF_ONESHOT , +IRQF_TRIGGER_HIGH |IRQF_ONESHOT |IRQF_NO_AUTOEN ,"es8316" , es8316); -if (ret ==0 ) { -/* Gets re-enabled by es8316_set_jack() */ -disable_irq (es8316->irq); - }else { +if (ret) {dev_warn (dev,"Failed to get IRQ %d: %d\n" , es8316->irq, ret); es8316->irq = -ENXIO ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 203/381 ASoC: es8316: Handle optional IRQ assignment
In reply to Greg Kroah-HartmanFrom: Cristian Ciocaltea <[email protected]>
[ Upstream commit 39db65a0a17b54915b269d3685f253a4731f344c ]
The driver is able to work fine without relying on a mandatory interrupt being assigned to the I2C device. This is only needed when making use of the jack-detect support.
However, the following warning message is always emitted when there is no such interrupt available:
es8316 0-0011: Failed to get IRQ 0: -22
Do not attempt to request an IRQ if it is not available/valid. This also ensures the rather misleading message is not displayed anymore.
Also note the IRQ validation relies on commit dab472eb931bc291 ("i2c /
ACPI: Use 0 to indicate that device does not have interrupt assigned").
--- sound/soc/codecs/es8316.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
sound/soc/codecs/es8316.c +8 -6
@@ -807,12 +807,14 @@ static int es8316_i2c_probe(struct i2c_client *i2c_client, es8316->irq = i2c_client->irq;mutex_init (&es8316->lock); - ret =devm_request_threaded_irq (dev, es8316->irq,NULL , es8316_irq, -IRQF_TRIGGER_HIGH |IRQF_ONESHOT |IRQF_NO_AUTOEN , -"es8316" , es8316); -if (ret) { -dev_warn (dev,"Failed to get IRQ %d: %d\n" , es8316->irq, ret); - es8316->irq = -ENXIO ; +if (es8316->irq >0 ) { + ret =devm_request_threaded_irq (dev, es8316->irq,NULL , es8316_irq, +IRQF_TRIGGER_HIGH |IRQF_ONESHOT |IRQF_NO_AUTOEN , +"es8316" , es8316); +if (ret) { +dev_warn (dev,"Failed to get IRQ %d: %d\n" , es8316->irq, ret); + es8316->irq = -ENXIO ; + } } return devm_snd_soc_register_component(&i2c_client->dev,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 204/381 linux/vt_buffer.h: allow either builtin or modular for macros
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 2b76ffe81e32afd6d318dc4547e2ba8c46207b77 ]
Fix build errors on ARCH=alpha when CONFIG_MDA_CONSOLE=m. This allows the ARCH macros to be the only ones defined.
In file included from ../drivers/video/console/mdacon.c:37:../arch/alpha/include/asm/vga.h:17:40: error: expected identifier or '(' before 'volatile'
17 | static inline void scr_writew(u16 val, volatile u16 *addr)
| ^~~~~~~~../include/linux/vt_buffer.h:24:34: note: in definition of macro 'scr_writew'
24 | #define scr_writew(val, addr) (*(addr) = (val))
| ^~~~../include/linux/vt_buffer.h:24:40: error: expected ')' before '=' token
24 | #define scr_writew(val, addr) (*(addr) = (val))
| ^../arch/alpha/include/asm/vga.h:17:20: note: in expansion of macro 'scr_writew'
17 | static inline void scr_writew(u16 val, volatile u16 *addr)
| ^~~~~~~~~~
../arch/alpha/include/asm/vga.h:25:29: error: expected identifier or '(' before 'volatile'
25 | static inline u16 scr_readw(volatile const u16 *addr)
| ^~~~~~~~
--- include/linux/vt_buffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/vt_buffer.h +1 -1
@@ -16,7 +16,7 @@#include <linux/string.h> -#if defined(CONFIG_VGA_CONSOLE ) || defined(CONFIG_MDA_CONSOLE ) +#if IS_ENABLED (CONFIG_VGA_CONSOLE ) ||IS_ENABLED (CONFIG_MDA_CONSOLE )#include <asm/vga.h> #endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 205/381 spi: qup: Dont skip cleanup in removes error path
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 61f49171a43ab1f80c73c5c88c508770c461e0f2 ]
Returning early in a platform driver's remove callback is wrong. In this case the dma resources are not released in the error path. this is never retried later and so this is a permanent leak. To fix this, only skip hardware disabling if waking the device fails.
--- drivers/spi/spi-qup.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-)
drivers/spi/spi-qup.c +13 -9
@@ -1276,18 +1276,22 @@ static int spi_qup_remove(struct platform_device *pdev)struct spi_qup *controller =spi_master_get_devdata (master);int ret; - ret =pm_runtime_resume_and_get (&pdev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_sync (&pdev->dev); - ret =spi_qup_set_state (controller,QUP_STATE_RESET ); -if (ret) -return ret; +if (ret >=0 ) { + ret =spi_qup_set_state (controller,QUP_STATE_RESET ); +if (ret) +dev_warn (&pdev->dev,"failed to reset controller (%pe)\n" , +ERR_PTR (ret)); -spi_qup_release_dma (master); +clk_disable_unprepare (controller->cclk); +clk_disable_unprepare (controller->iclk); + }else { +dev_warn (&pdev->dev,"failed to resume, skip hw disable (%pe)\n" , +ERR_PTR (ret)); + } -clk_disable_unprepare (controller->cclk); -clk_disable_unprepare (controller->iclk); +spi_qup_release_dma (master);pm_runtime_put_noidle (&pdev->dev);pm_runtime_disable (&pdev->dev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 206/381 spi: fsl-spi: Fix CPM/QE mode Litte Endian
In reply to Greg Kroah-HartmanFrom: Christophe Leroy <[email protected]>
[ Upstream commit c20c57d9868d7f9fd1b2904c7801b07e128f6322 ]
CPM has the same problem as QE so for CPM also use the fix added by commit 0398fb70940e ("spi/spi_mpc8xxx: Fix QE mode Litte Endian"):
CPM mode uses Little Endian so words > 8 bits are byte swapped. Workaround this by always enforcing wordsize 8 for 16 and 32 bits words. Unfortunately this will not work for LSB transfers where wordsize is > 8 bits so disable these for now.
Also limit the workaround to 16 and 32 bits words because it can only work for multiples of 8-bits.
--- drivers/spi/spi-fsl-spi.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/spi/spi-fsl-spi.c +7 -5
@@ -207,8 +207,8 @@ static int mspi_apply_qe_mode_quirks(struct spi_mpc8xxx_cs *cs,struct spi_device *spi, int bits_per_word) { -/* QE uses Little Endian for words > 8 -* so transform all words > 8 into 8 bits +/* CPM/QE uses Little Endian for words > 8 +* so transform 16 and 32 bits words into 8 bits * Unfortnatly that doesn't work for LSB so * reject these for now */ /* Note: 32 bits word, LSB works iff
@@ -216,9 +216,11 @@ static int mspi_apply_qe_mode_quirks(struct spi_mpc8xxx_cs *cs,if (spi->mode &SPI_LSB_FIRST && bits_per_word >8 )return -EINVAL ; -if (bits_per_word >8 ) +if (bits_per_word <=8 ) +return bits_per_word; +if (bits_per_word ==16 || bits_per_word ==32 )return 8 ;/* pretend its 8 bits */ -return bits_per_word; +return -EINVAL ; } static int fsl_spi_setup_transfer(struct spi_device *spi,
@@ -248,7 +250,7 @@ static int fsl_spi_setup_transfer(struct spi_device *spi, bits_per_word =mspi_apply_cpu_mode_quirks (cs, spi, mpc8xxx_spi, bits_per_word); - else if (mpc8xxx_spi->flags & SPI_QE) + else bits_per_word =mspi_apply_qe_mode_quirks (cs, spi, bits_per_word);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 207/381 vmci_host: fix a race condition in vmci_host_poll() causing GPF
In reply to Greg Kroah-HartmanFrom: Dae R. Jeong <[email protected]>
[ Upstream commit ae13381da5ff0e8e084c0323c3cc0a945e43e9c7 ]
During fuzzing, a general protection fault is observed in vmci_host_poll().
general protection fault, probably for non-canonical address 0xdffffc0000000019: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x00000000000000c8-0x00000000000000cf] RIP: 0010:__lock_acquire+0xf3/0x5e00 kernel/locking/lockdep.c:4926 <- omitting registers -> Call Trace: <TASK> lock_acquire+0x1a4/0x4a0 kernel/locking/lockdep.c:5672 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0xb3/0x100 kernel/locking/spinlock.c:162 add_wait_queue+0x3d/0x260 kernel/sched/wait.c:22 poll_wait include/linux/poll.h:49 [inline] vmci_host_poll+0xf8/0x2b0 drivers/misc/vmw_vmci/vmci_host.c:174 vfs_poll include/linux/poll.h:88 [inline] do_pollfd fs/select.c:873 [inline] do_poll fs/select.c:921 [inline] do_sys_poll+0xc7c/0x1aa0 fs/select.c:1015 __do_sys_ppoll fs/select.c:1121 [inline] __se_sys_ppoll+0x2cc/0x330 fs/select.c:1101 do_syscall_x64 arch/x86/entry/common.c:51 [inline] do_syscall_64+0x4e/0xa0 arch/x86/entry/common.c:82 entry_SYSCALL_64_after_hwframe+0x46/0xb0
Example thread interleaving that causes the general protection fault is as follows:
CPU1 (vmci_host_poll) CPU2 (vmci_host_do_init_context)
----- -----
// Read uninitialized context
context = vmci_host_dev->context;
// Initialize context
vmci_host_dev->context = vmci_ctx_create();
vmci_host_dev->ct_type = VMCIOBJ_CONTEXT;if (vmci_host_dev->ct_type == VMCIOBJ_CONTEXT) {
// Dereferencing the wrong pointer
poll_wait(..., &context->host_context);
}In this scenario, vmci_host_poll() reads vmci_host_dev->context first, and then reads vmci_host_dev->ct_type to check that vmci_host_dev->context is initialized. However, since these two reads are not atomically executed, there is a chance of a race condition as described above.
To fix this race condition, read vmci_host_dev->context after checking the value of vmci_host_dev->ct_type so that vmci_host_poll() always reads an initialized context.
--- drivers/misc/vmw_vmci/vmci_host.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/misc/vmw_vmci/vmci_host.c +7 -1
@@ -165,10 +165,16 @@ static int vmci_host_close(struct inode *inode, struct file *filp)static __poll_t vmci_host_poll (struct file *filp,poll_table *wait) {struct vmci_host_dev *vmci_host_dev = filp->private_data; -struct vmci_ctx *context = vmci_host_dev->context; +struct vmci_ctx *context;__poll_t mask =0 ;if (vmci_host_dev->ct_type ==VMCIOBJ_CONTEXT ) { +/* +* Read context only if ct_type == VMCIOBJ_CONTEXT to make +* sure that context is initialized +*/ + context = vmci_host_dev->context; +/* Check for VMCI calls to this VM context. */ if (wait) poll_wait(filp, &context->host_context.wait_queue,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 208/381 of: Fix modalias string generation
In reply to Greg Kroah-HartmanFrom: Miquel Raynal <[email protected]>
[ Upstream commit b19a4266c52de78496fe40f0b37580a3b762e67d ]
The helper generating an OF based modalias (of_device_get_modalias()) works fine, but due to the use of snprintf() internally it needs a buffer one byte longer than what should be needed just for the entire string (excluding the '\0'). Most users of this helper are sysfs hooks providing the modalias string to users. They all provide a PAGE_SIZE buffer which is way above the number of bytes required to fit the modalias string and hence do not suffer from this issue.
There is another user though, of_device_request_module(), which is only called by drivers/usb/common/ulpi.c. This request module function is faulty, but maybe because in most cases there is an alternative, ULPI driver users have not noticed it.
In this function, of_device_get_modalias() is called twice. The first time without buffer just to get the number of bytes required by the modalias string (excluding the null byte), and a second time, after buffer allocation, to fill the buffer. The allocation asks for an additional byte, in order to store the trailing '\0'. However, the buffer *length* provided to of_device_get_modalias() excludes this extra byte. The internal use of snprintf() with a length that is exactly the number of bytes to be written has the effect of using the last available byte to store a '\0', which then smashes the last character of the modalias string.
Provide the actual size of the buffer to of_device_get_modalias() to fix this issue.
Note: the "str[size - 1] = '\0';" line is not really needed as snprintf will anyway end the string with a null byte, but there is a possibility that this function might be called on a struct device_node without compatible, in this case snprintf() would not be executed. So we keep it just to avoid possible unbounded strings.
--- drivers/of/device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/of/device.c +5 -2
@@ -264,12 +264,15 @@ int of_device_request_module(struct device *dev)if (size <0 )return size; - str =kmalloc (size +1 ,GFP_KERNEL ); +/* Reserve an additional byte for the trailing '\0' */ + size++; + + str =kmalloc (size,GFP_KERNEL );if (!str)return -ENOMEM ;of_device_get_modalias (dev, str, size); - str[size] ='\0' ; + str[size -1 ] ='\0' ; ret =request_module (str);kfree (str);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 209/381 PCI/EDR: Clear Device Status after EDR error recovery
In reply to Greg Kroah-HartmanFrom: Kuppuswamy Sathyanarayanan <[email protected]>
[ Upstream commit c441b1e03da6c680a3e12da59c554f454f2ccf5e ]
During EDR recovery, the OS must clear error status of the port that triggered DPC even if firmware retains control of DPC and AER (see the implementation note in the PCI Firmware spec r3.3, sec 4.6.12).
Prior to 068c29a248b6 ("PCI/ERR: Clear PCIe Device Status errors only if OS owns AER"), the port Device Status was cleared in this path:
edr_handle_event
dpc_process_error(dev) # "dev" triggered DPC
pcie_do_recovery(dev, dpc_reset_link)
dpc_reset_link # exit DPC
pcie_clear_device_status(dev) # clear Device Status
After 068c29a248b6, pcie_do_recovery() no longer clears Device Status when firmware controls AER, so the error bit remains set even after recovery.
Per the "Downstream Port Containment configuration control" bit in the returned _OSC Control Field (sec 4.5.1), the OS is allowed to clear error status until it evaluates _OST, so clear Device Status in edr_handle_event() if the error recovery was successful.
--- drivers/pci/pcie/edr.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/pcie/edr.c +1 -0
@@ -193,6 +193,7 @@ static void edr_handle_event(acpi_handle handle, u32 event, void *data)*/ if (estate ==PCI_ERS_RESULT_RECOVERED ) {pci_dbg (edev,"DPC port successfully recovered\n" ); +pcie_clear_device_status (edev);acpi_send_edr_status (pdev, edev,EDR_OST_SUCCESS ); }else {pci_dbg (edev,"DPC port recovery failed\n" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 210/381 ia64: mm/contig: fix section mismatch warning/error
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 58deeb4ef3b054498747d0929d94ac53ab90981f ]
alloc_per_cpu_data() is called by find_memory(), which is marked as __init. Therefore alloc_per_cpu_data() can also be marked as __init to remedy this modpost problem.
WARNING: modpost: vmlinux.o: section mismatch in reference: alloc_per_cpu_data (section: .text) -> memblock_alloc_try_nid (section: .init.text)
--- arch/ia64/mm/contig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/mm/contig.c +1 -1
@@ -79,7 +79,7 @@ void *per_cpu_init(void)return __per_cpu_start + __per_cpu_offset[smp_processor_id ()]; } -static inline void +static inline __init void alloc_per_cpu_data (void ) {size_t size =PERCPU_PAGE_SIZE *num_possible_cpus ();
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 211/381 ia64: salinfo: placate defined-but-not-used warning
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 0de155752b152d6bcd96b5b5bf20af336abd183a ]
When CONFIG_PROC_FS is not set, proc_salinfo_show() is not used. Mark the function as __maybe_unused to quieten the warning message.
../arch/ia64/kernel/salinfo.c:584:12: warning: 'proc_salinfo_show' defined but not used [-Wunused-function]
584 | static int proc_salinfo_show(struct seq_file *m, void *v)
| ^~~~~~~~~~~~~~~~~
--- arch/ia64/kernel/salinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/kernel/salinfo.c +1 -1
@@ -581,7 +581,7 @@ static int salinfo_cpu_pre_down(unsigned int cpu)* 'data' contains an integer that corresponds to the feature we're * testing */ -static int proc_salinfo_show (struct seq_file *m,void *v) +static int __maybe_unused proc_salinfo_show (struct seq_file *m,void *v) {unsigned long data = (unsigned long )v;seq_puts (m, (sal_platform_features & data) ?"1\n" :"0\n" );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 212/381 scripts/gdb: bail early if there are no clocks
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 1d7adbc74c009057ed9dc3112f388e91a9c79acc ]
Avoid generating an exception if there are no clocks registered:
(gdb) lx-clk-summary
enable prepare protect
clock count count count rate
------------------------------------------------------------------------
Python Exception <class 'gdb.error'>: No symbol "clk_root_list" in current context.
Error occurred in Python: No symbol "clk_root_list" in current context.
--- scripts/gdb/linux/clk.py | 2 ++ 1 file changed, 2 insertions(+)
scripts/gdb/linux/clk.py +2 -0
@@ -41,6 +41,8 @@ are cached and potentially out of date""" self.show_subtree(child, level + 1) def invoke(self, arg, from_tty): + if utils.gdb_eval_or_none("clk_root_list") is None: + raise gdb.GdbError("No clocks registered") gdb.write(" enable prepare protect \n") gdb.write(" clock count count count rate \n") gdb.write("------------------------------------------------------------------------\n")
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 213/381 scripts/gdb: bail early if there are no generic PD
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit f19c3c2959e465209ade1a7a699e6cbf4359ce78 ]
Avoid generating an exception if there are no generic power domain(s) registered:
(gdb) lx-genpd-summary
domain status children
/device runtime status
----------------------------------------------------------------------
Python Exception <class 'gdb.error'>: No symbol "gpd_list" in current context. Error occurred in Python: No symbol "gpd_list" in current context. (gdb) quit
--- scripts/gdb/linux/genpd.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/gdb/linux/genpd.py +3 -1
@@ -5,7 +5,7 @@ import gdb import sys -from linux.utils import CachedType +from linux.utils import CachedType, gdb_eval_or_none from linux.lists import list_for_each_entry generic_pm_domain_type = CachedType('struct generic_pm_domain')
@@ -70,6 +70,8 @@ Output is similar to /sys/kernel/debug/pm_genpd/pm_genpd_summary''' gdb.write(' %-50s %s\n' % (kobj_path, rtpm_status_str(dev))) def invoke(self, arg, from_tty): + if gdb_eval_or_none("&gpd_list") is None: + raise gdb.GdbError("No power domain(s) registered") gdb.write('domain status children\n'); gdb.write(' /device runtime status\n'); gdb.write('----------------------------------------------------------------------\n');
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 214/381 coresight: etm_pmu: Set the module field
In reply to Greg Kroah-HartmanFrom: Suzuki K Poulose <[email protected]>
[ Upstream commit 18996a113f2567aef3057e300e3193ce2df1684c ]
struct pmu::module must be set to the module owning the PMU driver. Set this for the coresight etm_pmu.
--- drivers/hwtracing/coresight/coresight-etm-perf.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwtracing/coresight/coresight-etm-perf.c +1 -0
@@ -619,6 +619,7 @@ int __init etm_perf_init(void) etm_pmu.addr_filters_sync = etm_addr_filters_sync; etm_pmu.addr_filters_validate = etm_addr_filters_validate; etm_pmu.nr_addr_filters =ETM_ADDR_CMP_MAX ; + etm_pmu.module =THIS_MODULE ; ret =perf_pmu_register (&etm_pmu,CORESIGHT_ETM_PMU_NAME ,-1 );if (ret ==0 )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 215/381 ASoC: fsl_mqs: move of_node_put() to the correct location
In reply to Greg Kroah-HartmanFrom: Liliang Ye <[email protected]>
[ Upstream commit 1c34890273a020d61d6127ade3f68ed1cb21c16a ]
of_node_put() should have been done directly after mqs_priv->regmap = syscon_node_to_regmap(gpr_np); otherwise it creates a reference leak on the success path.
To fix this, of_node_put() is moved to the correct location, and change all the gotos to direct returns.
--- sound/soc/fsl/fsl_mqs.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
sound/soc/fsl/fsl_mqs.c +5 -10
@@ -204,10 +204,10 @@ static int fsl_mqs_probe(struct platform_device *pdev) } mqs_priv->regmap =syscon_node_to_regmap (gpr_np); +of_node_put (gpr_np);if (IS_ERR (mqs_priv->regmap)) {dev_err (&pdev->dev,"failed to get gpr regmap\n" ); - ret =PTR_ERR (mqs_priv->regmap); - goto err_free_gpr_np; +return PTR_ERR (mqs_priv->regmap); } }else { regs =devm_platform_ioremap_resource (pdev,0 );
@@ -236,8 +236,7 @@ static int fsl_mqs_probe(struct platform_device *pdev)if (IS_ERR (mqs_priv->mclk)) {dev_err (&pdev->dev,"failed to get the clock: %ld\n" ,PTR_ERR (mqs_priv->mclk)); - ret =PTR_ERR (mqs_priv->mclk); - goto err_free_gpr_np; +return PTR_ERR (mqs_priv->mclk); }dev_set_drvdata (&pdev->dev, mqs_priv);
@@ -246,13 +245,9 @@ static int fsl_mqs_probe(struct platform_device *pdev) ret =devm_snd_soc_register_component (&pdev->dev, &soc_codec_fsl_mqs, &fsl_mqs_dai,1 );if (ret) - goto err_free_gpr_np; -return 0 ; - -err_free_gpr_np: -of_node_put (gpr_np); +return ret; -return ret; +return 0 ; }static int fsl_mqs_remove (struct platform_device *pdev)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 216/381 spi: cadence-quadspi: fix suspend-resume implementations
In reply to Greg Kroah-HartmanFrom: Dhruva Gole <[email protected]>
[ Upstream commit 2087e85bb66ee3652dafe732bb9b9b896229eafc ]
The cadence QSPI driver misbehaves after performing a full system suspend resume:
...
spi-nor spi0.0: resume() failed
...
This results in a flash connected via OSPI interface after system suspend- resume to be unusable.
fix these suspend and resume functions.
--- drivers/spi/spi-cadence-quadspi.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/spi/spi-cadence-quadspi.c +16 -3
@@ -1355,17 +1355,30 @@ static int cqspi_remove(struct platform_device *pdev)static int cqspi_suspend (struct device *dev) {struct cqspi_st *cqspi =dev_get_drvdata (dev); +struct spi_master *master =dev_get_drvdata (dev); +int ret; + ret =spi_master_suspend (master);cqspi_controller_enable (cqspi,0 ); -return 0 ; + +clk_disable_unprepare (cqspi->clk); + +return ret; }static int cqspi_resume (struct device *dev) {struct cqspi_st *cqspi =dev_get_drvdata (dev); +struct spi_master *master =dev_get_drvdata (dev); -cqspi_controller_enable (cqspi,1 ); -return 0 ; +clk_prepare_enable (cqspi->clk); +cqspi_wait_idle (cqspi); +cqspi_controller_init (cqspi); + + cqspi->current_cs =-1 ; + cqspi->sclk =0 ; + +return spi_master_resume (master); }static const struct dev_pm_ops cqspi__dev_pm_ops = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 217/381 i2c: cadence: cdns_i2c_master_xfer(): Fix runtime PM leak on error path
In reply to Greg Kroah-HartmanFrom: Lars-Peter Clausen <[email protected]>
[ Upstream commit ae1664f04f504a998737f5bb563f16b44357bcca ]
The cdns_i2c_master_xfer() function gets a runtime PM reference when the function is entered. This reference is released when the function is exited. There is currently one error path where the function exits directly, which leads to a leak of the runtime PM reference.
Make sure that this error path also releases the runtime PM reference.
--- drivers/i2c/busses/i2c-cadence.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-cadence.c +4 -2
@@ -792,8 +792,10 @@ static int cdns_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,#if IS_ENABLED (CONFIG_I2C_SLAVE )/* Check i2c operating mode and switch if possible */ if (id->dev_mode ==CDNS_I2C_MODE_SLAVE ) { -if (id->slave_state !=CDNS_I2C_SLAVE_STATE_IDLE ) -return -EAGAIN ; +if (id->slave_state !=CDNS_I2C_SLAVE_STATE_IDLE ) { + ret = -EAGAIN ; + goto out; + }/* Set mode to master */ cdns_i2c_set_mode (CDNS_I2C_MODE_MASTER , id);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 218/381 uapi/linux/const.h: prefer ISO-friendly __typeof__
In reply to Greg Kroah-HartmanFrom: Kevin Brodsky <[email protected]>
[ Upstream commit 31088f6f7906253ef4577f6a9b84e2d42447dba0 ]
typeof is (still) a GNU extension, which means that it cannot be used when building ISO C (e.g. -std=c99). It should therefore be avoided in uapi headers in favour of the ISO-friendly __typeof__.
Unfortunately this issue could not be detected by CONFIG_UAPI_HEADER_TEST=y as the __ALIGN_KERNEL() macro is not expanded in any uapi header.
This matters from a userspace perspective, not a kernel one. uapi headers and their contents are expected to be usable in a variety of situations, and in particular when building ISO C applications (with -std=c99 or similar).
This particular problem can be reproduced by trying to use the __ALIGN_KERNEL macro directly in application code, say:
#include <linux/const.h>
int align(int x, int a)
{
return __KERNEL_ALIGN(x, a);
}and trying to build that with -std=c99.
--- include/uapi/linux/const.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/const.h +1 -1
@@ -28,7 +28,7 @@#define _BITUL (x) (_UL(1) << (x))#define _BITULL (x) (_ULL(1) << (x)) -#define __ALIGN_KERNEL (x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) +#define __ALIGN_KERNEL (x, a) __ALIGN_KERNEL_MASK(x, (__typeof__(x))(a) - 1)#define __ALIGN_KERNEL_MASK (x, mask) (((x) + (mask)) & ~(mask))#define __KERNEL_DIV_ROUND_UP (n, d) (((n) + (d) - 1) / (d))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 219/381 sh: sq: Fix incorrect element size for allocating bitmap buffer
In reply to Greg Kroah-HartmanFrom: John Paul Adrian Glaubitz <[email protected]>
[ Upstream commit 80f746e2bd0e1da3fdb49a53570e54a1a225faac ]
The Store Queue code allocates a bitmap buffer with the size of multiple of sizeof(long) in sq_api_init(). While the buffer size is calculated correctly, the code uses the wrong element size to allocate the buffer which results in the allocated bitmap buffer being too small.
Fix this by allocating the buffer with kcalloc() with element size sizeof(long) instead of kzalloc() whose elements size defaults to sizeof(char).
--- arch/sh/kernel/cpu/sh4/sq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sh/kernel/cpu/sh4/sq.c +1 -1
@@ -381,7 +381,7 @@ static int __init sq_api_init(void)if (unlikely (!sq_cache))return ret; - sq_bitmap =kzalloc (size,GFP_KERNEL ); + sq_bitmap =kcalloc (size,sizeof (long ),GFP_KERNEL );if (unlikely (!sq_bitmap)) goto out;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 220/381 usb: gadget: tegra-xudc: Fix crash in vbus_draw
In reply to Greg Kroah-HartmanFrom: Jon Hunter <[email protected]>
[ Upstream commit 5629d31955297ca47b9283c64fff70f2f34aa528 ]
Commit ac82b56bda5f ("usb: gadget: tegra-xudc: Add vbus_draw support") populated the vbus_draw callback for the Tegra XUDC driver. The function tegra_xudc_gadget_vbus_draw(), that was added by this commit, assumes that the pointer 'curr_usbphy' has been initialised, which is not always the case because this is only initialised when the USB role is updated. Fix this crash, by checking that the 'curr_usbphy' is valid before dereferencing.
--- drivers/usb/gadget/udc/tegra-xudc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/tegra-xudc.c +1 -1
@@ -2154,7 +2154,7 @@ static int tegra_xudc_gadget_vbus_draw(struct usb_gadget *gadget,dev_dbg (xudc->dev,"%s: %u mA\n" , __func__, m_a); -if (xudc->curr_usbphy->chg_type ==SDP_TYPE ) +if (xudc->curr_usbphy && xudc->curr_usbphy->chg_type ==SDP_TYPE ) ret =usb_phy_set_power (xudc->curr_usbphy, m_a);return ret;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 221/381 usb: chipidea: fix missing goto in `ci_hdrc_probe`
In reply to Greg Kroah-HartmanFrom: Yinhao Hu <[email protected]>
[ Upstream commit d6f712f53b79f5017cdcefafb7a5aea9ec52da5d ]
Quoted 1 line
From the comment of
ci_usb_phy_init, it returns an error code if
usb_phy_init has failed, and it should do some clean up, not just return directly.
Fix this by goto the error handling.
--- drivers/usb/chipidea/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/chipidea/core.c +1 -1
@@ -1090,7 +1090,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) ret =ci_usb_phy_init (ci);if (ret) {dev_err (dev,"unable to init phy: %d\n" , ret); -return ret; + goto ulpi_exit; } ci->hw_bank.phys = res->start;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 222/381 usb: mtu3: fix kernel panic at qmu transfer done irq handler
In reply to Greg Kroah-HartmanFrom: Chunfeng Yun <[email protected]>
[ Upstream commit d28f4091ea7ec3510fd6a3c6d433234e7a2bef14 ]
When handle qmu transfer irq, it will unlock @mtu->lock before give back request, if another thread handle disconnect event at the same time, and try to disable ep, it may lock @mtu->lock and free qmu ring, then qmu irq hanlder may get a NULL gpd, avoid the KE by checking gpd's value before handling it.
e.g.
qmu done irq on cpu0 thread running on cpu1
qmu_done_tx()
handle gpd [0]
mtu3_requ_complete() mtu3_gadget_ep_disable()
unlock @mtu->lock
give back request lock @mtu->lock
mtu3_ep_disable()
mtu3_gpd_ring_free()
unlock @mtu->lock
lock @mtu->lock
get next gpd [1][1]: goto [0] to handle next gpd, and next gpd may be NULL.
--- drivers/usb/mtu3/mtu3_qmu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/mtu3/mtu3_qmu.c +3 -2
@@ -210,6 +210,7 @@ static struct qmu_gpd *advance_enq_gpd(struct mtu3_gpd_ring *ring)return ring->enqueue; } +/* @dequeue may be NULL if ring is unallocated or freed */ static struct qmu_gpd *advance_deq_gpd (struct mtu3_gpd_ring *ring) {if (ring->dequeue < ring->end)
@@ -484,7 +485,7 @@ static void qmu_done_tx(struct mtu3 *mtu, u8 epnum)dev_dbg (mtu->dev,"%s EP%d, last=%p, current=%p, enq=%p\n" , __func__, epnum, gpd, gpd_current, ring->enqueue); -while (gpd != gpd_current && !GET_GPD_HWO (gpd)) { +while (gpd && gpd != gpd_current && !GET_GPD_HWO (gpd)) { mreq =next_request (mep);
@@ -523,7 +524,7 @@ static void qmu_done_rx(struct mtu3 *mtu, u8 epnum)dev_dbg (mtu->dev,"%s EP%d, last=%p, current=%p, enq=%p\n" , __func__, epnum, gpd, gpd_current, ring->enqueue); -while (gpd != gpd_current && !GET_GPD_HWO (gpd)) { +while (gpd && gpd != gpd_current && !GET_GPD_HWO (gpd)) { mreq =next_request (mep);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 223/381 firmware: stratix10-svc: Fix an NULL vs IS_ERR() bug in probe
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit e1d6ca042e62c2a69513235f8629eb6e62ca79c5 ]
The svc_create_memory_pool() function returns error pointers. It never returns NULL. Fix the check.
--- drivers/firmware/stratix10-svc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/stratix10-svc.c +2 -2
@@ -989,8 +989,8 @@ static int stratix10_svc_drv_probe(struct platform_device *pdev)return ret; genpool =svc_create_memory_pool (pdev, sh_memory); -if (!genpool) -return -ENOMEM ; +if (IS_ERR (genpool)) +return PTR_ERR (genpool);/* allocate service controller and supporting channel */ controller =devm_kzalloc (dev,sizeof (*controller),GFP_KERNEL );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 224/381 tty: serial: fsl_lpuart: adjust buffer length to the intended size
In reply to Greg Kroah-HartmanFrom: Shenwei Wang <[email protected]>
[ Upstream commit f73fd750552524b06b5d77ebfdd106ccc8fcac61 ]
Based on the fls function definition provided below, we should not subtract 1 to obtain the correct buffer length:
fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
--- drivers/tty/serial/fsl_lpuart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/fsl_lpuart.c +1 -1
@@ -1220,7 +1220,7 @@ static inline int lpuart_start_rx_dma(struct lpuart_port *sport)* 10ms at any baud rate. */ sport->rx_dma_rng_buf_len = (DMA_RX_TIMEOUT * baud / bits /1000 ) *2 ; - sport->rx_dma_rng_buf_len = (1 << (fls (sport->rx_dma_rng_buf_len) -1 )); + sport->rx_dma_rng_buf_len = (1 <<fls (sport->rx_dma_rng_buf_len));if (sport->rx_dma_rng_buf_len <16 ) sport->rx_dma_rng_buf_len =16 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 225/381 serial: 8250: Add missing wakeup event reporting
In reply to Greg Kroah-HartmanFrom: Florian Fainelli <[email protected]>
[ Upstream commit 0ba9e3a13c6adfa99e32b2576d20820ab10ad48a ]
An 8250 UART configured as a wake-up source would not have reported itself through sysfs as being the source of wake-up, correct that.
--- drivers/tty/serial/8250/8250_port.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/tty/serial/8250/8250_port.c +4 -0
@@ -15,6 +15,7 @@#include <linux/moduleparam.h> #include <linux/ioport.h> #include <linux/init.h> +#include <linux/irq.h> #include <linux/console.h> #include <linux/gpio/consumer.h> #include <linux/sysrq.h>
@@ -1889,6 +1890,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)unsigned char status;unsigned long flags;struct uart_8250_port *up =up_to_u8250p (port); +struct tty_port *tport = &port->state->port;bool skip_rx = false;if (iir &UART_IIR_NO_INT )
@@ -1912,6 +1914,8 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) skip_rx = true;if (status & (UART_LSR_DR |UART_LSR_BI ) && !skip_rx) { +if (irqd_is_wakeup_set (irq_get_irq_data (port->irq))) +pm_wakeup_event (tport->tty->dev,0 );if (!up->dma ||handle_rx_dma (up, iir)) status =serial8250_rx_chars (up, status); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 226/381 staging: rtl8192e: Fix W_DISABLE# does not work after stop/start
In reply to Greg Kroah-HartmanFrom: Philipp Hortmann <[email protected]>
[ Upstream commit 3fac2397f562eb669ddc2f45867a253f3fc26184 ]
When loading the driver for rtl8192e, the W_DISABLE# switch is working as intended. But when the WLAN is turned off in software and then turned on again the W_DISABLE# does not work anymore. Reason for this is that in the function _rtl92e_dm_check_rf_ctrl_gpio() the bfirst_after_down is checked and returned when true. bfirst_after_down is set true when switching the WLAN off in software. But it is not set to false again when WLAN is turned on again.
Add bfirst_after_down = false in _rtl92e_sta_up to reset bit and fix above described bug.
--- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/rtl8192e/rtl8192e/rtl_core.c +1 -0
@@ -770,6 +770,7 @@ static int _rtl92e_sta_up(struct net_device *dev, bool is_silent_reset)else netif_wake_queue (dev); + priv->bfirst_after_down = false;return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 227/381 spmi: Add a check for remove callback when removing a SPMI driver
In reply to Greg Kroah-HartmanFrom: Jishnu Prakash <[email protected]>
[ Upstream commit b56eef3e16d888883fefab47425036de80dd38fc ]
When removing a SPMI driver, there can be a crash due to NULL pointer dereference if it does not have a remove callback defined. This is one such call trace observed when removing the QCOM SPMI PMIC driver:
dump_backtrace.cfi_jt+0x0/0x8 dump_stack_lvl+0xd8/0x16c panic+0x188/0x498 __cfi_slowpath+0x0/0x214 __cfi_slowpath+0x1dc/0x214 spmi_drv_remove+0x16c/0x1e0 device_release_driver_internal+0x468/0x79c driver_detach+0x11c/0x1a0 bus_remove_driver+0xc4/0x124 driver_unregister+0x58/0x84 cleanup_module+0x1c/0xc24 [qcom_spmi_pmic] __do_sys_delete_module+0x3ec/0x53c __arm64_sys_delete_module+0x18/0x28 el0_svc_common+0xdc/0x294 el0_svc+0x38/0x9c el0_sync_handler+0x8c/0xf0 el0_sync+0x1b4/0x1c0
If a driver has all its resources allocated through devm_() APIs and does not need any other explicit cleanup, it would not require a remove callback to be defined. Hence, add a check for remove callback presence before calling it when removing a SPMI driver.
--- drivers/spmi/spmi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spmi/spmi.c +2 -1
@@ -348,7 +348,8 @@ static int spmi_drv_remove(struct device *dev)const struct spmi_driver *sdrv =to_spmi_driver (dev->driver);pm_runtime_get_sync (dev); - sdrv->remove (to_spmi_device (dev)); +if (sdrv->remove) + sdrv->remove (to_spmi_device (dev));pm_runtime_put_noidle (dev);pm_runtime_disable (dev);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 228/381 macintosh/windfarm_smu_sat: Add missing of_node_put()
In reply to Greg Kroah-HartmanFrom: Liang He <[email protected]>
[ Upstream commit 631cf002826007ab7415258ee647dcaf8845ad5a ]
We call of_node_get() in wf_sat_probe() after sat is created, so we need the of_node_put() before *kfree(sat)*.
--- drivers/macintosh/windfarm_smu_sat.c | 1 + 1 file changed, 1 insertion(+)
drivers/macintosh/windfarm_smu_sat.c +1 -0
@@ -171,6 +171,7 @@ static void wf_sat_release(struct kref *ref)if (sat->nr >=0 ) sats[sat->nr] =NULL ; +of_node_put (sat->node);kfree (sat); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 229/381 powerpc/mpc512x: fix resource printk format warning
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 7538c97e2b80ff6b7a8ea2ecf16a04355461b439 ]
Use "%pa" format specifier for resource_size_t to avoid a compiler printk format warning.
../arch/powerpc/platforms/512x/clock-commonclk.c: In function 'mpc5121_clk_provide_backwards_compat':../arch/powerpc/platforms/512x/clock-commonclk.c:989:44: error: format '%x' expects argument of type 'unsigned int', but argument 4 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=]
989 | snprintf(devname, sizeof(devname), "%08x.%s", res.start, np->name); \
| ^~~~~~~~~ ~~~~~~~~~
| |
| resource_size_t {aka long long unsigned int}Prevents 24 such warnings.
--- arch/powerpc/platforms/512x/clock-commonclk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/512x/clock-commonclk.c +1 -1
@@ -984,7 +984,7 @@ static void mpc5121_clk_provide_migration_support(void)#define NODE_PREP do { \ of_address_to_resource(np, 0, &res); \ - snprintf(devname, sizeof(devname), "%08x.%s", res.start, np->name); \ + snprintf(devname, sizeof(devname), "%pa.%s", &res.start, np->name); \ } while (0)#define NODE_CHK (clkname, clkitem, regnode, regflag) do { \
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 230/381 powerpc/wii: fix resource printk format warnings
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 7b69600d4da0049244e9be2f5ef5a2f8e04fcd9a ]
Use "%pa" format specifier for resource_size_t to avoid compiler printk format warnings.
../arch/powerpc/platforms/embedded6xx/flipper-pic.c: In function 'flipper_pic_init':../include/linux/kern_levels.h:5:25: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=] ../arch/powerpc/platforms/embedded6xx/flipper-pic.c:148:9: note: in expansion of macro 'pr_info'
148 | pr_info("controller at 0x%08x mapped to 0x%p\n", res.start, io_base);
| ^~~~~~~../arch/powerpc/platforms/embedded6xx/hlwd-pic.c: In function 'hlwd_pic_init':../include/linux/kern_levels.h:5:25: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=] ../arch/powerpc/platforms/embedded6xx/hlwd-pic.c:174:9: note: in expansion of macro 'pr_info'
174 | pr_info("controller at 0x%08x mapped to 0x%p\n", res.start, io_base);
| ^~~~~~~../arch/powerpc/platforms/embedded6xx/wii.c: In function 'wii_ioremap_hw_regs':../include/linux/kern_levels.h:5:25: error: format '%x' expects argument of type 'unsigned int', but argument 3 has type 'resource_size_t' {aka 'long long unsigned int'} [-Werror=format=] ../arch/powerpc/platforms/embedded6xx/wii.c:77:17: note: in expansion of macro 'pr_info'
77 | pr_info("%s at 0x%08x mapped to 0x%p\n", name,
| ^~~~~~~--- arch/powerpc/platforms/embedded6xx/flipper-pic.c | 2 +- arch/powerpc/platforms/embedded6xx/hlwd-pic.c | 2 +- arch/powerpc/platforms/embedded6xx/wii.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
arch/powerpc/platforms/embedded6xx/flipper-pic.c +1 -1
@@ -144,7 +144,7 @@ static struct irq_domain * __init flipper_pic_init(struct device_node *np) } io_base =ioremap (res.start,resource_size (&res)); -pr_info ("controller at 0x%08x mapped to 0x%p\n" , res.start, io_base); +pr_info ("controller at 0x%pa mapped to 0x%p\n" , &res.start, io_base);__flipper_quiesce (io_base);
arch/powerpc/platforms/embedded6xx/hlwd-pic.c +1 -1
@@ -173,7 +173,7 @@ static struct irq_domain *hlwd_pic_init(struct device_node *np)return NULL ; } -pr_info ("controller at 0x%08x mapped to 0x%p\n" , res.start, io_base); +pr_info ("controller at 0x%pa mapped to 0x%p\n" , &res.start, io_base);__hlwd_quiesce (io_base);
arch/powerpc/platforms/embedded6xx/wii.c +2 -2
@@ -89,8 +89,8 @@ static void __iomem *wii_ioremap_hw_regs(char *name, char *compatible) hw_regs =ioremap (res.start,resource_size (&res));if (hw_regs) { -pr_info ("%s at 0x%08x mapped to 0x%p\n" , name, - res.start, hw_regs); +pr_info ("%s at 0x%pa mapped to 0x%p\n" , name, + &res.start, hw_regs); } out_put:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 231/381 powerpc/sysdev/tsi108: fix resource printk format warnings
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 55d8bd02cc1b9f1063993b5c42c9cabf4af67dea ]
Use "%pa" format specifier for resource_size_t to avoid a compiler printk format warning.
arch/powerpc/sysdev/tsi108_pci.c: In function 'tsi108_setup_pci':
include/linux/kern_levels.h:5:25: error: format '%x' expects argument of type 'unsigned int', but argument 2 has type 'resource_size_t'
--- arch/powerpc/sysdev/tsi108_pci.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/powerpc/sysdev/tsi108_pci.c +2 -3
@@ -216,9 +216,8 @@ int __init tsi108_setup_pci(struct device_node *dev, u32 cfg_phys, int primary) (hose)->ops = &tsi108_direct_pci_ops; -printk (KERN_INFO "Found tsi108 PCI host bridge at 0x%08x. " -"Firmware bus number: %d->%d\n" , - rsrc.start, hose->first_busno, hose->last_busno); +pr_info ("Found tsi108 PCI host bridge at 0x%pa. Firmware bus number: %d->%d\n" , + &rsrc.start, hose->first_busno, hose->last_busno);/* Interpret the "ranges" property */ /* This also maps the I/O region and sets isa_io/mem_base */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 232/381 macintosh: via-pmu-led: requires ATA to be set
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 05dce4ba125336875cd3eed3c1503fa81cd2f691 ]
LEDS_TRIGGER_DISK depends on ATA, so selecting LEDS_TRIGGER_DISK when ATA is not set/enabled causes a Kconfig warning:
WARNING: unmet direct dependencies detected for LEDS_TRIGGER_DISK
Depends on [n]: NEW_LEDS [=y] && LEDS_TRIGGERS [=y] && ATA [=n]
Selected by [y]:
- ADB_PMU_LED_DISK [=y] && MACINTOSH_DRIVERS [=y] && ADB_PMU_LED [=y] && LEDS_CLASS [=y]
Fix this by making ADB_PMU_LED_DISK depend on ATA.
Seen on both PPC32 and PPC64.
--- drivers/macintosh/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/macintosh/Kconfig +1 -0
@@ -86,6 +86,7 @@ config ADB_PMU_LED config ADB_PMU_LED_DISK bool "Use front LED as DISK LED by default" + depends on ATA depends on ADB_PMU_LED depends on LEDS_CLASS select LEDS_TRIGGERS
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 233/381 powerpc/rtas: use memmove for potentially overlapping buffer copy
In reply to Greg Kroah-HartmanFrom: Nathan Lynch <[email protected]>
[ Upstream commit 271208ee5e335cb1ad280d22784940daf7ddf820 ]
Using memcpy() isn't safe when buf is identical to rtas_err_buf, which can happen during boot before slab is up. Full context which may not be obvious from the diff:
if (altbuf) {
buf = altbuf;
} else {
buf = rtas_err_buf;
if (slab_is_available())
buf = kmalloc(RTAS_ERROR_LOG_MAX, GFP_ATOMIC);
}
if (buf)
memcpy(buf, rtas_err_buf, RTAS_ERROR_LOG_MAX);This was found by inspection and I'm not aware of it causing problems in practice. It appears to have been introduced by commit 033ef338b6e0 ("powerpc: Merge rtas.c into arch/powerpc/kernel"); the old ppc64 version of this code did not have this problem.
Use memmove() instead.
--- arch/powerpc/kernel/rtas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/rtas.c +1 -1
@@ -399,7 +399,7 @@ static char *__fetch_rtas_last_error(char *altbuf) buf =kmalloc (RTAS_ERROR_LOG_MAX ,GFP_ATOMIC ); }if (buf) -memcpy (buf, rtas_err_buf,RTAS_ERROR_LOG_MAX ); +memmove (buf, rtas_err_buf,RTAS_ERROR_LOG_MAX ); }return buf;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 234/381 perf/core: Fix hardlockup failure caused by perf throttle
In reply to Greg Kroah-HartmanFrom: Yang Jihong <[email protected]>
[ Upstream commit 15def34e2635ab7e0e96f1bc32e1b69609f14942 ]
commit e050e3f0a71bf ("perf: Fix broken interrupt rate throttling") introduces a change in throttling threshold judgment. Before this, compare hwc->interrupts and max_samples_per_tick, then increase hwc->interrupts by 1, but this commit reverses order of these two behaviors, causing the semantics of max_samples_per_tick to change. In literal sense of "max_samples_per_tick", if hwc->interrupts == max_samples_per_tick, it should not be throttled, therefore, the judgment condition should be changed to "hwc->interrupts > max_samples_per_tick".
In fact, this may cause the hardlockup to fail, The minimum value of max_samples_per_tick may be 1, in this case, the return value of __perf_event_account_interrupt function is 1.
As a result, nmi_watchdog gets throttled, which would stop PMU (Use x86 architecture as an example, see x86_pmu_handle_irq).
--- kernel/events/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/events/core.c +2 -2
@@ -8925,8 +8925,8 @@ __perf_event_account_interrupt(struct perf_event *event, int throttle) hwc->interrupts =1 ; }else { hwc->interrupts++; -if (unlikely (throttle - && hwc->interrupts >= max_samples_per_tick)) { +if (unlikely (throttle && + hwc->interrupts > max_samples_per_tick)) {__this_cpu_inc (perf_throttled_count);tick_dep_set_cpu (smp_processor_id (),TICK_DEP_BIT_PERF_EVENTS ); hwc->interrupts =MAX_INTERRUPTS ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 235/381 clk: at91: clk-sam9x60-pll: fix return value check
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 1bd8e27fd0db0fe7f489213836dcbab92934f8fa ]
sam9x60_frac_pll_compute_mul_frac() can't return zero. Remove the check against zero to reflect this.
--- drivers/clk/at91/clk-sam9x60-pll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/at91/clk-sam9x60-pll.c +1 -1
@@ -452,7 +452,7 @@ sam9x60_clk_register_frac_pll(struct regmap *regmap, spinlock_t *lock, ret =sam9x60_frac_pll_compute_mul_frac (&frac->core,FCORE_MIN , parent_rate, true); -if (ret <=0 ) { +if (ret <0 ) { hw =ERR_PTR (ret); goto free; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 236/381 RDMA/siw: Fix potential page_array out of range access
In reply to Greg Kroah-HartmanFrom: Daniil Dulov <[email protected]>
[ Upstream commit 271bfcfb83a9f77cbae3d6e1a16e3c14132922f0 ]
When seg is equal to MAX_ARRAY, the loop should break, otherwise it will result in out of range access.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/infiniband/sw/siw/siw_qp_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/siw/siw_qp_tx.c +1 -1
@@ -548,7 +548,7 @@ static int siw_tx_hdt(struct siw_iwarp_tx *c_tx, struct socket *s) data_len -= plen; fp_off =0 ; -if (++seg > (int )MAX_ARRAY ) { +if (++seg >= (int )MAX_ARRAY ) {siw_dbg_qp (tx_qp (c_tx),"to many fragments\n" );siw_unmap_pages (page_array, kmap_mask); wqe->processed -= c_tx->bytes_unsent;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 237/381 RDMA/rdmavt: Delete unnecessary NULL check
In reply to Greg Kroah-HartmanFrom: Natalia Petrova <[email protected]>
[ Upstream commit b73a0b80c69de77d8d4942abb37066531c0169b2 ]
There is no need to check 'rdi->qp_dev' for NULL. The field 'qp_dev' is created in rvt_register_device() which will fail if the 'qp_dev' allocation fails in rvt_driver_qp_init(). Overwise this pointer doesn't changed and passed to rvt_qp_exit() by the next step.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/infiniband/sw/rdmavt/qp.c | 2 -- 1 file changed, 2 deletions(-)
drivers/infiniband/sw/rdmavt/qp.c +0 -2
@@ -505,8 +505,6 @@ void rvt_qp_exit(struct rvt_dev_info *rdi)if (qps_inuse)rvt_pr_err (rdi,"QP memory leak! %u still in use\n" , qps_inuse); -if (!rdi->qp_dev) -return ;kfree (rdi->qp_dev->qp_table);free_qpn_table (&rdi->qp_dev->qpn_table);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 238/381 workqueue: Rename "delayed" (delayed by active management) to "inactive"
In reply to Greg Kroah-HartmanFrom: Lai Jiangshan <[email protected]>
[ Upstream commit f97a4a1a3f8769e3452885967955e21c88f3f263 ]
There are two kinds of "delayed" work items in workqueue subsystem.
One is for timer-delayed work items which are visible to workqueue users. The other kind is for work items delayed by active management which can not be directly visible to workqueue users. We mixed the word "delayed" for both kinds and caused somewhat ambiguity.
This patch renames the later one (delayed by active management) to "inactive", because it is used for workqueue active management and most of its related symbols are named with "active" or "activate".
All "delayed" and "DELAYED" are carefully checked and renamed one by one to avoid accidentally changing the name of the other kind for timer-delayed.
No functional change intended.
Stable-dep-of: 335a42ebb0ca ("workqueue: Fix hung time report of worker pools")
--- include/linux/workqueue.h | 4 +-- kernel/workqueue.c | 58 +++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 31 deletions(-)
include/linux/workqueue.h +2 -2
@@ -29,7 +29,7 @@ void delayed_work_timer_fn(struct timer_list *t);enum {WORK_STRUCT_PENDING_BIT =0 ,/* work item is pending execution */ -WORK_STRUCT_DELAYED_BIT =1 ,/* work item is delayed */ +WORK_STRUCT_INACTIVE_BIT =1 ,/* work item is inactive */ WORK_STRUCT_PWQ_BIT =2 ,/* data points to pwq */ WORK_STRUCT_LINKED_BIT =3 ,/* next work is linked to this one */ #ifdef CONFIG_DEBUG_OBJECTS_WORK
@@ -42,7 +42,7 @@ enum {WORK_STRUCT_COLOR_BITS =4 ,WORK_STRUCT_PENDING =1 <<WORK_STRUCT_PENDING_BIT , -WORK_STRUCT_DELAYED =1 <<WORK_STRUCT_DELAYED_BIT , +WORK_STRUCT_INACTIVE =1 <<WORK_STRUCT_INACTIVE_BIT ,WORK_STRUCT_PWQ =1 <<WORK_STRUCT_PWQ_BIT ,WORK_STRUCT_LINKED =1 <<WORK_STRUCT_LINKED_BIT , #ifdef CONFIG_DEBUG_OBJECTS_WORK
kernel/workqueue.c +29 -29
174 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 239/381 workqueue: Fix hung time report of worker pools
In reply to Greg Kroah-HartmanFrom: Petr Mladek <[email protected]>
[ Upstream commit 335a42ebb0ca8ee9997a1731aaaae6dcd704c113 ]
The workqueue watchdog prints a warning when there is no progress in a worker pool. Where the progress means that the pool started processing a pending work item.
Note that it is perfectly fine to process work items much longer. The progress should be guaranteed by waking up or creating idle workers.
show_one_worker_pool() prints state of non-idle worker pool. It shows a delay since the last pool->watchdog_ts.
The timestamp is updated when a first pending work is queued in __queue_work(). Also it is updated when a work is dequeued for processing in worker_thread() and rescuer_thread().
The delay is misleading when there is no pending work item. In this case it shows how long the last work item is being proceed. Show zero instead. There is no stall if there is no pending work.
--- kernel/workqueue.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
kernel/workqueue.c +6 -3
@@ -4816,16 +4816,19 @@ void show_workqueue_state(void)for_each_pool (pool, pi) {struct worker *worker;bool first = true; +unsigned long hung =0 ;raw_spin_lock_irqsave (&pool->lock, flags);if (pool->nr_workers == pool->nr_idle) goto next_pool; +/* How long the first pending work is waiting for a worker. */ +if (!list_empty (&pool->worklist)) + hung =jiffies_to_msecs (jiffies - pool->watchdog_ts) /1000 ; +pr_info ("pool %d:" , pool->id);pr_cont_pool_info (pool); -pr_cont (" hung=%us workers=%d" , -jiffies_to_msecs (jiffies - pool->watchdog_ts) /1000 , - pool->nr_workers); +pr_cont (" hung=%lus workers=%d" , hung, pool->nr_workers);if (pool->manager)pr_cont (" manager: %d" ,task_pid_nr (pool->manager->task));
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 240/381 rtc: omap: include header for omap_rtc_power_off_program prototype
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit f69c2b5420497b7a54181ce170d682cbeb1f119f ]
Non-static functions should have a prototype:
drivers/rtc/rtc-omap.c:410:5: error: no previous prototype for ‘omap_rtc_power_off_program’ [-Werror=missing-prototypes]
--- drivers/rtc/rtc-omap.c | 1 + 1 file changed, 1 insertion(+)
drivers/rtc/rtc-omap.c +1 -0
@@ -25,6 +25,7 @@#include <linux/platform_device.h> #include <linux/pm_runtime.h> #include <linux/rtc.h> +#include <linux/rtc/rtc-omap.h> /* * The OMAP RTC is a year/month/day/hours/minutes/seconds BCD clock
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 241/381 RDMA/mlx4: Prevent shift wrapping in set_user_sq_size()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit d50b3c73f1ac20dabc53dc6e9d64ce9c79a331eb ]
The ucmd->log_sq_bb_count variable is controlled by the user so this shift can wrap. Fix it by using check_shl_overflow() in the same way that it was done in commit 515f60004ed9 ("RDMA/hns: Prevent undefined behavior in hns_roce_set_user_sq_size()").
--- drivers/infiniband/hw/mlx4/qp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mlx4/qp.c +6 -2
@@ -412,9 +412,13 @@ static int set_user_sq_size(struct mlx4_ib_dev *dev,struct mlx4_ib_qp *qp, struct mlx4_ib_create_qp *ucmd) { + u32 cnt; +/* Sanity check SQ size before proceeding */ -if ((1 << ucmd->log_sq_bb_count) > dev->dev->caps.max_wqes || - ucmd->log_sq_stride > +if (check_shl_overflow (1 , ucmd->log_sq_bb_count, &cnt) || + cnt > dev->dev->caps.max_wqes) +return -EINVAL ; +if (ucmd->log_sq_stride >ilog2 (roundup_pow_of_two (dev->dev->caps.max_sq_desc_sz)) || ucmd->log_sq_stride <MLX4_IB_MIN_SQ_STRIDE )return -EINVAL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 242/381 rtc: meson-vrtc: Use ktime_get_real_ts64() to get the current time
In reply to Greg Kroah-HartmanFrom: Martin Blumenstingl <[email protected]>
[ Upstream commit 0e6255fa3f649170da6bd1a544680589cfae1131 ]
The VRTC alarm register can be programmed with an amount of seconds after which the SoC will be woken up by the VRTC timer again. We are already converting the alarm time from meson_vrtc_set_alarm() to "seconds since 1970". This means we also need to use "seconds since 1970" for the current time.
This fixes a problem where setting the alarm to one minute in the future results in the firmware (which handles wakeup) to output (on the serial console) that the system will be woken up in billions of seconds. ktime_get_raw_ts64() returns the time since boot, not since 1970. Switch to ktime_get_real_ts64() to fix the calculation of the alarm time and to make the SoC wake up at the specified date/time. Also the firmware (which manages suspend) now prints either 59 or 60 seconds until wakeup (depending on how long it takes for the system to enter suspend).
--- drivers/rtc/rtc-meson-vrtc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-meson-vrtc.c +2 -2
@@ -23,7 +23,7 @@ static int meson_vrtc_read_time(struct device *dev, struct rtc_time *tm)struct timespec64 time;dev_dbg (dev,"%s\n" , __func__); -ktime_get_raw_ts64 (&time); +ktime_get_real_ts64 (&time);rtc_time64_to_tm (time.tv_sec, tm);return 0 ;
@@ -96,7 +96,7 @@ static int __maybe_unused meson_vrtc_suspend(struct device *dev)long alarm_secs;struct timespec64 time; -ktime_get_raw_ts64 (&time); +ktime_get_real_ts64 (&time); local_time = time.tv_sec; dev_dbg(dev, "alarm_time = %lus, local_time=%lus\n",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 243/381 power: supply: generic-adc-battery: fix unit scaling
In reply to Greg Kroah-HartmanFrom: Sebastian Reichel <[email protected]>
[ Upstream commit 44263f50065969f2344808388bd589740f026167 ]
power-supply properties are reported in µV, µA and µW. The IIO API provides mV, mA, mW, so the values need to be multiplied by 1000.
--- drivers/power/supply/generic-adc-battery.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/power/supply/generic-adc-battery.c +3 -0
@@ -138,6 +138,9 @@ static int read_channel(struct gab *adc_bat, enum power_supply_property psp, result);if (ret <0 )pr_err ("read channel error\n" ); +else + *result *=1000 ; +return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 244/381 clk: add missing of_node_put() in "assigned-clocks" property parsing
In reply to Greg Kroah-HartmanFrom: Clément Léger <[email protected]>
[ Upstream commit 27a6e1b09a782517fddac91259970ac466a3f7b6 ]
When returning from of_parse_phandle_with_args(), the np member of the of_phandle_args structure should be put after usage. Add missing of_node_put() calls in both __set_clk_parents() and __set_clk_rates().
--- drivers/clk/clk-conf.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/clk/clk-conf.c +10 -2
@@ -33,9 +33,12 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier)else return rc; } -if (clkspec.np == node && !clk_supplier) +if (clkspec.np == node && !clk_supplier) { +of_node_put (clkspec.np);return 0 ; + } pclk =of_clk_get_from_provider (&clkspec); +of_node_put (clkspec.np);if (IS_ERR (pclk)) {if (PTR_ERR (pclk) != -EPROBE_DEFER ) pr_warn("clk: couldn't get parent clock %d for %pOF\n",
@@ -48,10 +51,12 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier)if (rc <0 ) goto err;if (clkspec.np == node && !clk_supplier) { +of_node_put (clkspec.np); rc =0 ; goto err; } clk =of_clk_get_from_provider (&clkspec); +of_node_put (clkspec.np);if (IS_ERR (clk)) {if (PTR_ERR (clk) != -EPROBE_DEFER ) pr_warn("clk: couldn't get assigned clock %d for %pOF\n",
@@ -93,10 +98,13 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier)else return rc; } -if (clkspec.np == node && !clk_supplier) +if (clkspec.np == node && !clk_supplier) { +of_node_put (clkspec.np);return 0 ; + } clk =of_clk_get_from_provider (&clkspec); +of_node_put (clkspec.np);if (IS_ERR (clk)) {if (PTR_ERR (clk) != -EPROBE_DEFER ) pr_warn("clk: couldn't get clock %d for %pOF\n",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 245/381 RDMA/siw: Remove namespace check from siw_netdev_event()
In reply to Greg Kroah-HartmanFrom: Tetsuo Handa <[email protected]>
[ Upstream commit 266e9b3475ba82212062771fdbc40be0e3c06ec8 ]
syzbot is reporting that siw_netdev_event(NETDEV_UNREGISTER) cannot destroy siw_device created after unshare(CLONE_NEWNET) due to net namespace check. It seems that this check was by error there and should be removed.
--- drivers/infiniband/sw/siw/siw_main.c | 3 --- 1 file changed, 3 deletions(-)
drivers/infiniband/sw/siw/siw_main.c +0 -3
@@ -458,9 +458,6 @@ static int siw_netdev_event(struct notifier_block *nb, unsigned long event,dev_dbg (&netdev->dev,"siw: event %lu\n" , event); -if (dev_net (netdev) != &init_net) -return NOTIFY_OK ; - base_dev =ib_device_get_by_netdev (netdev,RDMA_DRIVER_SIW );if (!base_dev)return NOTIFY_OK ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 246/381 RDMA/cm: Trace icm_send_rej event before the cm state is reset
In reply to Greg Kroah-HartmanFrom: Mark Zhang <[email protected]>
[ Upstream commit bd9de1badac7e4ff6780365d4aa38983f5e2a436 ]
Trace icm_send_rej event before the cm state is reset to idle, so that correct cm state will be logged. For example when an incoming request is rejected, the old trace log was:
icm_send_rej: local_id=961102742 remote_id=3829151631 state=IDLE reason=REJ_CONSUMER_DEFINED
With this patch:
icm_send_rej: local_id=312971016 remote_id=3778819983 state=MRA_REQ_SENT reason=REJ_CONSUMER_DEFINED--- drivers/infiniband/core/cm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/core/cm.c +2 -1
@@ -2924,6 +2924,8 @@ static int cm_send_rej_locked(struct cm_id_private *cm_id_priv, (ari && ari_length > IB_CM_REJ_ARI_LENGTH))return -EINVAL ; +trace_icm_send_rej (&cm_id_priv->id, reason); +switch (state) {case IB_CM_REQ_SENT :case IB_CM_MRA_REQ_RCVD :
@@ -2954,7 +2956,6 @@ static int cm_send_rej_locked(struct cm_id_private *cm_id_priv,return -EINVAL ; } -trace_icm_send_rej (&cm_id_priv->id, reason); ret =ib_post_send_mad (msg,NULL );if (ret) {cm_free_msg (msg);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 247/381 RDMA/srpt: Add a check for valid mad_agent pointer
In reply to Greg Kroah-HartmanFrom: Saravanan Vajravel <[email protected]>
[ Upstream commit eca5cd9474cd26d62f9756f536e2e656d3f62f3a ]
When unregistering MAD agent, srpt module has a non-null check for 'mad_agent' pointer before invoking ib_unregister_mad_agent(). This check can pass if 'mad_agent' variable holds an error value. The 'mad_agent' can have an error value for a short window when srpt_add_one() and srpt_remove_one() is executed simultaneously.
In srpt module, added a valid pointer check for 'sport->mad_agent' before unregistering MAD agent.
This issue can hit when RoCE driver unregisters ib_device
Stack Trace:
------------
BUG: kernel NULL pointer dereference, address: 000000000000004d PGD 145003067 P4D 145003067 PUD 2324fe067 PMD 0 Oops: 0002 [#1] PREEMPT SMP NOPTI CPU: 10 PID: 4459 Comm: kworker/u80:0 Kdump: loaded Tainted: P Hardware name: Dell Inc. PowerEdge R640/06NR82, BIOS 2.5.4 01/13/2020 Workqueue: bnxt_re bnxt_re_task [bnxt_re] RIP: 0010:_raw_spin_lock_irqsave+0x19/0x40 Call Trace: ib_unregister_mad_agent+0x46/0x2f0 [ib_core] IPv6: ADDRCONF(NETDEV_CHANGE): bond0: link becomes ready ? __schedule+0x20b/0x560 srpt_unregister_mad_agent+0x93/0xd0 [ib_srpt] srpt_remove_one+0x20/0x150 [ib_srpt] remove_client_context+0x88/0xd0 [ib_core] bond0: (slave p2p1): link status definitely up, 100000 Mbps full duplex disable_device+0x8a/0x160 [ib_core] bond0: active interface up! ? kernfs_name_hash+0x12/0x80 (NULL device *): Bonding Info Received: rdev: 000000006c0b8247 __ib_unregister_device+0x42/0xb0 [ib_core] (NULL device *): Master: mode: 4 num_slaves:2 ib_unregister_device+0x22/0x30 [ib_core] (NULL device *): Slave: id: 105069936 name:p2p1 link:0 state:0 bnxt_re_stopqps_and_ib_uninit+0x83/0x90 [bnxt_re] bnxt_re_alloc_lag+0x12e/0x4e0 [bnxt_re]
--- drivers/infiniband/ulp/srpt/ib_srpt.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/infiniband/ulp/srpt/ib_srpt.c +13 -10
@@ -549,6 +549,7 @@ static int srpt_format_guid(char *buf, unsigned int size, const __be64 *guid)*/ static int srpt_refresh_port (struct srpt_port *sport) { +struct ib_mad_agent *mad_agent;struct ib_mad_reg_req reg_req;struct ib_port_modify port_modify;struct ib_port_attr port_attr;
@@ -593,24 +594,26 @@ static int srpt_refresh_port(struct srpt_port *sport)set_bit (IB_MGMT_METHOD_GET , reg_req.method_mask);set_bit (IB_MGMT_METHOD_SET , reg_req.method_mask); - sport->mad_agent =ib_register_mad_agent (sport->sdev->device, - sport->port, -IB_QPT_GSI , - ®_req,0 , - srpt_mad_send_handler, - srpt_mad_recv_handler, - sport,0 ); -if (IS_ERR (sport->mad_agent)) { + mad_agent =ib_register_mad_agent (sport->sdev->device, + sport->port, +IB_QPT_GSI , + ®_req,0 , + srpt_mad_send_handler, + srpt_mad_recv_handler, + sport,0 ); +if (IS_ERR (mad_agent)) {pr_err ("%s-%d: MAD agent registration failed (%ld). Note: this is expected if SR-IOV is enabled.\n" ,dev_name (&sport->sdev->device->dev), sport->port, -PTR_ERR (sport->mad_agent)); +PTR_ERR (mad_agent)); sport->mad_agent =NULL ;memset (&port_modify,0 ,sizeof (port_modify)); port_modify.clr_port_cap_mask =IB_PORT_DEVICE_MGMT_SUP ;ib_modify_port (sport->sdev->device, sport->port,0 , &port_modify); - +return 0 ; } + + sport->mad_agent = mad_agent; }return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 248/381 IB/hfi1: Fix SDMA mmu_rb_node not being evicted in LRU order
In reply to Greg Kroah-HartmanFrom: Patrick Kelsey <[email protected]>
[ Upstream commit 9fe8fec5e43d5a80f43cbf61aaada1b047a1eb61 ]
hfi1_mmu_rb_remove_unless_exact() did not move mmu_rb_node objects in mmu_rb_handler->lru_list after getting a cache hit on an mmu_rb_node.
As a result, hfi1_mmu_rb_evict() was not guaranteed to evict truly least-recently used nodes.
This could be a performance issue for an application when that application:
- Uses some long-lived buffers frequently.
- Uses a large number of buffers once.
- Hits the mmu_rb_handler cache size or pinned-page limits, forcing mmu_rb_handler cache entries to be evicted.
In this case, the one-time use buffers cause the long-lived buffer entries to eventually filter to the end of the LRU list where hfi1_mmu_rb_evict() will consider evicting a frequently-used long-lived entry instead of evicting one of the one-time use entries.
Fix this by inserting new mmu_rb_node at the tail of mmu_rb_handler->lru_list and move mmu_rb_ndoe to the tail of mmu_rb_handler->lru_list when the mmu_rb_node is a hit in hfi1_mmu_rb_remove_unless_exact(). Change hfi1_mmu_rb_evict() to evict from the head of mmu_rb_handler->lru_list instead of the tail.
--- drivers/infiniband/hw/hfi1/mmu_rb.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/infiniband/hw/hfi1/mmu_rb.c +6 -7
@@ -171,7 +171,7 @@ int hfi1_mmu_rb_insert(struct mmu_rb_handler *handler, goto unlock; }__mmu_int_rb_insert (mnode, &handler->root); -list_add (&mnode->list, &handler->lru_list); +list_add_tail (&mnode->list, &handler->lru_list); ret = handler->ops->insert (handler->ops_arg, mnode);if (ret) {
@@ -222,8 +222,10 @@ bool hfi1_mmu_rb_remove_unless_exact(struct mmu_rb_handler *handler,spin_lock_irqsave (&handler->lock, flags); node =__mmu_rb_search (handler, addr, len);if (node) { -if (node->addr == addr && node->len == len) +if (node->addr == addr && node->len == len) { +list_move_tail (&node->list, &handler->lru_list); goto unlock; + }__mmu_int_rb_remove (node, &handler->root);list_del (&node->list);/* remove from LRU list */ ret = true;
@@ -247,8 +249,7 @@ void hfi1_mmu_rb_evict(struct mmu_rb_handler *handler, void *evict_arg)INIT_LIST_HEAD (&del_list);spin_lock_irqsave (&handler->lock, flags); -list_for_each_entry_safe_reverse (rbnode, ptr, &handler->lru_list, - list) { +list_for_each_entry_safe (rbnode, ptr, &handler->lru_list, list) {if (handler->ops->evict (handler->ops_arg, rbnode, evict_arg, &stop)) {__mmu_int_rb_remove (rbnode, &handler->root);
@@ -260,9 +261,7 @@ void hfi1_mmu_rb_evict(struct mmu_rb_handler *handler, void *evict_arg) }spin_unlock_irqrestore (&handler->lock, flags); -while (!list_empty (&del_list)) { - rbnode = list_first_entry(&del_list, struct mmu_rb_node, list); -list_del (&rbnode->list); +list_for_each_entry_safe (rbnode, ptr, &del_list, list) { handler->ops->remove (handler->ops_arg, rbnode); } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 249/381 IB/hfi1: Add AIP tx traces
In reply to Greg Kroah-HartmanFrom: Mike Marciniszyn <[email protected]>
[ Upstream commit 4bd00b55c978017aad10f0ff3e45525cd62cca07 ]
Add traces to allow for debugging issues with AIP tx.
Stable-dep-of: 00cbce5cbf88 ("IB/hfi1: Fix bugs with non-PAGE_SIZE-end multi-iovec user SDMA requests")
--- drivers/infiniband/hw/hfi1/ipoib_tx.c | 18 ++++- drivers/infiniband/hw/hfi1/trace_tx.h | 104 ++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 3 deletions(-)
drivers/infiniband/hw/hfi1/ipoib_tx.c +15 -3
@@ -15,6 +15,7 @@#include "verbs.h" #include "trace_ibhdrs.h" #include "ipoib.h" +#include "trace_tx.h" /* Add a convenience helper */ #define CIRC_ADD (val, add, size) (((val) + (add)) & ((size) - 1))
@@ -63,12 +64,14 @@ static u64 hfi1_ipoib_used(struct hfi1_ipoib_txq *txq)static void hfi1_ipoib_stop_txq (struct hfi1_ipoib_txq *txq) { +trace_hfi1_txq_stop (txq);if (atomic_inc_return (&txq->stops) ==1 )netif_stop_subqueue (txq->priv->netdev, txq->q_idx); }static void hfi1_ipoib_wake_txq (struct hfi1_ipoib_txq *txq) { +trace_hfi1_txq_wake (txq);if (atomic_dec_and_test (&txq->stops))netif_wake_subqueue (txq->priv->netdev, txq->q_idx); }
@@ -89,8 +92,10 @@ static void hfi1_ipoib_check_queue_depth(struct hfi1_ipoib_txq *txq) { ++txq->sent_txreqs;if (hfi1_ipoib_used (txq) >=hfi1_ipoib_ring_hwat (txq) && - !atomic_xchg (&txq->ring_full,1 )) + !atomic_xchg (&txq->ring_full,1 )) { +trace_hfi1_txq_full (txq);hfi1_ipoib_stop_txq (txq); + } }static void hfi1_ipoib_check_queue_stopped (struct hfi1_ipoib_txq *txq)
@@ -112,8 +117,10 @@ static void hfi1_ipoib_check_queue_stopped(struct hfi1_ipoib_txq *txq)* to protect against ring overflow. */ if (hfi1_ipoib_used (txq) <hfi1_ipoib_ring_lwat (txq) && -atomic_xchg (&txq->ring_full,0 )) +atomic_xchg (&txq->ring_full,0 )) { +trace_hfi1_txq_xmit_unstopped (txq);hfi1_ipoib_wake_txq (txq); + } }static void hfi1_ipoib_free_tx (struct ipoib_txreq *tx,int budget)
@@ -405,6 +412,7 @@ static struct ipoib_txreq *hfi1_ipoib_send_dma_common(struct net_device *dev,sdma_select_engine_sc (priv->dd, txp->flow.tx_queue, txp->flow.sc5); +trace_hfi1_flow_switch (txp->txq); }return tx;
@@ -525,6 +533,7 @@ static int hfi1_ipoib_send_dma_list(struct net_device *dev,if (txq->flow.as_int != txp->flow.as_int) {int ret; +trace_hfi1_flow_flush (txq); ret =hfi1_ipoib_flush_tx_list (dev, txq);if (unlikely (ret)) {if (ret == -EBUSY )
@@ -635,8 +644,10 @@ static int hfi1_ipoib_sdma_sleep(struct sdma_engine *sde,/* came from non-list submit */ list_add_tail (&txreq->list, &txq->tx_list);if (list_empty (&txq->wait.list)) { -if (!atomic_xchg (&txq->no_desc,1 )) +if (!atomic_xchg (&txq->no_desc,1 )) { +trace_hfi1_txq_queued (txq);hfi1_ipoib_stop_txq (txq); + }iowait_queue (pkts_sent, wait->iow, &sde->dmawait); }
@@ -659,6 +670,7 @@ static void hfi1_ipoib_sdma_wakeup(struct iowait *wait, int reason)struct hfi1_ipoib_txq *txq = container_of(wait, struct hfi1_ipoib_txq, wait); +trace_hfi1_txq_wakeup (txq);if (likely (txq->priv->netdev->reg_state ==NETREG_REGISTERED ))iowait_schedule (wait, system_highpri_wq,WORK_CPU_UNBOUND ); }
drivers/infiniband/hw/hfi1/trace_tx.h +104 -0
116 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 250/381 IB/hfi1: Add additional usdma traces
In reply to Greg Kroah-HartmanFrom: Mike Marciniszyn <[email protected]>
[ Upstream commit 6b13215df1d37f5be23fc4a01a915a287b25ce15 ]
Add traces that were vital in isolating an issue with pq waitlist in commit fa8dac396863 ("IB/hfi1: Fix another case where pq is left on waitlist")
Stable-dep-of: 00cbce5cbf88 ("IB/hfi1: Fix bugs with non-PAGE_SIZE-end multi-iovec user SDMA requests")
--- drivers/infiniband/hw/hfi1/trace_tx.h | 75 ++++++++++++++++++++++++++ drivers/infiniband/hw/hfi1/user_sdma.c | 12 +++-- drivers/infiniband/hw/hfi1/user_sdma.h | 1 + 3 files changed, 85 insertions(+), 3 deletions(-)
drivers/infiniband/hw/hfi1/trace_tx.h +75 -0
@@ -54,6 +54,7 @@#include "mad.h" #include "sdma.h" #include "ipoib.h" +#include "user_sdma.h" const char *parse_sdma_flags (struct trace_seq *p,u64 desc0,u64 desc1);
@@ -654,6 +655,80 @@ TRACE_EVENT(hfi1_sdma_user_completion, __entry->code) ); +TRACE_EVENT (hfi1_usdma_defer, + TP_PROTO(struct hfi1_user_sdma_pkt_q *pq, + struct sdma_engine *sde, + struct iowait *wait), +TP_ARGS (pq, sde, wait), + TP_STRUCT__entry(DD_DEV_ENTRY(pq->dd) + __field(struct hfi1_user_sdma_pkt_q *, pq) + __field(struct sdma_engine *, sde) + __field(struct iowait *, wait) + __field(int, engine) +__field (int, empty) + ), + TP_fast_assign(DD_DEV_ASSIGN(pq->dd); + __entry->pq = pq; + __entry->sde = sde; + __entry->wait = wait; + __entry->engine = sde->this_idx; + __entry->empty = list_empty(&__entry->wait->list); + ), +TP_printk ("[%s] pq %llx sde %llx wait %llx engine %d empty %d" , +__get_str (dev), + (unsigned long long )__entry->pq, + (unsigned long long )__entry->sde, + (unsigned long long )__entry->wait, + __entry->engine, + __entry->empty + ) +); + +TRACE_EVENT (hfi1_usdma_activate, + TP_PROTO(struct hfi1_user_sdma_pkt_q *pq, + struct iowait *wait, + int reason), +TP_ARGS (pq, wait, reason), + TP_STRUCT__entry(DD_DEV_ENTRY(pq->dd) + __field(struct hfi1_user_sdma_pkt_q *, pq) + __field(struct iowait *, wait) +__field (int, reason) + ), + TP_fast_assign(DD_DEV_ASSIGN(pq->dd); + __entry->pq = pq; + __entry->wait = wait; + __entry->reason = reason; + ), +TP_printk ("[%s] pq %llx wait %llx reason %d" , +__get_str (dev), + (unsigned long long )__entry->pq, + (unsigned long long )__entry->wait, + __entry->reason + ) +); + +TRACE_EVENT (hfi1_usdma_we, + TP_PROTO(struct hfi1_user_sdma_pkt_q *pq, + int we_ret), +TP_ARGS (pq, we_ret), + TP_STRUCT__entry(DD_DEV_ENTRY(pq->dd) + __field(struct hfi1_user_sdma_pkt_q *, pq) + __field(int, state) +__field (int, we_ret) + ), + TP_fast_assign(DD_DEV_ASSIGN(pq->dd); + __entry->pq = pq; + __entry->state = pq->state; + __entry->we_ret = we_ret; + ), +TP_printk ("[%s] pq %llx state %d we_ret %d" , +__get_str (dev), + (unsigned long long )__entry->pq, + __entry->state, + __entry->we_ret + ) +); +const char *print_u32_array (struct trace_seq *,u32 *,int );#define __print_u32_hex (arr, len) print_u32_array(p, arr, len)
drivers/infiniband/hw/hfi1/user_sdma.c +9 -3
@@ -133,6 +133,7 @@ static int defer_packet_queue( container_of(wait->iow, struct hfi1_user_sdma_pkt_q, busy);write_seqlock (&sde->waitlock); +trace_hfi1_usdma_defer (pq, sde, &pq->busy);if (sdma_progress (sde, seq, txreq)) goto eagain;/*
@@ -157,7 +158,8 @@ static void activate_packet_queue(struct iowait *wait, int reason) {struct hfi1_user_sdma_pkt_q *pq = container_of(wait, struct hfi1_user_sdma_pkt_q, busy); - pq->busy.lock =NULL ; + +trace_hfi1_usdma_activate (pq, wait, reason);xchg (&pq->state,SDMA_PKT_Q_ACTIVE );wake_up (&wait->wait_dma); };
@@ -599,13 +601,17 @@ int hfi1_user_sdma_process_request(struct hfi1_filedata *fd,while (req->seqsubmitted != req->info.npkts) { ret =user_sdma_send_pkts (req, pcount);if (ret <0 ) { +int we_ret; +if (ret != -EBUSY ) goto free_req; -if (wait_event_interruptible_timeout ( + we_ret =wait_event_interruptible_timeout ( pq->busy.wait_dma, pq->state ==SDMA_PKT_Q_ACTIVE ,msecs_to_jiffies ( -SDMA_IOWAIT_TIMEOUT )) <=0 ) +SDMA_IOWAIT_TIMEOUT )); +trace_hfi1_usdma_we (pq, we_ret); +if (we_ret <=0 )flush_pq_iowait (pq); } }
drivers/infiniband/hw/hfi1/user_sdma.h +1 -0
@@ -53,6 +53,7 @@#include "common.h" #include "iowait.h" #include "user_exp_rcv.h" +#include "mmu_rb.h" /* The maximum number of Data io vectors per message/request */ #define MAX_VECTORS_PER_REQ 8
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 251/381 IB/hfi1: Fix bugs with non-PAGE_SIZE-end multi-iovec user SDMA requests
In reply to Greg Kroah-HartmanFrom: Patrick Kelsey <[email protected]>
[ Upstream commit 00cbce5cbf88459cd1aa1d60d0f1df15477df127 ]
hfi1 user SDMA request processing has two bugs that can cause data corruption for user SDMA requests that have multiple payload iovecs where an iovec other than the tail iovec does not run up to the page boundary for the buffer pointed to by that iovec.a
Here are the specific bugs:
1. user_sdma_txadd() does not use struct user_sdma_iovec->iov.iov_len. Rather, user_sdma_txadd() will add up to PAGE_SIZE bytes from iovec to the packet, even if some of those bytes are past iovec->iov.iov_len and are thus not intended to be in the packet.
2. user_sdma_txadd() and user_sdma_send_pkts() fail to advance to the next iovec in user_sdma_request->iovs when the current iovec is not PAGE_SIZE and does not contain enough data to complete the packet. The transmitted packet will contain the wrong data from the iovec pages.
This has not been an issue with SDMA packets from hfi1 Verbs or PSM2 because they only produce iovecs that end short of PAGE_SIZE as the tail iovec of an SDMA request.
Fixing these bugs exposes other bugs with the SDMA pin cache (struct mmu_rb_handler) that get in way of supporting user SDMA requests with multiple payload iovecs whose buffers do not end at PAGE_SIZE. So this commit fixes those issues as well.
Here are the mmu_rb_handler bugs that non-PAGE_SIZE-end multi-iovec payload user SDMA requests can hit:
1. Overlapping memory ranges in mmu_rb_handler will result in duplicate pinnings.
2. When extending an existing mmu_rb_handler entry (struct mmu_rb_node), the mmu_rb code (1) removes the existing entry under a lock, (2) releases that lock, pins the new pages, (3) then reacquires the lock to insert the extended mmu_rb_node.
If someone else comes in and inserts an overlapping entry between (2) and (3), insert in (3) will fail.
The failure path code in this case unpins _all_ pages in either the original mmu_rb_node or the new mmu_rb_node that was inserted between
(2) and (3).
3. In hfi1_mmu_rb_remove_unless_exact(), mmu_rb_node->refcount is incremented outside of mmu_rb_handler->lock. As a result, mmu_rb_node could be evicted by another thread that gets mmu_rb_handler->lock and checks mmu_rb_node->refcount before mmu_rb_node->refcount is incremented.
4. Related to #2 above, SDMA request submission failure path does not check mmu_rb_node->refcount before freeing mmu_rb_node object.
If there are other SDMA requests in progress whose iovecs have pointers to the now-freed mmu_rb_node(s), those pointers to the now-freed mmu_rb nodes will be dereferenced when those SDMA requests complete.
--- drivers/infiniband/hw/hfi1/ipoib_tx.c | 1 + drivers/infiniband/hw/hfi1/mmu_rb.c | 66 +-- drivers/infiniband/hw/hfi1/mmu_rb.h | 8 +- drivers/infiniband/hw/hfi1/sdma.c | 21 +- drivers/infiniband/hw/hfi1/sdma.h | 16 +- drivers/infiniband/hw/hfi1/sdma_txreq.h | 1 + drivers/infiniband/hw/hfi1/trace_mmu.h | 4 - drivers/infiniband/hw/hfi1/user_sdma.c | 600 +++++++++++++++--------- drivers/infiniband/hw/hfi1/user_sdma.h | 5 - drivers/infiniband/hw/hfi1/verbs.c | 4 +- drivers/infiniband/hw/hfi1/vnic_sdma.c | 1 + 11 files changed, 423 insertions(+), 304 deletions(-)
drivers/infiniband/hw/hfi1/ipoib_tx.c +1 -0
@@ -251,6 +251,7 @@ static int hfi1_ipoib_build_ulp_payload(struct ipoib_txreq *tx,const skb_frag_t *frag = &skb_shinfo (skb)->frags[i]; ret = sdma_txadd_page(dd, + NULL, txreq, skb_frag_page(frag), frag->bv_offset,
drivers/infiniband/hw/hfi1/mmu_rb.c +14 -52
90 lines not on this page · raw message
drivers/infiniband/hw/hfi1/mmu_rb.h +3 -5
@@ -93,10 +93,8 @@ void hfi1_mmu_rb_unregister(struct mmu_rb_handler *handler);int hfi1_mmu_rb_insert (struct mmu_rb_handler *handler,struct mmu_rb_node *mnode);void hfi1_mmu_rb_evict (struct mmu_rb_handler *handler,void *evict_arg); -void hfi1_mmu_rb_remove (struct mmu_rb_handler *handler, -struct mmu_rb_node *mnode); -bool hfi1_mmu_rb_remove_unless_exact (struct mmu_rb_handler *handler, -unsigned long addr,unsigned long len, -struct mmu_rb_node **rb_node); +struct mmu_rb_node *hfi1_mmu_rb_get_first (struct mmu_rb_handler *handler, +unsigned long addr, +unsigned long len);#endif /* _HFI1_MMU_RB_H */
drivers/infiniband/hw/hfi1/sdma.c +4 -17
@@ -1635,22 +1635,7 @@ static inline void sdma_unmap_desc(struct hfi1_devdata *dd, struct sdma_desc *descp) { - switch (sdma_mapping_type(descp)) { - case SDMA_MAP_SINGLE: -dma_unmap_single ( - &dd->pcidev->dev, -sdma_mapping_addr (descp ), -sdma_mapping_len (descp ), -DMA_TO_DEVICE ); -break ; -case SDMA_MAP_PAGE : -dma_unmap_page ( - &dd->pcidev->dev, -sdma_mapping_addr (descp), -sdma_mapping_len (descp), -DMA_TO_DEVICE ); -break ; - } +system_descriptor_complete (dd ,descp ); }/*
@@ -3170,7 +3155,7 @@ int ext_coal_sdma_tx_descs(struct hfi1_devdata *dd, struct sdma_txreq *tx,/* Add descriptor for coalesce buffer */ tx->desc_limit =MAX_DESC ; -return _sdma_txadd_daddr (dd,SDMA_MAP_SINGLE , tx, +return _sdma_txadd_daddr (dd,SDMA_MAP_SINGLE ,NULL , tx, addr, tx->tlen); }
@@ -3210,10 +3195,12 @@ int _pad_sdma_tx_descs(struct hfi1_devdata *dd, struct sdma_txreq *tx)return rval; } } +/* finish the one just added */ make_tx_sdma_desc ( tx,SDMA_MAP_NONE , +NULL , dd->sdma_pad_phys,sizeof (u32) - (tx->packet_len & (sizeof (u32) -1 )));_sdma_close_tx (dd, tx);
drivers/infiniband/hw/hfi1/sdma.h +11 -5
@@ -635,6 +635,7 @@ static inline dma_addr_t sdma_mapping_addr(struct sdma_desc *d)static inline void make_tx_sdma_desc (struct sdma_txreq *tx,int type, +void *pinning_ctx,dma_addr_t addr,size_t len) {
@@ -653,6 +654,7 @@ static inline void make_tx_sdma_desc( << SDMA_DESC0_PHY_ADDR_SHIFT) | (((u64 )len &SDMA_DESC0_BYTE_COUNT_MASK ) <<SDMA_DESC0_BYTE_COUNT_SHIFT ); + desc->pinning_ctx = pinning_ctx; }/* helper to extend txreq */
@@ -685,6 +687,7 @@ static inline void _sdma_close_tx(struct hfi1_devdata *dd,static inline int _sdma_txadd_daddr (struct hfi1_devdata *dd,int type, +void *pinning_ctx,struct sdma_txreq *tx,dma_addr_t addr,u16 len)
@@ -694,6 +697,7 @@ static inline int _sdma_txadd_daddr(make_tx_sdma_desc ( tx, type, + pinning_ctx, addr, len);WARN_ON (len > tx->tlen); tx->tlen -= len;
@@ -714,6 +718,7 @@ static inline int _sdma_txadd_daddr(/** * sdma_txadd_page() - add a page to the sdma_txreq * @dd: the device to use for mapping +* @pinning_ctx: context to be released at descriptor retirement * @tx: tx request to which the page is added * @page: page to map * @offset: offset within the page
@@ -729,6 +734,7 @@ static inline int _sdma_txadd_daddr(*/ static inline int sdma_txadd_page( struct hfi1_devdata *dd, + void *pinning_ctx, struct sdma_txreq *tx, struct page *page, unsigned long offset,
@@ -756,8 +762,7 @@ static inline int sdma_txadd_page(return -ENOSPC ; } -return _sdma_txadd_daddr ( - dd,SDMA_MAP_PAGE , tx, addr, len); +return _sdma_txadd_daddr (dd,SDMA_MAP_PAGE , pinning_ctx, tx, addr, len); }/**
@@ -791,7 +796,8 @@ static inline int sdma_txadd_daddr(return rval; } -return _sdma_txadd_daddr (dd,SDMA_MAP_NONE , tx, addr, len); +return _sdma_txadd_daddr (dd,SDMA_MAP_NONE ,NULL , tx, + addr, len); }/**
@@ -837,8 +843,7 @@ static inline int sdma_txadd_kvaddr(return -ENOSPC ; } -return _sdma_txadd_daddr ( - dd,SDMA_MAP_SINGLE , tx, addr, len); +return _sdma_txadd_daddr (dd,SDMA_MAP_SINGLE ,NULL , tx, addr, len); }struct iowait_work ;
@@ -1090,4 +1095,5 @@ extern uint mod_num_sdma;void sdma_update_lmc (struct hfi1_devdata *dd,u64 mask,u32 lid); +void system_descriptor_complete (struct hfi1_devdata *dd,struct sdma_desc *descp);#endif
drivers/infiniband/hw/hfi1/sdma_txreq.h +1 -0
@@ -61,6 +61,7 @@struct sdma_desc {/* private: don't use directly */ u64 qw[2 ]; +void *pinning_ctx; };/**
drivers/infiniband/hw/hfi1/trace_mmu.h +0 -4
@@ -78,10 +78,6 @@ DEFINE_EVENT(hfi1_mmu_rb_template, hfi1_mmu_rb_search, TP_PROTO(unsigned long addr, unsigned long len), TP_ARGS(addr, len)); -DEFINE_EVENT (hfi1_mmu_rb_template, hfi1_mmu_rb_remove, - TP_PROTO(unsigned long addr, unsigned long len), -TP_ARGS (addr, len)); -DEFINE_EVENT (hfi1_mmu_rb_template, hfi1_mmu_mem_invalidate, TP_PROTO(unsigned long addr, unsigned long len),TP_ARGS (addr, len));
drivers/infiniband/hw/hfi1/user_sdma.c +386 -214
700 lines not on this page · raw message
drivers/infiniband/hw/hfi1/user_sdma.h +0 -5
@@ -153,16 +153,11 @@ struct sdma_mmu_node {struct user_sdma_iovec {struct list_head list;struct iovec iov; -/* number of pages in this vector */ -unsigned int npages; -/* array of pinned pages for this vector */ -struct page **pages;/* * offset into the virtual address space of the vector at * which we last left off. */ u64 offset; -struct sdma_mmu_node *node; };/* evict operation argument */
drivers/infiniband/hw/hfi1/verbs.c +2 -2
@@ -820,8 +820,8 @@ static int build_verbs_tx_desc(/* add icrc, lt byte, and padding to flit */ if (extra_bytes) - ret =sdma_txadd_daddr (sde->dd, &tx->txreq, - sde->dd->sdma_pad_phys, extra_bytes); + ret =sdma_txadd_daddr (sde->dd, &tx->txreq, sde->dd->sdma_pad_phys, + extra_bytes); bail_txadd:return ret;
drivers/infiniband/hw/hfi1/vnic_sdma.c +1 -0
@@ -106,6 +106,7 @@ static noinline int build_vnic_ulp_payload(struct sdma_engine *sde,/* combine physically continuous fragments later? */ ret = sdma_txadd_page(sde->dd, + NULL, &tx->txreq, skb_frag_page(frag), skb_frag_off(frag),
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 252/381 NFSv4.1: Always send a RECLAIM_COMPLETE after establishing lease
In reply to Greg Kroah-HartmanFrom: Trond Myklebust <[email protected]>
[ Upstream commit 40882deb83c29d8df4470d4e5e7f137b6acf7ad1 ]
The spec requires that we always at least send a RECLAIM_COMPLETE when we're done establishing the lease and recovering any state.
--- fs/nfs/nfs4state.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/nfs/nfs4state.c +4 -0
@@ -67,6 +67,8 @@#define OPENOWNER_POOL_SIZE 8 +static void nfs4_state_start_reclaim_reboot (struct nfs_client *clp); +const nfs4_stateid zero_stateid = { { .data = {0 } }, .type =NFS4_SPECIAL_STATEID_TYPE ,
@@ -330,6 +332,8 @@ int nfs41_init_clientid(struct nfs_client *clp, const struct cred *cred) status =nfs4_proc_create_session (clp, cred);if (status !=0 ) goto out; +if (!(clp->cl_exchange_flags &EXCHGID4_FLAG_CONFIRMED_R )) +nfs4_state_start_reclaim_reboot (clp);nfs41_finish_session_reset (clp);nfs_mark_client_ready (clp,NFS_CS_READY ); out:
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 253/381 firmware: raspberrypi: Introduce devm_rpi_firmware_get()
In reply to Greg Kroah-HartmanFrom: Nicolas Saenz Julienne <[email protected]>
[ Upstream commit f663204c9a1f8d6fcc590667d9d7a9f44e064644 ]
It'll simplify the firmware handling for most consumers.
Stable-dep-of: 5bca3688bdbc ("Input: raspberrypi-ts - fix refcount leak in rpi_ts_probe")
--- drivers/firmware/raspberrypi.c | 29 ++++++++++++++++++++++ include/soc/bcm2835/raspberrypi-firmware.h | 8 ++++++ 2 files changed, 37 insertions(+)
drivers/firmware/raspberrypi.c +29 -0
@@ -243,6 +243,13 @@ void rpi_firmware_put(struct rpi_firmware *fw) }EXPORT_SYMBOL_GPL (rpi_firmware_put); +static void devm_rpi_firmware_put (void *data) +{ +struct rpi_firmware *fw = data; + +rpi_firmware_put (fw); +} +static int rpi_firmware_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -338,6 +345,28 @@ struct rpi_firmware *rpi_firmware_get(struct device_node *firmware_node) }EXPORT_SYMBOL_GPL (rpi_firmware_get); +/** +* devm_rpi_firmware_get - Get pointer to rpi_firmware structure. +* @firmware_node: Pointer to the firmware Device Tree node. +* +* Returns NULL is the firmware device is not ready. +*/ +struct rpi_firmware *devm_rpi_firmware_get (struct device *dev, +struct device_node *firmware_node) +{ +struct rpi_firmware *fw; + + fw =rpi_firmware_get (firmware_node); +if (!fw) +return NULL ; + +if (devm_add_action_or_reset (dev, devm_rpi_firmware_put, fw)) +return NULL ; + +return fw; +} +EXPORT_SYMBOL_GPL (devm_rpi_firmware_get); +static const struct of_device_id rpi_firmware_of_match[] = { { .compatible ="raspberrypi,bcm2835-firmware" , }, {},
include/soc/bcm2835/raspberrypi-firmware.h +8 -0
@@ -142,6 +142,8 @@ int rpi_firmware_property_list(struct rpi_firmware *fw, void *data, size_t tag_size);void rpi_firmware_put (struct rpi_firmware *fw);struct rpi_firmware *rpi_firmware_get (struct device_node *firmware_node); +struct rpi_firmware *devm_rpi_firmware_get (struct device *dev, +struct device_node *firmware_node);#else static inline int rpi_firmware_property (struct rpi_firmware *fw,u32 tag,void *data,size_t len)
@@ -160,6 +162,12 @@ static inline struct rpi_firmware *rpi_firmware_get(struct device_node *firmware {return NULL ; } + +static inline struct rpi_firmware *devm_rpi_firmware_get (struct device *dev, +struct device_node *firmware_node) +{ +return NULL ; +}#endif #endif /* __SOC_RASPBERRY_FIRMWARE_H__ */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 254/381 input: raspberrypi-ts: Release firmware handle when not needed
In reply to Greg Kroah-HartmanFrom: Nicolas Saenz Julienne <[email protected]>
[ Upstream commit 3b8ddff780b7d12e99ae39177f84b9003097777a ]
There is no use for the firmware interface after getting the touch buffer address, so release it.
Stable-dep-of: 5bca3688bdbc ("Input: raspberrypi-ts - fix refcount leak in rpi_ts_probe")
--- drivers/input/touchscreen/raspberrypi-ts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/raspberrypi-ts.c +1 -1
@@ -160,7 +160,7 @@ static int rpi_ts_probe(struct platform_device *pdev) touchbuf = (u32 )ts->fw_regs_phys; error =rpi_firmware_property (fw,RPI_FIRMWARE_FRAMEBUFFER_SET_TOUCHBUF , &touchbuf,sizeof (touchbuf)); - +rpi_firmware_put (fw);if (error || touchbuf !=0 ) {dev_warn (dev,"Failed to set touchbuf, %d\n" , error);return error;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 255/381 Input: raspberrypi-ts - fix refcount leak in rpi_ts_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 5bca3688bdbc3b58a2894b8671a8e2378efe28bd ]
rpi_firmware_get() take reference, we need to release it in error paths as well. Use devm_rpi_firmware_get() helper to handling the resources. Also remove the existing rpi_firmware_put().
--- drivers/input/touchscreen/raspberrypi-ts.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/input/touchscreen/raspberrypi-ts.c +1 -2
@@ -134,7 +134,7 @@ static int rpi_ts_probe(struct platform_device *pdev)return -ENOENT ; } - fw =rpi_firmware_get (fw_node); + fw =devm_rpi_firmware_get (&pdev->dev, fw_node);of_node_put (fw_node);if (!fw)return -EPROBE_DEFER ;
@@ -160,7 +160,6 @@ static int rpi_ts_probe(struct platform_device *pdev) touchbuf = (u32 )ts->fw_regs_phys; error =rpi_firmware_property (fw,RPI_FIRMWARE_FRAMEBUFFER_SET_TOUCHBUF , &touchbuf,sizeof (touchbuf)); -rpi_firmware_put (fw);if (error || touchbuf !=0 ) {dev_warn (dev,"Failed to set touchbuf, %d\n" , error);return error;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 256/381 RDMA/mlx5: Fix flow counter query via DEVX
In reply to Greg Kroah-HartmanFrom: Mark Bloch <[email protected]>
[ Upstream commit 3e358ea8614ddfbc59ca7a3f5dff5dde2b350b2c ]
Commit cited in "fixes" tag added bulk support for flow counters but it didn't account that's also possible to query a counter using a non-base id if the counter was allocated as bulk.
When a user performs a query, validate the flow counter id given in the mailbox is inside the valid range taking bulk value into account.
--- drivers/infiniband/hw/mlx5/devx.c | 31 ++++++++++++++++++++++++++----- include/linux/mlx5/mlx5_ifc.h | 3 ++- 2 files changed, 28 insertions(+), 6 deletions(-)
drivers/infiniband/hw/mlx5/devx.c +26 -5
@@ -595,7 +595,21 @@ static bool devx_is_valid_obj_id(struct uverbs_attr_bundle *attrs, obj_id;case MLX5_IB_OBJECT_DEVX_OBJ : -return ((struct devx_obj *)uobj->object)->obj_id == obj_id; + { +u16 opcode =MLX5_GET (general_obj_in_cmd_hdr, in, opcode); +struct devx_obj *devx_uobj = uobj->object; + +if (opcode ==MLX5_CMD_OP_QUERY_FLOW_COUNTER && + devx_uobj->flow_counter_bulk_size) { +u64 end; + + end = devx_uobj->obj_id + + devx_uobj->flow_counter_bulk_size; +return devx_uobj->obj_id <= obj_id && end > obj_id; + } + +return devx_uobj->obj_id == obj_id; + }default :return false;
@@ -1416,10 +1430,17 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_OBJ_CREATE)( goto obj_free;if (opcode ==MLX5_CMD_OP_ALLOC_FLOW_COUNTER ) { -u8 bulk =MLX5_GET (alloc_flow_counter_in, - cmd_in, - flow_counter_bulk); - obj->flow_counter_bulk_size =128UL * bulk; +u32 bulk =MLX5_GET (alloc_flow_counter_in, + cmd_in, + flow_counter_bulk_log_size); + +if (bulk) + bulk =1 << bulk; +else + bulk =128UL *MLX5_GET (alloc_flow_counter_in, + cmd_in, + flow_counter_bulk); + obj->flow_counter_bulk_size = bulk; } uobj->object = obj;
include/linux/mlx5/mlx5_ifc.h +2 -1
@@ -8331,7 +8331,8 @@ struct mlx5_ifc_alloc_flow_counter_in_bits {u8 reserved_at_20[0x10 ];u8 op_mod[0x10 ]; -u8 reserved_at_40[0x38 ]; +u8 reserved_at_40[0x33 ]; +u8 flow_counter_bulk_log_size[0x5 ];u8 flow_counter_bulk[0x8 ]; };
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 257/381 SUNRPC: remove the maximum number of retries in call_bind_status
In reply to Greg Kroah-HartmanFrom: Dai Ngo <[email protected]>
[ Upstream commit 691d0b782066a6eeeecbfceb7910a8f6184e6105 ]
Currently call_bind_status places a hard limit of 3 to the number of retries on EACCES error. This limit was done to prevent NLM unlock requests from being hang forever when the server keeps returning garbage. However this change causes problem for cases when NLM service takes longer than 9 seconds to register with the port mapper after a restart.
This patch removes this hard coded limit and let the RPC handles the retry based on the standard hard/soft task semantics.
--- include/linux/sunrpc/sched.h | 3 +-- net/sunrpc/clnt.c | 3 --- net/sunrpc/sched.c | 1 - 3 files changed, 1 insertion(+), 6 deletions(-)
include/linux/sunrpc/sched.h +1 -2
@@ -90,8 +90,7 @@ struct rpc_task {#endif unsigned char tk_priority : 2,/* Task priority */ tk_garb_retry : 2, - tk_cred_retry : 2, - tk_rebind_retry : 2; + tk_cred_retry : 2; };typedef void (*rpc_action )(struct rpc_task *);
net/sunrpc/clnt.c +0 -3
@@ -1967,9 +1967,6 @@ call_bind_status(struct rpc_task *task) status = -EOPNOTSUPP ;break ; } -if (task->tk_rebind_retry ==0 ) -break ; - task->tk_rebind_retry--;rpc_delay (task,3 *HZ ); goto retry_timeout;case -ENOBUFS :
net/sunrpc/sched.c +0 -1
@@ -796,7 +796,6 @@ rpc_init_task_statistics(struct rpc_task *task)/* Initialize retry counters */ task->tk_garb_retry =2 ; task->tk_cred_retry =2 ; - task->tk_rebind_retry =2 ;/* starting timestamp */ task->tk_start =ktime_get ();
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 258/381 RDMA/mlx5: Use correct device num_ports when modify DC
In reply to Greg Kroah-HartmanFrom: Mark Zhang <[email protected]>
[ Upstream commit 746aa3c8cb1a650ff2583497ac646e505831b9b9 ]
Just like other QP types, when modify DC, the port_num should be compared with dev->num_ports, instead of HCA_CAP.num_ports. Otherwise Multi-port vHCA on DC may not work.
--- drivers/infiniband/hw/mlx5/qp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/qp.c +1 -1
@@ -4164,7 +4164,7 @@ static int mlx5_ib_modify_dct(struct ib_qp *ibqp, struct ib_qp_attr *attr,return -EINVAL ;if (attr->port_num ==0 || - attr->port_num >MLX5_CAP_GEN (dev->mdev, num_ports)) { + attr->port_num > dev->num_ports) {mlx5_ib_dbg (dev,"invalid port number %d. number of ports is %d\n" , attr->port_num, dev->num_ports);return -EINVAL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 259/381 clocksource/drivers/davinci: Fix memory leak in davinci_timer_register when init fails
In reply to Greg Kroah-HartmanFrom: Qinrun Dai <[email protected]>
[ Upstream commit fb73556386e074e9bee9fa2d253aeaefe4e063e0 ]
Smatch reports:drivers/clocksource/timer-davinci.c:332 davinci_timer_register()
warn: 'base' from ioremap() not released on lines: 274.
Fix this and other potential memory leak problems
by adding a set of corresponding exit lables.
--- drivers/clocksource/timer-davinci.c | 30 +++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-)
drivers/clocksource/timer-davinci.c +24 -6
@@ -258,21 +258,25 @@ int __init davinci_timer_register(struct clk *clk, resource_size(&timer_cfg->reg), "davinci-timer")) {pr_err ("Unable to request memory region\n" ); -return -EBUSY ; + rv = -EBUSY ; + goto exit_clk_disable; } base =ioremap (timer_cfg->reg.start,resource_size (&timer_cfg->reg));if (!base) {pr_err ("Unable to map the register range\n" ); -return -ENOMEM ; + rv = -ENOMEM ; + goto exit_mem_region; }davinci_timer_init (base); tick_rate =clk_get_rate (clk); clockevent =kzalloc (sizeof (*clockevent),GFP_KERNEL ); -if (!clockevent) -return -ENOMEM ; +if (!clockevent) { + rv = -ENOMEM ; + goto exit_iounmap_base; + } clockevent->dev.name ="tim12" ; clockevent->dev.features =CLOCK_EVT_FEAT_ONESHOT ;
@@ -297,7 +301,7 @@ int __init davinci_timer_register(struct clk *clk, "clockevent/tim12", clockevent);if (rv) {pr_err ("Unable to request the clockevent interrupt\n" ); -return rv; + goto exit_free_clockevent; } davinci_clocksource.dev.rating =300 ;
@@ -324,13 +328,27 @@ int __init davinci_timer_register(struct clk *clk, rv =clocksource_register_hz (&davinci_clocksource.dev, tick_rate);if (rv) {pr_err ("Unable to register clocksource\n" ); -return rv; + goto exit_free_irq; }sched_clock_register (davinci_timer_read_sched_clock,DAVINCI_TIMER_CLKSRC_BITS , tick_rate);return 0 ; + +exit_free_irq: +free_irq (timer_cfg->irq[DAVINCI_TIMER_CLOCKEVENT_IRQ ].start, + clockevent); +exit_free_clockevent: +kfree (clockevent); +exit_iounmap_base: +iounmap (base); +exit_mem_region: +release_mem_region (timer_cfg->reg.start, +resource_size (&timer_cfg->reg)); +exit_clk_disable: +clk_disable_unprepare (clk); +return rv; }static int __init of_davinci_timer_register (struct device_node *np)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 260/381 openrisc: Properly store r31 to pt_regs on unhandled exceptions
In reply to Greg Kroah-HartmanFrom: Stafford Horne <[email protected]>
[ Upstream commit 812489ac4dd91144a74ce65ecf232252a2e406fb ]
In commit 91993c8c2ed5 ("openrisc: use shadow registers to save regs on exception") the unhandled exception path was changed to do an early store of r30 instead of r31. The entry code was not updated and r31 is not getting stored to pt_regs.
This patch updates the entry handler to store r31 instead of r30. We also remove some misleading commented out store r30 and r31 instructrions.
I noticed this while working on adding floating point exception handling, This issue probably would never impact anything since we kill the process or Oops right away on unhandled exceptions.
--- arch/openrisc/kernel/entry.S | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/openrisc/kernel/entry.S +2 -4
@@ -173,7 +173,6 @@ handler: ;\ l.sw PT_GPR28(r1),r28 ;\ l.sw PT_GPR29(r1),r29 ;\ /* r30 already save */ ;\ -/* l.sw PT_GPR30(r1),r30*/ ;\ l.sw PT_GPR31(r1),r31 ;\ TRACE_IRQS_OFF_ENTRY ;\ /* Store -1 in orig_gpr11 for non-syscall exceptions */ ;\
@@ -211,9 +210,8 @@ handler: ;\ l.sw PT_GPR27(r1),r27 ;\ l.sw PT_GPR28(r1),r28 ;\ l.sw PT_GPR29(r1),r29 ;\ - /* r31 already saved */ ;\ - l.sw PT_GPR30(r1),r30 ;\ -/* l.sw PT_GPR31(r1),r31 */ ;\ + /* r30 already saved */ ;\ + l.sw PT_GPR31(r1),r31 ;\ /* Store -1 in orig_gpr11 for non-syscall exceptions */ ;\ l.addi r30,r0,-1 ;\ l.sw PT_ORIG_GPR11(r1),r30 ;\
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 261/381 ext4: fix use-after-free read in ext4_find_extent for bigalloc + inline
In reply to Greg Kroah-HartmanFrom: Ye Bin <[email protected]>
[ Upstream commit 835659598c67907b98cd2aa57bb951dfaf675c69 ]
Syzbot found the following issue:
loop0: detected capacity change from 0 to 2048
EXT4-fs (loop0): mounted filesystem 00000000-0000-0000-0000-000000000000 without journal. Quota mode: none.
==================================================================
BUG: KASAN: use-after-free in ext4_ext_binsearch_idx fs/ext4/extents.c:768 [inline] BUG: KASAN: use-after-free in ext4_find_extent+0x76e/0xd90 fs/ext4/extents.c:931 Read of size 4 at addr ffff888073644750 by task syz-executor420/5067 CPU: 0 PID: 5067 Comm: syz-executor420 Not tainted 6.2.0-rc1-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0x1b1/0x290 lib/dump_stack.c:106 print_address_description+0x74/0x340 mm/kasan/report.c:306 print_report+0x107/0x1f0 mm/kasan/report.c:417 kasan_report+0xcd/0x100 mm/kasan/report.c:517 ext4_ext_binsearch_idx fs/ext4/extents.c:768 [inline] ext4_find_extent+0x76e/0xd90 fs/ext4/extents.c:931 ext4_clu_mapped+0x117/0x970 fs/ext4/extents.c:5809 ext4_insert_delayed_block fs/ext4/inode.c:1696 [inline] ext4_da_map_blocks fs/ext4/inode.c:1806 [inline] ext4_da_get_block_prep+0x9e8/0x13c0 fs/ext4/inode.c:1870 ext4_block_write_begin+0x6a8/0x2290 fs/ext4/inode.c:1098 ext4_da_write_begin+0x539/0x760 fs/ext4/inode.c:3082 generic_perform_write+0x2e4/0x5e0 mm/filemap.c:3772 ext4_buffered_write_iter+0x122/0x3a0 fs/ext4/file.c:285 ext4_file_write_iter+0x1d0/0x18f0 call_write_iter include/linux/fs.h:2186 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0x7dc/0xc50 fs/read_write.c:584 ksys_write+0x177/0x2a0 fs/read_write.c:637 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0033:0x7f4b7a9737b9 RSP: 002b:00007ffc5cac3668 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f4b7a9737b9 RDX: 00000000175d9003 RSI: 0000000020000200 RDI: 0000000000000004 RBP: 00007f4b7a933050 R08: 0000000000000000 R09: 0000000000000000 R10: 000000000000079f R11: 0000000000000246 R12: 00007f4b7a9330e0 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 </TASK>
Above issue is happens when enable bigalloc and inline data feature. As commit 131294c35ed6 fixed delayed allocation bug in ext4_clu_mapped for bigalloc + inline. But it only resolved issue when has inline data, if inline data has been converted to extent(ext4_da_convert_inline_data_to_extent) before writepages, there is no EXT4_STATE_MAY_INLINE_DATA flag. However i_data is still store inline data in this scene. Then will trigger UAF when find extent.
To resolve above issue, there is need to add judge "ext4_has_inline_data(inode)" in ext4_clu_mapped().
--- fs/ext4/extents.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/extents.c +2 -1
@@ -5805,7 +5805,8 @@ int ext4_clu_mapped(struct inode *inode, ext4_lblk_t lclu)* mapped - no physical clusters have been allocated, and the * file has no extents */ -if (ext4_test_inode_state (inode,EXT4_STATE_MAY_INLINE_DATA )) +if (ext4_test_inode_state (inode,EXT4_STATE_MAY_INLINE_DATA ) || +ext4_has_inline_data (inode))return 0 ;/* search for the extent closest to the first block in the cluster */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 262/381 leds: TI_LMU_COMMON: select REGMAP instead of depending on it
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit a61079efc87888587e463afaed82417b162fbd69 ]
REGMAP is a hidden (not user visible) symbol. Users cannot set it directly thru "make *config", so drivers should select it instead of depending on it if they need it.
Consistently using "select" or "depends on" can also help reduce Kconfig circular dependency issues.
Therefore, change the use of "depends on REGMAP" to "select REGMAP".
--- drivers/leds/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/Kconfig +1 -1
@@ -871,7 +871,7 @@ config LEDS_SPI_BYTE config LEDS_TI_LMU_COMMON tristate "LED driver for TI LMU" depends on LEDS_CLASS - depends on REGMAP + select REGMAP help Say Y to enable the LED driver for TI LMU devices. This supports common features between the TI LM3532, LM3631, LM3632,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 263/381 dmaengine: mv_xor_v2: Fix an error code.
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 827026ae2e56ec05ef1155661079badbbfc0b038 ]
If the probe is deferred, -EPROBE_DEFER should be returned, not +EPROBE_DEFER.
--- drivers/dma/mv_xor_v2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/mv_xor_v2.c +1 -1
@@ -756,7 +756,7 @@ static int mv_xor_v2_probe(struct platform_device *pdev) xor_dev->clk =devm_clk_get (&pdev->dev,NULL );if (PTR_ERR (xor_dev->clk) == -EPROBE_DEFER ) { - ret =EPROBE_DEFER ; + ret = -EPROBE_DEFER ; goto disable_reg_clk; }if (!IS_ERR (xor_dev->clk)) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 264/381 leds: tca6507: Fix error handling of using fwnode_property_read_string
In reply to Greg Kroah-HartmanFrom: H. Nikolaus Schaller <[email protected]>
[ Upstream commit c1087c29e96a48e9080377e168d35dcb52fb068b ]
Commit 96f524105b9c ("leds: tca6507: use fwnode API instead of OF")
changed to fwnode API but did not take into account that a missing property "linux,default-trigger" now seems to return an error and as a side effect sets value to -1. This seems to be different from of_get_property() which always returned NULL in any case of error.
Neglecting this side-effect leads to
[ 11.201965] Unable to handle kernel paging request at virtual address ffffffff when read
in the strcmp() of led_trigger_set_default() if there is no led-trigger defined in the DTS.
I don't know if this was recently introduced somewhere in the fwnode lib or if the effect was missed in initial testing. Anyways it seems to be a bug to ignore the error return value of an optional value here in the driver.
--- drivers/leds/leds-tca6507.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/leds/leds-tca6507.c +3 -2
@@ -696,8 +696,9 @@ tca6507_led_dt_init(struct device *dev)if (fwnode_property_read_string (child,"label" , &led.name)) led.name =fwnode_get_name (child); -fwnode_property_read_string (child,"linux,default-trigger" , - &led.default_trigger); +if (fwnode_property_read_string (child,"linux,default-trigger" , + &led.default_trigger)) + led.default_trigger =NULL ; led.flags =0 ; if (fwnode_property_match_string(child, "compatible",
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 265/381 pwm: mtk-disp: Dont check the return code of pwmchip_remove()
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 9b7b5736ffd5da6f8f6329ebe5f1829cbcf8afae ]
pwmchip_remove() returns always 0. Don't use the value to make it possible to eventually change the function to return void. Also the driver core ignores the return value of mtk_disp_pwm_remove().
Stable-dep-of: 36dd7f530ae7 ("pwm: mtk-disp: Disable shadow registers before setting backlight values")
--- drivers/pwm/pwm-mtk-disp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pwm/pwm-mtk-disp.c +2 -3
@@ -240,13 +240,12 @@ static int mtk_disp_pwm_probe(struct platform_device *pdev)static int mtk_disp_pwm_remove (struct platform_device *pdev) {struct mtk_disp_pwm *mdp =platform_get_drvdata (pdev); -int ret; - ret =pwmchip_remove (&mdp->chip); +pwmchip_remove (&mdp->chip);clk_unprepare (mdp->clk_mm);clk_unprepare (mdp->clk_main); -return ret; +return 0 ; }static const struct mtk_pwm_data mt2701_pwm_data = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 266/381 pwm: mtk-disp: Adjust the clocks to avoid them mismatch
In reply to Greg Kroah-HartmanFrom: Jitao Shi <[email protected]>
[ Upstream commit d7a4e582587d97a586b1f7709e3bddcf35928e96 ]
The clks "main" and "mm" are prepared in .probe() (and unprepared in .remove()). This results in the clocks being on during suspend which results in unnecessarily increased power consumption.
Remove the clock operations from .probe() and .remove(). Add the clk_prepare_enable() in .enable() and the clk_disable_unprepare() in .disable().
Stable-dep-of: 36dd7f530ae7 ("pwm: mtk-disp: Disable shadow registers before setting backlight values")
--- drivers/pwm/pwm-mtk-disp.c | 91 +++++++++++++++++--------------------- 1 file changed, 41 insertions(+), 50 deletions(-)
drivers/pwm/pwm-mtk-disp.c +41 -50
@@ -74,6 +74,19 @@ static int mtk_disp_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,u64 div, rate;int err; + err =clk_prepare_enable (mdp->clk_main); +if (err <0 ) { +dev_err (chip->dev,"Can't enable mdp->clk_main: %pe\n" ,ERR_PTR (err)); +return err; + } + + err =clk_prepare_enable (mdp->clk_mm); +if (err <0 ) { +dev_err (chip->dev,"Can't enable mdp->clk_mm: %pe\n" ,ERR_PTR (err)); +clk_disable_unprepare (mdp->clk_main); +return err; + } +/* * Find period, high_width and clk_div to suit duty_ns and period_ns. * Calculate proper div value to keep period value in the bound.
@@ -87,8 +100,11 @@ static int mtk_disp_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, rate =clk_get_rate (mdp->clk_main); clk_div =div_u64 (rate * period_ns,NSEC_PER_SEC ) >>PWM_PERIOD_BIT_WIDTH ; -if (clk_div >PWM_CLKDIV_MAX ) +if (clk_div >PWM_CLKDIV_MAX ) { +clk_disable_unprepare (mdp->clk_mm); +clk_disable_unprepare (mdp->clk_main);return -EINVAL ; + } div =NSEC_PER_SEC * (clk_div +1 ); period =div64_u64 (rate * period_ns, div);
@@ -98,16 +114,6 @@ static int mtk_disp_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, high_width =div64_u64 (rate * duty_ns, div); value = period | (high_width <<PWM_HIGH_WIDTH_SHIFT ); - err =clk_enable (mdp->clk_main); -if (err <0 ) -return err; - - err =clk_enable (mdp->clk_mm); -if (err <0 ) { -clk_disable (mdp->clk_main); -return err; - } -mtk_disp_pwm_update_bits (mdp, mdp->data->con0,PWM_CLKDIV_MASK , clk_div <<PWM_CLKDIV_SHIFT );
@@ -122,10 +128,21 @@ static int mtk_disp_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,mtk_disp_pwm_update_bits (mdp, mdp->data->commit, mdp->data->commit_mask,0x0 ); + }else { +/* +* For MT2701, disable double buffer before writing register +* and select manual mode and use PWM_PERIOD/PWM_HIGH_WIDTH. +*/ +mtk_disp_pwm_update_bits (mdp, mdp->data->bls_debug, + mdp->data->bls_debug_mask, + mdp->data->bls_debug_mask); +mtk_disp_pwm_update_bits (mdp, mdp->data->con0, + mdp->data->con0_sel, + mdp->data->con0_sel); } -clk_disable (mdp->clk_mm); -clk_disable (mdp->clk_main); +clk_disable_unprepare (mdp->clk_mm); +clk_disable_unprepare (mdp->clk_main);return 0 ; }
@@ -135,13 +152,16 @@ static int mtk_disp_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)struct mtk_disp_pwm *mdp =to_mtk_disp_pwm (chip);int err; - err =clk_enable (mdp->clk_main); -if (err <0 ) + err =clk_prepare_enable (mdp->clk_main); +if (err <0 ) { +dev_err (chip->dev,"Can't enable mdp->clk_main: %pe\n" ,ERR_PTR (err));return err; + } - err =clk_enable (mdp->clk_mm); + err =clk_prepare_enable (mdp->clk_mm);if (err <0 ) { -clk_disable (mdp->clk_main); +dev_err (chip->dev,"Can't enable mdp->clk_mm: %pe\n" ,ERR_PTR (err)); +clk_disable_unprepare (mdp->clk_main);return err; }
@@ -158,8 +178,8 @@ static void mtk_disp_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)mtk_disp_pwm_update_bits (mdp,DISP_PWM_EN , mdp->data->enable_mask,0x0 ); -clk_disable (mdp->clk_mm); -clk_disable (mdp->clk_main); +clk_disable_unprepare (mdp->clk_mm); +clk_disable_unprepare (mdp->clk_main); }static const struct pwm_ops mtk_disp_pwm_ops = {
@@ -194,14 +214,6 @@ static int mtk_disp_pwm_probe(struct platform_device *pdev)if (IS_ERR (mdp->clk_mm))return PTR_ERR (mdp->clk_mm); - ret =clk_prepare (mdp->clk_main); -if (ret <0 ) -return ret; - - ret =clk_prepare (mdp->clk_mm); -if (ret <0 ) - goto disable_clk_main; - mdp->chip.dev = &pdev->dev; mdp->chip.ops = &mtk_disp_pwm_ops; mdp->chip.base =-1 ;
@@ -209,32 +221,13 @@ static int mtk_disp_pwm_probe(struct platform_device *pdev) ret =pwmchip_add (&mdp->chip);if (ret <0 ) { -dev_err (&pdev->dev,"pwmchip_add() failed: %d\n" , ret); - goto disable_clk_mm; +dev_err (&pdev->dev,"pwmchip_add() failed: %pe\n" ,ERR_PTR (ret)); +return ret; }platform_set_drvdata (pdev, mdp); -/* -* For MT2701, disable double buffer before writing register -* and select manual mode and use PWM_PERIOD/PWM_HIGH_WIDTH. -*/ -if (!mdp->data->has_commit) { -mtk_disp_pwm_update_bits (mdp, mdp->data->bls_debug, - mdp->data->bls_debug_mask, - mdp->data->bls_debug_mask); -mtk_disp_pwm_update_bits (mdp, mdp->data->con0, - mdp->data->con0_sel, - mdp->data->con0_sel); - } -return 0 ; - -disable_clk_mm: -clk_unprepare (mdp->clk_mm); -disable_clk_main: -clk_unprepare (mdp->clk_main); -return ret; }static int mtk_disp_pwm_remove (struct platform_device *pdev)
@@ -242,8 +235,6 @@ static int mtk_disp_pwm_remove(struct platform_device *pdev)struct mtk_disp_pwm *mdp =platform_get_drvdata (pdev);pwmchip_remove (&mdp->chip); -clk_unprepare (mdp->clk_mm); -clk_unprepare (mdp->clk_main);return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 267/381 pwm: mtk-disp: Disable shadow registers before setting backlight values
In reply to Greg Kroah-HartmanFrom: AngeloGioacchino Del Regno <[email protected]>
[ Upstream commit 36dd7f530ae7d9ce9e853ffb8aa337de65c6600b ]
If shadow registers usage is not desired, disable that before performing any write to CON0/1 registers in the .apply() callback, otherwise we may lose clkdiv or period/width updates.
--- drivers/pwm/pwm-mtk-disp.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/pwm/pwm-mtk-disp.c +13 -11
@@ -114,6 +114,19 @@ static int mtk_disp_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, high_width =div64_u64 (rate * duty_ns, div); value = period | (high_width <<PWM_HIGH_WIDTH_SHIFT ); +if (mdp->data->bls_debug && !mdp->data->has_commit) { +/* +* For MT2701, disable double buffer before writing register +* and select manual mode and use PWM_PERIOD/PWM_HIGH_WIDTH. +*/ +mtk_disp_pwm_update_bits (mdp, mdp->data->bls_debug, + mdp->data->bls_debug_mask, + mdp->data->bls_debug_mask); +mtk_disp_pwm_update_bits (mdp, mdp->data->con0, + mdp->data->con0_sel, + mdp->data->con0_sel); + } +mtk_disp_pwm_update_bits (mdp, mdp->data->con0,PWM_CLKDIV_MASK , clk_div <<PWM_CLKDIV_SHIFT );
@@ -128,17 +141,6 @@ static int mtk_disp_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,mtk_disp_pwm_update_bits (mdp, mdp->data->commit, mdp->data->commit_mask,0x0 ); - }else { -/* -* For MT2701, disable double buffer before writing register -* and select manual mode and use PWM_PERIOD/PWM_HIGH_WIDTH. -*/ -mtk_disp_pwm_update_bits (mdp, mdp->data->bls_debug, - mdp->data->bls_debug_mask, - mdp->data->bls_debug_mask); -mtk_disp_pwm_update_bits (mdp, mdp->data->con0, - mdp->data->con0_sel, - mdp->data->con0_sel); }clk_disable_unprepare (mdp->clk_mm);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 268/381 phy: tegra: xusb: Add missing tegra_xusb_port_unregister for usb2_port and ulpi_port
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit e024854048e733391b31fe5a398704b31b9af803 ]
The tegra_xusb_port_unregister should be called when usb2_port and ulpi_port map fails in tegra_xusb_add_usb2_port() or in tegra_xusb_add_ulpi_port(), fix it.
--- drivers/phy/tegra/xusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/phy/tegra/xusb.c +2 -0
@@ -775,6 +775,7 @@ static int tegra_xusb_add_usb2_port(struct tegra_xusb_padctl *padctl, usb2->base.lane = usb2->base.ops->map (&usb2->base);if (IS_ERR (usb2->base.lane)) { err =PTR_ERR (usb2->base.lane); +tegra_xusb_port_unregister (&usb2->base); goto out; }
@@ -841,6 +842,7 @@ static int tegra_xusb_add_ulpi_port(struct tegra_xusb_padctl *padctl, ulpi->base.lane = ulpi->base.ops->map (&ulpi->base);if (IS_ERR (ulpi->base.lane)) { err =PTR_ERR (ulpi->base.lane); +tegra_xusb_port_unregister (&ulpi->base); goto out; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 269/381 dmaengine: dw-edma: Fix to change for continuous transfer
In reply to Greg Kroah-HartmanFrom: Shunsuke Mie <[email protected]>
[ Upstream commit a251994a441ee0a69ba7062c8cd2d08ead3db379 ]
The dw-edma driver stops after processing a DMA request even if a request remains in the issued queue, which is not the expected behavior. The DMA engine API requires continuous processing.
Add a trigger to start after one processing finished if there are requests remain.
--- drivers/dma/dw-edma/dw-edma-core.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-)
drivers/dma/dw-edma/dw-edma-core.c +11 -9
@@ -166,7 +166,7 @@ static void vchan_free_desc(struct virt_dma_desc *vdesc)dw_edma_free_desc (vd2dw_edma_desc (vdesc)); } -static void dw_edma_start_transfer (struct dw_edma_chan *chan) +static int dw_edma_start_transfer (struct dw_edma_chan *chan) {struct dw_edma_chunk *child;struct dw_edma_desc *desc;
@@ -174,16 +174,16 @@ static void dw_edma_start_transfer(struct dw_edma_chan *chan) vd =vchan_next_desc (&chan->vc);if (!vd) -return ; +return 0 ; desc =vd2dw_edma_desc (vd);if (!desc) -return ; +return 0 ; child =list_first_entry_or_null (&desc->chunk->list, struct dw_edma_chunk, list);if (!child) -return ; +return 0 ;dw_edma_v0_core_start (child, !desc->xfer_sz); desc->xfer_sz += child->ll_region.sz;
@@ -191,6 +191,8 @@ static void dw_edma_start_transfer(struct dw_edma_chan *chan)list_del (&child->list);kfree (child); desc->chunks_alloc--; + +return 1 ; } static int dw_edma_device_config(struct dma_chan *dchan,
@@ -497,14 +499,14 @@ static void dw_edma_done_interrupt(struct dw_edma_chan *chan)switch (chan->request) {case EDMA_REQ_NONE : desc =vd2dw_edma_desc (vd); -if (desc->chunks_alloc) { - chan->status =EDMA_ST_BUSY ; -dw_edma_start_transfer (chan); - }else { +if (!desc->chunks_alloc) {list_del (&vd->node);vchan_cookie_complete (vd); - chan->status =EDMA_ST_IDLE ; } + +/* Continue transferring if there are remaining chunks or issued requests. +*/ + chan->status =dw_edma_start_transfer (chan) ?EDMA_ST_BUSY :EDMA_ST_IDLE ;break ;case EDMA_REQ_STOP :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 270/381 dmaengine: dw-edma: Fix to enable to issue dma request on DMA processing
In reply to Greg Kroah-HartmanFrom: Shunsuke Mie <[email protected]>
[ Upstream commit 970b17dfe264a9085ba4e593730ecfd496b950ab ]
The issue_pending request is ignored while driver is processing a DMA request. Fix to issue the pending requests on any dma channel status.
--- drivers/dma/dw-edma/dw-edma-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/dma/dw-edma/dw-edma-core.c +5 -2
@@ -276,9 +276,12 @@ static void dw_edma_device_issue_pending(struct dma_chan *dchan)struct dw_edma_chan *chan =dchan2dw_edma_chan (dchan);unsigned long flags; +if (!chan->configured) +return ; +spin_lock_irqsave (&chan->vc.lock, flags); -if (chan->configured && chan->request ==EDMA_REQ_NONE && - chan->status ==EDMA_ST_IDLE &&vchan_issue_pending (&chan->vc)) { +if (vchan_issue_pending (&chan->vc) && chan->request ==EDMA_REQ_NONE && + chan->status ==EDMA_ST_IDLE ) { chan->status =EDMA_ST_BUSY ;dw_edma_start_transfer (chan); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 271/381 dmaengine: at_xdmac: do not enable all cyclic channels
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit f8435befd81dd85b7b610598551fadf675849bc1 ]
Do not global enable all the cyclic channels in at_xdmac_resume(). Instead save the global status in at_xdmac_suspend() and re-enable the cyclic channel only if it was active before suspend.
--- drivers/dma/at_xdmac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/dma/at_xdmac.c +4 -1
@@ -212,6 +212,7 @@ struct at_xdmac {int irq;struct clk *clk;u32 save_gim; +u32 save_gs;struct dma_pool *at_xdmac_desc_pool;struct at_xdmac_chan chan[]; };
@@ -1910,6 +1911,7 @@ static int atmel_xdmac_suspend(struct device *dev) } } atxdmac->save_gim =at_xdmac_read (atxdmac,AT_XDMAC_GIM ); + atxdmac->save_gs =at_xdmac_read (atxdmac,AT_XDMAC_GS );at_xdmac_off (atxdmac);clk_disable_unprepare (atxdmac->clk);
@@ -1946,7 +1948,8 @@ static int atmel_xdmac_resume(struct device *dev)at_xdmac_chan_write (atchan,AT_XDMAC_CNDC , atchan->save_cndc);at_xdmac_chan_write (atchan,AT_XDMAC_CIE , atchan->save_cim);wmb (); -at_xdmac_write (atxdmac,AT_XDMAC_GE , atchan->mask); +if (atxdmac->save_gs & atchan->mask) +at_xdmac_write (atxdmac,AT_XDMAC_GE , atchan->mask); } }return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 272/381 thermal/drivers/mediatek: Use devm_of_iomap to avoid resource leak in mtk_thermal_probe
In reply to Greg Kroah-HartmanFrom: Kang Chen <[email protected]>
[ Upstream commit f05c7b7d9ea9477fcc388476c6f4ade8c66d2d26 ]
Smatch reports:
1. mtk_thermal_probe() warn: 'apmixed_base' from of_iomap() not released.
2. mtk_thermal_probe() warn: 'auxadc_base' from of_iomap() not released.
The original code forgets to release iomap resource when handling errors, fix it by switch to devm_of_iomap.
--- drivers/thermal/mtk_thermal.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/thermal/mtk_thermal.c +12 -2
@@ -1026,7 +1026,12 @@ static int mtk_thermal_probe(struct platform_device *pdev)return -ENODEV ; } - auxadc_base =of_iomap (auxadc,0 ); + auxadc_base =devm_of_iomap (&pdev->dev, auxadc,0 ,NULL ); +if (IS_ERR (auxadc_base)) { +of_node_put (auxadc); +return PTR_ERR (auxadc_base); + } + auxadc_phys_base =of_get_phys_base (auxadc);of_node_put (auxadc);
@@ -1042,7 +1047,12 @@ static int mtk_thermal_probe(struct platform_device *pdev)return -ENODEV ; } - apmixed_base =of_iomap (apmixedsys,0 ); + apmixed_base =devm_of_iomap (&pdev->dev, apmixedsys,0 ,NULL ); +if (IS_ERR (apmixed_base)) { +of_node_put (apmixedsys); +return PTR_ERR (apmixed_base); + } + apmixed_phys_base =of_get_phys_base (apmixedsys);of_node_put (apmixedsys);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 273/381 mfd: tqmx86: Do not access I2C_DETECT register through io_base
In reply to Greg Kroah-HartmanFrom: Matthias Schiffer <[email protected]>
[ Upstream commit 1be1b23696b3d4b0231c694f5e0767b4471d33a9 ]
The I2C_DETECT register is at IO port 0x1a7, which is outside the range passed to devm_ioport_map() for io_base, and was only working because there aren't actually any bounds checks for IO port accesses.
Extending the range does not seem like a good solution here, as it would then conflict with the IO resource assigned to the I2C controller. As this is just a one-off access during probe, use a simple inb() instead.
While we're at it, drop the unused define TQMX86_REG_I2C_INT_EN.
--- drivers/mfd/tqmx86.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/mfd/tqmx86.c +7 -3
@@ -45,9 +45,8 @@#define TQMX86_REG_IO_EXT_INT_MASK 0x3#define TQMX86_REG_IO_EXT_INT_GPIO_SHIFT 4 -#define TQMX86_REG_I2C_DETECT 0x47 +#define TQMX86_REG_I2C_DETECT 0x1a7#define TQMX86_REG_I2C_DETECT_SOFT 0xa5 -#define TQMX86_REG_I2C_INT_EN 0x49static uint gpio_irq;module_param (gpio_irq, uint,0 );
@@ -195,7 +194,12 @@ static int tqmx86_probe(struct platform_device *pdev)"Found %s - Board ID %d, PCB Revision %d, PLD Revision %d\n" , board_name, board_id, rev >> 4, rev & 0xf); - i2c_det =ioread8 (io_base +TQMX86_REG_I2C_DETECT ); +/* +* The I2C_DETECT register is in the range assigned to the I2C driver +* later, so we don't extend TQMX86_IOSIZE. Use inb() for this one-off +* access instead of ioport_map + unmap. +*/ + i2c_det =inb (TQMX86_REG_I2C_DETECT );if (gpio_irq_cfg) { io_ext_int_val =
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 274/381 mfd: tqmx86: Remove incorrect TQMx90UC board ID
In reply to Greg Kroah-HartmanFrom: Matthias Schiffer <[email protected]>
[ Upstream commit 16b2ad150f74db0eb91f445061f16140b5aaa650 ]
No TQMx90UC exists at the moment, and it is undecided whether ID 10 will be used eventually (and if it is, how that SoM will be named).
Stable-dep-of: 051c69ff4f60 ("mfd: tqmx86: Specify IO port register range more precisely")
--- drivers/mfd/tqmx86.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/mfd/tqmx86.c +0 -4
@@ -35,7 +35,6 @@#define TQMX86_REG_BOARD_ID_E39x 7#define TQMX86_REG_BOARD_ID_70EB 8#define TQMX86_REG_BOARD_ID_80UC 9 -#define TQMX86_REG_BOARD_ID_90UC 10#define TQMX86_REG_BOARD_REV 0x21#define TQMX86_REG_IO_EXT_INT 0x26#define TQMX86_REG_IO_EXT_INT_NONE 0
@@ -127,8 +126,6 @@ static const char *tqmx86_board_id_to_name(u8 board_id)return "TQMx70EB" ;case TQMX86_REG_BOARD_ID_80UC :return "TQMx80UC" ; -case TQMX86_REG_BOARD_ID_90UC : -return "TQMx90UC" ;default :return "Unknown" ; }
@@ -141,7 +138,6 @@ static int tqmx86_board_id_to_clk_rate(u8 board_id)case TQMX86_REG_BOARD_ID_60EB :case TQMX86_REG_BOARD_ID_70EB :case TQMX86_REG_BOARD_ID_80UC : -case TQMX86_REG_BOARD_ID_90UC :return 24000 ;case TQMX86_REG_BOARD_ID_E39M :case TQMX86_REG_BOARD_ID_E39C :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 275/381 mfd: tqmx86: Add support for TQMx110EB and TQMxE40x
In reply to Greg Kroah-HartmanFrom: Matthias Schiffer <[email protected]>
[ Upstream commit 3da48ccb1d0f3b53b1e8c9022edbedc2a6e3f50a ]
Add the board IDs for the TQMx110EB and the TQMxE40x family. All use a 24MHz LPC clock.
Stable-dep-of: 051c69ff4f60 ("mfd: tqmx86: Specify IO port register range more precisely")
--- drivers/mfd/tqmx86.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/mfd/tqmx86.c +20 -0
@@ -35,6 +35,11 @@#define TQMX86_REG_BOARD_ID_E39x 7#define TQMX86_REG_BOARD_ID_70EB 8#define TQMX86_REG_BOARD_ID_80UC 9 +#define TQMX86_REG_BOARD_ID_110EB 11 +#define TQMX86_REG_BOARD_ID_E40M 12 +#define TQMX86_REG_BOARD_ID_E40S 13 +#define TQMX86_REG_BOARD_ID_E40C1 14 +#define TQMX86_REG_BOARD_ID_E40C2 15#define TQMX86_REG_BOARD_REV 0x21#define TQMX86_REG_IO_EXT_INT 0x26#define TQMX86_REG_IO_EXT_INT_NONE 0
@@ -126,6 +131,16 @@ static const char *tqmx86_board_id_to_name(u8 board_id)return "TQMx70EB" ;case TQMX86_REG_BOARD_ID_80UC :return "TQMx80UC" ; +case TQMX86_REG_BOARD_ID_110EB : +return "TQMx110EB" ; +case TQMX86_REG_BOARD_ID_E40M : +return "TQMxE40M" ; +case TQMX86_REG_BOARD_ID_E40S : +return "TQMxE40S" ; +case TQMX86_REG_BOARD_ID_E40C1 : +return "TQMxE40C1" ; +case TQMX86_REG_BOARD_ID_E40C2 : +return "TQMxE40C2" ;default :return "Unknown" ; }
@@ -138,6 +153,11 @@ static int tqmx86_board_id_to_clk_rate(u8 board_id)case TQMX86_REG_BOARD_ID_60EB :case TQMX86_REG_BOARD_ID_70EB :case TQMX86_REG_BOARD_ID_80UC : +case TQMX86_REG_BOARD_ID_110EB : +case TQMX86_REG_BOARD_ID_E40M : +case TQMX86_REG_BOARD_ID_E40S : +case TQMX86_REG_BOARD_ID_E40C1 : +case TQMX86_REG_BOARD_ID_E40C2 :return 24000 ;case TQMX86_REG_BOARD_ID_E39M :case TQMX86_REG_BOARD_ID_E39C :
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 276/381 mfd: tqmx86: Specify IO port register range more precisely
In reply to Greg Kroah-HartmanFrom: Matthias Schiffer <[email protected]>
[ Upstream commit 051c69ff4f607aa114c7bbdd7c41ed881367aeee ]
Registers 0x160..0x17f are unassigned. Use 0x180 as base register and update offets accordingly.
Also change the size of the range to include 0x19f. While 0x19f is currently reserved for future extensions, so are several of the previous registers up to 0x19e, and it is weird to leave out just the last one.
--- drivers/mfd/tqmx86.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mfd/tqmx86.c +5 -5
@@ -16,8 +16,8 @@#include <linux/platform_data/i2c-ocores.h> #include <linux/platform_device.h> -#define TQMX86_IOBASE 0x160 -#define TQMX86_IOSIZE 0x3f +#define TQMX86_IOBASE 0x180 +#define TQMX86_IOSIZE 0x20#define TQMX86_IOBASE_I2C 0x1a0#define TQMX86_IOSIZE_I2C 0xa#define TQMX86_IOBASE_WATCHDOG 0x18b
@@ -25,7 +25,7 @@#define TQMX86_IOBASE_GPIO 0x18d#define TQMX86_IOSIZE_GPIO 0x4 -#define TQMX86_REG_BOARD_ID 0x20 +#define TQMX86_REG_BOARD_ID 0x00#define TQMX86_REG_BOARD_ID_E38M 1#define TQMX86_REG_BOARD_ID_50UC 2#define TQMX86_REG_BOARD_ID_E38C 3
@@ -40,8 +40,8 @@#define TQMX86_REG_BOARD_ID_E40S 13#define TQMX86_REG_BOARD_ID_E40C1 14#define TQMX86_REG_BOARD_ID_E40C2 15 -#define TQMX86_REG_BOARD_REV 0x21 -#define TQMX86_REG_IO_EXT_INT 0x26 +#define TQMX86_REG_BOARD_REV 0x01 +#define TQMX86_REG_IO_EXT_INT 0x06#define TQMX86_REG_IO_EXT_INT_NONE 0#define TQMX86_REG_IO_EXT_INT_7 1#define TQMX86_REG_IO_EXT_INT_9 2
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 277/381 mfd: tqmx86: Correct board names for TQMxE39x
In reply to Greg Kroah-HartmanFrom: Matthias Schiffer <[email protected]>
[ Upstream commit f376c479668557bcc2fd9e9fbc0f53e7819a11cd ]
It seems that this driver was developed based on preliminary documentation. Report the correct names for all TQMxE39x variants, as they are used by the released hardware revisions:
- Fix names for TQMxE39C1/C2 board IDs
- Distinguish TQMxE39M and TQMxE39S, which use the same board ID
The TQMxE39M/S are distinguished using the SAUC (Sanctioned Alternate Uses Configuration) register of the GPIO controller. This also prepares for the correct handling of the differences between the GPIO controllers of our COMe and SMARC modules.
--- drivers/mfd/tqmx86.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
drivers/mfd/tqmx86.c +17 -15
@@ -30,9 +30,9 @@#define TQMX86_REG_BOARD_ID_50UC 2#define TQMX86_REG_BOARD_ID_E38C 3#define TQMX86_REG_BOARD_ID_60EB 4 -#define TQMX86_REG_BOARD_ID_E39M 5 -#define TQMX86_REG_BOARD_ID_E39C 6 -#define TQMX86_REG_BOARD_ID_E39x 7 +#define TQMX86_REG_BOARD_ID_E39MS 5 +#define TQMX86_REG_BOARD_ID_E39C1 6 +#define TQMX86_REG_BOARD_ID_E39C2 7#define TQMX86_REG_BOARD_ID_70EB 8#define TQMX86_REG_BOARD_ID_80UC 9#define TQMX86_REG_BOARD_ID_110EB 11
@@ -48,6 +48,7 @@#define TQMX86_REG_IO_EXT_INT_12 3#define TQMX86_REG_IO_EXT_INT_MASK 0x3#define TQMX86_REG_IO_EXT_INT_GPIO_SHIFT 4 +#define TQMX86_REG_SAUC 0x17#define TQMX86_REG_I2C_DETECT 0x1a7#define TQMX86_REG_I2C_DETECT_SOFT 0xa5
@@ -110,7 +111,7 @@ static const struct mfd_cell tqmx86_devs[] = { }, }; -static const char *tqmx86_board_id_to_name (u8 board_id) +static const char *tqmx86_board_id_to_name (u8 board_id,u8 sauc) {switch (board_id) {case TQMX86_REG_BOARD_ID_E38M :
@@ -121,12 +122,12 @@ static const char *tqmx86_board_id_to_name(u8 board_id)return "TQMxE38C" ;case TQMX86_REG_BOARD_ID_60EB :return "TQMx60EB" ; -case TQMX86_REG_BOARD_ID_E39M : -return "TQMxE39M" ; -case TQMX86_REG_BOARD_ID_E39C : -return "TQMxE39C" ; -case TQMX86_REG_BOARD_ID_E39x: -return "TQMxE39x" ; +case TQMX86_REG_BOARD_ID_E39MS : +return (sauc ==0xff ) ?"TQMxE39M" :"TQMxE39S" ; +case TQMX86_REG_BOARD_ID_E39C1 : +return "TQMxE39C1" ; +case TQMX86_REG_BOARD_ID_E39C2 : +return "TQMxE39C2" ;case TQMX86_REG_BOARD_ID_70EB :return "TQMx70EB" ;case TQMX86_REG_BOARD_ID_80UC :
@@ -159,9 +160,9 @@ static int tqmx86_board_id_to_clk_rate(u8 board_id)case TQMX86_REG_BOARD_ID_E40C1 :case TQMX86_REG_BOARD_ID_E40C2 :return 24000 ; -case TQMX86_REG_BOARD_ID_E39M : -case TQMX86_REG_BOARD_ID_E39C : -case TQMX86_REG_BOARD_ID_E39x: +case TQMX86_REG_BOARD_ID_E39MS : +case TQMX86_REG_BOARD_ID_E39C1 : +case TQMX86_REG_BOARD_ID_E39C2 :return 25000 ;case TQMX86_REG_BOARD_ID_E38M :case TQMX86_REG_BOARD_ID_E38C :
@@ -173,7 +174,7 @@ static int tqmx86_board_id_to_clk_rate(u8 board_id)static int tqmx86_probe (struct platform_device *pdev) { -u8 board_id, rev, i2c_det, io_ext_int_val; +u8 board_id, sauc, rev, i2c_det, io_ext_int_val;struct device *dev = &pdev->dev;u8 gpio_irq_cfg, readback;const char *board_name;
@@ -203,7 +204,8 @@ static int tqmx86_probe(struct platform_device *pdev)return -ENOMEM ; board_id =ioread8 (io_base +TQMX86_REG_BOARD_ID ); - board_name =tqmx86_board_id_to_name (board_id); + sauc =ioread8 (io_base +TQMX86_REG_SAUC ); + board_name =tqmx86_board_id_to_name (board_id, sauc); rev =ioread8 (io_base +TQMX86_REG_BOARD_REV ); dev_info(dev,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 278/381 afs: Fix updating of i_size with dv jump from server
In reply to Greg Kroah-HartmanFrom: Marc Dionne <[email protected]>
[ Upstream commit d7f74e9a917503ee78f2b603a456d7227cf38919 ]
If the data version returned from the server is larger than expected, the local data is invalidated, but we may still want to note the remote file size.
Since we're setting change_size, we have to also set data_changed for the i_size to get updated.
--- fs/afs/inode.c | 1 + 1 file changed, 1 insertion(+)
fs/afs/inode.c +1 -0
@@ -218,6 +218,7 @@ static void afs_apply_status(struct afs_operation *op,set_bit (AFS_VNODE_ZAP_DATA , &vnode->flags); } change_size = true; + data_changed = true; }else if (vnode->status.type ==AFS_FTYPE_DIR ) {/* Expected directory change is handled elsewhere so * that we can locally edit the directory and save on a
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 279/381 scripts/gdb: fix lx-timerlist for Python3
In reply to Greg Kroah-HartmanFrom: Peng Liu <[email protected]>
commit 7362042f3556528e9e9b1eb5ce8d7a3a6331476b upstream.
Below incompatibilities between Python2 and Python3 made lx-timerlist fail to run under Python3.
o xrange() is replaced by range() in Python3
o bytes and str are different types in Python3
o the return value of Inferior.read_memory() is memoryview object in Python3
akpm: cc stable so that older kernels are properly debuggable under newer Python.
--- scripts/gdb/linux/timerlist.py | 4 +++- scripts/gdb/linux/utils.py | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-)
scripts/gdb/linux/timerlist.py +3 -1
@@ -73,7 +73,7 @@ def print_cpu(hrtimer_bases, cpu, max_cl ts = cpus.per_cpu(tick_sched_ptr, cpu) text = "cpu: {}\n".format(cpu) - for i in xrange(max_clock_bases): + for i in range(max_clock_bases): text += " clock {}:\n".format(i) text += print_base(cpu_base['clock_base'][i])
@@ -158,6 +158,8 @@ def pr_cpumask(mask): num_bytes = (nr_cpu_ids + 7) / 8 buf = utils.read_memoryview(inf, bits, num_bytes).tobytes() buf = binascii.b2a_hex(buf) + if type(buf) is not str: + buf=buf.decode() chunks = [] i = num_bytes
scripts/gdb/linux/utils.py +4 -1
@@ -89,7 +89,10 @@ def get_target_endianness(): def read_memoryview(inf, start, length): - return memoryview(inf.read_memory(start, length)) + m = inf.read_memory(start, length) + if type(m) is memoryview: + return m + return memoryview(m) def read_u16(buffer, offset):
Greg Kroah-Hartman
maintainerPATCH 280/381 btrfs: scrub: reject unsupported scrub flags
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit 604e6681e114d05a2e384c4d1e8ef81918037ef5 upstream.
Since the introduction of scrub interface, the only flag that we support is BTRFS_SCRUB_READONLY. Thus there is no sanity checks, if there are some undefined flags passed in, we just ignore them.
This is problematic if we want to introduce new scrub flags, as we have no way to determine if such flags are supported.
Address the problem by introducing a check for the flags, and if unsupported flags are set, return -EOPNOTSUPP to inform the user space.
This check should be backported for all supported kernels before any new scrub flags are introduced.
--- fs/btrfs/ioctl.c | 5 +++++ include/uapi/linux/btrfs.h | 1 + 2 files changed, 6 insertions(+)
fs/btrfs/ioctl.c +5 -0
@@ -3702,6 +3702,11 @@ static long btrfs_ioctl_scrub(struct filif (IS_ERR (sa))return PTR_ERR (sa); +if (sa->flags & ~BTRFS_SCRUB_SUPPORTED_FLAGS ) { + ret = -EOPNOTSUPP ; + goto out; + } +if (!(sa->flags &BTRFS_SCRUB_READONLY )) { ret =mnt_want_write_file (file);if (ret)
include/uapi/linux/btrfs.h +1 -0
@@ -181,6 +181,7 @@ struct btrfs_scrub_progress { };#define BTRFS_SCRUB_READONLY 1 +#define BTRFS_SCRUB_SUPPORTED_FLAGS (BTRFS_SCRUB_READONLY)struct btrfs_ioctl_scrub_args {__u64 devid;/* in */ __u64 start;/* in */
Greg Kroah-Hartman
maintainerPATCH 281/381 s390/dasd: fix hanging blockdevice after request requeue
In reply to Greg Kroah-HartmanFrom: Stefan Haberland <[email protected]>
commit d8898ee50edecacdf0141f26fd90acf43d7e9cd7 upstream.
The DASD driver does not kick the requeue list when requeuing IO requests to the blocklayer. This might lead to hanging blockdevice when there is no other trigger for this.
Fix by automatically kick the requeue list when requeuing DASD requests to the blocklayer.
--- drivers/s390/block/dasd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/block/dasd.c +1 -1
@@ -3000,7 +3000,7 @@ static int _dasd_requeue_request(structreturn 0 ;spin_lock_irq (&cqr->dq->lock); req = (struct request *) cqr->callback_data; -blk_mq_requeue_request (req, false); +blk_mq_requeue_request (req, true);spin_unlock_irq (&cqr->dq->lock);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 282/381 ia64: fix an addr to taddr in huge_pte_offset()
In reply to Greg Kroah-HartmanFrom: Hugh Dickins <[email protected]>
commit 3647ebcfbfca384840231fe13fae665453238a61 upstream.
I know nothing of ia64 htlbpage_to_page(), but guess that the p4d line should be using taddr rather than addr, like everywhere else.
--- arch/ia64/mm/hugetlbpage.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/mm/hugetlbpage.c +1 -1
@@ -57,7 +57,7 @@ huge_pte_offset (struct mm_struct *mm, u pgd =pgd_offset (mm, taddr);if (pgd_present (*pgd)) { - p4d =p4d_offset (pgd, addr); + p4d =p4d_offset (pgd, taddr);if (p4d_present (*p4d)) { pud =pud_offset (p4d, taddr);if (pud_present (*pud)) {
Greg Kroah-Hartman
maintainerPATCH 283/381 dm clone: call kmem_cache_destroy() in dm_clone_init() error path
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
commit 6827af4a9a9f5bb664c42abf7c11af4978d72201 upstream.
Otherwise the _hydration_cache will leak if dm_register_target() fails.
--- drivers/md/dm-clone-target.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/dm-clone-target.c +1 -0
@@ -2221,6 +2221,7 @@ static int __init dm_clone_init(void) r =dm_register_target (&clone_target);if (r <0 ) {DMERR ("Failed to register clone target" ); +kmem_cache_destroy (_hydration_cache);return r; }
Greg Kroah-Hartman
maintainerPATCH 284/381 dm integrity: call kmem_cache_destroy() in dm_integrity_init() error path
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
commit 6b79a428c02769f2a11f8ae76bf866226d134887 upstream.
Otherwise the journal_io_cache will leak if dm_register_target() fails.
--- drivers/md/dm-integrity.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/md/dm-integrity.c +5 -3
@@ -4481,11 +4481,13 @@ static int __init dm_integrity_init(void } r =dm_register_target (&integrity_target); - -if (r <0 ) +if (r <0 ) {DMERR ("register failed %d" , r); +kmem_cache_destroy (journal_io_cache); +return r; + } -return r; +return 0 ; } static void __exit dm_integrity_exit(void)
Greg Kroah-Hartman
maintainerPATCH 285/381 dm flakey: fix a crash with invalid table line
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit 98dba02d9a93eec11bffbb93c7c51624290702d2 upstream.
This command will crash with NULL pointer dereference:
dmsetup create flakey --table \
"0 blockdev --getsize /dev/ram0 flakey /dev/ram0 0 0 1 2 corrupt_bio_byte 512"
Fix the crash by checking if arg_name is non-NULL before comparing it.
--- drivers/md/dm-flakey.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-flakey.c +2 -2
@@ -124,9 +124,9 @@ static int parse_features(struct dm_arg_* Direction r or w? */ arg_name =dm_shift_arg (as); -if (!strcasecmp (arg_name,"w" )) +if (arg_name && !strcasecmp (arg_name,"w" )) fc->corrupt_bio_rw =WRITE ; -else if (!strcasecmp (arg_name,"r" )) +else if (arg_name && !strcasecmp (arg_name,"r" )) fc->corrupt_bio_rw =READ ;else { ti->error ="Invalid corrupt bio direction (r or w)" ;
Greg Kroah-Hartman
maintainerPATCH 286/381 dm ioctl: fix nested locking in table_clear() to remove deadlock concern
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
commit 3d32aaa7e66d5c1479a3c31d6c2c5d45dd0d3b89 upstream.
syzkaller found the following problematic rwsem locking (with write lock already held):
down_read+0x9d/0x450 kernel/locking/rwsem.c:1509 dm_get_inactive_table+0x2b/0xc0 drivers/md/dm-ioctl.c:773 __dev_status+0x4fd/0x7c0 drivers/md/dm-ioctl.c:844 table_clear+0x197/0x280 drivers/md/dm-ioctl.c:1537
In table_clear, it first acquires a write lock
https://elixir.bootlin.com/linux/v6.2/source/drivers/md/dm-ioctl.c#L1520down_write(&_hash_lock);
Then before the lock is released at L1539, there is a path shown above:table_clear -> __dev_status -> dm_get_inactive_table -> down_read
https://elixir.bootlin.com/linux/v6.2/source/drivers/md/dm-ioctl.c#L773down_read(&_hash_lock);
It tries to acquire the same read lock again, resulting in the deadlock problem.
Fix this by moving table_clear()'s __dev_status() call to after its up_write(&_hash_lock);
--- drivers/md/dm-ioctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/md/dm-ioctl.c +4 -3
@@ -1435,11 +1435,12 @@ static int table_clear(struct file *filp hc->new_map =NULL ; } - param->flags &= ~DM_INACTIVE_PRESENT_FLAG ; - -__dev_status (hc->md, param); md = hc->md;up_write (&_hash_lock); + + param->flags &= ~DM_INACTIVE_PRESENT_FLAG ; +__dev_status (md, param); +if (old_map) {dm_sync_table (md);dm_table_destroy (old_map);
Greg Kroah-Hartman
maintainerPATCH 287/381 perf auxtrace: Fix address filter entire kernel size
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
commit 1f9f33ccf0320be21703d9195dd2b36a1c9a07cb upstream.
kallsyms is not completely in address order.
In find_entire_kern_cb(), calculate the kernel end from the maximum address not the last symbol.
Example:
Before:
$ sudo cat /proc/kallsyms | grep ' [twTw] ' | tail -1
ffffffffc00b8bd0 t bpf_prog_6deef7357e7b4530 [bpf]
$ sudo cat /proc/kallsyms | grep ' [twTw] ' | sort | tail -1
ffffffffc15e0cc0 t iwl_mvm_exit [iwlmvm]
$ perf.d093603a05aa record -v --kcore -e intel_pt// --filter 'filter *' -- uname |& grep filter
Address filter: filter 0xffffffff93200000/0x2ceba000After:
$ perf.8fb0f7a01f8e record -v --kcore -e intel_pt// --filter 'filter *' -- uname |& grep filter
Address filter: filter 0xffffffff93200000/0x2e3e2000--- tools/perf/util/auxtrace.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/util/auxtrace.c +4 -1
@@ -2279,6 +2279,7 @@ static int find_entire_kern_cb(void *arg char type, u64 start) {struct sym_args *args = arg; +u64 size;if (!kallsyms__is_function (type))return 0 ;
@@ -2288,7 +2289,9 @@ static int find_entire_kern_cb(void *arg args->start = start; }/* Don't know exactly where the kernel ends, so we add a page */ - args->size =round_up (start, page_size) + page_size - args->start; + size =round_up (start, page_size) + page_size - args->start; +if (size > args->size) + args->size = size;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 288/381 perf intel-pt: Fix CYC timestamps after standalone CBR
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
commit 430635a0ef1ce958b7b4311f172694ece2c692b8 upstream.
After a standalone CBR (not associated with TSC), update the cycles reference timestamp and reset the cycle count, so that CYC timestamps are calculated relative to that point with the new frequency.
--- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +2 -0
@@ -1639,6 +1639,8 @@ static void intel_pt_calc_cbr(struct int decoder->cbr = cbr; decoder->cbr_cyc_to_tsc = decoder->max_non_turbo_ratio_fp / cbr; + decoder->cyc_ref_timestamp = decoder->timestamp; + decoder->cycle_cnt =0 ;intel_pt_mtc_cyc_cnt_cbr (decoder); }
Greg Kroah-Hartman
maintainerPATCH 289/381 arm64: Always load shadow stack pointer directly from the task struct
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit 2198d07c509f1db4a1185d1f65aaada794c6ea59 upstream.
All occurrences of the scs_load macro load the value of the shadow call stack pointer from the task which is current at that point. So instead of taking a task struct register argument in the scs_load macro to specify the task struct to load from, let's always reference the current task directly. This should make it much harder to exploit any instruction sequences reloading the shadow call stack pointer register from memory.
--- arch/arm64/include/asm/scs.h | 7 ++++--- arch/arm64/kernel/entry.S | 4 ++-- arch/arm64/kernel/head.S | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-)
arch/arm64/include/asm/scs.h +4 -3
@@ -9,15 +9,16 @@#ifdef CONFIG_SHADOW_CALL_STACK scs_sp .req x18 - .macro scs_load tsk, tmp - ldr scs_sp, [\tsk, #TSK_TI_SCS_SP] + .macro scs_load_current + get_current_task scs_sp + ldr scs_sp, [scs_sp, #TSK_TI_SCS_SP] .endm .macro scs_save tsk, tmp str scs_sp, [\tsk, #TSK_TI_SCS_SP] .endm #else - .macro scs_load tsk, tmp + .macro scs_load_current .endm .macro scs_save tsk, tmp
arch/arm64/kernel/entry.S +2 -2
@@ -221,7 +221,7 @@ alternative_else_nop_endif ptrauth_keys_install_kernel tsk, x20, x22, x23 - scs_load tsk, x20 + scs_load_current .else add x21, sp, #S_FRAME_SIZE get_current_task tsk
@@ -1025,7 +1025,7 @@ SYM_FUNC_START(cpu_switch_to) msr sp_el0, x1 ptrauth_keys_install_kernel x1, x8, x9, x10 scs_save x0, x8 - scs_load x1, x8 + scs_load_current ret SYM_FUNC_END(cpu_switch_to) NOKPROBE(cpu_switch_to)
arch/arm64/kernel/head.S +1 -1
@@ -747,7 +747,7 @@ SYM_FUNC_START_LOCAL(__secondary_switche ldr x2, [x0, #CPU_BOOT_TASK] cbz x2, __secondary_too_slow msr sp_el0, x2 - scs_load x2, x3 + scs_load_current mov x29, #0 mov x30, #0
Greg Kroah-Hartman
maintainerPATCH 290/381 arm64: Stash shadow stack pointer in the task struct on interrupt
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
commit 59b37fe52f49955791a460752c37145f1afdcad1 upstream.
Instead of reloading the shadow call stack pointer from the ordinary stack, which may be vulnerable to the kind of gadget based attacks shadow call stacks were designed to prevent, let's store a task's shadow call stack pointer in the task struct when switching to the shadow IRQ stack.
Given that currently, the task_struct::scs_sp field is only used to preserve the shadow call stack pointer while a task is scheduled out or running in user space, reusing this field to preserve and restore it while running off the IRQ stack must be safe, as those occurrences are guaranteed to never overlap. (The stack switching logic only switches stacks when running from the task stack, and so the value being saved here always corresponds to the task mode shadow stack)
While at it, fold a mov/add/mov sequence into a single add.
--- arch/arm64/kernel/entry.S | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/arm64/kernel/entry.S +2 -6
@@ -431,9 +431,7 @@ SYM_CODE_END(__swpan_exit_el0) .macro irq_stack_entry mov x19, sp // preserve the original sp -#ifdef CONFIG_SHADOW_CALL_STACK - mov x24, scs_sp // preserve the original shadow stack -#endif + scs_save tsk // preserve the original shadow stack /* * Compare sp with the base of the task stack.
@@ -467,9 +465,7 @@ SYM_CODE_END(__swpan_exit_el0) */ .macro irq_stack_exit mov sp, x19 -#ifdef CONFIG_SHADOW_CALL_STACK - mov scs_sp, x24 -#endif + scs_load_current .endm /* GPRs used by entry code */
Greg Kroah-Hartman
maintainerPATCH 291/381 debugobject: Ensure pool refill (again)
In reply to Greg Kroah-HartmanFrom: Thomas Gleixner <[email protected]>
commit 0af462f19e635ad522f28981238334620881badc upstream.
The recent fix to ensure atomicity of lookup and allocation inadvertently broke the pool refill mechanism.
Prior to that change debug_objects_activate() and debug_objecs_assert_init() invoked debug_objecs_init() to set up the tracking object for statically initialized objects. That's not longer the case and debug_objecs_init() is now the only place which does pool refills.
Depending on the number of statically initialized objects this can be enough to actually deplete the pool, which was observed by Ido via a debugobjects OOM warning.
Restore the old behaviour by adding explicit refill opportunities to debug_objects_activate() and debug_objecs_assert_init().
--- lib/debugobjects.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
lib/debugobjects.c +15 -1
@@ -590,6 +590,16 @@ static struct debug_obj *lookup_object_oreturn NULL ; } +static void debug_objects_fill_pool (void ) +{ +/* +* On RT enabled kernels the pool refill must happen in preemptible +* context: +*/ +if (!IS_ENABLED (CONFIG_PREEMPT_RT ) ||preemptible ()) +fill_pool (); +} +static void __debug_object_init (void *addr,const struct debug_obj_descr *descr,int onstack) {
@@ -598,7 +608,7 @@ __debug_object_init(void *addr, const ststruct debug_obj *obj;unsigned long flags; -fill_pool (); +debug_objects_fill_pool (); db =get_bucket ((unsigned long ) addr);
@@ -683,6 +693,8 @@ int debug_object_activate(void *addr, coif (!debug_objects_enabled)return 0 ; +debug_objects_fill_pool (); + db =get_bucket ((unsigned long ) addr);raw_spin_lock_irqsave (&db->lock, flags);
@@ -892,6 +904,8 @@ void debug_object_assert_init(void *addrif (!debug_objects_enabled)return ; +debug_objects_fill_pool (); + db =get_bucket ((unsigned long ) addr);raw_spin_lock_irqsave (&db->lock, flags);
Greg Kroah-Hartman
maintainerPATCH 292/381 sound/oss/dmasound: fix dmasound_setup defined but not used
In reply to Greg Kroah-HartmanFrom: Miles Chen <[email protected]>
commit 357ad4d898286b94aaae0cb7e3f573459e5b98b9 upstream.
We observed: 'dmasound_setup' defined but not used error with COMPILER=gcc ARCH=m68k DEFCONFIG=allmodconfig build.
Fix it by adding __maybe_unused to dmasound_setup.
Error(s):sound/oss/dmasound/dmasound_core.c:1431:12: error: 'dmasound_setup' defined but not used [-Werror=unused-function]
--- sound/oss/dmasound/dmasound_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/oss/dmasound/dmasound_core.c +1 -1
@@ -1442,7 +1442,7 @@ void dmasound_deinit(void)unregister_sound_dsp (sq_unit); } -static int dmasound_setup (char *str) +static int __maybe_unused dmasound_setup (char *str) {int ints[6 ], size;
Greg Kroah-Hartman
maintainerPATCH 293/381 arm64: dts: qcom: sdm845: correct dynamic power coefficients - again
In reply to Greg Kroah-HartmanFrom: Vincent Guittot <[email protected]>
commit 44750f153699b6e4f851a399287e5c8df208d696 upstream.
While stressing EAS on my dragonboard RB3, I have noticed that LITTLE cores where never selected as the most energy efficient CPU whatever the utilization level of waking task.
energy model framework uses its cost field to estimate the energy with the formula:
nrg = cost of the selected OPP * utilization / CPU's max capacity
which ends up selecting the CPU with lowest cost / max capacity ration as long as the utilization fits in the OPP's capacity.
If we compare the cost of a little OPP with similar capacity of a big OPP like :
OPP(kHz) OPP capacity cost max capacity cost/max capacity LITTLE 1766400 407 351114 407 863 big 1056000 408 520267 1024 508
This can be interpreted as the LITTLE core consumes 70% more than big core for the same compute capacity.
According to [1], LITTLE consumes 10% less than big core for Coremark benchmark at those OPPs. If we consider that everything else stays unchanged, the dynamic-power-coefficient of LITTLE core should be only 53% of the current value: 290 * 53% = 154
Set the dynamic-power-coefficient of CPU0-3 to 154 to fix the energy model.
[1] https://github.com/kdrag0n/freqbench/tree/master/results/sdm845/main
--- arch/arm64/boot/dts/qcom/sdm845.dtsi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/qcom/sdm845.dtsi +4 -4
@@ -197,7 +197,7 @@ &LITTLE_CPU_SLEEP_1 &CLUSTER_SLEEP_0>; capacity-dmips-mhz = <611>; - dynamic-power-coefficient = <290>; + dynamic-power-coefficient = <154>; qcom,freq-domain = <&cpufreq_hw 0>; operating-points-v2 = <&cpu0_opp_table>; interconnects = <&gladiator_noc MASTER_APPSS_PROC 3 &mem_noc SLAVE_EBI1 3>,
@@ -222,7 +222,7 @@ &LITTLE_CPU_SLEEP_1 &CLUSTER_SLEEP_0>; capacity-dmips-mhz = <611>; - dynamic-power-coefficient = <290>; + dynamic-power-coefficient = <154>; qcom,freq-domain = <&cpufreq_hw 0>; operating-points-v2 = <&cpu0_opp_table>; interconnects = <&gladiator_noc MASTER_APPSS_PROC 3 &mem_noc SLAVE_EBI1 3>,
@@ -244,7 +244,7 @@ &LITTLE_CPU_SLEEP_1 &CLUSTER_SLEEP_0>; capacity-dmips-mhz = <611>; - dynamic-power-coefficient = <290>; + dynamic-power-coefficient = <154>; qcom,freq-domain = <&cpufreq_hw 0>; operating-points-v2 = <&cpu0_opp_table>; interconnects = <&gladiator_noc MASTER_APPSS_PROC 3 &mem_noc SLAVE_EBI1 3>,
@@ -266,7 +266,7 @@ &LITTLE_CPU_SLEEP_1 &CLUSTER_SLEEP_0>; capacity-dmips-mhz = <611>; - dynamic-power-coefficient = <290>; + dynamic-power-coefficient = <154>; qcom,freq-domain = <&cpufreq_hw 0>; operating-points-v2 = <&cpu0_opp_table>; interconnects = <&gladiator_noc MASTER_APPSS_PROC 3 &mem_noc SLAVE_EBI1 3>,
Greg Kroah-Hartman
maintainerPATCH 294/381 scsi: target: core: Avoid smp_processor_id() in preemptible code
In reply to Greg Kroah-HartmanFrom: Shin'ichiro Kawasaki <[email protected]>
commit 70ca3c57ff914113f681e657634f7fbfa68e1ad1 upstream.
The BUG message "BUG: using smp_processor_id() in preemptible [00000000] code" was observed for TCMU devices with kernel config DEBUG_PREEMPT.
The message was observed when blktests block/005 was run on TCMU devices with fileio backend or user:zbc backend [1]. The commit 1130b499b4a7 ("scsi: target: tcm_loop: Use LIO wq cmd submission helper") triggered the symptom. The commit modified work queue to handle commands and changed 'current->nr_cpu_allowed' at smp_processor_id() call.
The message was also observed at system shutdown when TCMU devices were not cleaned up [2]. The function smp_processor_id() was called in SCSI host work queue for abort handling, and triggered the BUG message. This symptom was observed regardless of the commit 1130b499b4a7 ("scsi: target:tcm_loop: Use LIO wq cmd submission helper").
To avoid the preemptible code check at smp_processor_id(), get CPU ID with raw_smp_processor_id() instead. The CPU ID is used for performance improvement then thread move to other CPU will not affect the code.
[1]
[ 56.468103] run blktests block/005 at 2021-05-12 14:16:38 [ 57.369473] check_preemption_disabled: 85 callbacks suppressed [ 57.369480] BUG: using smp_processor_id() in preemptible [00000000] code: fio/1511 [ 57.369506] BUG: using smp_processor_id() in preemptible [00000000] code: fio/1510 [ 57.369512] BUG: using smp_processor_id() in preemptible [00000000] code: fio/1506 [ 57.369552] caller is __target_init_cmd+0x157/0x170 [target_core_mod] [ 57.369606] CPU: 4 PID: 1506 Comm: fio Not tainted 5.13.0-rc1+ #34 [ 57.369613] Hardware name: System manufacturer System Product Name/PRIME Z270-A, BIOS 1302 03/15/2018 [ 57.369617] Call Trace: [ 57.369621] BUG: using smp_processor_id() in preemptible [00000000] code: fio/1507 [ 57.369628] dump_stack+0x6d/0x89 [ 57.369642] check_preemption_disabled+0xc8/0xd0 [ 57.369628] caller is __target_init_cmd+0x157/0x170 [target_core_mod] [ 57.369655] __target_init_cmd+0x157/0x170 [target_core_mod] [ 57.369695] target_init_cmd+0x76/0x90 [target_core_mod] [ 57.369732] tcm_loop_queuecommand+0x109/0x210 [tcm_loop] [ 57.369744] scsi_queue_rq+0x38e/0xc40 [ 57.369761] __blk_mq_try_issue_directly+0x109/0x1c0 [ 57.369779] blk_mq_try_issue_directly+0x43/0x90 [ 57.369790] blk_mq_submit_bio+0x4e5/0x5d0 [ 57.369812] submit_bio_noacct+0x46e/0x4e0 [ 57.369830] __blkdev_direct_IO_simple+0x1a3/0x2d0 [ 57.369859] ? set_init_blocksize.isra.0+0x60/0x60 [ 57.369880] generic_file_read_iter+0x89/0x160 [ 57.369898] blkdev_read_iter+0x44/0x60 [ 57.369906] new_sync_read+0x102/0x170 [ 57.369929] vfs_read+0xd4/0x160 [ 57.369941] __x64_sys_pread64+0x6e/0xa0 [ 57.369946] ? lockdep_hardirqs_on+0x79/0x100 [ 57.369958] do_syscall_64+0x3a/0x70 [ 57.369965] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 57.369973] RIP: 0033:0x7f7ed4c1399f [ 57.369979] Code: 08 89 3c 24 48 89 4c 24 18 e8 7d f3 ff ff 4c 8b 54 24 18 48 8b 54 24 10 41 89 c0 48 8b 74 24 08 8b 3c 24 b8 11 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 04 24 e8 cd f3 ff ff 48 8b [ 57.369983] RSP: 002b:00007ffd7918c580 EFLAGS: 00000293 ORIG_RAX: 0000000000000011 [ 57.369990] RAX: ffffffffffffffda RBX: 00000000015b4540 RCX: 00007f7ed4c1399f [ 57.369993] RDX: 0000000000001000 RSI: 00000000015de000 RDI: 0000000000000009 [ 57.369996] RBP: 00000000015b4540 R08: 0000000000000000 R09: 0000000000000001 [ 57.369999] R10: 0000000000e5c000 R11: 0000000000000293 R12: 00007f7eb5269a70 [ 57.370002] R13: 0000000000000000 R14: 0000000000001000 R15: 00000000015b4568 [ 57.370031] CPU: 7 PID: 1507 Comm: fio Not tainted 5.13.0-rc1+ #34 [ 57.370036] Hardware name: System manufacturer System Product Name/PRIME Z270-A, BIOS 1302 03/15/2018 [ 57.370039] Call Trace: [ 57.370045] dump_stack+0x6d/0x89 [ 57.370056] check_preemption_disabled+0xc8/0xd0 [ 57.370068] __target_init_cmd+0x157/0x170 [target_core_mod] [ 57.370121] target_init_cmd+0x76/0x90 [target_core_mod] [ 57.370178] tcm_loop_queuecommand+0x109/0x210 [tcm_loop] [ 57.370197] scsi_queue_rq+0x38e/0xc40 [ 57.370224] __blk_mq_try_issue_directly+0x109/0x1c0
...
[2]
[ 117.458597] BUG: using smp_processor_id() in preemptible [00000000] code: kworker/u16:8 [ 117.467279] caller is __target_init_cmd+0x157/0x170 [target_core_mod] [ 117.473893] CPU: 1 PID: 418 Comm: kworker/u16:6 Not tainted 5.13.0-rc1+ #34 [ 117.481150] Hardware name: System manufacturer System Product Name/PRIME Z270-A, BIOS 8 [ 117.481153] Workqueue: scsi_tmf_7 scmd_eh_abort_handler [ 117.481156] Call Trace: [ 117.481158] dump_stack+0x6d/0x89 [ 117.481162] check_preemption_disabled+0xc8/0xd0 [ 117.512575] target_submit_tmr+0x41/0x150 [target_core_mod] [ 117.519705] tcm_loop_issue_tmr+0xa7/0x100 [tcm_loop] [ 117.524913] tcm_loop_abort_task+0x43/0x60 [tcm_loop] [ 117.530137] scmd_eh_abort_handler+0x7b/0x230 [ 117.534681] process_one_work+0x268/0x580 [ 117.538862] worker_thread+0x55/0x3b0 [ 117.542652] ? process_one_work+0x580/0x580 [ 117.548351] kthread+0x143/0x160 [ 117.551675] ? kthread_create_worker_on_cpu+0x40/0x40 [ 117.556873] ret_from_fork+0x1f/0x30
--- drivers/target/target_core_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/target/target_core_transport.c +1 -1
@@ -1396,7 +1396,7 @@ void transport_init_se_cmd( cmd->orig_fe_lun = unpacked_lun;if (!(cmd->se_cmd_flags &SCF_USE_CPUID )) - cmd->cpuid =smp_processor_id (); + cmd->cpuid =raw_smp_processor_id (); cmd->state_active = false; }
Greg Kroah-Hartman
maintainerPATCH 295/381 netfilter: nf_tables: deactivate anonymous set from preparation phase
In reply to Greg Kroah-HartmanFrom: Pablo Neira Ayuso <[email protected]>
commit c1592a89942e9678f7d9c8030efa777c0d57edab upstream.
Toggle deleted anonymous sets as inactive in the next generation, so users cannot perform any update on it. Clear the generation bitmask in case the transaction is aborted.
The following KASAN splat shows a set element deletion for a bound anonymous set that has been already removed in the same transaction.
[ 64.921510] ================================================================== [ 64.923123] BUG: KASAN: wild-memory-access in nf_tables_commit+0xa24/0x1490 [nf_tables] [ 64.924745] Write of size 8 at addr dead000000000122 by task test/890 [ 64.927903] CPU: 3 PID: 890 Comm: test Not tainted 6.3.0+ #253 [ 64.931120] Call Trace: [ 64.932699] <TASK> [ 64.934292] dump_stack_lvl+0x33/0x50 [ 64.935908] ? nf_tables_commit+0xa24/0x1490 [nf_tables] [ 64.937551] kasan_report+0xda/0x120 [ 64.939186] ? nf_tables_commit+0xa24/0x1490 [nf_tables] [ 64.940814] nf_tables_commit+0xa24/0x1490 [nf_tables] [ 64.942452] ? __kasan_slab_alloc+0x2d/0x60 [ 64.944070] ? nf_tables_setelem_notify+0x190/0x190 [nf_tables] [ 64.945710] ? kasan_set_track+0x21/0x30 [ 64.947323] nfnetlink_rcv_batch+0x709/0xd90 [nfnetlink] [ 64.948898] ? nfnetlink_rcv_msg+0x480/0x480 [nfnetlink]
--- include/net/netfilter/nf_tables.h | 1 + net/netfilter/nf_tables_api.c | 12 ++++++++++++ net/netfilter/nft_dynset.c | 2 +- net/netfilter/nft_lookup.c | 2 +- net/netfilter/nft_objref.c | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-)
include/net/netfilter/nf_tables.h +1 -0
@@ -507,6 +507,7 @@ struct nft_set_binding { };enum nft_trans_phase ; +void nf_tables_activate_set (const struct nft_ctx *ctx,struct nft_set *set);void nf_tables_deactivate_set (const struct nft_ctx *ctx,struct nft_set *set,struct nft_set_binding *binding,enum nft_trans_phase phase);
net/netfilter/nf_tables_api.c +12 -0
@@ -4479,12 +4479,24 @@ static void nf_tables_unbind_set(const s } } +void nf_tables_activate_set (const struct nft_ctx *ctx,struct nft_set *set) +{ +if (nft_set_is_anonymous (set)) +nft_clear (ctx->net, set); + + set->use++; +} +EXPORT_SYMBOL_GPL (nf_tables_activate_set); +void nf_tables_deactivate_set (const struct nft_ctx *ctx,struct nft_set *set,struct nft_set_binding *binding,enum nft_trans_phase phase) {switch (phase) {case NFT_TRANS_PREPARE : +if (nft_set_is_anonymous (set)) +nft_deactivate_next (ctx->net, set); + set->use--;return ;case NFT_TRANS_ABORT :
net/netfilter/nft_dynset.c +1 -1
@@ -233,7 +233,7 @@ static void nft_dynset_activate(const st {struct nft_dynset *priv =nft_expr_priv (expr); - priv->set->use++; +nf_tables_activate_set (ctx, priv->set); } static void nft_dynset_destroy(const struct nft_ctx *ctx,
net/netfilter/nft_lookup.c +1 -1
@@ -132,7 +132,7 @@ static void nft_lookup_activate(const st {struct nft_lookup *priv =nft_expr_priv (expr); - priv->set->use++; +nf_tables_activate_set (ctx, priv->set); } static void nft_lookup_destroy(const struct nft_ctx *ctx,
net/netfilter/nft_objref.c +1 -1
@@ -180,7 +180,7 @@ static void nft_objref_map_activate(cons {struct nft_objref_map *priv =nft_expr_priv (expr); - priv->set->use++; +nf_tables_activate_set (ctx, priv->set); } static void nft_objref_map_destroy(const struct nft_ctx *ctx,
Greg Kroah-Hartman
maintainerPATCH 296/381 tty: create internal tty.h file
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 98602c010ceba82f2c2384122dbd07bc965fd367 ]
There are a number of functions and #defines in include/linux/tty.h that do not belong there as they are private to the tty core code.
Create an initial drivers/tty/tty.h file and copy the odd "tty logging" macros into it to seed the file with some initial things that we know nothing outside of the tty core should be calling.
Stable-dep-of: 094fb49a2d0d ("tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH")
--- drivers/tty/n_tty.c | 1 + drivers/tty/pty.c | 1 + drivers/tty/tty.h | 21 +++++++++++++++++++++ drivers/tty/tty_io.c | 1 + drivers/tty/tty_jobctrl.c | 1 + drivers/tty/tty_ldisc.c | 1 + drivers/tty/tty_port.c | 1 + include/linux/tty.h | 12 ------------ 8 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 drivers/tty/tty.h
drivers/tty/n_tty.c +1 -0
@@ -49,6 +49,7 @@#include <linux/module.h> #include <linux/ratelimit.h> #include <linux/vmalloc.h> +#include "tty.h" /* * Until this number of characters is queued in the xmit buffer, select will
drivers/tty/pty.c +1 -0
@@ -29,6 +29,7 @@#include <linux/file.h> #include <linux/ioctl.h> #include <linux/compat.h> +#include "tty.h" #undef TTY_DEBUG_HANGUP#ifdef TTY_DEBUG_HANGUP
drivers/tty/tty.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* TTY core internal functions +*/ + +#ifndef _TTY_INTERNAL_H +#define _TTY_INTERNAL_H + +#define tty_msg (fn, tty, f, ...) \ + fn("%s %s: " f, tty_driver_name(tty), tty_name(tty), ##__VA_ARGS__) + +#define tty_debug (tty, f, ...) tty_msg(pr_debug, tty, f, ##__VA_ARGS__) +#define tty_info (tty, f, ...) tty_msg(pr_info, tty, f, ##__VA_ARGS__) +#define tty_notice (tty, f, ...) tty_msg(pr_notice, tty, f, ##__VA_ARGS__) +#define tty_warn (tty, f, ...) tty_msg(pr_warn, tty, f, ##__VA_ARGS__) +#define tty_err (tty, f, ...) tty_msg(pr_err, tty, f, ##__VA_ARGS__) + +#define tty_info_ratelimited (tty, f, ...) \ + tty_msg(pr_info_ratelimited, tty, f, ##__VA_ARGS__) + +#endif
drivers/tty/tty_io.c +1 -0
@@ -108,6 +108,7 @@#include <linux/kmod.h> #include <linux/nsproxy.h> +#include "tty.h" #undef TTY_DEBUG_HANGUP#ifdef TTY_DEBUG_HANGUP
drivers/tty/tty_jobctrl.c +1 -0
@@ -11,6 +11,7 @@#include <linux/tty.h> #include <linux/fcntl.h> #include <linux/uaccess.h> +#include "tty.h" static int is_ignored (int sig) {
drivers/tty/tty_ldisc.c +1 -0
@@ -19,6 +19,7 @@#include <linux/seq_file.h> #include <linux/uaccess.h> #include <linux/ratelimit.h> +#include "tty.h" #undef LDISC_DEBUG_HANGUP
drivers/tty/tty_port.c +1 -0
@@ -18,6 +18,7 @@#include <linux/delay.h> #include <linux/module.h> #include <linux/serdev.h> +#include "tty.h" static int tty_port_default_receive_buf(struct tty_port *port, const unsigned char *p,
include/linux/tty.h +0 -12
@@ -786,16 +786,4 @@ static inline void proc_tty_register_driver(struct tty_driver *d) {}static inline void proc_tty_unregister_driver (struct tty_driver *d) {}#endif -#define tty_msg (fn, tty, f, ...) \ - fn("%s %s: " f, tty_driver_name(tty), tty_name(tty), ##__VA_ARGS__) - -#define tty_debug (tty, f, ...) tty_msg(pr_debug, tty, f, ##__VA_ARGS__) -#define tty_info (tty, f, ...) tty_msg(pr_info, tty, f, ##__VA_ARGS__) -#define tty_notice (tty, f, ...) tty_msg(pr_notice, tty, f, ##__VA_ARGS__) -#define tty_warn (tty, f, ...) tty_msg(pr_warn, tty, f, ##__VA_ARGS__) -#define tty_err (tty, f, ...) tty_msg(pr_err, tty, f, ##__VA_ARGS__) - -#define tty_info_ratelimited (tty, f, ...) \ - tty_msg(pr_info_ratelimited, tty, f, ##__VA_ARGS__) -#endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 297/381 tty: audit: move some local functions out of tty.h
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit da5d669e00d2c437b3f508d60add417fc74f4bb6 ]
The functions tty_audit_add_data() and tty_audit_tiocsti() are local to the tty core code, and do not need to be in a "kernel-wide" header file so move them to drivers/tty/tty.h
Stable-dep-of: 094fb49a2d0d ("tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH")
--- drivers/tty/tty.h | 14 ++++++++++++++ drivers/tty/tty_audit.c | 1 + include/linux/tty.h | 10 ---------- 3 files changed, 15 insertions(+), 10 deletions(-)
drivers/tty/tty.h +14 -0
@@ -18,4 +18,18 @@#define tty_info_ratelimited (tty, f, ...) \ tty_msg(pr_info_ratelimited, tty, f, ##__VA_ARGS__) +/* tty_audit.c */ +#ifdef CONFIG_AUDIT +void tty_audit_add_data (struct tty_struct *tty,const void *data,size_t size); +void tty_audit_tiocsti (struct tty_struct *tty,char ch); +#else +static inline void tty_audit_add_data (struct tty_struct *tty,const void *data, +size_t size) +{ +} +static inline void tty_audit_tiocsti (struct tty_struct *tty,char ch) +{ +} +#endif +#endif
drivers/tty/tty_audit.c +1 -0
@@ -10,6 +10,7 @@#include <linux/audit.h> #include <linux/slab.h> #include <linux/tty.h> +#include "tty.h" struct tty_audit_buf {struct mutex mutex;/* Protects all data below */
include/linux/tty.h +0 -10
@@ -731,20 +731,10 @@ static inline void n_tty_init(void) { }/* tty_audit.c */ #ifdef CONFIG_AUDIT -extern void tty_audit_add_data (struct tty_struct *tty,const void *data, -size_t size);extern void tty_audit_exit (void );extern void tty_audit_fork (struct signal_struct *sig); -extern void tty_audit_tiocsti (struct tty_struct *tty,char ch);extern int tty_audit_push (void );#else -static inline void tty_audit_add_data (struct tty_struct *tty,const void *data, -size_t size) -{ -} -static inline void tty_audit_tiocsti (struct tty_struct *tty,char ch) -{ -}static inline void tty_audit_exit (void ) { }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 298/381 tty: move some internal tty lock enums and functions out of tty.h
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 6c80c0b94b94192d9a34b400f8237703c6475f4d ]
Move the TTY_LOCK_* enums and tty_ldisc lock functions out of the global tty.h into the local header file to clean things up.
Stable-dep-of: 094fb49a2d0d ("tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH")
--- drivers/tty/tty.h | 26 ++++++++++++++++++++++++++ drivers/tty/tty_buffer.c | 2 +- drivers/tty/tty_mutex.c | 1 + include/linux/tty.h | 26 -------------------------- 4 files changed, 28 insertions(+), 27 deletions(-)
drivers/tty/tty.h +26 -0
@@ -18,6 +18,32 @@#define tty_info_ratelimited (tty, f, ...) \ tty_msg(pr_info_ratelimited, tty, f, ##__VA_ARGS__) +/* +* Lock subclasses for tty locks +* +* TTY_LOCK_NORMAL is for normal ttys and master ptys. +* TTY_LOCK_SLAVE is for slave ptys only. +* +* Lock subclasses are necessary for handling nested locking with pty pairs. +* tty locks which use nested locking: +* +* legacy_mutex - Nested tty locks are necessary for releasing pty pairs. +* The stable lock order is master pty first, then slave pty. +* termios_rwsem - The stable lock order is tty_buffer lock->termios_rwsem. +* Subclassing this lock enables the slave pty to hold its +* termios_rwsem when claiming the master tty_buffer lock. +* tty_buffer lock - slave ptys can claim nested buffer lock when handling +* signal chars. The stable lock order is slave pty, then +* master. +*/ +enum { +TTY_LOCK_NORMAL =0 , +TTY_LOCK_SLAVE , +}; + +int tty_ldisc_lock (struct tty_struct *tty,unsigned long timeout); +void tty_ldisc_unlock (struct tty_struct *tty); +/* tty_audit.c */ #ifdef CONFIG_AUDIT void tty_audit_add_data (struct tty_struct *tty,const void *data,size_t size);
drivers/tty/tty_buffer.c +1 -1
@@ -17,7 +17,7 @@#include <linux/delay.h> #include <linux/module.h> #include <linux/ratelimit.h> - +#include "tty.h" #define MIN_TTYB_SIZE 256#define TTYB_ALIGN_MASK 255
drivers/tty/tty_mutex.c +1 -0
@@ -4,6 +4,7 @@#include <linux/kallsyms.h> #include <linux/semaphore.h> #include <linux/sched.h> +#include "tty.h" /* Legacy tty mutex glue */
include/linux/tty.h +0 -26
@@ -16,30 +16,6 @@#include <linux/llist.h> -/* -* Lock subclasses for tty locks -* -* TTY_LOCK_NORMAL is for normal ttys and master ptys. -* TTY_LOCK_SLAVE is for slave ptys only. -* -* Lock subclasses are necessary for handling nested locking with pty pairs. -* tty locks which use nested locking: -* -* legacy_mutex - Nested tty locks are necessary for releasing pty pairs. -* The stable lock order is master pty first, then slave pty. -* termios_rwsem - The stable lock order is tty_buffer lock->termios_rwsem. -* Subclassing this lock enables the slave pty to hold its -* termios_rwsem when claiming the master tty_buffer lock. -* tty_buffer lock - slave ptys can claim nested buffer lock when handling -* signal chars. The stable lock order is slave pty, then -* master. -*/ - -enum { -TTY_LOCK_NORMAL =0 , -TTY_LOCK_SLAVE , -}; -/* * (Note: the *_driver.minor_start values 1, 64, 128, 192 are * hardcoded at present.)
@@ -419,8 +395,6 @@ extern const char *tty_name(const struct tty_struct *tty);extern struct tty_struct *tty_kopen (dev_t device);extern void tty_kclose (struct tty_struct *tty);extern int tty_dev_name_to_number (const char *name,dev_t *number); -extern int tty_ldisc_lock (struct tty_struct *tty,unsigned long timeout); -extern void tty_ldisc_unlock (struct tty_struct *tty);extern ssize_t redirected_tty_write (struct kiocb *,struct iov_iter *);#else static inline void tty_kref_put (struct tty_struct *tty)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 299/381 tty: move some tty-only functions to drivers/tty/tty.h
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 9f72cab1596327e1011ab4599c07b165e0fb45db ]
The flow change and restricted_tty_write() logic is internal to the tty core only, so move it out of the include/linux/tty.h file.
Stable-dep-of: 094fb49a2d0d ("tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH")
--- drivers/tty/tty.h | 17 +++++++++++++++++ drivers/tty/tty_ioctl.c | 1 + include/linux/tty.h | 16 ---------------- 3 files changed, 18 insertions(+), 16 deletions(-)
drivers/tty/tty.h +17 -0
@@ -41,6 +41,21 @@ enum { TTY_LOCK_SLAVE, }; +/* Values for tty->flow_change */ +#define TTY_THROTTLE_SAFE 1 +#define TTY_UNTHROTTLE_SAFE 2 + +static inline void __tty_set_flow_change (struct tty_struct *tty,int val) +{ + tty->flow_change = val; +} + +static inline void tty_set_flow_change (struct tty_struct *tty,int val) +{ + tty->flow_change = val; +smp_mb (); +} +int tty_ldisc_lock (struct tty_struct *tty,unsigned long timeout);void tty_ldisc_unlock (struct tty_struct *tty);
@@ -58,4 +73,6 @@ static inline void tty_audit_tiocsti(struct tty_struct *tty, char ch) }#endif +ssize_t redirected_tty_write (struct kiocb *,struct iov_iter *); +#endif
drivers/tty/tty_ioctl.c +1 -0
@@ -21,6 +21,7 @@#include <linux/bitops.h> #include <linux/mutex.h> #include <linux/compat.h> +#include "tty.h" #include <asm/io.h> #include <linux/uaccess.h>
include/linux/tty.h +0 -16
@@ -350,21 +350,6 @@ struct tty_file_private {#define TTY_LDISC_CHANGING 20/* Change pending - non-block IO */ #define TTY_LDISC_HALTED 22/* Line discipline is halted */ -/* Values for tty->flow_change */ -#define TTY_THROTTLE_SAFE 1 -#define TTY_UNTHROTTLE_SAFE 2 - -static inline void __tty_set_flow_change (struct tty_struct *tty,int val) -{ - tty->flow_change = val; -} - -static inline void tty_set_flow_change (struct tty_struct *tty,int val) -{ - tty->flow_change = val; -smp_mb (); -} -static inline bool tty_io_nonblock (struct tty_struct *tty,struct file *file) { return file->f_flags & O_NONBLOCK ||
@@ -395,7 +380,6 @@ extern const char *tty_name(const struct tty_struct *tty);extern struct tty_struct *tty_kopen (dev_t device);extern void tty_kclose (struct tty_struct *tty);extern int tty_dev_name_to_number (const char *name,dev_t *number); -extern ssize_t redirected_tty_write (struct kiocb *,struct iov_iter *);#else static inline void tty_kref_put (struct tty_struct *tty) { }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 300/381 tty: clean include/linux/tty.h up
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 5ffa6e344a1c92a27c242f500fc74e6eb361a4bc ]
There are a lot of tty-core-only functions that are listed in include/linux/tty.h. Move them to drivers/tty/tty.h so that no one else can accidentally call them or think that they are public functions.
Stable-dep-of: 094fb49a2d0d ("tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH")
--- drivers/tty/n_gsm.c | 1 + drivers/tty/n_hdlc.c | 1 + drivers/tty/tty.h | 37 +++++++++++++++++++++++++++++++++++++ drivers/tty/tty_baudrate.c | 1 + include/linux/tty.h | 33 --------------------------------- 5 files changed, 40 insertions(+), 33 deletions(-)
drivers/tty/n_gsm.c +1 -0
@@ -50,6 +50,7 @@#include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/gsmmux.h> +#include "tty.h" static int debug;module_param (debug, int,0600 );
drivers/tty/n_hdlc.c +1 -0
@@ -100,6 +100,7 @@#include <asm/termios.h> #include <linux/uaccess.h> +#include "tty.h" /* * Buffers for individual HDLC frames
drivers/tty/tty.h +37 -0
@@ -59,6 +59,43 @@ static inline void tty_set_flow_change(struct tty_struct *tty, int val)int tty_ldisc_lock (struct tty_struct *tty,unsigned long timeout);void tty_ldisc_unlock (struct tty_struct *tty); +int __tty_check_change (struct tty_struct *tty,int sig); +int tty_check_change (struct tty_struct *tty); +void __stop_tty (struct tty_struct *tty); +void __start_tty (struct tty_struct *tty); +void tty_vhangup_session (struct tty_struct *tty); +void tty_open_proc_set_tty (struct file *filp,struct tty_struct *tty); +int tty_signal_session_leader (struct tty_struct *tty,int exit_session); +void session_clear_tty (struct pid *session); +void tty_buffer_free_all (struct tty_port *port); +void tty_buffer_flush (struct tty_struct *tty,struct tty_ldisc *ld); +void tty_buffer_init (struct tty_port *port); +void tty_buffer_set_lock_subclass (struct tty_port *port); +bool tty_buffer_restart_work (struct tty_port *port); +bool tty_buffer_cancel_work (struct tty_port *port); +void tty_buffer_flush_work (struct tty_port *port); +speed_t tty_termios_input_baud_rate (struct ktermios *termios); +void tty_ldisc_hangup (struct tty_struct *tty,bool reset); +int tty_ldisc_reinit (struct tty_struct *tty,int disc); +long tty_ioctl (struct file *file,unsigned int cmd,unsigned long arg); +long tty_jobctrl_ioctl (struct tty_struct *tty,struct tty_struct *real_tty, +struct file *file,unsigned int cmd,unsigned long arg); +void tty_default_fops (struct file_operations *fops); +struct tty_struct *alloc_tty_struct (struct tty_driver *driver,int idx); +int tty_alloc_file (struct file *file); +void tty_add_file (struct tty_struct *tty,struct file *file); +void tty_free_file (struct file *file); +int tty_release (struct inode *inode,struct file *filp); + +#define tty_is_writelocked (tty) (mutex_is_locked(&tty->atomic_write_lock)) + +int tty_ldisc_setup (struct tty_struct *tty,struct tty_struct *o_tty); +void tty_ldisc_release (struct tty_struct *tty); +int __must_check tty_ldisc_init (struct tty_struct *tty); +void tty_ldisc_deinit (struct tty_struct *tty); + +void tty_sysctl_init (void ); +/* tty_audit.c */ #ifdef CONFIG_AUDIT void tty_audit_add_data (struct tty_struct *tty,const void *data,size_t size);
drivers/tty/tty_baudrate.c +1 -0
@@ -8,6 +8,7 @@#include <linux/termios.h> #include <linux/tty.h> #include <linux/export.h> +#include "tty.h" /*
include/linux/tty.h +0 -33
@@ -432,11 +432,7 @@ static inline struct tty_struct *tty_kref_get(struct tty_struct *tty)extern const char *tty_driver_name (const struct tty_struct *tty);extern void tty_wait_until_sent (struct tty_struct *tty,long timeout); -extern int __tty_check_change (struct tty_struct *tty,int sig); -extern int tty_check_change (struct tty_struct *tty); -extern void __stop_tty (struct tty_struct *tty);extern void stop_tty (struct tty_struct *tty); -extern void __start_tty (struct tty_struct *tty);extern void start_tty (struct tty_struct *tty);extern int tty_register_driver (struct tty_driver *driver);extern int tty_unregister_driver (struct tty_driver *driver);
@@ -461,23 +457,11 @@ extern int tty_do_resize(struct tty_struct *tty, struct winsize *ws);extern int is_current_pgrp_orphaned (void );extern void tty_hangup (struct tty_struct *tty);extern void tty_vhangup (struct tty_struct *tty); -extern void tty_vhangup_session (struct tty_struct *tty);extern int tty_hung_up_p (struct file *filp);extern void do_SAK (struct tty_struct *tty);extern void __do_SAK (struct tty_struct *tty); -extern void tty_open_proc_set_tty (struct file *filp,struct tty_struct *tty); -extern int tty_signal_session_leader (struct tty_struct *tty,int exit_session); -extern void session_clear_tty (struct pid *session);extern void no_tty (void ); -extern void tty_buffer_free_all (struct tty_port *port); -extern void tty_buffer_flush (struct tty_struct *tty,struct tty_ldisc *ld); -extern void tty_buffer_init (struct tty_port *port); -extern void tty_buffer_set_lock_subclass (struct tty_port *port); -extern bool tty_buffer_restart_work (struct tty_port *port); -extern bool tty_buffer_cancel_work (struct tty_port *port); -extern void tty_buffer_flush_work (struct tty_port *port);extern speed_t tty_termios_baud_rate (struct ktermios *termios); -extern speed_t tty_termios_input_baud_rate (struct ktermios *termios);extern void tty_termios_encode_baud_rate (struct ktermios *termios,speed_t ibaud,speed_t obaud); extern void tty_encode_baud_rate(struct tty_struct *tty,
@@ -505,27 +489,16 @@ extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt);extern struct tty_ldisc *tty_ldisc_ref (struct tty_struct *);extern void tty_ldisc_deref (struct tty_ldisc *);extern struct tty_ldisc *tty_ldisc_ref_wait (struct tty_struct *); -extern void tty_ldisc_hangup (struct tty_struct *tty,bool reset); -extern int tty_ldisc_reinit (struct tty_struct *tty,int disc);extern const struct seq_operations tty_ldiscs_seq_ops;extern void tty_wakeup (struct tty_struct *tty);extern void tty_ldisc_flush (struct tty_struct *tty); -extern long tty_ioctl (struct file *file,unsigned int cmd,unsigned long arg);extern int tty_mode_ioctl (struct tty_struct *tty,struct file *file,unsigned int cmd,unsigned long arg); -extern long tty_jobctrl_ioctl (struct tty_struct *tty,struct tty_struct *real_tty, -struct file *file,unsigned int cmd,unsigned long arg);extern int tty_perform_flush (struct tty_struct *tty,unsigned long arg); -extern void tty_default_fops (struct file_operations *fops); -extern struct tty_struct *alloc_tty_struct (struct tty_driver *driver,int idx); -extern int tty_alloc_file (struct file *file); -extern void tty_add_file (struct tty_struct *tty,struct file *file); -extern void tty_free_file (struct file *file);extern struct tty_struct *tty_init_dev (struct tty_driver *driver,int idx);extern void tty_release_struct (struct tty_struct *tty,int idx); -extern int tty_release (struct inode *inode,struct file *filp);extern void tty_init_termios (struct tty_struct *tty);extern void tty_save_termios (struct tty_struct *tty); extern int tty_standard_install(struct tty_driver *driver,
@@ -533,8 +506,6 @@ extern int tty_standard_install(struct tty_driver *driver,extern struct mutex tty_mutex; -#define tty_is_writelocked (tty) (mutex_is_locked(&tty->atomic_write_lock)) -extern void tty_port_init (struct tty_port *port);extern void tty_port_link_device (struct tty_port *port,struct tty_driver *driver,unsigned index);
@@ -672,10 +643,6 @@ static inline int tty_port_users(struct tty_port *port)extern int tty_register_ldisc (int disc,struct tty_ldisc_ops *new_ldisc);extern int tty_unregister_ldisc (int disc);extern int tty_set_ldisc (struct tty_struct *tty,int disc); -extern int tty_ldisc_setup (struct tty_struct *tty,struct tty_struct *o_tty); -extern void tty_ldisc_release (struct tty_struct *tty); -extern int __must_check tty_ldisc_init (struct tty_struct *tty); -extern void tty_ldisc_deinit (struct tty_struct *tty);extern int tty_ldisc_receive_buf (struct tty_ldisc *ld,const unsigned char *p,char *f,int count);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 301/381 tty: Prevent writing chars during tcsetattr TCSADRAIN/FLUSH
In reply to Greg Kroah-HartmanFrom: Ilpo Järvinen <[email protected]>
[ Upstream commit 094fb49a2d0d6827c86d2e0840873e6db0c491d2 ]
If userspace races tcsetattr() with a write, the drained condition might not be guaranteed by the kernel. There is a race window after checking Tx is empty before tty_set_termios() takes termios_rwsem for write. During that race window, more characters can be queued by a racing writer.
Any ongoing transmission might produce garbage during HW's ->set_termios() call. The intent of TCSADRAIN/FLUSH seems to be preventing such a character corruption. If those flags are set, take tty's write lock to stop any writer before performing the lower layer Tx empty check and wait for the pending characters to be sent (if any).
The initial wait for all-writers-done must be placed outside of tty's write lock to avoid deadlock which makes it impossible to use tty_wait_until_sent(). The write lock is retried if a racing write is detected.
--- drivers/tty/tty.h | 2 ++ drivers/tty/tty_io.c | 4 ++-- drivers/tty/tty_ioctl.c | 45 ++++++++++++++++++++++++++++++----------- 3 files changed, 37 insertions(+), 14 deletions(-)
drivers/tty/tty.h +2 -0
@@ -63,6 +63,8 @@ int __tty_check_change(struct tty_struct *tty, int sig);int tty_check_change (struct tty_struct *tty);void __stop_tty (struct tty_struct *tty);void __start_tty (struct tty_struct *tty); +void tty_write_unlock (struct tty_struct *tty); +int tty_write_lock (struct tty_struct *tty,int ndelay);void tty_vhangup_session (struct tty_struct *tty);void tty_open_proc_set_tty (struct file *filp,struct tty_struct *tty);int tty_signal_session_leader (struct tty_struct *tty,int exit_session);
drivers/tty/tty_io.c +2 -2
@@ -942,13 +942,13 @@ static ssize_t tty_read(struct kiocb *iocb, struct iov_iter *to)return i; } -static void tty_write_unlock (struct tty_struct *tty) +void tty_write_unlock (struct tty_struct *tty) {mutex_unlock (&tty->atomic_write_lock);wake_up_interruptible_poll (&tty->write_wait,EPOLLOUT ); } -static int tty_write_lock (struct tty_struct *tty,int ndelay) +int tty_write_lock (struct tty_struct *tty,int ndelay) {if (!mutex_trylock (&tty->atomic_write_lock)) {if (ndelay)
drivers/tty/tty_ioctl.c +33 -12
54 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 302/381 ring-buffer: Ensure proper resetting of atomic variables in ring_buffer_reset_online_cpus
In reply to Greg Kroah-HartmanFrom: Tze-nan Wu <[email protected]>
[ Upstream commit 7c339fb4d8577792378136c15fde773cfb863cb8 ]
In ring_buffer_reset_online_cpus, the buffer_size_kb write operation may permanently fail if the cpu_online_mask changes between two for_each_online_buffer_cpu loops. The number of increases and decreases on both cpu_buffer->resize_disabled and cpu_buffer->record_disabled may be inconsistent, causing some CPUs to have non-zero values for these atomic variables after the function returns.
This issue can be reproduced by "echo 0 > trace" while hotplugging cpu. After reproducing success, we can find out buffer_size_kb will not be functional anymore.
To prevent leaving 'resize_disabled' and 'record_disabled' non-zero after ring_buffer_reset_online_cpus returns, we ensure that each atomic variable has been set up before atomic_sub() to it.
--- kernel/trace/ring_buffer.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
kernel/trace/ring_buffer.c +13 -3
@@ -5051,6 +5051,9 @@ void ring_buffer_reset_cpu(struct trace_buffer *buffer, int cpu) }EXPORT_SYMBOL_GPL (ring_buffer_reset_cpu); +/* Flag to ensure proper resetting of atomic variables */ +#define RESET_BIT (1 << 30) +/** * ring_buffer_reset_cpu - reset a ring buffer per CPU buffer * @buffer: The ring buffer to reset a per cpu buffer of
@@ -5067,20 +5070,27 @@ void ring_buffer_reset_online_cpus(struct trace_buffer *buffer)for_each_online_buffer_cpu (buffer, cpu) { cpu_buffer = buffer->buffers[cpu]; -atomic_inc (&cpu_buffer->resize_disabled); +atomic_add (RESET_BIT , &cpu_buffer->resize_disabled);atomic_inc (&cpu_buffer->record_disabled); }/* Make sure all commits have finished */ synchronize_rcu (); -for_each_online_buffer_cpu (buffer, cpu) { +for_each_buffer_cpu (buffer, cpu) { cpu_buffer = buffer->buffers[cpu]; +/* +* If a CPU came online during the synchronize_rcu(), then +* ignore it. +*/ +if (!(atomic_read (&cpu_buffer->resize_disabled) &RESET_BIT )) +continue ; +reset_disabled_cpu_buffer (cpu_buffer);atomic_dec (&cpu_buffer->record_disabled); -atomic_dec (&cpu_buffer->resize_disabled); +atomic_sub (RESET_BIT , &cpu_buffer->resize_disabled); }mutex_unlock (&buffer->mutex);
Signature · 1 line
2.39.2