6.7.12-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 140/432 cifs: prevent updating file size from server if we have a read/write lease
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bharath SM <[email protected]>
[ Upstream commit e4b61f3b1c67f5068590965f64ea6e8d5d5bd961 ]
In cases of large directories, the readdir operation may span multiple round trips to retrieve contents. This introduces a potential race condition in case of concurrent write and readdir operations. If the readdir operation initiates before a write has been processed by the server, it may update the file size attribute to an older value. Address this issue by avoiding file size updates from readdir when we have read/write lease.
Scenario:
1) process1: open dir xyz
2) process1: readdir instance 1 on xyz
3) process2: create file.txt for write
4) process2: write x bytes to file.txt
5) process2: close file.txt
6) process2: open file.txt for read
7) process1: readdir 2 - overwrites file.txt inode size to 0
8) process2: read contents of file.txt - bug, short read with 0 bytes
--- fs/smb/client/cifsproto.h | 6 ++++-- fs/smb/client/file.c | 8 +++++--- fs/smb/client/inode.c | 13 +++++++------ fs/smb/client/readdir.c | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-)
fs/smb/client/cifsproto.h +4 -2
@@ -144,7 +144,8 @@ extern int cifs_reconnect(struct TCP_Server_Info *server,extern int checkSMB (char *buf,unsigned int len,struct TCP_Server_Info *srvr);extern bool is_valid_oplock_break (char *,struct TCP_Server_Info *);extern bool backup_cred (struct cifs_sb_info *); -extern bool is_size_safe_to_change (struct cifsInodeInfo *,__u64 eof); +extern bool is_size_safe_to_change (struct cifsInodeInfo *cifsInode,__u64 eof, +bool from_readdir);extern void cifs_update_eof (struct cifsInodeInfo *cifsi,loff_t offset,unsigned int bytes_written);extern struct cifsFileInfo *find_writable_file (struct cifsInodeInfo *,int );
@@ -201,7 +202,8 @@ extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb);extern void cifs_dir_info_to_fattr (struct cifs_fattr *,FILE_DIRECTORY_INFO *,struct cifs_sb_info *); -extern int cifs_fattr_to_inode (struct inode *inode,struct cifs_fattr *fattr); +extern int cifs_fattr_to_inode (struct inode *inode,struct cifs_fattr *fattr, +bool from_readdir);extern struct inode *cifs_iget (struct super_block *sb,struct cifs_fattr *fattr);
fs/smb/client/file.c +5 -3
@@ -329,7 +329,7 @@ int cifs_posix_open(const char *full_path, struct inode **pinode, } }else {cifs_revalidate_mapping (*pinode); - rc =cifs_fattr_to_inode (*pinode, &fattr); + rc =cifs_fattr_to_inode (*pinode, &fattr, false); } posix_open_ret:
@@ -4766,12 +4766,14 @@ static int is_inode_writable(struct cifsInodeInfo *cifs_inode)refreshing the inode only on increases in the file size but this is tricky to do without racing with writebehind page caching in the current Linux kernel design */ -bool is_size_safe_to_change (struct cifsInodeInfo *cifsInode,__u64 end_of_file) +bool is_size_safe_to_change (struct cifsInodeInfo *cifsInode,__u64 end_of_file, +bool from_readdir) {if (!cifsInode)return true; -if (is_inode_writable (cifsInode)) { +if (is_inode_writable (cifsInode) || + ((cifsInode->oplock &CIFS_CACHE_RW_FLG ) !=0 && from_readdir)) {/* This inode is open for write at least once */ struct cifs_sb_info *cifs_sb;
fs/smb/client/inode.c +7 -6
@@ -147,7 +147,8 @@ cifs_nlink_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)/* populate an inode with info from a cifs_fattr struct */ int -cifs_fattr_to_inode (struct inode *inode,struct cifs_fattr *fattr) +cifs_fattr_to_inode (struct inode *inode,struct cifs_fattr *fattr, +bool from_readdir) {struct cifsInodeInfo *cifs_i =CIFS_I (inode);struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb);
@@ -199,7 +200,7 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)* Can't safely change the file size here if the client is writing to * it due to potential races. */ -if (is_size_safe_to_change (cifs_i, fattr->cf_eof)) { +if (is_size_safe_to_change (cifs_i, fattr->cf_eof, from_readdir)) {i_size_write (inode, fattr->cf_eof);/*
@@ -368,7 +369,7 @@ static int update_inode_info(struct super_block *sb,CIFS_I (*inode)->time =0 ;/* force reval */ return -ESTALE ; } -return cifs_fattr_to_inode (*inode, fattr); +return cifs_fattr_to_inode (*inode, fattr, false); }#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
@@ -403,7 +404,7 @@ cifs_get_file_info_unix(struct file *filp) }else goto cifs_gfiunix_out; - rc =cifs_fattr_to_inode (inode, &fattr); + rc =cifs_fattr_to_inode (inode, &fattr, false); cifs_gfiunix_out:free_xid (xid);
@@ -928,7 +929,7 @@ cifs_get_file_info(struct file *filp) fattr.cf_uniqueid =CIFS_I (inode)->uniqueid; fattr.cf_flags |=CIFS_FATTR_NEED_REVAL ;/* if filetype is different, return error */ - rc =cifs_fattr_to_inode (inode, &fattr); + rc =cifs_fattr_to_inode (inode, &fattr, false); cgfi_exit:cifs_free_open_info (&data);free_xid (xid);
@@ -1467,7 +1468,7 @@ cifs_iget(struct super_block *sb, struct cifs_fattr *fattr) }/* can't fail - see cifs_find_inode() */ -cifs_fattr_to_inode (inode, fattr); +cifs_fattr_to_inode (inode, fattr, false);if (sb->s_flags &SB_NOATIME ) inode->i_flags |=S_NOATIME |S_NOCMTIME ;if (inode->i_state &I_NEW ) {
fs/smb/client/readdir.c +1 -1
@@ -148,7 +148,7 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name, rc = -ESTALE ; } } -if (!rc && !cifs_fattr_to_inode (inode, fattr)) { +if (!rc && !cifs_fattr_to_inode (inode, fattr, true)) {dput (dentry);return ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 141/432 cifs: allow changing password during remount
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
[ Upstream commit c1eb537bf4560b3ad4df606c266c665624f3b502 ]
There are cases where a session is disconnected and password has changed on the server (or expired) for this user and this currently can not be fixed without unmount and mounting again. This patch allows remount to change the password (for the non Kerberos case, Kerberos ticket refresh is handled differently) when the session is disconnected and the user can not reconnect due to still using old password.
Future patches should also allow us to setup the keyring (cifscreds) to have an "alternate password" so we would be able to change the password before the session drops (without the risk of races between when the password changes and the disconnect occurs - ie cases where the old password is still needed because the new password has not fully rolled out to all servers yet).
--- fs/smb/client/cifs_debug.c | 2 ++ fs/smb/client/cifsglob.h | 1 + fs/smb/client/fs_context.c | 27 ++++++++++++++++++++++----- fs/smb/client/smb2pdu.c | 5 +++++ 4 files changed, 30 insertions(+), 5 deletions(-)
fs/smb/client/cifs_debug.c +2 -0
@@ -488,6 +488,8 @@ static int cifs_debug_data_proc_show(struct seq_file *m, void *v) ses->ses_count, ses->serverOS, ses->serverNOS, ses->capabilities, ses->ses_status); } +if (ses->expired_pwd) +seq_puts (m,"password no longer valid " );spin_unlock (&ses->ses_lock); seq_printf(m, "\n\tSecurity type: %s ",
fs/smb/client/cifsglob.h +1 -0
@@ -1052,6 +1052,7 @@ struct cifs_ses {enum securityEnum sectype;/* what security flavor was specified? */ bool sign;/* is signing required? */ bool domainAuto:1; +bool expired_pwd;/* track if access denied or expired pwd so can know if need to update */ unsigned int flags;__u16 session_flags;__u8 smb3signingkey[SMB3_SIGN_KEY_SIZE ];
fs/smb/client/fs_context.c +22 -5
@@ -771,7 +771,7 @@ static void smb3_fs_context_free(struct fs_context *fc)*/ static int smb3_verify_reconfigure_ctx (struct fs_context *fc,struct smb3_fs_context *new_ctx, -struct smb3_fs_context *old_ctx) +struct smb3_fs_context *old_ctx,bool need_recon) {if (new_ctx->posix_paths != old_ctx->posix_paths) {cifs_errorf (fc,"can not change posixpaths during remount\n" );
@@ -797,8 +797,15 @@ static int smb3_verify_reconfigure_ctx(struct fs_context *fc, }if (new_ctx->password && (!old_ctx->password ||strcmp (new_ctx->password, old_ctx->password))) { -cifs_errorf (fc,"can not change password during remount\n" ); -return -EINVAL ; +if (need_recon == false) { +cifs_errorf (fc, +"can not change password of active session during remount\n" ); +return -EINVAL ; + }else if (old_ctx->sectype == Kerberos) { +cifs_errorf (fc, +"can not change password for Kerberos via remount\n" ); +return -EINVAL ; + } }if (new_ctx->domainname && (!old_ctx->domainname ||strcmp (new_ctx->domainname, old_ctx->domainname))) {
@@ -842,9 +849,14 @@ static int smb3_reconfigure(struct fs_context *fc)struct smb3_fs_context *ctx =smb3_fc2context (fc);struct dentry *root = fc->root;struct cifs_sb_info *cifs_sb =CIFS_SB (root->d_sb); +struct cifs_ses *ses =cifs_sb_master_tcon (cifs_sb)->ses; +bool need_recon = false;int rc; - rc =smb3_verify_reconfigure_ctx (fc, ctx, cifs_sb->ctx); +if (ses->expired_pwd) + need_recon = true; + + rc =smb3_verify_reconfigure_ctx (fc, ctx, cifs_sb->ctx, need_recon);if (rc)return rc;
@@ -857,7 +869,12 @@ static int smb3_reconfigure(struct fs_context *fc)STEAL_STRING (cifs_sb, ctx,UNC );STEAL_STRING (cifs_sb, ctx, source);STEAL_STRING (cifs_sb, ctx, username); -STEAL_STRING_SENSITIVE (cifs_sb, ctx, password); +if (need_recon == false) +STEAL_STRING_SENSITIVE (cifs_sb, ctx, password); +else { +kfree_sensitive (ses->password); + ses->password =kstrdup (ctx->password,GFP_KERNEL ); + }STEAL_STRING (cifs_sb, ctx, domainname);STEAL_STRING (cifs_sb, ctx, nodename);STEAL_STRING (cifs_sb, ctx, iocharset);
fs/smb/client/smb2pdu.c +5 -0
@@ -1536,6 +1536,11 @@ SMB2_sess_sendreceive(struct SMB2_sess_data *sess_data) &sess_data->buf0_type, CIFS_LOG_ERROR | CIFS_SESS_OP, &rsp_iov);cifs_small_buf_release (sess_data->iov[0 ].iov_base); +if (rc ==0 ) + sess_data->ses->expired_pwd = false; +else if ((rc == -EACCES ) || (rc == -EKEYEXPIRED ) || (rc == -EKEYREVOKED )) + sess_data->ses->expired_pwd = true; +memcpy (&sess_data->iov[0 ], &rsp_iov,sizeof (struct kvec ));return rc;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 142/432 thermal/drivers/mediatek: Fix control buffer enablement on MT7896
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frank Wunderlich <[email protected]>
[ Upstream commit 371ed6263e2403068b359f0c07188548c2d70827 ]
Reading thermal sensor on mt7986 devices returns invalid temperature:
bpi-r3 ~ # cat /sys/class/thermal/thermal_zone0/temp
-274000
Fix this by adding missing members in mtk_thermal_data struct which were used in mtk_thermal_turn_on_buffer after commit 33140e668b10.
--- drivers/thermal/mediatek/auxadc_thermal.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/thermal/mediatek/auxadc_thermal.c +3 -0
@@ -690,6 +690,9 @@ static const struct mtk_thermal_data mt7986_thermal_data = { .adcpnp = mt7986_adcpnp, .sensor_mux_values = mt7986_mux_values, .version = MTK_THERMAL_V3, + .apmixed_buffer_ctl_reg = APMIXED_SYS_TS_CON1, + .apmixed_buffer_ctl_mask = GENMASK(31, 6) | BIT(3), + .apmixed_buffer_ctl_set = BIT(0), };static bool mtk_thermal_temp_is_valid (int temp)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 143/432 vfio/pci: Disable auto-enable of exclusive INTx IRQ
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
[ Upstream commit fe9a7082684eb059b925c535682e68c34d487d43 ]
Currently for devices requiring masking at the irqchip for INTx, ie. devices without DisINTx support, the IRQ is enabled in request_irq() and subsequently disabled as necessary to align with the masked status flag. This presents a window where the interrupt could fire between these events, resulting in the IRQ incrementing the disable depth twice. This would be unrecoverable for a user since the masked flag prevents nested enables through vfio.
Instead, invert the logic using IRQF_NO_AUTOEN such that exclusive INTx is never auto-enabled, then unmask as required.
--- drivers/vfio/pci/vfio_pci_intrs.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/vfio/pci/vfio_pci_intrs.c +10 -7
@@ -296,8 +296,15 @@ static int vfio_intx_set_signal(struct vfio_pci_core_device *vdev, int fd) ctx->trigger = trigger; +/* +* Devices without DisINTx support require an exclusive interrupt, +* IRQ masking is performed at the IRQ chip. The masked status is +* protected by vdev->irqlock. Setup the IRQ without auto-enable and +* unmask as necessary below under lock. DisINTx is unmodified by +* the IRQ configuration and may therefore use auto-enable. +*/ if (!vdev->pci_2_3) - irqflags =0 ; + irqflags =IRQF_NO_AUTOEN ; ret =request_irq (pdev->irq, vfio_intx_handler, irqflags, ctx->name, vdev);
@@ -308,13 +315,9 @@ static int vfio_intx_set_signal(struct vfio_pci_core_device *vdev, int fd)return ret; } -/* -* INTx disable will stick across the new irq setup, -* disable_irq won't. -*/ spin_lock_irqsave (&vdev->irqlock, flags); -if (!vdev->pci_2_3 && ctx->masked) -disable_irq_nosync (pdev->irq); +if (!vdev->pci_2_3 && !ctx->masked) +enable_irq (pdev->irq);spin_unlock_irqrestore (&vdev->irqlock, flags);return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 144/432 vfio/pci: Lock external INTx masking ops
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
[ Upstream commit 810cd4bb53456d0503cc4e7934e063835152c1b7 ]
Mask operations through config space changes to DisINTx may race INTx configuration changes via ioctl. Create wrappers that add locking for paths outside of the core interrupt code.
In particular, irq_type is updated holding igate, therefore testing is_intx() requires holding igate. For example clearing DisINTx from config space can otherwise race changes of the interrupt configuration.
This aligns interfaces which may trigger the INTx eventfd into two camps, one side serialized by igate and the other only enabled while INTx is configured. A subsequent patch introduces synchronization for the latter flows.
--- drivers/vfio/pci/vfio_pci_intrs.c | 34 +++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
drivers/vfio/pci/vfio_pci_intrs.c +28 -6
@@ -99,13 +99,15 @@ static void vfio_send_intx_eventfd(void *opaque, void *unused) }/* Returns true if the INTx vfio_pci_irq_ctx.masked value is changed. */ -bool vfio_pci_intx_mask (struct vfio_pci_core_device *vdev) +static bool __vfio_pci_intx_mask (struct vfio_pci_core_device *vdev) {struct pci_dev *pdev = vdev->pdev;struct vfio_pci_irq_ctx *ctx;unsigned long flags;bool masked_changed = false; +lockdep_assert_held (&vdev->igate); +spin_lock_irqsave (&vdev->irqlock, flags);/*
@@ -143,6 +145,17 @@ bool vfio_pci_intx_mask(struct vfio_pci_core_device *vdev)return masked_changed; } +bool vfio_pci_intx_mask (struct vfio_pci_core_device *vdev) +{ +bool mask_changed; + +mutex_lock (&vdev->igate); + mask_changed =__vfio_pci_intx_mask (vdev); +mutex_unlock (&vdev->igate); + +return mask_changed; +} +/* * If this is triggered by an eventfd, we can't call eventfd_signal * or else we'll deadlock on the eventfd wait queue. Return >0 when
@@ -194,12 +207,21 @@ static int vfio_pci_intx_unmask_handler(void *opaque, void *unused)return ret; } -void vfio_pci_intx_unmask (struct vfio_pci_core_device *vdev) +static void __vfio_pci_intx_unmask (struct vfio_pci_core_device *vdev) { +lockdep_assert_held (&vdev->igate); +if (vfio_pci_intx_unmask_handler (vdev,NULL ) >0 )vfio_send_intx_eventfd (vdev,NULL ); } +void vfio_pci_intx_unmask (struct vfio_pci_core_device *vdev) +{ +mutex_lock (&vdev->igate); +__vfio_pci_intx_unmask (vdev); +mutex_unlock (&vdev->igate); +} +static irqreturn_t vfio_intx_handler (int irq,void *dev_id) {struct vfio_pci_core_device *vdev = dev_id;
@@ -563,11 +585,11 @@ static int vfio_pci_set_intx_unmask(struct vfio_pci_core_device *vdev,return -EINVAL ;if (flags &VFIO_IRQ_SET_DATA_NONE ) { -vfio_pci_intx_unmask (vdev); +__vfio_pci_intx_unmask (vdev); }else if (flags &VFIO_IRQ_SET_DATA_BOOL ) {uint8_t unmask = *(uint8_t *)data;if (unmask) -vfio_pci_intx_unmask (vdev); +__vfio_pci_intx_unmask (vdev); }else if (flags &VFIO_IRQ_SET_DATA_EVENTFD ) {struct vfio_pci_irq_ctx *ctx =vfio_irq_ctx_get (vdev,0 );int32_t fd = *(int32_t *)data;
@@ -594,11 +616,11 @@ static int vfio_pci_set_intx_mask(struct vfio_pci_core_device *vdev,return -EINVAL ;if (flags &VFIO_IRQ_SET_DATA_NONE ) { -vfio_pci_intx_mask (vdev); +__vfio_pci_intx_mask (vdev); }else if (flags &VFIO_IRQ_SET_DATA_BOOL ) {uint8_t mask = *(uint8_t *)data;if (mask) -vfio_pci_intx_mask (vdev); +__vfio_pci_intx_mask (vdev); }else if (flags &VFIO_IRQ_SET_DATA_EVENTFD ) {return -ENOTTY ;/* XXX implement me */ }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 145/432 vfio/platform: Disable virqfds on cleanup
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
[ Upstream commit fcdc0d3d40bc26c105acf8467f7d9018970944ae ]
irqfds for mask and unmask that are not specifically disabled by the user are leaked. Remove any irqfds during cleanup
--- drivers/vfio/platform/vfio_platform_irq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/vfio/platform/vfio_platform_irq.c +4 -1
@@ -321,8 +321,11 @@ void vfio_platform_irq_cleanup(struct vfio_platform_device *vdev) {int i; -for (i =0 ; i < vdev->num_irqs; i++) +for (i =0 ; i < vdev->num_irqs; i++) { +vfio_virqfd_disable (&vdev->irqs[i].mask); +vfio_virqfd_disable (&vdev->irqs[i].unmask);vfio_set_trigger (vdev, i,-1 ,NULL ); + } vdev->num_irqs =0 ;kfree (vdev->irqs);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 146/432 i915: make inject_virtual_interrupt() void
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit 85884871921000b9bca2184077b1159771e50047 ]
The single caller of inject_virtual_interrupt() ignores the return value anyway. This allows us to simplify eventfd_signal() in follow-up patches.
Stable-dep-of: 675daf435e9f ("vfio/platform: Create persistent IRQ handlers")
--- drivers/gpu/drm/i915/gvt/interrupt.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/gvt/interrupt.c +6 -7
@@ -422,7 +422,7 @@ static void init_irq_map(struct intel_gvt_irq *irq)#define MSI_CAP_DATA (offset) (offset + 8)#define MSI_CAP_EN 0x1 -static int inject_virtual_interrupt (struct intel_vgpu *vgpu) +static void inject_virtual_interrupt (struct intel_vgpu *vgpu) {unsigned long offset = vgpu->gvt->device_info.msi_cap_offset;u16 control, data;
@@ -434,10 +434,10 @@ static int inject_virtual_interrupt(struct intel_vgpu *vgpu)/* Do not generate MSI if MSIEN is disabled */ if (!(control &MSI_CAP_EN )) -return 0 ; +return ;if (WARN (control &GENMASK (15 ,1 ),"only support one MSI format\n" )) -return -EINVAL ; +return ;trace_inject_msi (vgpu->id, addr, data);
@@ -451,10 +451,9 @@ static int inject_virtual_interrupt(struct intel_vgpu *vgpu)* returned and don't inject interrupt into guest. */ if (!test_bit (INTEL_VGPU_STATUS_ATTACHED , vgpu->status)) -return -ESRCH ; -if (vgpu->msi_trigger &&eventfd_signal (vgpu->msi_trigger,1 ) !=1 ) -return -EFAULT ; -return 0 ; +return ; +if (vgpu->msi_trigger) +eventfd_signal (vgpu->msi_trigger,1 ); } static void propagate_event(struct intel_gvt_irq *irq,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 147/432 eventfd: simplify eventfd_signal()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Brauner <[email protected]>
[ Upstream commit 3652117f854819a148ff0fbe4492587d3520b5e5 ]
Ever since the eventfd type was introduced back in 2007 in commit e1ad7468c77d ("signal/timer/event: eventfd core") the eventfd_signal() function only ever passed 1 as a value for @n. There's no point in keeping that additional argument.
Stable-dep-of: 675daf435e9f ("vfio/platform: Create persistent IRQ handlers")
--- arch/x86/kvm/hyperv.c | 2 +- arch/x86/kvm/xen.c | 2 +- drivers/accel/habanalabs/common/device.c | 2 +- drivers/fpga/dfl.c | 2 +- drivers/gpu/drm/drm_syncobj.c | 6 +++--- drivers/gpu/drm/i915/gvt/interrupt.c | 2 +- drivers/infiniband/hw/mlx5/devx.c | 2 +- drivers/misc/ocxl/file.c | 2 +- drivers/s390/cio/vfio_ccw_chp.c | 2 +- drivers/s390/cio/vfio_ccw_drv.c | 4 ++-- drivers/s390/cio/vfio_ccw_ops.c | 6 +++--- drivers/s390/crypto/vfio_ap_ops.c | 2 +- drivers/usb/gadget/function/f_fs.c | 4 ++-- drivers/vdpa/vdpa_user/vduse_dev.c | 6 +++--- drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c | 2 +- drivers/vfio/pci/vfio_pci_core.c | 6 +++--- drivers/vfio/pci/vfio_pci_intrs.c | 12 ++++++------ drivers/vfio/platform/vfio_platform_irq.c | 4 ++-- drivers/vhost/vdpa.c | 4 ++-- drivers/vhost/vhost.c | 10 +++++----- drivers/vhost/vhost.h | 2 +- drivers/virt/acrn/ioeventfd.c | 2 +- drivers/xen/privcmd.c | 2 +- fs/aio.c | 2 +- fs/eventfd.c | 11 ++++------- include/linux/eventfd.h | 4 ++-- mm/memcontrol.c | 10 +++++----- mm/vmpressure.c | 2 +- samples/vfio-mdev/mtty.c | 4 ++-- virt/kvm/eventfd.c | 4 ++-- 30 files changed, 61 insertions(+), 64 deletions(-)
arch/x86/kvm/hyperv.c +1 -1
@@ -2388,7 +2388,7 @@ static u16 kvm_hvcall_signal_event(struct kvm_vcpu *vcpu, struct kvm_hv_hcall *hif (!eventfd)return HV_STATUS_INVALID_PORT_ID ; -eventfd_signal (eventfd,1 ); +eventfd_signal (eventfd);return HV_STATUS_SUCCESS ; }
arch/x86/kvm/xen.c +1 -1
@@ -2088,7 +2088,7 @@ static bool kvm_xen_hcall_evtchn_send(struct kvm_vcpu *vcpu, u64 param, u64 *r)if (ret <0 && ret != -ENOTCONN )return false; }else { -eventfd_signal (evtchnfd->deliver.eventfd.ctx,1 ); +eventfd_signal (evtchnfd->deliver.eventfd.ctx); } *r =0 ;
drivers/accel/habanalabs/common/device.c +1 -1
@@ -2047,7 +2047,7 @@ static void hl_notifier_event_send(struct hl_notifier_event *notifier_event, u64 notifier_event->events_mask |= event_mask;if (notifier_event->eventfd) -eventfd_signal (notifier_event->eventfd,1 ); +eventfd_signal (notifier_event->eventfd);mutex_unlock (¬ifier_event->lock); }
drivers/fpga/dfl.c +1 -1
@@ -1872,7 +1872,7 @@ static irqreturn_t dfl_irq_handler(int irq, void *arg) {struct eventfd_ctx *trigger = arg; -eventfd_signal (trigger,1 ); +eventfd_signal (trigger);return IRQ_HANDLED ; }
drivers/gpu/drm/drm_syncobj.c +3 -3
@@ -1367,7 +1367,7 @@ static void syncobj_eventfd_entry_fence_func(struct dma_fence *fence,struct syncobj_eventfd_entry *entry = container_of(cb, struct syncobj_eventfd_entry, fence_cb); -eventfd_signal (entry->ev_fd_ctx,1 ); +eventfd_signal (entry->ev_fd_ctx);syncobj_eventfd_entry_free (entry); }
@@ -1401,13 +1401,13 @@ syncobj_eventfd_entry_func(struct drm_syncobj *syncobj, entry->fence = fence;if (entry->flags &DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE ) { -eventfd_signal (entry->ev_fd_ctx,1 ); +eventfd_signal (entry->ev_fd_ctx);syncobj_eventfd_entry_free (entry); }else { ret =dma_fence_add_callback (fence, &entry->fence_cb, syncobj_eventfd_entry_fence_func);if (ret == -ENOENT ) { -eventfd_signal (entry->ev_fd_ctx,1 ); +eventfd_signal (entry->ev_fd_ctx);syncobj_eventfd_entry_free (entry); } }
drivers/gpu/drm/i915/gvt/interrupt.c +1 -1
@@ -453,7 +453,7 @@ static void inject_virtual_interrupt(struct intel_vgpu *vgpu)if (!test_bit (INTEL_VGPU_STATUS_ATTACHED , vgpu->status))return ;if (vgpu->msi_trigger) -eventfd_signal (vgpu->msi_trigger,1 ); +eventfd_signal (vgpu->msi_trigger); } static void propagate_event(struct intel_gvt_irq *irq,
drivers/infiniband/hw/mlx5/devx.c +1 -1
@@ -2498,7 +2498,7 @@ static void dispatch_event_fd(struct list_head *fd_list,list_for_each_entry_rcu (item, fd_list, xa_list) {if (item->eventfd) -eventfd_signal (item->eventfd,1 ); +eventfd_signal (item->eventfd);else deliver_event (item, data); }
drivers/misc/ocxl/file.c +1 -1
@@ -184,7 +184,7 @@ static irqreturn_t irq_handler(void *private) {struct eventfd_ctx *ev_ctx = private; -eventfd_signal (ev_ctx,1 ); +eventfd_signal (ev_ctx);return IRQ_HANDLED ; }
drivers/s390/cio/vfio_ccw_chp.c +1 -1
@@ -115,7 +115,7 @@ static ssize_t vfio_ccw_crw_region_read(struct vfio_ccw_private *private,/* Notify the guest if more CRWs are on our queue */ if (!list_empty (&private->crw) && private->crw_trigger) -eventfd_signal (private->crw_trigger,1 ); +eventfd_signal (private->crw_trigger);return ret; }
drivers/s390/cio/vfio_ccw_drv.c +2 -2
@@ -112,7 +112,7 @@ void vfio_ccw_sch_io_todo(struct work_struct *work) private->state =VFIO_CCW_STATE_IDLE ;if (private->io_trigger) -eventfd_signal (private->io_trigger,1 ); +eventfd_signal (private->io_trigger); }void vfio_ccw_crw_todo (struct work_struct *work)
@@ -122,7 +122,7 @@ void vfio_ccw_crw_todo(struct work_struct *work) private = container_of(work, struct vfio_ccw_private, crw_work);if (!list_empty (&private->crw) && private->crw_trigger) -eventfd_signal (private->crw_trigger,1 ); +eventfd_signal (private->crw_trigger); }/*
drivers/s390/cio/vfio_ccw_ops.c +3 -3
@@ -421,7 +421,7 @@ static int vfio_ccw_mdev_set_irqs(struct vfio_ccw_private *private,case VFIO_IRQ_SET_DATA_NONE : {if (*ctx) -eventfd_signal (*ctx,1 ); +eventfd_signal (*ctx);return 0 ; }case VFIO_IRQ_SET_DATA_BOOL :
@@ -432,7 +432,7 @@ static int vfio_ccw_mdev_set_irqs(struct vfio_ccw_private *private,return -EFAULT ;if (trigger && *ctx) -eventfd_signal (*ctx,1 ); +eventfd_signal (*ctx);return 0 ; }case VFIO_IRQ_SET_DATA_EVENTFD :
@@ -612,7 +612,7 @@ static void vfio_ccw_mdev_request(struct vfio_device *vdev, unsigned int count)"Relaying device request to user (#%u)\n" , count); -eventfd_signal (private->req_trigger,1 ); +eventfd_signal (private->req_trigger); }else if (count ==0 ) {dev_notice (dev,"No device request channel registered, blocked until released by user\n" );
drivers/s390/crypto/vfio_ap_ops.c +1 -1
@@ -1862,7 +1862,7 @@ static void vfio_ap_mdev_request(struct vfio_device *vdev, unsigned int count)"Relaying device request to user (#%u)\n" , count); -eventfd_signal (matrix_mdev->req_trigger,1 ); +eventfd_signal (matrix_mdev->req_trigger); }else if (count ==0 ) {dev_notice (dev,"No device request registered, blocked until released by user\n" );
drivers/usb/gadget/function/f_fs.c +2 -2
@@ -831,7 +831,7 @@ static void ffs_user_copy_worker(struct work_struct *work) io_data->kiocb->ki_complete (io_data->kiocb, ret);if (io_data->ffs->ffs_eventfd && !kiocb_has_eventfd) -eventfd_signal (io_data->ffs->ffs_eventfd,1 ); +eventfd_signal (io_data->ffs->ffs_eventfd);if (io_data->read)kfree (io_data->to_free);
@@ -2738,7 +2738,7 @@ static void __ffs_event_add(struct ffs_data *ffs, ffs->ev.types[ffs->ev.count++] = type;wake_up_locked (&ffs->ev.waitq);if (ffs->ffs_eventfd) -eventfd_signal (ffs->ffs_eventfd,1 ); +eventfd_signal (ffs->ffs_eventfd); } static void ffs_event_add(struct ffs_data *ffs,
drivers/vdpa/vdpa_user/vduse_dev.c +3 -3
@@ -493,7 +493,7 @@ static void vduse_vq_kick(struct vduse_virtqueue *vq) goto unlock;if (vq->kickfd) -eventfd_signal (vq->kickfd,1 ); +eventfd_signal (vq->kickfd);else vq->kicked = true; unlock:
@@ -911,7 +911,7 @@ static int vduse_kickfd_setup(struct vduse_dev *dev,eventfd_ctx_put (vq->kickfd); vq->kickfd = ctx;if (vq->ready && vq->kicked && vq->kickfd) { -eventfd_signal (vq->kickfd,1 ); +eventfd_signal (vq->kickfd); vq->kicked = false; }spin_unlock (&vq->kick_lock);
@@ -960,7 +960,7 @@ static bool vduse_vq_signal_irqfd(struct vduse_virtqueue *vq)spin_lock_irq (&vq->irq_lock);if (vq->ready && vq->cb.trigger) { -eventfd_signal (vq->cb.trigger,1 ); +eventfd_signal (vq->cb.trigger); signal = true; }spin_unlock_irq (&vq->irq_lock);
drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c +1 -1
@@ -54,7 +54,7 @@ static irqreturn_t vfio_fsl_mc_irq_handler(int irq_num, void *arg) {struct vfio_fsl_mc_irq *mc_irq = (struct vfio_fsl_mc_irq *)arg; -eventfd_signal (mc_irq->trigger,1 ); +eventfd_signal (mc_irq->trigger);return IRQ_HANDLED ; }
drivers/vfio/pci/vfio_pci_core.c +3 -3
@@ -443,7 +443,7 @@ static int vfio_pci_core_runtime_resume(struct device *dev)*/ down_write (&vdev->memory_lock);if (vdev->pm_wake_eventfd_ctx) { -eventfd_signal (vdev->pm_wake_eventfd_ctx,1 ); +eventfd_signal (vdev->pm_wake_eventfd_ctx);__vfio_pci_runtime_pm_exit (vdev); }up_write (&vdev->memory_lock);
@@ -1883,7 +1883,7 @@ void vfio_pci_core_request(struct vfio_device *core_vdev, unsigned int count)pci_notice_ratelimited (pdev,"Relaying device request to user (#%u)\n" , count); -eventfd_signal (vdev->req_trigger,1 ); +eventfd_signal (vdev->req_trigger); }else if (count ==0 ) {pci_warn (pdev,"No device request channel registered, blocked until released by user\n" );
@@ -2302,7 +2302,7 @@ pci_ers_result_t vfio_pci_core_aer_err_detected(struct pci_dev *pdev,mutex_lock (&vdev->igate);if (vdev->err_trigger) -eventfd_signal (vdev->err_trigger,1 ); +eventfd_signal (vdev->err_trigger);mutex_unlock (&vdev->igate);
drivers/vfio/pci/vfio_pci_intrs.c +6 -6
@@ -94,7 +94,7 @@ static void vfio_send_intx_eventfd(void *opaque, void *unused) ctx =vfio_irq_ctx_get (vdev,0 );if (WARN_ON_ONCE (!ctx))return ; -eventfd_signal (ctx->trigger,1 ); +eventfd_signal (ctx->trigger); } }
@@ -367,7 +367,7 @@ static irqreturn_t vfio_msihandler(int irq, void *arg) {struct eventfd_ctx *trigger = arg; -eventfd_signal (trigger,1 ); +eventfd_signal (trigger);return IRQ_HANDLED ; }
@@ -714,11 +714,11 @@ static int vfio_pci_set_msi_trigger(struct vfio_pci_core_device *vdev,if (!ctx)continue ;if (flags &VFIO_IRQ_SET_DATA_NONE ) { -eventfd_signal (ctx->trigger,1 ); +eventfd_signal (ctx->trigger); }else if (flags &VFIO_IRQ_SET_DATA_BOOL ) {uint8_t *bools = data;if (bools[i - start]) -eventfd_signal (ctx->trigger,1 ); +eventfd_signal (ctx->trigger); } }return 0 ;
@@ -732,7 +732,7 @@ static int vfio_pci_set_ctx_trigger_single(struct eventfd_ctx **ctx,if (flags &VFIO_IRQ_SET_DATA_NONE ) {if (*ctx) {if (count) { -eventfd_signal (*ctx,1 ); +eventfd_signal (*ctx); }else {eventfd_ctx_put (*ctx); *ctx =NULL ;
@@ -747,7 +747,7 @@ static int vfio_pci_set_ctx_trigger_single(struct eventfd_ctx **ctx, trigger = *(uint8_t *)data;if (trigger && *ctx) -eventfd_signal (*ctx,1 ); +eventfd_signal (*ctx);return 0 ; }else if (flags &VFIO_IRQ_SET_DATA_EVENTFD ) {
drivers/vfio/platform/vfio_platform_irq.c +2 -2
@@ -155,7 +155,7 @@ static irqreturn_t vfio_automasked_irq_handler(int irq, void *dev_id)spin_unlock_irqrestore (&irq_ctx->lock, flags);if (ret ==IRQ_HANDLED ) -eventfd_signal (irq_ctx->trigger,1 ); +eventfd_signal (irq_ctx->trigger);return ret; }
@@ -164,7 +164,7 @@ static irqreturn_t vfio_irq_handler(int irq, void *dev_id) {struct vfio_platform_irq *irq_ctx = dev_id; -eventfd_signal (irq_ctx->trigger,1 ); +eventfd_signal (irq_ctx->trigger);return IRQ_HANDLED ; }
drivers/vhost/vdpa.c +2 -2
@@ -178,7 +178,7 @@ static irqreturn_t vhost_vdpa_virtqueue_cb(void *private)struct eventfd_ctx *call_ctx = vq->call_ctx.ctx;if (call_ctx) -eventfd_signal (call_ctx,1 ); +eventfd_signal (call_ctx);return IRQ_HANDLED ; }
@@ -189,7 +189,7 @@ static irqreturn_t vhost_vdpa_config_cb(void *private)struct eventfd_ctx *config_ctx = v->config_ctx;if (config_ctx) -eventfd_signal (config_ctx,1 ); +eventfd_signal (config_ctx);return IRQ_HANDLED ; }
drivers/vhost/vhost.c +5 -5
@@ -2248,7 +2248,7 @@ int vhost_log_write(struct vhost_virtqueue *vq, struct vhost_log *log, len -= l;if (!len) {if (vq->log_ctx) -eventfd_signal (vq->log_ctx,1 ); +eventfd_signal (vq->log_ctx);return 0 ; } }
@@ -2271,7 +2271,7 @@ static int vhost_update_used_flags(struct vhost_virtqueue *vq)log_used (vq, (used - (void __user *)vq->used),sizeof vq->used->flags);if (vq->log_ctx) -eventfd_signal (vq->log_ctx,1 ); +eventfd_signal (vq->log_ctx); }return 0 ; }
@@ -2289,7 +2289,7 @@ static int vhost_update_avail_event(struct vhost_virtqueue *vq)log_used (vq, (used - (void __user *)vq->used),sizeof *vhost_avail_event (vq));if (vq->log_ctx) -eventfd_signal (vq->log_ctx,1 ); +eventfd_signal (vq->log_ctx); }return 0 ; }
@@ -2715,7 +2715,7 @@ int vhost_add_used_n(struct vhost_virtqueue *vq, struct vring_used_elem *heads,log_used (vq, offsetof(struct vring_used , idx),sizeof vq->used->idx);if (vq->log_ctx) -eventfd_signal (vq->log_ctx,1 ); +eventfd_signal (vq->log_ctx); }return r; }
@@ -2763,7 +2763,7 @@ void vhost_signal(struct vhost_dev *dev, struct vhost_virtqueue *vq) {/* Signal the Guest tell them we used something up. */ if (vq->call_ctx.ctx &&vhost_notify (dev, vq)) -eventfd_signal (vq->call_ctx.ctx,1 ); +eventfd_signal (vq->call_ctx.ctx); }EXPORT_SYMBOL_GPL (vhost_signal);
drivers/vhost/vhost.h +1 -1
@@ -249,7 +249,7 @@ void vhost_iotlb_map_free(struct vhost_iotlb *iotlb,#define vq_err (vq, fmt, ...) do { \ pr_debug(pr_fmt(fmt), ##__VA_ARGS__); \ if ((vq)->error_ctx) \ - eventfd_signal((vq)->error_ctx, 1);\ + eventfd_signal((vq)->error_ctx);\ } while (0)enum {
drivers/virt/acrn/ioeventfd.c +1 -1
@@ -223,7 +223,7 @@ static int acrn_ioeventfd_handler(struct acrn_ioreq_client *client,mutex_lock (&client->vm->ioeventfds_lock); p =hsm_ioeventfd_match (client->vm, addr, val, size, req->type);if (p) -eventfd_signal (p->eventfd,1 ); +eventfd_signal (p->eventfd);mutex_unlock (&client->vm->ioeventfds_lock);return 0 ;
drivers/xen/privcmd.c +1 -1
@@ -1147,7 +1147,7 @@ static irqreturn_t ioeventfd_interrupt(int irq, void *dev_id)if (ioreq->addr == kioeventfd->addr +VIRTIO_MMIO_QUEUE_NOTIFY && ioreq->size == kioeventfd->addr_len && (ioreq->data &QUEUE_NOTIFY_VQ_MASK ) == kioeventfd->vq) { -eventfd_signal (kioeventfd->eventfd,1 ); +eventfd_signal (kioeventfd->eventfd); state =STATE_IORESP_READY ;break ; }
fs/aio.c +1 -1
@@ -1173,7 +1173,7 @@ static void aio_complete(struct aio_kiocb *iocb)* from IRQ context. */ if (iocb->ki_eventfd) -eventfd_signal (iocb->ki_eventfd,1 ); +eventfd_signal (iocb->ki_eventfd);/* * We have to order our ring_info tail store above and test
fs/eventfd.c +4 -7
@@ -72,22 +72,19 @@ __u64 eventfd_signal_mask(struct eventfd_ctx *ctx, __u64 n, __poll_t mask) }/** -* eventfd_signal - Adds @n to the eventfd counter. +* eventfd_signal - Increment the event counter * @ctx: [in] Pointer to the eventfd context. -* @n: [in] Value of the counter to be added to the eventfd internal counter. -* The value cannot be negative. * * This function is supposed to be called by the kernel in paths that do not * allow sleeping. In this function we allow the counter to reach the ULLONG_MAX * value, and we signal this as overflow condition by returning a EPOLLERR * to poll(2). * -* Returns the amount by which the counter was incremented. This will be less -* than @n if the counter has overflowed. +* Returns the amount by which the counter was incremented. */ -__u64 eventfd_signal (struct eventfd_ctx *ctx,__u64 n) +__u64 eventfd_signal (struct eventfd_ctx *ctx) { -return eventfd_signal_mask (ctx, n,0 ); +return eventfd_signal_mask (ctx,1 ,0 ); }EXPORT_SYMBOL_GPL (eventfd_signal);
include/linux/eventfd.h +2 -2
@@ -35,7 +35,7 @@ void eventfd_ctx_put(struct eventfd_ctx *ctx);struct file *eventfd_fget (int fd);struct eventfd_ctx *eventfd_ctx_fdget (int fd);struct eventfd_ctx *eventfd_ctx_fileget (struct file *file); -__u64 eventfd_signal (struct eventfd_ctx *ctx,__u64 n); +__u64 eventfd_signal (struct eventfd_ctx *ctx);__u64 eventfd_signal_mask (struct eventfd_ctx *ctx,__u64 n,__poll_t mask);int eventfd_ctx_remove_wait_queue (struct eventfd_ctx *ctx,wait_queue_entry_t *wait,__u64 *cnt);
@@ -58,7 +58,7 @@ static inline struct eventfd_ctx *eventfd_ctx_fdget(int fd)return ERR_PTR (-ENOSYS ); } -static inline int eventfd_signal (struct eventfd_ctx *ctx,__u64 n) +static inline int eventfd_signal (struct eventfd_ctx *ctx) {return -ENOSYS ; }
mm/memcontrol.c +5 -5
@@ -4379,7 +4379,7 @@ static void __mem_cgroup_threshold(struct mem_cgroup *memcg, bool swap)* only one element of the array here. */ for (; i >=0 &&unlikely (t->entries[i].threshold > usage); i--) -eventfd_signal (t->entries[i].eventfd,1 ); +eventfd_signal (t->entries[i].eventfd);/* i = current_threshold + 1 */ i++;
@@ -4391,7 +4391,7 @@ static void __mem_cgroup_threshold(struct mem_cgroup *memcg, bool swap)* only one element of the array here. */ for (; i < t->size &&unlikely (t->entries[i].threshold <= usage); i++) -eventfd_signal (t->entries[i].eventfd,1 ); +eventfd_signal (t->entries[i].eventfd);/* Update current_threshold */ t->current_threshold = i -1 ;
@@ -4431,7 +4431,7 @@ static int mem_cgroup_oom_notify_cb(struct mem_cgroup *memcg)spin_lock (&memcg_oom_lock);list_for_each_entry (ev, &memcg->oom_notify, list) -eventfd_signal (ev->eventfd,1 ); +eventfd_signal (ev->eventfd);spin_unlock (&memcg_oom_lock);return 0 ;
@@ -4650,7 +4650,7 @@ static int mem_cgroup_oom_register_event(struct mem_cgroup *memcg,/* already in OOM ? */ if (memcg->under_oom) -eventfd_signal (eventfd,1 ); +eventfd_signal (eventfd);spin_unlock (&memcg_oom_lock);return 0 ;
@@ -4942,7 +4942,7 @@ static void memcg_event_remove(struct work_struct *work) event->unregister_event (memcg, event->eventfd);/* Notify userspace the event is going away. */ -eventfd_signal (event->eventfd,1 ); +eventfd_signal (event->eventfd);eventfd_ctx_put (event->eventfd);kfree (event);
mm/vmpressure.c +1 -1
@@ -169,7 +169,7 @@ static bool vmpressure_event(struct vmpressure *vmpr,continue ;if (level < ev->level)continue ; -eventfd_signal (ev->efd,1 ); +eventfd_signal (ev->efd); ret = true; }mutex_unlock (&vmpr->events_lock);
samples/vfio-mdev/mtty.c +2 -2
@@ -234,10 +234,10 @@ static void mtty_trigger_interrupt(struct mdev_state *mdev_state)if (is_msi (mdev_state)) {if (mdev_state->msi_evtfd) -eventfd_signal (mdev_state->msi_evtfd,1 ); +eventfd_signal (mdev_state->msi_evtfd); }else if (is_intx (mdev_state)) {if (mdev_state->intx_evtfd && !mdev_state->intx_mask) { -eventfd_signal (mdev_state->intx_evtfd,1 ); +eventfd_signal (mdev_state->intx_evtfd); mdev_state->intx_mask = true; } }
virt/kvm/eventfd.c +2 -2
@@ -61,7 +61,7 @@ static void irqfd_resampler_notify(struct kvm_kernel_irqfd_resampler *resampler)list_for_each_entry_srcu (irqfd, &resampler->list, resampler_link,srcu_read_lock_held (&resampler->kvm->irq_srcu)) -eventfd_signal (irqfd->resamplefd,1 ); +eventfd_signal (irqfd->resamplefd); }/*
@@ -786,7 +786,7 @@ ioeventfd_write(struct kvm_vcpu *vcpu, struct kvm_io_device *this, gpa_t addr,if (!ioeventfd_in_range (p, addr, len, val))return -EOPNOTSUPP ; -eventfd_signal (p->eventfd,1 ); +eventfd_signal (p->eventfd);return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 148/432 vfio/platform: Create persistent IRQ handlers
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
[ Upstream commit 675daf435e9f8e5a5eab140a9864dfad6668b375 ]
The vfio-platform SET_IRQS ioctl currently allows loopback triggering of an interrupt before a signaling eventfd has been configured by the user, which thereby allows a NULL pointer dereference.
Rather than register the IRQ relative to a valid trigger, register all IRQs in a disabled state in the device open path. This allows mask operations on the IRQ to nest within the overall enable state governed by a valid eventfd signal. This decouples @masked, protected by the @locked spinlock from @trigger, protected via the @igate mutex.
In doing so, it's guaranteed that changes to @trigger cannot race the IRQ handlers because the IRQ handler is synchronously disabled before modifying the trigger, and loopback triggering of the IRQ via ioctl is safe due to serialization with trigger changes via igate.
For compatibility, request_irq() failures are maintained to be local to the SET_IRQS ioctl rather than a fatal error in the open device path. This allows, for example, a userspace driver with polling mode support to continue to work regardless of moving the request_irq() call site. This necessarily blocks all SET_IRQS access to the failed index.
--- drivers/vfio/platform/vfio_platform_irq.c | 100 +++++++++++++++------- 1 file changed, 68 insertions(+), 32 deletions(-)
drivers/vfio/platform/vfio_platform_irq.c +68 -32
@@ -136,6 +136,16 @@ static int vfio_platform_set_irq_unmask(struct vfio_platform_device *vdev,return 0 ; } +/* +* The trigger eventfd is guaranteed valid in the interrupt path +* and protected by the igate mutex when triggered via ioctl. +*/ +static void vfio_send_eventfd (struct vfio_platform_irq *irq_ctx) +{ +if (likely (irq_ctx->trigger)) +eventfd_signal (irq_ctx->trigger); +} +static irqreturn_t vfio_automasked_irq_handler (int irq,void *dev_id) {struct vfio_platform_irq *irq_ctx = dev_id;
@@ -155,7 +165,7 @@ static irqreturn_t vfio_automasked_irq_handler(int irq, void *dev_id)spin_unlock_irqrestore (&irq_ctx->lock, flags);if (ret ==IRQ_HANDLED ) -eventfd_signal (irq_ctx->trigger); +vfio_send_eventfd (irq_ctx);return ret; }
@@ -164,52 +174,40 @@ static irqreturn_t vfio_irq_handler(int irq, void *dev_id) {struct vfio_platform_irq *irq_ctx = dev_id; -eventfd_signal (irq_ctx->trigger); +vfio_send_eventfd (irq_ctx);return IRQ_HANDLED ; }static int vfio_set_trigger (struct vfio_platform_device *vdev,int index, -int fd,irq_handler_t handler) +int fd) {struct vfio_platform_irq *irq = &vdev->irqs[index];struct eventfd_ctx *trigger; -int ret;if (irq->trigger) { -irq_clear_status_flags (irq->hwirq,IRQ_NOAUTOEN ); -free_irq (irq->hwirq, irq); -kfree (irq->name); +disable_irq (irq->hwirq);eventfd_ctx_put (irq->trigger); irq->trigger =NULL ; }if (fd <0 )/* Disable only */ return 0 ; - irq->name =kasprintf (GFP_KERNEL_ACCOUNT ,"vfio-irq[%d](%s)" , - irq->hwirq, vdev->name); -if (!irq->name) -return -ENOMEM ; trigger =eventfd_ctx_fdget (fd); -if (IS_ERR (trigger)) { -kfree (irq->name); +if (IS_ERR (trigger))return PTR_ERR (trigger); - } irq->trigger = trigger; -irq_set_status_flags (irq->hwirq,IRQ_NOAUTOEN ); - ret =request_irq (irq->hwirq, handler,0 , irq->name, irq); -if (ret) { -kfree (irq->name); -eventfd_ctx_put (trigger); - irq->trigger =NULL ; -return ret; - } - -if (!irq->masked) -enable_irq (irq->hwirq); +/* +* irq->masked effectively provides nested disables within the overall +* enable relative to trigger. Specifically request_irq() is called +* with NO_AUTOEN, therefore the IRQ is initially disabled. The user +* may only further disable the IRQ with a MASK operations because +* irq->masked is initially false. +*/ +enable_irq (irq->hwirq);return 0 ; }
@@ -228,7 +226,7 @@ static int vfio_platform_set_irq_trigger(struct vfio_platform_device *vdev, handler = vfio_irq_handler;if (!count && (flags &VFIO_IRQ_SET_DATA_NONE )) -return vfio_set_trigger (vdev, index,-1 , handler); +return vfio_set_trigger (vdev, index,-1 );if (start !=0 || count !=1 )return -EINVAL ;
@@ -236,7 +234,7 @@ static int vfio_platform_set_irq_trigger(struct vfio_platform_device *vdev,if (flags &VFIO_IRQ_SET_DATA_EVENTFD ) {int32_t fd = *(int32_t *)data; -return vfio_set_trigger (vdev, index, fd, handler); +return vfio_set_trigger (vdev, index, fd); }if (flags &VFIO_IRQ_SET_DATA_NONE ) {
@@ -260,6 +258,14 @@ int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev, unsigned start, unsigned count, uint32_t flags, void *data) = NULL; +/* +* For compatibility, errors from request_irq() are local to the +* SET_IRQS path and reflected in the name pointer. This allows, +* for example, polling mode fallback for an exclusive IRQ failure. +*/ +if (IS_ERR (vdev->irqs[index].name)) +return PTR_ERR (vdev->irqs[index].name); +switch (flags &VFIO_IRQ_SET_ACTION_TYPE_MASK ) {case VFIO_IRQ_SET_ACTION_MASK : func = vfio_platform_set_irq_mask;
@@ -280,7 +286,7 @@ int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev,int vfio_platform_irq_init (struct vfio_platform_device *vdev) { -int cnt =0 , i; +int cnt =0 , i, ret =0 ;while (vdev->get_irq (vdev, cnt) >=0 ) cnt++;
@@ -292,29 +298,54 @@ int vfio_platform_irq_init(struct vfio_platform_device *vdev)for (i =0 ; i < cnt; i++) {int hwirq = vdev->get_irq (vdev, i); +irq_handler_t handler = vfio_irq_handler; -if (hwirq <0 ) +if (hwirq <0 ) { + ret = -EINVAL ; goto err; + }spin_lock_init (&vdev->irqs[i].lock); vdev->irqs[i].flags =VFIO_IRQ_INFO_EVENTFD ; -if (irq_get_trigger_type (hwirq) &IRQ_TYPE_LEVEL_MASK ) +if (irq_get_trigger_type (hwirq) &IRQ_TYPE_LEVEL_MASK ) { vdev->irqs[i].flags |=VFIO_IRQ_INFO_MASKABLE |VFIO_IRQ_INFO_AUTOMASKED ; + handler = vfio_automasked_irq_handler; + } vdev->irqs[i].count =1 ; vdev->irqs[i].hwirq = hwirq; vdev->irqs[i].masked = false; + vdev->irqs[i].name =kasprintf (GFP_KERNEL_ACCOUNT , +"vfio-irq[%d](%s)" , hwirq, + vdev->name); +if (!vdev->irqs[i].name) { + ret = -ENOMEM ; + goto err; + } + + ret =request_irq (hwirq, handler,IRQF_NO_AUTOEN , + vdev->irqs[i].name, &vdev->irqs[i]); +if (ret) { +kfree (vdev->irqs[i].name); + vdev->irqs[i].name =ERR_PTR (ret); + } } vdev->num_irqs = cnt;return 0 ; err: +for (--i; i >=0 ; i--) { +if (!IS_ERR (vdev->irqs[i].name)) { +free_irq (vdev->irqs[i].hwirq, &vdev->irqs[i]); +kfree (vdev->irqs[i].name); + } + }kfree (vdev->irqs); -return -EINVAL ; +return ret; }void vfio_platform_irq_cleanup (struct vfio_platform_device *vdev)
@@ -324,7 +355,12 @@ void vfio_platform_irq_cleanup(struct vfio_platform_device *vdev)for (i =0 ; i < vdev->num_irqs; i++) {vfio_virqfd_disable (&vdev->irqs[i].mask);vfio_virqfd_disable (&vdev->irqs[i].unmask); -vfio_set_trigger (vdev, i,-1 ,NULL ); +if (!IS_ERR (vdev->irqs[i].name)) { +free_irq (vdev->irqs[i].hwirq, &vdev->irqs[i]); +if (vdev->irqs[i].trigger) +eventfd_ctx_put (vdev->irqs[i].trigger); +kfree (vdev->irqs[i].name); + } } vdev->num_irqs =0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 149/432 vfio/fsl-mc: Block calling interrupt handler without trigger
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
[ Upstream commit 7447d911af699a15f8d050dfcb7c680a86f87012 ]
The eventfd_ctx trigger pointer of the vfio_fsl_mc_irq object is initially NULL and may become NULL if the user sets the trigger eventfd to -1. The interrupt handler itself is guaranteed that trigger is always valid between request_irq() and free_irq(), but the loopback testing mechanisms to invoke the handler function need to test the trigger. The triggering and setting ioctl paths both make use of igate and are therefore mutually exclusive.
The vfio-fsl-mc driver does not make use of irqfds, nor does it support any sort of masking operations, therefore unlike vfio-pci and vfio-platform, the flow can remain essentially unchanged.
--- drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/vfio/fsl-mc/vfio_fsl_mc_intr.c +4 -3
@@ -141,13 +141,14 @@ static int vfio_fsl_mc_set_irq_trigger(struct vfio_fsl_mc_device *vdev, irq = &vdev->mc_irqs[index];if (flags &VFIO_IRQ_SET_DATA_NONE ) { -vfio_fsl_mc_irq_handler (hwirq, irq); +if (irq->trigger) +eventfd_signal (irq->trigger); }else if (flags &VFIO_IRQ_SET_DATA_BOOL ) {u8 trigger = *(u8 *)data; -if (trigger) -vfio_fsl_mc_irq_handler (hwirq, irq); +if (trigger && irq->trigger) +eventfd_signal (irq->trigger); }return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 150/432 tpm,tpm_tis: Avoid warning splat at shutdown
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lino Sanfilippo <[email protected]>
[ Upstream commit b7ab4bbd0188f3985b821fa09456b11105a8dedf ]
If interrupts are not activated the work struct 'free_irq_work' is not initialized. This results in a warning splat at module shutdown.
Fix this by always initializing the work regardless of whether interrupts are activated or not.
--- drivers/char/tpm/tpm_tis_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/char/tpm/tpm_tis_core.c +1 -2
@@ -919,8 +919,6 @@ static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,int rc;u32 int_status; -INIT_WORK (&priv->free_irq_work, tpm_tis_free_irq_func); - rc =devm_request_threaded_irq (chip->dev.parent, irq,NULL , tis_int_handler,IRQF_ONESHOT | flags,dev_name (&chip->dev), chip);
@@ -1132,6 +1130,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, priv->phy_ops = phy_ops; priv->locality_count =0 ;mutex_init (&priv->locality_count_mutex); +INIT_WORK (&priv->free_irq_work, tpm_tis_free_irq_func);dev_set_drvdata (&chip->dev, priv);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 151/432 ksmbd: replace generic_fillattr with vfs_getattr
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marios Makassikis <[email protected]>
[ Upstream commit 5614c8c487f6af627614dd2efca038e4afe0c6d7 ]
generic_fillattr should not be used outside of ->getattr implementations.
Use vfs_getattr instead, and adapt functions to return an error code to the caller.
--- fs/smb/server/smb2pdu.c | 170 ++++++++++++++++++++++++------------- fs/smb/server/smb_common.c | 11 ++- fs/smb/server/vfs.c | 12 ++- 3 files changed, 127 insertions(+), 66 deletions(-)
fs/smb/server/smb2pdu.c +110 -60
@@ -3828,11 +3828,16 @@ static int process_query_dir_entries(struct smb2_query_dir_private *priv) } ksmbd_kstat.kstat = &kstat; -if (priv->info_level !=FILE_NAMES_INFORMATION ) -ksmbd_vfs_fill_dentry_attrs (priv->work, - idmap, - dent, - &ksmbd_kstat); +if (priv->info_level !=FILE_NAMES_INFORMATION ) { + rc =ksmbd_vfs_fill_dentry_attrs (priv->work, + idmap, + dent, + &ksmbd_kstat); +if (rc) { +dput (dent); +continue ; + } + } rc = smb2_populate_readdir_entry(priv->work->conn, priv->info_level,
@@ -4480,6 +4485,7 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp,struct smb2_file_basic_info *basic_info;struct kstat stat;u64 time; +int ret;if (!(fp->daccess &FILE_READ_ATTRIBUTES_LE )) { pr_err("no right to read the attributes : 0x%x\n",
@@ -4487,9 +4493,12 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp,return -EACCES ; } + ret =vfs_getattr (&fp->filp->f_path, &stat,STATX_BASIC_STATS , +AT_STATX_SYNC_AS_STAT ); +if (ret) +return ret; + basic_info = (struct smb2_file_basic_info *)rsp->Buffer; -generic_fillattr (file_mnt_idmap (fp->filp),STATX_BASIC_STATS , -file_inode (fp->filp), &stat); basic_info->CreationTime =cpu_to_le64 (fp->create_time); time =ksmbd_UnixTimeToNT (stat.atime); basic_info->LastAccessTime =cpu_to_le64 (time);
@@ -4504,27 +4513,31 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp,return 0 ; } -static void get_file_standard_info (struct smb2_query_info_rsp *rsp, -struct ksmbd_file *fp,void *rsp_org) +static int get_file_standard_info (struct smb2_query_info_rsp *rsp, +struct ksmbd_file *fp,void *rsp_org) {struct smb2_file_standard_info *sinfo;unsigned int delete_pending; -struct inode *inode;struct kstat stat; +int ret; - inode =file_inode (fp->filp); -generic_fillattr (file_mnt_idmap (fp->filp),STATX_BASIC_STATS , inode, &stat); + ret =vfs_getattr (&fp->filp->f_path, &stat,STATX_BASIC_STATS , +AT_STATX_SYNC_AS_STAT ); +if (ret) +return ret; sinfo = (struct smb2_file_standard_info *)rsp->Buffer; delete_pending =ksmbd_inode_pending_delete (fp); - sinfo->AllocationSize =cpu_to_le64 (inode->i_blocks <<9 ); + sinfo->AllocationSize =cpu_to_le64 (stat.blocks <<9 ); sinfo->EndOfFile =S_ISDIR (stat.mode) ?0 :cpu_to_le64 (stat.size); sinfo->NumberOfLinks =cpu_to_le32 (get_nlink (&stat) - delete_pending); sinfo->DeletePending = delete_pending; sinfo->Directory =S_ISDIR (stat.mode) ?1 :0 ; rsp->OutputBufferLength =cpu_to_le32 (sizeof (struct smb2_file_standard_info )); + +return 0 ; } static void get_file_alignment_info(struct smb2_query_info_rsp *rsp,
@@ -4546,11 +4559,11 @@ static int get_file_all_info(struct ksmbd_work *work,struct ksmbd_conn *conn = work->conn;struct smb2_file_all_info *file_info;unsigned int delete_pending; -struct inode *inode;struct kstat stat;int conv_len;char *filename;u64 time; +int ret;if (!(fp->daccess &FILE_READ_ATTRIBUTES_LE )) { ksmbd_debug(SMB, "no right to read the attributes : 0x%x\n",
@@ -4562,8 +4575,10 @@ static int get_file_all_info(struct ksmbd_work *work,if (IS_ERR (filename))return PTR_ERR (filename); - inode =file_inode (fp->filp); -generic_fillattr (file_mnt_idmap (fp->filp),STATX_BASIC_STATS , inode, &stat); + ret =vfs_getattr (&fp->filp->f_path, &stat,STATX_BASIC_STATS , +AT_STATX_SYNC_AS_STAT ); +if (ret) +return ret;ksmbd_debug (SMB ,"filename = %s\n" , filename); delete_pending =ksmbd_inode_pending_delete (fp);
@@ -4579,7 +4594,7 @@ static int get_file_all_info(struct ksmbd_work *work, file_info->Attributes = fp->f_ci->m_fattr; file_info->Pad1 =0 ; file_info->AllocationSize = -cpu_to_le64 (inode->i_blocks <<9 ); +cpu_to_le64 (stat.blocks <<9 ); file_info->EndOfFile =S_ISDIR (stat.mode) ?0 :cpu_to_le64 (stat.size); file_info->NumberOfLinks =cpu_to_le32 (get_nlink (&stat) - delete_pending);
@@ -4623,10 +4638,10 @@ static void get_file_alternate_info(struct ksmbd_work *work,cpu_to_le32 (sizeof (struct smb2_file_alt_name_info ) + conv_len); } -static void get_file_stream_info (struct ksmbd_work *work, -struct smb2_query_info_rsp *rsp, -struct ksmbd_file *fp, -void *rsp_org) +static int get_file_stream_info (struct ksmbd_work *work, +struct smb2_query_info_rsp *rsp, +struct ksmbd_file *fp, +void *rsp_org) {struct ksmbd_conn *conn = work->conn;struct smb2_file_stream_info *file_info;
@@ -4637,9 +4652,13 @@ static void get_file_stream_info(struct ksmbd_work *work,int nbytes =0 , streamlen, stream_name_len, next, idx =0 ;int buf_free_len;struct smb2_query_info_req *req =ksmbd_req_buf_next (work); +int ret; + + ret =vfs_getattr (&fp->filp->f_path, &stat,STATX_BASIC_STATS , +AT_STATX_SYNC_AS_STAT ); +if (ret) +return ret; -generic_fillattr (file_mnt_idmap (fp->filp),STATX_BASIC_STATS , -file_inode (fp->filp), &stat); file_info = (struct smb2_file_stream_info *)rsp->Buffer; buf_free_len =
@@ -4720,29 +4739,37 @@ static void get_file_stream_info(struct ksmbd_work *work,kvfree (xattr_list); rsp->OutputBufferLength =cpu_to_le32 (nbytes); + +return 0 ; } -static void get_file_internal_info (struct smb2_query_info_rsp *rsp, -struct ksmbd_file *fp,void *rsp_org) +static int get_file_internal_info (struct smb2_query_info_rsp *rsp, +struct ksmbd_file *fp,void *rsp_org) {struct smb2_file_internal_info *file_info;struct kstat stat; +int ret; + + ret =vfs_getattr (&fp->filp->f_path, &stat,STATX_BASIC_STATS , +AT_STATX_SYNC_AS_STAT ); +if (ret) +return ret; -generic_fillattr (file_mnt_idmap (fp->filp),STATX_BASIC_STATS , -file_inode (fp->filp), &stat); file_info = (struct smb2_file_internal_info *)rsp->Buffer; file_info->IndexNumber =cpu_to_le64 (stat.ino); rsp->OutputBufferLength =cpu_to_le32 (sizeof (struct smb2_file_internal_info )); + +return 0 ; }static int get_file_network_open_info (struct smb2_query_info_rsp *rsp,struct ksmbd_file *fp,void *rsp_org) {struct smb2_file_ntwrk_info *file_info; -struct inode *inode;struct kstat stat;u64 time; +int ret;if (!(fp->daccess &FILE_READ_ATTRIBUTES_LE )) { pr_err("no right to read the attributes : 0x%x\n",
@@ -4750,10 +4777,12 @@ static int get_file_network_open_info(struct smb2_query_info_rsp *rsp,return -EACCES ; } - file_info = (struct smb2_file_ntwrk_info *)rsp->Buffer; + ret =vfs_getattr (&fp->filp->f_path, &stat,STATX_BASIC_STATS , +AT_STATX_SYNC_AS_STAT ); +if (ret) +return ret; - inode =file_inode (fp->filp); -generic_fillattr (file_mnt_idmap (fp->filp),STATX_BASIC_STATS , inode, &stat); + file_info = (struct smb2_file_ntwrk_info *)rsp->Buffer; file_info->CreationTime =cpu_to_le64 (fp->create_time); time =ksmbd_UnixTimeToNT (stat.atime);
@@ -4763,8 +4792,7 @@ static int get_file_network_open_info(struct smb2_query_info_rsp *rsp, time =ksmbd_UnixTimeToNT (stat.ctime); file_info->ChangeTime =cpu_to_le64 (time); file_info->Attributes = fp->f_ci->m_fattr; - file_info->AllocationSize = -cpu_to_le64 (inode->i_blocks <<9 ); + file_info->AllocationSize =cpu_to_le64 (stat.blocks <<9 ); file_info->EndOfFile =S_ISDIR (stat.mode) ?0 :cpu_to_le64 (stat.size); file_info->Reserved =cpu_to_le32 (0 ); rsp->OutputBufferLength =
@@ -4804,14 +4832,17 @@ static void get_file_mode_info(struct smb2_query_info_rsp *rsp,cpu_to_le32 (sizeof (struct smb2_file_mode_info )); } -static void get_file_compression_info (struct smb2_query_info_rsp *rsp, -struct ksmbd_file *fp,void *rsp_org) +static int get_file_compression_info (struct smb2_query_info_rsp *rsp, +struct ksmbd_file *fp,void *rsp_org) {struct smb2_file_comp_info *file_info;struct kstat stat; +int ret; -generic_fillattr (file_mnt_idmap (fp->filp),STATX_BASIC_STATS , -file_inode (fp->filp), &stat); + ret =vfs_getattr (&fp->filp->f_path, &stat,STATX_BASIC_STATS , +AT_STATX_SYNC_AS_STAT ); +if (ret) +return ret; file_info = (struct smb2_file_comp_info *)rsp->Buffer; file_info->CompressedFileSize =cpu_to_le64 (stat.blocks <<9 );
@@ -4823,6 +4854,8 @@ static void get_file_compression_info(struct smb2_query_info_rsp *rsp, rsp->OutputBufferLength =cpu_to_le32 (sizeof (struct smb2_file_comp_info )); + +return 0 ; } static int get_file_attribute_tag_info(struct smb2_query_info_rsp *rsp,
@@ -4844,7 +4877,7 @@ static int get_file_attribute_tag_info(struct smb2_query_info_rsp *rsp,return 0 ; } -static void find_file_posix_info (struct smb2_query_info_rsp *rsp, +static int find_file_posix_info (struct smb2_query_info_rsp *rsp,struct ksmbd_file *fp,void *rsp_org) {struct smb311_posix_qinfo *file_info;
@@ -4852,24 +4885,31 @@ static void find_file_posix_info(struct smb2_query_info_rsp *rsp,struct mnt_idmap *idmap =file_mnt_idmap (fp->filp);vfsuid_t vfsuid =i_uid_into_vfsuid (idmap, inode);vfsgid_t vfsgid =i_gid_into_vfsgid (idmap, inode); +struct kstat stat;u64 time;int out_buf_len =sizeof (struct smb311_posix_qinfo ) +32 ; +int ret; + + ret =vfs_getattr (&fp->filp->f_path, &stat,STATX_BASIC_STATS , +AT_STATX_SYNC_AS_STAT ); +if (ret) +return ret; file_info = (struct smb311_posix_qinfo *)rsp->Buffer; file_info->CreationTime =cpu_to_le64 (fp->create_time); - time =ksmbd_UnixTimeToNT (inode_get_atime (inode)); + time =ksmbd_UnixTimeToNT (stat.atime); file_info->LastAccessTime =cpu_to_le64 (time); - time =ksmbd_UnixTimeToNT (inode_get_mtime (inode)); + time =ksmbd_UnixTimeToNT (stat.mtime); file_info->LastWriteTime =cpu_to_le64 (time); - time =ksmbd_UnixTimeToNT (inode_get_ctime (inode)); + time =ksmbd_UnixTimeToNT (stat.ctime); file_info->ChangeTime =cpu_to_le64 (time); file_info->DosAttributes = fp->f_ci->m_fattr; - file_info->Inode =cpu_to_le64 (inode->i_ino); - file_info->EndOfFile =cpu_to_le64 (inode->i_size); - file_info->AllocationSize =cpu_to_le64 (inode->i_blocks <<9 ); - file_info->HardLinks =cpu_to_le32 (inode->i_nlink); - file_info->Mode =cpu_to_le32 (inode->i_mode &0777 ); - file_info->DeviceId =cpu_to_le32 (inode->i_rdev); + file_info->Inode =cpu_to_le64 (stat.ino); + file_info->EndOfFile =cpu_to_le64 (stat.size); + file_info->AllocationSize =cpu_to_le64 (stat.blocks <<9 ); + file_info->HardLinks =cpu_to_le32 (stat.nlink); + file_info->Mode =cpu_to_le32 (stat.mode &0777 ); + file_info->DeviceId =cpu_to_le32 (stat.rdev);/* * Sids(32) contain two sids(Domain sid(16), UNIX group sid(16)).
@@ -4882,6 +4922,8 @@ static void find_file_posix_info(struct smb2_query_info_rsp *rsp, SIDUNIX_GROUP, (struct smb_sid *)&file_info->Sids[16]); rsp->OutputBufferLength =cpu_to_le32 (out_buf_len); + +return 0 ; } static int smb2_get_info_file(struct ksmbd_work *work,
@@ -4930,7 +4972,7 @@ static int smb2_get_info_file(struct ksmbd_work *work,break ;case FILE_STANDARD_INFORMATION : -get_file_standard_info (rsp, fp, work->response_buf); + rc =get_file_standard_info (rsp, fp, work->response_buf);break ;case FILE_ALIGNMENT_INFORMATION :
@@ -4946,11 +4988,11 @@ static int smb2_get_info_file(struct ksmbd_work *work,break ;case FILE_STREAM_INFORMATION : -get_file_stream_info (work, rsp, fp, work->response_buf); + rc =get_file_stream_info (work, rsp, fp, work->response_buf);break ;case FILE_INTERNAL_INFORMATION : -get_file_internal_info (rsp, fp, work->response_buf); + rc =get_file_internal_info (rsp, fp, work->response_buf);break ;case FILE_NETWORK_OPEN_INFORMATION :
@@ -4974,7 +5016,7 @@ static int smb2_get_info_file(struct ksmbd_work *work,break ;case FILE_COMPRESSION_INFORMATION : -get_file_compression_info (rsp, fp, work->response_buf); + rc =get_file_compression_info (rsp, fp, work->response_buf);break ;case FILE_ATTRIBUTE_TAG_INFORMATION :
@@ -4985,7 +5027,7 @@ static int smb2_get_info_file(struct ksmbd_work *work,pr_err ("client doesn't negotiate with SMB3.1.1 POSIX Extensions\n" ); rc = -EOPNOTSUPP ; }else { -find_file_posix_info (rsp, fp, work->response_buf); + rc =find_file_posix_info (rsp, fp, work->response_buf); }break ;default :
@@ -5398,7 +5440,6 @@ int smb2_close(struct ksmbd_work *work)struct smb2_close_rsp *rsp;struct ksmbd_conn *conn = work->conn;struct ksmbd_file *fp; -struct inode *inode;u64 time;int err =0 ;
@@ -5453,24 +5494,33 @@ int smb2_close(struct ksmbd_work *work) rsp->Reserved =0 ;if (req->Flags ==SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB ) { +struct kstat stat; +int ret; + fp =ksmbd_lookup_fd_fast (work, volatile_id);if (!fp) { err = -ENOENT ; goto out; } - inode =file_inode (fp->filp); + ret =vfs_getattr (&fp->filp->f_path, &stat,STATX_BASIC_STATS , +AT_STATX_SYNC_AS_STAT ); +if (ret) { +ksmbd_fd_put (work, fp); + goto out; + } + rsp->Flags =SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB ; - rsp->AllocationSize =S_ISDIR (inode->i_mode) ?0 : -cpu_to_le64 (inode->i_blocks <<9 ); - rsp->EndOfFile =cpu_to_le64 (inode->i_size); + rsp->AllocationSize =S_ISDIR (stat.mode) ?0 : +cpu_to_le64 (stat.blocks <<9 ); + rsp->EndOfFile =cpu_to_le64 (stat.size); rsp->Attributes = fp->f_ci->m_fattr; rsp->CreationTime =cpu_to_le64 (fp->create_time); - time =ksmbd_UnixTimeToNT (inode_get_atime (inode)); + time =ksmbd_UnixTimeToNT (stat.atime); rsp->LastAccessTime =cpu_to_le64 (time); - time =ksmbd_UnixTimeToNT (inode_get_mtime (inode)); + time =ksmbd_UnixTimeToNT (stat.mtime); rsp->LastWriteTime =cpu_to_le64 (time); - time =ksmbd_UnixTimeToNT (inode_get_ctime (inode)); + time =ksmbd_UnixTimeToNT (stat.ctime); rsp->ChangeTime =cpu_to_le64 (time);ksmbd_fd_put (work, fp); }else {
fs/smb/server/smb_common.c +7 -4
@@ -457,10 +457,13 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level, } ksmbd_kstat.kstat = &kstat; -ksmbd_vfs_fill_dentry_attrs (work, - idmap, - dentry, - &ksmbd_kstat); + rc =ksmbd_vfs_fill_dentry_attrs (work, + idmap, + dentry, + &ksmbd_kstat); +if (rc) +break ; + rc =fn (conn, info_level, d_info, &ksmbd_kstat);if (rc)break ;
fs/smb/server/vfs.c +10 -2
@@ -1669,11 +1669,19 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,struct dentry *dentry, struct ksmbd_kstat *ksmbd_kstat) { + struct ksmbd_share_config *share_conf = work->tcon->share_conf;u64 time;int rc; +struct path path = { + .mnt = share_conf->vfs_path.mnt, + .dentry = dentry, + }; -generic_fillattr (idmap,STATX_BASIC_STATS ,d_inode (dentry), - ksmbd_kstat->kstat); + rc =vfs_getattr (&path, ksmbd_kstat->kstat, +STATX_BASIC_STATS |STATX_BTIME , +AT_STATX_SYNC_AS_STAT ); +if (rc) +return rc; time =ksmbd_UnixTimeToNT (ksmbd_kstat->kstat->ctime); ksmbd_kstat->create_time = time;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 152/432 ksmbd: retrieve number of blocks using vfs_getattr in set_file_allocation_info
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marios Makassikis <[email protected]>
[ Upstream commit 34cd86b6632718b7df3999d96f51e63de41c5e4f ]
Use vfs_getattr() to retrieve stat information, rather than make assumptions about how a filesystem fills inode structs.
--- fs/smb/server/smb2pdu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/smb/server/smb2pdu.c +8 -2
@@ -5809,15 +5809,21 @@ static int set_file_allocation_info(struct ksmbd_work *work,loff_t alloc_blks;struct inode *inode; +struct kstat stat;int rc;if (!(fp->daccess &FILE_WRITE_DATA_LE ))return -EACCES ; + rc =vfs_getattr (&fp->filp->f_path, &stat,STATX_BASIC_STATS , +AT_STATX_SYNC_AS_STAT ); +if (rc) +return rc; + alloc_blks = (le64_to_cpu (file_alloc_info->AllocationSize) +511 ) >>9 ; inode =file_inode (fp->filp); -if (alloc_blks > inode->i_blocks) { +if (alloc_blks > stat.blocks) {smb_break_all_levII_oplock (work, fp,1 ); rc =vfs_fallocate (fp->filp,FALLOC_FL_KEEP_SIZE ,0 , alloc_blks *512 );
@@ -5825,7 +5831,7 @@ static int set_file_allocation_info(struct ksmbd_work *work,pr_err ("vfs_fallocate is failed : %d\n" , rc);return rc; } - }else if (alloc_blks < inode->i_blocks) { + }else if (alloc_blks < stat.blocks) {loff_t size;/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 153/432 platform/x86/intel/tpmi: Change vsec offset to u64
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <[email protected]>
[ Upstream commit 57221a07ff37ff356f9265acd228bc3c8744c8fc ]
The vsec offset can be 64 bit long depending on the PFS start. So change type to u64. Also use 64 bit formatting for seq_printf.
--- drivers/platform/x86/intel/tpmi.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/platform/x86/intel/tpmi.c +5 -4
@@ -96,7 +96,7 @@ struct intel_tpmi_pfs_entry {*/ struct intel_tpmi_pm_feature {struct intel_tpmi_pfs_entry pfs_header; -unsigned int vsec_offset; +u64 vsec_offset;struct intel_vsec_device *vsec_dev; };
@@ -389,7 +389,7 @@ static int tpmi_pfs_dbg_show(struct seq_file *s, void *unused) read_blocked = feature_state.read_blocked ?'Y' :'N' ; write_blocked = feature_state.write_blocked ?'Y' :'N' ; } - seq_printf(s, "0x%02x\t\t0x%02x\t\t0x%04x\t\t0x%04x\t\t0x%02x\t\t0x%08x\t%c\t%c\t\t%c\t\t%c\n", + seq_printf(s, "0x%02x\t\t0x%02x\t\t0x%04x\t\t0x%04x\t\t0x%02x\t\t0x%016llx\t%c\t%c\t\t%c\t\t%c\n", pfs->pfs_header.tpmi_id, pfs->pfs_header.num_entries, pfs->pfs_header.entry_size, pfs->pfs_header.cap_offset, pfs->pfs_header.attribute, pfs->vsec_offset, locked, disabled,
@@ -408,7 +408,8 @@ static int tpmi_mem_dump_show(struct seq_file *s, void *unused)struct intel_tpmi_pm_feature *pfs = s->private;int count, ret =0 ;void __iomem *mem; -u32 off, size; +u32 size; +u64 off;u8 *buffer; size =TPMI_GET_SINGLE_ENTRY_SIZE (pfs);
@@ -424,7 +425,7 @@ static int tpmi_mem_dump_show(struct seq_file *s, void *unused)mutex_lock (&tpmi_dev_lock);for (count =0 ; count < pfs->pfs_header.num_entries; ++count) { -seq_printf (s,"TPMI Instance:%d offset:0x%x\n" , count, off); +seq_printf (s,"TPMI Instance:%d offset:0x%llx\n" , count, off); mem =ioremap (off, size);if (!mem) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 154/432 io_uring/rw: return IOU_ISSUE_SKIP_COMPLETE for multishot retry
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
[ Upstream commit 0a3737db8479b77f95f4bfda8e71b03c697eb56a ]
If read multishot is being invoked from the poll retry handler, then we should return IOU_ISSUE_SKIP_COMPLETE rather than -EAGAIN. If not, then a CQE will be posted with -EAGAIN rather than triggering the retry when the file is flagged as readable again.
--- io_uring/rw.c | 2 ++ 1 file changed, 2 insertions(+)
io_uring/rw.c +2 -0
@@ -942,6 +942,8 @@ int io_read_mshot(struct io_kiocb *req, unsigned int issue_flags)*/ if (io_kbuf_recycle (req, issue_flags)) rw->len =0 ; +if (issue_flags &IO_URING_F_MULTISHOT ) +return IOU_ISSUE_SKIP_COMPLETE ;return -EAGAIN ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 155/432 io_uring: clean rings on NO_MMAP alloc fail
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
[ Upstream commit cef59d1ea7170ec753182302645a0191c8aa3382 ]
We make a few cancellation judgements based on ctx->rings, so let's zero it afer deallocation for IORING_SETUP_NO_MMAP just like it's done with the mmap case. Likely, it's not a real problem, but zeroing is safer and better tested.
--- io_uring/io_uring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
io_uring/io_uring.c +3 -2
@@ -2757,14 +2757,15 @@ static void io_rings_free(struct io_ring_ctx *ctx)if (!(ctx->flags &IORING_SETUP_NO_MMAP )) {io_mem_free (ctx->rings);io_mem_free (ctx->sq_sqes); - ctx->rings =NULL ; - ctx->sq_sqes =NULL ; }else {io_pages_free (&ctx->ring_pages, ctx->n_ring_pages); ctx->n_ring_pages =0 ;io_pages_free (&ctx->sqe_pages, ctx->n_sqe_pages); ctx->n_sqe_pages =0 ; } + + ctx->rings =NULL ; + ctx->sq_sqes =NULL ; }void *io_mem_alloc (size_t size)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 156/432 ring-buffer: Fix waking up ring buffer readers
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit b3594573681b53316ec0365332681a30463edfd6 ]
A task can wait on a ring buffer for when it fills up to a specific watermark. The writer will check the minimum watermark that waiters are waiting for and if the ring buffer is past that, it will wake up all the waiters.
The waiters are in a wait loop, and will first check if a signal is pending and then check if the ring buffer is at the desired level where it should break out of the loop.
If a file that uses a ring buffer closes, and there's threads waiting on the ring buffer, it needs to wake up those threads. To do this, a "wait_index" was used.
Before entering the wait loop, the waiter will read the wait_index. On wakeup, it will check if the wait_index is different than when it entered the loop, and will exit the loop if it is. The waker will only need to update the wait_index before waking up the waiters.
This had a couple of bugs. One trivial one and one broken by design.
The trivial bug was that the waiter checked the wait_index after the schedule() call. It had to be checked between the prepare_to_wait() and the schedule() which it was not.
The main bug is that the first check to set the default wait_index will always be outside the prepare_to_wait() and the schedule(). That's because the ring_buffer_wait() doesn't have enough context to know if it should break out of the loop.
The loop itself is not needed, because all the callers to the ring_buffer_wait() also has their own loop, as the callers have a better sense of what the context is to decide whether to break out of the loop or not.
Just have the ring_buffer_wait() block once, and if it gets woken up, exit the function and let the callers decide what to do next.
Stable-dep-of: 761d9473e27f ("ring-buffer: Do not set shortest_full when full target is hit")
--- kernel/trace/ring_buffer.c | 139 ++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 71 deletions(-)
kernel/trace/ring_buffer.c +68 -71
@@ -412,7 +412,6 @@ struct rb_irq_work {struct irq_work work;wait_queue_head_t waiters;wait_queue_head_t full_waiters; -long wait_index;bool waiters_pending;bool full_waiters_pending;bool wakeup_full;
@@ -945,14 +944,40 @@ void ring_buffer_wake_waiters(struct trace_buffer *buffer, int cpu) rbwork = &cpu_buffer->irq_work; } - rbwork->wait_index++; -/* make sure the waiters see the new index */ -smp_wmb (); -/* This can be called in any context */ irq_work_queue (&rbwork->work); } +static bool rb_watermark_hit (struct trace_buffer *buffer,int cpu,int full) +{ +struct ring_buffer_per_cpu *cpu_buffer; +bool ret = false; + +/* Reads of all CPUs always waits for any data */ +if (cpu ==RING_BUFFER_ALL_CPUS ) +return !ring_buffer_empty (buffer); + + cpu_buffer = buffer->buffers[cpu]; + +if (!ring_buffer_empty_cpu (buffer, cpu)) { +unsigned long flags; +bool pagebusy; + +if (!full) +return true; + +raw_spin_lock_irqsave (&cpu_buffer->reader_lock, flags); + pagebusy = cpu_buffer->reader_page == cpu_buffer->commit_page; + ret = !pagebusy &&full_hit (buffer, cpu, full); + +if (!cpu_buffer->shortest_full || + cpu_buffer->shortest_full > full) + cpu_buffer->shortest_full = full; +raw_spin_unlock_irqrestore (&cpu_buffer->reader_lock, flags); + } +return ret; +} +/** * ring_buffer_wait - wait for input to the ring buffer * @buffer: buffer to wait on
@@ -968,7 +993,6 @@ int ring_buffer_wait(struct trace_buffer *buffer, int cpu, int full)struct ring_buffer_per_cpu *cpu_buffer;DEFINE_WAIT (wait);struct rb_irq_work *work; -long wait_index;int ret =0 ;/*
@@ -987,81 +1011,54 @@ int ring_buffer_wait(struct trace_buffer *buffer, int cpu, int full) work = &cpu_buffer->irq_work; } - wait_index =READ_ONCE (work->wait_index); - -while (true) { -if (full) -prepare_to_wait (&work->full_waiters, &wait,TASK_INTERRUPTIBLE ); -else -prepare_to_wait (&work->waiters, &wait,TASK_INTERRUPTIBLE ); - -/* -* The events can happen in critical sections where -* checking a work queue can cause deadlocks. -* After adding a task to the queue, this flag is set -* only to notify events to try to wake up the queue -* using irq_work. -* -* We don't clear it even if the buffer is no longer -* empty. The flag only causes the next event to run -* irq_work to do the work queue wake up. The worse -* that can happen if we race with !trace_empty() is that -* an event will cause an irq_work to try to wake up -* an empty queue. -* -* There's no reason to protect this flag either, as -* the work queue and irq_work logic will do the necessary -* synchronization for the wake ups. The only thing -* that is necessary is that the wake up happens after -* a task has been queued. It's OK for spurious wake ups. -*/ -if (full) - work->full_waiters_pending = true; -else - work->waiters_pending = true; - -if (signal_pending (current)) { - ret = -EINTR ; -break ; - } - -if (cpu ==RING_BUFFER_ALL_CPUS && !ring_buffer_empty (buffer)) -break ; - -if (cpu !=RING_BUFFER_ALL_CPUS && - !ring_buffer_empty_cpu (buffer, cpu)) { -unsigned long flags; -bool pagebusy; -bool done; - -if (!full) -break ; - -raw_spin_lock_irqsave (&cpu_buffer->reader_lock, flags); - pagebusy = cpu_buffer->reader_page == cpu_buffer->commit_page; - done = !pagebusy &&full_hit (buffer, cpu, full); +if (full) +prepare_to_wait (&work->full_waiters, &wait,TASK_INTERRUPTIBLE ); +else +prepare_to_wait (&work->waiters, &wait,TASK_INTERRUPTIBLE ); -if (!cpu_buffer->shortest_full || - cpu_buffer->shortest_full > full) - cpu_buffer->shortest_full = full; -raw_spin_unlock_irqrestore (&cpu_buffer->reader_lock, flags); -if (done) -break ; - } +/* +* The events can happen in critical sections where +* checking a work queue can cause deadlocks. +* After adding a task to the queue, this flag is set +* only to notify events to try to wake up the queue +* using irq_work. +* +* We don't clear it even if the buffer is no longer +* empty. The flag only causes the next event to run +* irq_work to do the work queue wake up. The worse +* that can happen if we race with !trace_empty() is that +* an event will cause an irq_work to try to wake up +* an empty queue. +* +* There's no reason to protect this flag either, as +* the work queue and irq_work logic will do the necessary +* synchronization for the wake ups. The only thing +* that is necessary is that the wake up happens after +* a task has been queued. It's OK for spurious wake ups. +*/ +if (full) + work->full_waiters_pending = true; +else + work->waiters_pending = true; -schedule (); +if (rb_watermark_hit (buffer, cpu, full)) + goto out; -/* Make sure to see the new wait index */ -smp_rmb (); -if (wait_index != work->wait_index) -break ; +if (signal_pending (current)) { + ret = -EINTR ; + goto out; } +schedule (); + out:if (full)finish_wait (&work->full_waiters, &wait);else finish_wait (&work->waiters, &wait); +if (!ret && !rb_watermark_hit (buffer, cpu, full) &&signal_pending (current)) + ret = -EINTR ; +return ret; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 157/432 ring-buffer: Do not set shortest_full when full target is hit
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit 761d9473e27f0c8782895013a3e7b52a37c8bcfc ]
The rb_watermark_hit() checks if the amount of data in the ring buffer is above the percentage level passed in by the "full" variable. If it is, it returns true.
But it also sets the "shortest_full" field of the cpu_buffer that informs writers that it needs to call the irq_work if the amount of data on the ring buffer is above the requested amount.
The rb_watermark_hit() always sets the shortest_full even if the amount in the ring buffer is what it wants. As it is not going to wait, because it has what it wants, there's no reason to set shortest_full.
--- kernel/trace/ring_buffer.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/trace/ring_buffer.c +4 -3
@@ -970,9 +970,10 @@ static bool rb_watermark_hit(struct trace_buffer *buffer, int cpu, int full) pagebusy = cpu_buffer->reader_page == cpu_buffer->commit_page; ret = !pagebusy &&full_hit (buffer, cpu, full); -if (!cpu_buffer->shortest_full || - cpu_buffer->shortest_full > full) - cpu_buffer->shortest_full = full; +if (!ret && (!cpu_buffer->shortest_full || + cpu_buffer->shortest_full > full)) { + cpu_buffer->shortest_full = full; + }raw_spin_unlock_irqrestore (&cpu_buffer->reader_lock, flags); }return ret;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 158/432 ring-buffer: Fix resetting of shortest_full
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit 68282dd930ea38b068ce2c109d12405f40df3f93 ]
The "shortest_full" variable is used to keep track of the waiter that is waiting for the smallest amount on the ring buffer before being woken up. When a tasks waits on the ring buffer, it passes in a "full" value that is a percentage. 0 means wake up on any data. 1-100 means wake up from 1% to 100% full buffer.
As all waiters are on the same wait queue, the wake up happens for the waiter with the smallest percentage.
The problem is that the smallest_full on the cpu_buffer that stores the smallest amount doesn't get reset when all the waiters are woken up. It does get reset when the ring buffer is reset (echo > /sys/kernel/tracing/trace).
This means that tasks may be woken up more often then when they want to be. Instead, have the shortest_full field get reset just before waking up all the tasks. If the tasks wait again, they will update the shortest_full before sleeping.
Also add locking around setting of shortest_full in the poll logic, and change "work" to "rbwork" to match the variable name for rb_irq_work structures that are used in other places.
Stable-dep-of: 8145f1c35fa6 ("ring-buffer: Fix full_waiters_pending in poll")
--- kernel/trace/ring_buffer.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-)
kernel/trace/ring_buffer.c +23 -7
@@ -902,8 +902,19 @@ static void rb_wake_up_waiters(struct irq_work *work)wake_up_all (&rbwork->waiters);if (rbwork->full_waiters_pending || rbwork->wakeup_full) { +/* Only cpu_buffer sets the above flags */ +struct ring_buffer_per_cpu *cpu_buffer = + container_of(rbwork, struct ring_buffer_per_cpu, irq_work); + +/* Called from interrupt context */ +raw_spin_lock (&cpu_buffer->reader_lock); rbwork->wakeup_full = false; rbwork->full_waiters_pending = false; + +/* Waking up all waiters, they will reset the shortest full */ + cpu_buffer->shortest_full =0 ; +raw_spin_unlock (&cpu_buffer->reader_lock); +wake_up_all (&rbwork->full_waiters); } }
@@ -1082,28 +1093,33 @@ __poll_t ring_buffer_poll_wait(struct trace_buffer *buffer, int cpu, struct file *filp, poll_table *poll_table, int full) { struct ring_buffer_per_cpu *cpu_buffer; -struct rb_irq_work *work; +struct rb_irq_work *rbwork;if (cpu ==RING_BUFFER_ALL_CPUS ) { - work = &buffer->irq_work; + rbwork = &buffer->irq_work; full =0 ; }else {if (!cpumask_test_cpu (cpu, buffer->cpumask))return EPOLLERR ; cpu_buffer = buffer->buffers[cpu]; - work = &cpu_buffer->irq_work; + rbwork = &cpu_buffer->irq_work; }if (full) { -poll_wait (filp, &work->full_waiters, poll_table); - work->full_waiters_pending = true; +unsigned long flags; + +poll_wait (filp, &rbwork->full_waiters, poll_table); + +raw_spin_lock_irqsave (&cpu_buffer->reader_lock, flags); + rbwork->full_waiters_pending = true;if (!cpu_buffer->shortest_full || cpu_buffer->shortest_full > full) cpu_buffer->shortest_full = full; +raw_spin_unlock_irqrestore (&cpu_buffer->reader_lock, flags); }else { -poll_wait (filp, &work->waiters, poll_table); - work->waiters_pending = true; +poll_wait (filp, &rbwork->waiters, poll_table); + rbwork->waiters_pending = true; }/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 159/432 ring-buffer: Fix full_waiters_pending in poll
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit 8145f1c35fa648da662078efab299c4467b85ad5 ]
If a reader of the ring buffer is doing a poll, and waiting for the ring buffer to hit a specific watermark, there could be a case where it gets into an infinite ping-pong loop.
The poll code has:
rbwork->full_waiters_pending = true;
if (!cpu_buffer->shortest_full ||
cpu_buffer->shortest_full > full)
cpu_buffer->shortest_full = full;The writer will see full_waiters_pending and check if the ring buffer is filled over the percentage of the shortest_full value. If it is, it calls an irq_work to wake up all the waiters.
But the code could get into a circular loop:
CPU 0 CPU 1
----- -----
[ Poll ]
[ shortest_full = 0 ]
rbwork->full_waiters_pending = true;
if (rbwork->full_waiters_pending &&
[ buffer percent ] > shortest_full) {
rbwork->wakeup_full = true;
[ queue_irqwork ]cpu_buffer->shortest_full = full;
[ IRQ work ]
if (rbwork->wakeup_full) {
cpu_buffer->shortest_full = 0;
wakeup poll waiters;
[woken]
if ([ buffer percent ] > full)
break;
rbwork->full_waiters_pending = true;
if (rbwork->full_waiters_pending &&
[ buffer percent ] > shortest_full) {
rbwork->wakeup_full = true;
[ queue_irqwork ]cpu_buffer->shortest_full = full;
[ IRQ work ]
if (rbwork->wakeup_full) {
cpu_buffer->shortest_full = 0;
wakeup poll waiters;[woken]
[ Wash, rinse, repeat! ]
In the poll, the shortest_full needs to be set before the full_pending_waiters, as once that is set, the writer will compare the current shortest_full (which is incorrect) to decide to call the irq_work, which will reset the shortest_full (expecting the readers to update it).
Also move the setting of full_waiters_pending after the check if the ring buffer has the required percentage filled. There's no reason to tell the writer to wake up waiters if there are no waiters.
--- kernel/trace/ring_buffer.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
kernel/trace/ring_buffer.c +20 -7
@@ -1112,16 +1112,32 @@ __poll_t ring_buffer_poll_wait(struct trace_buffer *buffer, int cpu,poll_wait (filp, &rbwork->full_waiters, poll_table);raw_spin_lock_irqsave (&cpu_buffer->reader_lock, flags); - rbwork->full_waiters_pending = true;if (!cpu_buffer->shortest_full || cpu_buffer->shortest_full > full) cpu_buffer->shortest_full = full;raw_spin_unlock_irqrestore (&cpu_buffer->reader_lock, flags); - }else { -poll_wait (filp, &rbwork->waiters, poll_table); - rbwork->waiters_pending = true; +if (full_hit (buffer, cpu, full)) +return EPOLLIN |EPOLLRDNORM ; +/* +* Only allow full_waiters_pending update to be seen after +* the shortest_full is set. If the writer sees the +* full_waiters_pending flag set, it will compare the +* amount in the ring buffer to shortest_full. If the amount +* in the ring buffer is greater than the shortest_full +* percent, it will call the irq_work handler to wake up +* this list. The irq_handler will reset shortest_full +* back to zero. That's done under the reader_lock, but +* the below smp_mb() makes sure that the update to +* full_waiters_pending doesn't leak up into the above. +*/ +smp_mb (); + rbwork->full_waiters_pending = true; +return 0 ; } +poll_wait (filp, &rbwork->waiters, poll_table); + rbwork->waiters_pending = true; +/* * There's a tight race between setting the waiters_pending and * checking if the ring buffer is empty. Once the waiters_pending bit
@@ -1137,9 +1153,6 @@ __poll_t ring_buffer_poll_wait(struct trace_buffer *buffer, int cpu,*/ smp_mb (); -if (full) -return full_hit (buffer, cpu, full) ?EPOLLIN |EPOLLRDNORM :0 ; -if ((cpu ==RING_BUFFER_ALL_CPUS && !ring_buffer_empty (buffer)) || (cpu !=RING_BUFFER_ALL_CPUS && !ring_buffer_empty_cpu (buffer, cpu)))return EPOLLIN |EPOLLRDNORM ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 160/432 ring-buffer: Use wait_event_interruptible() in ring_buffer_wait()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit 7af9ded0c2caac0a95f33df5cb04706b0f502588 ]
Convert ring_buffer_wait() over to wait_event_interruptible(). The default condition is to execute the wait loop inside __wait_event() just once.
This does not change the ring_buffer_wait() prototype yet, but restructures the code so that it can take a "cond" and "data" parameter and will call wait_event_interruptible() with a helper function as the condition.
The helper function (rb_wait_cond) takes the cond function and data parameters. It will first check if the buffer hit the watermark defined by the "full" parameter and then call the passed in condition parameter. If either are true, it returns true.
If rb_wait_cond() does not return true, it will set the appropriate "waiters_pending" flag and returns false.
--- include/linux/ring_buffer.h | 1 + kernel/trace/ring_buffer.c | 116 +++++++++++++++++++++--------------- 2 files changed, 69 insertions(+), 48 deletions(-)
include/linux/ring_buffer.h +1 -0
@@ -98,6 +98,7 @@ __ring_buffer_alloc(unsigned long size, unsigned flags, struct lock_class_key *k__ring_buffer_alloc ((size), (flags), &__key); \ }) +typedef bool (*ring_buffer_cond_fn )(void *data);int ring_buffer_wait (struct trace_buffer *buffer,int cpu,int full);__poll_t ring_buffer_poll_wait (struct trace_buffer *buffer,int cpu,struct file *filp,poll_table *poll_table,int full);
kernel/trace/ring_buffer.c +68 -48
138 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 161/432 dlm: fix user space lkb refcounting
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Aring <[email protected]>
[ Upstream commit 2ab3d705ca5d4f7ea345a21c3da41a447a549649 ]
This patch fixes to check on the right return value if it was the last callback. The rv variable got overwritten by the return of copy_result_to_user(). Fixing it by introducing a second variable for the return value and don't let rv being overwritten.
--- fs/dlm/user.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/dlm/user.c +5 -5
@@ -806,7 +806,7 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,struct dlm_lkb *lkb;DECLARE_WAITQUEUE (wait, current);struct dlm_callback *cb; -int rv, copy_lvb =0 ; +int rv, ret, copy_lvb =0 ;int old_mode, new_mode;if (count ==sizeof (struct dlm_device_version )) {
@@ -906,9 +906,9 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,trace_dlm_ast (lkb->lkb_resource->res_ls, lkb); } - rv =copy_result_to_user (lkb->lkb_ua, -test_bit (DLM_PROC_FLAGS_COMPAT , &proc->flags), - cb->flags, cb->mode, copy_lvb, buf, count); + ret =copy_result_to_user (lkb->lkb_ua, +test_bit (DLM_PROC_FLAGS_COMPAT , &proc->flags), + cb->flags, cb->mode, copy_lvb, buf, count);kref_put (&cb->ref, dlm_release_callback);
@@ -916,7 +916,7 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,if (rv ==DLM_DEQUEUE_CALLBACK_LAST )dlm_put_lkb (lkb); -return rv; +return ret; }static __poll_t device_poll (struct file *file,poll_table *wait)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 162/432 soc: fsl: qbman: Always disable interrupts when taking cgr_lock
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Anderson <[email protected]>
[ Upstream commit 584c2a9184a33a40fceee838f856de3cffa19be3 ]
smp_call_function_single disables IRQs when executing the callback. To prevent deadlocks, we must disable IRQs when taking cgr_lock elsewhere. This is already done by qman_update_cgr and qman_delete_cgr; fix the other lockers.
--- drivers/soc/fsl/qbman/qman.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/soc/fsl/qbman/qman.c +5 -5
@@ -1456,11 +1456,11 @@ static void qm_congestion_task(struct work_struct *work)union qm_mc_result *mcr;struct qman_cgr *cgr; -spin_lock (&p->cgr_lock); +spin_lock_irq (&p->cgr_lock);qm_mc_start (&p->p);qm_mc_commit (&p->p,QM_MCC_VERB_QUERYCONGESTION );if (!qm_mc_result_timeout (&p->p, &mcr)) { -spin_unlock (&p->cgr_lock); +spin_unlock_irq (&p->cgr_lock);dev_crit (p->config->dev,"QUERYCONGESTION timeout\n" );qman_p_irqsource_add (p,QM_PIRQ_CSCI );return ;
@@ -1476,7 +1476,7 @@ static void qm_congestion_task(struct work_struct *work)list_for_each_entry (cgr, &p->cgr_cbs, node)if (cgr->cb &&qman_cgrs_get (&c, cgr->cgrid)) cgr->cb (p, cgr,qman_cgrs_get (&rr, cgr->cgrid)); -spin_unlock (&p->cgr_lock); +spin_unlock_irq (&p->cgr_lock);qman_p_irqsource_add (p,QM_PIRQ_CSCI ); }
@@ -2440,7 +2440,7 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags,preempt_enable (); cgr->chan = p->config->channel; -spin_lock (&p->cgr_lock); +spin_lock_irq (&p->cgr_lock);if (opts) {struct qm_mcc_initcgr local_opts = *opts;
@@ -2477,7 +2477,7 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags, qman_cgrs_get(&p->cgrs[1], cgr->cgrid)) cgr->cb(p, cgr, 1); out: -spin_unlock (&p->cgr_lock); +spin_unlock_irq (&p->cgr_lock);put_affine_portal ();return ret; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 163/432 soc: fsl: qbman: Use raw spinlock for cgr_lock
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Anderson <[email protected]>
[ Upstream commit fbec4e7fed89b579f2483041fabf9650fb0dd6bc ]
smp_call_function always runs its callback in hard IRQ context, even on PREEMPT_RT, where spinlocks can sleep. So we need to use a raw spinlock for cgr_lock to ensure we aren't waiting on a sleeping task.
Although this bug has existed for a while, it was not apparent until commit ef2a8d5478b9 ("net: dpaa: Adjust queue depth on rate change") which invokes smp_call_function_single via qman_update_cgr_safe every time a link goes up or down.
--- drivers/soc/fsl/qbman/qman.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
drivers/soc/fsl/qbman/qman.c +14 -11
@@ -991,7 +991,7 @@ struct qman_portal {/* linked-list of CSCN handlers. */ struct list_head cgr_cbs;/* list lock */ -spinlock_t cgr_lock; +raw_spinlock_t cgr_lock;struct work_struct congestion_work;struct work_struct mr_work;char irqname[MAX_IRQNAME ];
@@ -1281,7 +1281,7 @@ static int qman_create_portal(struct qman_portal *portal,/* if the given mask is NULL, assume all CGRs can be seen */ qman_cgrs_fill (&portal->cgrs[0 ]);INIT_LIST_HEAD (&portal->cgr_cbs); -spin_lock_init (&portal->cgr_lock); +raw_spin_lock_init (&portal->cgr_lock);INIT_WORK (&portal->congestion_work, qm_congestion_task);INIT_WORK (&portal->mr_work, qm_mr_process_task); portal->bits =0 ;
@@ -1456,11 +1456,14 @@ static void qm_congestion_task(struct work_struct *work)union qm_mc_result *mcr;struct qman_cgr *cgr; -spin_lock_irq (&p->cgr_lock); +/* +* FIXME: QM_MCR_TIMEOUT is 10ms, which is too long for a raw spinlock! +*/ +raw_spin_lock_irq (&p->cgr_lock);qm_mc_start (&p->p);qm_mc_commit (&p->p,QM_MCC_VERB_QUERYCONGESTION );if (!qm_mc_result_timeout (&p->p, &mcr)) { -spin_unlock_irq (&p->cgr_lock); +raw_spin_unlock_irq (&p->cgr_lock);dev_crit (p->config->dev,"QUERYCONGESTION timeout\n" );qman_p_irqsource_add (p,QM_PIRQ_CSCI );return ;
@@ -1476,7 +1479,7 @@ static void qm_congestion_task(struct work_struct *work)list_for_each_entry (cgr, &p->cgr_cbs, node)if (cgr->cb &&qman_cgrs_get (&c, cgr->cgrid)) cgr->cb (p, cgr,qman_cgrs_get (&rr, cgr->cgrid)); -spin_unlock_irq (&p->cgr_lock); +raw_spin_unlock_irq (&p->cgr_lock);qman_p_irqsource_add (p,QM_PIRQ_CSCI ); }
@@ -2440,7 +2443,7 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags,preempt_enable (); cgr->chan = p->config->channel; -spin_lock_irq (&p->cgr_lock); +raw_spin_lock_irq (&p->cgr_lock);if (opts) {struct qm_mcc_initcgr local_opts = *opts;
@@ -2477,7 +2480,7 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags, qman_cgrs_get(&p->cgrs[1], cgr->cgrid)) cgr->cb(p, cgr, 1); out: -spin_unlock_irq (&p->cgr_lock); +raw_spin_unlock_irq (&p->cgr_lock);put_affine_portal ();return ret; }
@@ -2512,7 +2515,7 @@ int qman_delete_cgr(struct qman_cgr *cgr)return -EINVAL ;memset (&local_opts,0 ,sizeof (struct qm_mcc_initcgr )); -spin_lock_irqsave (&p->cgr_lock, irqflags); +raw_spin_lock_irqsave (&p->cgr_lock, irqflags);list_del (&cgr->node);/* * If there are no other CGR objects for this CGRID in the list,
@@ -2537,7 +2540,7 @@ int qman_delete_cgr(struct qman_cgr *cgr)/* add back to the list */ list_add (&cgr->node, &p->cgr_cbs); release_lock: -spin_unlock_irqrestore (&p->cgr_lock, irqflags); +raw_spin_unlock_irqrestore (&p->cgr_lock, irqflags);put_affine_portal ();return ret; }
@@ -2577,9 +2580,9 @@ static int qman_update_cgr(struct qman_cgr *cgr, struct qm_mcc_initcgr *opts)if (!p)return -EINVAL ; -spin_lock_irqsave (&p->cgr_lock, irqflags); +raw_spin_lock_irqsave (&p->cgr_lock, irqflags); ret =qm_modify_cgr (cgr,0 , opts); -spin_unlock_irqrestore (&p->cgr_lock, irqflags); +raw_spin_unlock_irqrestore (&p->cgr_lock, irqflags);put_affine_portal ();return ret; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 164/432 s390/zcrypt: fix reference counting on zcrypt card objects
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harald Freudenberger <[email protected]>
[ Upstream commit 50ed48c80fecbe17218afed4f8bed005c802976c ]
Tests with hot-plugging crytpo cards on KVM guests with debug kernel build revealed an use after free for the load field of the struct zcrypt_card. The reason was an incorrect reference handling of the zcrypt card object which could lead to a free of the zcrypt card object while it was still in use.
This is an example of the slab message:
kernel: 0x00000000885a7512-0x00000000885a7513 @offset=1298. First byte 0x68 instead of 0x6b
kernel: Allocated in zcrypt_card_alloc+0x36/0x70 [zcrypt] age=18046 cpu=3 pid=43
kernel: kmalloc_trace+0x3f2/0x470
kernel: zcrypt_card_alloc+0x36/0x70 [zcrypt]
kernel: zcrypt_cex4_card_probe+0x26/0x380 [zcrypt_cex4]
kernel: ap_device_probe+0x15c/0x290
kernel: really_probe+0xd2/0x468
kernel: driver_probe_device+0x40/0xf0
kernel: __device_attach_driver+0xc0/0x140
kernel: bus_for_each_drv+0x8c/0xd0
kernel: __device_attach+0x114/0x198
kernel: bus_probe_device+0xb4/0xc8
kernel: device_add+0x4d2/0x6e0
kernel: ap_scan_adapter+0x3d0/0x7c0
kernel: ap_scan_bus+0x5a/0x3b0
kernel: ap_scan_bus_wq_callback+0x40/0x60
kernel: process_one_work+0x26e/0x620
kernel: worker_thread+0x21c/0x440
kernel: Freed in zcrypt_card_put+0x54/0x80 [zcrypt] age=9024 cpu=3 pid=43
kernel: kfree+0x37e/0x418
kernel: zcrypt_card_put+0x54/0x80 [zcrypt]
kernel: ap_device_remove+0x4c/0xe0
kernel: device_release_driver_internal+0x1c4/0x270
kernel: bus_remove_device+0x100/0x188
kernel: device_del+0x164/0x3c0
kernel: device_unregister+0x30/0x90
kernel: ap_scan_adapter+0xc8/0x7c0
kernel: ap_scan_bus+0x5a/0x3b0
kernel: ap_scan_bus_wq_callback+0x40/0x60
kernel: process_one_work+0x26e/0x620
kernel: worker_thread+0x21c/0x440
kernel: kthread+0x150/0x168
kernel: __ret_from_fork+0x3c/0x58
kernel: ret_from_fork+0xa/0x30
kernel: Slab 0x00000372022169c0 objects=20 used=18 fp=0x00000000885a7c88 flags=0x3ffff00000000a00(workingset|slab|node=0|zone=1|lastcpupid=0x1ffff)
kernel: Object 0x00000000885a74b8 @offset=1208 fp=0x00000000885a7c88
kernel: Redzone 00000000885a74b0: bb bb bb bb bb bb bb bb ........
kernel: Object 00000000885a74b8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk
kernel: Object 00000000885a74c8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk
kernel: Object 00000000885a74d8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk
kernel: Object 00000000885a74e8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk
kernel: Object 00000000885a74f8: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b kkkkkkkkkkkkkkkk
kernel: Object 00000000885a7508: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 68 4b 6b 6b 6b a5 kkkkkkkkkkhKkkk.
kernel: Redzone 00000000885a7518: bb bb bb bb bb bb bb bb ........
kernel: Padding 00000000885a756c: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZZZZZ
kernel: CPU: 0 PID: 387 Comm: systemd-udevd Not tainted 6.8.0-HF #2
kernel: Hardware name: IBM 3931 A01 704 (KVM/Linux)
kernel: Call Trace:
kernel: [<00000000ca5ab5b8>] dump_stack_lvl+0x90/0x120
kernel: [<00000000c99d78bc>] check_bytes_and_report+0x114/0x140
kernel: [<00000000c99d53cc>] check_object+0x334/0x3f8
kernel: [<00000000c99d820c>] alloc_debug_processing+0xc4/0x1f8
kernel: [<00000000c99d852e>] get_partial_node.part.0+0x1ee/0x3e0
kernel: [<00000000c99d94ec>] ___slab_alloc+0xaf4/0x13c8
kernel: [<00000000c99d9e38>] __slab_alloc.constprop.0+0x78/0xb8
kernel: [<00000000c99dc8dc>] __kmalloc+0x434/0x590
kernel: [<00000000c9b4c0ce>] ext4_htree_store_dirent+0x4e/0x1c0
kernel: [<00000000c9b908a2>] htree_dirblock_to_tree+0x17a/0x3f0
kernel: [<00000000c9b919dc>] ext4_htree_fill_tree+0x134/0x400
kernel: [<00000000c9b4b3d0>] ext4_dx_readdir+0x160/0x2f0
kernel: [<00000000c9b4bedc>] ext4_readdir+0x5f4/0x760
kernel: [<00000000c9a7efc4>] iterate_dir+0xb4/0x280
kernel: [<00000000c9a7f1ea>] __do_sys_getdents64+0x5a/0x120
kernel: [<00000000ca5d6946>] __do_syscall+0x256/0x310
kernel: [<00000000ca5eea10>] system_call+0x70/0x98
kernel: INFO: lockdep is turned off.
kernel: FIX kmalloc-96: Restoring Poison 0x00000000885a7512-0x00000000885a7513=0x6b
kernel: FIX kmalloc-96: Marking all objects usedThe fix is simple: Before use of the queue not only the queue object but also the card object needs to increase it's reference count with a call to zcrypt_card_get(). Similar after use of the queue not only the queue but also the card object's reference count is decreased with zcrypt_card_put().
--- drivers/s390/crypto/zcrypt_api.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/s390/crypto/zcrypt_api.c +2 -0
@@ -579,6 +579,7 @@ static inline struct zcrypt_queue *zcrypt_pick_queue(struct zcrypt_card *zc, {if (!zq || !try_module_get (zq->queue->ap_dev.device.driver->owner))return NULL ; +zcrypt_card_get (zc);zcrypt_queue_get (zq);get_device (&zq->queue->ap_dev.device);atomic_add (weight, &zc->load);
@@ -598,6 +599,7 @@ static inline void zcrypt_drop_queue(struct zcrypt_card *zc,atomic_sub (weight, &zq->load);put_device (&zq->queue->ap_dev.device);zcrypt_queue_put (zq); +zcrypt_card_put (zc);module_put (mod); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 165/432 drm/probe-helper: warn about negative .get_modes()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
[ Upstream commit 7af03e688792293ba33149fb8df619a8dff90e80 ]
The .get_modes() callback is supposed to return the number of modes, never a negative error code. If a negative value is returned, it'll just be interpreted as a negative count, and added to previous calculations.
Document the rules, but handle the negative values gracefully with an error message.
--- drivers/gpu/drm/drm_probe_helper.c | 7 +++++++ include/drm/drm_modeset_helper_vtables.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_probe_helper.c +7 -0
@@ -419,6 +419,13 @@ static int drm_helper_probe_get_modes(struct drm_connector *connector) count = connector_funcs->get_modes (connector); +/* The .get_modes() callback should not return negative values. */ +if (count <0 ) { +drm_err (connector->dev,".get_modes() returned %pe\n" , +ERR_PTR (count)); + count =0 ; + } +/* * Fallback for when DDC probe failed in drm_get_edid() and thus skipped * override/firmware EDID.
include/drm/drm_modeset_helper_vtables.h +2 -1
@@ -898,7 +898,8 @@ struct drm_connector_helper_funcs {* * RETURNS: * -* The number of modes added by calling drm_mode_probed_add(). +* The number of modes added by calling drm_mode_probed_add(). Return 0 +* on failures (no modes) instead of negative error codes. */ int (*get_modes)(struct drm_connector *connector);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 166/432 drm/panel: do not return negative error codes from drm_panel_get_modes()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
[ Upstream commit fc4e97726530241d96dd7db72eb65979217422c9 ]
None of the callers of drm_panel_get_modes() expect it to return negative error codes. Either they propagate the return value in their struct drm_connector_helper_funcs .get_modes() hook (which is also not supposed to return negative codes), or add it to other counts leading to bogus values.
On the other hand, many of the struct drm_panel_funcs .get_modes() hooks do return negative error codes, so handle them gracefully instead of propagating further.
Return 0 for no modes, whatever the reason.
--- drivers/gpu/drm/drm_panel.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_panel.c +11 -6
@@ -274,19 +274,24 @@ EXPORT_SYMBOL(drm_panel_disable);* The modes probed from the panel are automatically added to the connector * that the panel is attached to. * -* Return: The number of modes available from the panel on success or a -* negative error code on failure. +* Return: The number of modes available from the panel on success, or 0 on +* failure (no modes). */ int drm_panel_get_modes (struct drm_panel *panel,struct drm_connector *connector) {if (!panel) -return -EINVAL ; +return 0 ; -if (panel->funcs && panel->funcs->get_modes) -return panel->funcs->get_modes (panel, connector); +if (panel->funcs && panel->funcs->get_modes) { +int num; -return -EOPNOTSUPP ; + num = panel->funcs->get_modes (panel, connector); +if (num >0 ) +return num; + } + +return 0 ; }EXPORT_SYMBOL (drm_panel_get_modes);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 167/432 drm/exynos: do not return negative values from .get_modes()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
[ Upstream commit 13d5b040363c7ec0ac29c2de9cf661a24a8aa531 ]
The .get_modes() hooks aren't supposed to return negative error codes. Return 0 for no modes, whatever the reason.
--- drivers/gpu/drm/exynos/exynos_drm_vidi.c | 4 ++-- drivers/gpu/drm/exynos/exynos_hdmi.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_vidi.c +2 -2
@@ -316,14 +316,14 @@ static int vidi_get_modes(struct drm_connector *connector)*/ if (!ctx->raw_edid) {DRM_DEV_DEBUG_KMS (ctx->dev,"raw_edid is null.\n" ); -return -EFAULT ; +return 0 ; } edid_len = (1 + ctx->raw_edid->extensions) *EDID_LENGTH ; edid =kmemdup (ctx->raw_edid, edid_len,GFP_KERNEL );if (!edid) {DRM_DEV_DEBUG_KMS (ctx->dev,"failed to allocate edid\n" ); -return -ENOMEM ; +return 0 ; }drm_connector_update_edid_property (connector, edid);
drivers/gpu/drm/exynos/exynos_hdmi.c +2 -2
@@ -887,11 +887,11 @@ static int hdmi_get_modes(struct drm_connector *connector)int ret;if (!hdata->ddc_adpt) -return -ENODEV ; +return 0 ; edid =drm_get_edid (connector, hdata->ddc_adpt);if (!edid) -return -ENODEV ; +return 0 ; hdata->dvi_mode = !connector->display_info.is_hdmi; DRM_DEV_DEBUG_KMS(hdata->dev, "%s : width[%d] x height[%d]\n",
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 168/432 drm/imx/ipuv3: do not return negative values from .get_modes()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
[ Upstream commit c2da9ada64962fcd2e6395ed9987b9874ea032d3 ]
The .get_modes() hooks aren't supposed to return negative error codes. Return 0 for no modes, whatever the reason.
--- drivers/gpu/drm/imx/ipuv3/parallel-display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/imx/ipuv3/parallel-display.c +2 -2
@@ -72,14 +72,14 @@ static int imx_pd_connector_get_modes(struct drm_connector *connector)int ret;if (!mode) -return -EINVAL ; +return 0 ; ret =of_get_drm_display_mode (np, &imxpd->mode, &imxpd->bus_flags,OF_USE_NATIVE_MODE );if (ret) {drm_mode_destroy (connector->dev, mode); -return ret; +return 0 ; }drm_mode_copy (mode, &imxpd->mode);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 169/432 drm/vc4: hdmi: do not return negative values from .get_modes()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
[ Upstream commit abf493988e380f25242c1023275c68bd3579c9ce ]
The .get_modes() hooks aren't supposed to return negative error codes. Return 0 for no modes, whatever the reason.
--- drivers/gpu/drm/vc4/vc4_hdmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_hdmi.c +1 -1
@@ -508,7 +508,7 @@ static int vc4_hdmi_connector_get_modes(struct drm_connector *connector) edid =drm_get_edid (connector, vc4_hdmi->ddc);cec_s_phys_addr_from_edid (vc4_hdmi->cec_adap, edid);if (!edid) -return -ENODEV ; +return 0 ;drm_connector_update_edid_property (connector, edid); ret =drm_add_edid_modes (connector, edid);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 170/432 clocksource/drivers/timer-riscv: Clear timer interrupt on timer initialization
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ley Foon Tan <[email protected]>
[ Upstream commit 8248ca30ef89f9cc74ace62ae1b9a22b5f16736c ]
In the RISC-V specification, the stimecmp register doesn't have a default value. To prevent the timer interrupt from being triggered during timer initialization, clear the timer interrupt by writing stimecmp with a maximum value.
--- drivers/clocksource/timer-riscv.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/clocksource/timer-riscv.c +3 -0
@@ -101,6 +101,9 @@ static int riscv_timer_starting_cpu(unsigned int cpu) {struct clock_event_device *ce =per_cpu_ptr (&riscv_clock_event, cpu); +/* Clear timer interrupt */ +riscv_clock_event_stop (); + ce->cpumask =cpumask_of (cpu); ce->irq = riscv_clock_event_irq;if (riscv_timer_cannot_wake_cpu)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 171/432 memtest: use {READ,WRITE}_ONCE in memory scanning
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiang Zhang <[email protected]>
[ Upstream commit 82634d7e24271698e50a3ec811e5f50de790a65f ]
memtest failed to find bad memory when compiled with clang. So use {WRITE,READ}_ONCE to access memory to avoid compiler over optimization.
--- mm/memtest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memtest.c +2 -2
@@ -51,10 +51,10 @@ static void __init memtest(u64 pattern, phys_addr_t start_phys, phys_addr_t size last_bad =0 ;for (p = start; p < end; p++) - *p = pattern; +WRITE_ONCE (*p, pattern);for (p = start; p < end; p++, start_phys_aligned += incr) { -if (*p == pattern) +if (READ_ONCE (*p) == pattern)continue ;if (start_phys_aligned == last_bad + incr) { last_bad += incr;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 172/432 Revert "block/mq-deadline: use correct way to throttling write requests"
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 256aab46e31683d76d45ccbedc287b4d3f3e322b ]
The code "max(1U, 3 * (1U << shift) / 4)" comes from the Kyber I/O scheduler. The Kyber I/O scheduler maintains one internal queue per hwq and hence derives its async_depth from the number of hwq tags. Using this approach for the mq-deadline scheduler is wrong since the mq-deadline scheduler maintains one internal queue for all hwqs combined. Hence this revert.
--- block/mq-deadline.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
block/mq-deadline.c +1 -2
@@ -646,9 +646,8 @@ static void dd_depth_updated(struct blk_mq_hw_ctx *hctx)struct request_queue *q = hctx->queue;struct deadline_data *dd = q->elevator->elevator_data;struct blk_mq_tags *tags = hctx->sched_tags; -unsigned int shift = tags->bitmap_tags.sb.shift; - dd->async_depth =max (1U ,3 * (1U << shift) /4 ); + dd->async_depth =max (1UL ,3 * q->nr_requests /4 );sbitmap_queue_min_shallow_depth (&tags->bitmap_tags, dd->async_depth); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 173/432 f2fs: mark inode dirty for FI_ATOMIC_COMMITTED flag
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sunmin Jeong <[email protected]>
[ Upstream commit 4bf78322346f6320313683dc9464e5423423ad5c ]
In f2fs_update_inode, i_size of the atomic file isn't updated until FI_ATOMIC_COMMITTED flag is set. When committing atomic write right after the writeback of the inode, i_size of the raw inode will not be updated. It can cause the atomicity corruption due to a mismatch between old file size and new data.
To prevent the problem, let's mark inode dirty for FI_ATOMIC_COMMITTED
Atomic write thread Writeback thread
__writeback_single_inode
write_inode
f2fs_update_inode
- skip i_size update
f2fs_ioc_commit_atomic_write
f2fs_commit_atomic_write
set_inode_flag(inode, FI_ATOMIC_COMMITTED)
f2fs_do_sync_file
f2fs_fsync_node_pages
- skip f2fs_update_inode since the inode is clean
--- fs/f2fs/f2fs.h | 1 + 1 file changed, 1 insertion(+)
fs/f2fs/f2fs.h +1 -0
@@ -3025,6 +3025,7 @@ static inline void __mark_inode_dirty_flag(struct inode *inode,case FI_INLINE_DOTS :case FI_PIN_FILE :case FI_COMPRESS_RELEASED : +case FI_ATOMIC_COMMITTED :f2fs_mark_inode_dirty_sync (inode, true); } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 174/432 f2fs: truncate page cache before clearing flags when aborting atomic write
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sunmin Jeong <[email protected]>
[ Upstream commit 74b0ebcbdde4c7fe23c979e4cfc2fdbf349c39a3 ]
In f2fs_do_write_data_page, FI_ATOMIC_FILE flag selects the target inode between the original inode and COW inode. When aborting atomic write and writeback occur simultaneously, invalid data can be written to original inode if the FI_ATOMIC_FILE flag is cleared meanwhile.
To prevent the problem, let's truncate all pages before clearing the flag
Atomic write thread Writeback thread
f2fs_abort_atomic_write
clear_inode_flag(inode, FI_ATOMIC_FILE)
__writeback_single_inode
do_writepages
f2fs_do_write_data_page
- use dn of original inode
truncate_inode_pages_final
--- fs/f2fs/segment.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/segment.c +3 -1
@@ -192,6 +192,9 @@ void f2fs_abort_atomic_write(struct inode *inode, bool clean)if (!f2fs_is_atomic_file (inode))return ; +if (clean) +truncate_inode_pages_final (inode->i_mapping); +release_atomic_write_cnt (inode);clear_inode_flag (inode,FI_ATOMIC_COMMITTED );clear_inode_flag (inode,FI_ATOMIC_REPLACE );
@@ -201,7 +204,6 @@ void f2fs_abort_atomic_write(struct inode *inode, bool clean)F2FS_I (inode)->atomic_write_task =NULL ;if (clean) { -truncate_inode_pages_final (inode->i_mapping);f2fs_i_size_write (inode, fi->original_i_size); fi->original_i_size =0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 175/432 nilfs2: fix failure to detect DAT corruption in btree and direct mappings
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit f2f26b4a84a0ef41791bd2d70861c8eac748f4ba ]
Patch series "nilfs2: fix kernel bug at submit_bh_wbc()".
This resolves a kernel BUG reported by syzbot. Since there are two flaws involved, I've made each one a separate patch.
The first patch alone resolves the syzbot-reported bug, but I think both fixes should be sent to stable, so I've tagged them as such.
This patch (of 2):
Syzbot has reported a kernel bug in submit_bh_wbc() when writing file data to a nilfs2 file system whose metadata is corrupted.
There are two flaws involved in this issue.
The first flaw is that when nilfs_get_block() locates a data block using btree or direct mapping, if the disk address translation routine nilfs_dat_translate() fails with internal code -ENOENT due to DAT metadata corruption, it can be passed back to nilfs_get_block(). This causes nilfs_get_block() to misidentify an existing block as non-existent, causing both data block lookup and insertion to fail inconsistently.
The second flaw is that nilfs_get_block() returns a successful status in this inconsistent state. This causes the caller __block_write_begin_int() or others to request a read even though the buffer is not mapped, resulting in a BUG_ON check for the BH_Mapped flag in submit_bh_wbc() failing.
This fixes the first issue by changing the return value to code -EINVAL when a conversion using DAT fails with code -ENOENT, avoiding the conflicting condition that leads to the kernel bug described above. Here, code -EINVAL indicates that metadata corruption was detected during the block lookup, which will be properly handled as a file system error and converted to -EIO when passing through the nilfs2 bmap layer.
--- fs/nilfs2/btree.c | 9 +++++++-- fs/nilfs2/direct.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-)
fs/nilfs2/btree.c +7 -2
@@ -724,7 +724,7 @@ static int nilfs_btree_lookup_contig(const struct nilfs_bmap *btree, dat =nilfs_bmap_get_dat (btree); ret =nilfs_dat_translate (dat, ptr, &blocknr);if (ret <0 ) - goto out; + goto dat_error; ptr = blocknr; } cnt =1 ;
@@ -743,7 +743,7 @@ static int nilfs_btree_lookup_contig(const struct nilfs_bmap *btree,if (dat) { ret =nilfs_dat_translate (dat, ptr2, &blocknr);if (ret <0 ) - goto out; + goto dat_error; ptr2 = blocknr; }if (ptr2 != ptr + cnt || ++cnt == maxblocks)
@@ -781,6 +781,11 @@ static int nilfs_btree_lookup_contig(const struct nilfs_bmap *btree, out:nilfs_btree_free_path (path);return ret; + + dat_error: +if (ret == -ENOENT ) + ret = -EINVAL ;/* Notify bmap layer of metadata corruption */ + goto out; } static void nilfs_btree_promote_key(struct nilfs_bmap *btree,
fs/nilfs2/direct.c +7 -2
@@ -66,7 +66,7 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *direct, dat =nilfs_bmap_get_dat (direct); ret =nilfs_dat_translate (dat, ptr, &blocknr);if (ret <0 ) -return ret; + goto dat_error; ptr = blocknr; }
@@ -79,7 +79,7 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *direct,if (dat) { ret =nilfs_dat_translate (dat, ptr2, &blocknr);if (ret <0 ) -return ret; + goto dat_error; ptr2 = blocknr; }if (ptr2 != ptr + cnt)
@@ -87,6 +87,11 @@ static int nilfs_direct_lookup_contig(const struct nilfs_bmap *direct, } *ptrp = ptr;return cnt; + + dat_error: +if (ret == -ENOENT ) + ret = -EINVAL ;/* Notify bmap layer of metadata corruption */ +return ret; } static __u64
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 176/432 nilfs2: prevent kernel bug at submit_bh_wbc()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 269cdf353b5bdd15f1a079671b0f889113865f20 ]
Fix a bug where nilfs_get_block() returns a successful status when searching and inserting the specified block both fail inconsistently. If this inconsistent behavior is not due to a previously fixed bug, then an unexpected race is occurring, so return a temporary error -EAGAIN instead.
This prevents callers such as __block_write_begin_int() from requesting a read into a buffer that is not mapped, which would cause the BUG_ON check for the BH_Mapped flag in submit_bh_wbc() to fail.
--- fs/nilfs2/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nilfs2/inode.c +1 -1
@@ -112,7 +112,7 @@ int nilfs_get_block(struct inode *inode, sector_t blkoff,"%s (ino=%lu): a race condition while inserting a data block at offset=%llu" , __func__, inode->i_ino, (unsigned long long)blkoff); - err =0 ; + err = -EAGAIN ; }nilfs_transaction_abort (inode->i_sb); goto out;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 177/432 cifs: make sure server interfaces are requested only for SMB3+
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
[ Upstream commit 13c0a74747cb7fdadf58c5d3a7d52cfca2d51736 ]
Some code paths for querying server interfaces make a false assumption that it will only get called for SMB3+. Since this function now can get called from a generic code paths, the correct thing to do is to have specific handler for this functionality per SMB dialect, and call this handler.
This change adds such a handler and implements this handler only for SMB 3.0 and 3.1.1.
--- fs/smb/client/cifsglob.h | 3 +++ fs/smb/client/connect.c | 6 +++++- fs/smb/client/smb2ops.c | 2 ++ fs/smb/client/smb2pdu.c | 5 +++-- 4 files changed, 13 insertions(+), 3 deletions(-)
fs/smb/client/cifsglob.h +3 -0
@@ -339,6 +339,9 @@ struct smb_version_operations {/* informational QFS call */ void (*qfs_tcon)(const unsigned int ,struct cifs_tcon *,struct cifs_sb_info *); +/* query for server interfaces */ +int (*query_server_interfaces)(const unsigned int ,struct cifs_tcon *, +bool );/* check if a path is accessible or not */ int (*is_path_accessible)(const unsigned int ,struct cifs_tcon *,struct cifs_sb_info *,const char *);
fs/smb/client/connect.c +5 -1
@@ -123,12 +123,16 @@ static void smb2_query_server_interfaces(struct work_struct *work)struct cifs_tcon *tcon =container_of (work, struct cifs_tcon, query_interfaces.work); +struct TCP_Server_Info *server = tcon->ses->server;/* * query server network interfaces, in case they change */ +if (!server->ops->query_server_interfaces) +return ; + xid =get_xid (); - rc =SMB3_request_interfaces (xid, tcon, false); + rc = server->ops->query_server_interfaces (xid, tcon, false);free_xid (xid);if (rc) {
fs/smb/client/smb2ops.c +2 -0
@@ -5429,6 +5429,7 @@ struct smb_version_operations smb30_operations = { .tree_connect = SMB2_tcon, .tree_disconnect = SMB2_tdis, .qfs_tcon = smb3_qfs_tcon, + .query_server_interfaces = SMB3_request_interfaces, .is_path_accessible = smb2_is_path_accessible, .can_echo = smb2_can_echo, .echo = SMB2_echo,
@@ -5543,6 +5544,7 @@ struct smb_version_operations smb311_operations = { .tree_connect = SMB2_tcon, .tree_disconnect = SMB2_tdis, .qfs_tcon = smb3_qfs_tcon, + .query_server_interfaces = SMB3_request_interfaces, .is_path_accessible = smb2_is_path_accessible, .can_echo = smb2_can_echo, .echo = SMB2_echo,
fs/smb/client/smb2pdu.c +3 -2
@@ -409,14 +409,15 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,spin_unlock (&ses->ses_lock);if (!rc && - (server->capabilities &SMB2_GLOBAL_CAP_MULTI_CHANNEL )) { + (server->capabilities &SMB2_GLOBAL_CAP_MULTI_CHANNEL ) && + server->ops->query_server_interfaces) {mutex_unlock (&ses->session_mutex);/* * query server network interfaces, in case they change */ xid =get_xid (); - rc =SMB3_request_interfaces (xid, tcon, false); + rc = server->ops->query_server_interfaces (xid, tcon, false);free_xid (xid);if (rc == -EOPNOTSUPP && ses->chan_count >1 ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 178/432 cifs: delete unnecessary NULL checks in cifs_chan_update_iface()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit c3a11c0ec66c1e0652e3a2bb4f5cc74eea0ba486 ]
We return early if "iface" is NULL so there is no need to check here. Delete those checks.
Stable-dep-of: 16a57d768111 ("cifs: reduce warning log level for server not advertising interfaces")
--- fs/smb/client/sess.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)
fs/smb/client/sess.c +11 -15
@@ -472,27 +472,23 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)kref_put (&old_iface->refcount, release_iface); }else if (!chan_index) {/* special case: update interface for primary channel */ -if (iface) { -cifs_dbg (FYI ,"referencing primary channel iface: %pIS\n" , - &iface->sockaddr); - iface->num_channels++; - iface->weight_fulfilled++; - } +cifs_dbg (FYI ,"referencing primary channel iface: %pIS\n" , + &iface->sockaddr); + iface->num_channels++; + iface->weight_fulfilled++; }spin_unlock (&ses->iface_lock); -if (iface) { -spin_lock (&ses->chan_lock); - chan_index =cifs_ses_get_chan_index (ses, server); -if (chan_index ==CIFS_INVAL_CHAN_INDEX ) { -spin_unlock (&ses->chan_lock); -return 0 ; - } - - ses->chans[chan_index].iface = iface; +spin_lock (&ses->chan_lock); + chan_index =cifs_ses_get_chan_index (ses, server); +if (chan_index ==CIFS_INVAL_CHAN_INDEX ) {spin_unlock (&ses->chan_lock); +return 0 ; } + ses->chans[chan_index].iface = iface; +spin_unlock (&ses->chan_lock); +return rc; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 179/432 cifs: make cifs_chan_update_iface() a void function
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 8d606c311b75e81063b4ea650b301cbe0c4ed5e1 ]
The return values for cifs_chan_update_iface() didn't match what the documentation said and nothing was checking them anyway. Just make it a void function.
Stable-dep-of: 16a57d768111 ("cifs: reduce warning log level for server not advertising interfaces")
--- fs/smb/client/cifsproto.h | 2 +- fs/smb/client/sess.c | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-)
fs/smb/client/cifsproto.h +1 -1
@@ -654,7 +654,7 @@ cifs_chan_is_iface_active(struct cifs_ses *ses, struct TCP_Server_Info *server);void cifs_disable_secondary_channels (struct cifs_ses *ses); -int +void cifs_chan_update_iface (struct cifs_ses *ses,struct TCP_Server_Info *server);int SMB3_request_interfaces (const unsigned int xid,struct cifs_tcon *tcon,bool in_mount);
fs/smb/client/sess.c +7 -10
@@ -361,10 +361,9 @@ cifs_disable_secondary_channels(struct cifs_ses *ses)/* * update the iface for the channel if necessary. -* will return 0 when iface is updated, 1 if removed, 2 otherwise * Must be called with chan_lock held. */ -int +void cifs_chan_update_iface (struct cifs_ses *ses,struct TCP_Server_Info *server) {unsigned int chan_index;
@@ -373,20 +372,19 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)struct cifs_server_iface *old_iface =NULL ;struct cifs_server_iface *last_iface =NULL ;struct sockaddr_storage ss; -int rc =0 ;spin_lock (&ses->chan_lock); chan_index =cifs_ses_get_chan_index (ses, server);if (chan_index ==CIFS_INVAL_CHAN_INDEX ) {spin_unlock (&ses->chan_lock); -return 0 ; +return ; }if (ses->chans[chan_index].iface) { old_iface = ses->chans[chan_index].iface;if (old_iface->is_active) {spin_unlock (&ses->chan_lock); -return 1 ; +return ; } }spin_unlock (&ses->chan_lock);
@@ -399,7 +397,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)if (!ses->iface_count) {spin_unlock (&ses->iface_lock);cifs_dbg (VFS ,"server %s does not advertise interfaces\n" , ses->server->hostname); -return 0 ; +return ; } last_iface = list_last_entry(&ses->iface_list, struct cifs_server_iface,
@@ -439,7 +437,6 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) }if (list_entry_is_head (iface, &ses->iface_list, iface_head)) { - rc =1 ; iface =NULL ;cifs_dbg (FYI ,"unable to find a suitable iface\n" ); }
@@ -454,7 +451,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) }spin_unlock (&ses->iface_lock); -return 0 ; +return ; }/* now drop the ref to the current iface */
@@ -483,13 +480,13 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server) chan_index =cifs_ses_get_chan_index (ses, server);if (chan_index ==CIFS_INVAL_CHAN_INDEX ) {spin_unlock (&ses->chan_lock); -return 0 ; +return ; } ses->chans[chan_index].iface = iface;spin_unlock (&ses->chan_lock); -return rc; +return ; }/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 180/432 cifs: reduce warning log level for server not advertising interfaces
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
[ Upstream commit 16a57d7681110b25708c7042688412238e6f73a9 ]
Several users have reported this log getting dumped too regularly to kernel log. The likely root cause has been identified, and it suggests that this situation is expected for some configurations (for example SMB2.1).
Since the function returns appropriately even for such cases, it is fairly harmless to make this a debug log. When needed, the verbosity can be increased to capture this log.
--- fs/smb/client/sess.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/sess.c +2 -2
@@ -230,7 +230,7 @@ int cifs_try_adding_channels(struct cifs_ses *ses)spin_lock (&ses->iface_lock);if (!ses->iface_count) {spin_unlock (&ses->iface_lock); -cifs_dbg (VFS ,"server %s does not advertise interfaces\n" , +cifs_dbg (ONCE ,"server %s does not advertise interfaces\n" , ses->server->hostname);break ; }
@@ -396,7 +396,7 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)spin_lock (&ses->iface_lock);if (!ses->iface_count) {spin_unlock (&ses->iface_lock); -cifs_dbg (VFS ,"server %s does not advertise interfaces\n" , ses->server->hostname); +cifs_dbg (ONCE ,"server %s does not advertise interfaces\n" , ses->server->hostname);return ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 181/432 cifs: open_cached_dir(): add FILE_READ_EA to desired access
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eugene Korenevsky <[email protected]>
[ Upstream commit f1b8224b4e6ed59e7e6f5c548673c67410098d8d ]
Since smb2_query_eas() reads EA and uses cached directory, open_cached_dir() should request FILE_READ_EA access.
Otherwise listxattr() and getxattr() will fail with EACCES (0xc0000022 STATUS_ACCESS_DENIED SMB status).
--- fs/smb/client/cached_dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/smb/client/cached_dir.c +2 -1
@@ -233,7 +233,8 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, .tcon = tcon, .path = path, .create_options = cifs_create_options(cifs_sb, CREATE_NOT_FILE), - .desired_access = FILE_READ_DATA | FILE_READ_ATTRIBUTES, + .desired_access = FILE_READ_DATA | FILE_READ_ATTRIBUTES | + FILE_READ_EA, .disposition = FILE_OPEN, .fid = pfid, };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 182/432 mtd: rawnand: Fix and simplify again the continuous read derivations
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal <[email protected]>
[ Upstream commit c7ee7c8d4b60fe46d4861b1200bc1c7ab657960a ]
We need to avoid the first page if we don't read it entirely. We need to avoid the last page if we don't read it entirely. While rather simple, this logic has been failed in the previous fix. This time I wrote about 30 unit tests locally to check each possible condition, hopefully I covered them all.
--- drivers/mtd/nand/raw/nand_base.c | 34 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-)
drivers/mtd/nand/raw/nand_base.c +20 -14
@@ -3460,30 +3460,36 @@ static void rawnand_enable_cont_reads(struct nand_chip *chip, unsigned int page, u32 readlen, int col) {struct mtd_info *mtd =nand_to_mtd (chip); -unsigned int end_page, end_col; +unsigned int first_page, last_page; chip->cont_read.ongoing = false;if (!chip->controller->supported_op.cont_read)return ; - end_page =DIV_ROUND_UP (col + readlen, mtd->writesize); - end_col = (col + readlen) % mtd->writesize; +/* +* Don't bother making any calculations if the length is too small. +* Side effect: avoids possible integer underflows below. +*/ +if (readlen < (2 * mtd->writesize)) +return ; +/* Derive the page where continuous read should start (the first full page read) */ + first_page = page;if (col) - page++; - -if (end_col && end_page) - end_page--; + first_page++; -if (page +1 > end_page) -return ; - - chip->cont_read.first_page = page; - chip->cont_read.last_page = end_page; - chip->cont_read.ongoing = true; +/* Derive the page where continuous read should stop (the last full page read) */ + last_page = page + ((col + readlen) / mtd->writesize) -1 ; -rawnand_cap_cont_reads (chip); +/* Configure and enable continuous read when suitable */ +if (first_page < last_page) { + chip->cont_read.first_page = first_page; + chip->cont_read.last_page = last_page; + chip->cont_read.ongoing = true; +/* May reset the ongoing flag */ +rawnand_cap_cont_reads (chip); + } }static void rawnand_cont_read_skip_first_page (struct nand_chip *chip,unsigned int page)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 183/432 mtd: rawnand: Add a helper for calculating a page index
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal <[email protected]>
[ Upstream commit df9803bf5a91e3599f12b53c94722f2c4e144a86 ]
For LUN crossing boundaries, it is handy to know what is the index of the last page in a LUN. This helper will soon be reused. At the same time I rename page_per_lun to ppl in the calling function to clarify the lines.
--- drivers/mtd/nand/raw/nand_base.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/mtd/nand/raw/nand_base.c +11 -5
@@ -1207,19 +1207,25 @@ static int nand_lp_exec_read_page_op(struct nand_chip *chip, unsigned int page,return nand_exec_op (chip, &op); } +static unsigned int rawnand_last_page_of_lun (unsigned int pages_per_lun,unsigned int lun) +{ +/* lun is expected to be very small */ +return (lun * pages_per_lun) + pages_per_lun -1 ; +} +static void rawnand_cap_cont_reads (struct nand_chip *chip) {struct nand_memory_organization *memorg; -unsigned int pages_per_lun, first_lun, last_lun; +unsigned int ppl, first_lun, last_lun; memorg =nanddev_get_memorg (&chip->base); - pages_per_lun = memorg->pages_per_eraseblock * memorg->eraseblocks_per_lun; - first_lun = chip->cont_read.first_page / pages_per_lun; - last_lun = chip->cont_read.last_page / pages_per_lun; + ppl = memorg->pages_per_eraseblock * memorg->eraseblocks_per_lun; + first_lun = chip->cont_read.first_page / ppl; + last_lun = chip->cont_read.last_page / ppl;/* Prevent sequential cache reads across LUN boundaries */ if (first_lun != last_lun) - chip->cont_read.pause_page = first_lun * pages_per_lun + pages_per_lun -1 ; + chip->cont_read.pause_page =rawnand_last_page_of_lun (ppl, first_lun);else chip->cont_read.pause_page = chip->cont_read.last_page; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 184/432 mtd: rawnand: Ensure all continuous terms are always in sync
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal <[email protected]>
[ Upstream commit 6fb075fca63c3486612986eeff84ed4179644038 ]
While crossing a LUN boundary, it is probably safer (and clearer) to keep all members of the continuous read structure aligned, including the pause page (which is the last page of the lun or the last page of the continuous read). Once these members properly in sync, we can use the rawnand_cap_cont_reads() helper everywhere to "prepare" the next continuous read if there is one.
--- drivers/mtd/nand/raw/nand_base.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
drivers/mtd/nand/raw/nand_base.c +14 -9
@@ -1228,6 +1228,15 @@ static void rawnand_cap_cont_reads(struct nand_chip *chip) chip->cont_read.pause_page =rawnand_last_page_of_lun (ppl, first_lun); else chip->cont_read.pause_page = chip->cont_read.last_page; + +if (chip->cont_read.first_page == chip->cont_read.pause_page) { + chip->cont_read.first_page++; + chip->cont_read.pause_page =min (chip->cont_read.last_page, +rawnand_last_page_of_lun (ppl, first_lun +1 )); + } + +if (chip->cont_read.first_page >= chip->cont_read.last_page) + chip->cont_read.ongoing = false; } static int nand_lp_exec_cont_read_page_op(struct nand_chip *chip, unsigned int page,
@@ -1294,12 +1303,11 @@ static int nand_lp_exec_cont_read_page_op(struct nand_chip *chip, unsigned int pif (!chip->cont_read.ongoing)return 0 ; -if (page == chip->cont_read.pause_page && - page != chip->cont_read.last_page) { - chip->cont_read.first_page = chip->cont_read.pause_page +1 ; -rawnand_cap_cont_reads (chip); - }else if (page == chip->cont_read.last_page) { +if (page == chip->cont_read.last_page) { chip->cont_read.ongoing = false; + }else if (page == chip->cont_read.pause_page) { + chip->cont_read.first_page++; +rawnand_cap_cont_reads (chip); }return 0 ;
@@ -3504,10 +3512,7 @@ static void rawnand_cont_read_skip_first_page(struct nand_chip *chip, unsigned ireturn ; chip->cont_read.first_page++; -if (chip->cont_read.first_page == chip->cont_read.pause_page) - chip->cont_read.first_page++; -if (chip->cont_read.first_page >= chip->cont_read.last_page) - chip->cont_read.ongoing = false; +rawnand_cap_cont_reads (chip); }/**
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 185/432 mtd: rawnand: Constrain even more when continuous reads are enabled
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal <[email protected]>
[ Upstream commit 78ffbefba8d7822b232585570b293de5bc397da6 ]
As a matter of fact, continuous reads require additional handling at the operation level in order for them to work properly. The core helpers do have this additional logic now, but any time a controller implements its own page helper, this extra logic is "lost". This means we need another level of per-controller driver checks to ensure they can leverage continuous reads. This is for now unsupported, so in order to ensure continuous reads are enabled only when fully using the core page helpers, we need to add more initial checks.
Also, as performance is not relevant during raw accesses, we also prevent these from enabling the feature.
This should solve the issue seen with controllers such as the STM32 FMC2 when in sequencer mode. In this case, the continuous read feature would be enabled but not leveraged, and most importantly not disabled, leading to further operations to fail.
--- drivers/mtd/nand/raw/nand_base.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/nand_base.c +11 -1
@@ -3588,7 +3588,8 @@ static int nand_do_read_ops(struct nand_chip *chip, loff_t from, oob = ops->oobbuf; oob_required = oob ?1 :0 ; -rawnand_enable_cont_reads (chip, page, readlen, col); +if (likely (ops->mode !=MTD_OPS_RAW )) +rawnand_enable_cont_reads (chip, page, readlen, col);while (1 ) {struct mtd_ecc_stats ecc_stats = mtd->ecc_stats;
@@ -5206,6 +5207,15 @@ static void rawnand_late_check_supported_ops(struct nand_chip *chip)if (!nand_has_exec_op (chip))return ; +/* +* For now, continuous reads can only be used with the core page helpers. +* This can be extended later. +*/ +if (!(chip->ecc.read_page == nand_read_page_hwecc || + chip->ecc.read_page == nand_read_page_syndrome || + chip->ecc.read_page == nand_read_page_swecc)) +return ; +rawnand_check_cont_read_support (chip); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 186/432 cpufreq: dt: always allocate zeroed cpumask
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit d2399501c2c081eac703ca9597ceb83c7875a537 ]
Commit 0499a78369ad ("ARM64: Dynamically allocate cpumasks and increase supported CPUs to 512") changed the handling of cpumasks on ARM 64bit, what resulted in the strange issues and warnings during cpufreq-dt initialization on some big.LITTLE platforms.
This was caused by mixing OPPs between big and LITTLE cores, because OPP-sharing information between big and LITTLE cores is computed on cpumask, which in turn was not zeroed on allocation. Fix this by switching to zalloc_cpumask_var() call.
--- drivers/cpufreq/cpufreq-dt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/cpufreq/cpufreq-dt.c +1 -1
@@ -208,7 +208,7 @@ static int dt_cpufreq_early_init(struct device *dev, int cpu)if (!priv)return -ENOMEM ; -if (!alloc_cpumask_var (&priv->cpus,GFP_KERNEL )) +if (!zalloc_cpumask_var (&priv->cpus,GFP_KERNEL ))return -ENOMEM ;cpumask_set_cpu (cpu, priv->cpus);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 187/432 io_uring/futex: always remove futex entry for cancel all
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
[ Upstream commit 30dab608c3cb99c2a05b76289fd05551703979ae ]
We know the request is either being removed, or already in the process of being removed through task_work, so we can delete it from our futex list upfront. This is important for remove all conditions, as we otherwise will find it multiple times and prevent cancelation progress.
--- io_uring/futex.c | 1 + 1 file changed, 1 insertion(+)
io_uring/futex.c +1 -0
@@ -159,6 +159,7 @@ bool io_futex_remove_all(struct io_ring_ctx *ctx, struct task_struct *task,hlist_for_each_entry_safe (req, tmp, &ctx->futex_list, hash_node) {if (!io_match_task_safe (req, task, cancel_all))continue ; +hlist_del_init (&req->hash_node);__io_futex_cancel (ctx, req); found = true; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 188/432 io_uring/waitid: always remove waitid entry for cancel all
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
[ Upstream commit 2b35b8b43e07b1a6f06fdd84cf4b9eb24785896d ]
We know the request is either being removed, or already in the process of being removed through task_work, so we can delete it from our waitid list upfront. This is important for remove all conditions, as we otherwise will find it multiple times and prevent cancelation progress.
Remove the dead check in cancelation as well for the hash_node being empty or not. We already have a waitid reference check for ownership, so we don't need to check the list too.
--- io_uring/waitid.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
io_uring/waitid.c +1 -6
@@ -125,12 +125,6 @@ static void io_waitid_complete(struct io_kiocb *req, int ret)lockdep_assert_held (&req->ctx->uring_lock); -/* -* Did cancel find it meanwhile? -*/ -if (hlist_unhashed (&req->hash_node)) -return ; -hlist_del_init (&req->hash_node); ret =io_waitid_finish (req, ret);
@@ -202,6 +196,7 @@ bool io_waitid_remove_all(struct io_ring_ctx *ctx, struct task_struct *task,hlist_for_each_entry_safe (req, tmp, &ctx->waitid_list, hash_node) {if (!io_match_task_safe (req, task, cancel_all))continue ; +hlist_del_init (&req->hash_node);__io_waitid_cancel (ctx, req); found = true; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 189/432 x86/CPU/AMD: Update the Zenbleed microcode revisions
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Borislav Petkov (AMD) <[email protected]>
[ Upstream commit 5c84b051bd4e777cf37aaff983277e58c99618d5 ]
Update them to the correct revision numbers.
--- arch/x86/kernel/cpu/amd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/kernel/cpu/amd.c +5 -5
@@ -1002,11 +1002,11 @@ static bool cpu_has_zenbleed_microcode(void)u32 good_rev =0 ;switch (boot_cpu_data.x86_model) { - case 0x30 ... 0x3f: good_rev = 0x0830107a; break; - case 0x60 ... 0x67: good_rev = 0x0860010b; break; - case 0x68 ... 0x6f: good_rev = 0x08608105; break; - case 0x70 ... 0x7f: good_rev = 0x08701032; break; - case 0xa0 ... 0xaf: good_rev = 0x08a00008; break; + case 0x30 ... 0x3f: good_rev = 0x0830107b; break; + case 0x60 ... 0x67: good_rev = 0x0860010c; break; + case 0x68 ... 0x6f: good_rev = 0x08608107; break; + case 0x70 ... 0x7f: good_rev = 0x08701033; break; + case 0xa0 ... 0xaf: good_rev = 0x08a00009; break;default :return false;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 190/432 ksmbd: fix slab-out-of-bounds in smb_strndup_from_utf16()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit a80a486d72e20bd12c335bcd38b6e6f19356b0aa ]
If ->NameOffset of smb2_create_req is smaller than Buffer offset of smb2_create_req, slab-out-of-bounds read can happen from smb2_open. This patch set the minimum value of the name offset to the buffer offset to validate name length of smb2_create_req().
--- fs/smb/server/smb2misc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/smb/server/smb2misc.c +4 -1
@@ -107,7 +107,10 @@ static int smb2_get_data_area_len(unsigned int *off, unsigned int *len,case SMB2_CREATE : {unsigned short int name_off = -le16_to_cpu (((struct smb2_create_req *)hdr)->NameOffset); + max_t(unsigned short int, +le16_to_cpu (((struct smb2_create_req *)hdr)->NameOffset), + offsetof(struct smb2_create_req , Buffer)); +unsigned short int name_len =le16_to_cpu (((struct smb2_create_req *)hdr)->NameLength);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 191/432 net: esp: fix bad handling of pages from page_pool
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dragos Tatulea <[email protected]>
[ Upstream commit c3198822c6cb9fb588e446540485669cc81c5d34 ]
When the skb is reorganized during esp_output (!esp->inline), the pages coming from the original skb fragments are supposed to be released back to the system through put_page. But if the skb fragment pages are originating from a page_pool, calling put_page on them will trigger a page_pool leak which will eventually result in a crash.
This leak can be easily observed when using CONFIG_DEBUG_VM and doing ipsec + gre (non offloaded) forwarding:
BUG: Bad page state in process ksoftirqd/16 pfn:1451b6 page:00000000de2b8d32 refcount:0 mapcount:0 mapping:0000000000000000 index:0x1451b6000 pfn:0x1451b6 flags: 0x200000000000000(node=0|zone=2) page_type: 0xffffffff() raw: 0200000000000000 dead000000000040 ffff88810d23c000 0000000000000000 raw: 00000001451b6000 0000000000000001 00000000ffffffff 0000000000000000 page dumped because: page_pool leak Modules linked in: ip_gre gre mlx5_ib mlx5_core xt_conntrack xt_MASQUERADE nf_conntrack_netlink nfnetlink iptable_nat nf_nat xt_addrtype br_netfilter rpcrdma rdma_ucm ib_iser libiscsi scsi_transport_iscsi ib_umad rdma_cm ib_ipoib iw_cm ib_cm ib_uverbs ib_core overlay zram zsmalloc fuse [last unloaded: mlx5_core] CPU: 16 PID: 96 Comm: ksoftirqd/16 Not tainted 6.8.0-rc4+ #22 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x36/0x50 bad_page+0x70/0xf0 free_unref_page_prepare+0x27a/0x460 free_unref_page+0x38/0x120 esp_ssg_unref.isra.0+0x15f/0x200 esp_output_tail+0x66d/0x780 esp_xmit+0x2c5/0x360 validate_xmit_xfrm+0x313/0x370 ? validate_xmit_skb+0x1d/0x330 validate_xmit_skb_list+0x4c/0x70 sch_direct_xmit+0x23e/0x350 __dev_queue_xmit+0x337/0xba0 ? nf_hook_slow+0x3f/0xd0 ip_finish_output2+0x25e/0x580 iptunnel_xmit+0x19b/0x240 ip_tunnel_xmit+0x5fb/0xb60 ipgre_xmit+0x14d/0x280 [ip_gre] dev_hard_start_xmit+0xc3/0x1c0 __dev_queue_xmit+0x208/0xba0 ? nf_hook_slow+0x3f/0xd0 ip_finish_output2+0x1ca/0x580 ip_sublist_rcv_finish+0x32/0x40 ip_sublist_rcv+0x1b2/0x1f0 ? ip_rcv_finish_core.constprop.0+0x460/0x460 ip_list_rcv+0x103/0x130 __netif_receive_skb_list_core+0x181/0x1e0 netif_receive_skb_list_internal+0x1b3/0x2c0 napi_gro_receive+0xc8/0x200 gro_cell_poll+0x52/0x90 __napi_poll+0x25/0x1a0 net_rx_action+0x28e/0x300 __do_softirq+0xc3/0x276 ? sort_range+0x20/0x20 run_ksoftirqd+0x1e/0x30 smpboot_thread_fn+0xa6/0x130 kthread+0xcd/0x100 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x31/0x50 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork_asm+0x11/0x20 </TASK>
The suggested fix is to introduce a new wrapper (skb_page_unref) that covers page refcounting for page_pool pages as well.
--- include/linux/skbuff.h | 10 ++++++++++ net/ipv4/esp4.c | 8 ++++---- net/ipv6/esp6.c | 8 ++++---- 3 files changed, 18 insertions(+), 8 deletions(-)
include/linux/skbuff.h +10 -0
@@ -3438,6 +3438,16 @@ static inline void skb_frag_ref(struct sk_buff *skb, int f)bool napi_pp_put_page (struct page *page,bool napi_safe); +static inline void +skb_page_unref (const struct sk_buff *skb,struct page *page,bool napi_safe) +{ +#ifdef CONFIG_PAGE_POOL +if (skb->pp_recycle &&napi_pp_put_page (page, napi_safe)) +return ; +#endif +put_page (page); +} +static inline void napi_frag_unref (skb_frag_t *frag,bool recycle,bool napi_safe) {
net/ipv4/esp4.c +4 -4
@@ -95,7 +95,7 @@ static inline struct scatterlist *esp_req_sg(struct crypto_aead *aead, __alignof__(struct scatterlist)); } -static void esp_ssg_unref (struct xfrm_state *x,void *tmp) +static void esp_ssg_unref (struct xfrm_state *x,void *tmp,struct sk_buff *skb) {struct crypto_aead *aead = x->data;int extralen =0 ;
@@ -114,7 +114,7 @@ static void esp_ssg_unref(struct xfrm_state *x, void *tmp)*/ if (req->src != req->dst)for (sg =sg_next (req->src); sg; sg =sg_next (sg)) -put_page (sg_page (sg)); +skb_page_unref (skb,sg_page (sg), false); }#ifdef CONFIG_INET_ESPINTCP
@@ -260,7 +260,7 @@ static void esp_output_done(void *data, int err) } tmp =ESP_SKB_CB (skb)->tmp; -esp_ssg_unref (x, tmp); +esp_ssg_unref (x, tmp, skb);kfree (tmp);if (xo && (xo->flags &XFRM_DEV_RESUME )) {
@@ -639,7 +639,7 @@ int esp_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info * }if (sg != dsg) -esp_ssg_unref (x, tmp); +esp_ssg_unref (x, tmp, skb);if (!err && x->encap && x->encap->encap_type ==TCP_ENCAP_ESPINTCP ) err =esp_output_tail_tcp (x, skb);
net/ipv6/esp6.c +4 -4
@@ -112,7 +112,7 @@ static inline struct scatterlist *esp_req_sg(struct crypto_aead *aead, __alignof__(struct scatterlist)); } -static void esp_ssg_unref (struct xfrm_state *x,void *tmp) +static void esp_ssg_unref (struct xfrm_state *x,void *tmp,struct sk_buff *skb) {struct crypto_aead *aead = x->data;int extralen =0 ;
@@ -131,7 +131,7 @@ static void esp_ssg_unref(struct xfrm_state *x, void *tmp)*/ if (req->src != req->dst)for (sg =sg_next (req->src); sg; sg =sg_next (sg)) -put_page (sg_page (sg)); +skb_page_unref (skb,sg_page (sg), false); }#ifdef CONFIG_INET6_ESPINTCP
@@ -294,7 +294,7 @@ static void esp_output_done(void *data, int err) } tmp =ESP_SKB_CB (skb)->tmp; -esp_ssg_unref (x, tmp); +esp_ssg_unref (x, tmp, skb);kfree (tmp);esp_output_encap_csum (skb);
@@ -677,7 +677,7 @@ int esp6_output_tail(struct xfrm_state *x, struct sk_buff *skb, struct esp_info }if (sg != dsg) -esp_ssg_unref (x, tmp); +esp_ssg_unref (x, tmp, skb);if (!err && x->encap && x->encap->encap_type ==TCP_ENCAP_ESPINTCP ) err =esp_output_tail_tcp (x, skb);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 192/432 NFSD: Fix nfsd_clid_class use of __string_len() macro
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit 9388a2aa453321bcf1ad2603959debea9e6ab6d4 ]
I'm working on restructuring the __string* macros so that it doesn't need to recalculate the string twice. That is, it will save it off when processing __string() and the __assign_str() will not need to do the work again as it currently does.
Currently __string_len(item, src, len) doesn't actually use "src", but my changes will require src to be correct as that is where the __assign_str() will get its value from.
The event class nfsd_clid_class has:
__string_len(name, name, clp->cl_name.len)
But the second "name" does not exist and causes my changes to fail to build. That second parameter should be: clp->cl_name.data.
--- fs/nfsd/trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/trace.h +1 -1
@@ -843,7 +843,7 @@ DECLARE_EVENT_CLASS(nfsd_clid_class, __array(unsigned char, addr, sizeof(struct sockaddr_in6)) __field(unsigned long, flavor) __array(unsigned char, verifier, NFS4_VERIFIER_SIZE) - __string_len(name, name, clp->cl_name.len) + __string_len(name, clp->cl_name.data, clp->cl_name.len) ),TP_fast_assign ( __entry->cl_boot = clp->cl_clientid.cl_boot;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 193/432 drm/i915: Add missing ; to __assign_str() macros in tracepoint code
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit 0df4c388a1e310400a6e90fb10b286e2673756f0 ]
I'm working on improving the __assign_str() and __string() macros to be more efficient, and removed some unneeded semicolons. This triggered a bug in the build as some of the __assign_str() macros in intel_display_trace was missing a terminating semicolon.
--- drivers/gpu/drm/i915/display/intel_display_trace.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/display/intel_display_trace.h +3 -3
@@ -411,7 +411,7 @@ TRACE_EVENT(intel_fbc_activate,struct intel_crtc *crtc =intel_crtc_for_pipe (to_i915 (plane->base.dev), plane->pipe);__assign_str (dev,__dev_name_kms (plane)); -__assign_str (name, plane->base.name) +__assign_str (name, plane->base.name); __entry->pipe = crtc->pipe; __entry->frame =intel_crtc_get_vblank_counter (crtc); __entry->scanline =intel_get_crtc_scanline (crtc);
@@ -438,7 +438,7 @@ TRACE_EVENT(intel_fbc_deactivate,struct intel_crtc *crtc =intel_crtc_for_pipe (to_i915 (plane->base.dev), plane->pipe);__assign_str (dev,__dev_name_kms (plane)); -__assign_str (name, plane->base.name) +__assign_str (name, plane->base.name); __entry->pipe = crtc->pipe; __entry->frame =intel_crtc_get_vblank_counter (crtc); __entry->scanline =intel_get_crtc_scanline (crtc);
@@ -465,7 +465,7 @@ TRACE_EVENT(intel_fbc_nuke,struct intel_crtc *crtc =intel_crtc_for_pipe (to_i915 (plane->base.dev), plane->pipe);__assign_str (dev,__dev_name_kms (plane)); -__assign_str (name, plane->base.name) +__assign_str (name, plane->base.name); __entry->pipe = crtc->pipe; __entry->frame =intel_crtc_get_vblank_counter (crtc); __entry->scanline =intel_get_crtc_scanline (crtc);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 194/432 net: hns3: tracing: fix hclgevf trace event strings
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
[ Upstream commit 3f9952e8d80cca2da3b47ecd5ad9ec16cfd1a649 ]
The __string() and __assign_str() helper macros of the TRACE_EVENT() macro are going through some optimizations where only the source string of __string() will be used and the __assign_str() source will be ignored and later removed.
To make sure that there's no issues, a new check is added between the __string() src argument and the __assign_str() src argument that does a strcmp() to make sure they are the same string.
The hclgevf trace events have:
__assign_str(devname, &hdev->nic.kinfo.netdev->name);
Which triggers the warning:
hclgevf_trace.h:34:39: error: passing argument 1 of ‘strcmp’ from incompatible pointer type [-Werror=incompatible-pointer-types]
34 | __assign_str(devname, &hdev->nic.kinfo.netdev->name);
[..]arch/x86/include/asm/string_64.h:75:24: note: expected ‘const char *’ but argument is of type ‘char (*)[16]’
75 | int strcmp(const char *cs, const char *ct);
| ~~~~~~~~~~~~^~Because __assign_str() now has:
WARN_ON_ONCE(__builtin_constant_p(src) ? \ strcmp((src), __data_offsets.dst##_ptr_) : \ (src) != __data_offsets.dst##_ptr_); \
The problem is the '&' on hdev->nic.kinfo.netdev->name. That's because that name is:
char name[IFNAMSIZ]
Where passing an address '&' of a char array is not compatible with strcmp().
The '&' is not necessary, remove it.
--- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h | 8 ++++---- .../net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_trace.h +4 -4
@@ -24,7 +24,7 @@ TRACE_EVENT(hclge_pf_mbx_get, __field(u8, code) __field(u8, subcode) __string(pciname, pci_name(hdev->pdev)) - __string(devname, &hdev->vport[0].nic.kinfo.netdev->name) + __string(devname, hdev->vport[0].nic.kinfo.netdev->name)__array (u32, mbx_data,PF_GET_MBX_LEN ) ),
@@ -33,7 +33,7 @@ TRACE_EVENT(hclge_pf_mbx_get, __entry->code = req->msg.code; __entry->subcode = req->msg.subcode;__assign_str (pciname,pci_name (hdev->pdev)); -__assign_str (devname, &hdev->vport[0 ].nic.kinfo.netdev->name); +__assign_str (devname, hdev->vport[0 ].nic.kinfo.netdev->name);memcpy (__entry->mbx_data, req,sizeof (struct hclge_mbx_vf_to_pf_cmd )); ),
@@ -56,7 +56,7 @@ TRACE_EVENT(hclge_pf_mbx_send, __field(u8, vfid) __field(u16, code) __string(pciname, pci_name(hdev->pdev)) - __string(devname, &hdev->vport[0].nic.kinfo.netdev->name) + __string(devname, hdev->vport[0].nic.kinfo.netdev->name)__array (u32, mbx_data,PF_SEND_MBX_LEN ) ),
@@ -64,7 +64,7 @@ TRACE_EVENT(hclge_pf_mbx_send, __entry->vfid = req->dest_vfid; __entry->code =le16_to_cpu (req->msg.code);__assign_str (pciname,pci_name (hdev->pdev)); -__assign_str (devname, &hdev->vport[0 ].nic.kinfo.netdev->name); +__assign_str (devname, hdev->vport[0 ].nic.kinfo.netdev->name);memcpy (__entry->mbx_data, req,sizeof (struct hclge_mbx_pf_to_vf_cmd )); ),
drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_trace.h +4 -4
@@ -23,7 +23,7 @@ TRACE_EVENT(hclge_vf_mbx_get, __field(u8, vfid) __field(u16, code) __string(pciname, pci_name(hdev->pdev)) - __string(devname, &hdev->nic.kinfo.netdev->name) + __string(devname, hdev->nic.kinfo.netdev->name)__array (u32, mbx_data,VF_GET_MBX_LEN ) ),
@@ -31,7 +31,7 @@ TRACE_EVENT(hclge_vf_mbx_get, __entry->vfid = req->dest_vfid; __entry->code =le16_to_cpu (req->msg.code);__assign_str (pciname,pci_name (hdev->pdev)); -__assign_str (devname, &hdev->nic.kinfo.netdev->name); +__assign_str (devname, hdev->nic.kinfo.netdev->name);memcpy (__entry->mbx_data, req,sizeof (struct hclge_mbx_pf_to_vf_cmd )); ),
@@ -55,7 +55,7 @@ TRACE_EVENT(hclge_vf_mbx_send, __field(u8, code) __field(u8, subcode) __string(pciname, pci_name(hdev->pdev)) - __string(devname, &hdev->nic.kinfo.netdev->name) + __string(devname, hdev->nic.kinfo.netdev->name)__array (u32, mbx_data,VF_SEND_MBX_LEN ) ),
@@ -64,7 +64,7 @@ TRACE_EVENT(hclge_vf_mbx_send, __entry->code = req->msg.code; __entry->subcode = req->msg.subcode;__assign_str (pciname,pci_name (hdev->pdev)); -__assign_str (devname, &hdev->nic.kinfo.netdev->name); +__assign_str (devname, hdev->nic.kinfo.netdev->name);memcpy (__entry->mbx_data, req,sizeof (struct hclge_mbx_vf_to_pf_cmd )); ),
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 195/432 cxl/trace: Properly initialize cxl_poison region name
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alison Schofield <[email protected]>
[ Upstream commit 6c871260965255a1c142fb77ccee58b172d1690b ]
The TP_STRUCT__entry that gets assigned the region name, or an empty string if no region is present, is erroneously initialized to the cxl_region pointer. It needs to be properly initialized otherwise it's length is wrong and garbage chars can appear in the kernel trace output: /sys/kernel/tracing/trace
The bad initialization was due in part to a naming conflict with the parameter: struct cxl_region *region. The field 'region' is already exposed externally as the region name, so changing that to something logical, like 'region_name' is not an option. Instead rename the internal only struct cxl_region to the commonly used 'cxlr'.
Impact is that tooling depending on that trace data can miss picking up a valid event when searching by region name. The TP_printk() output, if enabled, does emit the correct region names in the dmesg log.
This was found during testing of the cxl-list option to report media-errors for a region.
--- drivers/cxl/core/trace.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/cxl/core/trace.h +7 -7
@@ -642,18 +642,18 @@ u64 cxl_trace_hpa(struct cxl_region *cxlr, struct cxl_memdev *memdev, u64 dpa); TRACE_EVENT(cxl_poison, - TP_PROTO(struct cxl_memdev *cxlmd, struct cxl_region *region, + TP_PROTO(struct cxl_memdev *cxlmd, struct cxl_region *cxlr, const struct cxl_poison_record *record, u8 flags, __le64 overflow_ts, enum cxl_poison_trace_type trace_type), - TP_ARGS(cxlmd, region, record, flags, overflow_ts, trace_type), + TP_ARGS(cxlmd, cxlr, record, flags, overflow_ts, trace_type), TP_STRUCT__entry( __string(memdev, dev_name(&cxlmd->dev)) __string(host, dev_name(cxlmd->dev.parent)) __field(u64, serial) __field(u8, trace_type) - __string(region, region) + __string(region, cxlr ? dev_name(&cxlr->dev) : "") __field(u64, overflow_ts) __field(u64, hpa) __field(u64, dpa)
@@ -673,10 +673,10 @@ TRACE_EVENT(cxl_poison, __entry->source =cxl_poison_record_source (record); __entry->trace_type = trace_type; __entry->flags = flags; -if (region) { -__assign_str (region,dev_name (®ion->dev)); -memcpy (__entry->uuid, ®ion->params.uuid,16 ); - __entry->hpa =cxl_trace_hpa (region, cxlmd, +if (cxlr) { +__assign_str (region,dev_name (&cxlr->dev)); +memcpy (__entry->uuid, &cxlr->params.uuid,16 ); + __entry->hpa =cxl_trace_hpa (cxlr, cxlmd, __entry->dpa); }else {__assign_str (region,"" );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 196/432 ksmbd: fix potencial out-of-bounds when buffer offset is invalid
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit c6cd2e8d2d9aa7ee35b1fa6a668e32a22a9753da ]
I found potencial out-of-bounds when buffer offset fields of a few requests is invalid. This patch set the minimum value of buffer offset field to ->Buffer offset to validate buffer length.
--- fs/smb/server/smb2misc.c | 23 +++++++++++++------ fs/smb/server/smb2pdu.c | 48 ++++++++++++++++++++++------------------ 2 files changed, 42 insertions(+), 29 deletions(-)
fs/smb/server/smb2misc.c +16 -7
@@ -101,7 +101,9 @@ static int smb2_get_data_area_len(unsigned int *off, unsigned int *len, *len =le16_to_cpu (((struct smb2_sess_setup_req *)hdr)->SecurityBufferLength);break ;case SMB2_TREE_CONNECT : - *off =le16_to_cpu (((struct smb2_tree_connect_req *)hdr)->PathOffset); + *off = max_t(unsigned short int, +le16_to_cpu (((struct smb2_tree_connect_req *)hdr)->PathOffset), + offsetof(struct smb2_tree_connect_req , Buffer)); *len =le16_to_cpu (((struct smb2_tree_connect_req *)hdr)->PathLength);break ;case SMB2_CREATE :
@@ -110,7 +112,6 @@ static int smb2_get_data_area_len(unsigned int *off, unsigned int *len, max_t(unsigned short int,le16_to_cpu (((struct smb2_create_req *)hdr)->NameOffset), offsetof(struct smb2_create_req, Buffer)); -unsigned short int name_len =le16_to_cpu (((struct smb2_create_req *)hdr)->NameLength);
@@ -131,11 +132,15 @@ static int smb2_get_data_area_len(unsigned int *off, unsigned int *len,break ; }case SMB2_QUERY_INFO : - *off =le16_to_cpu (((struct smb2_query_info_req *)hdr)->InputBufferOffset); + *off = max_t(unsigned int, +le16_to_cpu (((struct smb2_query_info_req *)hdr)->InputBufferOffset), + offsetof(struct smb2_query_info_req , Buffer)); *len =le32_to_cpu (((struct smb2_query_info_req *)hdr)->InputBufferLength);break ;case SMB2_SET_INFO : - *off =le16_to_cpu (((struct smb2_set_info_req *)hdr)->BufferOffset); + *off = max_t(unsigned int, +le16_to_cpu (((struct smb2_set_info_req *)hdr)->BufferOffset), + offsetof(struct smb2_set_info_req , Buffer)); *len =le32_to_cpu (((struct smb2_set_info_req *)hdr)->BufferLength);break ;case SMB2_READ :
@@ -145,7 +150,7 @@ static int smb2_get_data_area_len(unsigned int *off, unsigned int *len,case SMB2_WRITE :if (((struct smb2_write_req *)hdr)->DataOffset || ((struct smb2_write_req *)hdr)->Length) { - *off = max_t(unsigned int, + *off = max_t(unsigned short int,le16_to_cpu (((struct smb2_write_req *)hdr)->DataOffset), offsetof(struct smb2_write_req , Buffer)); *len =le32_to_cpu (((struct smb2_write_req *)hdr)->Length);
@@ -156,7 +161,9 @@ static int smb2_get_data_area_len(unsigned int *off, unsigned int *len, *len =le16_to_cpu (((struct smb2_write_req *)hdr)->WriteChannelInfoLength);break ;case SMB2_QUERY_DIRECTORY : - *off =le16_to_cpu (((struct smb2_query_directory_req *)hdr)->FileNameOffset); + *off = max_t(unsigned short int, +le16_to_cpu (((struct smb2_query_directory_req *)hdr)->FileNameOffset), + offsetof(struct smb2_query_directory_req , Buffer)); *len =le16_to_cpu (((struct smb2_query_directory_req *)hdr)->FileNameLength);break ;case SMB2_LOCK :
@@ -171,7 +178,9 @@ static int smb2_get_data_area_len(unsigned int *off, unsigned int *len,break ; }case SMB2_IOCTL : - *off =le32_to_cpu (((struct smb2_ioctl_req *)hdr)->InputOffset); + *off = max_t(unsigned int, +le32_to_cpu (((struct smb2_ioctl_req *)hdr)->InputOffset), + offsetof(struct smb2_ioctl_req , Buffer)); *len =le32_to_cpu (((struct smb2_ioctl_req *)hdr)->InputCount);break ;default :
fs/smb/server/smb2pdu.c +26 -22
192 lines not on this page · raw message
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 197/432 virtio: Define feature bit for administration virtqueue
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Liu <[email protected]>
[ Upstream commit 838bebb4c926a573839ff1bfe1b654a6ed0f9779 ]
Introduce VIRTIO_F_ADMIN_VQ which is used for administration virtqueue support.
Stable-dep-of: 310227f42882 ("virtio: reenable config if freezing device failed")
--- include/uapi/linux/virtio_config.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
include/uapi/linux/virtio_config.h +7 -1
@@ -52,7 +52,7 @@* rest are per-device feature bits. */ #define VIRTIO_TRANSPORT_F_START 28 -#define VIRTIO_TRANSPORT_F_END 41 +#define VIRTIO_TRANSPORT_F_END 42#ifndef VIRTIO_CONFIG_NO_LEGACY /* Do we get callbacks when the ring is completely used, even if we've
@@ -114,4 +114,10 @@* This feature indicates that the driver can reset a queue individually. */ #define VIRTIO_F_RING_RESET 40 + +/* +* This feature indicates that the device support administration virtqueues. +*/ +#define VIRTIO_F_ADMIN_VQ 41 +#endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 198/432 virtio: reenable config if freezing device failed
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
[ Upstream commit 310227f42882c52356b523e2f4e11690eebcd2ab ]
Currently, we don't reenable the config if freezing the device failed.
For example, virtio-mem currently doesn't support suspend+resume, and trying to freeze the device will always fail. Afterwards, the device will no longer respond to resize requests, because it won't get notified about config changes.
Let's fix this by re-enabling the config if freezing fails.
Message-Id: <[email protected]>
--- drivers/virtio/virtio.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/virtio/virtio.c +8 -2
@@ -489,13 +489,19 @@ EXPORT_SYMBOL_GPL(unregister_virtio_device);int virtio_device_freeze (struct virtio_device *dev) {struct virtio_driver *drv =drv_to_virtio (dev->dev.driver); +int ret;virtio_config_disable (dev); dev->failed = dev->config->get_status (dev) &VIRTIO_CONFIG_S_FAILED ; -if (drv && drv->freeze) -return drv->freeze (dev); +if (drv && drv->freeze) { + ret = drv->freeze (dev); +if (ret) { +virtio_config_enable (dev); +return ret; + } + }return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 199/432 LoongArch: Change __my_cpu_offset definition to avoid mis-optimization
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
[ Upstream commit c87e12e0e8c1241410e758e181ca6bf23efa5b5b ]
Quoted 1 line
From GCC commit
3f13154553f8546a("df-scan: remove ad-hoc handling of
global regs in asms"), global registers will no longer be forced to add to the def-use chain. Then current_thread_info(), current_stack_pointer and __my_cpu_offset may be lifted out of the loop because they are no longer treated as "volatile variables".
This optimization is still correct for the current_thread_info() and current_stack_pointer usages because they are associated to a thread. However it is wrong for __my_cpu_offset because it is associated to a CPU rather than a thread: if the thread migrates to a different CPU in the loop, __my_cpu_offset should be changed.
Change __my_cpu_offset definition to treat it as a "volatile variable", in order to avoid such a mis-optimization.
--- arch/loongarch/include/asm/percpu.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/loongarch/include/asm/percpu.h +6 -1
@@ -29,7 +29,12 @@ static inline void set_my_cpu_offset(unsigned long off) __my_cpu_offset = off;csr_write64 (off,PERCPU_BASE_KS ); } -#define __my_cpu_offset __my_cpu_offset + +#define __my_cpu_offset \ +({ \ + __asm__ __volatile__("":"+r"(__my_cpu_offset)); \ + __my_cpu_offset; \ +})#define PERCPU_OP (op, asm_op, c_op) \ static __always_inline unsigned long __percpu_##op(void *ptr, \
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 200/432 LoongArch: Define the __io_aw() hook as mmiowb()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
[ Upstream commit 9c68ece8b2a5c5ff9b2fcaea923dd73efeb174cd ]
Commit fb24ea52f78e0d595852e ("drivers: Remove explicit invocations of mmiowb()") remove all mmiowb() in drivers, but it says:
"NOTE: mmiowb() has only ever guaranteed ordering in conjunction with spin_unlock(). However, pairing each mmiowb() removal in this patch with the corresponding call to spin_unlock() is not at all trivial, so there is a small chance that this change may regress any drivers incorrectly relying on mmiowb() to order MMIO writes between CPUs using lock-free synchronisation."
The mmio in radeon_ring_commit() is protected by a mutex rather than a spinlock, but in the mutex fastpath it behaves similar to spinlock. We can add mmiowb() calls in the radeon driver but the maintainer says he doesn't like such a workaround, and radeon is not the only example of mutex protected mmio.
So we should extend the mmiowb tracking system from spinlock to mutex, and maybe other locking primitives. This is not easy and error prone, so we solve it in the architectural code, by simply defining the __io_aw() hook as mmiowb(). And we no longer need to override queued_spin_unlock() so use the generic definition.
Without this, we get such an error when run 'glxgears' on weak ordering architectures such as LoongArch:
radeon 0000:04:00.0: ring 0 stalled for more than 10324msec
radeon 0000:04:00.0: ring 3 stalled for more than 10240msec
radeon 0000:04:00.0: GPU lockup (current fence id 0x000000000001f412 last fence id 0x000000000001f414 on ring 3) radeon 0000:04:00.0: GPU lockup (current fence id 0x000000000000f940 last fence id 0x000000000000f941 on ring 0) radeon 0000:04:00.0: scheduling IB failed (-35).
[drm:radeon_gem_va_ioctl [radeon]] *ERROR* Couldn't update BO_VA (-35)
radeon 0000:04:00.0: scheduling IB failed (-35).
[drm:radeon_gem_va_ioctl [radeon]] *ERROR* Couldn't update BO_VA (-35)
radeon 0000:04:00.0: scheduling IB failed (-35).
[drm:radeon_gem_va_ioctl [radeon]] *ERROR* Couldn't update BO_VA (-35)
radeon 0000:04:00.0: scheduling IB failed (-35).
[drm:radeon_gem_va_ioctl [radeon]] *ERROR* Couldn't update BO_VA (-35)
radeon 0000:04:00.0: scheduling IB failed (-35).
[drm:radeon_gem_va_ioctl [radeon]] *ERROR* Couldn't update BO_VA (-35)
radeon 0000:04:00.0: scheduling IB failed (-35).
[drm:radeon_gem_va_ioctl [radeon]] *ERROR* Couldn't update BO_VA (-35)
radeon 0000:04:00.0: scheduling IB failed (-35).
[drm:radeon_gem_va_ioctl [radeon]] *ERROR* Couldn't update BO_VA (-35)
--- arch/loongarch/include/asm/Kbuild | 1 + arch/loongarch/include/asm/io.h | 2 ++ arch/loongarch/include/asm/qspinlock.h | 18 ------------------ 3 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 arch/loongarch/include/asm/qspinlock.h
arch/loongarch/include/asm/Kbuild +1 -0
@@ -4,6 +4,7 @@ generic-y += mcs_spinlock.h generic-y += parport.h generic-y += early_ioremap.h generic-y += qrwlock.h +generic-y += qspinlock.h generic-y += rwsem.h generic-y += segment.h generic-y += user.h
arch/loongarch/include/asm/io.h +2 -0
@@ -71,6 +71,8 @@ extern void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t#define memcpy_fromio (a, c, l) __memcpy_fromio((a), (c), (l))#define memcpy_toio (c, a, l) __memcpy_toio((c), (a), (l)) +#define __io_aw () mmiowb() +#include <asm-generic/io.h> #define ARCH_HAS_VALID_PHYS_ADDR_RANGE
arch/loongarch/include/asm/qspinlock.h deleted +0 -18
@@ -1,18 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _ASM_QSPINLOCK_H -#define _ASM_QSPINLOCK_H - -#include <asm-generic/qspinlock_types.h> - -#define queued_spin_unlock queued_spin_unlock - -static inline void queued_spin_unlock (struct qspinlock *lock) -{ -compiletime_assert_atomic_type (lock->locked); -c_sync (); -WRITE_ONCE (lock->locked,0 ); -} - -#include <asm-generic/qspinlock.h> - -#endif /* _ASM_QSPINLOCK_H */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 201/432 LoongArch/crypto: Clean up useless assignment operations
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuli Wang <[email protected]>
[ Upstream commit fea1c949f6ca5059e12de00d0483645debc5b206 ]
The LoongArch CRC32 hw acceleration is based on arch/mips/crypto/ crc32-mips.c. While the MIPS code supports both MIPS32 and MIPS64, but LoongArch32 lacks the CRC instruction. As a result, the line "len -= sizeof(u32)" is unnecessary.
Removing it can make context code style more unified and improve code readability.
--- arch/loongarch/crypto/crc32-loongarch.c | 2 -- 1 file changed, 2 deletions(-)
arch/loongarch/crypto/crc32-loongarch.c +0 -2
@@ -44,7 +44,6 @@ static u32 crc32_loongarch_hw(u32 crc_, const u8 *p, unsigned int len)CRC32 (crc, value, w); p +=sizeof (u32); - len -=sizeof (u32); }if (len &sizeof (u16)) {
@@ -80,7 +79,6 @@ static u32 crc32c_loongarch_hw(u32 crc_, const u8 *p, unsigned int len)CRC32C (crc, value, w); p +=sizeof (u32); - len -=sizeof (u32); }if (len &sizeof (u16)) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 202/432 wireguard: netlink: check for dangling peer via is_dead instead of empty list
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason A. Donenfeld <[email protected]>
[ Upstream commit 55b6c738673871c9b0edae05d0c97995c1ff08c4 ]
If all peers are removed via wg_peer_remove_all(), rather than setting peer_list to empty, the peer is added to a temporary list with a head on the stack of wg_peer_remove_all(). If a netlink dump is resumed and the cursored peer is one that has been removed via wg_peer_remove_all(), it will iterate from that peer and then attempt to dump freed peers.
Fix this by instead checking peer->is_dead, which was explictly created for this purpose. Also move up the device_update_lock lockdep assertion, since reading is_dead relies on that.
It can be reproduced by a small script like:
echo "Setting config..."
ip link add dev wg0 type wireguard
wg setconf wg0 /big-config
(
while true; do
echo "Showing config..."
wg showconf wg0 > /dev/null
done
) &
sleep 4
wg setconf wg0 <(printf "[Peer]\nPublicKey=$(wg genkey)\n")
Resulting in:
BUG: KASAN: slab-use-after-free in __lock_acquire+0x182a/0x1b20
Read of size 8 at addr ffff88811956ec70 by task wg/59
CPU: 2 PID: 59 Comm: wg Not tainted 6.8.0-rc2-debug+ #5
Call Trace:
<TASK>
dump_stack_lvl+0x47/0x70
print_address_description.constprop.0+0x2c/0x380
print_report+0xab/0x250
kasan_report+0xba/0xf0
__lock_acquire+0x182a/0x1b20
lock_acquire+0x191/0x4b0
down_read+0x80/0x440
get_peer+0x140/0xcb0
wg_get_device_dump+0x471/0x1130--- drivers/net/wireguard/netlink.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireguard/netlink.c +3 -3
@@ -255,17 +255,17 @@ static int wg_get_device_dump(struct sk_buff *skb, struct netlink_callback *cb)if (!peers_nest) goto out; ret =0 ; -/* If the last cursor was removed via list_del_init in peer_remove, then +lockdep_assert_held (&wg->device_update_lock); +/* If the last cursor was removed in peer_remove or peer_remove_all, then * we just treat this the same as there being no more peers left. The * reason is that seq_nr should indicate to userspace that this isn't a * coherent dump anyway, so they'll try again. */ if (list_empty (&wg->peer_list) || - (ctx->next_peer &&list_empty (&ctx->next_peer->peer_list))) { + (ctx->next_peer && ctx->next_peer->is_dead)) {nla_nest_cancel (skb, peers_nest); goto out; } -lockdep_assert_held (&wg->device_update_lock); peer =list_prepare_entry (ctx->next_peer, &wg->peer_list, peer_list);list_for_each_entry_continue (peer, &wg->peer_list, peer_list) {if (get_peer (peer, skb, ctx)) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 203/432 wireguard: netlink: access device through ctx instead of peer
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason A. Donenfeld <[email protected]>
[ Upstream commit 71cbd32e3db82ea4a74e3ef9aeeaa6971969c86f ]
The previous commit fixed a bug that led to a NULL peer->device being dereferenced. It's actually easier and faster performance-wise to instead get the device from ctx->wg. This semantically makes more sense too, since ctx->wg->peer_allowedips.seq is compared with ctx->allowedips_seq, basing them both in ctx. This also acts as a defence in depth provision against freed peers.
--- drivers/net/wireguard/netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireguard/netlink.c +2 -2
@@ -164,8 +164,8 @@ get_peer(struct wg_peer *peer, struct sk_buff *skb, struct dump_ctx *ctx)if (!allowedips_node) goto no_allowedips;if (!ctx->allowedips_seq) - ctx->allowedips_seq = peer->device->peer_allowedips.seq; -else if (ctx->allowedips_seq != peer->device->peer_allowedips.seq) + ctx->allowedips_seq = ctx->wg->peer_allowedips.seq; +else if (ctx->allowedips_seq != ctx->wg->peer_allowedips.seq) goto no_allowedips; allowedips_nest =nla_nest_start (skb,WGPEER_A_ALLOWEDIPS );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 204/432 wireguard: selftests: set RISCV_ISA_FALLBACK on riscv{32,64}
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason A. Donenfeld <[email protected]>
[ Upstream commit e995f5dd9a9cef818af32ec60fc38d68614afd12 ]
This option is needed to continue booting with QEMU. Recent changes that made this optional meant that it gets unset in the test harness, and so WireGuard CI has been broken. Fix this by simply setting this option.
--- tools/testing/selftests/wireguard/qemu/arch/riscv32.config | 1 + tools/testing/selftests/wireguard/qemu/arch/riscv64.config | 1 + 2 files changed, 2 insertions(+)
tools/testing/selftests/wireguard/qemu/arch/riscv32.config +1 -0
@@ -3,6 +3,7 @@ CONFIG_ARCH_RV32I=y CONFIG_MMU=y CONFIG_FPU=y CONFIG_SOC_VIRT=y +CONFIG_RISCV_ISA_FALLBACK=y CONFIG_SERIAL_8250=y CONFIG_SERIAL_8250_CONSOLE=y CONFIG_SERIAL_OF_PLATFORM=y
tools/testing/selftests/wireguard/qemu/arch/riscv64.config +1 -0
@@ -2,6 +2,7 @@ CONFIG_ARCH_RV64I=y CONFIG_MMU=y CONFIG_FPU=y CONFIG_SOC_VIRT=y +CONFIG_RISCV_ISA_FALLBACK=y CONFIG_SERIAL_8250=y CONFIG_SERIAL_8250_CONSOLE=y CONFIG_SERIAL_OF_PLATFORM=y
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 205/432 ahci: asm1064: correct count of reported ports
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Jr. Melnikov <[email protected]>
[ Upstream commit 9815e39617541ef52d0dfac4be274ad378c6dc09 ]
The ASM1064 SATA host controller always reports wrongly, that it has 24 ports. But in reality, it only has four ports.
before:
ahci 0000:04:00.0: SSS flag set, parallel bus scan disabled
ahci 0000:04:00.0: AHCI 0001.0301 32 slots 24 ports 6 Gbps 0xffff0f impl SATA mode ahci 0000:04:00.0: flags: 64bit ncq sntf stag pm led only pio sxs deso sadm sds apst
after:
ahci 0000:04:00.0: ASM1064 has only four ports
ahci 0000:04:00.0: forcing port_map 0xffff0f -> 0xf
ahci 0000:04:00.0: SSS flag set, parallel bus scan disabled
ahci 0000:04:00.0: AHCI 0001.0301 32 slots 24 ports 6 Gbps 0xf impl SATA mode ahci 0000:04:00.0: flags: 64bit ncq sntf stag pm led only pio sxs deso sadm sds apst
Stable-dep-of: 6cd8adc3e189 ("ahci: asm1064: asm1166: don't limit reported ports")
--- drivers/ata/ahci.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/ata/ahci.c +11 -3
@@ -671,9 +671,17 @@ MODULE_PARM_DESC(mobile_lpm_policy, "Default LPM policy for mobile chipsets");static void ahci_pci_save_initial_config (struct pci_dev *pdev,struct ahci_host_priv *hpriv) { -if (pdev->vendor ==PCI_VENDOR_ID_ASMEDIA && pdev->device ==0x1166 ) { -dev_info (&pdev->dev,"ASM1166 has only six ports\n" ); - hpriv->saved_port_map =0x3f ; +if (pdev->vendor ==PCI_VENDOR_ID_ASMEDIA ) { +switch (pdev->device) { +case 0x1166 : +dev_info (&pdev->dev,"ASM1166 has only six ports\n" ); + hpriv->saved_port_map =0x3f ; +break ; +case 0x1064 : +dev_info (&pdev->dev,"ASM1064 has only four ports\n" ); + hpriv->saved_port_map =0xf ; +break ; + } }if (pdev->vendor ==PCI_VENDOR_ID_JMICRON && pdev->device ==0x2361 ) {
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 206/432 ahci: asm1064: asm1166: dont limit reported ports
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Conrad Kostecki <[email protected]>
[ Upstream commit 6cd8adc3e18960f6e59d797285ed34ef473cc896 ]
Previously, patches have been added to limit the reported count of SATA ports for asm1064 and asm1166 SATA controllers, as those controllers do report more ports than physically having.
While it is allowed to report more ports than physically having in CAP.NP, it is not allowed to report more ports than physically having in the PI (Ports Implemented) register, which is what these HBAs do. (This is a AHCI spec violation.)
Unfortunately, it seems that the PMP implementation in these ASMedia HBAs is also violating the AHCI and SATA-IO PMP specification.
What these HBAs do is that they do not report that they support PMP (CAP.SPM (Supports Port Multiplier) is not set).
Instead, they have decided to add extra "virtual" ports in the PI register that is used if a port multiplier is connected to any of the physical ports of the HBA.
Enumerating the devices behind the PMP as specified in the AHCI and SATA-IO specifications, by using PMP READ and PMP WRITE commands to the physical ports of the HBA is not possible, you have to use the "virtual" ports.
This is of course bad, because this gives us no way to detect the device and vendor ID of the PMP actually connected to the HBA, which means that we can not apply the proper PMP quirks for the PMP that is connected to the HBA.
Limiting the port map will thus stop these controllers from working with SATA Port Multipliers.
This patch reverts both patches for asm1064 and asm1166, so old behavior is restored and SATA PMP will work again, but it will also reintroduce the (minutes long) extra boot time for the ASMedia controllers that do not have a PMP connected (either on the PCIe card itself, or an external PMP).
However, a longer boot time for some, is the lesser evil compared to some other users not being able to detect their drives at all.
--- drivers/ata/ahci.c | 13 ------------- 1 file changed, 13 deletions(-)
drivers/ata/ahci.c +0 -13
@@ -671,19 +671,6 @@ MODULE_PARM_DESC(mobile_lpm_policy, "Default LPM policy for mobile chipsets");static void ahci_pci_save_initial_config (struct pci_dev *pdev,struct ahci_host_priv *hpriv) { -if (pdev->vendor ==PCI_VENDOR_ID_ASMEDIA ) { -switch (pdev->device) { -case 0x1166 : -dev_info (&pdev->dev,"ASM1166 has only six ports\n" ); - hpriv->saved_port_map =0x3f ; -break ; -case 0x1064 : -dev_info (&pdev->dev,"ASM1064 has only four ports\n" ); - hpriv->saved_port_map =0xf ; -break ; - } - } -if (pdev->vendor ==PCI_VENDOR_ID_JMICRON && pdev->device ==0x2361 ) {dev_info (&pdev->dev,"JMB361 has only one port\n" ); hpriv->saved_port_map =1 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 207/432 drm/amd/display: Change default size for dummy plane in DML2
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Swapnil Patel <[email protected]>
[ Upstream commit 75eb8f7df65c5e6eb22a5aff8deb60ce0b65de1a ]
[WHY & HOW]
Currently, to map dc states into dml_display_cfg,
We create a dummy plane if the stream doesn't have any planes attached to it. This dummy plane uses max addersable width height. This results in certain mode validations failing when they shouldn't.
--- .../display/dc/dml2/dml2_translation_helper.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dml2/dml2_translation_helper.c +15 -3
@@ -824,13 +824,25 @@ static struct scaler_data get_scaler_data_for_plane(const struct dc_plane_statestatic void populate_dummy_dml_plane_cfg (struct dml_plane_cfg_st *out,unsigned int location,const struct dc_stream_state *in) { +dml_uint_t width, height; + +if (in->timing.h_addressable >3840 ) + width =3840 ; +else + width = in->timing.h_addressable;// 4K max + +if (in->timing.v_addressable >2160 ) + height =2160 ; +else + height = in->timing.v_addressable;// 4K max + out->CursorBPP[location] = dml_cur_32bit; out->CursorWidth[location] =256 ; out->GPUVMMinPageSizeKBytes[location] =256 ; - out->ViewportWidth[location] = in->timing.h_addressable; - out->ViewportHeight[location] = in->timing.v_addressable; + out->ViewportWidth[location] = width; + out->ViewportHeight[location] = height; out->ViewportStationary[location] = false; out->ViewportWidthChroma[location] =0 ; out->ViewportHeightChroma[location] =0 ;
@@ -849,7 +861,7 @@ static void populate_dummy_dml_plane_cfg(struct dml_plane_cfg_st *out, unsigned out->HTapsChroma[location] =0 ; out->VTapsChroma[location] =0 ; out->SourceScan[location] = dml_rotation_0; - out->ScalerRecoutWidth[location] = in->timing.h_addressable; + out->ScalerRecoutWidth[location] = width; out->LBBitPerPixel[location] =57 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 208/432 drm/amdgpu: amdgpu_ttm_gart_bind set gtt bound flag
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Philip Yang <[email protected]>
[ Upstream commit 6c6064cbe58b43533e3451ad6a8ba9736c109ac3 ]
Otherwise after the GTT bo is released, the GTT and gart space is freed but amdgpu_ttm_backend_unbind will not clear the gart page table entry and leave valid mapping entry pointing to the stale system page. Then if GPU access the gart address mistakely, it will read undefined value instead page fault, harder to debug and reproduce the real issue.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
@@ -869,6 +869,7 @@ static void amdgpu_ttm_gart_bind(struct amdgpu_device *adev,amdgpu_gart_bind (adev, gtt->offset, ttm->num_pages, gtt->ttm.dma_address, flags); } + gtt->bound = true; }/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 209/432 drm/amdgpu/pm: Fix NULL pointer dereference when get power limit
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Jun <[email protected]>
[ Upstream commit 08ae9ef829b8055c2fdc8cfee37510c1f4721a07 ]
Because powerplay_table initialization is skipped under sriov case, We check and set default lower and upper OD value if powerplay_table is NULL.
--- .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 14 ++++++++------ drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 16 +++++++++------- .../drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 14 ++++++++------ .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 14 ++++++++------ .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 14 ++++++++------ 5 files changed, 41 insertions(+), 31 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +8 -6
@@ -1286,7 +1286,7 @@ static int arcturus_get_power_limit(struct smu_context *smu,struct smu_11_0_powerplay_table *powerplay_table = (struct smu_11_0_powerplay_table *)smu->smu_table.power_play_table;PPTable_t *pptable = smu->smu_table.driver_pptable; -uint32_t power_limit, od_percent_upper, od_percent_lower; +uint32_t power_limit, od_percent_upper =0 , od_percent_lower =0 ;if (smu_v11_0_get_current_power_limit (smu, &power_limit)) {/* the last hope to figure out the ppt limit */
@@ -1303,12 +1303,14 @@ static int arcturus_get_power_limit(struct smu_context *smu,if (default_power_limit) *default_power_limit = power_limit; -if (smu->od_enabled) - od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); -else - od_percent_upper =0 ; +if (powerplay_table) { +if (smu->od_enabled) + od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); +else + od_percent_upper =0 ; - od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); + }dev_dbg (smu->adev->dev,"od percent upper:%d, od percent lower:%d (default power: %d)\n" , od_percent_upper, od_percent_lower, power_limit);
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +9 -7
@@ -2339,7 +2339,7 @@ static int navi10_get_power_limit(struct smu_context *smu, (struct smu_11_0_powerplay_table *)smu->smu_table.power_play_table;struct smu_11_0_overdrive_table *od_settings = smu->od_settings;PPTable_t *pptable = smu->smu_table.driver_pptable; -uint32_t power_limit, od_percent_upper, od_percent_lower; +uint32_t power_limit, od_percent_upper =0 , od_percent_lower =0 ;if (smu_v11_0_get_current_power_limit (smu, &power_limit)) {/* the last hope to figure out the ppt limit */
@@ -2356,13 +2356,15 @@ static int navi10_get_power_limit(struct smu_context *smu,if (default_power_limit) *default_power_limit = power_limit; -if (smu->od_enabled && -navi10_od_feature_is_supported (od_settings,SMU_11_0_ODCAP_POWER_LIMIT )) - od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); -else - od_percent_upper =0 ; +if (powerplay_table) { +if (smu->od_enabled && +navi10_od_feature_is_supported (od_settings,SMU_11_0_ODCAP_POWER_LIMIT )) + od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); +else + od_percent_upper =0 ; - od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); + }dev_dbg (smu->adev->dev,"od percent upper:%d, od percent lower:%d (default power: %d)\n" , od_percent_upper, od_percent_lower, power_limit);
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +8 -6
@@ -625,7 +625,7 @@ static int sienna_cichlid_get_power_limit(struct smu_context *smu, {struct smu_11_0_7_powerplay_table *powerplay_table = (struct smu_11_0_7_powerplay_table *)smu->smu_table.power_play_table; -uint32_t power_limit, od_percent_upper, od_percent_lower; +uint32_t power_limit, od_percent_upper =0 , od_percent_lower =0 ;uint16_t *table_member;GET_PPTABLE_MEMBER (SocketPowerLimitAc, &table_member);
@@ -640,12 +640,14 @@ static int sienna_cichlid_get_power_limit(struct smu_context *smu,if (default_power_limit) *default_power_limit = power_limit; -if (smu->od_enabled) - od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_11_0_7_ODSETTING_POWERPERCENTAGE ]); -else - od_percent_upper =0 ; +if (powerplay_table) { +if (smu->od_enabled) + od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_11_0_7_ODSETTING_POWERPERCENTAGE ]); +else + od_percent_upper =0 ; - od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_7_ODSETTING_POWERPERCENTAGE ]); + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_7_ODSETTING_POWERPERCENTAGE ]); + }dev_dbg (smu->adev->dev,"od percent upper:%d, od percent lower:%d (default power: %d)\n" , od_percent_upper, od_percent_lower, power_limit);
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +8 -6
@@ -2351,7 +2351,7 @@ static int smu_v13_0_0_get_power_limit(struct smu_context *smu, (struct smu_13_0_0_powerplay_table *)table_context->power_play_table;PPTable_t *pptable = table_context->driver_pptable;SkuTable_t *skutable = &pptable->SkuTable; -uint32_t power_limit, od_percent_upper, od_percent_lower; +uint32_t power_limit, od_percent_upper =0 , od_percent_lower =0 ;uint32_t msg_limit = skutable->MsgLimits.Power[PPT_THROTTLER_PPT0 ][POWER_SOURCE_AC ];if (smu_v13_0_get_current_power_limit (smu, &power_limit))
@@ -2364,12 +2364,14 @@ static int smu_v13_0_0_get_power_limit(struct smu_context *smu,if (default_power_limit) *default_power_limit = power_limit; -if (smu->od_enabled) - od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_13_0_0_ODSETTING_POWERPERCENTAGE ]); -else - od_percent_upper =0 ; +if (powerplay_table) { +if (smu->od_enabled) + od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_13_0_0_ODSETTING_POWERPERCENTAGE ]); +else + od_percent_upper =0 ; - od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_13_0_0_ODSETTING_POWERPERCENTAGE ]); + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_13_0_0_ODSETTING_POWERPERCENTAGE ]); + }dev_dbg (smu->adev->dev,"od percent upper:%d, od percent lower:%d (default power: %d)\n" , od_percent_upper, od_percent_lower, power_limit);
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +8 -6
@@ -2315,7 +2315,7 @@ static int smu_v13_0_7_get_power_limit(struct smu_context *smu, (struct smu_13_0_7_powerplay_table *)table_context->power_play_table;PPTable_t *pptable = table_context->driver_pptable;SkuTable_t *skutable = &pptable->SkuTable; -uint32_t power_limit, od_percent_upper, od_percent_lower; +uint32_t power_limit, od_percent_upper =0 , od_percent_lower =0 ;uint32_t msg_limit = skutable->MsgLimits.Power[PPT_THROTTLER_PPT0 ][POWER_SOURCE_AC ];if (smu_v13_0_get_current_power_limit (smu, &power_limit))
@@ -2328,12 +2328,14 @@ static int smu_v13_0_7_get_power_limit(struct smu_context *smu,if (default_power_limit) *default_power_limit = power_limit; -if (smu->od_enabled) - od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_13_0_7_ODSETTING_POWERPERCENTAGE ]); -else - od_percent_upper =0 ; +if (powerplay_table) { +if (smu->od_enabled) + od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_13_0_7_ODSETTING_POWERPERCENTAGE ]); +else + od_percent_upper =0 ; - od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_13_0_7_ODSETTING_POWERPERCENTAGE ]); + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_13_0_7_ODSETTING_POWERPERCENTAGE ]); + }dev_dbg (smu->adev->dev,"od percent upper:%d, od percent lower:%d (default power: %d)\n" , od_percent_upper, od_percent_lower, power_limit);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 210/432 drm/amdgpu/pm: Check the validity of overdiver power limit
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Jun <[email protected]>
[ Upstream commit e17718251addb31e1771fd28735ec410e6ca650a ]
Check the validity of overdriver power limit before using it.
--- .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 11 +++++---- .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 9 ++++---- .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 23 +++++++++++-------- .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 10 ++++---- .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 10 ++++---- 5 files changed, 37 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +7 -4
@@ -1285,6 +1285,7 @@ static int arcturus_get_power_limit(struct smu_context *smu, {struct smu_11_0_powerplay_table *powerplay_table = (struct smu_11_0_powerplay_table *)smu->smu_table.power_play_table; +struct smu_11_0_overdrive_table *od_settings = smu->od_settings;PPTable_t *pptable = smu->smu_table.driver_pptable;uint32_t power_limit, od_percent_upper =0 , od_percent_lower =0 ;
@@ -1304,12 +1305,14 @@ static int arcturus_get_power_limit(struct smu_context *smu, *default_power_limit = power_limit;if (powerplay_table) { -if (smu->od_enabled) +if (smu->od_enabled && + od_settings->cap[SMU_11_0_ODCAP_POWER_LIMIT ]) { od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); -else + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); + }else if (od_settings->cap[SMU_11_0_ODCAP_POWER_LIMIT ]) { od_percent_upper =0 ; - - od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); + } } dev_dbg(smu->adev->dev, "od percent upper:%d, od percent lower:%d (default power: %d)\n",
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +5 -4
@@ -2358,12 +2358,13 @@ static int navi10_get_power_limit(struct smu_context *smu,if (powerplay_table) {if (smu->od_enabled && -navi10_od_feature_is_supported (od_settings,SMU_11_0_ODCAP_POWER_LIMIT )) +navi10_od_feature_is_supported (od_settings,SMU_11_0_ODCAP_POWER_LIMIT )) { od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); -else + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); + }else if (navi10_od_feature_is_supported (od_settings,SMU_11_0_ODCAP_POWER_LIMIT )) { od_percent_upper =0 ; - - od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_ODSETTING_POWERPERCENTAGE ]); + } } dev_dbg(smu->adev->dev, "od percent upper:%d, od percent lower:%d (default power: %d)\n",
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +13 -10
@@ -617,6 +617,12 @@ static uint32_t sienna_cichlid_get_throttler_status_locked(struct smu_context *sreturn throttler_status; } +static bool sienna_cichlid_is_od_feature_supported (struct smu_11_0_7_overdrive_table *od_table, +enum SMU_11_0_7_ODFEATURE_CAP cap) +{ +return od_table->cap[cap]; +} + static int sienna_cichlid_get_power_limit(struct smu_context *smu, uint32_t *current_power_limit, uint32_t *default_power_limit,
@@ -625,6 +631,7 @@ static int sienna_cichlid_get_power_limit(struct smu_context *smu, {struct smu_11_0_7_powerplay_table *powerplay_table = (struct smu_11_0_7_powerplay_table *)smu->smu_table.power_play_table; +struct smu_11_0_7_overdrive_table *od_settings = smu->od_settings;uint32_t power_limit, od_percent_upper =0 , od_percent_lower =0 ;uint16_t *table_member;
@@ -641,12 +648,14 @@ static int sienna_cichlid_get_power_limit(struct smu_context *smu, *default_power_limit = power_limit;if (powerplay_table) { -if (smu->od_enabled) +if (smu->od_enabled && +sienna_cichlid_is_od_feature_supported (od_settings,SMU_11_0_7_ODCAP_POWER_LIMIT )) { od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_11_0_7_ODSETTING_POWERPERCENTAGE ]); -else + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_7_ODSETTING_POWERPERCENTAGE ]); + }else if ((sienna_cichlid_is_od_feature_supported (od_settings,SMU_11_0_7_ODCAP_POWER_LIMIT ))) { od_percent_upper =0 ; - - od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_7_ODSETTING_POWERPERCENTAGE ]); + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_11_0_7_ODSETTING_POWERPERCENTAGE ]); + } } dev_dbg(smu->adev->dev, "od percent upper:%d, od percent lower:%d (default power: %d)\n",
@@ -1252,12 +1261,6 @@ static bool sienna_cichlid_is_support_fine_grained_dpm(struct smu_context *smu,return dpm_desc->SnapToDiscrete ==0 ; } -static bool sienna_cichlid_is_od_feature_supported (struct smu_11_0_7_overdrive_table *od_table, -enum SMU_11_0_7_ODFEATURE_CAP cap) -{ -return od_table->cap[cap]; -} -static void sienna_cichlid_get_od_setting_range (struct smu_11_0_7_overdrive_table *od_table,enum SMU_11_0_7_ODSETTING_ID setting,uint32_t *min,uint32_t *max)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +6 -4
@@ -2365,12 +2365,14 @@ static int smu_v13_0_0_get_power_limit(struct smu_context *smu, *default_power_limit = power_limit;if (powerplay_table) { -if (smu->od_enabled) +if (smu->od_enabled && +smu_v13_0_0_is_od_feature_supported (smu,PP_OD_FEATURE_PPT_BIT )) { od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_13_0_0_ODSETTING_POWERPERCENTAGE ]); -else + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_13_0_0_ODSETTING_POWERPERCENTAGE ]); + }else if (smu_v13_0_0_is_od_feature_supported (smu,PP_OD_FEATURE_PPT_BIT )) { od_percent_upper =0 ; - - od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_13_0_0_ODSETTING_POWERPERCENTAGE ]); + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_13_0_0_ODSETTING_POWERPERCENTAGE ]); + } } dev_dbg(smu->adev->dev, "od percent upper:%d, od percent lower:%d (default power: %d)\n",
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +6 -4
@@ -2329,12 +2329,14 @@ static int smu_v13_0_7_get_power_limit(struct smu_context *smu, *default_power_limit = power_limit;if (powerplay_table) { -if (smu->od_enabled) +if (smu->od_enabled && + (smu_v13_0_7_is_od_feature_supported (smu,PP_OD_FEATURE_PPT_BIT ))) { od_percent_upper =le32_to_cpu (powerplay_table->overdrive_table.max[SMU_13_0_7_ODSETTING_POWERPERCENTAGE ]); -else + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_13_0_7_ODSETTING_POWERPERCENTAGE ]); + }else if (smu_v13_0_7_is_od_feature_supported (smu,PP_OD_FEATURE_PPT_BIT )) { od_percent_upper =0 ; - - od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_13_0_7_ODSETTING_POWERPERCENTAGE ]); + od_percent_lower =le32_to_cpu (powerplay_table->overdrive_table.min[SMU_13_0_7_ODSETTING_POWERPERCENTAGE ]); + } } dev_dbg(smu->adev->dev, "od percent upper:%d, od percent lower:%d (default power: %d)\n",
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 211/432 drm/amd/display: Add ODM check during pipe split/merge validation
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Relja Vojvodic <[email protected]>
[ Upstream commit dd2c5fac91d46df9dc1bf025ef23eff4704bd85f ]
[why]
When querying DML for a vlevel after pipes have been split or merged the ODM policy would revert to a default policy, which could cause the query to use the incorrect ODM status. In this case ODM 2to1 was validated, but the last DML query would assume no ODM and return the incorrect vlevel.
[how]
Added ODM check to apply the correct ODM policy before querying DML.
Stable-dep-of: 26fbcb3da77e ("drm/amd/display: Override min required DCFCLK in dml1_validate")
--- .../drm/amd/display/dc/dcn32/dcn32_resource.h | 2 ++ .../display/dc/dcn32/dcn32_resource_helpers.c | 26 +++++++++++++++++++ .../drm/amd/display/dc/dml/dcn32/dcn32_fpu.c | 3 +++ 3 files changed, 31 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.h +2 -0
@@ -183,6 +183,8 @@ bool dcn32_subvp_drr_admissable(struct dc *dc, struct dc_state *context);bool dcn32_subvp_vblank_admissable (struct dc *dc,struct dc_state *context,int vlevel); +void dcn32_update_dml_pipes_odm_policy_based_on_context (struct dc *dc,struct dc_state *context,display_e2e_pipe_params_st *pipes); +/* definitions for run time init of reg offsets */ /* CLK SRC */
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource_helpers.c +26 -0
@@ -778,3 +778,29 @@ bool dcn32_subvp_vblank_admissable(struct dc *dc, struct dc_state *context, intreturn result; } + +void dcn32_update_dml_pipes_odm_policy_based_on_context (struct dc *dc,struct dc_state *context, +display_e2e_pipe_params_st *pipes) +{ +int i, pipe_cnt; +struct resource_context *res_ctx = &context->res_ctx; +struct pipe_ctx *pipe =NULL ; + +for (i =0 , pipe_cnt =0 ; i < dc->res_pool->pipe_count; i++) { +int odm_slice_count =0 ; + +if (!res_ctx->pipe_ctx[i].stream) +continue ; + pipe = &res_ctx->pipe_ctx[i]; + odm_slice_count =resource_get_odm_slice_count (pipe); + +if (odm_slice_count ==1 ) + pipes[pipe_cnt].pipe.dest.odm_combine_policy = dm_odm_combine_policy_dal; +else if (odm_slice_count ==2 ) + pipes[pipe_cnt].pipe.dest.odm_combine_policy = dm_odm_combine_policy_2to1; +else if (odm_slice_count ==4 ) + pipes[pipe_cnt].pipe.dest.odm_combine_policy = dm_odm_combine_policy_4to1; + + pipe_cnt++; + } +}
drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c +3 -0
@@ -2178,6 +2178,7 @@ bool dcn32_internal_validate_bw(struct dc *dc,int i; pipe_cnt = dc->res_pool->funcs->populate_dml_pipes (dc, context, pipes, fast_validate); +dcn32_update_dml_pipes_odm_policy_based_on_context (dc, context, pipes);/* repopulate_pipes = 1 means the pipes were either split or merged. In this case * we have to re-calculate the DET allocation and run through DML once more to
@@ -2186,7 +2187,9 @@ bool dcn32_internal_validate_bw(struct dc *dc,* */ context->bw_ctx.dml.soc.allow_for_pstate_or_stutter_in_vblank_final = dm_prefetch_support_uclk_fclk_and_stutter_if_possible; + vlevel =dml_get_voltage_level (&context->bw_ctx.dml, pipes, pipe_cnt); +if (vlevel == context->bw_ctx.dml.soc.num_states) {/* failed after DET size changes */ goto validate_fail;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 212/432 drm/amd/display: Override min required DCFCLK in dml1_validate
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sohaib Nadeem <[email protected]>
[ Upstream commit 26fbcb3da77efc77bd7327b7916338d773cca484 ]
[WHY]:
Increasing min DCFCLK addresses underflow issues that occur when phantom pipe is turned on for some Sub-Viewport configs
[HOW]:dcn32_override_min_req_dcfclk is added to override DCFCLK value in dml1_validate when subviewport is being used.
--- drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c | 1 + drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.h | 3 +++ .../gpu/drm/amd/display/dc/dcn32/dcn32_resource_helpers.c | 6 ++++++ 3 files changed, 10 insertions(+)
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c +1 -0
@@ -1866,6 +1866,7 @@ static bool dml1_validate(struct dc *dc, struct dc_state *context, bool fast_val dc->res_pool->funcs->calculate_wm_and_dlg (dc, context, pipes, pipe_cnt, vlevel);dcn32_override_min_req_memclk (dc, context); +dcn32_override_min_req_dcfclk (dc, context);BW_VAL_TRACE_END_WATERMARKS ();
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.h +3 -0
@@ -41,6 +41,7 @@#define SUBVP_HIGH_REFRESH_LIST_LEN 4#define DCN3_2_MAX_SUBVP_PIXEL_RATE_MHZ 1800#define DCN3_2_VMIN_DISPCLK_HZ 717000000 +#define MIN_SUBVP_DCFCLK_KHZ 400000#define TO_DCN32_RES_POOL (pool)\ container_of(pool, struct dcn32_resource_pool, base)
@@ -185,6 +186,8 @@ bool dcn32_subvp_vblank_admissable(struct dc *dc, struct dc_state *context, intvoid dcn32_update_dml_pipes_odm_policy_based_on_context (struct dc *dc,struct dc_state *context,display_e2e_pipe_params_st *pipes); +void dcn32_override_min_req_dcfclk (struct dc *dc,struct dc_state *context); +/* definitions for run time init of reg offsets */ /* CLK SRC */
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource_helpers.c +6 -0
@@ -804,3 +804,9 @@ void dcn32_update_dml_pipes_odm_policy_based_on_context(struct dc *dc, struct dc pipe_cnt++; } } + +void dcn32_override_min_req_dcfclk (struct dc *dc,struct dc_state *context) +{ +if (dcn32_subvp_in_use (dc, context) && context->bw_ctx.bw.dcn.clk.dcfclk_khz <=MIN_SUBVP_DCFCLK_KHZ ) + context->bw_ctx.bw.dcn.clk.dcfclk_khz =MIN_SUBVP_DCFCLK_KHZ ; +}
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 213/432 drm/amd/display: Allow dirty rects to be sent to dmub when abm is active
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josip Pavic <[email protected]>
[ Upstream commit 7fb19d9510937121a1f285894cffd30bc96572e3 ]
[WHY]
It's beneficial for ABM to know when new frame data are available.
[HOW]
Add new condition to allow dirty rects to be sent to DMUB when ABM is active. ABM will use this as a signal that a new frame has arrived.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/dc/core/dc.c +3 -0
@@ -3340,6 +3340,9 @@ static bool dc_dmub_should_send_dirty_rect_cmd(struct dc *dc, struct dc_stream_sif (stream->link->replay_settings.config.replay_supported)return true; +if (stream->ctx->dce_version >=DCN_VERSION_3_5 && stream->abm_level) +return true; +return false; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 214/432 drm/amd/display: Add dml2 copy functions
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dillon Varone <[email protected]>
[ Upstream commit abd26a3252cbd1a3ae4e46d37596d176fe50b41a ]
Add function to handle deep copying dml2 context.
Stable-dep-of: 4f5b8d78ca43 ("drm/amd/display: Init DPPCLK from SMU on dcn32")
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 15 +++------- .../drm/amd/display/dc/dml2/dml2_wrapper.c | 29 ++++++++++++++++++- .../drm/amd/display/dc/dml2/dml2_wrapper.h | 4 +++ 3 files changed, 36 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +4 -11
@@ -2258,23 +2258,16 @@ struct dc_state *dc_copy_state(struct dc_state *src_ctx) {int i, j;struct dc_state *new_ctx =kvmalloc (sizeof (struct dc_state ),GFP_KERNEL ); -#ifdef CONFIG_DRM_AMD_DC_FP -struct dml2_context *dml2 =NULL ; -#endif if (!new_ctx)return NULL ;memcpy (new_ctx, src_ctx,sizeof (struct dc_state ));#ifdef CONFIG_DRM_AMD_DC_FP -if (new_ctx->bw_ctx.dml2) { - dml2 =kzalloc (sizeof (struct dml2_context ),GFP_KERNEL ); -if (!dml2) -return NULL ; - -memcpy (dml2, src_ctx->bw_ctx.dml2,sizeof (struct dml2_context )); - new_ctx->bw_ctx.dml2 = dml2; - } +if (new_ctx->bw_ctx.dml2 && !dml2_create_copy (&new_ctx->bw_ctx.dml2, src_ctx->bw_ctx.dml2)) { +dc_release_state (new_ctx); +return NULL ; + }#endif for (i =0 ; i <MAX_PIPES ; i++) {
drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c +28 -1
@@ -696,10 +696,15 @@ bool dml2_validate(const struct dc *in_dc, struct dc_state *context, bool fast_vreturn out; } +static inline struct dml2_context *dml2_allocate_memory (void ) +{ +return (struct dml2_context *)kzalloc (sizeof (struct dml2_context ),GFP_KERNEL ); +} +bool dml2_create (const struct dc *in_dc,const struct dml2_configuration_options *config,struct dml2_context **dml2) {// Allocate Mode Lib Ctx - *dml2 = (struct dml2_context *)kzalloc (sizeof (struct dml2_context ),GFP_KERNEL ); + *dml2 =dml2_allocate_memory ();if (!(*dml2))return false;
@@ -750,3 +755,25 @@ void dml2_extract_dram_and_fclk_change_support(struct dml2_context *dml2, *fclk_change_support = (unsigned int ) dml2->v20.dml_core_ctx.ms.support.FCLKChangeSupport[0 ]; *dram_clk_change_support = (unsigned int ) dml2->v20.dml_core_ctx.ms.support.DRAMClockChangeSupport[0 ]; } + +void dml2_copy (struct dml2_context *dst_dml2, +struct dml2_context *src_dml2) +{ +/* copy Mode Lib Ctx */ +memcpy (dst_dml2, src_dml2,sizeof (struct dml2_context )); +} + +bool dml2_create_copy (struct dml2_context **dst_dml2, +struct dml2_context *src_dml2) +{ +/* Allocate Mode Lib Ctx */ + *dst_dml2 =dml2_allocate_memory (); + +if (!(*dst_dml2)) +return false; + +/* copy Mode Lib Ctx */ +dml2_copy (*dst_dml2, src_dml2); + +return true; +}
drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.h +4 -0
@@ -191,6 +191,10 @@ bool dml2_create(const struct dc *in_dc, struct dml2_context **dml2);void dml2_destroy (struct dml2_context *dml2); +void dml2_copy (struct dml2_context *dst_dml2, +struct dml2_context *src_dml2); +bool dml2_create_copy (struct dml2_context **dst_dml2, +struct dml2_context *src_dml2);/* * dml2_validate - Determines if a display configuration is supported or not.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 215/432 drm/amd/display: Init DPPCLK from SMU on dcn32
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dillon Varone <[email protected]>
[ Upstream commit 4f5b8d78ca43fcc695ba16c83ebfabbfe09506d6 ]
[WHY & HOW]
DPPCLK ranges should be obtained from the SMU when available.
--- .../display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c | 14 ++++++++++ .../drm/amd/display/dc/dcn32/dcn32_resource.c | 2 ++ .../amd/display/dc/dcn321/dcn321_resource.c | 2 ++ .../drm/amd/display/dc/dml2/dml2_wrapper.c | 28 +++++++++++++------ .../drm/amd/display/dc/dml2/dml2_wrapper.h | 3 ++ 5 files changed, 41 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c +14 -0
@@ -217,6 +217,16 @@ void dcn32_init_clocks(struct clk_mgr *clk_mgr_base)if (clk_mgr_base->bw_params->dc_mode_limit.dispclk_mhz >1950 ) clk_mgr_base->bw_params->dc_mode_limit.dispclk_mhz =1950 ; +/* DPPCLK */ +dcn32_init_single_clock (clk_mgr,PPCLK_DPPCLK , + &clk_mgr_base->bw_params->clk_table.entries[0 ].dppclk_mhz, + &num_entries_per_clk->num_dppclk_levels); + num_levels = num_entries_per_clk->num_dppclk_levels; + clk_mgr_base->bw_params->dc_mode_limit.dppclk_mhz =dcn30_smu_get_dc_mode_max_dpm_freq (clk_mgr,PPCLK_DPPCLK ); +//HW recommends limit of 1950 MHz in display clock for all DCN3.2.x +if (clk_mgr_base->bw_params->dc_mode_limit.dppclk_mhz >1950 ) + clk_mgr_base->bw_params->dc_mode_limit.dppclk_mhz =1950 ; +if (num_entries_per_clk->num_dcfclk_levels && num_entries_per_clk->num_dtbclk_levels && num_entries_per_clk->num_dispclk_levels)
@@ -241,6 +251,10 @@ void dcn32_init_clocks(struct clk_mgr *clk_mgr_base) = khz_to_mhz_ceil(clk_mgr_base->ctx->dc->debug.min_dpp_clk_khz); } +for (i =0 ; i < num_levels; i++) +if (clk_mgr_base->bw_params->clk_table.entries[i].dppclk_mhz >1950 ) + clk_mgr_base->bw_params->clk_table.entries[i].dppclk_mhz =1950 ; +/* Get UCLK, update bounding box */ clk_mgr_base->funcs->get_memclk_states_from_smu (clk_mgr_base);
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_resource.c +2 -0
@@ -2012,6 +2012,8 @@ static void dcn32_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw {DC_FP_START ();dcn32_update_bw_bounding_box_fpu (dc, bw_params); +if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2) +dml2_reinit (dc, &dc->dml2_options, &dc->current_state->bw_ctx.dml2);DC_FP_END (); }
drivers/gpu/drm/amd/display/dc/dcn321/dcn321_resource.c +2 -0
@@ -1579,6 +1579,8 @@ static void dcn321_update_bw_bounding_box(struct dc *dc, struct clk_bw_params *b {DC_FP_START ();dcn321_update_bw_bounding_box_fpu (dc, bw_params); +if (dc->debug.using_dml2 && dc->current_state && dc->current_state->bw_ctx.dml2) +dml2_reinit (dc, &dc->dml2_options, &dc->current_state->bw_ctx.dml2);DC_FP_END (); }
drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.c +20 -8
@@ -701,13 +701,8 @@ static inline struct dml2_context *dml2_allocate_memory(void)return (struct dml2_context *)kzalloc (sizeof (struct dml2_context ),GFP_KERNEL ); } -bool dml2_create (const struct dc *in_dc,const struct dml2_configuration_options *config,struct dml2_context **dml2) +static void dml2_init (const struct dc *in_dc,const struct dml2_configuration_options *config,struct dml2_context **dml2) { -// Allocate Mode Lib Ctx - *dml2 =dml2_allocate_memory (); - -if (!(*dml2)) -return false;// Store config options (*dml2)->config = *config;
@@ -735,9 +730,18 @@ bool dml2_create(const struct dc *in_dc, const struct dml2_configuration_optionsinitialize_dml2_soc_bbox (*dml2, in_dc, &(*dml2)->v20.dml_core_ctx.soc);initialize_dml2_soc_states (*dml2, in_dc, &(*dml2)->v20.dml_core_ctx.soc, &(*dml2)->v20.dml_core_ctx.states); +} + +bool dml2_create (const struct dc *in_dc,const struct dml2_configuration_options *config,struct dml2_context **dml2) +{ +// Allocate Mode Lib Ctx + *dml2 =dml2_allocate_memory (); + +if (!(*dml2)) +return false; + +dml2_init (in_dc, config, dml2); -/*Initialize DML20 instance which calls dml2_core_create, and core_dcn3_populate_informative*/ -//dml2_initialize_instance(&(*dml_ctx)->v20.dml_init); return true; }
@@ -777,3 +781,11 @@ bool dml2_create_copy(struct dml2_context **dst_dml2,return true; } + +void dml2_reinit (const struct dc *in_dc, +const struct dml2_configuration_options *config, +struct dml2_context **dml2) +{ + +dml2_init (in_dc, config, dml2); +}
drivers/gpu/drm/amd/display/dc/dml2/dml2_wrapper.h +3 -0
@@ -195,6 +195,9 @@ void dml2_copy(struct dml2_context *dst_dml2, struct dml2_context *src_dml2);bool dml2_create_copy (struct dml2_context **dst_dml2,struct dml2_context *src_dml2); +void dml2_reinit (const struct dc *in_dc, +const struct dml2_configuration_options *config, +struct dml2_context **dml2);/* * dml2_validate - Determines if a display configuration is supported or not.
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 216/432 drm/amd/display: Update odm when ODM combine is changed on an otg master pipe with no plane
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wenjing Liu <[email protected]>
[ Upstream commit 86e9523fb0efce27095d3086473c739cce720d01 ]
[WHY]
When committing an update with ODM combine change when the plane is removing or already removed, we fail to detect odm change in pipe update flags. This has caused mismatch between new dc state and the actual hardware state, because we missed odm programming.
[HOW]
- Detect odm change even for otg master pipe without a plane.
- Update odm config before calling program pipes for pipe with planes.
The commit also updates blank pattern programming when odm is changed without plane. This is because number of OPP is changed when ODM combine is changed. Blank pattern is per OPP so we will need to reprogram OPP based on the new pipe topology.
--- .../amd/display/dc/hwss/dcn20/dcn20_hwseq.c | 41 ++++++++++--------- .../amd/display/dc/hwss/dcn32/dcn32_hwseq.c | 7 ++++ 2 files changed, 28 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn20/dcn20_hwseq.c +21 -20
@@ -1385,6 +1385,11 @@ static void dcn20_detect_pipe_changes(struct pipe_ctx *old_pipe, struct pipe_ctxreturn ; } +if (resource_is_pipe_type (new_pipe,OTG_MASTER ) && +resource_is_odm_topology_changed (new_pipe, old_pipe)) +/* Detect odm changes */ + new_pipe->update_flags.bits.odm =1 ; +/* Exit on unchanged, unused pipe */ if (!old_pipe->plane_state && !new_pipe->plane_state)return ;
@@ -1434,10 +1439,6 @@ static void dcn20_detect_pipe_changes(struct pipe_ctx *old_pipe, struct pipe_ctx/* Detect top pipe only changes */ if (resource_is_pipe_type (new_pipe,OTG_MASTER )) { -/* Detect odm changes */ -if (resource_is_odm_topology_changed (new_pipe, old_pipe)) - new_pipe->update_flags.bits.odm =1 ; -/* Detect global sync changes */ if (old_pipe->pipe_dlg_param.vready_offset != new_pipe->pipe_dlg_param.vready_offset || old_pipe->pipe_dlg_param.vstartup_start != new_pipe->pipe_dlg_param.vstartup_start
@@ -1879,19 +1880,20 @@ void dcn20_program_front_end_for_ctx(DC_LOGGER_INIT (dc->ctx->logger);unsigned int prev_hubp_count =0 ;unsigned int hubp_count =0 ; +struct pipe_ctx *pipe;if (resource_is_pipe_topology_changed (dc->current_state, context))resource_log_pipe_topology_update (dc, context);if (dc->hwss.program_triplebuffer !=NULL && dc->debug.enable_tri_buf) {for (i =0 ; i < dc->res_pool->pipe_count; i++) { -struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i]; + pipe = &context->res_ctx.pipe_ctx[i]; -if (!pipe_ctx->top_pipe && !pipe_ctx->prev_odm_pipe && pipe_ctx->plane_state) { -ASSERT (!pipe_ctx->plane_state->triplebuffer_flips); +if (!pipe->top_pipe && !pipe->prev_odm_pipe && pipe->plane_state) { +ASSERT (!pipe->plane_state->triplebuffer_flips);/*turn off triple buffer for full update*/ dc->hwss.program_triplebuffer ( - dc, pipe_ctx, pipe_ctx->plane_state->triplebuffer_flips); + dc, pipe, pipe->plane_state->triplebuffer_flips); } } }
@@ -1965,12 +1967,22 @@ void dcn20_program_front_end_for_ctx(DC_LOG_DC ("Reset mpcc for pipe %d\n" , dc->current_state->res_ctx.pipe_ctx[i].pipe_idx); } +/* update ODM for blanked OTG master pipes */ +for (i =0 ; i < dc->res_pool->pipe_count; i++) { + pipe = &context->res_ctx.pipe_ctx[i]; +if (resource_is_pipe_type (pipe,OTG_MASTER ) && + !resource_is_pipe_type (pipe,DPP_PIPE ) && + pipe->update_flags.bits.odm && + hws->funcs.update_odm) + hws->funcs.update_odm (dc, context, pipe); + } +/* * Program all updated pipes, order matters for mpcc setup. Start with * top pipe and program all pipes that follow in order */ for (i =0 ; i < dc->res_pool->pipe_count; i++) { -struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i]; + pipe = &context->res_ctx.pipe_ctx[i];if (pipe->plane_state && !pipe->top_pipe) {while (pipe) {
@@ -2009,17 +2021,6 @@ void dcn20_program_front_end_for_ctx( context->stream_status[0].plane_count > 1) { pipe->plane_res.hubp->funcs->hubp_wait_pipe_read_start (pipe->plane_res.hubp); } - -/* when dynamic ODM is active, pipes must be reconfigured when all planes are -* disabled, as some transitions will leave software and hardware state -* mismatched. -*/ -if (dc->debug.enable_single_display_2to1_odm_policy && - pipe->stream && - pipe->update_flags.bits.disable && - !pipe->prev_odm_pipe && - hws->funcs.update_odm) - hws->funcs.update_odm (dc, context, pipe); } }
drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c +7 -0
@@ -1159,6 +1159,13 @@ void dcn32_update_odm(struct dc *dc, struct dc_state *context, struct pipe_ctx * dsc->funcs->dsc_disconnect (dsc); } } + +if (!resource_is_pipe_type (pipe_ctx,DPP_PIPE )) +/* +* blank pattern is generated by OPP, reprogram blank pattern +* due to OPP count change +*/ + dc->hwseq->funcs.blank_pixel_data (dc, pipe_ctx, true); }unsigned int dcn32_calculate_dccg_k1_k2_values (struct pipe_ctx *pipe_ctx,unsigned int *k1_div,unsigned int *k2_div)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 217/432 drm/amd/display: Fix idle check for shared firmware state
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Kazlauskas <[email protected]>
[ Upstream commit 3d066f9547dd58329b526db44f42c487a7974703 ]
[WHY]
We still had an instance of get_idle_state checking the PMFW scratch register instead of the actual idle allow signal.
[HOW]
Replace it with the SW state check for whether we had allowed idle through notify_idle.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +3 -9
@@ -4925,22 +4925,16 @@ void dc_allow_idle_optimizations(struct dc *dc, bool allow)bool dc_dmub_is_ips_idle_state (struct dc *dc) { -uint32_t idle_state =0 ; -if (dc->debug.disable_idle_power_optimizations)return false;if (!dc->caps.ips_support || (dc->config.disable_ips ==DMUB_IPS_DISABLE_ALL ))return false; -if (dc->hwss.get_idle_state) - idle_state = dc->hwss.get_idle_state (dc); - -if (!(idle_state &DMUB_IPS1_ALLOW_MASK ) || - !(idle_state &DMUB_IPS2_ALLOW_MASK )) -return true; +if (!dc->ctx->dmub_srv) +return false; -return false; +return dc->ctx->dmub_srv->idle_allowed; }/* set min and max memory clock to lowest and highest DPM level, respectively */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 218/432 drm/amd/display: Return the correct HDCP error code
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rodrigo Siqueira <[email protected]>
[ Upstream commit e64b3f55e458ce7e2087a0051f47edabf74545e7 ]
[WHY & HOW]
If the display is null when creating an HDCP session, return a proper error code.
--- drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c +3 -0
@@ -513,6 +513,9 @@ enum mod_hdcp_status mod_hdcp_hdcp2_create_session(struct mod_hdcp *hdcp) hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.context.mem_context.shared_buf;memset (hdcp_cmd,0 ,sizeof (struct ta_hdcp_shared_memory )); +if (!display) +return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND ; + hdcp_cmd->in_msg.hdcp2_create_session_v2.display_handle = display->index;if (hdcp->connection.link.adjust.hdcp2.force_type ==MOD_HDCP_FORCE_TYPE_0 )
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 219/432 drm/amd/display: Fix noise issue on HDMI AV mute
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Ma <[email protected]>
[ Upstream commit 69e3be6893a7e668660b05a966bead82bbddb01d ]
[Why]
When mode switching is triggered there is momentary noise visible on some HDMI TV or displays.
[How]
Wait for 2 frames to make sure we have enough time to send out AV mute and sink receives a full frame.
--- .../gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/hwss/dcn30/dcn30_hwseq.c +11 -1
@@ -656,10 +656,20 @@ void dcn30_set_avmute(struct pipe_ctx *pipe_ctx, bool enable)if (pipe_ctx ==NULL )return ; -if (dc_is_hdmi_signal (pipe_ctx->stream->signal) && pipe_ctx->stream_res.stream_enc !=NULL ) +if (dc_is_hdmi_signal (pipe_ctx->stream->signal) && pipe_ctx->stream_res.stream_enc !=NULL ) { pipe_ctx->stream_res.stream_enc->funcs->set_avmute ( pipe_ctx->stream_res.stream_enc, enable); + +/* Wait for two frame to make sure AV mute is sent out */ +if (enable) { + pipe_ctx->stream_res.tg->funcs->wait_for_state (pipe_ctx->stream_res.tg,CRTC_STATE_VACTIVE ); + pipe_ctx->stream_res.tg->funcs->wait_for_state (pipe_ctx->stream_res.tg,CRTC_STATE_VBLANK ); + pipe_ctx->stream_res.tg->funcs->wait_for_state (pipe_ctx->stream_res.tg,CRTC_STATE_VACTIVE ); + pipe_ctx->stream_res.tg->funcs->wait_for_state (pipe_ctx->stream_res.tg,CRTC_STATE_VBLANK ); + pipe_ctx->stream_res.tg->funcs->wait_for_state (pipe_ctx->stream_res.tg,CRTC_STATE_VACTIVE ); + } + } }void dcn30_update_info_frame (struct pipe_ctx *pipe_ctx)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 220/432 dm snapshot: fix lockup in dm_exception_table_exit
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit 6e7132ed3c07bd8a6ce3db4bb307ef2852b322dc ]
There was reported lockup when we exit a snapshot with many exceptions. Fix this by adding "cond_resched" to the loop that frees the exceptions.
--- drivers/md/dm-snap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/dm-snap.c +3 -1
@@ -684,8 +684,10 @@ static void dm_exception_table_exit(struct dm_exception_table *et,for (i =0 ; i < size; i++) { slot = et->table + i; -hlist_bl_for_each_entry_safe (ex, pos, n, slot, hash_list) +hlist_bl_for_each_entry_safe (ex, pos, n, slot, hash_list) {kmem_cache_free (mem, ex); +cond_resched (); + } }kvfree (et->table);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 221/432 x86/pm: Work around false positive kmemleak report in msr_build_context()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anton Altaparmakov <[email protected]>
[ Upstream commit e3f269ed0accbb22aa8f25d2daffa23c3fccd407 ]
Since:
7ee18d677989 ("x86/power: Make restore_processor_context() sane")
kmemleak reports this issue:
unreferenced object 0xf68241e0 (size 32):
comm "swapper/0", pid 1, jiffies 4294668610 (age 68.432s)
hex dump (first 32 bytes):
00 cc cc cc 29 10 01 c0 00 00 00 00 00 00 00 00 ....)...........
00 42 82 f6 cc cc cc cc cc cc cc cc cc cc cc cc .B..............
backtrace:
[<461c1d50>] __kmem_cache_alloc_node+0x106/0x260
[<ea65e13b>] __kmalloc+0x54/0x160
[<c3858cd2>] msr_build_context.constprop.0+0x35/0x100
[<46635aff>] pm_check_save_msr+0x63/0x80
[<6b6bb938>] do_one_initcall+0x41/0x1f0
[<3f3add60>] kernel_init_freeable+0x199/0x1e8
[<3b538fde>] kernel_init+0x1a/0x110
[<938ae2b2>] ret_from_fork+0x1c/0x28Which is a false positive.
Reproducer:
- Run rsync of whole kernel tree (multiple times if needed).
- start a kmemleak scan
- Note this is just an example: a lot of our internal tests hit these.
The root cause is similar to the fix in:
b0b592cf0836 x86/pm: Fix false positive kmemleak report in msr_build_context()
ie. the alignment within the packed struct saved_context which has everything unaligned as there is only "u16 gs;" at start of struct where in the past there were four u16 there thus aligning everything afterwards. The issue is with the fact that Kmemleak only searches for pointers that are aligned (see how pointers are scanned in kmemleak.c) so when the struct members are not aligned it doesn't see them.
Testing:
We run a lot of tests with our CI, and after applying this fix we do not see any kmemleak issues any more whilst without it we see hundreds of the above report. From a single, simple test run consisting of 416 individual test cases on kernel 5.10 x86 with kmemleak enabled we got 20 failures due to this, which is quite a lot. With this fix applied we get zero kmemleak related failures.
--- arch/x86/include/asm/suspend_32.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/include/asm/suspend_32.h +5 -5
@@ -12,11 +12,6 @@/* image of the saved processor state */ struct saved_context { -/* -* On x86_32, all segment registers except gs are saved at kernel -* entry in pt_regs. -*/ -u16 gs;unsigned long cr0, cr2, cr3, cr4;u64 misc_enable;struct saved_msrs saved_msrs;
@@ -27,6 +22,11 @@ struct saved_context {unsigned long tr;unsigned long safety;unsigned long return_address; +/* +* On x86_32, all segment registers except gs are saved at kernel +* entry in pt_regs. +*/ +u16 gs;bool misc_enable_saved; } __attribute__((packed));
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 222/432 wifi: brcmfmac: add per-vendor feature detection callback
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arend van Spriel <[email protected]>
[ Upstream commit 14e1391b71027948cdbacdbea4bf8858c2068eb7 ]
Adding a .feat_attach() callback allowing per-vendor overrides of the driver feature flags. In this patch the callback is only provided by BCA vendor to disable SAE feature as it has not been confirmed yet. BCA chips generally do not have the in-driver supplicant (idsup) feature so they rely on NL80211_CMD_EXTERNAL_AUTH to trigger user-space authentication.
Stable-dep-of: 85da8f71aaa7 ("wifi: brcmfmac: Demote vendor-specific attach/detach messages to info")
--- .../wireless/broadcom/brcm80211/brcmfmac/bca/core.c | 8 ++++++++ .../wireless/broadcom/brcm80211/brcmfmac/feature.c | 3 +++ .../net/wireless/broadcom/brcm80211/brcmfmac/fwvid.h | 12 ++++++++++++ 3 files changed, 23 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bca/core.c +8 -0
@@ -7,6 +7,7 @@#include <core.h> #include <bus.h> #include <fwvid.h> +#include <feature.h> #include "vops.h"
@@ -21,7 +22,14 @@ static void brcmf_bca_detach(struct brcmf_pub *drvr)pr_err ("%s: executing\n" , __func__); } +static void brcmf_bca_feat_attach (struct brcmf_if *ifp) +{ +/* SAE support not confirmed so disabling for now */ + ifp->drvr->feat_flags &= ~BIT (BRCMF_FEAT_SAE ); +} +const struct brcmf_fwvid_ops brcmf_bca_ops = { .attach = brcmf_bca_attach, .detach = brcmf_bca_detach, + .feat_attach = brcmf_bca_feat_attach, };
drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c +3 -0
@@ -13,6 +13,7 @@#include "debug.h" #include "fwil.h" #include "fwil_types.h" +#include "fwvid.h" #include "feature.h" #include "common.h"
@@ -339,6 +340,8 @@ void brcmf_feat_attach(struct brcmf_pub *drvr)brcmf_feat_iovar_int_get (ifp,BRCMF_FEAT_FWSUP ,"sup_wpa" );brcmf_feat_iovar_int_get (ifp,BRCMF_FEAT_SCAN_V2 ,"scan_ver" ); +brcmf_fwvid_feat_attach (ifp); +if (drvr->settings->feature_disable) { brcmf_dbg(INFO, "Features: 0x%02x, disable: 0x%02x\n", ifp->drvr->feat_flags,
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwvid.h +12 -0
@@ -8,10 +8,12 @@#include "firmware.h" struct brcmf_pub ; +struct brcmf_if ;struct brcmf_fwvid_ops {int (*attach)(struct brcmf_pub *drvr);void (*detach)(struct brcmf_pub *drvr); +void (*feat_attach)(struct brcmf_if *ifp); };/* exported functions */
@@ -44,4 +46,14 @@ static inline void brcmf_fwvid_detach(struct brcmf_pub *drvr) brcmf_fwvid_detach_ops(drvr); } +static inline void brcmf_fwvid_feat_attach (struct brcmf_if *ifp) +{ +const struct brcmf_fwvid_ops *vops = ifp->drvr->vops; + +if (!vops->feat_attach) +return ; + + vops->feat_attach (ifp); +} +#endif /* FWVID_H_ */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 223/432 wifi: brcmfmac: cfg80211: Use WSEC to set SAE password
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hector Martin <[email protected]>
[ Upstream commit 9f7861c56b51b84d30114e7fea9d744a9d5ba9b7 ]
Using the WSEC command instead of sae_password seems to be the supported mechanism on newer firmware, and also how the brcmdhd driver does it.
The existing firmware mechanism intended for (some) Cypress chips has been separated from the new firmware mechanism using the multi-vendor framework. Depending on the device it will select the appropriate firmware mechanism.
This makes WPA3 work with iwd, or with wpa_supplicant pending a support patchset [2].
[1] https://rachelbythebay.com/w/2023/11/06/wpa3/
[2] http://lists.infradead.org/pipermail/hostap/2023-July/041653.html
Stable-dep-of: 85da8f71aaa7 ("wifi: brcmfmac: Demote vendor-specific attach/detach messages to info")
--- .../broadcom/brcm80211/brcmfmac/cfg80211.c | 56 ++++++++----------- .../broadcom/brcm80211/brcmfmac/cfg80211.h | 2 + .../broadcom/brcm80211/brcmfmac/cyw/core.c | 28 ++++++++++ .../broadcom/brcm80211/brcmfmac/fwil.c | 1 + .../broadcom/brcm80211/brcmfmac/fwil_types.h | 2 +- .../broadcom/brcm80211/brcmfmac/fwvid.h | 13 +++++ .../broadcom/brcm80211/brcmfmac/wcc/core.c | 9 +++ 7 files changed, 76 insertions(+), 35 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +22 -34
@@ -32,6 +32,7 @@#include "vendor.h" #include "bus.h" #include "common.h" +#include "fwvid.h" #define BRCMF_SCAN_IE_LEN_MAX 2048
@@ -1686,52 +1687,39 @@ static u16 brcmf_map_fw_linkdown_reason(const struct brcmf_event_msg *e)return reason; } -static int brcmf_set_pmk (struct brcmf_if *ifp,const u8 *pmk_data,u16 pmk_len) +int brcmf_set_wsec (struct brcmf_if *ifp,const u8 *key,u16 key_len,u16 flags) {struct brcmf_pub *drvr = ifp->drvr;struct brcmf_wsec_pmk_le pmk;int err; +if (key_len >sizeof (pmk.key)) { +bphy_err (drvr,"key must be less than %zu bytes\n" , +sizeof (pmk.key)); +return -EINVAL ; + } +memset (&pmk,0 ,sizeof (pmk)); -/* pass pmk directly */ - pmk.key_len =cpu_to_le16 (pmk_len); - pmk.flags =cpu_to_le16 (0 ); -memcpy (pmk.key, pmk_data, pmk_len); +/* pass key material directly */ + pmk.key_len =cpu_to_le16 (key_len); + pmk.flags =cpu_to_le16 (flags); +memcpy (pmk.key, key, key_len); -/* store psk in firmware */ +/* store key material in firmware */ err =brcmf_fil_cmd_data_set (ifp,BRCMF_C_SET_WSEC_PMK , &pmk,sizeof (pmk));if (err <0 )bphy_err (drvr,"failed to change PSK in firmware (len=%u)\n" , - pmk_len); + key_len);return err; } +BRCMF_EXPORT_SYMBOL_GPL (brcmf_set_wsec); -static int brcmf_set_sae_password (struct brcmf_if *ifp,const u8 *pwd_data, -u16 pwd_len) +static int brcmf_set_pmk (struct brcmf_if *ifp,const u8 *pmk_data,u16 pmk_len) { -struct brcmf_pub *drvr = ifp->drvr; -struct brcmf_wsec_sae_pwd_le sae_pwd; -int err; - -if (pwd_len >BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ) { -bphy_err (drvr,"sae_password must be less than %d\n" , -BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ); -return -EINVAL ; - } - - sae_pwd.key_len =cpu_to_le16 (pwd_len); -memcpy (sae_pwd.key, pwd_data, pwd_len); - - err =brcmf_fil_iovar_data_set (ifp,"sae_password" , &sae_pwd, -sizeof (sae_pwd)); -if (err <0 ) -bphy_err (drvr,"failed to set SAE password in firmware (len=%u)\n" , - pwd_len); - -return err; +return brcmf_set_wsec (ifp, pmk_data, pmk_len,0 ); } static void brcmf_link_down(struct brcmf_cfg80211_vif *vif, u16 reason,
@@ -2502,8 +2490,7 @@ brcmf_cfg80211_connect(struct wiphy *wiphy, struct net_device *ndev,bphy_err (drvr,"failed to clean up user-space RSNE\n" ); goto done; } - err =brcmf_set_sae_password (ifp, sme->crypto.sae_pwd, - sme->crypto.sae_pwd_len); + err =brcmf_fwvid_set_sae_password (ifp, &sme->crypto);if (!err && sme->crypto.psk) err =brcmf_set_pmk (ifp, sme->crypto.psk,BRCMF_WSEC_MAX_PSK_LEN );
@@ -5256,8 +5243,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wiphy, struct net_device *ndev,if (crypto->sae_pwd) {brcmf_dbg (INFO ,"using SAE offload\n" ); profile->use_fwauth |=BIT (BRCMF_PROFILE_FWAUTH_SAE ); - err =brcmf_set_sae_password (ifp, crypto->sae_pwd, - crypto->sae_pwd_len); + err =brcmf_fwvid_set_sae_password (ifp, crypto);if (err <0 ) goto exit; }
@@ -5364,10 +5350,12 @@ static int brcmf_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *ndev,msleep (400 );if (profile->use_fwauth !=BIT (BRCMF_PROFILE_FWAUTH_NONE )) { +struct cfg80211_crypto_settings crypto = {}; +if (profile->use_fwauth &BIT (BRCMF_PROFILE_FWAUTH_PSK ))brcmf_set_pmk (ifp,NULL ,0 );if (profile->use_fwauth &BIT (BRCMF_PROFILE_FWAUTH_SAE )) -brcmf_set_sae_password (ifp,NULL ,0 ); +brcmf_fwvid_set_sae_password (ifp, &crypto); profile->use_fwauth =BIT (BRCMF_PROFILE_FWAUTH_NONE ); }
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h +2 -0
@@ -468,4 +468,6 @@ void brcmf_set_mpc(struct brcmf_if *ndev, int mpc);void brcmf_abort_scanning (struct brcmf_cfg80211_info *cfg);void brcmf_cfg80211_free_netdev (struct net_device *ndev); +int brcmf_set_wsec (struct brcmf_if *ifp,const u8 *key,u16 key_len,u16 flags); +#endif /* BRCMFMAC_CFG80211_H */
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/core.c +28 -0
@@ -7,6 +7,7 @@#include <core.h> #include <bus.h> #include <fwvid.h> +#include <fwil.h> #include "vops.h"
@@ -21,7 +22,34 @@ static void brcmf_cyw_detach(struct brcmf_pub *drvr)pr_err ("%s: executing\n" , __func__); } +static int brcmf_cyw_set_sae_pwd (struct brcmf_if *ifp, +struct cfg80211_crypto_settings *crypto) +{ +struct brcmf_pub *drvr = ifp->drvr; +struct brcmf_wsec_sae_pwd_le sae_pwd; +u16 pwd_len = crypto->sae_pwd_len; +int err; + +if (pwd_len >BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ) { +bphy_err (drvr,"sae_password must be less than %d\n" , +BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ); +return -EINVAL ; + } + + sae_pwd.key_len =cpu_to_le16 (pwd_len); +memcpy (sae_pwd.key, crypto->sae_pwd, pwd_len); + + err =brcmf_fil_iovar_data_set (ifp,"sae_password" , &sae_pwd, +sizeof (sae_pwd)); +if (err <0 ) +bphy_err (drvr,"failed to set SAE password in firmware (len=%u)\n" , + pwd_len); + +return err; +} +const struct brcmf_fwvid_ops brcmf_cyw_ops = { .attach = brcmf_cyw_attach, .detach = brcmf_cyw_detach, + .set_sae_password = brcmf_cyw_set_sae_pwd, };
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c +1 -0
@@ -239,6 +239,7 @@ brcmf_fil_iovar_data_set(struct brcmf_if *ifp, const char *name, const void *datmutex_unlock (&drvr->proto_block);return err; } +BRCMF_EXPORT_SYMBOL_GPL (brcmf_fil_iovar_data_set); s32 brcmf_fil_iovar_data_get(struct brcmf_if *ifp, const char *name, void *data,
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h +1 -1
@@ -584,7 +584,7 @@ struct brcmf_wsec_key_le {struct brcmf_wsec_pmk_le {__le16 key_len;__le16 flags; -u8 key[2 *BRCMF_WSEC_MAX_PSK_LEN +1 ]; +u8 key[BRCMF_WSEC_MAX_SAE_PASSWORD_LEN ]; };/**
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwvid.h +13 -0
@@ -6,6 +6,7 @@#define FWVID_H_ #include "firmware.h" +#include "cfg80211.h" struct brcmf_pub ;struct brcmf_if ;
@@ -14,6 +15,7 @@ struct brcmf_fwvid_ops {int (*attach)(struct brcmf_pub *drvr);void (*detach)(struct brcmf_pub *drvr);void (*feat_attach)(struct brcmf_if *ifp); +int (*set_sae_password)(struct brcmf_if *ifp,struct cfg80211_crypto_settings *crypto); };/* exported functions */
@@ -56,4 +58,15 @@ static inline void brcmf_fwvid_feat_attach(struct brcmf_if *ifp) vops->feat_attach(ifp); } +static inline int brcmf_fwvid_set_sae_password (struct brcmf_if *ifp, +struct cfg80211_crypto_settings *crypto) +{ +const struct brcmf_fwvid_ops *vops = ifp->drvr->vops; + +if (!vops || !vops->set_sae_password) +return -EOPNOTSUPP ; + +return vops->set_sae_password (ifp, crypto); +} +#endif /* FWVID_H_ */
drivers/net/wireless/broadcom/brcm80211/brcmfmac/wcc/core.c +9 -0
@@ -7,6 +7,7 @@#include <core.h> #include <bus.h> #include <fwvid.h> +#include <fwil.h> #include "vops.h"
@@ -21,7 +22,15 @@ static void brcmf_wcc_detach(struct brcmf_pub *drvr)pr_debug ("%s: executing\n" , __func__); } +static int brcmf_wcc_set_sae_pwd (struct brcmf_if *ifp, +struct cfg80211_crypto_settings *crypto) +{ +return brcmf_set_wsec (ifp, crypto->sae_pwd, crypto->sae_pwd_len, +BRCMF_WSEC_PASSPHRASE ); +} +const struct brcmf_fwvid_ops brcmf_wcc_ops = { .attach = brcmf_wcc_attach, .detach = brcmf_wcc_detach, + .set_sae_password = brcmf_wcc_set_sae_pwd, };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 224/432 wifi: brcmfmac: Demote vendor-specific attach/detach messages to info
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hector Martin <[email protected]>
[ Upstream commit 85da8f71aaa7b83ea7ef0e89182e0cd47e16d465 ]
People are getting spooked by brcmfmac errors on their boot console. There's no reason for these messages to be errors.
--- .../broadcom/brcm80211/brcmfmac/bca/core.c | 13 ---------- .../broadcom/brcm80211/brcmfmac/cyw/core.c | 13 ---------- .../broadcom/brcm80211/brcmfmac/fwvid.c | 7 +++-- .../broadcom/brcm80211/brcmfmac/fwvid.h | 26 ++----------------- .../broadcom/brcm80211/brcmfmac/wcc/core.c | 15 +---------- 5 files changed, 6 insertions(+), 68 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/bca/core.c +0 -13
@@ -11,17 +11,6 @@#include "vops.h" -static int brcmf_bca_attach (struct brcmf_pub *drvr) -{ -pr_err ("%s: executing\n" , __func__); -return 0 ; -} - -static void brcmf_bca_detach (struct brcmf_pub *drvr) -{ -pr_err ("%s: executing\n" , __func__); -} -static void brcmf_bca_feat_attach (struct brcmf_if *ifp) {/* SAE support not confirmed so disabling for now */
@@ -29,7 +18,5 @@ static void brcmf_bca_feat_attach(struct brcmf_if *ifp) }const struct brcmf_fwvid_ops brcmf_bca_ops = { - .attach = brcmf_bca_attach, - .detach = brcmf_bca_detach, .feat_attach = brcmf_bca_feat_attach, };
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/core.c +0 -13
@@ -11,17 +11,6 @@#include "vops.h" -static int brcmf_cyw_attach (struct brcmf_pub *drvr) -{ -pr_err ("%s: executing\n" , __func__); -return 0 ; -} - -static void brcmf_cyw_detach (struct brcmf_pub *drvr) -{ -pr_err ("%s: executing\n" , __func__); -} -static int brcmf_cyw_set_sae_pwd (struct brcmf_if *ifp,struct cfg80211_crypto_settings *crypto) {
@@ -49,7 +38,5 @@ static int brcmf_cyw_set_sae_pwd(struct brcmf_if *ifp, }const struct brcmf_fwvid_ops brcmf_cyw_ops = { - .attach = brcmf_cyw_attach, - .detach = brcmf_cyw_detach, .set_sae_password = brcmf_cyw_set_sae_pwd, };
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwvid.c +3 -4
@@ -89,8 +89,7 @@ int brcmf_fwvid_register_vendor(enum brcmf_fwvendor fwvid, struct module *vmod,if (fwvid >=BRCMF_FWVENDOR_NUM )return -ERANGE ; -if (WARN_ON (!vmod) ||WARN_ON (!vops) || -WARN_ON (!vops->attach) ||WARN_ON (!vops->detach)) +if (WARN_ON (!vmod) ||WARN_ON (!vops))return -EINVAL ;if (WARN_ON (fwvid_list[fwvid].vmod))
@@ -150,7 +149,7 @@ static inline int brcmf_fwvid_request_module(enum brcmf_fwvendor fwvid) }#endif -int brcmf_fwvid_attach_ops (struct brcmf_pub *drvr) +int brcmf_fwvid_attach (struct brcmf_pub *drvr) {enum brcmf_fwvendor fwvid = drvr->bus_if->fwvid;int ret;
@@ -175,7 +174,7 @@ int brcmf_fwvid_attach_ops(struct brcmf_pub *drvr)return ret; } -void brcmf_fwvid_detach_ops (struct brcmf_pub *drvr) +void brcmf_fwvid_detach (struct brcmf_pub *drvr) {enum brcmf_fwvendor fwvid = drvr->bus_if->fwvid;
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwvid.h +2 -24
@@ -12,8 +12,6 @@ struct brcmf_pub;struct brcmf_if ;struct brcmf_fwvid_ops { -int (*attach)(struct brcmf_pub *drvr); -void (*detach)(struct brcmf_pub *drvr);void (*feat_attach)(struct brcmf_if *ifp);int (*set_sae_password)(struct brcmf_if *ifp,struct cfg80211_crypto_settings *crypto); };
@@ -24,30 +22,10 @@ int brcmf_fwvid_register_vendor(enum brcmf_fwvendor fwvid, struct module *mod,int brcmf_fwvid_unregister_vendor (enum brcmf_fwvendor fwvid,struct module *mod);/* core driver functions */ -int brcmf_fwvid_attach_ops (struct brcmf_pub *drvr); -void brcmf_fwvid_detach_ops (struct brcmf_pub *drvr); +int brcmf_fwvid_attach (struct brcmf_pub *drvr); +void brcmf_fwvid_detach (struct brcmf_pub *drvr);const char *brcmf_fwvid_vendor_name (struct brcmf_pub *drvr); -static inline int brcmf_fwvid_attach (struct brcmf_pub *drvr) -{ -int ret; - - ret =brcmf_fwvid_attach_ops (drvr); -if (ret) -return ret; - -return drvr->vops->attach (drvr); -} - -static inline void brcmf_fwvid_detach (struct brcmf_pub *drvr) -{ -if (!drvr->vops) -return ; - - drvr->vops->detach (drvr); -brcmf_fwvid_detach_ops (drvr); -} -static inline void brcmf_fwvid_feat_attach (struct brcmf_if *ifp) {const struct brcmf_fwvid_ops *vops = ifp->drvr->vops;
drivers/net/wireless/broadcom/brcm80211/brcmfmac/wcc/core.c +1 -14
@@ -7,21 +7,10 @@#include <core.h> #include <bus.h> #include <fwvid.h> -#include <fwil.h> +#include <cfg80211.h> #include "vops.h" -static int brcmf_wcc_attach (struct brcmf_pub *drvr) -{ -pr_debug ("%s: executing\n" , __func__); -return 0 ; -} - -static void brcmf_wcc_detach (struct brcmf_pub *drvr) -{ -pr_debug ("%s: executing\n" , __func__); -} -static int brcmf_wcc_set_sae_pwd (struct brcmf_if *ifp,struct cfg80211_crypto_settings *crypto) {
@@ -30,7 +19,5 @@ static int brcmf_wcc_set_sae_pwd(struct brcmf_if *ifp, }const struct brcmf_fwvid_ops brcmf_wcc_ops = { - .attach = brcmf_wcc_attach, - .detach = brcmf_wcc_detach, .set_sae_password = brcmf_wcc_set_sae_pwd, };
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 225/432 drm/ttm: Make sure the mapped tt pages are decrypted when needed
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <[email protected]>
[ Upstream commit 71ce046327cfd3aef3f93d1c44e091395eb03f8f ]
Some drivers require the mapped tt pages to be decrypted. In an ideal world this would have been handled by the dma layer, but the TTM page fault handling would have to be rewritten to able to do that.
A side-effect of the TTM page fault handling is using a dma allocation per order (via ttm_pool_alloc_page) which makes it impossible to just trivially use dma_mmap_attrs. As a result ttm has to be very careful about trying to make its pgprot for the mapped tt pages match what the dma layer thinks it is. At the ttm layer it's possible to deduce the requirement to have tt pages decrypted by checking whether coherent dma allocations have been requested and the system is running with confidential computing technologies.
This approach isn't ideal but keeping TTM matching DMAs expectations for the page properties is in general fragile, unfortunately proper fix would require a rewrite of TTM's page fault handling.
Fixes vmwgfx with SEV enabled.
v2: Explicitly include cc_platform.h
v3: Use CC_ATTR_GUEST_MEM_ENCRYPT instead of CC_ATTR_MEM_ENCRYPT to limit the scope to guests and log when memory decryption is enabled.
--- drivers/gpu/drm/ttm/ttm_bo_util.c | 13 +++++++++++-- drivers/gpu/drm/ttm/ttm_tt.c | 13 +++++++++++++ include/drm/ttm/ttm_tt.h | 9 ++++++++- 3 files changed, 32 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_util.c +11 -2
@@ -294,7 +294,13 @@ pgprot_t ttm_io_prot(struct ttm_buffer_object *bo, struct ttm_resource *res,enum ttm_caching caching; man =ttm_manager_type (bo->bdev, res->mem_type); - caching = man->use_tt ? bo->ttm->caching : res->bus.caching; +if (man->use_tt) { + caching = bo->ttm->caching; +if (bo->ttm->page_flags &TTM_TT_FLAG_DECRYPTED ) + tmp =pgprot_decrypted (tmp); + }else { + caching = res->bus.caching; + }return ttm_prot_from_caching (caching, tmp); }
@@ -337,6 +343,8 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo, .no_wait_gpu = false };struct ttm_tt *ttm = bo->ttm; +struct ttm_resource_manager *man = +ttm_manager_type (bo->bdev, bo->resource->mem_type);pgprot_t prot;int ret;
@@ -346,7 +354,8 @@ static int ttm_bo_kmap_ttm(struct ttm_buffer_object *bo,if (ret)return ret; -if (num_pages ==1 && ttm->caching == ttm_cached) { +if (num_pages ==1 && ttm->caching == ttm_cached && + !(man->use_tt && (ttm->page_flags &TTM_TT_FLAG_DECRYPTED ))) {/* * We're mapping a single page, and the desired * page protection is consistent with the bo.
drivers/gpu/drm/ttm/ttm_tt.c +13 -0
@@ -31,11 +31,14 @@#define pr_fmt (fmt) "[TTM] " fmt +#include <linux/cc_platform.h> #include <linux/sched.h> #include <linux/shmem_fs.h> #include <linux/file.h> #include <linux/module.h> #include <drm/drm_cache.h> +#include <drm/drm_device.h> +#include <drm/drm_util.h> #include <drm/ttm/ttm_bo.h> #include <drm/ttm/ttm_tt.h>
@@ -60,6 +63,7 @@ static atomic_long_t ttm_dma32_pages_allocated;int ttm_tt_create (struct ttm_buffer_object *bo,bool zero_alloc) {struct ttm_device *bdev = bo->bdev; +struct drm_device *ddev = bo->base.dev;uint32_t page_flags =0 ;dma_resv_assert_held (bo->base.resv);
@@ -81,6 +85,15 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc)pr_err ("Illegal buffer object type\n" );return -EINVAL ; } +/* +* When using dma_alloc_coherent with memory encryption the +* mapped TT pages need to be decrypted or otherwise the drivers +* will end up sending encrypted mem to the gpu. +*/ +if (bdev->pool.use_dma_alloc &&cc_platform_has (CC_ATTR_GUEST_MEM_ENCRYPT )) { + page_flags |=TTM_TT_FLAG_DECRYPTED ; +drm_info (ddev,"TT memory decryption enabled." ); + } bo->ttm = bdev->funcs->ttm_tt_create (bo, page_flags);if (unlikely (bo->ttm ==NULL ))
include/drm/ttm/ttm_tt.h +8 -1
@@ -79,6 +79,12 @@ struct ttm_tt {* page_flags = TTM_TT_FLAG_EXTERNAL | * TTM_TT_FLAG_EXTERNAL_MAPPABLE; * +* TTM_TT_FLAG_DECRYPTED: The mapped ttm pages should be marked as +* not encrypted. The framework will try to match what the dma layer +* is doing, but note that it is a little fragile because ttm page +* fault handling abuses the DMA api a bit and dma_map_attrs can't be +* used to assure pgprot always matches. +* * TTM_TT_FLAG_PRIV_POPULATED: TTM internal only. DO NOT USE. This is * set by TTM after ttm_tt_populate() has successfully returned, and is * then unset when TTM calls ttm_tt_unpopulate().
@@ -87,8 +93,9 @@ struct ttm_tt {#define TTM_TT_FLAG_ZERO_ALLOC BIT(1)#define TTM_TT_FLAG_EXTERNAL BIT(2)#define TTM_TT_FLAG_EXTERNAL_MAPPABLE BIT(3) +#define TTM_TT_FLAG_DECRYPTED BIT(4) -#define TTM_TT_FLAG_PRIV_POPULATED BIT(4) +#define TTM_TT_FLAG_PRIV_POPULATED BIT(5)uint32_t page_flags;/** @num_pages: Number of pages in the page array. */ uint32_t num_pages;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 226/432 vfio: Introduce interface to flush virqfd inject workqueue
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
[ Upstream commit b620ecbd17a03cacd06f014a5d3f3a11285ce053 ]
In order to synchronize changes that can affect the thread callback, introduce an interface to force a flush of the inject workqueue. The irqfd pointer is only valid under spinlock, but the workqueue cannot be flushed under spinlock. Therefore the flush work for the irqfd is queued under spinlock. The vfio_irqfd_cleanup_wq workqueue is re-used for queuing this work such that flushing the workqueue is also ordered relative to shutdown.
Stable-dep-of: 18c198c96a81 ("vfio/pci: Create persistent INTx handler")
--- drivers/vfio/virqfd.c | 21 +++++++++++++++++++++ include/linux/vfio.h | 2 ++ 2 files changed, 23 insertions(+)
drivers/vfio/virqfd.c +21 -0
@@ -101,6 +101,13 @@ static void virqfd_inject(struct work_struct *work) virqfd->thread (virqfd->opaque, virqfd->data); } +static void virqfd_flush_inject (struct work_struct *work) +{ + struct virqfd *virqfd = container_of(work, struct virqfd, flush_inject); + +flush_work (&virqfd->inject); +} + int vfio_virqfd_enable(void *opaque, int (*handler)(void *, void *), void (*thread)(void *, void *),
@@ -124,6 +131,7 @@ int vfio_virqfd_enable(void *opaque,INIT_WORK (&virqfd->shutdown, virqfd_shutdown);INIT_WORK (&virqfd->inject, virqfd_inject); +INIT_WORK (&virqfd->flush_inject, virqfd_flush_inject); irqfd =fdget (fd);if (!irqfd.file) {
@@ -213,3 +221,16 @@ void vfio_virqfd_disable(struct virqfd **pvirqfd)flush_workqueue (vfio_irqfd_cleanup_wq); }EXPORT_SYMBOL_GPL (vfio_virqfd_disable); + +void vfio_virqfd_flush_thread (struct virqfd **pvirqfd) +{ +unsigned long flags; + +spin_lock_irqsave (&virqfd_lock, flags); +if (*pvirqfd && (*pvirqfd)->thread) +queue_work (vfio_irqfd_cleanup_wq, &(*pvirqfd)->flush_inject); +spin_unlock_irqrestore (&virqfd_lock, flags); + +flush_workqueue (vfio_irqfd_cleanup_wq); +} +EXPORT_SYMBOL_GPL (vfio_virqfd_flush_thread);
include/linux/vfio.h +2 -0
@@ -349,6 +349,7 @@ struct virqfd {wait_queue_entry_t wait;poll_table pt;struct work_struct shutdown; +struct work_struct flush_inject;struct virqfd **pvirqfd; };
@@ -356,5 +357,6 @@ int vfio_virqfd_enable(void *opaque, int (*handler)(void *, void *), void (*thread)(void *, void *), void *data, struct virqfd **pvirqfd, int fd);void vfio_virqfd_disable (struct virqfd **pvirqfd); +void vfio_virqfd_flush_thread (struct virqfd **pvirqfd);#endif /* VFIO_H */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 227/432 vfio/pci: Create persistent INTx handler
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Williamson <[email protected]>
[ Upstream commit 18c198c96a815c962adc2b9b77909eec0be7df4d ]
A vulnerability exists where the eventfd for INTx signaling can be deconfigured, which unregisters the IRQ handler but still allows eventfds to be signaled with a NULL context through the SET_IRQS ioctl or through unmask irqfd if the device interrupt is pending.
Ideally this could be solved with some additional locking; the igate mutex serializes the ioctl and config space accesses, and the interrupt handler is unregistered relative to the trigger, but the irqfd path runs asynchronous to those. The igate mutex cannot be acquired from the atomic context of the eventfd wake function. Disabling the irqfd relative to the eventfd registration is potentially incompatible with existing userspace.
As a result, the solution implemented here moves configuration of the INTx interrupt handler to track the lifetime of the INTx context object and irq_type configuration, rather than registration of a particular trigger eventfd. Synchronization is added between the ioctl path and eventfd_signal() wrapper such that the eventfd trigger can be dynamically updated relative to in-flight interrupts or irqfd callbacks.
--- drivers/vfio/pci/vfio_pci_intrs.c | 145 ++++++++++++++++-------------- 1 file changed, 78 insertions(+), 67 deletions(-)
drivers/vfio/pci/vfio_pci_intrs.c +78 -67
@@ -90,11 +90,15 @@ static void vfio_send_intx_eventfd(void *opaque, void *unused)if (likely (is_intx (vdev) && !vdev->virq_disabled)) {struct vfio_pci_irq_ctx *ctx; +struct eventfd_ctx *trigger; ctx =vfio_irq_ctx_get (vdev,0 );if (WARN_ON_ONCE (!ctx))return ; -eventfd_signal (ctx->trigger); + + trigger =READ_ONCE (ctx->trigger); +if (likely (trigger)) +eventfd_signal (trigger); } }
@@ -253,100 +257,100 @@ static irqreturn_t vfio_intx_handler(int irq, void *dev_id)return ret; } -static int vfio_intx_enable (struct vfio_pci_core_device *vdev) +static int vfio_intx_enable (struct vfio_pci_core_device *vdev, +struct eventfd_ctx *trigger) { +struct pci_dev *pdev = vdev->pdev;struct vfio_pci_irq_ctx *ctx; +unsigned long irqflags; +char *name; +int ret;if (!is_irq_none (vdev))return -EINVAL ; -if (!vdev->pdev->irq) +if (!pdev->irq)return -ENODEV ; + name =kasprintf (GFP_KERNEL_ACCOUNT ,"vfio-intx(%s)" ,pci_name (pdev)); +if (!name) +return -ENOMEM ; + ctx =vfio_irq_ctx_alloc (vdev,0 );if (!ctx)return -ENOMEM ; + ctx->name = name; + ctx->trigger = trigger; +/* -* If the virtual interrupt is masked, restore it. Devices -* supporting DisINTx can be masked at the hardware level -* here, non-PCI-2.3 devices will have to wait until the -* interrupt is enabled. +* Fill the initial masked state based on virq_disabled. After +* enable, changing the DisINTx bit in vconfig directly changes INTx +* masking. igate prevents races during setup, once running masked +* is protected via irqlock. +* +* Devices supporting DisINTx also reflect the current mask state in +* the physical DisINTx bit, which is not affected during IRQ setup. +* +* Devices without DisINTx support require an exclusive interrupt. +* IRQ masking is performed at the IRQ chip. Again, igate protects +* against races during setup and IRQ handlers and irqfds are not +* yet active, therefore masked is stable and can be used to +* conditionally auto-enable the IRQ. +* +* irq_type must be stable while the IRQ handler is registered, +* therefore it must be set before request_irq(). */ ctx->masked = vdev->virq_disabled; -if (vdev->pci_2_3) -pci_intx (vdev->pdev, !ctx->masked); +if (vdev->pci_2_3) { +pci_intx (pdev, !ctx->masked); + irqflags =IRQF_SHARED ; + }else { + irqflags = ctx->masked ?IRQF_NO_AUTOEN :0 ; + } vdev->irq_type =VFIO_PCI_INTX_IRQ_INDEX ; + ret =request_irq (pdev->irq, vfio_intx_handler, + irqflags, ctx->name, vdev); +if (ret) { + vdev->irq_type =VFIO_PCI_NUM_IRQS ; +kfree (name); +vfio_irq_ctx_free (vdev, ctx,0 ); +return ret; + } +return 0 ; } -static int vfio_intx_set_signal (struct vfio_pci_core_device *vdev,int fd) +static int vfio_intx_set_signal (struct vfio_pci_core_device *vdev, +struct eventfd_ctx *trigger) {struct pci_dev *pdev = vdev->pdev; -unsigned long irqflags =IRQF_SHARED ;struct vfio_pci_irq_ctx *ctx; -struct eventfd_ctx *trigger; -unsigned long flags; -int ret; +struct eventfd_ctx *old; ctx =vfio_irq_ctx_get (vdev,0 );if (WARN_ON_ONCE (!ctx))return -EINVAL ; -if (ctx->trigger) { -free_irq (pdev->irq, vdev); -kfree (ctx->name); -eventfd_ctx_put (ctx->trigger); - ctx->trigger =NULL ; - } - -if (fd <0 )/* Disable only */ -return 0 ; - - ctx->name =kasprintf (GFP_KERNEL_ACCOUNT ,"vfio-intx(%s)" , -pci_name (pdev)); -if (!ctx->name) -return -ENOMEM ; - - trigger =eventfd_ctx_fdget (fd); -if (IS_ERR (trigger)) { -kfree (ctx->name); -return PTR_ERR (trigger); - } + old = ctx->trigger; - ctx->trigger = trigger; +WRITE_ONCE (ctx->trigger, trigger); -/* -* Devices without DisINTx support require an exclusive interrupt, -* IRQ masking is performed at the IRQ chip. The masked status is -* protected by vdev->irqlock. Setup the IRQ without auto-enable and -* unmask as necessary below under lock. DisINTx is unmodified by -* the IRQ configuration and may therefore use auto-enable. -*/ -if (!vdev->pci_2_3) - irqflags =IRQF_NO_AUTOEN ; - - ret =request_irq (pdev->irq, vfio_intx_handler, - irqflags, ctx->name, vdev); -if (ret) { - ctx->trigger =NULL ; -kfree (ctx->name); -eventfd_ctx_put (trigger); -return ret; +/* Releasing an old ctx requires synchronizing in-flight users */ +if (old) { +synchronize_irq (pdev->irq); +vfio_virqfd_flush_thread (&ctx->unmask); +eventfd_ctx_put (old); } -spin_lock_irqsave (&vdev->irqlock, flags); -if (!vdev->pci_2_3 && !ctx->masked) -enable_irq (pdev->irq); -spin_unlock_irqrestore (&vdev->irqlock, flags); -return 0 ; }static void vfio_intx_disable (struct vfio_pci_core_device *vdev) { +struct pci_dev *pdev = vdev->pdev;struct vfio_pci_irq_ctx *ctx; ctx =vfio_irq_ctx_get (vdev,0 );
@@ -354,10 +358,13 @@ static void vfio_intx_disable(struct vfio_pci_core_device *vdev)if (ctx) {vfio_virqfd_disable (&ctx->unmask);vfio_virqfd_disable (&ctx->mask); +free_irq (pdev->irq, vdev); +if (ctx->trigger) +eventfd_ctx_put (ctx->trigger); +kfree (ctx->name); +vfio_irq_ctx_free (vdev, ctx,0 ); } -vfio_intx_set_signal (vdev,-1 ); vdev->irq_type =VFIO_PCI_NUM_IRQS ; -vfio_irq_ctx_free (vdev, ctx,0 ); }/*
@@ -641,19 +648,23 @@ static int vfio_pci_set_intx_trigger(struct vfio_pci_core_device *vdev,return -EINVAL ;if (flags &VFIO_IRQ_SET_DATA_EVENTFD ) { +struct eventfd_ctx *trigger =NULL ;int32_t fd = *(int32_t *)data;int ret; -if (is_intx (vdev)) -return vfio_intx_set_signal (vdev, fd); +if (fd >=0 ) { + trigger =eventfd_ctx_fdget (fd); +if (IS_ERR (trigger)) +return PTR_ERR (trigger); + } - ret =vfio_intx_enable (vdev); -if (ret) -return ret; +if (is_intx (vdev)) + ret =vfio_intx_set_signal (vdev, trigger); +else + ret =vfio_intx_enable (vdev, trigger); - ret =vfio_intx_set_signal (vdev, fd); -if (ret) -vfio_intx_disable (vdev); +if (ret && trigger) +eventfd_ctx_put (trigger);return ret; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 228/432 drm/bridge: add ->edid_read hook and drm_bridge_edid_read()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
[ Upstream commit d807ad80d811ba0c22adfd871e2a46491f80d6e2 ]
Add new struct drm_edid based ->edid_read hook and drm_bridge_edid_read() function to call the hook.
v2: Include drm/drm_edid.h
Stable-dep-of: 171b711b26cc ("drm/bridge: lt8912b: do not return negative values from .get_modes()")
--- drivers/gpu/drm/drm_bridge.c | 46 +++++++++++++++++++++++++++++++++++- include/drm/drm_bridge.h | 33 ++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_bridge.c +45 -1
@@ -27,8 +27,9 @@#include <linux/mutex.h> #include <drm/drm_atomic_state_helper.h> -#include <drm/drm_debugfs.h> #include <drm/drm_bridge.h> +#include <drm/drm_debugfs.h> +#include <drm/drm_edid.h> #include <drm/drm_encoder.h> #include <drm/drm_file.h> #include <drm/drm_of.h>
@@ -1206,6 +1207,47 @@ int drm_bridge_get_modes(struct drm_bridge *bridge, }EXPORT_SYMBOL_GPL (drm_bridge_get_modes); +/** +* drm_bridge_edid_read - read the EDID data of the connected display +* @bridge: bridge control structure +* @connector: the connector to read EDID for +* +* If the bridge supports output EDID retrieval, as reported by the +* DRM_BRIDGE_OP_EDID bridge ops flag, call &drm_bridge_funcs.edid_read to get +* the EDID and return it. Otherwise return NULL. +* +* If &drm_bridge_funcs.edid_read is not set, fall back to using +* drm_bridge_get_edid() and wrapping it in struct drm_edid. +* +* RETURNS: +* The retrieved EDID on success, or NULL otherwise. +*/ +const struct drm_edid *drm_bridge_edid_read (struct drm_bridge *bridge, +struct drm_connector *connector) +{ +if (!(bridge->ops &DRM_BRIDGE_OP_EDID )) +return NULL ; + +/* Transitional: Fall back to ->get_edid. */ +if (!bridge->funcs->edid_read) { +const struct drm_edid *drm_edid; +struct edid *edid; + + edid =drm_bridge_get_edid (bridge, connector); +if (!edid) +return NULL ; + + drm_edid =drm_edid_alloc (edid, (edid->extensions +1 ) *EDID_LENGTH ); + +kfree (edid); + +return drm_edid; + } + +return bridge->funcs->edid_read (bridge, connector); +} +EXPORT_SYMBOL_GPL (drm_bridge_edid_read); +/** * drm_bridge_get_edid - get the EDID data of the connected display * @bridge: bridge control structure
@@ -1215,6 +1257,8 @@ EXPORT_SYMBOL_GPL(drm_bridge_get_modes);* DRM_BRIDGE_OP_EDID bridge ops flag, call &drm_bridge_funcs.get_edid to * get the EDID and return it. Otherwise return NULL. * +* Deprecated. Prefer using drm_bridge_edid_read(). +* * RETURNS: * The retrieved EDID on success, or NULL otherwise. */
include/drm/drm_bridge.h +33 -0
@@ -557,6 +557,37 @@ struct drm_bridge_funcs {int (*get_modes)(struct drm_bridge *bridge,struct drm_connector *connector); +/** +* @edid_read: +* +* Read the EDID data of the connected display. +* +* The @edid_read callback is the preferred way of reporting mode +* information for a display connected to the bridge output. Bridges +* that support reading EDID shall implement this callback and leave +* the @get_modes callback unimplemented. +* +* The caller of this operation shall first verify the output +* connection status and refrain from reading EDID from a disconnected +* output. +* +* This callback is optional. Bridges that implement it shall set the +* DRM_BRIDGE_OP_EDID flag in their &drm_bridge->ops. +* +* The connector parameter shall be used for the sole purpose of EDID +* retrieval, and shall not be stored internally by bridge drivers for +* future usage. +* +* RETURNS: +* +* An edid structure newly allocated with drm_edid_alloc() or returned +* from drm_edid_read() family of functions on success, or NULL +* otherwise. The caller is responsible for freeing the returned edid +* structure with drm_edid_free(). +*/ +const struct drm_edid *(*edid_read)(struct drm_bridge *bridge, +struct drm_connector *connector); +/** * @get_edid: *
@@ -888,6 +919,8 @@ drm_atomic_helper_bridge_propagate_bus_fmt(struct drm_bridge *bridge,enum drm_connector_status drm_bridge_detect (struct drm_bridge *bridge);int drm_bridge_get_modes (struct drm_bridge *bridge,struct drm_connector *connector); +const struct drm_edid *drm_bridge_edid_read (struct drm_bridge *bridge, +struct drm_connector *connector);struct edid *drm_bridge_get_edid (struct drm_bridge *bridge,struct drm_connector *connector); void drm_bridge_hpd_enable(struct drm_bridge *bridge,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 229/432 drm/bridge: lt8912b: use drm_bridge_edid_read()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
[ Upstream commit 60d1fe1a7f302cc1151b155ac2d134db59bb1420 ]
Prefer using the struct drm_edid based functions.
Stable-dep-of: 171b711b26cc ("drm/bridge: lt8912b: do not return negative values from .get_modes()")
--- drivers/gpu/drm/bridge/lontium-lt8912b.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/gpu/drm/bridge/lontium-lt8912b.c +6 -6
@@ -429,16 +429,16 @@ lt8912_connector_mode_valid(struct drm_connector *connector,static int lt8912_connector_get_modes (struct drm_connector *connector) { -struct edid *edid; +const struct drm_edid *drm_edid;int ret =-1 ;int num =0 ;struct lt8912 *lt =connector_to_lt8912 (connector);u32 bus_format =MEDIA_BUS_FMT_RGB888_1X24 ; - edid =drm_bridge_get_edid (lt->hdmi_port, connector); -if (edid) { -drm_connector_update_edid_property (connector, edid); - num =drm_add_edid_modes (connector, edid); + drm_edid =drm_bridge_edid_read (lt->hdmi_port, connector); +if (drm_edid) { +drm_edid_connector_update (connector, drm_edid); + num =drm_edid_connector_add_modes (connector); }else {return ret; }
@@ -448,7 +448,7 @@ static int lt8912_connector_get_modes(struct drm_connector *connector)if (ret) num = ret; -kfree (edid); +drm_edid_free (drm_edid);return num; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 230/432 drm/bridge: lt8912b: clear the EDID property on failures
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
[ Upstream commit 29e032296da5d6294378ffa8bad8e976c5aadbf5 ]
If EDID read fails, clear the EDID property.
Stable-dep-of: 171b711b26cc ("drm/bridge: lt8912b: do not return negative values from .get_modes()")
--- drivers/gpu/drm/bridge/lontium-lt8912b.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/lontium-lt8912b.c +1 -1
@@ -436,8 +436,8 @@ static int lt8912_connector_get_modes(struct drm_connector *connector)u32 bus_format =MEDIA_BUS_FMT_RGB888_1X24 ; drm_edid =drm_bridge_edid_read (lt->hdmi_port, connector); +drm_edid_connector_update (connector, drm_edid);if (drm_edid) { -drm_edid_connector_update (connector, drm_edid); num =drm_edid_connector_add_modes (connector); }else {return ret;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 231/432 drm/bridge: lt8912b: do not return negative values from .get_modes()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
[ Upstream commit 171b711b26cce208bb628526b1b368aeec7b6fa4 ]
The .get_modes() hooks aren't supposed to return negative error codes. Return 0 for no modes, whatever the reason.
--- drivers/gpu/drm/bridge/lontium-lt8912b.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/gpu/drm/bridge/lontium-lt8912b.c +7 -9
@@ -430,23 +430,21 @@ lt8912_connector_mode_valid(struct drm_connector *connector,static int lt8912_connector_get_modes (struct drm_connector *connector) {const struct drm_edid *drm_edid; -int ret =-1 ; -int num =0 ;struct lt8912 *lt =connector_to_lt8912 (connector);u32 bus_format =MEDIA_BUS_FMT_RGB888_1X24 ; +int ret, num; drm_edid =drm_bridge_edid_read (lt->hdmi_port, connector);drm_edid_connector_update (connector, drm_edid); -if (drm_edid) { - num =drm_edid_connector_add_modes (connector); - }else { -return ret; - } +if (!drm_edid) +return 0 ; + + num =drm_edid_connector_add_modes (connector); ret =drm_display_info_set_bus_formats (&connector->display_info, &bus_format,1 ); -if (ret) - num = ret; +if (ret <0 ) + num =0 ;drm_edid_free (drm_edid);return num;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 232/432 workqueue: Shorten events_freezable_power_efficient name
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Audra Mitchell <[email protected]>
commit 8318d6a6362f5903edb4c904a8dd447e59be4ad1 upstream.
Since we have set the WQ_NAME_LEN to 32, decrease the name of events_freezable_power_efficient so that it does not trip the name length warning when the workqueue is created.
--- kernel/workqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/workqueue.c +1 -1
@@ -7109,7 +7109,7 @@ void __init workqueue_init_early(void) WQ_FREEZABLE, 0); system_power_efficient_wq =alloc_workqueue ("events_power_efficient" ,WQ_POWER_EFFICIENT ,0 ); - system_freezable_power_efficient_wq =alloc_workqueue ("events_freezable_power_efficient" , + system_freezable_power_efficient_wq =alloc_workqueue ("events_freezable_pwr_efficient" ,WQ_FREEZABLE |WQ_POWER_EFFICIENT ,0 ); BUG_ON(!system_wq || !system_highpri_wq || !system_long_wq ||
Greg Kroah-Hartman
maintainerPATCH 233/432 drm/amd/display: Use freesync when `DRM_EDID_FEATURE_CONTINUOUS_FREQ` found
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit 2f14c0c8cae8e9e3b603a3f91909baba66540027 upstream.
The monitor shipped with the Framework 16 supports VRR [1], but it's not being advertised.
This is because the detailed timing block doesn't contain EDID_DETAIL_MONITOR_RANGE which amdgpu looks for to find min and max frequencies. This check however is superfluous for this case because update_display_info() calls drm_get_monitor_range() to get these ranges already.
So if the DRM_EDID_FEATURE_CONTINUOUS_FREQ EDID feature is found then turn on freesync without extra checks.
v2: squash in fix from Harry
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +14 -8
@@ -10839,18 +10839,24 @@ void amdgpu_dm_update_freesync_caps(struif (!adev->dm.freesync_module) goto update; -if (sink->sink_signal ==SIGNAL_TYPE_DISPLAY_PORT - || sink->sink_signal ==SIGNAL_TYPE_EDP ) { +if (edid && (sink->sink_signal ==SIGNAL_TYPE_DISPLAY_PORT || + sink->sink_signal ==SIGNAL_TYPE_EDP )) {bool edid_check_required = false; -if (edid) { - edid_check_required =is_dp_capable_without_timing_msa ( - adev->dm.dc, - amdgpu_dm_connector); +if (is_dp_capable_without_timing_msa (adev->dm.dc, + amdgpu_dm_connector)) { +if (edid->features &DRM_EDID_FEATURE_CONTINUOUS_FREQ ) { + freesync_capable = true; + amdgpu_dm_connector->min_vfreq = connector->display_info.monitor_range.min_vfreq; + amdgpu_dm_connector->max_vfreq = connector->display_info.monitor_range.max_vfreq; + }else { + edid_check_required = edid->version >1 || + (edid->version ==1 && + edid->revision >1 ); + } } -if (edid_check_required == true && (edid->version >1 || - (edid->version ==1 && edid->revision >1 ))) { +if (edid_check_required) {for (i =0 ; i <4 ; i++) { timing = &edid->detailed_timings[i];
Greg Kroah-Hartman
maintainerPATCH 234/432 netfilter: nf_tables: mark set as dead when unbinding anonymous set with timeout
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
commit 552705a3650bbf46a22b1adedc1b04181490fc36 upstream.
While the rhashtable set gc runs asynchronously, a race allows it to collect elements from anonymous sets with timeouts while it is being released from the commit path.
Mingi Cho originally reported this issue in a different path in 6.1.x with a pipapo set with low timeouts which is not possible upstream since 7395dfacfff6 ("netfilter: nf_tables: use timestamp to check for set element timeout").
Fix this by setting on the dead flag for anonymous sets to skip async gc in this case.
According to 08e4c8c5919f ("netfilter: nf_tables: mark newset as dead on transaction abort"), Florian plans to accelerate abort path by releasing objects via workqueue, therefore, this sets on the dead flag for abort path too.
--- net/netfilter/nf_tables_api.c | 1 + 1 file changed, 1 insertion(+)
net/netfilter/nf_tables_api.c +1 -0
@@ -5423,6 +5423,7 @@ static void nf_tables_unbind_set(const sif (list_empty (&set->bindings) &&nft_set_is_anonymous (set)) {list_del_rcu (&set->list); + set->dead =1 ;if (event)nf_tables_set_notify (ctx, set,NFT_MSG_DELSET ,GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 235/432 netfilter: nf_tables: disallow anonymous set with timeout flag
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
commit 16603605b667b70da974bea8216c93e7db043bf1 upstream.
Anonymous sets are never used with timeout from userspace, reject this. Exception to this rule is NFT_SET_EVAL to ensure legacy meters still work.
--- net/netfilter/nf_tables_api.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/nf_tables_api.c +3 -0
@@ -5000,6 +5000,9 @@ static int nf_tables_newset(struct sk_buif ((flags & (NFT_SET_EVAL |NFT_SET_OBJECT )) == (NFT_SET_EVAL |NFT_SET_OBJECT ))return -EOPNOTSUPP ; +if ((flags & (NFT_SET_ANONYMOUS |NFT_SET_TIMEOUT |NFT_SET_EVAL )) == + (NFT_SET_ANONYMOUS |NFT_SET_TIMEOUT )) +return -EOPNOTSUPP ; } desc.dtype =0 ;
Greg Kroah-Hartman
maintainerPATCH 236/432 netfilter: nf_tables: reject constant set with timeout
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
commit 5f4fc4bd5cddb4770ab120ce44f02695c4505562 upstream.
This set combination is weird: it allows for elements to be added/deleted, but once bound to the rule it cannot be updated anymore. Eventually, all elements expire, leading to an empty set which cannot be updated anymore. Reject this flags combination.
--- net/netfilter/nf_tables_api.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/nf_tables_api.c +3 -0
@@ -5003,6 +5003,9 @@ static int nf_tables_newset(struct sk_buif ((flags & (NFT_SET_ANONYMOUS |NFT_SET_TIMEOUT |NFT_SET_EVAL )) == (NFT_SET_ANONYMOUS |NFT_SET_TIMEOUT ))return -EOPNOTSUPP ; +if ((flags & (NFT_SET_CONSTANT |NFT_SET_TIMEOUT )) == + (NFT_SET_CONSTANT |NFT_SET_TIMEOUT )) +return -EOPNOTSUPP ; } desc.dtype =0 ;
Greg Kroah-Hartman
maintainerPATCH 237/432 Drivers: hv: vmbus: Calculate ring buffer size for more efficient use of memory
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Kelley <[email protected]>
commit b8209544296edbd1af186e2ea9c648642c37b18c upstream.
The VMBUS_RING_SIZE macro adds space for a ring buffer header to the requested ring buffer size. The header size is always 1 page, and so its size varies based on the PAGE_SIZE for which the kernel is built. If the requested ring buffer size is a large power-of-2 size and the header size is small, the resulting size is inefficient in its use of memory. For example, a 512 Kbyte ring buffer with a 4 Kbyte page size results in a 516 Kbyte allocation, which is rounded to up 1 Mbyte by the memory allocator, and wastes 508 Kbytes of memory.
In such situations, the exact size of the ring buffer isn't that important, and it's OK to allocate the 4 Kbyte header at the beginning of the 512 Kbytes, leaving the ring buffer itself with just 508 Kbytes. The memory allocation can be 512 Kbytes instead of 1 Mbyte and nothing is wasted.
Update VMBUS_RING_SIZE to implement this approach for "large" ring buffer sizes. "Large" is somewhat arbitrarily defined as 8 times the size of the ring buffer header (which is of size PAGE_SIZE). For example, for 4 Kbyte PAGE_SIZE, ring buffers of 32 Kbytes and larger use the first 4 Kbytes as the ring buffer header. For 64 Kbyte PAGE_SIZE, ring buffers of 512 Kbytes and larger use the first 64 Kbytes as the ring buffer header. In both cases, smaller sizes add space for the header so the ring size isn't reduced too much by using part of the space for the header. For example, with a 64 Kbyte page size, we don't want a 128 Kbyte ring buffer to be reduced to 64 Kbytes by allocating half of the space for the header. In such a case, the memory allocation is less efficient, but it's the best that can be done.
While the new algorithm slightly changes the amount of space allocated for ring buffers by drivers that use VMBUS_RING_SIZE, the devices aren't known to be sensitive to small changes in ring buffer size, so there shouldn't be any effect.
Message-ID: <[email protected]>
--- include/linux/hyperv.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
include/linux/hyperv.h +21 -1
@@ -164,8 +164,28 @@ struct hv_ring_buffer {u8 buffer[]; } __packed; + +/* +* If the requested ring buffer size is at least 8 times the size of the +* header, steal space from the ring buffer for the header. Otherwise, add +* space for the header so that is doesn't take too much of the ring buffer +* space. +* +* The factor of 8 is somewhat arbitrary. The goal is to prevent adding a +* relatively small header (4 Kbytes on x86) to a large-ish power-of-2 ring +* buffer size (such as 128 Kbytes) and so end up making a nearly twice as +* large allocation that will be almost half wasted. As a contrasting example, +* on ARM64 with 64 Kbyte page size, we don't want to take 64 Kbytes for the +* header from a 128 Kbyte allocation, leaving only 64 Kbytes for the ring. +* In this latter case, we must add 64 Kbytes for the header and not worry +* about what's wasted. +*/ +#define VMBUS_HEADER_ADJ (payload_sz) \ + ((payload_sz) >= 8 * sizeof(struct hv_ring_buffer) ? \ + 0 : sizeof(struct hv_ring_buffer)) +/* Calculate the proper size of a ringbuffer, it must be page-aligned */ -#define VMBUS_RING_SIZE (payload_sz) PAGE_ALIGN(sizeof(struct hv_ring_buffer) + \ +#define VMBUS_RING_SIZE (payload_sz) PAGE_ALIGN(VMBUS_HEADER_ADJ(payload_sz) + \ (payload_sz))struct hv_ring_buffer_info {
Greg Kroah-Hartman
maintainerPATCH 238/432 nouveau: lock the client object tree.
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Airlie <[email protected]>
commit b7cc4ff787a572edf2c55caeffaa88cd801eb135 upstream.
It appears the client object tree has no locking unless I've missed something else. Fix races around adding/removing client objects, mostly vram bar mappings.
4562.099306] general protection fault, probably for non-canonical address 0x6677ed422bceb80c: 0000 [#1] PREEMPT SMP PTI
[ 4562.099314] CPU: 2 PID: 23171 Comm: deqp-vk Not tainted 6.8.0-rc6+ #27 [ 4562.099324] Hardware name: Gigabyte Technology Co., Ltd. Z390 I AORUS PRO WIFI/Z390 I AORUS PRO WIFI-CF, BIOS F8 11/05/2021 [ 4562.099330] RIP: 0010:nvkm_object_search+0x1d/0x70 [nouveau] [ 4562.099503] Code: 90 90 90 90 90 90 90 90 90 90 90 90 90 66 0f 1f 00 0f 1f 44 00 00 48 89 f8 48 85 f6 74 39 48 8b 87 a0 00 00 00 48 85 c0 74 12 <48> 8b 48 f8 48 39 ce 73 15 48 8b 40 10 48 85 c0 75 ee 48 c7 c0 fe [ 4562.099506] RSP: 0000:ffffa94cc420bbf8 EFLAGS: 00010206 [ 4562.099512] RAX: 6677ed422bceb814 RBX: ffff98108791f400 RCX: ffff9810f26b8f58 [ 4562.099517] RDX: 0000000000000000 RSI: ffff9810f26b9158 RDI: ffff98108791f400 [ 4562.099519] RBP: ffff9810f26b9158 R08: 0000000000000000 R09: 0000000000000000 [ 4562.099521] R10: ffffa94cc420bc48 R11: 0000000000000001 R12: ffff9810f02a7cc0 [ 4562.099526] R13: 0000000000000000 R14: 00000000000000ff R15: 0000000000000007 [ 4562.099528] FS: 00007f629c5017c0(0000) GS:ffff98142c700000(0000) knlGS:0000000000000000 [ 4562.099534] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 4562.099536] CR2: 00007f629a882000 CR3: 000000017019e004 CR4: 00000000003706f0 [ 4562.099541] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 4562.099542] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 4562.099544] Call Trace: [ 4562.099555] <TASK> [ 4562.099573] ? die_addr+0x36/0x90 [ 4562.099583] ? exc_general_protection+0x246/0x4a0 [ 4562.099593] ? asm_exc_general_protection+0x26/0x30 [ 4562.099600] ? nvkm_object_search+0x1d/0x70 [nouveau] [ 4562.099730] nvkm_ioctl+0xa1/0x250 [nouveau] [ 4562.099861] nvif_object_map_handle+0xc8/0x180 [nouveau] [ 4562.099986] nouveau_ttm_io_mem_reserve+0x122/0x270 [nouveau] [ 4562.100156] ? dma_resv_test_signaled+0x26/0xb0 [ 4562.100163] ttm_bo_vm_fault_reserved+0x97/0x3c0 [ttm] [ 4562.100182] ? __mutex_unlock_slowpath+0x2a/0x270 [ 4562.100189] nouveau_ttm_fault+0x69/0xb0 [nouveau] [ 4562.100356] __do_fault+0x32/0x150 [ 4562.100362] do_fault+0x7c/0x560 [ 4562.100369] __handle_mm_fault+0x800/0xc10 [ 4562.100382] handle_mm_fault+0x17c/0x3e0 [ 4562.100388] do_user_addr_fault+0x208/0x860 [ 4562.100395] exc_page_fault+0x7f/0x200 [ 4562.100402] asm_exc_page_fault+0x26/0x30 [ 4562.100412] RIP: 0033:0x9b9870 [ 4562.100419] Code: 85 a8 f7 ff ff 8b 8d 80 f7 ff ff 89 08 e9 18 f2 ff ff 0f 1f 84 00 00 00 00 00 44 89 32 e9 90 fa ff ff 0f 1f 84 00 00 00 00 00 <44> 89 32 e9 f8 f1 ff ff 0f 1f 84 00 00 00 00 00 66 44 89 32 e9 e7 [ 4562.100422] RSP: 002b:00007fff9ba2dc70 EFLAGS: 00010246 [ 4562.100426] RAX: 0000000000000004 RBX: 000000000dd65e10 RCX: 000000fff0000000 [ 4562.100428] RDX: 00007f629a882000 RSI: 00007f629a882000 RDI: 0000000000000066 [ 4562.100432] RBP: 00007fff9ba2e570 R08: 0000000000000000 R09: 0000000123ddf000 [ 4562.100434] R10: 0000000000000001 R11: 0000000000000246 R12: 000000007fffffff [ 4562.100436] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 [ 4562.100446] </TASK> [ 4562.100448] Modules linked in: nf_conntrack_netbios_ns nf_conntrack_broadcast nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reject_ipv4 nf_reject_ipv6 nft_reject nft_ct nft_chain_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 ip_set nf_tables libcrc32c nfnetlink cmac bnep sunrpc iwlmvm intel_rapl_msr intel_rapl_common snd_sof_pci_intel_cnl x86_pkg_temp_thermal intel_powerclamp snd_sof_intel_hda_common mac80211 coretemp snd_soc_acpi_intel_match kvm_intel snd_soc_acpi snd_soc_hdac_hda snd_sof_pci snd_sof_xtensa_dsp snd_sof_intel_hda_mlink snd_sof_intel_hda snd_sof kvm snd_sof_utils snd_soc_core snd_hda_codec_realtek libarc4 snd_hda_codec_generic snd_compress snd_hda_ext_core vfat fat snd_hda_intel snd_intel_dspcfg irqbypass iwlwifi snd_hda_codec snd_hwdep snd_hda_core btusb btrtl mei_hdcp iTCO_wdt rapl mei_pxp btintel snd_seq iTCO_vendor_support btbcm snd_seq_device intel_cstate bluetooth snd_pcm cfg80211 intel_wmi_thunderbolt wmi_bmof intel_uncore snd_timer mei_me snd ecdh_generic i2c_i801 [ 4562.100541] ecc mei i2c_smbus soundcore rfkill intel_pch_thermal acpi_pad zram nouveau drm_ttm_helper ttm gpu_sched i2c_algo_bit drm_gpuvm drm_exec mxm_wmi drm_display_helper drm_kms_helper drm crct10dif_pclmul crc32_pclmul nvme e1000e crc32c_intel nvme_core ghash_clmulni_intel video wmi pinctrl_cannonlake ip6_tables ip_tables fuse [ 4562.100616] ---[ end trace 0000000000000000 ]---
--- drivers/gpu/drm/nouveau/include/nvkm/core/client.h | 1 drivers/gpu/drm/nouveau/nvkm/core/client.c | 1 drivers/gpu/drm/nouveau/nvkm/core/object.c | 26 ++++++++++++++++----- 3 files changed, 22 insertions(+), 6 deletions(-)
drivers/gpu/drm/nouveau/include/nvkm/core/client.h +1 -0
@@ -11,6 +11,7 @@ struct nvkm_client {u32 debug;struct rb_root objroot; +spinlock_t obj_lock;void *data;int (*event)(u64 token,void *argv,u32 argc);
drivers/gpu/drm/nouveau/nvkm/core/client.c +1 -0
@@ -180,6 +180,7 @@ nvkm_client_new(const char *name, u64 de client->device = device; client->debug =nvkm_dbgopt (dbg,"CLIENT" ); client->objroot =RB_ROOT ; +spin_lock_init (&client->obj_lock); client->event = event;INIT_LIST_HEAD (&client->umem);spin_lock_init (&client->lock);
drivers/gpu/drm/nouveau/nvkm/core/object.c +20 -6
@@ -30,8 +30,10 @@ nvkm_object_search(struct nvkm_client *c const struct nvkm_object_func *func) {struct nvkm_object *object; +unsigned long flags;if (handle) { +spin_lock_irqsave (&client->obj_lock, flags);struct rb_node *node = client->objroot.rb_node;while (node) { object =rb_entry (node,typeof (*object), node);
@@ -40,9 +42,12 @@ nvkm_object_search(struct nvkm_client *celse if (handle > object->object) node = node->rb_right; -else +else { +spin_unlock_irqrestore (&client->obj_lock, flags); goto done; + } } +spin_unlock_irqrestore (&client->obj_lock, flags);return ERR_PTR (-ENOENT ); }else { object = &client->object;
@@ -57,30 +62,39 @@ done:void nvkm_object_remove (struct nvkm_object *object) { +unsigned long flags; + +spin_lock_irqsave (&object->client->obj_lock, flags);if (!RB_EMPTY_NODE (&object->node))rb_erase (&object->node, &object->client->objroot); +spin_unlock_irqrestore (&object->client->obj_lock, flags); }bool nvkm_object_insert (struct nvkm_object *object) { -struct rb_node **ptr = &object->client->objroot.rb_node; +struct rb_node **ptr;struct rb_node *parent =NULL ; +unsigned long flags; +spin_lock_irqsave (&object->client->obj_lock, flags); + ptr = &object->client->objroot.rb_node;while (*ptr) {struct nvkm_object *this =rb_entry (*ptr,typeof (*this), node); parent = *ptr; -if (object->object < this->object) +if (object->object < this->object) { ptr = &parent->rb_left; -else -if (object->object > this->object) + }else if (object->object > this->object) { ptr = &parent->rb_right; -else + }else { +spin_unlock_irqrestore (&object->client->obj_lock, flags);return false; + } }rb_link_node (&object->node, parent, ptr);rb_insert_color (&object->node, &object->client->objroot); +spin_unlock_irqrestore (&object->client->obj_lock, flags);return true; }
Greg Kroah-Hartman
maintainerPATCH 239/432 drm/nouveau: fix stale locked mutex in nouveau_gem_ioctl_pushbuf
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karol Herbst <[email protected]>
commit daf8739c3322a762ce84f240f50e0c39181a41ab upstream.
If VM_BIND is enabled on the client the legacy submission ioctl can't be used, however if a client tries to do so regardless it will return an error. In this case the clients mutex remained unlocked leading to a deadlock inside nouveau_drm_postclose or any other nouveau ioctl call.
--- drivers/gpu/drm/nouveau/nouveau_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_gem.c +1 -1
@@ -758,7 +758,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_devreturn -ENOMEM ;if (unlikely (nouveau_cli_uvmm (cli))) -return -ENOSYS ; +return nouveau_abi16_put (abi16, -ENOSYS );list_for_each_entry (temp, &abi16->channels, head) {if (temp->chan->chid == req->channel) {
Greg Kroah-Hartman
maintainerPATCH 240/432 crypto: rk3288 - Fix use after free in unprepare
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
commit c0afb6b88fbbc177fa322a835f874be217bffe45 upstream.
The unprepare call must be carried out before the finalize call as the latter can free the request.
--- drivers/crypto/rockchip/rk3288_crypto_ahash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/rockchip/rk3288_crypto_ahash.c +2 -2
@@ -332,12 +332,12 @@ static int rk_hash_run(struct crypto_eng theend:pm_runtime_put_autosuspend (rkc->dev); +rk_hash_unprepare (engine, breq); +local_bh_disable ();crypto_finalize_hash_request (engine, breq, err);local_bh_enable (); -rk_hash_unprepare (engine, breq); -return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 241/432 crypto: sun8i-ce - Fix use after free in unprepare
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Skvortsov <[email protected]>
commit 183420038444547c149a0fc5f58e792c2752860c upstream.
sun8i_ce_cipher_unprepare should be called before crypto_finalize_skcipher_request, because client callbacks may immediately free memory, that isn't needed anymore. But it will be used by unprepare after free. Before removing prepare/unprepare callbacks it was handled by crypto engine in crypto_finalize_request.
Usually that results in a pointer dereference problem during a in crypto selftest.
Unable to handle kernel NULL pointer dereference at
virtual address 0000000000000030
Mem abort info:
ESR = 0x0000000096000004
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x04: level 0 translation fault
Data abort info:
ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
CM = 0, WnR = 0, TnD = 0, TagAccess = 0
GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
user pgtable: 4k pages, 48-bit VAs, pgdp=000000004716d000
[0000000000000030] pgd=0000000000000000, p4d=0000000000000000
Internal error: Oops: 0000000096000004 [#1] SMPThis problem is detected by KASAN as well.
==================================================================
BUG: KASAN: slab-use-after-free in sun8i_ce_cipher_do_one+0x6e8/0xf80 [sun8i_ce] Read of size 8 at addr ffff00000dcdc040 by task 1c15000.crypto-/373 Hardware name: Pine64 PinePhone (1.2) (DT) Call trace: dump_backtrace+0x9c/0x128 show_stack+0x20/0x38 dump_stack_lvl+0x48/0x60 print_report+0xf8/0x5d8 kasan_report+0x90/0xd0 __asan_load8+0x9c/0xc0 sun8i_ce_cipher_do_one+0x6e8/0xf80 [sun8i_ce] crypto_pump_work+0x354/0x620 [crypto_engine] kthread_worker_fn+0x244/0x498 kthread+0x168/0x178 ret_from_fork+0x10/0x20 Allocated by task 379: kasan_save_stack+0x3c/0x68 kasan_set_track+0x2c/0x40 kasan_save_alloc_info+0x24/0x38 __kasan_kmalloc+0xd4/0xd8 __kmalloc+0x74/0x1d0 alg_test_skcipher+0x90/0x1f0 alg_test+0x24c/0x830 cryptomgr_test+0x38/0x60 kthread+0x168/0x178 ret_from_fork+0x10/0x20 Freed by task 379: kasan_save_stack+0x3c/0x68 kasan_set_track+0x2c/0x40 kasan_save_free_info+0x38/0x60 __kasan_slab_free+0x100/0x170 slab_free_freelist_hook+0xd4/0x1e8 __kmem_cache_free+0x15c/0x290 kfree+0x74/0x100 kfree_sensitive+0x80/0xb0 alg_test_skcipher+0x12c/0x1f0 alg_test+0x24c/0x830 cryptomgr_test+0x38/0x60 kthread+0x168/0x178 ret_from_fork+0x10/0x20 The buggy address belongs to the object at ffff00000dcdc000 which belongs to the cache kmalloc-256 of size 256 The buggy address is located 64 bytes inside of freed 256-byte region [ffff00000dcdc000, ffff00000dcdc100)
--- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c | 34 ++++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +17 -17
@@ -299,22 +299,6 @@ theend:return err; } -static void sun8i_ce_cipher_run (struct crypto_engine *engine,void *areq) -{ - struct skcipher_request *breq = container_of(areq, struct skcipher_request, base); -struct crypto_skcipher *tfm =crypto_skcipher_reqtfm (breq); -struct sun8i_cipher_tfm_ctx *op =crypto_skcipher_ctx (tfm); -struct sun8i_ce_dev *ce = op->ce; -struct sun8i_cipher_req_ctx *rctx =skcipher_request_ctx (breq); -int flow, err; - - flow = rctx->flow; - err =sun8i_ce_run_task (ce, flow,crypto_tfm_alg_name (breq->base.tfm)); -local_bh_disable (); -crypto_finalize_skcipher_request (engine, breq, err); -local_bh_enable (); -} -static void sun8i_ce_cipher_unprepare (struct crypto_engine *engine,void *async_req) {
@@ -360,6 +344,23 @@ static void sun8i_ce_cipher_unprepare(stdma_unmap_single (ce->dev, rctx->addr_key, op->keylen,DMA_TO_DEVICE ); } +static void sun8i_ce_cipher_run (struct crypto_engine *engine,void *areq) +{ + struct skcipher_request *breq = container_of(areq, struct skcipher_request, base); +struct crypto_skcipher *tfm =crypto_skcipher_reqtfm (breq); +struct sun8i_cipher_tfm_ctx *op =crypto_skcipher_ctx (tfm); +struct sun8i_ce_dev *ce = op->ce; +struct sun8i_cipher_req_ctx *rctx =skcipher_request_ctx (breq); +int flow, err; + + flow = rctx->flow; + err =sun8i_ce_run_task (ce, flow,crypto_tfm_alg_name (breq->base.tfm)); +sun8i_ce_cipher_unprepare (engine, areq); +local_bh_disable (); +crypto_finalize_skcipher_request (engine, breq, err); +local_bh_enable (); +} +int sun8i_ce_cipher_do_one (struct crypto_engine *engine,void *areq) {int err =sun8i_ce_cipher_prepare (engine, areq);
@@ -368,7 +369,6 @@ int sun8i_ce_cipher_do_one(struct cryptoreturn err;sun8i_ce_cipher_run (engine, areq); -sun8i_ce_cipher_unprepare (engine, areq);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 242/432 Revert "crypto: pkcs7 - remove sha1 support"
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 203a6763ab699da0568fd2b76303d03bb121abd4 upstream.
This reverts commit 16ab7cb5825fc3425c16ad2c6e53d827f382d7c6 because it broke iwd. iwd uses the KEYCTL_PKEY_* UAPIs via its dependency libell, and apparently it is relying on SHA-1 signature support. These UAPIs are fairly obscure, and their documentation does not mention which algorithms they support. iwd really should be using a properly supported userspace crypto library instead. Regardless, since something broke we have to revert the change.
It may be possible that some parts of this commit can be reinstated without breaking iwd (e.g. probably the removal of MODULE_SIG_SHA1), but for now this just does a full revert to get things working again.
--- crypto/asymmetric_keys/mscode_parser.c | 3 + crypto/asymmetric_keys/pkcs7_parser.c | 4 + crypto/asymmetric_keys/public_key.c | 3 - crypto/asymmetric_keys/signature.c | 2 crypto/asymmetric_keys/x509_cert_parser.c | 8 +++ crypto/testmgr.h | 80 ++++++++++++++++++++++++++++++ include/linux/oid_registry.h | 4 + kernel/module/Kconfig | 5 + 8 files changed, 107 insertions(+), 2 deletions(-)
crypto/asymmetric_keys/mscode_parser.c +3 -0
@@ -75,6 +75,9 @@ int mscode_note_digest_algo(void *contex oid =look_up_OID (value, vlen);switch (oid) { +case OID_sha1: + ctx->digest_algo ="sha1" ; +break ;case OID_sha256: ctx->digest_algo ="sha256" ;break ;
crypto/asymmetric_keys/pkcs7_parser.c +4 -0
@@ -227,6 +227,9 @@ int pkcs7_sig_note_digest_algo(void *construct pkcs7_parse_context *ctx = context;switch (ctx->last_oid) { +case OID_sha1: + ctx->sinfo->sig->hash_algo ="sha1" ; +break ;case OID_sha256: ctx->sinfo->sig->hash_algo ="sha256" ;break ;
@@ -278,6 +281,7 @@ int pkcs7_sig_note_pkey_algo(void *conte ctx->sinfo->sig->pkey_algo ="rsa" ; ctx->sinfo->sig->encoding ="pkcs1" ;break ; +case OID_id_ecdsa_with_sha1:case OID_id_ecdsa_with_sha224:case OID_id_ecdsa_with_sha256:case OID_id_ecdsa_with_sha384:
crypto/asymmetric_keys/public_key.c +2 -1
@@ -115,7 +115,8 @@ software_key_determine_akcipher(const st*/ if (!hash_algo)return -EINVAL ; - if (strcmp(hash_algo, "sha224") != 0 && + if (strcmp(hash_algo, "sha1") != 0 && + strcmp(hash_algo, "sha224") != 0 && strcmp(hash_algo, "sha256") != 0 && strcmp(hash_algo, "sha384") != 0 && strcmp(hash_algo, "sha512") != 0 &&
crypto/asymmetric_keys/signature.c +1 -1
@@ -115,7 +115,7 @@ EXPORT_SYMBOL_GPL(decrypt_blob);* Sign the specified data blob using the private key specified by params->key. * The signature is wrapped in an encoding if params->encoding is specified * (eg. "pkcs1"). If the encoding needs to know the digest type, this can be -* passed through params->hash_algo (eg. "sha512"). +* passed through params->hash_algo (eg. "sha1"). * * Returns the length of the data placed in the signature buffer or an error. */
crypto/asymmetric_keys/x509_cert_parser.c +8 -0
@@ -198,6 +198,10 @@ int x509_note_sig_algo(void *context, sidefault :return -ENOPKG ;/* Unsupported combination */ +case OID_sha1WithRSAEncryption: + ctx->cert->sig->hash_algo ="sha1" ; + goto rsa_pkcs1; +case OID_sha256WithRSAEncryption: ctx->cert->sig->hash_algo ="sha256" ; goto rsa_pkcs1;
@@ -214,6 +218,10 @@ int x509_note_sig_algo(void *context, si ctx->cert->sig->hash_algo ="sha224" ; goto rsa_pkcs1; +case OID_id_ecdsa_with_sha1: + ctx->cert->sig->hash_algo ="sha1" ; + goto ecdsa; +case OID_id_rsassa_pkcs1_v1_5_with_sha3_256: ctx->cert->sig->hash_algo ="sha3-256" ; goto rsa_pkcs1;
crypto/testmgr.h +80 -0
98 lines not on this page · raw message
include/linux/oid_registry.h +4 -0
@@ -17,10 +17,12 @@* build_OID_registry.pl to generate the data for look_up_OID(). */ enum OID { + OID_id_dsa_with_sha1,/* 1.2.840.10030.4.3 */ OID_id_dsa,/* 1.2.840.10040.4.1 */ OID_id_ecPublicKey,/* 1.2.840.10045.2.1 */ OID_id_prime192v1,/* 1.2.840.10045.3.1.1 */ OID_id_prime256v1,/* 1.2.840.10045.3.1.7 */ + OID_id_ecdsa_with_sha1,/* 1.2.840.10045.4.1 */ OID_id_ecdsa_with_sha224,/* 1.2.840.10045.4.3.1 */ OID_id_ecdsa_with_sha256,/* 1.2.840.10045.4.3.2 */ OID_id_ecdsa_with_sha384,/* 1.2.840.10045.4.3.3 */
@@ -28,6 +30,7 @@ enum OID {/* PKCS#1 {iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) pkcs-1(1)} */ OID_rsaEncryption,/* 1.2.840.113549.1.1.1 */ + OID_sha1WithRSAEncryption,/* 1.2.840.113549.1.1.5 */ OID_sha256WithRSAEncryption,/* 1.2.840.113549.1.1.11 */ OID_sha384WithRSAEncryption,/* 1.2.840.113549.1.1.12 */ OID_sha512WithRSAEncryption, /* 1.2.840.113549.1.1.13 */
@@ -64,6 +67,7 @@ enum OID {OID_PKU2U ,/* 1.3.5.1.5.2.7 */ OID_Scram,/* 1.3.6.1.5.5.14 */ OID_certAuthInfoAccess,/* 1.3.6.1.5.5.7.1.1 */ + OID_sha1,/* 1.3.14.3.2.26 */ OID_id_ansip384r1,/* 1.3.132.0.34 */ OID_sha256,/* 2.16.840.1.101.3.4.2.1 */ OID_sha384, /* 2.16.840.1.101.3.4.2.2 */
kernel/module/Kconfig +5 -0
@@ -236,6 +236,10 @@ choice possible to load a signed module containing the algorithm to check the signature on that module. +config MODULE_SIG_SHA1 + bool "Sign modules with SHA-1" + select CRYPTO_SHA1 + config MODULE_SIG_SHA256 bool "Sign modules with SHA-256" select CRYPTO_SHA256
@@ -265,6 +269,7 @@ endchoice config MODULE_SIG_HASH string depends on MODULE_SIG || IMA_APPRAISE_MODSIG + default "sha1" if MODULE_SIG_SHA1 default "sha256" if MODULE_SIG_SHA256 default "sha384" if MODULE_SIG_SHA384 default "sha512" if MODULE_SIG_SHA512
Greg Kroah-Hartman
maintainerPATCH 243/432 xfrm: Avoid clang fortify warning in copy_to_user_tmpl()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 1a807e46aa93ebad1dfbed4f82dc3bf779423a6e upstream.
After a couple recent changes in LLVM, there is a warning (or error with CONFIG_WERROR=y or W=e) from the compile time fortify source routines, specifically the memset() in copy_to_user_tmpl().
In file included from net/xfrm/xfrm_user.c:14:
...
include/linux/fortify-string.h:438:4: error: call to '__write_overflow_field' declared with 'warning' attribute: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror,-Wattribute-warning]
438 | __write_overflow_field(p_size_field, size);
| ^1 error generated.
While ->xfrm_nr has been validated against XFRM_MAX_DEPTH when its value is first assigned in copy_templates() by calling validate_tmpl() first (so there should not be any issue in practice), LLVM/clang cannot really deduce that across the boundaries of these functions. Without that knowledge, it cannot assume that the loop stops before i is greater than XFRM_MAX_DEPTH, which would indeed result a stack buffer overflow in the memset().
To make the bounds of ->xfrm_nr clear to the compiler and add additional defense in case copy_to_user_tmpl() is ever used in a path where ->xfrm_nr has not been properly validated against XFRM_MAX_DEPTH first, add an explicit bound check and early return, which clears up the warning.
--- net/xfrm/xfrm_user.c | 3 +++ 1 file changed, 3 insertions(+)
net/xfrm/xfrm_user.c +3 -0
@@ -2017,6 +2017,9 @@ static int copy_to_user_tmpl(struct xfrmif (xp->xfrm_nr ==0 )return 0 ; +if (xp->xfrm_nr >XFRM_MAX_DEPTH ) +return -ENOBUFS ; +for (i =0 ; i < xp->xfrm_nr; i++) {struct xfrm_user_tmpl *up = &vec[i];struct xfrm_tmpl *kp = &xp->xfrm_vec[i];
Greg Kroah-Hartman
maintainerPATCH 244/432 mm, mmap: fix vma_merge() case 7 with vma_ops->close
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vlastimil Babka <[email protected]>
commit fc0c8f9089c20d198d8fe51ddc28bfa1af588dce upstream.
When debugging issues with a workload using SysV shmem, Michal Hocko has come up with a reproducer that shows how a series of mprotect() operations can result in an elevated shm_nattch and thus leak of the resource.
The problem is caused by wrong assumptions in vma_merge() commit 714965ca8252 ("mm/mmap: start distinguishing if vma can be removed in mergeability test"). The shmem vmas have a vma_ops->close callback that decrements shm_nattch, and we remove the vma without calling it.
vma_merge() has thus historically avoided merging vma's with vma_ops->close and commit 714965ca8252 was supposed to keep it that way. It relaxed the checks for vma_ops->close in can_vma_merge_after() assuming that it is never called on a vma that would be a candidate for removal. However, the vma_merge() code does also use the result of this check in the decision to remove a different vma in the merge case 7.
A robust solution would be to refactor vma_merge() code in a way that the vma_ops->close check is only done for vma's that are actually going to be removed, and not as part of the preliminary checks. That would both solve the existing bug, and also allow additional merges that the checks currently prevent unnecessarily in some cases.
However to fix the existing bug first with a minimized risk, and for easier stable backports, this patch only adds a vma_ops->close check to the buggy case 7 specifically. All other cases of vma removal are covered by the can_vma_merge_before() check that includes the test for vma_ops->close.
The reproducer code, adapted from Michal Hocko's code:
int main(int argc, char *argv[]) {
int segment_id;
size_t segment_size = 20 * PAGE_SIZE;
char * sh_mem;
struct shmid_ds shmid_ds;
key_t key = 0x1234;
segment_id = shmget(key, segment_size,
IPC_CREAT | IPC_EXCL | S_IRUSR | S_IWUSR);
sh_mem = (char *)shmat(segment_id, NULL, 0);
mprotect(sh_mem + 2*PAGE_SIZE, PAGE_SIZE, PROT_NONE);
mprotect(sh_mem + PAGE_SIZE, PAGE_SIZE, PROT_WRITE);
mprotect(sh_mem + 2*PAGE_SIZE, PAGE_SIZE, PROT_WRITE);
shmdt(sh_mem);
shmctl(segment_id, IPC_STAT, &shmid_ds);
printf("nattch after shmdt(): %lu (expected: 0)\n", shmid_ds.shm_nattch); if (shmctl(segment_id, IPC_RMID, 0))
printf("IPCRM failed %d\n", errno); return (shmid_ds.shm_nattch) ? 1 : 0;
}
--- mm/mmap.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
mm/mmap.c +9 -1
@@ -954,13 +954,21 @@ static struct vm_area_struct }else if (merge_prev) {/* case 2 */ if (curr) {vma_start_write (curr); - err =dup_anon_vma (prev, curr, &anon_dup);if (end == curr->vm_end) {/* case 7 */ +/* +* can_vma_merge_after() assumed we would not be +* removing prev vma, so it skipped the check +* for vm_ops->close, but we are removing curr +*/ +if (curr->vm_ops && curr->vm_ops->close) + err = -EINVAL ; remove = curr; }else {/* case 5 */ adjust = curr; adj_start = (end - curr->vm_start); } +if (!err) + err =dup_anon_vma (prev, curr, &anon_dup); } }else {/* merge_next */ vma_start_write (next);
Greg Kroah-Hartman
maintainerPATCH 245/432 selftests: mptcp: diag: return KSFT_FAIL not test_cnt
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geliang Tang <[email protected]>
commit 45bcc0346561daa3f59e19a753cc7f3e08e8dff1 upstream.
The test counter 'test_cnt' should not be returned in diag.sh, e.g. what if only the 4th test fail? Will do 'exit 4' which is 'exit ${KSFT_SKIP}', the whole test will be marked as skipped instead of 'failed'!
So we should do ret=${KSFT_FAIL} instead.
--- tools/testing/selftests/net/mptcp/diag.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/net/mptcp/diag.sh +3 -3
@@ -69,7 +69,7 @@ __chk_nr() else echo "[ fail ] expected $expected found $nr" mptcp_lib_result_fail "${msg}" - ret=$test_cnt + ret=${KSFT_FAIL} fi else echo "[ ok ]"
@@ -115,11 +115,11 @@ wait_msk_nr() if [ $i -ge $timeout ]; then echo "[ fail ] timeout while expecting $expected max $max last $nr" mptcp_lib_result_fail "${msg} # timeout" - ret=$test_cnt + ret=${KSFT_FAIL} elif [ $nr != $expected ]; then echo "[ fail ] expected $expected found $nr" mptcp_lib_result_fail "${msg} # unexpected result" - ret=$test_cnt + ret=${KSFT_FAIL} else echo "[ ok ]" mptcp_lib_result_pass "${msg}"
Greg Kroah-Hartman
maintainerPATCH 246/432 usb: typec: tpcm: Fix PORT_RESET behavior for self powered devices
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Badhri Jagan Sridharan <[email protected]>
commit 197331b27ac890d0209232d5f669830cd00e8918 upstream.
While commit 69f89168b310 ("usb: typec: tpcm: Fix issues with power being removed during reset") fixes the boot issues for bus powered devices such as LibreTech Renegade Elite/Firefly, it trades off the CC pins NOT being Hi-Zed during errory recovery (i.e PORT_RESET) for devices which are NOT bus powered(a.k.a self powered). This change Hi-Zs the CC pins only for self powered devices, thus preventing brown out for bus powered devices
Adhering to spec is gaining more importance due to the Common charger initiative enforced by the European Union.
Quoting from the spec:
4.5.2.2.2.1 ErrorRecovery State Requirements
The port shall not drive VBUS or VCONN, and shall present a high-impedance to ground (above zOPEN) on its CC1 and CC2 pins.
Hi-Zing the CC pins is the inteded behavior for PORT_RESET. CC pins are set to default state after tErrorRecovery in PORT_RESET_WAIT_OFF.
4.5.2.2.2.2 Exiting From ErrorRecovery State
A Sink shall transition to Unattached.SNK after tErrorRecovery. A Source shall transition to Unattached.SRC after tErrorRecovery.
--- drivers/usb/typec/tcpm/tcpm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/tcpm.c +5 -2
@@ -4859,8 +4859,11 @@ static void run_state_machine(struct tcpbreak ;case PORT_RESET :tcpm_reset_port (port); -tcpm_set_cc (port,tcpm_default_state (port) ==SNK_UNATTACHED ? -TYPEC_CC_RD :tcpm_rp_cc (port)); +if (port->self_powered) +tcpm_set_cc (port,TYPEC_CC_OPEN ); +else +tcpm_set_cc (port,tcpm_default_state (port) ==SNK_UNATTACHED ? +TYPEC_CC_RD :tcpm_rp_cc (port));tcpm_set_state (port,PORT_RESET_WAIT_OFF ,PD_T_ERROR_RECOVERY );break ;
Greg Kroah-Hartman
maintainerPATCH 247/432 thunderbolt: Fix NULL pointer dereference in tb_port_update_credits()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mika Westerberg <[email protected]>
commit d3d17e23d1a0d1f959b4fa55b35f1802d9c584fa upstream.
Olliver reported that his system crashes when plugging in Thunderbolt 1 device:
BUG: kernel NULL pointer dereference, address: 0000000000000020 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP NOPTI RIP: 0010:tb_port_do_update_credits+0x1b/0x130 [thunderbolt] Call Trace: <TASK> ? __die+0x23/0x70 ? page_fault_oops+0x171/0x4e0 ? exc_page_fault+0x7f/0x180 ? asm_exc_page_fault+0x26/0x30 ? tb_port_do_update_credits+0x1b/0x130 ? tb_switch_update_link_attributes+0x83/0xd0 tb_switch_add+0x7a2/0xfe0 tb_scan_port+0x236/0x6f0 tb_handle_hotplug+0x6db/0x900 process_one_work+0x171/0x340 worker_thread+0x27b/0x3a0 ? __pfx_worker_thread+0x10/0x10 kthread+0xe5/0x120 ? __pfx_kthread+0x10/0x10 ret_from_fork+0x31/0x50 ? __pfx_kthread+0x10/0x10 ret_from_fork_asm+0x1b/0x30 </TASK>
This is due the fact that some Thunderbolt 1 devices only have one lane adapter. Fix this by checking for the lane 1 before we read its credits.
--- drivers/thunderbolt/switch.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/thunderbolt/switch.c +3 -0
@@ -1265,6 +1265,9 @@ int tb_port_update_credits(struct tb_por ret =tb_port_do_update_credits (port);if (ret)return ret; + +if (!port->dual_link_port) +return 0 ;return tb_port_do_update_credits (port->dual_link_port); }
Greg Kroah-Hartman
maintainerPATCH 248/432 cgroup/cpuset: Fix retval in update_cpumask()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kamalesh Babulal <[email protected]>
commit 25125a4762835d62ba1e540c1351d447fc1f6c7c upstream.
The update_cpumask(), checks for newly requested cpumask by calling validate_change(), which returns an error on passing an invalid set of cpu(s). Independent of the error returned, update_cpumask() always returns zero, suppressing the error and returning success to the user on writing an invalid cpu range for a cpuset. Fix it by returning retval instead, which is returned by validate_change().
--- kernel/cgroup/cpuset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cgroup/cpuset.c +1 -1
@@ -2466,7 +2466,7 @@ static int update_cpumask(struct cpusetupdate_partition_sd_lb (cs, old_prs); out_free:free_cpumasks (NULL , &tmp); -return 0 ; +return retval; }/**
Greg Kroah-Hartman
maintainerPATCH 249/432 cgroup/cpuset: Fix a memory leak in update_exclusive_cpumask()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waiman Long <[email protected]>
commit 66f40b926dd249f74334a22162c09e7ec1ec5b07 upstream.
Fix a possible memory leak in update_exclusive_cpumask() by moving the alloc_cpumasks() down after the validate_change() check which can fail and still before the temporary cpumasks are needed.
--- kernel/cgroup/cpuset.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/cgroup/cpuset.c +3 -3
@@ -2502,9 +2502,6 @@ static int update_exclusive_cpumask(struif (cpumask_equal (cs->exclusive_cpus, trialcs->exclusive_cpus))return 0 ; -if (alloc_cpumasks (NULL , &tmp)) -return -ENOMEM ; -if (*buf)compute_effective_exclusive_cpumask (trialcs,NULL );
@@ -2519,6 +2516,9 @@ static int update_exclusive_cpumask(struif (retval)return retval; +if (alloc_cpumasks (NULL , &tmp)) +return -ENOMEM ; +if (old_prs) {if (cpumask_empty (trialcs->effective_xcpus)) { invalidate = true;
Greg Kroah-Hartman
maintainerPATCH 250/432 Input: xpad - add additional HyperX Controller Identifiers
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Nguyen <[email protected]>
commit dd50f771af20fb02b1aecde04fbd085c872a9139 upstream.
Add additional HyperX device identifiers to xpad_device and xpad_table.
--- drivers/input/joystick/xpad.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/input/joystick/xpad.c +6 -0
@@ -130,7 +130,12 @@ static const struct xpad_device { { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 }, { 0x03eb, 0xff01, "Wooting One (Legacy)", 0, XTYPE_XBOX360 }, { 0x03eb, 0xff02, "Wooting Two (Legacy)", 0, XTYPE_XBOX360 }, + { 0x03f0, 0x038D, "HyperX Clutch", 0, XTYPE_XBOX360 }, /* wired */ + { 0x03f0, 0x048D, "HyperX Clutch", 0, XTYPE_XBOX360 }, /* wireless */ { 0x03f0, 0x0495, "HyperX Clutch Gladiate", 0, XTYPE_XBOXONE }, + { 0x03f0, 0x07A0, "HyperX Clutch Gladiate RGB", 0, XTYPE_XBOXONE }, + { 0x03f0, 0x08B6, "HyperX Clutch Gladiate", 0, XTYPE_XBOXONE }, /* v2 */ + { 0x03f0, 0x09B4, "HyperX Clutch Tanto", 0, XTYPE_XBOXONE }, { 0x044f, 0x0f00, "Thrustmaster Wheel", 0, XTYPE_XBOX }, { 0x044f, 0x0f03, "Thrustmaster Wheel", 0, XTYPE_XBOX }, { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
@@ -463,6 +468,7 @@ static const struct usb_device_id xpad_t { USB_INTERFACE_INFO('X', 'B', 0) }, /* Xbox USB-IF not-approved class */XPAD_XBOX360_VENDOR (0x0079 ),/* GPD Win 2 controller */ XPAD_XBOX360_VENDOR (0x03eb ),/* Wooting Keyboards (Legacy) */ +XPAD_XBOX360_VENDOR (0x03f0 ),/* HP HyperX Xbox 360 controllers */ XPAD_XBOXONE_VENDOR (0x03f0 ),/* HP HyperX Xbox One controllers */ XPAD_XBOX360_VENDOR (0x044f ),/* Thrustmaster Xbox 360 controllers */ XPAD_XBOX360_VENDOR(0x045e), /* Microsoft Xbox 360 controllers */
Greg Kroah-Hartman
maintainerPATCH 251/432 init/Kconfig: lower GCC version check for -Warray-bounds
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 3e00f5802fabf2f504070a591b14b648523ede13 upstream.
We continue to see false positives from -Warray-bounds even in GCC 10, which is getting reported in a few places[1] still:
security/security.c:811:2: warning: `memcpy' offset 32 is out of the bounds [0, 0] [-Warray-bounds]
Lower the GCC version check from 11 to 10.
--- init/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
init/Kconfig +3 -3
@@ -876,14 +876,14 @@ config CC_IMPLICIT_FALLTHROUGH default "-Wimplicit-fallthrough=5" if CC_IS_GCC && $(cc-option,-Wimplicit-fallthrough=5) default "-Wimplicit-fallthrough" if CC_IS_CLANG && $(cc-option,-Wunreachable-code-fallthrough) -# Currently, disable gcc-11+ array-bounds globally. +# Currently, disable gcc-10+ array-bounds globally. # It's still broken in gcc-13, so no upper bound yet. -config GCC11_NO_ARRAY_BOUNDS +config GCC10_NO_ARRAY_BOUNDS def_bool y config CC_NO_ARRAY_BOUNDS bool - default y if CC_IS_GCC && GCC_VERSION >= 110000 && GCC11_NO_ARRAY_BOUNDS + default y if CC_IS_GCC && GCC_VERSION >= 100000 && GCC10_NO_ARRAY_BOUNDS # # For architectures that know their GCC __int128 support is sound
Greg Kroah-Hartman
maintainerPATCH 252/432 firewire: ohci: prevent leak of left-over IRQ on unbind
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Edmund Raile <[email protected]>
commit 575801663c7dc38f826212b39e3b91a4a8661c33 upstream.
Commit 5a95f1ded28691e6 ("firewire: ohci: use devres for requested IRQ") also removed the call to free_irq() in pci_remove(), leading to a leftover irq of devm_request_irq() at pci_disable_msi() in pci_remove() when unbinding the driver from the device
remove_proc_entry: removing non-empty directory 'irq/136', leaking at least 'firewire_ohci'
Call Trace:
? remove_proc_entry+0x19c/0x1c0
? __warn+0x81/0x130
? remove_proc_entry+0x19c/0x1c0
? report_bug+0x171/0x1a0
? console_unlock+0x78/0x120
? handle_bug+0x3c/0x80
? exc_invalid_op+0x17/0x70
? asm_exc_invalid_op+0x1a/0x20
? remove_proc_entry+0x19c/0x1c0
unregister_irq_proc+0xf4/0x120
free_desc+0x3d/0xe0
? kfree+0x29f/0x2f0
irq_free_descs+0x47/0x70
msi_domain_free_locked.part.0+0x19d/0x1d0
msi_domain_free_irqs_all_locked+0x81/0xc0
pci_free_msi_irqs+0x12/0x40
pci_disable_msi+0x4c/0x60
pci_remove+0x9d/0xc0 [firewire_ohci
01b483699bebf9cb07a3d69df0aa2bee71db1b26]
pci_device_remove+0x37/0xa0
device_release_driver_internal+0x19f/0x200
unbind_store+0xa1/0xb0remove irq with devm_free_irq() before pci_disable_msi() also remove it in fail_msi: of pci_probe() as this would lead to an identical leak
--- drivers/firewire/ohci.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/firewire/ohci.c +2 -0
@@ -3773,6 +3773,7 @@ static int pci_probe(struct pci_dev *devreturn 0 ; fail_msi: +devm_free_irq (&dev->dev, dev->irq, ohci);pci_disable_msi (dev);return err;
@@ -3800,6 +3801,7 @@ static void pci_remove(struct pci_dev *dsoftware_reset (ohci); +devm_free_irq (&dev->dev, dev->irq, ohci);pci_disable_msi (dev);dev_notice (&dev->dev,"removing fw-ohci device\n" );
Greg Kroah-Hartman
maintainerPATCH 253/432 KVM: x86: Mark target gfn of emulated atomic instruction as dirty
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 910c57dfa4d113aae6571c2a8b9ae8c430975902 upstream.
When emulating an atomic access on behalf of the guest, mark the target gfn dirty if the CMPXCHG by KVM is attempted and doesn't fault. This fixes a bug where KVM effectively corrupts guest memory during live migration by writing to guest memory without informing userspace that the page is dirty.
Marking the page dirty got unintentionally dropped when KVM's emulated CMPXCHG was converted to do a user access. Before that, KVM explicitly mapped the guest page into kernel memory, and marked the page dirty during the unmap phase.
Mark the page dirty even if the CMPXCHG fails, as the old data is written back on failure, i.e. the page is still written. The value written is guaranteed to be the same because the operation is atomic, but KVM's ABI is that all writes are dirty logged regardless of the value written. And more importantly, that's what KVM did before the buggy commit.
Huge kudos to the folks on the Cc list (and many others), who did all the actual work of triaging and debugging.
base-commit: 6769ea8da8a93ed4630f1ce64df6aafcaabfce64
--- arch/x86/kvm/x86.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/x86/kvm/x86.c +10 -0
@@ -7951,6 +7951,16 @@ static int emulator_cmpxchg_emulated(strif (r <0 )return X86EMUL_UNHANDLEABLE ; + +/* +* Mark the page dirty _before_ checking whether or not the CMPXCHG was +* successful, as the old value is written back on failure. Note, for +* live migration, this is unnecessarily conservative as CMPXCHG writes +* back the original value and the access is atomic, but KVM's ABI is +* that all writes are dirty logged, regardless of the value written. +*/ +kvm_vcpu_mark_page_dirty (vcpu,gpa_to_gfn (gpa)); +if (r)return X86EMUL_CMPXCHG_FAILED ;
Greg Kroah-Hartman
maintainerPATCH 254/432 KVM: SVM: Flush pages under kvm->lock to fix UAF in svm_register_enc_region()
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 5ef1d8c1ddbf696e47b226e11888eaf8d9e8e807 upstream.
Do the cache flush of converted pages in svm_register_enc_region() before dropping kvm->lock to fix use-after-free issues where region and/or its array of pages could be freed by a different task, e.g. if userspace has __unregister_enc_region_locked() already queued up for the region.
Note, the "obvious" alternative of using local variables doesn't fully resolve the bug, as region->pages is also dynamically allocated. I.e. the region structure itself would be fine, but region->pages could be freed.
Flushing multiple pages under kvm->lock is unfortunate, but the entire flow is a rare slow path, and the manual flush is only needed on CPUs that lack coherency for encrypted memory.
Message-Id: <[email protected]>
--- arch/x86/kvm/svm/sev.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
arch/x86/kvm/svm/sev.c +9 -7
@@ -1975,20 +1975,22 @@ int sev_mem_enc_register_region(struct k goto e_free; } - region->uaddr = range->addr; - region->size = range->size; - -list_add_tail (®ion->list, &sev->regions_list); -mutex_unlock (&kvm->lock); -/* * The guest may change the memory encryption attribute from C=0 -> C=1 * or vice versa for this memory range. Lets make sure caches are * flushed to ensure that guest data gets written into memory with -* correct C-bit. +* correct C-bit. Note, this must be done before dropping kvm->lock, +* as region and its array of pages can be freed by a different task +* once kvm->lock is released. */ sev_clflush_pages (region->pages, region->npages); + region->uaddr = range->addr; + region->size = range->size; + +list_add_tail (®ion->list, &sev->regions_list); +mutex_unlock (&kvm->lock); +return ret; e_free:
Greg Kroah-Hartman
maintainerPATCH 255/432 SEV: disable SEV-ES DebugSwap by default
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Bonzini <[email protected]>
commit 5abf6dceb066f2b02b225fd561440c98a8062681 upstream.
The DebugSwap feature of SEV-ES provides a way for confidential guests to use data breakpoints. However, because the status of the DebugSwap feature is recorded in the VMSA, enabling it by default invalidates the attestation signatures. In 6.10 we will introduce a new API to create SEV VMs that will allow enabling DebugSwap based on what the user tells KVM to do. Contextually, we will change the legacy KVM_SEV_ES_INIT API to never enable DebugSwap.
For compatibility with kernels that pre-date the introduction of DebugSwap, as well as with those where KVM_SEV_ES_INIT will never enable it, do not enable the feature by default. If anybody wants to use it, for now they can enable the sev_es_debug_swap_enabled module parameter, but this will result in a warning.
--- arch/x86/kvm/svm/sev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kvm/svm/sev.c +5 -2
@@ -57,7 +57,7 @@ static bool sev_es_enabled = true;module_param_named (sev_es, sev_es_enabled, bool,0444 );/* enable/disable SEV-ES DebugSwap support */ -static bool sev_es_debug_swap_enabled = true; +static bool sev_es_debug_swap_enabled = false;module_param_named (debug_swap, sev_es_debug_swap_enabled, bool,0444 );#else #define sev_enabled false
@@ -612,8 +612,11 @@ static int sev_es_sync_vmsa(struct vcpu_ save->xss = svm->vcpu.arch.ia32_xss; save->dr6 = svm->vcpu.arch.dr6; -if (sev_es_debug_swap_enabled) +if (sev_es_debug_swap_enabled) { save->sev_features |=SVM_SEV_FEAT_DEBUG_SWAP ; +pr_warn_once ("Enabling DebugSwap with KVM_SEV_ES_INIT. " +"This will not work starting with Linux 6.10\n" ); + }pr_debug ("Virtual Machine Save Area (VMSA):\n" );print_hex_dump_debug ("" ,DUMP_PREFIX_NONE ,16 ,1 , save,sizeof (*save), false);
Greg Kroah-Hartman
maintainerPATCH 256/432 tracing: Use .flush() call to wake up readers
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt (Google) <[email protected]>
commit e5d7c1916562f0e856eb3d6f569629fcd535fed2 upstream.
The .release() function does not get called until all readers of a file descriptor are finished.
If a thread is blocked on reading a file descriptor in ring_buffer_wait(), and another thread closes the file descriptor, it will not wake up the other thread as ring_buffer_wake_waiters() is called by .release(), and that will not get called until the .read() is finished.
The issue originally showed up in trace-cmd, but the readers are actually other processes with their own file descriptors. So calling close() would wake up the other tasks because they are blocked on another descriptor then the one that was closed(). But there's other wake ups that solve that issue.
When a thread is blocked on a read, it can still hang even when another thread closed its descriptor.
This is what the .flush() callback is for. Have the .flush() wake up the readers.
--- kernel/trace/trace.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
kernel/trace/trace.c +15 -6
@@ -8352,6 +8352,20 @@ tracing_buffers_read(struct file *filp,return size; } +static int tracing_buffers_flush (struct file *file,fl_owner_t id) +{ +struct ftrace_buffer_info *info = file->private_data; +struct trace_iterator *iter = &info->iter; + + iter->wait_index++; +/* Make sure the waiters see the new wait_index */ +smp_wmb (); + +ring_buffer_wake_waiters (iter->array_buffer->buffer, iter->cpu_file); + +return 0 ; +} +static int tracing_buffers_release (struct inode *inode,struct file *file) {struct ftrace_buffer_info *info = file->private_data;
@@ -8363,12 +8377,6 @@ static int tracing_buffers_release(struc__trace_array_put (iter->tr); - iter->wait_index++; -/* Make sure the waiters see the new wait_index */ -smp_wmb (); - -ring_buffer_wake_waiters (iter->array_buffer->buffer, iter->cpu_file); -if (info->spare)ring_buffer_free_read_page (iter->array_buffer->buffer, info->spare_cpu, info->spare);
@@ -8582,6 +8590,7 @@ static const struct file_operations trac .read = tracing_buffers_read, .poll = tracing_buffers_poll, .release = tracing_buffers_release, + .flush = tracing_buffers_flush, .splice_read = tracing_buffers_splice_read, .unlocked_ioctl = tracing_buffers_ioctl, .llseek = no_llseek,
Greg Kroah-Hartman
maintainerPATCH 257/432 drm/amdgpu/pm: Fix the error of pwm1_enable setting
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Jun <[email protected]>
commit 0dafaf659cc463f2db0af92003313a8bc46781cd upstream.
Fix the pwm_mode value error which used forpwm1_enable setting
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +11 -1
@@ -2518,6 +2518,7 @@ static ssize_t amdgpu_hwmon_set_pwm1_ena {struct amdgpu_device *adev =dev_get_drvdata (dev);int err, ret; +u32 pwm_mode;int value;if (amdgpu_in_reset (adev))
@@ -2529,13 +2530,22 @@ static ssize_t amdgpu_hwmon_set_pwm1_enaif (err)return err; +if (value ==0 ) + pwm_mode =AMD_FAN_CTRL_NONE ; +else if (value ==1 ) + pwm_mode =AMD_FAN_CTRL_MANUAL ; +else if (value ==2 ) + pwm_mode =AMD_FAN_CTRL_AUTO ; +else +return -EINVAL ; + ret =pm_runtime_get_sync (adev_to_drm (adev)->dev);if (ret <0 ) {pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);return ret; } - ret =amdgpu_dpm_set_fan_control_mode (adev, value); + ret =amdgpu_dpm_set_fan_control_mode (adev, pwm_mode);pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);
Greg Kroah-Hartman
maintainerPATCH 258/432 tty: serial: imx: Fix broken RS485
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rickard x Andersson <[email protected]>
commit 672448ccf9b6a676f96f9352cbf91f4d35f4084a upstream.
When about to transmit the function imx_uart_start_tx is called and in some RS485 configurations this function will call imx_uart_stop_rx. The problem is that imx_uart_stop_rx will enable loopback in order to release the RS485 bus, but when loopback is enabled transmitted data will just be looped to RX.
This patch fixes the above problem by not enabling loopback when about to transmit.
This driver now works well when used for RS485 half duplex master configurations.
--- drivers/tty/serial/imx.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
drivers/tty/serial/imx.c +18 -4
@@ -462,8 +462,7 @@ static void imx_uart_stop_tx(struct uart } } -/* called with port.lock taken and irqs off */ -static void imx_uart_stop_rx (struct uart_port *port) +static void imx_uart_stop_rx_with_loopback_ctrl (struct uart_port *port,bool loopback) {struct imx_port *sport = (struct imx_port *)port;u32 ucr1, ucr2, ucr4, uts;
@@ -485,7 +484,7 @@ static void imx_uart_stop_rx(struct uart/* See SER_RS485_ENABLED/UTS_LOOP comment in imx_uart_probe() */ if (port->rs485.flags &SER_RS485_ENABLED && port->rs485.flags &SER_RS485_RTS_ON_SEND && - sport->have_rtscts && !sport->have_rtsgpio) { + sport->have_rtscts && !sport->have_rtsgpio && loopback) { uts =imx_uart_readl (sport,imx_uart_uts_reg (sport)); uts |=UTS_LOOP ;imx_uart_writel (sport, uts,imx_uart_uts_reg (sport));
@@ -498,6 +497,16 @@ static void imx_uart_stop_rx(struct uart }/* called with port.lock taken and irqs off */ +static void imx_uart_stop_rx (struct uart_port *port) +{ +/* +* Stop RX and enable loopback in order to make sure RS485 bus +* is not blocked. Se comment in imx_uart_probe(). +*/ +imx_uart_stop_rx_with_loopback_ctrl (port, true); +} + +/* called with port.lock taken and irqs off */ static void imx_uart_enable_ms (struct uart_port *port) {struct imx_port *sport = (struct imx_port *)port;
@@ -682,9 +691,14 @@ static void imx_uart_start_tx(struct uarimx_uart_rts_inactive (sport, &ucr2);imx_uart_writel (sport, ucr2,UCR2 ); +/* +* Since we are about to transmit we can not stop RX +* with loopback enabled because that will make our +* transmitted data being just looped to RX. +*/ if (!(port->rs485.flags &SER_RS485_RX_DURING_TX ) && !port->rs485_rx_during_tx_gpio) -imx_uart_stop_rx (port); +imx_uart_stop_rx_with_loopback_ctrl (port, false); sport->tx_state =WAIT_AFTER_RTS ;
Greg Kroah-Hartman
maintainerPATCH 259/432 drm/i915: Check before removing mm notifier
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nirmoy Das <[email protected]>
commit 01bb1ae35006e473138c90711bad1a6b614a1823 upstream.
Error in mmu_interval_notifier_insert() can leave a NULL notifier.mm pointer. Catch that and return early.
--- drivers/gpu/drm/i915/gem/i915_gem_userptr.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/i915/gem/i915_gem_userptr.c +3 -0
@@ -379,6 +379,9 @@ i915_gem_userptr_release(struct drm_i915 {GEM_WARN_ON (obj->userptr.page_ref); +if (!obj->userptr.notifier.mm) +return ; +mmu_interval_notifier_remove (&obj->userptr.notifier); obj->userptr.notifier.mm =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 260/432 ALSA: hda/realtek - Fix headset Mic no show at resume back for Lenovo ALC897 platform
In reply to Greg Kroah-Hartman6.7-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
commit d397b6e56151099cf3b1f7bfccb204a6a8591720 upstream.
Headset Mic will no show at resume back.
This patch will fix this issue.
--- sound/pci/hda/patch_realtek.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
sound/pci/hda/patch_realtek.c +5 -2
@@ -11735,8 +11735,7 @@ static void alc897_hp_automute_hook(strusnd_hda_gen_hp_automute (codec, jack); vref = spec->gen.hp_jack_present ? (PIN_HP |AC_PINCTL_VREF_100 ) :PIN_HP ; -snd_hda_codec_write (codec,0x1b ,0 ,AC_VERB_SET_PIN_WIDGET_CONTROL , - vref); +snd_hda_set_pin_ctl (codec,0x1b , vref); } static void alc897_fixup_lenovo_headset_mic(struct hda_codec *codec,
@@ -11745,6 +11744,10 @@ static void alc897_fixup_lenovo_headset_struct alc_spec *spec = codec->spec;if (action ==HDA_FIXUP_ACT_PRE_PROBE ) { spec->gen.hp_automute_hook = alc897_hp_automute_hook; + spec->no_shutup_pins =1 ; + } +if (action ==HDA_FIXUP_ACT_PROBE ) { +snd_hda_set_pin_ctl_cache (codec,0x1a ,PIN_IN |AC_PINCTL_VREF_100 ); } }