6.1.103-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 276/440 dt-bindings: thermal: correct thermal zone node name limit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit 97e32381d0fc6c2602a767b0c46e15eb2b75971d upstream.
Linux kernel uses thermal zone node name during registering thermal zones and has a hard-coded limit of 20 characters, including terminating NUL byte. The bindings expect node names to finish with '-thermal' which is eight bytes long, thus we have only 11 characters for the reset of the node name (thus 10 for the pattern after leading fixed character).
--- Documentation/devicetree/bindings/thermal/thermal-zones.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/thermal/thermal-zones.yaml +4 -1
@@ -49,7 +49,10 @@ properties: to take when the temperature crosses those thresholds. patternProperties: - "^[a-zA-Z][a-zA-Z0-9\\-]{1,12}-thermal$": + # Node name is limited in size due to Linux kernel requirements - 19 + # characters in total (see THERMAL_NAME_LENGTH, including terminating NUL + # byte): + "^[a-zA-Z][a-zA-Z0-9\\-]{1,10}-thermal$": type: object description: Each thermal zone node contains information about how frequently it
Greg Kroah-Hartman
maintainerPATCH 277/440 tick/broadcast: Make takeover of broadcast hrtimer reliable
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Liao <[email protected]>
commit f7d43dd206e7e18c182f200e67a8db8c209907fa upstream.
Running the LTP hotplug stress test on a aarch64 machine results in rcu_sched stall warnings when the broadcast hrtimer was owned by the un-plugged CPU. The issue is the following:
CPU1 (owns the broadcast hrtimer) CPU2
tick_broadcast_enter() // shutdown local timer device broadcast_shutdown_local() ... tick_broadcast_exit() clockevents_switch_state(dev, CLOCK_EVT_STATE_ONESHOT) // timer device is not programmed cpumask_set_cpu(cpu, tick_broadcast_force_mask) initiates offlining of CPU1
take_cpu_down()
/*
* CPU1 shuts down and does not
* send broadcast IPI anymore
*/
takedown_cpu() hotplug_cpu__broadcast_tick_pull() // move broadcast hrtimer to this CPU clockevents_program_event() bc_set_next() hrtimer_start() /* * timer device is not programmed * because only the first expiring * timer will trigger clockevent * device reprogramming */
What happens is that CPU2 exits broadcast mode with force bit set, then the local timer device is not reprogrammed and CPU2 expects to receive the expired event by the broadcast IPI. But this does not happen because CPU1 is offlined by CPU2. CPU switches the clockevent device to ONESHOT state, but does not reprogram the device.
The subsequent reprogramming of the hrtimer broadcast device does not program the clockevent device of CPU2 either because the pending expiry time is already in the past and the CPU expects the event to be delivered. As a consequence all CPUs which wait for a broadcast event to be delivered are stuck forever.
Fix this issue by reprogramming the local timer device if the broadcast force bit of the CPU is set so that the broadcast hrtimer is delivered.
[ tglx: Massage comment and change log. Add Fixes tag ]
--- kernel/time/tick-broadcast.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
kernel/time/tick-broadcast.c +23 -0
@@ -1137,6 +1137,7 @@ void tick_broadcast_switch_to_oneshot(vo#ifdef CONFIG_HOTPLUG_CPU void hotplug_cpu__broadcast_tick_pull (int deadcpu) { +struct tick_device *td =this_cpu_ptr (&tick_cpu_device);struct clock_event_device *bc;unsigned long flags;
@@ -1144,6 +1145,28 @@ void hotplug_cpu__broadcast_tick_pull(in bc = tick_broadcast_device.evtdev;if (bc &&broadcast_needs_cpu (bc, deadcpu)) { +/* +* If the broadcast force bit of the current CPU is set, +* then the current CPU has not yet reprogrammed the local +* timer device to avoid a ping-pong race. See +* ___tick_broadcast_oneshot_control(). +* +* If the broadcast device is hrtimer based then +* programming the broadcast event below does not have any +* effect because the local clockevent device is not +* running and not programmed because the broadcast event +* is not earlier than the pending event of the local clock +* event device. As a consequence all CPUs waiting for a +* broadcast event are stuck forever. +* +* Detect this condition and reprogram the cpu local timer +* device to avoid the starvation. +*/ +if (tick_check_broadcast_expired ()) { +cpumask_clear_cpu (smp_processor_id (), tick_broadcast_force_mask); +tick_program_event (td->evtdev->next_event,1 ); + } +/* This moves the broadcast assignment to this CPU: */ clockevents_program_event (bc, bc->next_event,1 ); }
Greg Kroah-Hartman
maintainerPATCH 278/440 net: netconsole: Disable target before netpoll cleanup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
commit 97d9fba9a812cada5484667a46e14a4c976ca330 upstream.
Currently, netconsole cleans up the netpoll structure before disabling the target. This approach can lead to race conditions, as message senders (write_ext_msg() and write_msg()) check if the target is enabled before using netpoll. The sender can validate that the target is enabled, but, the netpoll might be de-allocated already, causing undesired behaviours.
This patch reverses the order of operations:
1. Disable the target
2. Clean up the netpoll structure
This change eliminates the potential race condition, ensuring that no messages are sent through a partially cleaned-up netpoll structure.
--- drivers/net/netconsole.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/netconsole.c +1 -1
@@ -716,6 +716,7 @@ restart:/* rtnl_lock already held * we might sleep in __netpoll_cleanup() */ + nt->enabled = false;spin_unlock_irqrestore (&target_list_lock, flags);__netpoll_cleanup (&nt->np);
@@ -723,7 +724,6 @@ restart:spin_lock_irqsave (&target_list_lock, flags);netdev_put (nt->np.dev, &nt->np.dev_tracker); nt->np.dev =NULL ; - nt->enabled = false; stopped = true;netconsole_target_put (nt); goto restart;
Greg Kroah-Hartman
maintainerPATCH 279/440 af_packet: Handle outgoing VLAN packets without hardware offloading
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengen Du <[email protected]>
commit 79eecf631c14e7f4057186570ac20e2cfac3802e upstream.
The issue initially stems from libpcap. The ethertype will be overwritten as the VLAN TPID if the network interface lacks hardware VLAN offloading. In the outbound packet path, if hardware VLAN offloading is unavailable, the VLAN tag is inserted into the payload but then cleared from the sk_buff struct. Consequently, this can lead to a false negative when checking for the presence of a VLAN tag, causing the packet sniffing outcome to lack VLAN tag information (i.e., TCI-TPID). As a result, the packet capturing tool may be unable to parse packets as expected.
The TCI-TPID is missing because the prb_fill_vlan_info() function does not modify the tp_vlan_tci/tp_vlan_tpid values, as the information is in the payload and not in the sk_buff struct. The skb_vlan_tag_present() function only checks vlan_all in the sk_buff struct. In cooked mode, the L2 header is stripped, preventing the packet capturing tool from determining the correct TCI-TPID value. Additionally, the protocol in SLL is incorrect, which means the packet capturing tool cannot parse the L3 header correctly.
--- net/packet/af_packet.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 2 deletions(-)
net/packet/af_packet.c +84 -2
@@ -541,6 +541,61 @@ static void *packet_current_frame(structreturn packet_lookup_frame (po, rb, rb->head, status); } +static u16 vlan_get_tci (struct sk_buff *skb,struct net_device *dev) +{ +u8 *skb_orig_data = skb->data; +int skb_orig_len = skb->len; +struct vlan_hdr vhdr, *vh; +unsigned int header_len; + +if (!dev) +return 0 ; + +/* In the SOCK_DGRAM scenario, skb data starts at the network +* protocol, which is after the VLAN headers. The outer VLAN +* header is at the hard_header_len offset in non-variable +* length link layer headers. If it's a VLAN device, the +* min_header_len should be used to exclude the VLAN header +* size. +*/ +if (dev->min_header_len == dev->hard_header_len) + header_len = dev->hard_header_len; +else if (is_vlan_dev (dev)) + header_len = dev->min_header_len; +else +return 0 ; + +skb_push (skb, skb->data -skb_mac_header (skb)); + vh =skb_header_pointer (skb, header_len,sizeof (vhdr), &vhdr); +if (skb_orig_data != skb->data) { + skb->data = skb_orig_data; + skb->len = skb_orig_len; + } +if (unlikely (!vh)) +return 0 ; + +return ntohs (vh->h_vlan_TCI); +} + +static __be16 vlan_get_protocol_dgram (struct sk_buff *skb) +{ +__be16 proto = skb->protocol; + +if (unlikely (eth_type_vlan (proto))) { +u8 *skb_orig_data = skb->data; +int skb_orig_len = skb->len; + +skb_push (skb, skb->data -skb_mac_header (skb)); + proto =__vlan_get_protocol (skb, proto,NULL ); +if (skb_orig_data != skb->data) { + skb->data = skb_orig_data; + skb->len = skb_orig_len; + } + } + +return proto; +} +static void prb_del_retire_blk_timer (struct tpacket_kbdq_core *pkc) {del_timer_sync (&pkc->retire_blk_timer);
@@ -1010,10 +1065,16 @@ static void prb_clear_rxhash(struct tpacstatic void prb_fill_vlan_info (struct tpacket_kbdq_core *pkc,struct tpacket3_hdr *ppd) { + struct packet_sock *po = container_of(pkc, struct packet_sock, rx_ring.prb_bdqc); +if (skb_vlan_tag_present (pkc->skb)) { ppd->hv1.tp_vlan_tci =skb_vlan_tag_get (pkc->skb); ppd->hv1.tp_vlan_tpid =ntohs (pkc->skb->vlan_proto); ppd->tp_status =TP_STATUS_VLAN_VALID |TP_STATUS_VLAN_TPID_VALID ; + }else if (unlikely (po->sk.sk_type ==SOCK_DGRAM &ð_type_vlan (pkc->skb->protocol))) { + ppd->hv1.tp_vlan_tci =vlan_get_tci (pkc->skb, pkc->skb->dev); + ppd->hv1.tp_vlan_tpid =ntohs (pkc->skb->protocol); + ppd->tp_status =TP_STATUS_VLAN_VALID |TP_STATUS_VLAN_TPID_VALID ; }else { ppd->hv1.tp_vlan_tci =0 ; ppd->hv1.tp_vlan_tpid =0 ;
@@ -2431,6 +2492,10 @@ static int tpacket_rcv(struct sk_buff *s h.h2->tp_vlan_tci =skb_vlan_tag_get (skb); h.h2->tp_vlan_tpid =ntohs (skb->vlan_proto); status |=TP_STATUS_VLAN_VALID |TP_STATUS_VLAN_TPID_VALID ; + }else if (unlikely (sk->sk_type ==SOCK_DGRAM &ð_type_vlan (skb->protocol))) { + h.h2->tp_vlan_tci =vlan_get_tci (skb, skb->dev); + h.h2->tp_vlan_tpid =ntohs (skb->protocol); + status |=TP_STATUS_VLAN_VALID |TP_STATUS_VLAN_TPID_VALID ; }else { h.h2->tp_vlan_tci =0 ; h.h2->tp_vlan_tpid =0 ;
@@ -2460,7 +2525,8 @@ static int tpacket_rcv(struct sk_buff *s sll->sll_halen =dev_parse_header (skb, sll->sll_addr); sll->sll_family =AF_PACKET ; sll->sll_hatype = dev->type; - sll->sll_protocol = skb->protocol; + sll->sll_protocol = (sk->sk_type ==SOCK_DGRAM ) ? +vlan_get_protocol_dgram (skb) : skb->protocol; sll->sll_pkttype = skb->pkt_type;if (unlikely (packet_sock_flag (po,PACKET_SOCK_ORIGDEV ))) sll->sll_ifindex = orig_dev->ifindex;
@@ -3481,7 +3547,8 @@ static int packet_recvmsg(struct socket/* Original length was stored in sockaddr_ll fields */ origlen =PACKET_SKB_CB (skb)->sa.origlen; sll->sll_family =AF_PACKET ; - sll->sll_protocol = skb->protocol; + sll->sll_protocol = (sock->type ==SOCK_DGRAM ) ? +vlan_get_protocol_dgram (skb) : skb->protocol; }sock_recv_cmsgs (msg, sk, skb);
@@ -3536,6 +3603,21 @@ static int packet_recvmsg(struct socket aux.tp_vlan_tci =skb_vlan_tag_get (skb); aux.tp_vlan_tpid =ntohs (skb->vlan_proto); aux.tp_status |=TP_STATUS_VLAN_VALID |TP_STATUS_VLAN_TPID_VALID ; + }else if (unlikely (sock->type ==SOCK_DGRAM &ð_type_vlan (skb->protocol))) { +struct sockaddr_ll *sll = &PACKET_SKB_CB (skb)->sa.ll; +struct net_device *dev; + +rcu_read_lock (); + dev =dev_get_by_index_rcu (sock_net (sk), sll->sll_ifindex); +if (dev) { + aux.tp_vlan_tci =vlan_get_tci (skb, dev); + aux.tp_vlan_tpid =ntohs (skb->protocol); + aux.tp_status |=TP_STATUS_VLAN_VALID |TP_STATUS_VLAN_TPID_VALID ; + }else { + aux.tp_vlan_tci =0 ; + aux.tp_vlan_tpid =0 ; + } +rcu_read_unlock (); }else { aux.tp_vlan_tci =0 ; aux.tp_vlan_tpid =0 ;
Greg Kroah-Hartman
maintainerPATCH 280/440 kernel: rerun task_work while freezing in get_signal()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit 943ad0b62e3c21f324c4884caa6cb4a871bca05c upstream.
io_uring can asynchronously add a task_work while the task is getting freezed. TIF_NOTIFY_SIGNAL will prevent the task from sleeping in do_freezer_trap(), and since the get_signal()'s relock loop doesn't retry task_work, the task will spin there not being able to sleep until the freezing is cancelled / the task is killed / etc.
Run task_works in the freezer path. Keep the patch small and simple so it can be easily back ported, but we might need to do some cleaning after and look if there are other places with similar problems.
--- kernel/signal.c | 8 ++++++++ 1 file changed, 8 insertions(+)
kernel/signal.c +8 -0
@@ -2558,6 +2558,14 @@ static void do_freezer_trap(void)spin_unlock_irq (¤t->sighand->siglock);cgroup_enter_frozen ();schedule (); + +/* +* We could've been woken by task_work, run it to clear +* TIF_NOTIFY_SIGNAL. The caller will retry if necessary. +*/ +clear_notify_signal (); +if (unlikely (task_work_pending (current))) +task_work_run (); }static int ptrace_signal (int signr,kernel_siginfo_t *info,enum pid_type type)
Greg Kroah-Hartman
maintainerPATCH 281/440 ipv4: fix source address selection with route leak
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Dichtel <[email protected]>
commit 6807352353561187a718e87204458999dbcbba1b upstream.
By default, an address assigned to the output interface is selected when the source address is not specified. This is problematic when a route, configured in a vrf, uses an interface from another vrf (aka route leak). The original vrf does not own the selected source address.
Let's add a check against the output interface and call the appropriate function to select the source address.
--- net/ipv4/fib_semantics.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
net/ipv4/fib_semantics.c +11 -2
@@ -2270,6 +2270,15 @@ void fib_select_path(struct net *net, stfib_select_default (fl4, res); check_saddr: -if (!fl4->saddr) - fl4->saddr =fib_result_prefsrc (net, res); +if (!fl4->saddr) { +struct net_device *l3mdev; + + l3mdev =dev_get_by_index_rcu (net, fl4->flowi4_l3mdev); + +if (!l3mdev || +l3mdev_master_dev_rcu (FIB_RES_DEV (*res)) == l3mdev) + fl4->saddr =fib_result_prefsrc (net, res); +else + fl4->saddr =inet_select_addr (l3mdev,0 ,RT_SCOPE_LINK ); + } }
Greg Kroah-Hartman
maintainerPATCH 282/440 ipv6: take care of scope when choosing the src addr
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Dichtel <[email protected]>
commit abb9a68d2c64dd9b128ae1f2e635e4d805e7ce64 upstream.
When the source address is selected, the scope must be checked. For example, if a loopback address is assigned to the vrf device, it must not be chosen for packets sent outside.
--- net/ipv6/addrconf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv6/addrconf.c +2 -1
@@ -1831,7 +1831,8 @@ int ipv6_dev_get_saddr(struct net *net, master, &dst, scores, hiscore_idx); -if (scores[hiscore_idx].ifa) +if (scores[hiscore_idx].ifa && + scores[hiscore_idx].scopedist >=0 ) goto out; }
Greg Kroah-Hartman
maintainerPATCH 283/440 sched/fair: set_load_weight() must also call reweight_task() for SCHED_IDLE tasks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit d329605287020c3d1c3b0dadc63d8208e7251382 upstream.
When a task's weight is being changed, set_load_weight() is called with @update_load set. As weight changes aren't trivial for the fair class, set_load_weight() calls fair.c::reweight_task() for fair class tasks.
However, set_load_weight() first tests task_has_idle_policy() on entry and skips calling reweight_task() for SCHED_IDLE tasks. This is buggy as SCHED_IDLE tasks are just fair tasks with a very low weight and they would incorrectly skip load, vlag and position updates.
Fix it by updating reweight_task() to take struct load_weight as idle weight can't be expressed with prio and making set_load_weight() call reweight_task() for SCHED_IDLE tasks too when @update_load is set.
--- kernel/sched/core.c | 23 ++++++++++------------- kernel/sched/fair.c | 7 +++---- kernel/sched/sched.h | 2 +- 3 files changed, 14 insertions(+), 18 deletions(-)
kernel/sched/core.c +10 -13
@@ -1259,27 +1259,24 @@ int tg_nop(struct task_group *tg, void *static void set_load_weight (struct task_struct *p,bool update_load) {int prio = p->static_prio -MAX_RT_PRIO ; -struct load_weight *load = &p->se.load; +struct load_weight lw; -/* -* SCHED_IDLE tasks get minimal weight: -*/ if (task_has_idle_policy (p)) { - load->weight =scale_load (WEIGHT_IDLEPRIO ); - load->inv_weight =WMULT_IDLEPRIO ; -return ; + lw.weight =scale_load (WEIGHT_IDLEPRIO ); + lw.inv_weight =WMULT_IDLEPRIO ; + }else { + lw.weight =scale_load (sched_prio_to_weight[prio]); + lw.inv_weight = sched_prio_to_wmult[prio]; }/* * SCHED_OTHER tasks have to update their load when changing their * weight */ -if (update_load && p->sched_class == &fair_sched_class) { -reweight_task (p, prio); - }else { - load->weight =scale_load (sched_prio_to_weight[prio]); - load->inv_weight = sched_prio_to_wmult[prio]; - } +if (update_load && p->sched_class == &fair_sched_class) +reweight_task (p, &lw); +else + p->se.load = lw; }#ifdef CONFIG_UCLAMP_TASK
kernel/sched/fair.c +3 -4
@@ -3330,15 +3330,14 @@ static void reweight_entity(struct cfs_r } -void reweight_task (struct task_struct *p,int prio) +void reweight_task (struct task_struct *p,const struct load_weight *lw) {struct sched_entity *se = &p->se;struct cfs_rq *cfs_rq =cfs_rq_of (se);struct load_weight *load = &se->load; -unsigned long weight =scale_load (sched_prio_to_weight[prio]); -reweight_entity (cfs_rq, se, weight); - load->inv_weight = sched_prio_to_wmult[prio]; +reweight_entity (cfs_rq, se, lw->weight); + load->inv_weight = lw->inv_weight; }static inline int throttled_hierarchy (struct cfs_rq *cfs_rq);
kernel/sched/sched.h +1 -1
@@ -2346,7 +2346,7 @@ extern void init_sched_dl_class(void);extern void init_sched_rt_class (void );extern void init_sched_fair_class (void ); -extern void reweight_task (struct task_struct *p,int prio); +extern void reweight_task (struct task_struct *p,const struct load_weight *lw);extern void resched_curr (struct rq *rq);extern void resched_cpu (int cpu);
Greg Kroah-Hartman
maintainerPATCH 284/440 fuse: verify {g,u}id mount options correctly
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Sandeen <[email protected]>
commit 525bd65aa759ec320af1dc06e114ed69733e9e23 upstream.
As was done in0200679fc795 ("tmpfs: verify {g,u}id mount options correctly") we need to validate that the requested uid and/or gid is representable in the filesystem's idmapping.
Cribbing from the above commit log,
The contract for {g,u}id mount options and {g,u}id values in general set from userspace has always been that they are translated according to the caller's idmapping. In so far, fuse has been doing the correct thing. But since fuse is mountable in unprivileged contexts it is also necessary to verify that the resulting {k,g}uid is representable in the namespace of the superblock.
--- fs/fuse/inode.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-)
fs/fuse/inode.c +20 -4
@@ -724,6 +724,8 @@ static int fuse_parse_param(struct fs_costruct fs_parse_result result;struct fuse_fs_context *ctx = fsc->fs_private;int opt; +kuid_t kuid; +kgid_t kgid;if (fsc->purpose ==FS_CONTEXT_FOR_RECONFIGURE ) {/*
@@ -768,16 +770,30 @@ static int fuse_parse_param(struct fs_cobreak ;case OPT_USER_ID : - ctx->user_id =make_kuid (fsc->user_ns, result.uint_32); -if (!uid_valid (ctx->user_id)) + kuid =make_kuid (fsc->user_ns, result.uint_32); +if (!uid_valid (kuid))return invalfc (fsc,"Invalid user_id" ); +/* +* The requested uid must be representable in the +* filesystem's idmapping. +*/ +if (!kuid_has_mapping (fsc->user_ns, kuid)) +return invalfc (fsc,"Invalid user_id" ); + ctx->user_id = kuid; ctx->user_id_present = true;break ;case OPT_GROUP_ID : - ctx->group_id =make_kgid (fsc->user_ns, result.uint_32); -if (!gid_valid (ctx->group_id)) + kgid =make_kgid (fsc->user_ns, result.uint_32);; +if (!gid_valid (kgid)) +return invalfc (fsc,"Invalid group_id" ); +/* +* The requested gid must be representable in the +* filesystem's idmapping. +*/ +if (!kgid_has_mapping (fsc->user_ns, kgid))return invalfc (fsc,"Invalid group_id" ); + ctx->group_id = kgid; ctx->group_id_present = true;break ;
Greg Kroah-Hartman
maintainerPATCH 285/440 char: tpm: Fix possible memory leak in tpm_bios_measurements_open()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Hattori <[email protected]>
commit 5d8e2971e817bb64225fc0b6327a78752f58a9aa upstream.
In tpm_bios_measurements_open(), get_device() is called on the device embedded in struct tpm_chip. In the error path, however, put_device() is not called. This results in a reference count leak, which prevents the device from being properly released. This commit makes sure to call put_device() when the seq_open() call fails.
--- drivers/char/tpm/eventlog/common.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/char/tpm/eventlog/common.c +2 -0
@@ -47,6 +47,8 @@ static int tpm_bios_measurements_open(stif (!err) { seq = file->private_data; seq->private = chip; + }else { +put_device (&chip->dev); }return err;
Greg Kroah-Hartman
maintainerPATCH 286/440 media: venus: fix use after free in vdec_close
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dikshita Agarwal <[email protected]>
commit a0157b5aa34eb43ec4c5510f9c260bbb03be937e upstream.
There appears to be a possible use after free with vdec_close(). The firmware will add buffer release work to the work queue through HFI callbacks as a normal part of decoding. Randomly closing the decoder device from userspace during normal decoding can incur a read after free for inst.
Fix it by cancelling the work in vdec_close.
--- drivers/media/platform/qcom/venus/vdec.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/qcom/venus/vdec.c +1 -0
@@ -1705,6 +1705,7 @@ static int vdec_close(struct file *file)vdec_pm_get (inst); +cancel_work_sync (&inst->delayed_process_work);v4l2_m2m_ctx_release (inst->m2m_ctx);v4l2_m2m_release (inst->m2m_dev);vdec_ctrl_deinit (inst);
Greg Kroah-Hartman
maintainerPATCH 287/440 ata: libata-scsi: Honor the D_SENSE bit for CK_COND=1 and no error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Pylypiv <[email protected]>
commit 28ab9769117ca944cb6eb537af5599aa436287a4 upstream.
SAT-5 revision 8 specification removed the text about the ANSI INCITS 431-2007 compliance which was requiring SCSI/ATA Translation (SAT) to return descriptor format sense data for the ATA PASS-THROUGH commands regardless of the setting of the D_SENSE bit.
Let's honor the D_SENSE bit for ATA PASS-THROUGH commands while generating the "ATA PASS-THROUGH INFORMATION AVAILABLE" sense data.
SAT-5 revision 7
================
12.2.2.8 Fixed format sense data
Table 212 shows the fields returned in the fixed format sense data (see SPC-5) for ATA PASS-THROUGH commands. SATLs compliant with ANSI INCITS 431-2007, SCSI/ATA Translation (SAT) return descriptor format sense data for the ATA PASS-THROUGH commands regardless of the setting of the D_SENSE bit.
SAT-5 revision 8
================
12.2.2.8 Fixed format sense data
Table 211 shows the fields returned in the fixed format sense data (see SPC-5) for ATA PASS-THROUGH commands.
--- drivers/ata/libata-scsi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/ata/libata-scsi.c +2 -5
@@ -900,11 +900,8 @@ static void ata_gen_passthru_sense(struc &sense_key, &asc, &ascq, verbose);ata_scsi_set_sense (qc->dev, cmd, sense_key, asc, ascq); }else { -/* -* ATA PASS-THROUGH INFORMATION AVAILABLE -* Always in descriptor format sense. -*/ -scsi_build_sense (cmd,1 ,RECOVERED_ERROR ,0 ,0x1D ); +/* ATA PASS-THROUGH INFORMATION AVAILABLE */ +ata_scsi_set_sense (qc->dev, cmd,RECOVERED_ERROR ,0 ,0x1D ); }if ((cmd->sense_buffer[0 ] &0x7f ) >=0x72 ) {
Greg Kroah-Hartman
maintainerPATCH 288/440 hfs: fix to initialize fields of hfs_inode_info after hfs_alloc_inode()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
commit 26a2ed107929a855155429b11e1293b83e6b2a8b upstream.
Syzbot reports uninitialized value access issue as below:
loop0: detected capacity change from 0 to 64
=====================================================
BUG: KMSAN: uninit-value in hfs_revalidate_dentry+0x307/0x3f0 fs/hfs/sysdep.c:30 hfs_revalidate_dentry+0x307/0x3f0 fs/hfs/sysdep.c:30 d_revalidate fs/namei.c:862 [inline] lookup_fast+0x89e/0x8e0 fs/namei.c:1649 walk_component fs/namei.c:2001 [inline] link_path_walk+0x817/0x1480 fs/namei.c:2332 path_lookupat+0xd9/0x6f0 fs/namei.c:2485 filename_lookup+0x22e/0x740 fs/namei.c:2515 user_path_at_empty+0x8b/0x390 fs/namei.c:2924 user_path_at include/linux/namei.h:57 [inline] do_mount fs/namespace.c:3689 [inline] __do_sys_mount fs/namespace.c:3898 [inline] __se_sys_mount+0x66b/0x810 fs/namespace.c:3875 __x64_sys_mount+0xe4/0x140 fs/namespace.c:3875 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x63/0x6b BUG: KMSAN: uninit-value in hfs_ext_read_extent fs/hfs/extent.c:196 [inline] BUG: KMSAN: uninit-value in hfs_get_block+0x92d/0x1620 fs/hfs/extent.c:366 hfs_ext_read_extent fs/hfs/extent.c:196 [inline] hfs_get_block+0x92d/0x1620 fs/hfs/extent.c:366 block_read_full_folio+0x4ff/0x11b0 fs/buffer.c:2271 hfs_read_folio+0x55/0x60 fs/hfs/inode.c:39 filemap_read_folio+0x148/0x4f0 mm/filemap.c:2426 do_read_cache_folio+0x7c8/0xd90 mm/filemap.c:3553 do_read_cache_page mm/filemap.c:3595 [inline] read_cache_page+0xfb/0x2f0 mm/filemap.c:3604 read_mapping_page include/linux/pagemap.h:755 [inline] hfs_btree_open+0x928/0x1ae0 fs/hfs/btree.c:78 hfs_mdb_get+0x260c/0x3000 fs/hfs/mdb.c:204 hfs_fill_super+0x1fb1/0x2790 fs/hfs/super.c:406 mount_bdev+0x628/0x920 fs/super.c:1359 hfs_mount+0xcd/0xe0 fs/hfs/super.c:456 legacy_get_tree+0x167/0x2e0 fs/fs_context.c:610 vfs_get_tree+0xdc/0x5d0 fs/super.c:1489 do_new_mount+0x7a9/0x16f0 fs/namespace.c:3145 path_mount+0xf98/0x26a0 fs/namespace.c:3475 do_mount fs/namespace.c:3488 [inline] __do_sys_mount fs/namespace.c:3697 [inline] __se_sys_mount+0x919/0x9e0 fs/namespace.c:3674 __ia32_sys_mount+0x15b/0x1b0 fs/namespace.c:3674 do_syscall_32_irqs_on arch/x86/entry/common.c:112 [inline] __do_fast_syscall_32+0xa2/0x100 arch/x86/entry/common.c:178 do_fast_syscall_32+0x37/0x80 arch/x86/entry/common.c:203 do_SYSENTER_32+0x1f/0x30 arch/x86/entry/common.c:246 entry_SYSENTER_compat_after_hwframe+0x70/0x82
Uninit was created at:
__alloc_pages+0x9a6/0xe00 mm/page_alloc.c:4590 __alloc_pages_node include/linux/gfp.h:238 [inline] alloc_pages_node include/linux/gfp.h:261 [inline] alloc_slab_page mm/slub.c:2190 [inline] allocate_slab mm/slub.c:2354 [inline] new_slab+0x2d7/0x1400 mm/slub.c:2407 ___slab_alloc+0x16b5/0x3970 mm/slub.c:3540 __slab_alloc mm/slub.c:3625 [inline] __slab_alloc_node mm/slub.c:3678 [inline] slab_alloc_node mm/slub.c:3850 [inline] kmem_cache_alloc_lru+0x64d/0xb30 mm/slub.c:3879 alloc_inode_sb include/linux/fs.h:3018 [inline] hfs_alloc_inode+0x5a/0xc0 fs/hfs/super.c:165 alloc_inode+0x83/0x440 fs/inode.c:260 new_inode_pseudo fs/inode.c:1005 [inline] new_inode+0x38/0x4f0 fs/inode.c:1031 hfs_new_inode+0x61/0x1010 fs/hfs/inode.c:186 hfs_mkdir+0x54/0x250 fs/hfs/dir.c:228 vfs_mkdir+0x49a/0x700 fs/namei.c:4126 do_mkdirat+0x529/0x810 fs/namei.c:4149 __do_sys_mkdirat fs/namei.c:4164 [inline] __se_sys_mkdirat fs/namei.c:4162 [inline] __x64_sys_mkdirat+0xc8/0x120 fs/namei.c:4162 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcf/0x1e0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x63/0x6b
It missed to initialize .tz_secondswest, .cached_start and .cached_blocks fields in struct hfs_inode_info after hfs_alloc_inode(), fix it.
--- fs/hfs/inode.c | 3 +++ 1 file changed, 3 insertions(+)
fs/hfs/inode.c +3 -0
@@ -204,6 +204,7 @@ struct inode *hfs_new_inode(struct inodeHFS_I (inode)->flags =0 ;HFS_I (inode)->rsrc_inode =NULL ;HFS_I (inode)->fs_blocks =0 ; +HFS_I (inode)->tz_secondswest = sys_tz.tz_minuteswest *60 ;if (S_ISDIR (mode)) { inode->i_size =2 ;HFS_SB (sb)->folder_count++;
@@ -279,6 +280,8 @@ void hfs_inode_read_fork(struct inode *ifor (count =0 , i =0 ; i <3 ; i++) count +=be16_to_cpu (ext[i].count);HFS_I (inode)->first_blocks = count; +HFS_I (inode)->cached_start =0 ; +HFS_I (inode)->cached_blocks =0 ; inode->i_size =HFS_I (inode)->phys_size = log_size;HFS_I (inode)->fs_blocks = (log_size + sb->s_blocksize -1 ) >> sb->s_blocksize_bits;
Greg Kroah-Hartman
maintainerPATCH 289/440 ext2: Verify bitmap and itable block numbers before using them
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 322a6aff03937aa1ece33b4e46c298eafaf9ac41 upstream.
Verify bitmap block numbers and inode table blocks are sane before using them for checking bits in the block bitmap.
--- fs/ext2/balloc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/ext2/balloc.c +9 -2
@@ -79,26 +79,33 @@ static int ext2_valid_block_bitmap(strucext2_grpblk_t next_zero_bit;ext2_fsblk_t bitmap_blk;ext2_fsblk_t group_first_block; +ext2_grpblk_t max_bit; group_first_block =ext2_group_first_block_no (sb, block_group); + max_bit =ext2_group_last_block_no (sb, block_group) - group_first_block;/* check whether block bitmap block number is set */ bitmap_blk =le32_to_cpu (desc->bg_block_bitmap); offset = bitmap_blk - group_first_block; -if (!ext2_test_bit (offset, bh->b_data)) +if (offset <0 || offset > max_bit || + !ext2_test_bit (offset, bh->b_data))/* bad block bitmap */ goto err_out;/* check whether the inode bitmap block number is set */ bitmap_blk =le32_to_cpu (desc->bg_inode_bitmap); offset = bitmap_blk - group_first_block; -if (!ext2_test_bit (offset, bh->b_data)) +if (offset <0 || offset > max_bit || + !ext2_test_bit (offset, bh->b_data))/* bad block bitmap */ goto err_out;/* check whether the inode table block number is set */ bitmap_blk =le32_to_cpu (desc->bg_inode_table); offset = bitmap_blk - group_first_block; +if (offset <0 || offset > max_bit || + offset +EXT2_SB (sb)->s_itb_per_group -1 > max_bit) + goto err_out; next_zero_bit =ext2_find_next_zero_bit (bh->b_data, offset +EXT2_SB (sb)->s_itb_per_group, offset);
Greg Kroah-Hartman
maintainerPATCH 290/440 drm/gma500: fix null pointer dereference in cdv_intel_lvds_get_modes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit cb520c3f366c77e8d69e4e2e2781a8ce48d98e79 upstream.
In cdv_intel_lvds_get_modes(), the return value of drm_mode_duplicate() is assigned to mode, which will lead to a NULL pointer dereference on failure of drm_mode_duplicate(). Add a check to avoid npd.
--- drivers/gpu/drm/gma500/cdv_intel_lvds.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/gma500/cdv_intel_lvds.c +3 -0
@@ -309,6 +309,9 @@ static int cdv_intel_lvds_get_modes(struif (mode_dev->panel_fixed_mode !=NULL ) {struct drm_display_mode *mode =drm_mode_duplicate (dev, mode_dev->panel_fixed_mode); +if (!mode) +return 0 ; +drm_mode_probed_add (connector, mode);return 1 ; }
Greg Kroah-Hartman
maintainerPATCH 291/440 drm/gma500: fix null pointer dereference in psb_intel_lvds_get_modes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit 2df7aac81070987b0f052985856aa325a38debf6 upstream.
In psb_intel_lvds_get_modes(), the return value of drm_mode_duplicate() is assigned to mode, which will lead to a possible NULL pointer dereference on failure of drm_mode_duplicate(). Add a check to avoid npd.
--- drivers/gpu/drm/gma500/psb_intel_lvds.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/gma500/psb_intel_lvds.c +3 -0
@@ -502,6 +502,9 @@ static int psb_intel_lvds_get_modes(struif (mode_dev->panel_fixed_mode !=NULL ) {struct drm_display_mode *mode =drm_mode_duplicate (dev, mode_dev->panel_fixed_mode); +if (!mode) +return 0 ; +drm_mode_probed_add (connector, mode);return 1 ; }
Greg Kroah-Hartman
maintainerPATCH 292/440 scsi: qla2xxx: Fix optrom version displayed in FDMI
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shreyas Deodhar <[email protected]>
commit 348744f27a35e087acc9378bf53537fbfb072775 upstream.
Bios version was popluated for FDMI response. Systems with EFI would show optrom version as 0. EFI version is populated here and BIOS version is already displayed under FDMI_HBA_BOOT_BIOS_NAME.
--- drivers/scsi/qla2xxx/qla_gs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_gs.c +1 -1
@@ -1710,7 +1710,7 @@ qla2x00_hba_attributes(scsi_qla_host_t * eiter->type =cpu_to_be16 (FDMI_HBA_OPTION_ROM_VERSION ); alen =scnprintf ( eiter->a.orom_version,sizeof (eiter->a.orom_version), -"%d.%02d" , ha->bios_revision[1 ], ha->bios_revision[0 ]); +"%d.%02d" , ha->efi_revision[1 ], ha->efi_revision[0 ]); alen +=FDMI_ATTR_ALIGNMENT (alen); alen +=FDMI_ATTR_TYPELEN (eiter); eiter->len =cpu_to_be16 (alen);
Greg Kroah-Hartman
maintainerPATCH 293/440 drm/amd/display: Check for NULL pointer
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sung Joon Kim <[email protected]>
commit 4ab68e168ae1695f7c04fae98930740aaf7c50fa upstream.
[why & how]
Need to make sure plane_state is initialized
before accessing its members.
--- drivers/gpu/drm/amd/display/dc/core/dc_surface.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/core/dc_surface.c +2 -1
@@ -154,7 +154,8 @@ const struct dc_plane_status *dc_plane_gif (pipe_ctx->plane_state != plane_state)continue ; - pipe_ctx->plane_state->status.is_flip_pending = false; +if (pipe_ctx->plane_state) + pipe_ctx->plane_state->status.is_flip_pending = false;break ; }
Greg Kroah-Hartman
maintainerPATCH 294/440 sched/fair: Use all little CPUs for CPU-bound workloads
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pierre Gondois <[email protected]>
commit 3af7524b14198f5159a86692d57a9f28ec9375ce upstream.
Running N CPU-bound tasks on an N CPUs platform:
- with asymmetric CPU capacity
- not being a DynamIq system (i.e. having a PKG level sched domain without the SD_SHARE_PKG_RESOURCES flag set)
.. might result in a task placement where two tasks run on a big CPU and none on a little CPU. This placement could be more optimal by using all CPUs.
Testing platform:
Juno-r2:
- 2 big CPUs (1-2), maximum capacity of 1024
- 4 little CPUs (0,3-5), maximum capacity of 383
Testing workload ([1]):
Spawn 6 CPU-bound tasks. During the first 100ms (step 1), each tasks is affine to a CPU, except for:
- one little CPU which is left idle.
- one big CPU which has 2 tasks affine.
After the 100ms (step 2), remove the cpumask affinity.
Behavior before the patch:
During step 2, the load balancer running from the idle CPU tags sched domains as:
- little CPUs: 'group_has_spare'. Cf. group_has_capacity() and group_is_overloaded(), 3 CPU-bound tasks run on a 4 CPUs sched-domain, and the idle CPU provides enough spare capacity regarding the imbalance_pct
- big CPUs: 'group_overloaded'. Indeed, 3 tasks run on a 2 CPUs sched-domain, so the following path is used:
group_is_overloaded()
\-if (sgs->sum_nr_running <= sgs->group_weight) return true;
The following path which would change the migration type to 'migrate_task' is not taken:
calculate_imbalance()
\-if (env->idle != CPU_NOT_IDLE && env->imbalance == 0)
as the local group has some spare capacity, so the imbalance is not 0.
The migration type requested is 'migrate_util' and the busiest runqueue is the big CPU's runqueue having 2 tasks (each having a utilization of 512). The idle little CPU cannot pull one of these task as its capacity is too small for the task. The following path is used:
detach_tasks()
\-case migrate_util:
\-if (util > env->imbalance) goto next;After the patch:
As the number of failed balancing attempts grows (with 'nr_balance_failed'), progressively make it easier to migrate a big task to the idling little CPU. A similar mechanism is used for the 'migrate_load' migration type.
Improvement:
Running the testing workload [1] with the step 2 representing a ~10s load for a big CPU:
Before patch: ~19.3s
After patch: ~18s (-6.7%)
Similar issue reported at:
https://lore.kernel.org/lkml/[email protected]/
--- kernel/sched/fair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/fair.c +1 -1
@@ -8524,7 +8524,7 @@ static int detach_tasks(struct lb_env *ecase migrate_util: util =task_util_est (p); -if (util > env->imbalance) +if (shr_bound (util, env->sd->nr_balance_failed) > env->imbalance) goto next; env->imbalance -= util;
Greg Kroah-Hartman
maintainerPATCH 295/440 apparmor: use kvfree_sensitive to free data->data
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
commit 2bc73505a5cd2a18a7a542022722f136c19e3b87 upstream.
Inside unpack_profile() data->data is allocated using kvmemdup() so it should be freed with the corresponding kvfree_sensitive().
Also add missing data->data release for rhashtable insertion failure path in unpack_profile().
Found by Linux Verification Center (linuxtesting.org).
--- security/apparmor/policy.c | 2 +- security/apparmor/policy_unpack.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
security/apparmor/policy.c +1 -1
@@ -187,7 +187,7 @@ static void aa_free_data(void *ptr, void {struct aa_data *data = ptr; -kfree_sensitive (data->data); +kvfree_sensitive (data->data, data->size);kfree_sensitive (data->key);kfree_sensitive (data); }
security/apparmor/policy_unpack.c +1 -0
@@ -898,6 +898,7 @@ static struct aa_profile *unpack_profileif (rhashtable_insert_fast (profile->data, &data->head, profile->data->p)) { +kvfree_sensitive (data->data, data->size);kfree_sensitive (data->key);kfree_sensitive (data); info ="failed to insert data to table" ;
Greg Kroah-Hartman
maintainerPATCH 296/440 cifs: fix potential null pointer use in destroy_workqueue in init_cifs error path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 193cc89ea0ca1da311877d2b4bb5e9f03bcc82a2 upstream.
Dan Carpenter reported a Smack static checker warning:
fs/smb/client/cifsfs.c:1981 init_cifs()
error: we previously assumed 'serverclose_wq' could be null (see line 1895)
The patch which introduced the serverclose workqueue used the wrong oredering in error paths in init_cifs() for freeing it on errors.
--- fs/smb/client/cifsfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/smb/client/cifsfs.c +4 -4
@@ -1872,12 +1872,12 @@ init_cifs(void) WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);if (!serverclose_wq) { rc = -ENOMEM ; - goto out_destroy_serverclose_wq; + goto out_destroy_deferredclose_wq; } rc =cifs_init_inodecache ();if (rc) - goto out_destroy_deferredclose_wq; + goto out_destroy_serverclose_wq; rc =init_mids ();if (rc)
@@ -1939,6 +1939,8 @@ out_destroy_mids:destroy_mids (); out_destroy_inodecache:cifs_destroy_inodecache (); +out_destroy_serverclose_wq: +destroy_workqueue (serverclose_wq); out_destroy_deferredclose_wq:destroy_workqueue (deferredclose_wq); out_destroy_cifsoplockd_wq:
@@ -1949,8 +1951,6 @@ out_destroy_decrypt_wq:destroy_workqueue (decrypt_wq); out_destroy_cifsiod_wq:destroy_workqueue (cifsiod_wq); -out_destroy_serverclose_wq: -destroy_workqueue (serverclose_wq); out_clean_proc:cifs_proc_clean ();return rc;
Greg Kroah-Hartman
maintainerPATCH 297/440 cifs: fix reconnect with SMB1 UNIX Extensions
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit a214384ce26b6111ea8c8d58fa82a1ca63996c38 upstream.
When mounting with the SMB1 Unix Extensions (e.g. mounts to Samba with vers=1.0), reconnects no longer reset the Unix Extensions (SetFSInfo SET_FILE_UNIX_BASIC) after tcon so most operations (e.g. stat, ls, open, statfs) will fail continuously with:
"Operation not supported"
if the connection ever resets (e.g. due to brief network disconnect)
--- fs/smb/client/connect.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
fs/smb/client/connect.c +16 -1
@@ -3975,6 +3975,7 @@ error: }#endif +#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY /* * Issue a TREE_CONNECT request. */
@@ -4096,11 +4097,25 @@ CIFSTCon(const unsigned int xid, struct else tcon->Flags = 0;cifs_dbg (FYI ,"Tcon flags: 0x%x\n" , tcon->Flags); - } +/* +* reset_cifs_unix_caps calls QFSInfo which requires +* need_reconnect to be false, but we would not need to call +* reset_caps if this were not a reconnect case so must check +* need_reconnect flag here. The caller will also clear +* need_reconnect when tcon was successful but needed to be +* cleared earlier in the case of unix extensions reconnect +*/ +if (tcon->need_reconnect && tcon->unix_ext) { +cifs_dbg (FYI ,"resetting caps for %s\n" , tcon->tree_name); + tcon->need_reconnect = false; +reset_cifs_unix_caps (xid, tcon,NULL ,NULL ); + } + }cifs_buf_release (smb_buffer);return rc; } +#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ static void delayed_free (struct rcu_head *p) {
Greg Kroah-Hartman
maintainerPATCH 298/440 cifs: mount with "unix" mount option for SMB1 incorrectly handled
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 0e314e452687ce0ec5874e42cdb993a34325d3d2 upstream.
Although by default we negotiate CIFS Unix Extensions for SMB1 mounts to Samba (and they work if the user does not specify "unix" or "posix" or "linux" on mount), and we do properly handle when a user turns them off with "nounix" mount parm. But with the changes to the mount API we broke cases where the user explicitly specifies the "unix" option (or equivalently "linux" or "posix") on mount with vers=1.0 to Samba or other servers which support the CIFS Unix Extensions.
"mount error(95): Operation not supported"
and logged:
"CIFS: VFS: Check vers= mount option. SMB3.11 disabled but required for POSIX extensions"
even though CIFS Unix Extensions are supported for vers=1.0 This patch fixes the case where the user specifies both "unix" (or equivalently "posix" or "linux") and "vers=1.0" on mount to a server which supports the CIFS Unix Extensions.
--- fs/smb/client/connect.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/smb/client/connect.c +7 -0
@@ -2592,6 +2592,13 @@ cifs_get_tcon(struct cifs_ses *ses, strucifs_dbg (VFS ,"Server does not support mounting with posix SMB3.11 extensions\n" ); rc = -EOPNOTSUPP ; goto out_fail; + }else if (ses->server->vals->protocol_id ==SMB10_PROT_ID ) +if (cap_unix (ses)) +cifs_dbg (FYI ,"Unix Extensions requested on SMB1 mount\n" ); +else { +cifs_dbg (VFS ,"SMB1 Unix Extensions not supported by server\n" ); + rc = -EOPNOTSUPP ; + goto out_fail; }else {cifs_dbg (VFS ,"Check vers= mount option. SMB3.11 " "disabled but required for POSIX extensions\n" );
Greg Kroah-Hartman
maintainerPATCH 299/440 task_work: s/task_work_cancel()/task_work_cancel_func()/
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frederic Weisbecker <[email protected]>
commit 68cbd415dd4b9c5b9df69f0f091879e56bf5907a upstream.
A proper task_work_cancel() API that actually cancels a callback and not *any* callback pointing to a given function is going to be needed for perf events event freeing. Do the appropriate rename to prepare for that.
--- include/linux/task_work.h | 2 +- kernel/irq/manage.c | 2 +- kernel/task_work.c | 10 +++++----- security/keys/keyctl.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-)
include/linux/task_work.h +1 -1
@@ -30,7 +30,7 @@ int task_work_add(struct task_struct *tastruct callback_head *task_work_cancel_match (struct task_struct *task,bool (*match)(struct callback_head *,void *data),void *data); -struct callback_head *task_work_cancel (struct task_struct *,task_work_func_t ); +struct callback_head *task_work_cancel_func (struct task_struct *,task_work_func_t );void task_work_run (void );static inline void exit_task_work (struct task_struct *task)
kernel/irq/manage.c +1 -1
@@ -1324,7 +1324,7 @@ static int irq_thread(void *data)* synchronize_hardirq(). So neither IRQTF_RUNTHREAD nor the * oneshot mask bit can be set. */ -task_work_cancel (current, irq_thread_dtor); +task_work_cancel_func (current, irq_thread_dtor);return 0 ; }
kernel/task_work.c +5 -5
@@ -119,9 +119,9 @@ static bool task_work_func_match(struct }/** -* task_work_cancel - cancel a pending work added by task_work_add() -* @task: the task which should execute the work -* @func: identifies the work to remove +* task_work_cancel_func - cancel a pending work matching a function added by task_work_add() +* @task: the task which should execute the func's work +* @func: identifies the func to match with a work to remove * * Find the last queued pending work with ->func == @func and remove * it from queue.
@@ -130,7 +130,7 @@ static bool task_work_func_match(struct* The found work or NULL if not found. */ struct callback_head * -task_work_cancel (struct task_struct *task,task_work_func_t func) +task_work_cancel_func (struct task_struct *task,task_work_func_t func) {return task_work_cancel_match (task, task_work_func_match, func); }
@@ -167,7 +167,7 @@ void task_work_run(void)if (!work)break ;/* -* Synchronize with task_work_cancel(). It can not remove +* Synchronize with task_work_cancel_match(). It can not remove * the first entry == work, cmpxchg(task_works) must fail. * But it can remove another entry from the ->next list. */
security/keys/keyctl.c +1 -1
@@ -1694,7 +1694,7 @@ long keyctl_session_to_parent(void) goto unlock;/* cancel an already pending keyring replacement */ - oldwork =task_work_cancel (parent, key_change_session_keyring); + oldwork =task_work_cancel_func (parent, key_change_session_keyring);/* the replacement session keyring is applied just prior to userspace * restarting */
Greg Kroah-Hartman
maintainerPATCH 300/440 task_work: Introduce task_work_cancel() again
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frederic Weisbecker <[email protected]>
commit f409530e4db9dd11b88cb7703c97c8f326ff6566 upstream.
Re-introduce task_work_cancel(), this time to cancel an actual callback and not *any* callback pointing to a given function. This is going to be needed for perf events event freeing.
--- include/linux/task_work.h | 1 + kernel/task_work.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+)
include/linux/task_work.h +1 -0
@@ -31,6 +31,7 @@ int task_work_add(struct task_struct *tastruct callback_head *task_work_cancel_match (struct task_struct *task,bool (*match)(struct callback_head *,void *data),void *data);struct callback_head *task_work_cancel_func (struct task_struct *,task_work_func_t ); +bool task_work_cancel (struct task_struct *task,struct callback_head *cb);void task_work_run (void );static inline void exit_task_work (struct task_struct *task)
kernel/task_work.c +24 -0
@@ -135,6 +135,30 @@ task_work_cancel_func(struct task_structreturn task_work_cancel_match (task, task_work_func_match, func); } +static bool task_work_match (struct callback_head *cb,void *data) +{ +return cb == data; +} + +/** +* task_work_cancel - cancel a pending work added by task_work_add() +* @task: the task which should execute the work +* @cb: the callback to remove if queued +* +* Remove a callback from a task's queue if queued. +* +* RETURNS: +* True if the callback was queued and got cancelled, false otherwise. +*/ +bool task_work_cancel (struct task_struct *task,struct callback_head *cb) +{ +struct callback_head *ret; + + ret =task_work_cancel_match (task, task_work_match, cb); + +return ret == cb; +} +/** * task_work_run - execute the works added by task_work_add() *
Greg Kroah-Hartman
maintainerPATCH 301/440 udf: Avoid using corrupted block bitmap buffer
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit a90d4471146de21745980cba51ce88e7926bcc4f upstream.
When the filesystem block bitmap is corrupted, we detect the corruption while loading the bitmap and fail the allocation with error. However the next allocation from the same bitmap will notice the bitmap buffer is already loaded and tries to allocate from the bitmap with mixed results (depending on the exact nature of the bitmap corruption). Fix the problem by using BH_verified bit to indicate whether the bitmap is valid or not.
--- fs/udf/balloc.c | 15 +++++++++++++-- fs/udf/super.c | 3 ++- 2 files changed, 15 insertions(+), 3 deletions(-)
fs/udf/balloc.c +13 -2
@@ -68,8 +68,12 @@ static int read_block_bitmap(struct supe }for (i =0 ; i < count; i++) -if (udf_test_bit (i + off, bh->b_data)) +if (udf_test_bit (i + off, bh->b_data)) { + bitmap->s_block_bitmap[bitmap_nr] = +ERR_PTR (-EFSCORRUPTED ); +brelse (bh);return -EFSCORRUPTED ; + }return 0 ; }
@@ -85,8 +89,15 @@ static int __load_block_bitmap(struct su block_group, nr_groups); } -if (bitmap->s_block_bitmap[block_group]) +if (bitmap->s_block_bitmap[block_group]) { +/* +* The bitmap failed verification in the past. No point in +* trying again. +*/ +if (IS_ERR (bitmap->s_block_bitmap[block_group])) +return PTR_ERR (bitmap->s_block_bitmap[block_group]);return block_group; + } retval =read_block_bitmap (sb, bitmap, block_group, block_group);if (retval <0 )
fs/udf/super.c +2 -1
@@ -266,7 +266,8 @@ static void udf_sb_free_bitmap(struct udint nr_groups = bitmap->s_nr_groups;for (i =0 ; i < nr_groups; i++) -brelse (bitmap->s_block_bitmap[i]); +if (!IS_ERR_OR_NULL (bitmap->s_block_bitmap[i])) +brelse (bitmap->s_block_bitmap[i]);kvfree (bitmap); }
Greg Kroah-Hartman
maintainerPATCH 302/440 m68k: amiga: Turn off Warp1260 interrupts during boot
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Pisati <[email protected]>
commit 1d8491d3e726984343dd8c3cdbe2f2b47cfdd928 upstream.
On an Amiga 1200 equipped with a Warp1260 accelerator, an interrupt storm coming from the accelerator board causes the machine to crash in local_irq_enable() or auto_irq_enable(). Disabling interrupts for the Warp1260 in amiga_parse_bootinfo() fixes the problem.
--- arch/m68k/amiga/config.c | 9 +++++++++ include/uapi/linux/zorro_ids.h | 3 +++ 2 files changed, 12 insertions(+)
arch/m68k/amiga/config.c +9 -0
@@ -180,6 +180,15 @@ int __init amiga_parse_bootinfo(const st dev->slotsize =be16_to_cpu (cd->cd_SlotSize); dev->boardaddr =be32_to_cpu (cd->cd_BoardAddr); dev->boardsize =be32_to_cpu (cd->cd_BoardSize); + +/* CS-LAB Warp 1260 workaround */ +if (be16_to_cpu (dev->rom.er_Manufacturer) ==ZORRO_MANUF (ZORRO_PROD_CSLAB_WARP_1260 ) && + dev->rom.er_Product ==ZORRO_PROD (ZORRO_PROD_CSLAB_WARP_1260 )) { + +/* turn off all interrupts */ +pr_info ("Warp 1260 card detected: applying interrupt storm workaround\n" ); + *(uint32_t *)(dev->boardaddr +0x1000 ) =0xfff ; + } }else pr_warn ("amiga_parse_bootinfo: too many AutoConfig devices\n" );#endif /* CONFIG_ZORRO */
include/uapi/linux/zorro_ids.h +3 -0
@@ -449,6 +449,9 @@#define ZORRO_PROD_VMC_ISDN_BLASTER_Z2 ZORRO_ID(VMC, 0x01, 0)#define ZORRO_PROD_VMC_HYPERCOM_4 ZORRO_ID(VMC, 0x02, 0) +#define ZORRO_MANUF_CSLAB 0x1400 +#define ZORRO_PROD_CSLAB_WARP_1260 ZORRO_ID(CSLAB, 0x65, 0) +#define ZORRO_MANUF_INFORMATION 0x157C#define ZORRO_PROD_INFORMATION_ISDN_ENGINE_I ZORRO_ID(INFORMATION, 0x64, 0)
Greg Kroah-Hartman
maintainerPATCH 303/440 ext4: check dot and dotdot of dx_root before making dir indexed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit 50ea741def587a64e08879ce6c6a30131f7111e7 upstream.
Syzbot reports a issue as follows:
============================================
BUG: unable to handle page fault for address: ffffed11022e24fe PGD 23ffee067 P4D 23ffee067 PUD 0 Oops: Oops: 0000 [#1] PREEMPT SMP KASAN PTI CPU: 0 PID: 5079 Comm: syz-executor306 Not tainted 6.10.0-rc5-g55027e689933 #0 Call Trace: <TASK> make_indexed_dir+0xdaf/0x13c0 fs/ext4/namei.c:2341 ext4_add_entry+0x222a/0x25d0 fs/ext4/namei.c:2451 ext4_rename fs/ext4/namei.c:3936 [inline] ext4_rename2+0x26e5/0x4370 fs/ext4/namei.c:4214
[...]
============================================
The immediate cause of this problem is that there is only one valid dentry for the block to be split during do_split, so split==0 results in out of bounds accesses to the map triggering the issue.
do_split
unsigned split
dx_make_map
count = 1
split = count/2 = 0;
continued = hash2 == map[split - 1].hash;
---> map[4294967295]The maximum length of a filename is 255 and the minimum block size is 1024, so it is always guaranteed that the number of entries is greater than or equal to 2 when do_split() is called.
But syzbot's crafted image has no dot and dotdot in dir, and the dentry distribution in dirblock is as follows:
bus dentry1 hole dentry2 free
|xx--|xx-------------|...............|xx-------------|...............| 0 12 (8+248)=256 268 256 524 (8+256)=264 788 236 1024
So when renaming dentry1 increases its name_len length by 1, neither hole nor free is sufficient to hold the new dentry, and make_indexed_dir() is called.
In make_indexed_dir() it is assumed that the first two entries of the dirblock must be dot and dotdot, so bus and dentry1 are left in dx_root because they are treated as dot and dotdot, and only dentry2 is moved to the new leaf block. That's why count is equal to 1.
Therefore add the ext4_check_dx_root() helper function to add more sanity checks to dot and dotdot before starting the conversion to avoid the above issue.
--- fs/ext4/namei.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-)
fs/ext4/namei.c +51 -5
@@ -2218,6 +2218,52 @@ static int add_dirent_to_buf(handle_t *hreturn err ? err : err2; } +static bool ext4_check_dx_root (struct inode *dir,struct dx_root *root) +{ +struct fake_dirent *fde; +const char *error_msg; +unsigned int rlen; +unsigned int blocksize = dir->i_sb->s_blocksize; +char *blockend = (char *)root + dir->i_sb->s_blocksize; + + fde = &root->dot; +if (unlikely (fde->name_len !=1 )) { + error_msg ="invalid name_len for '.'" ; + goto corrupted; + } +if (unlikely (strncmp (root->dot_name,"." , fde->name_len))) { + error_msg ="invalid name for '.'" ; + goto corrupted; + } + rlen =ext4_rec_len_from_disk (fde->rec_len, blocksize); +if (unlikely ((char *)fde + rlen >= blockend)) { + error_msg ="invalid rec_len for '.'" ; + goto corrupted; + } + + fde = &root->dotdot; +if (unlikely (fde->name_len !=2 )) { + error_msg ="invalid name_len for '..'" ; + goto corrupted; + } +if (unlikely (strncmp (root->dotdot_name,".." , fde->name_len))) { + error_msg ="invalid name for '..'" ; + goto corrupted; + } + rlen =ext4_rec_len_from_disk (fde->rec_len, blocksize); +if (unlikely ((char *)fde + rlen >= blockend)) { + error_msg ="invalid rec_len for '..'" ; + goto corrupted; + } + +return true; + +corrupted: +EXT4_ERROR_INODE (dir,"Corrupt dir, %s, running e2fsck is recommended" , + error_msg); +return false; +} +/* * This converts a one block unindexed directory to a 3 block indexed * directory, and adds the dentry to the indexed directory.
@@ -2252,17 +2298,17 @@ static int make_indexed_dir(handle_t *habrelse (bh);return retval; } + root = (struct dx_root *) bh->b_data; +if (!ext4_check_dx_root (dir, root)) { +brelse (bh); +return -EFSCORRUPTED ; + }/* The 0th block becomes the root, move the dirents out */ fde = &root->dotdot; de = (struct ext4_dir_entry_2 *)((char *)fde +ext4_rec_len_from_disk (fde->rec_len, blocksize)); -if ((char *) de >= (((char *) root) + blocksize)) { -EXT4_ERROR_INODE (dir,"invalid rec_len for '..'" ); -brelse (bh); -return -EFSCORRUPTED ; - } len = ((char *) root) + (blocksize - csum_size) - (char *) de;/* Allocate new block for the 0th block's dirents */
Greg Kroah-Hartman
maintainerPATCH 304/440 ext4: make sure the first directory block is not a hole
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit f9ca51596bbfd0f9c386dd1c613c394c78d9e5e6 upstream.
The syzbot constructs a directory that has no dirblock but is non-inline, i.e. the first directory block is a hole. And no errors are reported when creating files in this directory in the following flow.
ext4_mknod
...
ext4_add_entry
// Read block 0
ext4_read_dirblock(dir, block, DIRENT)
bh = ext4_bread(NULL, inode, block, 0)
if (!bh && (type == INDEX || type == DIRENT_HTREE))
// The first directory block is a hole
// But type == DIRENT, so no error is reported.After that, we get a directory block without '.' and '..' but with a valid dentry. This may cause some code that relies on dot or dotdot (such as make_indexed_dir()) to crash.
Therefore when ext4_read_dirblock() finds that the first directory block is a hole report that the filesystem is corrupted and return an error to avoid loading corrupted data from disk causing something bad.
--- fs/ext4/namei.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
fs/ext4/namei.c +6 -11
@@ -151,10 +151,11 @@ static struct buffer_head *__ext4_read_dreturn bh; } -if (!bh && (type ==INDEX || type ==DIRENT_HTREE )) { +/* The first directory block must not be a hole. */ +if (!bh && (type ==INDEX || type ==DIRENT_HTREE || block ==0 )) {ext4_error_inode (inode, func, line, block, -"Directory hole found for htree %s block" , - (type ==INDEX ) ?"index" :"leaf" ); +"Directory hole found for htree %s block %u" , + (type ==INDEX ) ?"index" :"leaf" , block);return ERR_PTR (-EFSCORRUPTED ); }if (!bh)
@@ -3133,10 +3134,7 @@ bool ext4_empty_dir(struct inode *inode)EXT4_ERROR_INODE (inode,"invalid size" );return false; } -/* The first directory block must not be a hole, -* so treat it as DIRENT_HTREE -*/ - bh =ext4_read_dirblock (inode,0 ,DIRENT_HTREE ); + bh =ext4_read_dirblock (inode,0 ,EITHER );if (IS_ERR (bh))return false;
@@ -3580,10 +3578,7 @@ static struct buffer_head *ext4_get_firsstruct ext4_dir_entry_2 *de;unsigned int offset; -/* The first directory block must not be a hole, so -* treat it as DIRENT_HTREE -*/ - bh =ext4_read_dirblock (inode,0 ,DIRENT_HTREE ); + bh =ext4_read_dirblock (inode,0 ,EITHER );if (IS_ERR (bh)) { *retval =PTR_ERR (bh);return NULL ;
Greg Kroah-Hartman
maintainerPATCH 305/440 io_uring: tighten task exit cancellations
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit f8b632e89a101dae349a7b212c1771d7925f441b upstream.
io_uring_cancel_generic() should retry if any state changes like a request is completed, however in case of a task exit it only goes for another loop and avoids schedule() if any tracked (i.e. REQ_F_INFLIGHT) request got completed.
Let's assume we have a non-tracked request executing in iowq and a tracked request linked to it. Let's also assume io_uring_cancel_generic() fails to find and cancel the request, i.e. via io_run_local_work(), which may happen as io-wq has gaps. Next, the request logically completes, io-wq still hold a ref but queues it for completion via tw, which happens in io_uring_try_cancel_requests(). After, right before prepare_to_wait() io-wq puts the request, grabs the linked one and tries executes it, e.g. arms polling. Finally the cancellation loop calls prepare_to_wait(), there are no tw to run, no tracked request was completed, so the tctx_inflight() check passes and the task is put to indefinite sleep.
--- io_uring/io_uring.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
io_uring/io_uring.c +4 -1
@@ -3000,8 +3000,11 @@ __cold void io_uring_cancel_generic(boolbool loop = false;io_uring_drop_tctx_refs (current); +if (!tctx_inflight (tctx, !cancel_all)) +break ; +/* read completions before cancelations */ - inflight =tctx_inflight (tctx, !cancel_all); + inflight =tctx_inflight (tctx, false);if (!inflight)break ;
Greg Kroah-Hartman
maintainerPATCH 306/440 trace/pid_list: Change gfp flags in pid_list_fill_irq()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: levi.yun <[email protected]>
commit 7dc836187f7c6f70a82b4521503e9f9f96194581 upstream.
pid_list_fill_irq() runs via irq_work.
When CONFIG_PREEMPT_RT is disabled, it would run in irq_context. so it shouldn't sleep while memory allocation.
Change gfp flags from GFP_KERNEL to GFP_NOWAIT to prevent sleep in irq_work.
This change wouldn't impact functionality in practice because the worst-size is 2K.
--- kernel/trace/pid_list.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/pid_list.c +2 -2
@@ -354,7 +354,7 @@ static void pid_list_refill_irq(struct iwhile (upper_count-- >0 ) {union upper_chunk *chunk; - chunk =kzalloc (sizeof (*chunk),GFP_KERNEL ); + chunk =kzalloc (sizeof (*chunk),GFP_NOWAIT );if (!chunk)break ; *upper_next = chunk;
@@ -365,7 +365,7 @@ static void pid_list_refill_irq(struct iwhile (lower_count-- >0 ) {union lower_chunk *chunk; - chunk =kzalloc (sizeof (*chunk),GFP_KERNEL ); + chunk =kzalloc (sizeof (*chunk),GFP_NOWAIT );if (!chunk)break ; *lower_next = chunk;
Greg Kroah-Hartman
maintainerPATCH 307/440 selftests/landlock: Add cred_transfer test
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mickaël Salaün <[email protected]>
commit cc374782b6ca0fd634482391da977542443d3368 upstream.
Check that keyctl(KEYCTL_SESSION_TO_PARENT) preserves the parent's restrictions.
--- tools/testing/selftests/landlock/base_test.c | 74 +++++++++++++++++++++++++++ tools/testing/selftests/landlock/config | 5 + 2 files changed, 77 insertions(+), 2 deletions(-)
tools/testing/selftests/landlock/base_test.c +74 -0
@@ -9,6 +9,7 @@#define _GNU_SOURCE#include <errno.h> #include <fcntl.h> +#include <linux/keyctl.h> #include <linux/landlock.h> #include <string.h> #include <sys/prctl.h>
@@ -356,4 +357,77 @@ TEST(ruleset_fd_transfer)ASSERT_EQ (EXIT_SUCCESS ,WEXITSTATUS (status)); } +TEST (cred_transfer) +{ +struct landlock_ruleset_attr ruleset_attr = { + .handled_access_fs =LANDLOCK_ACCESS_FS_READ_DIR , + }; +int ruleset_fd, dir_fd; +pid_t child; +int status; + +drop_caps (_metadata); + + dir_fd =open ("/" ,O_RDONLY |O_DIRECTORY |O_CLOEXEC ); +EXPECT_LE (0 , dir_fd); +EXPECT_EQ (0 ,close (dir_fd)); + +/* Denies opening directories. */ + ruleset_fd = +landlock_create_ruleset (&ruleset_attr,sizeof (ruleset_attr),0 ); +ASSERT_LE (0 , ruleset_fd); +EXPECT_EQ (0 ,prctl (PR_SET_NO_NEW_PRIVS ,1 ,0 ,0 ,0 )); +ASSERT_EQ (0 ,landlock_restrict_self (ruleset_fd,0 )); +EXPECT_EQ (0 ,close (ruleset_fd)); + +/* Checks ruleset enforcement. */ +EXPECT_EQ (-1 ,open ("/" ,O_RDONLY |O_DIRECTORY |O_CLOEXEC )); +EXPECT_EQ (EACCES , errno); + +/* Needed for KEYCTL_SESSION_TO_PARENT permission checks */ +EXPECT_NE (-1 ,syscall (__NR_keyctl,KEYCTL_JOIN_SESSION_KEYRING ,NULL ,0 , + 0, 0)) + { +TH_LOG ("Failed to join session keyring: %s" ,strerror (errno)); + } + + child =fork (); +ASSERT_LE (0 , child); +if (child ==0 ) { +/* Checks ruleset enforcement. */ +EXPECT_EQ (-1 ,open ("/" ,O_RDONLY |O_DIRECTORY |O_CLOEXEC )); +EXPECT_EQ (EACCES , errno); + +/* +* KEYCTL_SESSION_TO_PARENT is a no-op unless we have a +* different session keyring in the child, so make that happen. +*/ +EXPECT_NE (-1 ,syscall (__NR_keyctl,KEYCTL_JOIN_SESSION_KEYRING , +NULL ,0 ,0 ,0 )); + +/* +* KEYCTL_SESSION_TO_PARENT installs credentials on the parent +* that never go through the cred_prepare hook, this path uses +* cred_transfer instead. +*/ +EXPECT_EQ (0 ,syscall (__NR_keyctl,KEYCTL_SESSION_TO_PARENT ,0 , +0 ,0 ,0 )); + +/* Re-checks ruleset enforcement. */ +EXPECT_EQ (-1 ,open ("/" ,O_RDONLY |O_DIRECTORY |O_CLOEXEC )); +EXPECT_EQ (EACCES , errno); + +_exit (_metadata->passed ?EXIT_SUCCESS :EXIT_FAILURE ); +return ; + } + +EXPECT_EQ (child,waitpid (child, &status,0 )); +EXPECT_EQ (1 ,WIFEXITED (status)); +EXPECT_EQ (EXIT_SUCCESS ,WEXITSTATUS (status)); + +/* Re-checks ruleset enforcement. */ +EXPECT_EQ (-1 ,open ("/" ,O_RDONLY |O_DIRECTORY |O_CLOEXEC )); +EXPECT_EQ (EACCES , errno); +} +TEST_HARNESS_MAIN
tools/testing/selftests/landlock/config +3 -2
@@ -1,7 +1,8 @@ +CONFIG_KEYS=y CONFIG_OVERLAY_FS=y +CONFIG_SECURITY=y CONFIG_SECURITY_LANDLOCK=y CONFIG_SECURITY_PATH=y -CONFIG_SECURITY=y CONFIG_SHMEM=y -CONFIG_TMPFS_XATTR=y CONFIG_TMPFS=y +CONFIG_TMPFS_XATTR=y
Greg Kroah-Hartman
maintainerPATCH 308/440 wifi: mwifiex: Fix interface type change
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael Beims <[email protected]>
commit a17b9f590f6ec2b9f1b12b1db3bf1d181de6b272 upstream.
When changing the interface type we also need to update the bss_num, the driver private data is searched based on a unique (bss_type, bss_num) tuple, therefore every time bss_type changes, bss_num must also change.
This fixes for example an issue in which, after the mode changed, a wireless scan on the changed interface would not finish, leading to repeated -EBUSY messages to userspace when other scan requests were sent.
--- drivers/net/wireless/marvell/mwifiex/cfg80211.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/marvell/mwifiex/cfg80211.c +2 -0
@@ -926,6 +926,8 @@ mwifiex_init_new_priv_params(struct mwifreturn -EOPNOTSUPP ; } + priv->bss_num =mwifiex_get_unused_bss_num (adapter, priv->bss_type); +spin_lock_irqsave (&adapter->main_proc_lock, flags); adapter->main_locked = false;spin_unlock_irqrestore (&adapter->main_proc_lock, flags);
Greg Kroah-Hartman
maintainerPATCH 309/440 drivers: soc: xilinx: check return status of get_api_version()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jay Buddhabhatti <[email protected]>
commit 9b003e14801cf85a8cebeddc87bc9fc77100fdce upstream.
Currently return status is not getting checked for get_api_version and because of that for x86 arch we are getting below smatch error.
CC drivers/soc/xilinx/zynqmp_power.odrivers/soc/xilinx/zynqmp_power.c: In function 'zynqmp_pm_probe':drivers/soc/xilinx/zynqmp_power.c:295:12: warning: 'pm_api_version' is used uninitialized [-Wuninitialized]
295 | if (pm_api_version < ZYNQMP_PM_VERSION)
| ^
CHECK drivers/soc/xilinx/zynqmp_power.cdrivers/soc/xilinx/zynqmp_power.c:295 zynqmp_pm_probe() error:
uninitialized symbol 'pm_api_version'.
So, check return status of pm_get_api_version and return error in case of failure to avoid checking uninitialized pm_api_version variable.
--- drivers/soc/xilinx/zynqmp_power.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/soc/xilinx/zynqmp_power.c +3 -1
@@ -187,7 +187,9 @@ static int zynqmp_pm_probe(struct platfou32 pm_api_version;struct mbox_client *client; -zynqmp_pm_get_api_version (&pm_api_version); + ret =zynqmp_pm_get_api_version (&pm_api_version); +if (ret) +return ret;/* Check PM API version number */ if (pm_api_version <ZYNQMP_PM_VERSION )
Greg Kroah-Hartman
maintainerPATCH 310/440 leds: ss4200: Convert PCIBIOS_* return codes to errnos
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
commit ce068e83976140badb19c7f1307926b4b562fac4 upstream.
ich7_lpc_probe() uses pci_read_config_dword() that returns PCIBIOS_* codes. The error handling code assumes incorrectly it's a normal errno and checks for < 0. The return code is returned from the probe function as is but probe functions should return normal errnos.
Remove < 0 from the check and convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal errno before returning it.
--- drivers/leds/leds-ss4200.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/leds/leds-ss4200.c +5 -2
@@ -356,8 +356,10 @@ static int ich7_lpc_probe(struct pci_dev nas_gpio_pci_dev = dev; status =pci_read_config_dword (dev,PMBASE , &g_pm_io_base); -if (status) +if (status) { + status =pcibios_err_to_errno (status); goto out; + } g_pm_io_base &=0x00000ff80 ; status =pci_read_config_dword (dev,GPIO_CTRL , &gc);
@@ -369,8 +371,9 @@ static int ich7_lpc_probe(struct pci_dev } status =pci_read_config_dword (dev,GPIO_BASE , &nas_gpio_io_base); -if (0 > status) { +if (status) {dev_info (&dev->dev,"Unable to read GPIOBASE.\n" ); + status =pcibios_err_to_errno (status); goto out; }dev_dbg (&dev->dev,": GPIOBASE = 0x%08x\n" , nas_gpio_io_base);
Greg Kroah-Hartman
maintainerPATCH 311/440 leds: mt6360: Fix memory leak in mt6360_init_isnk_properties()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Carrasco <[email protected]>
commit e41d574b359ccd8d99be65c6f11502efa2b83136 upstream.
The fwnode_for_each_child_node() loop requires manual intervention to decrement the child refcount in case of an early return.
Add the missing calls to fwnode_handle_put(child) to avoid memory leaks in the error paths.
--- drivers/leds/flash/leds-mt6360.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/leds/flash/leds-mt6360.c +4 -1
@@ -637,14 +637,17 @@ static int mt6360_init_isnk_properties(s ret =fwnode_property_read_u32 (child,"reg" , ®);if (ret || reg >MT6360_LED_ISNK3 || - priv->leds_active &BIT (reg)) + priv->leds_active &BIT (reg)) { +fwnode_handle_put (child);return -EINVAL ; + } ret =fwnode_property_read_u32 (child,"color" , &color);if (ret) {dev_err (priv->dev,"led %d, no color specified\n" , led->led_no); +fwnode_handle_put (child);return ret; }
Greg Kroah-Hartman
maintainerPATCH 312/440 jbd2: make jbd2_journal_get_max_txn_bufs() internal
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 4aa99c71e42ad60178c1154ec24e3df9c684fb67 upstream.
There's no reason to have jbd2_journal_get_max_txn_bufs() public function. Currently all users are internal and can use journal->j_max_transaction_buffers instead. This saves some unnecessary recomputations of the limit as a bonus which becomes important as this function gets more complex in the following patch.
--- fs/jbd2/commit.c | 2 +- fs/jbd2/journal.c | 5 +++++ include/linux/jbd2.h | 5 ----- 3 files changed, 6 insertions(+), 6 deletions(-)
fs/jbd2/commit.c +1 -1
@@ -801,7 +801,7 @@ start_journal_io:if (first_block < journal->j_tail) freed += journal->j_last - journal->j_first;/* Update tail only if we free significant amount of space */ -if (freed <jbd2_journal_get_max_txn_bufs (journal)) +if (freed < journal->j_max_transaction_buffers) update_tail =0 ; }J_ASSERT (commit_transaction->t_state ==T_COMMIT );
fs/jbd2/journal.c +5 -0
@@ -1532,6 +1532,11 @@ static void journal_fail_superblock(jour journal->j_sb_buffer =NULL ; } +static int jbd2_journal_get_max_txn_bufs (journal_t *journal) +{ +return (journal->j_total_len - journal->j_fc_wbufsize) /4 ; +} +/* * Given a journal_t structure, initialise the various fields for * startup of a new journaling session. We use this both when creating
include/linux/jbd2.h +0 -5
@@ -1665,11 +1665,6 @@ int jbd2_wait_inode_data(journal_t *jourint jbd2_fc_wait_bufs (journal_t *journal,int num_blks);int jbd2_fc_release_bufs (journal_t *journal); -static inline int jbd2_journal_get_max_txn_bufs (journal_t *journal) -{ -return (journal->j_total_len - journal->j_fc_wbufsize) /4 ; -} -/* * is_journal_abort *
Greg Kroah-Hartman
maintainerPATCH 313/440 media: uvcvideo: Fix integer overflow calculating timestamp
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ricardo Ribalda <[email protected]>
commit 8676a5e796fa18f55897ca36a94b2adf7f73ebd1 upstream.
The function uvc_video_clock_update() supports a single SOF overflow. Or in other words, the maximum difference between the first ant the last timestamp can be 4096 ticks or 4.096 seconds.
This results in a maximum value for y2 of: 0x12FBECA00, that overflows 32bits.
y2 = (u32)ktime_to_ns(ktime_sub(last->host_time, first->host_time)) + y1;
Extend the size of y2 to u64 to support all its values.
Without this patch:
# yavta -s 1920x1080 -f YUYV -t 1/5 -c /dev/video0 Device /dev/v4l/by-id/usb-Shine-Optics_Integrated_Camera_0001-video-index0 opened. Device `Integrated Camera: Integrated C' on `usb-0000:00:14.0-6' (driver 'uvcvideo') supports video, capture, without mplanes. Video format set: YUYV (56595559) 1920x1080 (stride 3840) field none buffer size 4147200 Video format: YUYV (56595559) 1920x1080 (stride 3840) field none buffer size 4147200 Current frame rate: 1/5 Setting frame rate to: 1/5 Frame rate set: 1/5 8 buffers requested. length: 4147200 offset: 0 timestamp type/source: mono/SoE Buffer 0/0 mapped at address 0x7947ea94c000. length: 4147200 offset: 4149248 timestamp type/source: mono/SoE Buffer 1/0 mapped at address 0x7947ea557000. length: 4147200 offset: 8298496 timestamp type/source: mono/SoE Buffer 2/0 mapped at address 0x7947ea162000. length: 4147200 offset: 12447744 timestamp type/source: mono/SoE Buffer 3/0 mapped at address 0x7947e9d6d000. length: 4147200 offset: 16596992 timestamp type/source: mono/SoE Buffer 4/0 mapped at address 0x7947e9978000. length: 4147200 offset: 20746240 timestamp type/source: mono/SoE Buffer 5/0 mapped at address 0x7947e9583000. length: 4147200 offset: 24895488 timestamp type/source: mono/SoE Buffer 6/0 mapped at address 0x7947e918e000. length: 4147200 offset: 29044736 timestamp type/source: mono/SoE Buffer 7/0 mapped at address 0x7947e8d99000. 0 (0) [-] none 0 4147200 B 507.554210 508.874282 242.836 fps ts mono/SoE 1 (1) [-] none 2 4147200 B 508.886298 509.074289 0.751 fps ts mono/SoE 2 (2) [-] none 3 4147200 B 509.076362 509.274307 5.261 fps ts mono/SoE 3 (3) [-] none 4 4147200 B 509.276371 509.474336 5.000 fps ts mono/SoE 4 (4) [-] none 5 4147200 B 509.476394 509.674394 4.999 fps ts mono/SoE 5 (5) [-] none 6 4147200 B 509.676506 509.874345 4.997 fps ts mono/SoE 6 (6) [-] none 7 4147200 B 509.876430 510.074370 5.002 fps ts mono/SoE 7 (7) [-] none 8 4147200 B 510.076434 510.274365 5.000 fps ts mono/SoE 8 (0) [-] none 9 4147200 B 510.276421 510.474333 5.000 fps ts mono/SoE 9 (1) [-] none 10 4147200 B 510.476391 510.674429 5.001 fps ts mono/SoE 10 (2) [-] none 11 4147200 B 510.676434 510.874283 4.999 fps ts mono/SoE 11 (3) [-] none 12 4147200 B 510.886264 511.074349 4.766 fps ts mono/SoE 12 (4) [-] none 13 4147200 B 511.070577 511.274304 5.426 fps ts mono/SoE 13 (5) [-] none 14 4147200 B 511.286249 511.474301 4.637 fps ts mono/SoE 14 (6) [-] none 15 4147200 B 511.470542 511.674251 5.426 fps ts mono/SoE 15 (7) [-] none 16 4147200 B 511.672651 511.874337 4.948 fps ts mono/SoE 16 (0) [-] none 17 4147200 B 511.873988 512.074462 4.967 fps ts mono/SoE 17 (1) [-] none 18 4147200 B 512.075982 512.278296 4.951 fps ts mono/SoE 18 (2) [-] none 19 4147200 B 512.282631 512.482423 4.839 fps ts mono/SoE 19 (3) [-] none 20 4147200 B 518.986637 512.686333 0.149 fps ts mono/SoE 20 (4) [-] none 21 4147200 B 518.342709 512.886386 -1.553 fps ts mono/SoE 21 (5) [-] none 22 4147200 B 517.909812 513.090360 -2.310 fps ts mono/SoE 22 (6) [-] none 23 4147200 B 517.590775 513.294454 -3.134 fps ts mono/SoE 23 (7) [-] none 24 4147200 B 513.298465 513.494335 -0.233 fps ts mono/SoE 24 (0) [-] none 25 4147200 B 513.510273 513.698375 4.721 fps ts mono/SoE 25 (1) [-] none 26 4147200 B 513.698904 513.902327 5.301 fps ts mono/SoE 26 (2) [-] none 27 4147200 B 513.895971 514.102348 5.074 fps ts mono/SoE 27 (3) [-] none 28 4147200 B 514.099091 514.306337 4.923 fps ts mono/SoE 28 (4) [-] none 29 4147200 B 514.310348 514.510567 4.734 fps ts mono/SoE 29 (5) [-] none 30 4147200 B 514.509295 514.710367 5.026 fps ts mono/SoE 30 (6) [-] none 31 4147200 B 521.532513 514.914398 0.142 fps ts mono/SoE 31 (7) [-] none 32 4147200 B 520.885277 515.118385 -1.545 fps ts mono/SoE 32 (0) [-] none 33 4147200 B 520.411140 515.318336 -2.109 fps ts mono/SoE 33 (1) [-] none 34 4147200 B 515.325425 515.522278 -0.197 fps ts mono/SoE 34 (2) [-] none 35 4147200 B 515.538276 515.726423 4.698 fps ts mono/SoE 35 (3) [-] none 36 4147200 B 515.720767 515.930373 5.480 fps ts mono/SoE
--- drivers/media/usb/uvc/uvc_video.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/media/usb/uvc/uvc_video.c +5 -5
@@ -705,11 +705,11 @@ void uvc_video_clock_update(struct uvc_sunsigned long flags;u64 timestamp;u32 delta_stc; -u32 y1, y2; +u32 y1;u32 x1, x2;u32 mean;u32 sof; -u64 y; +u64 y, y2;if (!uvc_hw_timestamps_param)return ;
@@ -749,7 +749,7 @@ void uvc_video_clock_update(struct uvc_s sof = y; uvc_dbg(stream->dev, CLOCK, - "%s: PTS %u y %llu.%06llu SOF %u.%06llu (x1 %u x2 %u y1 %u y2 %u SOF offset %u)\n", + "%s: PTS %u y %llu.%06llu SOF %u.%06llu (x1 %u x2 %u y1 %u y2 %llu SOF offset %u)\n", stream->dev->name, buf->pts, y >> 16, div_u64((y & 0xffff) * 1000000, 65536), sof >> 16, div_u64(((u64)sof & 0xffff) * 1000000LLU, 65536),
@@ -764,7 +764,7 @@ void uvc_video_clock_update(struct uvc_s goto done; y1 =NSEC_PER_SEC ; - y2 = (u32 )ktime_to_ns (ktime_sub (last->host_time, first->host_time)) + y1; + y2 =ktime_to_ns (ktime_sub (last->host_time, first->host_time)) + y1;/* * Interpolated and host SOF timestamps can wrap around at slightly
@@ -785,7 +785,7 @@ void uvc_video_clock_update(struct uvc_s timestamp =ktime_to_ns (first->host_time) + y - y1; uvc_dbg(stream->dev, CLOCK, - "%s: SOF %u.%06llu y %llu ts %llu buf ts %llu (x1 %u/%u/%u x2 %u/%u/%u y1 %u y2 %u)\n", + "%s: SOF %u.%06llu y %llu ts %llu buf ts %llu (x1 %u/%u/%u x2 %u/%u/%u y1 %u y2 %llu)\n", stream->dev->name, sof >> 16, div_u64(((u64)sof & 0xffff) * 1000000LLU, 65536), y, timestamp, vbuf->vb2_buf.timestamp,
Greg Kroah-Hartman
maintainerPATCH 314/440 KVM: VMX: Split out the non-virtualization part of vmx_interrupt_blocked()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 322a569c4b4188a0da2812f9e952780ce09b74ba upstream.
Move the non-VMX chunk of the "interrupt blocked" checks to a separate helper so that KVM can reuse the code to detect if interrupts are blocked for L2, e.g. to determine if a virtual interrupt _for L2_ is a valid wake event. If L1 disables HLT-exiting for L2, nested APICv is enabled, and L2 HLTs, then L2 virtual interrupts are valid wake events, but if and only if interrupts are unblocked for L2.
--- arch/x86/kvm/vmx/vmx.c | 11 ++++++++--- arch/x86/kvm/vmx/vmx.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-)
arch/x86/kvm/vmx/vmx.c +8 -3
@@ -4980,14 +4980,19 @@ static int vmx_nmi_allowed(struct kvm_vcreturn !vmx_nmi_blocked (vcpu); } +bool __vmx_interrupt_blocked (struct kvm_vcpu *vcpu) +{ +return !(vmx_get_rflags (vcpu) &X86_EFLAGS_IF ) || + (vmcs_read32 (GUEST_INTERRUPTIBILITY_INFO ) & + (GUEST_INTR_STATE_STI |GUEST_INTR_STATE_MOV_SS )); +} +bool vmx_interrupt_blocked (struct kvm_vcpu *vcpu) {if (is_guest_mode (vcpu) &&nested_exit_on_intr (vcpu))return false; -return !(vmx_get_rflags (vcpu) &X86_EFLAGS_IF ) || - (vmcs_read32 (GUEST_INTERRUPTIBILITY_INFO ) & - (GUEST_INTR_STATE_STI |GUEST_INTR_STATE_MOV_SS )); +return __vmx_interrupt_blocked (vcpu); }static int vmx_interrupt_allowed (struct kvm_vcpu *vcpu,bool for_injection)
arch/x86/kvm/vmx/vmx.h +1 -0
@@ -413,6 +413,7 @@ u64 construct_eptp(struct kvm_vcpu *vcpubool vmx_guest_inject_ac (struct kvm_vcpu *vcpu);void vmx_update_exception_bitmap (struct kvm_vcpu *vcpu);bool vmx_nmi_blocked (struct kvm_vcpu *vcpu); +bool __vmx_interrupt_blocked (struct kvm_vcpu *vcpu);bool vmx_interrupt_blocked (struct kvm_vcpu *vcpu);bool vmx_get_nmi_mask (struct kvm_vcpu *vcpu);void vmx_set_nmi_mask (struct kvm_vcpu *vcpu,bool masked);
Greg Kroah-Hartman
maintainerPATCH 315/440 KVM: nVMX: Request immediate exit iff pending nested event needs injection
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
commit 32f55e475ce2c4b8b124d335fcfaf1152ba977a1 upstream.
When requesting an immediate exit from L2 in order to inject a pending event, do so only if the pending event actually requires manual injection, i.e. if and only if KVM actually needs to regain control in order to deliver the event.
Avoiding the "immediate exit" isn't simply an optimization, it's necessary to make forward progress, as the "already expired" VMX preemption timer trick that KVM uses to force a VM-Exit has higher priority than events that aren't directly injected.
At present time, this is a glorified nop as all events processed by vmx_has_nested_events() require injection, but that will not hold true in the future, e.g. if there's a pending virtual interrupt in vmcs02.RVI. I.e. if KVM is trying to deliver a virtual interrupt to L2, the expired VMX preemption timer will trigger VM-Exit before the virtual interrupt is delivered, and KVM will effectively hang the vCPU in an endless loop of forced immediate VM-Exits (because the pending virtual interrupt never goes away).
--- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/vmx/nested.c | 2 +- arch/x86/kvm/x86.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
arch/x86/include/asm/kvm_host.h +1 -1
@@ -1651,7 +1651,7 @@ struct kvm_x86_nested_ops {bool (*is_exception_vmexit)(struct kvm_vcpu *vcpu,u8 vector,u32 error_code);int (*check_events)(struct kvm_vcpu *vcpu); -bool (*has_events)(struct kvm_vcpu *vcpu); +bool (*has_events)(struct kvm_vcpu *vcpu,bool for_injection);void (*triple_fault)(struct kvm_vcpu *vcpu); int (*get_state)(struct kvm_vcpu *vcpu, struct kvm_nested_state __user *user_kvm_nested_state,
arch/x86/kvm/vmx/nested.c +1 -1
@@ -3934,7 +3934,7 @@ static bool nested_vmx_preemption_timer_to_vmx (vcpu)->nested.preemption_timer_expired; } -static bool vmx_has_nested_events (struct kvm_vcpu *vcpu) +static bool vmx_has_nested_events (struct kvm_vcpu *vcpu,bool for_injection) {return nested_vmx_preemption_timer_pending (vcpu) ||to_vmx (vcpu)->nested.mtf_pending;
arch/x86/kvm/x86.c +2 -2
@@ -10131,7 +10131,7 @@ static int kvm_check_and_inject_events(sif (is_guest_mode (vcpu) && kvm_x86_ops.nested_ops->has_events && - kvm_x86_ops.nested_ops->has_events (vcpu)) + kvm_x86_ops.nested_ops->has_events (vcpu, true)) *req_immediate_exit = true;/*
@@ -13013,7 +13013,7 @@ static inline bool kvm_vcpu_has_events(sif (is_guest_mode (vcpu) && kvm_x86_ops.nested_ops->has_events && - kvm_x86_ops.nested_ops->has_events (vcpu)) + kvm_x86_ops.nested_ops->has_events (vcpu, false))return true;if (kvm_xen_has_pending_events (vcpu))
Greg Kroah-Hartman
maintainerPATCH 316/440 ALSA: usb-audio: Fix microphone sound on HD webcam.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: wangdicheng <[email protected]>
commit 74dba240881820b46b9b1c62ef4de3bfff47fbd4 upstream.
I own an external usb Webcam, HD webcam, which had low mic volume and inconsistent sound quality. Video works as expected.
(snip)
[ 95.473820][ 1] [ T73] usb 5-2.2: new high-speed USB device number 7 using xhci_hcd [ 95.773974][ 1] [ T73] usb 5-2.2: New USB device found, idVendor=1bcf, idProduct=2281, bcdDevice= 0.05 [ 95.783445][ 1] [ T73] usb 5-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 95.791872][ 1] [ T73] usb 5-2.2: Product: HD webcam [ 95.797001][ 1] [ T73] usb 5-2.2: Manufacturer: Sunplus IT Co [ 95.802996][ 1] [ T73] usb 5-2.2: SerialNumber: 20200513 [ 96.092610][ 2] [ T3680] usb 5-2.2: Warning! Unlikely big volume range (=4096), cval->res is probably wrong. [ 96.102436][ 2] [ T3680] usb 5-2.2: [5] FU [Mic Capture Volume] ch = 1, val = 0/4096/1
Set up quirk cval->res to 16 for 256 levels,
Set GET_SAMPLE_RATE quirk flag to stop trying to get the sample rate. Confirmed that happened anyway later due to the backoff mechanism, After 3 failures.
All audio stream on device interfaces share the same values, apart from wMaxPacketSize and tSamFreq :
bLength 9
bDescriptorType 4
bInterfaceNumber 3
bAlternateSetting 4
bNumEndpoints 1
bInterfaceClass 1 AudioInterface Descriptor:
bLength 9 bDescriptorType 4 bInterfaceNumber 3 bAlternateSetting 4 bNumEndpoints 1 bInterfaceClass 1 Audio bInterfaceSubClass 2 Streaming bInterfaceProtocol 0 iInterface 0
AudioStreaming Interface Descriptor:
bLength 7
bDescriptorType 36
bDescriptorSubtype 1 (AS_GENERAL)
bTerminalLink 3
bDelay 1 frames
wFormatTag 0x0001 PCM
AudioStreaming Interface Descriptor:
bLength 11
bDescriptorType 36
bDescriptorSubtype 2 (FORMAT_TYPE)
bFormatType 1 (FORMAT_TYPE_I)
bNrChannels 1
bSubframeSize 2
bBitResolution 16
bSamFreqType 1 Discrete
tSamFreq[ 0] 48000
Endpoint Descriptor:
bLength 9
bDescriptorType 5
bEndpointAddress 0x86 EP 6 IN
bmAttributes 5
Transfer Type Isochronous
Synch Type Asynchronous
Usage Type Data
wMaxPacketSize 0x0064 1x 100 bytes
bInterval 4
bRefresh 0
bSynchAddress 0
AudioStreaming Endpoint Descriptor:
bLength 7
bDescriptorType 37
bDescriptorSubtype 1 (EP_GENERAL)
bmAttributes 0x01
Sampling Frequency
bLockDelayUnits 0 Undefined
wLockDelay 0x0000
(snip)
Testing patch provides consistent good sound recording quality and volume range.
(snip)
[ 95.473820][ 1] [ T73] usb 5-2.2: new high-speed USB device number 7 using xhci_hcd [ 95.773974][ 1] [ T73] usb 5-2.2: New USB device found, idVendor=1bcf, idProduct=2281, bcdDevice= 0.05 [ 95.783445][ 1] [ T73] usb 5-2.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 95.791872][ 1] [ T73] usb 5-2.2: Product: HD webcam [ 95.797001][ 1] [ T73] usb 5-2.2: Manufacturer: Sunplus IT Co [ 95.802996][ 1] [ T73] usb 5-2.2: SerialNumber: 20200513 [ 96.110630][ 3] [ T3680] usbcore: registered new interface driver snd-usb-audio [ 96.114329][ 7] [ T3677] usb 5-2.2: Found UVC 1.00 device HD webcam (1bcf:2281) [ 96.167555][ 7] [ T3677] usbcore: registered new interface driver uvcvideo
--- sound/usb/mixer.c | 7 +++++++ sound/usb/quirks.c | 2 ++ 2 files changed, 9 insertions(+)
sound/usb/mixer.c +7 -0
@@ -1211,6 +1211,13 @@ static void volume_control_quirks(struct cval->res =16 ; }break ; +case USB_ID (0x1bcf ,0x2281 ):/* HD Webcam */ +if (!strcmp (kctl->id.name,"Mic Capture Volume" )) { +usb_audio_info (chip, +"set resolution quirk: cval->res = 16\n" ); + cval->res =16 ; + } +break ; } }
sound/usb/quirks.c +2 -0
@@ -2183,6 +2183,8 @@ static const struct usb_audio_quirk_flag QUIRK_FLAG_ALIGN_TRANSFER),DEVICE_FLG (0x534d ,0x2109 ,/* MacroSilicon MS2109 */ QUIRK_FLAG_ALIGN_TRANSFER ), +DEVICE_FLG (0x1bcf ,0x2281 ,/* HD Webcam */ +QUIRK_FLAG_GET_SAMPLE_RATE ),/* Vendor matches */ VENDOR_FLG(0x045e, /* MS Lifecam */
Greg Kroah-Hartman
maintainerPATCH 317/440 ALSA: usb-audio: Move HD Webcam quirk to the right place
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 7010d9464f7ca3ee2d75095ea2e642a9009a41ff upstream.
The quirk_flags_table[] is sorted in the USB ID order, while the last fix was put at a wrong position. Adjust the entry at the right position.
--- sound/usb/quirks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/usb/quirks.c +2 -2
@@ -2125,6 +2125,8 @@ static const struct usb_audio_quirk_flag QUIRK_FLAG_GET_SAMPLE_RATE),DEVICE_FLG (0x19f7 ,0x0035 ,/* RODE NT-USB+ */ QUIRK_FLAG_GET_SAMPLE_RATE ), +DEVICE_FLG (0x1bcf ,0x2281 ,/* HD Webcam */ +QUIRK_FLAG_GET_SAMPLE_RATE ),DEVICE_FLG (0x1bcf ,0x2283 ,/* NexiGo N930AF FHD Webcam */ QUIRK_FLAG_GET_SAMPLE_RATE ), DEVICE_FLG(0x2040, 0x7200, /* Hauppauge HVR-950Q */
@@ -2183,8 +2185,6 @@ static const struct usb_audio_quirk_flag QUIRK_FLAG_ALIGN_TRANSFER),DEVICE_FLG (0x534d ,0x2109 ,/* MacroSilicon MS2109 */ QUIRK_FLAG_ALIGN_TRANSFER ), -DEVICE_FLG (0x1bcf ,0x2281 ,/* HD Webcam */ -QUIRK_FLAG_GET_SAMPLE_RATE ),/* Vendor matches */ VENDOR_FLG(0x045e, /* MS Lifecam */
Greg Kroah-Hartman
maintainerPATCH 318/440 ALSA: usb-audio: Add a quirk for Sonix HD USB Camera
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: wangdicheng <[email protected]>
commit 21451dfd853e7d8e6e3fbd7ef1fbdb2f2ead12f5 upstream.
Sonix HD USB Camera does not support reading the sample rate which leads to many lines of "cannot get freq at ep 0x84".
This patch adds the USB ID to quirks.c and avoids those error messages.
(snip)
[1.789698] usb 3-3: new high-speed USB device number 2 using xhci_hcd [1.984121] usb 3-3: New USB device found, idVendor=0c45, idProduct=6340, bcdDevice= 0.00 [1.984124] usb 3-3: New USB device strings: Mfr=2, Product=1, SerialNumber=0 [1.984127] usb 3-3: Product: USB 2.0 Camera [1.984128] usb 3-3: Manufacturer: Sonix Technology Co., Ltd. [5.440957] usb 3-3: 3:1: cannot get freq at ep 0x84 [12.130679] usb 3-3: 3:1: cannot get freq at ep 0x84 [12.175065] usb 3-3: 3:1: cannot get freq at ep 0x84
--- sound/usb/quirks.c | 2 ++ 1 file changed, 2 insertions(+)
sound/usb/quirks.c +2 -0
@@ -2083,6 +2083,8 @@ static const struct usb_audio_quirk_flag QUIRK_FLAG_CTL_MSG_DELAY_1M),DEVICE_FLG (0x0b0e ,0x0349 ,/* Jabra 550a */ QUIRK_FLAG_CTL_MSG_DELAY_1M ), +DEVICE_FLG (0x0c45 ,0x6340 ,/* Sonix HD USB Camera */ +QUIRK_FLAG_GET_SAMPLE_RATE ),DEVICE_FLG (0x0ecb ,0x205c ,/* JBL Quantum610 Wireless */ QUIRK_FLAG_FIXED_RATE ), DEVICE_FLG(0x0ecb, 0x2069, /* JBL Quantum810 Wireless */
Greg Kroah-Hartman
maintainerPATCH 319/440 tools/memory-model: Fix bug in lock.cat
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
commit 4c830eef806679dc243e191f962c488dd9d00708 upstream.
Andrea reported that the following innocuous litmus test:
C T
{}
P0(spinlock_t *x)
{
int r0;
spin_lock(x);
spin_unlock(x);
r0 = spin_is_locked(x);
}gives rise to a nonsensical empty result with no executions:
$ herd7 -conf linux-kernel.cfg T.litmus Test T Required States 0 Ok Witnesses Positive: 0 Negative: 0 Condition forall (true) Observation T Never 0 0 Time T 0.00 Hash=6fa204e139ddddf2cb6fa963bad117c0
The problem is caused by a bug in the lock.cat part of the LKMM. Its computation of the rf relation for RU (read-unlocked) events is faulty; it implicitly assumes that every RU event must read from either a UL (unlock) event in another thread or from the lock's initial state. Neither is true in the litmus test above, so the computation yields no possible executions.
The lock.cat code tries to make up for this deficiency by allowing RU events outside of critical sections to read from the last po-previous UL event. But it does this incorrectly, trying to keep these rfi links separate from the rfe links that might also be needed, and passing only the latter to herd7's cross() macro.
The problem is fixed by merging the two sets of possible rf links for RU events and using them all in the call to cross().
--- tools/memory-model/lock.cat | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
tools/memory-model/lock.cat +10 -10
@@ -102,19 +102,19 @@ let rf-lf = rfe-lf | rfi-lf * within one of the lock's critical sections returns False. *) -(* rfi for RU events: an RU may read from the last po-previous UL *) -let rfi-ru = ([UL] ; po-loc ; [RU]) \ ([UL] ; po-loc ; [LKW] ; po-loc) - -(* rfe for RU events: an RU may read from an external UL or the initial write *) -let all-possible-rfe-ru = - let possible-rfe-ru r = +(* + * rf for RU events: an RU may read from an external UL or the initial write, + * or from the last po-previous UL + *) +let all-possible-rf-ru = + let possible-rf-ru r = let pair-to-relation p = p ++ 0 - in map pair-to-relation (((UL | IW) * {r}) & loc & ext) - in map possible-rfe-ru RU + in map pair-to-relation ((((UL | IW) * {r}) & loc & ext) | + (((UL * {r}) & po-loc) \ ([UL] ; po-loc ; [LKW] ; po-loc))) + in map possible-rf-ru RU (* Generate all rf relations for RU events *) -with rfe-ru from cross(all-possible-rfe-ru) -let rf-ru = rfe-ru | rfi-ru +with rf-ru from cross(all-possible-rf-ru) (* Final rf relation *) let rf = rf | rf-lf | rf-ru
Greg Kroah-Hartman
maintainerPATCH 320/440 hwrng: amd - Convert PCIBIOS_* return codes to errnos
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
commit 14cba6ace79627a57fb9058582b03f0ed3832390 upstream.
amd_rng_mod_init() uses pci_read_config_dword() that returns PCIBIOS_* codes. The return code is then returned as is but amd_rng_mod_init() is a module_init() function that should return normal errnos.
Convert PCIBIOS_* returns code using pcibios_err_to_errno() into normal errno before returning it.
--- drivers/char/hw_random/amd-rng.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/char/hw_random/amd-rng.c +3 -1
@@ -142,8 +142,10 @@ static int __init amd_rng_mod_init(void) found: err =pci_read_config_dword (pdev,0x58 , &pmbase); -if (err) +if (err) { + err =pcibios_err_to_errno (err); goto put_dev; + } pmbase &=0x0000FF00 ;if (pmbase ==0 ) {
Greg Kroah-Hartman
maintainerPATCH 321/440 parisc: Fix warning at drivers/pci/msi/msi.h:121
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: John David Anglin <[email protected]>
commit 4c29ab84cfec17081aae7a7a28f8d2c93c42dcae upstream.
Fix warning at drivers/pci/msi/msi.h:121.
Recently, I added a PCI to PCIe bridge adaptor and a PCIe NVME card to my rp3440. Then, I noticed this warning at boot:
WARNING: CPU: 0 PID: 10 at drivers/pci/msi/msi.h:121 pci_msi_setup_msi_irqs+0x68/0x90 CPU: 0 PID: 10 Comm: kworker/u32:0 Not tainted 6.9.7-parisc64 #1 Debian 6.9.7-1 Hardware name: 9000/800/rp3440 Workqueue: async async_run_entry_fn
We need to select PCI_MSI_ARCH_FALLBACKS when PCI_MSI is selected.
--- arch/parisc/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/parisc/Kconfig +1 -0
@@ -75,6 +75,7 @@ config PARISC select HAVE_SOFTIRQ_ON_OWN_STACK if IRQSTACKS select TRACE_IRQFLAGS_SUPPORT select HAVE_FUNCTION_DESCRIPTORS if 64BIT + select PCI_MSI_ARCH_FALLBACKS if PCI_MSI help The PA-RISC microprocessor is designed by Hewlett-Packard and used
Greg Kroah-Hartman
maintainerPATCH 322/440 PCI: hv: Return zero, not garbage, when reading PCI_INTERRUPT_PIN
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Liu <[email protected]>
commit fea93a3e5d5e6a09eb153866d2ce60ea3287a70d upstream.
The intent of the code snippet is to always return 0 for both PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN.
The check misses PCI_INTERRUPT_PIN. This patch fixes that.
This is discovered by this call in VFIO:
pci_read_config_byte(vdev->pdev, PCI_INTERRUPT_PIN, &pin);
The old code does not set *val to 0 because it misses the check for PCI_INTERRUPT_PIN. Garbage is returned in that case.
--- drivers/pci/controller/pci-hyperv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/pci-hyperv.c +2 -2
@@ -1092,8 +1092,8 @@ static void _hv_pcifront_read_config(str PCI_CAPABILITY_LIST) {/* ROM BARs are unimplemented */ *val =0 ; - } else if (where >= PCI_INTERRUPT_LINE && where + size <= - PCI_INTERRUPT_PIN) { + } else if ((where >= PCI_INTERRUPT_LINE && where + size <= PCI_INTERRUPT_PIN) || + (where >= PCI_INTERRUPT_PIN && where + size <= PCI_MIN_GNT)) {/* * Interrupt Line and Interrupt PIN are hard-wired to zero * because this front-end only supports message-signaled
Greg Kroah-Hartman
maintainerPATCH 323/440 PCI: dw-rockchip: Fix initial PERST# GPIO value
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
commit 28b8d7793b8573563b3d45321376f36168d77b1e upstream.
PERST# is active low according to the PCIe specification.
However, the existing pcie-dw-rockchip.c driver does:
gpiod_set_value(..., 0); msleep(100); gpiod_set_value(..., 1);
when asserting + deasserting PERST#.
This is of course wrong, but because all the device trees for this compatible string have also incorrectly marked this GPIO as ACTIVE_HIGH:
$ git grep -B 10 reset-gpios arch/arm64/boot/dts/rockchip/rk3568* $ git grep -B 10 reset-gpios arch/arm64/boot/dts/rockchip/rk3588*
The actual toggling of PERST# is correct, and we cannot change it anyway, since that would break device tree compatibility.
However, this driver does request the GPIO to be initialized as GPIOD_OUT_HIGH, which does cause a silly sequence where PERST# gets toggled back and forth for no good reason.
Fix this by requesting the GPIO to be initialized as GPIOD_OUT_LOW (which for this driver means PERST# asserted).
This will avoid an unnecessary signal change where PERST# gets deasserted (by devm_gpiod_get_optional()) and then gets asserted (by rockchip_pcie_start_link()) just a few instructions later.
Before patch, debug prints on EP side, when booting RC:
[ 845.606810] pci: PERST# asserted by host! [ 852.483985] pci: PERST# de-asserted by host! [ 852.503041] pci: PERST# asserted by host! [ 852.610318] pci: PERST# de-asserted by host!
After patch, debug prints on EP side, when booting RC:
[ 125.107921] pci: PERST# asserted by host! [ 132.111429] pci: PERST# de-asserted by host!
This extra, very short, PERST# assertion + deassertion has been reported to cause issues with certain WLAN controllers, e.g. RTL8822CE.
--- drivers/pci/controller/dwc/pcie-dw-rockchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-dw-rockchip.c +1 -1
@@ -240,7 +240,7 @@ static int rockchip_pcie_resource_get(streturn PTR_ERR (rockchip->apb_base); rockchip->rst_gpio =devm_gpiod_get_optional (&pdev->dev,"reset" , -GPIOD_OUT_HIGH ); +GPIOD_OUT_LOW );if (IS_ERR (rockchip->rst_gpio))return PTR_ERR (rockchip->rst_gpio);
Greg Kroah-Hartman
maintainerPATCH 324/440 PCI: rockchip: Use GPIOD_OUT_LOW flag while requesting ep_gpio
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
commit 840b7a5edf88fe678c60dee88a135647c0ea4375 upstream.
Rockchip platforms use 'GPIO_ACTIVE_HIGH' flag in the devicetree definition for ep_gpio. This means, whatever the logical value set by the driver for the ep_gpio, physical line will output the same logic level.
For instance,
gpiod_set_value_cansleep(rockchip->ep_gpio, 0); --> Level low gpiod_set_value_cansleep(rockchip->ep_gpio, 1); --> Level high
But while requesting the ep_gpio, GPIOD_OUT_HIGH flag is currently used. Now, this also causes the physical line to output 'high' creating trouble for endpoint devices during host reboot.
When host reboot happens, the ep_gpio will initially output 'low' due to the GPIO getting reset to its POR value. Then during host controller probe, it will output 'high' due to GPIOD_OUT_HIGH flag. Then during rockchip_pcie_host_init_port(), it will first output 'low' and then 'high' indicating the completion of controller initialization.
On the endpoint side, each output 'low' of ep_gpio is accounted for PERST# assert and 'high' for PERST# deassert. With the above mentioned flow during host reboot, endpoint will witness below state changes for PERST#:
(1) PERST# assert - GPIO POR state
(2) PERST# deassert - GPIOD_OUT_HIGH while requesting GPIO
(3) PERST# assert - rockchip_pcie_host_init_port()
(4) PERST# deassert - rockchip_pcie_host_init_port()
Now the time interval between (2) and (3) is very short as both happen during the driver probe(), and this results in a race in the endpoint. Because, before completing the PERST# deassertion in (2), endpoint got another PERST# assert in (3).
A proper way to fix this issue is to change the GPIOD_OUT_HIGH flag in (2) to GPIOD_OUT_LOW. Because the usual convention is to request the GPIO with a state corresponding to its 'initial/default' value and let the driver change the state of the GPIO when required.
As per that, the ep_gpio should be requested with GPIOD_OUT_LOW as it corresponds to the POR value of '0' (PERST# assert in the endpoint). Then the driver can change the state of the ep_gpio later in rockchip_pcie_host_init_port() as per the initialization sequence.
This fixes the firmware crash issue in Qcom based modems connected to Rockpro64 based board.
--- drivers/pci/controller/pcie-rockchip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pcie-rockchip.c +1 -1
@@ -120,7 +120,7 @@ int rockchip_pcie_parse_dt(struct rockchif (rockchip->is_rc) { rockchip->ep_gpio =devm_gpiod_get_optional (dev,"ep" , -GPIOD_OUT_HIGH ); +GPIOD_OUT_LOW );if (IS_ERR (rockchip->ep_gpio))return dev_err_probe (dev,PTR_ERR (rockchip->ep_gpio),"failed to get ep GPIO\n" );
Greg Kroah-Hartman
maintainerPATCH 325/440 PCI: loongson: Enable MSI in LS7A Root Complex
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
commit a4bbcac11d3cea85822af8b40daed7e96bca5068 upstream.
The LS7A chipset can be used as part of a PCIe Root Complex with Loongson-3C6000 and similar CPUs. In this case, DEV_LS7A_PCIE_PORT5 has a PCI_CLASS_BRIDGE_HOST class code, and it is a Type 0 Function whose config space provides access to Root Complex registers.
The DEV_LS7A_PCIE_PORT5 has an MSI Capability, and its MSI Enable bit must be set before other devices below the Root Complex can use MSI. This is not the standard PCI behavior of MSI Enable, so the normal PCI MSI code does not set it.
Set the DEV_LS7A_PCIE_PORT5 MSI Enable bit via a quirk so other devices below the Root Complex can use MSI.
--- drivers/pci/controller/pci-loongson.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/pci/controller/pci-loongson.c +13 -0
@@ -163,6 +163,19 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LODECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_LOONGSON ,DEV_LS7A_HDMI , loongson_pci_pin_quirk); +static void loongson_pci_msi_quirk (struct pci_dev *dev) +{ +u16 val, class = dev->class >>8 ; + +if (class !=PCI_CLASS_BRIDGE_HOST ) +return ; + +pci_read_config_word (dev, dev->msi_cap +PCI_MSI_FLAGS , &val); + val |=PCI_MSI_FLAGS_ENABLE ; +pci_write_config_word (dev, dev->msi_cap +PCI_MSI_FLAGS , val); +} +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_LOONGSON ,DEV_LS7A_PCIE_PORT5 , loongson_pci_msi_quirk); +static struct loongson_pci *pci_bus_to_loongson_pci (struct pci_bus *bus) {struct pci_config_window *cfg;
Greg Kroah-Hartman
maintainerPATCH 326/440 binder: fix hang of unregistered readers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos Llamas <[email protected]>
commit 31643d84b8c3d9c846aa0e20bc033e46c68c7e7d upstream.
With the introduction of binder_available_for_proc_work_ilocked() in commit 1b77e9dcc3da ("ANDROID: binder: remove proc waitqueue") a binder thread can only "wait_for_proc_work" after its thread->looper has been marked as BINDER_LOOPER_STATE_{ENTERED|REGISTERED}.
This means an unregistered reader risks waiting indefinitely for work since it never gets added to the proc->waiting_threads. If there are no further references to its waitqueue either the task will hang. The same applies to readers using the (e)poll interface.
I couldn't find the rationale behind this restriction. So this patch restores the previous behavior of allowing unregistered threads to "wait_for_proc_work". Note that an error message for this scenario, which had previously become unreachable, is now re-enabled.
--- drivers/android/binder.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/android/binder.c +1 -3
@@ -569,9 +569,7 @@ static bool binder_has_work(struct bindestatic bool binder_available_for_proc_work_ilocked (struct binder_thread *thread) {return !thread->transaction_stack && -binder_worklist_empty_ilocked (&thread->todo) && - (thread->looper & (BINDER_LOOPER_STATE_ENTERED | -BINDER_LOOPER_STATE_REGISTERED )); +binder_worklist_empty_ilocked (&thread->todo); } static void binder_wakeup_poll_threads_ilocked(struct binder_proc *proc,
Greg Kroah-Hartman
maintainerPATCH 327/440 dev/parport: fix the array out-of-bounds risk
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: tuhaowen <[email protected]>
commit ab11dac93d2d568d151b1918d7b84c2d02bacbd5 upstream.
Fixed array out-of-bounds issues caused by sprintf by replacing it with snprintf for safer data copying, ensuring the destination buffer is not overflowed.
Below is the stack trace I encountered during the actual issue:
[ 66.575408s] [pid:5118,cpu4,QThread,4]Kernel panic - not syncing: stack-protector:
Kernel stack is corrupted in: do_hardware_base_addr+0xcc/0xd0 [parport] [ 66.575408s] [pid:5118,cpu4,QThread,5]CPU: 4 PID: 5118 Comm:
QThread Tainted: G S W O 5.10.97-arm64-desktop #7100.57021.2
[ 66.575439s] [pid:5118,cpu4,QThread,6]TGID: 5087 Comm: EFileApp
[ 66.575439s] [pid:5118,cpu4,QThread,7]Hardware name: HUAWEI HUAWEI QingYun PGUX-W515x-B081/SP1PANGUXM, BIOS 1.00.07 04/29/2024
[ 66.575439s] [pid:5118,cpu4,QThread,8]Call trace:
[ 66.575469s] [pid:5118,cpu4,QThread,9] dump_backtrace+0x0/0x1c0
[ 66.575469s] [pid:5118,cpu4,QThread,0] show_stack+0x14/0x20
[ 66.575469s] [pid:5118,cpu4,QThread,1] dump_stack+0xd4/0x10c
[ 66.575500s] [pid:5118,cpu4,QThread,2] panic+0x1d8/0x3bc
[ 66.575500s] [pid:5118,cpu4,QThread,3] __stack_chk_fail+0x2c/0x38
[ 66.575500s] [pid:5118,cpu4,QThread,4] do_hardware_base_addr+0xcc/0xd0 [parport]
--- drivers/parport/procfs.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/parport/procfs.c +12 -12
@@ -51,12 +51,12 @@ static int do_active_device(struct ctl_tfor (dev = port->devices; dev ; dev = dev->next) {if (dev == port->cad) { - len +=sprintf (buffer,"%s\n" , dev->name); + len +=snprintf (buffer,sizeof (buffer),"%s\n" , dev->name); } }if (!len) { - len +=sprintf (buffer,"%s\n" ,"none" ); + len +=snprintf (buffer,sizeof (buffer),"%s\n" ,"none" ); }if (len > *lenp)
@@ -87,19 +87,19 @@ static int do_autoprobe(struct ctl_table }if ((str = info->class_name) !=NULL ) - len +=sprintf (buffer + len,"CLASS:%s;\n" , str); + len +=snprintf (buffer + len,sizeof (buffer) - len,"CLASS:%s;\n" , str);if ((str = info->model) !=NULL ) - len +=sprintf (buffer + len,"MODEL:%s;\n" , str); + len +=snprintf (buffer + len,sizeof (buffer) - len,"MODEL:%s;\n" , str);if ((str = info->mfr) !=NULL ) - len +=sprintf (buffer + len,"MANUFACTURER:%s;\n" , str); + len +=snprintf (buffer + len,sizeof (buffer) - len,"MANUFACTURER:%s;\n" , str);if ((str = info->description) !=NULL ) - len +=sprintf (buffer + len,"DESCRIPTION:%s;\n" , str); + len +=snprintf (buffer + len,sizeof (buffer) - len,"DESCRIPTION:%s;\n" , str);if ((str = info->cmdset) !=NULL ) - len +=sprintf (buffer + len,"COMMAND SET:%s;\n" , str); + len +=snprintf (buffer + len,sizeof (buffer) - len,"COMMAND SET:%s;\n" , str);if (len > *lenp) len = *lenp;
@@ -117,7 +117,7 @@ static int do_hardware_base_addr(struct void *result, size_t *lenp, loff_t *ppos) { struct parport *port = (struct parport *)table->extra1; -char buffer[20 ]; +char buffer[64 ];int len =0 ;if (*ppos) {
@@ -128,7 +128,7 @@ static int do_hardware_base_addr(structif (write)/* permissions prevent this anyway */ return -EACCES ; - len +=sprintf (buffer,"%lu\t%lu\n" , port->base, port->base_hi); + len +=snprintf (buffer,sizeof (buffer),"%lu\t%lu\n" , port->base, port->base_hi);if (len > *lenp) len = *lenp;
@@ -155,7 +155,7 @@ static int do_hardware_irq(struct ctl_taif (write)/* permissions prevent this anyway */ return -EACCES ; - len +=sprintf (buffer,"%d\n" , port->irq); + len +=snprintf (buffer,sizeof (buffer),"%d\n" , port->irq);if (len > *lenp) len = *lenp;
@@ -182,7 +182,7 @@ static int do_hardware_dma(struct ctl_taif (write)/* permissions prevent this anyway */ return -EACCES ; - len +=sprintf (buffer,"%d\n" , port->dma); + len +=snprintf (buffer,sizeof (buffer),"%d\n" , port->dma);if (len > *lenp) len = *lenp;
@@ -213,7 +213,7 @@ static int do_hardware_modes(struct ctl_#define printmode (x) \ do { \ if (port->modes & PARPORT_MODE_##x) \ - len += sprintf(buffer + len, "%s%s", f++ ? "," : "", #x); \ + len += snprintf(buffer + len, sizeof(buffer) - len, "%s%s", f++ ? "," : "", #x); \ } while (0)int f =0 ;printmode (PCSPP );
Greg Kroah-Hartman
maintainerPATCH 328/440 fs/ntfs3: Update log->page_{mask,bits} if log->page_size changed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huacai Chen <[email protected]>
commit 2fef55d8f78383c8e6d6d4c014b9597375132696 upstream.
If an NTFS file system is mounted to another system with different PAGE_SIZE from the original system, log->page_size will change in log_replay(), but log->page_{mask,bits} don't change correspondingly. This will cause a panic because "u32 bytes = log->page_size - page_off" will get a negative value in the later read_log_page().
--- fs/ntfs3/fslog.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs3/fslog.c +3 -0
@@ -3937,6 +3937,9 @@ init_log_instance: goto out; } + log->page_mask = log->page_size -1 ; + log->page_bits =blksize_bits (log->page_size); +/* If the file size has shrunk then we won't mount it. */ if (l_size <le64_to_cpu (ra2->l_size)) { err = -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 329/440 scsi: qla2xxx: Return ENOBUFS if sg_cnt is more than one for ELS cmds
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Saurav Kashyap <[email protected]>
commit ce2065c4cc4f05635413f63f6dc038d7d4842e31 upstream.
Firmware only supports single DSDs in ELS Pass-through IOCB (0x53h), sg cnt is decided by the SCSI ML. User is not aware of the cause of an acutal error.
Return the appropriate return code that will be decoded by API and application and proper error message will be displayed to user.
--- drivers/scsi/qla2xxx/qla_bsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_bsg.c +1 -1
@@ -324,7 +324,7 @@ qla2x00_process_els(struct bsg_job *bsg_"request_sg_cnt=%x reply_sg_cnt=%x.\n" , bsg_job->request_payload.sg_cnt, bsg_job->reply_payload.sg_cnt); - rval = -EPERM ; + rval = -ENOBUFS ; goto done; }
Greg Kroah-Hartman
maintainerPATCH 330/440 f2fs: fix to force buffered IO on inline_data inode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
commit 5c8764f8679e659c5cb295af7d32279002d13735 upstream.
It will return all zero data when DIO reading from inline_data inode, it is because f2fs_iomap_begin() assign iomap->type w/ IOMAP_HOLE incorrectly for this case.
We can let iomap framework handle inline data via assigning iomap->type and iomap->inline_data correctly, however, it will be a little bit complicated when handling race case in between direct IO and buffered IO.
So, let's force to use buffered IO to fix this issue.
--- fs/f2fs/file.c | 2 ++ 1 file changed, 2 insertions(+)
fs/f2fs/file.c +2 -0
@@ -812,6 +812,8 @@ static bool f2fs_force_buffered_io(strucreturn true;if (f2fs_compressed_file (inode))return true; +if (f2fs_has_inline_data (inode)) +return true;/* disallow direct IO if any of devices has unaligned blksize */ if (f2fs_is_multi_device (sbi) && !sbi->aligned_blksize)
Greg Kroah-Hartman
maintainerPATCH 331/440 f2fs: fix to dont dirty inode for readonly filesystem
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
commit 192b8fb8d1c8ca3c87366ebbef599fa80bb626b8 upstream.
syzbot reports f2fs bug as below:
kernel BUG at fs/f2fs/inode.c:933!
RIP: 0010:f2fs_evict_inode+0x1576/0x1590 fs/f2fs/inode.c:933 Call Trace: evict+0x2a4/0x620 fs/inode.c:664 dispose_list fs/inode.c:697 [inline] evict_inodes+0x5f8/0x690 fs/inode.c:747 generic_shutdown_super+0x9d/0x2c0 fs/super.c:675 kill_block_super+0x44/0x90 fs/super.c:1667 kill_f2fs_super+0x303/0x3b0 fs/f2fs/super.c:4894 deactivate_locked_super+0xc1/0x130 fs/super.c:484 cleanup_mnt+0x426/0x4c0 fs/namespace.c:1256 task_work_run+0x24a/0x300 kernel/task_work.c:180 ptrace_notify+0x2cd/0x380 kernel/signal.c:2399 ptrace_report_syscall include/linux/ptrace.h:411 [inline] ptrace_report_syscall_exit include/linux/ptrace.h:473 [inline] syscall_exit_work kernel/entry/common.c:251 [inline] syscall_exit_to_user_mode_prepare kernel/entry/common.c:278 [inline] __syscall_exit_to_user_mode_work kernel/entry/common.c:283 [inline] syscall_exit_to_user_mode+0x15c/0x280 kernel/entry/common.c:296 do_syscall_64+0x50/0x110 arch/x86/entry/common.c:88 entry_SYSCALL_64_after_hwframe+0x63/0x6b
The root cause is:
- do_sys_open
- f2fs_lookup
- __f2fs_find_entry
- f2fs_i_depth_write
- f2fs_mark_inode_dirty_sync
- f2fs_dirty_inode
- set_inode_flag(inode, FI_DIRTY_INODE)
- umount
- kill_f2fs_super
- kill_block_super
- generic_shutdown_super
- sync_filesystem
: sb is readonly, skip sync_filesystem()
- evict_inodes
- iput
- f2fs_evict_inode
- f2fs_bug_on(sbi, is_inode_flag_set(inode, FI_DIRTY_INODE)) : trigger kernel panic
When we try to repair i_current_depth in readonly filesystem, let's skip dirty inode to avoid panic in later f2fs_evict_inode().
--- fs/f2fs/inode.c | 3 +++ 1 file changed, 3 insertions(+)
fs/f2fs/inode.c +3 -0
@@ -27,6 +27,9 @@ void f2fs_mark_inode_dirty_sync(struct iif (is_inode_flag_set (inode,FI_NEW_INODE ))return ; +if (f2fs_readonly (F2FS_I_SB (inode)->sb)) +return ; +if (f2fs_inode_dirtied (inode, sync))return ;
Greg Kroah-Hartman
maintainerPATCH 332/440 f2fs: fix return value of f2fs_convert_inline_inode()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
commit a8eb3de28e7a365690c61161e7a07a4fc7c60bbf upstream.
If device is readonly, make f2fs_convert_inline_inode() return EROFS instead of zero, otherwise it may trigger panic during writeback of inline inode's dirty page as below:
f2fs_write_single_data_page+0xbb6/0x1e90 fs/f2fs/data.c:2888 f2fs_write_cache_pages fs/f2fs/data.c:3187 [inline] __f2fs_write_data_pages fs/f2fs/data.c:3342 [inline] f2fs_write_data_pages+0x1efe/0x3a90 fs/f2fs/data.c:3369 do_writepages+0x359/0x870 mm/page-writeback.c:2634 filemap_fdatawrite_wbc+0x125/0x180 mm/filemap.c:397 __filemap_fdatawrite_range mm/filemap.c:430 [inline] file_write_and_wait_range+0x1aa/0x290 mm/filemap.c:788 f2fs_do_sync_file+0x68a/0x1ae0 fs/f2fs/file.c:276 generic_write_sync include/linux/fs.h:2806 [inline] f2fs_file_write_iter+0x7bd/0x24e0 fs/f2fs/file.c:4977 call_write_iter include/linux/fs.h:2114 [inline] new_sync_write fs/read_write.c:497 [inline] vfs_write+0xa72/0xc90 fs/read_write.c:590 ksys_write+0x1a0/0x2c0 fs/read_write.c:643 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f
--- fs/f2fs/inline.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/f2fs/inline.c +4 -2
@@ -204,8 +204,10 @@ int f2fs_convert_inline_inode(struct inostruct page *ipage, *page;int err =0 ; -if (!f2fs_has_inline_data (inode) || -f2fs_hw_is_readonly (sbi) ||f2fs_readonly (sbi->sb)) +if (f2fs_hw_is_readonly (sbi) ||f2fs_readonly (sbi->sb)) +return -EROFS ; + +if (!f2fs_has_inline_data (inode))return 0 ; err =f2fs_dquot_initialize (inode);
Greg Kroah-Hartman
maintainerPATCH 333/440 clk: davinci: da8xx-cfgchip: Initialize clk_init_data before use
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bastien Curutchet <[email protected]>
commit a83b22754e351f13fb46596c85f667dc33da71ec upstream.
The flag attribute of the struct clk_init_data isn't initialized before the devm_clk_hw_register() call. This can lead to unexpected behavior during registration.
Initialize the entire clk_init_data to zero at declaration.
--- drivers/clk/davinci/da8xx-cfgchip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/davinci/da8xx-cfgchip.c +2 -2
@@ -505,7 +505,7 @@ da8xx_cfgchip_register_usb0_clk48(structconst char *const parent_names[] = {"usb_refclkin" ,"pll0_auxclk" };struct clk *fck_clk;struct da8xx_usb0_clk48 *usb0; -struct clk_init_data init; +struct clk_init_data init = {};int ret; fck_clk =devm_clk_get (dev,"fck" );
@@ -579,7 +579,7 @@ da8xx_cfgchip_register_usb1_clk48(struct {const char *const parent_names[] = {"usb0_clk48" ,"usb_refclkin" };struct da8xx_usb1_clk48 *usb1; -struct clk_init_data init; +struct clk_init_data init = {};int ret; usb1 =devm_kzalloc (dev,sizeof (*usb1),GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 334/440 ubi: eba: properly rollback inside self_check_eba
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
commit 745d9f4a31defec731119ee8aad8ba9f2536dd9a upstream.
In case of a memory allocation failure in the volumes loop we can only process the already allocated scan_eba and fm_eba array elements on the error path - others are still uninitialized.
Found by Linux Verification Center (linuxtesting.org).
--- drivers/mtd/ubi/eba.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/ubi/eba.c +2 -1
@@ -1560,6 +1560,7 @@ int self_check_eba(struct ubi_device *ub GFP_KERNEL);if (!fm_eba[i]) { ret = -ENOMEM ; +kfree (scan_eba[i]); goto out_free; }
@@ -1595,7 +1596,7 @@ int self_check_eba(struct ubi_device *ub } out_free: -for (i =0 ; i < num_volumes; i++) { +while (--i >=0 ) {if (!ubi->volumes[i])continue ;
Greg Kroah-Hartman
maintainerPATCH 335/440 decompress_bunzip2: fix rare decompression failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ross Lagerwall <[email protected]>
commit bf6acd5d16057d7accbbb1bf7dc6d8c56eeb4ecc upstream.
The decompression code parses a huffman tree and counts the number of symbols for a given bit length. In rare cases, there may be >= 256 symbols with a given bit length, causing the unsigned char to overflow. This causes a decompression failure later when the code tries and fails to find the bit length for a given symbol.
Since the maximum number of symbols is 258, use unsigned short instead.
--- lib/decompress_bunzip2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lib/decompress_bunzip2.c +2 -1
@@ -232,7 +232,8 @@ static int INIT get_next_block(struct buRUNB) */ symCount = symTotal+2 ;for (j =0 ; j < groupCount; j++) { -unsigned char length[MAX_SYMBOLS ], temp[MAX_HUFCODE_BITS +1 ]; +unsigned char length[MAX_SYMBOLS ]; +unsigned short temp[MAX_HUFCODE_BITS +1 ];int minLen, maxLen, pp;/* Read Huffman code lengths for each symbol. They're stored in a way similar to mtf; record a starting
Greg Kroah-Hartman
maintainerPATCH 336/440 kbuild: Fix -S -c in x86 stack protector scripts
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 3415b10a03945b0da4a635e146750dfe5ce0f448 upstream.
After a recent change in clang to stop consuming all instances of '-S' and '-c' [1], the stack protector scripts break due to the kernel's use of -Werror=unused-command-line-argument to catch cases where flags are not being properly consumed by the compiler driver:
$ echo | clang -o - -x c - -S -c -Werror=unused-command-line-argument clang: error: argument unused during compilation: '-c' [-Werror,-Wunused-command-line-argument]
This results in CONFIG_STACKPROTECTOR getting disabled because CONFIG_CC_HAS_SANE_STACKPROTECTOR is no longer set.
'-c' and '-S' both instruct the compiler to stop at different stages of the pipeline ('-S' after compiling, '-c' after assembling), so having them present together in the same command makes little sense. In this case, the test wants to stop before assembling because it is looking at the textual assembly output of the compiler for either '%fs' or '%gs', so remove '-c' from the list of arguments to resolve the error.
All versions of GCC continue to work after this change, along with versions of clang that do or do not contain the change mentioned above.
--- scripts/gcc-x86_32-has-stack-protector.sh | 2 +- scripts/gcc-x86_64-has-stack-protector.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
scripts/gcc-x86_32-has-stack-protector.sh +1 -1
@@ -5,4 +5,4 @@ # -mstack-protector-guard-reg, added by # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81708 -echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -m32 -O0 -fstack-protector -mstack-protector-guard-reg=fs -mstack-protector-guard-symbol=__stack_chk_guard - -o - 2> /dev/null | grep -q "%fs" +echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -m32 -O0 -fstack-protector -mstack-protector-guard-reg=fs -mstack-protector-guard-symbol=__stack_chk_guard - -o - 2> /dev/null | grep -q "%fs"
scripts/gcc-x86_64-has-stack-protector.sh +1 -1
@@ -1,4 +1,4 @@ #!/bin/sh # SPDX-License-Identifier: GPL-2.0 -echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -m64 -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs" +echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -m64 -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
Greg Kroah-Hartman
maintainerPATCH 337/440 ASoC: amd: yc: Support mic on Lenovo Thinkpad E16 Gen 2
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 1d9ce4440414c92acb17eece3218fe5c92b141e3 upstream.
Lenovo Thinkpad E16 Gen 2 AMD model (model 21M5) needs a corresponding quirk entry for making the internal mic working.
--- sound/soc/amd/yc/acp6x-mach.c | 7 +++++++ 1 file changed, 7 insertions(+)
sound/soc/amd/yc/acp6x-mach.c +7 -0
@@ -224,6 +224,13 @@ static const struct dmi_system_id yc_acp .driver_data = &acp6x_card, .matches = {DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), + DMI_MATCH(DMI_PRODUCT_NAME, "21M5"), + } + }, + { + .driver_data = &acp6x_card, + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"LENOVO" ), DMI_MATCH(DMI_PRODUCT_NAME, "82TL"), } },
Greg Kroah-Hartman
maintainerPATCH 338/440 kobject_uevent: Fix OOB access within zap_modalias_env()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
commit dd6e9894b451e7c85cceb8e9dc5432679a70e7dc upstream.
zap_modalias_env() wrongly calculates size of memory block to move, so will cause OOB memory access issue if variable MODALIAS is not the last one within its @env parameter, fixed by correcting size to memmove.
--- lib/kobject_uevent.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
lib/kobject_uevent.c +16 -1
@@ -432,8 +432,23 @@ static void zap_modalias_env(struct kobj len =strlen (env->envp[i]) +1 ;if (i != env->envp_idx -1 ) { +/* @env->envp[] contains pointers to @env->buf[] +* with @env->buflen chars, and we are removing +* variable MODALIAS here pointed by @env->envp[i] +* with length @len as shown below: +* +* 0 @env->buf[] @env->buflen +* --------------------------------------------- +* ^ ^ ^ ^ +* | |-> @len <-| target block | +* @env->envp[0] @env->envp[i] @env->envp[i + 1] +* +* so the "target block" indicated above is moved +* backward by @len, and its right size is +* @env->buflen - (@env->envp[i + 1] - @env->envp[0]). +*/ memmove (env->envp[i], env->envp[i +1 ], - env->buflen - len); + env->buflen - (env->envp[i +1 ] - env->envp[0 ]));for (j = i; j < env->envp_idx -1 ; j++) env->envp[j] = env->envp[j +1 ] - len;
Greg Kroah-Hartman
maintainerPATCH 339/440 gve: Fix an edge case for TSO skb validity check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bailey Forrest <[email protected]>
commit 36e3b949e35964e22b9a57f960660fc599038dd4 upstream.
The NIC requires each TSO segment to not span more than 10 descriptors. NIC further requires each descriptor to not exceed 16KB - 1 (GVE_TX_MAX_BUF_SIZE_DQO).
The descriptors for an skb are generated by gve_tx_add_skb_no_copy_dqo() for DQO RDA queue format. gve_tx_add_skb_no_copy_dqo() loops through each skb frag and generates a descriptor for the entire frag if the frag size is not greater than GVE_TX_MAX_BUF_SIZE_DQO. If the frag size is greater than GVE_TX_MAX_BUF_SIZE_DQO, it is split into descriptor(s) of size GVE_TX_MAX_BUF_SIZE_DQO and a descriptor is generated for the remainder (frag size % GVE_TX_MAX_BUF_SIZE_DQO).
gve_can_send_tso() checks if the descriptors thus generated for an skb would meet the requirement that each TSO-segment not span more than 10 descriptors. However, the current code misses an edge case when a TSO segment spans multiple descriptors within a large frag. This change fixes the edge case.
gve_can_send_tso() relies on the assumption that max gso size (9728) is less than GVE_TX_MAX_BUF_SIZE_DQO and therefore within an skb fragment a TSO segment can never span more than 2 descriptors.
--- drivers/net/ethernet/google/gve/gve_tx_dqo.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
drivers/net/ethernet/google/gve/gve_tx_dqo.c +21 -1
@@ -596,22 +596,42 @@ static bool gve_can_send_tso(const strucconst int header_len =skb_tcp_all_headers (skb);const int gso_size = shinfo->gso_size;int cur_seg_num_bufs; +int prev_frag_size;int cur_seg_size;int i; cur_seg_size =skb_headlen (skb) - header_len; + prev_frag_size =skb_headlen (skb); cur_seg_num_bufs = cur_seg_size >0 ;for (i =0 ; i < shinfo->nr_frags; i++) {if (cur_seg_size >= gso_size) { cur_seg_size %= gso_size; cur_seg_num_bufs = cur_seg_size >0 ; + +if (prev_frag_size >GVE_TX_MAX_BUF_SIZE_DQO ) { +int prev_frag_remain = prev_frag_size % +GVE_TX_MAX_BUF_SIZE_DQO ; + +/* If the last descriptor of the previous frag +* is less than cur_seg_size, the segment will +* span two descriptors in the previous frag. +* Since max gso size (9728) is less than +* GVE_TX_MAX_BUF_SIZE_DQO, it is impossible +* for the segment to span more than two +* descriptors. +*/ +if (prev_frag_remain && + cur_seg_size > prev_frag_remain) + cur_seg_num_bufs++; + } }if (unlikely (++cur_seg_num_bufs > max_bufs_per_seg))return false; - cur_seg_size +=skb_frag_size (&shinfo->frags[i]); + prev_frag_size =skb_frag_size (&shinfo->frags[i]); + cur_seg_size += prev_frag_size; }return true;
Greg Kroah-Hartman
maintainerPATCH 340/440 ice: Add a per-VF limit on number of FDIR filters
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahmed Zaki <[email protected]>
commit 6ebbe97a488179f5dc85f2f1e0c89b486e99ee97 upstream.
While the iavf driver adds a s/w limit (128) on the number of FDIR filters that the VF can request, a malicious VF driver can request more than that and exhaust the resources for other VFs.
Add a similar limit in ice.
--- drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c | 2 +- drivers/net/ethernet/intel/ice/ice_fdir.h | 3 +++ drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c | 16 ++++++++++++++++ drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.h | 1 + 4 files changed, 21 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c +1 -1
@@ -531,7 +531,7 @@ ice_parse_rx_flow_user_data(struct ethto* * Returns the number of available flow director filters to this VSI */ -static int ice_fdir_num_avail_fltr (struct ice_hw *hw,struct ice_vsi *vsi) +int ice_fdir_num_avail_fltr (struct ice_hw *hw,struct ice_vsi *vsi) {u16 vsi_num =ice_get_hw_vsi_num (hw, vsi->idx);u16 num_guar;
drivers/net/ethernet/intel/ice/ice_fdir.h +3 -0
@@ -202,6 +202,8 @@ struct ice_fdir_base_pkt {const u8 *tun_pkt; }; +struct ice_vsi ; +int ice_alloc_fd_res_cntr (struct ice_hw *hw,u16 *cntr_id);int ice_free_fd_res_cntr (struct ice_hw *hw,u16 cntr_id);int ice_alloc_fd_guar_item (struct ice_hw *hw,u16 *cntr_id,u16 num_fltr);
@@ -213,6 +215,7 @@ int ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input, u8 *pkt, bool frag, bool tun);int ice_get_fdir_cnt_all (struct ice_hw *hw); +int ice_fdir_num_avail_fltr (struct ice_hw *hw,struct ice_vsi *vsi);bool ice_fdir_is_dup_fltr (struct ice_hw *hw,struct ice_fdir_fltr *input);bool ice_fdir_has_frag (enum ice_fltr_ptype flow); struct ice_fdir_fltr *
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +16 -0
@@ -551,6 +551,8 @@ static void ice_vc_fdir_reset_cnt_all(st fdir->fdir_fltr_cnt[flow][0 ] =0 ; fdir->fdir_fltr_cnt[flow][1 ] =0 ; } + + fdir->fdir_fltr_cnt_total =0 ; }/**
@@ -1567,6 +1569,7 @@ ice_vc_add_fdir_fltr_post(struct ice_vf resp->status = status; resp->flow_id = conf->flow_id; vf->fdir.fdir_fltr_cnt[conf->input.flow_type][is_tun]++; + vf->fdir.fdir_fltr_cnt_total++; ret =ice_vc_send_msg_to_vf (vf, ctx->v_opcode, v_ret, (u8 *)resp, len);
@@ -1631,6 +1634,7 @@ ice_vc_del_fdir_fltr_post(struct ice_vf resp->status = status;ice_vc_fdir_remove_entry (vf, conf, conf->flow_id); vf->fdir.fdir_fltr_cnt[conf->input.flow_type][is_tun]--; + vf->fdir.fdir_fltr_cnt_total--; ret =ice_vc_send_msg_to_vf (vf, ctx->v_opcode, v_ret, (u8 *)resp, len);
@@ -1797,6 +1801,7 @@ int ice_vc_add_fdir_fltr(struct ice_vf *struct virtchnl_fdir_add *stat =NULL ;struct virtchnl_fdir_fltr_conf *conf;enum virtchnl_status_code v_ret; +struct ice_vsi *vf_vsi;struct device *dev;struct ice_pf *pf;int is_tun =0 ;
@@ -1805,6 +1810,17 @@ int ice_vc_add_fdir_fltr(struct ice_vf * pf = vf->pf; dev =ice_pf_to_dev (pf); + vf_vsi =ice_get_vf_vsi (vf); + +#define ICE_VF_MAX_FDIR_FILTERS 128 +if (!ice_fdir_num_avail_fltr (&pf->hw, vf_vsi) || + vf->fdir.fdir_fltr_cnt_total >=ICE_VF_MAX_FDIR_FILTERS ) { + v_ret =VIRTCHNL_STATUS_ERR_PARAM ; +dev_err (dev,"Max number of FDIR filters for VF %d is reached\n" , + vf->vf_id); + goto err_exit; + } + ret =ice_vc_fdir_param_check (vf, fltr->vsi_id);if (ret) { v_ret =VIRTCHNL_STATUS_ERR_PARAM ;
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.h +1 -0
@@ -29,6 +29,7 @@ struct ice_vf_fdir_ctx {struct ice_vf_fdir {u16 fdir_fltr_cnt[ICE_FLTR_PTYPE_MAX ][ICE_FD_HW_SEG_MAX ];int prof_entry_cnt[ICE_FLTR_PTYPE_MAX ][ICE_FD_HW_SEG_MAX ]; +u16 fdir_fltr_cnt_total;struct ice_fd_hw_prof **fdir_prof;struct idr fdir_rule_idr;
Greg Kroah-Hartman
maintainerPATCH 341/440 devres: Fix devm_krealloc() wasting memory
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
commit c884e3249f753dcef7a2b2023541ac1dc46b318e upstream.
Driver API devm_krealloc() calls alloc_dr() with wrong argument @total_new_size, so causes more memory to be allocated than required fix this memory waste by using @new_size as the argument for alloc_dr().
--- drivers/base/devres.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/base/devres.c +4 -1
@@ -892,9 +892,12 @@ void *devm_krealloc(struct device *dev,/* * Otherwise: allocate new, larger chunk. We need to allocate before * taking the lock as most probably the caller uses GFP_KERNEL. +* alloc_dr() will call check_dr_size() to reserve extra memory +* for struct devres automatically, so size @new_size user request +* is delivered to it directly as devm_kmalloc() does. */ new_dr =alloc_dr (devm_kmalloc_release, - total_new_size, gfp,dev_to_node (dev)); + new_size, gfp,dev_to_node (dev));if (!new_dr)return NULL ;
Greg Kroah-Hartman
maintainerPATCH 342/440 devres: Fix memory leakage caused by driver API devm_free_percpu()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
commit bd50a974097bb82d52a458bd3ee39fb723129a0c upstream.
It will cause memory leakage when use driver API devm_free_percpu() to free memory allocated by devm_alloc_percpu(), fixed by using devres_release() instead of devres_destroy() within devm_free_percpu().
--- drivers/base/devres.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/base/devres.c +5 -1
@@ -1221,7 +1221,11 @@ EXPORT_SYMBOL_GPL(__devm_alloc_percpu);*/ void devm_free_percpu (struct device *dev,void __percpu *pdata) { -WARN_ON (devres_destroy (dev, devm_percpu_release, devm_percpu_match, +/* +* Use devres_release() to prevent memory leakage as +* devm_free_pages() does. +*/ +WARN_ON (devres_release (dev, devm_percpu_release, devm_percpu_match, (__force void *)pdata)); }EXPORT_SYMBOL_GPL (devm_free_percpu);
Greg Kroah-Hartman
maintainerPATCH 343/440 irqchip/imx-irqsteer: Handle runtime power management correctly
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shenwei Wang <[email protected]>
commit 33b1c47d1fc0b5f06a393bb915db85baacba18ea upstream.
The power domain is automatically activated from clk_prepare(). However, on certain platforms like i.MX8QM and i.MX8QXP, the power-on handling invokes sleeping functions, which triggers the 'scheduling while atomic' bug in the context switch path during device probing:
BUG: scheduling while atomic: kworker/u13:1/48/0x00000002 Call trace: __schedule_bug+0x54/0x6c __schedule+0x7f0/0xa94 schedule+0x5c/0xc4 schedule_preempt_disabled+0x24/0x40 __mutex_lock.constprop.0+0x2c0/0x540 __mutex_lock_slowpath+0x14/0x20 mutex_lock+0x48/0x54 clk_prepare_lock+0x44/0xa0 clk_prepare+0x20/0x44 imx_irqsteer_resume+0x28/0xe0 pm_generic_runtime_resume+0x2c/0x44 __genpd_runtime_resume+0x30/0x80 genpd_runtime_resume+0xc8/0x2c0 __rpm_callback+0x48/0x1d8 rpm_callback+0x6c/0x78 rpm_resume+0x490/0x6b4 __pm_runtime_resume+0x50/0x94 irq_chip_pm_get+0x2c/0xa0 __irq_do_set_handler+0x178/0x24c irq_set_chained_handler_and_data+0x60/0xa4 mxc_gpio_probe+0x160/0x4b0
Cure this by implementing the irq_bus_lock/sync_unlock() interrupt chip callbacks and handle power management in them as they are invoked from non-atomic context.
[ tglx: Rewrote change log, added Fixes tag ]
--- drivers/irqchip/irq-imx-irqsteer.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/irqchip/irq-imx-irqsteer.c +21 -3
@@ -35,6 +35,7 @@ struct irqsteer_data {int channel;struct irq_domain *domain;u32 *saved_reg; +struct device *dev; }; static int imx_irqsteer_get_reg_index(struct irqsteer_data *data,
@@ -71,10 +72,26 @@ static void imx_irqsteer_irq_mask(structraw_spin_unlock_irqrestore (&data->lock, flags); } +static void imx_irqsteer_irq_bus_lock (struct irq_data *d) +{ +struct irqsteer_data *data = d->chip_data; + +pm_runtime_get_sync (data->dev); +} + +static void imx_irqsteer_irq_bus_sync_unlock (struct irq_data *d) +{ +struct irqsteer_data *data = d->chip_data; + +pm_runtime_put_autosuspend (data->dev); +} +static const struct irq_chip imx_irqsteer_irq_chip = { - .name ="irqsteer" , - .irq_mask = imx_irqsteer_irq_mask, - .irq_unmask = imx_irqsteer_irq_unmask, + .name ="irqsteer" , + .irq_mask = imx_irqsteer_irq_mask, + .irq_unmask = imx_irqsteer_irq_unmask, + .irq_bus_lock = imx_irqsteer_irq_bus_lock, + .irq_bus_sync_unlock = imx_irqsteer_irq_bus_sync_unlock, }; static int imx_irqsteer_irq_map(struct irq_domain *h, unsigned int irq,
@@ -149,6 +166,7 @@ static int imx_irqsteer_probe(struct plaif (!data)return -ENOMEM ; + data->dev = &pdev->dev; data->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (data->regs)) {dev_err (&pdev->dev,"failed to initialize reg\n" );
Greg Kroah-Hartman
maintainerPATCH 344/440 mm/numa_balancing: teach mpol_to_str about the balancing mode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tvrtko Ursulin <[email protected]>
commit af649773fb25250cd22625af021fb6275c56a3ee upstream.
Since balancing mode was added in bda420b98505 ("numa balancing: migrate on fault among multiple bound nodes"), it was possible to set this mode but it wouldn't be shown in /proc/<pid>/numa_maps since there was no support for it in the mpol_to_str() helper.
Furthermore, because the balancing mode sets the MPOL_F_MORON flag, it would be displayed as 'default' due a workaround introduced a few years earlier in 8790c71a18e5 ("mm/mempolicy.c: fix mempolicy printing in numa_maps").
To tidy this up we implement two changes:
Replace the MPOL_F_MORON check by pointer comparison against the preferred_node_policy array. By doing this we generalise the current special casing and replace the incorrect 'default' with the correct 'bind' for the mode.
Secondly, we add a string representation and corresponding handling for the MPOL_F_NUMA_BALANCING flag.
With the two changes together we start showing the balancing flag when it is set and therefore complete the fix.
Representation format chosen is to separate multiple flags with vertical bars, following what existed long time ago in kernel 2.6.25. But as between then and now there wasn't a way to display multiple flags, this patch does not change the format in practice.
Some /proc/<pid>/numa_maps output examples:
555559580000 bind=balancing:0-1,3 file=...
555585800000 bind=balancing|static:0,2 file=...
555635240000 prefer=relative:0 file=
References: 8790c71a18e5 ("mm/mempolicy.c: fix mempolicy printing in numa_maps")
--- mm/mempolicy.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
mm/mempolicy.c +14 -4
@@ -3112,8 +3112,9 @@ out:* @pol: pointer to mempolicy to be formatted * * Convert @pol into a string. If @buffer is too short, truncate the string. -* Recommend a @maxlen of at least 32 for the longest mode, "interleave", the -* longest flag, "relative", and to display at least a few node ids. +* Recommend a @maxlen of at least 51 for the longest mode, "weighted +* interleave", plus the longest flag flags, "relative|balancing", and to +* display at least a few node ids. */ void mpol_to_str (char *buffer,int maxlen,struct mempolicy *pol) {
@@ -3122,7 +3123,10 @@ void mpol_to_str(char *buffer, int maxleunsigned short mode =MPOL_DEFAULT ;unsigned short flags =0 ; -if (pol && pol != &default_policy && !(pol->flags &MPOL_F_MORON )) { +if (pol && + pol != &default_policy && + !(pol >= &preferred_node_policy[0 ] && + pol <= &preferred_node_policy[ARRAY_SIZE (preferred_node_policy) -1 ])) { mode = pol->mode; flags = pol->flags; }
@@ -3149,12 +3153,18 @@ void mpol_to_str(char *buffer, int maxle p +=snprintf (p, buffer + maxlen - p,"=" );/* -* Currently, the only defined flags are mutually exclusive +* Static and relative are mutually exclusive. */ if (flags &MPOL_F_STATIC_NODES ) p +=snprintf (p, buffer + maxlen - p,"static" );else if (flags &MPOL_F_RELATIVE_NODES ) p +=snprintf (p, buffer + maxlen - p,"relative" ); + +if (flags &MPOL_F_NUMA_BALANCING ) { +if (!is_power_of_2 (flags &MPOL_MODE_FLAGS )) + p +=snprintf (p, buffer + maxlen - p,"|" ); + p +=snprintf (p, buffer + maxlen - p,"balancing" ); + } }if (!nodes_empty (nodes))
Greg Kroah-Hartman
maintainerPATCH 345/440 rtc: cmos: Fix return value of nvmem callbacks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joy Chakraborty <[email protected]>
commit 1c184baccf0d5e2ef4cc1562261d0e48508a1c2b upstream.
Read/write callbacks registered with nvmem core expect 0 to be returned on success and a negative value to be returned on failure.
cmos_nvram_read()/cmos_nvram_write() currently return the number of bytes read or written, fix to return 0 on success and -EIO incase number of bytes requested was not read or written.
--- drivers/rtc/rtc-cmos.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/rtc/rtc-cmos.c +4 -6
@@ -643,11 +643,10 @@ static int cmos_nvram_read(void *priv, u size_t count) {unsigned char *buf = val; -int retval; off +=NVRAM_OFFSET ;spin_lock_irq (&rtc_lock); -for (retval =0 ; count; count--, off++, retval++) { +for (; count; count--, off++) {if (off <128 ) *buf++ =CMOS_READ (off);else if (can_bank2)
@@ -657,7 +656,7 @@ static int cmos_nvram_read(void *priv, u }spin_unlock_irq (&rtc_lock); -return retval; +return count ? -EIO :0 ; } static int cmos_nvram_write(void *priv, unsigned int off, void *val,
@@ -665,7 +664,6 @@ static int cmos_nvram_write(void *priv, {struct cmos_rtc *cmos = priv;unsigned char *buf = val; -int retval;/* NOTE: on at least PCs and Ataris, the boot firmware uses a * checksum on part of the NVRAM data. That's currently ignored
@@ -674,7 +672,7 @@ static int cmos_nvram_write(void *priv,*/ off +=NVRAM_OFFSET ;spin_lock_irq (&rtc_lock); -for (retval =0 ; count; count--, off++, retval++) { +for (; count; count--, off++) {/* don't trash RTC registers */ if (off == cmos->day_alrm || off == cmos->mon_alrm
@@ -689,7 +687,7 @@ static int cmos_nvram_write(void *priv, }spin_unlock_irq (&rtc_lock); -return retval; +return count ? -EIO :0 ; }/*----------------------------------------------------------------*/
Greg Kroah-Hartman
maintainerPATCH 346/440 scsi: qla2xxx: During vport delete send async logout explicitly
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manish Rangankar <[email protected]>
commit 76f480d7c717368f29a3870f7d64471ce0ff8fb2 upstream.
During vport delete, it is observed that during unload we hit a crash because of stale entries in outstanding command array. For all these stale I/O entries, eh_abort was issued and aborted (fast_fail_io = 2009h) but I/Os could not complete while vport delete is in process of deleting.
BUG: kernel NULL pointer dereference, address: 000000000000001c #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP NOPTI Workqueue: qla2xxx_wq qla_do_work [qla2xxx] RIP: 0010:dma_direct_unmap_sg+0x51/0x1e0 RSP: 0018:ffffa1e1e150fc68 EFLAGS: 00010046 RAX: 0000000000000000 RBX: 0000000000000021 RCX: 0000000000000001 RDX: 0000000000000021 RSI: 0000000000000000 RDI: ffff8ce208a7a0d0 RBP: ffff8ce208a7a0d0 R08: 0000000000000000 R09: ffff8ce378aac9c8 R10: ffff8ce378aac8a0 R11: ffffa1e1e150f9d8 R12: 0000000000000000 R13: 0000000000000000 R14: ffff8ce378aac9c8 R15: 0000000000000000 FS: 0000000000000000(0000) GS:ffff8d217f000000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000000001c CR3: 0000002089acc000 CR4: 0000000000350ee0 Call Trace: <TASK> qla2xxx_qpair_sp_free_dma+0x417/0x4e0 ? qla2xxx_qpair_sp_compl+0x10d/0x1a0 ? qla2x00_status_entry+0x768/0x2830 ? newidle_balance+0x2f0/0x430 ? dequeue_entity+0x100/0x3c0 ? qla24xx_process_response_queue+0x6a1/0x19e0 ? __schedule+0x2d5/0x1140 ? qla_do_work+0x47/0x60 ? process_one_work+0x267/0x440 ? process_one_work+0x440/0x440 ? worker_thread+0x2d/0x3d0 ? process_one_work+0x440/0x440 ? kthread+0x156/0x180 ? set_kthread_struct+0x50/0x50 ? ret_from_fork+0x22/0x30 </TASK>
Send out async logout explicitly for all the ports during vport delete.
--- drivers/scsi/qla2xxx/qla_mid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_mid.c +1 -1
@@ -180,7 +180,7 @@ qla24xx_disable_vp(scsi_qla_host_t *vha)atomic_set (&vha->loop_state,LOOP_DOWN );atomic_set (&vha->loop_down_timer,LOOP_DOWN_TIME );list_for_each_entry (fcport, &vha->vp_fcports, list) - fcport->logout_on_delete =0 ; + fcport->logout_on_delete =1 ;if (!vha->hw->flags.edif_enabled)qla2x00_wait_for_sess_deletion (vha);
Greg Kroah-Hartman
maintainerPATCH 347/440 scsi: qla2xxx: Unable to act on RSCN for port online
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit c3d98b12eef8db436e32f1a8c5478be57dc15621 upstream.
The device does not come online when the target port is online. There were multiple RSCNs indicating multiple devices were affected. Driver is in the process of finishing a fabric scan. A new RSCN (device up) arrived at the tail end of the last fabric scan. Driver mistakenly thinks the new RSCN is being taken care of by the previous fabric scan, where this notification is cleared and not acted on. The laser needs to be blinked again to get the device to show up.
To prevent driver from accidentally clearing the RSCN notification, each RSCN is given a generation value. A fabric scan will scan for that generation(s). Any new RSCN arrive after the scan start will have a new generation value. This will trigger another scan to get latest data. The RSCN notification flag will be cleared when the scan is associate to that generation.
--- drivers/scsi/qla2xxx/qla_def.h | 3 +++ drivers/scsi/qla2xxx/qla_gs.c | 33 ++++++++++++++++++++++++++++++--- drivers/scsi/qla2xxx/qla_init.c | 24 +++++++++++++++++++----- drivers/scsi/qla2xxx/qla_inline.h | 8 ++++++++ 4 files changed, 60 insertions(+), 8 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +3 -0
@@ -3278,6 +3278,8 @@ struct fab_scan_rp {struct fab_scan {struct fab_scan_rp *l;u32 size; +u32 rscn_gen_start; +u32 rscn_gen_end;u16 scan_retry;#define MAX_SCAN_RETRIES 5enum scan_flags_t scan_flags;
@@ -4985,6 +4987,7 @@ typedef struct scsi_qla_host {/* Counter to detect races between ELS and RSCN events */ atomic_t generation_tick; +atomic_t rscn_gen;/* Time when global fcport update has been scheduled */ int total_fcport_update_gen;/* List of pending LOGOs, protected by tgt_mutex */
drivers/scsi/qla2xxx/qla_gs.c +30 -3
@@ -3465,6 +3465,29 @@ static int qla2x00_is_a_vp(scsi_qla_hostreturn rc; } +static bool qla_ok_to_clear_rscn (scsi_qla_host_t *vha,fc_port_t *fcport) +{ +u32 rscn_gen; + + rscn_gen =atomic_read (&vha->rscn_gen); +ql_dbg (ql_dbg_disc + ql_dbg_verbose, vha,0x2017 , +"%s %d %8phC rscn_gen %x start %x end %x current %x\n" , + __func__, __LINE__, fcport->port_name, fcport->rscn_gen, + vha->scan.rscn_gen_start, vha->scan.rscn_gen_end, rscn_gen); + +if (val_is_in_range (fcport->rscn_gen, vha->scan.rscn_gen_start, + vha->scan.rscn_gen_end)) +/* rscn came in before fabric scan */ +return true; + +if (val_is_in_range (fcport->rscn_gen, vha->scan.rscn_gen_end, rscn_gen)) +/* rscn came in after fabric scan */ +return false; + +/* rare: fcport's scan_needed + rscn_gen must be stale */ +return true; +} +void qla24xx_async_gnnft_done (scsi_qla_host_t *vha,srb_t *sp) {fc_port_t *fcport;
@@ -3578,10 +3601,10 @@ void qla24xx_async_gnnft_done(scsi_qla_h (fcport->scan_needed && fcport->port_type != FCT_INITIATOR && fcport->port_type != FCT_NVME_INITIATOR)) { + fcport->scan_needed =0 ;qlt_schedule_sess_for_deletion (fcport); } fcport->d_id.b24 = rp->id.b24; - fcport->scan_needed =0 ;break ; }
@@ -3622,7 +3645,9 @@ login_logout: do_delete = true; } - fcport->scan_needed =0 ; +if (qla_ok_to_clear_rscn (vha, fcport)) + fcport->scan_needed =0 ; + if (((qla_dual_mode_enabled(vha) || qla_ini_mode_enabled(vha)) && atomic_read(&fcport->state) == FCS_ONLINE) ||
@@ -3652,7 +3677,9 @@ login_logout: fcport->port_name, fcport->loop_id, fcport->login_retry); } - fcport->scan_needed =0 ; + +if (qla_ok_to_clear_rscn (vha, fcport)) + fcport->scan_needed =0 ;qla24xx_fcport_handle_login (vha, fcport); } }
drivers/scsi/qla2xxx/qla_init.c +19 -5
@@ -1843,10 +1843,18 @@ int qla24xx_post_newsess_work(struct scsreturn qla2x00_post_work (vha, e); } +static void qla_rscn_gen_tick (scsi_qla_host_t *vha,u32 *ret_rscn_gen) +{ + *ret_rscn_gen =atomic_inc_return (&vha->rscn_gen); +/* memory barrier */ +wmb (); +} +void qla2x00_handle_rscn (scsi_qla_host_t *vha,struct event_arg *ea) {fc_port_t *fcport;unsigned long flags; +u32 rscn_gen;switch (ea->id.b.rsvd_1) {case RSCN_PORT_ADDR :
@@ -1876,15 +1884,16 @@ void qla2x00_handle_rscn(scsi_qla_host_t* Otherwise we're already in the middle of a relogin */ fcport->scan_needed =1 ; - fcport->rscn_gen++; +qla_rscn_gen_tick (vha, &fcport->rscn_gen); } }else { fcport->scan_needed =1 ; - fcport->rscn_gen++; +qla_rscn_gen_tick (vha, &fcport->rscn_gen); } }break ;case RSCN_AREA_ADDR : +qla_rscn_gen_tick (vha, &rscn_gen);list_for_each_entry (fcport, &vha->vp_fcports, list) {if (fcport->flags &FCF_FCP2_DEVICE &&atomic_read (&fcport->state) ==FCS_ONLINE )
@@ -1892,11 +1901,12 @@ void qla2x00_handle_rscn(scsi_qla_host_tif ((ea->id.b24 &0xffff00 ) == (fcport->d_id.b24 &0xffff00 )) { fcport->scan_needed =1 ; - fcport->rscn_gen++; + fcport->rscn_gen = rscn_gen; } }break ;case RSCN_DOM_ADDR : +qla_rscn_gen_tick (vha, &rscn_gen);list_for_each_entry (fcport, &vha->vp_fcports, list) {if (fcport->flags &FCF_FCP2_DEVICE &&atomic_read (&fcport->state) ==FCS_ONLINE )
@@ -1904,19 +1914,20 @@ void qla2x00_handle_rscn(scsi_qla_host_tif ((ea->id.b24 &0xff0000 ) == (fcport->d_id.b24 &0xff0000 )) { fcport->scan_needed =1 ; - fcport->rscn_gen++; + fcport->rscn_gen = rscn_gen; } }break ;case RSCN_FAB_ADDR :default : +qla_rscn_gen_tick (vha, &rscn_gen);list_for_each_entry (fcport, &vha->vp_fcports, list) {if (fcport->flags &FCF_FCP2_DEVICE &&atomic_read (&fcport->state) ==FCS_ONLINE )continue ; fcport->scan_needed =1 ; - fcport->rscn_gen++; + fcport->rscn_gen = rscn_gen; }break ; }
@@ -1925,6 +1936,7 @@ void qla2x00_handle_rscn(scsi_qla_host_tif (vha->scan.scan_flags ==0 ) {ql_dbg (ql_dbg_disc, vha,0xffff ,"%s: schedule\n" , __func__); vha->scan.scan_flags |=SF_QUEUED ; + vha->scan.rscn_gen_start =atomic_read (&vha->rscn_gen);schedule_delayed_work (&vha->scan.scan_work,5 ); }spin_unlock_irqrestore (&vha->work_lock, flags);
@@ -6419,6 +6431,8 @@ qla2x00_configure_fabric(scsi_qla_host_tqlt_do_generation_tick (vha, &discovery_gen);if (USE_ASYNC_SCAN (ha)) { +/* start of scan begins here */ + vha->scan.rscn_gen_end =atomic_read (&vha->rscn_gen); rval =qla24xx_async_gpnft (vha,FC4_TYPE_FCP_SCSI ,NULL );if (rval)
drivers/scsi/qla2xxx/qla_inline.h +8 -0
@@ -631,3 +631,11 @@ static inline int qla_mapq_alloc_qp_cpu_ }return 0 ; } + +static inline bool val_is_in_range (u32 val,u32 start,u32 end) +{ +if (val >= start && val <= end) +return true; +else +return false; +}
Greg Kroah-Hartman
maintainerPATCH 348/440 scsi: qla2xxx: Fix for possible memory corruption
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shreyas Deodhar <[email protected]>
commit c03d740152f78e86945a75b2ad541bf972fab92a upstream.
Init Control Block is dereferenced incorrectly. Correctly dereference ICB
--- drivers/scsi/qla2xxx/qla_os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_os.c +1 -1
@@ -4667,7 +4667,7 @@ static void qla2x00_number_of_exch(scsi_qla_host_t *vha, u32 *ret_cnt, u16 max_cnt) {u32 temp; -struct init_cb_81xx *icb = (struct init_cb_81xx *)&vha->hw->init_cb; +struct init_cb_81xx *icb = (struct init_cb_81xx *)vha->hw->init_cb; *ret_cnt =FW_DEF_EXCHANGES_CNT ;if (max_cnt > vha->hw->max_exchg)
Greg Kroah-Hartman
maintainerPATCH 349/440 scsi: qla2xxx: Use QP lock to search for bsg
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit c449b4198701d828e40d60a2abd30970b74a1d75 upstream.
On bsg timeout, hardware_lock is used as part of search for the srb. Instead, qpair lock should be used to iterate through different qpair.
--- drivers/scsi/qla2xxx/qla_bsg.c | 96 ++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 39 deletions(-)
drivers/scsi/qla2xxx/qla_bsg.c +57 -39
@@ -3059,17 +3059,61 @@ skip_chip_chk:return ret; } -int -qla24xx_bsg_timeout (struct bsg_job *bsg_job) +static bool qla_bsg_found (struct qla_qpair *qpair,struct bsg_job *bsg_job) { +bool found = false;struct fc_bsg_reply *bsg_reply = bsg_job->reply;scsi_qla_host_t *vha =shost_priv (fc_bsg_to_shost (bsg_job));struct qla_hw_data *ha = vha->hw; -srb_t *sp; -int cnt, que; +srb_t *sp =NULL ; +int cnt;unsigned long flags;struct req_que *req; +spin_lock_irqsave (qpair->qp_lock_ptr, flags); + req = qpair->req; + +for (cnt =1 ; cnt < req->num_outstanding_cmds; cnt++) { + sp = req->outstanding_cmds[cnt]; +if (sp && + (sp->type ==SRB_CT_CMD || + sp->type ==SRB_ELS_CMD_HST || + sp->type ==SRB_ELS_CMD_HST_NOLOGIN ) && + sp->u.bsg_job == bsg_job) { + req->outstanding_cmds[cnt] =NULL ; +spin_unlock_irqrestore (qpair->qp_lock_ptr, flags); + +if (!ha->flags.eeh_busy && ha->isp_ops->abort_command (sp)) { +ql_log (ql_log_warn, vha,0x7089 , +"mbx abort_command failed.\n" ); + bsg_reply->result = -EIO ; + }else { +ql_dbg (ql_dbg_user, vha,0x708a , +"mbx abort_command success.\n" ); + bsg_reply->result =0 ; + } +/* ref: INIT */ +kref_put (&sp->cmd_kref, qla2x00_sp_release); + + found = true; + goto done; + } + } +spin_unlock_irqrestore (qpair->qp_lock_ptr, flags); + +done: +return found; +} + +int +qla24xx_bsg_timeout (struct bsg_job *bsg_job) +{ +struct fc_bsg_reply *bsg_reply = bsg_job->reply; +scsi_qla_host_t *vha =shost_priv (fc_bsg_to_shost (bsg_job)); +struct qla_hw_data *ha = vha->hw; +int i; +struct qla_qpair *qpair; +ql_log (ql_log_info, vha,0x708b ,"%s CMD timeout. bsg ptr %p.\n" , __func__, bsg_job);
@@ -3079,48 +3123,22 @@ qla24xx_bsg_timeout(struct bsg_job *bsg_qla_pci_set_eeh_busy (vha); } +if (qla_bsg_found (ha->base_qpair, bsg_job)) + goto done; +/* find the bsg job from the active list of commands */ -spin_lock_irqsave (&ha->hardware_lock, flags); -for (que =0 ; que < ha->max_req_queues; que++) { - req = ha->req_q_map[que]; -if (!req) +for (i =0 ; i < ha->max_qpairs; i++) { + qpair = vha->hw->queue_pair_map[i]; +if (!qpair)continue ; - -for (cnt =1 ; cnt < req->num_outstanding_cmds; cnt++) { - sp = req->outstanding_cmds[cnt]; -if (sp && - (sp->type ==SRB_CT_CMD || - sp->type ==SRB_ELS_CMD_HST || - sp->type ==SRB_ELS_CMD_HST_NOLOGIN || - sp->type ==SRB_FXIOCB_BCMD ) && - sp->u.bsg_job == bsg_job) { - req->outstanding_cmds[cnt] =NULL ; -spin_unlock_irqrestore (&ha->hardware_lock, flags); - -if (!ha->flags.eeh_busy && ha->isp_ops->abort_command (sp)) { -ql_log (ql_log_warn, vha,0x7089 , -"mbx abort_command failed.\n" ); - bsg_reply->result = -EIO ; - }else { -ql_dbg (ql_dbg_user, vha,0x708a , -"mbx abort_command success.\n" ); - bsg_reply->result =0 ; - } -spin_lock_irqsave (&ha->hardware_lock, flags); - goto done; - - } - } +if (qla_bsg_found (qpair, bsg_job)) + goto done; } -spin_unlock_irqrestore (&ha->hardware_lock, flags); +ql_log (ql_log_info, vha,0x708b ,"SRB not found to abort.\n" ); bsg_reply->result = -ENXIO ; -return 0 ; done: -spin_unlock_irqrestore (&ha->hardware_lock, flags); -/* ref: INIT */ -kref_put (&sp->cmd_kref, qla2x00_sp_release);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 350/440 scsi: qla2xxx: Fix flash read failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quinn Tran <[email protected]>
commit 29e222085d8907ccff18ecd931bdd4c6b1f11b92 upstream.
Link up failure is observed as a result of flash read failure. Current code does not check flash read return code where it relies on FW checksum to detect the problem.
Add check of flash read failure to detect the problem sooner.
--- drivers/scsi/qla2xxx/qla_init.c | 63 ++++++++++++++++++----- drivers/scsi/qla2xxx/qla_sup.c | 108 +++++++++++++++++++++++++++------------- 2 files changed, 125 insertions(+), 46 deletions(-)
drivers/scsi/qla2xxx/qla_init.c +50 -13
@@ -8274,15 +8274,21 @@ qla28xx_get_aux_images(struct qla27xx_image_status pri_aux_image_status, sec_aux_image_status;bool valid_pri_image = false, valid_sec_image = false;bool active_pri_image = false, active_sec_image = false; +int rc;if (!ha->flt_region_aux_img_status_pri) {ql_dbg (ql_dbg_init, vha,0x018a ,"Primary aux image not addressed\n" ); goto check_sec_image; } -qla24xx_read_flash_data (vha, (uint32_t *)&pri_aux_image_status, + rc =qla24xx_read_flash_data (vha, (uint32_t *)&pri_aux_image_status, ha->flt_region_aux_img_status_pri,sizeof (pri_aux_image_status) >>2 ); +if (rc) { +ql_log (ql_log_info, vha,0x01a1 , +"Unable to read Primary aux image(%x).\n" , rc); + goto check_sec_image; + }qla27xx_print_image (vha,"Primary aux image" , &pri_aux_image_status);if (qla28xx_check_aux_image_status_signature (&pri_aux_image_status)) {
@@ -8313,9 +8319,15 @@ check_sec_image: goto check_valid_image; } -qla24xx_read_flash_data (vha, (uint32_t *)&sec_aux_image_status, + rc =qla24xx_read_flash_data (vha, (uint32_t *)&sec_aux_image_status, ha->flt_region_aux_img_status_sec,sizeof (sec_aux_image_status) >>2 ); +if (rc) { +ql_log (ql_log_info, vha,0x01a2 , +"Unable to read Secondary aux image(%x).\n" , rc); + goto check_valid_image; + } +qla27xx_print_image (vha,"Secondary aux image" , &sec_aux_image_status);if (qla28xx_check_aux_image_status_signature (&sec_aux_image_status)) {
@@ -8373,6 +8385,7 @@ qla27xx_get_active_image(struct scsi_qlastruct qla27xx_image_status pri_image_status, sec_image_status;bool valid_pri_image = false, valid_sec_image = false;bool active_pri_image = false, active_sec_image = false; +int rc;if (!ha->flt_region_img_status_pri) {ql_dbg (ql_dbg_init, vha,0x018a ,"Primary image not addressed\n" );
@@ -8414,8 +8427,14 @@ check_sec_image: goto check_valid_image; } -qla24xx_read_flash_data (vha, (uint32_t *)(&sec_image_status), + rc =qla24xx_read_flash_data (vha, (uint32_t *)(&sec_image_status), ha->flt_region_img_status_sec,sizeof (sec_image_status) >>2 ); +if (rc) { +ql_log (ql_log_info, vha,0x01a3 , +"Unable to read Secondary image status(%x).\n" , rc); + goto check_valid_image; + } +qla27xx_print_image (vha,"Secondary image" , &sec_image_status);if (qla27xx_check_image_status_signature (&sec_image_status)) {
@@ -8487,11 +8506,10 @@ qla24xx_load_risc_flash(scsi_qla_host_t "FW: Loading firmware from flash (%x).\n", faddr); dcode = (uint32_t *)req->ring; -qla24xx_read_flash_data (vha, dcode, faddr,8 ); -if (qla24xx_risc_firmware_invalid (dcode)) { + rval =qla24xx_read_flash_data (vha, dcode, faddr,8 ); +if (rval ||qla24xx_risc_firmware_invalid (dcode)) {ql_log (ql_log_fatal, vha,0x008c , -"Unable to verify the integrity of flash firmware " -"image.\n" ); +"Unable to verify the integrity of flash firmware image (rval %x).\n" , rval);ql_log (ql_log_fatal, vha,0x008d ,"Firmware data: %08x %08x %08x %08x.\n" , dcode[0 ], dcode[1 ], dcode[2 ], dcode[3 ]);
@@ -8505,7 +8523,12 @@ qla24xx_load_risc_flash(scsi_qla_host_tfor (j =0 ; j < segments; j++) {ql_dbg (ql_dbg_init, vha,0x008d ,"-> Loading segment %u...\n" , j); -qla24xx_read_flash_data (vha, dcode, faddr,10 ); + rval =qla24xx_read_flash_data (vha, dcode, faddr,10 ); +if (rval) { +ql_log (ql_log_fatal, vha,0x016a , +"-> Unable to read segment addr + size .\n" ); +return QLA_FUNCTION_FAILED ; + } risc_addr =be32_to_cpu ((__force __be32 )dcode[2 ]); risc_size =be32_to_cpu ((__force __be32 )dcode[3 ]);if (!*srisc_addr) {
@@ -8521,7 +8544,13 @@ qla24xx_load_risc_flash(scsi_qla_host_tql_dbg (ql_dbg_init, vha,0x008e ,"-> Loading fragment %u: %#x <- %#x (%#lx dwords)...\n" , fragment, risc_addr, faddr, dlen); -qla24xx_read_flash_data (vha, dcode, faddr, dlen); + rval =qla24xx_read_flash_data (vha, dcode, faddr, dlen); +if (rval) { +ql_log (ql_log_fatal, vha,0x016b , +"-> Unable to read fragment(faddr %#x dlen %#lx).\n" , + faddr, dlen); +return QLA_FUNCTION_FAILED ; + }for (i =0 ; i < dlen; i++) dcode[i] =swab32 (dcode[i]);
@@ -8550,7 +8579,14 @@ qla24xx_load_risc_flash(scsi_qla_host_t fwdt->length =0 ; dcode = (uint32_t *)req->ring; -qla24xx_read_flash_data (vha, dcode, faddr,7 ); + + rval =qla24xx_read_flash_data (vha, dcode, faddr,7 ); +if (rval) { +ql_log (ql_log_fatal, vha,0x016c , +"-> Unable to read template size.\n" ); + goto failed; + } + risc_size =be32_to_cpu ((__force __be32 )dcode[2 ]); ql_dbg(ql_dbg_init, vha, 0x0161, "-> fwdt%u template array at %#x (%#x dwords)\n",
@@ -8576,11 +8612,12 @@ qla24xx_load_risc_flash(scsi_qla_host_t } dcode = fwdt->template; -qla24xx_read_flash_data (vha, dcode, faddr, risc_size); + rval =qla24xx_read_flash_data (vha, dcode, faddr, risc_size); -if (!qla27xx_fwdt_template_valid (dcode)) { +if (rval || !qla27xx_fwdt_template_valid (dcode)) {ql_log (ql_log_warn, vha,0x0165 , -"-> fwdt%u failed template validate\n" , j); +"-> fwdt%u failed template validate (rval %x)\n" , + j, rval); goto failed; }
drivers/scsi/qla2xxx/qla_sup.c +75 -33
188 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 351/440 scsi: qla2xxx: Complete command early within lock
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shreyas Deodhar <[email protected]>
commit 4475afa2646d3fec176fc4d011d3879b26cb26e3 upstream.
A crash was observed while performing NPIV and FW reset,
BUG: kernel NULL pointer dereference, address: 000000000000001c #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 1 PREEMPT_RT SMP NOPTI RIP: 0010:dma_direct_unmap_sg+0x51/0x1e0 RSP: 0018:ffffc90026f47b88 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000021 RCX: 0000000000000002 RDX: 0000000000000021 RSI: 0000000000000000 RDI: ffff8881041130d0 RBP: ffff8881041130d0 R08: 0000000000000000 R09: 0000000000000034 R10: ffffc90026f47c48 R11: 0000000000000031 R12: 0000000000000000 R13: 0000000000000000 R14: ffff8881565e4a20 R15: 0000000000000000 FS: 00007f4c69ed3d00(0000) GS:ffff889faac80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000000001c CR3: 0000000288a50002 CR4: 00000000007706e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: <TASK> ? __die_body+0x1a/0x60 ? page_fault_oops+0x16f/0x4a0 ? do_user_addr_fault+0x174/0x7f0 ? exc_page_fault+0x69/0x1a0 ? asm_exc_page_fault+0x22/0x30 ? dma_direct_unmap_sg+0x51/0x1e0 ? preempt_count_sub+0x96/0xe0 qla2xxx_qpair_sp_free_dma+0x29f/0x3b0 [qla2xxx] qla2xxx_qpair_sp_compl+0x60/0x80 [qla2xxx] __qla2x00_abort_all_cmds+0xa2/0x450 [qla2xxx]
The command completion was done early while aborting the commands in driver unload path but outside lock to avoid the WARN_ON condition of performing dma_free_attr within the lock. However this caused race condition while command completion via multiple paths causing system crash.
Hence complete the command early in unload path but within the lock to avoid race condition.
--- drivers/scsi/qla2xxx/qla_os.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +0 -5
@@ -1869,14 +1869,9 @@ __qla2x00_abort_all_cmds(struct qla_qpaifor (cnt =1 ; cnt < req->num_outstanding_cmds; cnt++) { sp = req->outstanding_cmds[cnt];if (sp) { -/* -* perform lockless completion during driver unload -*/ if (qla2x00_chip_is_down (vha)) { req->outstanding_cmds[cnt] =NULL ; -spin_unlock_irqrestore (qp->qp_lock_ptr, flags); sp->done (sp, res); -spin_lock_irqsave (qp->qp_lock_ptr, flags);continue ; }
Greg Kroah-Hartman
maintainerPATCH 352/440 scsi: qla2xxx: validate nvme_local_port correctly
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nilesh Javali <[email protected]>
commit eb1d4ce2609584eeb7694866f34d4b213caa3af9 upstream.
The driver load failed with error message,
qla2xxx [0000:04:00.0]-ffff:0: register_localport failed: ret=ffffffef
and with a kernel crash,
BUG: unable to handle kernel NULL pointer dereference at 0000000000000070 Workqueue: events_unbound qla_register_fcport_fn [qla2xxx] RIP: 0010:nvme_fc_register_remoteport+0x16/0x430 [nvme_fc] RSP: 0018:ffffaaa040eb3d98 EFLAGS: 00010282 RAX: 0000000000000000 RBX: ffff9dfb46b78c00 RCX: 0000000000000000 RDX: ffff9dfb46b78da8 RSI: ffffaaa040eb3e08 RDI: 0000000000000000 RBP: ffff9dfb612a0a58 R08: ffffffffaf1d6270 R09: 3a34303a30303030 R10: 34303a303030305b R11: 2078787832616c71 R12: ffff9dfb46b78dd4 R13: ffff9dfb46b78c24 R14: ffff9dfb41525300 R15: ffff9dfb46b78da8 FS: 0000000000000000(0000) GS:ffff9dfc67c00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000070 CR3: 000000018da10004 CR4: 00000000000206f0 Call Trace: qla_nvme_register_remote+0xeb/0x1f0 [qla2xxx] ? qla2x00_dfs_create_rport+0x231/0x270 [qla2xxx] qla2x00_update_fcport+0x2a1/0x3c0 [qla2xxx] qla_register_fcport_fn+0x54/0xc0 [qla2xxx]
Exit the qla_nvme_register_remote() function when qla_nvme_register_hba() fails and correctly validate nvme_local_port.
--- drivers/scsi/qla2xxx/qla_nvme.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_nvme.c +4 -1
@@ -29,7 +29,10 @@ int qla_nvme_register_remote(struct scsireturn 0 ; } -if (!vha->nvme_local_port &&qla_nvme_register_hba (vha)) +if (qla_nvme_register_hba (vha)) +return 0 ; + +if (!vha->nvme_local_port)return 0 ; if (!(fcport->nvme_prli_service_param &
Greg Kroah-Hartman
maintainerPATCH 353/440 perf: Fix event leak upon exit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frederic Weisbecker <[email protected]>
commit 2fd5ad3f310de22836cdacae919dd99d758a1f1b upstream.
When a task is scheduled out, pending sigtrap deliveries are deferred to the target task upon resume to userspace via task_work.
However failures while adding an event's callback to the task_work engine are ignored. And since the last call for events exit happen after task work is eventually closed, there is a small window during which pending sigtrap can be queued though ignored, leaking the event refcount addition such as in the following scenario:
TASK A
-----
do_exit()
exit_task_work(tsk);
<IRQ>
perf_event_overflow()
event->pending_sigtrap = pending_id;
irq_work_queue(&event->pending_irq);
</IRQ>
=========> PREEMPTION: TASK A -> TASK B
event_sched_out()
event->pending_sigtrap = 0;
atomic_long_inc_not_zero(&event->refcount)
// FAILS: task work has exited
task_work_add(&event->pending_task)
[...]
<IRQ WORK>
perf_pending_irq()
// early return: event->oncpu = -1
</IRQ WORK>
[...]
=========> TASK B -> TASK A
perf_event_exit_task(tsk)
perf_event_exit_event()
free_event()
WARN(atomic_long_cmpxchg(&event->refcount, 1, 0) != 1)
// leak event due to unexpected refcount == 2As a result the event is never released while the task exits.
Fix this with appropriate task_work_add()'s error handling.
--- kernel/events/core.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
kernel/events/core.c +5 -8
@@ -2316,18 +2316,15 @@ event_sched_out(struct perf_event *event }if (event->pending_sigtrap) { -bool dec = true; - event->pending_sigtrap =0 ;if (state !=PERF_EVENT_STATE_OFF && - !event->pending_work) { - event->pending_work =1 ; - dec = false; + !event->pending_work && + !task_work_add (current, &event->pending_task,TWA_RESUME )) {WARN_ON_ONCE (!atomic_long_inc_not_zero (&event->refcount)); -task_work_add (current, &event->pending_task,TWA_RESUME ); - } -if (dec) + event->pending_work =1 ; + }else {local_dec (&event->ctx->nr_pending); + } }perf_event_set_state (event, state);
Greg Kroah-Hartman
maintainerPATCH 354/440 perf: Fix event leak upon exec and file release
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Frederic Weisbecker <[email protected]>
commit 3a5465418f5fd970e86a86c7f4075be262682840 upstream.
The perf pending task work is never waited upon the matching event release. In the case of a child event, released via free_event() directly, this can potentially result in a leaked event, such as in the following scenario that doesn't even require a weak IRQ work implementation to trigger:
schedule()
prepare_task_switch()
=======> <NMI>
perf_event_overflow()
event->pending_sigtrap = ...
irq_work_queue(&event->pending_irq)
<======= </NMI>
perf_event_task_sched_out()
event_sched_out()
event->pending_sigtrap = 0;
atomic_long_inc_not_zero(&event->refcount)
task_work_add(&event->pending_task)
finish_lock_switch()
=======> <IRQ>
perf_pending_irq()
//do nothing, rely on pending task work<======= </IRQ>
begin_new_exec()
perf_event_exit_task()
perf_event_exit_event()
// If is child event
free_event()
WARN(atomic_long_cmpxchg(&event->refcount, 1, 0) != 1)
// event is leakedSimilar scenarios can also happen with perf_event_remove_on_exec() or simply against concurrent perf_event_release().
Fix this with synchonizing against the possibly remaining pending task work while freeing the event, just like is done with remaining pending IRQ work. This means that the pending task callback neither need nor should hold a reference to the event, preventing it from ever beeing freed.
--- include/linux/perf_event.h | 1 + kernel/events/core.c | 38 ++++++++++++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 4 deletions(-)
include/linux/perf_event.h +1 -0
@@ -765,6 +765,7 @@ struct perf_event {struct irq_work pending_irq;struct callback_head pending_task;unsigned int pending_work; +struct rcuwait pending_work_wait;atomic_t event_limit;
kernel/events/core.c +34 -4
@@ -2320,7 +2320,6 @@ event_sched_out(struct perf_event *eventif (state !=PERF_EVENT_STATE_OFF && !event->pending_work && !task_work_add (current, &event->pending_task,TWA_RESUME )) { -WARN_ON_ONCE (!atomic_long_inc_not_zero (&event->refcount)); event->pending_work =1 ; }else {local_dec (&event->ctx->nr_pending);
@@ -5004,9 +5003,35 @@ static bool exclusive_event_installable(static void perf_addr_filters_splice (struct perf_event *event,struct list_head *head); +static void perf_pending_task_sync (struct perf_event *event) +{ +struct callback_head *head = &event->pending_task; + +if (!event->pending_work) +return ; +/* +* If the task is queued to the current task's queue, we +* obviously can't wait for it to complete. Simply cancel it. +*/ +if (task_work_cancel (current, head)) { + event->pending_work =0 ; +local_dec (&event->ctx->nr_pending); +return ; + } + +/* +* All accesses related to the event are within the same +* non-preemptible section in perf_pending_task(). The RCU +* grace period before the event is freed will make sure all +* those accesses are complete by then. +*/ +rcuwait_wait_event (&event->pending_work_wait, !event->pending_work,TASK_UNINTERRUPTIBLE ); +} +static void _free_event (struct perf_event *event) {irq_work_sync (&event->pending_irq); +perf_pending_task_sync (event);unaccount_event (event);
@@ -6637,23 +6662,27 @@ static void perf_pending_task(struct calint rctx;/* +* All accesses to the event must belong to the same implicit RCU read-side +* critical section as the ->pending_work reset. See comment in +* perf_pending_task_sync(). +*/ +preempt_disable_notrace (); +/* * If we 'fail' here, that's OK, it means recursion is already disabled * and we won't recurse 'further'. */ -preempt_disable_notrace (); rctx =perf_swevent_get_recursion_context ();if (event->pending_work) { event->pending_work =0 ;perf_sigtrap (event);local_dec (&event->ctx->nr_pending); +rcuwait_wake_up (&event->pending_work_wait); }if (rctx >=0 )perf_swevent_put_recursion_context (rctx);preempt_enable_notrace (); - -put_event (event); }#ifdef CONFIG_GUEST_PERF_EVENTS
@@ -11779,6 +11808,7 @@ perf_event_alloc(struct perf_event_attrinit_waitqueue_head (&event->waitq);init_irq_work (&event->pending_irq, perf_pending_irq);init_task_work (&event->pending_task, perf_pending_task); +rcuwait_init (&event->pending_work_wait);mutex_init (&event->mmap_mutex);raw_spin_lock_init (&event->addr_filters.lock);
Greg Kroah-Hartman
maintainerPATCH 355/440 perf/x86/intel/uncore: Fix the bits of the CHA extended umask for SPR
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kan Liang <[email protected]>
commit a5a6ff3d639d088d4af7e2935e1ee0d8b4e817d4 upstream.
The perf stat errors out with UNC_CHA_TOR_INSERTS.IA_HIT_CXL_ACC_LOCAL event.
$perf stat -e uncore_cha_55/event=0x35,umask=0x10c0008101/ -a -- ls
event syntax error: '..0x35,umask=0x10c0008101/'
\___ Bad event or PMU
The definition of the CHA umask is config:8-15,32-55, which is 32bit. However, the umask of the event is bigger than 32bit.
This is an error in the original uncore spec.
Add a new umask_ext5 for the new CHA umask range.
--- arch/x86/events/intel/uncore_snbep.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/x86/events/intel/uncore_snbep.c +4 -2
@@ -459,6 +459,7 @@#define SPR_RAW_EVENT_MASK_EXT 0xffffff/* SPR CHA */ +#define SPR_CHA_EVENT_MASK_EXT 0xffffffff#define SPR_CHA_PMON_CTL_TID_EN (1 << 16)#define SPR_CHA_PMON_EVENT_MASK (SNBEP_PMON_RAW_EVENT_MASK | \ SPR_CHA_PMON_CTL_TID_EN)
@@ -475,6 +476,7 @@ DEFINE_UNCORE_FORMAT_ATTR(umask_ext, umaDEFINE_UNCORE_FORMAT_ATTR (umask_ext2, umask,"config:8-15,32-57" );DEFINE_UNCORE_FORMAT_ATTR (umask_ext3, umask,"config:8-15,32-39" );DEFINE_UNCORE_FORMAT_ATTR (umask_ext4, umask,"config:8-15,32-55" ); +DEFINE_UNCORE_FORMAT_ATTR (umask_ext5, umask,"config:8-15,32-63" );DEFINE_UNCORE_FORMAT_ATTR (qor, qor,"config:16" );DEFINE_UNCORE_FORMAT_ATTR (edge, edge,"config:18" );DEFINE_UNCORE_FORMAT_ATTR (tid_en, tid_en,"config:19" );
@@ -5648,7 +5650,7 @@ static struct intel_uncore_ops spr_uncorstatic struct attribute *spr_uncore_cha_formats_attr[] = { &format_attr_event.attr, - &format_attr_umask_ext4.attr, + &format_attr_umask_ext5.attr, &format_attr_tid_en2.attr, &format_attr_edge.attr, &format_attr_inv.attr,
@@ -5684,7 +5686,7 @@ ATTRIBUTE_GROUPS(uncore_alias);static struct intel_uncore_type spr_uncore_chabox = { .name ="cha" , .event_mask =SPR_CHA_PMON_EVENT_MASK , - .event_mask_ext =SPR_RAW_EVENT_MASK_EXT , + .event_mask_ext =SPR_CHA_EVENT_MASK_EXT , .num_shared_regs =1 , .constraints = skx_uncore_chabox_constraints, .ops = &spr_uncore_chabox_ops,
Greg Kroah-Hartman
maintainerPATCH 356/440 perf/x86/intel/pt: Fix topa_entry base length
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Cavenati <[email protected]>
commit 5638bd722a44bbe97c1a7b3fae5b9efddb3e70ff upstream.
topa_entry->base needs to store a pfn. It obviously needs to be large enough to store the largest possible x86 pfn which is MAXPHYADDR-PAGE_SIZE (52-12). So it is 4 bits too small.
Increase the size of topa_entry->base from 36 bits to 40 bits.
Note, systems where physical addresses can be 256TiB or more are affected.
[ Adrian: Amend commit message as suggested by Dave Hansen ]
--- arch/x86/events/intel/pt.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/events/intel/pt.h +2 -2
@@ -33,8 +33,8 @@ struct topa_entry { u64 rsvd2 : 1; u64 size : 4; u64 rsvd3 : 2; - u64 base : 36; - u64 rsvd4 : 16; + u64 base : 40; + u64 rsvd4 : 12; };/* TSC to Core Crystal Clock Ratio */
Greg Kroah-Hartman
maintainerPATCH 357/440 perf/x86/intel/pt: Fix a topa_entry base address calculation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
commit ad97196379d0b8cb24ef3d5006978a6554e6467f upstream.
topa_entry->base is a bit-field. Bit-fields are not promoted to a 64-bit type, even if the underlying type is 64-bit, and so, if necessary, must be cast to a larger type when calculations are done.
Fix a topa_entry->base address calculation by adding a cast.
Without the cast, the address was limited to 36-bits i.e. 64GiB.
The address calculation is used on systems that do not support Multiple Entry ToPA (only Broadwell), and affects physical addresses on or above 64GiB. Instead of writing to the correct address, the address comprising the first 36 bits would be written to.
Intel PT snapshot and sampling modes are not affected.
--- arch/x86/events/intel/pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/pt.c +1 -1
@@ -877,7 +877,7 @@ static void pt_update_head(struct pt *pt*/ static void *pt_buffer_region (struct pt_buffer *buf) { -return phys_to_virt (TOPA_ENTRY (buf->cur, buf->cur_idx)->base <<TOPA_SHIFT ); +return phys_to_virt ((phys_addr_t )TOPA_ENTRY (buf->cur, buf->cur_idx)->base <<TOPA_SHIFT ); }/**
Greg Kroah-Hartman
maintainerPATCH 358/440 drm/i915/gt: Do not consider preemption during execlists_dequeue for gen8
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nitin Gote <[email protected]>
commit 65564157ae64cec0f527583f96e32f484f730f92 upstream.
We're seeing a GPU hang issue on a CHV platform, which was caused by commit bac24f59f454 ("drm/i915/execlists: Enable coarse preemption boundaries for Gen8").
The Gen8 platform only supports timeslicing and doesn't have a preemption mechanism, as its engines do not have a preemption timer.
Commit 751f82b353a6 ("drm/i915/gt: Only disable preemption on Gen8 render engines") addressed this issue only for render engines. This patch extends that fix by ensuring that preemption is not considered for all engines on Gen8 platforms.
v4:
- Use the correct Fixes tag (Rodrigo Vivi)
- Reworded commit log (Andi Shyti)
v3:
- Inside need_preempt(), condition of can_preempt() is not required as simplified can_preempt() is enough. (Chris Wilson)
v2: Simplify can_preempt() function (Tvrtko Ursulin)
--- drivers/gpu/drm/i915/gt/intel_execlists_submission.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +1 -5
@@ -3313,11 +3313,7 @@ static void remove_from_engine(struct i9static bool can_preempt (struct intel_engine_cs *engine) { -if (GRAPHICS_VER (engine->i915) >8 ) -return true; - -/* GPGPU on bdw requires extra w/a; not implemented */ -return engine->class !=RENDER_CLASS ; +return GRAPHICS_VER (engine->i915) >8 ; }static void kick_execlists (const struct i915_request *rq,int prio)
Greg Kroah-Hartman
maintainerPATCH 359/440 drm/amdgpu/sdma5.2: Update wptr registers as well as doorbell
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit a03ebf116303e5d13ba9a2b65726b106cb1e96f6 upstream.
We seem to have a case where SDMA will sometimes miss a doorbell if GFX is entering the powergating state when the doorbell comes in. To workaround this, we can update the wptr via MMIO, however, this is only safe because we disallow gfxoff in begin_ring() for SDMA 5.2 and then allow it again in end_ring().
Enable this workaround while we are root causing the issue with the HW team.
--- drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +12 -0
@@ -241,6 +241,14 @@ static void sdma_v5_2_ring_set_wptr(struDRM_DEBUG ("calling WDOORBELL64(0x%08x, 0x%016llx)\n" , ring->doorbell_index, ring->wptr <<2 );WDOORBELL64 (ring->doorbell_index, ring->wptr <<2 ); +/* SDMA seems to miss doorbells sometimes when powergating kicks in. +* Updating the wptr directly will wake it. This is only safe because +* we disallow gfxoff in begin_use() and then allow it again in end_use(). +*/ +WREG32 (sdma_v5_2_get_reg_offset (adev, ring->me, mmSDMA0_GFX_RB_WPTR), +lower_32_bits (ring->wptr <<2 )); +WREG32 (sdma_v5_2_get_reg_offset (adev, ring->me, mmSDMA0_GFX_RB_WPTR_HI), +upper_32_bits (ring->wptr <<2 )); }else {DRM_DEBUG ("Not using doorbell -- " "mmSDMA%i_GFX_RB_WPTR == 0x%08x "
@@ -1705,6 +1713,10 @@ static void sdma_v5_2_ring_begin_use(str* but it shouldn't hurt for other parts since * this GFXOFF will be disallowed anyway when SDMA is * active, this just makes it explicit. +* sdma_v5_2_ring_set_wptr() takes advantage of this +* to update the wptr because sometimes SDMA seems to miss +* doorbells when entering PG. If you remove this, update +* sdma_v5_2_ring_set_wptr() as well! */ amdgpu_gfx_off_ctrl (adev, false); }
Greg Kroah-Hartman
maintainerPATCH 360/440 drm/dp_mst: Fix all mstb marked as not probed after suspend/resume
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wayne Lin <[email protected]>
commit d63d81094d208abb20fc444514b2d9ec2f4b7c4e upstream.
[Why]
After supend/resume, with topology unchanged, observe that link_address_sent of all mstb are marked as false even the topology probing is done without any error.
It is caused by wrongly also include "ret == 0" case as a probing failure case.
[How]
Remove inappropriate checking conditions.
--- drivers/gpu/drm/display/drm_dp_mst_topology.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/display/drm_dp_mst_topology.c +2 -2
@@ -2923,7 +2923,7 @@ static int drm_dp_send_link_address(stru/* FIXME: Actually do some real error handling here */ ret =drm_dp_mst_wait_tx_reply (mstb, txmsg); -if (ret <=0 ) { +if (ret <0 ) {drm_err (mgr->dev,"Sending link address failed with %d\n" , ret); goto out; }
@@ -2975,7 +2975,7 @@ static int drm_dp_send_link_address(strumutex_unlock (&mgr->lock); out: -if (ret <=0 ) +if (ret <0 ) mstb->link_address_sent = false;kfree (txmsg);return ret <0 ? ret : changed;
Greg Kroah-Hartman
maintainerPATCH 361/440 drm/i915/dp: Reset intel_dp->link_trained before retraining the link
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Deak <[email protected]>
commit d13e2a6e95e6b87f571c837c71a3d05691def9bb upstream.
Regularly retraining a link during an atomic commit happens with the given pipe/link already disabled and hence intel_dp->link_trained being false. Ensure this also for retraining a DP SST link via direct calls to the link training functions (vs. an actual commit as for DP MST). So far nothing depended on this, however the next patch will depend on link_trained==false for changing the LTTPR mode to non-transparent.
--- drivers/gpu/drm/i915/display/intel_dp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/i915/display/intel_dp.c +2 -0
@@ -4089,6 +4089,8 @@ int intel_dp_retrain_link(struct intel_e !intel_dp_mst_is_master_trans(crtc_state))continue ; + intel_dp->link_trained = false; +intel_dp_check_frl_training (intel_dp);intel_dp_pcon_dsc_configure (intel_dp, crtc_state);intel_dp_start_link_train (intel_dp, crtc_state);
Greg Kroah-Hartman
maintainerPATCH 362/440 rtc: isl1208: Fix return value of nvmem callbacks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joy Chakraborty <[email protected]>
commit 70f1ae5f0e7f44edf842444044615da7b59838c1 upstream.
Read/write callbacks registered with nvmem core expect 0 to be returned on success and a negative value to be returned on failure.
isl1208_nvmem_read()/isl1208_nvmem_write() currently return the number of bytes read/written on success, fix to return 0 on success and negative on failure.
--- drivers/rtc/rtc-isl1208.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/rtc/rtc-isl1208.c +4 -7
@@ -743,14 +743,13 @@ static int isl1208_nvmem_read(void *priv {struct isl1208_state *isl1208 = priv;struct i2c_client *client =to_i2c_client (isl1208->rtc->dev.parent); -int ret;/* nvmem sanitizes offset/count for us, but count==0 is possible */ if (!count)return count; - ret =isl1208_i2c_read_regs (client,ISL1208_REG_USR1 + off, buf, + +return isl1208_i2c_read_regs (client,ISL1208_REG_USR1 + off, buf, count); -return ret ==0 ? count : ret; } static int isl1208_nvmem_write(void *priv, unsigned int off, void *buf,
@@ -758,15 +757,13 @@ static int isl1208_nvmem_write(void *pri {struct isl1208_state *isl1208 = priv;struct i2c_client *client =to_i2c_client (isl1208->rtc->dev.parent); -int ret;/* nvmem sanitizes off/count for us, but count==0 is possible */ if (!count)return count; - ret =isl1208_i2c_set_regs (client,ISL1208_REG_USR1 + off, buf, - count); -return ret ==0 ? count : ret; +return isl1208_i2c_set_regs (client,ISL1208_REG_USR1 + off, buf, + count); }static const struct nvmem_config isl1208_nvmem_config = {
Greg Kroah-Hartman
maintainerPATCH 363/440 watchdog/perf: properly initialize the turbo mode timestamp and rearm counter
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit f944ffcbc2e1c759764850261670586ddf3bdabb upstream.
For systems on which the performance counter can expire early due to turbo modes the watchdog handler has a safety net in place which validates that since the last watchdog event there has at least 4/5th of the watchdog period elapsed.
This works reliably only after the first watchdog event because the per CPU variable which holds the timestamp of the last event is never initialized.
So a first spurious event will validate against a timestamp of 0 which results in a delta which is likely to be way over the 4/5 threshold of the period. As this might happen before the first watchdog hrtimer event increments the watchdog counter, this can lead to false positives.
Fix this by initializing the timestamp before enabling the hardware event. Reset the rearm counter as well, as that might be non zero after the watchdog was disabled and reenabled.
--- kernel/watchdog_hld.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
kernel/watchdog_hld.c +8 -3
@@ -91,11 +91,15 @@ static bool watchdog_check_timestamp(voi__this_cpu_write (last_timestamp, now);return true; } -#else -static inline bool watchdog_check_timestamp (void ) + +static void watchdog_init_timestamp (void ) { -return true; +__this_cpu_write (nmi_rearmed,0 ); +__this_cpu_write (last_timestamp,ktime_get_mono_fast_ns ()); } +#else +static inline bool watchdog_check_timestamp (void ) {return true; } +static inline void watchdog_init_timestamp (void ) { }#endif static struct perf_event_attr wd_hw_attr = {
@@ -196,6 +200,7 @@ void hardlockup_detector_perf_enable(voiif (!atomic_fetch_inc (&watchdog_cpus))pr_info ("Enabled. Permanently consumes one hw-PMU counter.\n" ); +watchdog_init_timestamp ();perf_event_enable (this_cpu_read (watchdog_ev)); }
Greg Kroah-Hartman
maintainerPATCH 364/440 platform: mips: cpu_hwmon: Disable driver on unsupported hardware
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaxun Yang <[email protected]>
commit f4d430db17b4ef4e9c3c352a04b2fe3c93011978 upstream.
cpu_hwmon is unsupported on CPUs without loongson_chiptemp register and csr.
--- drivers/platform/mips/cpu_hwmon.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/platform/mips/cpu_hwmon.c +3 -0
@@ -139,6 +139,9 @@ static int __init loongson_hwmon_init(vo csr_temp_enable =csr_readl (LOONGSON_CSR_FEATURES ) &LOONGSON_CSRF_TEMP ; +if (!csr_temp_enable && !loongson_chiptemp[0 ]) +return -ENODEV ; + nr_packages = loongson_sysconf.nr_cpus / loongson_sysconf.cores_per_package;
Greg Kroah-Hartman
maintainerPATCH 365/440 RDMA/iwcm: Fix a use-after-free related to destroying CM IDs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
commit aee2424246f9f1dadc33faa78990c1e2eb7826e4 upstream.
iw_conn_req_handler() associates a new struct rdma_id_private (conn_id) with an existing struct iw_cm_id (cm_id) as follows:
conn_id->cm_id.iw = cm_id;
cm_id->context = conn_id;
cm_id->cm_handler = cma_iw_handler;rdma_destroy_id() frees both the cm_id and the struct rdma_id_private. Make sure that cm_work_handler() does not trigger a use-after-free by only freeing of the struct rdma_id_private after all pending work has finished.
--- drivers/infiniband/core/iwcm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/infiniband/core/iwcm.c +7 -4
@@ -369,8 +369,10 @@ EXPORT_SYMBOL(iw_cm_disconnect);* * Clean up all resources associated with the connection and release * the initial reference taken by iw_create_cm_id. +* +* Returns true if and only if the last cm_id_priv reference has been dropped. */ -static void destroy_cm_id (struct iw_cm_id *cm_id) +static bool destroy_cm_id (struct iw_cm_id *cm_id) {struct iwcm_id_private *cm_id_priv;struct ib_qp *qp;
@@ -440,7 +442,7 @@ static void destroy_cm_id(struct iw_cm_iiwpm_remove_mapping (&cm_id->local_addr,RDMA_NL_IWCM ); } - (void )iwcm_deref_id (cm_id_priv); +return iwcm_deref_id (cm_id_priv); }/*
@@ -451,7 +453,8 @@ static void destroy_cm_id(struct iw_cm_i*/ void iw_destroy_cm_id (struct iw_cm_id *cm_id) { -destroy_cm_id (cm_id); +if (!destroy_cm_id (cm_id)) +flush_workqueue (iwcm_wq); }EXPORT_SYMBOL (iw_destroy_cm_id);
@@ -1035,7 +1038,7 @@ static void cm_work_handler(struct work_if (!test_bit (IWCM_F_DROP_EVENTS , &cm_id_priv->flags)) { ret =process_event (cm_id_priv, &levent);if (ret) -destroy_cm_id (&cm_id_priv->id); +WARN_ON_ONCE (destroy_cm_id (&cm_id_priv->id)); }else pr_debug ("dropping event %d\n" , levent.event);if (iwcm_deref_id (cm_id_priv))
Greg Kroah-Hartman
maintainerPATCH 366/440 selftests/sigaltstack: Fix ppc64 GCC build
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
commit 17c743b9da9e0d073ff19fd5313f521744514939 upstream.
Building the sigaltstack test with GCC on 64-bit powerpc errors with:
gcc -Wall sas.c -o /home/michael/linux/.build/kselftest/sigaltstack/sas
In file included from sas.c:23:
current_stack_pointer.h:22:2: error: #error "implement current_stack_pointer equivalent"
22 | #error "implement current_stack_pointer equivalent"
| ^~~~~
sas.c: In function ‘my_usr1’:
sas.c:50:13: error: ‘sp’ undeclared (first use in this function); did you mean ‘p’?
50 | if (sp < (unsigned long)sstack ||
| ^~This happens because GCC doesn't define __ppc__ for 64-bit builds, only 32-bit builds. Instead use __powerpc__ to detect powerpc builds, which is defined by clang and GCC for 64-bit and 32-bit builds.
--- tools/testing/selftests/sigaltstack/current_stack_pointer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/sigaltstack/current_stack_pointer.h +1 -1
@@ -8,7 +8,7 @@ register unsigned long sp asm("sp"); registerunsigned long sp asm("esp" );#elif __loongarch64 registerunsigned long sp asm("$sp" ); -#elif __ppc__ +#elif __powerpc__ registerunsigned long sp asm("r1" );#elif __s390x__ registerunsigned long sp asm("%15" );
Greg Kroah-Hartman
maintainerPATCH 367/440 dm-verity: fix dm_is_verity_target() when dm-verity is builtin
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 3708c7269593b836b1d684214cd9f5d83e4ed3fd upstream.
When CONFIG_DM_VERITY=y, dm_is_verity_target() returned true for any builtin dm target, not just dm-verity. Fix this by checking for verity_target instead of THIS_MODULE (which is NULL for builtin code).
--- drivers/md/dm-verity-target.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/md/dm-verity-target.c +8 -8
@@ -1497,14 +1497,6 @@ bad: }/* -* Check whether a DM target is a verity target. -*/ -bool dm_is_verity_target (struct dm_target *ti) -{ -return ti->type->module ==THIS_MODULE ; -} - -/* * Get the verity mode (error behavior) of a verity target. * * Returns the verity mode of the target, or -EINVAL if 'ti' is not a verity
@@ -1575,6 +1567,14 @@ static void __exit dm_verity_exit(void)module_init (dm_verity_init);module_exit (dm_verity_exit); +/* +* Check whether a DM target is a verity target. +*/ +bool dm_is_verity_target (struct dm_target *ti) +{ +return ti->type == &verity_target; +} +MODULE_AUTHOR ("Mikulas Patocka <[email protected]>" );MODULE_AUTHOR ("Mandeep Baines <[email protected]>" );MODULE_AUTHOR ("Will Drewry <[email protected]>" );
Greg Kroah-Hartman
maintainerPATCH 368/440 rbd: dont assume rbd_is_lock_owner() for exclusive mappings
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit 3ceccb14f5576e02b81cc8b105ab81f224bd87f6 upstream.
Expanding on the previous commit, assuming that rbd_is_lock_owner() always returns true (i.e. that we are either in RBD_LOCK_STATE_LOCKED or RBD_LOCK_STATE_QUIESCING) if the mapping is exclusive is wrong too. In case ceph_cls_set_cookie() fails, the lock would be temporarily released even if the mapping is exclusive, meaning that we can end up even in RBD_LOCK_STATE_UNLOCKED.
IOW, exclusive mappings are really "just" about disabling automatic lock transitions (as documented in the man page), not about grabbing the lock and holding on to it whatever it takes.
--- drivers/block/rbd.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/block/rbd.c +0 -5
@@ -6589,11 +6589,6 @@ static int rbd_add_acquire_lock(struct rif (ret)return ret; -/* -* The lock may have been released by now, unless automatic lock -* transitions are disabled. -*/ -rbd_assert (!rbd_dev->opts->exclusive ||rbd_is_lock_owner (rbd_dev));return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 369/440 remoteproc: stm32_rproc: Fix mailbox interrupts queuing
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gwenael Treuveur <[email protected]>
commit c3281abea67c9c0dc6219bbc41d1feae05a16da3 upstream.
Manage interrupt coming from coprocessor also when state is ATTACHED.
--- drivers/remoteproc/stm32_rproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/stm32_rproc.c +1 -1
@@ -293,7 +293,7 @@ static void stm32_rproc_mb_vq_work(strucmutex_lock (&rproc->lock); -if (rproc->state !=RPROC_RUNNING ) +if (rproc->state !=RPROC_RUNNING && rproc->state !=RPROC_ATTACHED ) goto unlock_mutex;if (rproc_vq_interrupt (rproc, mb->vq_id) ==IRQ_NONE )
Greg Kroah-Hartman
maintainerPATCH 370/440 remoteproc: imx_rproc: Skip over memory region when node value is NULL
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Mishin <[email protected]>
commit 2fa26ca8b786888673689ccc9da6094150939982 upstream.
In imx_rproc_addr_init() "nph = of_count_phandle_with_args()" just counts number of phandles. But phandles may be empty. So of_parse_phandle() in the parsing loop (0 < a < nph) may return NULL which is later dereferenced. Adjust this issue by adding NULL-return check.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/remoteproc/imx_rproc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/remoteproc/imx_rproc.c +2 -0
@@ -596,6 +596,8 @@ static int imx_rproc_addr_init(struct imstruct resource res; node =of_parse_phandle (np,"memory-region" , a); +if (!node) +continue ;/* Not map vdevbuffer, vdevring region */ if (!strncmp (node->name,"vdev" ,strlen ("vdev" ))) {of_node_put (node);
Greg Kroah-Hartman
maintainerPATCH 371/440 remoteproc: imx_rproc: Fix refcount mistake in imx_rproc_addr_init
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Mishin <[email protected]>
commit dce68a49be26abf52712e0ee452a45fa01ab4624 upstream.
In imx_rproc_addr_init() strcmp() is performed over the node after the of_node_put() is performed over it.
Fix this error by moving of_node_put() calls.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/remoteproc/imx_rproc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/remoteproc/imx_rproc.c +6 -2
@@ -604,25 +604,29 @@ static int imx_rproc_addr_init(struct imcontinue ; } err =of_address_to_resource (node,0 , &res); -of_node_put (node);if (err) {dev_err (dev,"unable to resolve memory region\n" ); +of_node_put (node);return err; } -if (b >=IMX_RPROC_MEM_MAX ) +if (b >=IMX_RPROC_MEM_MAX ) { +of_node_put (node);break ; + }/* Not use resource version, because we might share region */ priv->mem[b].cpu_addr =devm_ioremap_wc (&pdev->dev, res.start,resource_size (&res));if (!priv->mem[b].cpu_addr) {dev_err (dev,"failed to remap %pr\n" , &res); +of_node_put (node);return -ENOMEM ; } priv->mem[b].sys_addr = res.start; priv->mem[b].size =resource_size (&res);if (!strcmp (node->name,"rsc-table" )) priv->rsc_table = priv->mem[b].cpu_addr; +of_node_put (node); b++; }
Greg Kroah-Hartman
maintainerPATCH 372/440 MIPS: dts: loongson: Add ISA node
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaxun Yang <[email protected]>
commit da3f62466e5afc752f8b72146bbc4700dbba5a9f upstream.
ISA node is required by Loongson64 platforms to initialize PIO support.
Kernel will hang at boot without ISA node.
--- arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi | 7 +++++++ 1 file changed, 7 insertions(+)
arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi +7 -0
@@ -52,6 +52,13 @@ 0 0x40000000 0 0x40000000 0 0x40000000 0xfe 0x00000000 0xfe 0x00000000 0 0x40000000>; + isa@18000000 { + compatible = "isa"; + #size-cells = <1>; + #address-cells = <2>; + ranges = <1 0x0 0x0 0x18000000 0x4000>; + }; + pm: reset-controller@1fe07000 { compatible = "loongson,ls2k-pm"; reg = <0 0x1fe07000 0 0x422>;
Greg Kroah-Hartman
maintainerPATCH 373/440 MIPS: ip30: ip30-console: Add missing include
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaxun Yang <[email protected]>
commit 8de4ed75bd14ed197119ac509c6902a8561e0c1c upstream.
Include linux/processor.h to fix build error:
arch/mips/sgi-ip30/ip30-console.c: In function ‘prom_putchar’:arch/mips/sgi-ip30/ip30-console.c:21:17: error: implicit declaration of function ‘cpu_relax’ [-Werror=implicit-function-declaration]
21 | cpu_relax();
--- arch/mips/sgi-ip30/ip30-console.c | 1 + 1 file changed, 1 insertion(+)
arch/mips/sgi-ip30/ip30-console.c +1 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/io.h> +#include <linux/processor.h> #include <asm/sn/ioc3.h>
Greg Kroah-Hartman
maintainerPATCH 374/440 MIPS: dts: loongson: Fix GMAC phy node
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaxun Yang <[email protected]>
commit 813c18d1ca1987afaf47e035152e1baa1375b1b2 upstream.
phy-mode should be rgmii-id to match hardware configuration.
Also there should be a phy-handle to reference phy node.
--- arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi +4 -2
@@ -137,7 +137,8 @@ <13 IRQ_TYPE_LEVEL_LOW>; interrupt-names = "macirq", "eth_lpi"; interrupt-parent = <&liointc0>; - phy-mode = "rgmii"; + phy-mode = "rgmii-id"; + phy-handle = <&phy1>; mdio { #address-cells = <1>; #size-cells = <0>;
@@ -160,7 +161,8 @@ <15 IRQ_TYPE_LEVEL_LOW>; interrupt-names = "macirq", "eth_lpi"; interrupt-parent = <&liointc0>; - phy-mode = "rgmii"; + phy-mode = "rgmii-id"; + phy-handle = <&phy1>; mdio { #address-cells = <1>; #size-cells = <0>;
Greg Kroah-Hartman
maintainerPATCH 375/440 MIPS: Loongson64: env: Hook up Loongsson-2K
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaxun Yang <[email protected]>
commit 77543269ff23c75bebfb8e6e9a1177b350908ea7 upstream.
Somehow those enablement bits were left over when we were adding initial Loongson-2K support.
Set up basic information and select proper builtin DTB for Loongson-2K.
--- arch/mips/include/asm/mach-loongson64/boot_param.h | 2 ++ arch/mips/loongson64/env.c | 8 ++++++++ 2 files changed, 10 insertions(+)
arch/mips/include/asm/mach-loongson64/boot_param.h +2 -0
@@ -42,12 +42,14 @@ enum loongson_cpu_type { Legacy_1B =0x5 , Legacy_2G =0x6 , Legacy_2H =0x7 , + Legacy_2K =0x8 , Loongson_1A =0x100 , Loongson_1B =0x101 , Loongson_2E =0x200 , Loongson_2F =0x201 , Loongson_2G =0x202 , Loongson_2H =0x203 , + Loongson_2K =0x204 , Loongson_3A =0x300 , Loongson_3B =0x301 };
arch/mips/loongson64/env.c +8 -0
@@ -88,6 +88,12 @@ void __init prom_lefi_init_env(void) cpu_clock_freq = ecpu->cpu_clock_freq; loongson_sysconf.cputype = ecpu->cputype;switch (ecpu->cputype) { +case Legacy_2K: +case Loongson_2K: + smp_group[0 ] =0x900000001fe11000 ; + loongson_sysconf.cores_per_node =2 ; + loongson_sysconf.cores_per_package =2 ; +break ;case Legacy_3A:case Loongson_3A: loongson_sysconf.cores_per_node =4 ;
@@ -221,6 +227,8 @@ void __init prom_lefi_init_env(void)default :break ; } + }else if ((read_c0_prid () &PRID_IMP_MASK ) ==PRID_IMP_LOONGSON_64R ) { + loongson_fdt_blob = __dtb_loongson64_2core_2k1000_begin; }else if ((read_c0_prid () &PRID_IMP_MASK ) ==PRID_IMP_LOONGSON_64G ) {if (loongson_sysconf.bridgetype ==LS7A ) loongson_fdt_blob = __dtb_loongson64g_4core_ls7a_begin;
Greg Kroah-Hartman
maintainerPATCH 376/440 MIPS: Loongson64: Remove memory node for builtin-dtb
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaxun Yang <[email protected]>
commit b81656c37acf1e682dde02f3e07987784b0f3634 upstream.
Builtin DTBS should never contain memory node as memory is going to be managed by LEFI interface.
Remove memory node to prevent confliction.
--- arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi | 8 -------- 1 file changed, 8 deletions(-)
arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi +0 -8
@@ -23,14 +23,6 @@ }; }; - memory@200000 { - compatible = "memory"; - device_type = "memory"; - reg = <0x00000000 0x00200000 0x00000000 0x0ee00000>, /* 238 MB at 2 MB */ - <0x00000000 0x20000000 0x00000000 0x1f000000>, /* 496 MB at 512 MB */ - <0x00000001 0x10000000 0x00000001 0xb0000000>; /* 6912 MB at 4352MB */ - }; - cpu_clk: cpu_clk { #clock-cells = <0>; compatible = "fixed-clock";
Greg Kroah-Hartman
maintainerPATCH 377/440 MIPS: Loongson64: reset: Prioritise firmware service
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaxun Yang <[email protected]>
commit 4e7ca0b57f3bc09ba3e4ab86bf6b7c35134bfd04 upstream.
We should always use firmware's poweroff & reboot service if it's available as firmware may need to perform more task than platform's syscon etc.
However _machine_restart & poweroff hooks are registered at low priority, which means platform reboot driver can override them.
Register firmware based reboot/poweroff implementation with register_sys_off_handler with appropriate priority so that they will be prioritised. Remove _machine_halt hook as it's deemed to be unnecessary.
--- arch/mips/loongson64/reset.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-)
arch/mips/loongson64/reset.c +16 -22
@@ -11,6 +11,7 @@#include <linux/init.h> #include <linux/kexec.h> #include <linux/pm.h> +#include <linux/reboot.h> #include <linux/slab.h> #include <asm/bootinfo.h>
@@ -21,36 +22,21 @@#include <loongson.h> #include <boot_param.h> -static void loongson_restart (char *command) +static int firmware_restart (struct sys_off_data *unusedd) {void (*fw_restart)(void ) = (void *)loongson_sysconf.restart_addr;fw_restart (); -while (1 ) { -if (cpu_wait) -cpu_wait (); - } +return NOTIFY_DONE ; } -static void loongson_poweroff (void ) +static int firmware_poweroff (struct sys_off_data *unused) {void (*fw_poweroff)(void ) = (void *)loongson_sysconf.poweroff_addr;fw_poweroff (); -while (1 ) { -if (cpu_wait) -cpu_wait (); - } -} - -static void loongson_halt (void ) -{ -pr_notice ("\n\n** You can safely turn off the power now **\n\n" ); -while (1 ) { -if (cpu_wait) -cpu_wait (); - } +return NOTIFY_DONE ; }#ifdef CONFIG_KEXEC
@@ -154,9 +140,17 @@ static void loongson_crash_shutdown(strustatic int __init mips_reboot_setup (void ) { - _machine_restart = loongson_restart; - _machine_halt = loongson_halt; - pm_power_off = loongson_poweroff; +if (loongson_sysconf.restart_addr) { +register_sys_off_handler (SYS_OFF_MODE_RESTART , +SYS_OFF_PRIO_FIRMWARE , + firmware_restart,NULL ); + } + +if (loongson_sysconf.poweroff_addr) { +register_sys_off_handler (SYS_OFF_MODE_POWER_OFF , +SYS_OFF_PRIO_FIRMWARE , + firmware_poweroff,NULL ); + }#ifdef CONFIG_KEXEC kexec_argv =kmalloc (KEXEC_ARGV_SIZE ,GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 378/440 MIPS: Loongson64: Test register availability before use
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaxun Yang <[email protected]>
commit c04366b1207a036b7de02dfcc1ac7138d3343c9b upstream.
Some global register address variable may be missing on specific CPU type, test them before use them.
--- arch/mips/loongson64/smp.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
arch/mips/loongson64/smp.c +21 -2
@@ -479,12 +479,25 @@ static void loongson3_smp_finish(void)static void __init loongson3_smp_setup (void ) {int i =0 , num =0 ;/* i: physical id, num: logical id */ +int max_cpus =0 ;init_cpu_possible (cpu_none_mask); +for (i =0 ; i <ARRAY_SIZE (smp_group); i++) { +if (!smp_group[i]) +break ; + max_cpus += loongson_sysconf.cores_per_node; + } + +if (max_cpus < loongson_sysconf.nr_cpus) { +pr_err ("SMP Groups are less than the number of CPUs\n" ); + loongson_sysconf.nr_cpus = max_cpus ? max_cpus :1 ; + } +/* For unified kernel, NR_CPUS is the maximum possible value, * loongson_sysconf.nr_cpus is the really present value */ + i =0 ;while (i < loongson_sysconf.nr_cpus) {if (loongson_sysconf.reserved_cpus_mask & (1 <<i)) {/* Reserved physical CPU cores */
@@ -505,14 +518,14 @@ static void __init loongson3_smp_setup(v __cpu_logical_map[num] =-1 ; num++; } -csr_ipi_probe ();ipi_set0_regs_init ();ipi_clear0_regs_init ();ipi_status0_regs_init ();ipi_en0_regs_init ();ipi_mailbox_buf_init (); -ipi_write_enable (0 ); +if (smp_group[0 ]) +ipi_write_enable (0 );cpu_set_core (&cpu_data[0 ],cpu_logical_map (0 ) % loongson_sysconf.cores_per_package);
@@ -829,6 +842,9 @@ static int loongson3_disable_clock(unsiguint64_t core_id =cpu_core (&cpu_data[cpu]);uint64_t package_id = cpu_data[cpu].package; +if (!loongson_chipcfg[package_id] || !loongson_freqctrl[package_id]) +return 0 ; +if ((read_c0_prid () &PRID_REV_MASK ) ==PRID_REV_LOONGSON3A_R1 ) {LOONGSON_CHIPCFG (package_id) &= ~(1 << (12 + core_id)); }else {
@@ -843,6 +859,9 @@ static int loongson3_enable_clock(unsignuint64_t core_id =cpu_core (&cpu_data[cpu]);uint64_t package_id = cpu_data[cpu].package; +if (!loongson_chipcfg[package_id] || !loongson_freqctrl[package_id]) +return 0 ; +if ((read_c0_prid () &PRID_REV_MASK ) ==PRID_REV_LOONGSON3A_R1 ) {LOONGSON_CHIPCFG (package_id) |=1 << (12 + core_id); }else {
Greg Kroah-Hartman
maintainerPATCH 379/440 drm/etnaviv: dont block scheduler when GPU is still active
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lucas Stach <[email protected]>
commit 704d3d60fec451f37706368d9d3e320322978986 upstream.
Since 45ecaea73883 ("drm/sched: Partial revert of 'drm/sched: Keep s_fence->parent pointer'") still active jobs aren't put back in the pending list on drm_sched_start(), as they don't have a active parent fence anymore, so if the GPU is still working and the timeout is extended, all currently active jobs will be freed.
To avoid prematurely freeing jobs that are still active on the GPU, don't block the scheduler until we are fully committed to actually reset the GPU.
As the current job is already removed from the pending list and will not be put back when drm_sched_start() isn't called, we must make sure to put the job back on the pending list when extending the timeout.
--- drivers/gpu/drm/etnaviv/etnaviv_sched.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_sched.c +4 -5
@@ -38,9 +38,6 @@ static enum drm_gpu_sched_stat etnaviv_su32 dma_addr;int change; -/* block scheduler */ -drm_sched_stop (&gpu->sched, sched_job); -/* * If the GPU managed to complete this jobs fence, the timout is * spurious. Bail out.
@@ -62,6 +59,9 @@ static enum drm_gpu_sched_stat etnaviv_s goto out_no_timeout; } +/* block scheduler */ +drm_sched_stop (&gpu->sched, sched_job); +if (sched_job)drm_sched_increase_karma (sched_job);
@@ -75,8 +75,7 @@ static enum drm_gpu_sched_stat etnaviv_sreturn DRM_GPU_SCHED_STAT_NOMINAL ; out_no_timeout: -/* restart scheduler after GPU is usable again */ -drm_sched_start (&gpu->sched, true); +list_add (&sched_job->list, &sched_job->sched->pending_list);return DRM_GPU_SCHED_STAT_NOMINAL ; }
Greg Kroah-Hartman
maintainerPATCH 380/440 drm/panfrost: Mark simple_ondemand governor as softdep
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dragan Simic <[email protected]>
commit 80f4e62730a91572b7fdc657f7bb747e107ae308 upstream.
Panfrost DRM driver uses devfreq to perform DVFS, while using simple_ondemand devfreq governor by default. This causes driver initialization to fail on boot when simple_ondemand governor isn't built into the kernel statically, as a result of the missing module dependency and, consequently, the required governor module not being included in the initial ramdisk. Thus, let's mark simple_ondemand governor as a softdep for Panfrost, to have its kernel module included in the initial ramdisk.
This is a rather longstanding issue that has forced distributions to build devfreq governors statically into their kernels, [1][2] or has forced users to introduce some unnecessary workarounds. [3]
For future reference, not having support for the simple_ondemand governor in the initial ramdisk produces errors in the kernel log similar to these below, which were taken from a Pine64 RockPro64:
panfrost ff9a0000.gpu: [drm:panfrost_devfreq_init [panfrost]] *ERROR* Couldn't initialize GPU devfreq panfrost ff9a0000.gpu: Fatal error during GPU init
panfrost: probe of ff9a0000.gpu failed with error -22
Having simple_ondemand marked as a softdep for Panfrost may not resolve this issue for all Linux distributions. In particular, it will remain unresolved for the distributions whose utilities for the initial ramdisk generation do not handle the available softdep information [4] properly yet. However, some Linux distributions already handle softdeps properly while generating their initial ramdisks, [5] and this is a prerequisite step in the right direction for the distributions that don't handle them properly yet.
[1] https://gitlab.manjaro.org/manjaro-arm/packages/core/linux/-/blob/linux61/config?ref_type=heads#L8180
[2] https://salsa.debian.org/kernel-team/linux/-/merge_requests/1066
[3] https://forum.pine64.org/showthread.php?tid=15458
[4] https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/commit/?id=49d8e0b59052999de577ab732b719cfbeb89504d
[5] https://github.com/archlinux/mkinitcpio/commit/97ac4d37aae084a050be512f6d8f4489054668ad
--- drivers/gpu/drm/panfrost/panfrost_drv.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/panfrost/panfrost_drv.c +1 -0
@@ -704,3 +704,4 @@ module_platform_driver(panfrost_driver);MODULE_AUTHOR ("Panfrost Project Developers" );MODULE_DESCRIPTION ("Panfrost DRM Driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_SOFTDEP ("pre: governor_simpleondemand" );
Greg Kroah-Hartman
maintainerPATCH 381/440 rbd: rename RBD_LOCK_STATE_RELEASING and releasing_wait
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit f5c466a0fdb2d9f3650d2e3911b0735f17ba00cf upstream.
... to RBD_LOCK_STATE_QUIESCING and quiescing_wait to recognize that this state and the associated completion are backing rbd_quiesce_lock(), which isn't specific to releasing the lock.
While exclusive lock does get quiesced before it's released, it also gets quiesced before an attempt to update the cookie is made and there the lock is not released as long as ceph_cls_set_cookie() succeeds.
--- drivers/block/rbd.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/block/rbd.c +10 -10
@@ -362,7 +362,7 @@ enum rbd_watch_state {enum rbd_lock_state {RBD_LOCK_STATE_UNLOCKED ,RBD_LOCK_STATE_LOCKED , -RBD_LOCK_STATE_RELEASING , +RBD_LOCK_STATE_QUIESCING , };/* WatchNotify::ClientId */
@@ -422,7 +422,7 @@ struct rbd_device {struct list_head running_list;struct completion acquire_wait;int acquire_err; -struct completion releasing_wait; +struct completion quiescing_wait;spinlock_t object_map_lock;u8 *object_map;
@@ -525,7 +525,7 @@ static bool __rbd_is_lock_owner(struct rlockdep_assert_held (&rbd_dev->lock_rwsem);return rbd_dev->lock_state ==RBD_LOCK_STATE_LOCKED || - rbd_dev->lock_state ==RBD_LOCK_STATE_RELEASING ; + rbd_dev->lock_state ==RBD_LOCK_STATE_QUIESCING ; }static bool rbd_is_lock_owner (struct rbd_device *rbd_dev)
@@ -3459,12 +3459,12 @@ static void rbd_lock_del_request(structspin_lock (&rbd_dev->lock_lists_lock);if (!list_empty (&img_req->lock_item)) {list_del_init (&img_req->lock_item); - need_wakeup = (rbd_dev->lock_state ==RBD_LOCK_STATE_RELEASING && + need_wakeup = (rbd_dev->lock_state ==RBD_LOCK_STATE_QUIESCING &&list_empty (&rbd_dev->running_list)); }spin_unlock (&rbd_dev->lock_lists_lock);if (need_wakeup) -complete (&rbd_dev->releasing_wait); +complete (&rbd_dev->quiescing_wait); }static int rbd_img_exclusive_lock (struct rbd_img_request *img_req)
@@ -4182,16 +4182,16 @@ static bool rbd_quiesce_lock(struct rbd_/* * Ensure that all in-flight IO is flushed. */ - rbd_dev->lock_state =RBD_LOCK_STATE_RELEASING ; -rbd_assert (!completion_done (&rbd_dev->releasing_wait)); + rbd_dev->lock_state =RBD_LOCK_STATE_QUIESCING ; +rbd_assert (!completion_done (&rbd_dev->quiescing_wait));if (list_empty (&rbd_dev->running_list))return true;up_write (&rbd_dev->lock_rwsem); -wait_for_completion (&rbd_dev->releasing_wait); +wait_for_completion (&rbd_dev->quiescing_wait);down_write (&rbd_dev->lock_rwsem); -if (rbd_dev->lock_state !=RBD_LOCK_STATE_RELEASING ) +if (rbd_dev->lock_state !=RBD_LOCK_STATE_QUIESCING )return false;rbd_assert (list_empty (&rbd_dev->running_list));
@@ -5383,7 +5383,7 @@ static struct rbd_device *__rbd_dev_creaINIT_LIST_HEAD (&rbd_dev->acquiring_list);INIT_LIST_HEAD (&rbd_dev->running_list);init_completion (&rbd_dev->acquire_wait); -init_completion (&rbd_dev->releasing_wait); +init_completion (&rbd_dev->quiescing_wait);spin_lock_init (&rbd_dev->object_map_lock);
Greg Kroah-Hartman
maintainerPATCH 382/440 rbd: dont assume RBD_LOCK_STATE_LOCKED for exclusive mappings
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilya Dryomov <[email protected]>
commit 2237ceb71f89837ac47c5dce2aaa2c2b3a337a3c upstream.
Every time a watch is reestablished after getting lost, we need to update the cookie which involves quiescing exclusive lock. For this, we transition from RBD_LOCK_STATE_LOCKED to RBD_LOCK_STATE_QUIESCING roughly for the duration of rbd_reacquire_lock() call. If the mapping is exclusive and I/O happens to arrive in this time window, it's failed with EROFS (later translated to EIO) based on the wrong assumption in rbd_img_exclusive_lock() -- "lock got released?" check there stopped making sense with commit a2b1da09793d ("rbd: lock should be quiesced on reacquire").
To make it worse, any such I/O is added to the acquiring list before EROFS is returned and this sets up for violating rbd_lock_del_request() precondition that the request is either on the running list or not on any list at all -- see commit ded080c86b3f ("rbd: don't move requests to the running list on errors"). rbd_lock_del_request() ends up processing these requests as if they were on the running list which screws up quiescing_wait completion counter and ultimately leads to
rbd_assert(!completion_done(&rbd_dev->quiescing_wait));
being triggered on the next watch error.
--- drivers/block/rbd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/block/rbd.c +5 -5
@@ -3458,6 +3458,7 @@ static void rbd_lock_del_request(structlockdep_assert_held (&rbd_dev->lock_rwsem);spin_lock (&rbd_dev->lock_lists_lock);if (!list_empty (&img_req->lock_item)) { +rbd_assert (!list_empty (&rbd_dev->running_list));list_del_init (&img_req->lock_item); need_wakeup = (rbd_dev->lock_state ==RBD_LOCK_STATE_QUIESCING &&list_empty (&rbd_dev->running_list));
@@ -3477,11 +3478,6 @@ static int rbd_img_exclusive_lock(structif (rbd_lock_add_request (img_req))return 1 ; -if (rbd_dev->opts->exclusive) { -WARN_ON (1 );/* lock got released? */ -return -EROFS ; - } -/* * Note the use of mod_delayed_work() in rbd_acquire_lock() * and cancel_delayed_work() in wake_lock_waiters().
@@ -4602,6 +4598,10 @@ static void rbd_reacquire_lock(struct rbrbd_warn (rbd_dev,"failed to update lock cookie: %d" , ret); +if (rbd_dev->opts->exclusive) +rbd_warn (rbd_dev, +"temporarily releasing lock on exclusive mapping" ); +/* * Lock cookie cannot be updated on older OSDs, so do * a manual release and queue an acquire.
Greg Kroah-Hartman
maintainerPATCH 383/440 bpf: Synchronize dispatcher update with bpf_dispatcher_xdp_func
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <[email protected]>
commit 4121d4481b72501aa4d22680be4ea1096d69d133 upstream.
Hao Sun reported crash in dispatcher image [1].
Currently we don't have any sync between bpf_dispatcher_update and bpf_dispatcher_xdp_func, so following race is possible:
cpu 0: cpu 1:
bpf_prog_run_xdp
...
bpf_dispatcher_xdp_func
in image at offset 0x0
bpf_dispatcher_update
update image at offset 0x800
bpf_dispatcher_update
update image at offset 0x0
in image at offset 0x0 -> crashFixing this by synchronizing dispatcher image update (which is done in bpf_dispatcher_update function) with bpf_dispatcher_xdp_func that reads and execute the dispatcher image.
Calling synchronize_rcu after updating and installing new image ensures that readers leave old image before it's changed in the next dispatcher update. The update itself is locked with dispatcher's mutex.
The bpf_prog_run_xdp is called under local_bh_disable and synchronize_rcu will wait for it to leave [2].
[1] https://lore.kernel.org/bpf/Y5SFho7ZYXr9ifRn@krava/T/#m00c29ece654bc9f332a17df493bbca33e702896c
[2] https://lore.kernel.org/bpf/[email protected]/T/#mff43e2c003ae99f4a38f353c7969be4c7162e877
--- kernel/bpf/dispatcher.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/bpf/dispatcher.c +5 -0
@@ -125,6 +125,11 @@ static void bpf_dispatcher_update(struct__BPF_DISPATCHER_UPDATE (d, new ?: (void *)&bpf_dispatcher_nop_func); +/* Make sure all the callers executing the previous/old half of the +* image leave it, so following update call can modify it safely. +*/ +synchronize_rcu (); +if (new) d->image_off = noff; }
Greg Kroah-Hartman
maintainerPATCH 384/440 Bluetooth: btusb: Add RTL8852BE device 0489:e125 to device tables
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hilda Wu <[email protected]>
commit 295ef07a9dae6182ad4b689aa8c6a7dbba21474c upstream.
Add the support ID 0489:e125 to usb_device_id table for Realtek RTL8852B chip.
The device info from /sys/kernel/debug/usb/devices as below.
T: Bus=01 Lev=01 Prnt=01 Port=07 Cnt=03 Dev#= 5 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0489 ProdID=e125 Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -545,6 +545,8 @@ static const struct usb_device_id blackl BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3571), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0489, 0xe125), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH },/* Realtek Bluetooth devices */ { USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01),
Greg Kroah-Hartman
maintainerPATCH 385/440 Bluetooth: btusb: Add Realtek RTL8852BE support ID 0x13d3:0x3591
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
commit 473a89b4ed7fd52a419340f7c540d5c8fc96fc75 upstream.
Add the support ID(0x13d3, 0x3591) to usb_device_id table for Realtek RTL8852BE.
The device table is as follows:
T: Bus=01 Lev=02 Prnt=03 Port=00 Cnt=01 Dev#= 5 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=13d3 ProdID=3591 Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -545,6 +545,8 @@ static const struct usb_device_id blackl BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3571), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x13d3, 0x3591), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x0489, 0xe125), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH },
Greg Kroah-Hartman
maintainerPATCH 386/440 nilfs2: handle inconsistent state in nilfs_btnode_create_block()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
commit 4811f7af6090e8f5a398fbdd766f903ef6c0d787 upstream.
Syzbot reported that a buffer state inconsistency was detected in nilfs_btnode_create_block(), triggering a kernel bug.
It is not appropriate to treat this inconsistency as a bug; it can occur if the argument block address (the buffer index of the newly created block) is a virtual block number and has been reallocated due to corruption of the bitmap used to manage its allocation state.
So, modify nilfs_btnode_create_block() and its callers to treat it as a possible filesystem error, rather than triggering a kernel bug.
--- fs/nilfs2/btnode.c | 25 ++++++++++++++++++++----- fs/nilfs2/btree.c | 4 ++-- 2 files changed, 22 insertions(+), 7 deletions(-)
fs/nilfs2/btnode.c +20 -5
@@ -51,12 +51,21 @@ nilfs_btnode_create_block(struct address bh =nilfs_grab_buffer (inode, btnc, blocknr,BIT (BH_NILFS_Node));if (unlikely (!bh)) -return NULL ; +return ERR_PTR (-ENOMEM );if (unlikely (buffer_mapped (bh) ||buffer_uptodate (bh) ||buffer_dirty (bh))) { -brelse (bh); -BUG (); +/* +* The block buffer at the specified new address was already +* in use. This can happen if it is a virtual block number +* and has been reallocated due to corruption of the bitmap +* used to manage its allocation state (if not, the buffer +* clearing of an abandoned b-tree node is missing somewhere). +*/ +nilfs_error (inode->i_sb, +"state inconsistency probably due to duplicate use of b-tree node block address %llu (ino=%lu)" , + (unsigned long long )blocknr, inode->i_ino); + goto failed; }memset (bh->b_data,0 ,i_blocksize (inode)); bh->b_bdev = inode->i_sb->s_bdev;
@@ -67,6 +76,12 @@ nilfs_btnode_create_block(struct addressunlock_page (bh->b_page);put_page (bh->b_page);return bh; + +failed: +unlock_page (bh->b_page); +put_page (bh->b_page); +brelse (bh); +return ERR_PTR (-EIO ); } int nilfs_btnode_submit_block(struct address_space *btnc, __u64 blocknr,
@@ -217,8 +232,8 @@ retry: } nbh =nilfs_btnode_create_block (btnc, newkey); -if (!nbh) -return -ENOMEM ; +if (IS_ERR (nbh)) +return PTR_ERR (nbh);BUG_ON (nbh == obh); ctxt->newbh = nbh;
fs/nilfs2/btree.c +2 -2
@@ -63,8 +63,8 @@ static int nilfs_btree_get_new_block(construct buffer_head *bh; bh =nilfs_btnode_create_block (btnc, ptr); -if (!bh) -return -ENOMEM ; +if (IS_ERR (bh)) +return PTR_ERR (bh);set_buffer_nilfs_volatile (bh); *bhp = bh;
Greg Kroah-Hartman
maintainerPATCH 387/440 PCI: Introduce cleanup helpers for device reference counts and locks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ira Weiny <[email protected]>
commit ced085ef369af7a2b6da962ec2fbd01339f60693 upstream.
The "goto error" pattern is notorious for introducing subtle resource leaks. Use the new cleanup.h helpers for PCI device reference counts and locks.
Similar to the new put_device() and device_lock() cleanup helpers, __free(put_device) and guard(device), define the same for PCI devices, __free(pci_dev_put) and guard(pci_dev). These helpers eliminate the need for "goto free;" and "goto unlock;" patterns. For example, A 'struct pci_dev *' instance declared as:
struct pci_dev *pdev __free(pci_dev_put) = NULL;
...will automatically call pci_dev_put() if @pdev is non-NULL when @pdev goes out of scope (automatic variable scope). If a function wants to invoke pci_dev_put() on error, but return @pdev on success, it can do:
return no_free_ptr(pdev);
...or:
return_ptr(pdev);
For potential cleanup opportunity there are 587 open-coded calls to pci_dev_put() in the kernel with 65 instances within 10 lines of a goto statement with the CXL driver threatening to add another one.
The guard() helper holds the associated lock for the remainder of the current scope in which it was invoked. So, for example:
func(...)
{
if (...) {
...
guard(pci_dev); /* pci_dev_lock() invoked here */
...
} /* <- implied pci_dev_unlock() triggered here */
}There are 15 invocations of pci_dev_unlock() in the kernel with 5 instances within 10 lines of a goto statement. Again, the CXL driver is threatening to add another.
Introduce these helpers to preclude the addition of new more error prone goto put; / goto unlock; sequences. For now, these helpers are used in drivers/cxl/pci.c to allow ACPI error reports to be fed back into the CXL driver associated with the PCI device identified in the report.
--- include/linux/pci.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/pci.h +2 -0
@@ -1138,6 +1138,7 @@ int pci_get_interrupt_pin(struct pci_devu8 pci_common_swizzle (struct pci_dev *dev,u8 *pinp);struct pci_dev *pci_dev_get (struct pci_dev *dev);void pci_dev_put (struct pci_dev *dev); +DEFINE_FREE(pci_dev_put, struct pci_dev *, if (_T) pci_dev_put(_T))void pci_remove_bus (struct pci_bus *b);void pci_stop_and_remove_bus_device (struct pci_dev *dev);void pci_stop_and_remove_bus_device_locked (struct pci_dev *dev);
@@ -1746,6 +1747,7 @@ void pci_cfg_access_unlock(struct pci_devoid pci_dev_lock (struct pci_dev *dev);int pci_dev_trylock (struct pci_dev *dev);void pci_dev_unlock (struct pci_dev *dev); +DEFINE_GUARD(pci_dev, struct pci_dev *, pci_dev_lock(_T), pci_dev_unlock(_T))/* * PCI domain support. Sometimes called PCI segment (eg by ACPI),
Greg Kroah-Hartman
maintainerPATCH 388/440 PCI/DPC: Fix use-after-free on concurrent DPC and hot-removal
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit 11a1f4bc47362700fcbde717292158873fb847ed upstream.
Keith reports a use-after-free when a DPC event occurs concurrently to hot-removal of the same portion of the hierarchy:
The dpc_handler() awaits readiness of the secondary bus below the Downstream Port where the DPC event occurred. To do so, it polls the config space of the first child device on the secondary bus. If that child device is concurrently removed, accesses to its struct pci_dev cause the kernel to oops.
That's because pci_bridge_wait_for_secondary_bus() neglects to hold a reference on the child device. Before v6.3, the function was only called on resume from system sleep or on runtime resume. Holding a reference wasn't necessary back then because the pciehp IRQ thread could never run concurrently. (On resume from system sleep, IRQs are not enabled until after the resume_noirq phase. And runtime resume is always awaited before a PCI device is removed.)
However starting with v6.3, pci_bridge_wait_for_secondary_bus() is also called on a DPC event. Commit 53b54ad074de ("PCI/DPC: Await readiness of secondary bus after reset"), which introduced that, failed to appreciate that pci_bridge_wait_for_secondary_bus() now needs to hold a reference on the child device because dpc_handler() and pciehp may indeed run concurrently. The commit was backported to v5.10+ stable kernels, so that's the oldest one affected.
Add the missing reference acquisition.
Abridged stack trace:
BUG: unable to handle page fault for address: 00000000091400c0 CPU: 15 PID: 2464 Comm: irq/53-pcie-dpc 6.9.0 RIP: pci_bus_read_config_dword+0x17/0x50 pci_dev_wait() pci_bridge_wait_for_secondary_bus() dpc_reset_link() pcie_do_recovery() dpc_handler()
--- drivers/pci/pci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/pci.c +3 -3
@@ -5007,7 +5007,7 @@ static int pci_bus_max_d3cold_delay(consint pci_bridge_wait_for_secondary_bus (struct pci_dev *dev,char *reset_type,int timeout) { -struct pci_dev *child; + struct pci_dev *child __free(pci_dev_put) = NULL;int delay;if (pci_dev_is_disconnected (dev))
@@ -5036,8 +5036,8 @@ int pci_bridge_wait_for_secondary_bus(streturn 0 ; } - child = list_first_entry(&dev->subordinate->devices, struct pci_dev, - bus_list); + child =pci_dev_get (list_first_entry (&dev->subordinate->devices, + struct pci_dev, bus_list));up_read (&pci_bus_sem);/*
Greg Kroah-Hartman
maintainerPATCH 389/440 io_uring/io-wq: limit retrying worker initialisation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
commit 0453aad676ff99787124b9b3af4a5f59fbe808e2 upstream.
If io-wq worker creation fails, we retry it by queueing up a task_work. tasK_work is needed because it should be done from the user process context. The problem is that retries are not limited, and if queueing a task_work is the reason for the failure, we might get into an infinite loop.
It doesn't seem to happen now but it would with the following patch executing task_work in the freezer's loop. For now, arbitrarily limit the number of attempts to create a worker.
--- io_uring/io-wq.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
io_uring/io-wq.c +7 -3
@@ -22,6 +22,7 @@#include "io_uring.h" #define WORKER_IDLE_TIMEOUT (5 * HZ) +#define WORKER_INIT_LIMIT 3enum {IO_WORKER_F_UP =1 ,/* up and active */
@@ -58,6 +59,7 @@ struct io_worker {unsigned long create_state;struct callback_head create_work;int create_index; +int init_retries;union {struct rcu_head rcu;
@@ -729,7 +731,7 @@ static bool io_wq_work_match_all(structreturn true; } -static inline bool io_should_retry_thread (long err) +static inline bool io_should_retry_thread (struct io_worker *worker,long err) {/* * Prevent perpetual task_work retry, if the task (or its group) is
@@ -737,6 +739,8 @@ static inline bool io_should_retry_threa*/ if (fatal_signal_pending (current))return false; +if (worker->init_retries++ >=WORKER_INIT_LIMIT ) +return false;switch (err) {case -EAGAIN :
@@ -763,7 +767,7 @@ static void create_worker_cont(struct caio_init_new_worker (wqe, worker, tsk);io_worker_release (worker);return ; - }else if (!io_should_retry_thread (PTR_ERR (tsk))) { + }else if (!io_should_retry_thread (worker,PTR_ERR (tsk))) {struct io_wqe_acct *acct =io_wqe_get_acct (worker);atomic_dec (&acct->nr_running);
@@ -830,7 +834,7 @@ fail: tsk =create_io_thread (io_wqe_worker, worker, wqe->node);if (!IS_ERR (tsk)) {io_init_new_worker (wqe, worker, tsk); - }else if (!io_should_retry_thread (PTR_ERR (tsk))) { + }else if (!io_should_retry_thread (worker,PTR_ERR (tsk))) {kfree (worker); goto fail; }else {
Greg Kroah-Hartman
maintainerPATCH 390/440 wifi: mac80211: Allow NSS change only up to capability
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rameshkumar Sundaram <[email protected]>
commit 57b341e9ab13e5688491bfd54f8b5502416c8905 upstream.
Stations can update bandwidth/NSS change in
VHT action frame with action type Operating Mode Notification. (IEEE Std 802.11-2020 - 9.4.1.53 Operating Mode field)
For Operating Mode Notification, an RX NSS change to a value greater than AP's maximum NSS should not be allowed. During fuzz testing, by forcefully sending VHT Op. mode notif. frames from STA with random rx_nss values, it is found that AP accepts rx_nss values greater that APs maximum NSS instead of discarding such NSS change.
Hence allow NSS change only up to maximum NSS that is negotiated and capped to AP's capability during association.
--- net/mac80211/vht.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
net/mac80211/vht.c +20 -5
@@ -637,7 +637,7 @@ u32 __ieee80211_vht_handle_opmode(structenum ieee80211_sta_rx_bandwidth new_bw;struct sta_opmode_info sta_opmode = {};u32 changed =0 ; -u8 nss; +u8 nss, cur_nss;/* ignore - no support for BF yet */ if (opmode &IEEE80211_OPMODE_NOTIF_RX_NSS_TYPE_BF )
@@ -648,10 +648,25 @@ u32 __ieee80211_vht_handle_opmode(struct nss +=1 ;if (link_sta->pub->rx_nss != nss) { - link_sta->pub->rx_nss = nss; - sta_opmode.rx_nss = nss; - changed |=IEEE80211_RC_NSS_CHANGED ; - sta_opmode.changed |=STA_OPMODE_N_SS_CHANGED ; + cur_nss = link_sta->pub->rx_nss; +/* Reset rx_nss and call ieee80211_sta_set_rx_nss() which +* will set the same to max nss value calculated based on capability. +*/ + link_sta->pub->rx_nss =0 ; +ieee80211_sta_set_rx_nss (link_sta); +/* Do not allow an nss change to rx_nss greater than max_nss +* negotiated and capped to APs capability during association. +*/ +if (nss <= link_sta->pub->rx_nss) { + link_sta->pub->rx_nss = nss; + sta_opmode.rx_nss = nss; + changed |=IEEE80211_RC_NSS_CHANGED ; + sta_opmode.changed |=STA_OPMODE_N_SS_CHANGED ; + }else { + link_sta->pub->rx_nss = cur_nss; +pr_warn_ratelimited ("Ignoring NSS change in VHT Operating Mode Notification from %pM with invalid nss %d" , + link_sta->pub->addr, nss); + } }switch (opmode &IEEE80211_OPMODE_NOTIF_CHANWIDTH_MASK ) {
Greg Kroah-Hartman
maintainerPATCH 391/440 wifi: mac80211: track capability/opmode NSS separately
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit a8bca3e9371dc5e276af4168be099b2a05554c2a upstream.
We're currently tracking rx_nss for each station, and that is meant to be initialized to the capability NSS and later reduced by the operating mode notification NSS.
However, we're mixing up capabilities and operating mode NSS in the same variable. This forces us to recalculate the NSS capability on operating mode notification RX, which is a bit strange; due to the previous fix I had to never keep rx_nss as zero, it also means that the capa is never taken into account properly.
Fix all this by storing the capability value, that can be recalculated unconditionally whenever needed, and storing the operating mode notification NSS separately, taking it into account when assigning the final rx_nss value.
--- net/mac80211/cfg.c | 2 - net/mac80211/ieee80211_i.h | 2 - net/mac80211/rate.c | 2 - net/mac80211/sta_info.h | 6 ++++- net/mac80211/vht.c | 46 +++++++++++++++++++++------------------------ 5 files changed, 30 insertions(+), 28 deletions(-)
net/mac80211/cfg.c +1 -1
@@ -1775,7 +1775,7 @@ static int sta_link_apply_parameters(str sband->band); } -ieee80211_sta_set_rx_nss (link_sta); +ieee80211_sta_init_nss (link_sta);return ret; }
net/mac80211/ieee80211_i.h +1 -1
@@ -2071,7 +2071,7 @@ enum ieee80211_sta_rx_bandwidth ieee80211_sta_cap_rx_bw(struct link_sta_info *link_sta);enum ieee80211_sta_rx_bandwidth ieee80211_sta_cur_vht_bw (struct link_sta_info *link_sta); -void ieee80211_sta_set_rx_nss (struct link_sta_info *link_sta); +void ieee80211_sta_init_nss (struct link_sta_info *link_sta);enum ieee80211_sta_rx_bandwidth ieee80211_chan_width_to_rx_bw (enum nl80211_chan_width width);enum nl80211_chan_width
net/mac80211/rate.c +1 -1
@@ -37,7 +37,7 @@ void rate_control_rate_init(struct sta_istruct ieee80211_supported_band *sband;struct ieee80211_chanctx_conf *chanctx_conf; -ieee80211_sta_set_rx_nss (&sta->deflink); +ieee80211_sta_init_nss (&sta->deflink);if (!ref)return ;
net/mac80211/sta_info.h +5 -1
@@ -3,7 +3,7 @@* Copyright 2002-2005, Devicescape Software, Inc. * Copyright 2013-2014 Intel Mobile Communications GmbH * Copyright(c) 2015-2017 Intel Deutschland GmbH -* Copyright(c) 2020-2022 Intel Corporation +* Copyright(c) 2020-2024 Intel Corporation */ #ifndef STA_INFO_H
@@ -485,6 +485,8 @@ struct ieee80211_fragment_cache {* same for non-MLD STA. This is used as key for searching link STA * @link_id: Link ID uniquely identifying the link STA. This is 0 for non-MLD * and set to the corresponding vif LinkId for MLD STA +* @op_mode_nss: NSS limit as set by operating mode notification, or 0 +* @capa_nss: NSS limit as determined by local and peer capabilities * @link_hash_node: hash node for rhashtable * @sta: Points to the STA info * @gtk: group keys negotiated with this station, if any
@@ -520,6 +522,8 @@ struct link_sta_info {u8 addr[ETH_ALEN ];u8 link_id; +u8 op_mode_nss, capa_nss; +struct rhlist_head link_hash_node;struct sta_info *sta;
net/mac80211/vht.c +22 -24
81 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 392/440 wifi: mac80211: check basic rates validity
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit ce04abc3fcc62cd5640af981ebfd7c4dc3bded28 upstream.
When userspace sets basic rates, it might send us some rates list that's empty or consists of invalid values only. We're currently ignoring invalid values and then may end up with a rates bitmap that's empty, which later results in a warning.
Reject the call if there were no valid rates.
--- net/mac80211/cfg.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
net/mac80211/cfg.c +11 -10
@@ -2577,6 +2577,17 @@ static int ieee80211_change_bss(struct wif (!sband)return -EINVAL ; +if (params->basic_rates) { +if (!ieee80211_parse_bitrates (sdata->vif.bss_conf.chandef.width, + wiphy->bands[sband->band], + params->basic_rates, + params->basic_rates_len, + &sdata->vif.bss_conf.basic_rates)) +return -EINVAL ; + changed |=BSS_CHANGED_BASIC_RATES ; +ieee80211_check_rate_mask (&sdata->deflink); + } +if (params->use_cts_prot >=0 ) { sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot; changed |=BSS_CHANGED_ERP_CTS_PROT ;
@@ -2600,16 +2611,6 @@ static int ieee80211_change_bss(struct w changed |=BSS_CHANGED_ERP_SLOT ; } -if (params->basic_rates) { -ieee80211_parse_bitrates (sdata->vif.bss_conf.chandef.width, - wiphy->bands[sband->band], - params->basic_rates, - params->basic_rates_len, - &sdata->vif.bss_conf.basic_rates); - changed |=BSS_CHANGED_BASIC_RATES ; -ieee80211_check_rate_mask (&sdata->deflink); - } -if (params->ap_isolate >=0 ) {if (params->ap_isolate) sdata->flags |=IEEE80211_SDATA_DONT_BRIDGE_PACKETS ;
Greg Kroah-Hartman
maintainerPATCH 393/440 kdb: address -Wformat-security warnings
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 70867efacf4370b6c7cdfc7a5b11300e9ef7de64 ]
When -Wformat-security is not disabled, using a string pointer as a format causes a warning:
kernel/debug/kdb/kdb_io.c: In function 'kdb_read':kernel/debug/kdb/kdb_io.c:365:36: error: format not a string literal and no format arguments [-Werror=format-security]
365 | kdb_printf(kdb_prompt_str);
| ^~~~~~~~~~~~~~
kernel/debug/kdb/kdb_io.c: In function 'kdb_getstr':
kernel/debug/kdb/kdb_io.c:456:20: error: format not a string literal and no format arguments [-Werror=format-security]
456 | kdb_printf(kdb_prompt_str);
| ^~~~~~~~~~~~~~Use an explcit "%s" format instead.
--- kernel/debug/kdb/kdb_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/debug/kdb/kdb_io.c +2 -2
@@ -357,7 +357,7 @@ static char *kdb_read(char *buffer, size_t bufsize)if (i >= dtab_count)kdb_printf ("..." );kdb_printf ("\n" ); -kdb_printf (kdb_prompt_str); +kdb_printf ("%s" , kdb_prompt_str);kdb_printf ("%s" , buffer);if (cp != lastchar)kdb_position_cursor (kdb_prompt_str, buffer, cp);
@@ -449,7 +449,7 @@ char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt) {if (prompt && kdb_prompt_str != prompt)strscpy (kdb_prompt_str, prompt,CMD_BUFLEN ); -kdb_printf (kdb_prompt_str); +kdb_printf ("%s" , kdb_prompt_str); kdb_nextline =1 ;/* Prompt and input resets line number */ return kdb_read (buffer, bufsize); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 394/440 kdb: Use the passed prompt in kdb_position_cursor()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Douglas Anderson <[email protected]>
[ Upstream commit e2e821095949cde46256034975a90f88626a2a73 ]
The function kdb_position_cursor() takes in a "prompt" parameter but never uses it. This doesn't _really_ matter since all current callers of the function pass the same value and it's a global variable, but it's a bit ugly. Let's clean it up.
Found by code inspection. This patch is expected to functionally be a no-op.
--- kernel/debug/kdb/kdb_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/debug/kdb/kdb_io.c +1 -1
@@ -193,7 +193,7 @@ char kdb_getchar(void)*/ static void kdb_position_cursor (char *prompt,char *buffer,char *cp) { -kdb_printf ("\r%s" , kdb_prompt_str); +kdb_printf ("\r%s" , prompt);if (cp > buffer)kdb_printf ("%.*s" , (int )(cp - buffer), buffer); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 395/440 jfs: Fix array-index-out-of-bounds in diFree
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
[ Upstream commit f73f969b2eb39ad8056f6c7f3a295fa2f85e313a ]
--- fs/jfs/jfs_imap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/jfs/jfs_imap.c +4 -1
@@ -290,7 +290,7 @@ int diSync(struct inode *ipimap)int diRead (struct inode *ip) {struct jfs_sb_info *sbi =JFS_SBI (ip->i_sb); -int iagno, ino, extno, rc; +int iagno, ino, extno, rc, agno;struct inode *ipimap;struct dinode *dp;struct iag *iagp;
@@ -339,8 +339,11 @@ int diRead(struct inode *ip)/* get the ag for the iag */ agstart =le64_to_cpu (iagp->agstart); + agno =BLKTOAG (agstart,JFS_SBI (ip->i_sb));release_metapage (mp); +if (agno >=MAXAG || agno <0 ) +return -EIO ; rel_inode = (ino & (INOSPERPAGE -1 )); pageno = blkno >> sbi->l2nbperpage;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 396/440 dmaengine: ti: k3-udma: Fix BCHAN count with UHC and HC channels
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vignesh Raghavendra <[email protected]>
[ Upstream commit 372f8b3621294173f539b32976e41e6e12f5decf ]
Unlike other channel counts in CAPx registers, BCDMA BCHAN CNT doesn't include UHC and HC BC channels. So include them explicitly to arrive at total BC channel in the instance.
--- drivers/dma/ti/k3-udma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/dma/ti/k3-udma.c +3 -1
@@ -4423,7 +4423,9 @@ static int udma_get_mmrs(struct platform_device *pdev, struct udma_dev *ud) ud->rchan_cnt =UDMA_CAP2_RCHAN_CNT (cap2);break ;case DMA_TYPE_BCDMA : - ud->bchan_cnt =BCDMA_CAP2_BCHAN_CNT (cap2); + ud->bchan_cnt =BCDMA_CAP2_BCHAN_CNT (cap2) + +BCDMA_CAP3_HBCHAN_CNT (cap3) + +BCDMA_CAP3_UBCHAN_CNT (cap3); ud->tchan_cnt =BCDMA_CAP2_TCHAN_CNT (cap2); ud->rchan_cnt =BCDMA_CAP2_RCHAN_CNT (cap2); ud->rflow_cnt = ud->rchan_cnt;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 397/440 phy: cadence-torrent: Check return value on register read
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
[ Upstream commit 967969cf594ed3c1678a9918d6e9bb2d1591cbe9 ]
cdns_torrent_dp_set_power_state() does not consider that ret might be overwritten. Add return value check of regmap_read_poll_timeout() after register read in cdns_torrent_dp_set_power_state().
--- drivers/phy/cadence/phy-cadence-torrent.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/phy/cadence/phy-cadence-torrent.c +3 -0
@@ -1087,6 +1087,9 @@ static int cdns_torrent_dp_set_power_state(struct cdns_torrent_phy *cdns_phy, ret =regmap_read_poll_timeout (regmap,PHY_PMA_XCVR_POWER_STATE_ACK , read_val, (read_val & mask) == value,0 ,POLL_TIMEOUT_US ); +if (ret) +return ret; +cdns_torrent_dp_write (regmap,PHY_PMA_XCVR_POWER_STATE_REQ ,0x00000000 );ndelay (100 );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 398/440 um: time-travel: fix time-travel-start option
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 7d0a8a490aa3a2a82de8826aaf1dfa38575cb77a ]
We need to have the = as part of the option so that the value can be parsed properly. Also document that it must be given in nanoseconds, not seconds.
--- arch/um/kernel/time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/um/kernel/time.c +2 -2
@@ -874,9 +874,9 @@ int setup_time_travel_start(char *str) return 1; } -__setup ("time-travel-start" , setup_time_travel_start); +__setup ("time-travel-start=" , setup_time_travel_start);__uml_help (setup_time_travel_start, -"time-travel-start=<seconds>\n" +"time-travel-start=<nanoseconds>\n" "Configure the UML instance's wall clock to start at this value rather than\n" "the host's wall clock at the time of UML boot.\n" );#endif
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 399/440 um: time-travel: fix signal blocking race/hang
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 2cf3a3c4b84def5406b830452b1cb8bbfffe0ebe ]
When signals are hard-blocked in order to do time-travel socket processing, we set signals_blocked and then handle SIGIO signals by setting the SIGIO bit in signals_pending. When unblocking, we first set signals_blocked to 0, and then handle all pending signals. We have to set it first, so that we can again properly block/unblock inside the unblock, if the time-travel handlers need to be processed.
Unfortunately, this is racy. We can get into this situation:
// signals_pending = SIGIO_MASK
unblock_signals_hard()
signals_blocked = 0;
if (signals_pending && signals_enabled) {
block_signals();
unblock_signals()
...
sig_handler_common(SIGIO, NULL, NULL);
sigio_handler()
...
sigio_reg_handler()
irq_do_timetravel_handler()
reg->timetravel_handler() ==
vu_req_interrupt_comm_handler()
vu_req_read_message()
vhost_user_recv_req()
vhost_user_recv()
vhost_user_recv_header()
// reads 12 bytes header of
// 20 bytes message
<-- receive SIGIO here <--
sig_handler()
int enabled = signals_enabled; // 1
if ((signals_blocked || !enabled) && (sig == SIGIO)) {
if (!signals_blocked && time_travel_mode == TT_MODE_EXTERNAL)
sigio_run_timetravel_handlers()
_sigio_handler()
sigio_reg_handler()
... as above ...
vhost_user_recv_header()
// reads 8 bytes that were message payload
// as if it were header - but aborts since
// it then gets -EAGAIN
...
--> end signal handler -->
// continue in vhost_user_recv()
// full_read() for 8 bytes payload busy loops
// entire process hangs hereConceptually, to fix this, we need to ensure that the signal handler cannot run while we hard-unblock signals. The thing that makes this more complex is that we can be doing hard-block/unblock while unblocking. Introduce a new signals_blocked_pending variable that we can keep at non-zero as long as pending signals are being processed, then we only need to ensure it's decremented safely and the signal handler will only increment it if it's already non-zero (or signals_blocked is set, of course.)
Note also that only the outermost call to hard-unblock is allowed to decrement signals_blocked_pending, since it could otherwise reach zero in an inner call, and leave the same race happening if the timetravel_handler loops, but that's basically required of it.
--- arch/um/os-Linux/signal.c | 118 +++++++++++++++++++++++++++++++------- 1 file changed, 98 insertions(+), 20 deletions(-)
arch/um/os-Linux/signal.c +98 -20
@@ -8,6 +8,7 @@#include <stdlib.h> #include <stdarg.h> +#include <stdbool.h> #include <errno.h> #include <signal.h> #include <string.h>
@@ -65,9 +66,7 @@ static void sig_handler_common(int sig, struct siginfo *si, mcontext_t *mc)int signals_enabled;#ifdef UML_CONFIG_UML_TIME_TRAVEL_SUPPORT -static int signals_blocked; -#else -#define signals_blocked 0 +static int signals_blocked, signals_blocked_pending;#endif static unsigned int signals_pending;static unsigned int signals_active =0 ;
@@ -76,14 +75,27 @@ void sig_handler(int sig, struct siginfo *si, mcontext_t *mc) {int enabled = signals_enabled; -if ((signals_blocked || !enabled) && (sig ==SIGIO )) { +#ifdef UML_CONFIG_UML_TIME_TRAVEL_SUPPORT +if ((signals_blocked || +__atomic_load_n (&signals_blocked_pending, __ATOMIC_SEQ_CST)) && + (sig ==SIGIO )) { +/* increment so unblock will do another round */ +__atomic_add_fetch (&signals_blocked_pending,1 , + __ATOMIC_SEQ_CST); +return ; + } +#endif + +if (!enabled && (sig ==SIGIO )) {/* * In TT_MODE_EXTERNAL, need to still call time-travel -* handlers unless signals are also blocked for the -* external time message processing. This will mark -* signals_pending by itself (only if necessary.) +* handlers. This will mark signals_pending by itself +* (only if necessary.) +* Note we won't get here if signals are hard-blocked +* (which is handled above), in that case the hard- +* unblock will handle things. */ -if (!signals_blocked && time_travel_mode ==TT_MODE_EXTERNAL ) +if (time_travel_mode ==TT_MODE_EXTERNAL )sigio_run_timetravel_handlers ();else signals_pending |=SIGIO_MASK ;
@@ -380,33 +392,99 @@ int um_set_signals_trace(int enable)#ifdef UML_CONFIG_UML_TIME_TRAVEL_SUPPORT void mark_sigio_pending (void ) { +/* +* It would seem that this should be atomic so +* it isn't a read-modify-write with a signal +* that could happen in the middle, losing the +* value set by the signal. +* +* However, this function is only called when in +* time-travel=ext simulation mode, in which case +* the only signal ever pending is SIGIO, which +* is blocked while this can be called, and the +* timer signal (SIGALRM) cannot happen. +*/ signals_pending |=SIGIO_MASK ; }void block_signals_hard (void ) { -if (signals_blocked) -return ; - signals_blocked =1 ; + signals_blocked++;barrier (); }void unblock_signals_hard (void ) { +static bool unblocking; +if (!signals_blocked) +panic ("unblocking signals while not blocked" ); + +if (--signals_blocked)return ; -/* Must be set to 0 before we check the pending bits etc. */ - signals_blocked =0 ; +/* +* Must be set to 0 before we check pending so the +* SIGIO handler will run as normal unless we're still +* going to process signals_blocked_pending. +*/ barrier (); -if (signals_pending && signals_enabled) { -/* this is a bit inefficient, but that's not really important */ -block_signals (); -unblock_signals (); - }else if (signals_pending &SIGIO_MASK ) { -/* we need to run time-travel handlers even if not enabled */ -sigio_run_timetravel_handlers (); +/* +* Note that block_signals_hard()/unblock_signals_hard() can be called +* within the unblock_signals()/sigio_run_timetravel_handlers() below. +* This would still be prone to race conditions since it's actually a +* call _within_ e.g. vu_req_read_message(), where we observed this +* issue, which loops. Thus, if the inner call handles the recorded +* pending signals, we can get out of the inner call with the real +* signal hander no longer blocked, and still have a race. Thus don't +* handle unblocking in the inner call, if it happens, but only in +* the outermost call - 'unblocking' serves as an ownership for the +* signals_blocked_pending decrement. +*/ +if (unblocking) +return ; + unblocking = true; + +while (__atomic_load_n (&signals_blocked_pending, __ATOMIC_SEQ_CST)) { +if (signals_enabled) { +/* signals are enabled so we can touch this */ + signals_pending |=SIGIO_MASK ; +/* +* this is a bit inefficient, but that's +* not really important +*/ +block_signals (); +unblock_signals (); + }else { +/* +* we need to run time-travel handlers even +* if not enabled +*/ +sigio_run_timetravel_handlers (); + } + +/* +* The decrement of signals_blocked_pending must be atomic so +* that the signal handler will either happen before or after +* the decrement, not during a read-modify-write: +* - If it happens before, it can increment it and we'll +* decrement it and do another round in the loop. +* - If it happens after it'll see 0 for both signals_blocked +* and signals_blocked_pending and thus run the handler as +* usual (subject to signals_enabled, but that's unrelated.) +* +* Note that a call to unblock_signals_hard() within the calls +* to unblock_signals() or sigio_run_timetravel_handlers() above +* will do nothing due to the 'unblocking' state, so this cannot +* underflow as the only one decrementing will be the outermost +* one. +*/ +if (__atomic_sub_fetch (&signals_blocked_pending,1 , + __ATOMIC_SEQ_CST) <0 ) +panic ("signals_blocked_pending underflow" ); } + + unblocking = false; }#endif
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 400/440 f2fs: fix start segno of large section
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sheng Yong <[email protected]>
[ Upstream commit 8c409989678e92e4a737e7cd2bb04f3efb81071a ]
get_ckpt_valid_blocks() checks valid ckpt blocks in current section. It counts all vblocks from the first to the last segment in the large section. However, START_SEGNO() is used to get the first segno in an SIT block. This patch fixes that to get the correct start segno.
--- fs/f2fs/segment.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/segment.h +2 -1
@@ -373,7 +373,8 @@ static inline unsigned int get_ckpt_valid_blocks(struct f2fs_sb_info *sbi, unsigned int segno, bool use_section) {if (use_section &&__is_large_section (sbi)) { -unsigned int start_segno =START_SEGNO (segno); +unsigned int secno =GET_SEC_FROM_SEG (sbi, segno); +unsigned int start_segno =GET_SEG_FROM_SEC (sbi, secno);unsigned int blocks =0 ;int i;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 401/440 watchdog: rzg2l_wdt: Use pm_runtime_resume_and_get()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit f0ba0fcdd19943809b1a7f760f77f6673c6aa7f7 ]
pm_runtime_get_sync() may return with error. In case it returns with error dev->power.usage_count needs to be decremented. pm_runtime_resume_and_get() takes care of this. Thus use it.
Along with it the rzg2l_wdt_set_timeout() function was updated to propagate the result of rzg2l_wdt_start() to its caller.
--- drivers/watchdog/rzg2l_wdt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/watchdog/rzg2l_wdt.c +8 -3
@@ -123,8 +123,11 @@ static void rzg2l_wdt_init_timeout(struct watchdog_device *wdev)static int rzg2l_wdt_start (struct watchdog_device *wdev) {struct rzg2l_wdt_priv *priv =watchdog_get_drvdata (wdev); +int ret; -pm_runtime_get_sync (wdev->parent); + ret =pm_runtime_resume_and_get (wdev->parent); +if (ret) +return ret;/* Initialize time out */ rzg2l_wdt_init_timeout (wdev);
@@ -150,6 +153,8 @@ static int rzg2l_wdt_stop(struct watchdog_device *wdev)static int rzg2l_wdt_set_timeout (struct watchdog_device *wdev,unsigned int timeout) { +int ret =0 ; + wdev->timeout = timeout;/*
@@ -159,10 +164,10 @@ static int rzg2l_wdt_set_timeout(struct watchdog_device *wdev, unsigned int time*/ if (watchdog_active (wdev)) {rzg2l_wdt_stop (wdev); -rzg2l_wdt_start (wdev); + ret =rzg2l_wdt_start (wdev); } -return 0 ; +return ret; } static int rzg2l_wdt_restart(struct watchdog_device *wdev,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 402/440 watchdog: rzg2l_wdt: Check return status of pm_runtime_put()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claudiu Beznea <[email protected]>
[ Upstream commit 471e45a33302852bf79bc140fe418782f50734f6 ]
pm_runtime_put() may return an error code. Check its return status.
Along with it the rzg2l_wdt_set_timeout() function was updated to propagate the result of rzg2l_wdt_stop() to its caller.
--- drivers/watchdog/rzg2l_wdt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/watchdog/rzg2l_wdt.c +9 -2
@@ -144,9 +144,13 @@ static int rzg2l_wdt_start(struct watchdog_device *wdev)static int rzg2l_wdt_stop (struct watchdog_device *wdev) {struct rzg2l_wdt_priv *priv =watchdog_get_drvdata (wdev); +int ret;rzg2l_wdt_reset (priv); -pm_runtime_put (wdev->parent); + + ret =pm_runtime_put (wdev->parent); +if (ret <0 ) +return ret;return 0 ; }
@@ -163,7 +167,10 @@ static int rzg2l_wdt_set_timeout(struct watchdog_device *wdev, unsigned int time* to reset the module) so that it is updated with new timeout values. */ if (watchdog_active (wdev)) { -rzg2l_wdt_stop (wdev); + ret =rzg2l_wdt_stop (wdev); +if (ret) +return ret; + ret =rzg2l_wdt_start (wdev); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 403/440 f2fs: fix to update user block counts in block_operations()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit f06c0f82e38bbda7264d6ef3c90045ad2810e0f3 ]
Commit 59c9081bc86e ("f2fs: allow write page cache when writting cp") allows write() to write data to page cache during checkpoint, so block count fields like .total_valid_block_count, .alloc_valid_block_count and .rf_node_block_count may encounter race condition as below:
CP Thread A
- write_checkpoint
- block_operations
- f2fs_down_write(&sbi->node_change)
- __prepare_cp_block
: ckpt->valid_block_count = .total_valid_block_count
- f2fs_up_write(&sbi->node_change)
- write
- f2fs_preallocate_blocks
- f2fs_map_blocks(,F2FS_GET_BLOCK_PRE_AIO)
- f2fs_map_lock
- f2fs_down_read(&sbi->node_change)
- f2fs_reserve_new_blocks
- inc_valid_block_count
: percpu_counter_add(&sbi->alloc_valid_block_count, count) : sbi->total_valid_block_count += count
- f2fs_up_read(&sbi->node_change)
- do_checkpoint
: sbi->last_valid_block_count = sbi->total_valid_block_count
: percpu_counter_set(&sbi->alloc_valid_block_count, 0)
: percpu_counter_set(&sbi->rf_node_block_count, 0)
- fsync
- need_do_checkpoint
- f2fs_space_for_roll_forward
: alloc_valid_block_count was reset to zero,
so, it may missed last data during checkpoint
Let's change to update .total_valid_block_count, .alloc_valid_block_count and .rf_node_block_count in block_operations(), then their access can be protected by .node_change and .cp_rwsem lock, so that it can avoid above race condition.
--- fs/f2fs/checkpoint.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/f2fs/checkpoint.c +5 -5
@@ -1178,6 +1178,11 @@ static void __prepare_cp_block(struct f2fs_sb_info *sbi) ckpt->valid_node_count =cpu_to_le32 (valid_node_count (sbi)); ckpt->valid_inode_count =cpu_to_le32 (valid_inode_count (sbi)); ckpt->next_free_nid =cpu_to_le32 (last_nid); + +/* update user_block_counts */ + sbi->last_valid_block_count = sbi->total_valid_block_count; +percpu_counter_set (&sbi->alloc_valid_block_count,0 ); +percpu_counter_set (&sbi->rf_node_block_count,0 ); }static bool __need_flush_quota (struct f2fs_sb_info *sbi)
@@ -1569,11 +1574,6 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) start_blk +=NR_CURSEG_NODE_TYPE ; } -/* update user_block_counts */ - sbi->last_valid_block_count = sbi->total_valid_block_count; -percpu_counter_set (&sbi->alloc_valid_block_count,0 ); -percpu_counter_set (&sbi->rf_node_block_count,0 ); -/* Here, we have one bio having CP pack except cp pack 2 page */ f2fs_sync_meta_pages (sbi,META ,LONG_MAX ,FS_CP_META_IO );/* Wait for all dirty meta pages to be submitted for IO */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 404/440 kbuild: avoid build error when single DTB is turned into composite DTB
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit 712aba5543b88996bc4682086471076fbf048927 ]
As commit afa974b77128 ("kbuild: add real-prereqs shorthand for $(filter-out FORCE,$^)") explained, $(real-prereqs) is not just a list of objects when linking a multi-object module. If a single-object module is turned into a multi-object module, $^ (and therefore $(real-prereqs) as well) contains header files recorded in the *.cmd file. Such headers must be filtered out.
Now that a DTB can be built either from a single source or multiple source files, the same issue can occur.
Consider the following scenario:
First, foo.dtb is implemented as a single-blob device tree.
The code looks something like this:
[Sample Code 1]
Makefile:
dtb-y += foo.dtb
foo.dts:
#include <dt-bindings/gpio/gpio.h>
/dts-v1/;
/ { };When it is compiled, .foo.dtb.cmd records that foo.dtb depends on scripts/dtc/include-prefixes/dt-bindings/gpio/gpio.h.
Later, foo.dtb is split into a base and an overlay. The code looks something like this:
[Sample Code 2]
Makefile:
dtb-y += foo.dtb
foo-dtbs := foo-base.dtb foo-addon.dtbo
foo-base.dts:
#include <dt-bindings/gpio/gpio.h>
/dts-v1/;
/ { };foo-addon.dtso:
/dts-v1/;
/plugin/;
/ { };If you rebuild foo.dtb without 'make clean', you will get this error:
Overlay 'scripts/dtc/include-prefixes/dt-bindings/gpio/gpio.h' is incomplete
$(real-prereqs) contains not only foo-base.dtb and foo-addon.dtbo but also scripts/dtc/include-prefixes/dt-bindings/gpio/gpio.h, which is passed to scripts/dtc/fdtoverlay.
--- scripts/Makefile.lib | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
scripts/Makefile.lib +5 -1
@@ -382,8 +382,12 @@ cmd_dtc = $(HOSTCC) -E $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; -d $(depfile).dtc.tmp $(dtc-tmp) ; \ cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) +# NOTE: +# Do not replace $(filter %.dtb %.dtbo, $^) with $(real-prereqs). When a single +# DTB is turned into a multi-blob DTB, $^ will contain header file dependencies +# recorded in the .*.cmd file. quiet_cmd_fdtoverlay = DTOVL $@ - cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(real-prereqs) + cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(filter %.dtb %.dtbo, $^) $(multi-dtb-y): FORCE $(call if_changed,fdtoverlay)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 405/440 libbpf: Fix no-args func prototype BTF dumping syntax
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrii Nakryiko <[email protected]>
[ Upstream commit 189f1a976e426011e6a5588f1d3ceedf71fe2965 ]
For all these years libbpf's BTF dumper has been emitting not strictly valid syntax for function prototypes that have no input arguments.
Instead of int (*blah)() we should emit int (*blah)(void).
This is not normally a problem, but it manifests when we get kfuncs in vmlinux.h that have no input arguments. Due to compiler internal specifics, we get no BTF information for such kfuncs, if they are not declared with proper (void).
The fix is trivial. We also need to adjust a few ancient tests that happily assumed () is correct.
--- tools/lib/bpf/btf_dump.c | 8 +++++--- .../selftests/bpf/progs/btf_dump_test_case_multidim.c | 4 ++-- .../selftests/bpf/progs/btf_dump_test_case_syntax.c | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-)
tools/lib/bpf/btf_dump.c +5 -3
@@ -1521,10 +1521,12 @@ static void btf_dump_emit_type_chain(struct btf_dump *d,* Clang for BPF target generates func_proto with no * args as a func_proto with a single void arg (e.g., * `int (*f)(void)` vs just `int (*f)()`). We are -* going to pretend there are no args for such case. +* going to emit valid empty args (void) syntax for +* such case. Similarly and conveniently, valid +* no args case can be special-cased here as well. */ -if (vlen ==1 && p->type ==0 ) { -btf_dump_printf (d,")" ); +if (vlen ==0 || (vlen ==1 && p->type ==0 )) { +btf_dump_printf (d,"void)" );return ; }
tools/testing/selftests/bpf/progs/btf_dump_test_case_multidim.c +2 -2
@@ -14,9 +14,9 @@ typedef int *ptr_arr_t[6];typedef int *ptr_multiarr_t [7 ][8 ][9 ][10 ]; -typedef int * (*fn_ptr_arr_t [11 ])(); +typedef int * (*fn_ptr_arr_t [11 ])(void ); -typedef int * (*fn_ptr_multiarr_t [12 ][13 ])(); +typedef int * (*fn_ptr_multiarr_t [12 ][13 ])(void );struct root_struct {arr_t _1;
tools/testing/selftests/bpf/progs/btf_dump_test_case_syntax.c +2 -2
@@ -67,7 +67,7 @@ typedef void (*printf_fn_t)(const char *, ...);* `int -> char *` function and returns pointer to a char. Equivalent: * typedef char * (*fn_input_t)(int); * typedef char * (*fn_output_outer_t)(fn_input_t); -* typedef const fn_output_outer_t (* fn_output_inner_t)(); +* typedef const fn_output_outer_t (* fn_output_inner_t)(void); * typedef const fn_output_inner_t fn_ptr_arr2_t[5]; */ /* ----- START-EXPECTED-OUTPUT ----- */
@@ -94,7 +94,7 @@ typedef void (* (*signal_t)(int, void (*)(int)))(int);typedef char * (*fn_ptr_arr1_t [10 ])(int **); -typedef char * (* (*const fn_ptr_arr2_t [5 ])())(char * (*)(int )); +typedef char * (* (*const fn_ptr_arr2_t [5 ])(void ))(char * (*)(int ));struct struct_w_typedefs {int_t a;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 406/440 af_unix: Disable MSG_OOB handling for sockets in sockmap/sockhash
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Luczaj <[email protected]>
[ Upstream commit 638f32604385fd23059985da8de918e9c18f0b98 ]
AF_UNIX socket tracks the most recent OOB packet (in its receive queue) with an oob_skb pointer. BPF redirecting does not account for that: when an OOB packet is moved between sockets, oob_skb is left outdated. This results in a single skb that may be accessed from two different sockets.
Take the easy way out: silently drop MSG_OOB data targeting any socket that is in a sockmap or a sockhash. Note that such silent drop is akin to the fate of redirected skb's scm_fp_list (SCM_RIGHTS, SCM_CREDENTIALS).
For symmetry, forbid MSG_OOB in unix_bpf_recvmsg().
--- net/unix/af_unix.c | 41 ++++++++++++++++++++++++++++++++++++++++- net/unix/unix_bpf.c | 3 +++ 2 files changed, 43 insertions(+), 1 deletion(-)
net/unix/af_unix.c +40 -1
@@ -2710,10 +2710,49 @@ static struct sk_buff *manage_oob(struct sk_buff *skb, struct sock *sk,static int unix_stream_read_skb (struct sock *sk,skb_read_actor_t recv_actor) { +struct unix_sock *u =unix_sk (sk); +struct sk_buff *skb; +int err; +if (unlikely (READ_ONCE (sk->sk_state) !=TCP_ESTABLISHED ))return -ENOTCONN ; -return unix_read_skb (sk, recv_actor); +mutex_lock (&u->iolock); + skb =skb_recv_datagram (sk,MSG_DONTWAIT , &err); +mutex_unlock (&u->iolock); +if (!skb) +return err; + +#if IS_ENABLED (CONFIG_AF_UNIX_OOB ) +if (unlikely (skb ==READ_ONCE (u->oob_skb))) { +bool drop = false; + +unix_state_lock (sk); + +if (sock_flag (sk,SOCK_DEAD )) { +unix_state_unlock (sk); +kfree_skb (skb); +return -ECONNRESET ; + } + +spin_lock (&sk->sk_receive_queue.lock); +if (likely (skb == u->oob_skb)) { +WRITE_ONCE (u->oob_skb,NULL ); + drop = true; + } +spin_unlock (&sk->sk_receive_queue.lock); + +unix_state_unlock (sk); + +if (drop) { +WARN_ON_ONCE (skb_unref (skb)); +kfree_skb (skb); +return -EAGAIN ; + } + } +#endif + +return recv_actor (sk, skb); } static int unix_stream_read_generic(struct unix_stream_read_state *state,
net/unix/unix_bpf.c +3 -0
@@ -54,6 +54,9 @@ static int unix_bpf_recvmsg(struct sock *sk, struct msghdr *msg,struct sk_psock *psock;int copied; +if (flags &MSG_OOB ) +return -EOPNOTSUPP ; +if (!len)return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 407/440 dma: fix call order in dmam_free_coherent
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lance Richardson <[email protected]>
[ Upstream commit 28e8b7406d3a1f5329a03aa25a43aa28e087cb20 ]
dmam_free_coherent() frees a DMA allocation, which makes the freed vaddr available for reuse, then calls devres_destroy() to remove and free the data structure used to track the DMA allocation. Between the two calls, it is possible for a concurrent task to make an allocation with the same vaddr and add it to the devres list.
If this happens, there will be two entries in the devres list with the same vaddr and devres_destroy() can free the wrong entry, triggering the WARN_ON() in dmam_match.
Fix by destroying the devres entry before freeing the DMA allocation.
Tested:
kokonut //net/encryption
http://sponge2/b9145fe6-0f72-4325-ac2f-a84d81075b03
--- kernel/dma/mapping.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/dma/mapping.c +1 -1
@@ -63,8 +63,8 @@ void dmam_free_coherent(struct device *dev, size_t size, void *vaddr, {struct dma_devres match_data = { size, vaddr, dma_handle }; -dma_free_coherent (dev, size, vaddr, dma_handle);WARN_ON (devres_destroy (dev, dmam_release, dmam_match, &match_data)); +dma_free_coherent (dev, size, vaddr, dma_handle); }EXPORT_SYMBOL (dmam_free_coherent);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 408/440 bpf, events: Use prog to emit ksymbol event for main program
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hou Tao <[email protected]>
[ Upstream commit 0be9ae5486cd9e767138c13638820d240713f5f1 ]
Since commit 0108a4e9f358 ("bpf: ensure main program has an extable"), prog->aux->func[0]->kallsyms is left as uninitialized. For BPF programs with subprogs, the symbol for the main program is missing just as shown in the output of perf script below:
ffffffff81284b69 qp_trie_lookup_elem+0xb9 ([kernel.kallsyms]) ffffffffc0011125 bpf_prog_a4a0eb0651e6af8b_lookup_qp_trie+0x5d (bpf...) ffffffff8127bc2b bpf_for_each_array_elem+0x7b ([kernel.kallsyms]) ffffffffc00110a1 +0x25 ()
ffffffff8121a89a trace_call_bpf+0xca ([kernel.kallsyms])
Fix it by always using prog instead prog->aux->func[0] to emit ksymbol event for the main program. After the fix, the output of perf script will be correct:
ffffffff81284b96 qp_trie_lookup_elem+0xe6 ([kernel.kallsyms]) ffffffffc001382d bpf_prog_a4a0eb0651e6af8b_lookup_qp_trie+0x5d (bpf...) ffffffff8127bc2b bpf_for_each_array_elem+0x7b ([kernel.kallsyms]) ffffffffc0013779 bpf_prog_245c55ab25cfcf40_qp_trie_lookup+0x25 (bpf...) ffffffff8121a89a trace_call_bpf+0xca ([kernel.kallsyms])
--- kernel/events/core.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
kernel/events/core.c +13 -15
@@ -9097,21 +9097,19 @@ static void perf_event_bpf_emit_ksymbols(struct bpf_prog *prog,bool unregister = type ==PERF_BPF_EVENT_PROG_UNLOAD ;int i; -if (prog->aux->func_cnt ==0 ) { -perf_event_ksymbol (PERF_RECORD_KSYMBOL_TYPE_BPF , - (u64 )(unsigned long )prog->bpf_func, - prog->jited_len, unregister, - prog->aux->ksym.name); - }else { -for (i =0 ; i < prog->aux->func_cnt; i++) { -struct bpf_prog *subprog = prog->aux->func[i]; - -perf_event_ksymbol ( -PERF_RECORD_KSYMBOL_TYPE_BPF , - (u64 )(unsigned long )subprog->bpf_func, - subprog->jited_len, unregister, - subprog->aux->ksym.name); - } +perf_event_ksymbol (PERF_RECORD_KSYMBOL_TYPE_BPF , + (u64 )(unsigned long )prog->bpf_func, + prog->jited_len, unregister, + prog->aux->ksym.name); + +for (i =1 ; i < prog->aux->func_cnt; i++) { +struct bpf_prog *subprog = prog->aux->func[i]; + +perf_event_ksymbol ( +PERF_RECORD_KSYMBOL_TYPE_BPF , + (u64 )(unsigned long )subprog->bpf_func, + subprog->jited_len, unregister, + subprog->aux->ksym.name); } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 409/440 tools/resolve_btfids: Fix comparison of distinct pointer types warning in resolve_btfids
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liwei Song <[email protected]>
[ Upstream commit 13c9b702e6cb8e406d5fa6b2dca422fa42d2f13e ]
Add a type cast for set8->pairs to fix below compile warning:
main.c: In function 'sets_patch':
main.c:699:50: warning: comparison of distinct pointer types lacks a cast
699 | BUILD_BUG_ON(set8->pairs != &set8->pairs[0].id);
| ^~
--- tools/bpf/resolve_btfids/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bpf/resolve_btfids/main.c +1 -1
@@ -696,7 +696,7 @@ static int sets_patch(struct object *obj)* Make sure id is at the beginning of the pairs * struct, otherwise the below qsort would not work. */ -BUILD_BUG_ON (set8->pairs != &set8->pairs[0 ].id); +BUILD_BUG_ON ((u32 *)set8->pairs != &set8->pairs[0 ].id);qsort (set8->pairs, set8->cnt,sizeof (set8->pairs[0 ]), cmp_id);/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 410/440 MIPS: SMP-CPS: Fix address for GCR_ACCESS register for CM3 and later
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory CLEMENT <[email protected]>
[ Upstream commit a263e5f309f32301e1f3ad113293f4e68a82a646 ]
When the CM block migrated from CM2.5 to CM3.0, the address offset for the Global CSR Access Privilege register was modified. We saw this in the "MIPS64 I6500 Multiprocessing System Programmer's Guide," it is stated that "the Global CSR Access Privilege register is located at offset 0x0120" in section 5.4. It is at least the same for I6400.
This fix allows to use the VP cores in SMP mode if the reset values were modified by the bootloader.
Based on the work of Vladimir Kondratiev <[email protected]> and the feedback from Jiaxun Yang <[email protected]>.
--- arch/mips/include/asm/mips-cm.h | 4 ++++ arch/mips/kernel/smp-cps.c | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-)
arch/mips/include/asm/mips-cm.h +4 -0
@@ -228,6 +228,10 @@ GCR_ACCESSOR_RO(32, 0x0d0, gic_status) GCR_ACCESSOR_RO(32, 0x0f0, cpc_status)#define CM_GCR_CPC_STATUS_EX BIT(0) +/* GCR_ACCESS - Controls core/IOCU access to GCRs */ +GCR_ACCESSOR_RW(32, 0x120, access_cm3) +#define CM_GCR_ACCESS_ACCESSEN GENMASK(7, 0) +/* GCR_L2_CONFIG - Indicates L2 cache configuration when Config5.L2C=1 */ GCR_ACCESSOR_RW(32, 0x130, l2_config)#define CM_GCR_L2_CONFIG_BYPASS BIT(20)
arch/mips/kernel/smp-cps.c +4 -1
@@ -230,7 +230,10 @@ static void boot_core(unsigned int core, unsigned int vpe_id)write_gcr_co_reset_ext_base (CM_GCR_Cx_RESET_EXT_BASE_UEB);/* Ensure the core can access the GCRs */ -set_gcr_access (1 << core); +if (mips_cm_revision () <CM_REV_CM3 ) +set_gcr_access (1 << core); +else +set_gcr_access_cm3 (1 << core);if (mips_cpc_present ()) {/* Reset the core */
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 411/440 ipv4: Fix incorrect source address in Record Route option
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit cc73bbab4b1fb8a4f53a24645871dafa5f81266a ]
The Record Route IP option records the addresses of the routers that routed the packet. In the case of forwarded packets, the kernel performs a route lookup via fib_lookup() and fills in the preferred source address of the matched route.
The lookup is performed with the DS field of the forwarded packet, but using the RT_TOS() macro which only masks one of the two ECN bits. If the packet is ECT(0) or CE, the matched route might be different than the route via which the packet was forwarded as the input path masks both of the ECN bits, resulting in the wrong address being filled in the Record Route option.
Fix by masking both of the ECN bits.
--- net/ipv4/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv4/route.c +1 -1
@@ -1275,7 +1275,7 @@ void ip_rt_get_source(u8 *addr, struct sk_buff *skb, struct rtable *rt)struct flowi4 fl4 = { .daddr = iph->daddr, .saddr = iph->saddr, - .flowi4_tos =RT_TOS (iph->tos), + .flowi4_tos = iph->tos &IPTOS_RT_MASK , .flowi4_oif = rt->dst.dev->ifindex, .flowi4_iif = skb->dev->ifindex, .flowi4_mark = skb->mark,
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 412/440 net: bonding: correctly annotate RCU in bond_should_notify_peers()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 3ba359c0cd6eb5ea772125a7aededb4a2d516684 ]
RCU use in bond_should_notify_peers() looks wrong, since it does rcu_dereference(), leaves the critical section, and uses the pointer after that.
Luckily, it's called either inside a nested RCU critical section or with the RTNL held.
Annotate it with rcu_dereference_rtnl() instead, and remove the inner RCU critical section.
--- drivers/net/bonding/bond_main.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/bonding/bond_main.c +2 -5
@@ -1117,13 +1117,10 @@ static struct slave *bond_find_best_slave(struct bonding *bond)return bestslave; } +/* must be called in RCU critical section or with RTNL held */ static bool bond_should_notify_peers(struct bonding *bond) { - struct slave *slave; - - rcu_read_lock(); - slave = rcu_dereference(bond->curr_active_slave); - rcu_read_unlock(); + struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave); if (!slave || !bond->send_peer_notif || bond->send_peer_notif %
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 413/440 netfilter: nft_set_pipapo_avx2: disable softinterrupts
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit a16909ae9982e931841c456061cb57fbaec9c59e ]
We need to disable softinterrupts, else we get following problem:
1. pipapo_avx2 called from process context; fpu usable
2. preempt_disable() called, pcpu scratchmap in use
3. softirq handles rx or tx, we re-enter pipapo_avx2
4. fpu busy, fallback to generic non-avx version
5. fallback reuses scratch map and index, which are in use by the preempted process
Handle this same way as generic version by first disabling softinterrupts while the scratchmap is in use.
--- net/netfilter/nft_set_pipapo_avx2.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
net/netfilter/nft_set_pipapo_avx2.c +10 -2
@@ -1139,8 +1139,14 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,bool map_index;int i, ret =0 ; -if (unlikely (!irq_fpu_usable ())) -return nft_pipapo_lookup (net, set, key, ext); +local_bh_disable (); + +if (unlikely (!irq_fpu_usable ())) { +bool fallback_res =nft_pipapo_lookup (net, set, key, ext); + +local_bh_enable (); +return fallback_res; + } m =rcu_dereference (priv->match);
@@ -1155,6 +1161,7 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set, scratch = *raw_cpu_ptr (m->scratch);if (unlikely (!scratch)) {kernel_fpu_end (); +local_bh_enable ();return false; }
@@ -1235,6 +1242,7 @@ bool nft_pipapo_avx2_lookup(const struct net *net, const struct nft_set *set,if (i %2 ) scratch->map_index = !map_index;kernel_fpu_end (); +local_bh_enable ();return ret >=0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 414/440 tipc: Return non-zero value from tipc_udp_addr2str() on error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shigeru Yoshida <[email protected]>
[ Upstream commit fa96c6baef1b5385e2f0c0677b32b3839e716076 ]
tipc_udp_addr2str() should return non-zero value if the UDP media address is invalid. Otherwise, a buffer overflow access can occur in tipc_media_addr_printf(). Fix this by returning 1 on an invalid UDP media address.
--- net/tipc/udp_media.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/tipc/udp_media.c +4 -1
@@ -135,8 +135,11 @@ static int tipc_udp_addr2str(struct tipc_media_addr *a, char *buf, int size)snprintf (buf, size,"%pI4:%u" , &ua->ipv4,ntohs (ua->port)); else if (ntohs(ua->proto) == ETH_P_IPV6) snprintf(buf, size, "%pI6:%u", &ua->ipv6, ntohs(ua->port)); - else + else {pr_err ("Invalid UDP media address\n" ); +return 1 ; + } +return 0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 415/440 net: stmmac: Correct byte order of perfect_match
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Simon Horman <[email protected]>
[ Upstream commit e9dbebae2e3c338122716914fe105458f41e3a4a ]
The perfect_match parameter of the update_vlan_hash operation is __le16, and is correctly converted from host byte-order in the lone caller, stmmac_vlan_update().
However, the implementations of this caller, dwxgmac2_update_vlan_hash() and dwxgmac2_update_vlan_hash(), both treat this parameter as host byte order, using the following pattern:
u32 value = ... ... writel(value | perfect_match, ...);
This is not correct because both:
1) value is host byte order; and
2) writel expects a host byte order value as it's first argument
I believe that this will break on big endian systems. And I expect it has gone unnoticed by only being exercised on little endian systems.
The approach taken by this patch is to update the callback, and it's caller to simply use a host byte order value.
Flagged by Sparse.
Compile tested only.
--- drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | 2 +- drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 2 +- drivers/net/ethernet/stmicro/stmmac/hwif.h | 2 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +1 -1
@@ -971,7 +971,7 @@ static void dwmac4_set_mac_loopback(void __iomem *ioaddr, bool enable) }static void dwmac4_update_vlan_hash (struct mac_device_info *hw,u32 hash, -__le16 perfect_match,bool is_double) +u16 perfect_match,bool is_double) {void __iomem *ioaddr = hw->pcsr;u32 value;
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +1 -1
@@ -582,7 +582,7 @@ static int dwxgmac2_rss_configure(struct mac_device_info *hw, }static void dwxgmac2_update_vlan_hash (struct mac_device_info *hw,u32 hash, -__le16 perfect_match,bool is_double) +u16 perfect_match,bool is_double) {void __iomem *ioaddr = hw->pcsr;
drivers/net/ethernet/stmicro/stmmac/hwif.h +1 -1
@@ -366,7 +366,7 @@ struct stmmac_ops { struct stmmac_rss *cfg, u32 num_rxq);/* VLAN */ void (*update_vlan_hash)(struct mac_device_info *hw,u32 hash, -__le16 perfect_match,bool is_double); +u16 perfect_match,bool is_double);void (*enable_vlan)(struct mac_device_info *hw,u32 type); int (*add_hw_vlan_rx_fltr)(struct net_device *dev, struct mac_device_info *hw,
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +2 -2
@@ -6311,7 +6311,7 @@ static u32 stmmac_vid_crc32_le(__le16 vid_le)static int stmmac_vlan_update (struct stmmac_priv *priv,bool is_double) {u32 crc, hash =0 ; -__le16 pmatch =0 ; +u16 pmatch =0 ;int count =0 ;u16 vid =0 ;
@@ -6326,7 +6326,7 @@ static int stmmac_vlan_update(struct stmmac_priv *priv, bool is_double)if (count >2 )/* VID = 0 always passes filter */ return -EOPNOTSUPP ; - pmatch =cpu_to_le16 (vid); + pmatch = vid; hash =0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 416/440 net: nexthop: Initialize all fields in dumped nexthops
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Petr Machata <[email protected]>
[ Upstream commit 6d745cd0e9720282cd291d36b9db528aea18add2 ]
struct nexthop_grp contains two reserved fields that are not initialized by nla_put_nh_group(), and carry garbage. This can be observed e.g. with strace (edited for clarity):
# ip nexthop add id 1 dev lo
# ip nexthop add id 101 group 1
# strace -e recvmsg ip nexthop get id 101
...
recvmsg(... [{nla_len=12, nla_type=NHA_GROUP},
[{id=1, weight=0, resvd1=0x69, resvd2=0x67}]] ...) = 52The fields are reserved and therefore not currently used. But as they are, they leak kernel memory, and the fact they are not just zero complicates repurposing of the fields for new ends. Initialize the full structure.
--- net/ipv4/nexthop.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/ipv4/nexthop.c +4 -3
@@ -676,9 +676,10 @@ static int nla_put_nh_group(struct sk_buff *skb, struct nh_group *nhg) p =nla_data (nla);for (i =0 ; i < nhg->num_nh; ++i) { - p->id = nhg->nh_entries[i].nh->id; - p->weight = nhg->nh_entries[i].weight -1 ; - p +=1 ; + *p++ = (struct nexthop_grp ) { + .id = nhg->nh_entries[i].nh->id, + .weight = nhg->nh_entries[i].weight -1 , + }; }if (nhg->resilient &&nla_put_nh_group_res (skb, nhg))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 417/440 bpf: Fix a segment issue when downgrading gso_size
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fred Li <[email protected]>
[ Upstream commit fa5ef655615a01533035c6139248c5b33aa27028 ]
Linearize the skb when downgrading gso_size because it may trigger a BUG_ON() later when the skb is segmented as described in [1,2].
--- net/core/filter.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
net/core/filter.c +11 -4
@@ -3518,13 +3518,20 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff,if (skb_is_gso (skb)) {struct skb_shared_info *shinfo =skb_shinfo (skb); -/* Due to header grow, MSS needs to be downgraded. */ -if (!(flags &BPF_F_ADJ_ROOM_FIXED_GSO )) -skb_decrease_gso_size (shinfo, len_diff); -/* Header must be checked, and gso_segs recomputed. */ shinfo->gso_type |= gso_type; shinfo->gso_segs =0 ; + +/* Due to header growth, MSS needs to be downgraded. +* There is a BUG_ON() when segmenting the frag_list with +* head_frag true, so linearize the skb after downgrading +* the MSS. +*/ +if (!(flags &BPF_F_ADJ_ROOM_FIXED_GSO )) { +skb_decrease_gso_size (shinfo, len_diff); +if (shinfo->frag_list) +return skb_linearize (skb); + } }return 0 ;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 418/440 mISDN: Fix a use after free in hfcmulti_tx()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 61ab751451f5ebd0b98e02276a44e23a10110402 ]
Don't dereference *sp after calling dev_kfree_skb(*sp).
--- drivers/isdn/hardware/mISDN/hfcmulti.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/isdn/hardware/mISDN/hfcmulti.c +4 -3
@@ -1931,7 +1931,7 @@ hfcmulti_dtmf(struct hfc_multi *hc)static void hfcmulti_tx (struct hfc_multi *hc,int ch) { -int i, ii, temp, len =0 ; +int i, ii, temp, tmp_len, len =0 ;int Zspace, z1, z2;/* must be int for calculation */ int Fspace, f1, f2;u_char *d;
@@ -2152,14 +2152,15 @@ hfcmulti_tx(struct hfc_multi *hc, int ch)HFC_wait_nodebug (hc); } + tmp_len = (*sp)->len;dev_kfree_skb (*sp);/* check for next frame */ if (bch &&get_next_bframe (bch)) { - len = (*sp)->len; + len = tmp_len; goto next_frame; }if (dch &&get_next_dframe (dch)) { - len = (*sp)->len; + len = tmp_len; goto next_frame; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 419/440 apparmor: Fix null pointer deref when receiving skb during sock creation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiao Liang <[email protected]>
[ Upstream commit fce09ea314505a52f2436397608fa0a5d0934fb1 ]
The panic below is observed when receiving ICMP packets with secmark set while an ICMP raw socket is being created. SK_CTX(sk)->label is updated in apparmor_socket_post_create(), but the packet is delivered to the socket before that, causing the null pointer dereference. Drop the packet if label context is not set.
BUG: kernel NULL pointer dereference, address: 000000000000004c
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 0 P4D 0
Oops: 0000 [#1] PREEMPT SMP NOPTI
CPU: 0 PID: 407 Comm: a.out Not tainted 6.4.12-arch1-1 #1 3e6fa2753a2d75925c34ecb78e22e85a65d083df
Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 05/28/2020
RIP: 0010:aa_label_next_confined+0xb/0x40
Code: 00 00 48 89 ef e8 d5 25 0c 00 e9 66 ff ff ff 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 66 0f 1f 00 0f 1f 44 00 00 89 f0 <8b> 77 4c 39 c6 7e 1f 48 63 d0 48 8d 14 d7 eb 0b 83 c0 01 48 83 c2
RSP: 0018:ffffa92940003b08 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 000000000000000e
RDX: ffffa92940003be8 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffff8b57471e7800 R08: ffff8b574c642400 R09: 0000000000000002
R10: ffffffffbd820eeb R11: ffffffffbeb7ff00 R12: ffff8b574c642400
R13: 0000000000000001 R14: 0000000000000001 R15: 0000000000000000
FS: 00007fb092ea7640(0000) GS:ffff8b577bc00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000000000000004c CR3: 00000001020f2005 CR4: 00000000007706f0
PKRU: 55555554
Call Trace:
<IRQ>
? __die+0x23/0x70
? page_fault_oops+0x171/0x4e0
? exc_page_fault+0x7f/0x180
? asm_exc_page_fault+0x26/0x30
? aa_label_next_confined+0xb/0x40
apparmor_secmark_check+0xec/0x330
security_sock_rcv_skb+0x35/0x50
sk_filter_trim_cap+0x47/0x250
sock_queue_rcv_skb_reason+0x20/0x60
raw_rcv+0x13c/0x210
raw_local_deliver+0x1f3/0x250
ip_protocol_deliver_rcu+0x4f/0x2f0
ip_local_deliver_finish+0x76/0xa0
__netif_receive_skb_one_core+0x89/0xa0
netif_receive_skb+0x119/0x170
? __netdev_alloc_skb+0x3d/0x140
vmxnet3_rq_rx_complete+0xb23/0x1010 [vmxnet3 56a84f9c97178c57a43a24ec073b45a9d6f01f3a]
vmxnet3_poll_rx_only+0x36/0xb0 [vmxnet3 56a84f9c97178c57a43a24ec073b45a9d6f01f3a]
__napi_poll+0x28/0x1b0
net_rx_action+0x2a4/0x380
__do_softirq+0xd1/0x2c8
__irq_exit_rcu+0xbb/0xf0
common_interrupt+0x86/0xa0
</IRQ>
<TASK>
asm_common_interrupt+0x26/0x40
RIP: 0010:apparmor_socket_post_create+0xb/0x200
Code: 08 48 85 ff 75 a1 eb b1 0f 1f 80 00 00 00 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 f3 0f 1e fa 0f 1f 44 00 00 41 54 <55> 48 89 fd 53 45 85 c0 0f 84 b2 00 00 00 48 8b 1d 80 56 3f 02 48
RSP: 0018:ffffa92940ce7e50 EFLAGS: 00000286
RAX: ffffffffbc756440 RBX: 0000000000000000 RCX: 0000000000000001
RDX: 0000000000000003 RSI: 0000000000000002 RDI: ffff8b574eaab740
RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000
R10: ffff8b57444cec70 R11: 0000000000000000 R12: 0000000000000003
R13: 0000000000000002 R14: ffff8b574eaab740 R15: ffffffffbd8e4748
? __pfx_apparmor_socket_post_create+0x10/0x10
security_socket_post_create+0x4b/0x80
__sock_create+0x176/0x1f0
__sys_socket+0x89/0x100
__x64_sys_socket+0x17/0x20
do_syscall_64+0x5d/0x90
? do_syscall_64+0x6c/0x90
? do_syscall_64+0x6c/0x90
? do_syscall_64+0x6c/0x90
entry_SYSCALL_64_after_hwframe+0x72/0xdc--- security/apparmor/lsm.c | 7 +++++++ 1 file changed, 7 insertions(+)
security/apparmor/lsm.c +7 -0
@@ -1081,6 +1081,13 @@ static int apparmor_socket_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)if (!skb->secmark)return 0 ; +/* +* If reach here before socket_post_create hook is called, in which +* case label is null, drop the packet. +*/ +if (!ctx->label) +return -EACCES ; +return apparmor_secmark_check (ctx->label,OP_RECVMSG ,AA_MAY_RECEIVE , skb->secmark, sk); }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 420/440 powerpc: fix a file leak in kvm_vcpu_ioctl_enable_cap()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit b4cf5fc01ce83e5c0bcf3dbb9f929428646b9098 ]
missing fdput() on one of the failure exits
--- arch/powerpc/kvm/powerpc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/kvm/powerpc.c +3 -1
@@ -1998,8 +1998,10 @@ static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,break ; r = -ENXIO ; -if (!xive_enabled ()) +if (!xive_enabled ()) { +fdput (f);break ; + } r = -EPERM ; dev =kvm_device_from_filp (f.file);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 421/440 lirc: rc_dev_get_from_fd(): fix file leak
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit bba1f6758a9ec90c1adac5dcf78f8a15f1bad65b ]
missing fdput() on a failure exit
--- drivers/media/rc/lirc_dev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/rc/lirc_dev.c +3 -1
@@ -828,8 +828,10 @@ struct rc_dev *rc_dev_get_from_fd(int fd, bool write)return ERR_PTR (-EINVAL ); } -if (write && !(f.file->f_mode &FMODE_WRITE )) +if (write && !(f.file->f_mode &FMODE_WRITE )) { +fdput (f);return ERR_PTR (-EPERM ); + } fh = f.file->private_data; dev = fh->rc;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 422/440 auxdisplay: ht16k33: Drop reference after LED registration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Markus Elfring <[email protected]>
[ Upstream commit 2ccfe94bc3ac980d2d1df9f7a0b2c6d2137abe55 ]
The reference count is bumped by device_get_named_child_node() and never dropped. Since LED APIs do not require it to be bumped by the user, drop the reference after LED registration.
[andy: rewritten the commit message and amended the change]
--- drivers/auxdisplay/ht16k33.c | 1 + 1 file changed, 1 insertion(+)
drivers/auxdisplay/ht16k33.c +1 -0
@@ -507,6 +507,7 @@ static int ht16k33_led_probe(struct device *dev, struct led_classdev *led, led->max_brightness =MAX_BRIGHTNESS ; err =devm_led_classdev_register_ext (dev, led, &init_data); +fwnode_handle_put (init_data.fwnode);if (err)dev_err (dev,"Failed to register LED\n" );
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 423/440 ASoC: SOF: imx8m: Fix DSP control regmap retrieval
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Baluta <[email protected]>
[ Upstream commit 2634f745eac25a33f032df32cf98fca8538a534a ]
According to Documentation/devicetree/bindings/dsp/fsl,dsp.yaml fsl,dsp-ctrl is a phandle to syscon block so we need to use correct function to retrieve it.
Currently there is no SOF DSP DTS merged into mainline so there is no need to support the old way of retrieving the dsp control node.
--- sound/soc/sof/imx/imx8m.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/imx/imx8m.c +1 -1
@@ -243,7 +243,7 @@ static int imx8m_probe(struct snd_sof_dev *sdev)/* set default mailbox offset for FW ready message */ sdev->dsp_box.offset =MBOX_OFFSET ; - priv->regmap =syscon_regmap_lookup_by_compatible ("fsl,dsp-ctrl" ); + priv->regmap =syscon_regmap_lookup_by_phandle (np,"fsl,dsp-ctrl" );if (IS_ERR (priv->regmap)) {dev_err (sdev->dev,"cannot find dsp-ctrl registers" ); ret =PTR_ERR (priv->regmap);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 424/440 spi: microchip-core: fix the issues in the isr
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naga Sureshkumar Relli <[email protected]>
[ Upstream commit 502a582b8dd897d9282db47c0911d5320ef2e6b9 ]
It is possible for the TXDONE interrupt be raised if the tx FIFO becomes temporarily empty while transmitting, resulting in recursive calls to mchp_corespi_write_fifo() and therefore a garbage message might be transmitted depending on when the interrupt is triggered. Moving all of the tx FIFO writes out of the TXDONE portion of the interrupt handler avoids this problem.
Most of rest of the TXDONE portion of the handler is problematic too. Only reading the rx FIFO (and finalising the transfer) when the TXDONE interrupt is raised can cause the transfer to stall, if the final bytes of rx data are not available in the rx FIFO when the final TXDONE interrupt is raised. The transfer should be finalised regardless of which interrupt is raised, provided that all tx data has been set and all rx data received.
The first issue was encountered "in the wild", the second is theoretical.
--- drivers/spi/spi-microchip-core.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/spi/spi-microchip-core.c +8 -10
@@ -389,21 +389,18 @@ static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id)if (intfield ==0 )return IRQ_NONE ; -if (intfield &INT_TXDONE ) { +if (intfield &INT_TXDONE )mchp_corespi_write (spi,REG_INT_CLEAR ,INT_TXDONE ); +if (intfield &INT_RXRDY ) { +mchp_corespi_write (spi,REG_INT_CLEAR ,INT_RXRDY ); +if (spi->rx_len)mchp_corespi_read_fifo (spi); - -if (spi->tx_len) -mchp_corespi_write_fifo (spi); - -if (!spi->rx_len) - finalise = true; } -if (intfield &INT_RXRDY ) -mchp_corespi_write (spi,REG_INT_CLEAR ,INT_RXRDY ); +if (!spi->rx_len && !spi->tx_len) + finalise = true;if (intfield &INT_RX_CHANNEL_OVERFLOW ) {mchp_corespi_write (spi,REG_INT_CLEAR ,INT_RX_CHANNEL_OVERFLOW );
@@ -488,8 +485,9 @@ static int mchp_corespi_transfer_one(struct spi_master *master,mchp_corespi_set_xfer_size (spi, (spi->tx_len >FIFO_DEPTH ) ?FIFO_DEPTH : spi->tx_len); -if (spi->tx_len) +while (spi->tx_len)mchp_corespi_write_fifo (spi); +return 1 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 425/440 spi: microchip-core: only disable SPI controller when register value change requires it
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve Wilkins <[email protected]>
[ Upstream commit de9850b5c606b754dd7861678d6e2874b96b04f8 ]
Setting up many of the registers for a new SPI transfer involves unconditionally disabling the SPI controller, writing the register value and re-enabling the controller. This is being done for registers even when the value is unchanged and is also done for registers that don't require the controller to be disabled for the change to take effect. Make an effort to detect changes to the register values, and only disables the controller if the new register value is different and disabling the controller is required. This stops the controller being repeated disabled and the bus going tristate before every transfer.
--- drivers/spi/spi-microchip-core.c | 79 +++++++++++++++++--------------- 1 file changed, 41 insertions(+), 38 deletions(-)
drivers/spi/spi-microchip-core.c +41 -38
@@ -75,6 +75,7 @@#define REG_CONTROL (0x00)#define REG_FRAME_SIZE (0x04) +#define FRAME_SIZE_MASK GENMASK(5, 0)#define REG_STATUS (0x08)#define REG_INT_CLEAR (0x0c)#define REG_RX_DATA (0x10)
@@ -89,6 +90,7 @@#define REG_RIS (0x24)#define REG_CONTROL2 (0x28)#define REG_COMMAND (0x2c) +#define COMMAND_CLRFRAMECNT BIT(4)#define REG_PKTSIZE (0x30)#define REG_CMD_SIZE (0x34)#define REG_HWSTATUS (0x38)
@@ -157,62 +159,59 @@ static inline void mchp_corespi_read_fifo(struct mchp_corespi *spi)static void mchp_corespi_enable_ints (struct mchp_corespi *spi) { -u32 control, mask =INT_ENABLE_MASK ; - -mchp_corespi_disable (spi); - - control =mchp_corespi_read (spi,REG_CONTROL ); - - control |= mask; -mchp_corespi_write (spi,REG_CONTROL , control); +u32 control =mchp_corespi_read (spi,REG_CONTROL ); - control |=CONTROL_ENABLE ; + control |=INT_ENABLE_MASK ;mchp_corespi_write (spi,REG_CONTROL , control); }static void mchp_corespi_disable_ints (struct mchp_corespi *spi) { -u32 control, mask =INT_ENABLE_MASK ; - -mchp_corespi_disable (spi); - - control =mchp_corespi_read (spi,REG_CONTROL ); - control &= ~mask; -mchp_corespi_write (spi,REG_CONTROL , control); +u32 control =mchp_corespi_read (spi,REG_CONTROL ); - control |=CONTROL_ENABLE ; + control &= ~INT_ENABLE_MASK ;mchp_corespi_write (spi,REG_CONTROL , control); }static inline void mchp_corespi_set_xfer_size (struct mchp_corespi *spi,int len) {u32 control; -u16 lenpart; +u32 lenpart; +u32 frames =mchp_corespi_read (spi,REG_FRAMESUP );/* -* Disable the SPI controller. Writes to transfer length have -* no effect when the controller is enabled. +* Writing to FRAMECNT in REG_CONTROL will reset the frame count, taking +* a shortcut requires an explicit clear. */ -mchp_corespi_disable (spi); +if (frames == len) { +mchp_corespi_write (spi,REG_COMMAND ,COMMAND_CLRFRAMECNT ); +return ; + }/* * The lower 16 bits of the frame count are stored in the control reg * for legacy reasons, but the upper 16 written to a different register: * FRAMESUP. While both the upper and lower bits can be *READ* from the -* FRAMESUP register, writing to the lower 16 bits is a NOP +* FRAMESUP register, writing to the lower 16 bits is (supposedly) a NOP. +* +* The driver used to disable the controller while modifying the frame +* count, and mask off the lower 16 bits of len while writing to +* FRAMES_UP. When the driver was changed to disable the controller as +* infrequently as possible, it was discovered that the logic of +* lenpart = len & 0xffff_0000 +* write(REG_FRAMESUP, lenpart) +* would actually write zeros into the lower 16 bits on an mpfs250t-es, +* despite documentation stating these bits were read-only. +* Writing len unmasked into FRAMES_UP ensures those bits aren't zeroed +* on an mpfs250t-es and will be a NOP for the lower 16 bits on hardware +* that matches the documentation. */ lenpart = len &0xffff ; - control =mchp_corespi_read (spi,REG_CONTROL ); control &= ~CONTROL_FRAMECNT_MASK ; control |= lenpart <<CONTROL_FRAMECNT_SHIFT ;mchp_corespi_write (spi,REG_CONTROL , control); - - lenpart = len &0xffff0000 ; -mchp_corespi_write (spi,REG_FRAMESUP , lenpart); - - control |=CONTROL_ENABLE ; -mchp_corespi_write (spi,REG_CONTROL , control); +mchp_corespi_write (spi,REG_FRAMESUP , len); }static inline void mchp_corespi_write_fifo (struct mchp_corespi *spi)
@@ -235,17 +234,22 @@ static inline void mchp_corespi_write_fifo(struct mchp_corespi *spi)static inline void mchp_corespi_set_framesize (struct mchp_corespi *spi,int bt) { +u32 frame_size =mchp_corespi_read (spi,REG_FRAME_SIZE );u32 control; +if ((frame_size &FRAME_SIZE_MASK ) == bt) +return ; +/* * Disable the SPI controller. Writes to the frame size have * no effect when the controller is enabled. */ -mchp_corespi_disable (spi); + control =mchp_corespi_read (spi,REG_CONTROL ); + control &= ~CONTROL_ENABLE ; +mchp_corespi_write (spi,REG_CONTROL , control);mchp_corespi_write (spi,REG_FRAME_SIZE , bt); - control =mchp_corespi_read (spi,REG_CONTROL ); control |=CONTROL_ENABLE ;mchp_corespi_write (spi,REG_CONTROL , control); }
@@ -330,8 +334,6 @@ static inline void mchp_corespi_set_clk_gen(struct mchp_corespi *spi) {u32 control; -mchp_corespi_disable (spi); - control =mchp_corespi_read (spi,REG_CONTROL );if (spi->clk_mode) control |=CONTROL_CLKMODE ;
@@ -340,12 +342,12 @@ static inline void mchp_corespi_set_clk_gen(struct mchp_corespi *spi)mchp_corespi_write (spi,REG_CLK_GEN , spi->clk_gen);mchp_corespi_write (spi,REG_CONTROL , control); -mchp_corespi_write (spi,REG_CONTROL , control |CONTROL_ENABLE ); }static inline void mchp_corespi_set_mode (struct mchp_corespi *spi,unsigned int mode) { -u32 control, mode_val; +u32 mode_val; +u32 control =mchp_corespi_read (spi,REG_CONTROL );switch (mode &SPI_MODE_X_MASK ) {case SPI_MODE_0 :
@@ -363,12 +365,13 @@ static inline void mchp_corespi_set_mode(struct mchp_corespi *spi, unsigned int }/* -* Disable the SPI controller. Writes to the frame size have +* Disable the SPI controller. Writes to the frame protocol have * no effect when the controller is enabled. */ -mchp_corespi_disable (spi); - control =mchp_corespi_read (spi,REG_CONTROL ); + control &= ~CONTROL_ENABLE ; +mchp_corespi_write (spi,REG_CONTROL , control); + control &= ~(SPI_MODE_X_MASK <<MODE_X_MASK_SHIFT ); control |= mode_val;
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 426/440 spi: microchip-core: switch to use modern name
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Yingliang <[email protected]>
[ Upstream commit 8f8bf52ed5b76fc7958b0fbe3131540aecdff8ac ]
Change legacy name master/slave to modern name host/target or controller.
No functional changed.
Stable-dep-of: 3a5e76283672 ("spi: microchip-core: fix init function not setting the master and motorola modes")
--- drivers/spi/spi-microchip-core.c | 74 ++++++++++++++++---------------- 1 file changed, 37 insertions(+), 37 deletions(-)
drivers/spi/spi-microchip-core.c +37 -37
@@ -257,7 +257,7 @@ static inline void mchp_corespi_set_framesize(struct mchp_corespi *spi, int bt)static void mchp_corespi_set_cs (struct spi_device *spi,bool disable) {u32 reg; -struct mchp_corespi *corespi =spi_master_get_devdata (spi->master); +struct mchp_corespi *corespi =spi_controller_get_devdata (spi->controller); reg =mchp_corespi_read (corespi,REG_SLAVE_SELECT ); reg &= ~BIT (spi->chip_select);
@@ -268,11 +268,11 @@ static void mchp_corespi_set_cs(struct spi_device *spi, bool disable)static int mchp_corespi_setup (struct spi_device *spi) { -struct mchp_corespi *corespi =spi_master_get_devdata (spi->master); +struct mchp_corespi *corespi =spi_controller_get_devdata (spi->controller);u32 reg;/* -* Active high slaves need to be specifically set to their inactive +* Active high targets need to be specifically set to their inactive * states during probe by adding them to the "control group" & thus * driving their select line low. */
@@ -284,7 +284,7 @@ static int mchp_corespi_setup(struct spi_device *spi)return 0 ; } -static void mchp_corespi_init (struct spi_master *master,struct mchp_corespi *spi) +static void mchp_corespi_init (struct spi_controller *host,struct mchp_corespi *spi) {unsigned long clk_hz;u32 control =mchp_corespi_read (spi,REG_CONTROL );
@@ -298,7 +298,7 @@ static void mchp_corespi_init(struct spi_master *master, struct mchp_corespi *sp/* max. possible spi clock rate is the apb clock rate */ clk_hz =clk_get_rate (spi->clk); - master->max_speed_hz = clk_hz; + host->max_speed_hz = clk_hz;/* * The controller must be configured so that it doesn't remove Chip
@@ -318,7 +318,7 @@ static void mchp_corespi_init(struct spi_master *master, struct mchp_corespi *sp/* * It is required to enable direct mode, otherwise control over the chip * select is relinquished to the hardware. SSELOUT is enabled too so we -* can deal with active high slaves. +* can deal with active high targets. */ mchp_corespi_write (spi,REG_SLAVE_SELECT ,SSELOUT |SSEL_DIRECT );
@@ -383,8 +383,8 @@ static inline void mchp_corespi_set_mode(struct mchp_corespi *spi, unsigned intstatic irqreturn_t mchp_corespi_interrupt (int irq,void *dev_id) { -struct spi_master *master = dev_id; -struct mchp_corespi *spi =spi_master_get_devdata (master); +struct spi_controller *host = dev_id; +struct mchp_corespi *spi =spi_controller_get_devdata (host);u32 intfield =mchp_corespi_read (spi,REG_MIS ) &0xf ;bool finalise = false;
@@ -408,7 +408,7 @@ static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id)if (intfield &INT_RX_CHANNEL_OVERFLOW ) {mchp_corespi_write (spi,REG_INT_CLEAR ,INT_RX_CHANNEL_OVERFLOW ); finalise = true; -dev_err (&master->dev, +dev_err (&host->dev,"%s: RX OVERFLOW: rxlen: %d, txlen: %d\n" , __func__, spi->rx_len, spi->tx_len); }
@@ -416,13 +416,13 @@ static irqreturn_t mchp_corespi_interrupt(int irq, void *dev_id)if (intfield &INT_TX_CHANNEL_UNDERRUN ) {mchp_corespi_write (spi,REG_INT_CLEAR ,INT_TX_CHANNEL_UNDERRUN ); finalise = true; -dev_err (&master->dev, +dev_err (&host->dev,"%s: TX UNDERFLOW: rxlen: %d, txlen: %d\n" , __func__, spi->rx_len, spi->tx_len); }if (finalise) -spi_finalize_current_transfer (master); +spi_finalize_current_transfer (host);return IRQ_HANDLED ; }
@@ -464,16 +464,16 @@ static int mchp_corespi_calculate_clkgen(struct mchp_corespi *spi,return 0 ; } -static int mchp_corespi_transfer_one (struct spi_master *master, +static int mchp_corespi_transfer_one (struct spi_controller *host,struct spi_device *spi_dev,struct spi_transfer *xfer) { -struct mchp_corespi *spi =spi_master_get_devdata (master); +struct mchp_corespi *spi =spi_controller_get_devdata (host);int ret; ret =mchp_corespi_calculate_clkgen (spi, (unsigned long )xfer->speed_hz);if (ret) { -dev_err (&master->dev,"failed to set clk_gen for target %u Hz\n" , xfer->speed_hz); +dev_err (&host->dev,"failed to set clk_gen for target %u Hz\n" , xfer->speed_hz);return ret; }
@@ -494,11 +494,11 @@ static int mchp_corespi_transfer_one(struct spi_master *master,return 1 ; } -static int mchp_corespi_prepare_message (struct spi_master *master, +static int mchp_corespi_prepare_message (struct spi_controller *host,struct spi_message *msg) {struct spi_device *spi_dev = msg->spi; -struct mchp_corespi *spi =spi_master_get_devdata (master); +struct mchp_corespi *spi =spi_controller_get_devdata (host);mchp_corespi_set_framesize (spi,DEFAULT_FRAMESIZE );mchp_corespi_set_mode (spi, spi_dev->mode);
@@ -508,32 +508,32 @@ static int mchp_corespi_prepare_message(struct spi_master *master,static int mchp_corespi_probe (struct platform_device *pdev) { -struct spi_master *master; +struct spi_controller *host;struct mchp_corespi *spi;struct resource *res;u32 num_cs;int ret =0 ; - master =devm_spi_alloc_master (&pdev->dev,sizeof (*spi)); -if (!master) + host =devm_spi_alloc_host (&pdev->dev,sizeof (*spi)); +if (!host)return dev_err_probe (&pdev->dev, -ENOMEM , -"unable to allocate master for SPI controller\n" ); +"unable to allocate host for SPI controller\n" ); -platform_set_drvdata (pdev, master); +platform_set_drvdata (pdev, host);if (of_property_read_u32 (pdev->dev.of_node,"num-cs" , &num_cs)) num_cs =MAX_CS ; - master->num_chipselect = num_cs; - master->mode_bits =SPI_CPOL |SPI_CPHA |SPI_CS_HIGH ; - master->setup = mchp_corespi_setup; - master->bits_per_word_mask =SPI_BPW_MASK (8 ); - master->transfer_one = mchp_corespi_transfer_one; - master->prepare_message = mchp_corespi_prepare_message; - master->set_cs = mchp_corespi_set_cs; - master->dev.of_node = pdev->dev.of_node; + host->num_chipselect = num_cs; + host->mode_bits =SPI_CPOL |SPI_CPHA |SPI_CS_HIGH ; + host->setup = mchp_corespi_setup; + host->bits_per_word_mask =SPI_BPW_MASK (8 ); + host->transfer_one = mchp_corespi_transfer_one; + host->prepare_message = mchp_corespi_prepare_message; + host->set_cs = mchp_corespi_set_cs; + host->dev.of_node = pdev->dev.of_node; - spi =spi_master_get_devdata (master); + spi =spi_controller_get_devdata (host); spi->regs =devm_platform_get_and_ioremap_resource (pdev,0 , &res);if (IS_ERR (spi->regs))
@@ -546,7 +546,7 @@ static int mchp_corespi_probe(struct platform_device *pdev) spi->irq); ret =devm_request_irq (&pdev->dev, spi->irq, mchp_corespi_interrupt, -IRQF_SHARED ,dev_name (&pdev->dev), master); +IRQF_SHARED ,dev_name (&pdev->dev), host);if (ret)return dev_err_probe (&pdev->dev, ret,"could not request irq\n" );
@@ -561,25 +561,25 @@ static int mchp_corespi_probe(struct platform_device *pdev)return dev_err_probe (&pdev->dev, ret,"failed to enable clock\n" ); -mchp_corespi_init (master, spi); +mchp_corespi_init (host, spi); - ret =devm_spi_register_master (&pdev->dev, master); + ret =devm_spi_register_controller (&pdev->dev, host);if (ret) {mchp_corespi_disable (spi);clk_disable_unprepare (spi->clk);return dev_err_probe (&pdev->dev, ret, -"unable to register master for SPI controller\n" ); +"unable to register host for SPI controller\n" ); } -dev_info (&pdev->dev,"Registered SPI controller %d\n" , master->bus_num); +dev_info (&pdev->dev,"Registered SPI controller %d\n" , host->bus_num);return 0 ; }static int mchp_corespi_remove (struct platform_device *pdev) { -struct spi_master *master =platform_get_drvdata (pdev); -struct mchp_corespi *spi =spi_master_get_devdata (master); +struct spi_controller *host =platform_get_drvdata (pdev); +struct mchp_corespi *spi =spi_controller_get_devdata (host);mchp_corespi_disable_ints (spi);clk_disable_unprepare (spi->clk);
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 427/440 spi: microchip-core: fix init function not setting the master and motorola modes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve Wilkins <[email protected]>
[ Upstream commit 3a5e76283672efddf47cea39ccfe9f5735cc91d5 ]
mchp_corespi_init() reads the CONTROL register, sets the master and motorola bits, but doesn't write the value back to the register. The function also doesn't ensure the controller is disabled at the start, which may present a problem if the controller was used by an earlier boot stage as some settings (including the mode) can only be modified while the controller is disabled.
--- drivers/spi/spi-microchip-core.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/spi/spi-microchip-core.c +9 -8
@@ -289,17 +289,13 @@ static void mchp_corespi_init(struct spi_controller *host, struct mchp_corespi *unsigned long clk_hz;u32 control =mchp_corespi_read (spi,REG_CONTROL ); - control |=CONTROL_MASTER ; + control &= ~CONTROL_ENABLE ; +mchp_corespi_write (spi,REG_CONTROL , control); + control |=CONTROL_MASTER ; control &= ~CONTROL_MODE_MASK ; control |=MOTOROLA_MODE ; -mchp_corespi_set_framesize (spi,DEFAULT_FRAMESIZE ); - -/* max. possible spi clock rate is the apb clock rate */ - clk_hz =clk_get_rate (spi->clk); - host->max_speed_hz = clk_hz; -/* * The controller must be configured so that it doesn't remove Chip * Select until the entire message has been transferred, even if at
@@ -308,11 +304,16 @@ static void mchp_corespi_init(struct spi_controller *host, struct mchp_corespi ** BIGFIFO mode is also enabled, which sets the fifo depth to 32 frames * for the 8 bit transfers that this driver uses. */ - control =mchp_corespi_read (spi,REG_CONTROL ); control |=CONTROL_SPS |CONTROL_BIGFIFO ;mchp_corespi_write (spi,REG_CONTROL , control); +mchp_corespi_set_framesize (spi,DEFAULT_FRAMESIZE ); + +/* max. possible spi clock rate is the apb clock rate */ + clk_hz =clk_get_rate (spi->clk); + host->max_speed_hz = clk_hz; +mchp_corespi_enable_ints (spi);/*
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 428/440 nvme-pci: Fix the instructions for disabling power management
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
[ Upstream commit 92fc2c469eb26060384e9b2cd4cb0cc228aba582 ]
pcie_aspm=off tells the kernel not to modify the ASPM configuration. This setting does not guarantee that ASPM (Active State Power Management) is disabled. Hence add pcie_port_pm=off. This disables power management for all PCIe ports.
This patch has been tested on a workstation with a Samsung SSD 970 EVO Plus NVMe SSD.
--- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/pci.c +1 -1
@@ -1322,7 +1322,7 @@ static void nvme_warn_reset(struct nvme_dev *dev, u32 csts)dev_warn (dev->ctrl.device,"Does your device have a faulty power saving mode enabled?\n" );dev_warn (dev->ctrl.device, -"Try \"nvme_core.default_ps_max_latency_us=0 pcie_aspm=off\" and report a bug\n" ); +"Try \"nvme_core.default_ps_max_latency_us=0 pcie_aspm=off pcie_port_pm=off\" and report a bug\n" ); }static enum blk_eh_timer_return nvme_timeout (struct request *req)
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 429/440 spidev: Add Silicon Labs EM3581 device compatible
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Tremblay <[email protected]>
[ Upstream commit c67d90e058550403a3e6f9b05bfcdcfa12b1815c ]
Add compatible string for Silicon Labs EM3581 device.
Stable-dep-of: fc28d1c1fe3b ("spi: spidev: add correct compatible for Rohm BH2228FV")
--- drivers/spi/spidev.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/spi/spidev.c +2 -0
@@ -700,6 +700,7 @@ static const struct spi_device_id spidev_spi_ids[] = { { .name = "m53cpld" }, { .name = "spi-petra" }, { .name = "spi-authenta" }, + { .name = "em3581" }, {}, };MODULE_DEVICE_TABLE (spi, spidev_spi_ids);
@@ -726,6 +727,7 @@ static const struct of_device_id spidev_dt_ids[] = { { .compatible = "menlo,m53cpld", .data = &spidev_of_check }, { .compatible = "cisco,spi-petra", .data = &spidev_of_check }, { .compatible = "micron,spi-authenta", .data = &spidev_of_check }, + { .compatible = "silabs,em3581", .data = &spidev_of_check }, {}, };MODULE_DEVICE_TABLE (of, spidev_dt_ids);
Signature · 1 line
2.43.0