Select the types of activity you want to include in your feed.
ASoC: Merge up fixes
Merge branch 'for-7.0' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-7.1 for both ASoC and general bug fixes to support testing.
···8585the error message to the Root Port. Please refer to PCIe specs for other8686fields.87878888+The 'TLP Header' is the prefix/header of the TLP that caused the error8989+in raw hex format. To decode the TLP Header into human-readable form9090+one may use tlp-tool:9191+9292+https://github.com/mmpg-x86/tlp-tool9393+9494+Example usage::9595+9696+ curl -L https://git.kernel.org/linus/2ca1c94ce0b6 | rtlp-tool --aer9797+8898AER Ratelimits8999--------------90100
+29-7
Documentation/core-api/dma-attributes.rst
···149149DMA_ATTR_MMIO will not perform any cache flushing. The address150150provided must never be mapped cacheable into the CPU.151151152152-DMA_ATTR_CPU_CACHE_CLEAN153153-------------------------152152+DMA_ATTR_DEBUGGING_IGNORE_CACHELINES153153+------------------------------------154154155155-This attribute indicates the CPU will not dirty any cacheline overlapping this156156-DMA_FROM_DEVICE/DMA_BIDIRECTIONAL buffer while it is mapped. This allows157157-multiple small buffers to safely share a cacheline without risk of data158158-corruption, suppressing DMA debug warnings about overlapping mappings.159159-All mappings sharing a cacheline should have this attribute.155155+This attribute indicates that CPU cache lines may overlap for buffers mapped156156+with DMA_FROM_DEVICE or DMA_BIDIRECTIONAL.157157+158158+Such overlap may occur when callers map multiple small buffers that reside159159+within the same cache line. In this case, callers must guarantee that the CPU160160+will not dirty these cache lines after the mappings are established. When this161161+condition is met, multiple buffers can safely share a cache line without risking162162+data corruption.163163+164164+All mappings that share a cache line must set this attribute to suppress DMA165165+debug warnings about overlapping mappings.166166+167167+DMA_ATTR_REQUIRE_COHERENT168168+-------------------------169169+170170+DMA mapping requests with the DMA_ATTR_REQUIRE_COHERENT fail on any171171+system where SWIOTLB or cache management is required. This should only172172+be used to support uAPI designs that require continuous HW DMA173173+coherence with userspace processes, for example RDMA and DRM. At a174174+minimum the memory being mapped must be userspace memory from175175+pin_user_pages() or similar.176176+177177+Drivers should consider using dma_mmap_pages() instead of this178178+interface when building their uAPIs, when possible.179179+180180+It must never be used in an in-kernel driver that only works with181181+kernel memory.
+50
Documentation/filesystems/overlayfs.rst
···783783 mounted with "uuid=on".784784785785786786+Durability and copy up787787+----------------------788788+789789+The fsync(2) system call ensures that the data and metadata of a file790790+are safely written to the backing storage, which is expected to791791+guarantee the existence of the information post system crash.792792+793793+Without an fsync(2) call, there is no guarantee that the observed794794+data after a system crash will be either the old or the new data, but795795+in practice, the observed data after crash is often the old or new data796796+or a mix of both.797797+798798+When an overlayfs file is modified for the first time, copy up will799799+create a copy of the lower file and its parent directories in the upper800800+layer. Since the Linux filesystem API does not enforce any particular801801+ordering on storing changes without explicit fsync(2) calls, in case802802+of a system crash, the upper file could end up with no data at all803803+(i.e. zeros), which would be an unusual outcome. To avoid this804804+experience, overlayfs calls fsync(2) on the upper file before completing805805+data copy up with rename(2) or link(2) to make the copy up "atomic".806806+807807+By default, overlayfs does not explicitly call fsync(2) on copied up808808+directories or on metadata-only copy up, so it provides no guarantee to809809+persist the user's modification unless the user calls fsync(2).810810+The fsync during copy up only guarantees that if a copy up is observed811811+after a crash, the observed data is not zeroes or intermediate values812812+from the copy up staging area.813813+814814+On traditional local filesystems with a single journal (e.g. ext4, xfs),815815+fsync on a file also persists the parent directory changes, because they816816+are usually modified in the same transaction, so metadata durability during817817+data copy up effectively comes for free. Overlayfs further limits risk by818818+disallowing network filesystems as upper layer.819819+820820+Overlayfs can be tuned to prefer performance or durability when storing821821+to the underlying upper layer. This is controlled by the "fsync" mount822822+option, which supports these values:823823+824824+- "auto": (default)825825+ Call fsync(2) on upper file before completion of data copy up.826826+ No explicit fsync(2) on directory or metadata-only copy up.827827+- "strict":828828+ Call fsync(2) on upper file and directories before completion of any829829+ copy up.830830+- "volatile": [*]831831+ Prefer performance over durability (see `Volatile mount`_)832832+833833+[*] The mount option "volatile" is an alias to "fsync=volatile".834834+835835+786836Volatile mount787837--------------788838
+4-4
Documentation/hwmon/adm1177.rst
···2727Sysfs entries2828-------------29293030-The following attributes are supported. Current maxim attribute3030+The following attributes are supported. Current maximum attribute3131is read-write, all other attributes are read-only.32323333-in0_input Measured voltage in microvolts.3333+in0_input Measured voltage in millivolts.34343535-curr1_input Measured current in microamperes.3636-curr1_max_alarm Overcurrent alarm in microamperes.3535+curr1_input Measured current in milliamperes.3636+curr1_max Overcurrent shutdown threshold in milliamperes.
+6-4
Documentation/hwmon/peci-cputemp.rst
···5151temp1_crit Provides shutdown temperature of the CPU package which5252 is also known as the maximum processor junction5353 temperature, Tjmax or Tprochot.5454-temp1_crit_hyst Provides the hysteresis value from Tcontrol to Tjmax of5555- the CPU package.5454+temp1_crit_hyst Provides the hysteresis temperature of the CPU5555+ package. Returns Tcontrol, the temperature at which5656+ the critical condition clears.56575758temp2_label "DTS"5859temp2_input Provides current temperature of the CPU package scaled···6362temp2_crit Provides shutdown temperature of the CPU package which6463 is also known as the maximum processor junction6564 temperature, Tjmax or Tprochot.6666-temp2_crit_hyst Provides the hysteresis value from Tcontrol to Tjmax of6767- the CPU package.6565+temp2_crit_hyst Provides the hysteresis temperature of the CPU6666+ package. Returns Tcontrol, the temperature at which6767+ the critical condition clears.68686969temp3_label "Tcontrol"7070temp3_input Provides current Tcontrol temperature of the CPU
+19-4
Documentation/userspace-api/landlock.rst
···88=====================================991010:Author: Mickaël Salaün1111-:Date: January 20261111+:Date: March 202612121313The goal of Landlock is to enable restriction of ambient rights (e.g. global1414filesystem or network access) for a set of processes. Because Landlock···197197198198.. code-block:: c199199200200- __u32 restrict_flags = LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON;201201- if (abi < 7) {202202- /* Clear logging flags unsupported before ABI 7. */200200+ __u32 restrict_flags =201201+ LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON |202202+ LANDLOCK_RESTRICT_SELF_TSYNC;203203+ switch (abi) {204204+ case 1 ... 6:205205+ /* Removes logging flags for ABI < 7 */203206 restrict_flags &= ~(LANDLOCK_RESTRICT_SELF_LOG_SAME_EXEC_OFF |204207 LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON |205208 LANDLOCK_RESTRICT_SELF_LOG_SUBDOMAINS_OFF);209209+ __attribute__((fallthrough));210210+ case 7:211211+ /*212212+ * Removes multithreaded enforcement flag for ABI < 8213213+ *214214+ * WARNING: Without this flag, calling landlock_restrict_self(2) is215215+ * only equivalent if the calling process is single-threaded. Below216216+ * ABI v8 (and as of ABI v8, when not using this flag), a Landlock217217+ * policy would only be enforced for the calling thread and its218218+ * children (and not for all threads, including parents and siblings).219219+ */220220+ restrict_flags &= ~LANDLOCK_RESTRICT_SELF_TSYNC;206221 }207222208223The next step is to restrict the current thread from gaining more privileges
+16-7
MAINTAINERS
···39863986ASUS NOTEBOOKS AND EEEPC ACPI/WMI EXTRAS DRIVERS39873987M: Corentin Chary <corentin.chary@gmail.com>39883988M: Luke D. Jones <luke@ljones.dev>39893989-M: Denis Benato <benato.denis96@gmail.com>39893989+M: Denis Benato <denis.benato@linux.dev>39903990L: platform-driver-x86@vger.kernel.org39913991S: Maintained39923992W: https://asus-linux.org/···86288628F: include/uapi/drm/lima_drm.h8629862986308630DRM DRIVERS FOR LOONGSON86318631+M: Jianmin Lv <lvjianmin@loongson.cn>86328632+M: Qianhai Wu <wuqianhai@loongson.cn>86338633+R: Huacai Chen <chenhuacai@kernel.org>86348634+R: Mingcong Bai <jeffbai@aosc.io>86358635+R: Xi Ruoyao <xry111@xry111.site>86368636+R: Icenowy Zheng <zhengxingda@iscas.ac.cn>86318637L: dri-devel@lists.freedesktop.org86328632-S: Orphan86388638+S: Maintained86338639T: git https://gitlab.freedesktop.org/drm/misc/kernel.git86348640F: drivers/gpu/drm/loongson/86358641···9619961396209614EXT4 FILE SYSTEM96219615M: "Theodore Ts'o" <tytso@mit.edu>96229622-M: Andreas Dilger <adilger.kernel@dilger.ca>96169616+R: Andreas Dilger <adilger.kernel@dilger.ca>96179617+R: Baokun Li <libaokun@linux.alibaba.com>96189618+R: Jan Kara <jack@suse.cz>96199619+R: Ojaswin Mujoo <ojaswin@linux.ibm.com>96209620+R: Ritesh Harjani (IBM) <ritesh.list@gmail.com>96219621+R: Zhang Yi <yi.zhang@huawei.com>96239622L: linux-ext4@vger.kernel.org96249623S: Maintained96259624W: http://ext4.wiki.kernel.org···1202012009M: Wolfram Sang <wsa+renesas@sang-engineering.com>1202112010L: linux-i2c@vger.kernel.org1202212011S: Maintained1202312023-W: https://i2c.wiki.kernel.org/1202412012Q: https://patchwork.ozlabs.org/project/linux-i2c/list/1202512013T: git git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git1202612014F: Documentation/i2c/···1204512035M: Andi Shyti <andi.shyti@kernel.org>1204612036L: linux-i2c@vger.kernel.org1204712037S: Maintained1204812048-W: https://i2c.wiki.kernel.org/1204912038Q: https://patchwork.ozlabs.org/project/linux-i2c/list/1205012039T: git git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git1205112040F: Documentation/devicetree/bindings/i2c/···1688616877R: Rik van Riel <riel@surriel.com>1688716878R: Liam R. Howlett <Liam.Howlett@oracle.com>1688816879R: Vlastimil Babka <vbabka@kernel.org>1688916889-R: Harry Yoo <harry.yoo@oracle.com>1688016880+R: Harry Yoo <harry@kernel.org>1689016881R: Jann Horn <jannh@google.com>1689116882L: linux-mm@kvack.org1689216883S: Maintained···24352243432435324344SLAB ALLOCATOR2435424345M: Vlastimil Babka <vbabka@kernel.org>2435524355-M: Harry Yoo <harry.yoo@oracle.com>2434624346+M: Harry Yoo <harry@kernel.org>2435624347M: Andrew Morton <akpm@linux-foundation.org>2435724348R: Hao Li <hao.li@linux.dev>2435824349R: Christoph Lameter <cl@gentwo.org>
···17531753 if (!writable)17541754 return -EPERM;1755175517561756- ptep = (u64 __user *)hva + offset;17561756+ ptep = (void __user *)hva + offset;17571757 if (cpus_have_final_cap(ARM64_HAS_LSE_ATOMICS))17581758 r = __lse_swap_desc(ptep, old, new);17591759 else
+14
arch/arm64/kvm/reset.c
···247247 kvm_vcpu_set_be(vcpu);248248249249 *vcpu_pc(vcpu) = target_pc;250250+251251+ /*252252+ * We may come from a state where either a PC update was253253+ * pending (SMC call resulting in PC being increpented to254254+ * skip the SMC) or a pending exception. Make sure we get255255+ * rid of all that, as this cannot be valid out of reset.256256+ *257257+ * Note that clearing the exception mask also clears PC258258+ * updates, but that's an implementation detail, and we259259+ * really want to make it explicit.260260+ */261261+ vcpu_clear_flag(vcpu, PENDING_EXCEPTION);262262+ vcpu_clear_flag(vcpu, EXCEPT_MASK);263263+ vcpu_clear_flag(vcpu, INCREMENT_PC);250264 vcpu_set_reg(vcpu, 0, reset_state.r0);251265 }252266
+36
arch/loongarch/include/asm/linkage.h
···4141 .cfi_endproc; \4242 SYM_END(name, SYM_T_NONE)43434444+/*4545+ * This is for the signal handler trampoline, which is used as the return4646+ * address of the signal handlers in userspace instead of called normally.4747+ * The long standing libgcc bug https://gcc.gnu.org/PR124050 requires a4848+ * nop between .cfi_startproc and the actual address of the trampoline, so4949+ * we cannot simply use SYM_FUNC_START.5050+ *5151+ * This wrapper also contains all the .cfi_* directives for recovering5252+ * the content of the GPRs and the "return address" (where the rt_sigreturn5353+ * syscall will jump to), assuming there is a struct rt_sigframe (where5454+ * a struct sigcontext containing those information we need to recover) at5555+ * $sp. The "DWARF for the LoongArch(TM) Architecture" manual states5656+ * column 0 is for $zero, but it does not make too much sense to5757+ * save/restore the hardware zero register. Repurpose this column here5858+ * for the return address (here it's not the content of $ra we cannot use5959+ * the default column 3).6060+ */6161+#define SYM_SIGFUNC_START(name) \6262+ .cfi_startproc; \6363+ .cfi_signal_frame; \6464+ .cfi_def_cfa 3, RT_SIGFRAME_SC; \6565+ .cfi_return_column 0; \6666+ .cfi_offset 0, SC_PC; \6767+ \6868+ .irp num, 1, 2, 3, 4, 5, 6, 7, 8, \6969+ 9, 10, 11, 12, 13, 14, 15, 16, \7070+ 17, 18, 19, 20, 21, 22, 23, 24, \7171+ 25, 26, 27, 28, 29, 30, 31; \7272+ .cfi_offset \num, SC_REGS + \num * SZREG; \7373+ .endr; \7474+ \7575+ nop; \7676+ SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)7777+7878+#define SYM_SIGFUNC_END(name) SYM_FUNC_END(name)7979+4480#endif
···6262 * @size: number of elements in array6363 */6464#define array_index_mask_nospec array_index_mask_nospec6565-static inline unsigned long array_index_mask_nospec(unsigned long index,6666- unsigned long size)6565+static __always_inline unsigned long array_index_mask_nospec(unsigned long index,6666+ unsigned long size)6767{6868 unsigned long mask;6969
+3
arch/s390/include/asm/kvm_host.h
···710710void kvm_arch_crypto_set_masks(struct kvm *kvm, unsigned long *apm,711711 unsigned long *aqm, unsigned long *adm);712712713713+#define SIE64_RETURN_NORMAL 0714714+#define SIE64_RETURN_MCCK 1715715+713716int __sie64a(phys_addr_t sie_block_phys, struct kvm_s390_sie_block *sie_block, u64 *rsa,714717 unsigned long gasce);715718
+1-1
arch/s390/include/asm/stacktrace.h
···6262 struct {6363 unsigned long sie_control_block;6464 unsigned long sie_savearea;6565- unsigned long sie_reason;6565+ unsigned long sie_return;6666 unsigned long sie_flags;6767 unsigned long sie_control_block_phys;6868 unsigned long sie_guest_asce;
···2724272427252725 bit = bit_nr + (addr % PAGE_SIZE) * 8;2726272627272727+ /* kvm_set_routing_entry() should never allow this to happen */27282728+ WARN_ON_ONCE(bit > (PAGE_SIZE * BITS_PER_BYTE - 1));27292729+27272730 return swap ? (bit ^ (BITS_PER_LONG - 1)) : bit;27282731}27292732···28272824 int rc;2828282528292826 mci.val = mcck_info->mcic;28272827+28282828+ /* log machine checks being reinjected on all debugs */28292829+ VCPU_EVENT(vcpu, 2, "guest machine check %lx", mci.val);28302830+ KVM_EVENT(2, "guest machine check %lx", mci.val);28312831+ pr_info("guest machine check pid %d: %lx", current->pid, mci.val);28322832+28302833 if (mci.sr)28312834 cr14 |= CR14_RECOVERY_SUBMASK;28322835 if (mci.dg)···28612852 struct kvm_kernel_irq_routing_entry *e,28622853 const struct kvm_irq_routing_entry *ue)28632854{28552855+ const struct kvm_irq_routing_s390_adapter *adapter;28642856 u64 uaddr_s, uaddr_i;28652857 int idx;28662858···28712861 if (kvm_is_ucontrol(kvm))28722862 return -EINVAL;28732863 e->set = set_adapter_int;28642864+28652865+ adapter = &ue->u.adapter;28662866+ if (adapter->summary_addr + (adapter->summary_offset / 8) >=28672867+ (adapter->summary_addr & PAGE_MASK) + PAGE_SIZE)28682868+ return -EINVAL;28692869+ if (adapter->ind_addr + (adapter->ind_offset / 8) >=28702870+ (adapter->ind_addr & PAGE_MASK) + PAGE_SIZE)28712871+ return -EINVAL;2874287228752873 idx = srcu_read_lock(&kvm->srcu);28762874 uaddr_s = gpa_to_hva(kvm, ue->u.adapter.summary_addr);
+23-11
arch/s390/kvm/kvm-s390.c
···46174617 return 0;46184618}4619461946204620-static int vcpu_post_run(struct kvm_vcpu *vcpu, int exit_reason)46204620+static int vcpu_post_run(struct kvm_vcpu *vcpu, int sie_return)46214621{46224622 struct mcck_volatile_info *mcck_info;46234623 struct sie_page *sie_page;···46334633 vcpu->run->s.regs.gprs[14] = vcpu->arch.sie_block->gg14;46344634 vcpu->run->s.regs.gprs[15] = vcpu->arch.sie_block->gg15;4635463546364636- if (exit_reason == -EINTR) {46374637- VCPU_EVENT(vcpu, 3, "%s", "machine check");46364636+ if (sie_return == SIE64_RETURN_MCCK) {46384637 sie_page = container_of(vcpu->arch.sie_block,46394638 struct sie_page, sie_block);46404639 mcck_info = &sie_page->mcck_info;46414640 kvm_s390_reinject_machine_check(vcpu, mcck_info);46424641 return 0;46434642 }46434643+ WARN_ON_ONCE(sie_return != SIE64_RETURN_NORMAL);4644464446454645 if (vcpu->arch.sie_block->icptcode > 0) {46464646 rc = kvm_handle_sie_intercept(vcpu);···46794679#define PSW_INT_MASK (PSW_MASK_EXT | PSW_MASK_IO | PSW_MASK_MCHECK)46804680static int __vcpu_run(struct kvm_vcpu *vcpu)46814681{46824682- int rc, exit_reason;46824682+ int rc, sie_return;46834683 struct sie_page *sie_page = (struct sie_page *)vcpu->arch.sie_block;4684468446854685 /*···47194719 guest_timing_enter_irqoff();47204720 __disable_cpu_timer_accounting(vcpu);4721472147224722- exit_reason = kvm_s390_enter_exit_sie(vcpu->arch.sie_block,47234723- vcpu->run->s.regs.gprs,47244724- vcpu->arch.gmap->asce.val);47224722+ sie_return = kvm_s390_enter_exit_sie(vcpu->arch.sie_block,47234723+ vcpu->run->s.regs.gprs,47244724+ vcpu->arch.gmap->asce.val);4725472547264726 __enable_cpu_timer_accounting(vcpu);47274727 guest_timing_exit_irqoff();···47444744 }47454745 kvm_vcpu_srcu_read_lock(vcpu);4746474647474747- rc = vcpu_post_run(vcpu, exit_reason);47474747+ rc = vcpu_post_run(vcpu, sie_return);47484748 if (rc || guestdbg_exit_pending(vcpu)) {47494749 kvm_vcpu_srcu_read_unlock(vcpu);47504750 break;···55205520 }55215521#endif55225522 case KVM_S390_VCPU_FAULT: {55235523- idx = srcu_read_lock(&vcpu->kvm->srcu);55245524- r = vcpu_dat_fault_handler(vcpu, arg, 0);55255525- srcu_read_unlock(&vcpu->kvm->srcu, idx);55235523+ gpa_t gaddr = arg;55245524+55255525+ scoped_guard(srcu, &vcpu->kvm->srcu) {55265526+ r = vcpu_ucontrol_translate(vcpu, &gaddr);55275527+ if (r)55285528+ break;55295529+55305530+ r = kvm_s390_faultin_gfn_simple(vcpu, NULL, gpa_to_gfn(gaddr), false);55315531+ if (r == PGM_ADDRESSING)55325532+ r = -EFAULT;55335533+ if (r <= 0)55345534+ break;55355535+ r = -EIO;55365536+ KVM_BUG_ON(r, vcpu->kvm);55375537+ }55265538 break;55275539 }55285540 case KVM_ENABLE_CAP:
+8-4
arch/s390/kvm/vsie.c
···11221122{11231123 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;11241124 struct kvm_s390_sie_block *scb_o = vsie_page->scb_o;11251125+ unsigned long sie_return = SIE64_RETURN_NORMAL;11251126 int guest_bp_isolation;11261127 int rc = 0;11271128···11641163 goto xfer_to_guest_mode_check;11651164 }11661165 guest_timing_enter_irqoff();11671167- rc = kvm_s390_enter_exit_sie(scb_s, vcpu->run->s.regs.gprs, sg->asce.val);11661166+ sie_return = kvm_s390_enter_exit_sie(scb_s, vcpu->run->s.regs.gprs, sg->asce.val);11681167 guest_timing_exit_irqoff();11691168 local_irq_enable();11701169 }···1179117811801179 kvm_vcpu_srcu_read_lock(vcpu);1181118011821182- if (rc == -EINTR) {11831183- VCPU_EVENT(vcpu, 3, "%s", "machine check");11811181+ if (sie_return == SIE64_RETURN_MCCK) {11841182 kvm_s390_reinject_machine_check(vcpu, &vsie_page->mcck_info);11851183 return 0;11861184 }11851185+11861186+ WARN_ON_ONCE(sie_return != SIE64_RETURN_NORMAL);1187118711881188 if (rc > 0)11891189 rc = 0; /* we could still have an icpt */···13281326static int vsie_run(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)13291327{13301328 struct kvm_s390_sie_block *scb_s = &vsie_page->scb_s;13311331- struct gmap *sg;13291329+ struct gmap *sg = NULL;13321330 int rc = 0;1333133113341332 while (1) {···13681366 sg = gmap_put(sg);13691367 cond_resched();13701368 }13691369+ if (sg)13701370+ sg = gmap_put(sg);1371137113721372 if (rc == -EFAULT) {13731373 /*
+9-2
arch/s390/mm/fault.c
···441441 folio = phys_to_folio(addr);442442 if (unlikely(!folio_try_get(folio)))443443 return;444444- rc = arch_make_folio_accessible(folio);444444+ rc = uv_convert_from_secure(folio_to_phys(folio));445445+ if (!rc)446446+ clear_bit(PG_arch_1, &folio->flags.f);445447 folio_put(folio);448448+ /*449449+ * There are some valid fixup types for kernel450450+ * accesses to donated secure memory. zeropad is one451451+ * of them.452452+ */446453 if (rc)447447- BUG();454454+ return handle_fault_error_nolock(regs, 0);448455 } else {449456 if (faulthandler_disabled())450457 return handle_fault_error_nolock(regs, 0);
+6
arch/x86/coco/sev/noinstr.c
···121121122122 WARN_ON(!irqs_disabled());123123124124+ if (!sev_cfg.ghcbs_initialized)125125+ return boot_ghcb;126126+124127 data = this_cpu_read(runtime_data);125128 ghcb = &data->ghcb_page;126129···166163 struct ghcb *ghcb;167164168165 WARN_ON(!irqs_disabled());166166+167167+ if (!sev_cfg.ghcbs_initialized)168168+ return;169169170170 data = this_cpu_read(runtime_data);171171 ghcb = &data->ghcb_page;
+14
arch/x86/entry/entry_fred.c
···177177 }178178}179179180180+#ifdef CONFIG_AMD_MEM_ENCRYPT181181+noinstr void exc_vmm_communication(struct pt_regs *regs, unsigned long error_code)182182+{183183+ if (user_mode(regs))184184+ return user_exc_vmm_communication(regs, error_code);185185+ else186186+ return kernel_exc_vmm_communication(regs, error_code);187187+}188188+#endif189189+180190static noinstr void fred_hwexc(struct pt_regs *regs, unsigned long error_code)181191{182192 /* Optimize for #PF. That's the only exception which matters performance wise */···217207#ifdef CONFIG_X86_CET218208 case X86_TRAP_CP: return exc_control_protection(regs, error_code);219209#endif210210+#ifdef CONFIG_AMD_MEM_ENCRYPT211211+ case X86_TRAP_VC: return exc_vmm_communication(regs, error_code);212212+#endif213213+220214 default: return fred_bad_type(regs, error_code);221215 }222216
+26-7
arch/x86/kernel/cpu/common.c
···433433434434/* These bits should not change their value after CPU init is finished. */435435static const unsigned long cr4_pinned_mask = X86_CR4_SMEP | X86_CR4_SMAP | X86_CR4_UMIP |436436- X86_CR4_FSGSBASE | X86_CR4_CET | X86_CR4_FRED;436436+ X86_CR4_FSGSBASE | X86_CR4_CET;437437+438438+/*439439+ * The CR pinning protects against ROP on the 'mov %reg, %CRn' instruction(s).440440+ * Since you can ROP directly to these instructions (barring shadow stack),441441+ * any protection must follow immediately and unconditionally after that.442442+ *443443+ * Specifically, the CR[04] write functions below will have the value444444+ * validation controlled by the @cr_pinning static_branch which is445445+ * __ro_after_init, just like the cr4_pinned_bits value.446446+ *447447+ * Once set, an attacker will have to defeat page-tables to get around these448448+ * restrictions. Which is a much bigger ask than 'simple' ROP.449449+ */437450static DEFINE_STATIC_KEY_FALSE_RO(cr_pinning);438451static unsigned long cr4_pinned_bits __ro_after_init;439452···20632050 setup_umip(c);20642051 setup_lass(c);2065205220662066- /* Enable FSGSBASE instructions if available. */20672067- if (cpu_has(c, X86_FEATURE_FSGSBASE)) {20682068- cr4_set_bits(X86_CR4_FSGSBASE);20692069- elf_hwcap2 |= HWCAP2_FSGSBASE;20702070- }20712071-20722053 /*20732054 * The vendor-specific functions might have changed features.20742055 * Now we do "generic changes."···2422241524232416 /* GHCB needs to be setup to handle #VC. */24242417 setup_ghcb();24182418+24192419+ /*24202420+ * On CPUs with FSGSBASE support, paranoid_entry() uses24212421+ * ALTERNATIVE-patched RDGSBASE/WRGSBASE instructions. Secondary CPUs24222422+ * boot after alternatives are patched globally, so early exceptions24232423+ * execute patched code that depends on FSGSBASE. Enable the feature24242424+ * before any exceptions occur.24252425+ */24262426+ if (cpu_feature_enabled(X86_FEATURE_FSGSBASE)) {24272427+ cr4_set_bits(X86_CR4_FSGSBASE);24282428+ elf_hwcap2 |= HWCAP2_FSGSBASE;24292429+ }2425243024262431 if (cpu_feature_enabled(X86_FEATURE_FRED)) {24272432 /* The boot CPU has enabled FRED during early boot */
···15451545 unsigned int val_num)15461546{15471547 void *orig_work_buf;15481548+ unsigned int selector_reg;15481549 unsigned int win_offset;15491550 unsigned int win_page;15501551 bool page_chg;···15641563 return -EINVAL;15651564 }1566156515671567- /* It is possible to have selector register inside data window.15681568- In that case, selector register is located on every page and15691569- it needs no page switching, when accessed alone. */15661566+ /*15671567+ * Calculate the address of the selector register in the corresponding15681568+ * data window if it is located on every page.15691569+ */15701570+ page_chg = in_range(range->selector_reg, range->window_start, range->window_len);15711571+ if (page_chg)15721572+ selector_reg = range->range_min + win_page * range->window_len +15731573+ range->selector_reg - range->window_start;15741574+15751575+ /*15761576+ * It is possible to have selector register inside data window.15771577+ * In that case, selector register is located on every page and it15781578+ * needs no page switching, when accessed alone.15791579+ *15801580+ * Nevertheless we should synchronize the cache values for it.15811581+ * This can't be properly achieved if the selector register is15821582+ * the first and the only one to be read inside the data window.15831583+ * That's why we update it in that case as well.15841584+ *15851585+ * However, we specifically avoid updating it for the default page,15861586+ * when it's overlapped with the real data window, to prevent from15871587+ * infinite looping.15881588+ */15701589 if (val_num > 1 ||15901590+ (page_chg && selector_reg != range->selector_reg) ||15711591 range->window_start + win_offset != range->selector_reg) {15721592 /* Use separate work_buf during page switching */15731593 orig_work_buf = map->work_buf;···15971575 ret = _regmap_update_bits(map, range->selector_reg,15981576 range->selector_mask,15991577 win_page << range->selector_shift,16001600- &page_chg, false);15781578+ NULL, false);1601157916021580 map->work_buf = orig_work_buf;16031581
+14-25
drivers/block/zram/zram_drv.c
···917917918918static int zram_writeback_complete(struct zram *zram, struct zram_wb_req *req)919919{920920- u32 size, index = req->pps->index;921921- int err, prio;922922- bool huge;920920+ u32 index = req->pps->index;921921+ int err;923922924923 err = blk_status_to_errno(req->bio.bi_status);925924 if (err) {···945946 goto out;946947 }947948948948- if (zram->compressed_wb) {949949- /*950950- * ZRAM_WB slots get freed, we need to preserve data required951951- * for read decompression.952952- */953953- size = get_slot_size(zram, index);954954- prio = get_slot_comp_priority(zram, index);955955- huge = test_slot_flag(zram, index, ZRAM_HUGE);956956- }957957-958958- slot_free(zram, index);959959- set_slot_flag(zram, index, ZRAM_WB);949949+ clear_slot_flag(zram, index, ZRAM_IDLE);950950+ if (test_slot_flag(zram, index, ZRAM_HUGE))951951+ atomic64_dec(&zram->stats.huge_pages);952952+ atomic64_sub(get_slot_size(zram, index), &zram->stats.compr_data_size);953953+ zs_free(zram->mem_pool, get_slot_handle(zram, index));960954 set_slot_handle(zram, index, req->blk_idx);961961-962962- if (zram->compressed_wb) {963963- if (huge)964964- set_slot_flag(zram, index, ZRAM_HUGE);965965- set_slot_size(zram, index, size);966966- set_slot_comp_priority(zram, index, prio);967967- }968968-969969- atomic64_inc(&zram->stats.pages_stored);955955+ set_slot_flag(zram, index, ZRAM_WB);970956971957out:972958 slot_unlock(zram, index);···19942010 set_slot_comp_priority(zram, index, 0);1995201119962012 if (test_slot_flag(zram, index, ZRAM_HUGE)) {20132013+ /*20142014+ * Writeback completion decrements ->huge_pages but keeps20152015+ * ZRAM_HUGE flag for deferred decompression path.20162016+ */20172017+ if (!test_slot_flag(zram, index, ZRAM_WB))20182018+ atomic64_dec(&zram->stats.huge_pages);19972019 clear_slot_flag(zram, index, ZRAM_HUGE);19981998- atomic64_dec(&zram->stats.huge_pages);19992020 }2000202120012022 if (test_slot_flag(zram, index, ZRAM_WB)) {
+8-3
drivers/bluetooth/btintel.c
···251251252252 bt_dev_err(hdev, "Hardware error 0x%2.2x", code);253253254254+ hci_req_sync_lock(hdev);255255+254256 skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);255257 if (IS_ERR(skb)) {256258 bt_dev_err(hdev, "Reset after hardware error failed (%ld)",257259 PTR_ERR(skb));258258- return;260260+ goto unlock;259261 }260262 kfree_skb(skb);261263···265263 if (IS_ERR(skb)) {266264 bt_dev_err(hdev, "Retrieving Intel exception info failed (%ld)",267265 PTR_ERR(skb));268268- return;266266+ goto unlock;269267 }270268271269 if (skb->len != 13) {272270 bt_dev_err(hdev, "Exception info size mismatch");273271 kfree_skb(skb);274274- return;272272+ goto unlock;275273 }276274277275 bt_dev_err(hdev, "Exception info %s", (char *)(skb->data + 1));278276279277 kfree_skb(skb);278278+279279+unlock:280280+ hci_req_sync_unlock(hdev);280281}281282EXPORT_SYMBOL_GPL(btintel_hw_error);282283
···541541 if (err || !fw->data || !fw->size) {542542 bt_dev_err(lldev->hu.hdev, "request_firmware failed(errno %d) for %s",543543 err, bts_scr_name);544544+ if (!err)545545+ release_firmware(fw);544546 return -EINVAL;545547 }546548 ptr = (void *)fw->data;
+3-6
drivers/cpufreq/cpufreq.c
···14271427 * If there is a problem with its frequency table, take it14281428 * offline and drop it.14291429 */14301430- if (policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_ASCENDING &&14311431- policy->freq_table_sorted != CPUFREQ_TABLE_SORTED_DESCENDING) {14321432- ret = cpufreq_table_validate_and_sort(policy);14331433- if (ret)14341434- goto out_offline_policy;14351435- }14301430+ ret = cpufreq_table_validate_and_sort(policy);14311431+ if (ret)14321432+ goto out_offline_policy;1436143314371434 /* related_cpus should at least include policy->cpus. */14381435 cpumask_copy(policy->related_cpus, policy->cpus);
+12
drivers/cpufreq/cpufreq_conservative.c
···313313 dbs_info->requested_freq = policy->cur;314314}315315316316+static void cs_limits(struct cpufreq_policy *policy)317317+{318318+ struct cs_policy_dbs_info *dbs_info = to_dbs_info(policy->governor_data);319319+320320+ /*321321+ * The limits have changed, so may have the current frequency. Reset322322+ * requested_freq to avoid any unintended outcomes due to the mismatch.323323+ */324324+ dbs_info->requested_freq = policy->cur;325325+}326326+316327static struct dbs_governor cs_governor = {317328 .gov = CPUFREQ_DBS_GOVERNOR_INITIALIZER("conservative"),318329 .kobj_type = { .default_groups = cs_groups },···333322 .init = cs_init,334323 .exit = cs_exit,335324 .start = cs_start,325325+ .limits = cs_limits,336326};337327338328#define CPU_FREQ_GOV_CONSERVATIVE (cs_governor.gov)
···360360 if (policy_has_boost_freq(policy))361361 policy->boost_supported = true;362362363363+ if (policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_ASCENDING ||364364+ policy->freq_table_sorted == CPUFREQ_TABLE_SORTED_DESCENDING)365365+ return 0;366366+363367 return set_freq_table_sorted(policy);364368}365369
+1
drivers/cxl/Kconfig
···5959 tristate "CXL ACPI: Platform Support"6060 depends on ACPI6161 depends on ACPI_NUMA6262+ depends on CXL_PMEM || !CXL_PMEM6263 default CXL_BUS6364 select ACPI_TABLE_LIB6465 select ACPI_HMAT
+9-16
drivers/cxl/core/hdm.c
···9494 struct cxl_hdm *cxlhdm;9595 void __iomem *hdm;9696 u32 ctrl;9797- int i;98979998 if (!info)10099 return false;···112113 return false;113114114115 /*115115- * If any decoders are committed already, there should not be any116116- * emulated DVSEC decoders.116116+ * If HDM decoders are globally enabled, do not fall back to DVSEC117117+ * range emulation. Zeroed decoder registers after region teardown118118+ * do not imply absence of HDM capability.119119+ *120120+ * Falling back to DVSEC here would treat the decoder as AUTO and121121+ * may incorrectly latch default interleave settings.117122 */118118- for (i = 0; i < cxlhdm->decoder_count; i++) {119119- ctrl = readl(hdm + CXL_HDM_DECODER0_CTRL_OFFSET(i));120120- dev_dbg(&info->port->dev,121121- "decoder%d.%d: committed: %ld base: %#x_%.8x size: %#x_%.8x\n",122122- info->port->id, i,123123- FIELD_GET(CXL_HDM_DECODER0_CTRL_COMMITTED, ctrl),124124- readl(hdm + CXL_HDM_DECODER0_BASE_HIGH_OFFSET(i)),125125- readl(hdm + CXL_HDM_DECODER0_BASE_LOW_OFFSET(i)),126126- readl(hdm + CXL_HDM_DECODER0_SIZE_HIGH_OFFSET(i)),127127- readl(hdm + CXL_HDM_DECODER0_SIZE_LOW_OFFSET(i)));128128- if (FIELD_GET(CXL_HDM_DECODER0_CTRL_COMMITTED, ctrl))129129- return false;130130- }123123+ ctrl = readl(hdm + CXL_HDM_DECODER_CTRL_OFFSET);124124+ if (ctrl & CXL_HDM_DECODER_ENABLE)125125+ return false;131126132127 return true;133128}
+1-1
drivers/cxl/core/mbox.c
···13011301 * Require an endpoint to be safe otherwise the driver can not13021302 * be sure that the device is unmapped.13031303 */13041304- if (endpoint && cxl_num_decoders_committed(endpoint) == 0)13041304+ if (cxlmd->dev.driver && cxl_num_decoders_committed(endpoint) == 0)13051305 return __cxl_mem_sanitize(mds, cmd);1306130613071307 return -EBUSY;
···692692 goto err_ib_sched;693693 }694694695695- /* Drop the initial kref_init count (see drm_sched_main as example) */696696- dma_fence_put(f);697695 ret = dma_fence_wait(f, false);696696+ /* Drop the returned fence reference after the wait completes */697697+ dma_fence_put(f);698698699699err_ib_sched:700700 amdgpu_job_free(job);
+11-2
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
···4207420742084208static int amdgpu_device_get_job_timeout_settings(struct amdgpu_device *adev)42094209{42104210- char *input = amdgpu_lockup_timeout;42104210+ char buf[AMDGPU_MAX_TIMEOUT_PARAM_LENGTH];42114211+ char *input = buf;42114212 char *timeout_setting = NULL;42124213 int index = 0;42134214 long timeout;···42184217 adev->gfx_timeout = adev->compute_timeout = adev->sdma_timeout =42194218 adev->video_timeout = msecs_to_jiffies(2000);4220421942214221- if (!strnlen(input, AMDGPU_MAX_TIMEOUT_PARAM_LENGTH))42204220+ if (!strnlen(amdgpu_lockup_timeout, AMDGPU_MAX_TIMEOUT_PARAM_LENGTH))42224221 return 0;42224222+42234223+ /*42244224+ * strsep() destructively modifies its input by replacing delimiters42254225+ * with '\0'. Use a stack copy so the global module parameter buffer42264226+ * remains intact for multi-GPU systems where this function is called42274227+ * once per device.42284228+ */42294229+ strscpy(buf, amdgpu_lockup_timeout, sizeof(buf));4223423042244231 while ((timeout_setting = strsep(&input, ",")) &&42254232 strnlen(timeout_setting, AMDGPU_MAX_TIMEOUT_PARAM_LENGTH)) {
+32-13
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
···3535 * PASIDs are global address space identifiers that can be shared3636 * between the GPU, an IOMMU and the driver. VMs on different devices3737 * may use the same PASID if they share the same address3838- * space. Therefore PASIDs are allocated using a global IDA. VMs are3939- * looked up from the PASID per amdgpu_device.3838+ * space. Therefore PASIDs are allocated using IDR cyclic allocator3939+ * (similar to kernel PID allocation) which naturally delays reuse.4040+ * VMs are looked up from the PASID per amdgpu_device.4041 */4141-static DEFINE_IDA(amdgpu_pasid_ida);4242+4343+static DEFINE_IDR(amdgpu_pasid_idr);4444+static DEFINE_SPINLOCK(amdgpu_pasid_idr_lock);42454346/* Helper to free pasid from a fence callback */4447struct amdgpu_pasid_cb {···5350 * amdgpu_pasid_alloc - Allocate a PASID5451 * @bits: Maximum width of the PASID in bits, must be at least 15552 *5656- * Allocates a PASID of the given width while keeping smaller PASIDs5757- * available if possible.5353+ * Uses kernel's IDR cyclic allocator (same as PID allocation).5454+ * Allocates sequentially with automatic wrap-around.5855 *5956 * Returns a positive integer on success. Returns %-EINVAL if bits==0.6057 * Returns %-ENOSPC if no PASID was available. Returns %-ENOMEM on···6259 */6360int amdgpu_pasid_alloc(unsigned int bits)6461{6565- int pasid = -EINVAL;6262+ int pasid;66636767- for (bits = min(bits, 31U); bits > 0; bits--) {6868- pasid = ida_alloc_range(&amdgpu_pasid_ida, 1U << (bits - 1),6969- (1U << bits) - 1, GFP_KERNEL);7070- if (pasid != -ENOSPC)7171- break;7272- }6464+ if (bits == 0)6565+ return -EINVAL;6666+6767+ spin_lock(&amdgpu_pasid_idr_lock);6868+ pasid = idr_alloc_cyclic(&amdgpu_pasid_idr, NULL, 1,6969+ 1U << bits, GFP_KERNEL);7070+ spin_unlock(&amdgpu_pasid_idr_lock);73717472 if (pasid >= 0)7573 trace_amdgpu_pasid_allocated(pasid);···8581void amdgpu_pasid_free(u32 pasid)8682{8783 trace_amdgpu_pasid_freed(pasid);8888- ida_free(&amdgpu_pasid_ida, pasid);8484+8585+ spin_lock(&amdgpu_pasid_idr_lock);8686+ idr_remove(&amdgpu_pasid_idr, pasid);8787+ spin_unlock(&amdgpu_pasid_idr_lock);8988}90899190static void amdgpu_pasid_free_cb(struct dma_fence *fence,···622615 dma_fence_put(id->pasid_mapping);623616 }624617 }618618+}619619+620620+/**621621+ * amdgpu_pasid_mgr_cleanup - cleanup PASID manager622622+ *623623+ * Cleanup the IDR allocator.624624+ */625625+void amdgpu_pasid_mgr_cleanup(void)626626+{627627+ spin_lock(&amdgpu_pasid_idr_lock);628628+ idr_destroy(&amdgpu_pasid_idr);629629+ spin_unlock(&amdgpu_pasid_idr_lock);625630}
···31703170 struct kfd_process *process;31713171 int ret;3172317231733173- /* Each FD owns only one kfd_process */31743174- if (p->context_id != KFD_CONTEXT_ID_PRIMARY)31733173+ if (!filep->private_data || !p)31753174 return -EINVAL;3176317531773177- if (!filep->private_data || !p)31763176+ /* Each FD owns only one kfd_process */31773177+ if (p->context_id != KFD_CONTEXT_ID_PRIMARY)31783178 return -EINVAL;3179317931803180 mutex_lock(&kfd_processes_mutex);
+8-2
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
···3909390939103910 aconnector->dc_sink = sink;39113911 dc_sink_retain(aconnector->dc_sink);39123912+ drm_edid_free(aconnector->drm_edid);39133913+ aconnector->drm_edid = NULL;39123914 if (sink->dc_edid.length == 0) {39133913- aconnector->drm_edid = NULL;39143915 hdmi_cec_unset_edid(aconnector);39153916 if (aconnector->dc_link->aux_mode) {39163917 drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux);···54235422 caps = &dm->backlight_caps[aconnector->bl_idx];5424542354255424 /* Only offer ABM property when non-OLED and user didn't turn off by module parameter */54265426- if (!caps->ext_caps->bits.oled && amdgpu_dm_abm_level < 0)54255425+ if (caps->ext_caps && !caps->ext_caps->bits.oled && amdgpu_dm_abm_level < 0)54275426 drm_object_attach_property(&aconnector->base.base,54285427 dm->adev->mode_info.abm_level_property,54295428 ABM_SYSFS_CONTROL);···1252412523 }12525125241252612525 if (dc_resource_is_dsc_encoding_supported(dc)) {1252612526+ for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {1252712527+ dm_new_crtc_state = to_dm_crtc_state(new_crtc_state);1252812528+ dm_new_crtc_state->mode_changed_independent_from_dsc = new_crtc_state->mode_changed;1252912529+ }1253012530+1252712531 for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {1252812532 if (drm_atomic_crtc_needs_modeset(new_crtc_state)) {1252912533 ret = add_affected_mst_dsc_crtcs(state, crtc);
···602602 drm_syncobj_get(syncobj);603603604604 ret = xa_alloc(&file_private->syncobj_xa, handle, syncobj, xa_limit_32b,605605- GFP_NOWAIT);605605+ GFP_KERNEL);606606 if (ret)607607 drm_syncobj_put(syncobj);608608···716716 drm_syncobj_get(syncobj);717717718718 ret = xa_alloc(&file_private->syncobj_xa, handle, syncobj, xa_limit_32b,719719- GFP_NOWAIT);719719+ GFP_KERNEL);720720 if (ret)721721 drm_syncobj_put(syncobj);722722
+7-1
drivers/gpu/drm/i915/display/intel_display.c
···46024602 struct intel_crtc_state *crtc_state =46034603 intel_atomic_get_new_crtc_state(state, crtc);46044604 struct intel_crtc_state *saved_state;46054605+ int err;4605460646064607 saved_state = intel_crtc_state_alloc(crtc);46074608 if (!saved_state)···46114610 /* free the old crtc_state->hw members */46124611 intel_crtc_free_hw_state(crtc_state);4613461246144614- intel_dp_tunnel_atomic_clear_stream_bw(state, crtc_state);46134613+ err = intel_dp_tunnel_atomic_clear_stream_bw(state, crtc_state);46144614+ if (err) {46154615+ kfree(saved_state);46164616+46174617+ return err;46184618+ }4615461946164620 /* FIXME: before the switch to atomic started, a new pipe_config was46174621 * kzalloc'd. Code that depends on any field being zero should be
+14-6
drivers/gpu/drm/i915/display/intel_dp_tunnel.c
···621621 *622622 * Clear any DP tunnel stream BW requirement set by623623 * intel_dp_tunnel_atomic_compute_stream_bw().624624+ *625625+ * Returns 0 in case of success, a negative error code otherwise.624626 */625625-void intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state,626626- struct intel_crtc_state *crtc_state)627627+int intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state,628628+ struct intel_crtc_state *crtc_state)627629{628630 struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);631631+ int err;629632630633 if (!crtc_state->dp_tunnel_ref.tunnel)631631- return;634634+ return 0;632635633633- drm_dp_tunnel_atomic_set_stream_bw(&state->base,634634- crtc_state->dp_tunnel_ref.tunnel,635635- crtc->pipe, 0);636636+ err = drm_dp_tunnel_atomic_set_stream_bw(&state->base,637637+ crtc_state->dp_tunnel_ref.tunnel,638638+ crtc->pipe, 0);639639+ if (err)640640+ return err;641641+636642 drm_dp_tunnel_ref_put(&crtc_state->dp_tunnel_ref);643643+644644+ return 0;637645}638646639647/**
···496496497497 val = intel_de_read_fw(display, GMBUS3(display));498498 do {499499- if (extra_byte_added && len == 1)499499+ if (extra_byte_added && len == 1) {500500+ len--;500501 break;502502+ }501503502504 *buf++ = val & 0xff;503505 val >>= 8;
···14421442 err = vma_check_userptr(vm, op->map.vma, pt_update);14431443 break;14441444 case DRM_GPUVA_OP_REMAP:14451445- if (op->remap.prev)14451445+ if (op->remap.prev && !op->remap.skip_prev)14461446 err = vma_check_userptr(vm, op->remap.prev, pt_update);14471447- if (!err && op->remap.next)14471447+ if (!err && op->remap.next && !op->remap.skip_next)14481448 err = vma_check_userptr(vm, op->remap.next, pt_update);14491449 break;14501450 case DRM_GPUVA_OP_UNMAP:···2198219821992199 err = unbind_op_prepare(tile, pt_update_ops, old);2200220022012201- if (!err && op->remap.prev) {22012201+ if (!err && op->remap.prev && !op->remap.skip_prev) {22022202 err = bind_op_prepare(vm, tile, pt_update_ops,22032203 op->remap.prev, false);22042204 pt_update_ops->wait_vm_bookkeep = true;22052205 }22062206- if (!err && op->remap.next) {22062206+ if (!err && op->remap.next && !op->remap.skip_next) {22072207 err = bind_op_prepare(vm, tile, pt_update_ops,22082208 op->remap.next, false);22092209 pt_update_ops->wait_vm_bookkeep = true;···2428242824292429 unbind_op_commit(vm, tile, pt_update_ops, old, fence, fence2);2430243024312431- if (op->remap.prev)24312431+ if (op->remap.prev && !op->remap.skip_prev)24322432 bind_op_commit(vm, tile, pt_update_ops, op->remap.prev,24332433 fence, fence2, false);24342434- if (op->remap.next)24342434+ if (op->remap.next && !op->remap.skip_next)24352435 bind_op_commit(vm, tile, pt_update_ops, op->remap.next,24362436 fence, fence2, false);24372437 break;
+2
drivers/gpu/drm/xe/xe_sriov_packet.c
···341341 ret = xe_sriov_pf_migration_restore_produce(xe, vfid, *data);342342 if (ret) {343343 xe_sriov_packet_free(*data);344344+ *data = NULL;345345+344346 return ret;345347 }346348
+18-4
drivers/gpu/drm/xe/xe_vm.c
···25542554 if (!err && op->remap.skip_prev) {25552555 op->remap.prev->tile_present =25562556 tile_present;25572557- op->remap.prev = NULL;25582557 }25592558 }25602559 if (op->remap.next) {···25632564 if (!err && op->remap.skip_next) {25642565 op->remap.next->tile_present =25652566 tile_present;25662566- op->remap.next = NULL;25672567 }25682568 }2569256925702570- /* Adjust for partial unbind after removing VMA from VM */25702570+ /*25712571+ * Adjust for partial unbind after removing VMA from VM. In case25722572+ * of unwind we might need to undo this later.25732573+ */25712574 if (!err) {25722575 op->base.remap.unmap->va->va.addr = op->remap.start;25732576 op->base.remap.unmap->va->va.range = op->remap.range;···2688268726892688 op->remap.start = xe_vma_start(old);26902689 op->remap.range = xe_vma_size(old);26902690+ op->remap.old_start = op->remap.start;26912691+ op->remap.old_range = op->remap.range;2691269226922693 flags |= op->base.remap.unmap->va->flags & XE_VMA_CREATE_MASK;26932694 if (op->base.remap.prev) {···28382835 xe_svm_notifier_lock(vm);28392836 vma->gpuva.flags &= ~XE_VMA_DESTROYED;28402837 xe_svm_notifier_unlock(vm);28412841- if (post_commit)28382838+ if (post_commit) {28392839+ /*28402840+ * Restore the old va range, in case of the28412841+ * prev/next skip optimisation. Otherwise what28422842+ * we re-insert here could be smaller than the28432843+ * original range.28442844+ */28452845+ op->base.remap.unmap->va->va.addr =28462846+ op->remap.old_start;28472847+ op->base.remap.unmap->va->va.range =28482848+ op->remap.old_range;28422849 xe_vm_insert_vma(vm, vma);28502850+ }28432851 }28442852 break;28452853 }
+4
drivers/gpu/drm/xe/xe_vm_types.h
···373373 u64 start;374374 /** @range: range of the VMA unmap */375375 u64 range;376376+ /** @old_start: Original start of the VMA we unmap */377377+ u64 old_start;378378+ /** @old_range: Original range of the VMA we unmap */379379+ u64 old_range;376380 /** @skip_prev: skip prev rebind */377381 bool skip_prev;378382 /** @skip_next: skip next rebind */
···10181018 return 0;10191019}1020102010211021-static inline void i2c_imx_isr_read_continue(struct imx_i2c_struct *i2c_imx)10211021+static inline enum imx_i2c_state i2c_imx_isr_read_continue(struct imx_i2c_struct *i2c_imx)10221022{10231023+ enum imx_i2c_state next_state = IMX_I2C_STATE_READ_CONTINUE;10231024 unsigned int temp;1024102510251026 if ((i2c_imx->msg->len - 1) == i2c_imx->msg_buf_idx) {···10341033 i2c_imx->stopped = 1;10351034 temp &= ~(I2CR_MSTA | I2CR_MTX);10361035 imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);10371037- } else {10381038- /*10391039- * For i2c master receiver repeat restart operation like:10401040- * read -> repeat MSTA -> read/write10411041- * The controller must set MTX before read the last byte in10421042- * the first read operation, otherwise the first read cost10431043- * one extra clock cycle.10441044- */10451045- temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);10461046- temp |= I2CR_MTX;10471047- imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);10361036+10371037+ return IMX_I2C_STATE_DONE;10481038 }10391039+ /*10401040+ * For i2c master receiver repeat restart operation like:10411041+ * read -> repeat MSTA -> read/write10421042+ * The controller must set MTX before read the last byte in10431043+ * the first read operation, otherwise the first read cost10441044+ * one extra clock cycle.10451045+ */10461046+ temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);10471047+ temp |= I2CR_MTX;10481048+ imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2CR);10491049+ next_state = IMX_I2C_STATE_DONE;10491050 } else if (i2c_imx->msg_buf_idx == (i2c_imx->msg->len - 2)) {10501051 temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);10511052 temp |= I2CR_TXAK;···10551052 }1056105310571054 i2c_imx->msg->buf[i2c_imx->msg_buf_idx++] = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2DR);10551055+ return next_state;10581056}1059105710601058static inline void i2c_imx_isr_read_block_data_len(struct imx_i2c_struct *i2c_imx)···10921088 break;1093108910941090 case IMX_I2C_STATE_READ_CONTINUE:10951095- i2c_imx_isr_read_continue(i2c_imx);10961096- if (i2c_imx->msg_buf_idx == i2c_imx->msg->len) {10971097- i2c_imx->state = IMX_I2C_STATE_DONE;10911091+ i2c_imx->state = i2c_imx_isr_read_continue(i2c_imx);10921092+ if (i2c_imx->state == IMX_I2C_STATE_DONE)10981093 wake_up(&i2c_imx->queue);10991099- }11001094 break;1101109511021096 case IMX_I2C_STATE_READ_BLOCK_DATA:···14921490 bool is_lastmsg)14931491{14941492 int block_data = msgs->flags & I2C_M_RECV_LEN;14931493+ int ret = 0;1495149414961495 dev_dbg(&i2c_imx->adapter.dev,14971496 "<%s> write slave address: addr=0x%x\n",···15251522 dev_err(&i2c_imx->adapter.dev, "<%s> read timedout\n", __func__);15261523 return -ETIMEDOUT;15271524 }15281528- if (!i2c_imx->stopped)15291529- return i2c_imx_bus_busy(i2c_imx, 0, false);15251525+ if (i2c_imx->is_lastmsg) {15261526+ if (!i2c_imx->stopped)15271527+ ret = i2c_imx_bus_busy(i2c_imx, 0, false);15281528+ /*15291529+ * Only read the last byte of the last message after the bus is15301530+ * not busy. Else the controller generates another clock which15311531+ * might confuse devices.15321532+ */15331533+ if (!ret)15341534+ i2c_imx->msg->buf[i2c_imx->msg_buf_idx++] = imx_i2c_read_reg(i2c_imx,15351535+ IMX_I2C_I2DR);15361536+ }1530153715311531- return 0;15381538+ return ret;15321539}1533154015341541static int i2c_imx_xfer_common(struct i2c_adapter *adapter,
+30-13
drivers/infiniband/core/rw.c
···608608 if (rdma_rw_io_needs_mr(qp->device, port_num, dir, sg_cnt)) {609609 ret = rdma_rw_init_mr_wrs(ctx, qp, port_num, sg, sg_cnt,610610 sg_offset, remote_addr, rkey, dir);611611- } else if (sg_cnt > 1) {612612- ret = rdma_rw_init_map_wrs(ctx, qp, sg, sg_cnt, sg_offset,613613- remote_addr, rkey, dir);614614- } else {615615- ret = rdma_rw_init_single_wr(ctx, qp, sg, sg_offset,616616- remote_addr, rkey, dir);611611+ /*612612+ * If MR init succeeded or failed for a reason other613613+ * than pool exhaustion, that result is final.614614+ *615615+ * Pool exhaustion (-EAGAIN) from the max_sgl_rd616616+ * optimization is recoverable: fall back to617617+ * direct SGE posting. iWARP and force_mr require618618+ * MRs unconditionally, so -EAGAIN is terminal.619619+ */620620+ if (ret != -EAGAIN ||621621+ rdma_protocol_iwarp(qp->device, port_num) ||622622+ unlikely(rdma_rw_force_mr))623623+ goto out;617624 }618625626626+ if (sg_cnt > 1)627627+ ret = rdma_rw_init_map_wrs(ctx, qp, sg, sg_cnt, sg_offset,628628+ remote_addr, rkey, dir);629629+ else630630+ ret = rdma_rw_init_single_wr(ctx, qp, sg, sg_offset,631631+ remote_addr, rkey, dir);632632+633633+out:619634 if (ret < 0)620635 goto out_unmap_sg;621636 return ret;···701686 return ret;702687703688 /*704704- * IOVA mapping not available. Check if MR registration provides705705- * better performance than multiple SGE entries.689689+ * IOVA not available; fall back to the map_wrs path, which maps690690+ * each bvec as a direct SGE. This is always correct: the MR path691691+ * is a throughput optimization, not a correctness requirement.692692+ * (iWARP, which does require MRs, is handled by the check above.)693693+ *694694+ * The rdma_rw_io_needs_mr() gate is not used here because nr_bvec695695+ * is a raw page count that overstates DMA entry demand -- the bvec696696+ * caller has no post-DMA-coalescing segment count, and feeding the697697+ * inflated count into the MR path exhausts the pool on RDMA READs.706698 */707707- if (rdma_rw_io_needs_mr(dev, port_num, dir, nr_bvec))708708- return rdma_rw_init_mr_wrs_bvec(ctx, qp, port_num, bvecs,709709- nr_bvec, &iter, remote_addr,710710- rkey, dir);711711-712699 return rdma_rw_init_map_wrs_bvec(ctx, qp, bvecs, nr_bvec, &iter,713700 remote_addr, rkey, dir);714701}
+3-2
drivers/infiniband/core/umem.c
···55555656 if (dirty)5757 ib_dma_unmap_sgtable_attrs(dev, &umem->sgt_append.sgt,5858- DMA_BIDIRECTIONAL, 0);5858+ DMA_BIDIRECTIONAL,5959+ DMA_ATTR_REQUIRE_COHERENT);59606061 for_each_sgtable_sg(&umem->sgt_append.sgt, sg, i) {6162 unpin_user_page_range_dirty_lock(sg_page(sg),···170169 unsigned long lock_limit;171170 unsigned long new_pinned;172171 unsigned long cur_base;173173- unsigned long dma_attr = 0;172172+ unsigned long dma_attr = DMA_ATTR_REQUIRE_COHERENT;174173 struct mm_struct *mm;175174 unsigned long npages;176175 int pinned, ret;
···30823082 }3083308330843084 /*30853085- * We need to serialize streamon/off with queueing new requests.30853085+ * We need to serialize streamon/off/reqbufs with queueing new requests.30863086 * These ioctls may trigger the cancellation of a streaming30873087 * operation, and that should not be mixed with queueing a new30883088 * request at the same time.30893089 */30903090 if (v4l2_device_supports_requests(vfd->v4l2_dev) &&30913091- (cmd == VIDIOC_STREAMON || cmd == VIDIOC_STREAMOFF)) {30913091+ (cmd == VIDIOC_STREAMON || cmd == VIDIOC_STREAMOFF ||30923092+ cmd == VIDIOC_REQBUFS)) {30923093 req_queue_lock = &vfd->v4l2_dev->mdev->req_queue_mutex;3093309430943095 if (mutex_lock_interruptible(req_queue_lock))
+3-1
drivers/net/can/dev/netlink.c
···601601 /* We need synchronization with dev->stop() */602602 ASSERT_RTNL();603603604604- can_ctrlmode_changelink(dev, data, extack);604604+ err = can_ctrlmode_changelink(dev, data, extack);605605+ if (err)606606+ return err;605607606608 if (data[IFLA_CAN_BITTIMING]) {607609 struct can_bittiming bt;
+24-5
drivers/net/can/spi/mcp251x.c
···12251225 }1226122612271227 mutex_lock(&priv->mcp_lock);12281228- mcp251x_power_enable(priv->transceiver, 1);12281228+ ret = mcp251x_power_enable(priv->transceiver, 1);12291229+ if (ret) {12301230+ dev_err(&spi->dev, "failed to enable transceiver power: %pe\n", ERR_PTR(ret));12311231+ goto out_close_candev;12321232+ }1229123312301234 priv->force_quit = 0;12311235 priv->tx_skb = NULL;···12761272 mcp251x_hw_sleep(spi);12771273out_close:12781274 mcp251x_power_enable(priv->transceiver, 0);12751275+out_close_candev:12791276 close_candev(net);12801277 mutex_unlock(&priv->mcp_lock);12811278 if (release_irq)···15211516{15221517 struct spi_device *spi = to_spi_device(dev);15231518 struct mcp251x_priv *priv = spi_get_drvdata(spi);15191519+ int ret = 0;1524152015251525- if (priv->after_suspend & AFTER_SUSPEND_POWER)15261526- mcp251x_power_enable(priv->power, 1);15271527- if (priv->after_suspend & AFTER_SUSPEND_UP)15281528- mcp251x_power_enable(priv->transceiver, 1);15211521+ if (priv->after_suspend & AFTER_SUSPEND_POWER) {15221522+ ret = mcp251x_power_enable(priv->power, 1);15231523+ if (ret) {15241524+ dev_err(dev, "failed to restore power: %pe\n", ERR_PTR(ret));15251525+ return ret;15261526+ }15271527+ }15281528+15291529+ if (priv->after_suspend & AFTER_SUSPEND_UP) {15301530+ ret = mcp251x_power_enable(priv->transceiver, 1);15311531+ if (ret) {15321532+ dev_err(dev, "failed to restore transceiver power: %pe\n", ERR_PTR(ret));15331533+ if (priv->after_suspend & AFTER_SUSPEND_POWER)15341534+ mcp251x_power_enable(priv->power, 0);15351535+ return ret;15361536+ }15371537+ }1529153815301539 if (priv->after_suspend & (AFTER_SUSPEND_POWER | AFTER_SUSPEND_UP))15311540 queue_work(priv->wq, &priv->restart_work);
···2525 select SSB2626 select MII2727 select PHYLIB2828- select FIXED_PHY if BCM47XX2828+ select FIXED_PHY2929 help3030 If you have a network (Ethernet) controller of this type, say Y3131 or M here.
+23-18
drivers/net/ethernet/broadcom/asp2/bcmasp.c
···11521152 }11531153}1154115411551155-static void bcmasp_wol_irq_destroy(struct bcmasp_priv *priv)11561156-{11571157- if (priv->wol_irq > 0)11581158- free_irq(priv->wol_irq, priv);11591159-}11601160-11611155static void bcmasp_eee_fixup(struct bcmasp_intf *intf, bool en)11621156{11631157 u32 reg, phy_lpi_overwrite;···12491255 if (priv->irq <= 0)12501256 return -EINVAL;1251125712521252- priv->clk = devm_clk_get_optional_enabled(dev, "sw_asp");12581258+ priv->clk = devm_clk_get_optional(dev, "sw_asp");12531259 if (IS_ERR(priv->clk))12541260 return dev_err_probe(dev, PTR_ERR(priv->clk),12551261 "failed to request clock\n");···1277128312781284 bcmasp_set_pdata(priv, pdata);1279128512861286+ ret = clk_prepare_enable(priv->clk);12871287+ if (ret)12881288+ return dev_err_probe(dev, ret, "failed to start clock\n");12891289+12801290 /* Enable all clocks to ensure successful probing */12811291 bcmasp_core_clock_set(priv, ASP_CTRL_CLOCK_CTRL_ASP_ALL_DISABLE, 0);12821292···1292129412931295 ret = devm_request_irq(&pdev->dev, priv->irq, bcmasp_isr, 0,12941296 pdev->name, priv);12951295- if (ret)12961296- return dev_err_probe(dev, ret, "failed to request ASP interrupt: %d", ret);12971297+ if (ret) {12981298+ dev_err(dev, "Failed to request ASP interrupt: %d", ret);12991299+ goto err_clock_disable;13001300+ }1297130112981302 /* Register mdio child nodes */12991303 of_platform_populate(dev->of_node, bcmasp_mdio_of_match, NULL, dev);···1307130713081308 priv->mda_filters = devm_kcalloc(dev, priv->num_mda_filters,13091309 sizeof(*priv->mda_filters), GFP_KERNEL);13101310- if (!priv->mda_filters)13111311- return -ENOMEM;13101310+ if (!priv->mda_filters) {13111311+ ret = -ENOMEM;13121312+ goto err_clock_disable;13131313+ }1312131413131315 priv->net_filters = devm_kcalloc(dev, priv->num_net_filters,13141316 sizeof(*priv->net_filters), GFP_KERNEL);13151315- if (!priv->net_filters)13161316- return -ENOMEM;13171317+ if (!priv->net_filters) {13181318+ ret = -ENOMEM;13191319+ goto err_clock_disable;13201320+ }1317132113181322 bcmasp_core_init_filters(priv);13191323···13261322 ports_node = of_find_node_by_name(dev->of_node, "ethernet-ports");13271323 if (!ports_node) {13281324 dev_warn(dev, "No ports found\n");13291329- return -EINVAL;13251325+ ret = -EINVAL;13261326+ goto err_clock_disable;13301327 }1331132813321329 i = 0;···13491344 */13501345 bcmasp_core_clock_set(priv, 0, ASP_CTRL_CLOCK_CTRL_ASP_ALL_DISABLE);1351134613521352- clk_disable_unprepare(priv->clk);13531353-13541347 /* Now do the registration of the network ports which will take care13551348 * of managing the clock properly.13561349 */···13611358 count++;13621359 }1363136013611361+ clk_disable_unprepare(priv->clk);13621362+13641363 dev_info(dev, "Initialized %d port(s)\n", count);1365136413661365 return ret;1367136613681367err_cleanup:13691369- bcmasp_wol_irq_destroy(priv);13701368 bcmasp_remove_intfs(priv);13691369+err_clock_disable:13701370+ clk_disable_unprepare(priv->clk);1371137113721372 return ret;13731373}···13821376 if (!priv)13831377 return;1384137813851385- bcmasp_wol_irq_destroy(priv);13861379 bcmasp_remove_intfs(priv);13871380}13881381
+25-16
drivers/net/ethernet/cadence/macb_main.c
···10711071 }1072107210731073 if (tx_skb->skb) {10741074- napi_consume_skb(tx_skb->skb, budget);10741074+ dev_consume_skb_any(tx_skb->skb);10751075 tx_skb->skb = NULL;10761076 }10771077}···32243224 spin_lock_irq(&bp->stats_lock);32253225 gem_update_stats(bp);32263226 memcpy(data, &bp->ethtool_stats, sizeof(u64)32273227- * (GEM_STATS_LEN + QUEUE_STATS_LEN * MACB_MAX_QUEUES));32273227+ * (GEM_STATS_LEN + QUEUE_STATS_LEN * bp->num_queues));32283228 spin_unlock_irq(&bp->stats_lock);32293229}32303230···57765776 struct macb_queue *queue;57775777 struct in_device *idev;57785778 unsigned long flags;57795779+ u32 tmp, ifa_local;57795780 unsigned int q;57805781 int err;57815781- u32 tmp;5782578257835783 if (!device_may_wakeup(&bp->dev->dev))57845784 phy_exit(bp->phy);···57875787 return 0;5788578857895789 if (bp->wol & MACB_WOL_ENABLED) {57905790- /* Check for IP address in WOL ARP mode */57915791- idev = __in_dev_get_rcu(bp->dev);57925792- if (idev)57935793- ifa = rcu_dereference(idev->ifa_list);57945794- if ((bp->wolopts & WAKE_ARP) && !ifa) {57955795- netdev_err(netdev, "IP address not assigned as required by WoL walk ARP\n");57965796- return -EOPNOTSUPP;57905790+ if (bp->wolopts & WAKE_ARP) {57915791+ /* Check for IP address in WOL ARP mode */57925792+ rcu_read_lock();57935793+ idev = __in_dev_get_rcu(bp->dev);57945794+ if (idev)57955795+ ifa = rcu_dereference(idev->ifa_list);57965796+ if (!ifa) {57975797+ rcu_read_unlock();57985798+ netdev_err(netdev, "IP address not assigned as required by WoL walk ARP\n");57995799+ return -EOPNOTSUPP;58005800+ }58015801+ ifa_local = be32_to_cpu(ifa->ifa_local);58025802+ rcu_read_unlock();57975803 }58045804+57985805 spin_lock_irqsave(&bp->lock, flags);5799580658005807 /* Disable Tx and Rx engines before disabling the queues,···58405833 if (bp->wolopts & WAKE_ARP) {58415834 tmp |= MACB_BIT(ARP);58425835 /* write IP address into register */58435843- tmp |= MACB_BFEXT(IP, be32_to_cpu(ifa->ifa_local));58365836+ tmp |= MACB_BFEXT(IP, ifa_local);58445837 }58385838+ spin_unlock_irqrestore(&bp->lock, flags);5845583958465840 /* Change interrupt handler and58475841 * Enable WoL IRQ on queue 0···58555847 dev_err(dev,58565848 "Unable to request IRQ %d (error %d)\n",58575849 bp->queues[0].irq, err);58585858- spin_unlock_irqrestore(&bp->lock, flags);58595850 return err;58605851 }58525852+ spin_lock_irqsave(&bp->lock, flags);58615853 queue_writel(bp->queues, IER, GEM_BIT(WOL));58625854 gem_writel(bp, WOL, tmp);58555855+ spin_unlock_irqrestore(&bp->lock, flags);58635856 } else {58645857 err = devm_request_irq(dev, bp->queues[0].irq, macb_wol_interrupt,58655858 IRQF_SHARED, netdev->name, bp->queues);···58685859 dev_err(dev,58695860 "Unable to request IRQ %d (error %d)\n",58705861 bp->queues[0].irq, err);58715871- spin_unlock_irqrestore(&bp->lock, flags);58725862 return err;58735863 }58645864+ spin_lock_irqsave(&bp->lock, flags);58745865 queue_writel(bp->queues, IER, MACB_BIT(WOL));58755866 macb_writel(bp, WOL, tmp);58675867+ spin_unlock_irqrestore(&bp->lock, flags);58765868 }58775877- spin_unlock_irqrestore(&bp->lock, flags);5878586958795870 enable_irq_wake(bp->queues[0].irq);58805871 }···59415932 queue_readl(bp->queues, ISR);59425933 if (bp->caps & MACB_CAPS_ISR_CLEAR_ON_WRITE)59435934 queue_writel(bp->queues, ISR, -1);59355935+ spin_unlock_irqrestore(&bp->lock, flags);59365936+59445937 /* Replace interrupt handler on queue 0 */59455938 devm_free_irq(dev, bp->queues[0].irq, bp->queues);59465939 err = devm_request_irq(dev, bp->queues[0].irq, macb_interrupt,···59515940 dev_err(dev,59525941 "Unable to request IRQ %d (error %d)\n",59535942 bp->queues[0].irq, err);59545954- spin_unlock_irqrestore(&bp->lock, flags);59555943 return err;59565944 }59575957- spin_unlock_irqrestore(&bp->lock, flags);5958594559595946 disable_irq_wake(bp->queues[0].irq);59605947
···313313{314314 /* Report the maximum number queues, even if not every queue is315315 * currently configured. Since allocation of queues is in pairs,316316- * use netdev->real_num_tx_queues * 2. The real_num_tx_queues is set317317- * at device creation and never changes.316316+ * use netdev->num_tx_queues * 2. The num_tx_queues is set at317317+ * device creation and never changes.318318 */319319320320 if (sset == ETH_SS_STATS)321321 return IAVF_STATS_LEN +322322- (IAVF_QUEUE_STATS_LEN * 2 *323323- netdev->real_num_tx_queues);322322+ (IAVF_QUEUE_STATS_LEN * 2 * netdev->num_tx_queues);324323 else325324 return -EINVAL;326325}···344345 iavf_add_ethtool_stats(&data, adapter, iavf_gstrings_stats);345346346347 rcu_read_lock();347347- /* As num_active_queues describe both tx and rx queues, we can use348348- * it to iterate over rings' stats.348348+ /* Use num_tx_queues to report stats for the maximum number of queues.349349+ * Queues beyond num_active_queues will report zero.349350 */350350- for (i = 0; i < adapter->num_active_queues; i++) {351351- struct iavf_ring *ring;351351+ for (i = 0; i < netdev->num_tx_queues; i++) {352352+ struct iavf_ring *tx_ring = NULL, *rx_ring = NULL;352353353353- /* Tx rings stats */354354- ring = &adapter->tx_rings[i];355355- iavf_add_queue_stats(&data, ring);354354+ if (i < adapter->num_active_queues) {355355+ tx_ring = &adapter->tx_rings[i];356356+ rx_ring = &adapter->rx_rings[i];357357+ }356358357357- /* Rx rings stats */358358- ring = &adapter->rx_rings[i];359359- iavf_add_queue_stats(&data, ring);359359+ iavf_add_queue_stats(&data, tx_ring);360360+ iavf_add_queue_stats(&data, rx_ring);360361 }361362 rcu_read_unlock();362363}···375376 iavf_add_stat_strings(&data, iavf_gstrings_stats);376377377378 /* Queues are always allocated in pairs, so we just use378378- * real_num_tx_queues for both Tx and Rx queues.379379+ * num_tx_queues for both Tx and Rx queues.379380 */380380- for (i = 0; i < netdev->real_num_tx_queues; i++) {381381+ for (i = 0; i < netdev->num_tx_queues; i++) {381382 iavf_add_stat_strings(&data, iavf_gstrings_queue_stats,382383 "tx", i);383384 iavf_add_stat_strings(&data, iavf_gstrings_queue_stats,
+22
drivers/net/ethernet/intel/ice/ice.h
···840840}841841842842/**843843+ * ice_get_max_txq - return the maximum number of Tx queues for in a PF844844+ * @pf: PF structure845845+ *846846+ * Return: maximum number of Tx queues847847+ */848848+static inline int ice_get_max_txq(struct ice_pf *pf)849849+{850850+ return min(num_online_cpus(), pf->hw.func_caps.common_cap.num_txq);851851+}852852+853853+/**854854+ * ice_get_max_rxq - return the maximum number of Rx queues for in a PF855855+ * @pf: PF structure856856+ *857857+ * Return: maximum number of Rx queues858858+ */859859+static inline int ice_get_max_rxq(struct ice_pf *pf)860860+{861861+ return min(num_online_cpus(), pf->hw.func_caps.common_cap.num_rxq);862862+}863863+864864+/**843865 * ice_get_main_vsi - Get the PF VSI844866 * @pf: PF instance845867 *
+11-21
drivers/net/ethernet/intel/ice/ice_ethtool.c
···19301930 int i = 0;19311931 char *p;1932193219331933+ if (ice_is_port_repr_netdev(netdev)) {19341934+ ice_update_eth_stats(vsi);19351935+19361936+ for (j = 0; j < ICE_VSI_STATS_LEN; j++) {19371937+ p = (char *)vsi + ice_gstrings_vsi_stats[j].stat_offset;19381938+ data[i++] = (ice_gstrings_vsi_stats[j].sizeof_stat ==19391939+ sizeof(u64)) ? *(u64 *)p : *(u32 *)p;19401940+ }19411941+ return;19421942+ }19431943+19331944 ice_update_pf_stats(pf);19341945 ice_update_vsi_stats(vsi);19351946···19491938 data[i++] = (ice_gstrings_vsi_stats[j].sizeof_stat ==19501939 sizeof(u64)) ? *(u64 *)p : *(u32 *)p;19511940 }19521952-19531953- if (ice_is_port_repr_netdev(netdev))19541954- return;1955194119561942 /* populate per queue stats */19571943 rcu_read_lock();···37793771 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | BIT(HWTSTAMP_FILTER_ALL);3780377237813773 return 0;37823782-}37833783-37843784-/**37853785- * ice_get_max_txq - return the maximum number of Tx queues for in a PF37863786- * @pf: PF structure37873787- */37883788-static int ice_get_max_txq(struct ice_pf *pf)37893789-{37903790- return min(num_online_cpus(), pf->hw.func_caps.common_cap.num_txq);37913791-}37923792-37933793-/**37943794- * ice_get_max_rxq - return the maximum number of Rx queues for in a PF37953795- * @pf: PF structure37963796- */37973797-static int ice_get_max_rxq(struct ice_pf *pf)37983798-{37993799- return min(num_online_cpus(), pf->hw.func_caps.common_cap.num_rxq);38003774}3801377538023776/**
···17191719 if (ether_addr_equal(netdev->dev_addr, mac))17201720 return 0;1721172117221722- err = ionic_program_mac(lif, mac);17231723- if (err < 0)17241724- return err;17221722+ /* Only program macs for virtual functions to avoid losing the permanent17231723+ * Mac across warm reset/reboot.17241724+ */17251725+ if (lif->ionic->pdev->is_virtfn) {17261726+ err = ionic_program_mac(lif, mac);17271727+ if (err < 0)17281728+ return err;1725172917261726- if (err > 0)17271727- netdev_dbg(netdev, "%s: SET and GET ATTR Mac are not equal-due to old FW running\n",17281728- __func__);17301730+ if (err > 0)17311731+ netdev_dbg(netdev, "%s: SET and GET ATTR Mac are not equal-due to old FW running\n",17321732+ __func__);17331733+ }1729173417301735 err = eth_prepare_mac_addr_change(netdev, addr);17311736 if (err)
+2-2
drivers/net/ethernet/ti/icssg/icssg_common.c
···962962 pkt_len -= 4;963963 cppi5_desc_get_tags_ids(&desc_rx->hdr, &port_id, NULL);964964 psdata = cppi5_hdesc_get_psdata(desc_rx);965965- k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx);966965 count++;967966 xsk_buff_set_size(xdp, pkt_len);968967 xsk_buff_dma_sync_for_cpu(xdp);···987988 emac_dispatch_skb_zc(emac, xdp, psdata);988989 xsk_buff_free(xdp);989990 }991991+ k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx);990992 }991993992994 if (xdp_status & ICSSG_XDP_REDIR)···10571057 /* firmware adds 4 CRC bytes, strip them */10581058 pkt_len -= 4;10591059 cppi5_desc_get_tags_ids(&desc_rx->hdr, &port_id, NULL);10601060- k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx);1061106010621061 /* if allocation fails we drop the packet but push the10631062 * descriptor back to the ring with old page to prevent a stall···11141115 ndev->stats.rx_packets++;1115111611161117requeue:11181118+ k3_cppi_desc_pool_free(rx_chn->desc_pool, desc_rx);11171119 /* queue another RX DMA */11181120 ret = prueth_dma_rx_push_mapped(emac, &emac->rx_chns, new_page,11191121 PRUETH_MAX_PKT_SIZE);
+64-1
drivers/net/team/team_core.c
···20582058 * rt netlink interface20592059 ***********************/2060206020612061+/* For tx path we need a linkup && enabled port and for parse any port20622062+ * suffices.20632063+ */20642064+static struct team_port *team_header_port_get_rcu(struct team *team,20652065+ bool txable)20662066+{20672067+ struct team_port *port;20682068+20692069+ list_for_each_entry_rcu(port, &team->port_list, list) {20702070+ if (!txable || team_port_txable(port))20712071+ return port;20722072+ }20732073+20742074+ return NULL;20752075+}20762076+20772077+static int team_header_create(struct sk_buff *skb, struct net_device *team_dev,20782078+ unsigned short type, const void *daddr,20792079+ const void *saddr, unsigned int len)20802080+{20812081+ struct team *team = netdev_priv(team_dev);20822082+ const struct header_ops *port_ops;20832083+ struct team_port *port;20842084+ int ret = 0;20852085+20862086+ rcu_read_lock();20872087+ port = team_header_port_get_rcu(team, true);20882088+ if (port) {20892089+ port_ops = READ_ONCE(port->dev->header_ops);20902090+ if (port_ops && port_ops->create)20912091+ ret = port_ops->create(skb, port->dev,20922092+ type, daddr, saddr, len);20932093+ }20942094+ rcu_read_unlock();20952095+ return ret;20962096+}20972097+20982098+static int team_header_parse(const struct sk_buff *skb,20992099+ const struct net_device *team_dev,21002100+ unsigned char *haddr)21012101+{21022102+ struct team *team = netdev_priv(team_dev);21032103+ const struct header_ops *port_ops;21042104+ struct team_port *port;21052105+ int ret = 0;21062106+21072107+ rcu_read_lock();21082108+ port = team_header_port_get_rcu(team, false);21092109+ if (port) {21102110+ port_ops = READ_ONCE(port->dev->header_ops);21112111+ if (port_ops && port_ops->parse)21122112+ ret = port_ops->parse(skb, port->dev, haddr);21132113+ }21142114+ rcu_read_unlock();21152115+ return ret;21162116+}21172117+21182118+static const struct header_ops team_header_ops = {21192119+ .create = team_header_create,21202120+ .parse = team_header_parse,21212121+};21222122+20612123static void team_setup_by_port(struct net_device *dev,20622124 struct net_device *port_dev)20632125{···21282066 if (port_dev->type == ARPHRD_ETHER)21292067 dev->header_ops = team->header_ops_cache;21302068 else21312131- dev->header_ops = port_dev->header_ops;20692069+ dev->header_ops = port_dev->header_ops ?20702070+ &team_header_ops : NULL;21322071 dev->type = port_dev->type;21332072 dev->hard_header_len = port_dev->hard_header_len;21342073 dev->needed_headroom = port_dev->needed_headroom;
···66menu "PHY Subsystem"7788config PHY_COMMON_PROPS99- bool99+ bool "PHY common properties" if KUNIT_ALL_TESTS1010 help1111 This parses properties common between generic PHYs and Ethernet PHYs.1212···16161717config PHY_COMMON_PROPS_TEST1818 tristate "KUnit tests for PHY common props" if !KUNIT_ALL_TESTS1919- select PHY_COMMON_PROPS2020- depends on KUNIT1919+ depends on KUNIT && PHY_COMMON_PROPS2120 default KUNIT_ALL_TESTS2221 help2322 This builds KUnit tests for the PHY common property API.
···11351135 goto chip_error;11361136 }1137113711381138- ret = mtk_eint_init(pctl, pdev);11391139- if (ret)11401140- goto chip_error;11381138+ /* Only initialize EINT if we have EINT pins */11391139+ if (data->eint_hw.ap_num > 0) {11401140+ ret = mtk_eint_init(pctl, pdev);11411141+ if (ret)11421142+ goto chip_error;11431143+ }1141114411421145 return 0;11431146
+16
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
···723723 .pin_config_group_dbg_show = pmic_gpio_config_dbg_show,724724};725725726726+static int pmic_gpio_get_direction(struct gpio_chip *chip, unsigned pin)727727+{728728+ struct pmic_gpio_state *state = gpiochip_get_data(chip);729729+ struct pmic_gpio_pad *pad;730730+731731+ pad = state->ctrl->desc->pins[pin].drv_data;732732+733733+ if (!pad->is_enabled || pad->analog_pass ||734734+ (!pad->input_enabled && !pad->output_enabled))735735+ return -EINVAL;736736+737737+ /* Make sure the state is aligned on what pmic_gpio_get() returns */738738+ return pad->input_enabled ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;739739+}740740+726741static int pmic_gpio_direction_input(struct gpio_chip *chip, unsigned pin)727742{728743 struct pmic_gpio_state *state = gpiochip_get_data(chip);···816801}817802818803static const struct gpio_chip pmic_gpio_gpio_template = {804804+ .get_direction = pmic_gpio_get_direction,819805 .direction_input = pmic_gpio_direction_input,820806 .direction_output = pmic_gpio_direction_output,821807 .get = pmic_gpio_get,
···6565 select PINMUX6666 select GENERIC_PINCONF6767 select GPIOLIB6868+ select GPIO_GENERIC6869 help6970 The Hardware Debug Port allows the observation of internal signals.7071 It uses configurable multiplexer to route signals in a dedicated observation register.
+32-11
drivers/pinctrl/sunxi/pinctrl-sunxi.c
···157157 const char *pin_name,158158 const char *func_name)159159{160160+ unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;160161 int i;161162162163 for (i = 0; i < pctl->desc->npins; i++) {···169168 while (func->name) {170169 if (!strcmp(func->name, func_name) &&171170 (!func->variant ||172172- func->variant & pctl->variant))171171+ func->variant & variant))173172 return func;174173175174 func++;···210209 const u16 pin_num,211210 const u8 muxval)212211{212212+ unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;213213+213214 for (unsigned int i = 0; i < pctl->desc->npins; i++) {214215 const struct sunxi_desc_pin *pin = pctl->desc->pins + i;215216 struct sunxi_desc_function *func = pin->functions;···219216 if (pin->pin.number != pin_num)220217 continue;221218222222- if (pin->variant && !(pctl->variant & pin->variant))219219+ if (pin->variant && !(variant & pin->variant))223220 continue;224221225222 while (func->name) {···10921089{10931090 struct sunxi_pinctrl *pctl = irq_data_get_irq_chip_data(d);10941091 struct sunxi_desc_function *func;10921092+ unsigned int offset;10931093+ u32 reg, shift, mask;10941094+ u8 disabled_mux, muxval;10951095 int ret;1096109610971097 func = sunxi_pinctrl_desc_find_function_by_pin(pctl,···11021096 if (!func)11031097 return -EINVAL;1104109811051105- ret = gpiochip_lock_as_irq(pctl->chip,11061106- pctl->irq_array[d->hwirq] - pctl->desc->pin_base);10991099+ offset = pctl->irq_array[d->hwirq] - pctl->desc->pin_base;11001100+ sunxi_mux_reg(pctl, offset, ®, &shift, &mask);11011101+ muxval = (readl(pctl->membase + reg) & mask) >> shift;11021102+11031103+ /* Change muxing to GPIO INPUT mode if at reset value */11041104+ if (pctl->flags & SUNXI_PINCTRL_NEW_REG_LAYOUT)11051105+ disabled_mux = SUN4I_FUNC_DISABLED_NEW;11061106+ else11071107+ disabled_mux = SUN4I_FUNC_DISABLED_OLD;11081108+11091109+ if (muxval == disabled_mux)11101110+ sunxi_pmx_set(pctl->pctl_dev, pctl->irq_array[d->hwirq],11111111+ SUN4I_FUNC_INPUT);11121112+11131113+ ret = gpiochip_lock_as_irq(pctl->chip, offset);11071114 if (ret) {11081115 dev_err(pctl->dev, "unable to lock HW IRQ %lu for IRQ\n",11091116 irqd_to_hwirq(d));···13571338static int sunxi_pinctrl_build_state(struct platform_device *pdev)13581339{13591340 struct sunxi_pinctrl *pctl = platform_get_drvdata(pdev);13411341+ unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;13601342 void *ptr;13611343 int i;13621344···13821362 const struct sunxi_desc_pin *pin = pctl->desc->pins + i;13831363 struct sunxi_pinctrl_group *group = pctl->groups + pctl->ngroups;1384136413851385- if (pin->variant && !(pctl->variant & pin->variant))13651365+ if (pin->variant && !(variant & pin->variant))13861366 continue;1387136713881368 group->name = pin->pin.name;···14071387 const struct sunxi_desc_pin *pin = pctl->desc->pins + i;14081388 struct sunxi_desc_function *func;1409138914101410- if (pin->variant && !(pctl->variant & pin->variant))13901390+ if (pin->variant && !(variant & pin->variant))14111391 continue;1412139214131393 for (func = pin->functions; func->name; func++) {14141414- if (func->variant && !(pctl->variant & func->variant))13941394+ if (func->variant && !(variant & func->variant))14151395 continue;1416139614171397 /* Create interrupt mapping while we're at it */···14391419 const struct sunxi_desc_pin *pin = pctl->desc->pins + i;14401420 struct sunxi_desc_function *func;1441142114421442- if (pin->variant && !(pctl->variant & pin->variant))14221422+ if (pin->variant && !(variant & pin->variant))14431423 continue;1444142414451425 for (func = pin->functions; func->name; func++) {14461426 struct sunxi_pinctrl_function *func_item;14471427 const char **func_grp;1448142814491449- if (func->variant && !(pctl->variant & func->variant))14291429+ if (func->variant && !(variant & func->variant))14501430 continue;1451143114521432 func_item = sunxi_pinctrl_find_function_by_name(pctl,···1588156815891569 pctl->dev = &pdev->dev;15901570 pctl->desc = desc;15911591- pctl->variant = flags & SUNXI_PINCTRL_VARIANT_MASK;15711571+ pctl->flags = flags;15921572 if (flags & SUNXI_PINCTRL_NEW_REG_LAYOUT) {15931573 pctl->bank_mem_size = D1_BANK_MEM_SIZE;15941574 pctl->pull_regs_offset = D1_PULL_REGS_OFFSET;···1624160416251605 for (i = 0, pin_idx = 0; i < pctl->desc->npins; i++) {16261606 const struct sunxi_desc_pin *pin = pctl->desc->pins + i;16071607+ unsigned long variant = pctl->flags & SUNXI_PINCTRL_VARIANT_MASK;1627160816281628- if (pin->variant && !(pctl->variant & pin->variant))16091609+ if (pin->variant && !(variant & pin->variant))16291610 continue;1630161116311612 pins[pin_idx++] = pin->pin;
···612612 u32 num_cs = OSPI_NUM_CS;613613 int ret;614614615615- ctlr = spi_alloc_host(dev, sizeof(*ospi));615615+ ctlr = devm_spi_alloc_host(dev, sizeof(*ospi));616616 if (!ctlr)617617 return -ENOMEM;618618···635635 platform_set_drvdata(pdev, ospi);636636637637 ospi->base = devm_platform_ioremap_resource(pdev, 0);638638- if (IS_ERR(ospi->base)) {639639- ret = PTR_ERR(ospi->base);640640- goto err_put_ctlr;641641- }638638+ if (IS_ERR(ospi->base))639639+ return PTR_ERR(ospi->base);642640643641 ospi->clk = devm_clk_get_enabled(dev, NULL);644644- if (IS_ERR(ospi->clk)) {645645- ret = PTR_ERR(ospi->clk);646646- goto err_put_ctlr;647647- }642642+ if (IS_ERR(ospi->clk))643643+ return PTR_ERR(ospi->clk);648644649649- mutex_init(&ospi->mlock);645645+ ret = devm_mutex_init(dev, &ospi->mlock);646646+ if (ret)647647+ return ret;650648651649 ret = f_ospi_init(ospi);652650 if (ret)653653- goto err_destroy_mutex;651651+ return ret;654652655655- ret = devm_spi_register_controller(dev, ctlr);656656- if (ret)657657- goto err_destroy_mutex;658658-659659- return 0;660660-661661-err_destroy_mutex:662662- mutex_destroy(&ospi->mlock);663663-664664-err_put_ctlr:665665- spi_controller_put(ctlr);666666-667667- return ret;668668-}669669-670670-static void f_ospi_remove(struct platform_device *pdev)671671-{672672- struct f_ospi *ospi = platform_get_drvdata(pdev);673673-674674- mutex_destroy(&ospi->mlock);653653+ return devm_spi_register_controller(dev, ctlr);675654}676655677656static const struct of_device_id f_ospi_dt_ids[] = {···665686 .of_match_table = f_ospi_dt_ids,666687 },667688 .probe = f_ospi_probe,668668- .remove = f_ospi_remove,669689};670690module_platform_driver(f_ospi_driver);671691
+19-13
drivers/spi/spi.c
···5050 struct spi_device *spi = to_spi_device(dev);51515252 spi_controller_put(spi->controller);5353- kfree(spi->driver_override);5453 free_percpu(spi->pcpu_statistics);5554 kfree(spi);5655}···7273 struct device_attribute *a,7374 const char *buf, size_t count)7475{7575- struct spi_device *spi = to_spi_device(dev);7676 int ret;77777878- ret = driver_set_override(dev, &spi->driver_override, buf, count);7878+ ret = __device_set_driver_override(dev, buf, count);7979 if (ret)8080 return ret;8181···8486static ssize_t driver_override_show(struct device *dev,8587 struct device_attribute *a, char *buf)8688{8787- const struct spi_device *spi = to_spi_device(dev);8888- ssize_t len;8989-9090- device_lock(dev);9191- len = sysfs_emit(buf, "%s\n", spi->driver_override ? : "");9292- device_unlock(dev);9393- return len;8989+ guard(spinlock)(&dev->driver_override.lock);9090+ return sysfs_emit(buf, "%s\n", dev->driver_override.name ?: "");9491}9592static DEVICE_ATTR_RW(driver_override);9693···369376{370377 const struct spi_device *spi = to_spi_device(dev);371378 const struct spi_driver *sdrv = to_spi_driver(drv);379379+ int ret;372380373381 /* Check override first, and if set, only use the named driver */374374- if (spi->driver_override)375375- return strcmp(spi->driver_override, drv->name) == 0;382382+ ret = device_match_driver_override(dev, drv);383383+ if (ret >= 0)384384+ return ret;376385377386 /* Attempt an OF style match */378387 if (of_driver_match_device(dev, drv))···35343539 if (ret)35353540 return ret;3536354135373537- return devm_add_action_or_reset(dev, devm_spi_unregister_controller, ctlr);35423542+ /*35433543+ * Prevent controller from being freed by spi_unregister_controller()35443544+ * if devm_add_action_or_reset() fails for a non-devres allocated35453545+ * controller.35463546+ */35473547+ spi_controller_get(ctlr);3538354835493549+ ret = devm_add_action_or_reset(dev, devm_spi_unregister_controller, ctlr);35503550+35513551+ if (ret == 0 || ctlr->devm_allocated)35523552+ spi_controller_put(ctlr);35533553+35543554+ return ret;35393555}35403556EXPORT_SYMBOL_GPL(devm_spi_register_controller);35413557
+46-6
drivers/target/loopback/tcm_loop.c
···2626#include <linux/slab.h>2727#include <linux/types.h>2828#include <linux/configfs.h>2929+#include <linux/blk-mq.h>2930#include <scsi/scsi.h>3031#include <scsi/scsi_tcq.h>3132#include <scsi/scsi_host.h>···270269 return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED;271270}272271272272+static bool tcm_loop_flush_work_iter(struct request *rq, void *data)273273+{274274+ struct scsi_cmnd *sc = blk_mq_rq_to_pdu(rq);275275+ struct tcm_loop_cmd *tl_cmd = scsi_cmd_priv(sc);276276+ struct se_cmd *se_cmd = &tl_cmd->tl_se_cmd;277277+278278+ flush_work(&se_cmd->work);279279+ return true;280280+}281281+273282static int tcm_loop_target_reset(struct scsi_cmnd *sc)274283{275284 struct tcm_loop_hba *tl_hba;276285 struct tcm_loop_tpg *tl_tpg;286286+ struct Scsi_Host *sh = sc->device->host;287287+ int ret;277288278289 /*279290 * Locate the tcm_loop_hba_t pointer280291 */281281- tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host);292292+ tl_hba = *(struct tcm_loop_hba **)shost_priv(sh);282293 if (!tl_hba) {283294 pr_err("Unable to perform device reset without active I_T Nexus\n");284295 return FAILED;···299286 * Locate the tl_tpg pointer from TargetID in sc->device->id300287 */301288 tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];302302- if (tl_tpg) {303303- tl_tpg->tl_transport_status = TCM_TRANSPORT_ONLINE;304304- return SUCCESS;305305- }306306- return FAILED;289289+ if (!tl_tpg)290290+ return FAILED;291291+292292+ /*293293+ * Issue a LUN_RESET to drain all commands that the target core294294+ * knows about. This handles commands not yet marked CMD_T_COMPLETE.295295+ */296296+ ret = tcm_loop_issue_tmr(tl_tpg, sc->device->lun, 0, TMR_LUN_RESET);297297+ if (ret != TMR_FUNCTION_COMPLETE)298298+ return FAILED;299299+300300+ /*301301+ * Flush any deferred target core completion work that may still be302302+ * queued. Commands that already had CMD_T_COMPLETE set before the TMR303303+ * are skipped by the TMR drain, but their async completion work304304+ * (transport_lun_remove_cmd → percpu_ref_put, release_cmd → scsi_done)305305+ * may still be pending in target_completion_wq.306306+ *307307+ * The SCSI EH will reuse in-flight scsi_cmnd structures for recovery308308+ * commands (e.g. TUR) immediately after this handler returns SUCCESS —309309+ * if deferred work is still pending, the memset in queuecommand would310310+ * zero the se_cmd while the work accesses it, leaking the LUN311311+ * percpu_ref and hanging configfs unlink forever.312312+ *313313+ * Use blk_mq_tagset_busy_iter() to find all started requests and314314+ * flush_work() on each — the same pattern used by mpi3mr, scsi_debug,315315+ * and other SCSI drivers to drain outstanding commands during reset.316316+ */317317+ blk_mq_tagset_busy_iter(&sh->tag_set, tcm_loop_flush_work_iter, NULL);318318+319319+ tl_tpg->tl_transport_status = TCM_TRANSPORT_ONLINE;320320+ return SUCCESS;307321}308322309323static const struct scsi_host_template tcm_loop_driver_template = {
+1-1
drivers/target/target_core_file.c
···276276 ssize_t len = 0;277277 int ret = 0, i;278278279279- aio_cmd = kmalloc_flex(*aio_cmd, bvecs, sgl_nents);279279+ aio_cmd = kzalloc_flex(*aio_cmd, bvecs, sgl_nents);280280 if (!aio_cmd)281281 return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;282282
···176176177177static void set_soc_power_profile(struct proc_thermal_device *proc_priv, int slider)178178{179179+ u8 offset;179180 u64 val;180181181182 val = read_soc_slider(proc_priv);182183 val &= ~SLIDER_MASK;183184 val |= FIELD_PREP(SLIDER_MASK, slider) | BIT(SLIDER_ENABLE_BIT);184185186186+ if (slider == SOC_SLIDER_VALUE_MINIMUM || slider == SOC_SLIDER_VALUE_MAXIMUM)187187+ offset = 0;188188+ else189189+ offset = slider_offset;190190+185191 /* Set the slider offset from module params */186192 val &= ~SLIDER_OFFSET_MASK;187187- val |= FIELD_PREP(SLIDER_OFFSET_MASK, slider_offset);193193+ val |= FIELD_PREP(SLIDER_OFFSET_MASK, offset);188194189195 write_soc_slider(proc_priv, val);190196}
+2-3
drivers/vfio/pci/vfio_pci_dmabuf.c
···301301 */302302 ret = dma_buf_fd(priv->dmabuf, get_dma_buf.open_flags);303303 if (ret < 0)304304- goto err_dma_buf;304304+ dma_buf_put(priv->dmabuf);305305+305306 return ret;306307307307-err_dma_buf:308308- dma_buf_put(priv->dmabuf);309308err_dev_put:310309 vfio_device_put_registration(&vdev->vdev);311310err_free_phys:
+10-2
drivers/virt/coco/tdx-guest/tdx-guest.c
···171171#define GET_QUOTE_SUCCESS 0172172#define GET_QUOTE_IN_FLIGHT 0xffffffffffffffff173173174174+#define TDX_QUOTE_MAX_LEN (GET_QUOTE_BUF_SIZE - sizeof(struct tdx_quote_buf))175175+174176/* struct tdx_quote_buf: Format of Quote request buffer.175177 * @version: Quote format version, filled by TD.176178 * @status: Status code of Quote request, filled by VMM.···271269 u8 *buf;272270 struct tdx_quote_buf *quote_buf = quote_data;273271 struct tsm_report_desc *desc = &report->desc;272272+ u32 out_len;274273 int ret;275274 u64 err;276275···309306 return ret;310307 }311308312312- buf = kvmemdup(quote_buf->data, quote_buf->out_len, GFP_KERNEL);309309+ out_len = READ_ONCE(quote_buf->out_len);310310+311311+ if (out_len > TDX_QUOTE_MAX_LEN)312312+ return -EFBIG;313313+314314+ buf = kvmemdup(quote_buf->data, out_len, GFP_KERNEL);313315 if (!buf)314316 return -ENOMEM;315317316318 report->outblob = buf;317317- report->outblob_len = quote_buf->out_len;319319+ report->outblob_len = out_len;318320319321 /*320322 * TODO: parse the PEM-formatted cert chain out of the quote buffer when
+5-5
drivers/virtio/virtio_ring.c
···29122912 * @data: the token identifying the buffer.29132913 * @gfp: how to do memory allocations (if necessary).29142914 *29152915- * Same as virtqueue_add_inbuf but passes DMA_ATTR_CPU_CACHE_CLEAN to indicate29162916- * that the CPU will not dirty any cacheline overlapping this buffer while it29172917- * is available, and to suppress overlapping cacheline warnings in DMA debug29182918- * builds.29152915+ * Same as virtqueue_add_inbuf but passes DMA_ATTR_DEBUGGING_IGNORE_CACHELINES29162916+ * to indicate that the CPU will not dirty any cacheline overlapping this buffer29172917+ * while it is available, and to suppress overlapping cacheline warnings in DMA29182918+ * debug builds.29192919 *29202920 * Caller must ensure we don't call this with other virtqueue operations29212921 * at the same time (except where noted).···29282928 gfp_t gfp)29292929{29302930 return virtqueue_add(vq, &sg, num, 0, 1, data, NULL, false, gfp,29312931- DMA_ATTR_CPU_CACHE_CLEAN);29312931+ DMA_ATTR_DEBUGGING_IGNORE_CACHELINES);29322932}29332933EXPORT_SYMBOL_GPL(virtqueue_add_inbuf_cache_clean);29342934
+73-3
drivers/xen/privcmd.c
···1212#include <linux/eventfd.h>1313#include <linux/file.h>1414#include <linux/kernel.h>1515+#include <linux/kstrtox.h>1516#include <linux/module.h>1617#include <linux/mutex.h>1718#include <linux/poll.h>···3130#include <linux/seq_file.h>3231#include <linux/miscdevice.h>3332#include <linux/moduleparam.h>3333+#include <linux/notifier.h>3434+#include <linux/security.h>3435#include <linux/virtio_mmio.h>3636+#include <linux/wait.h>35373638#include <asm/xen/hypervisor.h>3739#include <asm/xen/hypercall.h>···5046#include <xen/page.h>5147#include <xen/xen-ops.h>5248#include <xen/balloon.h>4949+#include <xen/xenbus.h>5350#ifdef CONFIG_XEN_ACPI5451#include <xen/acpi.h>5552#endif···7368MODULE_PARM_DESC(dm_op_buf_max_size,7469 "Maximum size of a dm_op hypercall buffer");75707171+static bool unrestricted;7272+module_param(unrestricted, bool, 0);7373+MODULE_PARM_DESC(unrestricted,7474+ "Don't restrict hypercalls to target domain if running in a domU");7575+7676struct privcmd_data {7777 domid_t domid;7878};7979+8080+/* DOMID_INVALID implies no restriction */8181+static domid_t target_domain = DOMID_INVALID;8282+static bool restrict_wait;8383+static DECLARE_WAIT_QUEUE_HEAD(restrict_wait_wq);79848085static int privcmd_vma_range_is_mapped(8186 struct vm_area_struct *vma,···1578156315791564static int privcmd_open(struct inode *ino, struct file *file)15801565{15811581- struct privcmd_data *data = kzalloc_obj(*data);15661566+ struct privcmd_data *data;1582156715681568+ if (wait_event_interruptible(restrict_wait_wq, !restrict_wait) < 0)15691569+ return -EINTR;15701570+15711571+ data = kzalloc_obj(*data);15831572 if (!data)15841573 return -ENOMEM;1585157415861586- /* DOMID_INVALID implies no restriction */15871587- data->domid = DOMID_INVALID;15751575+ data->domid = target_domain;1588157615891577 file->private_data = data;15901578 return 0;···16801662 .fops = &xen_privcmd_fops,16811663};1682166416651665+static int init_restrict(struct notifier_block *notifier,16661666+ unsigned long event,16671667+ void *data)16681668+{16691669+ char *target;16701670+ unsigned int domid;16711671+16721672+ /* Default to an guaranteed unused domain-id. */16731673+ target_domain = DOMID_IDLE;16741674+16751675+ target = xenbus_read(XBT_NIL, "target", "", NULL);16761676+ if (IS_ERR(target) || kstrtouint(target, 10, &domid)) {16771677+ pr_err("No target domain found, blocking all hypercalls\n");16781678+ goto out;16791679+ }16801680+16811681+ target_domain = domid;16821682+16831683+ out:16841684+ if (!IS_ERR(target))16851685+ kfree(target);16861686+16871687+ restrict_wait = false;16881688+ wake_up_all(&restrict_wait_wq);16891689+16901690+ return NOTIFY_DONE;16911691+}16921692+16931693+static struct notifier_block xenstore_notifier = {16941694+ .notifier_call = init_restrict,16951695+};16961696+16971697+static void __init restrict_driver(void)16981698+{16991699+ if (unrestricted) {17001700+ if (security_locked_down(LOCKDOWN_XEN_USER_ACTIONS))17011701+ pr_warn("Kernel is locked down, parameter \"unrestricted\" ignored\n");17021702+ else17031703+ return;17041704+ }17051705+17061706+ restrict_wait = true;17071707+17081708+ register_xenstore_notifier(&xenstore_notifier);17091709+}17101710+16831711static int __init privcmd_init(void)16841712{16851713 int err;1686171416871715 if (!xen_domain())16881716 return -ENODEV;17171717+17181718+ if (!xen_initial_domain())17191719+ restrict_driver();1689172016901721 err = misc_register(&privcmd_dev);16911722 if (err != 0) {···1765169817661699static void __exit privcmd_exit(void)17671700{17011701+ if (!xen_initial_domain())17021702+ unregister_xenstore_notifier(&xenstore_notifier);17031703+17681704 privcmd_ioeventfd_exit();17691705 privcmd_irqfd_exit();17701706 misc_deregister(&privcmd_dev);
+1-1
fs/btrfs/block-group.c
···45834583 for (int i = 0; i < BTRFS_SPACE_INFO_SUB_GROUP_MAX; i++) {45844584 if (space_info->sub_group[i]) {45854585 check_removing_space_info(space_info->sub_group[i]);45864586- kfree(space_info->sub_group[i]);45864586+ btrfs_sysfs_remove_space_info(space_info->sub_group[i]);45874587 space_info->sub_group[i] = NULL;45884588 }45894589 }
···46164616 struct inode *inode, bool log_inode_only,46174617 u64 logged_isize)46184618{46194619+ u64 gen = BTRFS_I(inode)->generation;46194620 u64 flags;4620462146214622 if (log_inode_only) {46224622- /* set the generation to zero so the recover code46234623- * can tell the difference between an logging46244624- * just to say 'this inode exists' and a logging46254625- * to say 'update this inode with these values'46234623+ /*46244624+ * Set the generation to zero so the recover code can tell the46254625+ * difference between a logging just to say 'this inode exists'46264626+ * and a logging to say 'update this inode with these values'.46274627+ * But only if the inode was not already logged before.46284628+ * We access ->logged_trans directly since it was already set46294629+ * up in the call chain by btrfs_log_inode(), and data_race()46304630+ * to avoid false alerts from KCSAN and since it was set already46314631+ * and one can set it to 0 since that only happens on eviction46324632+ * and we are holding a ref on the inode.46264633 */46274627- btrfs_set_inode_generation(leaf, item, 0);46344634+ ASSERT(data_race(BTRFS_I(inode)->logged_trans) > 0);46354635+ if (data_race(BTRFS_I(inode)->logged_trans) < trans->transid)46364636+ gen = 0;46374637+46284638 btrfs_set_inode_size(leaf, item, logged_isize);46294639 } else {46304630- btrfs_set_inode_generation(leaf, item, BTRFS_I(inode)->generation);46314640 btrfs_set_inode_size(leaf, item, inode->i_size);46324641 }46424642+46434643+ btrfs_set_inode_generation(leaf, item, gen);4633464446344645 btrfs_set_inode_uid(leaf, item, i_uid_read(inode));46354646 btrfs_set_inode_gid(leaf, item, i_gid_read(inode));···54595448 return 0;54605449}5461545054625462-static int logged_inode_size(struct btrfs_root *log, struct btrfs_inode *inode,54635463- struct btrfs_path *path, u64 *size_ret)54515451+static int get_inode_size_to_log(struct btrfs_trans_handle *trans,54525452+ struct btrfs_inode *inode,54535453+ struct btrfs_path *path, u64 *size_ret)54645454{54655455 struct btrfs_key key;54565456+ struct btrfs_inode_item *item;54665457 int ret;5467545854685459 key.objectid = btrfs_ino(inode);54695460 key.type = BTRFS_INODE_ITEM_KEY;54705461 key.offset = 0;5471546254725472- ret = btrfs_search_slot(NULL, log, &key, path, 0, 0);54735473- if (ret < 0) {54745474- return ret;54755475- } else if (ret > 0) {54765476- *size_ret = 0;54775477- } else {54785478- struct btrfs_inode_item *item;54635463+ /*54645464+ * Our caller called inode_logged(), so logged_trans is up to date.54655465+ * Use data_race() to silence any warning from KCSAN. Once logged_trans54665466+ * is set, it can only be reset to 0 after inode eviction.54675467+ */54685468+ if (data_race(inode->logged_trans) == trans->transid) {54695469+ ret = btrfs_search_slot(NULL, inode->root->log_root, &key, path, 0, 0);54705470+ } else if (inode->generation < trans->transid) {54715471+ path->search_commit_root = true;54725472+ path->skip_locking = true;54735473+ ret = btrfs_search_slot(NULL, inode->root, &key, path, 0, 0);54745474+ path->search_commit_root = false;54755475+ path->skip_locking = false;5479547654805480- item = btrfs_item_ptr(path->nodes[0], path->slots[0],54815481- struct btrfs_inode_item);54825482- *size_ret = btrfs_inode_size(path->nodes[0], item);54835483- /*54845484- * If the in-memory inode's i_size is smaller then the inode54855485- * size stored in the btree, return the inode's i_size, so54865486- * that we get a correct inode size after replaying the log54875487- * when before a power failure we had a shrinking truncate54885488- * followed by addition of a new name (rename / new hard link).54895489- * Otherwise return the inode size from the btree, to avoid54905490- * data loss when replaying a log due to previously doing a54915491- * write that expands the inode's size and logging a new name54925492- * immediately after.54935493- */54945494- if (*size_ret > inode->vfs_inode.i_size)54955495- *size_ret = inode->vfs_inode.i_size;54775477+ } else {54785478+ *size_ret = 0;54795479+ return 0;54965480 }54815481+54825482+ /*54835483+ * If the inode was logged before or is from a past transaction, then54845484+ * its inode item must exist in the log root or in the commit root.54855485+ */54865486+ ASSERT(ret <= 0);54875487+ if (WARN_ON_ONCE(ret > 0))54885488+ ret = -ENOENT;54895489+54905490+ if (ret < 0)54915491+ return ret;54925492+54935493+ item = btrfs_item_ptr(path->nodes[0], path->slots[0],54945494+ struct btrfs_inode_item);54955495+ *size_ret = btrfs_inode_size(path->nodes[0], item);54965496+ /*54975497+ * If the in-memory inode's i_size is smaller then the inode size stored54985498+ * in the btree, return the inode's i_size, so that we get a correct54995499+ * inode size after replaying the log when before a power failure we had55005500+ * a shrinking truncate followed by addition of a new name (rename / new55015501+ * hard link). Otherwise return the inode size from the btree, to avoid55025502+ * data loss when replaying a log due to previously doing a write that55035503+ * expands the inode's size and logging a new name immediately after.55045504+ */55055505+ if (*size_ret > inode->vfs_inode.i_size)55065506+ *size_ret = inode->vfs_inode.i_size;5497550754985508 btrfs_release_path(path);54995509 return 0;···70286996 ret = drop_inode_items(trans, log, path, inode,70296997 BTRFS_XATTR_ITEM_KEY);70306998 } else {70317031- if (inode_only == LOG_INODE_EXISTS && ctx->logged_before) {69996999+ if (inode_only == LOG_INODE_EXISTS) {70327000 /*70337001 * Make sure the new inode item we write to the log has70347002 * the same isize as the current one (if it exists).···70427010 * (zeroes), as if an expanding truncate happened,70437011 * instead of getting a file of 4Kb only.70447012 */70457045- ret = logged_inode_size(log, inode, path, &logged_isize);70137013+ ret = get_inode_size_to_log(trans, inode, path, &logged_isize);70467014 if (ret)70477015 goto out_unlock;70487016 }
+3-2
fs/btrfs/volumes.c
···80998099 smp_rmb();8100810081018101 ret = update_dev_stat_item(trans, device);81028102- if (!ret)81038103- atomic_sub(stats_cnt, &device->dev_stats_ccnt);81028102+ if (ret)81038103+ break;81048104+ atomic_sub(stats_cnt, &device->dev_stats_ccnt);81048105 }81058106 mutex_unlock(&fs_devices->device_list_mutex);81068107
+3-1
fs/btrfs/zlib.c
···308308 }309309 /* Queue the remaining part of the folio. */310310 if (workspace->strm.total_out > bio->bi_iter.bi_size) {311311- u32 cur_len = offset_in_folio(out_folio, workspace->strm.total_out);311311+ const u32 cur_len = workspace->strm.total_out - bio->bi_iter.bi_size;312312+313313+ ASSERT(cur_len <= folio_size(out_folio));312314313315 if (!bio_add_folio(bio, out_folio, cur_len, 0)) {314316 ret = -E2BIG;
+29-14
fs/erofs/Kconfig
···1616 select ZLIB_INFLATE if EROFS_FS_ZIP_DEFLATE1717 select ZSTD_DECOMPRESS if EROFS_FS_ZIP_ZSTD1818 help1919- EROFS (Enhanced Read-Only File System) is a lightweight read-only2020- file system with modern designs (e.g. no buffer heads, inline2121- xattrs/data, chunk-based deduplication, multiple devices, etc.) for2222- scenarios which need high-performance read-only solutions, e.g.2323- smartphones with Android OS, LiveCDs and high-density hosts with2424- numerous containers;1919+ EROFS (Enhanced Read-Only File System) is a modern, lightweight,2020+ secure read-only filesystem for various use cases, such as immutable2121+ system images, container images, application sandboxes, and datasets.25222626- It also provides transparent compression and deduplication support to2727- improve storage density and maintain relatively high compression2828- ratios, and it implements in-place decompression to temporarily reuse2929- page cache for compressed data using proper strategies, which is3030- quite useful for ensuring guaranteed end-to-end runtime decompression2323+ EROFS uses a flexible, hierarchical on-disk design so that features2424+ can be enabled on demand: the core on-disk format is block-aligned in2525+ order to perform optimally on all kinds of devices, including block2626+ and memory-backed devices; the format is easy to parse and has zero2727+ metadata redundancy, unlike generic filesystems, making it ideal for2828+ filesystem auditing and remote access; inline data, random-access2929+ friendly directory data, inline/shared extended attributes and3030+ chunk-based deduplication ensure space efficiency while maintaining3131+ high performance.3232+3333+ Optionally, it supports multiple devices to reference external data,3434+ enabling data sharing for container images.3535+3636+ It also has advanced encoded on-disk layouts, particularly for data3737+ compression and fine-grained deduplication. It utilizes fixed-size3838+ output compression to improve storage density while keeping relatively3939+ high compression ratios. Furthermore, it implements in-place4040+ decompression to reuse file pages to keep compressed data temporarily4141+ with proper strategies, which ensures guaranteed end-to-end runtime3142 performance under extreme memory pressure without extra cost.32433333- See the documentation at <file:Documentation/filesystems/erofs.rst>3434- and the web pages at <https://erofs.docs.kernel.org> for more details.4444+ For more details, see the web pages at <https://erofs.docs.kernel.org>4545+ and the documentation at <file:Documentation/filesystems/erofs.rst>.4646+4747+ To compile EROFS filesystem support as a module, choose M here. The4848+ module will be called erofs.35493650 If unsure, say N.3751···119105 depends on EROFS_FS120106 default y121107 help122122- Enable transparent compression support for EROFS file systems.108108+ Enable EROFS compression layouts so that filesystems containing109109+ compressed files can be parsed by the kernel.123110124111 If you don't want to enable compression feature, say N.125112
+2-4
fs/erofs/fileio.c
···2525 container_of(iocb, struct erofs_fileio_rq, iocb);2626 struct folio_iter fi;27272828- if (ret >= 0 && ret != rq->bio.bi_iter.bi_size) {2929- bio_advance(&rq->bio, ret);3030- zero_fill_bio(&rq->bio);3131- }2828+ if (ret >= 0 && ret != rq->bio.bi_iter.bi_size)2929+ ret = -EIO;3230 if (!rq->bio.bi_end_io) {3331 bio_for_each_folio_all(fi, &rq->bio) {3432 DBG_BUGON(folio_test_uptodate(fi.folio));
+13-2
fs/erofs/ishare.c
···200200201201int __init erofs_init_ishare(void)202202{203203- erofs_ishare_mnt = kern_mount(&erofs_anon_fs_type);204204- return PTR_ERR_OR_ZERO(erofs_ishare_mnt);203203+ struct vfsmount *mnt;204204+ int ret;205205+206206+ mnt = kern_mount(&erofs_anon_fs_type);207207+ if (IS_ERR(mnt))208208+ return PTR_ERR(mnt);209209+ /* generic_fadvise() doesn't work if s_bdi == &noop_backing_dev_info */210210+ ret = super_setup_bdi(mnt->mnt_sb);211211+ if (ret)212212+ kern_unmount(mnt);213213+ else214214+ erofs_ishare_mnt = mnt;215215+ return ret;205216}206217207218void erofs_exit_ishare(void)
+3
fs/erofs/zdata.c
···14451445 int bios)14461446{14471447 struct erofs_sb_info *const sbi = EROFS_SB(io->sb);14481448+ int gfp_flag;1448144914491450 /* wake up the caller thread for sync decompression */14501451 if (io->sync) {···14781477 sbi->sync_decompress = EROFS_SYNC_DECOMPRESS_FORCE_ON;14791478 return;14801479 }14801480+ gfp_flag = memalloc_noio_save();14811481 z_erofs_decompressqueue_work(&io->u.work);14821482+ memalloc_noio_restore(gfp_flag);14821483}1483148414841485static void z_erofs_fill_bio_vec(struct bio_vec *bvec,
···163163 */164164165165 if (handle) {166166+ /*167167+ * Since the inode is new it is ok to pass the168168+ * XATTR_CREATE flag. This is necessary to match the169169+ * remaining journal credits check in the set_handle170170+ * function with the credits allocated for the new171171+ * inode.172172+ */166173 res = ext4_xattr_set_handle(handle, inode,167174 EXT4_XATTR_INDEX_ENCRYPTION,168175 EXT4_XATTR_NAME_ENCRYPTION_CONTEXT,169169- ctx, len, 0);176176+ ctx, len, XATTR_CREATE);170177 if (!res) {171178 ext4_set_inode_flag(inode, EXT4_INODE_ENCRYPT);172179 ext4_clear_inode_state(inode,
···184184 * - ENOMEM185185 * - EIO186186 */187187-static int __ext4_ext_dirty(const char *where, unsigned int line,188188- handle_t *handle, struct inode *inode,189189- struct ext4_ext_path *path)187187+int __ext4_ext_dirty(const char *where, unsigned int line,188188+ handle_t *handle, struct inode *inode,189189+ struct ext4_ext_path *path)190190{191191 int err;192192···17361736 err = ext4_ext_get_access(handle, inode, path + k);17371737 if (err)17381738 return err;17391739+ if (unlikely(path[k].p_idx > EXT_LAST_INDEX(path[k].p_hdr))) {17401740+ EXT4_ERROR_INODE(inode,17411741+ "path[%d].p_idx %p > EXT_LAST_INDEX %p",17421742+ k, path[k].p_idx,17431743+ EXT_LAST_INDEX(path[k].p_hdr));17441744+ return -EFSCORRUPTED;17451745+ }17391746 path[k].p_idx->ei_block = border;17401747 err = ext4_ext_dirty(handle, inode, path + k);17411748 if (err)···17551748 err = ext4_ext_get_access(handle, inode, path + k);17561749 if (err)17571750 goto clean;17511751+ if (unlikely(path[k].p_idx > EXT_LAST_INDEX(path[k].p_hdr))) {17521752+ EXT4_ERROR_INODE(inode,17531753+ "path[%d].p_idx %p > EXT_LAST_INDEX %p",17541754+ k, path[k].p_idx,17551755+ EXT_LAST_INDEX(path[k].p_hdr));17561756+ err = -EFSCORRUPTED;17571757+ goto clean;17581758+ }17581759 path[k].p_idx->ei_block = border;17591760 err = ext4_ext_dirty(handle, inode, path + k);17601761 if (err)···31593144}3160314531613146/* FIXME!! we need to try to merge to left or right after zero-out */31623162-static int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex)31473147+int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex)31633148{31643149 ext4_fsblk_t ee_pblock;31653150 unsigned int ee_len;···3254323932553240 insert_err = PTR_ERR(path);32563241 err = 0;32423242+ if (insert_err != -ENOSPC && insert_err != -EDQUOT &&32433243+ insert_err != -ENOMEM)32443244+ goto out_path;3257324532583246 /*32593247 * Get a new path to try to zeroout or fix the extent length.···32733255 goto out_path;32743256 }3275325732583258+ depth = ext_depth(inode);32593259+ ex = path[depth].p_ext;32603260+ if (!ex) {32613261+ EXT4_ERROR_INODE(inode,32623262+ "bad extent address lblock: %lu, depth: %d pblock %llu",32633263+ (unsigned long)ee_block, depth, path[depth].p_block);32643264+ err = -EFSCORRUPTED;32653265+ goto out;32663266+ }32673267+32763268 err = ext4_ext_get_access(handle, inode, path + depth);32773269 if (err)32783270 goto out;32793279-32803280- depth = ext_depth(inode);32813281- ex = path[depth].p_ext;3282327132833272fix_extent_len:32843273 ex->ee_len = orig_ex.ee_len;···3388336333893364 ext4_ext_mark_initialized(ex);3390336533913391- ext4_ext_dirty(handle, inode, path + depth);33663366+ err = ext4_ext_dirty(handle, inode, path + depth);33923367 if (err)33933368 return err;33943369···44824457 path = ext4_ext_insert_extent(handle, inode, path, &newex, flags);44834458 if (IS_ERR(path)) {44844459 err = PTR_ERR(path);44854485- if (allocated_clusters) {44604460+ /*44614461+ * Gracefully handle out of space conditions. If the filesystem44624462+ * is inconsistent, we'll just leak allocated blocks to avoid44634463+ * causing even more damage.44644464+ */44654465+ if (allocated_clusters && (err == -EDQUOT || err == -ENOSPC)) {44864466 int fb_flags = 0;44874487-44884467 /*44894468 * free data blocks we just allocated.44904469 * not a good idea to call discard here directly,···62676238 return 0;62686239}6269624062706270-#ifdef CONFIG_EXT4_KUNIT_TESTS62716271-#include "extents-test.c"62416241+#if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS)62426242+int ext4_ext_space_root_idx_test(struct inode *inode, int check)62436243+{62446244+ return ext4_ext_space_root_idx(inode, check);62456245+}62466246+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_ext_space_root_idx_test);62476247+62486248+struct ext4_ext_path *ext4_split_convert_extents_test(handle_t *handle,62496249+ struct inode *inode, struct ext4_map_blocks *map,62506250+ struct ext4_ext_path *path, int flags,62516251+ unsigned int *allocated)62526252+{62536253+ return ext4_split_convert_extents(handle, inode, map, path,62546254+ flags, allocated);62556255+}62566256+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_split_convert_extents_test);62576257+62586258+EXPORT_SYMBOL_FOR_EXT4_TEST(__ext4_ext_dirty);62596259+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_ext_zeroout);62606260+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_register_shrinker);62616261+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_unregister_shrinker);62626262+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_map_create_blocks);62636263+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_init_tree);62646264+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_lookup_extent);62656265+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_es_insert_extent);62666266+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_ext_insert_extent);62676267+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_find_extent);62686268+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_issue_zeroout);62696269+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_map_query_blocks);62726270#endif
+10-7
fs/ext4/fast_commit.c
···975975 int ret = 0;976976977977 list_for_each_entry(ei, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) {978978- ret = jbd2_submit_inode_data(journal, ei->jinode);978978+ ret = jbd2_submit_inode_data(journal, READ_ONCE(ei->jinode));979979 if (ret)980980 return ret;981981 }982982983983 list_for_each_entry(ei, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) {984984- ret = jbd2_wait_inode_data(journal, ei->jinode);984984+ ret = jbd2_wait_inode_data(journal, READ_ONCE(ei->jinode));985985 if (ret)986986 return ret;987987 }···16131613 /* Immediately update the inode on disk. */16141614 ret = ext4_handle_dirty_metadata(NULL, NULL, iloc.bh);16151615 if (ret)16161616- goto out;16161616+ goto out_brelse;16171617 ret = sync_dirty_buffer(iloc.bh);16181618 if (ret)16191619- goto out;16191619+ goto out_brelse;16201620 ret = ext4_mark_inode_used(sb, ino);16211621 if (ret)16221622- goto out;16221622+ goto out_brelse;1623162316241624 /* Given that we just wrote the inode on disk, this SHOULD succeed. */16251625 inode = ext4_iget(sb, ino, EXT4_IGET_NORMAL);16261626 if (IS_ERR(inode)) {16271627 ext4_debug("Inode not found.");16281628- return -EFSCORRUPTED;16281628+ inode = NULL;16291629+ ret = -EFSCORRUPTED;16301630+ goto out_brelse;16291631 }1630163216311633 /*···16441642 ext4_inode_csum_set(inode, ext4_raw_inode(&iloc), EXT4_I(inode));16451643 ret = ext4_handle_dirty_metadata(NULL, NULL, iloc.bh);16461644 sync_dirty_buffer(iloc.bh);16451645+out_brelse:16471646 brelse(iloc.bh);16481647out:16491648 iput(inode);16501649 if (!ret)16511650 blkdev_issue_flush(sb->s_bdev);1652165116531653- return 0;16521652+ return ret;16541653}1655165416561655/*
+14-2
fs/ext4/fsync.c
···8383 int datasync, bool *needs_barrier)8484{8585 struct inode *inode = file->f_inode;8686+ struct writeback_control wbc = {8787+ .sync_mode = WB_SYNC_ALL,8888+ .nr_to_write = 0,8989+ };8690 int ret;87918892 ret = generic_buffers_fsync_noflush(file, start, end, datasync);8989- if (!ret)9090- ret = ext4_sync_parent(inode);9393+ if (ret)9494+ return ret;9595+9696+ /* Force writeout of inode table buffer to disk */9797+ ret = ext4_write_inode(inode, &wbc);9898+ if (ret)9999+ return ret;100100+101101+ ret = ext4_sync_parent(inode);102102+91103 if (test_opt(inode->i_sb, BARRIER))92104 *needs_barrier = true;93105
+6
fs/ext4/ialloc.c
···686686 if (unlikely(!gdp))687687 return 0;688688689689+ /* Inode was never used in this filesystem? */690690+ if (ext4_has_group_desc_csum(sb) &&691691+ (gdp->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT) ||692692+ ino >= EXT4_INODES_PER_GROUP(sb) - ext4_itable_unused_count(sb, gdp)))693693+ return 0;694694+689695 bh = sb_find_get_block(sb, ext4_inode_table(sb, gdp) +690696 (ino / inodes_per_block));691697 if (!bh || !buffer_uptodate(bh))
···128128static inline int ext4_begin_ordered_truncate(struct inode *inode,129129 loff_t new_size)130130{131131+ struct jbd2_inode *jinode = READ_ONCE(EXT4_I(inode)->jinode);132132+131133 trace_ext4_begin_ordered_truncate(inode, new_size);132134 /*133135 * If jinode is zero, then we never opened the file for···137135 * jbd2_journal_begin_ordered_truncate() since there's no138136 * outstanding writes we need to flush.139137 */140140- if (!EXT4_I(inode)->jinode)138138+ if (!jinode)141139 return 0;142140 return jbd2_journal_begin_ordered_truncate(EXT4_JOURNAL(inode),143143- EXT4_I(inode)->jinode,141141+ jinode,144142 new_size);145143}146144···186184 if (EXT4_I(inode)->i_flags & EXT4_EA_INODE_FL)187185 ext4_evict_ea_inode(inode);188186 if (inode->i_nlink) {187187+ /*188188+ * If there's dirty page will lead to data loss, user189189+ * could see stale data.190190+ */191191+ if (unlikely(!ext4_emergency_state(inode->i_sb) &&192192+ mapping_tagged(&inode->i_data, PAGECACHE_TAG_DIRTY)))193193+ ext4_warning_inode(inode, "data will be lost");194194+189195 truncate_inode_pages_final(&inode->i_data);190196191197 goto no_delete;···44614451 spin_unlock(&inode->i_lock);44624452 return -ENOMEM;44634453 }44644464- ei->jinode = jinode;44654465- jbd2_journal_init_jbd_inode(ei->jinode, inode);44544454+ jbd2_journal_init_jbd_inode(jinode, inode);44554455+ /*44564456+ * Publish ->jinode only after it is fully initialized so that44574457+ * readers never observe a partially initialized jbd2_inode.44584458+ */44594459+ smp_wmb();44604460+ WRITE_ONCE(ei->jinode, jinode);44664461 jinode = NULL;44674462 }44684463 spin_unlock(&inode->i_lock);···54165401 inode->i_op = &ext4_encrypted_symlink_inode_operations;54175402 } else if (ext4_inode_is_fast_symlink(inode)) {54185403 inode->i_op = &ext4_fast_symlink_inode_operations;54195419- if (inode->i_size == 0 ||54205420- inode->i_size >= sizeof(ei->i_data) ||54215421- strnlen((char *)ei->i_data, inode->i_size + 1) !=54225422- inode->i_size) {54235423- ext4_error_inode(inode, function, line, 0,54245424- "invalid fast symlink length %llu",54255425- (unsigned long long)inode->i_size);54265426- ret = -EFSCORRUPTED;54275427- goto bad_inode;54045404+54055405+ /*54065406+ * Orphan cleanup can see inodes with i_size == 054075407+ * and i_data uninitialized. Skip size checks in54085408+ * that case. This is safe because the first thing54095409+ * ext4_evict_inode() does for fast symlinks is54105410+ * clearing of i_data and i_size.54115411+ */54125412+ if ((EXT4_SB(sb)->s_mount_state & EXT4_ORPHAN_FS)) {54135413+ if (inode->i_nlink != 0) {54145414+ ext4_error_inode(inode, function, line, 0,54155415+ "invalid orphan symlink nlink %d",54165416+ inode->i_nlink);54175417+ ret = -EFSCORRUPTED;54185418+ goto bad_inode;54195419+ }54205420+ } else {54215421+ if (inode->i_size == 0 ||54225422+ inode->i_size >= sizeof(ei->i_data) ||54235423+ strnlen((char *)ei->i_data, inode->i_size + 1) !=54245424+ inode->i_size) {54255425+ ext4_error_inode(inode, function, line, 0,54265426+ "invalid fast symlink length %llu",54275427+ (unsigned long long)inode->i_size);54285428+ ret = -EFSCORRUPTED;54295429+ goto bad_inode;54305430+ }54315431+ inode_set_cached_link(inode, (char *)ei->i_data,54325432+ inode->i_size);54285433 }54295429- inode_set_cached_link(inode, (char *)ei->i_data,54305430- inode->i_size);54315434 } else {54325435 inode->i_op = &ext4_symlink_inode_operations;54335436 }···5881584858825849 if (attr->ia_size == inode->i_size)58835850 inc_ivers = false;58515851+58525852+ /*58535853+ * If file has inline data but new size exceeds inline capacity,58545854+ * convert to extent-based storage first to prevent inconsistent58555855+ * state (inline flag set but size exceeds inline capacity).58565856+ */58575857+ if (ext4_has_inline_data(inode) &&58585858+ attr->ia_size > EXT4_I(inode)->i_inline_size) {58595859+ error = ext4_convert_inline_data(inode);58605860+ if (error)58615861+ goto err_out;58625862+ }5884586358855864 if (shrink) {58865865 if (ext4_should_order_data(inode)) {
+41-40
fs/ext4/mballoc-test.c
···88#include <linux/random.h>991010#include "ext4.h"1111+#include "mballoc.h"11121213struct mbt_grp_ctx {1314 struct buffer_head bitmap_bh;···337336 if (state)338337 mb_set_bits(bitmap_bh->b_data, blkoff, len);339338 else340340- mb_clear_bits(bitmap_bh->b_data, blkoff, len);339339+ mb_clear_bits_test(bitmap_bh->b_data, blkoff, len);341340342341 return 0;343342}···414413415414 /* get block at goal */416415 ar.goal = ext4_group_first_block_no(sb, goal_group);417417- found = ext4_mb_new_blocks_simple(&ar, &err);416416+ found = ext4_mb_new_blocks_simple_test(&ar, &err);418417 KUNIT_ASSERT_EQ_MSG(test, ar.goal, found,419418 "failed to alloc block at goal, expected %llu found %llu",420419 ar.goal, found);421420422421 /* get block after goal in goal group */423422 ar.goal = ext4_group_first_block_no(sb, goal_group);424424- found = ext4_mb_new_blocks_simple(&ar, &err);423423+ found = ext4_mb_new_blocks_simple_test(&ar, &err);425424 KUNIT_ASSERT_EQ_MSG(test, ar.goal + EXT4_C2B(sbi, 1), found,426425 "failed to alloc block after goal in goal group, expected %llu found %llu",427426 ar.goal + 1, found);···429428 /* get block after goal group */430429 mbt_ctx_mark_used(sb, goal_group, 0, EXT4_CLUSTERS_PER_GROUP(sb));431430 ar.goal = ext4_group_first_block_no(sb, goal_group);432432- found = ext4_mb_new_blocks_simple(&ar, &err);431431+ found = ext4_mb_new_blocks_simple_test(&ar, &err);433432 KUNIT_ASSERT_EQ_MSG(test,434433 ext4_group_first_block_no(sb, goal_group + 1), found,435434 "failed to alloc block after goal group, expected %llu found %llu",···439438 for (i = goal_group; i < ext4_get_groups_count(sb); i++)440439 mbt_ctx_mark_used(sb, i, 0, EXT4_CLUSTERS_PER_GROUP(sb));441440 ar.goal = ext4_group_first_block_no(sb, goal_group);442442- found = ext4_mb_new_blocks_simple(&ar, &err);441441+ found = ext4_mb_new_blocks_simple_test(&ar, &err);443442 KUNIT_ASSERT_EQ_MSG(test,444443 ext4_group_first_block_no(sb, 0) + EXT4_C2B(sbi, 1), found,445444 "failed to alloc block before goal group, expected %llu found %llu",···449448 for (i = 0; i < ext4_get_groups_count(sb); i++)450449 mbt_ctx_mark_used(sb, i, 0, EXT4_CLUSTERS_PER_GROUP(sb));451450 ar.goal = ext4_group_first_block_no(sb, goal_group);452452- found = ext4_mb_new_blocks_simple(&ar, &err);451451+ found = ext4_mb_new_blocks_simple_test(&ar, &err);453452 KUNIT_ASSERT_NE_MSG(test, err, 0,454453 "unexpectedly get block when no block is available");455454}···493492 continue;494493495494 bitmap = mbt_ctx_bitmap(sb, i);496496- bit = mb_find_next_zero_bit(bitmap, max, 0);495495+ bit = mb_find_next_zero_bit_test(bitmap, max, 0);497496 KUNIT_ASSERT_EQ_MSG(test, bit, max,498497 "free block on unexpected group %d", i);499498 }500499501500 bitmap = mbt_ctx_bitmap(sb, goal_group);502502- bit = mb_find_next_zero_bit(bitmap, max, 0);501501+ bit = mb_find_next_zero_bit_test(bitmap, max, 0);503502 KUNIT_ASSERT_EQ(test, bit, start);504503505505- bit = mb_find_next_bit(bitmap, max, bit + 1);504504+ bit = mb_find_next_bit_test(bitmap, max, bit + 1);506505 KUNIT_ASSERT_EQ(test, bit, start + len);507506}508507···525524526525 block = ext4_group_first_block_no(sb, goal_group) +527526 EXT4_C2B(sbi, start);528528- ext4_free_blocks_simple(inode, block, len);527527+ ext4_free_blocks_simple_test(inode, block, len);529528 validate_free_blocks_simple(test, sb, goal_group, start, len);530529 mbt_ctx_mark_used(sb, goal_group, 0, EXT4_CLUSTERS_PER_GROUP(sb));531530}···567566568567 bitmap = mbt_ctx_bitmap(sb, TEST_GOAL_GROUP);569568 memset(bitmap, 0, sb->s_blocksize);570570- ret = ext4_mb_mark_diskspace_used(ac, NULL);569569+ ret = ext4_mb_mark_diskspace_used_test(ac, NULL);571570 KUNIT_ASSERT_EQ(test, ret, 0);572571573572 max = EXT4_CLUSTERS_PER_GROUP(sb);574574- i = mb_find_next_bit(bitmap, max, 0);573573+ i = mb_find_next_bit_test(bitmap, max, 0);575574 KUNIT_ASSERT_EQ(test, i, start);576576- i = mb_find_next_zero_bit(bitmap, max, i + 1);575575+ i = mb_find_next_zero_bit_test(bitmap, max, i + 1);577576 KUNIT_ASSERT_EQ(test, i, start + len);578578- i = mb_find_next_bit(bitmap, max, i + 1);577577+ i = mb_find_next_bit_test(bitmap, max, i + 1);579578 KUNIT_ASSERT_EQ(test, max, i);580579}581580···618617 max = EXT4_CLUSTERS_PER_GROUP(sb);619618 bb_h = buddy + sbi->s_mb_offsets[1];620619621621- off = mb_find_next_zero_bit(bb, max, 0);620620+ off = mb_find_next_zero_bit_test(bb, max, 0);622621 grp->bb_first_free = off;623622 while (off < max) {624623 grp->bb_counters[0]++;625624 grp->bb_free++;626625627627- if (!(off & 1) && !mb_test_bit(off + 1, bb)) {626626+ if (!(off & 1) && !mb_test_bit_test(off + 1, bb)) {628627 grp->bb_free++;629628 grp->bb_counters[0]--;630630- mb_clear_bit(off >> 1, bb_h);629629+ mb_clear_bit_test(off >> 1, bb_h);631630 grp->bb_counters[1]++;632631 grp->bb_largest_free_order = 1;633632 off++;634633 }635634636636- off = mb_find_next_zero_bit(bb, max, off + 1);635635+ off = mb_find_next_zero_bit_test(bb, max, off + 1);637636 }638637639638 for (order = 1; order < MB_NUM_ORDERS(sb) - 1; order++) {640639 bb = buddy + sbi->s_mb_offsets[order];641640 bb_h = buddy + sbi->s_mb_offsets[order + 1];642641 max = max >> 1;643643- off = mb_find_next_zero_bit(bb, max, 0);642642+ off = mb_find_next_zero_bit_test(bb, max, 0);644643645644 while (off < max) {646646- if (!(off & 1) && !mb_test_bit(off + 1, bb)) {645645+ if (!(off & 1) && !mb_test_bit_test(off + 1, bb)) {647646 mb_set_bits(bb, off, 2);648647 grp->bb_counters[order] -= 2;649649- mb_clear_bit(off >> 1, bb_h);648648+ mb_clear_bit_test(off >> 1, bb_h);650649 grp->bb_counters[order + 1]++;651650 grp->bb_largest_free_order = order + 1;652651 off++;653652 }654653655655- off = mb_find_next_zero_bit(bb, max, off + 1);654654+ off = mb_find_next_zero_bit_test(bb, max, off + 1);656655 }657656 }658657659658 max = EXT4_CLUSTERS_PER_GROUP(sb);660660- off = mb_find_next_zero_bit(bitmap, max, 0);659659+ off = mb_find_next_zero_bit_test(bitmap, max, 0);661660 while (off < max) {662661 grp->bb_fragments++;663662664664- off = mb_find_next_bit(bitmap, max, off + 1);663663+ off = mb_find_next_bit_test(bitmap, max, off + 1);665664 if (off + 1 >= max)666665 break;667666668668- off = mb_find_next_zero_bit(bitmap, max, off + 1);667667+ off = mb_find_next_zero_bit_test(bitmap, max, off + 1);669668 }670669}671670···707706 /* needed by validation in ext4_mb_generate_buddy */708707 ext4_grp->bb_free = mbt_grp->bb_free;709708 memset(ext4_buddy, 0xff, sb->s_blocksize);710710- ext4_mb_generate_buddy(sb, ext4_buddy, bitmap, TEST_GOAL_GROUP,709709+ ext4_mb_generate_buddy_test(sb, ext4_buddy, bitmap, TEST_GOAL_GROUP,711710 ext4_grp);712711713712 KUNIT_ASSERT_EQ(test, memcmp(mbt_buddy, ext4_buddy, sb->s_blocksize),···761760 ex.fe_group = TEST_GOAL_GROUP;762761763762 ext4_lock_group(sb, TEST_GOAL_GROUP);764764- mb_mark_used(e4b, &ex);763763+ mb_mark_used_test(e4b, &ex);765764 ext4_unlock_group(sb, TEST_GOAL_GROUP);766765767766 mb_set_bits(bitmap, start, len);···770769 memset(buddy, 0xff, sb->s_blocksize);771770 for (i = 0; i < MB_NUM_ORDERS(sb); i++)772771 grp->bb_counters[i] = 0;773773- ext4_mb_generate_buddy(sb, buddy, bitmap, 0, grp);772772+ ext4_mb_generate_buddy_test(sb, buddy, bitmap, 0, grp);774773775774 KUNIT_ASSERT_EQ(test, memcmp(buddy, e4b->bd_buddy, sb->s_blocksize),776775 0);···799798 bb_counters[MB_NUM_ORDERS(sb)]), GFP_KERNEL);800799 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, grp);801800802802- ret = ext4_mb_load_buddy(sb, TEST_GOAL_GROUP, &e4b);801801+ ret = ext4_mb_load_buddy_test(sb, TEST_GOAL_GROUP, &e4b);803802 KUNIT_ASSERT_EQ(test, ret, 0);804803805804 grp->bb_free = EXT4_CLUSTERS_PER_GROUP(sb);···810809 test_mb_mark_used_range(test, &e4b, ranges[i].start,811810 ranges[i].len, bitmap, buddy, grp);812811813813- ext4_mb_unload_buddy(&e4b);812812+ ext4_mb_unload_buddy_test(&e4b);814813}815814816815static void···826825 return;827826828827 ext4_lock_group(sb, e4b->bd_group);829829- mb_free_blocks(NULL, e4b, start, len);828828+ mb_free_blocks_test(NULL, e4b, start, len);830829 ext4_unlock_group(sb, e4b->bd_group);831830832832- mb_clear_bits(bitmap, start, len);831831+ mb_clear_bits_test(bitmap, start, len);833832 /* bypass bb_free validatoin in ext4_mb_generate_buddy */834833 grp->bb_free += len;835834 memset(buddy, 0xff, sb->s_blocksize);836835 for (i = 0; i < MB_NUM_ORDERS(sb); i++)837836 grp->bb_counters[i] = 0;838838- ext4_mb_generate_buddy(sb, buddy, bitmap, 0, grp);837837+ ext4_mb_generate_buddy_test(sb, buddy, bitmap, 0, grp);839838840839 KUNIT_ASSERT_EQ(test, memcmp(buddy, e4b->bd_buddy, sb->s_blocksize),841840 0);···866865 bb_counters[MB_NUM_ORDERS(sb)]), GFP_KERNEL);867866 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, grp);868867869869- ret = ext4_mb_load_buddy(sb, TEST_GOAL_GROUP, &e4b);868868+ ret = ext4_mb_load_buddy_test(sb, TEST_GOAL_GROUP, &e4b);870869 KUNIT_ASSERT_EQ(test, ret, 0);871870872871 ex.fe_start = 0;···874873 ex.fe_group = TEST_GOAL_GROUP;875874876875 ext4_lock_group(sb, TEST_GOAL_GROUP);877877- mb_mark_used(&e4b, &ex);876876+ mb_mark_used_test(&e4b, &ex);878877 ext4_unlock_group(sb, TEST_GOAL_GROUP);879878880879 grp->bb_free = 0;···887886 test_mb_free_blocks_range(test, &e4b, ranges[i].start,888887 ranges[i].len, bitmap, buddy, grp);889888890890- ext4_mb_unload_buddy(&e4b);889889+ ext4_mb_unload_buddy_test(&e4b);891890}892891893892#define COUNT_FOR_ESTIMATE 100000···905904 if (sb->s_blocksize > PAGE_SIZE)906905 kunit_skip(test, "blocksize exceeds pagesize");907906908908- ret = ext4_mb_load_buddy(sb, TEST_GOAL_GROUP, &e4b);907907+ ret = ext4_mb_load_buddy_test(sb, TEST_GOAL_GROUP, &e4b);909908 KUNIT_ASSERT_EQ(test, ret, 0);910909911910 ex.fe_group = TEST_GOAL_GROUP;···919918 ex.fe_start = ranges[i].start;920919 ex.fe_len = ranges[i].len;921920 ext4_lock_group(sb, TEST_GOAL_GROUP);922922- mb_mark_used(&e4b, &ex);921921+ mb_mark_used_test(&e4b, &ex);923922 ext4_unlock_group(sb, TEST_GOAL_GROUP);924923 }925924 end = jiffies;···930929 continue;931930932931 ext4_lock_group(sb, TEST_GOAL_GROUP);933933- mb_free_blocks(NULL, &e4b, ranges[i].start,932932+ mb_free_blocks_test(NULL, &e4b, ranges[i].start,934933 ranges[i].len);935934 ext4_unlock_group(sb, TEST_GOAL_GROUP);936935 }937936 }938937939938 kunit_info(test, "costed jiffies %lu\n", all);940940- ext4_mb_unload_buddy(&e4b);939939+ ext4_mb_unload_buddy_test(&e4b);941940}942941943942static const struct mbt_ext4_block_layout mbt_test_layouts[] = {
+114-18
fs/ext4/mballoc.c
···1199119912001200 /* searching for the right group start from the goal value specified */12011201 start = ac->ac_g_ex.fe_group;12021202+ if (start >= ngroups)12031203+ start = 0;12021204 ac->ac_prefetch_grp = start;12031205 ac->ac_prefetch_nr = 0;12041206···24452443 return 0;2446244424472445 err = ext4_mb_load_buddy(ac->ac_sb, group, e4b);24482448- if (err)24462446+ if (err) {24472447+ if (EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info) &&24482448+ !(ac->ac_flags & EXT4_MB_HINT_GOAL_ONLY))24492449+ return 0;24492450 return err;24512451+ }2450245224512453 ext4_lock_group(ac->ac_sb, group);24522454 if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info)))···35863580 rcu_read_unlock();35873581 iput(sbi->s_buddy_cache);35883582err_freesgi:35893589- rcu_read_lock();35903590- kvfree(rcu_dereference(sbi->s_group_info));35913591- rcu_read_unlock();35833583+ kvfree(rcu_access_pointer(sbi->s_group_info));35923584 return -ENOMEM;35933585}35943586···38933889 struct kmem_cache *cachep = get_groupinfo_cache(sb->s_blocksize_bits);38943890 int count;3895389138963896- if (test_opt(sb, DISCARD)) {38973897- /*38983898- * wait the discard work to drain all of ext4_free_data38993899- */39003900- flush_work(&sbi->s_discard_work);39013901- WARN_ON_ONCE(!list_empty(&sbi->s_discard_list));39023902- }38923892+ /*38933893+ * wait the discard work to drain all of ext4_free_data38943894+ */38953895+ flush_work(&sbi->s_discard_work);38963896+ WARN_ON_ONCE(!list_empty(&sbi->s_discard_list));3903389739043904- if (sbi->s_group_info) {38983898+ group_info = rcu_access_pointer(sbi->s_group_info);38993899+ if (group_info) {39053900 for (i = 0; i < ngroups; i++) {39063901 cond_resched();39073902 grinfo = ext4_get_group_info(sb, i);···39183915 num_meta_group_infos = (ngroups +39193916 EXT4_DESC_PER_BLOCK(sb) - 1) >>39203917 EXT4_DESC_PER_BLOCK_BITS(sb);39213921- rcu_read_lock();39223922- group_info = rcu_dereference(sbi->s_group_info);39233918 for (i = 0; i < num_meta_group_infos; i++)39243919 kfree(group_info[i]);39253920 kvfree(group_info);39263926- rcu_read_unlock();39273921 }39283922 ext4_mb_avg_fragment_size_destroy(sbi);39293923 ext4_mb_largest_free_orders_destroy(sbi);···4084408440854085#define EXT4_MB_BITMAP_MARKED_CHECK 0x000140864086#define EXT4_MB_SYNC_UPDATE 0x000240874087-static int40874087+int40884088ext4_mb_mark_context(handle_t *handle, struct super_block *sb, bool state,40894089 ext4_group_t group, ext4_grpblk_t blkoff,40904090 ext4_grpblk_t len, int flags, ext4_grpblk_t *ret_changed)···71887188 return error;71897189}7190719071917191-#ifdef CONFIG_EXT4_KUNIT_TESTS71927192-#include "mballoc-test.c"71917191+#if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS)71927192+void mb_clear_bits_test(void *bm, int cur, int len)71937193+{71947194+ mb_clear_bits(bm, cur, len);71957195+}71967196+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_clear_bits_test);71977197+71987198+ext4_fsblk_t71997199+ext4_mb_new_blocks_simple_test(struct ext4_allocation_request *ar,72007200+ int *errp)72017201+{72027202+ return ext4_mb_new_blocks_simple(ar, errp);72037203+}72047204+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_new_blocks_simple_test);72057205+72067206+int mb_find_next_zero_bit_test(void *addr, int max, int start)72077207+{72087208+ return mb_find_next_zero_bit(addr, max, start);72097209+}72107210+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_find_next_zero_bit_test);72117211+72127212+int mb_find_next_bit_test(void *addr, int max, int start)72137213+{72147214+ return mb_find_next_bit(addr, max, start);72157215+}72167216+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_find_next_bit_test);72177217+72187218+void mb_clear_bit_test(int bit, void *addr)72197219+{72207220+ mb_clear_bit(bit, addr);72217221+}72227222+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_clear_bit_test);72237223+72247224+int mb_test_bit_test(int bit, void *addr)72257225+{72267226+ return mb_test_bit(bit, addr);72277227+}72287228+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_test_bit_test);72297229+72307230+int ext4_mb_mark_diskspace_used_test(struct ext4_allocation_context *ac,72317231+ handle_t *handle)72327232+{72337233+ return ext4_mb_mark_diskspace_used(ac, handle);72347234+}72357235+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_mark_diskspace_used_test);72367236+72377237+int mb_mark_used_test(struct ext4_buddy *e4b, struct ext4_free_extent *ex)72387238+{72397239+ return mb_mark_used(e4b, ex);72407240+}72417241+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_mark_used_test);72427242+72437243+void ext4_mb_generate_buddy_test(struct super_block *sb, void *buddy,72447244+ void *bitmap, ext4_group_t group,72457245+ struct ext4_group_info *grp)72467246+{72477247+ ext4_mb_generate_buddy(sb, buddy, bitmap, group, grp);72487248+}72497249+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_generate_buddy_test);72507250+72517251+int ext4_mb_load_buddy_test(struct super_block *sb, ext4_group_t group,72527252+ struct ext4_buddy *e4b)72537253+{72547254+ return ext4_mb_load_buddy(sb, group, e4b);72557255+}72567256+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_load_buddy_test);72577257+72587258+void ext4_mb_unload_buddy_test(struct ext4_buddy *e4b)72597259+{72607260+ ext4_mb_unload_buddy(e4b);72617261+}72627262+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_unload_buddy_test);72637263+72647264+void mb_free_blocks_test(struct inode *inode, struct ext4_buddy *e4b,72657265+ int first, int count)72667266+{72677267+ mb_free_blocks(inode, e4b, first, count);72687268+}72697269+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_free_blocks_test);72707270+72717271+void ext4_free_blocks_simple_test(struct inode *inode, ext4_fsblk_t block,72727272+ unsigned long count)72737273+{72747274+ return ext4_free_blocks_simple(inode, block, count);72757275+}72767276+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_free_blocks_simple_test);72777277+72787278+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_wait_block_bitmap);72797279+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_init);72807280+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_get_group_desc);72817281+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_count_free_clusters);72827282+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_get_group_info);72837283+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_free_group_clusters_set);72847284+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_release);72857285+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_read_block_bitmap_nowait);72867286+EXPORT_SYMBOL_FOR_EXT4_TEST(mb_set_bits);72877287+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_fc_init_inode);72887288+EXPORT_SYMBOL_FOR_EXT4_TEST(ext4_mb_mark_context);71937289#endif
+30
fs/ext4/mballoc.h
···270270 ext4_mballoc_query_range_fn formatter,271271 void *priv);272272273273+extern int ext4_mb_mark_context(handle_t *handle,274274+ struct super_block *sb, bool state,275275+ ext4_group_t group, ext4_grpblk_t blkoff,276276+ ext4_grpblk_t len, int flags,277277+ ext4_grpblk_t *ret_changed);278278+#if IS_ENABLED(CONFIG_EXT4_KUNIT_TESTS)279279+extern void mb_clear_bits_test(void *bm, int cur, int len);280280+extern ext4_fsblk_t281281+ext4_mb_new_blocks_simple_test(struct ext4_allocation_request *ar,282282+ int *errp);283283+extern int mb_find_next_zero_bit_test(void *addr, int max, int start);284284+extern int mb_find_next_bit_test(void *addr, int max, int start);285285+extern void mb_clear_bit_test(int bit, void *addr);286286+extern int mb_test_bit_test(int bit, void *addr);287287+extern int288288+ext4_mb_mark_diskspace_used_test(struct ext4_allocation_context *ac,289289+ handle_t *handle);290290+extern int mb_mark_used_test(struct ext4_buddy *e4b,291291+ struct ext4_free_extent *ex);292292+extern void ext4_mb_generate_buddy_test(struct super_block *sb,293293+ void *buddy, void *bitmap, ext4_group_t group,294294+ struct ext4_group_info *grp);295295+extern int ext4_mb_load_buddy_test(struct super_block *sb,296296+ ext4_group_t group, struct ext4_buddy *e4b);297297+extern void ext4_mb_unload_buddy_test(struct ext4_buddy *e4b);298298+extern void mb_free_blocks_test(struct inode *inode,299299+ struct ext4_buddy *e4b, int first, int count);300300+extern void ext4_free_blocks_simple_test(struct inode *inode,301301+ ext4_fsblk_t block, unsigned long count);302302+#endif273303#endif
+8-2
fs/ext4/page-io.c
···524524 nr_to_submit++;525525 } while ((bh = bh->b_this_page) != head);526526527527- /* Nothing to submit? Just unlock the folio... */528528- if (!nr_to_submit)527527+ if (!nr_to_submit) {528528+ /*529529+ * We have nothing to submit. Just cycle the folio through530530+ * writeback state to properly update xarray tags.531531+ */532532+ __folio_start_writeback(folio, keep_towrite);533533+ folio_end_writeback(folio);529534 return 0;535535+ }530536531537 bh = head = folio_buffers(folio);532538
+31-6
fs/ext4/super.c
···12541254 struct buffer_head **group_desc;12551255 int i;1256125612571257- rcu_read_lock();12581258- group_desc = rcu_dereference(sbi->s_group_desc);12571257+ group_desc = rcu_access_pointer(sbi->s_group_desc);12591258 for (i = 0; i < sbi->s_gdb_count; i++)12601259 brelse(group_desc[i]);12611260 kvfree(group_desc);12621262- rcu_read_unlock();12631261}1264126212651263static void ext4_flex_groups_free(struct ext4_sb_info *sbi)···12651267 struct flex_groups **flex_groups;12661268 int i;1267126912681268- rcu_read_lock();12691269- flex_groups = rcu_dereference(sbi->s_flex_groups);12701270+ flex_groups = rcu_access_pointer(sbi->s_flex_groups);12701271 if (flex_groups) {12711272 for (i = 0; i < sbi->s_flex_groups_allocated; i++)12721273 kvfree(flex_groups[i]);12731274 kvfree(flex_groups);12741275 }12751275- rcu_read_unlock();12761276}1277127712781278static void ext4_put_super(struct super_block *sb)···15231527 invalidate_inode_buffers(inode);15241528 clear_inode(inode);15251529 ext4_discard_preallocations(inode);15301530+ /*15311531+ * We must remove the inode from the hash before ext4_free_inode()15321532+ * clears the bit in inode bitmap as otherwise another process reusing15331533+ * the inode will block in insert_inode_hash() waiting for inode15341534+ * eviction to complete while holding transaction handle open, but15351535+ * ext4_evict_inode() still running for that inode could block waiting15361536+ * for transaction commit if the inode is marked as IS_SYNC => deadlock.15371537+ *15381538+ * Removing the inode from the hash here is safe. There are two cases15391539+ * to consider:15401540+ * 1) The inode still has references to it (i_nlink > 0). In that case15411541+ * we are keeping the inode and once we remove the inode from the hash,15421542+ * iget() can create the new inode structure for the same inode number15431543+ * and we are fine with that as all IO on behalf of the inode is15441544+ * finished.15451545+ * 2) We are deleting the inode (i_nlink == 0). In that case inode15461546+ * number cannot be reused until ext4_free_inode() clears the bit in15471547+ * the inode bitmap, at which point all IO is done and reuse is fine15481548+ * again.15491549+ */15501550+ remove_inode_hash(inode);15261551 ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS);15271552 dquot_drop(inode);15281553 if (EXT4_I(inode)->jinode) {···36503633 "extents feature\n");36513634 return 0;36523635 }36363636+ if (ext4_has_feature_bigalloc(sb) &&36373637+ le32_to_cpu(EXT4_SB(sb)->s_es->s_first_data_block)) {36383638+ ext4_msg(sb, KERN_WARNING,36393639+ "bad geometry: bigalloc file system with non-zero "36403640+ "first_data_block\n");36413641+ return 0;36423642+ }3653364336543644#if !IS_ENABLED(CONFIG_QUOTA) || !IS_ENABLED(CONFIG_QFMT_V2)36553645 if (!readonly && (ext4_has_feature_quota(sb) ||···5427540354285404 timer_setup(&sbi->s_err_report, print_daily_error_info, 0);54295405 spin_lock_init(&sbi->s_error_lock);54065406+ mutex_init(&sbi->s_error_notify_mutex);54305407 INIT_WORK(&sbi->s_sb_upd_work, update_super_work);5431540854325409 err = ext4_group_desc_init(sb, es, logical_sb_block, &first_not_zeroed);
···17111711 }17121712}1713171317141714+static bool __sync_lazytime(struct inode *inode)17151715+{17161716+ spin_lock(&inode->i_lock);17171717+ if (!(inode_state_read(inode) & I_DIRTY_TIME)) {17181718+ spin_unlock(&inode->i_lock);17191719+ return false;17201720+ }17211721+ inode_state_clear(inode, I_DIRTY_TIME);17221722+ spin_unlock(&inode->i_lock);17231723+ inode->i_op->sync_lazytime(inode);17241724+ return true;17251725+}17261726+17141727bool sync_lazytime(struct inode *inode)17151728{17161729 if (!(inode_state_read_once(inode) & I_DIRTY_TIME))···1731171817321719 trace_writeback_lazytime(inode);17331720 if (inode->i_op->sync_lazytime)17341734- inode->i_op->sync_lazytime(inode);17351735- else17361736- mark_inode_dirty_sync(inode);17211721+ return __sync_lazytime(inode);17221722+ mark_inode_dirty_sync(inode);17371723 return true;17381724}17391725···27872775 * The mapping can appear untagged while still on-list since we27882776 * do not have the mapping lock. Skip it here, wb completion27892777 * will remove it.27902790- *27912791- * If the mapping does not have data integrity semantics,27922792- * there's no need to wait for the writeout to complete, as the27932793- * mapping cannot guarantee that data is persistently stored.27942778 */27952795- if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK) ||27962796- mapping_no_data_integrity(mapping))27792779+ if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK))27972780 continue;2798278127992782 spin_unlock_irq(&sb->s_inode_wblist_lock);···29232916 */29242917 if (bdi == &noop_backing_dev_info)29252918 return;29192919+29202920+ /*29212921+ * If the superblock has SB_I_NO_DATA_INTEGRITY set, there's no need to29222922+ * wait for the writeout to complete, as the filesystem cannot guarantee29232923+ * data persistence on sync. Just kick off writeback and return.29242924+ */29252925+ if (sb->s_iflags & SB_I_NO_DATA_INTEGRITY) {29262926+ wakeup_flusher_threads_bdi(bdi, WB_REASON_SYNC);29272927+ return;29282928+ }29292929+29262930 WARN_ON(!rwsem_is_locked(&sb->s_umount));2927293129282932 /* protect against inode wb switch, see inode_switch_wbs_work_fn() */
+1-3
fs/fuse/file.c
···3201320132023202 inode->i_fop = &fuse_file_operations;32033203 inode->i_data.a_ops = &fuse_file_aops;32043204- if (fc->writeback_cache) {32043204+ if (fc->writeback_cache)32053205 mapping_set_writeback_may_deadlock_on_reclaim(&inode->i_data);32063206- mapping_set_no_data_integrity(&inode->i_data);32073207- }3208320632093207 INIT_LIST_HEAD(&fi->write_files);32103208 INIT_LIST_HEAD(&fi->queued_writes);
···88#include "internal.h"99#include "trace.h"10101111-static void iomap_read_end_io(struct bio *bio)1111+static DEFINE_SPINLOCK(failed_read_lock);1212+static struct bio_list failed_read_list = BIO_EMPTY_LIST;1313+1414+static void __iomap_read_end_io(struct bio *bio)1215{1316 int error = blk_status_to_errno(bio->bi_status);1417 struct folio_iter fi;···1916 bio_for_each_folio_all(fi, bio)2017 iomap_finish_folio_read(fi.folio, fi.offset, fi.length, error);2118 bio_put(bio);1919+}2020+2121+static void2222+iomap_fail_reads(2323+ struct work_struct *work)2424+{2525+ struct bio *bio;2626+ struct bio_list tmp = BIO_EMPTY_LIST;2727+ unsigned long flags;2828+2929+ spin_lock_irqsave(&failed_read_lock, flags);3030+ bio_list_merge_init(&tmp, &failed_read_list);3131+ spin_unlock_irqrestore(&failed_read_lock, flags);3232+3333+ while ((bio = bio_list_pop(&tmp)) != NULL) {3434+ __iomap_read_end_io(bio);3535+ cond_resched();3636+ }3737+}3838+3939+static DECLARE_WORK(failed_read_work, iomap_fail_reads);4040+4141+static void iomap_fail_buffered_read(struct bio *bio)4242+{4343+ unsigned long flags;4444+4545+ /*4646+ * Bounce I/O errors to a workqueue to avoid nested i_lock acquisitions4747+ * in the fserror code. The caller no longer owns the bio reference4848+ * after the spinlock drops.4949+ */5050+ spin_lock_irqsave(&failed_read_lock, flags);5151+ if (bio_list_empty(&failed_read_list))5252+ WARN_ON_ONCE(!schedule_work(&failed_read_work));5353+ bio_list_add(&failed_read_list, bio);5454+ spin_unlock_irqrestore(&failed_read_lock, flags);5555+}5656+5757+static void iomap_read_end_io(struct bio *bio)5858+{5959+ if (bio->bi_status) {6060+ iomap_fail_buffered_read(bio);6161+ return;6262+ }6363+6464+ __iomap_read_end_io(bio);2265}23662467static void iomap_bio_submit_read(struct iomap_read_folio_ctx *ctx)
+10-5
fs/iomap/buffered-io.c
···514514 loff_t length = iomap_length(iter);515515 struct folio *folio = ctx->cur_folio;516516 size_t folio_len = folio_size(folio);517517+ struct iomap_folio_state *ifs;517518 size_t poff, plen;518519 loff_t pos_diff;519520 int ret;···526525 return iomap_iter_advance(iter, length);527526 }528527529529- ifs_alloc(iter->inode, folio, iter->flags);528528+ ifs = ifs_alloc(iter->inode, folio, iter->flags);530529531530 length = min_t(loff_t, length, folio_len - offset_in_folio(folio, pos));532531 while (length) {···561560562561 *bytes_submitted += plen;563562 /*564564- * If the entire folio has been read in by the IO565565- * helper, then the helper owns the folio and will end566566- * the read on it.563563+ * Hand off folio ownership to the IO helper when:564564+ * 1) The entire folio has been submitted for IO, or565565+ * 2) There is no ifs attached to the folio566566+ *567567+ * Case (2) occurs when 1 << i_blkbits matches the folio568568+ * size but the underlying filesystem or block device569569+ * uses a smaller granularity for IO.567570 */568568- if (*bytes_submitted == folio_len)571571+ if (*bytes_submitted == folio_len || !ifs)569572 ctx->cur_folio = NULL;570573 }571574
+13-2
fs/jbd2/checkpoint.c
···267267 */268268 BUFFER_TRACE(bh, "queue");269269 get_bh(bh);270270- J_ASSERT_BH(bh, !buffer_jwrite(bh));270270+ if (WARN_ON_ONCE(buffer_jwrite(bh))) {271271+ put_bh(bh); /* drop the ref we just took */272272+ spin_unlock(&journal->j_list_lock);273273+ /* Clean up any previously batched buffers */274274+ if (batch_count)275275+ __flush_batch(journal, &batch_count);276276+ jbd2_journal_abort(journal, -EFSCORRUPTED);277277+ return -EFSCORRUPTED;278278+ }271279 journal->j_chkpt_bhs[batch_count++] = bh;272280 transaction->t_chp_stats.cs_written++;273281 transaction->t_checkpoint_list = jh->b_cpnext;···333325334326 if (!jbd2_journal_get_log_tail(journal, &first_tid, &blocknr))335327 return 1;336336- J_ASSERT(blocknr != 0);328328+ if (WARN_ON_ONCE(blocknr == 0)) {329329+ jbd2_journal_abort(journal, -EFSCORRUPTED);330330+ return -EFSCORRUPTED;331331+ }337332338333 /*339334 * We need to make sure that any blocks that were recently written out
+8-2
fs/namei.c
···24372437EXPORT_SYMBOL(hashlen_string);2438243824392439/*24402440- * Calculate the length and hash of the path component, and24412441- * return the length as the result.24402440+ * hash_name - Calculate the length and hash of the path component24412441+ * @nd: the path resolution state24422442+ * @name: the pathname to read the component from24432443+ * @lastword: if the component fits in a single word, LAST_WORD_IS_DOT,24442444+ * LAST_WORD_IS_DOTDOT, or some other value depending on whether the24452445+ * component is '.', '..', or something else. Otherwise, @lastword is 0.24462446+ *24472447+ * Returns: a pointer to the terminating '/' or NUL character in @name.24422448 */24432449static inline const char *hash_name(struct nameidata *nd,24442450 const char *name,
+1-2
fs/netfs/buffered_read.c
···171171 spin_lock(&rreq->lock);172172 list_add_tail(&subreq->rreq_link, &stream->subrequests);173173 if (list_is_first(&subreq->rreq_link, &stream->subrequests)) {174174- stream->front = subreq;175174 if (!stream->active) {176176- stream->collected_to = stream->front->start;175175+ stream->collected_to = subreq->start;177176 /* Store list pointers before active flag */178177 smp_store_release(&stream->active, true);179178 }
+1-2
fs/netfs/direct_read.c
···7171 spin_lock(&rreq->lock);7272 list_add_tail(&subreq->rreq_link, &stream->subrequests);7373 if (list_is_first(&subreq->rreq_link, &stream->subrequests)) {7474- stream->front = subreq;7574 if (!stream->active) {7676- stream->collected_to = stream->front->start;7575+ stream->collected_to = subreq->start;7776 /* Store list pointers before active flag */7877 smp_store_release(&stream->active, true);7978 }
···143143}144144145145/*146146+ * Select the span of a kvec iterator we're going to use. Limit it by both147147+ * maximum size and maximum number of segments. Returns the size of the span148148+ * in bytes.149149+ */150150+static size_t netfs_limit_kvec(const struct iov_iter *iter, size_t start_offset,151151+ size_t max_size, size_t max_segs)152152+{153153+ const struct kvec *kvecs = iter->kvec;154154+ unsigned int nkv = iter->nr_segs, ix = 0, nsegs = 0;155155+ size_t len, span = 0, n = iter->count;156156+ size_t skip = iter->iov_offset + start_offset;157157+158158+ if (WARN_ON(!iov_iter_is_kvec(iter)) ||159159+ WARN_ON(start_offset > n) ||160160+ n == 0)161161+ return 0;162162+163163+ while (n && ix < nkv && skip) {164164+ len = kvecs[ix].iov_len;165165+ if (skip < len)166166+ break;167167+ skip -= len;168168+ n -= len;169169+ ix++;170170+ }171171+172172+ while (n && ix < nkv) {173173+ len = min3(n, kvecs[ix].iov_len - skip, max_size);174174+ span += len;175175+ nsegs++;176176+ ix++;177177+ if (span >= max_size || nsegs >= max_segs)178178+ break;179179+ skip = 0;180180+ n -= len;181181+ }182182+183183+ return min(span, max_size);184184+}185185+186186+/*146187 * Select the span of an xarray iterator we're going to use. Limit it by both147188 * maximum size and maximum number of segments. It is assumed that segments148189 * can be larger than a page in size, provided they're physically contiguous.···286245 return netfs_limit_bvec(iter, start_offset, max_size, max_segs);287246 if (iov_iter_is_xarray(iter))288247 return netfs_limit_xarray(iter, start_offset, max_size, max_segs);248248+ if (iov_iter_is_kvec(iter))249249+ return netfs_limit_kvec(iter, start_offset, max_size, max_segs);289250 BUG();290251}291252EXPORT_SYMBOL(netfs_limit_iter);
+2-2
fs/netfs/read_collect.c
···205205 * in progress. The issuer thread may be adding stuff to the tail206206 * whilst we're doing this.207207 */208208- front = READ_ONCE(stream->front);208208+ front = list_first_entry_or_null(&stream->subrequests,209209+ struct netfs_io_subrequest, rreq_link);209210 while (front) {210211 size_t transferred;211212···302301 list_del_init(&front->rreq_link);303302 front = list_first_entry_or_null(&stream->subrequests,304303 struct netfs_io_subrequest, rreq_link);305305- stream->front = front;306304 spin_unlock(&rreq->lock);307305 netfs_put_subrequest(remove,308306 notes & ABANDON_SREQ ?
···107107 spin_lock(&rreq->lock);108108 list_add_tail(&subreq->rreq_link, &stream->subrequests);109109 trace_netfs_sreq(subreq, netfs_sreq_trace_added);110110- stream->front = subreq;111110 /* Store list pointers before active flag */112111 smp_store_release(&stream->active, true);113112 spin_unlock(&rreq->lock);
+2-2
fs/netfs/write_collect.c
···228228 if (!smp_load_acquire(&stream->active))229229 continue;230230231231- front = stream->front;231231+ front = list_first_entry_or_null(&stream->subrequests,232232+ struct netfs_io_subrequest, rreq_link);232233 while (front) {233234 trace_netfs_collect_sreq(wreq, front);234235 //_debug("sreq [%x] %llx %zx/%zx",···280279 list_del_init(&front->rreq_link);281280 front = list_first_entry_or_null(&stream->subrequests,282281 struct netfs_io_subrequest, rreq_link);283283- stream->front = front;284282 spin_unlock(&wreq->lock);285283 netfs_put_subrequest(remove,286284 notes & SAW_FAILURE ?
+1-2
fs/netfs/write_issue.c
···206206 spin_lock(&wreq->lock);207207 list_add_tail(&subreq->rreq_link, &stream->subrequests);208208 if (list_is_first(&subreq->rreq_link, &stream->subrequests)) {209209- stream->front = subreq;210209 if (!stream->active) {211211- stream->collected_to = stream->front->start;210210+ stream->collected_to = subreq->start;212211 /* Write list pointers before active flag */213212 smp_store_release(&stream->active, true);214213 }
+3-3
fs/overlayfs/copy_up.c
···11461146 return -EOVERFLOW;1147114711481148 /*11491149- * With metacopy disabled, we fsync after final metadata copyup, for11491149+ * With "fsync=strict", we fsync after final metadata copyup, for11501150 * both regular files and directories to get atomic copyup semantics11511151 * on filesystems that do not use strict metadata ordering (e.g. ubifs).11521152 *11531153- * With metacopy enabled we want to avoid fsync on all meta copyup11531153+ * By default, we want to avoid fsync on all meta copyup, because11541154 * that will hurt performance of workloads such as chown -R, so we11551155 * only fsync on data copyup as legacy behavior.11561156 */11571157- ctx.metadata_fsync = !OVL_FS(dentry->d_sb)->config.metacopy &&11571157+ ctx.metadata_fsync = ovl_should_sync_metadata(OVL_FS(dentry->d_sb)) &&11581158 (S_ISREG(ctx.stat.mode) || S_ISDIR(ctx.stat.mode));11591159 ctx.metacopy = ovl_need_meta_copy_up(dentry, ctx.stat.mode, flags);11601160
+21
fs/overlayfs/overlayfs.h
···9999 OVL_VERITY_REQUIRE,100100};101101102102+enum {103103+ OVL_FSYNC_VOLATILE,104104+ OVL_FSYNC_AUTO,105105+ OVL_FSYNC_STRICT,106106+};107107+102108/*103109 * The tuple (fh,uuid) is a universal unique identifier for a copy up origin,104110 * where:···660654static inline bool ovl_xino_warn(struct ovl_fs *ofs)661655{662656 return ofs->config.xino == OVL_XINO_ON;657657+}658658+659659+static inline bool ovl_should_sync(struct ovl_fs *ofs)660660+{661661+ return ofs->config.fsync_mode != OVL_FSYNC_VOLATILE;662662+}663663+664664+static inline bool ovl_should_sync_metadata(struct ovl_fs *ofs)665665+{666666+ return ofs->config.fsync_mode == OVL_FSYNC_STRICT;667667+}668668+669669+static inline bool ovl_is_volatile(struct ovl_config *config)670670+{671671+ return config->fsync_mode == OVL_FSYNC_VOLATILE;663672}664673665674/*
···776776 * For volatile mount, create a incompat/volatile/dirty file to keep777777 * track of it.778778 */779779- if (ofs->config.ovl_volatile) {779779+ if (ovl_is_volatile(&ofs->config)) {780780 err = ovl_create_volatile_dirty(ofs);781781 if (err < 0) {782782 pr_err("Failed to create volatile/dirty file.\n");
···5555 struct xfs_trans *tp;5656 struct xfs_inode *dp; /* inode */5757 struct xfs_attrlist_cursor_kern cursor; /* position in list */5858- void *buffer; /* output buffer */5858+ /* output buffer */5959+ void *buffer __counted_by_ptr(bufsize);59606061 /*6162 * Abort attribute list iteration if non-zero. Can be used to pass
+22
fs/xfs/libxfs/xfs_attr_leaf.c
···14161416}1417141714181418/*14191419+ * Reinitialize an existing attr fork block as an empty leaf, and attach14201420+ * the buffer to tp.14211421+ */14221422+int14231423+xfs_attr3_leaf_init(14241424+ struct xfs_trans *tp,14251425+ struct xfs_inode *dp,14261426+ xfs_dablk_t blkno)14271427+{14281428+ struct xfs_buf *bp = NULL;14291429+ struct xfs_da_args args = {14301430+ .trans = tp,14311431+ .dp = dp,14321432+ .owner = dp->i_ino,14331433+ .geo = dp->i_mount->m_attr_geo,14341434+ };14351435+14361436+ ASSERT(tp != NULL);14371437+14381438+ return xfs_attr3_leaf_create(&args, blkno, &bp);14391439+}14401440+/*14191441 * Split the leaf node, rebalance, then add the new entry.14201442 *14211443 * Returns 0 if the entry was added, 1 if a further split is needed or a
+3
fs/xfs/libxfs/xfs_attr_leaf.h
···8787/*8888 * Routines used for shrinking the Btree.8989 */9090+9191+int xfs_attr3_leaf_init(struct xfs_trans *tp, struct xfs_inode *dp,9292+ xfs_dablk_t blkno);9093int xfs_attr3_leaf_toosmall(struct xfs_da_state *state, int *retval);9194void xfs_attr3_leaf_unbalance(struct xfs_da_state *state,9295 struct xfs_da_state_blk *drop_blk,
+42-11
fs/xfs/libxfs/xfs_da_btree.c
···15061506}1507150715081508/*15091509- * Remove an entry from an intermediate node.15091509+ * Internal implementation to remove an entry from an intermediate node.15101510 */15111511STATIC void15121512-xfs_da3_node_remove(15131513- struct xfs_da_state *state,15141514- struct xfs_da_state_blk *drop_blk)15121512+__xfs_da3_node_remove(15131513+ struct xfs_trans *tp,15141514+ struct xfs_inode *dp,15151515+ struct xfs_da_geometry *geo,15161516+ struct xfs_da_state_blk *drop_blk)15151517{15161518 struct xfs_da_intnode *node;15171519 struct xfs_da3_icnode_hdr nodehdr;15181520 struct xfs_da_node_entry *btree;15191521 int index;15201522 int tmp;15211521- struct xfs_inode *dp = state->args->dp;15221522-15231523- trace_xfs_da_node_remove(state->args);1524152315251524 node = drop_blk->bp->b_addr;15261525 xfs_da3_node_hdr_from_disk(dp->i_mount, &nodehdr, node);···15351536 tmp = nodehdr.count - index - 1;15361537 tmp *= (uint)sizeof(xfs_da_node_entry_t);15371538 memmove(&btree[index], &btree[index + 1], tmp);15381538- xfs_trans_log_buf(state->args->trans, drop_blk->bp,15391539+ xfs_trans_log_buf(tp, drop_blk->bp,15391540 XFS_DA_LOGRANGE(node, &btree[index], tmp));15401541 index = nodehdr.count - 1;15411542 }15421543 memset(&btree[index], 0, sizeof(xfs_da_node_entry_t));15431543- xfs_trans_log_buf(state->args->trans, drop_blk->bp,15441544+ xfs_trans_log_buf(tp, drop_blk->bp,15441545 XFS_DA_LOGRANGE(node, &btree[index], sizeof(btree[index])));15451546 nodehdr.count -= 1;15461547 xfs_da3_node_hdr_to_disk(dp->i_mount, node, &nodehdr);15471547- xfs_trans_log_buf(state->args->trans, drop_blk->bp,15481548- XFS_DA_LOGRANGE(node, &node->hdr, state->args->geo->node_hdr_size));15481548+ xfs_trans_log_buf(tp, drop_blk->bp,15491549+ XFS_DA_LOGRANGE(node, &node->hdr, geo->node_hdr_size));1549155015501551 /*15511552 * Copy the last hash value from the block to propagate upwards.15521553 */15531554 drop_blk->hashval = be32_to_cpu(btree[index - 1].hashval);15551555+}15561556+15571557+/*15581558+ * Remove an entry from an intermediate node.15591559+ */15601560+STATIC void15611561+xfs_da3_node_remove(15621562+ struct xfs_da_state *state,15631563+ struct xfs_da_state_blk *drop_blk)15641564+{15651565+ trace_xfs_da_node_remove(state->args);15661566+15671567+ __xfs_da3_node_remove(state->args->trans, state->args->dp,15681568+ state->args->geo, drop_blk);15691569+}15701570+15711571+/*15721572+ * Remove an entry from an intermediate attr node at the specified index.15731573+ */15741574+void15751575+xfs_attr3_node_entry_remove(15761576+ struct xfs_trans *tp,15771577+ struct xfs_inode *dp,15781578+ struct xfs_buf *bp,15791579+ int index)15801580+{15811581+ struct xfs_da_state_blk blk = {15821582+ .index = index,15831583+ .bp = bp,15841584+ };15851585+15861586+ __xfs_da3_node_remove(tp, dp, dp->i_mount->m_attr_geo, &blk);15541587}1555158815561589/*
+2
fs/xfs/libxfs/xfs_da_btree.h
···184184int xfs_da3_join(xfs_da_state_t *state);185185void xfs_da3_fixhashpath(struct xfs_da_state *state,186186 struct xfs_da_state_path *path_to_to_fix);187187+void xfs_attr3_node_entry_remove(struct xfs_trans *tp, struct xfs_inode *dp,188188+ struct xfs_buf *bp, int index);187189188190/*189191 * Routines used for finding things in the Btree.
+3-1
fs/xfs/scrub/quota.c
···171171172172 error = xchk_quota_item_bmap(sc, dq, offset);173173 xchk_iunlock(sc, XFS_ILOCK_SHARED);174174- if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, offset, &error))174174+ if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, offset, &error)) {175175+ mutex_unlock(&dq->q_qlock);175176 return error;177177+ }176178177179 /*178180 * Warn if the hard limits are larger than the fs.
···140140 xfs_daddr_t parent_blkno, child_blkno;141141 struct xfs_buf *child_bp;142142 struct xfs_da3_icnode_hdr ichdr;143143- int error, i;143143+ int error;144144145145 /*146146 * Since this code is recursive (gasp!) we must protect ourselves.···152152 return -EFSCORRUPTED;153153 }154154155155- xfs_da3_node_hdr_from_disk(dp->i_mount, &ichdr, bp->b_addr);155155+ xfs_da3_node_hdr_from_disk(mp, &ichdr, bp->b_addr);156156 parent_blkno = xfs_buf_daddr(bp);157157 if (!ichdr.count) {158158 xfs_trans_brelse(*trans, bp);···167167 * over the leaves removing all of them. If this is higher up168168 * in the tree, recurse downward.169169 */170170- for (i = 0; i < ichdr.count; i++) {170170+ while (ichdr.count > 0) {171171 /*172172 * Read the subsidiary block to see what we have to work with.173173 * Don't do this in a transaction. This is a depth-first···218218 xfs_trans_binval(*trans, child_bp);219219 child_bp = NULL;220220221221- /*222222- * If we're not done, re-read the parent to get the next223223- * child block number.224224- */225225- if (i + 1 < ichdr.count) {226226- struct xfs_da3_icnode_hdr phdr;221221+ error = xfs_da3_node_read_mapped(*trans, dp,222222+ parent_blkno, &bp, XFS_ATTR_FORK);223223+ if (error)224224+ return error;227225228228- error = xfs_da3_node_read_mapped(*trans, dp,229229- parent_blkno, &bp, XFS_ATTR_FORK);226226+ /*227227+ * Remove entry from parent node, prevents being indexed to.228228+ */229229+ xfs_attr3_node_entry_remove(*trans, dp, bp, 0);230230+231231+ xfs_da3_node_hdr_from_disk(mp, &ichdr, bp->b_addr);232232+ bp = NULL;233233+234234+ if (ichdr.count > 0) {235235+ /*236236+ * If we're not done, get the next child block number.237237+ */238238+ child_fsb = be32_to_cpu(ichdr.btree[0].before);239239+240240+ /*241241+ * Atomically commit the whole invalidate stuff.242242+ */243243+ error = xfs_trans_roll_inode(trans, dp);230244 if (error)231245 return error;232232- xfs_da3_node_hdr_from_disk(dp->i_mount, &phdr,233233- bp->b_addr);234234- child_fsb = be32_to_cpu(phdr.btree[i + 1].before);235235- xfs_trans_brelse(*trans, bp);236236- bp = NULL;237246 }238238- /*239239- * Atomically commit the whole invalidate stuff.240240- */241241- error = xfs_trans_roll_inode(trans, dp);242242- if (error)243243- return error;244247 }245248246249 return 0;···260257 struct xfs_trans **trans,261258 struct xfs_inode *dp)262259{263263- struct xfs_mount *mp = dp->i_mount;264260 struct xfs_da_blkinfo *info;265261 struct xfs_buf *bp;266266- xfs_daddr_t blkno;267262 int error;268263269264 /*···273272 error = xfs_da3_node_read(*trans, dp, 0, &bp, XFS_ATTR_FORK);274273 if (error)275274 return error;276276- blkno = xfs_buf_daddr(bp);277275278276 /*279277 * Invalidate the tree, even if the "tree" is only a single leaf block.···283283 case cpu_to_be16(XFS_DA_NODE_MAGIC):284284 case cpu_to_be16(XFS_DA3_NODE_MAGIC):285285 error = xfs_attr3_node_inactive(trans, dp, bp, 1);286286+ /*287287+ * Empty root node block are not allowed, convert it to leaf.288288+ */289289+ if (!error)290290+ error = xfs_attr3_leaf_init(*trans, dp, 0);291291+ if (!error)292292+ error = xfs_trans_roll_inode(trans, dp);286293 break;287294 case cpu_to_be16(XFS_ATTR_LEAF_MAGIC):288295 case cpu_to_be16(XFS_ATTR3_LEAF_MAGIC):289296 error = xfs_attr3_leaf_inactive(trans, dp, bp);297297+ /*298298+ * Reinit the leaf before truncating extents so that a crash299299+ * mid-truncation leaves an empty leaf rather than one with300300+ * entries that may reference freed remote value blocks.301301+ */302302+ if (!error)303303+ error = xfs_attr3_leaf_init(*trans, dp, 0);304304+ if (!error)305305+ error = xfs_trans_roll_inode(trans, dp);290306 break;291307 default:292308 xfs_dirattr_mark_sick(dp, XFS_ATTR_FORK);···311295 xfs_trans_brelse(*trans, bp);312296 break;313297 }314314- if (error)315315- return error;316316-317317- /*318318- * Invalidate the incore copy of the root block.319319- */320320- error = xfs_trans_get_buf(*trans, mp->m_ddev_targp, blkno,321321- XFS_FSB_TO_BB(mp, mp->m_attr_geo->fsbcount), 0, &bp);322322- if (error)323323- return error;324324- xfs_trans_binval(*trans, bp); /* remove from cache */325325- /*326326- * Commit the invalidate and start the next transaction.327327- */328328- error = xfs_trans_roll_inode(trans, dp);329298330299 return error;331300}···329328{330329 struct xfs_trans *trans;331330 struct xfs_mount *mp;331331+ struct xfs_buf *bp;332332 int lock_mode = XFS_ILOCK_SHARED;333333 int error = 0;334334···365363 * removal below.366364 */367365 if (dp->i_af.if_nextents > 0) {366366+ /*367367+ * Invalidate and truncate all blocks but leave the root block.368368+ */368369 error = xfs_attr3_root_inactive(&trans, dp);369370 if (error)370371 goto out_cancel;371372373373+ error = xfs_itruncate_extents(&trans, dp, XFS_ATTR_FORK,374374+ XFS_FSB_TO_B(mp, mp->m_attr_geo->fsbcount));375375+ if (error)376376+ goto out_cancel;377377+378378+ /*379379+ * Invalidate and truncate the root block and ensure that the380380+ * operation is completed within a single transaction.381381+ */382382+ error = xfs_da_get_buf(trans, dp, 0, &bp, XFS_ATTR_FORK);383383+ if (error)384384+ goto out_cancel;385385+386386+ xfs_trans_binval(trans, bp);372387 error = xfs_itruncate_extents(&trans, dp, XFS_ATTR_FORK, 0);373388 if (error)374389 goto out_cancel;
+2-49
fs/xfs/xfs_attr_item.c
···653653 break;654654 }655655 if (error) {656656- xfs_irele(ip);657656 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp, attrp,658657 sizeof(*attrp));659658 return ERR_PTR(-EFSCORRUPTED);···10461047 break;10471048 case XFS_ATTRI_OP_FLAGS_SET:10481049 case XFS_ATTRI_OP_FLAGS_REPLACE:10491049- /* Log item, attr name, attr value */10501050- if (item->ri_total != 3) {10501050+ /* Log item, attr name, optional attr value */10511051+ if (item->ri_total != 2 + !!attri_formatp->alfi_value_len) {10511052 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,10521053 attri_formatp, len);10531054 return -EFSCORRUPTED;···11291130 XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,11301131 attri_formatp, len);11311132 return -EFSCORRUPTED;11321132- }11331133-11341134- switch (op) {11351135- case XFS_ATTRI_OP_FLAGS_REMOVE:11361136- /* Regular remove operations operate only on names. */11371137- if (attr_value != NULL || value_len != 0) {11381138- XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,11391139- attri_formatp, len);11401140- return -EFSCORRUPTED;11411141- }11421142- fallthrough;11431143- case XFS_ATTRI_OP_FLAGS_PPTR_REMOVE:11441144- case XFS_ATTRI_OP_FLAGS_PPTR_SET:11451145- case XFS_ATTRI_OP_FLAGS_SET:11461146- case XFS_ATTRI_OP_FLAGS_REPLACE:11471147- /*11481148- * Regular xattr set/remove/replace operations require a name11491149- * and do not take a newname. Values are optional for set and11501150- * replace.11511151- *11521152- * Name-value set/remove operations must have a name, do not11531153- * take a newname, and can take a value.11541154- */11551155- if (attr_name == NULL || name_len == 0) {11561156- XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,11571157- attri_formatp, len);11581158- return -EFSCORRUPTED;11591159- }11601160- break;11611161- case XFS_ATTRI_OP_FLAGS_PPTR_REPLACE:11621162- /*11631163- * Name-value replace operations require the caller to11641164- * specify the old and new names and values explicitly.11651165- * Values are optional.11661166- */11671167- if (attr_name == NULL || name_len == 0) {11681168- XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,11691169- attri_formatp, len);11701170- return -EFSCORRUPTED;11711171- }11721172- if (attr_new_name == NULL || new_name_len == 0) {11731173- XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,11741174- attri_formatp, len);11751175- return -EFSCORRUPTED;11761176- }11771177- break;11781133 }1179113411801135 /*
+7-2
fs/xfs/xfs_dquot_item.c
···125125 struct xfs_dq_logitem *qlip = DQUOT_ITEM(lip);126126 struct xfs_dquot *dqp = qlip->qli_dquot;127127 struct xfs_buf *bp;128128+ struct xfs_ail *ailp = lip->li_ailp;128129 uint rval = XFS_ITEM_SUCCESS;129130 int error;130131···154153 goto out_unlock;155154 }156155157157- spin_unlock(&lip->li_ailp->ail_lock);156156+ spin_unlock(&ailp->ail_lock);158157159158 error = xfs_dquot_use_attached_buf(dqp, &bp);160159 if (error == -EAGAIN) {···173172 rval = XFS_ITEM_FLUSHING;174173 }175174 xfs_buf_relse(bp);175175+ /*176176+ * The buffer no longer protects the log item from reclaim, so177177+ * do not reference lip after this point.178178+ */176179177180out_relock_ail:178178- spin_lock(&lip->li_ailp->ail_lock);181181+ spin_lock(&ailp->ail_lock);179182out_unlock:180183 mutex_unlock(&dqp->q_qlock);181184 return rval;
···746746 struct xfs_inode_log_item *iip = INODE_ITEM(lip);747747 struct xfs_inode *ip = iip->ili_inode;748748 struct xfs_buf *bp = lip->li_buf;749749+ struct xfs_ail *ailp = lip->li_ailp;749750 uint rval = XFS_ITEM_SUCCESS;750751 int error;751752···772771 if (!xfs_buf_trylock(bp))773772 return XFS_ITEM_LOCKED;774773775775- spin_unlock(&lip->li_ailp->ail_lock);774774+ spin_unlock(&ailp->ail_lock);776775777776 /*778777 * We need to hold a reference for flushing the cluster buffer as it may···796795 rval = XFS_ITEM_LOCKED;797796 }798797799799- spin_lock(&lip->li_ailp->ail_lock);798798+ /*799799+ * The buffer no longer protects the log item from reclaim, so800800+ * do not reference lip after this point.801801+ */802802+ spin_lock(&ailp->ail_lock);800803 return rval;801804}802805
+4-3
fs/xfs/xfs_mount.c
···608608 * have been retrying in the background. This will prevent never-ending609609 * retries in AIL pushing from hanging the unmount.610610 *611611- * Finally, we can push the AIL to clean all the remaining dirty objects, then612612- * reclaim the remaining inodes that are still in memory at this point in time.611611+ * Stop inodegc and background reclaim before pushing the AIL so that they612612+ * are not running while the AIL is being flushed. Then push the AIL to613613+ * clean all the remaining dirty objects and reclaim the remaining inodes.613614 */614615static void615616xfs_unmount_flush_inodes(···622621623622 xfs_set_unmounting(mp);624623625625- xfs_ail_push_all_sync(mp->m_ail);626624 xfs_inodegc_stop(mp);627625 cancel_delayed_work_sync(&mp->m_reclaim_work);626626+ xfs_ail_push_all_sync(mp->m_ail);628627 xfs_reclaim_inodes(mp);629628 xfs_health_unmount(mp);630629 xfs_healthmon_unmount(mp);
···365365 return XFS_ITEM_SUCCESS;366366}367367368368+/*369369+ * Push a single log item from the AIL.370370+ *371371+ * @lip may have been released and freed by the time this function returns,372372+ * so callers must not dereference the log item afterwards.373373+ */368374static inline uint369375xfsaild_push_item(370376 struct xfs_ail *ailp,···464458 return target_lsn;465459}466460461461+static void462462+xfsaild_process_logitem(463463+ struct xfs_ail *ailp,464464+ struct xfs_log_item *lip,465465+ int *stuck,466466+ int *flushing)467467+{468468+ struct xfs_mount *mp = ailp->ail_log->l_mp;469469+ uint type = lip->li_type;470470+ unsigned long flags = lip->li_flags;471471+ xfs_lsn_t item_lsn = lip->li_lsn;472472+ int lock_result;473473+474474+ /*475475+ * Note that iop_push may unlock and reacquire the AIL lock. We476476+ * rely on the AIL cursor implementation to be able to deal with477477+ * the dropped lock.478478+ *479479+ * The log item may have been freed by the push, so it must not480480+ * be accessed or dereferenced below this line.481481+ */482482+ lock_result = xfsaild_push_item(ailp, lip);483483+ switch (lock_result) {484484+ case XFS_ITEM_SUCCESS:485485+ XFS_STATS_INC(mp, xs_push_ail_success);486486+ trace_xfs_ail_push(ailp, type, flags, item_lsn);487487+488488+ ailp->ail_last_pushed_lsn = item_lsn;489489+ break;490490+491491+ case XFS_ITEM_FLUSHING:492492+ /*493493+ * The item or its backing buffer is already being494494+ * flushed. The typical reason for that is that an495495+ * inode buffer is locked because we already pushed the496496+ * updates to it as part of inode clustering.497497+ *498498+ * We do not want to stop flushing just because lots499499+ * of items are already being flushed, but we need to500500+ * re-try the flushing relatively soon if most of the501501+ * AIL is being flushed.502502+ */503503+ XFS_STATS_INC(mp, xs_push_ail_flushing);504504+ trace_xfs_ail_flushing(ailp, type, flags, item_lsn);505505+506506+ (*flushing)++;507507+ ailp->ail_last_pushed_lsn = item_lsn;508508+ break;509509+510510+ case XFS_ITEM_PINNED:511511+ XFS_STATS_INC(mp, xs_push_ail_pinned);512512+ trace_xfs_ail_pinned(ailp, type, flags, item_lsn);513513+514514+ (*stuck)++;515515+ ailp->ail_log_flush++;516516+ break;517517+ case XFS_ITEM_LOCKED:518518+ XFS_STATS_INC(mp, xs_push_ail_locked);519519+ trace_xfs_ail_locked(ailp, type, flags, item_lsn);520520+521521+ (*stuck)++;522522+ break;523523+ default:524524+ ASSERT(0);525525+ break;526526+ }527527+}528528+467529static long468530xfsaild_push(469531 struct xfs_ail *ailp)···579505580506 lsn = lip->li_lsn;581507 while ((XFS_LSN_CMP(lip->li_lsn, ailp->ail_target) <= 0)) {582582- int lock_result;583508584509 if (test_bit(XFS_LI_FLUSHING, &lip->li_flags))585510 goto next_item;586511587587- /*588588- * Note that iop_push may unlock and reacquire the AIL lock. We589589- * rely on the AIL cursor implementation to be able to deal with590590- * the dropped lock.591591- */592592- lock_result = xfsaild_push_item(ailp, lip);593593- switch (lock_result) {594594- case XFS_ITEM_SUCCESS:595595- XFS_STATS_INC(mp, xs_push_ail_success);596596- trace_xfs_ail_push(lip);597597-598598- ailp->ail_last_pushed_lsn = lsn;599599- break;600600-601601- case XFS_ITEM_FLUSHING:602602- /*603603- * The item or its backing buffer is already being604604- * flushed. The typical reason for that is that an605605- * inode buffer is locked because we already pushed the606606- * updates to it as part of inode clustering.607607- *608608- * We do not want to stop flushing just because lots609609- * of items are already being flushed, but we need to610610- * re-try the flushing relatively soon if most of the611611- * AIL is being flushed.612612- */613613- XFS_STATS_INC(mp, xs_push_ail_flushing);614614- trace_xfs_ail_flushing(lip);615615-616616- flushing++;617617- ailp->ail_last_pushed_lsn = lsn;618618- break;619619-620620- case XFS_ITEM_PINNED:621621- XFS_STATS_INC(mp, xs_push_ail_pinned);622622- trace_xfs_ail_pinned(lip);623623-624624- stuck++;625625- ailp->ail_log_flush++;626626- break;627627- case XFS_ITEM_LOCKED:628628- XFS_STATS_INC(mp, xs_push_ail_locked);629629- trace_xfs_ail_locked(lip);630630-631631- stuck++;632632- break;633633- default:634634- ASSERT(0);635635- break;636636- }637637-512512+ xfsaild_process_logitem(ailp, lip, &stuck, &flushing);638513 count++;639514640515 /*
+8-10
fs/xfs/xfs_verify_media.c
···183183 min_not_zero(SZ_1M, me->me_max_io_size);184184185185 BUILD_BUG_ON(BBSHIFT != SECTOR_SHIFT);186186- ASSERT(BBTOB(bbcount) >= bdev_logical_block_size(btp->bt_bdev));186186+ ASSERT(BBTOB(bbcount) >= btp->bt_logical_sectorsize);187187188188- return clamp(iosize, bdev_logical_block_size(btp->bt_bdev),189189- BBTOB(bbcount));188188+ return clamp(iosize, btp->bt_logical_sectorsize, BBTOB(bbcount));190189}191190192191/* Allocate as much memory as we can get for verification buffer. */···217218 unsigned int bio_bbcount,218219 blk_status_t bio_status)219220{220220- trace_xfs_verify_media_error(mp, me, btp->bt_bdev->bd_dev, daddr,221221- bio_bbcount, bio_status);221221+ trace_xfs_verify_media_error(mp, me, btp->bt_dev, daddr, bio_bbcount,222222+ bio_status);222223223224 /*224225 * Pass any error, I/O or otherwise, up to the caller if we didn't···279280 btp = mp->m_ddev_targp;280281 break;281282 case XFS_DEV_LOG:282282- if (mp->m_logdev_targp->bt_bdev != mp->m_ddev_targp->bt_bdev)283283+ if (mp->m_logdev_targp != mp->m_ddev_targp)283284 btp = mp->m_logdev_targp;284285 break;285286 case XFS_DEV_RT:···298299299300 /* start and end have to be aligned to the lba size */300301 if (!IS_ALIGNED(BBTOB(me->me_start_daddr | me->me_end_daddr),301301- bdev_logical_block_size(btp->bt_bdev)))302302+ btp->bt_logical_sectorsize))302303 return -EINVAL;303304304305 /*···330331 if (!folio)331332 return -ENOMEM;332333333333- trace_xfs_verify_media(mp, me, btp->bt_bdev->bd_dev, daddr, bbcount,334334- folio);334334+ trace_xfs_verify_media(mp, me, btp->bt_dev, daddr, bbcount, folio);335335336336 bio = bio_alloc(btp->bt_bdev, 1, REQ_OP_READ, GFP_KERNEL);337337 if (!bio) {···398400 * an operational error.399401 */400402 me->me_start_daddr = daddr;401401- trace_xfs_verify_media_end(mp, me, btp->bt_bdev->bd_dev);403403+ trace_xfs_verify_media_end(mp, me, btp->bt_dev);402404 return 0;403405}404406
···810810 struct damos_walk_control *walk_control;811811 struct mutex walk_control_lock;812812813813+ /*814814+ * indicate if this may be corrupted. Currentonly this is set only for815815+ * damon_commit_ctx() failure.816816+ */817817+ bool maybe_corrupted;818818+813819 /* Working thread of the given DAMON context */814820 struct task_struct *kdamond;815821 /* Protects @kdamond field access */
+13-6
include/linux/dma-mapping.h
···8080#define DMA_ATTR_MMIO (1UL << 10)81818282/*8383- * DMA_ATTR_CPU_CACHE_CLEAN: Indicates the CPU will not dirty any cacheline8484- * overlapping this buffer while it is mapped for DMA. All mappings sharing8585- * a cacheline must have this attribute for this to be considered safe.8383+ * DMA_ATTR_DEBUGGING_IGNORE_CACHELINES: Indicates the CPU cache line can be8484+ * overlapped. All mappings sharing a cacheline must have this attribute for8585+ * this to be considered safe.8686 */8787-#define DMA_ATTR_CPU_CACHE_CLEAN (1UL << 11)8787+#define DMA_ATTR_DEBUGGING_IGNORE_CACHELINES (1UL << 11)8888+8989+/*9090+ * DMA_ATTR_REQUIRE_COHERENT: Indicates that DMA coherency is required.9191+ * All mappings that carry this attribute can't work with SWIOTLB and cache9292+ * flushing.9393+ */9494+#define DMA_ATTR_REQUIRE_COHERENT (1UL << 12)88958996/*9097 * A dma_addr_t can hold any valid DMA or bus address for the platform. It can···255248{256249 return NULL;257250}258258-static void dma_free_attrs(struct device *dev, size_t size, void *cpu_addr,259259- dma_addr_t dma_handle, unsigned long attrs)251251+static inline void dma_free_attrs(struct device *dev, size_t size,252252+ void *cpu_addr, dma_addr_t dma_handle, unsigned long attrs)260253{261254}262255static inline void *dmam_alloc_attrs(struct device *dev, size_t size,
+1
include/linux/fs/super_types.h
···338338#define SB_I_NOUMASK 0x00001000 /* VFS does not apply umask */339339#define SB_I_NOIDMAP 0x00002000 /* No idmapped mounts on this superblock */340340#define SB_I_ALLOW_HSM 0x00004000 /* Allow HSM events on this superblock */341341+#define SB_I_NO_DATA_INTEGRITY 0x00008000 /* fs cannot guarantee data persistence on sync */341342342343#endif /* _LINUX_FS_SUPER_TYPES_H */
+21-11
include/linux/leafops.h
···363363 return swp_offset(entry) & SWP_PFN_MASK;364364}365365366366+static inline void softleaf_migration_sync(softleaf_t entry,367367+ struct folio *folio)368368+{369369+ /*370370+ * Ensure we do not race with split, which might alter tail pages into new371371+ * folios and thus result in observing an unlocked folio.372372+ * This matches the write barrier in __split_folio_to_order().373373+ */374374+ smp_rmb();375375+376376+ /*377377+ * Any use of migration entries may only occur while the378378+ * corresponding page is locked379379+ */380380+ VM_WARN_ON_ONCE(!folio_test_locked(folio));381381+}382382+366383/**367384 * softleaf_to_page() - Obtains struct page for PFN encoded within leaf entry.368385 * @entry: Leaf entry, softleaf_has_pfn(@entry) must return true.···391374 struct page *page = pfn_to_page(softleaf_to_pfn(entry));392375393376 VM_WARN_ON_ONCE(!softleaf_has_pfn(entry));394394- /*395395- * Any use of migration entries may only occur while the396396- * corresponding page is locked397397- */398398- VM_WARN_ON_ONCE(softleaf_is_migration(entry) && !PageLocked(page));377377+ if (softleaf_is_migration(entry))378378+ softleaf_migration_sync(entry, page_folio(page));399379400380 return page;401381}···408394 struct folio *folio = pfn_folio(softleaf_to_pfn(entry));409395410396 VM_WARN_ON_ONCE(!softleaf_has_pfn(entry));411411- /*412412- * Any use of migration entries may only occur while the413413- * corresponding folio is locked.414414- */415415- VM_WARN_ON_ONCE(softleaf_is_migration(entry) &&416416- !folio_test_locked(folio));397397+ if (softleaf_is_migration(entry))398398+ softleaf_migration_sync(entry, folio);417399418400 return folio;419401}
+1
include/linux/mempolicy.h
···5555 nodemask_t cpuset_mems_allowed; /* relative to these nodes */5656 nodemask_t user_nodemask; /* nodemask passed by user */5757 } w;5858+ struct rcu_head rcu;5859};59606061/*
-1
include/linux/netfs.h
···140140 void (*issue_write)(struct netfs_io_subrequest *subreq);141141 /* Collection tracking */142142 struct list_head subrequests; /* Contributory I/O operations */143143- struct netfs_io_subrequest *front; /* Op being collected */144143 unsigned long long collected_to; /* Position we've collected results to */145144 size_t transferred; /* The amount transferred from this stream */146145 unsigned short error; /* Aggregate error for the stream */
-11
include/linux/pagemap.h
···210210 AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM = 9,211211 AS_KERNEL_FILE = 10, /* mapping for a fake kernel file that shouldn't212212 account usage to user cgroups */213213- AS_NO_DATA_INTEGRITY = 11, /* no data integrity guarantees */214213 /* Bits 16-25 are used for FOLIO_ORDER */215214 AS_FOLIO_ORDER_BITS = 5,216215 AS_FOLIO_ORDER_MIN = 16,···343344static inline bool mapping_writeback_may_deadlock_on_reclaim(const struct address_space *mapping)344345{345346 return test_bit(AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM, &mapping->flags);346346-}347347-348348-static inline void mapping_set_no_data_integrity(struct address_space *mapping)349349-{350350- set_bit(AS_NO_DATA_INTEGRITY, &mapping->flags);351351-}352352-353353-static inline bool mapping_no_data_integrity(const struct address_space *mapping)354354-{355355- return test_bit(AS_NO_DATA_INTEGRITY, &mapping->flags);356347}357348358349static inline gfp_t mapping_gfp_mask(const struct address_space *mapping)
···159159 * @modalias: Name of the driver to use with this device, or an alias160160 * for that name. This appears in the sysfs "modalias" attribute161161 * for driver coldplugging, and in uevents used for hotplugging162162- * @driver_override: If the name of a driver is written to this attribute, then163163- * the device will bind to the named driver and only the named driver.164164- * Do not set directly, because core frees it; use driver_set_override() to165165- * set or clear it.166162 * @pcpu_statistics: statistics for the spi_device167163 * @word_delay: delay to be inserted between consecutive168164 * words of a transfer···220224 void *controller_state;221225 void *controller_data;222226 char modalias[SPI_NAME_SIZE];223223- const char *driver_override;224227225228 /* The statistics */226229 struct spi_statistics __percpu *pcpu_statistics;
···264264 return &hinfo->bhash2[hash & (hinfo->bhash_size - 1)];265265}266266267267+static inline bool inet_use_hash2_on_bind(const struct sock *sk)268268+{269269+#if IS_ENABLED(CONFIG_IPV6)270270+ if (sk->sk_family == AF_INET6) {271271+ if (ipv6_addr_any(&sk->sk_v6_rcv_saddr))272272+ return false;273273+274274+ if (!ipv6_addr_v4mapped(&sk->sk_v6_rcv_saddr))275275+ return true;276276+ }277277+#endif278278+ return sk->sk_rcv_saddr != htonl(INADDR_ANY);279279+}280280+267281struct inet_bind_hashbucket *268282inet_bhash2_addr_any_hashbucket(const struct sock *sk, const struct net *net, int port);269283
+20-1
include/net/ip6_fib.h
···507507void inet6_rt_notify(int event, struct fib6_info *rt, struct nl_info *info,508508 unsigned int flags);509509510510+void fib6_age_exceptions(struct fib6_info *rt, struct fib6_gc_args *gc_args,511511+ unsigned long now);510512void fib6_run_gc(unsigned long expires, struct net *net, bool force);511511-512513void fib6_gc_cleanup(void);513514514515int fib6_init(void);515516517517+#if IS_ENABLED(CONFIG_IPV6)516518/* Add the route to the gc list if it is not already there517519 *518520 * The callers should hold f6i->fib6_table->tb6_lock.···546544 if (!hlist_unhashed(&f6i->gc_link))547545 hlist_del_init(&f6i->gc_link);548546}547547+548548+static inline void fib6_may_remove_gc_list(struct net *net,549549+ struct fib6_info *f6i)550550+{551551+ struct fib6_gc_args gc_args;552552+553553+ if (hlist_unhashed(&f6i->gc_link))554554+ return;555555+556556+ gc_args.timeout = READ_ONCE(net->ipv6.sysctl.ip6_rt_gc_interval);557557+ gc_args.more = 0;558558+559559+ rcu_read_lock();560560+ fib6_age_exceptions(f6i, &gc_args, jiffies);561561+ rcu_read_unlock();562562+}563563+#endif549564550565struct ipv6_route_iter {551566 struct seq_net_private p;
+5
include/net/netfilter/nf_conntrack_core.h
···83838484extern spinlock_t nf_conntrack_expect_lock;85858686+static inline void lockdep_nfct_expect_lock_held(void)8787+{8888+ lockdep_assert_held(&nf_conntrack_expect_lock);8989+}9090+8691/* ctnetlink code shared by both ctnetlink and nf_conntrack_bpf */87928893static inline void __nf_ct_set_timeout(struct nf_conn *ct, u64 timeout)
+18-2
include/net/netfilter/nf_conntrack_expect.h
···2222 /* Hash member */2323 struct hlist_node hnode;24242525+ /* Network namespace */2626+ possible_net_t net;2727+2528 /* We expect this tuple, with the following mask */2629 struct nf_conntrack_tuple tuple;2730 struct nf_conntrack_tuple_mask mask;28313232+#ifdef CONFIG_NF_CONNTRACK_ZONES3333+ struct nf_conntrack_zone zone;3434+#endif2935 /* Usage count. */3036 refcount_t use;3137···4640 struct nf_conntrack_expect *this);47414842 /* Helper to assign to new connection */4949- struct nf_conntrack_helper *helper;4343+ struct nf_conntrack_helper __rcu *helper;50445145 /* The conntrack of the master connection */5246 struct nf_conn *master;···68626963static inline struct net *nf_ct_exp_net(struct nf_conntrack_expect *exp)7064{7171- return nf_ct_net(exp->master);6565+ return read_pnet(&exp->net);6666+}6767+6868+static inline bool nf_ct_exp_zone_equal_any(const struct nf_conntrack_expect *a,6969+ const struct nf_conntrack_zone *b)7070+{7171+#ifdef CONFIG_NF_CONNTRACK_ZONES7272+ return a->zone.id == b->id;7373+#else7474+ return true;7575+#endif7276}73777478#define NF_CT_EXP_POLICY_NAME_LEN 16
···2727#define SDCA_MAX_ENTITY_COUNT 12828282929/*3030- * Sanity check on number of initialization writes, can be expanded if needed.3131- */3232-#define SDCA_MAX_INIT_COUNT 20483333-3434-/*3530 * The Cluster IDs are 16-bit, so a maximum of 65535 Clusters per3631 * function can be represented, however limit this to a slightly3732 * more reasonable value. Can be expanded if needed.
···146146config CC_HAS_COUNTED_BY_PTR147147 bool148148 # supported since clang 22149149- default y if CC_IS_CLANG && CLANG_VERSION >= 220000149149+ default y if CC_IS_CLANG && CLANG_VERSION >= 220100150150 # supported since gcc 16.0.0151151 default y if CC_IS_GCC && GCC_VERSION >= 160000152152
···453453 return overlap;454454}455455456456-static void active_cacheline_inc_overlap(phys_addr_t cln)456456+static void active_cacheline_inc_overlap(phys_addr_t cln, bool is_cache_clean)457457{458458 int overlap = active_cacheline_read_overlap(cln);459459···462462 /* If we overflowed the overlap counter then we're potentially463463 * leaking dma-mappings.464464 */465465- WARN_ONCE(overlap > ACTIVE_CACHELINE_MAX_OVERLAP,465465+ WARN_ONCE(!is_cache_clean && overlap > ACTIVE_CACHELINE_MAX_OVERLAP,466466 pr_fmt("exceeded %d overlapping mappings of cacheline %pa\n"),467467 ACTIVE_CACHELINE_MAX_OVERLAP, &cln);468468}···495495 if (rc == -EEXIST) {496496 struct dma_debug_entry *existing;497497498498- active_cacheline_inc_overlap(cln);498498+ active_cacheline_inc_overlap(cln, entry->is_cache_clean);499499 existing = radix_tree_lookup(&dma_active_cacheline, cln);500500 /* A lookup failure here after we got -EEXIST is unexpected. */501501 WARN_ON(!existing);···601601 unsigned long flags;602602 int rc;603603604604- entry->is_cache_clean = !!(attrs & DMA_ATTR_CPU_CACHE_CLEAN);604604+ entry->is_cache_clean = attrs & (DMA_ATTR_DEBUGGING_IGNORE_CACHELINES |605605+ DMA_ATTR_REQUIRE_COHERENT);605606606607 bucket = get_hash_bucket(entry, &flags);607608 hash_bucket_add(bucket, entry);
+4-3
kernel/dma/direct.h
···8484 dma_addr_t dma_addr;85858686 if (is_swiotlb_force_bounce(dev)) {8787- if (attrs & DMA_ATTR_MMIO)8787+ if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT))8888 return DMA_MAPPING_ERROR;89899090 return swiotlb_map(dev, phys, size, dir, attrs);···9898 dma_addr = phys_to_dma(dev, phys);9999 if (unlikely(!dma_capable(dev, dma_addr, size, true)) ||100100 dma_kmalloc_needs_bounce(dev, size, dir)) {101101- if (is_swiotlb_active(dev))101101+ if (is_swiotlb_active(dev) &&102102+ !(attrs & DMA_ATTR_REQUIRE_COHERENT))102103 return swiotlb_map(dev, phys, size, dir, attrs);103104104105 goto err_overflow;···124123{125124 phys_addr_t phys;126125127127- if (attrs & DMA_ATTR_MMIO)126126+ if (attrs & (DMA_ATTR_MMIO | DMA_ATTR_REQUIRE_COHERENT))128127 /* nothing to do: uncached and no swiotlb */129128 return;130129
+6
kernel/dma/mapping.c
···164164 if (WARN_ON_ONCE(!dev->dma_mask))165165 return DMA_MAPPING_ERROR;166166167167+ if (!dev_is_dma_coherent(dev) && (attrs & DMA_ATTR_REQUIRE_COHERENT))168168+ return DMA_MAPPING_ERROR;169169+167170 if (dma_map_direct(dev, ops) ||168171 (!is_mmio && arch_dma_map_phys_direct(dev, phys + size)))169172 addr = dma_direct_map_phys(dev, phys, size, dir, attrs);···237234 int ents;238235239236 BUG_ON(!valid_dma_direction(dir));237237+238238+ if (!dev_is_dma_coherent(dev) && (attrs & DMA_ATTR_REQUIRE_COHERENT))239239+ return -EOPNOTSUPP;240240241241 if (WARN_ON_ONCE(!dev->dma_mask))242242 return 0;
+19-2
kernel/dma/swiotlb.c
···3030#include <linux/gfp.h>3131#include <linux/highmem.h>3232#include <linux/io.h>3333+#include <linux/kmsan-checks.h>3334#include <linux/iommu-helper.h>3435#include <linux/init.h>3536#include <linux/memblock.h>···902901903902 local_irq_save(flags);904903 page = pfn_to_page(pfn);905905- if (dir == DMA_TO_DEVICE)904904+ if (dir == DMA_TO_DEVICE) {905905+ /*906906+ * Ideally, kmsan_check_highmem_page()907907+ * could be used here to detect infoleaks,908908+ * but callers may map uninitialized buffers909909+ * that will be written by the device,910910+ * causing false positives.911911+ */906912 memcpy_from_page(vaddr, page, offset, sz);907907- else913913+ } else {914914+ kmsan_unpoison_memory(vaddr, sz);908915 memcpy_to_page(page, offset, vaddr, sz);916916+ }909917 local_irq_restore(flags);910918911919 size -= sz;···923913 offset = 0;924914 }925915 } else if (dir == DMA_TO_DEVICE) {916916+ /*917917+ * Ideally, kmsan_check_memory() could be used here to detect918918+ * infoleaks (uninitialized data being sent to device), but919919+ * callers may map uninitialized buffers that will be written920920+ * by the device, causing false positives.921921+ */926922 memcpy(vaddr, phys_to_virt(orig_addr), size);927923 } else {924924+ kmsan_unpoison_memory(vaddr, size);928925 memcpy(phys_to_virt(orig_addr), vaddr, size);929926 }930927}
+1-1
kernel/futex/core.c
···342342 if (!vma)343343 return FUTEX_NO_NODE;344344345345- mpol = vma_policy(vma);345345+ mpol = READ_ONCE(vma->vm_policy);346346 if (!mpol)347347 return FUTEX_NO_NODE;348348
···459459 if (ret)460460 return ret;461461462462+ /*463463+ * For now mandate both flags are identical, like the sys_futex()464464+ * interface has. If/when we merge the variable sized futex support,465465+ * that patch can modify this test to allow a difference in size.466466+ */467467+ if (futexes[0].w.flags != futexes[1].w.flags)468468+ return -EINVAL;469469+462470 cmpval = futexes[0].w.val;463471464472 return futex_requeue(u64_to_user_ptr(futexes[0].w.uaddr), futexes[0].w.flags,
+1-1
kernel/power/main.c
···4040{4141 WARN_ON(!mutex_is_locked(&system_transition_mutex));42424343- if (WARN_ON(!saved_gfp_count) || --saved_gfp_count)4343+ if (!saved_gfp_count || --saved_gfp_count)4444 return;45454646 gfp_allowed_mask = saved_gfp_mask;
+11
kernel/power/snapshot.c
···28552855{28562856 int error;2857285728582858+ /*28592859+ * Call snapshot_write_next() to drain any trailing zero pages,28602860+ * but make sure we're in the data page region first.28612861+ * This function can return PAGE_SIZE if the kernel was expecting28622862+ * another copy page. Return -ENODATA in that situation.28632863+ */28642864+ if (handle->cur > nr_meta_pages + 1) {28652865+ error = snapshot_write_next(handle);28662866+ if (error)28672867+ return error > 0 ? -ENODATA : error;28682868+ }28582869 copy_last_highmem_page();28592870 error = hibernate_restore_protect_page(handle->buffer);28602871 /* Do that only if we have loaded the image entirely */
···145145 return 0;146146}147147148148+struct damon_stat_system_ram_range_walk_arg {149149+ bool walked;150150+ struct resource res;151151+};152152+153153+static int damon_stat_system_ram_walk_fn(struct resource *res, void *arg)154154+{155155+ struct damon_stat_system_ram_range_walk_arg *a = arg;156156+157157+ if (!a->walked) {158158+ a->walked = true;159159+ a->res.start = res->start;160160+ }161161+ a->res.end = res->end;162162+ return 0;163163+}164164+165165+static unsigned long damon_stat_res_to_core_addr(resource_size_t ra,166166+ unsigned long addr_unit)167167+{168168+ /*169169+ * Use div_u64() for avoiding linking errors related with __udivdi3,170170+ * __aeabi_uldivmod, or similar problems. This should also improve the171171+ * performance optimization (read div_u64() comment for the detail).172172+ */173173+ if (sizeof(ra) == 8 && sizeof(addr_unit) == 4)174174+ return div_u64(ra, addr_unit);175175+ return ra / addr_unit;176176+}177177+178178+static int damon_stat_set_monitoring_region(struct damon_target *t,179179+ unsigned long addr_unit, unsigned long min_region_sz)180180+{181181+ struct damon_addr_range addr_range;182182+ struct damon_stat_system_ram_range_walk_arg arg = {};183183+184184+ walk_system_ram_res(0, -1, &arg, damon_stat_system_ram_walk_fn);185185+ if (!arg.walked)186186+ return -EINVAL;187187+ addr_range.start = damon_stat_res_to_core_addr(188188+ arg.res.start, addr_unit);189189+ addr_range.end = damon_stat_res_to_core_addr(190190+ arg.res.end + 1, addr_unit);191191+ if (addr_range.end <= addr_range.start)192192+ return -EINVAL;193193+ return damon_set_regions(t, &addr_range, 1, min_region_sz);194194+}195195+148196static struct damon_ctx *damon_stat_build_ctx(void)149197{150198 struct damon_ctx *ctx;151199 struct damon_attrs attrs;152200 struct damon_target *target;153153- unsigned long start = 0, end = 0;154201155202 ctx = damon_new_ctx();156203 if (!ctx)···227180 if (!target)228181 goto free_out;229182 damon_add_target(ctx, target);230230- if (damon_set_region_biggest_system_ram_default(target, &start, &end,231231- ctx->min_region_sz))183183+ if (damon_stat_set_monitoring_region(target, ctx->addr_unit,184184+ ctx->min_region_sz))232185 goto free_out;233186 return ctx;234187free_out:
+9-1
mm/damon/sysfs.c
···15241524 if (IS_ERR(param_ctx))15251525 return PTR_ERR(param_ctx);15261526 test_ctx = damon_sysfs_new_test_ctx(kdamond->damon_ctx);15271527- if (!test_ctx)15271527+ if (!test_ctx) {15281528+ damon_destroy_ctx(param_ctx);15281529 return -ENOMEM;15301530+ }15291531 err = damon_commit_ctx(test_ctx, param_ctx);15301532 if (err)15311533 goto out;···1620161816211619 if (!mutex_trylock(&damon_sysfs_lock))16221620 return 0;16211621+ if (sysfs_kdamond->contexts->nr != 1)16221622+ goto out;16231623 damon_sysfs_upd_tuned_intervals(sysfs_kdamond);16241624 damon_sysfs_upd_schemes_stats(sysfs_kdamond);16251625 damon_sysfs_upd_schemes_effective_quotas(sysfs_kdamond);16261626+out:16261627 mutex_unlock(&damon_sysfs_lock);16271628 return 0;16281629}···17521747static int damon_sysfs_handle_cmd(enum damon_sysfs_cmd cmd,17531748 struct damon_sysfs_kdamond *kdamond)17541749{17501750+ if (cmd != DAMON_SYSFS_CMD_OFF && kdamond->contexts->nr != 1)17511751+ return -EINVAL;17521752+17551753 switch (cmd) {17561754 case DAMON_SYSFS_CMD_ON:17571755 return damon_sysfs_turn_damon_on(kdamond);
+2-2
mm/hmm.c
···778778 struct page *page = hmm_pfn_to_page(pfns[idx]);779779 phys_addr_t paddr = hmm_pfn_to_phys(pfns[idx]);780780 size_t offset = idx * map->dma_entry_size;781781- unsigned long attrs = 0;781781+ unsigned long attrs = DMA_ATTR_REQUIRE_COHERENT;782782 dma_addr_t dma_addr;783783 int ret;784784···871871 struct dma_iova_state *state = &map->state;872872 dma_addr_t *dma_addrs = map->dma_list;873873 unsigned long *pfns = map->pfn_list;874874- unsigned long attrs = 0;874874+ unsigned long attrs = DMA_ATTR_REQUIRE_COHERENT;875875876876 if ((pfns[idx] & valid_dma) != valid_dma)877877 return false;
+15-3
mm/memory.c
···6815681568166816 pudp = pud_offset(p4dp, address);68176817 pud = pudp_get(pudp);68186818- if (pud_none(pud))68186818+ if (!pud_present(pud))68196819 goto out;68206820 if (pud_leaf(pud)) {68216821 lock = pud_lock(mm, pudp);68226822- if (!unlikely(pud_leaf(pud))) {68226822+ pud = pudp_get(pudp);68236823+68246824+ if (unlikely(!pud_present(pud))) {68256825+ spin_unlock(lock);68266826+ goto out;68276827+ } else if (unlikely(!pud_leaf(pud))) {68236828 spin_unlock(lock);68246829 goto retry;68256830 }···6836683168376832 pmdp = pmd_offset(pudp, address);68386833 pmd = pmdp_get_lockless(pmdp);68346834+ if (!pmd_present(pmd))68356835+ goto out;68396836 if (pmd_leaf(pmd)) {68406837 lock = pmd_lock(mm, pmdp);68416841- if (!unlikely(pmd_leaf(pmd))) {68386838+ pmd = pmdp_get(pmdp);68396839+68406840+ if (unlikely(!pmd_present(pmd))) {68416841+ spin_unlock(lock);68426842+ goto out;68436843+ } else if (unlikely(!pmd_leaf(pmd))) {68426844 spin_unlock(lock);68436845 goto retry;68446846 }
+8-2
mm/mempolicy.c
···487487{488488 if (!atomic_dec_and_test(&pol->refcnt))489489 return;490490- kmem_cache_free(policy_cache, pol);490490+ /*491491+ * Required to allow mmap_lock_speculative*() access, see for example492492+ * futex_key_to_node_opt(). All accesses are serialized by mmap_lock,493493+ * however the speculative lock section unbound by the normal lock494494+ * boundaries, requiring RCU freeing.495495+ */496496+ kfree_rcu(pol, rcu);491497}492498EXPORT_SYMBOL_FOR_MODULES(__mpol_put, "kvm");493499···10261020 }1027102110281022 old = vma->vm_policy;10291029- vma->vm_policy = new; /* protected by mmap_lock */10231023+ WRITE_ONCE(vma->vm_policy, new); /* protected by mmap_lock */10301024 mpol_put(old);1031102510321026 return 0;
+1-2
mm/mseal.c
···5656 unsigned long start, unsigned long end)5757{5858 struct vm_area_struct *vma, *prev;5959- unsigned long curr_start = start;6059 VMA_ITERATOR(vmi, mm, start);61606261 /* We know there are no gaps so this will be non-NULL. */···6566 prev = vma;66676768 for_each_vma_range(vmi, vma, end) {6969+ const unsigned long curr_start = MAX(vma->vm_start, start);6870 const unsigned long curr_end = MIN(vma->vm_end, end);69717072 if (!(vma->vm_flags & VM_SEALED)) {···7979 }80808181 prev = vma;8282- curr_start = curr_end;8382 }84838584 return 0;
+22-3
mm/pagewalk.c
···9797static int walk_pmd_range(pud_t *pud, unsigned long addr, unsigned long end,9898 struct mm_walk *walk)9999{100100+ pud_t pudval = pudp_get(pud);100101 pmd_t *pmd;101102 unsigned long next;102103 const struct mm_walk_ops *ops = walk->ops;···105104 bool has_install = ops->install_pte;106105 int err = 0;107106 int depth = real_depth(3);107107+108108+ /*109109+ * For PTE handling, pte_offset_map_lock() takes care of checking110110+ * whether there actually is a page table. But it also has to be111111+ * very careful about concurrent page table reclaim.112112+ *113113+ * Similarly, we have to be careful here - a PUD entry that points114114+ * to a PMD table cannot go away, so we can just walk it. But if115115+ * it's something else, we need to ensure we didn't race something,116116+ * so need to retry.117117+ *118118+ * A pertinent example of this is a PUD refault after PUD split -119119+ * we will need to split again or risk accessing invalid memory.120120+ */121121+ if (!pud_present(pudval) || pud_leaf(pudval)) {122122+ walk->action = ACTION_AGAIN;123123+ return 0;124124+ }108125109126 pmd = pmd_offset(pud, addr);110127 do {···237218 else if (pud_leaf(*pud) || !pud_present(*pud))238219 continue; /* Nothing to do. */239220240240- if (pud_none(*pud))241241- goto again;242242-243221 err = walk_pmd_range(pud, addr, next, walk);244222 if (err)245223 break;224224+225225+ if (walk->action == ACTION_AGAIN)226226+ goto again;246227 } while (pud++, addr = next, addr != end);247228248229 return err;
+7
mm/rmap.c
···457457 list_del(&avc->same_vma);458458 anon_vma_chain_free(avc);459459 }460460+461461+ /*462462+ * The anon_vma assigned to this VMA is no longer valid, as we were not463463+ * able to correctly clone AVC state. Avoid inconsistent anon_vma tree464464+ * state by resetting.465465+ */466466+ vma->anon_vma = NULL;460467}461468462469/**
+4-5
mm/swap_state.c
···494494495495 __folio_set_locked(folio);496496 __folio_set_swapbacked(folio);497497+498498+ if (!charged && mem_cgroup_swapin_charge_folio(folio, NULL, gfp, entry))499499+ goto failed;500500+497501 for (;;) {498502 ret = swap_cache_add_folio(folio, entry, &shadow);499503 if (!ret)···516512 swapcache = swap_cache_get_folio(entry);517513 if (swapcache)518514 goto failed;519519- }520520-521521- if (!charged && mem_cgroup_swapin_charge_folio(folio, NULL, gfp, entry)) {522522- swap_cache_del_folio(folio);523523- goto failed;524515 }525516526517 memcg1_swapin(entry, folio_nr_pages(folio));
···30953095 * hci_connect_le serializes the connection attempts so only one30963096 * connection can be in BT_CONNECT at time.30973097 */30983098- if (conn->state == BT_CONNECT && hdev->req_status == HCI_REQ_PEND) {30983098+ if (conn->state == BT_CONNECT && READ_ONCE(hdev->req_status) == HCI_REQ_PEND) {30993099 switch (hci_skb_event(hdev->sent_cmd)) {31003100 case HCI_EV_CONN_COMPLETE:31013101 case HCI_EV_LE_CONN_COMPLETE:
···2525{2626 bt_dev_dbg(hdev, "result 0x%2.2x", result);27272828- if (hdev->req_status != HCI_REQ_PEND)2828+ if (READ_ONCE(hdev->req_status) != HCI_REQ_PEND)2929 return;30303131 hdev->req_result = result;3232- hdev->req_status = HCI_REQ_DONE;3232+ WRITE_ONCE(hdev->req_status, HCI_REQ_DONE);33333434 /* Free the request command so it is not used as response */3535 kfree_skb(hdev->req_skb);···167167168168 hci_cmd_sync_add(&req, opcode, plen, param, event, sk);169169170170- hdev->req_status = HCI_REQ_PEND;170170+ WRITE_ONCE(hdev->req_status, HCI_REQ_PEND);171171172172 err = hci_req_sync_run(&req);173173 if (err < 0)174174 return ERR_PTR(err);175175176176 err = wait_event_interruptible_timeout(hdev->req_wait_q,177177- hdev->req_status != HCI_REQ_PEND,177177+ READ_ONCE(hdev->req_status) != HCI_REQ_PEND,178178 timeout);179179180180 if (err == -ERESTARTSYS)181181 return ERR_PTR(-EINTR);182182183183- switch (hdev->req_status) {183183+ switch (READ_ONCE(hdev->req_status)) {184184 case HCI_REQ_DONE:185185 err = -bt_to_errno(hdev->req_result);186186 break;···194194 break;195195 }196196197197- hdev->req_status = 0;197197+ WRITE_ONCE(hdev->req_status, 0);198198 hdev->req_result = 0;199199 skb = hdev->req_rsp;200200 hdev->req_rsp = NULL;···665665{666666 bt_dev_dbg(hdev, "err 0x%2.2x", err);667667668668- if (hdev->req_status == HCI_REQ_PEND) {668668+ if (READ_ONCE(hdev->req_status) == HCI_REQ_PEND) {669669 hdev->req_result = err;670670- hdev->req_status = HCI_REQ_CANCELED;670670+ WRITE_ONCE(hdev->req_status, HCI_REQ_CANCELED);671671672672 queue_work(hdev->workqueue, &hdev->cmd_sync_cancel_work);673673 }···683683{684684 bt_dev_dbg(hdev, "err 0x%2.2x", err);685685686686- if (hdev->req_status == HCI_REQ_PEND) {686686+ if (READ_ONCE(hdev->req_status) == HCI_REQ_PEND) {687687 /* req_result is __u32 so error must be positive to be properly688688 * propagated.689689 */690690 hdev->req_result = err < 0 ? -err : err;691691- hdev->req_status = HCI_REQ_CANCELED;691691+ WRITE_ONCE(hdev->req_status, HCI_REQ_CANCELED);692692693693 wake_up_interruptible(&hdev->req_wait_q);694694 }
+53-18
net/bluetooth/l2cap_core.c
···926926927927static int l2cap_get_ident(struct l2cap_conn *conn)928928{929929+ u8 max;930930+ int ident;931931+929932 /* LE link does not support tools like l2ping so use the full range */930933 if (conn->hcon->type == LE_LINK)931931- return ida_alloc_range(&conn->tx_ida, 1, 255, GFP_ATOMIC);932932-934934+ max = 255;933935 /* Get next available identificator.934936 * 1 - 128 are used by kernel.935937 * 129 - 199 are reserved.936938 * 200 - 254 are used by utilities like l2ping, etc.937939 */938938- return ida_alloc_range(&conn->tx_ida, 1, 128, GFP_ATOMIC);940940+ else941941+ max = 128;942942+943943+ /* Allocate ident using min as last used + 1 (cyclic) */944944+ ident = ida_alloc_range(&conn->tx_ida, READ_ONCE(conn->tx_ident) + 1,945945+ max, GFP_ATOMIC);946946+ /* Force min 1 to start over */947947+ if (ident <= 0) {948948+ ident = ida_alloc_range(&conn->tx_ida, 1, max, GFP_ATOMIC);949949+ if (ident <= 0) {950950+ /* If all idents are in use, log an error, this is951951+ * extremely unlikely to happen and would indicate a bug952952+ * in the code that idents are not being freed properly.953953+ */954954+ BT_ERR("Unable to allocate ident: %d", ident);955955+ return 0;956956+ }957957+ }958958+959959+ WRITE_ONCE(conn->tx_ident, ident);960960+961961+ return ident;939962}940963941964static void l2cap_send_acl(struct l2cap_conn *conn, struct sk_buff *skb,···1771174817721749 BT_DBG("hcon %p conn %p, err %d", hcon, conn, err);1773175017511751+ disable_delayed_work_sync(&conn->info_timer);17521752+ disable_delayed_work_sync(&conn->id_addr_timer);17531753+17741754 mutex_lock(&conn->lock);1775175517761756 kfree_skb(conn->rx_skb);···17881762 cancel_work_sync(&conn->pending_rx_work);1789176317901764 ida_destroy(&conn->tx_ida);17911791-17921792- cancel_delayed_work_sync(&conn->id_addr_timer);1793176517941766 l2cap_unregister_all_users(conn);17951767···18061782 l2cap_chan_unlock(chan);18071783 l2cap_chan_put(chan);18081784 }18091809-18101810- if (conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_SENT)18111811- cancel_delayed_work_sync(&conn->info_timer);1812178518131786 hci_chan_del(conn->hchan);18141787 conn->hchan = NULL;···2397237623982377 /* Remote device may have requested smaller PDUs */23992378 pdu_len = min_t(size_t, pdu_len, chan->remote_mps);23792379+23802380+ if (!pdu_len)23812381+ return -EINVAL;2400238224012383 if (len <= pdu_len) {24022384 sar = L2CAP_SAR_UNSEGMENTED;···43364312 if (test_bit(CONF_INPUT_DONE, &chan->conf_state)) {43374313 set_default_fcs(chan);4338431443394339- if (chan->mode == L2CAP_MODE_ERTM ||43404340- chan->mode == L2CAP_MODE_STREAMING)43414341- err = l2cap_ertm_init(chan);43154315+ if (chan->state != BT_CONNECTED) {43164316+ if (chan->mode == L2CAP_MODE_ERTM ||43174317+ chan->mode == L2CAP_MODE_STREAMING)43184318+ err = l2cap_ertm_init(chan);4342431943434343- if (err < 0)43444344- l2cap_send_disconn_req(chan, -err);43454345- else43464346- l2cap_chan_ready(chan);43204320+ if (err < 0)43214321+ l2cap_send_disconn_req(chan, -err);43224322+ else43234323+ l2cap_chan_ready(chan);43244324+ }4347432543484326 goto unlock;43494327 }···51075081 cmd_len -= sizeof(*req);51085082 num_scid = cmd_len / sizeof(u16);5109508351105110- /* Always respond with the same number of scids as in the request */51115111- rsp_len = cmd_len;51125112-51135084 if (num_scid > L2CAP_ECRED_MAX_CID) {51145085 result = L2CAP_CR_LE_INVALID_PARAMS;51155086 goto response;51165087 }50885088+50895089+ /* Always respond with the same number of scids as in the request */50905090+ rsp_len = cmd_len;5117509151185092 mtu = __le16_to_cpu(req->mtu);51195093 mps = __le16_to_cpu(req->mps);···66336607 struct l2cap_le_credits pkt;66346608 u16 return_credits = l2cap_le_rx_credits(chan);6635660966106610+ if (chan->mode != L2CAP_MODE_LE_FLOWCTL &&66116611+ chan->mode != L2CAP_MODE_EXT_FLOWCTL)66126612+ return;66136613+66366614 if (chan->rx_credits >= return_credits)66376615 return;66386616···6719668967206690 if (!chan->sdu) {67216691 u16 sdu_len;66926692+66936693+ if (!pskb_may_pull(skb, L2CAP_SDULEN_SIZE)) {66946694+ err = -EINVAL;66956695+ goto failed;66966696+ }6722669767236698 sdu_len = get_unaligned_le16(skb->data);67246699 skb_pull(skb, L2CAP_SDULEN_SIZE);
···53555355 * hci_adv_monitors_clear is about to be called which will take care of53565356 * freeing the adv_monitor instances.53575357 */53585358- if (status == -ECANCELED && !mgmt_pending_valid(hdev, cmd))53585358+ if (status == -ECANCELED || !mgmt_pending_valid(hdev, cmd))53595359 return;5360536053615361 monitor = cmd->user_data;
+7-3
net/bluetooth/sco.c
···401401 struct sock *sk;402402403403 sco_conn_lock(conn);404404- sk = conn->sk;404404+ sk = sco_sock_hold(conn);405405 sco_conn_unlock(conn);406406407407 if (!sk)···410410 BT_DBG("sk %p len %u", sk, skb->len);411411412412 if (sk->sk_state != BT_CONNECTED)413413- goto drop;413413+ goto drop_put;414414415415- if (!sock_queue_rcv_skb(sk, skb))415415+ if (!sock_queue_rcv_skb(sk, skb)) {416416+ sock_put(sk);416417 return;418418+ }417419420420+drop_put:421421+ sock_put(sk);418422drop:419423 kfree_skb(skb);420424}
···395395396396static bool expect_iter_me(struct nf_conntrack_expect *exp, void *data)397397{398398- struct nf_conn_help *help = nfct_help(exp->master);399398 const struct nf_conntrack_helper *me = data;400399 const struct nf_conntrack_helper *this;401400402402- if (exp->helper == me)403403- return true;404404-405405- this = rcu_dereference_protected(help->helper,401401+ this = rcu_dereference_protected(exp->helper,406402 lockdep_is_held(&nf_conntrack_expect_lock));407403 return this == me;408404}···417421418422 nf_ct_expect_iterate_destroy(expect_iter_me, NULL);419423 nf_ct_iterate_destroy(unhelp, me);424424+425425+ /* nf_ct_iterate_destroy() does an unconditional synchronize_rcu() as426426+ * last step, this ensures rcu readers of exp->helper are done.427427+ * No need for another synchronize_rcu() here.428428+ */420429}421430EXPORT_SYMBOL_GPL(nf_conntrack_helper_unregister);422431
···647647648648 if (data_len) {649649 struct nlattr *nla;650650- int size = nla_attr_size(data_len);651650652652- if (skb_tailroom(inst->skb) < nla_total_size(data_len))651651+ nla = nla_reserve(inst->skb, NFULA_PAYLOAD, data_len);652652+ if (!nla)653653 goto nla_put_failure;654654-655655- nla = skb_put(inst->skb, nla_total_size(data_len));656656- nla->nla_type = NFULA_PAYLOAD;657657- nla->nla_len = size;658654659655 if (skb_copy_bits(skb, 0, nla_data(nla), data_len))660656 BUG();
+10-10
net/netfilter/nft_set_pipapo_avx2.c
···242242243243 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);244244 if (last)245245- return b;245245+ ret = b;246246247247 if (unlikely(ret == -1))248248 ret = b / XSAVE_YMM_SIZE;···319319320320 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);321321 if (last)322322- return b;322322+ ret = b;323323324324 if (unlikely(ret == -1))325325 ret = b / XSAVE_YMM_SIZE;···414414415415 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);416416 if (last)417417- return b;417417+ ret = b;418418419419 if (unlikely(ret == -1))420420 ret = b / XSAVE_YMM_SIZE;···505505506506 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);507507 if (last)508508- return b;508508+ ret = b;509509510510 if (unlikely(ret == -1))511511 ret = b / XSAVE_YMM_SIZE;···641641642642 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);643643 if (last)644644- return b;644644+ ret = b;645645646646 if (unlikely(ret == -1))647647 ret = b / XSAVE_YMM_SIZE;···699699700700 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);701701 if (last)702702- return b;702702+ ret = b;703703704704 if (unlikely(ret == -1))705705 ret = b / XSAVE_YMM_SIZE;···764764765765 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);766766 if (last)767767- return b;767767+ ret = b;768768769769 if (unlikely(ret == -1))770770 ret = b / XSAVE_YMM_SIZE;···839839840840 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);841841 if (last)842842- return b;842842+ ret = b;843843844844 if (unlikely(ret == -1))845845 ret = b / XSAVE_YMM_SIZE;···925925926926 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);927927 if (last)928928- return b;928928+ ret = b;929929930930 if (unlikely(ret == -1))931931 ret = b / XSAVE_YMM_SIZE;···1019101910201020 b = nft_pipapo_avx2_refill(i_ul, &map[i_ul], fill, f->mt, last);10211021 if (last)10221022- return b;10221022+ ret = b;1023102310241024 if (unlikely(ret == -1))10251025 ret = b / XSAVE_YMM_SIZE;
+75-17
net/netfilter/nft_set_rbtree.c
···572572 return array;573573}574574575575-#define NFT_ARRAY_EXTRA_SIZE 10240576576-577575/* Similar to nft_rbtree_{u,k}size to hide details to userspace, but consider578576 * packed representation coming from userspace for anonymous sets too.579577 */580578static u32 nft_array_elems(const struct nft_set *set)581579{582582- u32 nelems = atomic_read(&set->nelems);580580+ u32 nelems = atomic_read(&set->nelems) - set->ndeact;583581584582 /* Adjacent intervals are represented with a single start element in585583 * anonymous sets, use the current element counter as is.···593595 return (nelems / 2) + 2;594596}595597596596-static int nft_array_may_resize(const struct nft_set *set)598598+#define NFT_ARRAY_INITIAL_SIZE 1024599599+#define NFT_ARRAY_INITIAL_ANON_SIZE 16600600+#define NFT_ARRAY_INITIAL_ANON_THRESH (8192U / sizeof(struct nft_array_interval))601601+602602+static int nft_array_may_resize(const struct nft_set *set, bool flush)597603{598598- u32 nelems = nft_array_elems(set), new_max_intervals;604604+ u32 initial_intervals, max_intervals, new_max_intervals, delta;605605+ u32 shrinked_max_intervals, nelems = nft_array_elems(set);599606 struct nft_rbtree *priv = nft_set_priv(set);600607 struct nft_array *array;601608602602- if (!priv->array_next) {603603- array = nft_array_alloc(nelems + NFT_ARRAY_EXTRA_SIZE);609609+ if (nft_set_is_anonymous(set))610610+ initial_intervals = NFT_ARRAY_INITIAL_ANON_SIZE;611611+ else612612+ initial_intervals = NFT_ARRAY_INITIAL_SIZE;613613+614614+ if (priv->array_next) {615615+ max_intervals = priv->array_next->max_intervals;616616+ new_max_intervals = priv->array_next->max_intervals;617617+ } else {618618+ if (priv->array) {619619+ max_intervals = priv->array->max_intervals;620620+ new_max_intervals = priv->array->max_intervals;621621+ } else {622622+ max_intervals = 0;623623+ new_max_intervals = initial_intervals;624624+ }625625+ }626626+627627+ if (nft_set_is_anonymous(set))628628+ goto maybe_grow;629629+630630+ if (flush) {631631+ /* Set flush just started, nelems still report elements.*/632632+ nelems = 0;633633+ new_max_intervals = NFT_ARRAY_INITIAL_SIZE;634634+ goto realloc_array;635635+ }636636+637637+ if (check_add_overflow(new_max_intervals, new_max_intervals,638638+ &shrinked_max_intervals))639639+ return -EOVERFLOW;640640+641641+ shrinked_max_intervals = DIV_ROUND_UP(shrinked_max_intervals, 3);642642+643643+ if (shrinked_max_intervals > NFT_ARRAY_INITIAL_SIZE &&644644+ nelems < shrinked_max_intervals) {645645+ new_max_intervals = shrinked_max_intervals;646646+ goto realloc_array;647647+ }648648+maybe_grow:649649+ if (nelems > new_max_intervals) {650650+ if (nft_set_is_anonymous(set) &&651651+ new_max_intervals < NFT_ARRAY_INITIAL_ANON_THRESH) {652652+ new_max_intervals <<= 1;653653+ } else {654654+ delta = new_max_intervals >> 1;655655+ if (check_add_overflow(new_max_intervals, delta,656656+ &new_max_intervals))657657+ return -EOVERFLOW;658658+ }659659+ }660660+661661+realloc_array:662662+ if (WARN_ON_ONCE(nelems > new_max_intervals))663663+ return -ENOMEM;664664+665665+ if (priv->array_next) {666666+ if (max_intervals == new_max_intervals)667667+ return 0;668668+669669+ if (nft_array_intervals_alloc(priv->array_next, new_max_intervals) < 0)670670+ return -ENOMEM;671671+ } else {672672+ array = nft_array_alloc(new_max_intervals);604673 if (!array)605674 return -ENOMEM;606675607676 priv->array_next = array;608677 }609609-610610- if (nelems < priv->array_next->max_intervals)611611- return 0;612612-613613- new_max_intervals = priv->array_next->max_intervals + NFT_ARRAY_EXTRA_SIZE;614614- if (nft_array_intervals_alloc(priv->array_next, new_max_intervals) < 0)615615- return -ENOMEM;616678617679 return 0;618680}···688630689631 nft_rbtree_maybe_reset_start_cookie(priv, tstamp);690632691691- if (nft_array_may_resize(set) < 0)633633+ if (nft_array_may_resize(set, false) < 0)692634 return -ENOMEM;693635694636 do {···799741 nft_rbtree_interval_null(set, this))800742 priv->start_rbe_cookie = 0;801743802802- if (nft_array_may_resize(set) < 0)744744+ if (nft_array_may_resize(set, false) < 0)803745 return NULL;804746805747 while (parent != NULL) {···869811870812 switch (iter->type) {871813 case NFT_ITER_UPDATE_CLONE:872872- if (nft_array_may_resize(set) < 0) {814814+ if (nft_array_may_resize(set, true) < 0) {873815 iter->err = -ENOMEM;874816 break;875817 }
+6-4
net/nfc/nci/core.c
···579579 skb_queue_purge(&ndev->rx_q);580580 skb_queue_purge(&ndev->tx_q);581581582582- /* Flush RX and TX wq */583583- flush_workqueue(ndev->rx_wq);582582+ /* Flush TX wq, RX wq flush can't be under the lock */584583 flush_workqueue(ndev->tx_wq);585584586585 /* Reset device */···591592 msecs_to_jiffies(NCI_RESET_TIMEOUT));592593593594 /* After this point our queues are empty594594- * and no works are scheduled.595595+ * rx work may be running but will see that NCI_UP was cleared595596 */596597 ndev->ops->close(ndev);597598598599 clear_bit(NCI_INIT, &ndev->flags);599600600600- /* Flush cmd wq */601601+ /* Flush cmd and tx wq */601602 flush_workqueue(ndev->cmd_wq);602603603604 timer_delete_sync(&ndev->cmd_timer);···611612 ndev->flags &= BIT(NCI_UNREG);612613613614 mutex_unlock(&ndev->req_lock);615615+616616+ /* rx_work may take req_lock via nci_deactivate_target */617617+ flush_workqueue(ndev->rx_wq);614618615619 return 0;616620}
+2
net/openvswitch/flow_netlink.c
···29532953 case OVS_KEY_ATTR_MPLS:29542954 if (!eth_p_mpls(eth_type))29552955 return -EINVAL;29562956+ if (key_len != sizeof(struct ovs_key_mpls))29572957+ return -EINVAL;29562958 break;2957295929582960 case OVS_KEY_ATTR_SCTP:
···246246 crypto_wait_req(-EINPROGRESS, &ctx->async_wait);247247 atomic_inc(&ctx->decrypt_pending);248248249249+ __skb_queue_purge(&ctx->async_hold);249250 return ctx->async_wait.err;250251}251252···2226222522272226 /* Wait for all previously submitted records to be decrypted */22282227 ret = tls_decrypt_async_wait(ctx);22292229- __skb_queue_purge(&ctx->async_hold);2230222822312229 if (ret) {22322230 if (err >= 0 || err == -EINPROGRESS)
+4-1
net/xfrm/xfrm_input.c
···75757676 spin_lock_bh(&xfrm_input_afinfo_lock);7777 if (likely(xfrm_input_afinfo[afinfo->is_ipip][afinfo->family])) {7878- if (unlikely(xfrm_input_afinfo[afinfo->is_ipip][afinfo->family] != afinfo))7878+ const struct xfrm_input_afinfo *cur;7979+8080+ cur = rcu_access_pointer(xfrm_input_afinfo[afinfo->is_ipip][afinfo->family]);8181+ if (unlikely(cur != afinfo))7982 err = -EINVAL;8083 else8184 RCU_INIT_POINTER(xfrm_input_afinfo[afinfo->is_ipip][afinfo->family], NULL);
···3535#endif3636#include <linux/unaligned.h>37373838+static struct sock *xfrm_net_nlsk(const struct net *net, const struct sk_buff *skb)3939+{4040+ /* get the source of this request, see netlink_unicast_kernel */4141+ const struct sock *sk = NETLINK_CB(skb).sk;4242+4343+ /* sk is refcounted, the netns stays alive and nlsk with it */4444+ return rcu_dereference_protected(net->xfrm.nlsk, sk->sk_net_refcnt);4545+}4646+3847static int verify_one_alg(struct nlattr **attrs, enum xfrm_attr_type_t type,3948 struct netlink_ext_ack *extack)4049{···17361727 err = build_spdinfo(r_skb, net, sportid, seq, *flags);17371728 BUG_ON(err < 0);1738172917391739- return nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid);17301730+ return nlmsg_unicast(xfrm_net_nlsk(net, skb), r_skb, sportid);17401731}1741173217421733static inline unsigned int xfrm_sadinfo_msgsize(void)···17961787 err = build_sadinfo(r_skb, net, sportid, seq, *flags);17971788 BUG_ON(err < 0);1798178917991799- return nlmsg_unicast(net->xfrm.nlsk, r_skb, sportid);17901790+ return nlmsg_unicast(xfrm_net_nlsk(net, skb), r_skb, sportid);18001791}1801179218021793static int xfrm_get_sa(struct sk_buff *skb, struct nlmsghdr *nlh,···18161807 if (IS_ERR(resp_skb)) {18171808 err = PTR_ERR(resp_skb);18181809 } else {18191819- err = nlmsg_unicast(net->xfrm.nlsk, resp_skb, NETLINK_CB(skb).portid);18101810+ err = nlmsg_unicast(xfrm_net_nlsk(net, skb), resp_skb, NETLINK_CB(skb).portid);18201811 }18211812 xfrm_state_put(x);18221813out_noput:···18591850 pcpu_num = nla_get_u32(attrs[XFRMA_SA_PCPU]);18601851 if (pcpu_num >= num_possible_cpus()) {18611852 err = -EINVAL;18531853+ NL_SET_ERR_MSG(extack, "pCPU number too big");18621854 goto out_noput;18631855 }18641856 }···19071897 }19081898 }1909189919101910- err = nlmsg_unicast(net->xfrm.nlsk, resp_skb, NETLINK_CB(skb).portid);19001900+ err = nlmsg_unicast(xfrm_net_nlsk(net, skb), resp_skb, NETLINK_CB(skb).portid);1911190119121902out:19131903 xfrm_state_put(x);···25522542 r_up->out = net->xfrm.policy_default[XFRM_POLICY_OUT];25532543 nlmsg_end(r_skb, r_nlh);2554254425552555- return nlmsg_unicast(net->xfrm.nlsk, r_skb, portid);25452545+ return nlmsg_unicast(xfrm_net_nlsk(net, skb), r_skb, portid);25562546}2557254725582548static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,···26182608 if (IS_ERR(resp_skb)) {26192609 err = PTR_ERR(resp_skb);26202610 } else {26212621- err = nlmsg_unicast(net->xfrm.nlsk, resp_skb,26112611+ err = nlmsg_unicast(xfrm_net_nlsk(net, skb), resp_skb,26222612 NETLINK_CB(skb).portid);26232613 }26242614 } else {···27912781 err = build_aevent(r_skb, x, &c);27922782 BUG_ON(err < 0);2793278327942794- err = nlmsg_unicast(net->xfrm.nlsk, r_skb, NETLINK_CB(skb).portid);27842784+ err = nlmsg_unicast(xfrm_net_nlsk(net, skb), r_skb, NETLINK_CB(skb).portid);27952785 spin_unlock_bh(&x->lock);27962786 xfrm_state_put(x);27972787 return err;···30113001 if (attrs[XFRMA_SA_PCPU]) {30123002 x->pcpu_num = nla_get_u32(attrs[XFRMA_SA_PCPU]);30133003 err = -EINVAL;30143014- if (x->pcpu_num >= num_possible_cpus())30043004+ if (x->pcpu_num >= num_possible_cpus()) {30053005+ NL_SET_ERR_MSG(extack, "pCPU number too big");30153006 goto free_state;30073007+ }30163008 }3017300930183010 err = verify_newpolicy_info(&ua->policy, extack);···34953483 goto err;34963484 }3497348534983498- err = netlink_dump_start(net->xfrm.nlsk, skb, nlh, &c);34863486+ err = netlink_dump_start(xfrm_net_nlsk(net, skb), skb, nlh, &c);34993487 goto err;35003488 }35013489···36853673 }36863674 if (x->if_id)36873675 l += nla_total_size(sizeof(x->if_id));36883688- if (x->pcpu_num)36763676+ if (x->pcpu_num != UINT_MAX)36893677 l += nla_total_size(sizeof(x->pcpu_num));3690367836913679 /* Must count x->lastused as it may become non-zero behind our back. */
+18-15
rust/kernel/regulator.rs
···2323 prelude::*,2424};25252626-use core::{marker::PhantomData, mem::ManuallyDrop, ptr::NonNull};2626+use core::{2727+ marker::PhantomData,2828+ mem::ManuallyDrop, //2929+};27302831mod private {2932 pub trait Sealed {}···232229///233230/// # Invariants234231///235235-/// - `inner` is a non-null wrapper over a pointer to a `struct236236-/// regulator` obtained from [`regulator_get()`].232232+/// - `inner` is a pointer obtained from a successful call to233233+/// [`regulator_get()`]. It is treated as an opaque token that may only be234234+/// accessed using C API methods (e.g., it may be `NULL` if the C API returns235235+/// `NULL`).237236///238237/// [`regulator_get()`]: https://docs.kernel.org/driver-api/regulator.html#c.regulator_get239238pub struct Regulator<State>240239where241240 State: RegulatorState,242241{243243- inner: NonNull<bindings::regulator>,242242+ inner: *mut bindings::regulator,244243 _phantom: PhantomData<State>,245244}246245···254249 // SAFETY: Safe as per the type invariants of `Regulator`.255250 to_result(unsafe {256251 bindings::regulator_set_voltage(257257- self.inner.as_ptr(),252252+ self.inner,258253 min_voltage.as_microvolts(),259254 max_voltage.as_microvolts(),260255 )···264259 /// Gets the current voltage of the regulator.265260 pub fn get_voltage(&self) -> Result<Voltage> {266261 // SAFETY: Safe as per the type invariants of `Regulator`.267267- let voltage = unsafe { bindings::regulator_get_voltage(self.inner.as_ptr()) };262262+ let voltage = unsafe { bindings::regulator_get_voltage(self.inner) };268263269264 to_result(voltage).map(|()| Voltage::from_microvolts(voltage))270265 }···275270 // received from the C code.276271 from_err_ptr(unsafe { bindings::regulator_get(dev.as_raw(), name.as_char_ptr()) })?;277272278278- // SAFETY: We can safely trust `inner` to be a pointer to a valid279279- // regulator if `ERR_PTR` was not returned.280280- let inner = unsafe { NonNull::new_unchecked(inner) };281281-273273+ // INVARIANT: `inner` is a pointer obtained from `regulator_get()`, and274274+ // the call was successful.282275 Ok(Self {283276 inner,284277 _phantom: PhantomData,···285282286283 fn enable_internal(&self) -> Result {287284 // SAFETY: Safe as per the type invariants of `Regulator`.288288- to_result(unsafe { bindings::regulator_enable(self.inner.as_ptr()) })285285+ to_result(unsafe { bindings::regulator_enable(self.inner) })289286 }290287291288 fn disable_internal(&self) -> Result {292289 // SAFETY: Safe as per the type invariants of `Regulator`.293293- to_result(unsafe { bindings::regulator_disable(self.inner.as_ptr()) })290290+ to_result(unsafe { bindings::regulator_disable(self.inner) })294291 }295292}296293···352349 /// Checks if the regulator is enabled.353350 pub fn is_enabled(&self) -> bool {354351 // SAFETY: Safe as per the type invariants of `Regulator`.355355- unsafe { bindings::regulator_is_enabled(self.inner.as_ptr()) != 0 }352352+ unsafe { bindings::regulator_is_enabled(self.inner) != 0 }356353 }357354}358355···362359 // SAFETY: By the type invariants, we know that `self` owns a363360 // reference on the enabled refcount, so it is safe to relinquish it364361 // now.365365- unsafe { bindings::regulator_disable(self.inner.as_ptr()) };362362+ unsafe { bindings::regulator_disable(self.inner) };366363 }367364 // SAFETY: By the type invariants, we know that `self` owns a reference,368365 // so it is safe to relinquish it now.369369- unsafe { bindings::regulator_put(self.inner.as_ptr()) };366366+ unsafe { bindings::regulator_put(self.inner) };370367 }371368}372369
+3-2
samples/landlock/sandboxer.c
···299299300300/* clang-format on */301301302302-#define LANDLOCK_ABI_LAST 7302302+#define LANDLOCK_ABI_LAST 8303303304304#define XSTR(s) #s305305#define STR(s) XSTR(s)···436436 /* Removes LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON for ABI < 7 */437437 supported_restrict_flags &=438438 ~LANDLOCK_RESTRICT_SELF_LOG_NEW_EXEC_ON;439439-439439+ __attribute__((fallthrough));440440+ case 7:440441 /* Must be printed for any ABI < LANDLOCK_ABI_LAST. */441442 fprintf(stderr,442443 "Hint: You should update the running kernel "
+11
scripts/coccinelle/api/kmalloc_objs.cocci
···122122- ALLOC(struct_size_t(TYPE, FLEX, COUNT), GFP)123123+ ALLOC_FLEX(TYPE, FLEX, COUNT, GFP)124124)125125+126126+@drop_gfp_kernel depends on patch && !(file in "tools") && !(file in "samples")@127127+identifier ALLOC = {kmalloc_obj,kmalloc_objs,kmalloc_flex,128128+ kzalloc_obj,kzalloc_objs,kzalloc_flex,129129+ kvmalloc_obj,kvmalloc_objs,kvmalloc_flex,130130+ kvzalloc_obj,kvzalloc_objs,kvzalloc_flex};131131+@@132132+133133+ ALLOC(...134134+- , GFP_KERNEL135135+ )
+10-14
scripts/kconfig/merge_config.sh
···151151 if ! "$AWK" -v prefix="$CONFIG_PREFIX" \152152 -v warnoverride="$WARNOVERRIDE" \153153 -v strict="$STRICT" \154154+ -v outfile="$TMP_FILE.new" \154155 -v builtin="$BUILTIN" \155156 -v warnredun="$WARNREDUN" '156157 BEGIN {···196195197196 # First pass: read merge file, store all lines and index198197 FILENAME == ARGV[1] {199199- mergefile = FILENAME198198+ mergefile = FILENAME200199 merge_lines[FNR] = $0201200 merge_total = FNR202201 cfg = get_cfg($0)···213212214213 # Not a config or not in merge file - keep it215214 if (cfg == "" || !(cfg in merge_cfg)) {216216- print $0 >> ARGV[3]215215+ print $0 >> outfile217216 next218217 }219218220220- prev_val = $0219219+ prev_val = $0221220 new_val = merge_cfg[cfg]222221223222 # BUILTIN: do not demote y to m224223 if (builtin == "true" && new_val ~ /=m$/ && prev_val ~ /=y$/) {225224 warn_builtin(cfg, prev_val, new_val)226226- print $0 >> ARGV[3]225225+ print $0 >> outfile227226 skip_merge[merge_cfg_line[cfg]] = 1228227 next229228 }···236235237236 # "=n" is the same as "is not set"238237 if (prev_val ~ /=n$/ && new_val ~ / is not set$/) {239239- print $0 >> ARGV[3]238238+ print $0 >> outfile240239 next241240 }242241···247246 }248247 }249248250250- # output file, skip all lines251251- FILENAME == ARGV[3] {252252- nextfile253253- }254254-255249 END {256250 # Newline in case base file lacks trailing newline257257- print "" >> ARGV[3]251251+ print "" >> outfile258252 # Append merge file, skipping lines marked for builtin preservation259253 for (i = 1; i <= merge_total; i++) {260254 if (!(i in skip_merge)) {261261- print merge_lines[i] >> ARGV[3]255255+ print merge_lines[i] >> outfile262256 }263257 }264258 if (strict_violated) {265259 exit 1266260 }267261 }' \268268- "$ORIG_MERGE_FILE" "$TMP_FILE" "$TMP_FILE.new"; then262262+ "$ORIG_MERGE_FILE" "$TMP_FILE"; then269263 # awk exited non-zero, strict mode was violated270264 STRICT_MODE_VIOLATED=true271265 fi···377381 STRICT_MODE_VIOLATED=true378382fi379383380380-if [ "$STRICT" == "true" ] && [ "$STRICT_MODE_VIOLATED" == "true" ]; then384384+if [ "$STRICT" = "true" ] && [ "$STRICT_MODE_VIOLATED" = "true" ]; then381385 echo "Requested and effective config differ"382386 exit 1383387fi
+1-2
security/landlock/domain.c
···9494 * allocate with GFP_KERNEL_ACCOUNT because it is independent from the9595 * caller.9696 */9797- details =9898- kzalloc_flex(*details, exe_path, path_size);9797+ details = kzalloc_flex(*details, exe_path, path_size);9998 if (!details)10099 return ERR_PTR(-ENOMEM);101100
···203203 return ctx;204204}205205206206+/**207207+ * tsync_works_trim - Put the last tsync_work element208208+ *209209+ * @s: TSYNC works to trim.210210+ *211211+ * Put the last task and decrement the size of @s.212212+ *213213+ * This helper does not cancel a running task, but just reset the last element214214+ * to zero.215215+ */216216+static void tsync_works_trim(struct tsync_works *s)217217+{218218+ struct tsync_work *ctx;219219+220220+ if (WARN_ON_ONCE(s->size <= 0))221221+ return;222222+223223+ ctx = s->works[s->size - 1];224224+225225+ /*226226+ * For consistency, remove the task from ctx so that it does not look like227227+ * we handed it a task_work.228228+ */229229+ put_task_struct(ctx->task);230230+ *ctx = (typeof(*ctx)){};231231+232232+ /*233233+ * Cancel the tsync_works_provide() change to recycle the reserved memory234234+ * for the next thread, if any. This also ensures that cancel_tsync_works()235235+ * and tsync_works_release() do not see any NULL task pointers.236236+ */237237+ s->size--;238238+}239239+206240/*207241 * tsync_works_grow_by - preallocates space for n more contexts in s208242 *···290256 * tsync_works_contains - checks for presence of task in s291257 */292258static bool tsync_works_contains_task(const struct tsync_works *s,293293- struct task_struct *task)259259+ const struct task_struct *task)294260{295261 size_t i;296262297263 for (i = 0; i < s->size; i++)298264 if (s->works[i]->task == task)299265 return true;266266+300267 return false;301268}302269···311276 size_t i;312277313278 for (i = 0; i < s->size; i++) {314314- if (!s->works[i]->task)279279+ if (WARN_ON_ONCE(!s->works[i]->task))315280 continue;316281317282 put_task_struct(s->works[i]->task);···319284320285 for (i = 0; i < s->capacity; i++)321286 kfree(s->works[i]);287287+322288 kfree(s->works);323289 s->works = NULL;324290 s->size = 0;···331295 */332296static size_t count_additional_threads(const struct tsync_works *works)333297{334334- struct task_struct *thread, *caller;298298+ const struct task_struct *caller, *thread;335299 size_t n = 0;336300337301 caller = current;···370334 struct tsync_shared_context *shared_ctx)371335{372336 int err;373373- struct task_struct *thread, *caller;337337+ const struct task_struct *caller;338338+ struct task_struct *thread;374339 struct tsync_work *ctx;375340 bool found_more_threads = false;376341···416379417380 init_task_work(&ctx->work, restrict_one_thread_callback);418381 err = task_work_add(thread, &ctx->work, TWA_SIGNAL);419419- if (err) {382382+ if (unlikely(err)) {420383 /*421384 * task_work_add() only fails if the task is about to exit. We422385 * checked that earlier, but it can happen as a race. Resume423386 * without setting an error, as the task is probably gone in the424424- * next loop iteration. For consistency, remove the task from ctx425425- * so that it does not look like we handed it a task_work.387387+ * next loop iteration.426388 */427427- put_task_struct(ctx->task);428428- ctx->task = NULL;389389+ tsync_works_trim(works);429390430391 atomic_dec(&shared_ctx->num_preparing);431392 atomic_dec(&shared_ctx->num_unfinished);···441406 * shared_ctx->num_preparing and shared_ctx->num_unfished and mark the two442407 * completions if needed, as if the task was never scheduled.443408 */444444-static void cancel_tsync_works(struct tsync_works *works,409409+static void cancel_tsync_works(const struct tsync_works *works,445410 struct tsync_shared_context *shared_ctx)446411{447447- int i;412412+ size_t i;448413449414 for (i = 0; i < works->size; i++) {415415+ if (WARN_ON_ONCE(!works->works[i]->task))416416+ continue;417417+450418 if (!task_work_cancel(works->works[i]->task,451419 &works->works[i]->work))452420 continue;···484446 shared_ctx.old_cred = old_cred;485447 shared_ctx.new_cred = new_cred;486448 shared_ctx.set_no_new_privs = task_no_new_privs(current);449449+450450+ /*451451+ * Serialize concurrent TSYNC operations to prevent deadlocks when452452+ * multiple threads call landlock_restrict_self() simultaneously.453453+ * If the lock is already held, we gracefully yield by restarting the454454+ * syscall. This allows the current thread to process pending455455+ * task_works before retrying.456456+ */457457+ if (!down_write_trylock(¤t->signal->exec_update_lock))458458+ return restart_syscall();487459488460 /*489461 * We schedule a pseudo-signal task_work for each of the calling task's···575527 -ERESTARTNOINTR);576528577529 /*578578- * Cancel task works for tasks that did not start running yet,579579- * and decrement all_prepared and num_unfinished accordingly.530530+ * Opportunistic improvement: try to cancel task531531+ * works for tasks that did not start running532532+ * yet. We do not have a guarantee that it533533+ * cancels any of the enqueued task works534534+ * because task_work_run() might already have535535+ * dequeued them.580536 */581537 cancel_tsync_works(&works, &shared_ctx);582538583539 /*584584- * The remaining task works have started running, so waiting for585585- * their completion will finish.540540+ * Break the loop with error. The cleanup code541541+ * after the loop unblocks the remaining542542+ * task_works.586543 */587587- wait_for_completion(&shared_ctx.all_prepared);544544+ break;588545 }589546 }590547 } while (found_more_threads &&591548 !atomic_read(&shared_ctx.preparation_error));592549593550 /*594594- * We now have all sibling threads blocking and in "prepared" state in the595595- * task work. Ask all threads to commit.551551+ * We now have either (a) all sibling threads blocking and in "prepared"552552+ * state in the task work, or (b) the preparation error is set. Ask all553553+ * threads to commit (or abort).596554 */597555 complete_all(&shared_ctx.ready_to_commit);598556···610556 wait_for_completion(&shared_ctx.all_finished);611557612558 tsync_works_release(&works);613613-559559+ up_write(¤t->signal->exec_update_lock);614560 return atomic_read(&shared_ctx.preparation_error);615561}
+1
security/security.c
···6161 [LOCKDOWN_BPF_WRITE_USER] = "use of bpf to write user RAM",6262 [LOCKDOWN_DBG_WRITE_KERNEL] = "use of kgdb/kdb to write kernel RAM",6363 [LOCKDOWN_RTAS_ERROR_INJECTION] = "RTAS error injection",6464+ [LOCKDOWN_XEN_USER_ACTIONS] = "Xen guest user action",6465 [LOCKDOWN_INTEGRITY_MAX] = "integrity",6566 [LOCKDOWN_KCORE] = "/proc/kcore access",6667 [LOCKDOWN_KPROBES] = "use of kprobes",
+1-1
sound/firewire/amdtp-stream.c
···11641164 struct pkt_desc *desc = s->packet_descs_cursor;11651165 unsigned int pkt_header_length;11661166 unsigned int packets;11671167- u32 curr_cycle_time;11671167+ u32 curr_cycle_time = 0;11681168 bool need_hw_irq;11691169 int i;11701170
···762762 return 0;763763}764764765765-static void adau1372_enable_pll(struct adau1372 *adau1372)765765+static int adau1372_enable_pll(struct adau1372 *adau1372)766766{767767 unsigned int val, timeout = 0;768768 int ret;···778778 timeout++;779779 } while (!(val & 1) && timeout < 3);780780781781- if (ret < 0 || !(val & 1))781781+ if (ret < 0 || !(val & 1)) {782782 dev_err(adau1372->dev, "Failed to lock PLL\n");783783+ return ret < 0 ? ret : -ETIMEDOUT;784784+ }785785+786786+ return 0;783787}784788785785-static void adau1372_set_power(struct adau1372 *adau1372, bool enable)789789+static int adau1372_set_power(struct adau1372 *adau1372, bool enable)786790{787791 if (adau1372->enabled == enable)788788- return;792792+ return 0;789793790794 if (enable) {791795 unsigned int clk_ctrl = ADAU1372_CLK_CTRL_MCLK_EN;796796+ int ret;792797793793- clk_prepare_enable(adau1372->mclk);798798+ ret = clk_prepare_enable(adau1372->mclk);799799+ if (ret)800800+ return ret;794801 if (adau1372->pd_gpio)795802 gpiod_set_value(adau1372->pd_gpio, 0);796803···811804 * accessed.812805 */813806 if (adau1372->use_pll) {814814- adau1372_enable_pll(adau1372);807807+ ret = adau1372_enable_pll(adau1372);808808+ if (ret) {809809+ regcache_cache_only(adau1372->regmap, true);810810+ if (adau1372->pd_gpio)811811+ gpiod_set_value(adau1372->pd_gpio, 1);812812+ clk_disable_unprepare(adau1372->mclk);813813+ return ret;814814+ }815815 clk_ctrl |= ADAU1372_CLK_CTRL_CLKSRC;816816 }817817···843829 }844830845831 adau1372->enabled = enable;832832+833833+ return 0;846834}847835848836static int adau1372_set_bias_level(struct snd_soc_component *component,···858842 case SND_SOC_BIAS_PREPARE:859843 break;860844 case SND_SOC_BIAS_STANDBY:861861- adau1372_set_power(adau1372, true);862862- break;845845+ return adau1372_set_power(adau1372, true);863846 case SND_SOC_BIAS_OFF:864864- adau1372_set_power(adau1372, false);865865- break;847847+ return adau1372_set_power(adau1372, false);866848 }867849868850 return 0;
+10-4
sound/soc/sdca/sdca_functions.c
···216216 } else if (num_init_writes % sizeof(*raw) != 0) {217217 dev_err(dev, "%pfwP: init table size invalid\n", function_node);218218 return -EINVAL;219219- } else if ((num_init_writes / sizeof(*raw)) > SDCA_MAX_INIT_COUNT) {220220- dev_err(dev, "%pfwP: maximum init table size exceeded\n", function_node);221221- return -EINVAL;222219 }223220224221 raw = kzalloc(num_init_writes, GFP_KERNEL);···16011604static struct sdca_entity *find_sdca_entity_by_label(struct sdca_function_data *function,16021605 const char *entity_label)16031606{16071607+ struct sdca_entity *entity = NULL;16041608 int i;1605160916061610 for (i = 0; i < function->num_entities; i++) {16071607- struct sdca_entity *entity = &function->entities[i];16111611+ entity = &function->entities[i];16121612+16131613+ /* check whole string first*/16141614+ if (!strcmp(entity->label, entity_label))16151615+ return entity;16161616+ }16171617+16181618+ for (i = 0; i < function->num_entities; i++) {16191619+ entity = &function->entities[i];1608162016091621 if (!strncmp(entity->label, entity_label, strlen(entity_label)))16101622 return entity;
+1-1
sound/soc/sof/ipc4-topology.c
···29512951 return -EINVAL;29522952 }2953295329542954- if (scontrol->priv_size < sizeof(struct sof_abi_hdr)) {29542954+ if (scontrol->priv_size && scontrol->priv_size < sizeof(struct sof_abi_hdr)) {29552955 dev_err(sdev->dev,29562956 "bytes control %s initial data size %zu is insufficient.\n",29572957 scontrol->name, scontrol->priv_size);
+1
sound/usb/Kconfig
···192192 tristate "Qualcomm Audio Offload driver"193193 depends on QCOM_QMI_HELPERS && SND_USB_AUDIO && SND_SOC_USB194194 depends on USB_XHCI_HCD && USB_XHCI_SIDEBAND195195+ select AUXILIARY_BUS195196 help196197 Say Y here to enable the Qualcomm USB audio offloading feature.197198
+1-1
sound/usb/qcom/qc_audio_offload.c
···11// SPDX-License-Identifier: GPL-2.022/*33- * Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights reserved.33+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.44 */5566#include <linux/auxiliary_bus.h>
···3232/**3333 * BUILD_BUG_ON_MSG - break compile if a condition is true & emit supplied3434 * error message.3535- * @condition: the condition which the compiler should know is false.3535+ * @cond: the condition which the compiler should know is false.3636+ * @msg: build-time error message3637 *3738 * See BUILD_BUG_ON for description.3839 */···61606261/**6362 * static_assert - check integer constant expression at build time6363+ * @expr: expression to be checked6464 *6565 * static_assert() is a wrapper for the C11 _Static_assert, with a6666 * little macro magic to make the message optional (defaulting to the
···11+#!/bin/bash22+# SPDX-License-Identifier: GPL-2.033+# shellcheck disable=SC215444+#55+# Reproduce the non-Ethernet header_ops confusion scenario with:66+# g0 (gre) -> b0 (bond) -> t0 (team)77+#88+# Before the fix, direct header_ops inheritance in this stack could call99+# callbacks with the wrong net_device context and crash.1010+1111+lib_dir=$(dirname "$0")1212+source "$lib_dir"/../../../net/lib.sh1313+1414+trap cleanup_all_ns EXIT1515+1616+setup_ns ns11717+1818+ip -n "$ns1" link add d0 type dummy1919+ip -n "$ns1" addr add 10.10.10.1/24 dev d02020+ip -n "$ns1" link set d0 up2121+2222+ip -n "$ns1" link add g0 type gre local 10.10.10.12323+ip -n "$ns1" link add b0 type bond mode active-backup2424+ip -n "$ns1" link add t0 type team2525+2626+ip -n "$ns1" link set g0 master b02727+ip -n "$ns1" link set b0 master t02828+2929+ip -n "$ns1" link set g0 up3030+ip -n "$ns1" link set b0 up3131+ip -n "$ns1" link set t0 up3232+3333+# IPv6 address assignment triggers MLD join reports that call3434+# dev_hard_header() on t0, exercising the inherited header_ops path.3535+ip -n "$ns1" -6 addr add 2001:db8:1::1/64 dev t0 nodad3636+for i in $(seq 1 20); do3737+ ip netns exec "$ns1" ping -6 -I t0 ff02::1 -c1 -W1 &>/dev/null || true3838+done3939+4040+echo "PASS: non-Ethernet header_ops stacking did not crash"4141+exit "$EXIT_STATUS"
···66 */7788#define _GNU_SOURCE99-#include <pthread.h>1010-#include <sys/prctl.h>119#include <linux/landlock.h>1010+#include <pthread.h>1111+#include <signal.h>1212+#include <sys/prctl.h>12131314#include "common.h"1415···155154 /* Expect that both succeeded. */156155 EXPECT_EQ(0, d[0].result);157156 EXPECT_EQ(0, d[1].result);157157+158158+ EXPECT_EQ(0, close(ruleset_fd));159159+}160160+161161+static void signal_nop_handler(int sig)162162+{163163+}164164+165165+struct signaler_data {166166+ pthread_t target;167167+ volatile bool stop;168168+};169169+170170+static void *signaler_thread(void *data)171171+{172172+ struct signaler_data *sd = data;173173+174174+ while (!sd->stop)175175+ pthread_kill(sd->target, SIGUSR1);176176+177177+ return NULL;178178+}179179+180180+/*181181+ * Number of idle sibling threads. This must be large enough that even on182182+ * machines with many cores, the sibling threads cannot all complete their183183+ * credential preparation in a single parallel wave, otherwise the signaler184184+ * thread has no window to interrupt wait_for_completion_interruptible().185185+ * 200 threads on a 64-core machine yields ~3 serialized waves, giving the186186+ * tight signal loop enough time to land an interruption.187187+ */188188+#define NUM_IDLE_THREADS 200189189+190190+/*191191+ * Exercises the tsync interruption and cancellation paths in tsync.c.192192+ *193193+ * When a signal interrupts the calling thread while it waits for sibling194194+ * threads to finish their credential preparation195195+ * (wait_for_completion_interruptible in landlock_restrict_sibling_threads),196196+ * the kernel sets ERESTARTNOINTR, cancels queued task works that have not197197+ * started yet (cancel_tsync_works), then waits for the remaining works to198198+ * finish. On the error return, syscalls.c aborts the prepared credentials.199199+ * The kernel automatically restarts the syscall, so userspace sees success.200200+ */201201+TEST(tsync_interrupt)202202+{203203+ size_t i;204204+ pthread_t threads[NUM_IDLE_THREADS];205205+ pthread_t signaler;206206+ struct signaler_data sd;207207+ struct sigaction sa = {};208208+ const int ruleset_fd = create_ruleset(_metadata);209209+210210+ disable_caps(_metadata);211211+212212+ /* Install a no-op SIGUSR1 handler so the signal does not kill us. */213213+ sa.sa_handler = signal_nop_handler;214214+ sigemptyset(&sa.sa_mask);215215+ ASSERT_EQ(0, sigaction(SIGUSR1, &sa, NULL));216216+217217+ ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0));218218+219219+ for (i = 0; i < NUM_IDLE_THREADS; i++)220220+ ASSERT_EQ(0, pthread_create(&threads[i], NULL, idle, NULL));221221+222222+ /*223223+ * Start a signaler thread that continuously sends SIGUSR1 to the224224+ * calling thread. This maximizes the chance of interrupting225225+ * wait_for_completion_interruptible() in the kernel's tsync path.226226+ */227227+ sd.target = pthread_self();228228+ sd.stop = false;229229+ ASSERT_EQ(0, pthread_create(&signaler, NULL, signaler_thread, &sd));230230+231231+ /*232232+ * The syscall may be interrupted and transparently restarted by the233233+ * kernel (ERESTARTNOINTR). From userspace, it should always succeed.234234+ */235235+ EXPECT_EQ(0, landlock_restrict_self(ruleset_fd,236236+ LANDLOCK_RESTRICT_SELF_TSYNC));237237+238238+ sd.stop = true;239239+ ASSERT_EQ(0, pthread_join(signaler, NULL));240240+241241+ for (i = 0; i < NUM_IDLE_THREADS; i++) {242242+ ASSERT_EQ(0, pthread_cancel(threads[i]));243243+ ASSERT_EQ(0, pthread_join(threads[i], NULL));244244+ }158245159246 EXPECT_EQ(0, close(ruleset_fd));160247}
···868868 check_rt_num 5 $($IP -6 route list |grep -v expires|grep 2001:20::|wc -l)869869 log_test $ret 0 "ipv6 route garbage collection (replace with permanent)"870870871871+ # Delete dummy_10 and remove all routes872872+ $IP link del dev dummy_10873873+874874+ # rd6 is required for the next test. (ipv6toolkit)875875+ if [ ! -x "$(command -v rd6)" ]; then876876+ echo "SKIP: rd6 not found."877877+ set +e878878+ cleanup &> /dev/null879879+ return880880+ fi881881+882882+ setup_ns ns2883883+ $IP link add veth1 type veth peer veth2 netns $ns2884884+ $IP link set veth1 up885885+ ip -netns $ns2 link set veth2 up886886+ $IP addr add fe80:dead::1/64 dev veth1887887+ ip -netns $ns2 addr add fe80:dead::2/64 dev veth2888888+889889+ # Add NTF_ROUTER neighbour to prevent rt6_age_examine_exception()890890+ # from removing not-yet-expired exceptions.891891+ ip -netns $ns2 link set veth2 address 00:11:22:33:44:55892892+ $IP neigh add fe80:dead::3 lladdr 00:11:22:33:44:55 dev veth1 router893893+894894+ $NS_EXEC sysctl -wq net.ipv6.conf.veth1.accept_redirects=1895895+ $NS_EXEC sysctl -wq net.ipv6.conf.veth1.forwarding=0896896+897897+ # Temporary routes898898+ for i in $(seq 1 5); do899899+ # Expire route after $EXPIRE seconds900900+ $IP -6 route add 2001:10::$i \901901+ via fe80:dead::2 dev veth1 expires $EXPIRE902902+903903+ ip netns exec $ns2 rd6 -i veth2 \904904+ -s fe80:dead::2 -d fe80:dead::1 \905905+ -r 2001:10::$i -t fe80:dead::3 -p ICMP6906906+ done907907+908908+ check_rt_num 5 $($IP -6 route list | grep expires | grep 2001:10:: | wc -l)909909+910910+ # Promote to permanent routes by "prepend" (w/o NLM_F_EXCL and NLM_F_REPLACE)911911+ for i in $(seq 1 5); do912912+ # -EEXIST, but the temporary route becomes the permanent route.913913+ $IP -6 route append 2001:10::$i \914914+ via fe80:dead::2 dev veth1 2>/dev/null || true915915+ done916916+917917+ check_rt_num 5 $($IP -6 route list | grep -v expires | grep 2001:10:: | wc -l)918918+ check_rt_num 5 $($IP -6 route list cache | grep 2001:10:: | wc -l)919919+920920+ # Trigger GC instead of waiting $GC_WAIT_TIME.921921+ # rt6_nh_dump_exceptions() just skips expired exceptions.922922+ $NS_EXEC sysctl -wq net.ipv6.route.flush=1923923+ check_rt_num 0 $($IP -6 route list cache | grep 2001:10:: | wc -l)924924+ log_test $ret 0 "ipv6 route garbage collection (promote to permanent routes)"925925+926926+ $IP neigh del fe80:dead::3 lladdr 00:11:22:33:44:55 dev veth1 router927927+ $IP link del veth1928928+871929 # ra6 is required for the next test. (ipv6toolkit)872930 if [ ! -x "$(command -v ra6)" ]; then873931 echo "SKIP: ra6 not found."···933875 cleanup &> /dev/null934876 return935877 fi936936-937937- # Delete dummy_10 and remove all routes938938- $IP link del dev dummy_10939878940879 # Create a pair of veth devices to send a RA message from one941880 # device to another.