6.6.3-rc1 review
Subsystems (8)
Greg Kroah-Hartman
maintainerPATCH 377/530 s390/cmma: fix initial kernel address space page table walk
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit 16ba44826a04834d3eeeda4b731c2ea3481062b7 upstream.
If the cmma no-dat feature is available the kernel page tables are walked to identify and mark all pages which are used for address translation (all region, segment, and page tables). In a subsequent loop all other pages are marked as "no-dat" pages with the ESSA instruction.
This information is visible to the hypervisor, so that the hypervisor can optimize purging of guest TLB entries. The initial loop however does not cover the complete kernel address space. This can result in pages being marked as not being used for dynamic address translation, even though they are. In turn guest TLB entries incorrectly may not be purged.
Fix this by adjusting the end address of the kernel address range being walked.
--- arch/s390/mm/page-states.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
arch/s390/mm/page-states.c +10 -3
@@ -151,15 +151,22 @@ static void mark_kernel_p4d(pgd_t *pgd,static void mark_kernel_pgd (void ) { -unsigned long addr, next; +unsigned long addr, next, max_addr;struct page *page;pgd_t *pgd;int i; addr =0 ; +/* +* Figure out maximum virtual address accessible with the +* kernel ASCE. This is required to keep the page table walker +* from accessing non-existent entries. +*/ + max_addr = (S390_lowcore.kernel_asce.val & _ASCE_TYPE_MASK) >>2 ; + max_addr =1UL << (max_addr *11 +31 ); pgd =pgd_offset_k (addr); do { - next = pgd_addr_end(addr, MODULES_END); + next = pgd_addr_end(addr, max_addr); if (pgd_none(*pgd)) continue; if (!pgd_folded(*pgd)) {
@@ -168,7 +175,7 @@ static void mark_kernel_pgd(void)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_p4d (pgd, addr, next); - }while (pgd++, addr = next, addr !=MODULES_END ); + }while (pgd++, addr = next, addr != max_addr); }void __init cmma_init_nodat (void )
Greg Kroah-Hartman
maintainerPATCH 378/530 s390/cmma: fix detection of DAT pages
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit 44d93045247661acbd50b1629e62f415f2747577 upstream.
If the cmma no-dat feature is available the kernel page tables are walked to identify and mark all pages which are used for address translation (all region, segment, and page tables). In a subsequent loop all other pages are marked as "no-dat" pages with the ESSA instruction.
This information is visible to the hypervisor, so that the hypervisor can optimize purging of guest TLB entries. The initial loop however is
incorrect: only the first three of the four pages which belong to segment and region tables will be marked as being used for DAT. The last page is incorrectly marked as no-dat.
This can result in incorrect guest TLB flushes.
Fix this by simply marking all four pages.
--- arch/s390/mm/page-states.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/s390/mm/page-states.c +3 -3
@@ -121,7 +121,7 @@ static void mark_kernel_pud(p4d_t *p4d,continue ;if (!pud_folded (*pud)) { page =phys_to_page (pud_val (*pud)); -for (i =0 ; i <3 ; i++) +for (i =0 ; i <4 ; i++)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_pmd (pud, addr, next);
@@ -142,7 +142,7 @@ static void mark_kernel_p4d(pgd_t *pgd,continue ;if (!p4d_folded (*p4d)) { page =phys_to_page (p4d_val (*p4d)); -for (i =0 ; i <3 ; i++) +for (i =0 ; i <4 ; i++)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_pud (p4d, addr, next);
@@ -171,7 +171,7 @@ static void mark_kernel_pgd(void)continue ;if (!pgd_folded (*pgd)) { page =phys_to_page (pgd_val (*pgd)); -for (i =0 ; i <3 ; i++) +for (i =0 ; i <4 ; i++)set_bit (PG_arch_1, &page[i].flags); }mark_kernel_p4d (pgd, addr, next);
Greg Kroah-Hartman
maintainerPATCH 379/530 s390/cmma: fix handling of swapper_pg_dir and invalid_pg_dir
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
commit 84bb41d5df48868055d159d9247b80927f1f70f9 upstream.
If the cmma no-dat feature is available the kernel page tables are walked to identify and mark all pages which are used for address translation (all region, segment, and page tables). In a subsequent loop all other pages are marked as "no-dat" pages with the ESSA instruction.
This information is visible to the hypervisor, so that the hypervisor can optimize purging of guest TLB entries. All pages used for swapper_pg_dir and invalid_pg_dir are incorrectly marked as no-dat, which in turn can result in incorrect guest TLB flushes.
Fix this by marking those pages correctly as being used for DAT.
--- arch/s390/mm/page-states.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/s390/mm/page-states.c +6 -0
@@ -188,6 +188,12 @@ void __init cmma_init_nodat(void)return ;/* Mark pages used in kernel page tables */ mark_kernel_pgd (); + page =virt_to_page (&swapper_pg_dir); +for (i =0 ; i <4 ; i++) +set_bit (PG_arch_1, &page[i].flags); + page =virt_to_page (&invalid_pg_dir); +for (i =0 ; i <4 ; i++) +set_bit (PG_arch_1, &page[i].flags);/* Set all kernel pages not used for page tables to stable/no-dat */ for_each_mem_pfn_range (i,MAX_NUMNODES , &start, &end,NULL ) {
Greg Kroah-Hartman
maintainerPATCH 380/530 mm/cma: use nth_page() in place of direct struct page manipulation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zi Yan <[email protected]>
commit 2e7cfe5cd5b6b0b98abf57a3074885979e187c1c upstream.
Patch series "Use nth_page() in place of direct struct page manipulation", v3.
On SPARSEMEM without VMEMMAP, struct page is not guaranteed to be contiguous, since each memory section's memmap might be allocated independently. hugetlb pages can go beyond a memory section size, thus direct struct page manipulation on hugetlb pages/subpages might give wrong struct page. Kernel provides nth_page() to do the manipulation properly. Use that whenever code can see hugetlb pages.
This patch (of 5):
When dealing with hugetlb pages, manipulating struct page pointers directly can get to wrong struct page, since struct page is not guaranteed to be contiguous on SPARSEMEM without VMEMMAP. Use nth_page() to handle it properly.
Without the fix, page_kasan_tag_reset() could reset wrong page tags, causing a wrong kasan result. No related bug is reported. The fix comes from code inspection.
--- mm/cma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/cma.c +1 -1
@@ -505,7 +505,7 @@ struct page *cma_alloc(struct cma *cma,*/ if (page) {for (i =0 ; i < count; i++) -page_kasan_tag_reset (page + i); +page_kasan_tag_reset (nth_page (page, i)); }if (ret && !no_warn) {
Greg Kroah-Hartman
maintainerPATCH 381/530 mm/hugetlb: use nth_page() in place of direct struct page manipulation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zi Yan <[email protected]>
commit 426056efe835cf4864ccf4c328fe3af9146fc539 upstream.
When dealing with hugetlb pages, manipulating struct page pointers directly can get to wrong struct page, since struct page is not guaranteed to be contiguous on SPARSEMEM without VMEMMAP. Use nth_page() to handle it properly.
A wrong or non-existing page might be tried to be grabbed, either leading to a non freeable page or kernel memory access errors. No bug is reported. It comes from code inspection.
--- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/hugetlb.c +1 -1
@@ -6520,7 +6520,7 @@ struct page *hugetlb_follow_page_mask(st } } - page += ((address & ~huge_page_mask (h)) >>PAGE_SHIFT ); + page =nth_page (page, ((address & ~huge_page_mask (h)) >>PAGE_SHIFT ));/* * Note that page may be a sub-page, and with vmemmap
Greg Kroah-Hartman
maintainerPATCH 382/530 mm/memory_hotplug: use pfn math in place of direct struct page manipulation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zi Yan <[email protected]>
commit 1640a0ef80f6d572725f5b0330038c18e98ea168 upstream.
When dealing with hugetlb pages, manipulating struct page pointers directly can get to wrong struct page, since struct page is not guaranteed to be contiguous on SPARSEMEM without VMEMMAP. Use pfn calculation to handle it properly.
Without the fix, a wrong number of page might be skipped. Since skip cannot be negative, scan_movable_page() will end early and might miss a movable page with -ENOENT. This might fail offline_pages(). No bug is reported. The fix comes from code inspection.
--- mm/memory_hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory_hotplug.c +1 -1
@@ -1689,7 +1689,7 @@ static int scan_movable_pages(unsigned l*/ if (HPageMigratable (head)) goto found; - skip =compound_nr (head) - (page - head); + skip =compound_nr (head) - (pfn -page_to_pfn (head)); pfn += skip -1 ; }return -ENOENT ;
Greg Kroah-Hartman
maintainerPATCH 383/530 mm: make PR_MDWE_REFUSE_EXEC_GAIN an unsigned long
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florent Revest <[email protected]>
commit 0da668333fb07805c2836d5d50e26eda915b24a1 upstream.
Defining a prctl flag as an int is a footgun because on a 64 bit machine and with a variadic implementation of prctl (like in musl and glibc), when used directly as a prctl argument, it can get casted to long with garbage upper bits which would result in unexpected behaviors.
This patch changes the constant to an unsigned long to eliminate that possibilities. This does not break UAPI.
I think that a stable backport would be "nice to have": to reduce the chances that users build binaries that could end up with garbage bits in their MDWE prctl arguments. We are not aware of anyone having yet encountered this corner case with MDWE prctls but a backport would reduce the likelihood it happens, since this sort of issues has happened with other prctls. But If this is perceived as a backporting burden, I suppose we could also live without a stable backport.
--- include/uapi/linux/prctl.h | 2 +- tools/include/uapi/linux/prctl.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
include/uapi/linux/prctl.h +1 -1
@@ -283,7 +283,7 @@ struct prctl_mm_map {/* Memory deny write / execute */ #define PR_SET_MDWE 65 -# define PR_MDWE_REFUSE_EXEC_GAIN 1 +# define PR_MDWE_REFUSE_EXEC_GAIN (1UL << 0)#define PR_GET_MDWE 66
tools/include/uapi/linux/prctl.h +1 -1
@@ -283,7 +283,7 @@ struct prctl_mm_map {/* Memory deny write / execute */ #define PR_SET_MDWE 65 -# define PR_MDWE_REFUSE_EXEC_GAIN 1 +# define PR_MDWE_REFUSE_EXEC_GAIN (1UL << 0)#define PR_GET_MDWE 66
Greg Kroah-Hartman
maintainerPATCH 374/530 dmaengine: stm32-mdma: correct desc prep when channel running
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alain Volmat <[email protected]>
commit 03f25d53b145bc2f7ccc82fc04e4482ed734f524 upstream.
In case of the prep descriptor while the channel is already running, the CCR register value stored into the channel could already have its EN bit set. This would lead to a bad transfer since, at start transfer time, enabling the channel while other registers aren't yet properly set. To avoid this, ensure to mask the CCR_EN bit when storing the ccr value into the mdma channel structure.
--- drivers/dma/stm32-mdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/stm32-mdma.c +2 -2
@@ -489,7 +489,7 @@ static int stm32_mdma_set_xfer_param(str src_maxburst = chan->dma_config.src_maxburst; dst_maxburst = chan->dma_config.dst_maxburst; - ccr =stm32_mdma_read (dmadev,STM32_MDMA_CCR (chan->id)); + ccr =stm32_mdma_read (dmadev,STM32_MDMA_CCR (chan->id)) & ~STM32_MDMA_CCR_EN ; ctcr =stm32_mdma_read (dmadev,STM32_MDMA_CTCR (chan->id)); ctbr =stm32_mdma_read (dmadev,STM32_MDMA_CTBR (chan->id));
@@ -965,7 +965,7 @@ stm32_mdma_prep_dma_memcpy(struct dma_chif (!desc)return NULL ; - ccr =stm32_mdma_read (dmadev,STM32_MDMA_CCR (chan->id)); + ccr =stm32_mdma_read (dmadev,STM32_MDMA_CCR (chan->id)) & ~STM32_MDMA_CCR_EN ; ctcr =stm32_mdma_read (dmadev,STM32_MDMA_CTCR (chan->id)); ctbr =stm32_mdma_read (dmadev,STM32_MDMA_CTBR (chan->id)); cbndtr =stm32_mdma_read (dmadev,STM32_MDMA_CBNDTR (chan->id));
Greg Kroah-Hartman
maintainerPATCH 402/530 apparmor: Fix regression in mount mediation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Johansen <[email protected]>
[ Upstream commit 157a3537d6bc28ceb9a11fc8cb67f2152d860146 ]
commit 2db154b3ea8e ("vfs: syscall: Add move_mount(2) to move mounts around")
introduced a new move_mount(2) system call and a corresponding new LSM security_move_mount hook but did not implement this hook for any existing LSM. This creates a regression for AppArmor mediation of mount. This patch provides a base mapping of the move_mount syscall to the existing mount mediation. In the future we may introduce additional mediations around the new mount calls.
--- security/apparmor/include/mount.h | 7 +++-- security/apparmor/lsm.c | 20 ++++++++++++-- security/apparmor/mount.c | 46 +++++++++++++++++++------------ 3 files changed, 51 insertions(+), 22 deletions(-)
security/apparmor/include/mount.h +5 -2
@@ -38,9 +38,12 @@ int aa_mount_change_type(const struct cred *subj_cred, struct aa_label *label, const struct path *path, unsigned long flags); +int aa_move_mount_old (const struct cred *subj_cred, +struct aa_label *label,const struct path *path, +const char *old_name);int aa_move_mount (const struct cred *subj_cred, -struct aa_label *label,const struct path *path, -const char *old_name); +struct aa_label *label,const struct path *from_path, +const struct path *to_path); int aa_new_mount(const struct cred *subj_cred, struct aa_label *label, const char *dev_name,
security/apparmor/lsm.c +18 -2
@@ -607,8 +607,8 @@ static int apparmor_sb_mount(const char *dev_name, const struct path *path, error =aa_mount_change_type (current_cred (), label, path, flags); else if (flags & MS_MOVE) - error =aa_move_mount (current_cred (), label, path, - dev_name); + error =aa_move_mount_old (current_cred (), label, path, + dev_name); else error =aa_new_mount (current_cred (), label, dev_name, path, type, flags, data);
@@ -618,6 +618,21 @@ static int apparmor_sb_mount(const char *dev_name, const struct path *path,return error; } +static int apparmor_move_mount (const struct path *from_path, +const struct path *to_path) +{ +struct aa_label *label; +int error =0 ; + + label =__begin_current_label_crit_section (); +if (!unconfined (label)) + error =aa_move_mount (current_cred (), label, from_path, + to_path); +__end_current_label_crit_section (label); + +return error; +} +static int apparmor_sb_umount (struct vfsmount *mnt,int flags) {struct aa_label *label;
@@ -1240,6 +1255,7 @@ static struct security_hook_list apparmor_hooks[] __ro_after_init = {LSM_HOOK_INIT (capget, apparmor_capget),LSM_HOOK_INIT (capable, apparmor_capable), +LSM_HOOK_INIT (move_mount, apparmor_move_mount),LSM_HOOK_INIT (sb_mount, apparmor_sb_mount),LSM_HOOK_INIT (sb_umount, apparmor_sb_umount), LSM_HOOK_INIT(sb_pivotroot, apparmor_sb_pivotroot),
security/apparmor/mount.c +28 -18
64 lines not on this page · raw message
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 411/530 selftests/resctrl: Extend signal handler coverage to unmount on receiving signal
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit 3aff5146445582454c35900f3c0c972987cdd595 ]
Unmounting resctrl FS has been moved into the per test functions in resctrl_tests.c by commit caddc0fbe495 ("selftests/resctrl: Move resctrl FS mount/umount to higher level"). In case a signal (SIGINT, SIGTERM, or SIGHUP) is received, the running selftest is aborted by ctrlc_handler() which then unmounts resctrl fs before exiting. The current section between signal_handler_register() and signal_handler_unregister(), however, does not cover the entire duration when resctrl FS is mounted.
Move signal_handler_register() and signal_handler_unregister() calls from per test files into resctrl_tests.c to properly unmount resctrl fs. In order to not add signal_handler_register()/unregister() n times, create helpers test_prepare() and test_cleanup().
Do not call ksft_exit_fail_msg() in test_prepare() but only in the per test function to keep the control flow cleaner without adding calls to exit() deep into the call chain.
Adjust child process kill() call in ctrlc_handler() to only be invoked if the child was already forked.
--- tools/testing/selftests/resctrl/cat_test.c | 8 --- .../testing/selftests/resctrl/resctrl_tests.c | 69 ++++++++++++------- tools/testing/selftests/resctrl/resctrl_val.c | 22 +++--- 3 files changed, 55 insertions(+), 44 deletions(-)
tools/testing/selftests/resctrl/cat_test.c +0 -8
@@ -167,12 +167,6 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)strcpy (param.filename,RESULT_FILE_NAME1 ); param.num_of_runs =0 ; param.cpu_no = sibling_cpu_no; - }else { - ret =signal_handler_register (); -if (ret) { -kill (bm_pid,SIGKILL ); - goto out; - } }remove (param.filename);
@@ -209,10 +203,8 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) }close (pipefd[0 ]);kill (bm_pid,SIGKILL ); -signal_handler_unregister (); } -out:cat_test_cleanup ();return ret;
tools/testing/selftests/resctrl/resctrl_tests.c +45 -24
144 lines not on this page · raw message
tools/testing/selftests/resctrl/resctrl_val.c +10 -12
@@ -468,7 +468,9 @@ pid_t bm_pid, ppid;void ctrlc_handler (int signum,siginfo_t *info,void *ptr) { -kill (bm_pid,SIGKILL ); +/* Only kill child after bm_pid is set after fork() */ +if (bm_pid) +kill (bm_pid,SIGKILL );umount_resctrlfs ();tests_cleanup ();ksft_print_msg ("Ending\n\n" );
@@ -485,6 +487,8 @@ int signal_handler_register(void)struct sigaction sigact = {};int ret =0 ; + bm_pid =0 ; + sigact.sa_sigaction = ctrlc_handler;sigemptyset (&sigact.sa_mask); sigact.sa_flags =SA_SIGINFO ;
@@ -706,10 +710,6 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *parksft_print_msg ("Benchmark PID: %d\n" , bm_pid); - ret =signal_handler_register (); -if (ret) - goto out; -/* * The cast removes constness but nothing mutates benchmark_cmd within * the context of this process. At the receiving process, it becomes
@@ -721,19 +721,19 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *par/* Taskset benchmark to specified cpu */ ret =taskset_benchmark (bm_pid, param->cpu_no);if (ret) - goto unregister; + goto out;/* Write benchmark to specified control&monitoring grp in resctrl FS */ ret =write_bm_pid_to_resctrl (bm_pid, param->ctrlgrp, param->mongrp, resctrl_val);if (ret) - goto unregister; + goto out;if (!strncmp (resctrl_val,MBM_STR ,sizeof (MBM_STR )) || !strncmp (resctrl_val,MBA_STR ,sizeof (MBA_STR ))) { ret =initialize_mem_bw_imc ();if (ret) - goto unregister; + goto out;initialize_mem_bw_resctrl (param->ctrlgrp, param->mongrp, param->cpu_no, resctrl_val);
@@ -748,7 +748,7 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *par sizeof(pipe_message)) {perror ("# failed reading message from child process" );close (pipefd[0 ]); - goto unregister; + goto out; } }close (pipefd[0 ]);
@@ -757,7 +757,7 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *parif (sigqueue (bm_pid,SIGUSR1 , value) ==-1 ) {perror ("# sigqueue SIGUSR1 to child" ); ret = errno; - goto unregister; + goto out; }/* Give benchmark enough time to fully run */
@@ -786,8 +786,6 @@ int resctrl_val(const char * const *benchmark_cmd, struct resctrl_val_param *par } } -unregister: -signal_handler_unregister (); out:kill (bm_pid,SIGKILL );
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 412/530 parisc: Prevent booting 64-bit kernels on PA1.x machines
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit a406b8b424fa01f244c1aab02ba186258448c36b upstream.
Bail out early with error message when trying to boot a 64-bit kernel on 32-bit machines. This fixes the previous commit to include the check for true 64-bit kernels as well.
--- arch/parisc/kernel/head.S | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
arch/parisc/kernel/head.S +2 -3
@@ -70,9 +70,8 @@ $bss_loop: stw,ma %arg2,4(%r1) stw,ma %arg3,4(%r1) -#if !defined(CONFIG_64BIT) && defined(CONFIG_PA20) - /* This 32-bit kernel was compiled for PA2.0 CPUs. Check current CPU - * and halt kernel if we detect a PA1.x CPU. */ +#if defined(CONFIG_PA20) + /* check for 64-bit capable CPU as required by current kernel */ ldi 32,%r10 mtctl %r10,%cr11 .level 2.0
Greg Kroah-Hartman
maintainerPATCH 413/530 parisc/pgtable: Do not drop upper 5 address bits of physical address
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 166b0110d1ee53290bd11618df6e3991c117495a upstream.
When calculating the pfn for the iitlbt/idtlbt instruction, do not drop the upper 5 address bits. This doesn't seem to have an effect on physical hardware which uses less physical address bits, but in qemu the missing bits are visible.
--- arch/parisc/kernel/entry.S | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
arch/parisc/kernel/entry.S +3 -4
@@ -475,13 +475,13 @@ * to a CPU TLB 4k PFN (4k => 12 bits to shift) */ #define PAGE_ADD_SHIFT (PAGE_SHIFT-12) #define PAGE_ADD_HUGE_SHIFT (REAL_HPAGE_SHIFT-12) + #define PFN_START_BIT (63-ASM_PFN_PTE_SHIFT+(63-58)-PAGE_ADD_SHIFT) /* Drop prot bits and convert to page addr for iitlbt and idtlbt */ .macro convert_for_tlb_insert20 pte,tmp #ifdef CONFIG_HUGETLB_PAGE copy \pte,\tmp - extrd,u \tmp,(63-ASM_PFN_PTE_SHIFT)+(63-58)+PAGE_ADD_SHIFT,\ - 64-PAGE_SHIFT-PAGE_ADD_SHIFT,\pte + extrd,u \tmp,PFN_START_BIT,PFN_START_BIT+1,\pte depdi _PAGE_SIZE_ENCODING_DEFAULT,63,\ (63-58)+PAGE_ADD_SHIFT,\pte
@@ -489,8 +489,7 @@ depdi _HUGE_PAGE_SIZE_ENCODING_DEFAULT,63,\ (63-58)+PAGE_ADD_HUGE_SHIFT,\pte #else /* Huge pages disabled */ - extrd,u \pte,(63-ASM_PFN_PTE_SHIFT)+(63-58)+PAGE_ADD_SHIFT,\ - 64-PAGE_SHIFT-PAGE_ADD_SHIFT,\pte + extrd,u \pte,PFN_START_BIT,PFN_START_BIT+1,\pte depdi _PAGE_SIZE_ENCODING_DEFAULT,63,\ (63-58)+PAGE_ADD_SHIFT,\pte #endif
Greg Kroah-Hartman
maintainerPATCH 414/530 parisc/power: Fix power soft-off when running on qemu
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 6ad6e15a9c46b8f0932cd99724f26f3db4db1cdf upstream.
Firmware returns the physical address of the power switch, so need to use gsc_writel() instead of direct memory access.
--- drivers/parisc/power.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/parisc/power.c +1 -1
@@ -201,7 +201,7 @@ static struct notifier_block parisc_panistatic int qemu_power_off (struct sys_off_data *data) {/* this turns the system off via SeaBIOS */ - *(int *)data->cb_data =0 ; +gsc_writel (0 , (unsigned long ) data->cb_data);pdc_soft_power_button (1 );return NOTIFY_DONE ; }
Greg Kroah-Hartman
maintainerPATCH 415/530 parisc: fix mmap_base calculation when stack grows upwards
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Helge Deller <[email protected]>
commit 5f74f820f6fc844b95f9e5e406e0a07d97510420 upstream.
Matoro reported various userspace crashes on the parisc platform with kernel 6.6 and bisected it to commit 3033cd430768 ("parisc: Use generic mmap top-down layout and brk randomization").
That commit switched parisc to use the common infrastructure to calculate mmap_base, but missed that the mmap_base() function takes care for architectures where the stack grows downwards only.
Fix the mmap_base() calculation to include the stack-grows-upwards case and thus fix the userspace crashes on parisc.
--- arch/parisc/Kconfig | 6 +++--- arch/parisc/include/asm/elf.h | 10 +--------- arch/parisc/include/asm/processor.h | 2 ++ arch/parisc/kernel/sys_parisc.c | 2 +- mm/util.c | 10 ++++++++++ 5 files changed, 17 insertions(+), 13 deletions(-)
arch/parisc/Kconfig +3 -3
@@ -138,11 +138,11 @@ config ARCH_MMAP_RND_COMPAT_BITS_MIN default 8 config ARCH_MMAP_RND_BITS_MAX - default 24 if 64BIT - default 17 + default 18 if 64BIT + default 13 config ARCH_MMAP_RND_COMPAT_BITS_MAX - default 17 + default 13 # unless you want to implement ACPI on PA-RISC ... ;-) config PM
arch/parisc/include/asm/elf.h +1 -9
@@ -349,15 +349,7 @@ struct pt_regs; /* forward declaration..#define ELF_HWCAP 0 -/* Masks for stack and mmap randomization */ -#define BRK_RND_MASK (is_32bit_task() ? 0x07ffUL : 0x3ffffUL) -#define MMAP_RND_MASK (is_32bit_task() ? 0x1fffUL : 0x3ffffUL) -#define STACK_RND_MASK MMAP_RND_MASK - -struct mm_struct ; -extern unsigned long arch_randomize_brk (struct mm_struct *); -#define arch_randomize_brk arch_randomize_brk - +#define STACK_RND_MASK 0x7ff/* 8MB of VA */ #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1struct linux_binprm ;
arch/parisc/include/asm/processor.h +2 -0
@@ -47,6 +47,8 @@#ifndef __ASSEMBLY__ +struct rlimit ; +unsigned long mmap_upper_limit (struct rlimit *rlim_stack);unsigned long calc_max_stack_size (unsigned long stack_max);/*
arch/parisc/kernel/sys_parisc.c +1 -1
@@ -77,7 +77,7 @@ unsigned long calc_max_stack_size(unsign* indicating that "current" should be used instead of a passed-in * value from the exec bprm as done with arch_pick_mmap_layout(). */ -static unsigned long mmap_upper_limit (struct rlimit *rlim_stack) +unsigned long mmap_upper_limit (struct rlimit *rlim_stack) {unsigned long stack_base;
mm/util.c +10 -0
@@ -414,6 +414,15 @@ static int mmap_is_legacy(struct rlimitstatic unsigned long mmap_base (unsigned long rnd,struct rlimit *rlim_stack) { +#ifdef CONFIG_STACK_GROWSUP +/* +* For an upwards growing stack the calculation is much simpler. +* Memory for the maximum stack size is reserved at the top of the +* task. mmap_base starts directly below the stack and grows +* downwards. +*/ +return PAGE_ALIGN_DOWN (mmap_upper_limit (rlim_stack) - rnd); +#else unsigned long gap = rlim_stack->rlim_cur;unsigned long pad = stack_guard_gap;
@@ -431,6 +440,7 @@ static unsigned long mmap_base(unsigned gap =MAX_GAP ;return PAGE_ALIGN (STACK_TOP - gap - rnd); +#endif }void arch_pick_mmap_layout (struct mm_struct *mm,struct rlimit *rlim_stack)
Greg Kroah-Hartman
maintainerPATCH 416/530 xhci: Enable RPM on controllers that support low-power states
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Basavaraj Natikar <[email protected]>
commit a5d6264b638efeca35eff72177fd28d149e0764b upstream.
Use the low-power states of the underlying platform to enable runtime PM. If the platform doesn't support runtime D3, then enabling default RPM will result in the controller malfunctioning, as in the case of hotplug devices not being detected because of a failed interrupt generation.
--- drivers/usb/host/xhci-pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/host/xhci-pci.c +3 -1
@@ -695,7 +695,9 @@ static int xhci_pci_probe(struct pci_dev/* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */ pm_runtime_put_noidle (&dev->dev); -if (xhci->quirks &XHCI_DEFAULT_PM_RUNTIME_ALLOW ) +if (pci_choose_state (dev,PMSG_SUSPEND ) ==PCI_D0 ) +pm_runtime_forbid (&dev->dev); +else if (xhci->quirks &XHCI_DEFAULT_PM_RUNTIME_ALLOW )pm_runtime_allow (&dev->dev);dma_set_max_seg_size (&dev->dev,UINT_MAX );
Greg Kroah-Hartman
maintainerPATCH 417/530 smb3: fix creating FIFOs when mounting with "sfu" mount option
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 72bc63f5e23a38b65ff2a201bdc11401d4223fa9 upstream.
Fixes some xfstests including generic/564 and generic/157
The "sfu" mount option can be useful for creating special files (character and block devices in particular) but could not create FIFOs. It did recognize existing empty files with the "system" attribute flag as FIFOs but this is too general, so to support creating FIFOs more safely use a new tag (but the same length as those for char and block devices ie "IntxLNK" and "IntxBLK") "LnxFIFO" to indicate that the file should be treated as a
FIFO (when mounted with the "sfu"). For some additional context note that
"sfu" followed the way that "Services for Unix" on Windows handled these special files (at least for character and block devices and symlinks), which is different than newer Windows which can handle special files as reparse points (which isn't an option to many servers).
--- fs/smb/client/cifspdu.h | 2 +- fs/smb/client/inode.c | 4 ++++ fs/smb/client/smb2ops.c | 8 +++++++- 3 files changed, 12 insertions(+), 2 deletions(-)
fs/smb/client/cifspdu.h +1 -1
@@ -2570,7 +2570,7 @@ typedef struct {struct win_dev { -unsigned char type[8 ];/* IntxCHR or IntxBLK */ +unsigned char type[8 ];/* IntxCHR or IntxBLK or LnxFIFO*/ __le64 major;__le64 minor; } __attribute__((packed));
fs/smb/client/inode.c +4 -0
@@ -592,6 +592,10 @@ cifs_sfu_type(struct cifs_fattr *fattr,cifs_dbg (FYI ,"Symlink\n" ); fattr->cf_mode |=S_IFLNK ; fattr->cf_dtype =DT_LNK ; + }else if (memcmp ("LnxFIFO" , pbuf,8 ) ==0 ) { +cifs_dbg (FYI ,"FIFO\n" ); + fattr->cf_mode |=S_IFIFO ; + fattr->cf_dtype =DT_FIFO ; }else { fattr->cf_mode |=S_IFREG ;/* file? */ fattr->cf_dtype =DT_REG ;
fs/smb/client/smb2ops.c +7 -1
@@ -5087,7 +5087,7 @@ smb2_make_node(unsigned int xid, struct* over SMB2/SMB3 and Samba will do this with SMB3.1.1 POSIX Extensions */ -if (!S_ISCHR (mode) && !S_ISBLK (mode)) +if (!S_ISCHR (mode) && !S_ISBLK (mode) && !S_ISFIFO (mode))return rc;cifs_dbg (FYI ,"sfu compat create special file\n" );
@@ -5135,6 +5135,12 @@ smb2_make_node(unsigned int xid, struct pdev->minor =cpu_to_le64 (MINOR (dev)); rc = tcon->ses->server->ops->sync_write (xid, &fid, &io_parms, &bytes_written, iov,1 ); + }else if (S_ISFIFO (mode)) { +memcpy (pdev->type,"LnxFIFO" ,8 ); + pdev->major =0 ; + pdev->minor =0 ; + rc = tcon->ses->server->ops->sync_write (xid, &fid, &io_parms, + &bytes_written, iov,1 ); } tcon->ses->server->ops->close (xid, tcon, &fid);d_drop (dentry);
Greg Kroah-Hartman
maintainerPATCH 418/530 smb3: fix touch -h of symlink
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 475efd9808a3094944a56240b2711349e433fb66 upstream.
For example:
touch -h -t 02011200 testfile
where testfile is a symlink would not change the timestamp, but
touch -t 02011200 testfiledoes work to change the timestamp of the target
--- fs/smb/client/cifsfs.c | 1 + 1 file changed, 1 insertion(+)
fs/smb/client/cifsfs.c +1 -0
@@ -1191,6 +1191,7 @@ const char *cifs_get_link(struct dentryconst struct inode_operations cifs_symlink_inode_ops = { .get_link = cifs_get_link, + .setattr = cifs_setattr, .permission = cifs_permission, .listxattr = cifs_listxattr, };
Greg Kroah-Hartman
maintainerPATCH 419/530 smb3: allow dumping session and tcon id to improve stats analysis and debugging
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit de4eceab578ead12a71e5b5588a57e142bbe8ceb upstream.
When multiple mounts are to the same share from the same client it was not possible to determine which section of /proc/fs/cifs/Stats (and DebugData) correspond to that mount. In some recent examples this turned out to be a significant problem when trying to analyze performance data - since there are many cases where unless we know the tree id and session id we can't figure out which stats (e.g. number of SMB3.1.1 requests by type, the total time they take, which is slowest, how many fail etc.) apply to which mount. The only existing loosely related ioctl CIFS_IOC_GET_MNT_INFO does not return the information needed to uniquely identify which tcon is which mount although it does return various flags and device info.
Add a cifs.ko ioctl CIFS_IOC_GET_TCON_INFO (0x800ccf0c) to return tid, session id, tree connect count.
--- fs/smb/client/cifs_ioctl.h | 6 ++++++ fs/smb/client/ioctl.c | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
fs/smb/client/cifs_ioctl.h +6 -0
@@ -26,6 +26,11 @@ struct smb_mnt_fs_info {__u64 cifs_posix_caps; } __packed; +struct smb_mnt_tcon_info { +__u32 tid; +__u64 session_id; +} __packed; +struct smb_snapshot_array {__u32 number_of_snapshots;__u32 number_of_snapshots_returned;
@@ -108,6 +113,7 @@ struct smb3_notify_info {#define CIFS_IOC_NOTIFY _IOW(CIFS_IOCTL_MAGIC, 9, struct smb3_notify)#define CIFS_DUMP_FULL_KEY _IOWR(CIFS_IOCTL_MAGIC, 10, struct smb3_full_key_debug_info)#define CIFS_IOC_NOTIFY_INFO _IOWR(CIFS_IOCTL_MAGIC, 11, struct smb3_notify_info) +#define CIFS_IOC_GET_TCON_INFO _IOR(CIFS_IOCTL_MAGIC, 12, struct smb_mnt_tcon_info)#define CIFS_IOC_SHUTDOWN _IOR('X', 125, __u32)/*
fs/smb/client/ioctl.c +25 -0
@@ -117,6 +117,20 @@ out_drop_write:return rc; } +static long smb_mnt_get_tcon_info (struct cifs_tcon *tcon,void __user *arg) +{ +int rc =0 ; +struct smb_mnt_tcon_info tcon_inf; + + tcon_inf.tid = tcon->tid; + tcon_inf.session_id = tcon->ses->Suid; + +if (copy_to_user (arg, &tcon_inf,sizeof (struct smb_mnt_tcon_info ))) + rc = -EFAULT ; + +return rc; +} +static long smb_mnt_get_fsinfo (unsigned int xid,struct cifs_tcon *tcon,void __user *arg) {
@@ -414,6 +428,17 @@ long cifs_ioctl(struct file *filep, unsi tcon =tlink_tcon (pSMBFile->tlink); rc =smb_mnt_get_fsinfo (xid, tcon, (void __user *)arg);break ; +case CIFS_IOC_GET_TCON_INFO : + cifs_sb =CIFS_SB (inode->i_sb); + tlink =cifs_sb_tlink (cifs_sb); +if (IS_ERR (tlink)) { + rc =PTR_ERR (tlink); +break ; + } + tcon =tlink_tcon (tlink); + rc =smb_mnt_get_tcon_info (tcon, (void __user *)arg); +cifs_put_tlink (tlink); +break ;case CIFS_ENUMERATE_SNAPSHOTS :if (pSMBFile ==NULL )break ;
Greg Kroah-Hartman
maintainerPATCH 420/530 smb3: fix caching of ctime on setxattr
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit 5923d6686a100c2b4cabd4c2ca9d5a12579c7614 upstream.
Fixes xfstest generic/728 which had been failing due to incorrect ctime after setxattr and removexattr
Update ctime on successful set of xattr
--- fs/smb/client/xattr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/smb/client/xattr.c +4 -1
@@ -150,10 +150,13 @@ static int cifs_xattr_set(const struct xif (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_XATTR ) goto out; -if (pTcon->ses->server->ops->set_EA) +if (pTcon->ses->server->ops->set_EA) { rc = pTcon->ses->server->ops->set_EA (xid, pTcon, full_path, name, value, (__u16 )size, cifs_sb->local_nls, cifs_sb); +if (rc ==0 ) +inode_set_ctime_current (inode); + }break ;case XATTR_CIFS_ACL :
Greg Kroah-Hartman
maintainerPATCH 403/530 Bluetooth: btusb: Add RTW8852BE device 13d3:3570 to device tables
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masum Reza <[email protected]>
[ Upstream commit 02be109d3a405dbc4d53fb4b4473d7a113548088 ]
This device is used in TP-Link TX20E WiFi+Bluetooth adapter.
Relevant information in /sys/kernel/debug/usb/devices about the Bluetooth device is listed as the below.
T: Bus=01 Lev=01 Prnt=01 Port=08 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=13d3 ProdID=3570 Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
Stable-dep-of: da06ff1f585e ("Bluetooth: btusb: Add 0bda:b85b for Fn-Link RTL8852BE")
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -543,6 +543,8 @@ static const struct usb_device_id quirks_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x0bda, 0x887b), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x13d3, 0x3570), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3571), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH },
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 421/530 smb: client: fix use-after-free bug in cifs_debug_data_proc_show()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit d328c09ee9f15ee5a26431f5aad7c9239fa85e62 upstream.
Skip SMB sessions that are being teared down
(e.g. @ses->ses_status == SES_EXITING) in cifs_debug_data_proc_show() to avoid use-after-free in @ses.
This fixes the following GPF when reading from /proc/fs/cifs/DebugData while mounting and umounting
[ 816.251274] general protection fault, probably for non-canonical address 0x6b6b6b6b6b6b6d81: 0000 [#1] PREEMPT SMP NOPTI ... [ 816.260138] Call Trace: [ 816.260329] <TASK> [ 816.260499] ? die_addr+0x36/0x90 [ 816.260762] ? exc_general_protection+0x1b3/0x410 [ 816.261126] ? asm_exc_general_protection+0x26/0x30 [ 816.261502] ? cifs_debug_tcon+0xbd/0x240 [cifs] [ 816.261878] ? cifs_debug_tcon+0xab/0x240 [cifs] [ 816.262249] cifs_debug_data_proc_show+0x516/0xdb0 [cifs] [ 816.262689] ? seq_read_iter+0x379/0x470 [ 816.262995] seq_read_iter+0x118/0x470 [ 816.263291] proc_reg_read_iter+0x53/0x90 [ 816.263596] ? srso_alias_return_thunk+0x5/0x7f [ 816.263945] vfs_read+0x201/0x350 [ 816.264211] ksys_read+0x75/0x100 [ 816.264472] do_syscall_64+0x3f/0x90 [ 816.264750] entry_SYSCALL_64_after_hwframe+0x6e/0xd8 [ 816.265135] RIP: 0033:0x7fd5e669d381
--- fs/smb/client/cifs_debug.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/smb/client/cifs_debug.c +6 -0
@@ -452,6 +452,11 @@ skip_rdma:seq_printf (m,"\n\n\tSessions: " ); i =0 ;list_for_each_entry (ses, &server->smb_ses_list, smb_ses_list) { +spin_lock (&ses->ses_lock); +if (ses->ses_status ==SES_EXITING ) { +spin_unlock (&ses->ses_lock); +continue ; + } i++; if ((ses->serverDomain == NULL) || (ses->serverOS == NULL) ||
@@ -472,6 +477,7 @@ skip_rdma: ses->ses_count, ses->serverOS, ses->serverNOS, ses->capabilities, ses->ses_status); } +spin_unlock (&ses->ses_lock);seq_printf (m,"\n\tSecurity type: %s " ,get_security_type_str (server->ops->select_sectype (server, ses->sectype)));
Greg Kroah-Hartman
maintainerPATCH 422/530 smb: client: fix use-after-free in smb2_query_info_compound()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit 5c86919455c1edec99ebd3338ad213b59271a71b upstream.
The following UAF was triggered when running fstests generic/072 with KASAN enabled against Windows Server 2022 and mount options 'multichannel,max_channels=2,vers=3.1.1,mfsymlinks,noperm'
BUG: KASAN: slab-use-after-free in smb2_query_info_compound+0x423/0x6d0 [cifs] Read of size 8 at addr ffff888014941048 by task xfs_io/27534 CPU: 0 PID: 27534 Comm: xfs_io Not tainted 6.6.0-rc7 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.2-3-gd478f380-rebuilt.opensuse.org 04/01/2014 Call Trace: dump_stack_lvl+0x4a/0x80 print_report+0xcf/0x650 ? srso_alias_return_thunk+0x5/0x7f ? srso_alias_return_thunk+0x5/0x7f ? __phys_addr+0x46/0x90 kasan_report+0xda/0x110 ? smb2_query_info_compound+0x423/0x6d0 [cifs] ? smb2_query_info_compound+0x423/0x6d0 [cifs] smb2_query_info_compound+0x423/0x6d0 [cifs] ? __pfx_smb2_query_info_compound+0x10/0x10 [cifs] ? srso_alias_return_thunk+0x5/0x7f ? __stack_depot_save+0x39/0x480 ? kasan_save_stack+0x33/0x60 ? kasan_set_track+0x25/0x30 ? ____kasan_slab_free+0x126/0x170 smb2_queryfs+0xc2/0x2c0 [cifs] ? __pfx_smb2_queryfs+0x10/0x10 [cifs] ? __pfx___lock_acquire+0x10/0x10 smb311_queryfs+0x210/0x220 [cifs] ? __pfx_smb311_queryfs+0x10/0x10 [cifs] ? srso_alias_return_thunk+0x5/0x7f ? __lock_acquire+0x480/0x26c0 ? lock_release+0x1ed/0x640 ? srso_alias_return_thunk+0x5/0x7f ? do_raw_spin_unlock+0x9b/0x100 cifs_statfs+0x18c/0x4b0 [cifs] statfs_by_dentry+0x9b/0xf0 fd_statfs+0x4e/0xb0 __do_sys_fstatfs+0x7f/0xe0 ? __pfx___do_sys_fstatfs+0x10/0x10 ? srso_alias_return_thunk+0x5/0x7f ? lockdep_hardirqs_on_prepare+0x136/0x200 ? srso_alias_return_thunk+0x5/0x7f do_syscall_64+0x3f/0x90 entry_SYSCALL_64_after_hwframe+0x6e/0xd8 Allocated by task 27534: kasan_save_stack+0x33/0x60 kasan_set_track+0x25/0x30 __kasan_kmalloc+0x8f/0xa0 open_cached_dir+0x71b/0x1240 [cifs] smb2_query_info_compound+0x5c3/0x6d0 [cifs] smb2_queryfs+0xc2/0x2c0 [cifs] smb311_queryfs+0x210/0x220 [cifs] cifs_statfs+0x18c/0x4b0 [cifs] statfs_by_dentry+0x9b/0xf0 fd_statfs+0x4e/0xb0 __do_sys_fstatfs+0x7f/0xe0 do_syscall_64+0x3f/0x90 entry_SYSCALL_64_after_hwframe+0x6e/0xd8 Freed by task 27534: kasan_save_stack+0x33/0x60 kasan_set_track+0x25/0x30 kasan_save_free_info+0x2b/0x50 ____kasan_slab_free+0x126/0x170 slab_free_freelist_hook+0xd0/0x1e0 __kmem_cache_free+0x9d/0x1b0 open_cached_dir+0xff5/0x1240 [cifs] smb2_query_info_compound+0x5c3/0x6d0 [cifs] smb2_queryfs+0xc2/0x2c0 [cifs]
This is a race between open_cached_dir() and cached_dir_lease_break() where the cache entry for the open directory handle receives a lease break while creating it. And before returning from open_cached_dir(), we put the last reference of the new @cfid because of !@cfid->has_lease.
Besides the UAF, while running xfstests a lot of missed lease breaks have been noticed in tests that run several concurrent statfs(2) calls on those cached fids
CIFS: VFS: \\w22-root1.gandalf.test No task to wake, unknown frame...
CIFS: VFS: \\w22-root1.gandalf.test Cmd: 18 Err: 0x0 Flags: 0x1...
CIFS: VFS: \\w22-root1.gandalf.test smb buf 00000000715bfe83 len 108
CIFS: VFS: Dump pending requests:
CIFS: VFS: \\w22-root1.gandalf.test No task to wake, unknown frame...
CIFS: VFS: \\w22-root1.gandalf.test Cmd: 18 Err: 0x0 Flags: 0x1...
CIFS: VFS: \\w22-root1.gandalf.test smb buf 000000005aa7316e len 108
...
To fix both, in open_cached_dir() ensure that @cfid->has_lease is set right before sending out compounded request so that any potential lease break will be get processed by demultiplex thread while we're still caching @cfid. And, if open failed for some reason, re-check @cfid->has_lease to decide whether or not put lease reference.
--- fs/smb/client/cached_dir.c | 84 ++++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 35 deletions(-)
fs/smb/client/cached_dir.c +49 -35
@@ -32,7 +32,7 @@ static struct cached_fid *find_or_create* fully cached or it may be in the process of * being deleted due to a lease break. */ -if (!cfid->has_lease) { +if (!cfid->time || !cfid->has_lease) {spin_unlock (&cfids->cfid_list_lock);return NULL ; }
@@ -193,10 +193,20 @@ int open_cached_dir(unsigned int xid, st npath =path_no_prefix (cifs_sb, path);if (IS_ERR (npath)) { rc =PTR_ERR (npath); -kfree (utf16_path); -return rc; + goto out; } +if (!npath[0 ]) { + dentry =dget (cifs_sb->root); + }else { + dentry =path_to_dentry (cifs_sb, npath); +if (IS_ERR (dentry)) { + rc = -ENOENT ; + goto out; + } + } + cfid->dentry = dentry; +/* * We do not hold the lock for the open because in case * SMB2_open needs to reconnect.
@@ -249,6 +259,15 @@ int open_cached_dir(unsigned int xid, stsmb2_set_related (&rqst[1 ]); +/* +* Set @cfid->has_lease to true before sending out compounded request so +* its lease reference can be put in cached_dir_lease_break() due to a +* potential lease break right after the request is sent or while @cfid +* is still being cached. Concurrent processes won't be to use it yet +* due to @cfid->time being zero. +*/ + cfid->has_lease = true; + rc =compound_send_recv (xid, ses, server, flags,2 , rqst, resp_buftype, rsp_iov);
@@ -263,6 +282,8 @@ int open_cached_dir(unsigned int xid, st cfid->tcon = tcon; cfid->is_open = true; +spin_lock (&cfids->cfid_list_lock); + o_rsp = (struct smb2_create_rsp *)rsp_iov[0 ].iov_base; oparms.fid->persistent_fid = o_rsp->PersistentFileId; oparms.fid->volatile_fid = o_rsp->VolatileFileId;
@@ -270,18 +291,25 @@ int open_cached_dir(unsigned int xid, st oparms.fid->mid =le64_to_cpu (o_rsp->hdr.MessageId);#endif /* CIFS_DEBUG2 */ -if (o_rsp->OplockLevel !=SMB2_OPLOCK_LEVEL_LEASE ) + rc = -EINVAL ; +if (o_rsp->OplockLevel !=SMB2_OPLOCK_LEVEL_LEASE ) { +spin_unlock (&cfids->cfid_list_lock); goto oshr_free; + }smb2_parse_contexts (server, o_rsp, &oparms.fid->epoch, oparms.fid->lease_key, &oplock,NULL ,NULL ); -if (!(oplock &SMB2_LEASE_READ_CACHING_HE )) +if (!(oplock &SMB2_LEASE_READ_CACHING_HE )) { +spin_unlock (&cfids->cfid_list_lock); goto oshr_free; + } qi_rsp = (struct smb2_query_info_rsp *)rsp_iov[1 ].iov_base; -if (le32_to_cpu (qi_rsp->OutputBufferLength) <sizeof (struct smb2_file_all_info )) +if (le32_to_cpu (qi_rsp->OutputBufferLength) <sizeof (struct smb2_file_all_info )) { +spin_unlock (&cfids->cfid_list_lock); goto oshr_free; + } if (!smb2_validate_and_copy_iov( le16_to_cpu(qi_rsp->OutputBufferOffset), sizeof(struct smb2_file_all_info),
@@ -289,37 +317,24 @@ int open_cached_dir(unsigned int xid, st (char *)&cfid->file_all_info)) cfid->file_all_info_is_valid = true; -if (!npath[0 ]) - dentry =dget (cifs_sb->root); -else { - dentry =path_to_dentry (cifs_sb, npath); -if (IS_ERR (dentry)) { - rc = -ENOENT ; - goto oshr_free; - } - } -spin_lock (&cfids->cfid_list_lock); - cfid->dentry = dentry; cfid->time = jiffies; - cfid->has_lease = true;spin_unlock (&cfids->cfid_list_lock); +/* At this point the directory handle is fully cached */ + rc =0 ; oshr_free: -kfree (utf16_path);SMB2_open_free (&rqst[0 ]);SMB2_query_info_free (&rqst[1 ]);free_rsp_buf (resp_buftype[0 ], rsp_iov[0 ].iov_base);free_rsp_buf (resp_buftype[1 ], rsp_iov[1 ].iov_base); -spin_lock (&cfids->cfid_list_lock); -if (!cfid->has_lease) { -if (rc) { -if (cfid->on_list) { -list_del (&cfid->entry); - cfid->on_list = false; - cfids->num_entries--; - } - rc = -ENOENT ; - }else { +if (rc) { +spin_lock (&cfids->cfid_list_lock); +if (cfid->on_list) { +list_del (&cfid->entry); + cfid->on_list = false; + cfids->num_entries--; + } +if (cfid->has_lease) {/* * We are guaranteed to have two references at this * point. One for the caller and one for a potential
@@ -327,25 +342,24 @@ oshr_free:* will be closed when the caller closes the cached * handle. */ + cfid->has_lease = false;spin_unlock (&cfids->cfid_list_lock);kref_put (&cfid->refcount, smb2_close_cached_fid); goto out; } +spin_unlock (&cfids->cfid_list_lock); } -spin_unlock (&cfids->cfid_list_lock); +out:if (rc) {if (cfid->is_open)SMB2_close (0 , cfid->tcon, cfid->fid.persistent_fid, cfid->fid.volatile_fid);free_cached_dir (cfid); - cfid =NULL ; - } -out: -if (rc ==0 ) { + }else { *ret_cfid = cfid;atomic_inc (&tcon->num_remote_opens); } - +kfree (utf16_path);return rc; }
Greg Kroah-Hartman
maintainerPATCH 423/530 smb: client: fix potential deadlock when releasing mids
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit e6322fd177c6885a21dd4609dc5e5c973d1a2eb7 upstream.
All release_mid() callers seem to hold a reference of @mid so there is no need to call kref_put(&mid->refcount, __release_mid) under @server->mid_lock spinlock. If they don't, then an use-after-free bug would have occurred anyways.
By getting rid of such spinlock also fixes a potential deadlock as shown below
CPU 0 CPU 1
------------------------------------------------------------------cifs_demultiplex_thread() cifs_debug_data_proc_show()
release_mid()
spin_lock(&server->mid_lock);
spin_lock(&cifs_tcp_ses_lock)
spin_lock(&server->mid_lock) __release_mid()
smb2_find_smb_tcon()
spin_lock(&cifs_tcp_ses_lock) *deadlock*
--- fs/smb/client/cifsproto.h | 7 ++++++- fs/smb/client/smb2misc.c | 2 +- fs/smb/client/transport.c | 11 +---------- 3 files changed, 8 insertions(+), 12 deletions(-)
fs/smb/client/cifsproto.h +6 -1
@@ -81,7 +81,7 @@ extern char *cifs_build_path_to_root(strextern char *build_wildcard_path_from_dentry (struct dentry *direntry);char *cifs_build_devname (char *nodename,const char *prepath);extern void delete_mid (struct mid_q_entry *mid); -extern void release_mid (struct mid_q_entry *mid); +void __release_mid (struct kref *refcount);extern void cifs_wake_up_task (struct mid_q_entry *mid);extern int cifs_handle_standard (struct TCP_Server_Info *server,struct mid_q_entry *mid);
@@ -740,4 +740,9 @@ static inline bool dfs_src_pathname_equa return true; } +static inline void release_mid (struct mid_q_entry *mid) +{ +kref_put (&mid->refcount, __release_mid); +} +#endif /* _CIFSPROTO_H */
fs/smb/client/smb2misc.c +1 -1
@@ -787,7 +787,7 @@ __smb2_handle_cancelled_cmd(struct cifs_ {struct close_cancelled_open *cancelled; - cancelled =kzalloc (sizeof (*cancelled),GFP_ATOMIC ); + cancelled =kzalloc (sizeof (*cancelled),GFP_KERNEL );if (!cancelled)return -ENOMEM ;
fs/smb/client/transport.c +1 -10
@@ -76,7 +76,7 @@ alloc_mid(const struct smb_hdr *smb_buffreturn temp; } -static void __release_mid (struct kref *refcount) +void __release_mid (struct kref *refcount) {struct mid_q_entry *midEntry = container_of(refcount, struct mid_q_entry, refcount);
@@ -156,15 +156,6 @@ static void __release_mid(struct kref *rmempool_free (midEntry, cifs_mid_poolp); } -void release_mid (struct mid_q_entry *mid) -{ -struct TCP_Server_Info *server = mid->server; - -spin_lock (&server->mid_lock); -kref_put (&mid->refcount, __release_mid); -spin_unlock (&server->mid_lock); -} -void delete_mid (struct mid_q_entry *mid) {
Greg Kroah-Hartman
maintainerPATCH 424/530 smb: client: fix mount when dns_resolver key is not available
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paulo Alcantara <[email protected]>
commit 5e2fd17f434d2fed78efb123e2fc6711e4f598f1 upstream.
There was a wrong assumption that with CONFIG_CIFS_DFS_UPCALL=y there would always be a dns_resolver key set up so we could unconditionally upcall to resolve UNC hostname rather than using the value provided by mount(2).
Only require it when performing automount of junctions within a DFS share so users that don't have dns_resolver key still can mount their regular shares with server hostname resolved by mount.cifs(8).
--- fs/smb/client/dfs.c | 18 +++++++++++++----- fs/smb/client/fs_context.h | 1 + fs/smb/client/namespace.c | 17 +++++++++++++++-- 3 files changed, 29 insertions(+), 7 deletions(-)
fs/smb/client/dfs.c +13 -5
@@ -263,15 +263,23 @@ out:return rc; } -/* Resolve UNC hostname in @ctx->source and set ip addr in @ctx->dstaddr */ +/* +* If @ctx->dfs_automount, then update @ctx->dstaddr earlier with the DFS root +* server from where we'll start following any referrals. Otherwise rely on the +* value provided by mount(2) as the user might not have dns_resolver key set up +* and therefore failing to upcall to resolve UNC hostname under @ctx->source. +*/ static int update_fs_context_dstaddr (struct smb3_fs_context *ctx) {struct sockaddr *addr = (struct sockaddr *)&ctx->dstaddr; -int rc; +int rc =0 ; - rc =dns_resolve_server_name_to_ip (ctx->source, addr,NULL ); -if (!rc) -cifs_set_port (addr, ctx->port); +if (!ctx->nodfs && ctx->dfs_automount) { + rc =dns_resolve_server_name_to_ip (ctx->source, addr,NULL ); +if (!rc) +cifs_set_port (addr, ctx->port); + ctx->dfs_automount = false; + }return rc; }
fs/smb/client/fs_context.h +1 -0
@@ -268,6 +268,7 @@ struct smb3_fs_context { bool witness:1; /* use witness protocol */char *leaf_fullpath;struct cifs_ses *dfs_root_ses; + bool dfs_automount:1; /* set for dfs automount only */ };extern const struct fs_parameter_spec smb3_fs_parameters[];
fs/smb/client/namespace.c +15 -2
@@ -117,6 +117,18 @@ cifs_build_devname(char *nodename, constreturn dev; } +static bool is_dfs_mount (struct dentry *dentry) +{ +struct cifs_sb_info *cifs_sb =CIFS_SB (dentry->d_sb); +struct cifs_tcon *tcon =cifs_sb_master_tcon (cifs_sb); +bool ret; + +spin_lock (&tcon->tc_lock); + ret = !!tcon->origin_fullpath; +spin_unlock (&tcon->tc_lock); +return ret; +} +/* Return full path out of a dentry set for automount */ static char *automount_fullpath (struct dentry *dentry,void *page) {
@@ -212,8 +224,9 @@ static struct vfsmount *cifs_do_automoun ctx->source =NULL ; goto out; } -cifs_dbg (FYI ,"%s: ctx: source=%s UNC=%s prepath=%s\n" , - __func__, ctx->source, ctx->UNC, ctx->prepath); + ctx->dfs_automount =is_dfs_mount (mntpt); +cifs_dbg (FYI ,"%s: ctx: source=%s UNC=%s prepath=%s dfs_automount=%d\n" , + __func__, ctx->source, ctx->UNC, ctx->prepath, ctx->dfs_automount); mnt =fc_mount (fc); out:
Greg Kroah-Hartman
maintainerPATCH 425/530 cifs: reconnect helper should set reconnect for the right channel
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
commit c3326a61cdbf3ce1273d9198b6cbf90965d7e029 upstream.
We introduced a helper function to be used by non-cifsd threads to mark the connection for reconnect. For multichannel, when only a particular channel needs to be reconnected, this had a bug.
This change fixes that by marking that particular channel for reconnect.
--- fs/smb/client/connect.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
fs/smb/client/connect.c +5 -4
@@ -156,13 +156,14 @@ cifs_signal_cifsd_for_reconnect(struct T/* If server is a channel, select the primary channel */ pserver =SERVER_IS_CHAN (server) ? server->primary_server : server; -spin_lock (&pserver->srv_lock); +/* if we need to signal just this channel */ if (!all_channels) { - pserver->tcpStatus = CifsNeedReconnect; -spin_unlock (&pserver->srv_lock); +spin_lock (&server->srv_lock); +if (server->tcpStatus != CifsExiting) + server->tcpStatus = CifsNeedReconnect; +spin_unlock (&server->srv_lock);return ; } -spin_unlock (&pserver->srv_lock);spin_lock (&cifs_tcp_ses_lock);list_for_each_entry (ses, &pserver->smb_ses_list, smb_ses_list) {
Greg Kroah-Hartman
maintainerPATCH 426/530 cifs: force interface update before a fresh session setup
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
commit d9a6d78096056a3cb5c5f07a730ab92f2f9ac4e6 upstream.
During a session reconnect, it is possible that the server moved to another physical server (happens in case of Azure files). So at this time, force a query of server interfaces again (in case of multichannel session), such that the secondary channels connect to the right IP addresses (possibly updated now).
--- fs/smb/client/connect.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/smb/client/connect.c +5 -1
@@ -3850,8 +3850,12 @@ cifs_setup_session(const unsigned int xi is_binding = !CIFS_ALL_CHANS_NEED_RECONNECT (ses);spin_unlock (&ses->chan_lock); -if (!is_binding) +if (!is_binding) { ses->ses_status =SES_IN_SETUP ; + +/* force iface_list refresh */ + ses->iface_last_update =0 ; + }spin_unlock (&ses->ses_lock);/* update ses ip_addr only for primary chan */
Greg Kroah-Hartman
maintainerPATCH 427/530 cifs: do not reset chan_max if multichannel is not supported at mount
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
commit 6e5e64c9477d58e73cb1a0e83eacad1f8df247cf upstream.
If the mount command has specified multichannel as a mount option, but multichannel is found to be unsupported by the server at the time of mount, we set chan_max to 1. Which means that the user needs to remount the share if the server starts supporting multichannel.
This change removes this reset. What it means is that if the user specified multichannel or max_channels during mount, and at this time, multichannel is not supported, but the server starts supporting it at a later point, the client will be capable of scaling out the number of channels.
--- fs/smb/client/sess.c | 1 - 1 file changed, 1 deletion(-)
fs/smb/client/sess.c +0 -1
@@ -186,7 +186,6 @@ int cifs_try_adding_channels(struct cifs }if (!(server->capabilities &SMB2_GLOBAL_CAP_MULTI_CHANNEL )) { - ses->chan_max =1 ;spin_unlock (&ses->chan_lock);cifs_server_dbg (VFS ,"no multichannel support\n" );return 0 ;
Greg Kroah-Hartman
maintainerPATCH 404/530 Bluetooth: btusb: Add 0bda:b85b for Fn-Link RTL8852BE
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guan Wentao <[email protected]>
[ Upstream commit da06ff1f585ea784c79f80e7fab0e0c4ebb49c1c ]
Add PID/VID 0bda:b85b for Realtek RTL8852BE USB bluetooth part. The PID/VID was reported by the patch last year. [1] Some SBCs like rockpi 5B A8 module contains the device. And it`s founded in website. [2] [3]
Here is the device tables in /sys/kernel/debug/usb/devices .
T: Bus=07 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=12 MxCh= 0 D: Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0bda ProdID=b85b Rev= 0.00 S: Manufacturer=Realtek S: Product=Bluetooth Radio S: SerialNumber=00e04c000001 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -543,6 +543,8 @@ static const struct usb_device_id quirks_table[] = { BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x0bda, 0x887b), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, + { USB_DEVICE(0x0bda, 0xb85b), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3570), .driver_info = BTUSB_REALTEK | BTUSB_WIDEBAND_SPEECH }, { USB_DEVICE(0x13d3, 0x3571), .driver_info = BTUSB_REALTEK |
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 405/530 drm/amd/display: enable dsc_clk even if dsc_pg disabled
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Ahmed <[email protected]>
[ Upstream commit 40255df370e94d44f0f0a924400d68db0ee31bec ]
[why]
need to enable dsc_clk regardless dsc_pg
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 8 ++++---- drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +4 -4
@@ -1843,7 +1843,7 @@ static enum dc_status dc_commit_state_no_check(struct dc *dc, struct dc_state *cif (dc->hwss.subvp_pipe_control_lock) dc->hwss.subvp_pipe_control_lock (dc, context, true, true,NULL , subvp_prev_use); -if (dc->debug.enable_double_buffered_dsc_pg_support) +if (dc->hwss.update_dsc_pg) dc->hwss.update_dsc_pg (dc, context, false);disable_dangling_plane (dc, context);
@@ -1950,7 +1950,7 @@ static enum dc_status dc_commit_state_no_check(struct dc *dc, struct dc_state *c dc->hwss.optimize_bandwidth (dc, context); } -if (dc->debug.enable_double_buffered_dsc_pg_support) +if (dc->hwss.update_dsc_pg) dc->hwss.update_dsc_pg (dc, context, true);if (dc->ctx->dce_version >=DCE_VERSION_MAX )
@@ -2197,7 +2197,7 @@ void dc_post_update_surfaces_to_stream(struct dc *dc) dc->hwss.optimize_bandwidth (dc, context); -if (dc->debug.enable_double_buffered_dsc_pg_support) +if (dc->hwss.update_dsc_pg) dc->hwss.update_dsc_pg (dc, context, true); }
@@ -3533,7 +3533,7 @@ static void commit_planes_for_stream(struct dc *dc,if (get_seamless_boot_stream_count (context) ==0 ) dc->hwss.prepare_bandwidth (dc, context); -if (dc->debug.enable_double_buffered_dsc_pg_support) +if (dc->hwss.update_dsc_pg) dc->hwss.update_dsc_pg (dc, context, false);context_clock_trace (dc, context);
drivers/gpu/drm/amd/display/dc/dcn32/dcn32_hwseq.c +3 -0
@@ -77,6 +77,9 @@ void dcn32_dsc_pg_control(if (hws->ctx->dc->debug.disable_dsc_power_gate)return ; +if (!hws->ctx->dc->debug.enable_double_buffered_dsc_pg_support) +return ; +REG_GET (DC_IP_REQUEST_CNTL ,IP_REQUEST_EN , &org_ip_request_cntl);if (org_ip_request_cntl ==0 )REG_SET (DC_IP_REQUEST_CNTL ,0 ,IP_REQUEST_EN ,1 );
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 406/530 torture: Make torture_hrtimeout_ns() take an hrtimer mode parameter
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul E. McKenney <[email protected]>
[ Upstream commit a741deac787f0d2d7068638c067db20af9e63752 ]
The current torture-test sleeps are waiting for a duration, but there are situations where it is better to wait for an absolute time, for example, when ending a stutter interval. This commit therefore adds an hrtimer mode parameter to torture_hrtimeout_ns(). Why not also the other torture_hrtimeout_*() functions? The theory is that most absolute times will be in nanoseconds, especially not (say) jiffies.
Stable-dep-of: cca42bd8eb1b ("rcutorture: Fix stuttering races and other issues")
--- include/linux/torture.h | 3 ++- kernel/torture.c | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-)
include/linux/torture.h +2 -1
@@ -81,7 +81,8 @@ static inline void torture_random_init(struct torture_random_state *trsp) }/* Definitions for high-resolution-timer sleeps. */ -int torture_hrtimeout_ns (ktime_t baset_ns,u32 fuzzt_ns,struct torture_random_state *trsp); +int torture_hrtimeout_ns (ktime_t baset_ns,u32 fuzzt_ns,const enum hrtimer_mode mode, +struct torture_random_state *trsp);int torture_hrtimeout_us (u32 baset_us,u32 fuzzt_ns,struct torture_random_state *trsp);int torture_hrtimeout_ms (u32 baset_ms,u32 fuzzt_us,struct torture_random_state *trsp);int torture_hrtimeout_jiffies (u32 baset_j,struct torture_random_state *trsp);
kernel/torture.c +7 -6
@@ -87,14 +87,15 @@ EXPORT_SYMBOL_GPL(verbose_torout_sleep);* nanosecond random fuzz. This function and its friends desynchronize * testing from the timer wheel. */ -int torture_hrtimeout_ns (ktime_t baset_ns,u32 fuzzt_ns,struct torture_random_state *trsp) +int torture_hrtimeout_ns (ktime_t baset_ns,u32 fuzzt_ns,const enum hrtimer_mode mode, +struct torture_random_state *trsp) {ktime_t hto = baset_ns;if (trsp) hto +=torture_random (trsp) % fuzzt_ns;set_current_state (TASK_IDLE ); -return schedule_hrtimeout (&hto,HRTIMER_MODE_REL ); +return schedule_hrtimeout (&hto, mode); }EXPORT_SYMBOL_GPL (torture_hrtimeout_ns);
@@ -106,7 +107,7 @@ int torture_hrtimeout_us(u32 baset_us, u32 fuzzt_ns, struct torture_random_state {ktime_t baset_ns = baset_us *NSEC_PER_USEC ; -return torture_hrtimeout_ns (baset_ns, fuzzt_ns, trsp); +return torture_hrtimeout_ns (baset_ns, fuzzt_ns,HRTIMER_MODE_REL , trsp); }EXPORT_SYMBOL_GPL (torture_hrtimeout_us);
@@ -123,7 +124,7 @@ int torture_hrtimeout_ms(u32 baset_ms, u32 fuzzt_us, struct torture_random_state fuzzt_ns = (u32 )~0U ; else fuzzt_ns = fuzzt_us *NSEC_PER_USEC ; -return torture_hrtimeout_ns (baset_ns, fuzzt_ns, trsp); +return torture_hrtimeout_ns (baset_ns, fuzzt_ns,HRTIMER_MODE_REL , trsp); }EXPORT_SYMBOL_GPL (torture_hrtimeout_ms);
@@ -136,7 +137,7 @@ int torture_hrtimeout_jiffies(u32 baset_j, struct torture_random_state *trsp) {ktime_t baset_ns =jiffies_to_nsecs (baset_j); -return torture_hrtimeout_ns (baset_ns,jiffies_to_nsecs (1 ), trsp); +return torture_hrtimeout_ns (baset_ns,jiffies_to_nsecs (1 ),HRTIMER_MODE_REL , trsp); }EXPORT_SYMBOL_GPL (torture_hrtimeout_jiffies);
@@ -153,7 +154,7 @@ int torture_hrtimeout_s(u32 baset_s, u32 fuzzt_ms, struct torture_random_state * fuzzt_ns = (u32 )~0U ; else fuzzt_ns = fuzzt_ms *NSEC_PER_MSEC ; -return torture_hrtimeout_ns (baset_ns, fuzzt_ns, trsp); +return torture_hrtimeout_ns (baset_ns, fuzzt_ns,HRTIMER_MODE_REL , trsp); }EXPORT_SYMBOL_GPL (torture_hrtimeout_s);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 407/530 rcutorture: Fix stuttering races and other issues
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joel Fernandes (Google) <[email protected]>
[ Upstream commit cca42bd8eb1b54a4c9bbf48c79d120e66619a3e4 ]
The stuttering code isn't functioning as expected. Ideally, it should pause the torture threads for a designated period before resuming. Yet, it fails to halt the test for the correct duration. Additionally, a race condition exists, potentially causing the stuttering code to pause for an extended period if the 'spt' variable is non-zero due to the stutter orchestration thread's inadequate CPU time.
Moreover, over-stuttering can hinder RCU's progress on TREE07 kernels. This happens as the stuttering code may run within a softirq due to RCU callbacks. Consequently, ksoftirqd keeps a CPU busy for several seconds, thus obstructing RCU's progress. This situation triggers a warning message in the logs:
[ 2169.481783] rcu_torture_writer: rtort_pipe_count: 9
This warning suggests that an RCU torture object, although invisible to RCU readers, couldn't make it past the pipe array and be freed -- a strong indication that there weren't enough grace periods during the stutter interval.
To address these issues, this patch sets the "stutter end" time to an absolute point in the future set by the main stutter thread. This is then used for waiting in stutter_wait(). While the stutter thread still defines this absolute time, the waiters' waiting logic doesn't rely on the stutter thread receiving sufficient CPU time to halt the stuttering as the halting is now self-controlled.
--- kernel/torture.c | 45 ++++++++++++--------------------------------- 1 file changed, 12 insertions(+), 33 deletions(-)
kernel/torture.c +12 -33
@@ -721,7 +721,7 @@ static void torture_shutdown_cleanup(void)* suddenly applied to or removed from the system. */ static struct task_struct *stutter_task; -static int stutter_pause_test; +static ktime_t stutter_till_abs_time;static int stutter;static int stutter_gap;
@@ -731,30 +731,16 @@ static int stutter_gap;*/ bool stutter_wait (const char *title) { -unsigned int i =0 ;bool ret = false; -int spt; +ktime_t till_ns;cond_resched_tasks_rcu_qs (); - spt =READ_ONCE (stutter_pause_test); -for (; spt; spt =READ_ONCE (stutter_pause_test)) { -if (!ret && !rt_task (current)) { -sched_set_normal (current,MAX_NICE ); - ret = true; - } -if (spt ==1 ) { -torture_hrtimeout_jiffies (1 ,NULL ); - }else if (spt ==2 ) { -while (READ_ONCE (stutter_pause_test)) { -if (!(i++ &0xffff )) -torture_hrtimeout_us (10 ,0 ,NULL ); -cond_resched (); - } - }else { -torture_hrtimeout_jiffies (round_jiffies_relative (HZ ),NULL ); - } -torture_shutdown_absorb (title); + till_ns =READ_ONCE (stutter_till_abs_time); +if (till_ns &&ktime_before (ktime_get (), till_ns)) { +torture_hrtimeout_ns (till_ns,0 ,HRTIMER_MODE_ABS ,NULL ); + ret = true; } +torture_shutdown_absorb (title);return ret; }EXPORT_SYMBOL_GPL (stutter_wait);
@@ -765,23 +751,16 @@ EXPORT_SYMBOL_GPL(stutter_wait);*/ static int torture_stutter (void *arg) { -DEFINE_TORTURE_RANDOM (rand); -int wtime; +ktime_t till_ns;VERBOSE_TOROUT_STRING ("torture_stutter task started" ); do { if (!torture_must_stop() && stutter > 1) { - wtime = stutter; - if (stutter > 2) { - WRITE_ONCE(stutter_pause_test, 1); - wtime = stutter - 3; - torture_hrtimeout_jiffies(wtime, &rand); - wtime = 2; - } - WRITE_ONCE(stutter_pause_test, 2); - torture_hrtimeout_jiffies(wtime, NULL); + till_ns = ktime_add_ns(ktime_get(), + jiffies_to_nsecs(stutter)); + WRITE_ONCE(stutter_till_abs_time, till_ns); + torture_hrtimeout_jiffies(stutter - 1, NULL); } - WRITE_ONCE(stutter_pause_test, 0); if (!torture_must_stop()) torture_hrtimeout_jiffies(stutter_gap, NULL); torture_shutdown_absorb("torture_stutter");
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 408/530 selftests/resctrl: Remove bw_report and bm_type from main()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit 47e36f16c7846bf3627ff68525e02555c53dc99e ]
bw_report is always set to "reads" and bm_type is set to "fill_buf" but is never used.
Set bw_report directly to "reads" in MBA/MBM test and remove bm_type.
Stable-dep-of: 3aff51464455 ("selftests/resctrl: Extend signal handler coverage to unmount on receiving signal")
--- tools/testing/selftests/resctrl/mba_test.c | 4 ++-- tools/testing/selftests/resctrl/mbm_test.c | 4 ++-- tools/testing/selftests/resctrl/resctrl.h | 4 ++-- .../testing/selftests/resctrl/resctrl_tests.c | 18 +++++++----------- 4 files changed, 13 insertions(+), 17 deletions(-)
tools/testing/selftests/resctrl/mba_test.c +2 -2
@@ -141,7 +141,7 @@ void mba_test_cleanup(void)remove (RESULT_FILE_NAME ); } -int mba_schemata_change (int cpu_no,char *bw_report,char **benchmark_cmd) +int mba_schemata_change (int cpu_no,char **benchmark_cmd) {struct resctrl_val_param param = { .resctrl_val =MBA_STR ,
@@ -149,7 +149,7 @@ int mba_schemata_change(int cpu_no, char *bw_report, char **benchmark_cmd) .mongrp = "m1", .cpu_no = cpu_no, .filename = RESULT_FILE_NAME, - .bw_report = bw_report, + .bw_report = "reads", .setup = mba_setup };int ret;
tools/testing/selftests/resctrl/mbm_test.c +2 -2
@@ -109,7 +109,7 @@ void mbm_test_cleanup(void)remove (RESULT_FILE_NAME ); } -int mbm_bw_change (size_t span,int cpu_no,char *bw_report,char **benchmark_cmd) +int mbm_bw_change (size_t span,int cpu_no,char **benchmark_cmd) {struct resctrl_val_param param = { .resctrl_val =MBM_STR ,
@@ -118,7 +118,7 @@ int mbm_bw_change(size_t span, int cpu_no, char *bw_report, char **benchmark_cmd .span = span, .cpu_no = cpu_no, .filename = RESULT_FILE_NAME, - .bw_report = bw_report, + .bw_report = "reads", .setup = mbm_setup };int ret;
tools/testing/selftests/resctrl/resctrl.h +2 -2
@@ -93,10 +93,10 @@ int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags);int run_fill_buf (size_t span,int memflush,int op,bool once);int resctrl_val (char **benchmark_cmd,struct resctrl_val_param *param); -int mbm_bw_change (size_t span,int cpu_no,char *bw_report,char **benchmark_cmd); +int mbm_bw_change (size_t span,int cpu_no,char **benchmark_cmd);void tests_cleanup (void );void mbm_test_cleanup (void ); -int mba_schemata_change (int cpu_no,char *bw_report,char **benchmark_cmd); +int mba_schemata_change (int cpu_no,char **benchmark_cmd);void mba_test_cleanup (void );int get_cbm_mask (char *cache_type,char *cbm_mask);int get_cache_size (int cpu_no,char *cache_type,unsigned long *cache_size);
tools/testing/selftests/resctrl/resctrl_tests.c +7 -11
@@ -70,8 +70,7 @@ void tests_cleanup(void)cat_test_cleanup (); } -static void run_mbm_test (char **benchmark_cmd,size_t span, -int cpu_no,char *bw_report) +static void run_mbm_test (char **benchmark_cmd,size_t span,int cpu_no) {int res;
@@ -90,7 +89,7 @@ static void run_mbm_test(char **benchmark_cmd, size_t span, goto umount; } - res =mbm_bw_change (span, cpu_no, bw_report, benchmark_cmd); + res =mbm_bw_change (span, cpu_no, benchmark_cmd);ksft_test_result (!res,"MBM: bw change\n" );if ((get_vendor () ==ARCH_INTEL ) && res)ksft_print_msg ("Intel MBM may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n" );
@@ -99,7 +98,7 @@ static void run_mbm_test(char **benchmark_cmd, size_t span,umount_resctrlfs (); } -static void run_mba_test (char **benchmark_cmd,int cpu_no,char *bw_report) +static void run_mba_test (char **benchmark_cmd,int cpu_no) {int res;
@@ -118,7 +117,7 @@ static void run_mba_test(char **benchmark_cmd, int cpu_no, char *bw_report) goto umount; } - res =mba_schemata_change (cpu_no, bw_report, benchmark_cmd); + res =mba_schemata_change (cpu_no, benchmark_cmd);ksft_test_result (!res,"MBA: schemata change\n" ); umount:
@@ -179,9 +178,9 @@ static void run_cat_test(int cpu_no, int no_of_bits)int main (int argc,char **argv) {bool has_ben = false, mbm_test = true, mba_test = true, cmt_test = true; -char *benchmark_cmd[BENCHMARK_ARGS ], bw_report[64 ], bm_type[64 ];char benchmark_cmd_area[BENCHMARK_ARGS ][BENCHMARK_ARG_SIZE ];int c, cpu_no =1 , argc_new = argc, i, no_of_bits =0 ; +char *benchmark_cmd[BENCHMARK_ARGS ];int ben_ind, ben_count, tests =0 ;size_t span =250 *MB ;bool cat_test = true;
@@ -284,9 +283,6 @@ int main(int argc, char **argv) benchmark_cmd[5 ] =NULL ; } -sprintf (bw_report,"reads" ); -sprintf (bm_type,"fill_buf" ); -if (!check_resctrlfs_support ())return ksft_exit_skip ("resctrl FS does not exist. Enable X86_CPU_RESCTRL config option.\n" );
@@ -298,10 +294,10 @@ int main(int argc, char **argv)ksft_set_plan (tests ? :4 );if (mbm_test) -run_mbm_test (benchmark_cmd, span, cpu_no, bw_report); +run_mbm_test (benchmark_cmd, span, cpu_no);if (mba_test) -run_mba_test (benchmark_cmd, cpu_no, bw_report); +run_mba_test (benchmark_cmd, cpu_no);if (cmt_test)run_cmt_test (benchmark_cmd, cpu_no);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 409/530 selftests/resctrl: Simplify span lifetime
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit b1a901e078c4ee4a6fe13021c4577ef5f3155251 ]
struct resctrl_val_param contains span member. resctrl_val(), however, never uses it because the value of span is embedded into the default benchmark command and parsed from it by run_benchmark().
Remove span from resctrl_val_param. Provide DEFAULT_SPAN for the code that needs it. CMT and CAT tests communicate span that is different from the DEFAULT_SPAN between their internal functions which is converted into passing it directly as a parameter.
Stable-dep-of: 3aff51464455 ("selftests/resctrl: Extend signal handler coverage to unmount on receiving signal")
--- tools/testing/selftests/resctrl/cache.c | 5 +++-- tools/testing/selftests/resctrl/cat_test.c | 13 +++++++------ tools/testing/selftests/resctrl/cmt_test.c | 11 ++++++----- tools/testing/selftests/resctrl/mbm_test.c | 5 ++--- tools/testing/selftests/resctrl/resctrl.h | 8 ++++---- tools/testing/selftests/resctrl/resctrl_tests.c | 9 ++++----- 6 files changed, 26 insertions(+), 25 deletions(-)
tools/testing/selftests/resctrl/cache.c +3 -2
@@ -205,10 +205,11 @@ int measure_cache_vals(struct resctrl_val_param *param, int bm_pid)* cache_val: execute benchmark and measure LLC occupancy resctrl * and perf cache miss for the benchmark * @param: parameters passed to cache_val() +* @span: buffer size for the benchmark * * Return: 0 on success. non-zero on failure. */ -int cat_val (struct resctrl_val_param *param) +int cat_val (struct resctrl_val_param *param,size_t span) {int memflush =1 , operation =0 , ret =0 ;char *resctrl_val = param->resctrl_val;
@@ -245,7 +246,7 @@ int cat_val(struct resctrl_val_param *param)if (ret)break ; -if (run_fill_buf (param->span, memflush, operation, true)) { +if (run_fill_buf (span, memflush, operation, true)) {fprintf (stderr,"Error-running fill buffer\n" ); ret =-1 ; goto pe_close;
tools/testing/selftests/resctrl/cat_test.c +7 -6
@@ -41,7 +41,7 @@ static int cat_setup(struct resctrl_val_param *p)return ret; } -static int check_results (struct resctrl_val_param *param) +static int check_results (struct resctrl_val_param *param,size_t span) {char *token_array[8 ], temp[512 ];unsigned long sum_llc_perf_miss =0 ;
@@ -76,7 +76,7 @@ static int check_results(struct resctrl_val_param *param)fclose (fp); no_of_bits =count_bits (param->mask); -return show_cache_info (sum_llc_perf_miss, no_of_bits, param->span /64 , +return show_cache_info (sum_llc_perf_miss, no_of_bits, span /64 ,MAX_DIFF ,MAX_DIFF_PERCENT , runs -1 ,get_vendor () ==ARCH_INTEL , false); }
@@ -96,6 +96,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)char cbm_mask[256 ];int count_of_bits;char pipe_message; +size_t span;/* Get default cbm mask for L3/L2 cache */ ret =get_cbm_mask (cache_type, cbm_mask);
@@ -140,7 +141,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)/* Set param values for parent thread which will be allocated bitmask * with (max_bits - n) bits */ - param.span = cache_size * (count_of_bits - n) / count_of_bits; + span = cache_size * (count_of_bits - n) / count_of_bits;strcpy (param.ctrlgrp,"c2" );strcpy (param.mongrp,"m2" );strcpy (param.filename,RESULT_FILE_NAME2 );
@@ -162,7 +163,7 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type) param.mask = l_mask_1;strcpy (param.ctrlgrp,"c1" );strcpy (param.mongrp,"m1" ); - param.span = cache_size * n / count_of_bits; + span = cache_size * n / count_of_bits;strcpy (param.filename,RESULT_FILE_NAME1 ); param.num_of_runs =0 ; param.cpu_no = sibling_cpu_no;
@@ -176,9 +177,9 @@ int cat_perf_miss_val(int cpu_no, int n, char *cache_type)remove (param.filename); - ret =cat_val (¶m); + ret =cat_val (¶m, span);if (ret ==0 ) - ret =check_results (¶m); + ret =check_results (¶m, span);if (bm_pid ==0 ) {/* Tell parent that child is ready */
tools/testing/selftests/resctrl/cmt_test.c +6 -5
@@ -27,7 +27,7 @@ static int cmt_setup(struct resctrl_val_param *p)return 0 ; } -static int check_results (struct resctrl_val_param *param,int no_of_bits) +static int check_results (struct resctrl_val_param *param,size_t span,int no_of_bits) {char *token_array[8 ], temp[512 ];unsigned long sum_llc_occu_resc =0 ;
@@ -58,7 +58,7 @@ static int check_results(struct resctrl_val_param *param, int no_of_bits) }fclose (fp); -return show_cache_info (sum_llc_occu_resc, no_of_bits, param->span, +return show_cache_info (sum_llc_occu_resc, no_of_bits, span,MAX_DIFF ,MAX_DIFF_PERCENT , runs -1 , true, true); }
@@ -74,6 +74,7 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd)unsigned long long_mask;char cbm_mask[256 ];int count_of_bits; +size_t span;int ret; ret =get_cbm_mask ("L3" , cbm_mask);
@@ -102,13 +103,13 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) .cpu_no = cpu_no, .filename = RESULT_FILE_NAME, .mask = ~(long_mask << n) & long_mask, - .span = cache_size * n / count_of_bits, .num_of_runs = 0, .setup = cmt_setup, }; + span = cache_size * n / count_of_bits;if (strcmp (benchmark_cmd[0 ],"fill_buf" ) ==0 ) -sprintf (benchmark_cmd[1 ],"%zu" , param.span); +sprintf (benchmark_cmd[1 ],"%zu" , span);remove (RESULT_FILE_NAME );
@@ -116,7 +117,7 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd)if (ret) goto out; - ret =check_results (¶m, n); + ret =check_results (¶m, span, n); out:cmt_test_cleanup ();
tools/testing/selftests/resctrl/mbm_test.c +2 -3
@@ -109,13 +109,12 @@ void mbm_test_cleanup(void)remove (RESULT_FILE_NAME ); } -int mbm_bw_change (size_t span,int cpu_no,char **benchmark_cmd) +int mbm_bw_change (int cpu_no,char **benchmark_cmd) {struct resctrl_val_param param = { .resctrl_val =MBM_STR , .ctrlgrp ="c1" , .mongrp ="m1" , - .span = span, .cpu_no = cpu_no, .filename =RESULT_FILE_NAME , .bw_report ="reads" ,
@@ -129,7 +128,7 @@ int mbm_bw_change(size_t span, int cpu_no, char **benchmark_cmd)if (ret) goto out; - ret =check_results (span); + ret =check_results (DEFAULT_SPAN ); out:mbm_test_cleanup ();
tools/testing/selftests/resctrl/resctrl.h +4 -4
@@ -33,6 +33,8 @@#define END_OF_TESTS 1 +#define DEFAULT_SPAN (250 * MB) +#define PARENT_EXIT (err_msg) \ do { \ perror(err_msg); \
@@ -47,7 +49,6 @@* @ctrlgrp: Name of the control monitor group (con_mon grp) * @mongrp: Name of the monitor group (mon grp) * @cpu_no: CPU number to which the benchmark would be binded -* @span: Memory bytes accessed in each benchmark iteration * @filename: Name of file to which the o/p should be written * @bw_report: Bandwidth report type (reads vs writes) * @setup: Call back function to setup test environment
@@ -57,7 +58,6 @@ struct resctrl_val_param {char ctrlgrp[64 ];char mongrp[64 ];int cpu_no; -size_t span;char filename[64 ];char *bw_report;unsigned long mask;
@@ -93,7 +93,7 @@ int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu, int group_fd, unsigned long flags);int run_fill_buf (size_t span,int memflush,int op,bool once);int resctrl_val (char **benchmark_cmd,struct resctrl_val_param *param); -int mbm_bw_change (size_t span,int cpu_no,char **benchmark_cmd); +int mbm_bw_change (int cpu_no,char **benchmark_cmd);void tests_cleanup (void );void mbm_test_cleanup (void );int mba_schemata_change (int cpu_no,char **benchmark_cmd);
@@ -103,7 +103,7 @@ int get_cache_size(int cpu_no, char *cache_type, unsigned long *cache_size);void ctrlc_handler (int signum,siginfo_t *info,void *ptr);int signal_handler_register (void );void signal_handler_unregister (void ); -int cat_val (struct resctrl_val_param *param); +int cat_val (struct resctrl_val_param *param,size_t span);void cat_test_cleanup (void );int cat_perf_miss_val (int cpu_no,int no_of_bits,char *cache_type);int cmt_resctrl_val (int cpu_no,int n,char **benchmark_cmd);
tools/testing/selftests/resctrl/resctrl_tests.c +4 -5
@@ -70,7 +70,7 @@ void tests_cleanup(void)cat_test_cleanup (); } -static void run_mbm_test (char **benchmark_cmd,size_t span,int cpu_no) +static void run_mbm_test (char **benchmark_cmd,int cpu_no) {int res;
@@ -89,7 +89,7 @@ static void run_mbm_test(char **benchmark_cmd, size_t span, int cpu_no) goto umount; } - res =mbm_bw_change (span, cpu_no, benchmark_cmd); + res =mbm_bw_change (cpu_no, benchmark_cmd);ksft_test_result (!res,"MBM: bw change\n" );if ((get_vendor () ==ARCH_INTEL ) && res)ksft_print_msg ("Intel MBM may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n" );
@@ -182,7 +182,6 @@ int main(int argc, char **argv)int c, cpu_no =1 , argc_new = argc, i, no_of_bits =0 ;char *benchmark_cmd[BENCHMARK_ARGS ];int ben_ind, ben_count, tests =0 ; -size_t span =250 *MB ;bool cat_test = true;for (i =0 ; i < argc; i++) {
@@ -276,7 +275,7 @@ int main(int argc, char **argv) benchmark_cmd[i] = benchmark_cmd_area[i];strcpy (benchmark_cmd[0 ],"fill_buf" ); -sprintf (benchmark_cmd[1 ],"%zu" , span); +sprintf (benchmark_cmd[1 ],"%u" ,DEFAULT_SPAN );strcpy (benchmark_cmd[2 ],"1" );strcpy (benchmark_cmd[3 ],"0" );strcpy (benchmark_cmd[4 ],"false" );
@@ -294,7 +293,7 @@ int main(int argc, char **argv)ksft_set_plan (tests ? :4 );if (mbm_test) -run_mbm_test (benchmark_cmd, span, cpu_no); +run_mbm_test (benchmark_cmd, cpu_no);if (mba_test)run_mba_test (benchmark_cmd, cpu_no);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 410/530 selftests/resctrl: Make benchmark command const and build it with pointers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilpo Järvinen <[email protected]>
[ Upstream commit e33cb5702a9f287d829b0e9e6abe57f6a4aba6d2 ]
Benchmark command is used in multiple tests so it should not be mutated by the tests but CMT test alters span argument. Due to the order of tests (CMT test runs last), mutating the span argument in CMT test does not trigger any real problems currently.
Mark benchmark_cmd strings as const and setup the benchmark command using pointers. Because the benchmark command becomes const, the input arguments can be used directly. Besides being simpler, using the input arguments directly also removes the internal size restriction.
CMT test has to create a copy of the benchmark command before altering the benchmark command.
Stable-dep-of: 3aff51464455 ("selftests/resctrl: Extend signal handler coverage to unmount on receiving signal")
--- tools/testing/selftests/resctrl/cmt_test.c | 25 +++++++++--- tools/testing/selftests/resctrl/mba_test.c | 2 +- tools/testing/selftests/resctrl/mbm_test.c | 2 +- tools/testing/selftests/resctrl/resctrl.h | 10 +++-- .../testing/selftests/resctrl/resctrl_tests.c | 39 ++++++++----------- tools/testing/selftests/resctrl/resctrl_val.c | 10 ++++- 6 files changed, 53 insertions(+), 35 deletions(-)
tools/testing/selftests/resctrl/cmt_test.c +20 -5
@@ -68,14 +68,17 @@ void cmt_test_cleanup(void)remove (RESULT_FILE_NAME ); } -int cmt_resctrl_val (int cpu_no,int n,char **benchmark_cmd) +int cmt_resctrl_val (int cpu_no,int n,const char *const *benchmark_cmd) { +const char *const *cmd = benchmark_cmd; +const char *new_cmd[BENCHMARK_ARGS ];unsigned long cache_size =0 ;unsigned long long_mask; +char *span_str =NULL ;char cbm_mask[256 ];int count_of_bits;size_t span; -int ret; +int ret, i; ret =get_cbm_mask ("L3" , cbm_mask);if (ret)
@@ -108,12 +111,23 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) }; span = cache_size * n / count_of_bits; -if (strcmp (benchmark_cmd[0 ],"fill_buf" ) ==0 ) -sprintf (benchmark_cmd[1 ],"%zu" , span); + +if (strcmp (cmd[0 ],"fill_buf" ) ==0 ) { +/* Duplicate the command to be able to replace span in it */ +for (i =0 ; benchmark_cmd[i]; i++) + new_cmd[i] = benchmark_cmd[i]; + new_cmd[i] =NULL ; + + ret =asprintf (&span_str,"%zu" , span); +if (ret <0 ) +return -1 ; + new_cmd[1 ] = span_str; + cmd = new_cmd; + }remove (RESULT_FILE_NAME ); - ret =resctrl_val (benchmark_cmd, ¶m); + ret =resctrl_val (cmd, ¶m);if (ret) goto out;
@@ -121,6 +135,7 @@ int cmt_resctrl_val(int cpu_no, int n, char **benchmark_cmd) out:cmt_test_cleanup (); +free (span_str);return ret; }
tools/testing/selftests/resctrl/mba_test.c +1 -1
@@ -141,7 +141,7 @@ void mba_test_cleanup(void)remove (RESULT_FILE_NAME ); } -int mba_schemata_change (int cpu_no,char **benchmark_cmd) +int mba_schemata_change (int cpu_no,const char *const *benchmark_cmd) {struct resctrl_val_param param = { .resctrl_val =MBA_STR ,
tools/testing/selftests/resctrl/mbm_test.c +1 -1
@@ -109,7 +109,7 @@ void mbm_test_cleanup(void)remove (RESULT_FILE_NAME ); } -int mbm_bw_change (int cpu_no,char **benchmark_cmd) +int mbm_bw_change (int cpu_no,const char *const *benchmark_cmd) {struct resctrl_val_param param = { .resctrl_val =MBM_STR ,
tools/testing/selftests/resctrl/resctrl.h +6 -4
@@ -33,6 +33,8 @@#define END_OF_TESTS 1 +#define BENCHMARK_ARGS 64 +#define DEFAULT_SPAN (250 * MB)#define PARENT_EXIT (err_msg) \
@@ -92,11 +94,11 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp,int perf_event_open (struct perf_event_attr *hw_event,pid_t pid,int cpu,int group_fd,unsigned long flags);int run_fill_buf (size_t span,int memflush,int op,bool once); -int resctrl_val (char **benchmark_cmd,struct resctrl_val_param *param); -int mbm_bw_change (int cpu_no,char **benchmark_cmd); +int resctrl_val (const char *const *benchmark_cmd,struct resctrl_val_param *param); +int mbm_bw_change (int cpu_no,const char *const *benchmark_cmd);void tests_cleanup (void );void mbm_test_cleanup (void ); -int mba_schemata_change (int cpu_no,char **benchmark_cmd); +int mba_schemata_change (int cpu_no,const char *const *benchmark_cmd);void mba_test_cleanup (void );int get_cbm_mask (char *cache_type,char *cbm_mask);int get_cache_size (int cpu_no,char *cache_type,unsigned long *cache_size);
@@ -106,7 +108,7 @@ void signal_handler_unregister(void);int cat_val (struct resctrl_val_param *param,size_t span);void cat_test_cleanup (void );int cat_perf_miss_val (int cpu_no,int no_of_bits,char *cache_type); -int cmt_resctrl_val (int cpu_no,int n,char **benchmark_cmd); +int cmt_resctrl_val (int cpu_no,int n,const char *const *benchmark_cmd);unsigned int count_bits (unsigned long n);void cmt_test_cleanup (void );int get_core_sibling (int cpu_no);
tools/testing/selftests/resctrl/resctrl_tests.c +17 -22
@@ -10,9 +10,6 @@*/ #include "resctrl.h" -#define BENCHMARK_ARGS 64 -#define BENCHMARK_ARG_SIZE 64 -static int detect_vendor (void ) {FILE *inf =fopen ("/proc/cpuinfo" ,"r" );
@@ -70,7 +67,7 @@ void tests_cleanup(void)cat_test_cleanup (); } -static void run_mbm_test (char **benchmark_cmd,int cpu_no) +static void run_mbm_test (const char *const *benchmark_cmd,int cpu_no) {int res;
@@ -98,7 +95,7 @@ static void run_mbm_test(char **benchmark_cmd, int cpu_no)umount_resctrlfs (); } -static void run_mba_test (char **benchmark_cmd,int cpu_no) +static void run_mba_test (const char *const *benchmark_cmd,int cpu_no) {int res;
@@ -124,7 +121,7 @@ static void run_mba_test(char **benchmark_cmd, int cpu_no)umount_resctrlfs (); } -static void run_cmt_test (char **benchmark_cmd,int cpu_no) +static void run_cmt_test (const char *const *benchmark_cmd,int cpu_no) {int res;
@@ -178,11 +175,12 @@ static void run_cat_test(int cpu_no, int no_of_bits)int main (int argc,char **argv) {bool has_ben = false, mbm_test = true, mba_test = true, cmt_test = true; -char benchmark_cmd_area[BENCHMARK_ARGS ][BENCHMARK_ARG_SIZE ];int c, cpu_no =1 , argc_new = argc, i, no_of_bits =0 ; -char *benchmark_cmd[BENCHMARK_ARGS ]; +const char *benchmark_cmd[BENCHMARK_ARGS ];int ben_ind, ben_count, tests =0 ; +char *span_str =NULL ;bool cat_test = true; +int ret;for (i =0 ; i < argc; i++) {if (strcmp (argv[i],"-b" ) ==0 ) {
@@ -262,23 +260,19 @@ int main(int argc, char **argv)ksft_exit_fail_msg ("Too long benchmark command.\n" );/* Extract benchmark command from command line. */ -for (i = ben_ind; i < argc; i++) { - benchmark_cmd[i - ben_ind] = benchmark_cmd_area[i]; -if (strlen (argv[i]) >=BENCHMARK_ARG_SIZE ) -ksft_exit_fail_msg ("Too long benchmark command argument.\n" ); -sprintf (benchmark_cmd[i - ben_ind],"%s" , argv[i]); - } +for (i =0 ; i < argc - ben_ind; i++) + benchmark_cmd[i] = argv[i + ben_ind]; benchmark_cmd[ben_count] =NULL ; }else {/* If no benchmark is given by "-b" argument, use fill_buf. */ -for (i =0 ; i <5 ; i++) - benchmark_cmd[i] = benchmark_cmd_area[i]; - -strcpy (benchmark_cmd[0 ],"fill_buf" ); -sprintf (benchmark_cmd[1 ],"%u" ,DEFAULT_SPAN ); -strcpy (benchmark_cmd[2 ],"1" ); -strcpy (benchmark_cmd[3 ],"0" ); -strcpy (benchmark_cmd[4 ],"false" ); + benchmark_cmd[0 ] ="fill_buf" ; + ret =asprintf (&span_str,"%u" ,DEFAULT_SPAN ); +if (ret <0 ) +ksft_exit_fail_msg ("Out of memory!\n" ); + benchmark_cmd[1 ] = span_str; + benchmark_cmd[2 ] ="1" ; + benchmark_cmd[3 ] ="0" ; + benchmark_cmd[4 ] ="false" ; benchmark_cmd[5 ] =NULL ; }
@@ -304,5 +298,6 @@ int main(int argc, char **argv)if (cat_test)run_cat_test (cpu_no, no_of_bits); +free (span_str);ksft_finished (); }
tools/testing/selftests/resctrl/resctrl_val.c +8 -2
@@ -629,7 +629,7 @@ measure_vals(struct resctrl_val_param *param, unsigned long *bw_resc_start)* * Return: 0 on success. non-zero on failure. */ -int resctrl_val (char **benchmark_cmd,struct resctrl_val_param *param) +int resctrl_val (const char *const *benchmark_cmd,struct resctrl_val_param *param) {char *resctrl_val = param->resctrl_val;unsigned long bw_resc_start =0 ;
@@ -710,7 +710,13 @@ int resctrl_val(char **benchmark_cmd, struct resctrl_val_param *param)if (ret) goto out; - value.sival_ptr = benchmark_cmd; +/* +* The cast removes constness but nothing mutates benchmark_cmd within +* the context of this process. At the receiving process, it becomes +* argv, which is mutable, on exec() but that's after fork() so it +* doesn't matter for the process running the tests. +*/ + value.sival_ptr = (void *)benchmark_cmd;/* Taskset benchmark to specified cpu */ ret =taskset_benchmark (bm_pid, param->cpu_no);
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 401/530 apparmor: pass cred through to audit info.
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Johansen <[email protected]>
[ Upstream commit 90c436a64a6e20482a9a613c47eb4af2e8a5328e ]
The cred is needed to properly audit some messages, and will be needed in the future for uid conditional mediation. So pass it through to where the apparmor_audit_data struct gets defined.
Stable-dep-of: 157a3537d6bc ("apparmor: Fix regression in mount mediation")
--- security/apparmor/apparmorfs.c | 11 ++- security/apparmor/capability.c | 5 +- security/apparmor/domain.c | 97 +++++++++++------- security/apparmor/file.c | 131 +++++++++++++++++-------- security/apparmor/include/audit.h | 1 + security/apparmor/include/capability.h | 3 +- security/apparmor/include/file.h | 17 ++-- security/apparmor/include/ipc.h | 4 +- security/apparmor/include/mount.h | 21 ++-- security/apparmor/include/net.h | 6 +- security/apparmor/include/policy.h | 9 +- security/apparmor/include/resource.h | 3 +- security/apparmor/include/task.h | 3 +- security/apparmor/ipc.c | 14 ++- security/apparmor/lsm.c | 85 +++++++++------- security/apparmor/mount.c | 85 ++++++++++------ security/apparmor/net.c | 17 ++-- security/apparmor/policy.c | 33 ++++--- security/apparmor/resource.c | 23 +++-- security/apparmor/task.c | 31 +++--- 20 files changed, 388 insertions(+), 211 deletions(-)
security/apparmor/apparmorfs.c +7 -4
@@ -423,7 +423,7 @@ static ssize_t policy_update(u32 mask, const char __user *buf, size_t size,/* high level check about policy management - fine grained in * below after unpack */ - error =aa_may_manage_policy (label, ns, mask); + error =aa_may_manage_policy (current_cred (), label, ns, mask);if (error) goto end_section;
@@ -486,7 +486,8 @@ static ssize_t profile_remove(struct file *f, const char __user *buf,/* high level check about policy management - fine grained in * below after unpack */ - error =aa_may_manage_policy (label, ns,AA_MAY_REMOVE_POLICY ); + error =aa_may_manage_policy (current_cred (), label, ns, +AA_MAY_REMOVE_POLICY );if (error) goto out;
@@ -1805,7 +1806,8 @@ static int ns_mkdir_op(struct mnt_idmap *idmap, struct inode *dir,int error; label =begin_current_label_crit_section (); - error =aa_may_manage_policy (label,NULL ,AA_MAY_LOAD_POLICY ); + error =aa_may_manage_policy (current_cred (), label,NULL , +AA_MAY_LOAD_POLICY );end_current_label_crit_section (label);if (error)return error;
@@ -1854,7 +1856,8 @@ static int ns_rmdir_op(struct inode *dir, struct dentry *dentry)int error; label =begin_current_label_crit_section (); - error =aa_may_manage_policy (label,NULL ,AA_MAY_LOAD_POLICY ); + error =aa_may_manage_policy (current_cred (), label,NULL , +AA_MAY_LOAD_POLICY );end_current_label_crit_section (label);if (error)return error;
security/apparmor/capability.c +4 -1
@@ -140,6 +140,7 @@ static int profile_capable(struct aa_profile *profile, int cap,/** * aa_capable - test permission to use capability +* @subj_cread: cred we are testing capability against * @label: label being tested for capability (NOT NULL) * @cap: capability to be tested * @opts: CAP_OPT_NOAUDIT bit determines whether audit record is generated
@@ -148,12 +149,14 @@ static int profile_capable(struct aa_profile *profile, int cap,* * Returns: 0 on success, or else an error code. */ -int aa_capable (struct aa_label *label,int cap,unsigned int opts) +int aa_capable (const struct cred *subj_cred,struct aa_label *label, +int cap,unsigned int opts) {struct aa_profile *profile;int error =0 ;DEFINE_AUDIT_DATA (ad,LSM_AUDIT_DATA_CAP ,AA_CLASS_CAP ,OP_CAPABLE ); + ad.subj_cred = subj_cred; ad.common.u.cap = cap; error =fn_for_each_confined (label, profile,profile_capable (profile, cap, opts, &ad));
security/apparmor/domain.c +64 -33
325 lines not on this page · raw message
security/apparmor/file.c +88 -43
345 lines not on this page · raw message
security/apparmor/include/audit.h +1 -0
@@ -109,6 +109,7 @@ struct apparmor_audit_data {int type;u16 class;const char *op; +const struct cred *subj_cred;struct aa_label *subj_label;const char *name;const char *info;
security/apparmor/include/capability.h +2 -1
@@ -36,7 +36,8 @@ struct aa_caps {extern struct aa_sfs_entry aa_sfs_entry_caps[]; -int aa_capable (struct aa_label *label,int cap,unsigned int opts); +int aa_capable (const struct cred *subj_cred,struct aa_label *label, +int cap,unsigned int opts);static inline void aa_free_cap_rules (struct aa_caps *caps) {
security/apparmor/include/file.h +10 -7
@@ -108,7 +108,8 @@ struct path_cond {#define COMBINED_PERM_MASK (X ) ((X).allow | (X).audit | (X).quiet | (X).kill) -int aa_audit_file (struct aa_profile *profile,struct aa_perms *perms, +int aa_audit_file (const struct cred *cred, +struct aa_profile *profile,struct aa_perms *perms,const char *op,u32 request,const char *name,const char *target,struct aa_label *tlabel,kuid_t ouid,const char *info,int error);
@@ -119,14 +120,16 @@ aa_state_t aa_str_perms(struct aa_policydb *file_rules, aa_state_t start, const char *name, struct path_cond *cond, struct aa_perms *perms); -int aa_path_perm (const char *op,struct aa_label *label, -const struct path *path,int flags,u32 request, -struct path_cond *cond); +int aa_path_perm (const char *op,const struct cred *subj_cred, +struct aa_label *label,const struct path *path, +int flags,u32 request,struct path_cond *cond); -int aa_path_link (struct aa_label *label,struct dentry *old_dentry, -const struct path *new_dir,struct dentry *new_dentry); +int aa_path_link (const struct cred *subj_cred,struct aa_label *label, +struct dentry *old_dentry,const struct path *new_dir, +struct dentry *new_dentry); -int aa_file_perm (const char *op,struct aa_label *label,struct file *file, +int aa_file_perm (const char *op,const struct cred *subj_cred, +struct aa_label *label,struct file *file,u32 request,bool in_atomic);void aa_inherit_files (const struct cred *cred,struct files_struct *files);
security/apparmor/include/ipc.h +3 -1
@@ -13,6 +13,8 @@#include <linux/sched.h> -int aa_may_signal (struct aa_label *sender,struct aa_label *target,int sig); +int aa_may_signal (const struct cred *subj_cred,struct aa_label *sender, +const struct cred *target_cred,struct aa_label *target, +int sig);#endif /* __AA_IPC_H */
security/apparmor/include/mount.h +14 -7
@@ -25,26 +25,33 @@#define AA_MS_IGNORE_MASK (MS_KERNMOUNT | MS_NOSEC | MS_ACTIVE | MS_BORN) -int aa_remount (struct aa_label *label,const struct path *path, +int aa_remount (const struct cred *subj_cred, +struct aa_label *label,const struct path *path,unsigned long flags,void *data); -int aa_bind_mount (struct aa_label *label,const struct path *path, +int aa_bind_mount (const struct cred *subj_cred, +struct aa_label *label,const struct path *path,const char *old_name,unsigned long flags); -int aa_mount_change_type (struct aa_label *label,const struct path *path, +int aa_mount_change_type (const struct cred *subj_cred, +struct aa_label *label,const struct path *path,unsigned long flags); -int aa_move_mount (struct aa_label *label,const struct path *path, +int aa_move_mount (const struct cred *subj_cred, +struct aa_label *label,const struct path *path,const char *old_name); -int aa_new_mount (struct aa_label *label,const char *dev_name, +int aa_new_mount (const struct cred *subj_cred, +struct aa_label *label,const char *dev_name,const struct path *path,const char *type,unsigned long flags,void *data); -int aa_umount (struct aa_label *label,struct vfsmount *mnt,int flags); +int aa_umount (const struct cred *subj_cred, +struct aa_label *label,struct vfsmount *mnt,int flags); -int aa_pivotroot (struct aa_label *label,const struct path *old_path, +int aa_pivotroot (const struct cred *subj_cred, +struct aa_label *label,const struct path *old_path,const struct path *new_path);#endif /* __AA_MOUNT_H */
security/apparmor/include/net.h +4 -2
@@ -93,7 +93,8 @@ void audit_net_cb(struct audit_buffer *ab, void *va);int aa_profile_af_perm (struct aa_profile *profile,struct apparmor_audit_data *ad,u32 request,u16 family,int type); -int aa_af_perm (struct aa_label *label,const char *op,u32 request,u16 family, +int aa_af_perm (const struct cred *subj_cred,struct aa_label *label, +const char *op,u32 request,u16 family,int type,int protocol); static inline int aa_profile_af_sk_perm(struct aa_profile *profile, struct apparmor_audit_data *ad,
@@ -105,7 +106,8 @@ static inline int aa_profile_af_sk_perm(struct aa_profile *profile, }int aa_sk_perm (const char *op,u32 request,struct sock *sk); -int aa_sock_file_perm (struct aa_label *label,const char *op,u32 request, +int aa_sock_file_perm (const struct cred *subj_cred,struct aa_label *label, +const char *op,u32 request,struct socket *sock); int apparmor_secmark_check(struct aa_label *label, char *op, u32 request,
security/apparmor/include/policy.h +6 -3
@@ -370,9 +370,12 @@ static inline int AUDIT_MODE(struct aa_profile *profile)return profile->audit; } -bool aa_policy_view_capable (struct aa_label *label,struct aa_ns *ns); -bool aa_policy_admin_capable (struct aa_label *label,struct aa_ns *ns); -int aa_may_manage_policy (struct aa_label *label,struct aa_ns *ns, +bool aa_policy_view_capable (const struct cred *subj_cred, +struct aa_label *label,struct aa_ns *ns); +bool aa_policy_admin_capable (const struct cred *subj_cred, +struct aa_label *label,struct aa_ns *ns); +int aa_may_manage_policy (const struct cred *subj_cred, +struct aa_label *label,struct aa_ns *ns,u32 mask);bool aa_current_policy_view_capable (struct aa_ns *ns);bool aa_current_policy_admin_capable (struct aa_ns *ns);
security/apparmor/include/resource.h +2 -1
@@ -33,7 +33,8 @@ struct aa_rlimit {extern struct aa_sfs_entry aa_sfs_entry_rlimit[];int aa_map_resource (int resource); -int aa_task_setrlimit (struct aa_label *label,struct task_struct *task, +int aa_task_setrlimit (const struct cred *subj_cred,struct aa_label *label, +struct task_struct *task,unsigned int resource,struct rlimit *new_rlim);void __aa_transition_rlimits (struct aa_label *old,struct aa_label *new);
security/apparmor/include/task.h +2 -1
@@ -91,7 +91,8 @@ static inline void aa_clear_task_ctx_trans(struct aa_task_ctx *ctx)"segv usr2 pipe alrm term stkflt chld cont stop stp ttin ttou urg " \"xcpu xfsz vtalrm prof winch io pwr sys emt lost" -int aa_may_ptrace(struct aa_label *tracer, struct aa_label *tracee, +int aa_may_ptrace(const struct cred *tracer_cred, struct aa_label *tracer, + const struct cred *tracee_cred, struct aa_label *tracee, u32 request);
security/apparmor/ipc.c +10 -4
@@ -75,7 +75,8 @@ static void audit_signal_cb(struct audit_buffer *ab, void *va) FLAGS_NONE, GFP_ATOMIC); } -static int profile_signal_perm (struct aa_profile *profile, +static int profile_signal_perm (const struct cred *cred, +struct aa_profile *profile,struct aa_label *peer,u32 request,struct apparmor_audit_data *ad) {
@@ -88,6 +89,7 @@ static int profile_signal_perm(struct aa_profile *profile, !ANY_RULE_MEDIATES(&profile->rules, AA_CLASS_SIGNAL))return 0 ; + ad->subj_cred = cred; ad->peer = peer;/* TODO: secondary cache check <profile, profile, perm> */ state = aa_dfa_next(rules->policy.dfa,
@@ -98,7 +100,9 @@ static int profile_signal_perm(struct aa_profile *profile,return aa_check_perms (profile, &perms, request, ad, audit_signal_cb); } -int aa_may_signal (struct aa_label *sender,struct aa_label *target,int sig) +int aa_may_signal (const struct cred *subj_cred,struct aa_label *sender, +const struct cred *target_cred,struct aa_label *target, +int sig) {struct aa_profile *profile;DEFINE_AUDIT_DATA (ad,LSM_AUDIT_DATA_NONE ,AA_CLASS_SIGNAL ,OP_SIGNAL );
@@ -106,6 +110,8 @@ int aa_may_signal(struct aa_label *sender, struct aa_label *target, int sig) ad.signal =map_signal_num (sig); ad.unmappedsig = sig;return xcheck_labels (sender, target, profile, -profile_signal_perm (profile, target,MAY_WRITE , &ad), -profile_signal_perm (profile, sender,MAY_READ , &ad)); +profile_signal_perm (subj_cred, profile, target, +MAY_WRITE , &ad), +profile_signal_perm (target_cred, profile, sender, +MAY_READ , &ad)); }
security/apparmor/lsm.c +52 -33
208 lines not on this page · raw message
security/apparmor/mount.c +55 -30
248 lines not on this page · raw message
security/apparmor/net.c +10 -7
@@ -135,8 +135,8 @@ int aa_profile_af_perm(struct aa_profile *profile,return aa_check_perms (profile, &perms, request, ad, audit_net_cb); } -int aa_af_perm (struct aa_label *label,const char *op,u32 request,u16 family, -int type,int protocol) +int aa_af_perm (const struct cred *subj_cred,struct aa_label *label, +const char *op,u32 request,u16 family,int type,int protocol) {struct aa_profile *profile;DEFINE_AUDIT_NET (ad, op,NULL , family, type, protocol);
@@ -146,7 +146,9 @@ int aa_af_perm(struct aa_label *label, const char *op, u32 request, u16 family, type)); } -static int aa_label_sk_perm (struct aa_label *label,const char *op,u32 request, +static int aa_label_sk_perm (const struct cred *subj_cred, +struct aa_label *label, +const char *op,u32 request,struct sock *sk) {struct aa_sk_ctx *ctx =SK_CTX (sk);
@@ -159,6 +161,7 @@ static int aa_label_sk_perm(struct aa_label *label, const char *op, u32 request,struct aa_profile *profile;DEFINE_AUDIT_SK (ad, op, sk); + ad.subj_cred = subj_cred; error =fn_for_each_confined (label, profile,aa_profile_af_sk_perm (profile, &ad, request, sk)); }
@@ -176,21 +179,21 @@ int aa_sk_perm(const char *op, u32 request, struct sock *sk)/* TODO: switch to begin_current_label ???? */ label =begin_current_label_crit_section (); - error =aa_label_sk_perm (label, op, request, sk); + error =aa_label_sk_perm (current_cred (), label, op, request, sk);end_current_label_crit_section (label);return error; } -int aa_sock_file_perm (struct aa_label *label,const char *op,u32 request, -struct socket *sock) +int aa_sock_file_perm (const struct cred *subj_cred,struct aa_label *label, +const char *op,u32 request,struct socket *sock) {AA_BUG (!label);AA_BUG (!sock);AA_BUG (!sock->sk); -return aa_label_sk_perm (label, op, request, sock->sk); +return aa_label_sk_perm (subj_cred, label, op, request, sock->sk); }#ifdef CONFIG_NETWORK_SECMARK
security/apparmor/policy.c +20 -13
@@ -762,21 +762,23 @@ static int audit_policy(struct aa_label *subj_label, const char *op,/* don't call out to other LSMs in the stack for apparmor policy admin * permissions */ -static int policy_ns_capable (struct aa_label *label, +static int policy_ns_capable (const struct cred *subj_cred, +struct aa_label *label,struct user_namespace *userns,int cap) {int err;/* check for MAC_ADMIN cap in cred */ - err =cap_capable (current_cred (), userns, cap,CAP_OPT_NONE ); + err =cap_capable (subj_cred, userns, cap,CAP_OPT_NONE );if (!err) - err =aa_capable (label, cap,CAP_OPT_NONE ); + err =aa_capable (subj_cred, label, cap,CAP_OPT_NONE );return err; }/** * aa_policy_view_capable - check if viewing policy in at @ns is allowed +* @subj_cred: cred of subject * @label: label that is trying to view policy in ns * @ns: namespace being viewed by @label (may be NULL if @label's ns) *
@@ -785,9 +787,10 @@ static int policy_ns_capable(struct aa_label *label,* If @ns is NULL then the namespace being viewed is assumed to be the * tasks current namespace. */ -bool aa_policy_view_capable (struct aa_label *label,struct aa_ns *ns) +bool aa_policy_view_capable (const struct cred *subj_cred, +struct aa_label *label,struct aa_ns *ns) { -struct user_namespace *user_ns =current_user_ns (); +struct user_namespace *user_ns = subj_cred->user_ns;struct aa_ns *view_ns =labels_view (label);bool root_in_user_ns =uid_eq (current_euid (),make_kuid (user_ns,0 )) ||in_egroup_p (make_kgid (user_ns,0 ));
@@ -804,15 +807,17 @@ bool aa_policy_view_capable(struct aa_label *label, struct aa_ns *ns)return response; } -bool aa_policy_admin_capable (struct aa_label *label,struct aa_ns *ns) +bool aa_policy_admin_capable (const struct cred *subj_cred, +struct aa_label *label,struct aa_ns *ns) { -struct user_namespace *user_ns =current_user_ns (); -bool capable =policy_ns_capable (label, user_ns,CAP_MAC_ADMIN ) ==0 ; +struct user_namespace *user_ns = subj_cred->user_ns; +bool capable =policy_ns_capable (subj_cred, label, user_ns, +CAP_MAC_ADMIN ) ==0 ;AA_DEBUG ("cap_mac_admin? %d\n" , capable);AA_DEBUG ("policy locked? %d\n" , aa_g_lock_policy); -return aa_policy_view_capable (label, ns) && capable && +return aa_policy_view_capable (subj_cred, label, ns) && capable && !aa_g_lock_policy; }
@@ -822,7 +827,7 @@ bool aa_current_policy_view_capable(struct aa_ns *ns)bool res; label =__begin_current_label_crit_section (); - res =aa_policy_view_capable (label, ns); + res =aa_policy_view_capable (current_cred (), label, ns);__end_current_label_crit_section (label);return res;
@@ -834,7 +839,7 @@ bool aa_current_policy_admin_capable(struct aa_ns *ns)bool res; label =__begin_current_label_crit_section (); - res =aa_policy_admin_capable (label, ns); + res =aa_policy_admin_capable (current_cred (), label, ns);__end_current_label_crit_section (label);return res;
@@ -842,13 +847,15 @@ bool aa_current_policy_admin_capable(struct aa_ns *ns)/** * aa_may_manage_policy - can the current task manage policy +* @subj_cred; subjects cred * @label: label to check if it can manage policy * @ns: namespace being managed by @label (may be NULL if @label's ns) * @mask: contains the policy manipulation operation being done * * Returns: 0 if the task is allowed to manipulate policy else error */ -int aa_may_manage_policy (struct aa_label *label,struct aa_ns *ns,u32 mask) +int aa_may_manage_policy (const struct cred *subj_cred,struct aa_label *label, +struct aa_ns *ns,u32 mask) {const char *op;
@@ -864,7 +871,7 @@ int aa_may_manage_policy(struct aa_label *label, struct aa_ns *ns, u32 mask)return audit_policy (label, op,NULL ,NULL ,"policy_locked" , -EACCES ); -if (!aa_policy_admin_capable (label, ns)) +if (!aa_policy_admin_capable (subj_cred, label, ns))return audit_policy (label, op,NULL ,NULL ,"not policy admin" , -EACCES );
security/apparmor/resource.c +15 -8
@@ -43,6 +43,7 @@ static void audit_cb(struct audit_buffer *ab, void *va)/** * audit_resource - audit setting resource limit +* @subj_cred: cred setting the resource * @profile: profile being enforced (NOT NULL) * @resource: rlimit being auditing * @value: value being set
@@ -52,13 +53,15 @@ static void audit_cb(struct audit_buffer *ab, void *va)* * Returns: 0 or ad->error else other error code on failure */ -static int audit_resource (struct aa_profile *profile,unsigned int resource, +static int audit_resource (const struct cred *subj_cred, +struct aa_profile *profile,unsigned int resource,unsigned long value,struct aa_label *peer,const char *info,int error) {DEFINE_AUDIT_DATA (ad,LSM_AUDIT_DATA_NONE ,AA_CLASS_RLIMITS ,OP_SETRLIMIT ); + ad.subj_cred = subj_cred; ad.rlim.rlim = resource; ad.rlim.max = value; ad.peer = peer;
@@ -82,7 +85,8 @@ int aa_map_resource(int resource)return rlim_map[resource]; } -static int profile_setrlimit (struct aa_profile *profile,unsigned int resource, +static int profile_setrlimit (const struct cred *subj_cred, +struct aa_profile *profile,unsigned int resource,struct rlimit *new_rlim) { struct aa_ruleset *rules = list_first_entry(&profile->rules,
@@ -92,12 +96,13 @@ static int profile_setrlimit(struct aa_profile *profile, unsigned int resource,if (rules->rlimits.mask & (1 << resource) && new_rlim->rlim_max > rules->rlimits.limits[resource].rlim_max) e = -EACCES ; -return audit_resource (profile, resource, new_rlim->rlim_max,NULL ,NULL , - e); +return audit_resource (subj_cred, profile, resource, new_rlim->rlim_max, +NULL ,NULL , e); }/** * aa_task_setrlimit - test permission to set an rlimit +* @subj_cred: cred setting the limit * @label: label confining the task (NOT NULL) * @task: task the resource is being set on * @resource: the resource being set
@@ -107,7 +112,8 @@ static int profile_setrlimit(struct aa_profile *profile, unsigned int resource,* * Returns: 0 or error code if setting resource failed */ -int aa_task_setrlimit (struct aa_label *label,struct task_struct *task, +int aa_task_setrlimit (const struct cred *subj_cred,struct aa_label *label, +struct task_struct *task,unsigned int resource,struct rlimit *new_rlim) {struct aa_profile *profile;
@@ -126,14 +132,15 @@ int aa_task_setrlimit(struct aa_label *label, struct task_struct *task,*/ if (label != peer && -aa_capable (label,CAP_SYS_RESOURCE ,CAP_OPT_NOAUDIT ) !=0 ) +aa_capable (subj_cred, label,CAP_SYS_RESOURCE ,CAP_OPT_NOAUDIT ) !=0 ) error =fn_for_each (label, profile, -audit_resource (profile, resource, +audit_resource (subj_cred, profile, resource, new_rlim->rlim_max, peer,"cap_sys_resource" , -EACCES ));else error =fn_for_each_confined (label, profile, -profile_setrlimit (profile, resource, new_rlim)); +profile_setrlimit (subj_cred, profile, resource, + new_rlim));aa_put_label (peer);return error;
security/apparmor/task.c +19 -12
@@ -226,14 +226,16 @@ static void audit_ptrace_cb(struct audit_buffer *ab, void *va)/* assumes check for RULE_MEDIATES is already done */ /* TODO: conditionals */ -static int profile_ptrace_perm (struct aa_profile *profile, -struct aa_label *peer,u32 request, -struct apparmor_audit_data *ad) +static int profile_ptrace_perm (const struct cred *cred, +struct aa_profile *profile, +struct aa_label *peer,u32 request, +struct apparmor_audit_data *ad) {struct aa_ruleset *rules =list_first_entry (&profile->rules,typeof (*rules), list);struct aa_perms perms = { }; + ad->subj_cred = cred; ad->peer = peer;aa_profile_match_label (profile, rules, peer,AA_CLASS_PTRACE , request, &perms);
@@ -241,7 +243,8 @@ static int profile_ptrace_perm(struct aa_profile *profile,return aa_check_perms (profile, &perms, request, ad, audit_ptrace_cb); } -static int profile_tracee_perm (struct aa_profile *tracee, +static int profile_tracee_perm (const struct cred *cred, +struct aa_profile *tracee,struct aa_label *tracer,u32 request,struct apparmor_audit_data *ad) {
@@ -249,10 +252,11 @@ static int profile_tracee_perm(struct aa_profile *tracee, !ANY_RULE_MEDIATES(&tracee->rules, AA_CLASS_PTRACE))return 0 ; -return profile_ptrace_perm (tracee, tracer, request, ad); +return profile_ptrace_perm (cred, tracee, tracer, request, ad); } -static int profile_tracer_perm (struct aa_profile *tracer, +static int profile_tracer_perm (const struct cred *cred, +struct aa_profile *tracer,struct aa_label *tracee,u32 request,struct apparmor_audit_data *ad) {
@@ -260,7 +264,7 @@ static int profile_tracer_perm(struct aa_profile *tracer,return 0 ;if (ANY_RULE_MEDIATES (&tracer->rules,AA_CLASS_PTRACE )) -return profile_ptrace_perm (tracer, tracee, request, ad); +return profile_ptrace_perm (cred, tracer, tracee, request, ad);/* profile uses the old style capability check for ptrace */ if (&tracer->label == tracee)
@@ -269,8 +273,8 @@ static int profile_tracer_perm(struct aa_profile *tracer, ad->subj_label = &tracer->label; ad->peer = tracee; ad->request =0 ; - ad->error =aa_capable (&tracer->label,CAP_SYS_PTRACE , -CAP_OPT_NONE ); + ad->error =aa_capable (cred, &tracer->label,CAP_SYS_PTRACE , +CAP_OPT_NONE );return aa_audit (AUDIT_APPARMOR_AUTO , tracer, ad, audit_ptrace_cb); }
@@ -283,7 +287,8 @@ static int profile_tracer_perm(struct aa_profile *tracer,* * Returns: %0 else error code if permission denied or error */ -int aa_may_ptrace (struct aa_label *tracer,struct aa_label *tracee, +int aa_may_ptrace (const struct cred *tracer_cred,struct aa_label *tracer, +const struct cred *tracee_cred,struct aa_label *tracee,u32 request) {struct aa_profile *profile;
@@ -291,6 +296,8 @@ int aa_may_ptrace(struct aa_label *tracer, struct aa_label *tracee,DEFINE_AUDIT_DATA (sa,LSM_AUDIT_DATA_NONE ,AA_CLASS_PTRACE ,OP_PTRACE );return xcheck_labels (tracer, tracee, profile, -profile_tracer_perm (profile, tracee, request, &sa), -profile_tracee_perm (profile, tracer, xrequest, &sa)); +profile_tracer_perm (tracer_cred, profile, tracee, + request, &sa), +profile_tracee_perm (tracee_cred, profile, tracer, + xrequest, &sa)); }
Signature · 1 line
2.42.0
Greg Kroah-Hartman
maintainerPATCH 429/530 cifs: Fix encryption of cleared, but unset rq_iter data buffers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Howells <[email protected]>
commit 37de5a80e932f828c34abeaae63170d73930dca3 upstream.
Each smb_rqst struct contains two things: an array of kvecs (rq_iov) that contains the protocol data for an RPC op and an iterator (rq_iter) that contains the data payload of an RPC op. When an smb_rqst is allocated rq_iter is it always cleared, but we don't set it up unless we're going to use it.
The functions that determines the size of the ciphertext buffer that will be needed to encrypt a request, cifs_get_num_sgs(), assumes that rq_iter is always initialised - and employs user_backed_iter() to check that the iterator isn't user-backed. This used to incidentally work, because ->user_backed was set to false because the iterator has never been initialised, but with commit f1b4cb650b9a0eeba206d8f069fcdc532bfbcd74[1] which changes user_backed_iter() to determine this based on the iterator type insted, a warning is now emitted:
WARNING: CPU: 7 PID: 4584 at fs/smb/client/cifsglob.h:2165 smb2_get_aead_req+0x3fc/0x420 [cifs]
...
RIP: 0010:smb2_get_aead_req+0x3fc/0x420 [cifs]
...
crypt_message+0x33e/0x550 [cifs]
smb3_init_transform_rq+0x27d/0x3f0 [cifs]
smb_send_rqst+0xc7/0x160 [cifs]
compound_send_recv+0x3ca/0x9f0 [cifs]
cifs_send_recv+0x25/0x30 [cifs]
SMB2_tcon+0x38a/0x820 [cifs]
cifs_get_smb_ses+0x69c/0xee0 [cifs]
cifs_mount_get_session+0x76/0x1d0 [cifs]
dfs_mount_share+0x74/0x9d0 [cifs]
cifs_mount+0x6e/0x2e0 [cifs]
cifs_smb3_do_mount+0x143/0x300 [cifs]
smb3_get_tree+0x15e/0x290 [cifs]
vfs_get_tree+0x2d/0xe0
do_new_mount+0x124/0x340
__se_sys_mount+0x143/0x1a0The problem is that rq_iter was never set, so the type is 0 (ie. ITER_UBUF) which causes user_backed_iter() to return true. The code doesn't malfunction because it checks the size of the iterator - which is 0.
Fix cifs_get_num_sgs() to ignore rq_iter if its count is 0, thereby bypassing the warnings.
It might be better to explicitly initialise rq_iter to a zero-length ITER_BVEC, say, as it can always be reinitialised later.
--- fs/smb/client/cifsglob.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
fs/smb/client/cifsglob.h +9 -3
@@ -2143,6 +2143,7 @@ static inline int cifs_get_num_sgs(constunsigned int len, skip;unsigned int nents =0 ;unsigned long addr; +size_t data_size;int i, j;/*
@@ -2158,17 +2159,21 @@ static inline int cifs_get_num_sgs(const* rqst[1+].rq_iov[0+] data to be encrypted/decrypted */ for (i =0 ; i < num_rqst; i++) { + data_size =iov_iter_count (&rqst[i].rq_iter); +/* We really don't want a mixture of pinned and unpinned pages * in the sglist. It's hard to keep track of which is what. * Instead, we convert to a BVEC-type iterator higher up. */ -if (WARN_ON_ONCE (user_backed_iter (&rqst[i].rq_iter))) +if (data_size && +WARN_ON_ONCE (user_backed_iter (&rqst[i].rq_iter)))return -EIO ;/* We also don't want to have any extra refs or pins to clean * up in the sglist. */ -if (WARN_ON_ONCE (iov_iter_extract_will_pin (&rqst[i].rq_iter))) +if (data_size && +WARN_ON_ONCE (iov_iter_extract_will_pin (&rqst[i].rq_iter)))return -EIO ;for (j =0 ; j < rqst[i].rq_nvec; j++) {
@@ -2184,7 +2189,8 @@ static inline int cifs_get_num_sgs(const } skip =0 ; } - nents +=iov_iter_npages (&rqst[i].rq_iter,INT_MAX ); +if (data_size) + nents +=iov_iter_npages (&rqst[i].rq_iter,INT_MAX ); } nents +=DIV_ROUND_UP (offset_in_page (sig) +SMB2_SIGNATURE_SIZE ,PAGE_SIZE );return nents;
Greg Kroah-Hartman
maintainerPATCH 438/530 Revert ncsi: Propagate carrier gain/loss events to the NCSI controller
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johnathan Mantey <[email protected]>
commit 9e2e7efbbbff69d8340abb56d375dd79d1f5770f upstream.
This reverts commit 3780bb29311eccb7a1c9641032a112eed237f7e3.
The cited commit introduced unwanted behavior.
The intent for the commit was to be able to detect carrier loss/gain for just the NIC connected to the BMC. The unwanted effect is a carrier loss for auxiliary paths also causes the BMC to lose carrier. The BMC never regains carrier despite the secondary NIC regaining a link.
This change, when merged, needs to be backported to stable kernels. 5.4-stable, 5.10-stable, 5.15-stable, 6.1-stable, 6.5-stable
--- net/ncsi/ncsi-aen.c | 5 ----- 1 file changed, 5 deletions(-)
net/ncsi/ncsi-aen.c +0 -5
@@ -89,11 +89,6 @@ static int ncsi_aen_handler_lsc(struct nif ((had_link == has_link) || chained)return 0 ; -if (had_link) -netif_carrier_off (ndp->ndev.dev); -else -netif_carrier_on (ndp->ndev.dev); -if (!ndp->multi_package && !nc->package->multi_channel) {if (had_link) { ndp->flags |=NCSI_DEV_RESHUFFLE ;
Greg Kroah-Hartman
maintainerPATCH 439/530 Revert "i2c: pxa: move to generic GPIO recovery"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Marko <[email protected]>
commit 7b211c7671212cad0b83603c674838c7e824d845 upstream.
This reverts commit 0b01392c18b9993a584f36ace1d61118772ad0ca.
Conversion of PXA to generic I2C recovery, makes the I2C bus completely lock up if recovery pinctrl is present in the DT and I2C recovery is enabled.
So, until the generic I2C recovery can also work with PXA lets revert to have working I2C and I2C recovery again.
--- drivers/i2c/busses/i2c-pxa.c | 76 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 8 deletions(-)
drivers/i2c/busses/i2c-pxa.c +68 -8
@@ -264,6 +264,9 @@ struct pxa_i2c {u32 hs_mask;struct i2c_bus_recovery_info recovery; +struct pinctrl *pinctrl; +struct pinctrl_state *pinctrl_default; +struct pinctrl_state *pinctrl_recovery; };#define _IBMR (i2c) ((i2c)->reg_ibmr)
@@ -1300,12 +1303,13 @@ static void i2c_pxa_prepare_recovery(str*/ gpiod_set_value (i2c->recovery.scl_gpiod, ibmr &IBMR_SCLS );gpiod_set_value (i2c->recovery.sda_gpiod, ibmr &IBMR_SDAS ); + +WARN_ON (pinctrl_select_state (i2c->pinctrl, i2c->pinctrl_recovery)); }static void i2c_pxa_unprepare_recovery (struct i2c_adapter *adap) {struct pxa_i2c *i2c = adap->algo_data; -struct i2c_bus_recovery_info *bri = adap->bus_recovery_info;u32 isr;/*
@@ -1319,7 +1323,7 @@ static void i2c_pxa_unprepare_recovery(si2c_pxa_do_reset (i2c); } -WARN_ON (pinctrl_select_state (bri->pinctrl, bri->pins_default)); +WARN_ON (pinctrl_select_state (i2c->pinctrl, i2c->pinctrl_default));dev_dbg (&i2c->adap.dev,"recovery: IBMR 0x%08x ISR 0x%08x\n" ,readl (_IBMR (i2c)),readl (_ISR (i2c)));
@@ -1341,20 +1345,76 @@ static int i2c_pxa_init_recovery(structif (IS_ENABLED (CONFIG_I2C_PXA_SLAVE ))return 0 ; - bri->pinctrl =devm_pinctrl_get (dev); -if (PTR_ERR (bri->pinctrl) == -ENODEV ) { - bri->pinctrl =NULL ; + i2c->pinctrl =devm_pinctrl_get (dev); +if (PTR_ERR (i2c->pinctrl) == -ENODEV ) + i2c->pinctrl =NULL ; +if (IS_ERR (i2c->pinctrl)) +return PTR_ERR (i2c->pinctrl); + +if (!i2c->pinctrl) +return 0 ; + + i2c->pinctrl_default =pinctrl_lookup_state (i2c->pinctrl, +PINCTRL_STATE_DEFAULT ); + i2c->pinctrl_recovery =pinctrl_lookup_state (i2c->pinctrl,"recovery" ); + +if (IS_ERR (i2c->pinctrl_default) ||IS_ERR (i2c->pinctrl_recovery)) { +dev_info (dev,"missing pinmux recovery information: %ld %ld\n" , +PTR_ERR (i2c->pinctrl_default), +PTR_ERR (i2c->pinctrl_recovery)); +return 0 ; + } + +/* +* Claiming GPIOs can influence the pinmux state, and may glitch the +* I2C bus. Do this carefully. +*/ + bri->scl_gpiod =devm_gpiod_get (dev,"scl" ,GPIOD_OUT_HIGH_OPEN_DRAIN ); +if (bri->scl_gpiod ==ERR_PTR (-EPROBE_DEFER )) +return -EPROBE_DEFER ; +if (IS_ERR (bri->scl_gpiod)) { +dev_info (dev,"missing scl gpio recovery information: %pe\n" , + bri->scl_gpiod); +return 0 ; + } + +/* +* We have SCL. Pull SCL low and wait a bit so that SDA glitches +* have no effect. +*/ +gpiod_direction_output (bri->scl_gpiod,0 ); +udelay (10 ); + bri->sda_gpiod =devm_gpiod_get (dev,"sda" ,GPIOD_OUT_HIGH_OPEN_DRAIN ); + +/* Wait a bit in case of a SDA glitch, and then release SCL. */ +udelay (10 ); +gpiod_direction_output (bri->scl_gpiod,1 ); + +if (bri->sda_gpiod ==ERR_PTR (-EPROBE_DEFER )) +return -EPROBE_DEFER ; + +if (IS_ERR (bri->sda_gpiod)) { +dev_info (dev,"missing sda gpio recovery information: %pe\n" , + bri->sda_gpiod);return 0 ; } -if (IS_ERR (bri->pinctrl)) -return PTR_ERR (bri->pinctrl); bri->prepare_recovery = i2c_pxa_prepare_recovery; bri->unprepare_recovery = i2c_pxa_unprepare_recovery; + bri->recover_bus = i2c_generic_scl_recovery; i2c->adap.bus_recovery_info = bri; -return 0 ; +/* +* Claiming GPIOs can change the pinmux state, which confuses the +* pinctrl since pinctrl's idea of the current setting is unaffected +* by the pinmux change caused by claiming the GPIO. Work around that +* by switching pinctrl to the GPIO state here. We do it this way to +* avoid glitching the I2C bus. +*/ +pinctrl_select_state (i2c->pinctrl, i2c->pinctrl_recovery); + +return pinctrl_select_state (i2c->pinctrl, i2c->pinctrl_default); }static int i2c_pxa_probe (struct platform_device *dev)
Greg Kroah-Hartman
maintainerPATCH 440/530 lsm: fix default return value for vm_enough_memory
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ondrej Mosnacek <[email protected]>
commit 866d648059d5faf53f1cd960b43fe8365ad93ea7 upstream.
1 is the return value that implements a "no-op" hook, not 0.
--- include/linux/lsm_hook_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/lsm_hook_defs.h +1 -1
@@ -48,7 +48,7 @@ LSM_HOOK(int, 0, quota_on, struct dentry LSM_HOOK(int, 0, syslog, int type) LSM_HOOK(int, 0, settime, const struct timespec64 *ts, const struct timezone *tz) -LSM_HOOK(int, 0, vm_enough_memory, struct mm_struct *mm, long pages) +LSM_HOOK(int, 1, vm_enough_memory, struct mm_struct *mm, long pages) LSM_HOOK(int, 0, bprm_creds_for_exec, struct linux_binprm *bprm) LSM_HOOK(int, 0, bprm_creds_from_file, struct linux_binprm *bprm, struct file *file) LSM_HOOK(int, 0, bprm_check_security, struct linux_binprm *bprm)
Greg Kroah-Hartman
maintainerPATCH 441/530 lsm: fix default return value for inode_getsecctx
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ondrej Mosnacek <[email protected]>
commit b36995b8609a5a8fe5cf259a1ee768fcaed919f8 upstream.
-EOPNOTSUPP is the return value that implements a "no-op" hook, not 0.
Without this fix having only the BPF LSM enabled (with no programs attached) can cause uninitialized variable reads in nfsd4_encode_fattr(), because the BPF hook returns 0 without touching the 'ctxlen' variable and the corresponding 'contextlen' variable in nfsd4_encode_fattr() remains uninitialized, yet being treated as valid based on the 0 return value.
--- include/linux/lsm_hook_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/lsm_hook_defs.h +1 -1
@@ -273,7 +273,7 @@ LSM_HOOK(void, LSM_RET_VOID, release_sec LSM_HOOK(void, LSM_RET_VOID, inode_invalidate_secctx, struct inode *inode) LSM_HOOK(int, 0, inode_notifysecctx, struct inode *inode, void *ctx, u32 ctxlen) LSM_HOOK(int, 0, inode_setsecctx, struct dentry *dentry, void *ctx, u32 ctxlen) -LSM_HOOK(int, 0, inode_getsecctx, struct inode *inode, void **ctx, +LSM_HOOK(int, -EOPNOTSUPP, inode_getsecctx, struct inode *inode, void **ctx, u32 *ctxlen)#if defined(CONFIG_SECURITY ) && defined(CONFIG_WATCH_QUEUE )
Greg Kroah-Hartman
maintainerPATCH 442/530 sbsa_gwdt: Calculate timeout with 64-bit math
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Darren Hart <[email protected]>
commit 5d6aa89bba5bd6af2580f872b57f438dab883738 upstream.
Commit abd3ac7902fb ("watchdog: sbsa: Support architecture version 1") introduced new timer math for watchdog revision 1 with the 48 bit offset register.
The gwdt->clk and timeout are u32, but the argument being calculated is u64. Without a cast, the compiler performs u32 operations, truncating intermediate steps, resulting in incorrect values.
A watchdog revision 1 implementation with a gwdt->clk of 1GHz and a timeout of 600s writes 3647256576 to the one shot watchdog instead of 300000000000, resulting in the watchdog firing in 3.6s instead of 600s.
Force u64 math by casting the first argument (gwdt->clk) as a u64. Make the order of operations explicit with parenthesis.
--- drivers/watchdog/sbsa_gwdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/watchdog/sbsa_gwdt.c +2 -2
@@ -152,14 +152,14 @@ static int sbsa_gwdt_set_timeout(struct timeout = clamp_t(unsigned int, timeout, 1, wdd->max_hw_heartbeat_ms / 1000);if (action) -sbsa_gwdt_reg_write (gwdt->clk * timeout, gwdt); +sbsa_gwdt_reg_write ((u64 )gwdt->clk * timeout, gwdt);else /* * In the single stage mode, The first signal (WS0) is ignored, * the timeout is (WOR * 2), so the WOR should be configured * to half value of timeout. */ -sbsa_gwdt_reg_write (gwdt->clk /2 * timeout, gwdt); +sbsa_gwdt_reg_write (((u64 )gwdt->clk /2 ) * timeout, gwdt);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 443/530 i2c: designware: Disable TX_EMPTY irq while waiting for block length byte
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tam Nguyen <[email protected]>
commit e8183fa10c25c7b3c20670bf2b430ddcc1ee03c0 upstream.
During SMBus block data read process, we have seen high interrupt rate because of TX_EMPTY irq status while waiting for block length byte (the first data byte after the address phase). The interrupt handler does not do anything because the internal state is kept as STATUS_WRITE_IN_PROGRESS. Hence, we should disable TX_EMPTY IRQ until I2C DesignWare receives first data byte from I2C device, then re-enable it to resume SMBus transaction.
It takes 0.789 ms for host to receive data length from slave. Without the patch, i2c_dw_isr() is called 99 times by TX_EMPTY interrupt. And it is none after applying the patch.
--- drivers/i2c/busses/i2c-designware-master.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-designware-master.c +16 -3
@@ -519,10 +519,16 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)/* * Because we don't know the buffer length in the -* I2C_FUNC_SMBUS_BLOCK_DATA case, we can't stop -* the transaction here. +* I2C_FUNC_SMBUS_BLOCK_DATA case, we can't stop the +* transaction here. Also disable the TX_EMPTY IRQ +* while waiting for the data length byte to avoid the +* bogus interrupts flood. */ -if (buf_len >0 || flags &I2C_M_RECV_LEN ) { +if (flags &I2C_M_RECV_LEN ) { + dev->status |=STATUS_WRITE_IN_PROGRESS ; + intr_mask &= ~DW_IC_INTR_TX_EMPTY ; +break ; + }else if (buf_len >0 ) {/* more bytes to be written */ dev->status |=STATUS_WRITE_IN_PROGRESS ;break ;
@@ -558,6 +564,13 @@ i2c_dw_recv_len(struct dw_i2c_dev *dev, msgs[dev->msg_read_idx].len = len; msgs[dev->msg_read_idx].flags &= ~I2C_M_RECV_LEN ; +/* +* Received buffer length, re-enable TX_EMPTY interrupt +* to resume the SMBUS transaction. +*/ +regmap_update_bits (dev->map,DW_IC_INTR_MASK ,DW_IC_INTR_TX_EMPTY , +DW_IC_INTR_TX_EMPTY ); +return len; }
Greg Kroah-Hartman
maintainerPATCH 444/530 s390/ap: fix AP bus crash on early config change callback invocation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harald Freudenberger <[email protected]>
commit e14aec23025eeb1f2159ba34dbc1458467c4c347 upstream.
Fix kernel crash in AP bus code caused by very early invocation of the config change callback function via SCLP.
After a fresh IML of the machine the crypto cards are still offline and will get switched online only with activation of any LPAR which has the card in it's configuration. A crypto card coming online is reported to the LPAR via SCLP and the AP bus offers a callback function to get this kind of information. However, it may happen that the callback is invoked before the AP bus init function is complete. As the callback triggers a synchronous AP bus scan, the scan may already run but some internal states are not initialized by the AP bus init function resulting in a crash like this:
[ 11.635859] Unable to handle kernel pointer dereference in virtual kernel address space [ 11.635861] Failing address: 0000000000000000 TEID: 0000000000000887 [ 11.635862] Fault in home space mode while using kernel ASCE. [ 11.635864] AS:00000000894c4007 R3:00000001fece8007 S:00000001fece7800 P:000000000000013d [ 11.635879] Oops: 0004 ilc:1 [#1] SMP [ 11.635882] Modules linked in: [ 11.635884] CPU: 5 PID: 42 Comm: kworker/5:0 Not tainted 6.6.0-rc3-00003-g4dbf7cdc6b42 #12 [ 11.635886] Hardware name: IBM 3931 A01 751 (LPAR) [ 11.635887] Workqueue: events_long ap_scan_bus [ 11.635891] Krnl PSW : 0704c00180000000 0000000000000000 (0x0) [ 11.635895] R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:0 PM:0 RI:0 EA:3 [ 11.635897] Krnl GPRS: 0000000001000a00 0000000000000000 0000000000000006 0000000089591940 [ 11.635899] 0000000080000000 0000000000000a00 0000000000000000 0000000000000000 [ 11.635901] 0000000081870c00 0000000089591000 000000008834e4e2 0000000002625a00 [ 11.635903] 0000000081734200 0000038000913c18 000000008834c6d6 0000038000913ac8 [ 11.635906] Krnl Code:>0000000000000000: 0000 illegal [ 11.635906] 0000000000000002: 0000 illegal [ 11.635906] 0000000000000004: 0000 illegal [ 11.635906] 0000000000000006: 0000 illegal [ 11.635906] 0000000000000008: 0000 illegal [ 11.635906] 000000000000000a: 0000 illegal [ 11.635906] 000000000000000c: 0000 illegal [ 11.635906] 000000000000000e: 0000 illegal [ 11.635915] Call Trace: [ 11.635916] [<0000000000000000>] 0x0 [ 11.635918] [<000000008834e4e2>] ap_queue_init_state+0x82/0xb8 [ 11.635921] [<000000008834ba1c>] ap_scan_domains+0x6fc/0x740 [ 11.635923] [<000000008834c092>] ap_scan_adapter+0x632/0x8b0 [ 11.635925] [<000000008834c3e4>] ap_scan_bus+0xd4/0x288 [ 11.635927] [<00000000879a33ba>] process_one_work+0x19a/0x410 [ 11.635930] Discipline DIAG cannot be used without z/VM [ 11.635930] [<00000000879a3a2c>] worker_thread+0x3fc/0x560 [ 11.635933] [<00000000879aea60>] kthread+0x120/0x128 [ 11.635936] [<000000008792afa4>] __ret_from_fork+0x3c/0x58 [ 11.635938] [<00000000885ebe62>] ret_from_fork+0xa/0x30 [ 11.635942] Last Breaking-Event-Address: [ 11.635942] [<000000008834c6d4>] ap_wait+0xcc/0x148
This patch improves the ap_bus_force_rescan() function which is invoked by the config change callback by checking if a first initial AP bus scan has been done. If not, the force rescan request is simple ignored. Anyhow it does not make sense to trigger AP bus re-scans even before the very first bus scan is complete.
--- drivers/s390/crypto/ap_bus.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/s390/crypto/ap_bus.c +4 -0
@@ -1022,6 +1022,10 @@ EXPORT_SYMBOL(ap_driver_unregister);void ap_bus_force_rescan (void ) { +/* Only trigger AP bus scans after the initial scan is done */ +if (atomic64_read (&ap_scan_bus_count) <=0 ) +return ; +/* processing a asynchronous bus rescan */ del_timer (&ap_config_timer);queue_work (system_long_wq, &ap_scan_work);
Greg Kroah-Hartman
maintainerPATCH 445/530 net: ethtool: Fix documentation of ethtool_sprintf()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Lunn <[email protected]>
commit f55d8e60f10909dbc5524e261041e1d28d7d20d8 upstream.
This function takes a pointer to a pointer, unlike sprintf() which is passed a plain pointer. Fix up the documentation to make this clear.
--- include/linux/ethtool.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/ethtool.h +2 -2
@@ -1045,10 +1045,10 @@ static inline int ethtool_mm_frag_size_m/** * ethtool_sprintf - Write formatted string to ethtool string data -* @data: Pointer to start of string to update +* @data: Pointer to a pointer to the start of string to update * @fmt: Format of string to write * -* Write formatted string to data. Update data to point at start of +* Write formatted string to *data. Update *data to point at start of * next string. */ extern __printf(2, 3) void ethtool_sprintf(u8 **data, const char *fmt, ...);
Greg Kroah-Hartman
maintainerPATCH 446/530 net: dsa: lan9303: consequently nested-lock physical MDIO
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander Sverdlin <[email protected]>
commit 5a22fbcc10f3f7d94c5d88afbbffa240a3677057 upstream.
When LAN9303 is MDIO-connected two callchains exist into mdio->bus->write():
1. switch ports 1&2 ("physical" PHYs):
virtual (switch-internal) MDIO bus (lan9303_switch_ops->phy_{read|write})->
lan9303_mdio_phy_{read|write} -> mdiobus_{read|write}_nested
2. LAN9303 virtual PHY:
virtual MDIO bus (lan9303_phy_{read|write}) ->
lan9303_virt_phy_reg_{read|write} -> regmap -> lan9303_mdio_{read|write}
If the latter functions just take mutex_lock(&sw_dev->device->bus->mdio_lock) it triggers a LOCKDEP false-positive splat. It's false-positive because the first mdio_lock in the second callchain above belongs to virtual MDIO bus, the second mdio_lock belongs to physical MDIO bus.
Consequent annotation in lan9303_mdio_{read|write} as nested lock (similar to lan9303_mdio_phy_{read|write}, it's the same physical MDIO bus) prevents the following splat:
WARNING: possible circular locking dependency detected
5.15.71 #1 Not tainted
------------------------------------------------------
kworker/u4:3/609 is trying to acquire lock:ffff000011531c68 (lan9303_mdio:131:(&lan9303_mdio_regmap_config)->lock){+.+.}-{3:3}, at: regmap_lock_mutex but task is already holding lock:ffff0000114c44d8 (&bus->mdio_lock){+.+.}-{3:3}, at: mdiobus_read
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #1 (&bus->mdio_lock){+.+.}-{3:3}:
lock_acquire
__mutex_lock
mutex_lock_nested
lan9303_mdio_read
_regmap_read
regmap_read
lan9303_probe
lan9303_mdio_probe
mdio_probe
really_probe
__driver_probe_device
driver_probe_device
__device_attach_driver
bus_for_each_drv
__device_attach
device_initial_probe
bus_probe_device
deferred_probe_work_func
process_one_work
worker_thread
kthread
ret_from_fork
-> #0 (lan9303_mdio:131:(&lan9303_mdio_regmap_config)->lock){+.+.}-{3:3}:
__lock_acquire
lock_acquire.part.0
lock_acquire
__mutex_lock
mutex_lock_nested
regmap_lock_mutex
regmap_read
lan9303_phy_read
dsa_slave_phy_read
__mdiobus_read
mdiobus_read
get_phy_device
mdiobus_scan
__mdiobus_register
dsa_register_switch
lan9303_probe
lan9303_mdio_probe
mdio_probe
really_probe
__driver_probe_device
driver_probe_device
__device_attach_driver
bus_for_each_drv
__device_attach
device_initial_probe
bus_probe_device
deferred_probe_work_func
process_one_work
worker_thread
kthread
ret_from_fork
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&bus->mdio_lock);
lock(lan9303_mdio:131:(&lan9303_mdio_regmap_config)->lock);
lock(&bus->mdio_lock);
lock(lan9303_mdio:131:(&lan9303_mdio_regmap_config)->lock);
*** DEADLOCK ***
5 locks held by kworker/u4:3/609:
#0: ffff000002842938 ((wq_completion)events_unbound){+.+.}-{0:0}, at: process_one_work
#1: ffff80000bacbd60 (deferred_probe_work){+.+.}-{0:0}, at: process_one_work
#2: ffff000007645178 (&dev->mutex){....}-{3:3}, at: __device_attach
#3: ffff8000096e6e78 (dsa2_mutex){+.+.}-{3:3}, at: dsa_register_switch
#4: ffff0000114c44d8 (&bus->mdio_lock){+.+.}-{3:3}, at: mdiobus_read
stack backtrace:
CPU: 1 PID: 609 Comm: kworker/u4:3 Not tainted 5.15.71 #1
Workqueue: events_unbound deferred_probe_work_func
Call trace:
dump_backtrace
show_stack
dump_stack_lvl
dump_stack
print_circular_bug
check_noncircular
__lock_acquire
lock_acquire.part.0
lock_acquire
__mutex_lock
mutex_lock_nested
regmap_lock_mutex
regmap_read
lan9303_phy_read
dsa_slave_phy_read
__mdiobus_read
mdiobus_read
get_phy_device
mdiobus_scan
__mdiobus_register
dsa_register_switch
lan9303_probe
lan9303_mdio_probe...
--- drivers/net/dsa/lan9303_mdio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/dsa/lan9303_mdio.c +2 -2
@@ -32,7 +32,7 @@ static int lan9303_mdio_write(void *ctx,struct lan9303_mdio *sw_dev = (struct lan9303_mdio *)ctx; reg <<=2 ;/* reg num to offset */ -mutex_lock (&sw_dev->device->bus->mdio_lock); +mutex_lock_nested (&sw_dev->device->bus->mdio_lock,MDIO_MUTEX_NESTED );lan9303_mdio_real_write (sw_dev->device, reg, val &0xffff );lan9303_mdio_real_write (sw_dev->device, reg +2 , (val >>16 ) &0xffff );mutex_unlock (&sw_dev->device->bus->mdio_lock);
@@ -50,7 +50,7 @@ static int lan9303_mdio_read(void *ctx,struct lan9303_mdio *sw_dev = (struct lan9303_mdio *)ctx; reg <<=2 ;/* reg num to offset */ -mutex_lock (&sw_dev->device->bus->mdio_lock); +mutex_lock_nested (&sw_dev->device->bus->mdio_lock,MDIO_MUTEX_NESTED ); *val =lan9303_mdio_real_read (sw_dev->device, reg); *val |= (lan9303_mdio_real_read (sw_dev->device, reg +2 ) <<16 );mutex_unlock (&sw_dev->device->bus->mdio_lock);
Greg Kroah-Hartman
maintainerPATCH 447/530 net: phylink: initialize carrier state at creation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Klaus Kudielka <[email protected]>
commit 02d5fdbf4f2b8c406f7a4c98fa52aa181a11d733 upstream.
Background: Turris Omnia (Armada 385); eth2 (mvneta) connected to SFP bus; SFP module is present, but no fiber connected, so definitely no carrier.
After booting, eth2 is down, but netdev LED trigger surprisingly reports link active. Then, after "ip link set eth2 up", the link indicator goes away - as I would have expected it from the beginning.
It turns out, that the default carrier state after netdev creation is "carrier ok". Some ethernet drivers explicitly call netif_carrier_off during probing, others (like mvneta) don't - which explains the current
behaviour: only when the device is brought up, phylink_start calls netif_carrier_off.
Fix this for all drivers using phylink, by calling netif_carrier_off in phylink_create.
--- drivers/net/phy/phylink.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/phylink.c +1 -0
@@ -1631,6 +1631,7 @@ struct phylink *phylink_create(struct ph pl->config = config;if (config->type ==PHYLINK_NETDEV ) { pl->netdev =to_net_dev (config->dev); +netif_carrier_off (pl->netdev); }else if (config->type ==PHYLINK_DEV ) { pl->dev = config->dev; }else {
Greg Kroah-Hartman
maintainerPATCH 430/530 xfs: recovery should not clear di_flushiter unconditionally
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Chinner <[email protected]>
commit 7930d9e103700cde15833638855b750715c12091 upstream.
Because on v3 inodes, di_flushiter doesn't exist. It overlaps with zero padding in the inode, except when NREXT64=1 configurations are in use and the zero padding is no longer padding but holds the 64 bit extent counter.
This manifests obviously on big endian platforms (e.g. s390) because the log dinode is in host order and the overlap is the LSBs of the extent count field. It is not noticed on little endian machines because the overlap is at the MSB end of the extent count field and we need to get more than 2^^48 extents in the inode before it manifests. i.e. the heat death of the universe will occur before we see the problem in little endian machines.
This is a zero-day issue for NREXT64=1 configuraitons on big endian machines. Fix it by only clearing di_flushiter on v2 inodes during recovery.
--- fs/xfs/xfs_inode_item_recover.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
fs/xfs/xfs_inode_item_recover.c +17 -15
@@ -369,24 +369,26 @@ xlog_recover_inode_commit_pass2(* superblock flag to determine whether we need to look at di_flushiter * to skip replay when the on disk inode is newer than the log one */ -if (!xfs_has_v3inodes (mp) && - ldip->di_flushiter <be16_to_cpu (dip->di_flushiter)) { -/* -* Deal with the wrap case, DI_MAX_FLUSH is less -* than smaller numbers -*/ -if (be16_to_cpu (dip->di_flushiter) ==DI_MAX_FLUSH && - ldip->di_flushiter < (DI_MAX_FLUSH >>1 )) { -/* do nothing */ - }else { -trace_xfs_log_recover_inode_skip (log, in_f); - error =0 ; - goto out_release; +if (!xfs_has_v3inodes (mp)) { +if (ldip->di_flushiter <be16_to_cpu (dip->di_flushiter)) { +/* +* Deal with the wrap case, DI_MAX_FLUSH is less +* than smaller numbers +*/ +if (be16_to_cpu (dip->di_flushiter) ==DI_MAX_FLUSH && + ldip->di_flushiter < (DI_MAX_FLUSH >>1 )) { +/* do nothing */ + }else { +trace_xfs_log_recover_inode_skip (log, in_f); + error =0 ; + goto out_release; + } } + +/* Take the opportunity to reset the flush iteration count */ + ldip->di_flushiter =0 ; } -/* Take the opportunity to reset the flush iteration count */ - ldip->di_flushiter =0 ;if (unlikely (S_ISREG (ldip->di_mode))) { if ((ldip->di_format != XFS_DINODE_FMT_EXTENTS) &&
Greg Kroah-Hartman
maintainerPATCH 448/530 gfs2: dont withdraw if init_threads() got interrupted
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Gruenbacher <[email protected]>
commit 0cdc6f44e9fdc2d20d720145bf99a39f611f6d61 upstream.
In gfs2_fill_super(), when mounting a gfs2 filesystem is interrupted, kthread_create() can return -EINTR. When that happens, we roll back what has already been done and abort the mount.
Since commit 62dd0f98a0e5 ("gfs2: Flag a withdraw if init_threads() fails), we are calling gfs2_withdraw_delayed() in gfs2_fill_super(); first via gfs2_make_fs_rw(), then directly. But gfs2_withdraw_delayed() only marks the filesystem as withdrawing and relies on a caller further up the stack to do the actual withdraw, which doesn't exist in the gfs2_fill_super() case. Because the filesystem is marked as withdrawing / withdrawn, function gfs2_lm_unmount() doesn't release the dlm lockspace, so when we try to mount that filesystem again, we get:
gfs2: fsid=gohan:gohan0: Trying to join cluster "lock_dlm", "gohan:gohan0"
gfs2: fsid=gohan:gohan0: dlm_new_lockspace error -17
Since commit b77b4a4815a9 ("gfs2: Rework freeze / thaw logic"), the deadlock this gfs2_withdraw_delayed() call was supposed to work around cannot occur anymore because freeze_go_callback() won't take the sb->s_umount semaphore unconditionally anymore, so we can get rid of the gfs2_withdraw_delayed() in gfs2_fill_super() entirely.
--- fs/gfs2/ops_fstype.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/gfs2/ops_fstype.c +1 -3
@@ -1281,10 +1281,8 @@ static int gfs2_fill_super(struct super_if (!sb_rdonly (sb)) { error =init_threads (sdp); -if (error) { -gfs2_withdraw_delayed (sdp); +if (error) goto fail_per_node; - } } error =gfs2_freeze_lock_shared (sdp);
Greg Kroah-Hartman
maintainerPATCH 449/530 i2c: i801: fix potential race in i801_block_transaction_byte_by_byte
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
commit f78ca48a8ba9cdec96e8839351e49eec3233b177 upstream.
Currently we set SMBHSTCNT_LAST_BYTE only after the host has started receiving the last byte. If we get e.g. preempted before setting SMBHSTCNT_LAST_BYTE, the host may be finished with receiving the byte before SMBHSTCNT_LAST_BYTE is set.
Therefore change the code to set SMBHSTCNT_LAST_BYTE before writing SMBHSTSTS_BYTE_DONE for the byte before the last byte. Now the code is also consistent with what we do in i801_isr_byte_done().
--- drivers/i2c/busses/i2c-i801.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/i2c/busses/i2c-i801.c +9 -10
@@ -681,15 +681,11 @@ static int i801_block_transaction_byte_breturn result ? priv->status : -ETIMEDOUT ; } -for (i =1 ; i <= len; i++) { -if (i == len && read_write ==I2C_SMBUS_READ ) - smbcmd |=SMBHSTCNT_LAST_BYTE ; -outb_p (smbcmd,SMBHSTCNT (priv)); - -if (i ==1 ) -outb_p (inb (SMBHSTCNT (priv)) |SMBHSTCNT_START , -SMBHSTCNT (priv)); +if (len ==1 && read_write ==I2C_SMBUS_READ ) + smbcmd |=SMBHSTCNT_LAST_BYTE ; +outb_p (smbcmd |SMBHSTCNT_START ,SMBHSTCNT (priv)); +for (i =1 ; i <= len; i++) { status =i801_wait_byte_done (priv);if (status)return status;
@@ -712,9 +708,12 @@ static int i801_block_transaction_byte_b data->block[0 ] = len; } -/* Retrieve/store value in SMBBLKDAT */ -if (read_write ==I2C_SMBUS_READ ) +if (read_write ==I2C_SMBUS_READ ) { data->block[i] =inb_p (SMBBLKDAT (priv)); +if (i == len -1 ) +outb_p (smbcmd |SMBHSTCNT_LAST_BYTE ,SMBHSTCNT (priv)); + } +if (read_write ==I2C_SMBUS_WRITE && i+1 <= len)outb_p (data->block[i+1 ],SMBBLKDAT (priv));
Greg Kroah-Hartman
maintainerPATCH 450/530 f2fs: do not return EFSCORRUPTED, but try to run online repair
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaegeuk Kim <[email protected]>
commit 50a472bbc79ff9d5a88be8019a60e936cadf9f13 upstream.
If we return the error, there's no way to recover the status as of now, since fsck does not fix the xattr boundary issue.
--- fs/f2fs/node.c | 4 +++- fs/f2fs/xattr.c | 20 +++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-)
fs/f2fs/node.c +3 -1
@@ -2751,7 +2751,9 @@ recover_xnid:f2fs_update_inode_page (inode);/* 3: update and set xattr node page dirty */ -memcpy (F2FS_NODE (xpage),F2FS_NODE (page),VALID_XATTR_BLOCK_SIZE ); +if (page) +memcpy (F2FS_NODE (xpage),F2FS_NODE (page), +VALID_XATTR_BLOCK_SIZE );set_page_dirty (xpage);f2fs_put_page (xpage,1 );
fs/f2fs/xattr.c +13 -7
@@ -364,10 +364,10 @@ static int lookup_all_xattrs(struct inod *xe =__find_xattr (cur_addr, last_txattr_addr,NULL , index, len, name);if (!*xe) { -f2fs_err (F2FS_I_SB (inode),"inode (%lu) has corrupted xattr" , +f2fs_err (F2FS_I_SB (inode),"lookup inode (%lu) has corrupted xattr" , inode->i_ino);set_sbi_flag (F2FS_I_SB (inode),SBI_NEED_FSCK ); - err = -EFSCORRUPTED ; + err = -ENODATA ;f2fs_handle_error (F2FS_I_SB (inode),ERROR_CORRUPTED_XATTR ); goto out;
@@ -584,13 +584,12 @@ ssize_t f2fs_listxattr(struct dentry *deif ((void *)(entry) +sizeof (__u32) > last_base_addr || (void *)XATTR_NEXT_ENTRY (entry) > last_base_addr) { -f2fs_err (F2FS_I_SB (inode),"inode (%lu) has corrupted xattr" , +f2fs_err (F2FS_I_SB (inode),"list inode (%lu) has corrupted xattr" , inode->i_ino);set_sbi_flag (F2FS_I_SB (inode),SBI_NEED_FSCK ); - error = -EFSCORRUPTED ;f2fs_handle_error (F2FS_I_SB (inode),ERROR_CORRUPTED_XATTR ); - goto cleanup; +break ; }if (!prefix)
@@ -650,7 +649,7 @@ static int __f2fs_setxattr(struct inodeif (size >MAX_VALUE_LEN (inode))return -E2BIG ; - +retry: error =read_all_xattrs (inode, ipage, &base_addr);if (error)return error;
@@ -660,7 +659,14 @@ static int __f2fs_setxattr(struct inode/* find entry with wanted name. */ here =__find_xattr (base_addr, last_base_addr,NULL , index, len, name);if (!here) { -f2fs_err (F2FS_I_SB (inode),"inode (%lu) has corrupted xattr" , +if (!F2FS_I (inode)->i_xattr_nid) { +f2fs_notice (F2FS_I_SB (inode), +"recover xattr in inode (%lu)" , inode->i_ino); +f2fs_recover_xattr_data (inode,NULL ); +kfree (base_addr); + goto retry; + } +f2fs_err (F2FS_I_SB (inode),"set inode (%lu) has corrupted xattr" , inode->i_ino);set_sbi_flag (F2FS_I_SB (inode),SBI_NEED_FSCK ); error = -EFSCORRUPTED ;
Greg Kroah-Hartman
maintainerPATCH 451/530 f2fs: set the default compress_level on ioctl
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaegeuk Kim <[email protected]>
commit f5f3bd903a5d3e3b2ba89f11e0e29db25e60c048 upstream.
Otherwise, we'll get a broken inode.
# touch $FILE # f2fs_io setflags compression $FILE # f2fs_io set_coption 2 8 $FILE
[ 112.227612] F2FS-fs (dm-51): sanity_check_compress_inode: inode (ino=8d3fe) has unsupported compress level: 0, run fsck to fix
--- fs/f2fs/file.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/f2fs/file.c +9 -0
@@ -4006,6 +4006,15 @@ static int f2fs_ioc_set_compress_option(F2FS_I (inode)->i_compress_algorithm = option.algorithm;F2FS_I (inode)->i_log_cluster_size = option.log_cluster_size;F2FS_I (inode)->i_cluster_size =BIT (option.log_cluster_size); +/* Set default level */ +if (F2FS_I (inode)->i_compress_algorithm ==COMPRESS_ZSTD ) +F2FS_I (inode)->i_compress_level =F2FS_ZSTD_DEFAULT_CLEVEL ; +else +F2FS_I (inode)->i_compress_level =0 ; +/* Adjust mount option level */ +if (option.algorithm ==F2FS_OPTION (sbi).compress_algorithm && +F2FS_OPTION (sbi).compress_level) +F2FS_I (inode)->i_compress_level =F2FS_OPTION (sbi).compress_level;f2fs_mark_inode_dirty_sync (inode, true);if (!f2fs_is_compress_backend_ready (inode))
Greg Kroah-Hartman
maintainerPATCH 452/530 f2fs: avoid format-overflow warning
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Su Hui <[email protected]>
commit e0d4e8acb3789c5a8651061fbab62ca24a45c063 upstream.
With gcc and W=1 option, there's a warning like this:
fs/f2fs/compress.c: In function ‘f2fs_init_page_array_cache’:fs/f2fs/compress.c:1984:47: error: ‘%u’ directive writing between 1 and 7 bytes into a region of size between 5 and 8 [-Werror=format-overflow=]
1984 | sprintf(slab_name, "f2fs_page_array_entry-%u:%u", MAJOR(dev),
MINOR(dev));
| ^~String "f2fs_page_array_entry-%u:%u" can up to 35. The first "%u" can up to 4 and the second "%u" can up to 7, so total size is "24 + 4 + 7 = 35". slab_name's size should be 35 rather than 32.
--- fs/f2fs/compress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/compress.c +1 -1
@@ -1976,7 +1976,7 @@ void f2fs_destroy_compress_inode(structint f2fs_init_page_array_cache (struct f2fs_sb_info *sbi) {dev_t dev = sbi->sb->s_bdev->bd_dev; -char slab_name[32 ]; +char slab_name[35 ];if (!f2fs_sb_has_compression (sbi))return 0 ;
Greg Kroah-Hartman
maintainerPATCH 453/530 f2fs: split initial and dynamic conditions for extent_cache
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jaegeuk Kim <[email protected]>
commit f803982190f0265fd36cf84670aa6daefc2b0768 upstream.
Let's allocate the extent_cache tree without dynamic conditions to avoid a missing condition causing a panic as below.
# create a file w/ a compressed flag # disable the compression # panic while updating extent_cache
F2FS-fs (dm-64): Swapfile: last extent is not aligned to section
F2FS-fs (dm-64): Swapfile (3) is not align to section: 1) creat(), 2) ioctl(F2FS_IOC_SET_PIN_FILE), 3) fallocate(2097152 * N) Adding 124996k swap on ./swap-file. Priority:0 extents:2 across:17179494468k
==================================================================
BUG: KASAN: null-ptr-deref in instrument_atomic_read_write out/common/include/linux/instrumented.h:101 [inline] BUG: KASAN: null-ptr-deref in atomic_try_cmpxchg_acquire out/common/include/asm-generic/atomic-instrumented.h:705 [inline] BUG: KASAN: null-ptr-deref in queued_write_lock out/common/include/asm-generic/qrwlock.h:92 [inline] BUG: KASAN: null-ptr-deref in __raw_write_lock out/common/include/linux/rwlock_api_smp.h:211 [inline] BUG: KASAN: null-ptr-deref in _raw_write_lock+0x5a/0x110 out/common/kernel/locking/spinlock.c:295 Write of size 4 at addr 0000000000000030 by task syz-executor154/3327 CPU: 0 PID: 3327 Comm: syz-executor154 Tainted: G O 5.10.185 #1 Hardware name: emulation qemu-x86/qemu-x86, BIOS 2023.01-21885-gb3cc1cd24d 01/01/2023 Call Trace: __dump_stack out/common/lib/dump_stack.c:77 [inline] dump_stack_lvl+0x17e/0x1c4 out/common/lib/dump_stack.c:118 __kasan_report+0x16c/0x260 out/common/mm/kasan/report.c:415 kasan_report+0x51/0x70 out/common/mm/kasan/report.c:428 kasan_check_range+0x2f3/0x340 out/common/mm/kasan/generic.c:186 __kasan_check_write+0x14/0x20 out/common/mm/kasan/shadow.c:37 instrument_atomic_read_write out/common/include/linux/instrumented.h:101 [inline] atomic_try_cmpxchg_acquire out/common/include/asm-generic/atomic-instrumented.h:705 [inline] queued_write_lock out/common/include/asm-generic/qrwlock.h:92 [inline] __raw_write_lock out/common/include/linux/rwlock_api_smp.h:211 [inline] _raw_write_lock+0x5a/0x110 out/common/kernel/locking/spinlock.c:295 __drop_extent_tree+0xdf/0x2f0 out/common/fs/f2fs/extent_cache.c:1155 f2fs_drop_extent_tree+0x17/0x30 out/common/fs/f2fs/extent_cache.c:1172 f2fs_insert_range out/common/fs/f2fs/file.c:1600 [inline] f2fs_fallocate+0x19fd/0x1f40 out/common/fs/f2fs/file.c:1764 vfs_fallocate+0x514/0x9b0 out/common/fs/open.c:310 ksys_fallocate out/common/fs/open.c:333 [inline] __do_sys_fallocate out/common/fs/open.c:341 [inline] __se_sys_fallocate out/common/fs/open.c:339 [inline] __x64_sys_fallocate+0xb8/0x100 out/common/fs/open.c:339 do_syscall_64+0x35/0x50 out/common/arch/x86/entry/common.c:46
--- fs/f2fs/extent_cache.c | 53 +++++++++++++++++++------------------------------ 1 file changed, 21 insertions(+), 32 deletions(-)
fs/f2fs/extent_cache.c +21 -32
@@ -74,40 +74,14 @@ static void __set_extent_info(struct ext } } -static bool __may_read_extent_tree (struct inode *inode) -{ -struct f2fs_sb_info *sbi =F2FS_I_SB (inode); - -if (!test_opt (sbi,READ_EXTENT_CACHE )) -return false; -if (is_inode_flag_set (inode,FI_NO_EXTENT )) -return false; -if (is_inode_flag_set (inode,FI_COMPRESSED_FILE ) && - !f2fs_sb_has_readonly (sbi)) -return false; -return S_ISREG (inode->i_mode); -} - -static bool __may_age_extent_tree (struct inode *inode) -{ -struct f2fs_sb_info *sbi =F2FS_I_SB (inode); - -if (!test_opt (sbi,AGE_EXTENT_CACHE )) -return false; -if (is_inode_flag_set (inode,FI_COMPRESSED_FILE )) -return false; -if (file_is_cold (inode)) -return false; - -return S_ISREG (inode->i_mode) ||S_ISDIR (inode->i_mode); -} -static bool __init_may_extent_tree (struct inode *inode,enum extent_type type) {if (type ==EX_READ ) -return __may_read_extent_tree (inode); -else if (type ==EX_BLOCK_AGE ) -return __may_age_extent_tree (inode); +return test_opt (F2FS_I_SB (inode),READ_EXTENT_CACHE ) && +S_ISREG (inode->i_mode); +if (type ==EX_BLOCK_AGE ) +return test_opt (F2FS_I_SB (inode),AGE_EXTENT_CACHE ) && + (S_ISREG (inode->i_mode) ||S_ISDIR (inode->i_mode));return false; }
@@ -120,7 +94,22 @@ static bool __may_extent_tree(struct inoif (list_empty (&F2FS_I_SB (inode)->s_list))return false; -return __init_may_extent_tree (inode, type); +if (!__init_may_extent_tree (inode, type)) +return false; + +if (type ==EX_READ ) { +if (is_inode_flag_set (inode,FI_NO_EXTENT )) +return false; +if (is_inode_flag_set (inode,FI_COMPRESSED_FILE ) && + !f2fs_sb_has_readonly (F2FS_I_SB (inode))) +return false; + }else if (type ==EX_BLOCK_AGE ) { +if (is_inode_flag_set (inode,FI_COMPRESSED_FILE )) +return false; +if (file_is_cold (inode)) +return false; + } +return true; } static void __try_update_largest_extent(struct extent_tree *et,
Greg Kroah-Hartman
maintainerPATCH 454/530 media: lirc: drop trailing space from scancode transmit
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
commit c8a489f820179fb12251e262b50303c29de991ac upstream.
When transmitting, infrared drivers expect an odd number of samples; iow without a trailing space. No problems have been observed so far, so this is just belt and braces.
--- drivers/media/rc/lirc_dev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/media/rc/lirc_dev.c +5 -1
@@ -276,7 +276,11 @@ static ssize_t lirc_transmit(struct fileif (ret <0 ) goto out_kfree_raw; - count = ret; +/* drop trailing space */ +if (!(ret %2 )) + count = ret -1 ; +else + count = ret; txbuf =kmalloc_array (count,sizeof (unsigned int ),GFP_KERNEL );if (!txbuf) {
Greg Kroah-Hartman
maintainerPATCH 455/530 media: sharp: fix sharp encoding
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
commit 4f7efc71891462ab7606da7039f480d7c1584a13 upstream.
The Sharp protocol[1] encoding has incorrect timings for bit space.
[1] https://www.sbprojects.net/knowledge/ir/sharp.php
--- drivers/media/rc/ir-sharp-decoder.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/media/rc/ir-sharp-decoder.c +5 -3
@@ -15,7 +15,9 @@#define SHARP_UNIT 40/* us */ #define SHARP_BIT_PULSE (8 * SHARP_UNIT)/* 320us */ #define SHARP_BIT_0_PERIOD (25 * SHARP_UNIT)/* 1ms (680us space) */ -#define SHARP_BIT_1_PERIOD (50 * SHARP_UNIT)/* 2ms (1680ms space) */ +#define SHARP_BIT_1_PERIOD (50 * SHARP_UNIT)/* 2ms (1680us space) */ +#define SHARP_BIT_0_SPACE (17 * SHARP_UNIT)/* 680us space */ +#define SHARP_BIT_1_SPACE (42 * SHARP_UNIT)/* 1680us space */ #define SHARP_ECHO_SPACE (1000 * SHARP_UNIT)/* 40 ms */ #define SHARP_TRAILER_SPACE (125 * SHARP_UNIT)/* 5 ms (even longer) */
@@ -168,8 +170,8 @@ static const struct ir_raw_timings_pd ir .header_pulse = 0, .header_space = 0, .bit_pulse = SHARP_BIT_PULSE, - .bit_space[0] = SHARP_BIT_0_PERIOD, - .bit_space[1] = SHARP_BIT_1_PERIOD, + .bit_space[0] = SHARP_BIT_0_SPACE, + .bit_space[1] = SHARP_BIT_1_SPACE, .trailer_pulse = SHARP_BIT_PULSE, .trailer_space = SHARP_ECHO_SPACE, .msb_first = 1,
Greg Kroah-Hartman
maintainerPATCH 431/530 btrfs: zoned: wait for data BG to be finished on direct IO allocation
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naohiro Aota <[email protected]>
commit 776a838f1fa95670c1c1cf7109a898090b473fa3 upstream.
Running the fio command below on a ZNS device results in "Resource temporarily unavailable" error.
$ sudo fio --name=w --directory=/mnt --filesize=1GB --bs=16MB --numjobs=16 \
--rw=write --ioengine=libaio --iodepth=128 --direct=1 fio: io_u error on file /mnt/w.2.0: Resource temporarily unavailable: write offset=117440512, buflen=16777216
fio: io_u error on file /mnt/w.2.0: Resource temporarily unavailable: write offset=134217728, buflen=16777216
...
This happens because -EAGAIN error returned from btrfs_reserve_extent() called from btrfs_new_extent_direct() is spilling over to the userland.
btrfs_reserve_extent() returns -EAGAIN when there is no active zone available. Then, the caller should wait for some other on-going IO to finish a zone and retry the allocation.
This logic is already implemented for buffered write in cow_file_range(), but it is missing for the direct IO counterpart. Implement the same logic for it.
--- fs/btrfs/inode.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/btrfs/inode.c +7 -0
@@ -6974,8 +6974,15 @@ static struct extent_map *btrfs_new_exteint ret; alloc_hint =get_extent_allocation_hint (inode, start, len); +again: ret =btrfs_reserve_extent (root, len, len, fs_info->sectorsize,0 , alloc_hint, &ins,1 ,1 ); +if (ret == -EAGAIN ) { +ASSERT (btrfs_is_zoned (fs_info)); +wait_on_bit_io (&inode->root->fs_info->flags,BTRFS_FS_NEED_ZONE_FINISH , +TASK_UNINTERRUPTIBLE ); + goto again; + }if (ret)return ERR_PTR (ret);
Greg Kroah-Hartman
maintainerPATCH 432/530 ALSA: info: Fix potential deadlock at disconnection
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit c7a60651953359f98dbf24b43e1bf561e1573ed4 upstream.
As reported recently, ALSA core info helper may cause a deadlock at the forced device disconnection during the procfs operation.
The proc_remove() (that is called from the snd_card_disconnect() helper) has a synchronization of the pending procfs accesses via wait_for_completion(). Meanwhile, ALSA procfs helper takes the global mutex_lock(&info_mutex) at both the proc_open callback and snd_card_info_disconnect() helper. Since the proc_open can't finish due to the mutex lock, wait_for_completion() never returns, either, hence it deadlocks.
TASK#1 TASK#2 proc_reg_open() takes use_pde() snd_info_text_entry_open() snd_card_disconnect() snd_info_card_disconnect() takes mutex_lock(&info_mutex) proc_remove() wait_for_completion(unused_pde) ... waiting task#1 closes mutex_lock(&info_mutex) => DEADLOCK
This patch is a workaround for avoiding the deadlock scenario above.
The basic strategy is to move proc_remove() call outside the mutex lock. proc_remove() can work gracefully without extra locking, and it can delete the tree recursively alone. So, we call proc_remove() at snd_info_card_disconnection() at first, then delete the rest resources recursively within the info_mutex lock.
After the change, the function snd_info_disconnect() doesn't do disconnection by itself any longer, but it merely clears the procfs pointer. So rename the function to snd_info_clear_entries() for avoiding confusion.
The similar change is applied to snd_info_free_entry(), too. Since the proc_remove() is called only conditionally with the non-NULL entry->p, it's skipped after the snd_info_clear_entries() call.
--- sound/core/info.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
sound/core/info.c +13 -8
@@ -56,7 +56,7 @@ struct snd_info_private_data { };static int snd_info_version_init (void ); -static void snd_info_disconnect (struct snd_info_entry *entry); +static void snd_info_clear_entries (struct snd_info_entry *entry);/*
@@ -569,11 +569,16 @@ void snd_info_card_disconnect(struct snd {if (!card)return ; -mutex_lock (&info_mutex); +proc_remove (card->proc_root_link); - card->proc_root_link =NULL ;if (card->proc_root) -snd_info_disconnect (card->proc_root); +proc_remove (card->proc_root->p); + +mutex_lock (&info_mutex); +if (card->proc_root) +snd_info_clear_entries (card->proc_root); + card->proc_root_link =NULL ; + card->proc_root =NULL ;mutex_unlock (&info_mutex); }
@@ -745,15 +750,14 @@ struct snd_info_entry *snd_info_create_c }EXPORT_SYMBOL (snd_info_create_card_entry); -static void snd_info_disconnect (struct snd_info_entry *entry) +static void snd_info_clear_entries (struct snd_info_entry *entry) {struct snd_info_entry *p;if (!entry->p)return ;list_for_each_entry (p, &entry->children, list) -snd_info_disconnect (p); -proc_remove (entry->p); +snd_info_clear_entries (p); entry->p =NULL ; }
@@ -770,8 +774,9 @@ void snd_info_free_entry(struct snd_infoif (!entry)return ;if (entry->p) { +proc_remove (entry->p);mutex_lock (&info_mutex); -snd_info_disconnect (entry); +snd_info_clear_entries (entry);mutex_unlock (&info_mutex); }
Greg Kroah-Hartman
maintainerPATCH 433/530 ALSA: hda/realtek: Enable Mute LED on HP 255 G8
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eymen Yigit <[email protected]>
commit 8384c0baf223e1c3bc7b1c711d80a4c6106d210e upstream.
This HP Notebook uses ALC236 codec with COEF 0x07 idx 1 controlling the mute LED. Enable already existing quirk for this device.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9746,6 +9746,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x8898 ,"HP EliteBook 845 G8 Notebook PC" ,ALC285_FIXUP_HP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x103c ,0x88d0 ,"HP Pavilion 15-eh1xxx (mainboard 88D0)" ,ALC287_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8902 ,"HP OMEN 16" ,ALC285_FIXUP_HP_MUTE_LED ), +SND_PCI_QUIRK (0x103c ,0x890e ,"HP 255 G8 Notebook PC" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ),SND_PCI_QUIRK (0x103c ,0x8919 ,"HP Pavilion Aero Laptop 13-be0xxx" ,ALC287_FIXUP_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x896d ,"HP ZBook Firefly 16 G9" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ), SND_PCI_QUIRK(0x103c, 0x896e, "HP EliteBook x360 830 G9", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
Greg Kroah-Hartman
maintainerPATCH 434/530 ALSA: hda/realtek - Add Dell ALC295 to pin fall back table
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kailang Yang <[email protected]>
commit 4b21a669ca21ed8f24ef4530b2918be5730114de upstream.
Add ALC295 to pin fall back table.
Remove 5 pin quirks for Dell ALC295.
ALC295 was only support MIC2 for external MIC function. ALC295 assigned model "ALC269_FIXUP_DELL1_MIC_NO_PRESENCE" for pin fall back table.
It was assigned wrong model. So, let's remove it.
--- sound/pci/hda/patch_realtek.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
sound/pci/hda/patch_realtek.c +3 -16
@@ -10735,22 +10735,6 @@ static const struct snd_hda_pin_quirk al {0x12, 0x90a60130}, {0x17, 0x90170110}, {0x21, 0x03211020}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , - {0x14, 0x90170110}, - {0x21, 0x04211020}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , - {0x14, 0x90170110}, - {0x21, 0x04211030}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE , -ALC295_STANDARD_PINS , - {0x17, 0x21014020}, - {0x18, 0x21a19030}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE , -ALC295_STANDARD_PINS , - {0x17, 0x21014040}, - {0x18, 0x21a19050}), -SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL1_MIC_NO_PRESENCE , -ALC295_STANDARD_PINS ),SND_HDA_PIN_QUIRK (0x10ec0298 ,0x1028 ,"Dell" ,ALC298_FIXUP_DELL1_MIC_NO_PRESENCE ,ALC298_STANDARD_PINS , {0x17, 0x90170110}),
@@ -10794,6 +10778,9 @@ static const struct snd_hda_pin_quirk alSND_HDA_PIN_QUIRK (0x10ec0289 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , {0x19, 0x40000000}, {0x1b, 0x40000000}), +SND_HDA_PIN_QUIRK (0x10ec0295 ,0x1028 ,"Dell" ,ALC269_FIXUP_DELL4_MIC_NO_PRESENCE , + {0x19, 0x40000000}, + {0x1b, 0x40000000}),SND_HDA_PIN_QUIRK (0x10ec0256 ,0x1028 ,"Dell" ,ALC255_FIXUP_DELL1_MIC_NO_PRESENCE , {0x19, 0x40000000}, {0x1a, 0x40000000}),
Greg Kroah-Hartman
maintainerPATCH 435/530 ALSA: hda/realtek - Enable internal speaker of ASUS K6500ZC
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandradeep Dey <[email protected]>
commit 713f040cd22285fcc506f40a0d259566e6758c3c upstream.
Apply the already existing quirk chain ALC294_FIXUP_ASUS_SPK to enable the internal speaker of ASUS K6500ZC.
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9821,6 +9821,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x1043 ,0x10a1 ,"ASUS UX391UA" ,ALC294_FIXUP_ASUS_SPK ),SND_PCI_QUIRK (0x1043 ,0x10c0 ,"ASUS X540SA" ,ALC256_FIXUP_ASUS_MIC ),SND_PCI_QUIRK (0x1043 ,0x10d0 ,"ASUS X540LA/X540LJ" ,ALC255_FIXUP_ASUS_MIC_NO_PRESENCE ), +SND_PCI_QUIRK (0x1043 ,0x10d3 ,"ASUS K6500ZC" ,ALC294_FIXUP_ASUS_SPK ),SND_PCI_QUIRK (0x1043 ,0x115d ,"Asus 1015E" ,ALC269_FIXUP_LIMIT_INT_MIC_BOOST ),SND_PCI_QUIRK (0x1043 ,0x11c0 ,"ASUS X556UR" ,ALC255_FIXUP_ASUS_MIC_NO_PRESENCE ), SND_PCI_QUIRK(0x1043, 0x125e, "ASUS Q524UQK", ALC255_FIXUP_ASUS_MIC_NO_PRESENCE),
Greg Kroah-Hartman
maintainerPATCH 436/530 ALSA: hda/realtek: Enable Mute LED on HP 255 G10
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matus Malych <[email protected]>
commit b944aa9d86d5f782bfe5e51336434c960304839c upstream.
HP 255 G10 has a mute LED that can be made to work using quirk ALC236_FIXUP_HP_MUTE_LED_COEFBIT2.
Enable already existing quirk - at correct line to keep order
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -9782,6 +9782,7 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x8abb ,"HP ZBook Firefly 14 G9" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8ad1 ,"HP EliteBook 840 14 inch G9 Notebook PC" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8ad2 ,"HP EliteBook 860 16 inch G9 Notebook PC" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8b2f ,"HP 255 15.6 inch G10 Notebook PC" ,ALC236_FIXUP_HP_MUTE_LED_COEFBIT2 ),SND_PCI_QUIRK (0x103c ,0x8b42 ,"HP" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8b43 ,"HP" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ), SND_PCI_QUIRK(0x103c, 0x8b44, "HP", ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED),
Greg Kroah-Hartman
maintainerPATCH 437/530 ALSA: hda/realtek: Add quirks for HP Laptops
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Binding <[email protected]>
commit 5d639b60971f003d3a9b2b31f8ec73b0718b5d57 upstream.
These HP laptops use Realtek HDA codec combined with 2 or 4 CS35L41 Amplifiers using SPI with Internal Boost.
--- sound/pci/hda/patch_realtek.c | 3 +++ 1 file changed, 3 insertions(+)
sound/pci/hda/patch_realtek.c +3 -0
@@ -9816,6 +9816,9 @@ static const struct snd_pci_quirk alc269SND_PCI_QUIRK (0x103c ,0x8c70 ,"HP EliteBook 835 G11" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8c71 ,"HP EliteBook 845 G11" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ),SND_PCI_QUIRK (0x103c ,0x8c72 ,"HP EliteBook 865 G11" ,ALC287_FIXUP_CS35L41_I2C_2_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8ca4 ,"HP ZBook Fury" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8ca7 ,"HP ZBook Fury" ,ALC245_FIXUP_CS35L41_SPI_2_HP_GPIO_LED ), +SND_PCI_QUIRK (0x103c ,0x8cf5 ,"HP ZBook Studio 16" ,ALC245_FIXUP_CS35L41_SPI_4_HP_GPIO_LED ),SND_PCI_QUIRK (0x1043 ,0x103e ,"ASUS X540SA" ,ALC256_FIXUP_ASUS_MIC ),SND_PCI_QUIRK (0x1043 ,0x103f ,"ASUS TX300" ,ALC282_FIXUP_ASUS_TX300 ), SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
Greg Kroah-Hartman
maintainerPATCH 428/530 cifs: do not pass cifs_sb when trying to add channels
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Prasad N <[email protected]>
commit 9599d59eb8fc0c0fd9480c4f22901533d08965ee upstream.
The only reason why cifs_sb gets passed today to cifs_try_adding_channels is to pass the local_nls field for the new channels and binding session. However, the ses struct already has local_nls field that is setup during the first cifs_setup_session. So there is no need to pass cifs_sb.
This change removes cifs_sb from the arg list for this and the functions that it calls and uses ses->local_nls instead.
--- fs/smb/client/cifsproto.h | 2 +- fs/smb/client/connect.c | 2 +- fs/smb/client/sess.c | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-)
fs/smb/client/cifsproto.h +1 -1
@@ -610,7 +610,7 @@ void cifs_free_hash(struct shash_desc **struct cifs_chan *cifs_ses_find_chan (struct cifs_ses *ses,struct TCP_Server_Info *server); -int cifs_try_adding_channels (struct cifs_sb_info *cifs_sb,struct cifs_ses *ses); +int cifs_try_adding_channels (struct cifs_ses *ses);bool is_server_using_iface (struct TCP_Server_Info *server,struct cifs_server_iface *iface);bool is_ses_using_iface (struct cifs_ses *ses,struct cifs_server_iface *iface);
fs/smb/client/connect.c +1 -1
@@ -3561,7 +3561,7 @@ int cifs_mount(struct cifs_sb_info *cifs ctx->prepath =NULL ; out: -cifs_try_adding_channels (cifs_sb, mnt_ctx.ses); +cifs_try_adding_channels (mnt_ctx.ses); rc =mount_setup_tlink (cifs_sb, mnt_ctx.ses, mnt_ctx.tcon);if (rc) goto error;
fs/smb/client/sess.c +6 -6
@@ -24,7 +24,7 @@#include "fs_context.h" static int -cifs_ses_add_channel (struct cifs_sb_info *cifs_sb,struct cifs_ses *ses, +cifs_ses_add_channel (struct cifs_ses *ses,struct cifs_server_iface *iface);bool
@@ -157,7 +157,7 @@ cifs_chan_is_iface_active(struct cifs_se }/* returns number of channels added */ -int cifs_try_adding_channels (struct cifs_sb_info *cifs_sb,struct cifs_ses *ses) +int cifs_try_adding_channels (struct cifs_ses *ses) {struct TCP_Server_Info *server = ses->server;int old_chan_count, new_chan_count;
@@ -230,7 +230,7 @@ int cifs_try_adding_channels(struct cifskref_get (&iface->refcount);spin_unlock (&ses->iface_lock); - rc =cifs_ses_add_channel (cifs_sb, ses, iface); + rc =cifs_ses_add_channel (ses, iface);spin_lock (&ses->iface_lock);if (rc) {
@@ -354,7 +354,7 @@ cifs_ses_find_chan(struct cifs_ses *ses, }static int -cifs_ses_add_channel (struct cifs_sb_info *cifs_sb,struct cifs_ses *ses, +cifs_ses_add_channel (struct cifs_ses *ses,struct cifs_server_iface *iface) {struct TCP_Server_Info *chan_server;
@@ -433,7 +433,7 @@ cifs_ses_add_channel(struct cifs_sb_info* This will be used for encoding/decoding user/domain/pw * during sess setup auth. */ - ctx->local_nls = cifs_sb->local_nls; + ctx->local_nls = ses->local_nls;/* Use RDMA if possible */ ctx->rdma = iface->rdma_capable;
@@ -479,7 +479,7 @@ cifs_ses_add_channel(struct cifs_sb_info rc =cifs_negotiate_protocol (xid, ses, chan->server);if (!rc) - rc =cifs_setup_session (xid, ses, chan->server, cifs_sb->local_nls); + rc =cifs_setup_session (xid, ses, chan->server, ses->local_nls);mutex_unlock (&ses->session_mutex);
Greg Kroah-Hartman
maintainerPATCH 457/530 media: venus: hfi: fix the check to handle session buffer requirement
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikash Garodia <[email protected]>
commit b18e36dfd6c935da60a971310374f3dfec3c82e1 upstream.
Buffer requirement, for different buffer type, comes from video firmware. While copying these requirements, there is an OOB possibility when the payload from firmware is more than expected size. Fix the check to avoid the OOB possibility.
--- drivers/media/platform/qcom/venus/hfi_msgs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/venus/hfi_msgs.c +1 -1
@@ -398,7 +398,7 @@ session_get_prop_buf_req(struct hfi_msg_memcpy (&bufreq[idx], buf_req,sizeof (*bufreq)); idx++; -if (idx >HFI_BUFFER_TYPE_MAX ) +if (idx >=HFI_BUFFER_TYPE_MAX )return HFI_ERR_SESSION_INVALID_PARAMETER ; req_bytes -=sizeof (struct hfi_buffer_requirements );
Greg Kroah-Hartman
maintainerPATCH 466/530 LoongArch: Mark __percpu functions as always inline
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 71945968d8b128c955204baa33ec03bdd91bdc26 upstream.
A recent change to the optimization pipeline in LLVM reveals some fragility around the inlining of LoongArch's __percpu functions, which manifests as a BUILD_BUG() failure:
In file included from kernel/sched/build_policy.c:17:
In file included from include/linux/sched/cputime.h:5:
In file included from include/linux/sched/signal.h:5:
In file included from include/linux/rculist.h:11:
In file included from include/linux/rcupdate.h:26:
In file included from include/linux/irqflags.h:18:
arch/loongarch/include/asm/percpu.h:97:3: error: call to '__compiletime_assert_51' declared with 'error' attribute: BUILD_BUG failed
97 | BUILD_BUG();
| ^
include/linux/build_bug.h:59:21: note: expanded from macro 'BUILD_BUG'
59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
| ^
include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^
include/linux/compiler_types.h:425:2: note: expanded from macro 'compiletime_assert'
425 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^
include/linux/compiler_types.h:413:2: note: expanded from macro '_compiletime_assert'
413 | __compiletime_assert(condition, msg, prefix, suffix)
| ^
include/linux/compiler_types.h:406:4: note: expanded from macro '__compiletime_assert'
406 | prefix ## suffix(); \
| ^
<scratch space>:86:1: note: expanded from here
86 | __compiletime_assert_51
| ^1 error generated.
If these functions are not inlined (which the compiler is free to do even with functions marked with the standard 'inline' keyword), the BUILD_BUG() in the default case cannot be eliminated since the compiler cannot prove it is never used, resulting in a build failure due to the error attribute.
Mark these functions as __always_inline to guarantee inlining so that the BUILD_BUG() only triggers when the default case genuinely cannot be eliminated due to an unexpected size.
--- arch/loongarch/include/asm/percpu.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/loongarch/include/asm/percpu.h +5 -5
@@ -32,7 +32,7 @@ static inline void set_my_cpu_offset(uns#define __my_cpu_offset __my_cpu_offset#define PERCPU_OP (op, asm_op, c_op) \ -static inline unsigned long __percpu_##op(void *ptr, \ +static __always_inline unsigned long __percpu_##op(void *ptr, \ unsigned long val, int size) \ { \ unsigned long ret; \
@@ -63,7 +63,7 @@ PERCPU_OP(and, and, &) PERCPU_OP(or, or, |) #undef PERCPU_OP -static inline unsigned long __percpu_read(void *ptr, int size) +static __always_inline unsigned long __percpu_read(void *ptr, int size) { unsigned long ret;
@@ -100,7 +100,7 @@ static inline unsigned long __percpu_reareturn ret; } -static inline void __percpu_write (void *ptr,unsigned long val,int size) +static __always_inline void __percpu_write(void *ptr, unsigned long val, int size) {switch (size) {case 1 :
@@ -132,8 +132,8 @@ static inline void __percpu_write(void * } } -static inline unsigned long __percpu_xchg (void *ptr,unsigned long val, -int size) +static __always_inline unsigned long __percpu_xchg (void *ptr,unsigned long val, +int size) {switch (size) {case 1 :
Greg Kroah-Hartman
maintainerPATCH 467/530 tracing: fprobe-event: Fix to check tracepoint event and return
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masami Hiramatsu (Google) <[email protected]>
commit ce51e6153f7781bcde0f8bb4c81d6fd85ee422e6 upstream.
Fix to check the tracepoint event is not valid with $retval. The commit 08c9306fc2e3 ("tracing/fprobe-event: Assume fprobe is a return event by $retval") introduced automatic return probe conversion with $retval. But since tracepoint event does not support return probe, $retval is not acceptable.
Without this fix, ftracetest, tprobe_syntax_errors.tc fails;
[22] Tracepoint probe event parser error log check [FAIL]
----
# tail 22-tprobe_syntax_errors.tc-log.mRKroL + ftrace_errlog_check trace_fprobe t kfree ^$retval dynamic_events + printf %s t kfree + wc -c + pos=8 + printf %s t kfree ^$retval + tr -d ^ + command=t kfree $retval + echo Test command: t kfree $retval Test command: t kfree $retval + echo ----
So 't kfree $retval' should fail (tracepoint doesn't support return probe) but passed it.
--- kernel/trace/trace_fprobe.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/trace/trace_fprobe.c +5 -4
@@ -927,11 +927,12 @@ static int parse_symbol_and_return(int argc, const char *argv[],for (i =2 ; i < argc; i++) { tmp =strstr (argv[i],"$retval" );if (tmp && !isalnum (tmp[7 ]) && tmp[7 ] !='_' ) { +if (is_tracepoint) { +trace_probe_log_set_index (i); +trace_probe_log_err (tmp - argv[i],RETVAL_ON_PROBE ); +return -EINVAL ; + } *is_return = true; -/* -* NOTE: Don't check is_tracepoint here, because it will -* be checked when the argument is parsed. -*/ break ; } }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 468/530 swiotlb: do not free decrypted pages if dynamic
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Petr Tesarik <[email protected]>
commit a5e3b127455d073f146a2a4ea3e7117635d34c5c upstream.
Fix these two error paths:
1. When set_memory_decrypted() fails, pages may be left fully or partially decrypted.
2. Decrypted pages may be freed if swiotlb_alloc_tlb() determines that the physical address is too high.
To fix the first issue, call set_memory_encrypted() on the allocated region after a failed decryption attempt. If that also fails, leak the pages.
To fix the second issue, check that the TLB physical address is below the requested limit before decrypting.
Let the caller differentiate between unsuitable physical address (=> retry from a lower zone) and allocation failures (=> no point in retrying).
--- kernel/dma/swiotlb.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
kernel/dma/swiotlb.c +16 -9
@@ -558,29 +558,40 @@ void __init swiotlb_exit(void)* alloc_dma_pages() - allocate pages to be used for DMA * @gfp: GFP flags for the allocation. * @bytes: Size of the buffer. +* @phys_limit: Maximum allowed physical address of the buffer. * * Allocate pages from the buddy allocator. If successful, make the allocated * pages decrypted that they can be used for DMA. * -* Return: Decrypted pages, or %NULL on failure. +* Return: Decrypted pages, %NULL on allocation failure, or ERR_PTR(-EAGAIN) +* if the allocated physical address was above @phys_limit. */ -static struct page *alloc_dma_pages (gfp_t gfp,size_t bytes) +static struct page *alloc_dma_pages (gfp_t gfp,size_t bytes,u64 phys_limit) {unsigned int order =get_order (bytes);struct page *page; +phys_addr_t paddr;void *vaddr; page =alloc_pages (gfp, order);if (!page)return NULL ; - vaddr =page_address (page); + paddr =page_to_phys (page); +if (paddr + bytes -1 > phys_limit) { +__free_pages (page, order); +return ERR_PTR (-EAGAIN ); + } + + vaddr =phys_to_virt (paddr);if (set_memory_decrypted ((unsigned long )vaddr,PFN_UP (bytes))) goto error;return page; error: -__free_pages (page, order); +/* Intentional leak if pages cannot be encrypted again. */ +if (!set_memory_encrypted ((unsigned long )vaddr,PFN_UP (bytes))) +__free_pages (page, order);return NULL ; }
@@ -618,11 +629,7 @@ static struct page *swiotlb_alloc_tlb(struct device *dev, size_t bytes,else if (phys_limit <=DMA_BIT_MASK (32 )) gfp |= __GFP_DMA32; -while ((page =alloc_dma_pages (gfp, bytes)) && -page_to_phys (page) + bytes -1 > phys_limit) { -/* allocated, but too high */ -__free_pages (page,get_order (bytes)); - +while (IS_ERR (page =alloc_dma_pages (gfp, bytes, phys_limit))) {if (IS_ENABLED (CONFIG_ZONE_DMA32 ) && phys_limit <DMA_BIT_MASK (64 ) && !(gfp & (__GFP_DMA32 | __GFP_DMA)))
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 469/530 swiotlb: fix out-of-bounds TLB allocations with CONFIG_SWIOTLB_DYNAMIC
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Petr Tesarik <[email protected]>
commit 53c87e846e335e3c18044c397cc35178163d7827 upstream.
Limit the free list length to the size of the IO TLB. Transient pool can be smaller than IO_TLB_SEGSIZE, but the free list is initialized with the assumption that the total number of slots is a multiple of IO_TLB_SEGSIZE. As a result, swiotlb_area_find_slots() may allocate slots past the end of a transient IO TLB buffer.
--- kernel/dma/swiotlb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/dma/swiotlb.c +2 -1
@@ -283,7 +283,8 @@ static void swiotlb_init_io_tlb_pool(struct io_tlb_pool *mem, phys_addr_t start, }for (i =0 ; i < mem->nslabs; i++) { - mem->slots[i].list =IO_TLB_SEGSIZE -io_tlb_offset (i); + mem->slots[i].list =min (IO_TLB_SEGSIZE -io_tlb_offset (i), + mem->nslabs - i); mem->slots[i].orig_addr =INVALID_PHYS_ADDR ; mem->slots[i].alloc_size =0 ; }
Signature · 1 line
2.43.0
Greg Kroah-Hartman
maintainerPATCH 470/530 riscv: Using TOOLCHAIN_HAS_ZIHINTPAUSE marco replace zihintpause
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minda Chen <[email protected]>
commit dd16ac404a685cce07e67261a94c6225d90ea7ba upstream.
Actually it is a part of Conor's
commit aae538cd03bc ("riscv: fix detection of toolchain Zihintpause support").
It is looks like a merge issue. Samuel's
commit 0b1d60d6dd9e ("riscv: Fix build with CONFIG_CC_OPTIMIZE_FOR_SIZE=y") do not base on Conor's commit and revert to __riscv_zihintpause. So this patch can fix it.
--- arch/riscv/include/asm/vdso/processor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/include/asm/vdso/processor.h +1 -1
@@ -14,7 +14,7 @@ static inline void cpu_relax(void) __asm__ __volatile__ ("div %0, %0, zero" :"=r" (dummy));#endif -#ifdef __riscv_zihintpause +#ifdef CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE /* * Reduce instruction retirement. * This assumes the PC changes.
Greg Kroah-Hartman
maintainerPATCH 471/530 riscv: put interrupt entries into .irqentry.text
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nam Cao <[email protected]>
commit 87615e95f6f9ccd36d4a3905a2d87f91967ea9d2 upstream.
The interrupt entries are expected to be in the .irqentry.text section. For example, for kprobes to work properly, exception code cannot be probed; this is ensured by blacklisting addresses in the .irqentry.text section.
--- arch/riscv/kernel/entry.S | 2 ++ 1 file changed, 2 insertions(+)
arch/riscv/kernel/entry.S +2 -0
@@ -16,6 +16,8 @@ #include <asm/errata_list.h> #include <linux/sizes.h> + .section .irqentry.text, "ax" + SYM_CODE_START(handle_exception) /* * If coming from userspace, preserve the user thread pointer and load
Greg Kroah-Hartman
maintainerPATCH 472/530 riscv: mm: Update the comment of CONFIG_PAGE_OFFSET
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Song Shuai <[email protected]>
commit 559fe94a449cba5b50a7cffea60474b385598c00 upstream.
Since the commit 011f09d12052 set sv57 as default for CONFIG_64BIT, the comment of CONFIG_PAGE_OFFSET should be updated too.
--- arch/riscv/include/asm/page.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/riscv/include/asm/page.h +2 -2
@@ -33,8 +33,8 @@#define PAGE_OFFSET _AC(CONFIG_PAGE_OFFSET, UL)#endif /* -* By default, CONFIG_PAGE_OFFSET value corresponds to SV48 address space so -* define the PAGE_OFFSET value for SV39. +* By default, CONFIG_PAGE_OFFSET value corresponds to SV57 address space so +* define the PAGE_OFFSET value for SV48 and SV39. */ #define PAGE_OFFSET_L4 _AC(0xffffaf8000000000, UL)#define PAGE_OFFSET_L3 _AC(0xffffffd800000000, UL)
Greg Kroah-Hartman
maintainerPATCH 473/530 riscv: correct pt_level name via pgtable_l5/4_enabled
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Song Shuai <[email protected]>
commit e59e5e2754bf983fc58ad18f99b5eec01f1a0745 upstream.
The pt_level uses CONFIG_PGTABLE_LEVELS to display page table names. But if page mode is downgraded from kernel cmdline or restricted by the hardware in 64BIT, it will give a wrong name.
Like, using no4lvl for sv39, ptdump named the 1G-mapping as "PUD" that should be "PGD":
0xffffffd840000000-0xffffffd900000000 0x00000000c0000000 3G PUD D A G . . W R V
So select "P4D/PUD" or "PGD" via pgtable_l5/4_enabled to correct it.
--- arch/riscv/mm/ptdump.c | 3 +++ 1 file changed, 3 insertions(+)
arch/riscv/mm/ptdump.c +3 -0
@@ -384,6 +384,9 @@ static int __init ptdump_init(void) kernel_ptd_info.base_addr =KERN_VIRT_START ; + pg_level[1 ].name = pgtable_l5_enabled ?"P4D" :"PGD" ; + pg_level[2 ].name = pgtable_l4_enabled ?"PUD" :"PGD" ; +for (i =0 ; i <ARRAY_SIZE (pg_level); i++)for (j =0 ; j <ARRAY_SIZE (pte_bits); j++) pg_level[i].mask |= pte_bits[j].mask;
Greg Kroah-Hartman
maintainerPATCH 474/530 riscv: kprobes: allow writing to x0
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nam Cao <[email protected]>
commit 8cb22bec142624d21bc85ff96b7bad10b6220e6a upstream.
Instructions can write to x0, so we should simulate these instructions normally.
Currently, the kernel hangs if an instruction who writes to x0 is simulated.
--- arch/riscv/kernel/probes/simulate-insn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/probes/simulate-insn.c +1 -1
@@ -24,7 +24,7 @@ static inline bool rv_insn_reg_set_val(s unsigned long val) {if (index ==0 ) -return false; +return true;else if (index <=31 ) *((unsigned long *)regs + index) = val;else
Greg Kroah-Hartman
maintainerPATCH 475/530 mmc: sdhci-pci-gli: A workaround to allow GL9750 to enter ASPM L1.2
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Shih <[email protected]>
commit d7133797e9e1b72fd89237f68cb36d745599ed86 upstream.
When GL9750 enters ASPM L1 sub-states, it will stay at L1.1 and will not enter L1.2. The workaround is to toggle PM state to allow GL9750 to enter ASPM L1.2.
--- drivers/mmc/host/sdhci-pci-gli.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/mmc/host/sdhci-pci-gli.c +14 -0
@@ -25,6 +25,9 @@#define GLI_9750_WT_EN_ON 0x1#define GLI_9750_WT_EN_OFF 0x0 +#define PCI_GLI_9750_PM_CTRL 0xFC +#define PCI_GLI_9750_PM_STATE GENMASK(1, 0) +#define SDHCI_GLI_9750_CFG2 0x848#define SDHCI_GLI_9750_CFG2_L1DLY GENMASK(28, 24)#define GLI_9750_CFG2_L1DLY_VALUE 0x1F
@@ -539,8 +542,12 @@ static void sdhci_gl9750_set_clock(strucstatic void gl9750_hw_setting (struct sdhci_host *host) { +struct sdhci_pci_slot *slot =sdhci_priv (host); +struct pci_dev *pdev;u32 value; + pdev = slot->chip->pdev; +gl9750_wt_on (host); value =sdhci_readl (host,SDHCI_GLI_9750_CFG2 );
@@ -550,6 +557,13 @@ static void gl9750_hw_setting(struct sdh GLI_9750_CFG2_L1DLY_VALUE);sdhci_writel (host, value,SDHCI_GLI_9750_CFG2 ); +/* toggle PM state to allow GL9750 to enter ASPM L1.2 */ +pci_read_config_dword (pdev,PCI_GLI_9750_PM_CTRL , &value); + value |=PCI_GLI_9750_PM_STATE ; +pci_write_config_dword (pdev,PCI_GLI_9750_PM_CTRL , value); + value &= ~PCI_GLI_9750_PM_STATE ; +pci_write_config_dword (pdev,PCI_GLI_9750_PM_CTRL , value); +gl9750_wt_off (host); }
Greg Kroah-Hartman
maintainerPATCH 458/530 media: venus: hfi: add checks to handle capabilities from firmware
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikash Garodia <[email protected]>
commit 8d0b89398b7ebc52103e055bf36b60b045f5258f upstream.
The hfi parser, parses the capabilities received from venus firmware and copies them to core capabilities. Consider below api, for example, fill_caps - In this api, caps in core structure gets updated with the number of capabilities received in firmware data payload. If the same api is called multiple times, there is a possibility of copying beyond the max allocated size in core caps.
Similar possibilities in fill_raw_fmts and fill_profile_level functions.
--- drivers/media/platform/qcom/venus/hfi_parser.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/media/platform/qcom/venus/hfi_parser.c +12 -0
@@ -89,6 +89,9 @@ static void fill_profile_level(struct hf {const struct hfi_profile_level *pl = data; +if (cap->num_pl + num >=HFI_MAX_PROFILE_COUNT ) +return ; +memcpy (&cap->pl[cap->num_pl], pl, num *sizeof (*pl)); cap->num_pl += num; }
@@ -114,6 +117,9 @@ fill_caps(struct hfi_plat_caps *cap, con {const struct hfi_capability *caps = data; +if (cap->num_caps + num >=MAX_CAP_ENTRIES ) +return ; +memcpy (&cap->caps[cap->num_caps], caps, num *sizeof (*caps)); cap->num_caps += num; }
@@ -140,6 +146,9 @@ static void fill_raw_fmts(struct hfi_pla {const struct raw_formats *formats = fmts; +if (cap->num_fmts + num_fmts >=MAX_FMT_ENTRIES ) +return ; +memcpy (&cap->fmts[cap->num_fmts], formats, num_fmts *sizeof (*formats)); cap->num_fmts += num_fmts; }
@@ -162,6 +171,9 @@ parse_raw_formats(struct venus_core *cor rawfmts[i].buftype = fmt->buffer_type; i++; +if (i >=MAX_FMT_ENTRIES ) +return ; +if (pinfo->num_planes >MAX_PLANES )break ;
Greg Kroah-Hartman
maintainerPATCH 476/530 mm: fix for negative counter: nr_file_hugepages
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Roesch <[email protected]>
commit a48d5bdc877b85201e42cef9c2fdf5378164c23a upstream.
While qualifiying the 6.4 release, the following warning was detected in messages:
vmstat_refresh: nr_file_hugepages -15664
The warning is caused by the incorrect updating of the NR_FILE_THPS counter in the function split_huge_page_to_list. The if case is checking for folio_test_swapbacked, but the else case is missing the check for folio_test_pmd_mappable. The other functions that manipulate the counter like __filemap_add_folio and filemap_unaccount_folio have the corresponding check.
I have a test case, which reproduces the problem. It can be found here:
https://github.com/sroeschus/testcase/blob/main/vmstat_refresh/madv.c
The test case reproduces on an XFS filesystem. Running the same test case on a BTRFS filesystem does not reproduce the problem.
AFAIK version 6.1 until 6.6 are affected by this problem.
--- mm/huge_memory.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
mm/huge_memory.c +9 -7
@@ -2737,13 +2737,15 @@ int split_huge_page_to_list(struct pageint nr =folio_nr_pages (folio);xas_split (&xas, folio,folio_order (folio)); -if (folio_test_swapbacked (folio)) { -__lruvec_stat_mod_folio (folio,NR_SHMEM_THPS , - -nr); - }else { -__lruvec_stat_mod_folio (folio,NR_FILE_THPS , - -nr); -filemap_nr_thps_dec (mapping); +if (folio_test_pmd_mappable (folio)) { +if (folio_test_swapbacked (folio)) { +__lruvec_stat_mod_folio (folio, +NR_SHMEM_THPS , -nr); + }else { +__lruvec_stat_mod_folio (folio, +NR_FILE_THPS , -nr); +filemap_nr_thps_dec (mapping); + } } }
Greg Kroah-Hartman
maintainerPATCH 477/530 mm: kmem: drop __GFP_NOFAIL when allocating objcg vectors
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roman Gushchin <[email protected]>
commit 24948e3b7b12e0031a6edb4f49bbb9fb2ad1e4e9 upstream.
Objcg vectors attached to slab pages to store slab object ownership information are allocated using gfp flags for the original slab allocation. Depending on slab page order and the size of slab objects, objcg vector can take several pages.
If the original allocation was done with the __GFP_NOFAIL flag, it triggered a warning in the page allocation code. Indeed, order > 1 pages should not been allocated with the __GFP_NOFAIL flag.
Fix this by simply dropping the __GFP_NOFAIL flag when allocating the objcg vector. It effectively allows to skip the accounting of a single slab object under a heavy memory pressure.
An alternative would be to implement the mechanism to fallback to order-0 allocations for accounting metadata, which is also not perfect because it will increase performance penalty and memory footprint of the kernel memory accounting under memory pressure.
--- mm/memcontrol.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/memcontrol.c +2 -1
@@ -2864,7 +2864,8 @@ static void commit_charge(struct folio ** Moreover, it should not come from DMA buffer and is not readily * reclaimable. So those GFP bits should be masked off. */ -#define OBJCGS_CLEAR_MASK (__GFP_DMA | __GFP_RECLAIMABLE | __GFP_ACCOUNT) +#define OBJCGS_CLEAR_MASK (__GFP_DMA | __GFP_RECLAIMABLE | \ + __GFP_ACCOUNT | __GFP_NOFAIL)/* * mod_objcg_mlstate() may be called with irq enabled, so
Greg Kroah-Hartman
maintainerPATCH 478/530 mptcp: deal with large GSO size
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit 9fce92f050f448a0d1ddd9083ef967d9930f1e52 upstream.
After the blamed commit below, the TCP sockets (and the MPTCP subflows) can build egress packets larger than 64K. That exceeds the maximum DSS data size, the length being misrepresent on the wire and the stream being corrupted, as later observed on the receiver:
WARNING: CPU: 0 PID: 9696 at net/mptcp/protocol.c:705 __mptcp_move_skbs_from_subflow+0x2604/0x26e0 CPU: 0 PID: 9696 Comm: syz-executor.7 Not tainted 6.6.0-rc5-gcd8bdf563d46 #45 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2.el7 04/01/2014 netlink: 8 bytes leftover after parsing attributes in process `syz-executor.4'. RIP: 0010:__mptcp_move_skbs_from_subflow+0x2604/0x26e0 net/mptcp/protocol.c:705 RSP: 0018:ffffc90000006e80 EFLAGS: 00010246 RAX: ffffffff83e9f674 RBX: ffff88802f45d870 RCX: ffff888102ad0000 netlink: 8 bytes leftover after parsing attributes in process `syz-executor.4'. RDX: 0000000080000303 RSI: 0000000000013908 RDI: 0000000000003908 RBP: ffffc90000007110 R08: ffffffff83e9e078 R09: 1ffff1100e548c8a R10: dffffc0000000000 R11: ffffed100e548c8b R12: 0000000000013908 R13: dffffc0000000000 R14: 0000000000003908 R15: 000000000031cf29 FS: 00007f239c47e700(0000) GS:ffff88811b200000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f239c45cd78 CR3: 000000006a66c006 CR4: 0000000000770ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000600 PKRU: 55555554 Call Trace: <IRQ> mptcp_data_ready+0x263/0xac0 net/mptcp/protocol.c:819 subflow_data_ready+0x268/0x6d0 net/mptcp/subflow.c:1409 tcp_data_queue+0x21a1/0x7a60 net/ipv4/tcp_input.c:5151 tcp_rcv_established+0x950/0x1d90 net/ipv4/tcp_input.c:6098 tcp_v6_do_rcv+0x554/0x12f0 net/ipv6/tcp_ipv6.c:1483 tcp_v6_rcv+0x2e26/0x3810 net/ipv6/tcp_ipv6.c:1749 ip6_protocol_deliver_rcu+0xd6b/0x1ae0 net/ipv6/ip6_input.c:438 ip6_input+0x1c5/0x470 net/ipv6/ip6_input.c:483 ipv6_rcv+0xef/0x2c0 include/linux/netfilter.h:304 __netif_receive_skb+0x1ea/0x6a0 net/core/dev.c:5532 process_backlog+0x353/0x660 net/core/dev.c:5974 __napi_poll+0xc6/0x5a0 net/core/dev.c:6536 net_rx_action+0x6a0/0xfd0 net/core/dev.c:6603 __do_softirq+0x184/0x524 kernel/softirq.c:553 do_softirq+0xdd/0x130 kernel/softirq.c:454
Address the issue explicitly bounding the maximum GSO size to what MPTCP actually allows.
--- net/mptcp/protocol.c | 4 ++++ 1 file changed, 4 insertions(+)
net/mptcp/protocol.c +4 -0
@@ -1231,6 +1231,8 @@ static void mptcp_update_infinite_map(stmptcp_do_fallback (ssk); } +#define MPTCP_MAX_GSO_SIZE (GSO_LEGACY_MAX_SIZE - (MAX_TCP_HEADER + 1)) +static int mptcp_sendmsg_frag (struct sock *sk,struct sock *ssk,struct mptcp_data_frag *dfrag,struct mptcp_sendmsg_info *info)
@@ -1257,6 +1259,8 @@ static int mptcp_sendmsg_frag(struct socreturn -EAGAIN ;/* compute send limit */ +if (unlikely (ssk->sk_gso_max_size >MPTCP_MAX_GSO_SIZE )) + ssk->sk_gso_max_size =MPTCP_MAX_GSO_SIZE ; info->mss_now =tcp_send_mss (ssk, &info->size_goal, info->flags); copy = info->size_goal;
Greg Kroah-Hartman
maintainerPATCH 479/530 mptcp: add validity check for sending RM_ADDR
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geliang Tang <[email protected]>
commit 8df220b29282e8b450ea57be62e1eccd4996837c upstream.
This patch adds the validity check for sending RM_ADDRs for userspace PM in mptcp_pm_remove_addrs(), only send a RM_ADDR when the address is in the anno_list or conn_list.
--- net/mptcp/pm_netlink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/mptcp/pm_netlink.c +3 -2
@@ -1538,8 +1538,9 @@ void mptcp_pm_remove_addrs(struct mptcp_struct mptcp_pm_addr_entry *entry;list_for_each_entry (entry, rm_list, list) { -remove_anno_list_by_saddr (msk, &entry->addr); -if (alist.nr <MPTCP_RM_IDS_MAX ) +if ((remove_anno_list_by_saddr (msk, &entry->addr) || +lookup_subflow_by_saddr (&msk->conn_list, &entry->addr)) && + alist.nr <MPTCP_RM_IDS_MAX ) alist.ids[alist.nr++] = entry->addr.id; }
Greg Kroah-Hartman
maintainerPATCH 480/530 mptcp: fix setsockopt(IP_TOS) subflow locking
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit 7679d34f97b7a09fd565f5729f79fd61b7c55329 upstream.
The MPTCP implementation of the IP_TOS socket option uses the lockless variant of the TOS manipulation helper and does not hold such lock at the helper invocation time.
Add the required locking.
--- net/mptcp/sockopt.c | 3 +++ 1 file changed, 3 insertions(+)
net/mptcp/sockopt.c +3 -0
@@ -737,8 +737,11 @@ static int mptcp_setsockopt_v4_set_tos(s val =inet_sk (sk)->tos;mptcp_for_each_subflow (msk, subflow) {struct sock *ssk =mptcp_subflow_tcp_sock (subflow); +bool slow; + slow =lock_sock_fast (ssk);__ip_sock_set_tos (ssk, val); +unlock_sock_fast (ssk, slow); }release_sock (sk);
Greg Kroah-Hartman
maintainerPATCH 481/530 selftests: mptcp: fix fastclose with csum failure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit 7cefbe5e1dacc7236caa77e9d072423f21422fe2 upstream.
Running the mp_join selftest manually with the following command line:
./mptcp_join.sh -z -C
leads to some failures:
002 fastclose server test
# ... rtx [fail] got 1 MP_RST[s] TX expected 0 # ... rstrx [fail] got 1 MP_RST[s] RX expected 0
The problem is really in the wrong expectations for the RST checks implied by the csum validation. Note that the same check is repeated explicitly in the same test-case, with the correct expectation and pass successfully.
Address the issue explicitly setting the correct expectation for the failing checks.
--- tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +1 -1
@@ -3237,7 +3237,7 @@ fastclose_tests() if reset_check_counter "fastclose server test" "MPTcpExtMPFastcloseRx"; then test_linkfail=1024 fastclose=server \ run_tests $ns1 $ns2 10.0.1.1 - chk_join_nr 0 0 0 + chk_join_nr 0 0 0 0 0 0 1 chk_fclose_nr 1 1 invert chk_rst_nr 1 1 fi
Greg Kroah-Hartman
maintainerPATCH 459/530 media: ccs: Correctly initialise try compose rectangle
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
commit 724ff68e968b19d786870d333f9952bdd6b119cb upstream.
Initialise the try sink compose rectangle size to the sink compose rectangle for binner and scaler sub-devices. This was missed due to the faulty condition that lead to the compose rectangles to be initialised for the pixel array sub-device where it is not relevant.
--- drivers/media/i2c/ccs/ccs-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/ccs/ccs-core.c +1 -1
@@ -3097,7 +3097,7 @@ static int ccs_open(struct v4l2_subdev * try_fmt->code = sensor->internal_csi_format->code; try_fmt->field =V4L2_FIELD_NONE ; -if (ssd != sensor->pixel_array) +if (ssd == sensor->pixel_array)continue ; try_comp =v4l2_subdev_get_try_compose (sd, fh->state, i);
Greg Kroah-Hartman
maintainerPATCH 460/530 drm/mediatek/dp: fix memory leak on ->get_edid callback audio detection
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
commit dab12fa8d2bd3868cf2de485ed15a3feef28a13d upstream.
The sads returned by drm_edid_to_sad() needs to be freed.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_dp.c +4 -1
@@ -2034,7 +2034,6 @@ static struct edid *mtk_dp_get_edid(strubool enabled = mtk_dp->enabled;struct edid *new_edid =NULL ;struct mtk_dp_audio_cfg *audio_caps = &mtk_dp->info.audio_cur_cfg; -struct cea_sad *sads;if (!enabled) {drm_atomic_bridge_chain_pre_enable (bridge, connector->state->state);
@@ -2053,7 +2052,11 @@ static struct edid *mtk_dp_get_edid(stru }if (new_edid) { +struct cea_sad *sads; + audio_caps->sad_count =drm_edid_to_sad (new_edid, &sads); +kfree (sads); + audio_caps->detect_monitor =drm_detect_monitor_audio (new_edid); }
Greg Kroah-Hartman
maintainerPATCH 461/530 drm/mediatek/dp: fix memory leak on ->get_edid callback error path
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
commit fcaf9761fd5884a64eaac48536f8c27ecfd2e6bc upstream.
Setting new_edid to NULL leaks the buffer.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/mediatek/mtk_dp.c +1 -0
@@ -2048,6 +2048,7 @@ static struct edid *mtk_dp_get_edid(stru*/ if (mtk_dp_parse_capabilities (mtk_dp)) {drm_err (mtk_dp->drm_dev,"Can't parse capabilities\n" ); +kfree (new_edid); new_edid =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 462/530 dm-bufio: fix no-sleep mode
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit 2a695062a5a42aead8c539a344168d4806b3fda2 upstream.
dm-bufio has a no-sleep mode. When activated (with the DM_BUFIO_CLIENT_NO_SLEEP flag), the bufio client is read-only and we could call dm_bufio_get from tasklets. This is used by dm-verity.
Unfortunately, commit 450e8dee51aa ("dm bufio: improve concurrent IO performance") broke this and the kernel would warn that cache_get() was calling down_read() from no-sleeping context. The bug can be reproduced by using "veritysetup open" with the "--use-tasklets" flag.
This commit fixes dm-bufio, so that the tasklet mode works again, by expanding use of the 'no_sleep_enabled' static_key to conditionally use either a rw_semaphore or rwlock_t (which are colocated in the buffer_tree structure using a union).
--- drivers/md/dm-bufio.c | 87 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 25 deletions(-)
drivers/md/dm-bufio.c +62 -25
@@ -254,7 +254,7 @@ enum evict_result {typedef enum evict_result (*le_predicate )(struct lru_entry *le,void *context); -static struct lru_entry *lru_evict (struct lru *lru,le_predicate pred,void *context) +static struct lru_entry *lru_evict (struct lru *lru,le_predicate pred,void *context,bool no_sleep) {unsigned long tested =0 ;struct list_head *h = lru->cursor;
@@ -295,7 +295,8 @@ static struct lru_entry *lru_evict(struc h = h->next; -cond_resched (); +if (!no_sleep) +cond_resched (); }return NULL ;
@@ -382,7 +383,10 @@ struct dm_buffer {*/ struct buffer_tree { -struct rw_semaphore lock; +union { +struct rw_semaphore lock; +rwlock_t spinlock; + } u;struct rb_root root; }____cacheline_aligned_in_smp ;
@@ -393,9 +397,12 @@ struct dm_buffer_cache {* on the locks. */ unsigned int num_locks; +bool no_sleep;struct buffer_tree trees[]; }; +static DEFINE_STATIC_KEY_FALSE (no_sleep_enabled); +static inline unsigned int cache_index (sector_t block,unsigned int num_locks) {return dm_hash_locks_index (block, num_locks);
@@ -403,22 +410,34 @@ static inline unsigned int cache_index(sstatic inline void cache_read_lock (struct dm_buffer_cache *bc,sector_t block) { -down_read (&bc->trees[cache_index (block, bc->num_locks)].lock); +if (static_branch_unlikely (&no_sleep_enabled) && bc->no_sleep) +read_lock_bh (&bc->trees[cache_index (block, bc->num_locks)].u.spinlock); +else +down_read (&bc->trees[cache_index (block, bc->num_locks)].u.lock); }static inline void cache_read_unlock (struct dm_buffer_cache *bc,sector_t block) { -up_read (&bc->trees[cache_index (block, bc->num_locks)].lock); +if (static_branch_unlikely (&no_sleep_enabled) && bc->no_sleep) +read_unlock_bh (&bc->trees[cache_index (block, bc->num_locks)].u.spinlock); +else +up_read (&bc->trees[cache_index (block, bc->num_locks)].u.lock); }static inline void cache_write_lock (struct dm_buffer_cache *bc,sector_t block) { -down_write (&bc->trees[cache_index (block, bc->num_locks)].lock); +if (static_branch_unlikely (&no_sleep_enabled) && bc->no_sleep) +write_lock_bh (&bc->trees[cache_index (block, bc->num_locks)].u.spinlock); +else +down_write (&bc->trees[cache_index (block, bc->num_locks)].u.lock); }static inline void cache_write_unlock (struct dm_buffer_cache *bc,sector_t block) { -up_write (&bc->trees[cache_index (block, bc->num_locks)].lock); +if (static_branch_unlikely (&no_sleep_enabled) && bc->no_sleep) +write_unlock_bh (&bc->trees[cache_index (block, bc->num_locks)].u.spinlock); +else +up_write (&bc->trees[cache_index (block, bc->num_locks)].u.lock); }/*
@@ -442,18 +461,32 @@ static void lh_init(struct lock_historystatic void __lh_lock (struct lock_history *lh,unsigned int index) { -if (lh->write) -down_write (&lh->cache->trees[index].lock); -else -down_read (&lh->cache->trees[index].lock); +if (lh->write) { +if (static_branch_unlikely (&no_sleep_enabled) && lh->cache->no_sleep) +write_lock_bh (&lh->cache->trees[index].u.spinlock); +else +down_write (&lh->cache->trees[index].u.lock); + }else { +if (static_branch_unlikely (&no_sleep_enabled) && lh->cache->no_sleep) +read_lock_bh (&lh->cache->trees[index].u.spinlock); +else +down_read (&lh->cache->trees[index].u.lock); + } }static void __lh_unlock (struct lock_history *lh,unsigned int index) { -if (lh->write) -up_write (&lh->cache->trees[index].lock); -else -up_read (&lh->cache->trees[index].lock); +if (lh->write) { +if (static_branch_unlikely (&no_sleep_enabled) && lh->cache->no_sleep) +write_unlock_bh (&lh->cache->trees[index].u.spinlock); +else +up_write (&lh->cache->trees[index].u.lock); + }else { +if (static_branch_unlikely (&no_sleep_enabled) && lh->cache->no_sleep) +read_unlock_bh (&lh->cache->trees[index].u.spinlock); +else +up_read (&lh->cache->trees[index].u.lock); + } }/*
@@ -502,14 +535,18 @@ static struct dm_buffer *list_to_buffer(return le_to_buffer (le); } -static void cache_init (struct dm_buffer_cache *bc,unsigned int num_locks) +static void cache_init (struct dm_buffer_cache *bc,unsigned int num_locks,bool no_sleep) {unsigned int i; bc->num_locks = num_locks; + bc->no_sleep = no_sleep;for (i =0 ; i < bc->num_locks; i++) { -init_rwsem (&bc->trees[i].lock); +if (no_sleep) +rwlock_init (&bc->trees[i].u.spinlock); +else +init_rwsem (&bc->trees[i].u.lock); bc->trees[i].root =RB_ROOT ; }
@@ -648,7 +685,7 @@ static struct dm_buffer *__cache_evict(sstruct lru_entry *le;struct dm_buffer *b; - le =lru_evict (&bc->lru[list_mode], __evict_pred, &w); + le =lru_evict (&bc->lru[list_mode], __evict_pred, &w, bc->no_sleep);if (!le)return NULL ;
@@ -702,7 +739,7 @@ static void __cache_mark_many(struct dm_struct evict_wrapper w = {.lh = lh, .pred = pred, .context = context};while (true) { - le =lru_evict (&bc->lru[old_mode], __evict_pred, &w); + le =lru_evict (&bc->lru[old_mode], __evict_pred, &w, bc->no_sleep);if (!le)break ;
@@ -915,10 +952,11 @@ static void cache_remove_range(struct dm {unsigned int i; +BUG_ON (bc->no_sleep);for (i =0 ; i < bc->num_locks; i++) { -down_write (&bc->trees[i].lock); +down_write (&bc->trees[i].u.lock);__remove_range (bc, &bc->trees[i].root, begin, end, pred, release); -up_write (&bc->trees[i].lock); +up_write (&bc->trees[i].u.lock); } }
@@ -979,8 +1017,6 @@ struct dm_bufio_client {struct dm_buffer_cache cache;/* must be last member */ }; -static DEFINE_STATIC_KEY_FALSE (no_sleep_enabled); -/*----------------------------------------------------------------*/ #define dm_bufio_in_request () (!!current->bio_list)
@@ -1871,7 +1907,8 @@ static void *new_read(struct dm_bufio_clif (need_submit)submit_io (b,REQ_OP_READ , read_endio); -wait_on_bit_io (&b->state,B_READING ,TASK_UNINTERRUPTIBLE ); +if (nf !=NF_GET )/* we already tested this condition above */ +wait_on_bit_io (&b->state,B_READING ,TASK_UNINTERRUPTIBLE );if (b->read_error) {int error =blk_status_to_errno (b->read_error);
@@ -2421,7 +2458,7 @@ struct dm_bufio_client *dm_bufio_client_ r = -ENOMEM ; goto bad_client; } -cache_init (&c->cache, num_locks); +cache_init (&c->cache, num_locks, (flags &DM_BUFIO_CLIENT_NO_SLEEP ) !=0 ); c->bdev = bdev; c->block_size = block_size;
Greg Kroah-Hartman
maintainerPATCH 463/530 dm-verity: dont use blocking calls from tasklets
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit 28f07f2ab4b3a2714f1fefcc58ada4bcc195f806 upstream.
The commit 5721d4e5a9cd enhanced dm-verity, so that it can verify blocks from tasklets rather than from workqueues. This reportedly improves performance significantly.
However, dm-verity was using the flag CRYPTO_TFM_REQ_MAY_SLEEP from tasklets which resulted in warnings about sleeping function being called from non-sleeping context.
BUG: sleeping function called from invalid context at crypto/internal.h:206 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 14, name: ksoftirqd/0 preempt_count: 100, expected: 0 RCU nest depth: 0, expected: 0 CPU: 0 PID: 14 Comm: ksoftirqd/0 Tainted: G W 6.7.0-rc1 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x32/0x50 __might_resched+0x110/0x160 crypto_hash_walk_done+0x54/0xb0 shash_ahash_update+0x51/0x60 verity_hash_update.isra.0+0x4a/0x130 [dm_verity] verity_verify_io+0x165/0x550 [dm_verity] ? free_unref_page+0xdf/0x170 ? psi_group_change+0x113/0x390 verity_tasklet+0xd/0x70 [dm_verity] tasklet_action_common.isra.0+0xb3/0xc0 __do_softirq+0xaf/0x1ec ? smpboot_thread_fn+0x1d/0x200 ? sort_range+0x20/0x20 run_ksoftirqd+0x15/0x30 smpboot_thread_fn+0xed/0x200 kthread+0xdc/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x28/0x40 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork_asm+0x11/0x20 </TASK>
This commit fixes dm-verity so that it doesn't use the flags CRYPTO_TFM_REQ_MAY_SLEEP and CRYPTO_TFM_REQ_MAY_BACKLOG from tasklets. The crypto API would do GFP_ATOMIC allocation instead, it could return -ENOMEM and we catch -ENOMEM in verity_tasklet and requeue the request to the workqueue.
--- drivers/md/dm-verity-fec.c | 4 ++-- drivers/md/dm-verity-target.c | 23 ++++++++++++----------- drivers/md/dm-verity.h | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-)
drivers/md/dm-verity-fec.c +2 -2
@@ -185,7 +185,7 @@ static int fec_is_erasure(struct dm_veri {if (unlikely (verity_hash (v,verity_io_hash_req (v, io), data,1 << v->data_dev_block_bits, -verity_io_real_digest (v, io)))) +verity_io_real_digest (v, io), true)))return 0 ; return memcmp(verity_io_real_digest(v, io), want_digest,
@@ -386,7 +386,7 @@ static int fec_decode_rsb(struct dm_veri/* Always re-validate the corrected block against the expected hash */ r =verity_hash (v,verity_io_hash_req (v, io), fio->output,1 << v->data_dev_block_bits, -verity_io_real_digest (v, io)); +verity_io_real_digest (v, io), true);if (unlikely (r <0 ))return r;
drivers/md/dm-verity-target.c +12 -11
@@ -135,20 +135,21 @@ static int verity_hash_update(struct dm_* Wrapper for crypto_ahash_init, which handles verity salting. */ static int verity_hash_init (struct dm_verity *v,struct ahash_request *req, -struct crypto_wait *wait) +struct crypto_wait *wait,bool may_sleep) {int r;ahash_request_set_tfm (req, v->tfm); -ahash_request_set_callback (req,CRYPTO_TFM_REQ_MAY_SLEEP | -CRYPTO_TFM_REQ_MAY_BACKLOG , - crypto_req_done, (void *)wait); +ahash_request_set_callback (req, + may_sleep ?CRYPTO_TFM_REQ_MAY_SLEEP |CRYPTO_TFM_REQ_MAY_BACKLOG :0 , + crypto_req_done, (void *)wait);crypto_init_wait (wait); r =crypto_wait_req (crypto_ahash_init (req), wait);if (unlikely (r <0 )) { -DMERR ("crypto_ahash_init failed: %d" , r); +if (r != -ENOMEM ) +DMERR ("crypto_ahash_init failed: %d" , r);return r; }
@@ -179,12 +180,12 @@ out: }int verity_hash (struct dm_verity *v,struct ahash_request *req, -const u8 *data,size_t len,u8 *digest) +const u8 *data,size_t len,u8 *digest,bool may_sleep) {int r;struct crypto_wait wait; - r =verity_hash_init (v, req, &wait); + r =verity_hash_init (v, req, &wait, may_sleep);if (unlikely (r <0 )) goto out;
@@ -322,7 +323,7 @@ static int verity_verify_level(struct dm r =verity_hash (v,verity_io_hash_req (v, io), data,1 << v->hash_dev_block_bits, -verity_io_real_digest (v, io)); +verity_io_real_digest (v, io), !io->in_tasklet);if (unlikely (r <0 )) goto release_ret_r;
@@ -556,7 +557,7 @@ static int verity_verify_io(struct dm_vecontinue ; } - r =verity_hash_init (v, req, &wait); + r =verity_hash_init (v, req, &wait, !io->in_tasklet);if (unlikely (r <0 ))return r;
@@ -652,7 +653,7 @@ static void verity_tasklet(unsigned long io->in_tasklet = true; err =verity_verify_io (io); -if (err == -EAGAIN ) { +if (err == -EAGAIN || err == -ENOMEM ) {/* fallback to retrying with work-queue */ INIT_WORK (&io->work, verity_work);queue_work (io->v->verify_wq, &io->work);
@@ -1033,7 +1034,7 @@ static int verity_alloc_zero_digest(stru goto out; r =verity_hash (v, req, zero_data,1 << v->data_dev_block_bits, - v->zero_digest); + v->zero_digest, true); out:kfree (req);
drivers/md/dm-verity.h +1 -1
@@ -128,7 +128,7 @@ extern int verity_for_bv_block(struct dm u8 *data, size_t len));extern int verity_hash (struct dm_verity *v,struct ahash_request *req, -const u8 *data,size_t len,u8 *digest); +const u8 *data,size_t len,u8 *digest,bool may_sleep);extern int verity_hash_for_block (struct dm_verity *v,struct dm_verity_io *io,sector_t block,u8 *digest,bool *is_zero);
Greg Kroah-Hartman
maintainerPATCH 464/530 nfsd: fix file memleak on client_opens_release
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mahmoud Adam <[email protected]>
commit bc1b5acb40201a0746d68a7d7cfc141899937f4f upstream.
seq_release should be called to free the allocated seq_file
--- fs/nfsd/nfs4state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4state.c +1 -1
@@ -2797,7 +2797,7 @@ static int client_opens_release(struct i/* XXX: alternatively, we could get/drop in seq start/stop */ drop_client (clp); -return 0 ; +return seq_release (inode, file); }static const struct file_operations client_states_fops = {
Greg Kroah-Hartman
maintainerPATCH 465/530 NFSD: Update nfsd_cache_append() to use xdr_stream
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
commit 49cecd8628a9855cd993792a0377559ea32d5e7c upstream.
When inserting a DRC-cached response into the reply buffer, ensure that the reply buffer's xdr_stream is updated properly. Otherwise the server will send a garbage response.
--- fs/nfsd/nfscache.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)
fs/nfsd/nfscache.c +7 -14
@@ -640,24 +640,17 @@ void nfsd_cache_update(struct svc_rqst *return ; } -/* -* Copy cached reply to current reply buffer. Should always fit. -* FIXME as reply is in a page, we should just attach the page, and -* keep a refcount.... -*/ static int nfsd_cache_append (struct svc_rqst *rqstp,struct kvec *data) { -struct kvec *vec = &rqstp->rq_res.head[0 ]; +__be32 *p; -if (vec->iov_len + data->iov_len >PAGE_SIZE ) { -printk (KERN_WARNING "nfsd: cached reply too large (%zd).\n" , - data->iov_len); -return 0 ; - } -memcpy ((char *)vec->iov_base + vec->iov_len, data->iov_base, data->iov_len); - vec->iov_len += data->iov_len; -return 1 ; + p =xdr_reserve_space (&rqstp->rq_res_stream, data->iov_len); +if (unlikely (!p)) +return false; +memcpy (p, data->iov_base, data->iov_len); +xdr_commit_encode (&rqstp->rq_res_stream); +return true; }/*
Greg Kroah-Hartman
maintainerPATCH 456/530 media: venus: hfi_parser: Add check to keep the number of codecs within range
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vikash Garodia <[email protected]>
commit 0768a9dd809ef52440b5df7dce5a1c1c7e97abbd upstream.
Supported codec bitmask is populated from the payload from venus firmware. There is a possible case when all the bits in the codec bitmask is set. In such case, core cap for decoder is filled and MAX_CODEC_NUM is utilized. Now while filling the caps for encoder, it can lead to access the caps array beyong 32 index. Hence leading to OOB write.
The fix counts the supported encoder and decoder. If the count is more than max, then it skips accessing the caps.
--- drivers/media/platform/qcom/venus/hfi_parser.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/qcom/venus/hfi_parser.c +3 -0
@@ -19,6 +19,9 @@ static void init_codecs(struct venus_corstruct hfi_plat_caps *caps = core->caps, *cap;unsigned long bit; +if (hweight_long (core->dec_codecs) +hweight_long (core->enc_codecs) >MAX_CODEC_NUM ) +return ; +for_each_set_bit (bit, &core->dec_codecs,MAX_CODEC_NUM ) { cap = &caps[core->codecs_count++]; cap->codec =BIT (bit);
Greg Kroah-Hartman
maintainerPATCH 483/530 r8169: add handling DASH when DASH is disabled
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChunHao Lin <[email protected]>
commit 0ab0c45d8aaea5192328bfa6989673aceafc767c upstream.
For devices that support DASH, even DASH is disabled, there may still exist a default firmware that will influence device behavior. So driver needs to handle DASH for devices that support DASH, no matter the DASH status is.
This patch also prepares for "fix network lost after resume on DASH systems".
--- drivers/net/ethernet/realtek/r8169_main.c | 36 ++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 11 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +25 -11
@@ -624,6 +624,7 @@ struct rtl8169_private { unsigned supports_gmii:1; unsigned aspm_manageable:1; + unsigned dash_enabled:1;dma_addr_t counters_phys_addr;struct rtl8169_counters *counters;struct rtl8169_tc_offsets tc_offset;
@@ -1253,14 +1254,26 @@ static bool r8168ep_check_dash(struct rtreturn r8168ep_ocp_read (tp,0x128 ) &BIT (0 ); } -static enum rtl_dash_type rtl_check_dash (struct rtl8169_private *tp) +static bool rtl_dash_is_enabled (struct rtl8169_private *tp) +{ +switch (tp->dash_type) { +case RTL_DASH_DP : +return r8168dp_check_dash (tp); +case RTL_DASH_EP : +return r8168ep_check_dash (tp); +default : +return false; + } +} + +static enum rtl_dash_type rtl_get_dash_type (struct rtl8169_private *tp) {switch (tp->mac_version) {case RTL_GIGA_MAC_VER_28 :case RTL_GIGA_MAC_VER_31 : -return r8168dp_check_dash (tp) ?RTL_DASH_DP :RTL_DASH_NONE ; +return RTL_DASH_DP ; case RTL_GIGA_MAC_VER_51 ... RTL_GIGA_MAC_VER_53: -return r8168ep_check_dash (tp) ?RTL_DASH_EP :RTL_DASH_NONE ; +return RTL_DASH_EP ;default :return RTL_DASH_NONE ; }
@@ -1453,7 +1466,7 @@ static void __rtl8169_set_wol(struct rtldevice_set_wakeup_enable (tp_to_dev (tp), wolopts); -if (tp->dash_type ==RTL_DASH_NONE ) { +if (!tp->dash_enabled) {rtl_set_d3_pll_down (tp, !wolopts); tp->dev->wol_enabled = wolopts ?1 :0 ; }
@@ -2512,7 +2525,7 @@ static void rtl_wol_enable_rx(struct rtlstatic void rtl_prepare_power_down (struct rtl8169_private *tp) { -if (tp->dash_type !=RTL_DASH_NONE ) +if (tp->dash_enabled)return ; if (tp->mac_version == RTL_GIGA_MAC_VER_32 ||
@@ -4875,7 +4888,7 @@ static int rtl8169_runtime_idle(struct d {struct rtl8169_private *tp =dev_get_drvdata (device); -if (tp->dash_type !=RTL_DASH_NONE ) +if (tp->dash_enabled)return -EBUSY ;if (!netif_running (tp->dev) || !netif_carrier_ok (tp->dev))
@@ -4901,8 +4914,7 @@ static void rtl_shutdown(struct pci_dev/* Restore original MAC address */ rtl_rar_set (tp, tp->dev->perm_addr); -if (system_state ==SYSTEM_POWER_OFF && - tp->dash_type ==RTL_DASH_NONE ) { +if (system_state ==SYSTEM_POWER_OFF && !tp->dash_enabled) {pci_wake_from_d3 (pdev, tp->saved_wolopts);pci_set_power_state (pdev, PCI_D3hot); }
@@ -5260,7 +5272,8 @@ static int rtl_init_one(struct pci_dev * rc =pci_disable_link_state (pdev,PCIE_LINK_STATE_L1 ); tp->aspm_manageable = !rc; - tp->dash_type =rtl_check_dash (tp); + tp->dash_type =rtl_get_dash_type (tp); + tp->dash_enabled =rtl_dash_is_enabled (tp); tp->cp_cmd =RTL_R16 (tp, CPlusCmd) &CPCMD_MASK ;
@@ -5331,7 +5344,7 @@ static int rtl_init_one(struct pci_dev */* configure chip for default features */ rtl8169_set_features (dev, dev->features); -if (tp->dash_type ==RTL_DASH_NONE ) { +if (!tp->dash_enabled) {rtl_set_d3_pll_down (tp, true); }else {rtl_set_d3_pll_down (tp, false);
@@ -5371,7 +5384,8 @@ static int rtl_init_one(struct pci_dev * "ok" : "ko"); if (tp->dash_type != RTL_DASH_NONE) { -netdev_info (dev,"DASH enabled\n" ); +netdev_info (dev,"DASH %s\n" , + tp->dash_enabled ?"enabled" :"disabled" );rtl8168_driver_start (tp); }
Greg Kroah-Hartman
maintainerPATCH 492/530 media: qcom: camss: Fix csid-gen2 for test pattern generator
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Konovalov <[email protected]>
commit 87889f1b7ea40d2544b49c62092e6ef2792dced7 upstream.
In the current driver csid Test Pattern Generator (TPG) doesn't work. This change:
- fixes writing frame width and height values into CSID_TPG_DT_n_CFG_0
- fixes the shift by one between test_pattern control value and the actual pattern.
- drops fixed VC of 0x0a which testing showed prohibited some test patterns in the CSID to produce output.
So that TPG starts working, but with the below limitations:
- only test_pattern=9 works as it should
- test_pattern=8 and test_pattern=7 produce black frame (all zeroes)
- the rest of test_pattern's don't work (yavta doesn't get the data)
- regardless of the CFA pattern set by 'media-ctl -V' the actual pixel order is always the same (RGGB for any RAW8 or RAW10P format in 4608x2592 resolution).
Tested with:
RAW10P format, VC0:
media-ctl -V '"msm_csid0":0[fmt:SRGGB10/4608x2592 field:none]' media-ctl -V '"msm_vfe0_rdi0":0[fmt:SRGGB10/4608x2592 field:none]' media-ctl -l '"msm_csid0":1->"msm_vfe0_rdi0":0[1]'
v4l2-ctl -d /dev/v4l-subdev6 -c test_pattern=9
yavta -B capture-mplane --capture=3 -n 3 -f SRGGB10P -s 4608x2592 /dev/video0
RAW10P format, VC1:
media-ctl -V '"msm_csid0":2[fmt:SRGGB10/4608x2592 field:none]' media-ctl -V '"msm_vfe0_rdi1":0[fmt:SRGGB10/4608x2592 field:none]' media-ctl -l '"msm_csid0":2->"msm_vfe0_rdi1":0[1]'
v4l2-ctl -d /dev/v4l-subdev6 -c test_pattern=9
yavta -B capture-mplane --capture=3 -n 3 -f SRGGB10P -s 4608x2592 /dev/video1
RAW8 format, VC0:
media-ctl --reset
media-ctl -V '"msm_csid0":0[fmt:SRGGB8/4608x2592 field:none]' media-ctl -V '"msm_vfe0_rdi0":0[fmt:SRGGB8/4608x2592 field:none]' media-ctl -l '"msm_csid0":1->"msm_vfe0_rdi0":0[1]'
yavta -B capture-mplane --capture=3 -n 3 -f SRGGB8 -s 4608x2592 /dev/video0
--- drivers/media/platform/qcom/camss/camss-csid-gen2.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/media/platform/qcom/camss/camss-csid-gen2.c +3 -6
@@ -355,9 +355,6 @@ static void __csid_configure_stream(struu8 dt_id = vc;if (tg->enabled) { -/* Config Test Generator */ - vc =0xa ; -/* configure one DT, infinite frames */ val = vc <<TPG_VC_CFG0_VC_NUM ; val |=INTELEAVING_MODE_ONE_SHOT <<TPG_VC_CFG0_LINE_INTERLEAVING_MODE ;
@@ -370,14 +367,14 @@ static void __csid_configure_stream(struwritel_relaxed (0x12345678 , csid->base +CSID_TPG_LFSR_SEED ); - val = input_format->height &0x1fff << TPG_DT_n_CFG_0_FRAME_HEIGHT; - val |= input_format->width &0x1fff << TPG_DT_n_CFG_0_FRAME_WIDTH; + val = (input_format->height &0x1fff ) << TPG_DT_n_CFG_0_FRAME_HEIGHT; + val |= (input_format->width &0x1fff ) << TPG_DT_n_CFG_0_FRAME_WIDTH;writel_relaxed (val, csid->base +CSID_TPG_DT_n_CFG_0 (0 )); val = format->data_type << TPG_DT_n_CFG_1_DATA_TYPE;writel_relaxed (val, csid->base +CSID_TPG_DT_n_CFG_1 (0 )); - val = tg->mode << TPG_DT_n_CFG_2_PAYLOAD_MODE; + val = (tg->mode -1 ) << TPG_DT_n_CFG_2_PAYLOAD_MODE; val |=0xBE << TPG_DT_n_CFG_2_USER_SPECIFIED_PAYLOAD; val |= format->decode_format << TPG_DT_n_CFG_2_ENCODE_FORMAT;writel_relaxed (val, csid->base +CSID_TPG_DT_n_CFG_2 (0 ));
Greg Kroah-Hartman
maintainerPATCH 493/530 Revert "HID: logitech-dj: Add support for a new lightspeed receiver iteration"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Kosina <[email protected]>
commit 5b4ffb176d7979ac66b349addf3f7de433335e00 upstream.
This reverts commit 9d1bd9346241cd6963b58da7ffb7ed303285f684.
Multiple people reported misbehaving devices and reverting this commit fixes the problem for them. As soon as the original commit author starts reacting again, we can try to figure out why he hasn't seen the issues (mismatching report descriptors?), but for the time being, fix for 6.7 by reverting.
--- drivers/hid/hid-ids.h | 1 - drivers/hid/hid-logitech-dj.c | 11 +++-------- 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/hid/hid-ids.h +0 -1
@@ -869,7 +869,6 @@#define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_2 0xc534#define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1 0xc539#define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_1 0xc53f -#define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_2 0xc547#define USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_POWERPLAY 0xc53a#define USB_DEVICE_ID_SPACETRAVELLER 0xc623#define USB_DEVICE_ID_SPACENAVIGATOR 0xc626
drivers/hid/hid-logitech-dj.c +3 -8
@@ -1695,12 +1695,11 @@ static int logi_dj_raw_event(struct hid_ }/* * Mouse-only receivers send unnumbered mouse data. The 27 MHz -* receiver uses 6 byte packets, the nano receiver 8 bytes, -* the lightspeed receiver (Pro X Superlight) 13 bytes. +* receiver uses 6 byte packets, the nano receiver 8 bytes. */ if (djrcv_dev->unnumbered_application ==HID_GD_MOUSE && - size <=13 ){ -u8 mouse_report[14 ]; + size <=8 ) { +u8 mouse_report[9 ];/* Prepend report id */ mouse_report[0 ] =REPORT_TYPE_MOUSE ;
@@ -1984,10 +1983,6 @@ static const struct hid_device_id logi_dHID_USB_DEVICE (USB_VENDOR_ID_LOGITECH , USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_1), .driver_data = recvr_type_gaming_hidpp}, - {/* Logitech lightspeed receiver (0xc547) */ -HID_USB_DEVICE (USB_VENDOR_ID_LOGITECH , - USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1_2), - .driver_data = recvr_type_gaming_hidpp}, { /* Logitech 27 MHz HID++ 1.0 receiver (0xc513) */ HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_MX3000_RECEIVER),
Greg Kroah-Hartman
maintainerPATCH 494/530 Revert "net: r8169: Disable multicast filter for RTL8168H and RTL8107E"
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiner Kallweit <[email protected]>
commit 6a26310273c323380da21eb23fcfd50e31140913 upstream.
This reverts commit efa5f1311c4998e9e6317c52bc5ee93b3a0f36df.
I couldn't reproduce the reported issue. What I did, based on a pcap packet log provided by the reporter:
- Used same chip version (RTL8168h)
- Set MAC address to the one used on the reporters system
- Replayed the EAPOL unicast packet that, according to the reporter, was filtered out by the mc filter.
The packet was properly received.
Therefore the root cause of the reported issue seems to be somewhere else. Disabling mc filtering completely for the most common chip version is a quite big hammer. Therefore revert the change and wait for further analysis results from the reporter.
--- drivers/net/ethernet/realtek/r8169_main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/realtek/r8169_main.c +1 -3
@@ -2599,9 +2599,7 @@ static void rtl_set_rx_mode(struct net_d rx_mode &= ~AcceptMulticast; }else if (netdev_mc_count (dev) >MC_FILTER_LIMIT || dev->flags &IFF_ALLMULTI || - tp->mac_version ==RTL_GIGA_MAC_VER_35 || - tp->mac_version ==RTL_GIGA_MAC_VER_46 || - tp->mac_version ==RTL_GIGA_MAC_VER_48 ) { + tp->mac_version ==RTL_GIGA_MAC_VER_35 ) {/* accept all multicasts */ }else if (netdev_mc_empty (dev)) { rx_mode &= ~AcceptMulticast;
Greg Kroah-Hartman
maintainerPATCH 495/530 ext4: fix race between writepages and remount
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit 745f17a4166e79315e4b7f33ce89d03e75a76983 upstream.
We got a WARNING in ext4_add_complete_io:
==================================================================
WARNING: at fs/ext4/page-io.c:231 ext4_put_io_end_defer+0x182/0x250 CPU: 10 PID: 77 Comm: ksoftirqd/10 Tainted: 6.3.0-rc2 #85 RIP: 0010:ext4_put_io_end_defer+0x182/0x250 [ext4] [...] Call Trace: <TASK> ext4_end_bio+0xa8/0x240 [ext4] bio_endio+0x195/0x310 blk_update_request+0x184/0x770 scsi_end_request+0x2f/0x240 scsi_io_completion+0x75/0x450 scsi_finish_command+0xef/0x160 scsi_complete+0xa3/0x180 blk_complete_reqs+0x60/0x80 blk_done_softirq+0x25/0x40 __do_softirq+0x119/0x4c8 run_ksoftirqd+0x42/0x70 smpboot_thread_fn+0x136/0x3c0 kthread+0x140/0x1a0 ret_from_fork+0x2c/0x50 ==================================================================
Above issue may happen as follows:
cpu1 cpu2
----------------------------|---------------------------- mount -o dioread_lockext4_writepages
ext4_do_writepages
*if (ext4_should_dioread_nolock(inode))*
// rsv_blocks is not assigned here
mount -o remount,dioread_nolock
ext4_journal_start_with_reserve
__ext4_journal_start
__ext4_journal_start_sb
jbd2__journal_start
*if (rsv_blocks)*
// h_rsv_handle is not initialized here
mpage_map_and_submit_extent
mpage_map_one_extent
dioread_nolock = ext4_should_dioread_nolock(inode)
if (dioread_nolock && (map->m_flags & EXT4_MAP_UNWRITTEN))
mpd->io_submit.io_end->handle = handle->h_rsv_handle
ext4_set_io_unwritten_flag
io_end->flag |= EXT4_IO_END_UNWRITTEN
// now io_end->handle is NULL but has EXT4_IO_END_UNWRITTEN flagscsi_finish_command
scsi_io_completion
scsi_io_completion_action
scsi_end_request
blk_update_request
req_bio_endio
bio_endio
bio->bi_end_io > ext4_end_bio
ext4_put_io_end_defer
ext4_add_complete_io
// trigger WARN_ON(!io_end->handle && sbi->s_journal);The immediate cause of this problem is that ext4_should_dioread_nolock() function returns inconsistent values in the ext4_do_writepages() and mpage_map_one_extent(). There are four conditions in this function that can be changed at mount time to cause this problem. These four conditions can be divided into two categories:
(1) journal_data and EXT4_EXTENTS_FL, which can be changed by ioctl
(2) DELALLOC and DIOREAD_NOLOCK, which can be changed by remount
The two in the first category have been fixed by commit c8585c6fcaf2 ("ext4: fix races between changing inode journal mode and ext4_writepages") and commit cb85f4d23f79 ("ext4: fix race between writepages and enabling EXT4_EXTENTS_FL") respectively.
Two cases in the other category have not yet been fixed, and the above issue is caused by this situation. We refer to the fix for the first category, when applying options during remount, we grab s_writepages_rwsem to avoid racing with writepages ops to trigger this problem.
--- fs/ext4/ext4.h | 3 ++- fs/ext4/super.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)
fs/ext4/ext4.h +2 -1
@@ -1676,7 +1676,8 @@ struct ext4_sb_info {/* * Barrier between writepages ops and changing any inode's JOURNAL_DATA -* or EXTENTS flag. +* or EXTENTS flag or between writepages ops and changing DELALLOC or +* DIOREAD_NOLOCK mount options on remount. */ struct percpu_rw_semaphore s_writepages_rwsem;struct dax_device *s_daxdev;
fs/ext4/super.c +14 -0
@@ -6443,6 +6443,7 @@ static int __ext4_remount(struct fs_contstruct ext4_mount_options old_opts;ext4_group_t g;int err =0 ; +int alloc_ctx;#ifdef CONFIG_QUOTA int enable_quota =0 ;int i, j;
@@ -6483,7 +6484,16 @@ static int __ext4_remount(struct fs_cont } +/* +* Changing the DIOREAD_NOLOCK or DELALLOC mount options may cause +* two calls to ext4_should_dioread_nolock() to return inconsistent +* values, triggering WARN_ON in ext4_add_complete_io(). we grab +* here s_writepages_rwsem to avoid race between writepages ops and +* remount. +*/ + alloc_ctx =ext4_writepages_down_write (sb);ext4_apply_options (fc, sb); +ext4_writepages_up_write (sb, alloc_ctx);if ((old_opts.s_mount_opt &EXT4_MOUNT_JOURNAL_CHECKSUM ) ^test_opt (sb,JOURNAL_CHECKSUM )) {
@@ -6701,6 +6711,8 @@ restore_opts:if (sb_rdonly (sb) && !(old_sb_flags &SB_RDONLY ) &&sb_any_quota_suspended (sb))dquot_resume (sb,-1 ); + + alloc_ctx =ext4_writepages_down_write (sb); sb->s_flags = old_sb_flags; sbi->s_mount_opt = old_opts.s_mount_opt; sbi->s_mount_opt2 = old_opts.s_mount_opt2;
@@ -6709,6 +6721,8 @@ restore_opts: sbi->s_commit_interval = old_opts.s_commit_interval; sbi->s_min_batch_time = old_opts.s_min_batch_time; sbi->s_max_batch_time = old_opts.s_max_batch_time; +ext4_writepages_up_write (sb, alloc_ctx); +if (!test_opt (sb,BLOCK_VALIDITY ) && sbi->s_system_blks)ext4_release_system_zone (sb);#ifdef CONFIG_QUOTA
Greg Kroah-Hartman
maintainerPATCH 496/530 ext4: no need to generate from free list in mballoc
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Jianjian <[email protected]>
commit ebf6cb7c6e1241984f75f29f1bdbfa2fe7168f88 upstream.
Commit 7a2fcbf7f85 ("ext4: don't use blocks freed but not yet committed in buddy cache init") added a code to mark as used blocks in the list of not yet committed freed blocks during initialization of a buddy page. However ext4_mb_free_metadata() makes sure buddy page is already loaded and takes a reference to it so it cannot happen that ext4_mb_init_cache() is called when efd list is non-empty. Just remove the ext4_mb_generate_from_freelist() call.
--- fs/ext4/mballoc.c | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-)
fs/ext4/mballoc.c +6 -33
@@ -417,8 +417,6 @@ static const char * const ext4_groupinfostatic void ext4_mb_generate_from_pa (struct super_block *sb,void *bitmap,ext4_group_t group); -static void ext4_mb_generate_from_freelist (struct super_block *sb,void *bitmap, -ext4_group_t group);static void ext4_mb_new_preallocation (struct ext4_allocation_context *ac); static bool ext4_mb_good_group(struct ext4_allocation_context *ac,
@@ -1361,17 +1359,17 @@ static int ext4_mb_init_cache(struct pag* We place the buddy block and bitmap block * close together */ + grinfo =ext4_get_group_info (sb, group); +if (!grinfo) { + err = -EFSCORRUPTED ; + goto out; + }if ((first_block + i) &1 ) {/* this is block of buddy */ BUG_ON (incore ==NULL );mb_debug (sb,"put buddy for group %u in page %lu/%x\n" , group, page->index, i * blocksize);trace_ext4_mb_buddy_bitmap_load (sb, group); - grinfo =ext4_get_group_info (sb, group); -if (!grinfo) { - err = -EFSCORRUPTED ; - goto out; - } grinfo->bb_fragments =0 ; memset(grinfo->bb_counters, 0, sizeof(*grinfo->bb_counters) *
@@ -1398,7 +1396,7 @@ static int ext4_mb_init_cache(struct pag/* mark all preallocated blks used in in-core bitmap */ ext4_mb_generate_from_pa (sb, data, group); -ext4_mb_generate_from_freelist (sb, data, group); +WARN_ON_ONCE (!RB_EMPTY_ROOT (&grinfo->bb_free_root));ext4_unlock_group (sb, group);/* set incore so that the buddy information can be
@@ -4959,31 +4957,6 @@ try_group_pa: }/* -* the function goes through all block freed in the group -* but not yet committed and marks them used in in-core bitmap. -* buddy must be generated from this bitmap -* Need to be called with the ext4 group lock held -*/ -static void ext4_mb_generate_from_freelist (struct super_block *sb,void *bitmap, -ext4_group_t group) -{ -struct rb_node *n; -struct ext4_group_info *grp; -struct ext4_free_data *entry; - - grp =ext4_get_group_info (sb, group); -if (!grp) -return ; - n =rb_first (&(grp->bb_free_root)); - -while (n) { - entry = rb_entry(n, struct ext4_free_data, efd_node); -mb_set_bits (bitmap, entry->efd_start_cluster, entry->efd_count); - n =rb_next (n); - } -} - -/* * the function goes through all preallocation in this group and marks them * used in in-core bitmap. buddy must be generated from this bitmap * Need to be called with ext4 group lock held
Greg Kroah-Hartman
maintainerPATCH 497/530 ext4: make sure allocate pending entry not fail
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
commit 8e387c89e96b9543a339f84043cf9df15fed2632 upstream.
__insert_pending() allocate memory in atomic context, so the allocation could fail, but we are not handling that failure now. It could lead ext4_es_remove_extent() to get wrong reserved clusters, and the global data blocks reservation count will be incorrect. The same to extents_status entry preallocation, preallocate pending entry out of the i_es_lock with __GFP_NOFAIL, make sure __insert_pending() and __revise_pending() always succeeds.
--- fs/ext4/extents_status.c | 123 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 89 insertions(+), 34 deletions(-)
fs/ext4/extents_status.c +89 -34
@@ -152,8 +152,9 @@ static int __es_remove_extent(struct inostatic int es_reclaim_extents (struct ext4_inode_info *ei,int *nr_to_scan);static int __es_shrink (struct ext4_sb_info *sbi,int nr_to_scan,struct ext4_inode_info *locked_ei); -static void __revise_pending (struct inode *inode,ext4_lblk_t lblk, -ext4_lblk_t len); +static int __revise_pending (struct inode *inode,ext4_lblk_t lblk, +ext4_lblk_t len, +struct pending_reservation **prealloc);int __init ext4_init_es (void ) {
@@ -448,6 +449,19 @@ static void ext4_es_list_del(struct inodspin_unlock (&sbi->s_es_lock); } +static inline struct pending_reservation *__alloc_pending (bool nofail) +{ +if (!nofail) +return kmem_cache_alloc (ext4_pending_cachep,GFP_ATOMIC ); + +return kmem_cache_zalloc (ext4_pending_cachep,GFP_KERNEL | __GFP_NOFAIL); +} + +static inline void __free_pending (struct pending_reservation *pr) +{ +kmem_cache_free (ext4_pending_cachep, pr); +} +/* * Returns true if we cannot fail to allocate memory for this extent_status * entry and cannot reclaim it until its status changes.
@@ -836,11 +850,12 @@ void ext4_es_insert_extent(struct inode {struct extent_status newes;ext4_lblk_t end = lblk + len -1 ; -int err1 =0 ; -int err2 =0 ; +int err1 =0 , err2 =0 , err3 =0 ;struct ext4_sb_info *sbi =EXT4_SB (inode->i_sb);struct extent_status *es1 =NULL ;struct extent_status *es2 =NULL ; +struct pending_reservation *pr =NULL ; +bool revise_pending = false;if (EXT4_SB (inode->i_sb)->s_mount_state &EXT4_FC_REPLAY )return ;
@@ -868,11 +883,17 @@ void ext4_es_insert_extent(struct inodeext4_es_insert_extent_check (inode, &newes); + revise_pending = sbi->s_cluster_ratio >1 && +test_opt (inode->i_sb,DELALLOC ) && + (status & (EXTENT_STATUS_WRITTEN | +EXTENT_STATUS_UNWRITTEN )); retry:if (err1 && !es1) es1 =__es_alloc_extent (true);if ((err1 || err2) && !es2) es2 =__es_alloc_extent (true); +if ((err1 || err2 || err3) && revise_pending && !pr) + pr =__alloc_pending (true);write_lock (&EXT4_I (inode)->i_es_lock); err1 =__es_remove_extent (inode, lblk, end,NULL , es1);
@@ -897,13 +918,18 @@ retry: es2 =NULL ; } -if (sbi->s_cluster_ratio >1 &&test_opt (inode->i_sb,DELALLOC ) && - (status &EXTENT_STATUS_WRITTEN || - status &EXTENT_STATUS_UNWRITTEN )) -__revise_pending (inode, lblk, len); +if (revise_pending) { + err3 =__revise_pending (inode, lblk, len, &pr); +if (err3 !=0 ) + goto error; +if (pr) { +__free_pending (pr); + pr =NULL ; + } + } error:write_unlock (&EXT4_I (inode)->i_es_lock); -if (err1 || err2) +if (err1 || err2 || err3) goto retry;ext4_es_print_tree (inode);
@@ -1311,7 +1337,7 @@ static unsigned int get_rsvd(struct inod rc->ndelonly--; node =rb_next (&pr->rb_node);rb_erase (&pr->rb_node, &tree->root); -kmem_cache_free (ext4_pending_cachep, pr); +__free_pending (pr);if (!node)break ; pr = rb_entry(node, struct pending_reservation,
@@ -1907,11 +1933,13 @@ static struct pending_reservation *__get* * @inode - file containing the cluster * @lblk - logical block in the cluster to be added +* @prealloc - preallocated pending entry * * Returns 0 on successful insertion and -ENOMEM on failure. If the * pending reservation is already in the set, returns successfully. */ -static int __insert_pending (struct inode *inode,ext4_lblk_t lblk) +static int __insert_pending (struct inode *inode,ext4_lblk_t lblk, +struct pending_reservation **prealloc) {struct ext4_sb_info *sbi =EXT4_SB (inode->i_sb);struct ext4_pending_tree *tree = &EXT4_I (inode)->i_pending_tree;
@@ -1937,10 +1965,15 @@ static int __insert_pending(struct inode } } - pr =kmem_cache_alloc (ext4_pending_cachep,GFP_ATOMIC ); -if (pr ==NULL ) { - ret = -ENOMEM ; - goto out; +if (likely (*prealloc ==NULL )) { + pr =__alloc_pending (false); +if (!pr) { + ret = -ENOMEM ; + goto out; + } + }else { + pr = *prealloc; + *prealloc =NULL ; } pr->lclu = lclu;
@@ -1970,7 +2003,7 @@ static void __remove_pending(struct inodif (pr !=NULL ) { tree = &EXT4_I (inode)->i_pending_tree;rb_erase (&pr->rb_node, &tree->root); -kmem_cache_free (ext4_pending_cachep, pr); +__free_pending (pr); } }
@@ -2029,10 +2062,10 @@ void ext4_es_insert_delayed_block(struct bool allocated) {struct extent_status newes; -int err1 =0 ; -int err2 =0 ; +int err1 =0 , err2 =0 , err3 =0 ;struct extent_status *es1 =NULL ;struct extent_status *es2 =NULL ; +struct pending_reservation *pr =NULL ;if (EXT4_SB (inode->i_sb)->s_mount_state &EXT4_FC_REPLAY )return ;
@@ -2052,6 +2085,8 @@ retry: es1 =__es_alloc_extent (true);if ((err1 || err2) && !es2) es2 =__es_alloc_extent (true); +if ((err1 || err2 || err3) && allocated && !pr) + pr =__alloc_pending (true);write_lock (&EXT4_I (inode)->i_es_lock); err1 =__es_remove_extent (inode, lblk, lblk,NULL , es1);
@@ -2074,11 +2109,18 @@ retry: es2 =NULL ; } -if (allocated) -__insert_pending (inode, lblk); +if (allocated) { + err3 =__insert_pending (inode, lblk, &pr); +if (err3 !=0 ) + goto error; +if (pr) { +__free_pending (pr); + pr =NULL ; + } + } error:write_unlock (&EXT4_I (inode)->i_es_lock); -if (err1 || err2) +if (err1 || err2 || err3) goto retry;ext4_es_print_tree (inode);
@@ -2184,21 +2226,24 @@ unsigned int ext4_es_delayed_clu(struct* @inode - file containing the range * @lblk - logical block defining the start of range * @len - length of range in blocks +* @prealloc - preallocated pending entry * * Used after a newly allocated extent is added to the extents status tree. * Requires that the extents in the range have either written or unwritten * status. Must be called while holding i_es_lock. */ -static void __revise_pending (struct inode *inode,ext4_lblk_t lblk, -ext4_lblk_t len) +static int __revise_pending (struct inode *inode,ext4_lblk_t lblk, +ext4_lblk_t len, +struct pending_reservation **prealloc) {struct ext4_sb_info *sbi =EXT4_SB (inode->i_sb);ext4_lblk_t end = lblk + len -1 ;ext4_lblk_t first, last;bool f_del = false, l_del = false; +int ret =0 ;if (len ==0 ) -return ; +return 0 ;/* * Two cases - block range within single cluster and block range
@@ -2219,7 +2264,9 @@ static void __revise_pending(struct inod f_del =__es_scan_range (inode, &ext4_es_is_delonly, first, lblk -1 );if (f_del) { -__insert_pending (inode, first); + ret =__insert_pending (inode, first, prealloc); +if (ret <0 ) + goto out; }else { last =EXT4_LBLK_CMASK (sbi, end) + sbi->s_cluster_ratio -1 ;
@@ -2227,9 +2274,11 @@ static void __revise_pending(struct inod l_del =__es_scan_range (inode, &ext4_es_is_delonly, end +1 , last); -if (l_del) -__insert_pending (inode, last); -else +if (l_del) { + ret =__insert_pending (inode, last, prealloc); +if (ret <0 ) + goto out; + }else __remove_pending (inode, last); } }else {
@@ -2237,18 +2286,24 @@ static void __revise_pending(struct inodif (first != lblk) f_del =__es_scan_range (inode, &ext4_es_is_delonly, first, lblk -1 ); -if (f_del) -__insert_pending (inode, first); -else +if (f_del) { + ret =__insert_pending (inode, first, prealloc); +if (ret <0 ) + goto out; + }else __remove_pending (inode, first); last =EXT4_LBLK_CMASK (sbi, end) + sbi->s_cluster_ratio -1 ;if (last != end) l_del =__es_scan_range (inode, &ext4_es_is_delonly, end +1 , last); -if (l_del) -__insert_pending (inode, last); -else +if (l_del) { + ret =__insert_pending (inode, last, prealloc); +if (ret <0 ) + goto out; + }else __remove_pending (inode, last); } +out: +return ret; }
Greg Kroah-Hartman
maintainerPATCH 498/530 ext4: apply umask if ACL support is disabled
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Max Kellermann <[email protected]>
commit 484fd6c1de13b336806a967908a927cc0356e312 upstream.
The function ext4_init_acl() calls posix_acl_create() which is responsible for applying the umask. But without CONFIG_EXT4_FS_POSIX_ACL, ext4_init_acl() is an empty inline function, and nobody applies the umask.
This fixes a bug which causes the umask to be ignored with O_TMPFILE on ext4:
https://github.com/MusicPlayerDaemon/MPD/issues/558
https://bugs.gentoo.org/show_bug.cgi?id=686142#c3
https://bugzilla.kernel.org/show_bug.cgi?id=203625
--- fs/ext4/acl.h | 5 +++++ 1 file changed, 5 insertions(+)
fs/ext4/acl.h +5 -0
@@ -68,6 +68,11 @@ extern int ext4_init_acl(handle_t *, strstatic inline int ext4_init_acl (handle_t *handle,struct inode *inode,struct inode *dir) { +/* usually, the umask is applied by posix_acl_create(), but if +ext4 ACL support is disabled at compile time, we need to do +it here, because posix_acl_create() will never be called */ + inode->i_mode &= ~current_umask (); +return 0 ; }#endif /* CONFIG_EXT4_FS_POSIX_ACL */
Greg Kroah-Hartman
maintainerPATCH 499/530 ext4: correct offset of gdb backup in non meta_bg group to update_backups
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
commit 31f13421c004a420c0e9d288859c9ea9259ea0cc upstream.
Commit 0aeaa2559d6d5 ("ext4: fix corruption when online resizing a 1K bigalloc fs") found that primary superblock's offset in its group is not equal to offset of backup superblock in its group when block size is 1K and bigalloc is enabled. As group descriptor blocks are right after superblock, we can't pass block number of gdb to update_backups for the same reason.
The root casue of the issue above is that leading 1K padding block is count as data block offset for primary block while backup block has no padding block offset in its group.
Remove padding data block count to fix the issue for gdb backups.
For meta_bg case, update_backups treat blk_off as block number, do no conversion in this case.
--- fs/ext4/resize.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/ext4/resize.c +4 -2
@@ -1601,6 +1601,8 @@ exit_journal:int gdb_num_end = ((group + flex_gd->count -1 ) /EXT4_DESC_PER_BLOCK (sb));int meta_bg =ext4_has_feature_meta_bg (sb); +sector_t padding_blocks = meta_bg ?0 : sbi->s_sbh->b_blocknr - +ext4_group_first_block_no (sb,0 );sector_t old_gdb =0 ; update_backups(sb, ext4_group_first_block_no(sb, 0),
@@ -1612,8 +1614,8 @@ exit_journal: gdb_num);if (old_gdb == gdb_bh->b_blocknr)continue ; -update_backups (sb, gdb_bh->b_blocknr, gdb_bh->b_data, - gdb_bh->b_size, meta_bg); +update_backups (sb, gdb_bh->b_blocknr - padding_blocks, + gdb_bh->b_data, gdb_bh->b_size, meta_bg); old_gdb = gdb_bh->b_blocknr; } }
Greg Kroah-Hartman
maintainerPATCH 500/530 ext4: mark buffer new if it is unwritten to avoid stale data exposure
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ojaswin Mujoo <[email protected]>
commit 2cd8bdb5efc1e0d5b11a4b7ba6b922fd2736a87f upstream.
** Short Version **
In ext4 with dioread_nolock, we could have a scenario where the bh returned by get_blocks (ext4_get_block_unwritten()) in __block_write_begin_int() has UNWRITTEN and MAPPED flag set. Since such a bh does not have NEW flag set we never zero out the range of bh that is not under write, causing whatever stale data is present in the folio at that time to be written out to disk. To fix this mark the buffer as new, in case it is unwritten, in ext4_get_block_unwritten().
** Long Version **
The issue mentioned above was resulting in two different bugs:
1. On block size < page size case in ext4, generic/269 was reliably failing with dioread_nolock. The state of the write was as follows:
* The write was extending i_size.
* The last block of the file was fallocated and had an unwritten extent
* We were near ENOSPC and hence we were switching to non-delayed alloc allocation.
In this case, the back trace that triggers the bug is as follows:
ext4_da_write_begin()
/* switch to nodelalloc due to low space */
ext4_write_begin()
ext4_should_dioread_nolock() // true since mount flags still have delalloc
__block_write_begin(..., ext4_get_block_unwritten)
__block_write_begin_int()
for(each buffer head in page) {
/* first iteration, this is bh1 which contains i_size */
if (!buffer_mapped)
get_block() /* returns bh with only UNWRITTEN and MAPPED */
/* second iteration, bh2 */
if (!buffer_mapped)
get_block() /* we fail here, could be ENOSPC */
}
if (err)
/*
* this would zero out all new buffers and mark them uptodate.
* Since bh1 was never marked new, we skip it here which causes
* the bug later.
*/
folio_zero_new_buffers();
/* ext4_wrte_begin() error handling */
ext4_truncate_failed_write()
ext4_truncate()
ext4_block_truncate_page()
__ext4_block_zero_page_range()
if(!buffer_uptodate())
ext4_read_bh_lock()
ext4_read_bh() -> ... ext4_submit_bh_wbc()
BUG_ON(buffer_unwritten(bh)); /* !!! */2. The second issue is stale data exposure with page size >= blocksize with dioread_nolock. The conditions needed for it to happen are same as the previous issue ie dioread_nolock around ENOSPC condition. The issue is also similar where in __block_write_begin_int() when we call ext4_get_block_unwritten() on the buffer_head and the underlying extent is unwritten, we get an unwritten and mapped buffer head. Since it is not new, we never zero out the partial range which is not under write, thus writing stale data to disk. This can be easily observed with the following reproducer:
fallocate -l 4k testfile
xfs_io -c "pwrite 2k 2k" testfile
# hexdump output will have stale data in from byte 0 to 2k in testfile hexdump -C testfile
NOTE: To trigger this, we need dioread_nolock enabled and write happening via ext4_write_begin(), which is usually used when we have -o nodealloc. Since dioread_nolock is disabled with nodelalloc, the only alternate way to call ext4_write_begin() is to ensure that delayed alloc switches to nodelalloc ie ext4_da_write_begin() calls ext4_write_begin(). This will usually happen when ext4 is almost full like the way generic/269 was triggering it in Issue 1 above. This might make the issue harder to hit. Hence, for reliable replication, I used the below patch to temporarily allow dioread_nolock with nodelalloc and then mount the disk with -o nodealloc,dioread_nolock. With this you can hit the stale data issue 100% of times:
@@ -508,8 +508,8 @@ static inline int ext4_should_dioread_nolock(struct inode *inode)
if (ext4_should_journal_data(inode))
return 0;
/* temporary fix to prevent generic/422 test failures */
- if (!test_opt(inode->i_sb, DELALLOC))
- return 0;
+ // if (!test_opt(inode->i_sb, DELALLOC))
+ // return 0;
return 1;
}
After applying this patch to mark buffer as NEW, both the above issues are fixed.
--- fs/ext4/inode.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
fs/ext4/inode.c +13 -1
@@ -789,10 +789,22 @@ int ext4_get_block(struct inode *inode,int ext4_get_block_unwritten (struct inode *inode,sector_t iblock,struct buffer_head *bh_result,int create) { +int ret =0 ; +ext4_debug ("ext4_get_block_unwritten: inode %lu, create flag %d\n" , inode->i_ino, create); -return _ext4_get_block (inode, iblock, bh_result, + ret =_ext4_get_block (inode, iblock, bh_result,EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT ); + +/* +* If the buffer is marked unwritten, mark it as new to make sure it is +* zeroed out correctly in case of partial writes. Otherwise, there is +* a chance of stale data getting exposed. +*/ +if (ret ==0 &&buffer_unwritten (bh_result)) +set_buffer_new (bh_result); + +return ret; }/* Maximum number of blocks we map for direct IO at once. */
Greg Kroah-Hartman
maintainerPATCH 501/530 ext4: correct return value of ext4_convert_meta_bg
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
commit 48f1551592c54f7d8e2befc72a99ff4e47f7dca0 upstream.
Avoid to ignore error in "err".
--- fs/ext4/resize.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/ext4/resize.c +1 -3
@@ -1982,9 +1982,7 @@ static int ext4_convert_meta_bg(struct s errout: ret =ext4_journal_stop (handle); -if (!err) - err = ret; -return ret; +return err ? err : ret; invalid_resize_inode:ext4_error (sb,"corrupted/inconsistent resize inode" );
Greg Kroah-Hartman
maintainerPATCH 484/530 mmc: sdhci-pci-gli: GL9750: Mask the replay timer timeout of AER
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Shih <[email protected]>
commit 015c9cbcf0ad709079117d27c2094a46e0eadcdb upstream.
Due to a flaw in the hardware design, the GL9750 replay timer frequently times out when ASPM is enabled. As a result, the warning messages will often appear in the system log when the system accesses the GL9750 PCI config. Therefore, the replay timer timeout must be masked.
--- drivers/mmc/host/sdhci-pci-gli.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mmc/host/sdhci-pci-gli.c +8 -0
@@ -28,6 +28,9 @@#define PCI_GLI_9750_PM_CTRL 0xFC#define PCI_GLI_9750_PM_STATE GENMASK(1, 0) +#define PCI_GLI_9750_CORRERR_MASK 0x214 +#define PCI_GLI_9750_CORRERR_MASK_REPLAY_TIMER_TIMEOUT BIT(12) +#define SDHCI_GLI_9750_CFG2 0x848#define SDHCI_GLI_9750_CFG2_L1DLY GENMASK(28, 24)#define GLI_9750_CFG2_L1DLY_VALUE 0x1F
@@ -564,6 +567,11 @@ static void gl9750_hw_setting(struct sdh value &= ~PCI_GLI_9750_PM_STATE ;pci_write_config_dword (pdev,PCI_GLI_9750_PM_CTRL , value); +/* mask the replay timer timeout of AER */ +pci_read_config_dword (pdev,PCI_GLI_9750_CORRERR_MASK , &value); + value |=PCI_GLI_9750_CORRERR_MASK_REPLAY_TIMER_TIMEOUT ; +pci_write_config_dword (pdev,PCI_GLI_9750_CORRERR_MASK , value); +gl9750_wt_off (host); }
Greg Kroah-Hartman
maintainerPATCH 502/530 ext4: correct the start block of counting reserved clusters
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
commit 40ea98396a3659062267d1fe5f99af4f7e4f05e3 upstream.
When big allocate feature is enabled, we need to count and update reserved clusters before removing a delayed only extent_status entry. {init|count|get}_rsvd() have already done this, but the start block number of this counting isn't correct in the following case.
lblk end
| | v v
-------------------------
| | orig_es
-------------------------
^ ^
len1 is 0 | len2 |
If the start block of the orig_es entry founded is bigger than lblk, we passed lblk as start block to count_rsvd(), but the length is correct, finally, the range to be counted is offset. This patch fix this by passing the start blocks to 'orig_es->lblk + len1'.
--- fs/ext4/extents_status.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext4/extents_status.c +2 -2
@@ -1431,8 +1431,8 @@ static int __es_remove_extent(struct ino } }if (count_reserved) -count_rsvd (inode, lblk, orig_es.es_len - len1 - len2, - &orig_es, &rc); +count_rsvd (inode, orig_es.es_lblk + len1, + orig_es.es_len - len1 - len2, &orig_es, &rc); goto out_get_reserved; }
Greg Kroah-Hartman
maintainerPATCH 503/530 ext4: remove gdb backup copy for meta bg in setup_new_flex_group_blocks
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
commit 40dd7953f4d606c280074f10d23046b6812708ce upstream.
Wrong check of gdb backup in meta bg as following:first_group is the first group of meta_bg which contains target group, so target group is always >= first_group. We check if target group has gdb backup by comparing first_group with [group + 1] and [group + EXT4_DESC_PER_BLOCK(sb) - 1]. As group >= first_group, then [group + N] is
Quoted 1 line
first_group. So no copy of gdb backup in meta bg is done in
setup_new_flex_group_blocks.
No need to do gdb backup copy in meta bg from setup_new_flex_group_blocks as we always copy updated gdb block to backups at end of ext4_flex_group_add as following:
ext4_flex_group_add
/* no gdb backup copy for meta bg any more */
setup_new_flex_group_blocks
/* update current group number */
ext4_update_super
sbi->s_groups_count += flex_gd->count; /*
* if group in meta bg contains backup is added, the primary gdb block
* of the meta bg will be copy to backup in new added group here. */
for (; gdb_num <= gdb_num_end; gdb_num++)
update_backups(...)
In summary, we can remove wrong gdb backup copy code in setup_new_flex_group_blocks.
--- fs/ext4/resize.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
fs/ext4/resize.c +2 -7
@@ -560,13 +560,8 @@ static int setup_new_flex_group_blocks(sif (meta_bg ==0 && !ext4_bg_has_super (sb, group)) goto handle_itb; -if (meta_bg ==1 ) { -ext4_group_t first_group; - first_group =ext4_meta_bg_first_group (sb, group); -if (first_group != group +1 && - first_group != group +EXT4_DESC_PER_BLOCK (sb) -1 ) - goto handle_itb; - } +if (meta_bg ==1 ) + goto handle_itb; block = start +ext4_bg_has_super (sb, group);/* Copy all of the GDT blocks into the backup in this group */
Greg Kroah-Hartman
maintainerPATCH 504/530 ext4: add missed brelse in update_backups
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
commit 9adac8b01f4be28acd5838aade42b8daa4f0b642 upstream.
add missed brelse in update_backups
--- fs/ext4/resize.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/resize.c +3 -1
@@ -1186,8 +1186,10 @@ static void update_backups(struct super_ ext4_group_first_block_no(sb, group));BUFFER_TRACE (bh,"get_write_access" );if ((err =ext4_journal_get_write_access (handle, sb, bh, -EXT4_JTR_NONE ))) +EXT4_JTR_NONE ))) { +brelse (bh);break ; + }lock_buffer (bh);memcpy (bh->b_data, data, size);if (rest)
Greg Kroah-Hartman
maintainerPATCH 505/530 ext4: properly sync file size update after O_SYNC direct IO
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <[email protected]>
commit 91562895f8030cb9a0470b1db49de79346a69f91 upstream.
Gao Xiang has reported that on ext4 O_SYNC direct IO does not properly sync file size update and thus if we crash at unfortunate moment, the file can have smaller size although O_SYNC IO has reported successful completion. The problem happens because update of on-disk inode size is handled in ext4_dio_write_iter() *after* iomap_dio_rw() (and thus dio_complete() in particular) has returned and generic_file_sync() gets called by dio_complete(). Fix the problem by handling on-disk inode size update directly in our ->end_io completion handler.
References: https://lore.kernel.org/all/[email protected]
--- fs/ext4/file.c | 153 ++++++++++++++++++++++++--------------------------------- 1 file changed, 65 insertions(+), 88 deletions(-)
fs/ext4/file.c +65 -88
@@ -306,80 +306,38 @@ out: }static ssize_t ext4_handle_inode_extension (struct inode *inode,loff_t offset, -ssize_t written,size_t count) +ssize_t count) {handle_t *handle; -bool truncate = false; -u8 blkbits = inode->i_blkbits; -ext4_lblk_t written_blk, end_blk; -int ret; - -/* -* Note that EXT4_I(inode)->i_disksize can get extended up to -* inode->i_size while the I/O was running due to writeback of delalloc -* blocks. But, the code in ext4_iomap_alloc() is careful to use -* zeroed/unwritten extents if this is possible; thus we won't leave -* uninitialized blocks in a file even if we didn't succeed in writing -* as much as we intended. -*/ -WARN_ON_ONCE (i_size_read (inode) <EXT4_I (inode)->i_disksize); -if (offset + count <=EXT4_I (inode)->i_disksize) { -/* -* We need to ensure that the inode is removed from the orphan -* list if it has been added prematurely, due to writeback of -* delalloc blocks. -*/ -if (!list_empty (&EXT4_I (inode)->i_orphan) && inode->i_nlink) { - handle =ext4_journal_start (inode,EXT4_HT_INODE ,2 ); - -if (IS_ERR (handle)) { -ext4_orphan_del (NULL , inode); -return PTR_ERR (handle); - } - -ext4_orphan_del (handle, inode); -ext4_journal_stop (handle); - } - -return written; - } - -if (written <0 ) - goto truncate; +lockdep_assert_held_write (&inode->i_rwsem); handle =ext4_journal_start (inode,EXT4_HT_INODE ,2 ); -if (IS_ERR (handle)) { - written =PTR_ERR (handle); - goto truncate; - } +if (IS_ERR (handle)) +return PTR_ERR (handle); -if (ext4_update_inode_size (inode, offset + written)) { - ret =ext4_mark_inode_dirty (handle, inode); +if (ext4_update_inode_size (inode, offset + count)) { +int ret =ext4_mark_inode_dirty (handle, inode);if (unlikely (ret)) { - written = ret;ext4_journal_stop (handle); - goto truncate; +return ret; } } -/* -* We may need to truncate allocated but not written blocks beyond EOF. -*/ - written_blk =ALIGN (offset + written,1 << blkbits); - end_blk =ALIGN (offset + count,1 << blkbits); -if (written_blk < end_blk &&ext4_can_truncate (inode)) - truncate = true; - -/* -* Remove the inode from the orphan list if it has been extended and -* everything went OK. -*/ -if (!truncate && inode->i_nlink) +if (inode->i_nlink)ext4_orphan_del (handle, inode);ext4_journal_stop (handle); -if (truncate) { -truncate: +return count; +} + +/* +* Clean up the inode after DIO or DAX extending write has completed and the +* inode size has been updated using ext4_handle_inode_extension(). +*/ +static void ext4_inode_extension_cleanup (struct inode *inode,ssize_t count) +{ +lockdep_assert_held_write (&inode->i_rwsem); +if (count <0 ) {ext4_truncate_failed_write (inode);/* * If the truncate operation failed early, then the inode may
@@ -388,9 +346,28 @@ truncate:*/ if (inode->i_nlink)ext4_orphan_del (NULL , inode); +return ; } +/* +* If i_disksize got extended due to writeback of delalloc blocks while +* the DIO was running we could fail to cleanup the orphan list in +* ext4_handle_inode_extension(). Do it now. +*/ +if (!list_empty (&EXT4_I (inode)->i_orphan) && inode->i_nlink) { +handle_t *handle =ext4_journal_start (inode,EXT4_HT_INODE ,2 ); -return written; +if (IS_ERR (handle)) { +/* +* The write has successfully completed. Not much to +* do with the error here so just cleanup the orphan +* list and hope for the best. +*/ +ext4_orphan_del (NULL , inode); +return ; + } +ext4_orphan_del (handle, inode); +ext4_journal_stop (handle); + } } static int ext4_dio_write_end_io(struct kiocb *iocb, ssize_t size,
@@ -399,31 +376,22 @@ static int ext4_dio_write_end_io(structloff_t pos = iocb->ki_pos;struct inode *inode =file_inode (iocb->ki_filp); +if (!error && size && flags &IOMAP_DIO_UNWRITTEN ) + error =ext4_convert_unwritten_extents (NULL , inode, pos, size);if (error)return error; - -if (size && flags &IOMAP_DIO_UNWRITTEN ) { - error =ext4_convert_unwritten_extents (NULL , inode, pos, size); -if (error <0 ) -return error; - }/* -* If we are extending the file, we have to update i_size here before -* page cache gets invalidated in iomap_dio_rw(). Otherwise racing -* buffered reads could zero out too much from page cache pages. Update -* of on-disk size will happen later in ext4_dio_write_iter() where -* we have enough information to also perform orphan list handling etc. -* Note that we perform all extending writes synchronously under -* i_rwsem held exclusively so i_size update is safe here in that case. -* If the write was not extending, we cannot see pos > i_size here -* because operations reducing i_size like truncate wait for all -* outstanding DIO before updating i_size. +* Note that EXT4_I(inode)->i_disksize can get extended up to +* inode->i_size while the I/O was running due to writeback of delalloc +* blocks. But the code in ext4_iomap_alloc() is careful to use +* zeroed/unwritten extents if this is possible; thus we won't leave +* uninitialized blocks in a file even if we didn't succeed in writing +* as much as we intended. */ - pos += size; -if (pos >i_size_read (inode)) -i_size_write (inode, pos); - -return 0 ; +WARN_ON_ONCE (i_size_read (inode) <READ_ONCE (EXT4_I (inode)->i_disksize)); +if (pos + size <=READ_ONCE (EXT4_I (inode)->i_disksize)) +return size; +return ext4_handle_inode_extension (inode, pos, size); }static const struct iomap_dio_ops ext4_dio_write_ops = {
@@ -606,9 +574,16 @@ static ssize_t ext4_dio_write_iter(struc dio_flags, NULL, 0);if (ret == -ENOTBLK ) ret =0 ; - -if (extend) - ret =ext4_handle_inode_extension (inode, offset, ret, count); +if (extend) { +/* +* We always perform extending DIO write synchronously so by +* now the IO is completed and ext4_handle_inode_extension() +* was called. Cleanup the inode in case of error or race with +* writeback of delalloc blocks. +*/ +WARN_ON_ONCE (ret == -EIOCBQUEUED ); +ext4_inode_extension_cleanup (inode, ret); + } out:if (ilock_shared)
@@ -689,8 +664,10 @@ ext4_dax_write_iter(struct kiocb *iocb, ret =dax_iomap_rw (iocb, from, &ext4_iomap_ops); -if (extend) - ret =ext4_handle_inode_extension (inode, offset, ret, count); +if (extend) { + ret =ext4_handle_inode_extension (inode, offset, ret); +ext4_inode_extension_cleanup (inode, ret); + } out:inode_unlock (inode);if (ret >0 )
Greg Kroah-Hartman
maintainerPATCH 506/530 ext4: fix racy may inline data check in dio write
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Foster <[email protected]>
commit ce56d21355cd6f6937aca32f1f44ca749d1e4808 upstream.
syzbot reports that the following warning from ext4_iomap_begin() triggers as of the commit referenced below:
if (WARN_ON_ONCE(ext4_has_inline_data(inode)))
return -ERANGE;This occurs during a dio write, which is never expected to encounter an inode with inline data. To enforce this behavior, ext4_dio_write_iter() checks the current inline state of the inode and clears the MAY_INLINE_DATA state flag to either fall back to buffered writes, or enforce that any other writers in progress on the inode are not allowed to create inline data.
The problem is that the check for existing inline data and the state flag can span a lock cycle. For example, if the ilock is originally locked shared and subsequently upgraded to exclusive, another writer may have reacquired the lock and created inline data before the dio write task acquires the lock and proceeds.
The commit referenced below loosens the lock requirements to allow some forms of unaligned dio writes to occur under shared lock, but AFAICT the inline data check was technically already racy for any dio write that would have involved a lock cycle. Regardless, lift clearing of the state bit to the same lock critical section that checks for preexisting inline data on the inode to close the race.
--- fs/ext4/file.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
fs/ext4/file.c +9 -7
@@ -537,18 +537,20 @@ static ssize_t ext4_dio_write_iter(strucreturn ext4_buffered_write_iter (iocb, from); } +/* +* Prevent inline data from being created since we are going to allocate +* blocks for DIO. We know the inode does not currently have inline data +* because ext4_should_use_dio() checked for it, but we have to clear +* the state flag before the write checks because a lock cycle could +* introduce races with other writers. +*/ +ext4_clear_inode_state (inode,EXT4_STATE_MAY_INLINE_DATA ); + ret =ext4_dio_write_checks (iocb, from, &ilock_shared, &extend, &unwritten, &dio_flags);if (ret <=0 )return ret; -/* -* Make sure inline data cannot be created anymore since we are going -* to allocate blocks for DIO. We know the inode does not have any -* inline data now because ext4_dio_supported() checked for that. -*/ -ext4_clear_inode_state (inode,EXT4_STATE_MAY_INLINE_DATA ); - offset = iocb->ki_pos; count = ret;
Greg Kroah-Hartman
maintainerPATCH 507/530 drm/amd/pm: Handle non-terminated overdrive commands.
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bas Nieuwenhuizen <[email protected]>
commit 08e9ebc75b5bcfec9d226f9e16bab2ab7b25a39a upstream.
The incoming strings might not be terminated by a newline or a 0.
(found while testing a program that just wrote the string
itself, causing a crash)
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +6 -2
@@ -734,7 +734,7 @@ static ssize_t amdgpu_set_pp_od_clk_voltif (adev->in_suspend && !adev->in_runpm)return -EPERM ; -if (count >127 ) +if (count >127 || count ==0 )return -EINVAL ;if (*buf =='s' )
@@ -754,7 +754,8 @@ static ssize_t amdgpu_set_pp_od_clk_voltelse return -EINVAL ; -memcpy (buf_cpy, buf, count+1 ); +memcpy (buf_cpy, buf, count); + buf_cpy[count] =0 ; tmp_str = buf_cpy;
@@ -771,6 +772,9 @@ static ssize_t amdgpu_set_pp_od_clk_voltreturn -EINVAL ; parameter_size++; +if (!tmp_str) +break ; +while (isspace (*tmp_str)) tmp_str++; }
Greg Kroah-Hartman
maintainerPATCH 508/530 drm: bridge: it66121: ->get_edid callback must not return err pointers
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jani Nikula <[email protected]>
commit 81995ee1620318b4c7bbeb02bcc372da2c078c76 upstream.
The drm stack does not expect error valued pointers for EDID anywhere.
--- drivers/gpu/drm/bridge/ite-it66121.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/ite-it66121.c +2 -2
@@ -884,14 +884,14 @@ static struct edid *it66121_bridge_get_emutex_lock (&ctx->lock); ret =it66121_preamble_ddc (ctx);if (ret) { - edid =ERR_PTR (ret); + edid =NULL ; goto out_unlock; } ret =regmap_write (ctx->regmap,IT66121_DDC_HEADER_REG ,IT66121_DDC_HEADER_EDID );if (ret) { - edid =ERR_PTR (ret); + edid =NULL ; goto out_unlock; }
Greg Kroah-Hartman
maintainerPATCH 509/530 x86/srso: Move retbleed IBPB check into existing has_microcode code block
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josh Poimboeuf <[email protected]>
commit 351236947a45a512c517153bbe109fe868d05e6d upstream.
Simplify the code flow a bit by moving the retbleed IBPB check into the existing 'has_microcode' block.
--- arch/x86/kernel/cpu/bugs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/kernel/cpu/bugs.c +1 -3
@@ -2422,10 +2422,8 @@ static void __init srso_select_mitigatiosetup_force_cpu_cap (X86_FEATURE_SRSO_NO );return ; } - } -if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) { -if (has_microcode) { +if (retbleed_mitigation ==RETBLEED_MITIGATION_IBPB ) { srso_mitigation =SRSO_MITIGATION_IBPB ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 485/530 media: qcom: camss: Fix pm_domain_on sequence in probe
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit 7405116519ad70b8c7340359bfac8db8279e7ce4 upstream.
We need to make sure camss_configure_pd() happens before camss_register_entities() as the vfe_get() path relies on the pointer provided by camss_configure_pd().
Fix the ordering sequence in probe to ensure the pointers vfe_get() demands are present by the time camss_register_entities() runs.
In order to facilitate backporting to stable kernels I've moved the configure_pd() call pretty early on the probe() function so that irrespective of the existence of the old error handling jump labels this patch should still apply to -next circa Aug 2023 to v5.13 inclusive.
--- drivers/media/platform/qcom/camss/camss.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/media/platform/qcom/camss/camss.c +6 -6
@@ -1619,6 +1619,12 @@ static int camss_probe(struct platform_dif (ret <0 ) goto err_cleanup; + ret =camss_configure_pd (camss); +if (ret <0 ) { +dev_err (dev,"Failed to configure power domains: %d\n" , ret); + goto err_cleanup; + } + ret =camss_init_subdevices (camss);if (ret <0 ) goto err_cleanup;
@@ -1678,12 +1684,6 @@ static int camss_probe(struct platform_d } } - ret =camss_configure_pd (camss); -if (ret <0 ) { -dev_err (dev,"Failed to configure power domains: %d\n" , ret); -return ret; - } -pm_runtime_enable (dev);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 486/530 media: qcom: camss: Fix vfe_get() error jump
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit 26bda3da00c3edef727a6acb00ed2eb4b22f8723 upstream.
Right now it is possible to do a vfe_get() with the internal reference count at 1. If vfe_check_clock_rates() returns non-zero then we will leave the reference count as-is and
run:
- pm_runtime_put_sync()
- vfe->ops->pm_domain_off()
skip:
- camss_disable_clocks()
Subsequent vfe_put() calls will when the ref-count is non-zero unconditionally run:
- pm_runtime_put_sync()
- vfe->ops->pm_domain_off()
- camss_disable_clocks()
vfe_get() should not attempt to roll-back on error when the ref-count is non-zero as the upper layers will still do their own vfe_put() operations.
vfe_put() will drop the reference count and do the necessary power domain release, the cleanup jumps in vfe_get() should only be run when the ref-count is zero.
[ 50.095796] CPU: 7 PID: 3075 Comm: cam Not tainted 6.3.2+ #80 [ 50.095798] Hardware name: LENOVO 21BXCTO1WW/21BXCTO1WW, BIOS N3HET82W (1.54 ) 05/26/2023 [ 50.095799] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 50.095802] pc : refcount_warn_saturate+0xf4/0x148 [ 50.095804] lr : refcount_warn_saturate+0xf4/0x148 [ 50.095805] sp : ffff80000c7cb8b0 [ 50.095806] x29: ffff80000c7cb8b0 x28: ffff16ecc0e3fc10 x27: 0000000000000000 [ 50.095810] x26: 0000000000000000 x25: 0000000000020802 x24: 0000000000000000 [ 50.095813] x23: ffff16ecc7360640 x22: 00000000ffffffff x21: 0000000000000005 [ 50.095815] x20: ffff16ed175f4400 x19: ffffb4d9852942a8 x18: ffffffffffffffff [ 50.095818] x17: ffffb4d9852d4a48 x16: ffffb4d983da5db8 x15: ffff80000c7cb320 [ 50.095821] x14: 0000000000000001 x13: 2e656572662d7265 x12: 7466612d65737520 [ 50.095823] x11: 00000000ffffefff x10: ffffb4d9850cebf0 x9 : ffffb4d9835cf954 [ 50.095826] x8 : 0000000000017fe8 x7 : c0000000ffffefff x6 : 0000000000057fa8 [ 50.095829] x5 : ffff16f813fe3d08 x4 : 0000000000000000 x3 : ffff621e8f4d2000 [ 50.095832] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff16ed32119040 [ 50.095835] Call trace: [ 50.095836] refcount_warn_saturate+0xf4/0x148 [ 50.095838] device_link_put_kref+0x84/0xc8 [ 50.095843] device_link_del+0x38/0x58 [ 50.095846] vfe_pm_domain_off+0x3c/0x50 [qcom_camss] [ 50.095860] vfe_put+0x114/0x140 [qcom_camss] [ 50.095869] csid_set_power+0x2c8/0x408 [qcom_camss] [ 50.095878] pipeline_pm_power_one+0x164/0x170 [videodev] [ 50.095896] pipeline_pm_power+0xc4/0x110 [videodev] [ 50.095909] v4l2_pipeline_pm_use+0x5c/0xa0 [videodev] [ 50.095923] v4l2_pipeline_pm_get+0x1c/0x30 [videodev] [ 50.095937] video_open+0x7c/0x100 [qcom_camss] [ 50.095945] v4l2_open+0x84/0x130 [videodev] [ 50.095960] chrdev_open+0xc8/0x250 [ 50.095964] do_dentry_open+0x1bc/0x498 [ 50.095966] vfs_open+0x34/0x40 [ 50.095968] path_openat+0xb44/0xf20 [ 50.095971] do_filp_open+0xa4/0x160 [ 50.095974] do_sys_openat2+0xc8/0x188 [ 50.095975] __arm64_sys_openat+0x6c/0xb8 [ 50.095977] invoke_syscall+0x50/0x128 [ 50.095982] el0_svc_common.constprop.0+0x4c/0x100 [ 50.095985] do_el0_svc+0x40/0xa8 [ 50.095988] el0_svc+0x2c/0x88 [ 50.095991] el0t_64_sync_handler+0xf4/0x120 [ 50.095994] el0t_64_sync+0x190/0x198 [ 50.095996] ---[ end trace 0000000000000000 ]---
--- drivers/media/platform/qcom/camss/camss-vfe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss-vfe.c +1 -1
@@ -611,7 +611,7 @@ int vfe_get(struct vfe_device *vfe) }else { ret =vfe_check_clock_rates (vfe);if (ret <0 ) - goto error_pm_runtime_get; + goto error_pm_domain; } vfe->power_count++;
Greg Kroah-Hartman
maintainerPATCH 487/530 media: qcom: camss: Fix VFE-17x vfe_disable_output()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit 3143ad282fc08bf995ee73e32a9e40c527bf265d upstream.
There are two problems with the current vfe_disable_output() routine.
Firstly we rightly use a spinlock to protect output->gen2.active_num everywhere except for in the IDLE timeout path of vfe_disable_output(). Even if that is not racy "in practice" somehow it is by happenstance not by design.
Secondly we do not get consistent behaviour from this routine. On sc8280xp 50% of the time I get "VFE idle timeout - resetting". In this case the subsequent capture will succeed. The other 50% of the time, we don't hit the idle timeout, never do the VFE reset and subsequent captures stall indefinitely.
Rewrite the vfe_disable_output() routine to
- Quiesce write masters with vfe_wm_stop()
- Set active_num = 0
remembering to hold the spinlock when we do so followed by
- Reset the VFE
Testing on sc8280xp and sdm845 shows this to be a valid fix.
--- drivers/media/platform/qcom/camss/camss-vfe-170.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)
drivers/media/platform/qcom/camss/camss-vfe-170.c +3 -19
@@ -7,7 +7,6 @@* Copyright (C) 2020-2021 Linaro Ltd. */ -#include <linux/delay.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/iopoll.h>
@@ -494,35 +493,20 @@ static int vfe_enable_output(struct vfe_return 0 ; } -static int vfe_disable_output (struct vfe_line *line) +static void vfe_disable_output (struct vfe_line *line) {struct vfe_device *vfe =to_vfe (line);struct vfe_output *output = &line->output;unsigned long flags;unsigned int i; -bool done; -int timeout =0 ; - -do { -spin_lock_irqsave (&vfe->output_lock, flags); - done = !output->gen2.active_num; -spin_unlock_irqrestore (&vfe->output_lock, flags); -usleep_range (10000 ,20000 ); - -if (timeout++ ==100 ) { -dev_err (vfe->camss->dev,"VFE idle timeout - resetting\n" ); -vfe_reset (vfe); - output->gen2.active_num =0 ; -return 0 ; - } - }while (!done);spin_lock_irqsave (&vfe->output_lock, flags);for (i =0 ; i < output->wm_num; i++)vfe_wm_stop (vfe, output->wm_idx[i]); + output->gen2.active_num =0 ;spin_unlock_irqrestore (&vfe->output_lock, flags); -return 0 ; +vfe_reset (vfe); }/*
Greg Kroah-Hartman
maintainerPATCH 488/530 media: qcom: camss: Fix VFE-480 vfe_disable_output()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit 7f24d291350426d40b36dfbe6b3090617cdfd37a upstream.
vfe-480 is copied from vfe-17x and has the same racy idle timeout bug as in 17x.
Fix the vfe_disable_output() logic to no longer be racy and to conform to the 17x way of quiescing and then resetting the VFE.
--- drivers/media/platform/qcom/camss/camss-vfe-480.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)
drivers/media/platform/qcom/camss/camss-vfe-480.c +3 -19
@@ -8,7 +8,6 @@* Copyright (C) 2021 Jonathan Marek */ -#include <linux/delay.h> #include <linux/interrupt.h> #include <linux/io.h> #include <linux/iopoll.h>
@@ -328,35 +327,20 @@ static int vfe_enable_output(struct vfe_return 0 ; } -static int vfe_disable_output (struct vfe_line *line) +static void vfe_disable_output (struct vfe_line *line) {struct vfe_device *vfe =to_vfe (line);struct vfe_output *output = &line->output;unsigned long flags;unsigned int i; -bool done; -int timeout =0 ; - -do { -spin_lock_irqsave (&vfe->output_lock, flags); - done = !output->gen2.active_num; -spin_unlock_irqrestore (&vfe->output_lock, flags); -usleep_range (10000 ,20000 ); - -if (timeout++ ==100 ) { -dev_err (vfe->camss->dev,"VFE idle timeout - resetting\n" ); -vfe_reset (vfe); - output->gen2.active_num =0 ; -return 0 ; - } - }while (!done);spin_lock_irqsave (&vfe->output_lock, flags);for (i =0 ; i < output->wm_num; i++)vfe_wm_stop (vfe, output->wm_idx[i]); + output->gen2.active_num =0 ;spin_unlock_irqrestore (&vfe->output_lock, flags); -return 0 ; +vfe_reset (vfe); }/*
Greg Kroah-Hartman
maintainerPATCH 489/530 media: qcom: camss: Fix missing vfe_lite clocks check
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit b6e1bdca463a932c1ac02caa7d3e14bf39288e0c upstream.
check_clock doesn't account for vfe_lite which means that vfe_lite will never get validated by this routine. Add the clock name to the expected set to remediate.
--- drivers/media/platform/qcom/camss/camss-vfe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss-vfe.c +2 -1
@@ -535,7 +535,8 @@ static int vfe_check_clock_rates(structstruct camss_clock *clock = &vfe->clock[i];if (!strcmp (clock->name,"vfe0" ) || - !strcmp (clock->name,"vfe1" )) { + !strcmp (clock->name,"vfe1" ) || + !strcmp (clock->name,"vfe_lite" )) {u64 min_rate =0 ;unsigned long rate;
Greg Kroah-Hartman
maintainerPATCH 490/530 media: qcom: camss: Fix set CSI2_RX_CFG1_VC_MODE when VC is greater than 3
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit e655d1ae9703286cef7fda8675cad62f649dc183 upstream.
VC_MODE = 0 implies a two bit VC address.VC_MODE = 1 is required for VCs with a larger address than two bits.
--- drivers/media/platform/qcom/camss/camss-csid-gen2.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/qcom/camss/camss-csid-gen2.c +2 -0
@@ -449,6 +449,8 @@ static void __csid_configure_stream(struwritel_relaxed (val, csid->base +CSID_CSI2_RX_CFG0 ); val =1 <<CSI2_RX_CFG1_PACKET_ECC_CORRECTION_EN ; +if (vc >3 ) + val |=1 <<CSI2_RX_CFG1_VC_MODE ; val |=1 <<CSI2_RX_CFG1_MISR_EN ;writel_relaxed (val, csid->base +CSID_CSI2_RX_CFG1 );
Greg Kroah-Hartman
maintainerPATCH 491/530 media: qcom: camss: Fix invalid clock enable bit disjunction
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryan O'Donoghue <[email protected]>
commit d8f7e1a60d01739a1d78db2b08603089c6cf7c8e upstream.
define CSIPHY_3PH_CMN_CSI_COMMON_CTRL5_CLK_ENABLE BIT(7)
disjunction for gen2 ? BIT(7) : is a nop we are setting the same bit either way.
--- drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/qcom/camss/camss-csiphy-3ph-1-0.c +1 -1
@@ -476,7 +476,7 @@ static void csiphy_lanes_enable(struct c settle_cnt =csiphy_settle_cnt_calc (link_freq, csiphy->timer_clk_rate); - val = is_gen2 ?BIT (7 ) :CSIPHY_3PH_CMN_CSI_COMMON_CTRL5_CLK_ENABLE ; + val =CSIPHY_3PH_CMN_CSI_COMMON_CTRL5_CLK_ENABLE ;for (i =0 ; i < c->num_data; i++) val |=BIT (c->data[i].pos *2 );
Greg Kroah-Hartman
maintainerPATCH 482/530 r8169: fix network lost after resume on DASH systems
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: ChunHao Lin <[email protected]>
commit 868c3b95afef4883bfb66c9397482da6840b5baf upstream.
Device that support DASH may be reseted or powered off during suspend. So driver needs to handle DASH during system suspend and resume. Or DASH firmware will influence device behavior and causes network lost.
--- drivers/net/ethernet/realtek/r8169_main.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/realtek/r8169_main.c +6 -0
@@ -4648,10 +4648,16 @@ static void rtl8169_down(struct rtl8169_rtl8169_cleanup (tp);rtl_disable_exit_l1 (tp);rtl_prepare_power_down (tp); + +if (tp->dash_type !=RTL_DASH_NONE ) +rtl8168_driver_stop (tp); }static void rtl8169_up (struct rtl8169_private *tp) { +if (tp->dash_type !=RTL_DASH_NONE ) +rtl8168_driver_start (tp); +pci_set_master (tp->pci_dev);phy_init_hw (tp->phydev);phy_resume (tp->phydev);
Greg Kroah-Hartman
maintainerPATCH 511/530 drm/i915/mtl: Support HBR3 rate with C10 phy and eDP in MTL
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chaitanya Kumar Borah <[email protected]>
commit ce4941c2d6459664761c9854701015d8e99414fb upstream.
eDP specification supports HBR3 link rate since v1.4a. Moreover, C10 phy can support HBR3 link rate for both DP and eDP. Therefore, do not clamp the supported rates for eDP at 6.75Gbps.
BSpec: 70073 74224
--- drivers/gpu/drm/i915/display/intel_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_dp.c +1 -1
@@ -430,7 +430,7 @@ static int mtl_max_source_rate(struct inenum phy phy =intel_port_to_phy (i915, dig_port->base.port);if (intel_is_c10phy (i915, phy)) -return intel_dp_is_edp (intel_dp) ?675000 :810000 ; +return 810000 ;return 2000000 ; }
Greg Kroah-Hartman
maintainerPATCH 520/530 drm/amdgpu: dont use ATRM for external devices
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
commit 432e664e7c98c243fab4c3c95bd463bea3aeed28 upstream.
The ATRM ACPI method is for fetching the dGPU vbios rom image on laptops and all-in-one systems. It should not be used for external add in cards. If the dGPU is thunderbolt connected, don't try ATRM.
v2: pci_is_thunderbolt_attached only works for Intel. Use
pdev->external_facing instead.
v3: dev_is_removable() seems to be what we want
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +5 -0
@@ -29,6 +29,7 @@#include "amdgpu.h" #include "atom.h" +#include <linux/device.h> #include <linux/pci.h> #include <linux/slab.h> #include <linux/acpi.h>
@@ -287,6 +288,10 @@ static bool amdgpu_atrm_get_bios(structif (adev->flags &AMD_IS_APU )return false; +/* ATRM is for on-platform devices only */ +if (dev_is_removable (&adev->pdev->dev)) +return false; +while ((pdev =pci_get_class (PCI_CLASS_DISPLAY_VGA <<8 , pdev)) !=NULL ) { dhandle =ACPI_HANDLE (&pdev->dev);if (!dhandle)
Greg Kroah-Hartman
maintainerPATCH 521/530 drm/amdgpu: fix error handling in amdgpu_vm_init
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian König <[email protected]>
commit 8473bfdcb5b1a32fd05629c4535ccacd73bc5567 upstream.
When clearing the root PD fails we need to properly release it again.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +16 -15
@@ -2125,7 +2125,8 @@ long amdgpu_vm_wait_idle(struct amdgpu_v* Returns: * 0 for success, error for failure. */ -int amdgpu_vm_init (struct amdgpu_device *adev,struct amdgpu_vm *vm,int32_t xcp_id) +int amdgpu_vm_init (struct amdgpu_device *adev,struct amdgpu_vm *vm, +int32_t xcp_id) {struct amdgpu_bo *root_bo;struct amdgpu_bo_vm *root;
@@ -2144,6 +2145,7 @@ int amdgpu_vm_init(struct amdgpu_deviceINIT_LIST_HEAD (&vm->done);INIT_LIST_HEAD (&vm->pt_freed);INIT_WORK (&vm->pt_free_work, amdgpu_vm_pt_free_work); +INIT_KFIFO (vm->faults); r =amdgpu_vm_init_entities (adev, vm);if (r)
@@ -2178,34 +2180,33 @@ int amdgpu_vm_init(struct amdgpu_device false, &root, xcp_id);if (r) goto error_free_delayed; - root_bo = &root->bo; + + root_bo =amdgpu_bo_ref (&root->bo); r =amdgpu_bo_reserve (root_bo, true); -if (r) - goto error_free_root; +if (r) { +amdgpu_bo_unref (&root->shadow); +amdgpu_bo_unref (&root_bo); + goto error_free_delayed; + } +amdgpu_vm_bo_base_init (&vm->root, vm, root_bo); r =dma_resv_reserve_fences (root_bo->tbo.base.resv,1 );if (r) - goto error_unreserve; - -amdgpu_vm_bo_base_init (&vm->root, vm, root_bo); + goto error_free_root; r =amdgpu_vm_pt_clear (adev, vm, root, false);if (r) - goto error_unreserve; + goto error_free_root;amdgpu_bo_unreserve (vm->root.bo); - -INIT_KFIFO (vm->faults); +amdgpu_bo_unref (&root_bo);return 0 ; -error_unreserve: -amdgpu_bo_unreserve (vm->root.bo); - error_free_root: -amdgpu_bo_unref (&root->shadow); +amdgpu_vm_pt_free_root (adev, vm); +amdgpu_bo_unreserve (vm->root.bo);amdgpu_bo_unref (&root_bo); - vm->root.bo =NULL ; error_free_delayed:dma_fence_put (vm->last_tlb_flush);
Greg Kroah-Hartman
maintainerPATCH 522/530 drm/amdgpu: fix error handling in amdgpu_bo_list_get()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian König <[email protected]>
commit 12f76050d8d4d10dab96333656b821bd4620d103 upstream.
We should not leak the pointer where we couldn't grab the reference on to the caller because it can be that the error handling still tries to put the reference then.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +1 -0
@@ -183,6 +183,7 @@ int amdgpu_bo_list_get(struct amdgpu_fpr }rcu_read_unlock (); + *result =NULL ;return -ENOENT ; }
Greg Kroah-Hartman
maintainerPATCH 523/530 drm/amdgpu: lower CS errors to debug severity
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian König <[email protected]>
commit 17daf01ab4e3e5a5929747aa05cc15eb2bad5438 upstream.
Otherwise userspace can spam the logs by using incorrect input values.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -1
@@ -1411,7 +1411,7 @@ int amdgpu_cs_ioctl(struct drm_device *dif (r == -ENOMEM )DRM_ERROR ("Not enough memory for command submission!\n" );else if (r != -ERESTARTSYS && r != -EAGAIN ) -DRM_ERROR ("Failed to process the buffer list %d!\n" , r); +DRM_DEBUG ("Failed to process the buffer list %d!\n" , r); goto error_fini; }
Greg Kroah-Hartman
maintainerPATCH 524/530 drm/amdgpu: Fix possible null pointer dereference
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Kuehling <[email protected]>
commit 256503071c2de2b5b5c20e06654aa9a44f13aa62 upstream.
mem = bo->tbo.resource may be NULL in amdgpu_vm_bo_update.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -2
@@ -1095,8 +1095,8 @@ int amdgpu_vm_bo_update(struct amdgpu_de bo =gem_to_amdgpu_bo (gobj); } mem = bo->tbo.resource; -if (mem->mem_type ==TTM_PL_TT || - mem->mem_type ==AMDGPU_PL_PREEMPT ) +if (mem && (mem->mem_type ==TTM_PL_TT || + mem->mem_type ==AMDGPU_PL_PREEMPT )) pages_addr = bo->tbo.ttm->dma_address; }
Greg Kroah-Hartman
maintainerPATCH 525/530 drm/amd/display: Guard against invalid RPTR/WPTR being set
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Kazlauskas <[email protected]>
commit 1ffa8602e39b89469dc703ebab7a7e44c33da0f7 upstream.
[WHY]
HW can return invalid values on register read, guard against these being set and causing us to access memory out of range and page fault.
[HOW]
Guard at sync_inbox1 and guard at pushing commands.
--- drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c +15 -3
@@ -658,9 +658,16 @@ enum dmub_status dmub_srv_sync_inbox1(streturn DMUB_STATUS_INVALID ;if (dmub->hw_funcs.get_inbox1_rptr && dmub->hw_funcs.get_inbox1_wptr) { - dmub->inbox1_rb.rptr = dmub->hw_funcs.get_inbox1_rptr (dmub); - dmub->inbox1_rb.wrpt = dmub->hw_funcs.get_inbox1_wptr (dmub); - dmub->inbox1_last_wptr = dmub->inbox1_rb.wrpt; +uint32_t rptr = dmub->hw_funcs.get_inbox1_rptr (dmub); +uint32_t wptr = dmub->hw_funcs.get_inbox1_wptr (dmub); + +if (rptr > dmub->inbox1_rb.capacity || wptr > dmub->inbox1_rb.capacity) { +return DMUB_STATUS_HW_FAILURE ; + }else { + dmub->inbox1_rb.rptr = rptr; + dmub->inbox1_rb.wrpt = wptr; + dmub->inbox1_last_wptr = dmub->inbox1_rb.wrpt; + } }return DMUB_STATUS_OK ;
@@ -694,6 +701,11 @@ enum dmub_status dmub_srv_cmd_queue(struif (!dmub->hw_init)return DMUB_STATUS_INVALID ; +if (dmub->inbox1_rb.rptr > dmub->inbox1_rb.capacity || + dmub->inbox1_rb.wrpt > dmub->inbox1_rb.capacity) { +return DMUB_STATUS_HW_FAILURE ; + } +if (dmub_rb_push_front (&dmub->inbox1_rb, cmd))return DMUB_STATUS_OK ;
Greg Kroah-Hartman
maintainerPATCH 526/530 drm/amd/display: Fix DSC not Enabled on Direct MST Sink
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fangzhi Zuo <[email protected]>
commit a58555359a9f870543aaddef277c3396159895ce upstream.
[WHY & HOW]
For the scenario when a dsc capable MST sink device is directly connected, it needs to use max dsc compression as the link bw constraint.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c | 29 +++++------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c +14 -15
@@ -1598,31 +1598,31 @@ enum dc_status dm_dp_mst_is_port_supportunsigned int upper_link_bw_in_kbps =0 , down_link_bw_in_kbps =0 ;unsigned int max_compressed_bw_in_kbps =0 ;struct dc_dsc_bw_range bw_range = {0 }; -struct drm_dp_mst_topology_mgr *mst_mgr; +uint16_t full_pbn = aconnector->mst_output_port->full_pbn;/* -* check if the mode could be supported if DSC pass-through is supported -* AND check if there enough bandwidth available to support the mode -* with DSC enabled. +* Consider the case with the depth of the mst topology tree is equal or less than 2 +* A. When dsc bitstream can be transmitted along the entire path +* 1. dsc is possible between source and branch/leaf device (common dsc params is possible), AND +* 2. dsc passthrough supported at MST branch, or +* 3. dsc decoding supported at leaf MST device +* Use maximum dsc compression as bw constraint +* B. When dsc bitstream cannot be transmitted along the entire path +* Use native bw as bw constraint */ if (is_dsc_common_config_possible (stream, &bw_range) && - aconnector->mst_output_port->passthrough_aux) { - mst_mgr = aconnector->mst_output_port->mgr; -mutex_lock (&mst_mgr->lock); - + (aconnector->mst_output_port->passthrough_aux || + aconnector->dsc_aux == &aconnector->mst_output_port->aux)) { cur_link_settings = stream->link->verified_link_cap; upper_link_bw_in_kbps =dc_link_bandwidth_kbps (aconnector->dc_link, - &cur_link_settings - ); - down_link_bw_in_kbps =kbps_from_pbn (aconnector->mst_output_port->full_pbn); + &cur_link_settings); + down_link_bw_in_kbps =kbps_from_pbn (full_pbn);/* pick the bottleneck */ end_to_end_bw_in_kbps =min (upper_link_bw_in_kbps, down_link_bw_in_kbps); -mutex_unlock (&mst_mgr->lock); -/* * use the maximum dsc compression bandwidth as the required * bandwidth for the mode
@@ -1637,8 +1637,7 @@ enum dc_status dm_dp_mst_is_port_support/* check if mode could be supported within full_pbn */ bpp =convert_dc_color_depth_into_bpc (stream->timing.display_color_depth) *3 ; pbn =drm_dp_calc_pbn_mode (stream->timing.pix_clk_100hz /10 , bpp, false); - -if (pbn > aconnector->mst_output_port->full_pbn) +if (pbn > full_pbn)return DC_FAIL_BANDWIDTH_VALIDATE ; }
Greg Kroah-Hartman
maintainerPATCH 527/530 drm/amd/display: fix a NULL pointer dereference in amdgpu_dm_i2c_xfer()
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit b71f4ade1b8900d30c661d6c27f87c35214c398c upstream.
When ddc_service_construct() is called, it explicitly checks both the link type and whether there is something on the link which will dictate whether the pin is marked as hw_supported.
If the pin isn't set or the link is not set (such as from unloading/reloading amdgpu in an IGT test) then fail the amdgpu_dm_i2c_xfer() call.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -0
@@ -7430,6 +7430,9 @@ static int amdgpu_dm_i2c_xfer(struct i2cint i;int result = -EIO ; +if (!ddc_service->ddc_pin || !ddc_service->ddc_pin->hw_info.hw_supported) +return result; + cmd.payloads =kcalloc (num,sizeof (struct i2c_payload ),GFP_KERNEL );if (!cmd.payloads)
Greg Kroah-Hartman
maintainerPATCH 528/530 drm/amd/display: Enable fast plane updates on DCN3.2 and above
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianci Yin <[email protected]>
commit 435f5b369657cffee4b04db1f5805b48599f4dbe upstream.
[WHY]
When cursor moves across screen boarder, lag cursor observed, since subvp settings need to sync up with vblank that causes cursor updates being delayed.
[HOW]
Enable fast plane updates on DCN3.2 to fix it.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -4
@@ -9541,14 +9541,14 @@ static bool should_reset_plane(struct drstruct drm_plane *other;struct drm_plane_state *old_other_state, *new_other_state;struct drm_crtc_state *new_crtc_state; +struct amdgpu_device *adev =drm_to_adev (plane->dev);int i;/* -* TODO: Remove this hack once the checks below are sufficient -* enough to determine when we need to reset all the planes on -* the stream. +* TODO: Remove this hack for all asics once it proves that the +* fast updates works fine on DCN3.2+. */ -if (state->allow_modeset) +if (adev->ip_versions[DCE_HWIP ][0 ] <IP_VERSION (3 ,2 ,0 ) && state->allow_modeset)return true;/* Exit early if we know that we're adding or removing the plane. */
Greg Kroah-Hartman
maintainerPATCH 529/530 drm/amd/display: Clear dpcd_sink_ext_caps if not set
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Hsieh <[email protected]>
commit 923bbfe6c888812db1088d684bd30c24036226d2 upstream.
[WHY]
Some eDP panels' ext caps don't set initial values and the value of dpcd_addr (0x317) is random.
It means that sometimes the eDP can be OLED, miniLED and etc, and cause incorrect backlight control interface.
[HOW]
Add remove_sink_ext_caps to remove sink ext caps (HDR, OLED and etc)
--- drivers/gpu/drm/amd/display/dc/dc_types.h | 1 + drivers/gpu/drm/amd/display/dc/link/link_detection.c | 3 +++ 2 files changed, 4 insertions(+)
drivers/gpu/drm/amd/display/dc/dc_types.h +1 -0
@@ -189,6 +189,7 @@ struct dc_panel_patch {unsigned int disable_fams;unsigned int skip_avmute;unsigned int mst_start_top_delay; +unsigned int remove_sink_ext_caps; };struct dc_edid_caps {
drivers/gpu/drm/amd/display/dc/link/link_detection.c +3 -0
@@ -1085,6 +1085,9 @@ static bool detect_link_and_local_sink(sif (sink->edid_caps.panel_patch.skip_scdc_overwrite) link->ctx->dc->debug.hdmi20_disable = true; +if (sink->edid_caps.panel_patch.remove_sink_ext_caps) + link->dpcd_sink_ext_caps.raw =0 ; +if (dc_is_hdmi_signal (link->connector_signal))read_scdc_caps (link->ddc, link->local_sink);
Greg Kroah-Hartman
maintainerPATCH 512/530 drm/i915: Bump GLK CDCLK frequency when driving multiple pipes
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ville Syrjälä <[email protected]>
commit 0cb89cd42fd22bbdec0b046c48f35775f5b88bdb upstream.
On GLK CDCLK frequency needs to be at least 2*96 MHz when accessing the audio hardware. Currently we bump the CDCLK frequency up temporarily (if not high enough already) whenever audio hardware is being accessed, and drop it back down afterwards.
With a single active pipe this works just fine as we can switch between all the valid CDCLK frequencies by changing the cd2x divider, which doesn't require a full modeset. However with multiple active pipes the cd2x divider trick no longer works, and thus we end up blinking all displays off and back on.
To avoid this let's just bump the CDCLK frequency to >=2*96MHz whenever multiple pipes are active. The downside is slightly higher power consumption, but that seems like an acceptable tradeoff. With a single active pipe we can stick to the current more optiomal (from power comsumption POV) behaviour.
--- drivers/gpu/drm/i915/display/intel_cdclk.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/i915/display/intel_cdclk.c +12 -0
@@ -2688,6 +2688,18 @@ static int intel_compute_min_cdclk(strucfor_each_pipe (dev_priv, pipe) min_cdclk =max (cdclk_state->min_cdclk[pipe], min_cdclk); +/* +* Avoid glk_force_audio_cdclk() causing excessive screen +* blinking when multiple pipes are active by making sure +* CDCLK frequency is always high enough for audio. With a +* single active pipe we can always change CDCLK frequency +* by changing the cd2x divider (see glk_cdclk_table[]) and +* thus a full modeset won't be needed then. +*/ +if (IS_GEMINILAKE (dev_priv) && cdclk_state->active_pipes && + !is_power_of_2 (cdclk_state->active_pipes)) + min_cdclk =max (2 *96000 , min_cdclk); +if (min_cdclk > dev_priv->display.cdclk.max_cdclk_freq) { drm_dbg_kms(&dev_priv->drm, "required cdclk (%d kHz) exceeds max (%d kHz)\n",
Greg Kroah-Hartman
maintainerPATCH 530/530 drm/amd/display: Change the DMCUB mailbox memory location from FB to inbox
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lewis Huang <[email protected]>
commit 5911d02cac70d7fb52009fbd37423e63f8f6f9bc upstream.
[WHY]
Flush command sent to DMCUB spends more time for execution on a dGPU than on an APU. This causes cursor lag when using high refresh rate mouses.
[HOW]
1. Change the DMCUB mailbox memory location from FB to inbox.
2. Only change windows memory to inbox.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 13 ++++---- drivers/gpu/drm/amd/display/dmub/dmub_srv.h | 22 +++++++++------ drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c | 32 ++++++++++++++++------ 3 files changed, 45 insertions(+), 22 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -6
@@ -2084,7 +2084,7 @@ static int dm_dmub_sw_init(struct amdgpustruct dmub_srv_create_params create_params;struct dmub_srv_region_params region_params;struct dmub_srv_region_info region_info; -struct dmub_srv_fb_params fb_params; +struct dmub_srv_memory_params memory_params;struct dmub_srv_fb_info *fb_info;struct dmub_srv *dmub_srv;const struct dmcub_firmware_header_v1_0 *hdr;
@@ -2184,6 +2184,7 @@ static int dm_dmub_sw_init(struct amdgpu adev->dm.dmub_fw->data +le32_to_cpu (hdr->header.ucode_array_offset_bytes) +PSP_HEADER_BYTES ; + region_params.is_mailbox_in_inbox = false; status =dmub_srv_calc_region_info (dmub_srv, ®ion_params, ®ion_info);
@@ -2207,10 +2208,10 @@ static int dm_dmub_sw_init(struct amdgpureturn r;/* Rebase the regions on the framebuffer address. */ -memset (&fb_params,0 ,sizeof (fb_params)); - fb_params.cpu_addr = adev->dm.dmub_bo_cpu_addr; - fb_params.gpu_addr = adev->dm.dmub_bo_gpu_addr; - fb_params.region_info = ®ion_info; +memset (&memory_params,0 ,sizeof (memory_params)); + memory_params.cpu_fb_addr = adev->dm.dmub_bo_cpu_addr; + memory_params.gpu_fb_addr = adev->dm.dmub_bo_gpu_addr; + memory_params.region_info = ®ion_info; adev->dm.dmub_fb_info =kzalloc (sizeof (*adev->dm.dmub_fb_info),GFP_KERNEL );
@@ -2222,7 +2223,7 @@ static int dm_dmub_sw_init(struct amdgpureturn -ENOMEM ; } - status =dmub_srv_calc_fb_info (dmub_srv, &fb_params, fb_info); + status =dmub_srv_calc_mem_info (dmub_srv, &memory_params, fb_info);if (status !=DMUB_STATUS_OK ) {DRM_ERROR ("Error calculating DMUB FB info: %d\n" , status);return -EINVAL ;
drivers/gpu/drm/amd/display/dmub/dmub_srv.h +14 -8
@@ -186,6 +186,7 @@ struct dmub_srv_region_params {uint32_t vbios_size;const uint8_t *fw_inst_const;const uint8_t *fw_bss_data; +bool is_mailbox_in_inbox; };/**
@@ -205,20 +206,25 @@ struct dmub_srv_region_params {*/ struct dmub_srv_region_info {uint32_t fb_size; +uint32_t inbox_size;uint8_t num_regions;struct dmub_region regions[DMUB_WINDOW_TOTAL ]; };/** -* struct dmub_srv_fb_params - parameters used for driver fb setup +* struct dmub_srv_memory_params - parameters used for driver fb setup * @region_info: region info calculated by dmub service -* @cpu_addr: base cpu address for the framebuffer -* @gpu_addr: base gpu virtual address for the framebuffer +* @cpu_fb_addr: base cpu address for the framebuffer +* @cpu_inbox_addr: base cpu address for the gart +* @gpu_fb_addr: base gpu virtual address for the framebuffer +* @gpu_inbox_addr: base gpu virtual address for the gart */ -struct dmub_srv_fb_params { +struct dmub_srv_memory_params {const struct dmub_srv_region_info *region_info; -void *cpu_addr; -uint64_t gpu_addr; +void *cpu_fb_addr; +void *cpu_inbox_addr; +uint64_t gpu_fb_addr; +uint64_t gpu_inbox_addr; };/**
@@ -546,8 +552,8 @@ dmub_srv_calc_region_info(struct dmub_sr* DMUB_STATUS_OK - success * DMUB_STATUS_INVALID - unspecified error */ -enum dmub_status dmub_srv_calc_fb_info (struct dmub_srv *dmub, -const struct dmub_srv_fb_params *params, +enum dmub_status dmub_srv_calc_mem_info (struct dmub_srv *dmub, +const struct dmub_srv_memory_params *params,struct dmub_srv_fb_info *out);/**
drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c +24 -8
@@ -386,7 +386,7 @@ dmub_srv_calc_region_info(struct dmub_sruint32_t fw_state_size =DMUB_FW_STATE_SIZE ;uint32_t trace_buffer_size =DMUB_TRACE_BUFFER_SIZE ;uint32_t scratch_mem_size =DMUB_SCRATCH_MEM_SIZE ; - +uint32_t previous_top =0 ;if (!dmub->sw_init)return DMUB_STATUS_INVALID ;
@@ -411,8 +411,15 @@ dmub_srv_calc_region_info(struct dmub_sr bios->base =dmub_align (stack->top,256 ); bios->top = bios->base + params->vbios_size; - mail->base =dmub_align (bios->top,256 ); - mail->top = mail->base +DMUB_MAILBOX_SIZE ; +if (params->is_mailbox_in_inbox) { + mail->base =0 ; + mail->top = mail->base +DMUB_MAILBOX_SIZE ; + previous_top = bios->top; + }else { + mail->base =dmub_align (bios->top,256 ); + mail->top = mail->base +DMUB_MAILBOX_SIZE ; + previous_top = mail->top; + } fw_info =dmub_get_fw_meta_info (params);
@@ -431,7 +438,7 @@ dmub_srv_calc_region_info(struct dmub_sr dmub->fw_version = fw_info->fw_version; } - trace_buff->base =dmub_align (mail->top,256 ); + trace_buff->base =dmub_align (previous_top,256 ); trace_buff->top = trace_buff->base +dmub_align (trace_buffer_size,64 ); fw_state->base =dmub_align (trace_buff->top,256 );
@@ -442,11 +449,14 @@ dmub_srv_calc_region_info(struct dmub_sr out->fb_size =dmub_align (scratch_mem->top,4096 ); +if (params->is_mailbox_in_inbox) + out->inbox_size =dmub_align (mail->top,4096 ); +return DMUB_STATUS_OK ; } -enum dmub_status dmub_srv_calc_fb_info (struct dmub_srv *dmub, -const struct dmub_srv_fb_params *params, +enum dmub_status dmub_srv_calc_mem_info (struct dmub_srv *dmub, +const struct dmub_srv_memory_params *params,struct dmub_srv_fb_info *out) {uint8_t *cpu_base;
@@ -461,8 +471,8 @@ enum dmub_status dmub_srv_calc_fb_info(sif (params->region_info->num_regions !=DMUB_NUM_WINDOWS )return DMUB_STATUS_INVALID ; - cpu_base = (uint8_t *)params->cpu_addr; - gpu_base = params->gpu_addr; + cpu_base = (uint8_t *)params->cpu_fb_addr; + gpu_base = params->gpu_fb_addr;for (i =0 ; i <DMUB_NUM_WINDOWS ; ++i) { const struct dmub_region *reg =
@@ -470,6 +480,12 @@ enum dmub_status dmub_srv_calc_fb_info(s out->fb[i].cpu_addr = cpu_base + reg->base; out->fb[i].gpu_addr = gpu_base + reg->base; + +if (i ==DMUB_WINDOW_4_MAILBOX && params->cpu_inbox_addr !=0 ) { + out->fb[i].cpu_addr = (uint8_t *)params->cpu_inbox_addr + reg->base; + out->fb[i].gpu_addr = params->gpu_inbox_addr + reg->base; + } + out->fb[i].size = reg->top - reg->base; }
Greg Kroah-Hartman
maintainerPATCH 513/530 drm/i915: Fix potential spectre vulnerability
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunwu Chan <[email protected]>
commit 1a8e9bad6ef563c28ab0f8619628d5511be55431 upstream.
Fix smatch warning:drivers/gpu/drm/i915/gem/i915_gem_context.c:847 set_proto_ctx_sseu()
warn: potential spectre issue 'pc->user_engines' [r] (local cap)
--- drivers/gpu/drm/i915/gem/i915_gem_context.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/i915/gem/i915_gem_context.c +1 -0
@@ -844,6 +844,7 @@ static int set_proto_ctx_sseu(struct drmif (idx >= pc->num_user_engines)return -EINVAL ; + idx =array_index_nospec (idx, pc->num_user_engines); pe = &pc->user_engines[idx];/* Only render engine supports RPCS configuration. */
Greg Kroah-Hartman
maintainerPATCH 514/530 drm/i915: Flush WC GGTT only on required platforms
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nirmoy Das <[email protected]>
commit 7d7a328d0e8d6edefb7b0d665185d468667588d0 upstream.
gen8_ggtt_invalidate() is only needed for limited set of platforms where GGTT is mapped as WC. This was added as way to fix WC based GGTT in commit 0f9b91c754b7 ("drm/i915: flush system agent TLBs on SNB") and there are no reference in HW docs that forces us to use this on non-WC backed GGTT.
This can also cause unwanted side-effects on XE_HP platforms where GFX_FLSH_CNTL_GEN6 is not valid anymore.
v2: Add a func to detect wc ggtt detection (Ville)
v3: Improve commit log and add reference commit (Daniel)
--- drivers/gpu/drm/i915/gt/intel_ggtt.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/gt/intel_ggtt.c +24 -11
@@ -190,6 +190,21 @@ void gen6_ggtt_invalidate(struct i915_ggspin_unlock_irq (&uncore->lock); } +static bool needs_wc_ggtt_mapping (struct drm_i915_private *i915) +{ +/* +* On BXT+/ICL+ writes larger than 64 bit to the GTT pagetable range +* will be dropped. For WC mappings in general we have 64 byte burst +* writes when the WC buffer is flushed, so we can't use it, but have to +* resort to an uncached mapping. The WC issue is easily caught by the +* readback check when writing GTT PTE entries. +*/ +if (!IS_GEN9_LP (i915) &&GRAPHICS_VER (i915) <11 ) +return true; + +return false; +} +static void gen8_ggtt_invalidate (struct i915_ggtt *ggtt) {struct intel_uncore *uncore = ggtt->vm.gt->uncore;
@@ -197,8 +212,12 @@ static void gen8_ggtt_invalidate(struct/* * Note that as an uncached mmio write, this will flush the * WCB of the writes into the GGTT before it triggers the invalidate. +* +* Only perform this when GGTT is mapped as WC, see ggtt_probe_common(). */ -intel_uncore_write_fw (uncore,GFX_FLSH_CNTL_GEN6 ,GFX_FLSH_CNTL_EN ); +if (needs_wc_ggtt_mapping (ggtt->vm.i915)) +intel_uncore_write_fw (uncore,GFX_FLSH_CNTL_GEN6 , +GFX_FLSH_CNTL_EN ); }static void guc_ggtt_invalidate (struct i915_ggtt *ggtt)
@@ -902,17 +921,11 @@ static int ggtt_probe_common(struct i915GEM_WARN_ON (pci_resource_len (pdev,GEN4_GTTMMADR_BAR ) !=gen6_gttmmadr_size (i915)); phys_addr =pci_resource_start (pdev,GEN4_GTTMMADR_BAR ) +gen6_gttadr_offset (i915); -/* -* On BXT+/ICL+ writes larger than 64 bit to the GTT pagetable range -* will be dropped. For WC mappings in general we have 64 byte burst -* writes when the WC buffer is flushed, so we can't use it, but have to -* resort to an uncached mapping. The WC issue is easily caught by the -* readback check when writing GTT PTE entries. -*/ -if (IS_GEN9_LP (i915) ||GRAPHICS_VER (i915) >=11 ) - ggtt->gsm =ioremap (phys_addr, size); -else +if (needs_wc_ggtt_mapping (i915)) ggtt->gsm =ioremap_wc (phys_addr, size); +else + ggtt->gsm =ioremap (phys_addr, size); +if (!ggtt->gsm) {drm_err (&i915->drm,"Failed to map the ggtt page table\n" );return -ENOMEM ;
Greg Kroah-Hartman
maintainerPATCH 515/530 drm/amd/pm: Fix error of MACO flag setting code
In reply to Greg Kroah-Hartman6.6-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Jun <[email protected]>
commit 7f3e6b840fa8b0889d776639310a5dc672c1e9e1 upstream.
MACO only works if BACO is supported
--- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 8 ++++---- drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +4 -4
@@ -352,12 +352,12 @@ static int smu_v13_0_0_check_powerplay_tif (powerplay_table->platform_caps &SMU_13_0_0_PP_PLATFORM_CAP_HARDWAREDC ) smu->dc_controlled_by_gpio = true; -if (powerplay_table->platform_caps &SMU_13_0_0_PP_PLATFORM_CAP_BACO || - powerplay_table->platform_caps &SMU_13_0_0_PP_PLATFORM_CAP_MACO ) +if (powerplay_table->platform_caps &SMU_13_0_0_PP_PLATFORM_CAP_BACO ) { smu_baco->platform_support = true; -if (powerplay_table->platform_caps &SMU_13_0_0_PP_PLATFORM_CAP_MACO ) - smu_baco->maco_support = true; +if (powerplay_table->platform_caps &SMU_13_0_0_PP_PLATFORM_CAP_MACO ) + smu_baco->maco_support = true; + }/* * We are in the transition to a new OD mechanism.
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +5 -4
@@ -341,12 +341,13 @@ static int smu_v13_0_7_check_powerplay_tif (powerplay_table->platform_caps &SMU_13_0_7_PP_PLATFORM_CAP_HARDWAREDC ) smu->dc_controlled_by_gpio = true; -if (powerplay_table->platform_caps &SMU_13_0_7_PP_PLATFORM_CAP_BACO || - powerplay_table->platform_caps &SMU_13_0_7_PP_PLATFORM_CAP_MACO ) +if (powerplay_table->platform_caps &SMU_13_0_7_PP_PLATFORM_CAP_BACO ) { smu_baco->platform_support = true; -if (smu_baco->platform_support && (BoardTable->HsrEnabled || BoardTable->VddqOffEnabled)) - smu_baco->maco_support = true; +if ((powerplay_table->platform_caps &SMU_13_0_7_PP_PLATFORM_CAP_MACO ) + && (BoardTable->HsrEnabled || BoardTable->VddqOffEnabled)) + smu_baco->maco_support = true; + }#if 0 if (!overdrive_lowerlimits->FeatureCtrlMask ||