5.15.33-rc1 review
Subsystems (13)
Greg Kroah-Hartman
maintainerPATCH 111/913 mm/kmemleak: reset tag when compare object pointer
In reply to Greg Kroah-HartmanFrom: Kuan-Ying Lee <[email protected]>
commit bfc8089f00fa526dea983844c880fa8106c33ac4 upstream.
When we use HW-tag based kasan and enable vmalloc support, we hit the following bug. It is due to comparison between tagged object and non-tagged pointer.
We need to reset the kasan tag when we need to compare tagged object and non-tagged pointer.
kmemleak: [name:kmemleak&]Scan area larger than object 0xffffffe77076f440
CPU: 4 PID: 1 Comm: init Tainted: G S W 5.15.25-android13-0-g5cacf919c2bc #1
Hardware name: MT6983(ENG) (DT)
Call trace:
add_scan_area+0xc4/0x244
kmemleak_scan_area+0x40/0x9c
layout_and_allocate+0x1e8/0x288
load_module+0x2c8/0xf00
__se_sys_finit_module+0x190/0x1d0
__arm64_sys_finit_module+0x20/0x30
invoke_syscall+0x60/0x170
el0_svc_common+0xc8/0x114
do_el0_svc+0x28/0xa0
el0_svc+0x60/0xf8
el0t_64_sync_handler+0x88/0xec
el0t_64_sync+0x1b4/0x1b8
kmemleak: [name:kmemleak&]Object 0xf5ffffe77076b000 (size 32768):
kmemleak: [name:kmemleak&] comm "init", pid 1, jiffies 4294894197
kmemleak: [name:kmemleak&] min_count = 0
kmemleak: [name:kmemleak&] count = 0
kmemleak: [name:kmemleak&] flags = 0x1
kmemleak: [name:kmemleak&] checksum = 0
kmemleak: [name:kmemleak&] backtrace:
module_alloc+0x9c/0x120
move_module+0x34/0x19c
layout_and_allocate+0x1c4/0x288
load_module+0x2c8/0xf00
__se_sys_finit_module+0x190/0x1d0
__arm64_sys_finit_module+0x20/0x30
invoke_syscall+0x60/0x170
el0_svc_common+0xc8/0x114
do_el0_svc+0x28/0xa0
el0_svc+0x60/0xf8
el0t_64_sync_handler+0x88/0xec
el0t_64_sync+0x1b4/0x1b8--- mm/kmemleak.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
mm/kmemleak.c +7 -2
@@ -789,6 +789,8 @@ static void add_scan_area(unsigned longunsigned long flags;struct kmemleak_object *object;struct kmemleak_scan_area *area =NULL ; +unsigned long untagged_ptr; +unsigned long untagged_objp; object =find_and_get_object (ptr,1 );if (!object) {
@@ -797,6 +799,9 @@ static void add_scan_area(unsigned longreturn ; } + untagged_ptr = (unsigned long )kasan_reset_tag ((void *)ptr); + untagged_objp = (unsigned long )kasan_reset_tag ((void *)object->pointer); +if (scan_area_cache) area =kmem_cache_alloc (scan_area_cache,gfp_kmemleak_mask (gfp));
@@ -808,8 +813,8 @@ static void add_scan_area(unsigned long goto out_unlock; }if (size ==SIZE_MAX ) { - size = object->pointer + object->size - ptr; - }else if (ptr + size > object->pointer + object->size) { + size = untagged_objp + object->size - untagged_ptr; + }else if (untagged_ptr + size > untagged_objp + object->size) {kmemleak_warn ("Scan area larger than object 0x%08lx\n" , ptr);dump_object_info (object);kmem_cache_free (scan_area_cache, area);
Greg Kroah-Hartman
maintainerPATCH 112/913 dm stats: fix too short end duration_ns when using precise_timestamps
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
commit 0cdb90f0f306384ecbc60dfd6dc48cdbc1f2d0d8 upstream.
dm_stats_account_io()'s STAT_PRECISE_TIMESTAMPS support doesn't handle the fact that with commit b879f915bc48 ("dm: properly fix redundant bio-based IO accounting") io->start_time _may_ be in the past (meaning the start_io_acct() was deferred until later).
Add a new dm_stats_recalc_precise_timestamps() helper that will set/clear a new 'precise_timestamps' flag in the dm_stats struct based on whether any configured stats enable STAT_PRECISE_TIMESTAMPS. And update DM core's alloc_io() to use dm_stats_record_start() to set stats_aux.duration_ns if stats->precise_timestamps is true.
Also, remove unused 'last_sector' and 'last_rw' members from the dm_stats struct.
--- drivers/md/dm-stats.c | 28 +++++++++++++++++++++++++--- drivers/md/dm-stats.h | 9 +++++++-- drivers/md/dm.c | 2 ++ 3 files changed, 34 insertions(+), 5 deletions(-)
drivers/md/dm-stats.c +25 -3
@@ -195,6 +195,7 @@ void dm_stats_init(struct dm_stats *statmutex_init (&stats->mutex);INIT_LIST_HEAD (&stats->list); + stats->precise_timestamps = false; stats->last = alloc_percpu(struct dm_stats_last_position);for_each_possible_cpu (cpu) { last =per_cpu_ptr (stats->last, cpu);
@@ -231,6 +232,22 @@ void dm_stats_cleanup(struct dm_stats *smutex_destroy (&stats->mutex); } +static void dm_stats_recalc_precise_timestamps (struct dm_stats *stats) +{ +struct list_head *l; +struct dm_stat *tmp_s; +bool precise_timestamps = false; + +list_for_each (l, &stats->list) { + tmp_s = container_of(l, struct dm_stat, list_entry); +if (tmp_s->stat_flags &STAT_PRECISE_TIMESTAMPS ) { + precise_timestamps = true; +break ; + } + } + stats->precise_timestamps = precise_timestamps; +} + static int dm_stats_create(struct dm_stats *stats, sector_t start, sector_t end, sector_t step, unsigned stat_flags, unsigned n_histogram_entries,
@@ -376,6 +393,9 @@ static int dm_stats_create(struct dm_sta } ret_id = s->id;list_add_tail_rcu (&s->list_entry, l); + +dm_stats_recalc_precise_timestamps (stats); +mutex_unlock (&stats->mutex);resume_callback (md);
@@ -418,6 +438,9 @@ static int dm_stats_delete(struct dm_sta }list_del_rcu (&s->list_entry); + +dm_stats_recalc_precise_timestamps (stats); +mutex_unlock (&stats->mutex);/*
@@ -654,9 +677,8 @@ void dm_stats_account_io(struct dm_stats got_precise_time = false;list_for_each_entry_rcu (s, &stats->list, list_entry) {if (s->stat_flags &STAT_PRECISE_TIMESTAMPS && !got_precise_time) { -if (!end) - stats_aux->duration_ns =ktime_to_ns (ktime_get ()); -else +/* start (!end) duration_ns is set by DM core's alloc_io() */ +if (end) stats_aux->duration_ns =ktime_to_ns (ktime_get ()) - stats_aux->duration_ns; got_precise_time = true; }
drivers/md/dm-stats.h +7 -2
@@ -13,8 +13,7 @@ struct dm_stats {struct mutex mutex;struct list_head list;/* list of struct dm_stat */ struct dm_stats_last_position __percpu *last; -sector_t last_sector; -unsigned last_rw; +bool precise_timestamps; };struct dm_stats_aux {
@@ -40,4 +39,10 @@ static inline bool dm_stats_used(struct return !list_empty(&st->list); } +static inline void dm_stats_record_start (struct dm_stats *stats,struct dm_stats_aux *aux) +{ +if (unlikely (stats->precise_timestamps)) + aux->duration_ns =ktime_to_ns (ktime_get ()); +} +#endif
drivers/md/dm.c +2 -0
@@ -537,6 +537,8 @@ static struct dm_io *alloc_io(struct map io->start_time = jiffies; +dm_stats_record_start (&md->stats, &io->stats_aux); +return io; }
Greg Kroah-Hartman
maintainerPATCH 113/913 dm: fix use-after-free in dm_cleanup_zoned_dev()
In reply to Greg Kroah-HartmanFrom: Kirill Tkhai <[email protected]>
commit 588b7f5df0cb64f281290c7672470c006abe7160 upstream.
dm_cleanup_zoned_dev() uses queue, so it must be called before blk_cleanup_disk() starts its killing:
blk_cleanup_disk->blk_cleanup_queue()->kobject_put()->blk_release_queue()-> ->...RCU...->blk_free_queue_rcu()->kmem_cache_free()
Otherwise, RCU callback may be executed first anddm_cleanup_zoned_dev() will touch free'd memory:
BUG: KASAN: use-after-free in dm_cleanup_zoned_dev+0x33/0xd0 Read of size 8 at addr ffff88805ac6e430 by task dmsetup/681 CPU: 4 PID: 681 Comm: dmsetup Not tainted 5.17.0-rc2+ #6 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.14.0-2 04/01/2014 Call Trace: <TASK> dump_stack_lvl+0x57/0x7d print_address_description.constprop.0+0x1f/0x150 ? dm_cleanup_zoned_dev+0x33/0xd0 kasan_report.cold+0x7f/0x11b ? dm_cleanup_zoned_dev+0x33/0xd0 dm_cleanup_zoned_dev+0x33/0xd0 __dm_destroy+0x26a/0x400 ? dm_blk_ioctl+0x230/0x230 ? up_write+0xd8/0x270 dev_remove+0x156/0x1d0 ctl_ioctl+0x269/0x530 ? table_clear+0x140/0x140 ? lock_release+0xb2/0x750 ? remove_all+0x40/0x40 ? rcu_read_lock_sched_held+0x12/0x70 ? lock_downgrade+0x3c0/0x3c0 ? rcu_read_lock_sched_held+0x12/0x70 dm_ctl_ioctl+0xa/0x10 __x64_sys_ioctl+0xb9/0xf0 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7fb6dfa95c27
--- drivers/md/dm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm.c +1 -1
@@ -1684,6 +1684,7 @@ static void cleanup_mapped_device(struct md->dax_dev =NULL ; } +dm_cleanup_zoned_dev (md);if (md->disk) {spin_lock (&_minor_lock); md->disk->private_data =NULL ;
@@ -1704,7 +1705,6 @@ static void cleanup_mapped_device(structmutex_destroy (&md->swap_bios_lock);dm_mq_cleanup_mapped_device (md); -dm_cleanup_zoned_dev (md); }/*
Greg Kroah-Hartman
maintainerPATCH 114/913 dm: interlock pending dm_io and dm_wait_for_bios_completion
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
commit 9f6dc633761006f974701d4c88da71ab68670749 upstream.
Commit d208b89401e0 ("dm: fix mempool NULL pointer race when completing IO") didn't go far enough.
When bio_end_io_acct ends the count of in-flight I/Os may reach zero and the DM device may be suspended. There is a possibility that the suspend races with dm_stats_account_io.
Fix this by adding percpu "pending_io" counters to track outstanding dm_io. Move kicking of suspend queue to dm_io_dec_pending(). Also, rename md_in_flight_bios() to dm_in_flight_bios() and update it to iterate all pending_io counters.
--- drivers/md/dm-core.h | 2 ++ drivers/md/dm.c | 35 +++++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-)
drivers/md/dm-core.h +2 -0
@@ -65,6 +65,8 @@ struct mapped_device {struct gendisk *disk;struct dax_device *dax_dev; +unsigned long __percpu *pending_io; +/* * A list of ios that arrived while we were suspended. */
drivers/md/dm.c +23 -12
@@ -507,10 +507,6 @@ static void end_io_acct(struct mapped_dedm_stats_account_io (&md->stats,bio_data_dir (bio), bio->bi_iter.bi_sector,bio_sectors (bio), true, duration, stats_aux); - -/* nudge anyone waiting on suspend queue */ -if (unlikely (wq_has_sleeper (&md->wait))) -wake_up (&md->wait); }static struct dm_io *alloc_io (struct mapped_device *md,struct bio *bio)
@@ -531,6 +527,7 @@ static struct dm_io *alloc_io(struct map io->magic =DM_IO_MAGIC ; io->status =0 ;atomic_set (&io->io_count,1 ); +this_cpu_inc (*md->pending_io); io->orig_bio = bio; io->md = md;spin_lock_init (&io->endio_lock);
@@ -828,6 +825,12 @@ void dm_io_dec_pending(struct dm_io *io, stats_aux = io->stats_aux;free_io (md, io);end_io_acct (md, bio, start_time, &stats_aux); +smp_wmb (); +this_cpu_dec (*md->pending_io); + +/* nudge anyone waiting on suspend queue */ +if (unlikely (wq_has_sleeper (&md->wait))) +wake_up (&md->wait);if (io_error ==BLK_STS_DM_REQUEUE )return ;
@@ -1697,6 +1700,11 @@ static void cleanup_mapped_device(structblk_cleanup_disk (md->disk); } +if (md->pending_io) { +free_percpu (md->pending_io); + md->pending_io =NULL ; + } +cleanup_srcu_struct (&md->io_barrier);mutex_destroy (&md->suspend_lock);
@@ -1794,6 +1802,10 @@ static struct mapped_device *alloc_dev(iif (!md->wq) goto bad; + md->pending_io = alloc_percpu(unsigned long); +if (!md->pending_io) + goto bad; +dm_stats_init (&md->stats);/* Populate the mapping, nobody knows we exist yet */
@@ -2209,16 +2221,13 @@ void dm_put(struct mapped_device *md) }EXPORT_SYMBOL_GPL (dm_put); -static bool md_in_flight_bios (struct mapped_device *md) +static bool dm_in_flight_bios (struct mapped_device *md) {int cpu; -struct block_device *part =dm_disk (md)->part0; -long sum =0 ; +unsigned long sum =0 ; -for_each_possible_cpu (cpu) { - sum +=part_stat_local_read_cpu (part, in_flight[0 ], cpu); - sum +=part_stat_local_read_cpu (part, in_flight[1 ], cpu); - } +for_each_possible_cpu (cpu) + sum += *per_cpu_ptr (md->pending_io, cpu);return sum !=0 ; }
@@ -2231,7 +2240,7 @@ static int dm_wait_for_bios_completion(swhile (true) {prepare_to_wait (&md->wait, &wait, task_state); -if (!md_in_flight_bios (md)) +if (!dm_in_flight_bios (md))break ;if (signal_pending_state (task_state, current)) {
@@ -2243,6 +2252,8 @@ static int dm_wait_for_bios_completion(s }finish_wait (&md->wait, &wait); +smp_rmb (); +return r; }
Greg Kroah-Hartman
maintainerPATCH 115/913 dm: fix double accounting of flush with data
In reply to Greg Kroah-HartmanFrom: Mike Snitzer <[email protected]>
commit 8d394bc4adf588ca4a0650745167cb83f86c18c9 upstream.
DM handles a flush with data by first issuing an empty flush and then once it completes the REQ_PREFLUSH flag is removed and the payload is issued. The problem fixed by this commit is that both the empty flush bio and the data payload will account the full extent of the data payload.
Fix this by factoring out dm_io_acct() and having it wrap all IO accounting to set the size of bio with REQ_PREFLUSH to 0, account the IO, and then restore the original size.
--- drivers/md/dm-stats.c | 6 ++++-- drivers/md/dm-stats.h | 2 +- drivers/md/dm.c | 47 +++++++++++++++++++++++++++++++++-------------- 3 files changed, 38 insertions(+), 17 deletions(-)
drivers/md/dm-stats.c +4 -2
@@ -644,13 +644,14 @@ static void __dm_stat_bio(struct dm_statvoid dm_stats_account_io (struct dm_stats *stats,unsigned long bi_rw,sector_t bi_sector,unsigned bi_sectors,bool end, -unsigned long duration_jiffies, +unsigned long start_time,struct dm_stats_aux *stats_aux) {struct dm_stat *s;sector_t end_sector;struct dm_stats_last_position *last;bool got_precise_time; +unsigned long duration_jiffies =0 ;if (unlikely (!bi_sectors))return ;
@@ -670,7 +671,8 @@ void dm_stats_account_io(struct dm_stats ));WRITE_ONCE (last->last_sector, end_sector);WRITE_ONCE (last->last_rw, bi_rw); - } + }else + duration_jiffies = jiffies - start_time;rcu_read_lock ();
drivers/md/dm-stats.h +1 -1
@@ -31,7 +31,7 @@ int dm_stats_message(struct mapped_devicvoid dm_stats_account_io (struct dm_stats *stats,unsigned long bi_rw,sector_t bi_sector,unsigned bi_sectors,bool end, -unsigned long duration_jiffies, +unsigned long start_time,struct dm_stats_aux *aux);static inline bool dm_stats_used (struct dm_stats *st)
drivers/md/dm.c +33 -14
69 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 116/913 dm integrity: set journal entry unused when shrinking device
In reply to Greg Kroah-HartmanFrom: Mikulas Patocka <[email protected]>
commit cc09e8a9dec4f0e8299e80a7a2a8e6f54164a10b upstream.
Commit f6f72f32c22c ("dm integrity: don't replay journal data past the end of the device") skips journal replay if the target sector points beyond the end of the device. Unfortunatelly, it doesn't set the journal entry unused, which resulted in this BUG being triggered:
BUG_ON(!journal_entry_is_unused(je))
Fix this by calling journal_entry_set_unused() for this case.
--- drivers/md/dm-integrity.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/md/dm-integrity.c +4 -2
@@ -2459,9 +2459,11 @@ static void do_journal_write(struct dm_idm_integrity_io_error (ic,"invalid sector in journal" , -EIO ); sec &= ~(sector_t)(ic->sectors_per_block -1 ); } +if (unlikely (sec >= ic->provided_data_sectors)) { +journal_entry_set_unused (je); +continue ; + } } -if (unlikely (sec >= ic->provided_data_sectors)) -continue ;get_area_and_offset (ic, sec, &area, &offset);restore_last_bytes (ic,access_journal_data (ic, i, j), je);for (k = j +1 ; k < ic->journal_section_entries; k++) {
Greg Kroah-Hartman
maintainerPATCH 117/913 tracing: Have trace event string test handle zero length strings
In reply to Greg Kroah-HartmanFrom: Steven Rostedt (Google) <[email protected]>
commit eca344a7362e0f34f179298fd8366bcd556eede1 upstream.
If a trace event has in its TP_printk():
"%*.s", len, len ? __get_str(string) : NULL
It is perfectly valid if len is zero and passing in the NULL. Unfortunately, the runtime string check at time of reading the trace sees the NULL and flags it as a bad string and produces a WARN_ON().
Handle this case by passing into the test function if the format has an asterisk (star) and if so, if the length is zero, then mark it as safe.
--- kernel/trace/trace.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
kernel/trace/trace.c +7 -2
@@ -3678,12 +3678,17 @@ static char *trace_iter_expand_format(st }/* Returns true if the string is safe to dereference from an event */ -static bool trace_safe_str (struct trace_iterator *iter,const char *str) +static bool trace_safe_str (struct trace_iterator *iter,const char *str, +bool star,int len) {unsigned long addr = (unsigned long )str;struct trace_event *trace_event;struct trace_event_call *event; +/* Ignore strings with no length */ +if (star && !len) +return true; +/* OK if part of the event data */ if ((addr >= (unsigned long )iter->ent) && (addr < (unsigned long )iter->ent + iter->ent_size))
@@ -3869,7 +3874,7 @@ void trace_check_vprintf(struct trace_it* instead. See samples/trace_events/trace-events-sample.h * for reference. */ -if (WARN_ONCE (!trace_safe_str (iter, str), +if (WARN_ONCE (!trace_safe_str (iter, str, star, len),"fmt: '%s' current_buffer: '%s'" , fmt,show_buffer (&iter->seq))) {int ret;
Greg Kroah-Hartman
maintainerPATCH 118/913 drbd: fix potential silent data corruption
In reply to Greg Kroah-HartmanFrom: Lars Ellenberg <[email protected]>
commit f4329d1f848ac35757d9cc5487669d19dfc5979c upstream.
Scenario:
---------
bio chain generated by blk_queue_split().
Some split bio fails and propagates its error status to the "parent" bio. But then the (last part of the) parent bio itself completes without error.
We would clobber the already recorded error status with BLK_STS_OK, causing silent data corruption.
Reproducer:
-----------
How to trigger this in the real world within seconds:
DRBD on top of degraded parity raid,
small stripe_cache_size, large read_ahead setting. Drop page cache (sysctl vm.drop_caches=1, fadvise "DONTNEED", umount and mount again, "reboot").
Cause significant read ahead.
Large read ahead request is split by blk_queue_split(). Parts of the read ahead that are already in the stripe cache, or find an available stripe cache to use, can be serviced. Parts of the read ahead that would need "too much work", would need to wait for a "stripe_head" to become available, are rejected immediately.
For larger read ahead requests that are split in many pieces, it is very likely that some "splits" will be serviced, but then the stripe cache is exhausted/busy, and the remaining ones will be rejected.
--- drivers/block/drbd/drbd_req.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/drbd/drbd_req.c +2 -1
@@ -180,7 +180,8 @@ void start_new_tl_epoch(struct drbd_connvoid complete_master_bio (struct drbd_device *device,struct bio_and_error *m) { - m->bio->bi_status =errno_to_blk_status (m->error); +if (unlikely (m->error)) + m->bio->bi_status =errno_to_blk_status (m->error);bio_endio (m->bio);dec_ap_bio (device); }
Greg Kroah-Hartman
maintainerPATCH 119/913 powerpc/kvm: Fix kvm_use_magic_page
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
commit 0c8eb2884a42d992c7726539328b7d3568f22143 upstream.
When switching from __get_user to fault_in_pages_readable, commit 9f9eae5ce717 broke kvm_use_magic_page: like __get_user, fault_in_pages_readable returns 0 on success.
--- arch/powerpc/kernel/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/kvm.c +1 -1
@@ -669,7 +669,7 @@ static void __init kvm_use_magic_page(voon_each_cpu (kvm_map_magic_page, &features,1 );/* Quick self-test to see if the mapping works */ -if (!fault_in_pages_readable ((const char *)KVM_MAGIC_PAGE ,sizeof (u32))) { +if (fault_in_pages_readable ((const char *)KVM_MAGIC_PAGE ,sizeof (u32))) { kvm_patching_worked = false;return ; }
Greg Kroah-Hartman
maintainerPATCH 120/913 PCI: fu740: Force 2.5GT/s for initial device probe
In reply to Greg Kroah-HartmanFrom: Ben Dooks <[email protected]>
commit a382c757ec5ef83137a86125f43a4c43dc2ab50b upstream.
The fu740 PCIe core does not probe any devices on the SiFive Unmatched board without this fix (or having U-Boot explicitly start the PCIe via either boot-script or user command). The fix is to start the link at 2.5GT/s speeds and once the link is up then change the maximum speed back to the default.
The U-Boot driver claims to set the link-speed to 2.5GT/s to get the probe to work (and U-Boot does print link up at 2.5GT/s) in the following code:
https://source.denx.de/u-boot/u-boot/-/blob/master/drivers/pci/pcie_dw_sifive.c?id=v2022.01#L271
--- drivers/pci/controller/dwc/pcie-fu740.c | 51 +++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-fu740.c +50 -1
@@ -181,10 +181,59 @@ static int fu740_pcie_start_link(struct {struct device *dev = pci->dev;struct fu740_pcie *afp =dev_get_drvdata (dev); +u8 cap_exp =dw_pcie_find_capability (pci,PCI_CAP_ID_EXP ); +int ret; +u32 orig, tmp; + +/* +* Force 2.5GT/s when starting the link, due to some devices not +* probing at higher speeds. This happens with the PCIe switch +* on the Unmatched board when U-Boot has not initialised the PCIe. +* The fix in U-Boot is to force 2.5GT/s, which then gets cleared +* by the soft reset done by this driver. +*/ +dev_dbg (dev,"cap_exp at %x\n" , cap_exp); +dw_pcie_dbi_ro_wr_en (pci); + + tmp =dw_pcie_readl_dbi (pci, cap_exp +PCI_EXP_LNKCAP ); + orig = tmp &PCI_EXP_LNKCAP_SLS ; + tmp &= ~PCI_EXP_LNKCAP_SLS ; + tmp |=PCI_EXP_LNKCAP_SLS_2_5GB ; +dw_pcie_writel_dbi (pci, cap_exp +PCI_EXP_LNKCAP , tmp);/* Enable LTSSM */ writel_relaxed (0x1 , afp->mgmt_base +PCIEX8MGMT_APP_LTSSM_ENABLE ); -return 0 ; + + ret =dw_pcie_wait_for_link (pci); +if (ret) { +dev_err (dev,"error: link did not start\n" ); + goto err; + } + + tmp =dw_pcie_readl_dbi (pci, cap_exp +PCI_EXP_LNKCAP ); +if ((tmp &PCI_EXP_LNKCAP_SLS ) != orig) { +dev_dbg (dev,"changing speed back to original\n" ); + + tmp &= ~PCI_EXP_LNKCAP_SLS ; + tmp |= orig; +dw_pcie_writel_dbi (pci, cap_exp +PCI_EXP_LNKCAP , tmp); + + tmp =dw_pcie_readl_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL ); + tmp |=PORT_LOGIC_SPEED_CHANGE ; +dw_pcie_writel_dbi (pci,PCIE_LINK_WIDTH_SPEED_CONTROL , tmp); + + ret =dw_pcie_wait_for_link (pci); +if (ret) { +dev_err (dev,"error: link did not start at new speed\n" ); + goto err; + } + } + + ret =0 ; +err: +WARN_ON (ret);/* we assume that errors will be very rare */ +dw_pcie_dbi_ro_wr_dis (pci); +return ret; }static int fu740_pcie_host_init (struct pcie_port *pp)
Greg Kroah-Hartman
maintainerPATCH 121/913 arm64: signal: nofpsimd: Do not allocate fp/simd context when not available
In reply to Greg Kroah-HartmanFrom: David Engraf <[email protected]>
commit 0a32c88ddb9af30e8a16d41d7b9b824c27d29459 upstream.
Commit 6d502b6ba1b2 ("arm64: signal: nofpsimd: Handle fp/simd context for signal frames") introduced saving the fp/simd context for signal handling only when support is available. But setup_sigframe_layout() always reserves memory for fp/simd context. The additional memory is not touched because preserve_fpsimd_context() is not called and thus the magic is invalid.
This may lead to an error when parse_user_sigframe() checks the fp/simd area and does not find a valid magic number.
--- arch/arm64/kernel/signal.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arm64/kernel/signal.c +6 -4
@@ -577,10 +577,12 @@ static int setup_sigframe_layout(struct {int err; - err =sigframe_alloc (user, &user->fpsimd_offset, -sizeof (struct fpsimd_context )); -if (err) -return err; +if (system_supports_fpsimd ()) { + err =sigframe_alloc (user, &user->fpsimd_offset, +sizeof (struct fpsimd_context )); +if (err) +return err; + }/* fault information, if valid */ if (add_all || current->thread.fault_code) {
Greg Kroah-Hartman
maintainerPATCH 122/913 arm64: Do not defer reserve_crashkernel() for platforms with no DMA memory zones
In reply to Greg Kroah-HartmanFrom: Vijay Balakrishna <[email protected]>
commit 031495635b4668f94e964e037ca93d0d38bfde58 upstream.
The following patches resulted in deferring crash kernel reservation to mem_init(), mainly aimed at platforms with DMA memory zones (no IOMMU), in particular Raspberry Pi 4.
commit 1a8e1cef7603 ("arm64: use both ZONE_DMA and ZONE_DMA32")
commit 8424ecdde7df ("arm64: mm: Set ZONE_DMA size based on devicetree's dma-ranges") commit 0a30c53573b0 ("arm64: mm: Move reserve_crashkernel() into mem_init()") commit 2687275a5843 ("arm64: Force NO_BLOCK_MAPPINGS if crashkernel reservation is required")
Above changes introduced boot slowdown due to linear map creation for all the memory banks with NO_BLOCK_MAPPINGS, see discussion[1]. The proposed changes restore crash kernel reservation to earlier behavior thus avoids slow boot, particularly for platforms with IOMMU (no DMA memory zones).
Tested changes to confirm no ~150ms boot slowdown on our SoC with IOMMU and 8GB memory. Also tested with ZONE_DMA and/or ZONE_DMA32 configs to confirm no regression to deferring scheme of crash kernel memory reservation. In both cases successfully collected kernel crash dump.
[1] https://lore.kernel.org/all/[email protected]/
--- arch/arm64/mm/init.c | 36 ++++++++++++++++++++++++++++++++---- arch/arm64/mm/mmu.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 5 deletions(-)
arch/arm64/mm/init.c +32 -4
@@ -61,8 +61,34 @@ EXPORT_SYMBOL(memstart_addr);* unless restricted on specific platforms (e.g. 30-bit on Raspberry Pi 4). * In such case, ZONE_DMA32 covers the rest of the 32-bit addressable memory, * otherwise it is empty. +* +* Memory reservation for crash kernel either done early or deferred +* depending on DMA memory zones configs (ZONE_DMA) -- +* +* In absence of ZONE_DMA configs arm64_dma_phys_limit initialized +* here instead of max_zone_phys(). This lets early reservation of +* crash kernel memory which has a dependency on arm64_dma_phys_limit. +* Reserving memory early for crash kernel allows linear creation of block +* mappings (greater than page-granularity) for all the memory bank rangs. +* In this scheme a comparatively quicker boot is observed. +* +* If ZONE_DMA configs are defined, crash kernel memory reservation +* is delayed until DMA zone memory range size initilazation performed in +* zone_sizes_init(). The defer is necessary to steer clear of DMA zone +* memory range to avoid overlap allocation. So crash kernel memory boundaries +* are not known when mapping all bank memory ranges, which otherwise means +* not possible to exclude crash kernel range from creating block mappings +* so page-granularity mappings are created for the entire memory range. +* Hence a slightly slower boot is observed. +* +* Note: Page-granularity mapppings are necessary for crash kernel memory +* range for shrinking its size via /sys/kernel/kexec_crash_size interface. */ -phys_addr_t arm64_dma_phys_limit__ro_after_init ; +#if IS_ENABLED (CONFIG_ZONE_DMA ) ||IS_ENABLED (CONFIG_ZONE_DMA32 ) +phys_addr_t __ro_after_init arm64_dma_phys_limit; +#else +const phys_addr_t arm64_dma_phys_limit =PHYS_MASK +1 ; +#endif #ifdef CONFIG_KEXEC_CORE /*
@@ -153,8 +179,6 @@ static void __init zone_sizes_init(unsigif (!arm64_dma_phys_limit) arm64_dma_phys_limit = dma32_phys_limit;#endif -if (!arm64_dma_phys_limit) - arm64_dma_phys_limit =PHYS_MASK +1 ; max_zone_pfns[ZONE_NORMAL ] = max;free_area_init (max_zone_pfns);
@@ -352,6 +376,9 @@ void __init arm64_memblock_init(void)early_init_fdt_scan_reserved_mem (); +if (!IS_ENABLED (CONFIG_ZONE_DMA ) && !IS_ENABLED (CONFIG_ZONE_DMA32 )) +reserve_crashkernel (); + high_memory =__va (memblock_end_of_DRAM () -1 ) +1 ; }
@@ -398,7 +425,8 @@ void __init bootmem_init(void)* request_standard_resources() depends on crashkernel's memory being * reserved, so do it here. */ -reserve_crashkernel (); +if (IS_ENABLED (CONFIG_ZONE_DMA ) ||IS_ENABLED (CONFIG_ZONE_DMA32 )) +reserve_crashkernel ();memblock_dump_all (); }
arch/arm64/mm/mmu.c +31 -1
@@ -516,7 +516,7 @@ static void __init map_mem(pgd_t *pgdp)*/ BUILD_BUG_ON (pgd_index (direct_map_end -1 ) ==pgd_index (direct_map_end)); -if (can_set_direct_map () || crash_mem_map ||IS_ENABLED (CONFIG_KFENCE )) +if (can_set_direct_map () ||IS_ENABLED (CONFIG_KFENCE )) flags |=NO_BLOCK_MAPPINGS |NO_CONT_MAPPINGS ;/*
@@ -527,6 +527,17 @@ static void __init map_mem(pgd_t *pgdp)*/ memblock_mark_nomap (kernel_start, kernel_end - kernel_start); +#ifdef CONFIG_KEXEC_CORE +if (crash_mem_map) { +if (IS_ENABLED (CONFIG_ZONE_DMA ) || +IS_ENABLED (CONFIG_ZONE_DMA32 )) + flags |=NO_BLOCK_MAPPINGS |NO_CONT_MAPPINGS ; +else if (crashk_res.end) +memblock_mark_nomap (crashk_res.start, +resource_size (&crashk_res)); + } +#endif +/* map all the memory banks */ for_each_mem_range (i, &start, &end) {if (start >= end)
@@ -553,6 +564,25 @@ static void __init map_mem(pgd_t *pgdp)__map_memblock (pgdp, kernel_start, kernel_end,PAGE_KERNEL ,NO_CONT_MAPPINGS );memblock_clear_nomap (kernel_start, kernel_end - kernel_start); + +/* +* Use page-level mappings here so that we can shrink the region +* in page granularity and put back unused memory to buddy system +* through /sys/kernel/kexec_crash_size interface. +*/ +#ifdef CONFIG_KEXEC_CORE +if (crash_mem_map && + !IS_ENABLED (CONFIG_ZONE_DMA ) && !IS_ENABLED (CONFIG_ZONE_DMA32 )) { +if (crashk_res.end) { +__map_memblock (pgdp, crashk_res.start, + crashk_res.end +1 , +PAGE_KERNEL , +NO_BLOCK_MAPPINGS |NO_CONT_MAPPINGS ); +memblock_clear_nomap (crashk_res.start, +resource_size (&crashk_res)); + } + } +#endif }void mark_rodata_ro (void )
Greg Kroah-Hartman
maintainerPATCH 123/913 arm64: dts: qcom: sm8250: Fix MSI IRQ for PCIe1 and PCIe2
In reply to Greg Kroah-HartmanFrom: Manivannan Sadhasivam <[email protected]>
commit 1b7101e8124b450f2d6a35591e9cbb478c143ace upstream.
Fix the MSI IRQ used for PCIe instances 1 and 2.
--- arch/arm64/boot/dts/qcom/sm8250.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/sm8250.dtsi +2 -2
@@ -1495,7 +1495,7 @@ ranges = <0x01000000 0x0 0x40200000 0x0 0x40200000 0x0 0x100000>, <0x02000000 0x0 0x40300000 0x0 0x40300000 0x0 0x1fd00000>; - interrupts = <GIC_SPI 306 IRQ_TYPE_EDGE_RISING>; + interrupts = <GIC_SPI 307 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "msi"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0x7>;
@@ -1601,7 +1601,7 @@ ranges = <0x01000000 0x0 0x64200000 0x0 0x64200000 0x0 0x100000>, <0x02000000 0x0 0x64300000 0x0 0x64300000 0x0 0x3d00000>; - interrupts = <GIC_SPI 236 IRQ_TYPE_EDGE_RISING>; + interrupts = <GIC_SPI 243 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "msi"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0x7>;
Greg Kroah-Hartman
maintainerPATCH 124/913 arm64: dts: ti: k3-am65: Fix gic-v3 compatible regs
In reply to Greg Kroah-HartmanFrom: Nishanth Menon <[email protected]>
commit 8cae268b70f387ff9e697ccd62fb2384079124e7 upstream.
Though GIC ARE option is disabled for no GIC-v2 compatibility, Cortex-A53 is free to implement the CPU interface as long as it communicates with the GIC using the stream protocol. This requires that the SoC integration mark out the PERIPHBASE[1] as reserved area within the SoC. See longer discussion in [2] for further information.
Update the GIC register map to indicate offsets from PERIPHBASE based on [3]. Without doing this, systems like kvm will not function with gic-v2 emulation.
[1] https://developer.arm.com/documentation/ddi0500/e/system-control/aarch64-register-descriptions/configuration-base-address-register--el1
[2] https://lore.kernel.org/all/[email protected]/
[3] https://developer.arm.com/documentation/ddi0500/e/generic-interrupt-controller-cpu-interface/gic-programmers-model/memory-map
--- arch/arm64/boot/dts/ti/k3-am65-main.dtsi | 5 ++++- arch/arm64/boot/dts/ti/k3-am65.dtsi | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/ti/k3-am65-main.dtsi +4 -1
@@ -35,7 +35,10 @@ #interrupt-cells = <3>; interrupt-controller; reg = <0x00 0x01800000 0x00 0x10000>, /* GICD */ - <0x00 0x01880000 0x00 0x90000>; /* GICR */ + <0x00 0x01880000 0x00 0x90000>, /* GICR */ + <0x00 0x6f000000 0x00 0x2000>, /* GICC */ + <0x00 0x6f010000 0x00 0x1000>, /* GICH */ + <0x00 0x6f020000 0x00 0x2000>; /* GICV */ /* * vcpumntirq: * virtual CPU interface maintenance interrupt
arch/arm64/boot/dts/ti/k3-am65.dtsi +1 -0
@@ -84,6 +84,7 @@ <0x00 0x46000000 0x00 0x46000000 0x00 0x00200000>, <0x00 0x47000000 0x00 0x47000000 0x00 0x00068400>, <0x00 0x50000000 0x00 0x50000000 0x00 0x8000000>, + <0x00 0x6f000000 0x00 0x6f000000 0x00 0x00310000>, /* A53 PERIPHBASE */ <0x00 0x70000000 0x00 0x70000000 0x00 0x200000>, <0x05 0x00000000 0x05 0x00000000 0x01 0x0000000>, <0x07 0x00000000 0x07 0x00000000 0x01 0x0000000>;
Greg Kroah-Hartman
maintainerPATCH 125/913 arm64: dts: ti: k3-j721e: Fix gic-v3 compatible regs
In reply to Greg Kroah-HartmanFrom: Nishanth Menon <[email protected]>
commit a06ed27f3bc63ab9e10007dc0118d910908eb045 upstream.
Though GIC ARE option is disabled for no GIC-v2 compatibility, Cortex-A72 is free to implement the CPU interface as long as it communicates with the GIC using the stream protocol. This requires that the SoC integration mark out the PERIPHBASE[1] as reserved area within the SoC. See longer discussion in [2] for further information.
Update the GIC register map to indicate offsets from PERIPHBASE based on [3]. Without doing this, systems like kvm will not function with gic-v2 emulation.
[1] https://developer.arm.com/documentation/100095/0002/system-control/aarch64-register-descriptions/configuration-base-address-register--el1
[2] https://lore.kernel.org/all/[email protected]/
[3] https://developer.arm.com/documentation/100095/0002/way1382452674438
--- arch/arm64/boot/dts/ti/k3-j721e-main.dtsi | 5 ++++- arch/arm64/boot/dts/ti/k3-j721e.dtsi | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/ti/k3-j721e-main.dtsi +4 -1
@@ -76,7 +76,10 @@ #interrupt-cells = <3>; interrupt-controller; reg = <0x00 0x01800000 0x00 0x10000>, /* GICD */ - <0x00 0x01900000 0x00 0x100000>; /* GICR */ + <0x00 0x01900000 0x00 0x100000>, /* GICR */ + <0x00 0x6f000000 0x00 0x2000>, /* GICC */ + <0x00 0x6f010000 0x00 0x1000>, /* GICH */ + <0x00 0x6f020000 0x00 0x2000>; /* GICV */ /* vcpumntirq: virtual CPU interface maintenance interrupt */ interrupts = <GIC_PPI 9 IRQ_TYPE_LEVEL_HIGH>;
arch/arm64/boot/dts/ti/k3-j721e.dtsi +1 -0
@@ -136,6 +136,7 @@ <0x00 0x0e000000 0x00 0x0e000000 0x00 0x01800000>, /* PCIe Core*/ <0x00 0x10000000 0x00 0x10000000 0x00 0x10000000>, /* PCIe DAT */ <0x00 0x64800000 0x00 0x64800000 0x00 0x00800000>, /* C71 */ + <0x00 0x6f000000 0x00 0x6f000000 0x00 0x00310000>, /* A72 PERIPHBASE */ <0x44 0x00000000 0x44 0x00000000 0x00 0x08000000>, /* PCIe2 DAT */ <0x44 0x10000000 0x44 0x10000000 0x00 0x08000000>, /* PCIe3 DAT */ <0x4d 0x80800000 0x4d 0x80800000 0x00 0x00800000>, /* C66_0 */
Greg Kroah-Hartman
maintainerPATCH 126/913 arm64: dts: ti: k3-j7200: Fix gic-v3 compatible regs
In reply to Greg Kroah-HartmanFrom: Nishanth Menon <[email protected]>
commit 1a307cc299430dd7139d351a3b8941f493dfa885 upstream.
Though GIC ARE option is disabled for no GIC-v2 compatibility, Cortex-A72 is free to implement the CPU interface as long as it communicates with the GIC using the stream protocol. This requires that the SoC integration mark out the PERIPHBASE[1] as reserved area within the SoC. See longer discussion in [2] for further information.
Update the GIC register map to indicate offsets from PERIPHBASE based on [3]. Without doing this, systems like kvm will not function with gic-v2 emulation.
[1] https://developer.arm.com/documentation/100095/0002/system-control/aarch64-register-descriptions/configuration-base-address-register--el1
[2] https://lore.kernel.org/all/[email protected]/
[3] https://developer.arm.com/documentation/100095/0002/way1382452674438
--- arch/arm64/boot/dts/ti/k3-j7200-main.dtsi | 5 ++++- arch/arm64/boot/dts/ti/k3-j7200.dtsi | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/ti/k3-j7200-main.dtsi +4 -1
@@ -54,7 +54,10 @@ #interrupt-cells = <3>; interrupt-controller; reg = <0x00 0x01800000 0x00 0x10000>, /* GICD */ - <0x00 0x01900000 0x00 0x100000>; /* GICR */ + <0x00 0x01900000 0x00 0x100000>, /* GICR */ + <0x00 0x6f000000 0x00 0x2000>, /* GICC */ + <0x00 0x6f010000 0x00 0x1000>, /* GICH */ + <0x00 0x6f020000 0x00 0x2000>; /* GICV */ /* vcpumntirq: virtual CPU interface maintenance interrupt */ interrupts = <GIC_PPI 9 IRQ_TYPE_LEVEL_HIGH>;
arch/arm64/boot/dts/ti/k3-j7200.dtsi +1 -0
@@ -127,6 +127,7 @@ <0x00 0x00a40000 0x00 0x00a40000 0x00 0x00000800>, /* timesync router */ <0x00 0x01000000 0x00 0x01000000 0x00 0x0d000000>, /* Most peripherals */ <0x00 0x30000000 0x00 0x30000000 0x00 0x0c400000>, /* MAIN NAVSS */ + <0x00 0x6f000000 0x00 0x6f000000 0x00 0x00310000>, /* A72 PERIPHBASE */ <0x00 0x70000000 0x00 0x70000000 0x00 0x00800000>, /* MSMC RAM */ <0x00 0x18000000 0x00 0x18000000 0x00 0x08000000>, /* PCIe1 DAT0 */ <0x41 0x00000000 0x41 0x00000000 0x01 0x00000000>, /* PCIe1 DAT1 */
Greg Kroah-Hartman
maintainerPATCH 127/913 arm64: dts: ti: k3-am64: Fix gic-v3 compatible regs
In reply to Greg Kroah-HartmanFrom: Nishanth Menon <[email protected]>
commit de60edf1be3d42d4a1b303b41c7c53b2f865726e upstream.
Though GIC ARE option is disabled for no GIC-v2 compatibility, Cortex-A53 is free to implement the CPU interface as long as it communicates with the GIC using the stream protocol. This requires that the SoC integration mark out the PERIPHBASE[1] as reserved area within the SoC. See longer discussion in [2] for further information.
Update the GIC register map to indicate offsets from PERIPHBASE based on [3]. Without doing this, systems like kvm will not function with gic-v2 emulation.
[1] https://developer.arm.com/documentation/ddi0500/e/system-control/aarch64-register-descriptions/configuration-base-address-register--el1
[2] https://lore.kernel.org/all/[email protected]/
[3] https://developer.arm.com/documentation/ddi0500/e/generic-interrupt-controller-cpu-interface/gic-programmers-model/memory-map
--- arch/arm64/boot/dts/ti/k3-am64-main.dtsi | 5 ++++- arch/arm64/boot/dts/ti/k3-am64.dtsi | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/ti/k3-am64-main.dtsi +4 -1
@@ -59,7 +59,10 @@ #interrupt-cells = <3>; interrupt-controller; reg = <0x00 0x01800000 0x00 0x10000>, /* GICD */ - <0x00 0x01840000 0x00 0xC0000>; /* GICR */ + <0x00 0x01840000 0x00 0xC0000>, /* GICR */ + <0x01 0x00000000 0x00 0x2000>, /* GICC */ + <0x01 0x00010000 0x00 0x1000>, /* GICH */ + <0x01 0x00020000 0x00 0x2000>; /* GICV */ /* * vcpumntirq: * virtual CPU interface maintenance interrupt
arch/arm64/boot/dts/ti/k3-am64.dtsi +1 -0
@@ -85,6 +85,7 @@ <0x00 0x68000000 0x00 0x68000000 0x00 0x08000000>, /* PCIe DAT0 */ <0x00 0x70000000 0x00 0x70000000 0x00 0x00200000>, /* OC SRAM */ <0x00 0x78000000 0x00 0x78000000 0x00 0x00800000>, /* Main R5FSS */ + <0x01 0x00000000 0x01 0x00000000 0x00 0x00310000>, /* A53 PERIPHBASE */ <0x06 0x00000000 0x06 0x00000000 0x01 0x00000000>, /* PCIe DAT1 */ <0x05 0x00000000 0x05 0x00000000 0x01 0x00000000>, /* FSS0 DAT3 */
Greg Kroah-Hartman
maintainerPATCH 128/913 ASoC: SOF: Intel: Fix NULL ptr dereference when ENOMEM
In reply to Greg Kroah-HartmanFrom: Ammar Faizi <[email protected]>
commit b7fb0ae09009d076964afe4c1a2bde1ee2bd88a9 upstream.
Do not call snd_dma_free_pages() when snd_dma_alloc_pages() returns -ENOMEM because it leads to a NULL pointer dereference bug.
The dmesg says:
[ T1387] sof-audio-pci-intel-tgl 0000:00:1f.3: error: memory alloc failed: -12
[ T1387] BUG: kernel NULL pointer dereference, address: 0000000000000000
[ T1387] #PF: supervisor read access in kernel mode
[ T1387] #PF: error_code(0x0000) - not-present page
[ T1387] PGD 0 P4D 0
[ T1387] Oops: 0000 [#1] PREEMPT SMP NOPTI
[ T1387] CPU: 6 PID: 1387 Comm: alsa-sink-HDA A Tainted: G W 5.17.0-rc4-superb-owl-00055-g80d47f5de5e3
[ T1387] Hardware name: HP HP Laptop 14s-dq2xxx/87FD, BIOS F.15 09/15/2021
[ T1387] RIP: 0010:dma_free_noncontiguous+0x37/0x80
[ T1387] Code: [... snip ...]
[ T1387] RSP: 0000:ffffc90002b87770 EFLAGS: 00010246
[ T1387] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[ T1387] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff888101db30d0
[ T1387] RBP: 00000000fffffff4 R08: 0000000000000000 R09: 0000000000000000
[ T1387] R10: 0000000000000000 R11: ffffc90002b874d0 R12: 0000000000000001
[ T1387] R13: 0000000000058000 R14: ffff888105260c68 R15: ffff888105260828
[ T1387] FS: 00007f42e2ffd640(0000) GS:ffff888466b80000(0000) knlGS:0000000000000000
[ T1387] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ T1387] CR2: 0000000000000000 CR3: 000000014acf0003 CR4: 0000000000770ee0
[ T1387] PKRU: 55555554
[ T1387] Call Trace:
[ T1387] <TASK>
[ T1387] cl_stream_prepare+0x10a/0x120 [snd_sof_intel_hda_common 146addf995b9279ae7f509621078cccbe4f875e1] [... snip ...]
[ T1387] </TASK>
--- sound/soc/sof/intel/hda-loader.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
sound/soc/sof/intel/hda-loader.c +6 -5
@@ -48,7 +48,7 @@ static struct hdac_ext_stream *cl_stream ret =snd_dma_alloc_pages (SNDRV_DMA_TYPE_DEV_SG , &pci->dev, size, dmab);if (ret <0 ) {dev_err (sdev->dev,"error: memory alloc failed: %d\n" , ret); - goto error; + goto out_put; } hstream->period_bytes =0 ;/* initialize period_bytes */
@@ -59,22 +59,23 @@ static struct hdac_ext_stream *cl_stream ret =hda_dsp_iccmax_stream_hw_params (sdev, dsp_stream, dmab,NULL );if (ret <0 ) {dev_err (sdev->dev,"error: iccmax stream prepare failed: %d\n" , ret); - goto error; + goto out_free; } }else { ret =hda_dsp_stream_hw_params (sdev, dsp_stream, dmab,NULL );if (ret <0 ) {dev_err (sdev->dev,"error: hdac prepare failed: %d\n" , ret); - goto error; + goto out_free; }hda_dsp_stream_spib_config (sdev, dsp_stream,HDA_DSP_SPIB_ENABLE , size); }return dsp_stream; -error: -hda_dsp_stream_put (sdev, direction, hstream->stream_tag); +out_free:snd_dma_free_pages (dmab); +out_put: +hda_dsp_stream_put (sdev, direction, hstream->stream_tag);return ERR_PTR (ret); }
Greg Kroah-Hartman
maintainerPATCH 129/913 Revert "ACPI: Pass the same capabilities to the _OSC regardless of the query flag"
In reply to Greg Kroah-HartmanFrom: Rafael J. Wysocki <[email protected]>
commit 2ca8e6285250c07a2e5a22ecbfd59b5a4ef73484 upstream.
Revert commit 159d8c274fd9 ("ACPI: Pass the same capabilities to the _OSC regardless of the query flag") which caused legitimate usage scenarios (when the platform firmware does not want the OS to control certain platform features controlled by the system bus scope _OSC) to break and was misguided by some misleading language in the _OSC definition in the ACPI specification (in particular, Section 6.2.11.1.3 "Sequence of _OSC Calls" that contradicts other perts of the _OSC definition).
--- drivers/acpi/bus.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
drivers/acpi/bus.c +19 -8
@@ -332,21 +332,32 @@ static void acpi_bus_osc_negotiate_platfif (ACPI_FAILURE (acpi_run_osc (handle, &context)))return ; -kfree (context.ret.pointer); + capbuf_ret = context.ret.pointer; +if (context.ret.length <=OSC_SUPPORT_DWORD ) { +kfree (context.ret.pointer); +return ; + } -/* Now run _OSC again with query flag clear */ +/* +* Now run _OSC again with query flag clear and with the caps +* supported by both the OS and the platform. +*/ capbuf[OSC_QUERY_DWORD ] =0 ; + capbuf[OSC_SUPPORT_DWORD ] = capbuf_ret[OSC_SUPPORT_DWORD ]; +kfree (context.ret.pointer);if (ACPI_FAILURE (acpi_run_osc (handle, &context)))return ; capbuf_ret = context.ret.pointer; - osc_sb_apei_support_acked = - capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_APEI_SUPPORT ; - osc_pc_lpi_support_confirmed = - capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_PCLPI_SUPPORT ; - osc_sb_native_usb4_support_confirmed = - capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_NATIVE_USB4_SUPPORT ; +if (context.ret.length >OSC_SUPPORT_DWORD ) { + osc_sb_apei_support_acked = + capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_APEI_SUPPORT ; + osc_pc_lpi_support_confirmed = + capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_PCLPI_SUPPORT ; + osc_sb_native_usb4_support_confirmed = + capbuf_ret[OSC_SUPPORT_DWORD ] &OSC_SB_NATIVE_USB4_SUPPORT ; + }kfree (context.ret.pointer); }
Greg Kroah-Hartman
maintainerPATCH 130/913 ACPI: properties: Consistently return -ENOENT if there are no more references
In reply to Greg Kroah-HartmanFrom: Sakari Ailus <[email protected]>
commit babc92da5928f81af951663fc436997352e02d3a upstream.
__acpi_node_get_property_reference() is documented to return -ENOENT if the caller requests a property reference at an index that does not exist, not -EINVAL which it actually does.
Fix this by returning -ENOENT consistenly, independently of whether the property value is a plain reference or a package.
--- drivers/acpi/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/property.c +1 -1
@@ -685,7 +685,7 @@ int __acpi_node_get_property_reference(c*/ if (obj->type ==ACPI_TYPE_LOCAL_REFERENCE ) {if (index) -return -EINVAL ; +return -ENOENT ; ret =acpi_bus_get_device (obj->reference.handle, &device);if (ret)
Greg Kroah-Hartman
maintainerPATCH 131/913 coredump: Also dump first pages of non-executable ELF libraries
In reply to Greg Kroah-HartmanFrom: Jann Horn <[email protected]>
commit 84158b7f6a0624b81800b4e7c90f7fb7fdecf66c upstream.
When I rewrote the VMA dumping logic for coredumps, I changed it to recognize ELF library mappings based on the file being executable instead of the mapping having an ELF header. But turns out, distros ship many ELF libraries as non-executable, so the heuristic goes wrong...
Restore the old behavior where FILTER(ELF_HEADERS) dumps the first page of any offset-0 readable mapping that starts with the ELF magic.
This fix is technically layer-breaking a bit, because it checks for something ELF-specific in fs/coredump.c; but since we probably want to share this between standard ELF and FDPIC ELF anyway, I guess it's fine? And this also keeps the change small for backporting.
--- fs/coredump.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-)
fs/coredump.c +34 -5
@@ -41,6 +41,7 @@#include <linux/fs.h> #include <linux/path.h> #include <linux/timekeeping.h> +#include <linux/elf.h> #include <linux/uaccess.h> #include <asm/mmu_context.h>
@@ -992,6 +993,8 @@ static bool always_dump_vma(struct vm_arreturn false; } +#define DUMP_SIZE_MAYBE_ELFHDR_PLACEHOLDER 1 +/* * Decide how much of @vma's contents should be included in a core dump. */
@@ -1051,9 +1054,20 @@ static unsigned long vma_dump_size(struc* dump the first page to aid in determining what was mapped here. */ if (FILTER (ELF_HEADERS ) && - vma->vm_pgoff ==0 && (vma->vm_flags &VM_READ ) && - (READ_ONCE (file_inode (vma->vm_file)->i_mode) &0111 ) !=0 ) -return PAGE_SIZE ; + vma->vm_pgoff ==0 && (vma->vm_flags &VM_READ )) { +if ((READ_ONCE (file_inode (vma->vm_file)->i_mode) &0111 ) !=0 ) +return PAGE_SIZE ; + +/* +* ELF libraries aren't always executable. +* We'll want to check whether the mapping starts with the ELF +* magic, but not now - we're holding the mmap lock, +* so copy_from_user() doesn't work here. +* Use a placeholder instead, and fix it up later in +* dump_vma_snapshot(). +*/ +return DUMP_SIZE_MAYBE_ELFHDR_PLACEHOLDER ; + }#undef FILTER
@@ -1128,8 +1142,6 @@ int dump_vma_snapshot(struct coredump_pa m->end = vma->vm_end; m->flags = vma->vm_flags; m->dump_size =vma_dump_size (vma, cprm->mm_flags); - - vma_data_size += m->dump_size; }mmap_write_unlock (mm);
@@ -1139,6 +1151,23 @@ int dump_vma_snapshot(struct coredump_pareturn -EFAULT ; } +for (i =0 ; i < *vma_count; i++) { +struct core_vma_metadata *m = (*vma_meta) + i; + +if (m->dump_size ==DUMP_SIZE_MAYBE_ELFHDR_PLACEHOLDER ) { +char elfmag[SELFMAG ]; + +if (copy_from_user (elfmag, (void __user *)m->start,SELFMAG ) || +memcmp (elfmag,ELFMAG ,SELFMAG ) !=0 ) { + m->dump_size =0 ; + }else { + m->dump_size =PAGE_SIZE ; + } + } + + vma_data_size += m->dump_size; + } + *vma_data_size_ptr = vma_data_size;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 132/913 ext4: fix ext4_fc_stats trace point
In reply to Greg Kroah-HartmanFrom: Ritesh Harjani <[email protected]>
commit 7af1974af0a9ba8a8ed2e3e947d87dd4d9a78d27 upstream.
ftrace's __print_symbolic() requires that any enum values used in the symbol to string translation table be wrapped in a TRACE_DEFINE_ENUM so that the enum value can be decoded from the ftrace ring buffer by user space tooling.
This patch also fixes few other problems found in this trace point. e.g. dereferencing structures in TP_printk which should not be done at any cost.
Also to avoid checkpatch warnings, this patch removes those whitespaces/tab stops issues.
--- include/trace/events/ext4.h | 80 +++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 30 deletions(-)
include/trace/events/ext4.h +50 -30
@@ -95,6 +95,17 @@ TRACE_DEFINE_ENUM(ES_REFERENCED_B); { FALLOC_FL_COLLAPSE_RANGE, "COLLAPSE_RANGE"}, \ { FALLOC_FL_ZERO_RANGE, "ZERO_RANGE"}) +TRACE_DEFINE_ENUM (EXT4_FC_REASON_XATTR ); +TRACE_DEFINE_ENUM (EXT4_FC_REASON_CROSS_RENAME ); +TRACE_DEFINE_ENUM (EXT4_FC_REASON_JOURNAL_FLAG_CHANGE ); +TRACE_DEFINE_ENUM (EXT4_FC_REASON_NOMEM ); +TRACE_DEFINE_ENUM (EXT4_FC_REASON_SWAP_BOOT ); +TRACE_DEFINE_ENUM (EXT4_FC_REASON_RESIZE ); +TRACE_DEFINE_ENUM (EXT4_FC_REASON_RENAME_DIR ); +TRACE_DEFINE_ENUM (EXT4_FC_REASON_FALLOC_RANGE ); +TRACE_DEFINE_ENUM (EXT4_FC_REASON_INODE_JOURNAL_DATA ); +TRACE_DEFINE_ENUM (EXT4_FC_REASON_MAX ); +#define show_fc_reason (reason) \ __print_symbolic(reason, \ { EXT4_FC_REASON_XATTR, "XATTR"}, \
@@ -2723,41 +2734,50 @@ TRACE_EVENT(ext4_fc_commit_stop,#define FC_REASON_NAME_STAT (reason) \ show_fc_reason(reason), \ - __entry->sbi->s_fc_stats.fc_ineligible_reason_count[reason] + __entry->fc_ineligible_rc[reason]TRACE_EVENT (ext4_fc_stats, - TP_PROTO(struct super_block *sb), + TP_PROTO(struct super_block *sb), + +TP_ARGS (sb), + +TP_STRUCT__entry ( + __field(dev_t, dev) + __array(unsigned int, fc_ineligible_rc, EXT4_FC_REASON_MAX) + __field(unsigned long, fc_commits) + __field(unsigned long, fc_ineligible_commits) + __field(unsigned long, fc_numblks) + ), -TP_ARGS (sb), +TP_fast_assign ( + int i; -TP_STRUCT__entry ( - __field(dev_t, dev) - __field(struct ext4_sb_info *, sbi) -__field (int, count) - ), - -TP_fast_assign ( - __entry->dev = sb->s_dev; - __entry->sbi = EXT4_SB(sb); - ), - -TP_printk ("dev %d:%d fc ineligible reasons:\n" -"%s:%d, %s:%d, %s:%d, %s:%d, %s:%d, %s:%d, %s:%d, %s:%d, %s:%d; " -"num_commits:%ld, ineligible: %ld, numblks: %ld" , -MAJOR (__entry->dev),MINOR (__entry->dev), -FC_REASON_NAME_STAT (EXT4_FC_REASON_XATTR ), -FC_REASON_NAME_STAT (EXT4_FC_REASON_CROSS_RENAME ), -FC_REASON_NAME_STAT (EXT4_FC_REASON_JOURNAL_FLAG_CHANGE ), -FC_REASON_NAME_STAT (EXT4_FC_REASON_NOMEM ), -FC_REASON_NAME_STAT (EXT4_FC_REASON_SWAP_BOOT ), -FC_REASON_NAME_STAT (EXT4_FC_REASON_RESIZE ), -FC_REASON_NAME_STAT (EXT4_FC_REASON_RENAME_DIR ), -FC_REASON_NAME_STAT (EXT4_FC_REASON_FALLOC_RANGE ), -FC_REASON_NAME_STAT (EXT4_FC_REASON_INODE_JOURNAL_DATA ), - __entry->sbi->s_fc_stats.fc_num_commits, - __entry->sbi->s_fc_stats.fc_ineligible_commits, - __entry->sbi->s_fc_stats.fc_numblks) + __entry->dev = sb->s_dev; + for (i = 0; i < EXT4_FC_REASON_MAX; i++) { + __entry->fc_ineligible_rc[i] = + EXT4_SB(sb)->s_fc_stats.fc_ineligible_reason_count[i]; + } + __entry->fc_commits = EXT4_SB(sb)->s_fc_stats.fc_num_commits; + __entry->fc_ineligible_commits = + EXT4_SB(sb)->s_fc_stats.fc_ineligible_commits; + __entry->fc_numblks = EXT4_SB(sb)->s_fc_stats.fc_numblks; + ), +TP_printk ("dev %d,%d fc ineligible reasons:\n" +"%s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u, %s:%u " +"num_commits:%lu, ineligible: %lu, numblks: %lu" , +MAJOR (__entry->dev),MINOR (__entry->dev), +FC_REASON_NAME_STAT (EXT4_FC_REASON_XATTR ), +FC_REASON_NAME_STAT (EXT4_FC_REASON_CROSS_RENAME ), +FC_REASON_NAME_STAT (EXT4_FC_REASON_JOURNAL_FLAG_CHANGE ), +FC_REASON_NAME_STAT (EXT4_FC_REASON_NOMEM ), +FC_REASON_NAME_STAT (EXT4_FC_REASON_SWAP_BOOT ), +FC_REASON_NAME_STAT (EXT4_FC_REASON_RESIZE ), +FC_REASON_NAME_STAT (EXT4_FC_REASON_RENAME_DIR ), +FC_REASON_NAME_STAT (EXT4_FC_REASON_FALLOC_RANGE ), +FC_REASON_NAME_STAT (EXT4_FC_REASON_INODE_JOURNAL_DATA ), + __entry->fc_commits, __entry->fc_ineligible_commits, + __entry->fc_numblks) );#define DEFINE_TRACE_DENTRY_EVENT (__type) \
Greg Kroah-Hartman
maintainerPATCH 133/913 ext4: fix fs corruption when tring to remove a non-empty directory with IO error
In reply to Greg Kroah-HartmanFrom: Ye Bin <[email protected]>
commit 7aab5c84a0f6ec2290e2ba4a6b245178b1bf949a upstream.
We inject IO error when rmdir non empty direcory, then got issue as follows:
step1: mkfs.ext4 -F /dev/sda
step2: mount /dev/sda test
step3: cd test
step4: mkdir -p 1/2
step5: rmdir 1
[ 110.920551] ext4_empty_dir: inject fault [ 110.921926] EXT4-fs warning (device sda): ext4_rmdir:3113: inode #12: comm rmdir: empty directory '1' has too many links (3)
step6: cd ..
step7: umount test
step8: fsck.ext4 -f /dev/sda
e2fsck 1.42.9 (28-Dec-2013)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Entry '..' in .../??? (13) has deleted/unused inode 12. Clear<y>? yes Pass 3: Checking directory connectivity
Unconnected directory inode 13 (...)
Connect to /lost+found<y>? yes
Pass 4: Checking reference counts
Inode 13 ref count is 3, should be 2. Fix<y>? yes
Pass 5: Checking group summary information
/dev/sda: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sda: 12/131072 files (0.0% non-contiguous), 26157/524288 blocks
ext4_rmdir
if (!ext4_empty_dir(inode)) goto end_rmdir; ext4_empty_dir bh = ext4_read_dirblock(inode, 0, DIRENT_HTREE); if (IS_ERR(bh)) return true;
Now if read directory block failed, 'ext4_empty_dir' will return true, assume directory is empty. Obviously, it will lead to above issue.
To solve this issue, if read directory block failed 'ext4_empty_dir' just return false. To avoid making things worse when file system is already corrupted, 'ext4_empty_dir' also return false.
--- fs/ext4/inline.c | 9 ++++----- fs/ext4/namei.c | 10 +++++----- 2 files changed, 9 insertions(+), 10 deletions(-)
fs/ext4/inline.c +4 -5
@@ -1788,19 +1788,20 @@ bool empty_inline_dir(struct inode *dir,void *inline_pos;unsigned int offset;struct ext4_dir_entry_2 *de; -bool ret = true; +bool ret = false; err =ext4_get_inode_loc (dir, &iloc);if (err) {EXT4_ERROR_INODE_ERR (dir, -err,"error %d getting inode %lu block" , err, dir->i_ino); -return true; +return false; }down_read (&EXT4_I (dir)->xattr_sem);if (!ext4_has_inline_data (dir)) { *has_inline_data =0 ; + ret = true; goto out; }
@@ -1809,7 +1810,6 @@ bool empty_inline_dir(struct inode *dir,ext4_warning (dir->i_sb,"bad inline directory (dir #%lu) - no `..'" , dir->i_ino); - ret = true; goto out; }
@@ -1828,16 +1828,15 @@ bool empty_inline_dir(struct inode *dir, dir->i_ino,le32_to_cpu (de->inode),le16_to_cpu (de->rec_len), de->name_len, inline_size); - ret = true; goto out; }if (le32_to_cpu (de->inode)) { - ret = false; goto out; } offset +=ext4_rec_len_from_disk (de->rec_len, inline_size); } + ret = true; out:up_read (&EXT4_I (dir)->xattr_sem);brelse (iloc.bh);
fs/ext4/namei.c +5 -5
@@ -2997,14 +2997,14 @@ bool ext4_empty_dir(struct inode *inode)if (inode->i_size <ext4_dir_rec_len (1 ,NULL ) +ext4_dir_rec_len (2 ,NULL )) {EXT4_ERROR_INODE (inode,"invalid size" ); -return true; +return false; }/* The first directory block must not be a hole, * so treat it as DIRENT_HTREE */ bh =ext4_read_dirblock (inode,0 ,DIRENT_HTREE );if (IS_ERR (bh)) -return true; +return false; de = (struct ext4_dir_entry_2 *) bh->b_data; if (ext4_check_dir_entry(inode, NULL, de, bh, bh->b_data, bh->b_size,
@@ -3012,7 +3012,7 @@ bool ext4_empty_dir(struct inode *inode) le32_to_cpu(de->inode) != inode->i_ino || strcmp(".", de->name)) {ext4_warning_inode (inode,"directory missing '.'" );brelse (bh); -return true; +return false; } offset =ext4_rec_len_from_disk (de->rec_len, sb->s_blocksize); de =ext4_next_entry (de, sb->s_blocksize);
@@ -3021,7 +3021,7 @@ bool ext4_empty_dir(struct inode *inode) le32_to_cpu(de->inode) == 0 || strcmp("..", de->name)) {ext4_warning_inode (inode,"directory missing '..'" );brelse (bh); -return true; +return false; } offset +=ext4_rec_len_from_disk (de->rec_len, sb->s_blocksize);while (offset < inode->i_size) {
@@ -3035,7 +3035,7 @@ bool ext4_empty_dir(struct inode *inode)continue ; }if (IS_ERR (bh)) -return true; +return false; } de = (struct ext4_dir_entry_2 *) (bh->b_data + (offset & (sb->s_blocksize -1 )));
Greg Kroah-Hartman
maintainerPATCH 134/913 ext4: make mb_optimize_scan performance mount option work with extents
In reply to Greg Kroah-HartmanFrom: Ojaswin Mujoo <[email protected]>
commit 077d0c2c78df6f7260cdd015a991327efa44d8ad upstream.
Currently mb_optimize_scan scan feature which improves filesystem performance heavily (when FS is fragmented), seems to be not working with files with extents (ext4 by default has files with extents).
This patch fixes that and makes mb_optimize_scan feature work for files with extents.
Below are some performance numbers obtained when allocating a 10M and 100M file with and w/o this patch on a filesytem with no 1M contiguous block.
<perf numbers>
===============
Workload: dd if=/dev/urandom of=test conv=fsync bs=1M count=10/100
Time taken
=====================================================
no. Size without-patch with-patch Diff(%) 1 10M 0m8.401s 0m5.623s 33.06% 2 100M 1m40.465s 1m14.737s 25.6%
<debug stats>
=============
w/o patch:
mballoc:
reqs: 17056
success: 11407
groups_scanned: 13643
cr0_stats:
hits: 37
groups_considered: 9472
useless_loops: 36
bad_suggestions: 0
cr1_stats:
hits: 11418
groups_considered: 908560
useless_loops: 1894
bad_suggestions: 0
cr2_stats:
hits: 1873
groups_considered: 6913
useless_loops: 21
cr3_stats:
hits: 21
groups_considered: 5040
useless_loops: 21
extents_scanned: 417364
goal_hits: 3707
2^n_hits: 37
breaks: 1873
lost: 0
buddies_generated: 239/240
buddies_time_used: 651080
preallocated: 705
discarded: 478with patch:
mballoc:
reqs: 12768
success: 11305
groups_scanned: 12768
cr0_stats:
hits: 1
groups_considered: 18
useless_loops: 0
bad_suggestions: 0
cr1_stats:
hits: 5829
groups_considered: 50626
useless_loops: 0
bad_suggestions: 0
cr2_stats:
hits: 6938
groups_considered: 580363
useless_loops: 0
cr3_stats:
hits: 0
groups_considered: 0
useless_loops: 0
extents_scanned: 309059
goal_hits: 0
2^n_hits: 1
breaks: 1463
lost: 0
buddies_generated: 239/240
buddies_time_used: 791392
preallocated: 673
discarded: 446--- fs/ext4/mballoc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/mballoc.c +1 -1
@@ -1000,7 +1000,7 @@ static inline int should_optimize_scan(sreturn 0 ;if (ac->ac_criteria >=2 )return 0 ; -if (ext4_test_inode_flag (ac->ac_inode,EXT4_INODE_EXTENTS )) +if (!ext4_test_inode_flag (ac->ac_inode,EXT4_INODE_EXTENTS ))return 0 ;return 1 ; }
Greg Kroah-Hartman
maintainerPATCH 135/913 drivers: hamradio: 6pack: fix UAF bug caused by mod_timer()
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
commit efe4186e6a1b54bf38b9e05450d43b0da1fd7739 upstream.
When a 6pack device is detaching, the sixpack_close() will act to cleanup necessary resources. Although del_timer_sync() in sixpack_close() won't return if there is an active timer, one could use mod_timer() in sp_xmit_on_air() to wake up timer again by calling userspace syscall such as ax25_sendmsg(), ax25_connect() and ax25_ioctl().
This unexpected waked handler, sp_xmit_on_air(), realizes nothing about the undergoing cleanup and may still call pty_write() to use driver layer resources that have already been released.
One of the possible race conditions is shown below:
(USE) | (FREE)
ax25_sendmsg() |
ax25_queue_xmit() |
... |
sp_xmit() |
sp_encaps() | sixpack_close()
sp_xmit_on_air() | del_timer_sync(&sp->tx_t)
mod_timer(&sp->tx_t,...) | ...
| unregister_netdev()
| ...
(wait a while) | tty_release()
| tty_release_struct()
| release_tty()
sp_xmit_on_air() | tty_kref_put(tty_struct) //FREE
pty_write(tty_struct) //USE | ...The corresponding fail log is shown below:
===============================================================
BUG: KASAN: use-after-free in __run_timers.part.0+0x170/0x470 Write of size 8 at addr ffff88800a652ab8 by task swapper/2/0 ... Call Trace: ... queue_work_on+0x3f/0x50 pty_write+0xcd/0xe0pty_write+0xcd/0xe0 sp_xmit_on_air+0xb2/0x1f0 call_timer_fn+0x28/0x150 __run_timers.part.0+0x3c2/0x470 run_timer_softirq+0x3b/0x80 __do_softirq+0xf1/0x380 ...
This patch reorders the del_timer_sync() after the unregister_netdev() to avoid UAF bugs. Because the unregister_netdev() is well synchronized, it flushs out any pending queues, waits the refcount of net_device decreases to zero and removes net_device from kernel. There is not any running routines after executing unregister_netdev(). Therefore, we could not arouse timer from userspace again.
--- drivers/net/hamradio/6pack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/hamradio/6pack.c +2 -2
@@ -669,14 +669,14 @@ static void sixpack_close(struct tty_str*/ netif_stop_queue (sp->dev); +unregister_netdev (sp->dev); +del_timer_sync (&sp->tx_t);del_timer_sync (&sp->resync_t);/* Free all 6pack frame buffers. */ kfree (sp->rbuff);kfree (sp->xbuff); - -unregister_netdev (sp->dev); }/* Perform I/O control on an active 6pack channel. */
Greg Kroah-Hartman
maintainerPATCH 136/913 samples/landlock: Fix path_list memory leak
In reply to Greg Kroah-HartmanFrom: Tom Rix <[email protected]>
commit 66b513b7c64a7290c1fbb88e657f7cece992e131 upstream.
Clang static analysis reports this error
sandboxer.c:134:8: warning: Potential leak of memory
pointed to by 'path_list'
ret = 0;
^path_list is allocated in parse_path() but never freed.
--- samples/landlock/sandboxer.c | 1 + 1 file changed, 1 insertion(+)
samples/landlock/sandboxer.c +1 -0
@@ -134,6 +134,7 @@ static int populate_ruleset( ret =0 ; out_free_name: +free (path_list);free (env_path_name);return ret; }
Greg Kroah-Hartman
maintainerPATCH 137/913 landlock: Use square brackets around "landlock-ruleset"
In reply to Greg Kroah-HartmanFrom: Christian Brauner <[email protected]>
commit aea0b9f2486da8497f35c7114b764bf55e17c7ea upstream.
Make the name of the anon inode fd "[landlock-ruleset]" instead of "landlock-ruleset". This is minor but most anon inode fds already carry square brackets around their name:
[eventfd]
[eventpoll]
[fanotify]
[fscontext]
[io_uring]
[pidfd]
[signalfd]
[timerfd]
[userfaultfd]For the sake of consistency lets do the same for the landlock-ruleset anon inode fd that comes with landlock. We did the same in 1cdc415f1083 ("uapi, fsopen: use square brackets around "fscontext" [ver #2]") for the new mount api.
--- security/landlock/syscalls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/landlock/syscalls.c +1 -1
@@ -192,7 +192,7 @@ SYSCALL_DEFINE3(landlock_create_ruleset,return PTR_ERR (ruleset);/* Creates anonymous FD referring to the ruleset. */ - ruleset_fd =anon_inode_getfd ("landlock-ruleset" , &ruleset_fops, + ruleset_fd =anon_inode_getfd ("[landlock-ruleset]" , &ruleset_fops, ruleset,O_RDWR |O_CLOEXEC );if (ruleset_fd <0 )landlock_put_ruleset (ruleset);
Greg Kroah-Hartman
maintainerPATCH 138/913 mailbox: tegra-hsp: Flush whole channel
In reply to Greg Kroah-HartmanFrom: Pekka Pessi <[email protected]>
commit 60de2d2dc284e0dd1c2c897d08625bde24ef3454 upstream.
The txdone can re-fill the mailbox. Keep polling the mailbox during the flush until all the messages have been delivered.
This fixes an issue with the Tegra Combined UART (TCU) where output can get truncated under high traffic load.
--- drivers/mailbox/tegra-hsp.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/mailbox/tegra-hsp.c +5 -0
@@ -412,6 +412,11 @@ static int tegra_hsp_mailbox_flush(struc value =tegra_hsp_channel_readl (ch,HSP_SM_SHRD_MBOX );if ((value &HSP_SM_SHRD_MBOX_FULL ) ==0 ) {mbox_chan_txdone (chan,0 ); + +/* Wait until channel is empty */ +if (chan->active_req !=NULL ) +continue ; +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 139/913 block: limit request dispatch loop duration
In reply to Greg Kroah-HartmanFrom: Shin'ichiro Kawasaki <[email protected]>
commit 572299f03afd676dd4e20669cdaf5ed0fe1379d4 upstream.
When IO requests are made continuously and the target block device handles requests faster than request arrival, the request dispatch loop keeps on repeating to dispatch the arriving requests very long time, more than a minute. Since the loop runs as a workqueue worker task, the very long loop duration triggers workqueue watchdog timeout and BUG [1].
To avoid the very long loop duration, break the loop periodically. When opportunity to dispatch requests still exists, check need_resched(). If need_resched() returns true, the dispatch loop already consumed its time slice, then reschedule the dispatch work and break the loop. With heavy IO load, need_resched() does not return true for 20~30 seconds. To cover such case, check time spent in the dispatch loop with jiffies. If more than 1 second is spent, reschedule the dispatch work and break the loop.
[1]
[ 609.691437] BUG: workqueue lockup - pool cpus=10 node=1 flags=0x0 nice=-20 stuck for 35s! [ 609.701820] Showing busy workqueues and worker pools: [ 609.707915] workqueue events: flags=0x0 [ 609.712615] pwq 0: cpus=0 node=0 flags=0x0 nice=0 active=1/256 refcnt=2 [ 609.712626] pending: drm_fb_helper_damage_work [drm_kms_helper] [ 609.712687] workqueue events_freezable: flags=0x4 [ 609.732943] pwq 0: cpus=0 node=0 flags=0x0 nice=0 active=1/256 refcnt=2 [ 609.732952] pending: pci_pme_list_scan [ 609.732968] workqueue events_power_efficient: flags=0x80 [ 609.751947] pwq 0: cpus=0 node=0 flags=0x0 nice=0 active=1/256 refcnt=2 [ 609.751955] pending: neigh_managed_work [ 609.752018] workqueue kblockd: flags=0x18 [ 609.769480] pwq 21: cpus=10 node=1 flags=0x0 nice=-20 active=3/256 refcnt=4 [ 609.769488] in-flight: 1020:blk_mq_run_work_fn [ 609.769498] pending: blk_mq_timeout_work, blk_mq_run_work_fn [ 609.769744] pool 21: cpus=10 node=1 flags=0x0 nice=-20 hung=35s workers=2 idle: 67 [ 639.899730] BUG: workqueue lockup - pool cpus=10 node=1 flags=0x0 nice=-20 stuck for 66s! [ 639.909513] Showing busy workqueues and worker pools: [ 639.915404] workqueue events: flags=0x0 [ 639.920197] pwq 0: cpus=0 node=0 flags=0x0 nice=0 active=1/256 refcnt=2 [ 639.920215] pending: drm_fb_helper_damage_work [drm_kms_helper] [ 639.920365] workqueue kblockd: flags=0x18 [ 639.939932] pwq 21: cpus=10 node=1 flags=0x0 nice=-20 active=3/256 refcnt=4 [ 639.939942] in-flight: 1020:blk_mq_run_work_fn [ 639.939955] pending: blk_mq_timeout_work, blk_mq_run_work_fn [ 639.940212] pool 21: cpus=10 node=1 flags=0x0 nice=-20 hung=66s workers=2 idle: 67
--- block/blk-mq-sched.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
block/blk-mq-sched.c +8 -1
@@ -208,11 +208,18 @@ static int __blk_mq_do_dispatch_sched(ststatic int blk_mq_do_dispatch_sched (struct blk_mq_hw_ctx *hctx) { +unsigned long end = jiffies +HZ ;int ret;do { ret =__blk_mq_do_dispatch_sched (hctx); - }while (ret ==1 ); +if (ret !=1 ) +break ; +if (need_resched () ||time_is_before_jiffies (end)) { +blk_mq_delay_run_hw_queue (hctx,0 ); +break ; + } + }while (1 );return ret; }
Greg Kroah-Hartman
maintainerPATCH 140/913 block: dont merge across cgroup boundaries if blkcg is enabled
In reply to Greg Kroah-HartmanFrom: Tejun Heo <[email protected]>
commit 6b2b04590b51aa4cf395fcd185ce439cab5961dc upstream.
blk-iocost and iolatency are cgroup aware rq-qos policies but they didn't disable merges across different cgroups. This obviously can lead to accounting and control errors but more importantly to priority inversions - e.g. an IO which belongs to a higher priority cgroup or IO class may end up getting throttled incorrectly because it gets merged to an IO issued from a low priority cgroup.
Fix it by adding blk_cgroup_mergeable() which is called from merge paths and rejects cross-cgroup and cross-issue_as_root merges.
--- block/blk-merge.c | 11 +++++++++++ include/linux/blk-cgroup.h | 17 +++++++++++++++++ 2 files changed, 28 insertions(+)
block/blk-merge.c +11 -0
@@ -7,6 +7,7 @@#include <linux/bio.h> #include <linux/blkdev.h> #include <linux/scatterlist.h> +#include <linux/blk-cgroup.h> #include <trace/events/block.h>
@@ -561,6 +562,9 @@ static inline unsigned int blk_rq_get_mastatic inline int ll_new_hw_segment (struct request *req,struct bio *bio,unsigned int nr_phys_segs) { +if (!blk_cgroup_mergeable (req, bio)) + goto no_merge; +if (blk_integrity_merge_bio (req->q, req, bio) == false) goto no_merge;
@@ -657,6 +661,9 @@ static int ll_merge_requests_fn(struct rif (total_phys_segments >blk_rq_get_max_segments (req))return 0 ; +if (!blk_cgroup_mergeable (req, next->bio)) +return 0 ; +if (blk_integrity_merge_rq (q, req, next) == false)return 0 ;
@@ -863,6 +870,10 @@ bool blk_rq_merge_ok(struct request *rq,if (rq->rq_disk != bio->bi_bdev->bd_disk)return false; +/* don't merge across cgroup boundaries */ +if (!blk_cgroup_mergeable (rq, bio)) +return false; +/* only merge integrity protected bio into ditto rq */ if (blk_integrity_merge_bio (rq->q, rq, bio) == false)return false;
include/linux/blk-cgroup.h +17 -0
@@ -24,6 +24,7 @@#include <linux/atomic.h> #include <linux/kthread.h> #include <linux/fs.h> +#include <linux/blk-mq.h> /* percpu_counter batch for blkg_[rw]stats, per-cpu drift doesn't matter */ #define BLKG_STAT_CPU_BATCH (INT_MAX / 2)
@@ -604,6 +605,21 @@ static inline void blkcg_clear_delay(stratomic_dec (&blkg->blkcg->css.cgroup->congestion_count); } +/** +* blk_cgroup_mergeable - Determine whether to allow or disallow merges +* @rq: request to merge into +* @bio: bio to merge +* +* @bio and @rq should belong to the same cgroup and their issue_as_root should +* match. The latter is necessary as we don't want to throttle e.g. a metadata +* update because it happens to be next to a regular IO. +*/ +static inline bool blk_cgroup_mergeable (struct request *rq,struct bio *bio) +{ +return rq->bio->bi_blkg == bio->bi_blkg && +bio_issue_as_root_blkg (rq->bio) ==bio_issue_as_root_blkg (bio); +} +void blk_cgroup_bio_start (struct bio *bio);void blkcg_add_delay (struct blkcg_gq *blkg,u64 now,u64 delta);void blkcg_schedule_throttle (struct request_queue *q,bool use_memdelay);
@@ -659,6 +675,7 @@ static inline void blkg_put(struct blkcgstatic inline bool blkcg_punt_bio_submit (struct bio *bio) {return false; }static inline void blkcg_bio_issue_init (struct bio *bio) { }static inline void blk_cgroup_bio_start (struct bio *bio) { } +static inline bool blk_cgroup_mergeable (struct request *rq,struct bio *bio) {return true; }#define blk_queue_for_each_rl (rl, q) \ for ((rl) = &(q)->root_rl; (rl); (rl) = NULL)
Greg Kroah-Hartman
maintainerPATCH 141/913 drm/edid: check basic audio support on CEA extension block
In reply to Greg Kroah-HartmanFrom: Cooper Chiou <[email protected]>
commit 5662abf6e21338be6d085d6375d3732ac6147fd2 upstream.
Tag code stored in bit7:5 for CTA block byte[3] is not the same as CEA extension block definition. Only check CEA block has basic audio support.
v3: update commit message.
--- drivers/gpu/drm/drm_edid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_edid.c +2 -1
@@ -4776,7 +4776,8 @@ bool drm_detect_monitor_audio(struct ediif (!edid_ext) goto end; - has_audio = ((edid_ext[3 ] &EDID_BASIC_AUDIO ) !=0 ); + has_audio = (edid_ext[0 ] ==CEA_EXT && + (edid_ext[3 ] &EDID_BASIC_AUDIO ) !=0 );if (has_audio) {DRM_DEBUG_KMS ("Monitor has basic audio support\n" );
Greg Kroah-Hartman
maintainerPATCH 142/913 fbdev: Hot-unplug firmware fb devices on forced removal
In reply to Greg Kroah-HartmanFrom: Thomas Zimmermann <[email protected]>
commit 27599aacbaefcbf2af7b06b0029459bbf682000d upstream.
Hot-unplug all firmware-framebuffer devices as part of removing them via remove_conflicting_framebuffers() et al. Releases all memory regions to be acquired by native drivers.
Firmware, such as EFI, install a framebuffer while posting the computer. After removing the firmware-framebuffer device from fbdev, a native driver takes over the hardware and the firmware framebuffer becomes invalid.
Firmware-framebuffer drivers, specifically simplefb, don't release their device from Linux' device hierarchy. It still owns the firmware framebuffer and blocks the native drivers from loading. This has been observed in the vmwgfx driver. [1]
Initiating a device removal (i.e., hot unplug) as part of remove_conflicting_framebuffers() removes the underlying device and returns the memory range to the system.
[1] https://lore.kernel.org/dri-devel/[email protected]/
v2:
* rename variable 'dev' to 'device' (Javier)
--- drivers/video/fbdev/core/fbmem.c | 29 ++++++++++++++++++++++++++--- include/linux/fb.h | 1 + 2 files changed, 27 insertions(+), 3 deletions(-)
drivers/video/fbdev/core/fbmem.c +26 -3
@@ -25,6 +25,7 @@#include <linux/init.h> #include <linux/linux_logo.h> #include <linux/proc_fs.h> +#include <linux/platform_device.h> #include <linux/seq_file.h> #include <linux/console.h> #include <linux/kmod.h>
@@ -1557,18 +1558,36 @@ static void do_remove_conflicting_frameb/* check all firmware fbs and kick off if the base addr overlaps */ for_each_registered_fb (i) {struct apertures_struct *gen_aper; +struct device *device;if (!(registered_fb[i]->flags &FBINFO_MISC_FIRMWARE ))continue ; gen_aper = registered_fb[i]->apertures; + device = registered_fb[i]->device;if (fb_do_apertures_overlap (gen_aper, a) || (primary && gen_aper && gen_aper->count && gen_aper->ranges[0 ].base ==VGA_FB_PHYS )) {printk (KERN_INFO "fb%d: switching to %s from %s\n" , i, name, registered_fb[i]->fix.id); -do_unregister_framebuffer (registered_fb[i]); + +/* +* If we kick-out a firmware driver, we also want to remove +* the underlying platform device, such as simple-framebuffer, +* VESA, EFI, etc. A native driver will then be able to +* allocate the memory range. +* +* If it's not a platform device, at least print a warning. A +* fix would add code to remove the device from the system. +*/ +if (dev_is_platform (device)) { + registered_fb[i]->forced_out = true; +platform_device_unregister (to_platform_device (device)); + }else { +pr_warn ("fb%d: cannot remove device\n" , i); +do_unregister_framebuffer (registered_fb[i]); + } } } }
@@ -1895,9 +1914,13 @@ EXPORT_SYMBOL(register_framebuffer);void unregister_framebuffer (struct fb_info *fb_info) { -mutex_lock (®istration_lock); +bool forced_out = fb_info->forced_out; + +if (!forced_out) +mutex_lock (®istration_lock);do_unregister_framebuffer (fb_info); -mutex_unlock (®istration_lock); +if (!forced_out) +mutex_unlock (®istration_lock); }EXPORT_SYMBOL (unregister_framebuffer);
include/linux/fb.h +1 -0
@@ -502,6 +502,7 @@ struct fb_info { } *apertures;bool skip_vt_switch;/* no VT switch on suspend/resume required */ +bool forced_out;/* set when being removed by another driver */ };static inline struct apertures_struct *alloc_apertures (unsigned int max_num) {
Greg Kroah-Hartman
maintainerPATCH 143/913 video: fbdev: sm712fb: Fix crash in smtcfb_read()
In reply to Greg Kroah-HartmanFrom: Helge Deller <[email protected]>
commit bd771cf5c4254511cc4abb88f3dab3bd58bdf8e8 upstream.
Zheyu Ma reported this crash in the sm712fb driver when reading three bytes from the framebuffer:
BUG: unable to handle page fault for address: ffffc90001ffffff RIP: 0010:smtcfb_read+0x230/0x3e0 Call Trace: vfs_read+0x198/0xa00 ? do_sys_openat2+0x27d/0x350 ? __fget_light+0x54/0x340 ksys_read+0xce/0x190 do_syscall_64+0x43/0x90
Fix it by removing the open-coded endianess fixup-code and by moving the pointer post decrement out the fb_readl() function.
--- drivers/video/fbdev/sm712fb.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-)
drivers/video/fbdev/sm712fb.c +7 -18
@@ -1047,7 +1047,7 @@ static ssize_t smtcfb_read(struct fb_infif (count + p > total_size) count = total_size - p; - buffer =kmalloc ((count >PAGE_SIZE ) ?PAGE_SIZE : count,GFP_KERNEL ); + buffer =kmalloc (PAGE_SIZE ,GFP_KERNEL );if (!buffer)return -ENOMEM ;
@@ -1059,25 +1059,14 @@ static ssize_t smtcfb_read(struct fb_infwhile (count) { c = (count >PAGE_SIZE ) ?PAGE_SIZE : count; dst = buffer; -for (i = c >>2 ; i--;) { - *dst =fb_readl (src++); - *dst =big_swap (*dst); +for (i = (c +3 ) >>2 ; i--;) { +u32 val; + + val =fb_readl (src); + *dst =big_swap (val); + src++; dst++; } -if (c &3 ) { -u8 *dst8 = (u8 *)dst; -u8 __iomem *src8 = (u8 __iomem *)src; - -for (i = c &3 ; i--;) { -if (i &1 ) { - *dst8++ =fb_readb (++src8); - }else { - *dst8++ =fb_readb (--src8); - src8 +=2 ; - } - } - src = (u32 __iomem *)src8; - }if (copy_to_user (buf, buffer, c)) { err = -EFAULT ;
Greg Kroah-Hartman
maintainerPATCH 144/913 video: fbdev: atari: Atari 2 bpp (STe) palette bugfix
In reply to Greg Kroah-HartmanFrom: Michael Schmitz <[email protected]>
commit c8be5edbd36ceed2ff3d6b8f8e40643c3f396ea3 upstream.
The code to set the shifter STe palette registers has a long standing operator precedence bug, manifesting as colors set on a 2 bits per pixel frame buffer coming up with a distinctive blue tint.
Add parentheses around the calculation of the per-color palette data before shifting those into their respective bit field position.
This bug goes back a long way (2.4 days at the very least) so there won't be a Fixes: tag.
Tested on ARAnyM as well on Falcon030 hardware.
--- drivers/video/fbdev/atafb.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/video/fbdev/atafb.c +6 -6
@@ -1683,9 +1683,9 @@ static int falcon_setcolreg(unsigned int ((blue & 0xfc00) >> 8));if (regno <16 ) { shifter_tt.color_reg[regno] = - (((red &0xe000 ) >>13 ) | ((red &0x1000 ) >>12 ) <<8 ) | - (((green &0xe000 ) >>13 ) | ((green &0x1000 ) >>12 ) <<4 ) | - ((blue &0xe000 ) >>13 ) | ((blue &0x1000 ) >>12 ); + ((((red &0xe000 ) >>13 ) | ((red &0x1000 ) >>12 )) <<8 ) | + ((((green &0xe000 ) >>13 ) | ((green &0x1000 ) >>12 )) <<4 ) | + ((blue &0xe000 ) >>13 ) | ((blue &0x1000 ) >>12 ); ((u32 *)info->pseudo_palette)[regno] = ((red &0xf800 ) | ((green &0xfc00 ) >>5 ) | ((blue &0xf800 ) >>11 ));
@@ -1971,9 +1971,9 @@ static int stste_setcolreg(unsigned int green >>=12 ;if (ATARIHW_PRESENT (EXTD_SHIFTER )) shifter_tt.color_reg[regno] = - (((red &0xe ) >>1 ) | ((red &1 ) <<3 ) <<8 ) | - (((green &0xe ) >>1 ) | ((green &1 ) <<3 ) <<4 ) | - ((blue &0xe ) >>1 ) | ((blue &1 ) <<3 ); + ((((red &0xe ) >>1 ) | ((red &1 ) <<3 )) <<8 ) | + ((((green &0xe ) >>1 ) | ((green &1 ) <<3 )) <<4 ) | + ((blue &0xe ) >>1 ) | ((blue &1 ) <<3 );else shifter_tt.color_reg[regno] = ((red & 0xe) << 7) |
Greg Kroah-Hartman
maintainerPATCH 145/913 rfkill: make new event layout opt-in
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
commit 54f586a9153201c6cff55e1f561990c78bd99aa7 upstream.
Again new complaints surfaced that we had broken the ABI here, although previously all the userspace tools had agreed that it was their mistake and fixed it. Yet now there are cases (e.g. RHEL) that want to run old userspace with newer kernels, and thus are broken.
Since this is a bit of a whack-a-mole thing, change the whole extensibility scheme of rfkill to no longer just rely on the message lengths, but instead require userspace to opt in via a new ioctl to a given maximum event size that it is willing to understand.
By default, set that to RFKILL_EVENT_SIZE_V1 (8), so that the behaviour for userspace not calling the ioctl will look as if it's just running on an older kernel.
--- include/uapi/linux/rfkill.h | 14 +++++++++++- net/rfkill/core.c | 48 +++++++++++++++++++++++++++++++------------- 2 files changed, 46 insertions(+), 16 deletions(-)
include/uapi/linux/rfkill.h +12 -2
@@ -159,8 +159,16 @@ struct rfkill_event_ext {* old behaviour for all userspace, unless it explicitly opts in to the * rules outlined here by using the new &struct rfkill_event_ext. * -* Userspace using &struct rfkill_event_ext must adhere to the following -* rules +* Additionally, some other userspace (bluez, g-s-d) was reading with a +* large size but as streaming reads rather than message-based, or with +* too strict checks for the returned size. So eventually, we completely +* reverted this, and extended messages need to be opted in to by using +* an ioctl: +* +* ioctl(fd, RFKILL_IOCTL_MAX_SIZE, sizeof(struct rfkill_event_ext)); +* +* Userspace using &struct rfkill_event_ext and the ioctl must adhere to +* the following rules: * * 1. accept short writes, optionally using them to detect that it's * running on an older kernel;
@@ -175,6 +183,8 @@ struct rfkill_event_ext {#define RFKILL_IOC_MAGIC 'R'#define RFKILL_IOC_NOINPUT 1#define RFKILL_IOCTL_NOINPUT _IO(RFKILL_IOC_MAGIC, RFKILL_IOC_NOINPUT) +#define RFKILL_IOC_MAX_SIZE 2 +#define RFKILL_IOCTL_MAX_SIZE _IOW(RFKILL_IOC_MAGIC, RFKILL_IOC_EXT_SIZE, __u32)/* and that's all userspace gets */
net/rfkill/core.c +34 -14
105 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 146/913 ARM: dts: at91: sama7g5: Remove unused properties in i2c nodes
In reply to Greg Kroah-HartmanFrom: Tudor Ambarus <[email protected]>
commit cbb92a7717d2e1c512b7e81c6b22c7298b58a881 upstream.
The "atmel,use-dma-rx", "atmel,use-dma-rx" dt properties are not used by the i2c-at91 driver, nor they are defined in the bindings file, thus remove them.
--- arch/arm/boot/dts/sama7g5.dtsi | 6 ------ 1 file changed, 6 deletions(-)
arch/arm/boot/dts/sama7g5.dtsi +0 -6
@@ -319,8 +319,6 @@ dmas = <&dma0 AT91_XDMAC_DT_PERID(7)>, <&dma0 AT91_XDMAC_DT_PERID(8)>; dma-names = "rx", "tx"; - atmel,use-dma-rx; - atmel,use-dma-tx; status = "disabled"; }; };
@@ -485,8 +483,6 @@ dmas = <&dma0 AT91_XDMAC_DT_PERID(21)>, <&dma0 AT91_XDMAC_DT_PERID(22)>; dma-names = "rx", "tx"; - atmel,use-dma-rx; - atmel,use-dma-tx; status = "disabled"; }; };
@@ -511,8 +507,6 @@ dmas = <&dma0 AT91_XDMAC_DT_PERID(23)>, <&dma0 AT91_XDMAC_DT_PERID(24)>; dma-names = "rx", "tx"; - atmel,use-dma-rx; - atmel,use-dma-tx; status = "disabled"; }; };
Greg Kroah-Hartman
maintainerPATCH 147/913 ARM: dts: at91: sama5d2: Fix PMERRLOC resource size
In reply to Greg Kroah-HartmanFrom: Tudor Ambarus <[email protected]>
commit 0fb578a529ac7aca326a9fa475b4a6f58a756fda upstream.
PMERRLOC resource size was set to 0x100, which resulted in HSMC_ERRLOCx register being truncated to offset x = 21, causing error correction to fail if more than 22 bit errors and if 24 or 32 bit error correction was supported.
--- arch/arm/boot/dts/sama5d2.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/sama5d2.dtsi +1 -1
@@ -413,7 +413,7 @@ pmecc: ecc-engine@f8014070 { compatible = "atmel,sama5d2-pmecc"; reg = <0xf8014070 0x490>, - <0xf8014500 0x100>; + <0xf8014500 0x200>; }; };
Greg Kroah-Hartman
maintainerPATCH 148/913 ARM: dts: exynos: fix UART3 pins configuration in Exynos5250
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit 372d7027fed43c8570018e124cf78b89523a1f8e upstream.
The gpa1-4 pin was put twice in UART3 pin configuration of Exynos5250, instead of proper pin gpa1-5.
--- arch/arm/boot/dts/exynos5250-pinctrl.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/exynos5250-pinctrl.dtsi +1 -1
@@ -260,7 +260,7 @@ }; uart3_data: uart3-data { - samsung,pins = "gpa1-4", "gpa1-4"; + samsung,pins = "gpa1-4", "gpa1-5"; samsung,pin-function = <EXYNOS_PIN_FUNC_2>; samsung,pin-pud = <EXYNOS_PIN_PULL_NONE>; samsung,pin-drv = <EXYNOS4_PIN_DRV_LV1>;
Greg Kroah-Hartman
maintainerPATCH 149/913 ARM: dts: exynos: add missing HDMI supplies on SMDK5250
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit 60a9914cb2061ba612a3f14f6ad329912b486360 upstream.
Add required VDD supplies to HDMI block on SMDK5250. Without them, the HDMI driver won't probe. Because of lack of schematics, use same supplies as on Arndale 5250 board (voltage matches).
--- arch/arm/boot/dts/exynos5250-smdk5250.dts | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/boot/dts/exynos5250-smdk5250.dts +3 -0
@@ -118,6 +118,9 @@ status = "okay"; ddc = <&i2c_2>; hpd-gpios = <&gpx3 7 GPIO_ACTIVE_HIGH>; + vdd-supply = <&ldo8_reg>; + vdd_osc-supply = <&ldo10_reg>; + vdd_pll-supply = <&ldo8_reg>; }; &i2c_0 {
Greg Kroah-Hartman
maintainerPATCH 150/913 ARM: dts: exynos: add missing HDMI supplies on SMDK5420
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit 453a24ded415f7fce0499c6b0a2c7b28f84911f2 upstream.
Add required VDD supplies to HDMI block on SMDK5420. Without them, the HDMI driver won't probe. Because of lack of schematics, use same supplies as on Arndale Octa and Odroid XU3 boards (voltage matches).
--- arch/arm/boot/dts/exynos5420-smdk5420.dts | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/boot/dts/exynos5420-smdk5420.dts +3 -0
@@ -124,6 +124,9 @@ hpd-gpios = <&gpx3 7 GPIO_ACTIVE_HIGH>; pinctrl-names = "default"; pinctrl-0 = <&hdmi_hpd_irq>; + vdd-supply = <&ldo6_reg>; + vdd_osc-supply = <&ldo7_reg>; + vdd_pll-supply = <&ldo6_reg>; }; &hsi2c_4 {
Greg Kroah-Hartman
maintainerPATCH 151/913 mgag200 fix memmapsl configuration in GCTL6 register
In reply to Greg Kroah-HartmanFrom: Jocelyn Falempe <[email protected]>
commit 028a73e10705af1ffd51f2537460f616dc58680e upstream.
On some servers with MGA G200_SE_A (rev 42), booting with Legacy BIOS, the hardware hangs when using kdump and kexec into the kdump kernel. This happens when the uncompress code tries to write "Decompressing Linux" to the VGA Console.
It can be reproduced by writing to the VGA console (0xB8000) after booting to graphic mode, it generates the following error:
kernel:NMI: PCI system error (SERR) for reason a0 on CPU 0. kernel:Dazed and confused, but trying to continue
The root cause is the configuration of the MGA GCTL6 register
According to the GCTL6 register documentation:
bit 0 is gcgrmode:
0: Enables alpha mode, and the character generator addressing system is
activated.
1: Enables graphics mode, and the character addressing system is not
used.
bit 1 is chainodd even:
0: The A0 signal of the memory address bus is used during system memory
addressing.
1: Allows A0 to be replaced by either the A16 signal of the system
address (ifmemmapsl is ‘00’), or by the hpgoddev (MISC<5>, odd/even page select) field, described on page 3-294).
bit 3-2 are memmapsl:
Memory map select bits 1 and 0. VGA.
These bits select where the video memory is mapped, as shown below:
00 => A0000h - BFFFFh
01 => A0000h - AFFFFh
10 => B0000h - B7FFFh
11 => B8000h - BFFFFhbit 7-4 are reserved.
Current code set it to 0x05 => memmapsl to b01 => 0xa0000 (graphic mode) But on x86, the VGA console is at 0xb8000 (text mode)
In arch/x86/boot/compressed/misc.c debug strings are written to 0xb8000 As the driver doesn't use this mapping at 0xa0000, it is safe to set it to 0xb8000 instead, to avoid kernel hang on G200_SE_A rev42, with kexec/kdump.
Thus changing the value 0x05 to 0x0d
--- drivers/gpu/drm/mgag200/mgag200_mode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/mgag200/mgag200_mode.c +4 -1
@@ -529,7 +529,10 @@ static void mgag200_set_format_regs(struWREG_GFX (3 ,0x00 );WREG_GFX (4 ,0x00 );WREG_GFX (5 ,0x40 ); -WREG_GFX (6 ,0x05 ); +/* GCTL6 should be 0x05, but we configure memmapsl to 0xb8000 (text mode), +* so that it doesn't hang when running kexec/kdump on G200_SE rev42. +*/ +WREG_GFX (6 ,0x0d );WREG_GFX (7 ,0x0f );WREG_GFX (8 ,0x0f );
Greg Kroah-Hartman
maintainerPATCH 152/913 carl9170: fix missing bit-wise or operator for tx_params
In reply to Greg Kroah-HartmanFrom: Colin Ian King <[email protected]>
commit 02a95374b5eebdbd3b6413fd7ddec151d2ea75a1 upstream.
Currently tx_params is being re-assigned with a new value and the previous setting IEEE80211_HT_MCS_TX_RX_DIFF is being overwritten. The assignment operator is incorrect, the original intent was to bit-wise or the value in. Fix this by replacing the = operator with |= instead.
Kudos to Christian Lamparter for suggesting the correct fix.
--- drivers/net/wireless/ath/carl9170/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/carl9170/main.c +1 -1
@@ -1915,7 +1915,7 @@ static int carl9170_parse_eeprom(structWARN_ON (!(tx_streams >=1 && tx_streams <=IEEE80211_HT_MCS_TX_MAX_STREAMS )); - tx_params = (tx_streams -1 ) << + tx_params |= (tx_streams -1 ) <<IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT ; carl9170_band_2GHz.ht_cap.mcs.tx_params |= tx_params;
Greg Kroah-Hartman
maintainerPATCH 153/913 pstore: Dont use semaphores in always-atomic-context code
In reply to Greg Kroah-HartmanFrom: Jann Horn <[email protected]>
commit 8126b1c73108bc691f5643df19071a59a69d0bc6 upstream.
pstore_dump() is *always* invoked in atomic context (nowadays in an RCU read-side critical section, before that under a spinlock). It doesn't make sense to try to use semaphores here.
This is mostly a revert of commit ea84b580b955 ("pstore: Convert buf_lock to semaphore"), except that two parts aren't restored back exactly as they were:
- keep the lock initialization in pstore_register
- in efi_pstore_write(), always set the "block" flag to false
- omit "is_locked", that was unnecessary since
commit 959217c84c27 ("pstore: Actually give up during locking failure")
- fix the bailout message
The actual problem that the buggy commit was trying to address may have been that the use of preemptible() in efi_pstore_write() was wrong - it only looks at preempt_count() and the state of IRQs, but __rcu_read_lock() doesn't touch either of those under CONFIG_PREEMPT_RCU. (Sidenote: CONFIG_PREEMPT_RCU means that the scheduler can preempt tasks in RCU read-side critical sections, but you're not allowed to actively block/reschedule.)
Lockdep probably never caught the problem because it's very rare that you actually hit the contended case, so lockdep always just sees the down_trylock(), not the down_interruptible(), and so it can't tell that there's a problem.
--- drivers/firmware/efi/efi-pstore.c | 2 +- fs/pstore/platform.c | 38 ++++++++++++++++++-------------------- include/linux/pstore.h | 6 +++--- 3 files changed, 22 insertions(+), 24 deletions(-)
drivers/firmware/efi/efi-pstore.c +1 -1
@@ -266,7 +266,7 @@ static int efi_pstore_write(struct pstor efi_name[i] = name[i]; ret =efivar_entry_set_safe (efi_name, vendor,PSTORE_EFI_ATTRIBUTES , -preemptible (), record->size, record->psi->buf); + false, record->size, record->psi->buf);if (record->reason ==KMSG_DUMP_OOPS &&try_module_get (THIS_MODULE ))if (!schedule_work (&efivar_work))
fs/pstore/platform.c +18 -20
@@ -143,21 +143,22 @@ static void pstore_timer_kick(void)mod_timer (&pstore_timer, jiffies +msecs_to_jiffies (pstore_update_ms)); } -/* -* Should pstore_dump() wait for a concurrent pstore_dump()? If -* not, the current pstore_dump() will report a failure to dump -* and return. -*/ -static bool pstore_cannot_wait (enum kmsg_dump_reason reason) +static bool pstore_cannot_block_path (enum kmsg_dump_reason reason) { -/* In NMI path, pstore shouldn't block regardless of reason. */ +/* +* In case of NMI path, pstore shouldn't be blocked +* regardless of reason. +*/ if (in_nmi ())return true;switch (reason) {/* In panic case, other cpus are stopped by smp_send_stop(). */ case KMSG_DUMP_PANIC : -/* Emergency restart shouldn't be blocked. */ +/* +* Emergency restart shouldn't be blocked by spinning on +* pstore_info::buf_lock. +*/ case KMSG_DUMP_EMERG :return true;default :
@@ -389,21 +390,19 @@ static void pstore_dump(struct kmsg_dumpunsigned long total =0 ;const char *why;unsigned int part =1 ; +unsigned long flags =0 ;int ret; why =kmsg_dump_reason_str (reason); -if (down_trylock (&psinfo->buf_lock)) { -/* Failed to acquire lock: give up if we cannot wait. */ -if (pstore_cannot_wait (reason)) { -pr_err ("dump skipped in %s path: may corrupt error record\n" , -in_nmi () ?"NMI" : why); -return ; - } -if (down_interruptible (&psinfo->buf_lock)) { -pr_err ("could not grab semaphore?!\n" ); +if (pstore_cannot_block_path (reason)) { +if (!spin_trylock_irqsave (&psinfo->buf_lock, flags)) { +pr_err ("dump skipped in %s path because of concurrent dump\n" , +in_nmi () ?"NMI" : why);return ; } + }else { +spin_lock_irqsave (&psinfo->buf_lock, flags); }kmsg_dump_rewind (&iter);
@@ -467,8 +466,7 @@ static void pstore_dump(struct kmsg_dump total += record.size; part++; } - -up (&psinfo->buf_lock); +spin_unlock_irqrestore (&psinfo->buf_lock, flags); }static struct kmsg_dumper pstore_dumper = {
@@ -594,7 +592,7 @@ int pstore_register(struct pstore_info * psi->write_user = pstore_write_user_compat; psinfo = psi;mutex_init (&psinfo->read_mutex); -sema_init (&psinfo->buf_lock,1 ); +spin_lock_init (&psinfo->buf_lock);if (psi->flags &PSTORE_FLAGS_DMESG )allocate_buf_for_compression ();
include/linux/pstore.h +3 -3
@@ -14,7 +14,7 @@#include <linux/errno.h> #include <linux/kmsg_dump.h> #include <linux/mutex.h> -#include <linux/semaphore.h> +#include <linux/spinlock.h> #include <linux/time.h> #include <linux/types.h>
@@ -87,7 +87,7 @@ struct pstore_record {* @owner: module which is responsible for this backend driver * @name: name of the backend driver * -* @buf_lock: semaphore to serialize access to @buf +* @buf_lock: spinlock to serialize access to @buf * @buf: preallocated crash dump buffer * @bufsize: size of @buf available for crash dump bytes (must match * smallest number of bytes available for writing to a
@@ -178,7 +178,7 @@ struct pstore_info {struct module *owner;const char *name; -struct semaphore buf_lock; +spinlock_t buf_lock;char *buf;size_t bufsize;
Greg Kroah-Hartman
maintainerPATCH 154/913 thermal: int340x: Increase bitmap size
In reply to Greg Kroah-HartmanFrom: Srinivas Pandruvada <[email protected]>
commit 668f69a5f863b877bc3ae129efe9a80b6f055141 upstream.
The number of policies are 10, so can't be supported by the bitmap size of u8.
Even though there are no platfoms with these many policies, but for correctness increase to u32.
--- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +1 -1
@@ -53,7 +53,7 @@ struct int3400_thermal_priv {struct art *arts;int trt_count;struct trt *trts; -u8 uuid_bitmap; +u32 uuid_bitmap;int rel_misc_dev_res;int current_uuid_index;char *data_vault;
Greg Kroah-Hartman
maintainerPATCH 155/913 lib/raid6/test: fix multiple definition linking error
In reply to Greg Kroah-HartmanFrom: Dirk Müller <[email protected]>
commit a5359ddd052860bacf957e65fe819c63e974b3a6 upstream.
GCC 10+ defaults to -fno-common, which enforces proper declaration of external references using "extern". without this change a link would fail with:
lib/raid6/test/algos.c:28: multiple definition of `raid6_call'; lib/raid6/test/test.c:22: first defined here
the pq.h header that is included already includes an extern declaration so we can just remove the redundant one here.
--- lib/raid6/test/test.c | 1 - 1 file changed, 1 deletion(-)
lib/raid6/test/test.c +0 -1
@@ -19,7 +19,6 @@#define NDISKS 16/* Including P and Q */ const char raid6_empty_zero_page[PAGE_SIZE] __attribute__((aligned(PAGE_SIZE))); -struct raid6_calls raid6_call;char *dataptrs[NDISKS ]; char data[NDISKS][PAGE_SIZE] __attribute__((aligned(PAGE_SIZE)));
Greg Kroah-Hartman
maintainerPATCH 156/913 exec: Force single empty string when argv is empty
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit dcd46d897adb70d63e025f175a00a89797d31a43 upstream.
Quoting[1] Ariadne Conill:
"In several other operating systems, it is a hard requirement that the second argument to execve(2) be the name of a program, thus prohibiting a scenario where argc < 1. POSIX 2017 also recommends this behaviour, but it is not an explicit requirement[2]:
The argument arg0 should point to a filename string that is associated with the process being started by one of the exec functions.
...
Interestingly, Michael Kerrisk opened an issue about this in 2008[3], but there was no consensus to support fixing this issue then. Hopefully now that CVE-2021-4034 shows practical exploitative use[4] of this bug in a shellcode, we can reconsider.
This issue is being tracked in the KSPP issue tracker[5]."
While the initial code searches[6][7] turned up what appeared to be mostly corner case tests, trying to that just reject argv == NULL (or an immediately terminated pointer list) quickly started tripping[8] existing userspace programs.
The next best approach is forcing a single empty string into argv and adjusting argc to match. The number of programs depending on argc == 0 seems a smaller set than those calling execve with a NULL argv.
Account for the additional stack space in bprm_stack_limits(). Inject an empty string when argc == 0 (and set argc = 1). Warn about the case so userspace has some notice about the change:
process './argc0' launched './argc0' with NULL argv: empty string added
Additionally WARN() and reject NULL argv usage for kernel threads.
[1] https://lore.kernel.org/lkml/[email protected]/
[2] https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
[3] https://bugzilla.kernel.org/show_bug.cgi?id=8408
[4] https://www.qualys.com/2022/01/25/cve-2021-4034/pwnkit.txt
[5] https://github.com/KSPP/linux/issues/176
[6] https://codesearch.debian.net/search?q=execve%5C+*%5C%28%5B%5E%2C%5D%2B%2C+*NULL&literal=0
[7] https://codesearch.debian.net/search?q=execlp%3F%5Cs*%5C%28%5B%5E%2C%5D%2B%2C%5Cs*NULL&literal=0
[8] https://lore.kernel.org/lkml/20220131144352.GE16385@xsang-OptiPlex-9020/
--- fs/exec.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
fs/exec.c +25 -1
@@ -494,8 +494,14 @@ static int bprm_stack_limits(struct linu* the stack. They aren't stored until much later when we can't * signal to the parent that the child has run out of stack space. * Instead, calculate it here so it's possible to fail gracefully. +* +* In the case of argc = 0, make sure there is space for adding a +* empty string (which will bump argc to 1), to ensure confused +* userspace programs don't start processing from argv[1], thinking +* argc can never be 0, to keep them from walking envp by accident. +* See do_execveat_common(). */ - ptr_size = (bprm->argc + bprm->envc) *sizeof (void *); + ptr_size = (max (bprm->argc,1 ) + bprm->envc) *sizeof (void *);if (limit <= ptr_size)return -E2BIG ; limit -= ptr_size;
@@ -1895,6 +1901,9 @@ static int do_execveat_common(int fd, st } retval =count (argv,MAX_ARG_STRINGS ); +if (retval ==0 ) +pr_warn_once ("process '%s' launched '%s' with NULL argv: empty string added\n" , + current->comm, bprm->filename);if (retval <0 ) goto out_free; bprm->argc = retval;
@@ -1921,6 +1930,19 @@ static int do_execveat_common(int fd, stif (retval <0 ) goto out_free; +/* +* When argv is empty, add an empty string ("") as argv[0] to +* ensure confused userspace programs that start processing +* from argv[1] won't end up walking envp. See also +* bprm_stack_limits(). +*/ +if (bprm->argc ==0 ) { + retval =copy_string_kernel ("" , bprm); +if (retval <0 ) + goto out_free; + bprm->argc =1 ; + } + retval =bprm_execve (bprm, fd, filename, flags); out_free:free_bprm (bprm);
@@ -1949,6 +1971,8 @@ int kernel_execve(const char *kernel_fil } retval =count_strings_kernel (argv); +if (WARN_ON_ONCE (retval ==0 )) + retval = -EINVAL ;if (retval <0 ) goto out_free; bprm->argc = retval;
Greg Kroah-Hartman
maintainerPATCH 157/913 crypto: rsa-pkcs1pad - only allow with rsa
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit 9b30430ea356f237945e52f8a3a42158877bd5a9 upstream.
The pkcs1pad template can be instantiated with an arbitrary akcipher algorithm, which doesn't make sense; it is specifically an RSA padding scheme. Make it check that the underlying algorithm really is RSA.
--- crypto/rsa-pkcs1pad.c | 5 +++++ 1 file changed, 5 insertions(+)
crypto/rsa-pkcs1pad.c +5 -0
@@ -621,6 +621,11 @@ static int pkcs1pad_create(struct crypto rsa_alg =crypto_spawn_akcipher_alg (&ctx->spawn); +if (strcmp (rsa_alg->base.cra_name,"rsa" ) !=0 ) { + err = -EINVAL ; + goto err_free_inst; + } + err = -ENAMETOOLONG ; hash_name =crypto_attr_alg_name (tb[2 ]);if (IS_ERR (hash_name)) {
Greg Kroah-Hartman
maintainerPATCH 158/913 crypto: rsa-pkcs1pad - correctly get hash from source scatterlist
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit e316f7179be22912281ce6331d96d7c121fb2b17 upstream.
Commit c7381b012872 ("crypto: akcipher - new verify API for public key algorithms") changed akcipher_alg::verify to take in both the signature and the actual hash and do the signature verification, rather than just return the hash expected by the signature as was the case before. To do this, it implemented a hack where the signature and hash are concatenated with each other in one scatterlist.
Obviously, for this to work correctly, akcipher_alg::verify needs to correctly extract the two items from the scatterlist it is given. Unfortunately, it doesn't correctly extract the hash in the case where the signature is longer than the RSA key size, as it assumes that the signature's length is equal to the RSA key size. This causes a prefix of the hash, or even the entire hash, to be taken from the *signature*.
(Note, the case of a signature longer than the RSA key size should not be allowed in the first place; a separate patch will fix that.)
It is unclear whether the resulting scheme has any useful security properties.
Fix this by correctly extracting the hash from the scatterlist.
--- crypto/rsa-pkcs1pad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/rsa-pkcs1pad.c +1 -1
@@ -495,7 +495,7 @@ static int pkcs1pad_verify_complete(strusg_nents_for_len (req->src, req->src_len + req->dst_len), req_ctx->out_buf + ctx->key_size, - req->dst_len, ctx->key_size); + req->dst_len, req->src_len);/* Do the actual verification step. */ if (memcmp (req_ctx->out_buf + ctx->key_size, out_buf + pos, req->dst_len) !=0 )
Greg Kroah-Hartman
maintainerPATCH 159/913 crypto: rsa-pkcs1pad - restore signature length check
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit d3481accd974541e6a5d6a1fb588924a3519c36e upstream.
RSA PKCS#1 v1.5 signatures are required to be the same length as the RSA key size. RFC8017 specifically requires the verifier to check this
(https://datatracker.ietf.org/doc/html/rfc8017#section-8.2.2).
Commit a49de377e051 ("crypto: Add hash param to pkcs1pad") changed the kernel to allow longer signatures, but didn't explain this part of the change; it seems to be unrelated to the rest of the commit.
Revert this change, since it doesn't appear to be correct.
We can be pretty sure that no one is relying on overly-long signatures (which would have to be front-padded with zeroes) being supported, given that they would have been broken since commit c7381b012872 ("crypto: akcipher - new verify API for public key algorithms").
--- crypto/rsa-pkcs1pad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/rsa-pkcs1pad.c +1 -1
@@ -538,7 +538,7 @@ static int pkcs1pad_verify(struct akciphif (WARN_ON (req->dst) ||WARN_ON (!req->dst_len) || - !ctx->key_size || req->src_len < ctx->key_size) + !ctx->key_size || req->src_len != ctx->key_size)return -EINVAL ; req_ctx->out_buf =kmalloc (ctx->key_size + req->dst_len,GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 160/913 crypto: rsa-pkcs1pad - fix buffer overread in pkcs1pad_verify_complete()
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
commit a24611ea356c7f3f0ec926da11b9482ac1f414fd upstream.
Before checking whether the expected digest_info is present, we need to check that there are enough bytes remaining.
--- crypto/rsa-pkcs1pad.c | 2 ++ 1 file changed, 2 insertions(+)
crypto/rsa-pkcs1pad.c +2 -0
@@ -476,6 +476,8 @@ static int pkcs1pad_verify_complete(stru pos++;if (digest_info) { +if (digest_info->size > dst_len - pos) + goto done;if (crypto_memneq (out_buf + pos, digest_info->data, digest_info->size)) goto done;
Greg Kroah-Hartman
maintainerPATCH 161/913 bcache: fixup multiple threads crash
In reply to Greg Kroah-HartmanFrom: Mingzhe Zou <[email protected]>
commit 887554ab96588de2917b6c8c73e552da082e5368 upstream.
When multiple threads to check btree nodes in parallel, the main thread wait for all threads to stop or CACHE_SET_IO_DISABLE flag:
wait_event_interruptible(check_state->wait,
atomic_read(&check_state->started) == 0 ||
test_bit(CACHE_SET_IO_DISABLE, &c->flags));However, the bch_btree_node_read and bch_btree_node_read_done maybe call bch_cache_set_error, then the CACHE_SET_IO_DISABLE will be set. If the flag already set, the main thread return error. At the same time, maybe some threads still running and read NULL pointer, the kernel will crash.
This patch change the event wait condition, the main thread must wait for all threads to stop.
--- drivers/md/bcache/btree.c | 6 ++++-- drivers/md/bcache/writeback.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/md/bcache/btree.c +4 -2
@@ -2060,9 +2060,11 @@ int bch_btree_check(struct cache_set *c) } } +/* +* Must wait for all threads to stop. +*/ wait_event_interruptible (check_state->wait, -atomic_read (&check_state->started) ==0 || -test_bit (CACHE_SET_IO_DISABLE , &c->flags)); +atomic_read (&check_state->started) ==0 );for (i =0 ; i < check_state->total_threads; i++) {if (check_state->infos[i].result) {
drivers/md/bcache/writeback.c +4 -2
@@ -998,9 +998,11 @@ void bch_sectors_dirty_init(struct bcach } } +/* +* Must wait for all threads to stop. +*/ wait_event_interruptible (state->wait, -atomic_read (&state->started) ==0 || -test_bit (CACHE_SET_IO_DISABLE , &c->flags)); +atomic_read (&state->started) ==0 ); out:kfree (state);
Greg Kroah-Hartman
maintainerPATCH 162/913 PM: domains: Fix sleep-in-atomic bug caused by genpd_debug_remove()
In reply to Greg Kroah-HartmanFrom: Shawn Guo <[email protected]>
commit f6bfe8b5b2c2a5ac8bd2fc7bca3706e6c3fc26d8 upstream.
When a genpd with GENPD_FLAG_IRQ_SAFE gets removed, the following sleep-in-atomic bug will be seen, as genpd_debug_remove() will be called with a spinlock being held.
[ 0.029183] BUG: sleeping function called from invalid context at kernel/locking/rwsem.c:1460 [ 0.029204] in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 1, name: swapper/0 [ 0.029219] preempt_count: 1, expected: 0 [ 0.029230] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.17.0-rc4+ #489 [ 0.029245] Hardware name: Thundercomm TurboX CM2290 (DT) [ 0.029256] Call trace: [ 0.029265] dump_backtrace.part.0+0xbc/0xd0 [ 0.029285] show_stack+0x3c/0xa0 [ 0.029298] dump_stack_lvl+0x7c/0xa0 [ 0.029311] dump_stack+0x18/0x34 [ 0.029323] __might_resched+0x10c/0x13c [ 0.029338] __might_sleep+0x4c/0x80 [ 0.029351] down_read+0x24/0xd0 [ 0.029363] lookup_one_len_unlocked+0x9c/0xcc [ 0.029379] lookup_positive_unlocked+0x10/0x50 [ 0.029392] debugfs_lookup+0x68/0xac [ 0.029406] genpd_remove.part.0+0x12c/0x1b4 [ 0.029419] of_genpd_remove_last+0xa8/0xd4 [ 0.029434] psci_cpuidle_domain_probe+0x174/0x53c [ 0.029449] platform_probe+0x68/0xe0 [ 0.029462] really_probe+0x190/0x430 [ 0.029473] __driver_probe_device+0x90/0x18c [ 0.029485] driver_probe_device+0x40/0xe0 [ 0.029497] __driver_attach+0xf4/0x1d0 [ 0.029508] bus_for_each_dev+0x70/0xd0 [ 0.029523] driver_attach+0x24/0x30 [ 0.029534] bus_add_driver+0x164/0x22c [ 0.029545] driver_register+0x78/0x130 [ 0.029556] __platform_driver_register+0x28/0x34 [ 0.029569] psci_idle_init_domains+0x1c/0x28 [ 0.029583] do_one_initcall+0x50/0x1b0 [ 0.029595] kernel_init_freeable+0x214/0x280 [ 0.029609] kernel_init+0x2c/0x13c [ 0.029622] ret_from_fork+0x10/0x20
It doesn't seem necessary to call genpd_debug_remove() with the lock, so move it out from locking to fix the problem.
--- drivers/base/power/domain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/power/domain.c +1 -1
@@ -2058,9 +2058,9 @@ static int genpd_remove(struct generic_pkfree (link); } -genpd_debug_remove (genpd);list_del (&genpd->gpd_list_node);genpd_unlock (genpd); +genpd_debug_remove (genpd);cancel_work_sync (&genpd->power_off_work);if (genpd_is_cpu_domain (genpd))free_cpumask_var (genpd->cpus);
Greg Kroah-Hartman
maintainerPATCH 163/913 DEC: Limit PMAX memory probing to R3k systems
In reply to Greg Kroah-HartmanFrom: Maciej W. Rozycki <[email protected]>
commit 244eae91a94c6dab82b3232967d10eeb9dfa21c6 upstream.
Recent tightening of the opcode table in binutils so as to consistently disallow the assembly or disassembly of CP0 instructions not supported by the processor architecture chosen has caused a regression like below:
arch/mips/dec/prom/locore.S: Assembler messages:arch/mips/dec/prom/locore.S:29: Error: opcode not supported on this processor: r4600 (mips3) `rfe'
in a piece of code used to probe for memory with PMAX DECstation models, which have non-REX firmware. Those computers always have an R2000 CPU and consequently the exception handler used in memory probing uses the RFE instruction, which those processors use.
While adding 64-bit support this code was correctly excluded for 64-bit configurations, however it should have also been excluded for irrelevant 32-bit configurations. Do this now then, and only enable PMAX memory probing for R3k systems.
--- arch/mips/dec/prom/Makefile | 2 +- arch/mips/include/asm/dec/prom.h | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-)
arch/mips/dec/prom/Makefile +1 -1
@@ -6,4 +6,4 @@ lib-y += init.o memory.o cmdline.o identify.o console.o -lib-$(CONFIG_32BIT) += locore.o +lib-$(CONFIG_CPU_R3000) += locore.o
arch/mips/include/asm/dec/prom.h +5 -10
@@ -43,16 +43,11 @@*/ #define REX_PROM_MAGIC 0x30464354 -#ifdef CONFIG_64BIT - -#define prom_is_rex (magic) 1/* KN04 and KN05 are REX PROMs. */ - -#else /* !CONFIG_64BIT */ - -#define prom_is_rex (magic) ((magic) == REX_PROM_MAGIC) - -#endif /* !CONFIG_64BIT */ - +/* KN04 and KN05 are REX PROMs, so only do the check for R3k systems. */ +static inline bool prom_is_rex (u32 magic) +{ +return !IS_ENABLED (CONFIG_CPU_R3000 ) || magic ==REX_PROM_MAGIC ; +}/* * 3MIN/MAXINE PROM entry points for DS5000/1xx's, DS5000/xx's and
Greg Kroah-Hartman
maintainerPATCH 164/913 media: gpio-ir-tx: fix transmit with long spaces on Orange Pi PC
In reply to Greg Kroah-HartmanFrom: Sean Young <[email protected]>
commit 5ad05ecad4326ddaa26a83ba2233a67be24c1aaa upstream.
Calling udelay for than 1000us does not always yield the correct results.
--- drivers/media/rc/gpio-ir-tx.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/media/rc/gpio-ir-tx.c +21 -7
@@ -48,11 +48,29 @@ static int gpio_ir_tx_set_carrier(structreturn 0 ; } +static void delay_until (ktime_t until) +{ +/* +* delta should never exceed 0.5 seconds (IR_MAX_DURATION) and on +* m68k ndelay(s64) does not compile; so use s32 rather than s64. +*/ +s32 delta; + +while (true) { + delta =ktime_us_delta (until,ktime_get ()); +if (delta <=0 ) +return ; + +/* udelay more than 1ms may not work */ + delta =min (delta,1000 ); +udelay (delta); + } +} +static void gpio_ir_tx_unmodulated (struct gpio_ir *gpio_ir,uint *txbuf,uint count) {ktime_t edge; -s32 delta;int i;local_irq_disable ();
@@ -63,9 +81,7 @@ static void gpio_ir_tx_unmodulated(strucgpiod_set_value (gpio_ir->gpio, !(i %2 )); edge =ktime_add_us (edge, txbuf[i]); - delta =ktime_us_delta (edge,ktime_get ()); -if (delta >0 ) -udelay (delta); +delay_until (edge); }gpiod_set_value (gpio_ir->gpio,0 );
@@ -97,9 +113,7 @@ static void gpio_ir_tx_modulated(structif (i %2 ) {// space edge =ktime_add_us (edge, txbuf[i]); - delta =ktime_us_delta (edge,ktime_get ()); -if (delta >0 ) -udelay (delta); +delay_until (edge); }else {// pulse ktime_t last =ktime_add_us (edge, txbuf[i]);
Greg Kroah-Hartman
maintainerPATCH 165/913 media: venus: hfi_cmds: List HDR10 property as unsupported for v1 and v3
In reply to Greg Kroah-HartmanFrom: Stanimir Varbanov <[email protected]>
commit 22beb839f48d841ec75974872863dc253d37c21c upstream.
The HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI HFI property is not supported on Venus v1 and v3.
--- drivers/media/platform/qcom/venus/hfi_cmds.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/platform/qcom/venus/hfi_cmds.c +2 -0
@@ -1054,6 +1054,8 @@ static int pkt_session_set_property_1x(s pkt->shdr.hdr.size +=sizeof (u32) +sizeof (*info);break ; } +case HFI_PROPERTY_PARAM_VENC_HDR10_PQ_SEI : +return -ENOTSUPP ;/* FOLLOWING PROPERTIES ARE NOT IMPLEMENTED IN CORE YET */ case HFI_PROPERTY_CONFIG_BUFFER_REQUIREMENTS :
Greg Kroah-Hartman
maintainerPATCH 166/913 media: venus: venc: Fix h264 8x8 transform control
In reply to Greg Kroah-HartmanFrom: Stanimir Varbanov <[email protected]>
commit 61b3317dd424a3488b6754d7ff8301944d9d17d7 upstream.
During encoder driver open controls are initialized via a call to v4l2_ctrl_handler_setup which returns EINVAL error for V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM v4l2 control. The control default value is disabled and because of firmware limitations 8x8 transform cannot be disabled for the supported HIGH and CONSTRAINED_HIGH profiles.
To fix the issue change the control default value to enabled (this is fine because the firmware enables 8x8 transform for high and constrained_high profiles by default). Also, correct the checking of profile ids in s_ctrl from hfi to v4l2 ids.
--- drivers/media/platform/qcom/venus/venc.c | 4 ++-- drivers/media/platform/qcom/venus/venc_ctrls.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/media/platform/qcom/venus/venc.c +2 -2
@@ -604,8 +604,8 @@ static int venc_set_properties(struct ve ptype =HFI_PROPERTY_PARAM_VENC_H264_TRANSFORM_8X8 ; h264_transform.enable_type =0 ; -if (ctr->profile.h264 ==HFI_H264_PROFILE_HIGH || - ctr->profile.h264 ==HFI_H264_PROFILE_CONSTRAINED_HIGH ) +if (ctr->profile.h264 ==V4L2_MPEG_VIDEO_H264_PROFILE_HIGH || + ctr->profile.h264 ==V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH ) h264_transform.enable_type = ctr->h264_8x8_transform; ret =hfi_session_set_property (inst, ptype, &h264_transform);
drivers/media/platform/qcom/venus/venc_ctrls.c +3 -3
@@ -320,8 +320,8 @@ static int venc_op_s_ctrl(struct v4l2_ct ctr->intra_refresh_period = ctrl->val;break ;case V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM : -if (ctr->profile.h264 !=HFI_H264_PROFILE_HIGH && - ctr->profile.h264 !=HFI_H264_PROFILE_CONSTRAINED_HIGH ) +if (ctr->profile.h264 !=V4L2_MPEG_VIDEO_H264_PROFILE_HIGH && + ctr->profile.h264 !=V4L2_MPEG_VIDEO_H264_PROFILE_CONSTRAINED_HIGH )return -EINVAL ;/*
@@ -457,7 +457,7 @@ int venc_ctrl_init(struct venus_inst *in V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MIN_QP, 1, 51, 1, 1);v4l2_ctrl_new_std (&inst->ctrl_handler, &venc_ctrl_ops, -V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM ,0 ,1 ,1 ,0 ); +V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM ,0 ,1 ,1 ,1 );v4l2_ctrl_new_std (&inst->ctrl_handler, &venc_ctrl_ops,V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP ,1 ,51 ,1 ,1 );
Greg Kroah-Hartman
maintainerPATCH 167/913 media: davinci: vpif: fix unbalanced runtime PM get
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit 4a321de239213300a714fa0353a5f1272d381a44 upstream.
Make sure to balance the runtime PM usage counter on driver unbind.
--- drivers/media/platform/davinci/vpif.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/davinci/vpif.c +1 -0
@@ -496,6 +496,7 @@ static int vpif_probe(struct platform_destatic int vpif_remove (struct platform_device *pdev) { +pm_runtime_put (&pdev->dev);pm_runtime_disable (&pdev->dev);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 168/913 media: davinci: vpif: fix unbalanced runtime PM enable
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
commit d42b3ad105b5d3481f6a56bc789aa2b27aa09325 upstream.
Make sure to disable runtime PM before returning on probe errors.
--- drivers/media/platform/davinci/vpif.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/media/platform/davinci/vpif.c +9 -2
@@ -428,6 +428,7 @@ static int vpif_probe(struct platform_destatic struct resource *res, *res_irq;struct platform_device *pdev_capture, *pdev_display;struct device_node *endpoint =NULL ; +int ret; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); vpif_base =devm_ioremap_resource (&pdev->dev, res);
@@ -457,8 +458,8 @@ static int vpif_probe(struct platform_de res_irq =platform_get_resource (pdev,IORESOURCE_IRQ ,0 );if (!res_irq) {dev_warn (&pdev->dev,"Missing IRQ resource.\n" ); -pm_runtime_put (&pdev->dev); -return -EINVAL ; + ret = -EINVAL ; + goto err_put_rpm; } pdev_capture = devm_kzalloc(&pdev->dev, sizeof(*pdev_capture),
@@ -492,6 +493,12 @@ static int vpif_probe(struct platform_de }return 0 ; + +err_put_rpm: +pm_runtime_put (&pdev->dev); +pm_runtime_disable (&pdev->dev); + +return ret; }static int vpif_remove (struct platform_device *pdev)
Greg Kroah-Hartman
maintainerPATCH 169/913 btrfs: zoned: mark relocation as writing
In reply to Greg Kroah-HartmanFrom: Naohiro Aota <[email protected]>
commit ca5e4ea0beaec8bc674121838bf8614c089effb9 upstream.
There is a hung_task issue with running generic/068 on an SMR device. The hang occurs while a process is trying to thaw the filesystem. The process is trying to take sb->s_umount to thaw the FS. The lock is held by fsstress, which calls btrfs_sync_fs() and is waiting for an ordered extent to finish. However, as the FS is frozen, the ordered extents never finish.
Having an ordered extent while the FS is frozen is the root cause of the hang. The ordered extent is initiated from btrfs_relocate_chunk() which is called from btrfs_reclaim_bgs_work().
This commit adds sb_*_write() around btrfs_relocate_chunk() call site. For the usual "btrfs balance" command, we already call it with mnt_want_file() in btrfs_ioctl_balance().
--- fs/btrfs/block-group.c | 8 +++++++- fs/btrfs/volumes.c | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-)
fs/btrfs/block-group.c +7 -1
@@ -1504,8 +1504,12 @@ void btrfs_reclaim_bgs_work(struct work_if (!test_bit (BTRFS_FS_OPEN , &fs_info->flags))return ; -if (!btrfs_exclop_start (fs_info,BTRFS_EXCLOP_BALANCE )) +sb_start_write (fs_info->sb); + +if (!btrfs_exclop_start (fs_info,BTRFS_EXCLOP_BALANCE )) { +sb_end_write (fs_info->sb);return ; + }/* * Long running balances can keep us blocked here for eternity, so
@@ -1513,6 +1517,7 @@ void btrfs_reclaim_bgs_work(struct work_*/ if (!mutex_trylock (&fs_info->reclaim_bgs_lock)) {btrfs_exclop_finish (fs_info); +sb_end_write (fs_info->sb);return ; }
@@ -1581,6 +1586,7 @@ next:spin_unlock (&fs_info->unused_bgs_lock);mutex_unlock (&fs_info->reclaim_bgs_lock);btrfs_exclop_finish (fs_info); +sb_end_write (fs_info->sb); }void btrfs_reclaim_bgs (struct btrfs_fs_info *fs_info)
fs/btrfs/volumes.c +3 -0
@@ -8185,10 +8185,12 @@ static int relocating_repair_kthread(voi target = cache->start;btrfs_put_block_group (cache); +sb_start_write (fs_info->sb);if (!btrfs_exclop_start (fs_info,BTRFS_EXCLOP_BALANCE )) {btrfs_info (fs_info,"zoned: skip relocating block group %llu to repair: EBUSY" , target); +sb_end_write (fs_info->sb);return -EBUSY ; }
@@ -8216,6 +8218,7 @@ out:btrfs_put_block_group (cache);mutex_unlock (&fs_info->reclaim_bgs_lock);btrfs_exclop_finish (fs_info); +sb_end_write (fs_info->sb);return ret; }
Greg Kroah-Hartman
maintainerPATCH 170/913 btrfs: extend locking to all space_info members accesses
In reply to Greg Kroah-HartmanFrom: Niels Dossche <[email protected]>
commit 06bae876634ebf837ba70ea3de532b288326103d upstream.
bytes_pinned is always accessed under space_info->lock, except in btrfs_preempt_reclaim_metadata_space, however the other members are accessed under that lock. The reserved member of the rsv's are also partially accessed under a lock and partially not. Move all these accesses into the same lock to ensure consistency.
This could potentially race and lead to a flush instead of a commit but it's not a big problem as it's only for preemptive flush.
--- fs/btrfs/space-info.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/space-info.c +2 -1
@@ -1054,7 +1054,6 @@ static void btrfs_preempt_reclaim_metada trans_rsv->reserved;if (block_rsv_size < space_info->bytes_may_use) delalloc_size = space_info->bytes_may_use - block_rsv_size; -spin_unlock (&space_info->lock);/* * We don't want to include the global_rsv in our calculation,
@@ -1085,6 +1084,8 @@ static void btrfs_preempt_reclaim_metada flush =FLUSH_DELAYED_REFS_NR ; } +spin_unlock (&space_info->lock); +/* * We don't want to reclaim everything, just a portion, so scale * down the to_reclaim by 1/4. If it takes us down to 0,
Greg Kroah-Hartman
maintainerPATCH 171/913 btrfs: verify the tranisd of the to-be-written dirty extent buffer
In reply to Greg Kroah-HartmanFrom: Qu Wenruo <[email protected]>
commit 3777369ff1518b579560611a0d0c33f930154f64 upstream.
[BUG]
There is a bug report that a bitflip in the transid part of an extent buffer makes btrfs to reject certain tree blocks:
BTRFS error (device dm-0): parent transid verify failed on 1382301696 wanted 262166 found 22
[CAUSE]
Note the failed transid check, hex(262166) = 0x40016, while hex(22) = 0x16.
It's an obvious bitflip.
Furthermore, the reporter also confirmed the bitflip is from the hardware, so it's a real hardware caused bitflip, and such problem can not be detected by the existing tree-checker framework.
As tree-checker can only verify the content inside one tree block, while generation of a tree block can only be verified against its parent.
So such problem remain undetected.
[FIX]
Although tree-checker can not verify it at write-time, we still have a quick (but not the most accurate) way to catch such obvious corruption.
Function csum_one_extent_buffer() is called before we submit metadata write.
Thus it means, all the extent buffer passed in should be dirty tree blocks, and should be newer than last committed transaction.
Using that we can catch the above bitflip.
Although it's not a perfect solution, as if the corrupted generation is higher than the correct value, we have no way to catch it at all.
--- fs/btrfs/disk-io.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
fs/btrfs/disk-io.c +20 -6
@@ -441,17 +441,31 @@ static int csum_one_extent_buffer(structelse ret =btrfs_check_leaf_full (eb); -if (ret <0 ) { -btrfs_print_tree (eb,0 ); +if (ret <0 ) + goto error; + +/* +* Also check the generation, the eb reached here must be newer than +* last committed. Or something seriously wrong happened. +*/ +if (unlikely (btrfs_header_generation (eb) <= fs_info->last_trans_committed)) { + ret = -EUCLEAN ;btrfs_err (fs_info, -"block=%llu write time tree block corruption detected" , - eb->start); -WARN_ON (IS_ENABLED (CONFIG_BTRFS_DEBUG )); -return ret; +"block=%llu bad generation, have %llu expect > %llu" , + eb->start,btrfs_header_generation (eb), + fs_info->last_trans_committed); + goto error; }write_extent_buffer (eb, result,0 , fs_info->csum_size);return 0 ; + +error: +btrfs_print_tree (eb,0 ); +btrfs_err (fs_info,"block=%llu write time tree block corruption detected" , + eb->start); +WARN_ON (IS_ENABLED (CONFIG_BTRFS_DEBUG )); +return ret; }/* Checksum all dirty extent buffers in one bio_vec */
Greg Kroah-Hartman
maintainerPATCH 172/913 xtensa: define update_mmu_tlb function
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
commit 1c4664faa38923330d478f046dc743a00c1e2dec upstream.
Before the commit f9ce0be71d1f ("mm: Cleanup faultaround and finish_fault() codepaths") there was a call to update_mmu_cache in alloc_set_pte that used to invalidate TLB entry caching invalid PTE that caused a page fault. That commit removed that call so now invalid TLB entry survives causing repetitive page faults on the CPU that took the initial fault until that TLB entry is occasionally evicted. This issue is spotted by the xtensa TLB sanity checker.
Fix this issue by defining update_mmu_tlb function that flushes TLB entry for the faulting address.
--- arch/xtensa/include/asm/pgtable.h | 4 ++++ arch/xtensa/mm/tlb.c | 6 ++++++ 2 files changed, 10 insertions(+)
arch/xtensa/include/asm/pgtable.h +4 -0
@@ -411,6 +411,10 @@ extern void update_mmu_cache(struct vm_typedef pte_t *pte_addr_t ; +void update_mmu_tlb (struct vm_area_struct *vma, +unsigned long address,pte_t *ptep); +#define __HAVE_ARCH_UPDATE_MMU_TLB +#endif /* !defined (__ASSEMBLY__) */ #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
arch/xtensa/mm/tlb.c +6 -0
@@ -162,6 +162,12 @@ void local_flush_tlb_kernel_range(unsign } } +void update_mmu_tlb (struct vm_area_struct *vma, +unsigned long address,pte_t *ptep) +{ +local_flush_tlb_page (vma, address); +} +#ifdef CONFIG_DEBUG_TLB_SANITY static unsigned get_pte_for_vaddr (unsigned vaddr)
Greg Kroah-Hartman
maintainerPATCH 173/913 xtensa: fix stop_machine_cpuslocked call in patch_text
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
commit f406f2d03e07afc199dd8cf501f361dde6be8a69 upstream.
patch_text must invoke patch_text_stop_machine on all online CPUs, but it calls stop_machine_cpuslocked with NULL cpumask. As a result only one CPU runs patch_text_stop_machine potentially leaving stale icache entries on other CPUs. Fix that by calling stop_machine_cpuslocked with cpu_online_mask as the last argument.
--- arch/xtensa/kernel/jump_label.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/xtensa/kernel/jump_label.c +1 -1
@@ -61,7 +61,7 @@ static void patch_text(unsigned long add .data = data, };stop_machine_cpuslocked (patch_text_stop_machine, - &patch,NULL ); + &patch, cpu_online_mask); }else {unsigned long flags;
Greg Kroah-Hartman
maintainerPATCH 174/913 xtensa: fix xtensa_wsr always writing 0
In reply to Greg Kroah-HartmanFrom: Max Filippov <[email protected]>
commit a3d0245c58f962ee99d4440ea0eaf45fb7f5a5cc upstream.
The commit cad6fade6e78 ("xtensa: clean up WSR*/RSR*/get_sr/set_sr") replaced 'WSR' macro in the function xtensa_wsr with 'xtensa_set_sr', but variable 'v' in the xtensa_set_sr body shadowed the argument 'v' passed to it, resulting in wrong value written to debug registers.
Fix that by removing intermediate variable from the xtensa_set_sr macro body.
--- arch/xtensa/include/asm/processor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/xtensa/include/asm/processor.h +2 -2
@@ -226,8 +226,8 @@ extern unsigned long get_wchan(struct ta#define xtensa_set_sr (x, sr) \ ({ \ - unsigned int v = (unsigned int)(x); \ - __asm__ __volatile__ ("wsr %0, "__stringify(sr) :: "a"(v)); \ + __asm__ __volatile__ ("wsr %0, "__stringify(sr) :: \ + "a"((unsigned int)(x))); \ })#define xtensa_get_sr (sr) \
Greg Kroah-Hartman
maintainerPATCH 175/913 drm/syncobj: flatten dma_fence_chains on transfer
In reply to Greg Kroah-HartmanFrom: Christian König <[email protected]>
commit 721255b52700b320c4ae2e23d57f7d9ad1db50b9 upstream.
It is illegal to add a dma_fence_chain as timeline point. Flatten out the fences into a dma_fence_array instead.
--- drivers/gpu/drm/drm_syncobj.c | 61 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 5 deletions(-)
drivers/gpu/drm/drm_syncobj.c +56 -5
@@ -853,12 +853,57 @@ drm_syncobj_fd_to_handle_ioctl(struct dr &args->handle); } + +/* +* Try to flatten a dma_fence_chain into a dma_fence_array so that it can be +* added as timeline fence to a chain again. +*/ +static int drm_syncobj_flatten_chain (struct dma_fence **f) +{ +struct dma_fence_chain *chain =to_dma_fence_chain (*f); +struct dma_fence *tmp, **fences; +struct dma_fence_array *array; +unsigned int count; + +if (!chain) +return 0 ; + + count =0 ; +dma_fence_chain_for_each (tmp, &chain->base) + ++count; + + fences =kmalloc_array (count,sizeof (*fences),GFP_KERNEL ); +if (!fences) +return -ENOMEM ; + + count =0 ; +dma_fence_chain_for_each (tmp, &chain->base) + fences[count++] =dma_fence_get (tmp); + + array =dma_fence_array_create (count, fences, +dma_fence_context_alloc (1 ), +1 , false); +if (!array) + goto free_fences; + +dma_fence_put (*f); + *f = &array->base; +return 0 ; + +free_fences: +while (count--) +dma_fence_put (fences[count]); + +kfree (fences); +return -ENOMEM ; +} +static int drm_syncobj_transfer_to_timeline (struct drm_file *file_private,struct drm_syncobj_transfer *args) {struct drm_syncobj *timeline_syncobj =NULL ; -struct dma_fence *fence;struct dma_fence_chain *chain; +struct dma_fence *fence;int ret; timeline_syncobj =drm_syncobj_find (file_private, args->dst_handle);
@@ -869,16 +914,22 @@ static int drm_syncobj_transfer_to_timel args->src_point, args->flags, &fence);if (ret) - goto err; + goto err_put_timeline; + + ret =drm_syncobj_flatten_chain (&fence); +if (ret) + goto err_free_fence; + chain =dma_fence_chain_alloc ();if (!chain) { ret = -ENOMEM ; - goto err1; + goto err_free_fence; } +drm_syncobj_add_point (timeline_syncobj, chain, fence, args->dst_point); -err1: +err_free_fence:dma_fence_put (fence); -err: +err_put_timeline:drm_syncobj_put (timeline_syncobj);return ret;
Greg Kroah-Hartman
maintainerPATCH 176/913 drm/nouveau/backlight: Fix LVDS backlight detection on some laptops
In reply to Greg Kroah-HartmanFrom: Lyude Paul <[email protected]>
commit 6b0076540faffd47f5a899bf12f3528c4f0e726b upstream.
It seems that some laptops will report having both an eDP and LVDS connector, even though only the LVDS connector is actually hooked up. This can lead to issues with backlight registration if the eDP connector ends up getting registered before the LVDS connector, as the backlight device will then be registered to the eDP connector instead of the LVDS connector.
So, fix this by only registering the backlight on connectors that are reported as being connected.
Bugzilla: https://gitlab.freedesktop.org/drm/nouveau/-/issues/137
--- drivers/gpu/drm/nouveau/nouveau_backlight.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_backlight.c +2 -1
@@ -294,7 +294,8 @@ nv50_backlight_init(struct nouveau_backlstruct nouveau_drm *drm =nouveau_drm (nv_encoder->base.base.dev);struct nvif_object *device = &drm->client.device.object; -if (!nvif_rd32 (device,NV50_PDISP_SOR_PWM_CTL (ffs (nv_encoder->dcb->or) -1 ))) +if (!nvif_rd32 (device,NV50_PDISP_SOR_PWM_CTL (ffs (nv_encoder->dcb->or) -1 )) || + nv_conn->base.status != connector_status_connected)return -ENODEV ;if (nv_conn->type == DCB_CONNECTOR_eDP) {
Greg Kroah-Hartman
maintainerPATCH 177/913 drm/nouveau/backlight: Just set all backlight types as RAW
In reply to Greg Kroah-HartmanFrom: Lyude Paul <[email protected]>
commit b21a142fd2055d8276169efcc95b624ff908a341 upstream.
Currently we can get a warning on systems with eDP backlights like so:
nv_backlight: invalid backlight type
WARNING: CPU: 4 PID: 454 at drivers/video/backlight/backlight.c:420
backlight_device_register+0x226/0x250This happens as a result of us not filling out props.type for the eDP backlight, even though we do it for all other backlight types.
Since nothing in our driver uses anything but BACKLIGHT_RAW, let's take the props\.type assignments out of the codepaths for individual backlight types and just set it unconditionally to prevent this from happening again.
--- drivers/gpu/drm/nouveau/nouveau_backlight.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_backlight.c +1 -2
@@ -101,7 +101,6 @@ nv40_backlight_init(struct nouveau_encodif (!(nvif_rd32 (device,NV40_PMC_BACKLIGHT ) &NV40_PMC_BACKLIGHT_MASK ))return -ENODEV ; - props->type =BACKLIGHT_RAW ; props->max_brightness =31 ; *ops = &nv40_bl_ops;return 0 ;
@@ -340,7 +339,6 @@ nv50_backlight_init(struct nouveau_backlelse *ops = &nva3_bl_ops; - props->type =BACKLIGHT_RAW ; props->max_brightness =100 ;return 0 ;
@@ -408,6 +406,7 @@ nouveau_backlight_init(struct drm_connec goto fail_alloc; } + props.type =BACKLIGHT_RAW ; bl->dev =backlight_device_register (backlight_name, connector->kdev, nv_encoder, ops, &props);if (IS_ERR (bl->dev)) {
Greg Kroah-Hartman
maintainerPATCH 178/913 drm/fb-helper: Mark screen buffers in system memory with FBINFO_VIRTFB
In reply to Greg Kroah-HartmanFrom: Thomas Zimmermann <[email protected]>
commit cd9f7f7ac5932129fe81b4c7559cfcb226ec7c5c upstream.
Mark screen buffers in system memory with FBINFO_VIRTFB. Otherwise, fbdev deferred I/O marks mmap'ed areas of system memory with VM_IO. (There's an inverse relationship between the two flags.)
For shadow buffers, also set the FBINFO_READS_FAST hint.
v3:
* change FB_ to FBINFO_ in commit description
v2:
* updated commit description (Daniel)
* added Fixes tag
--- drivers/gpu/drm/drm_fb_helper.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_fb_helper.c +6 -3
@@ -2346,6 +2346,7 @@ static int drm_fb_helper_generic_probe(s fbi->fbops = &drm_fbdev_fb_ops; fbi->screen_size = fb->height * fb->pitches[0 ]; fbi->fix.smem_len = fbi->screen_size; + fbi->flags =FBINFO_DEFAULT ;drm_fb_helper_fill_info (fbi, fb_helper, sizes);
@@ -2353,19 +2354,21 @@ static int drm_fb_helper_generic_probe(s fbi->screen_buffer =vzalloc (fbi->screen_size);if (!fbi->screen_buffer)return -ENOMEM ; + fbi->flags |=FBINFO_VIRTFB |FBINFO_READS_FAST ; fbi->fbdefio = &drm_fbdev_defio; -fb_deferred_io_init (fbi); }else {/* buffer is mapped for HW framebuffer */ ret =drm_client_buffer_vmap (fb_helper->buffer, &map);if (ret)return ret; -if (map.is_iomem) +if (map.is_iomem) { fbi->screen_base = map.vaddr_iomem; -else + }else { fbi->screen_buffer = map.vaddr; + fbi->flags |=FBINFO_VIRTFB ; + }/* * Shamelessly leak the physical address to user-space. As
Greg Kroah-Hartman
maintainerPATCH 179/913 brcmfmac: firmware: Allocate space for default boardrev in nvram
In reply to Greg Kroah-HartmanFrom: Hector Martin <[email protected]>
commit d19d8e3ba256f81ea4a27209dbbd1f0a00ef1903 upstream.
If boardrev is missing from the NVRAM we add a default one, but this might need more space in the output buffer than was allocated. Ensure we have enough padding for this in the buffer.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c +2 -0
@@ -207,6 +207,8 @@ static int brcmf_init_nvram_parser(struc size =BRCMF_FW_MAX_NVRAM_SIZE ; else size = data_len; +/* Add space for properties we may add */ + size +=strlen (BRCMF_FW_DEFAULT_BOARDREV ) +1 ;/* Alloc for extra 0 byte + roundup by 4 + length field */ size +=1 +3 +sizeof (u32); nvp->nvram =kzalloc (size,GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 180/913 brcmfmac: pcie: Release firmwares in the brcmf_pcie_setup error path
In reply to Greg Kroah-HartmanFrom: Hector Martin <[email protected]>
commit 5e90f0f3ead014867dade7a22f93958119f5efab upstream.
This avoids leaking memory if brcmf_chip_get_raminfo fails. Note that the CLM blob is released in the device remove path.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +2 -0
@@ -1777,6 +1777,8 @@ static void brcmf_pcie_setup(struct devi ret =brcmf_chip_get_raminfo (devinfo->ci);if (ret) {brcmf_err (bus,"Failed to get RAM info\n" ); +release_firmware (fw); +brcmf_fw_nvram_free (nvram); goto fail; }
Greg Kroah-Hartman
maintainerPATCH 181/913 brcmfmac: pcie: Declare missing firmware files in pcie.c
In reply to Greg Kroah-HartmanFrom: Hector Martin <[email protected]>
commit 6d766d8cb505ec1fae63da8faef4fc5712c3d794 upstream.
Move one of the declarations from sdio.c to pcie.c, since it makes no sense in the former (SDIO support is optional), and add missing ones.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 7 +++++++ drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 1 - 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +7 -0
@@ -59,6 +59,13 @@ BRCMF_FW_DEF(4366B, "brcmfmac4366b-pcie" BRCMF_FW_DEF(4366C, "brcmfmac4366c-pcie");BRCMF_FW_DEF (4371 ,"brcmfmac4371-pcie" ); +/* firmware config files */ +MODULE_FIRMWARE (BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.txt" ); +MODULE_FIRMWARE (BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.*.txt" ); + +/* per-board firmware binaries */ +MODULE_FIRMWARE (BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.*.bin" ); +static const struct brcmf_firmware_mapping brcmf_pcie_fwnames[] = {BRCMF_FW_ENTRY (BRCM_CC_43602_CHIP_ID ,0xFFFFFFFF ,43602 ), BRCMF_FW_ENTRY(BRCM_CC_43465_CHIP_ID, 0xFFFFFFF0, 4366C),
drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +0 -1
@@ -629,7 +629,6 @@ BRCMF_FW_CLM_DEF(43752, "brcmfmac43752-s/* firmware config files */ MODULE_FIRMWARE (BRCMF_FW_DEFAULT_PATH "brcmfmac*-sdio.*.txt" ); -MODULE_FIRMWARE (BRCMF_FW_DEFAULT_PATH "brcmfmac*-pcie.*.txt" );/* per-board firmware binaries */ MODULE_FIRMWARE (BRCMF_FW_DEFAULT_PATH "brcmfmac*-sdio.*.bin" );
Greg Kroah-Hartman
maintainerPATCH 182/913 brcmfmac: pcie: Replace brcmf_pcie_copy_mem_todev with memcpy_toio
In reply to Greg Kroah-HartmanFrom: Hector Martin <[email protected]>
commit 9466987f246758eb7e9071ae58005253f631271e upstream.
The alignment check was wrong (e.g. & 4 instead of & 3), and the logic was also inefficient if the length was not a multiple of 4, since it would needlessly fall back to copying the entire buffer bytewise.
We already have a perfectly good memcpy_toio function, so just call that instead of rolling our own copy logic here. brcmf_pcie_init_ringbuffers was already using it anyway.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 48 +--------------- 1 file changed, 4 insertions(+), 44 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +4 -44
@@ -12,6 +12,7 @@#include <linux/interrupt.h> #include <linux/bcma/bcma.h> #include <linux/sched.h> +#include <linux/io.h> #include <asm/unaligned.h> #include <soc.h>
@@ -455,47 +456,6 @@ brcmf_pcie_write_ram32(struct brcmf_pciestatic void -brcmf_pcie_copy_mem_todev (struct brcmf_pciedev_info *devinfo,u32 mem_offset, -void *srcaddr,u32 len) -{ -void __iomem *address = devinfo->tcm + mem_offset; -__le32 *src32; -__le16 *src16; -u8 *src8; - -if (((ulong )address &4 ) || ((ulong )srcaddr &4 ) || (len &4 )) { -if (((ulong )address &2 ) || ((ulong )srcaddr &2 ) || (len &2 )) { - src8 = (u8 *)srcaddr; -while (len) { -iowrite8 (*src8, address); - address++; - src8++; - len--; - } - }else { - len = len /2 ; - src16 = (__le16 *)srcaddr; -while (len) { -iowrite16 (le16_to_cpu (*src16), address); - address +=2 ; - src16++; - len--; - } - } - }else { - len = len /4 ; - src32 = (__le32 *)srcaddr; -while (len) { -iowrite32 (le32_to_cpu (*src32), address); - address +=4 ; - src32++; - len--; - } - } -} - - -static void brcmf_pcie_copy_dev_tomem (struct brcmf_pciedev_info *devinfo,u32 mem_offset,void *dstaddr,u32 len) {
@@ -1570,8 +1530,8 @@ static int brcmf_pcie_download_fw_nvram(return err;brcmf_dbg (PCIE ,"Download FW %s\n" , devinfo->fw_name); -brcmf_pcie_copy_mem_todev (devinfo, devinfo->ci->rambase, - (void *)fw->data, fw->size); +memcpy_toio (devinfo->tcm + devinfo->ci->rambase, + (void *)fw->data, fw->size); resetintr =get_unaligned_le32 (fw->data);release_firmware (fw);
@@ -1585,7 +1545,7 @@ static int brcmf_pcie_download_fw_nvram(brcmf_dbg (PCIE ,"Download NVRAM %s\n" , devinfo->nvram_name); address = devinfo->ci->rambase + devinfo->ci->ramsize - nvram_len; -brcmf_pcie_copy_mem_todev (devinfo, address, nvram, nvram_len); +memcpy_toio (devinfo->tcm + address, nvram, nvram_len);brcmf_fw_nvram_free (nvram); }else { brcmf_dbg(PCIE, "No matching NVRAM file found %s\n",
Greg Kroah-Hartman
maintainerPATCH 183/913 brcmfmac: pcie: Fix crashes due to early IRQs
In reply to Greg Kroah-HartmanFrom: Hector Martin <[email protected]>
commit b50255c83b914defd61a57fbc81d452334b63f4c upstream.
The driver was enabling IRQs before the message processing was initialized. This could cause IRQs to come in too early and crash the driver. Instead, move the IRQ enable and hostready to a bus preinit function, at which point everything is properly initialized.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +13 -3
@@ -1315,6 +1315,18 @@ static void brcmf_pcie_down(struct devic { } +static int brcmf_pcie_preinit (struct device *dev) +{ +struct brcmf_bus *bus_if =dev_get_drvdata (dev); +struct brcmf_pciedev *buspub = bus_if->bus_priv.pcie; + +brcmf_dbg (PCIE ,"Enter\n" ); + +brcmf_pcie_intr_enable (buspub->devinfo); +brcmf_pcie_hostready (buspub->devinfo); + +return 0 ; +}static int brcmf_pcie_tx (struct device *dev,struct sk_buff *skb) {
@@ -1423,6 +1435,7 @@ static int brcmf_pcie_reset(struct devic }static const struct brcmf_bus_ops brcmf_pcie_bus_ops = { + .preinit = brcmf_pcie_preinit, .txdata = brcmf_pcie_tx, .stop = brcmf_pcie_down, .txctl = brcmf_pcie_tx_ctlpkt,
@@ -1795,9 +1808,6 @@ static void brcmf_pcie_setup(struct deviinit_waitqueue_head (&devinfo->mbdata_resp_wait); -brcmf_pcie_intr_enable (devinfo); -brcmf_pcie_hostready (devinfo); - ret =brcmf_attach (&devinfo->pdev->dev);if (ret) goto fail;
Greg Kroah-Hartman
maintainerPATCH 184/913 drm/i915/opregion: check port number bounds for SWSCI display power state
In reply to Greg Kroah-HartmanFrom: Jani Nikula <[email protected]>
commit 24a644ebbfd3b13cda702f98907f9dd123e34bf9 upstream.
The mapping from enum port to whatever port numbering scheme is used by the SWSCI Display Power State Notification is odd, and the memory of it has faded. In any case, the parameter only has space for ports numbered [0..4], and UBSAN reports bit shift beyond it when the platform has port F or more.
Since the SWSCI functionality is supposed to be obsolete for new platforms (i.e. ones that might have port F or more), just bail out early if the mapped and mangled port number is beyond what the Display Power State Notification can support.
--- drivers/gpu/drm/i915/display/intel_opregion.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/gpu/drm/i915/display/intel_opregion.c +15 -0
@@ -376,6 +376,21 @@ int intel_opregion_notify_encoder(structreturn -EINVAL ; } +/* +* The port numbering and mapping here is bizarre. The now-obsolete +* swsci spec supports ports numbered [0..4]. Port E is handled as a +* special case, but port F and beyond are not. The functionality is +* supposed to be obsolete for new platforms. Just bail out if the port +* number is out of bounds after mapping. +*/ +if (port >4 ) { +drm_dbg_kms (&dev_priv->drm, +"[ENCODER:%d:%s] port %c (index %u) out of bounds for display power state notification\n" , + intel_encoder->base.base.id, intel_encoder->base.name, +port_name (intel_encoder->port), port); +return -EINVAL ; + } +if (!enable) parm |=4 <<8 ;
Greg Kroah-Hartman
maintainerPATCH 185/913 drm/i915/gem: add missing boundary check in vm_access
In reply to Greg Kroah-HartmanFrom: Mastan Katragadda <[email protected]>
commit 3886a86e7e6cc6ce2ce93c440fecd8f42aed0ce7 upstream.
A missing bounds check in vm_access() can lead to an out-of-bounds read or write in the adjacent memory area, since the len attribute is not validated before the memcpy later in the function, potentially hitting:
[ 183.637831] BUG: unable to handle page fault for address: ffffc90000c86000 [ 183.637934] #PF: supervisor read access in kernel mode [ 183.637997] #PF: error_code(0x0000) - not-present page [ 183.638059] PGD 100000067 P4D 100000067 PUD 100258067 PMD 106341067 PTE 0 [ 183.638144] Oops: 0000 [#2] PREEMPT SMP NOPTI [ 183.638201] CPU: 3 PID: 1790 Comm: poc Tainted: G D 5.17.0-rc6-ci-drm-11296+ #1 [ 183.638298] Hardware name: Intel Corporation CoffeeLake Client Platform/CoffeeLake H DDR4 RVP, BIOS CNLSFWR1.R00.X208.B00.1905301319 05/30/2019 [ 183.638430] RIP: 0010:memcpy_erms+0x6/0x10 [ 183.640213] RSP: 0018:ffffc90001763d48 EFLAGS: 00010246 [ 183.641117] RAX: ffff888109c14000 RBX: ffff888111bece40 RCX: 0000000000000ffc [ 183.642029] RDX: 0000000000001000 RSI: ffffc90000c86000 RDI: ffff888109c14004 [ 183.642946] RBP: 0000000000000ffc R08: 800000000000016b R09: 0000000000000000 [ 183.643848] R10: ffffc90000c85000 R11: 0000000000000048 R12: 0000000000001000 [ 183.644742] R13: ffff888111bed190 R14: ffff888109c14000 R15: 0000000000001000 [ 183.645653] FS: 00007fe5ef807540(0000) GS:ffff88845b380000(0000) knlGS:0000000000000000 [ 183.646570] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 183.647481] CR2: ffffc90000c86000 CR3: 000000010ff02006 CR4: 00000000003706e0 [ 183.648384] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 183.649271] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 183.650142] Call Trace: [ 183.650988] <TASK> [ 183.651793] vm_access+0x1f0/0x2a0 [i915] [ 183.652726] __access_remote_vm+0x224/0x380 [ 183.653561] mem_rw.isra.0+0xf9/0x190 [ 183.654402] vfs_read+0x9d/0x1b0 [ 183.655238] ksys_read+0x63/0xe0 [ 183.656065] do_syscall_64+0x38/0xc0 [ 183.656882] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 183.657663] RIP: 0033:0x7fe5ef725142 [ 183.659351] RSP: 002b:00007ffe1e81c7e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 [ 183.660227] RAX: ffffffffffffffda RBX: 0000557055dfb780 RCX: 00007fe5ef725142 [ 183.661104] RDX: 0000000000001000 RSI: 00007ffe1e81d880 RDI: 0000000000000005 [ 183.661972] RBP: 00007ffe1e81e890 R08: 0000000000000030 R09: 0000000000000046 [ 183.662832] R10: 0000557055dfc2e0 R11: 0000000000000246 R12: 0000557055dfb1c0 [ 183.663691] R13: 00007ffe1e81e980 R14: 0000000000000000 R15: 0000000000000000
Changes since v1:
- Updated if condition with range_overflows_t [Chris Wilson]
--- drivers/gpu/drm/i915/gem/i915_gem_mman.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gem/i915_gem_mman.c +1 -1
@@ -438,7 +438,7 @@ vm_access(struct vm_area_struct *area, ureturn -EACCES ; addr -= area->vm_start; -if (addr >= obj->base.size) +if (range_overflows_t (u64, addr, len, obj->base.size))return -EINVAL ;i915_gem_ww_ctx_init (&ww, true);
Greg Kroah-Hartman
maintainerPATCH 186/913 PCI: imx6: Allow to probe when dw_pcie_wait_for_link() fails
In reply to Greg Kroah-HartmanFrom: Fabio Estevam <[email protected]>
commit f81f095e87715e198471f4653952fe5e3f824874 upstream.
The intention of commit 886a9c134755 ("PCI: dwc: Move link handling into common code") was to standardize the behavior of link down as explained in its commit log:
"The behavior for a link down was inconsistent as some drivers would fail probe in that case while others succeed. Let's standardize this to succeed as there are usecases where devices (and the link) appear later even without hotplug. For example, a reconfigured FPGA device."
The pci-imx6 still fails to probe when the link is not present, which causes the following warning:
imx6q-pcie 8ffc000.pcie: Phy link never came up
imx6q-pcie: probe of 8ffc000.pcie failed with error -110
------------[ cut here ]------------ WARNING: CPU: 0 PID: 30 at drivers/regulator/core.c:2257 _regulator_put.part.0+0x1b8/0x1dc Modules linked in: CPU: 0 PID: 30 Comm: kworker/u2:2 Not tainted 5.15.0-next-20211103 #1 Hardware name: Freescale i.MX6 SoloX (Device Tree) Workqueue: events_unbound async_run_entry_fn [<c0111730>] (unwind_backtrace) from [<c010bb74>] (show_stack+0x10/0x14) [<c010bb74>] (show_stack) from [<c0f90290>] (dump_stack_lvl+0x58/0x70) [<c0f90290>] (dump_stack_lvl) from [<c012631c>] (__warn+0xd4/0x154) [<c012631c>] (__warn) from [<c0f87b00>] (warn_slowpath_fmt+0x74/0xa8) [<c0f87b00>] (warn_slowpath_fmt) from [<c076b4bc>] (_regulator_put.part.0+0x1b8/0x1dc) [<c076b4bc>] (_regulator_put.part.0) from [<c076b574>] (regulator_put+0x2c/0x3c) [<c076b574>] (regulator_put) from [<c08c3740>] (release_nodes+0x50/0x178)
Fix this problem by ignoring the dw_pcie_wait_for_link() error like it is done on the other dwc drivers.
Tested on imx6sx-sdb and imx6q-sabresd boards.
--- drivers/pci/controller/dwc/pci-imx6.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/pci/controller/dwc/pci-imx6.c +2 -8
@@ -779,9 +779,7 @@ static int imx6_pcie_start_link(struct d/* Start LTSSM. */ imx6_pcie_ltssm_enable (dev); - ret =dw_pcie_wait_for_link (pci); -if (ret) - goto err_reset_phy; +dw_pcie_wait_for_link (pci);if (pci->link_gen ==2 ) {/* Allow Gen2 mode after the link is up. */
@@ -817,11 +815,7 @@ static int imx6_pcie_start_link(struct d }/* Make sure link training is finished as well! */ - ret =dw_pcie_wait_for_link (pci); -if (ret) { -dev_err (dev,"Failed to bring link up!\n" ); - goto err_reset_phy; - } +dw_pcie_wait_for_link (pci); }else {dev_info (dev,"Link: Gen2 disabled\n" ); }
Greg Kroah-Hartman
maintainerPATCH 187/913 PCI: pciehp: Clear cmd_busy bit in polling mode
In reply to Greg Kroah-HartmanFrom: Liguang Zhang <[email protected]>
commit 92912b175178c7e895f5e5e9f1e30ac30319162b upstream.
Writes to a Downstream Port's Slot Control register are PCIe hotplug "commands." If the Port supports Command Completed events, software must wait for a command to complete before writing to Slot Control again.
pcie_do_write_cmd() sets ctrl->cmd_busy when it writes to Slot Control. If software notification is enabled, i.e., PCI_EXP_SLTCTL_HPIE and PCI_EXP_SLTCTL_CCIE are set, ctrl->cmd_busy is cleared by pciehp_isr().
But when software notification is disabled, as it is when pcie_init() powers off an empty slot, pcie_wait_cmd() uses pcie_poll_cmd() to poll for command completion, and it neglects to clear ctrl->cmd_busy, which leads to spurious timeouts:
pcieport 0000:00:03.0: pciehp: Timeout on hotplug command 0x01c0 (issued 2264 msec ago) pcieport 0000:00:03.0: pciehp: Timeout on hotplug command 0x05c0 (issued 2288 msec ago)
Clear ctrl->cmd_busy in pcie_poll_cmd() when it detects a Command Completed event (PCI_EXP_SLTSTA_CC).
--- drivers/pci/hotplug/pciehp_hpc.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/hotplug/pciehp_hpc.c +2 -0
@@ -98,6 +98,8 @@ static int pcie_poll_cmd(struct controllif (slot_status &PCI_EXP_SLTSTA_CC ) {pcie_capability_write_word (pdev,PCI_EXP_SLTSTA ,PCI_EXP_SLTSTA_CC ); + ctrl->cmd_busy =0 ; +smp_mb ();return 1 ; }msleep (10 );
Greg Kroah-Hartman
maintainerPATCH 188/913 PCI: xgene: Revert "PCI: xgene: Fix IB window setup"
In reply to Greg Kroah-HartmanFrom: Marc Zyngier <[email protected]>
commit 825da4e9cec68713fbb02dc6f71fe1bf65fe8050 upstream.
Commit c7a75d07827a ("PCI: xgene: Fix IB window setup") tried to fix the damages that 6dce5aa59e0b ("PCI: xgene: Use inbound resources for setup") caused, but actually didn't improve anything for some plarforms (at least Mustang and m400 are still broken).
Given that 6dce5aa59e0b has been reverted, revert this patch as well, restoring the PCIe support on XGene to its pre-5.5, working state.
--- drivers/pci/controller/pci-xgene.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pci-xgene.c +1 -1
@@ -466,7 +466,7 @@ static int xgene_pcie_select_ib_reg(u8 *return 1 ; } -if ((size >SZ_1K ) && (size <SZ_4G ) && !(*ib_reg_mask & (1 <<0 ))) { +if ((size >SZ_1K ) && (size <SZ_1T ) && !(*ib_reg_mask & (1 <<0 ))) { *ib_reg_mask |= (1 <<0 );return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 189/913 regulator: qcom_smd: fix for_each_child.cocci warnings
In reply to Greg Kroah-HartmanFrom: kernel test robot <[email protected]>
[ Upstream commit 6390d42c21efff0b4c10956a38e341f4e84ecd3d ]
drivers/regulator/qcom_smd-regulator.c:1318:1-33: WARNING: Function "for_each_available_child_of_node" should have of_node_put() before return around line 1321.
Semantic patch information:
False positives can be due to function calls within the for_each loop that may encapsulate an of_node_put.
Generated by: scripts/coccinelle/iterators/for_each_child.cocci
--- drivers/regulator/qcom_smd-regulator.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/regulator/qcom_smd-regulator.c +3 -1
@@ -1268,8 +1268,10 @@ static int rpm_reg_probe(struct platform_device *pdev)for_each_available_child_of_node (dev->of_node, node) { vreg =devm_kzalloc (&pdev->dev,sizeof (*vreg),GFP_KERNEL ); -if (!vreg) +if (!vreg) { +of_node_put (node);return -ENOMEM ; + } ret =rpm_regulator_init_vreg (vreg, dev, node, rpm, vreg_data);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 190/913 selinux: access superblock_security_struct in LSM blob way
In reply to Greg Kroah-HartmanFrom: GONG, Ruiqi <[email protected]>
[ Upstream commit 0266c25e7c2821181b610595df42cbca6bc93cb8 ]
LSM blob has been involved for superblock's security struct. So fix the remaining direct access to sb->s_security by using the LSM blob mechanism.
--- security/selinux/hooks.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/selinux/hooks.c +2 -2
@@ -492,7 +492,7 @@ static int selinux_is_sblabel_mnt(struct super_block *sb)static int sb_check_xattr_support (struct super_block *sb) { -struct superblock_security_struct *sbsec = sb->s_security; +struct superblock_security_struct *sbsec =selinux_superblock (sb);struct dentry *root = sb->s_root;struct inode *root_inode =d_backing_inode (root);u32 sid;
@@ -2695,7 +2695,7 @@ static int selinux_sb_eat_lsm_opts(char *options, void **mnt_opts)static int selinux_sb_mnt_opts_compat (struct super_block *sb,void *mnt_opts) {struct selinux_mnt_opts *opts = mnt_opts; -struct superblock_security_struct *sbsec = sb->s_security; +struct superblock_security_struct *sbsec =selinux_superblock (sb);u32 sid;int rc;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 191/913 selinux: check return value of sel_make_avc_files
In reply to Greg Kroah-HartmanFrom: Christian Göttsche <[email protected]>
[ Upstream commit bcb62828e3e8c813b6613db6eb7fd9657db248fc ]
sel_make_avc_files() might fail and return a negative errno value on memory allocation failures. Re-add the check of the return value, dropped in 66f8e2f03c02 ("selinux: sidtab reverse lookup hash table").
Reported by clang-analyzer:
security/selinux/selinuxfs.c:2129:2: warning: Value stored to
'ret' is never read [deadcode.DeadStores]
ret = sel_make_avc_files(dentry);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
--- security/selinux/selinuxfs.c | 2 ++ 1 file changed, 2 insertions(+)
security/selinux/selinuxfs.c +2 -0
@@ -2127,6 +2127,8 @@ static int sel_fill_super(struct super_block *sb, struct fs_context *fc) } ret =sel_make_avc_files (dentry); +if (ret) + goto err; dentry =sel_make_dir (sb->s_root,"ss" , &fsi->last_ino);if (IS_ERR (dentry)) {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 192/913 crypto: ccp - Ensure psp_ret is always initd in __sev_platform_init_locked()
In reply to Greg Kroah-HartmanFrom: Peter Gonda <[email protected]>
[ Upstream commit 1e1ec11d3ec3134e05d4710f4dee5f9bd05e828d ]
Initialize psp_ret inside of __sev_platform_init_locked() because there are many failure paths with PSP initialization that do not set __sev_do_cmd_locked().
--- drivers/crypto/ccp/sev-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ccp/sev-dev.c +1 -1
@@ -241,7 +241,7 @@ static int __sev_platform_init_locked(int *error)struct psp_device *psp = psp_master;struct sev_data_init data;struct sev_device *sev; -int psp_ret, rc =0 ; +int psp_ret =-1 , rc =0 ;if (!psp || !psp->sev_data)return -ENODEV ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 193/913 hwrng: cavium - Check health status while reading random data
In reply to Greg Kroah-HartmanFrom: Sunil Goutham <[email protected]>
[ Upstream commit 680efb33546be8960ccbb2f4e0e43034d9c93b30 ]
This RNG device is present on Marvell OcteonTx2 silicons as well and also provides entropy health status.
HW continuously checks health condition of entropy and reports faults. Fault is in terms of co-processor cycles since last fault detected. This doesn't get cleared and only updated when new fault is detected. Also there are chances of detecting false positives. So to detect a entropy failure SW has to check if failures are persistent ie cycles elapsed is frequently updated by HW.
This patch adds support to detect health failures using below algo.
1. Consider any fault detected before 10ms as a false positive and ignore. 10ms is chosen randomly, no significance.
2. Upon first failure detection make a note of cycles elapsed and when this error happened in realtime (cntvct).
3. Upon subsequent failure, check if this is new or a old one by comparing current cycles with the ones since last failure. cycles or time since last failure is calculated using cycles and time info captured at (2).
HEALTH_CHECK status register is not available to VF, hence had to map PF registers. Also since cycles are in terms of co-processor cycles, had to retrieve co-processor clock rate from RST device.
--- drivers/char/hw_random/Kconfig | 2 +- drivers/char/hw_random/cavium-rng-vf.c | 194 +++++++++++++++++++++++-- drivers/char/hw_random/cavium-rng.c | 11 +- 3 files changed, 190 insertions(+), 17 deletions(-)
drivers/char/hw_random/Kconfig +1 -1
@@ -414,7 +414,7 @@ config HW_RANDOM_MESON config HW_RANDOM_CAVIUM tristate "Cavium ThunderX Random Number Generator support" - depends on HW_RANDOM && PCI && (ARM64 || (COMPILE_TEST && 64BIT)) + depends on HW_RANDOM && PCI && ARM64 default HW_RANDOM help This driver provides kernel-side support for the Random Number
drivers/char/hw_random/cavium-rng-vf.c +185 -9
247 lines not on this page · raw message
drivers/char/hw_random/cavium-rng.c +4 -7
@@ -1,10 +1,7 @@ +// SPDX-License-Identifier: GPL-2.0 /* -* Hardware Random Number Generator support for Cavium Inc. -* Thunder processor family. -* -* This file is subject to the terms and conditions of the GNU General Public -* License. See the file "COPYING" in the main directory of this archive -* for more details. +* Hardware Random Number Generator support. +* Cavium Thunder, Marvell OcteonTx/Tx2 processor families. * * Copyright (C) 2016 Cavium, Inc. */
@@ -91,4 +88,4 @@ static struct pci_driver cavium_rng_pf_driver = {module_pci_driver (cavium_rng_pf_driver);MODULE_AUTHOR ("Omer Khaliq <[email protected]>" ); -MODULE_LICENSE ("GPL" ); +MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 194/913 hwrng: cavium - HW_RANDOM_CAVIUM should depend on ARCH_THUNDER
In reply to Greg Kroah-HartmanFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit ab7d88549e2f7ae116afd303f32e1950cb790a1d ]
The Cavium ThunderX Random Number Generator is only present on Cavium ThunderX SoCs, and not available as an independent PCIe endpoint. Hence add a dependency on ARCH_THUNDER, to prevent asking the user about this driver when configuring a kernel without Cavium Thunder SoC support.
--- drivers/char/hw_random/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/hw_random/Kconfig +1 -1
@@ -414,7 +414,7 @@ config HW_RANDOM_MESON config HW_RANDOM_CAVIUM tristate "Cavium ThunderX Random Number Generator support" - depends on HW_RANDOM && PCI && ARM64 + depends on HW_RANDOM && PCI && ARCH_THUNDER default HW_RANDOM help This driver provides kernel-side support for the Random Number
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 195/913 crypto: sun8i-ss - really disable hash on A80
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
[ Upstream commit 881fc7fba6c3e7d77d608b9a50b01a89d5e0c61b ]
When adding hashes support to sun8i-ss, I have added them only on A83T. But I forgot that 0 is a valid algorithm ID, so hashes are enabled on A80 but with an incorrect ID.
Anyway, even with correct IDs, hashes do not work on A80 and I cannot find why.
So let's disable all of them on A80.
--- drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-core.c +2 -0
@@ -30,6 +30,8 @@static const struct ss_variant ss_a80_variant = { .alg_cipher = {SS_ALG_AES ,SS_ALG_DES ,SS_ALG_3DES , }, + .alg_hash = {SS_ID_NOTSUPP ,SS_ID_NOTSUPP ,SS_ID_NOTSUPP ,SS_ID_NOTSUPP , + }, .op_mode = {SS_OP_ECB ,SS_OP_CBC , }, .ss_clks = {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 196/913 crypto: authenc - Fix sleep in atomic context in decrypt_tail
In reply to Greg Kroah-HartmanFrom: Herbert Xu <[email protected]>
[ Upstream commit 66eae850333d639fc278d6f915c6fc01499ea893 ]
The function crypto_authenc_decrypt_tail discards its flags argument and always relies on the flags from the original request when starting its sub-request.
This is clearly wrong as it may cause the SLEEPABLE flag to be set when it shouldn't.
--- crypto/authenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/authenc.c +1 -1
@@ -253,7 +253,7 @@ static int crypto_authenc_decrypt_tail(struct aead_request *req, dst =scatterwalk_ffwd (areq_ctx->dst, req->dst, req->assoclen);skcipher_request_set_tfm (skreq, ctx->enc); -skcipher_request_set_callback (skreq,aead_request_flags (req), +skcipher_request_set_callback (skreq, flags, req->base.complete, req->base.data);skcipher_request_set_crypt (skreq, src, dst, req->cryptlen - authsize, req->iv);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 197/913 crypto: mxs-dcp - Fix scatterlist processing
In reply to Greg Kroah-HartmanFrom: Tomas Paukrt <[email protected]>
[ Upstream commit 28e9b6d8199a3f124682b143800c2dacdc3d70dd ]
This patch fixes a bug in scatterlist processing that may cause incorrect AES block encryption/decryption.
--- drivers/crypto/mxs-dcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/mxs-dcp.c +1 -1
@@ -331,7 +331,7 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)memset (key +AES_KEYSIZE_128 ,0 ,AES_KEYSIZE_128 ); } -for_each_sg (req->src, src,sg_nents (src), i) { +for_each_sg (req->src, src,sg_nents (req->src), i) { src_buf =sg_virt (src); len =sg_dma_len (src); tlen += len;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 198/913 selinux: Fix selinux_sb_mnt_opts_compat()
In reply to Greg Kroah-HartmanFrom: Scott Mayhew <[email protected]>
[ Upstream commit b8b87fd954b4b1bdd2d739c8f50bf685351a1a94 ]
selinux_sb_mnt_opts_compat() is called under the sb_lock spinlock and shouldn't be performing any memory allocations. Fix this by parsing the sids at the same time we're chopping up the security mount options string and then using the pre-parsed sids when doing the comparison.
--- security/selinux/hooks.c | 75 ++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 34 deletions(-)
security/selinux/hooks.c +41 -34
@@ -355,6 +355,10 @@ static void inode_free_security(struct inode *inode)struct selinux_mnt_opts {const char *fscontext, *context, *rootcontext, *defcontext; +u32 fscontext_sid; +u32 context_sid; +u32 rootcontext_sid; +u32 defcontext_sid; };static void selinux_free_mnt_opts (void *mnt_opts)
@@ -611,15 +615,14 @@ static int bad_option(struct superblock_security_struct *sbsec, char flag,return 0 ; } -static int parse_sid (struct super_block *sb,const char *s,u32 *sid, -gfp_t gfp) +static int parse_sid (struct super_block *sb,const char *s,u32 *sid) {int rc =security_context_str_to_sid (&selinux_state, s, - sid, gfp); + sid,GFP_KERNEL );if (rc)pr_warn ("SELinux: security_context_str_to_sid" "(%s) failed for (dev %s, type %s) errno=%d\n" , - s, sb->s_id, sb->s_type->name, rc); + s, sb ? sb->s_id :"?" , sb ? sb->s_type->name :"?" , rc);return rc; }
@@ -686,8 +689,7 @@ static int selinux_set_mnt_opts(struct super_block *sb,*/ if (opts) {if (opts->fscontext) { - rc =parse_sid (sb, opts->fscontext, &fscontext_sid, -GFP_KERNEL ); + rc =parse_sid (sb, opts->fscontext, &fscontext_sid);if (rc) goto out; if (bad_option(sbsec, FSCONTEXT_MNT, sbsec->sid,
@@ -696,8 +698,7 @@ static int selinux_set_mnt_opts(struct super_block *sb, sbsec->flags |=FSCONTEXT_MNT ; }if (opts->context) { - rc =parse_sid (sb, opts->context, &context_sid, -GFP_KERNEL ); + rc =parse_sid (sb, opts->context, &context_sid);if (rc) goto out; if (bad_option(sbsec, CONTEXT_MNT, sbsec->mntpoint_sid,
@@ -706,8 +707,7 @@ static int selinux_set_mnt_opts(struct super_block *sb, sbsec->flags |=CONTEXT_MNT ; }if (opts->rootcontext) { - rc =parse_sid (sb, opts->rootcontext, &rootcontext_sid, -GFP_KERNEL ); + rc =parse_sid (sb, opts->rootcontext, &rootcontext_sid);if (rc) goto out; if (bad_option(sbsec, ROOTCONTEXT_MNT, root_isec->sid,
@@ -716,8 +716,7 @@ static int selinux_set_mnt_opts(struct super_block *sb, sbsec->flags |=ROOTCONTEXT_MNT ; }if (opts->defcontext) { - rc =parse_sid (sb, opts->defcontext, &defcontext_sid, -GFP_KERNEL ); + rc =parse_sid (sb, opts->defcontext, &defcontext_sid);if (rc) goto out; if (bad_option(sbsec, DEFCONTEXT_MNT, sbsec->def_sid,
@@ -1008,21 +1007,29 @@ static int selinux_add_opt(int token, const char *s, void **mnt_opts)if (opts->context || opts->defcontext) goto Einval; opts->context = s; +if (selinux_initialized (&selinux_state)) +parse_sid (NULL , s, &opts->context_sid);break ;case Opt_fscontext:if (opts->fscontext) goto Einval; opts->fscontext = s; +if (selinux_initialized (&selinux_state)) +parse_sid (NULL , s, &opts->fscontext_sid);break ;case Opt_rootcontext:if (opts->rootcontext) goto Einval; opts->rootcontext = s; +if (selinux_initialized (&selinux_state)) +parse_sid (NULL , s, &opts->rootcontext_sid);break ;case Opt_defcontext:if (opts->context || opts->defcontext) goto Einval; opts->defcontext = s; +if (selinux_initialized (&selinux_state)) +parse_sid (NULL , s, &opts->defcontext_sid);break ; }return 0 ;
@@ -2696,8 +2703,6 @@ static int selinux_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts) {struct selinux_mnt_opts *opts = mnt_opts;struct superblock_security_struct *sbsec =selinux_superblock (sb); -u32 sid; -int rc;/* * Superblock not initialized (i.e. no options) - reject if any
@@ -2714,34 +2719,36 @@ static int selinux_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts)return (sbsec->flags &SE_MNTMASK ) ?1 :0 ;if (opts->fscontext) { - rc =parse_sid (sb, opts->fscontext, &sid,GFP_NOWAIT ); -if (rc) +if (opts->fscontext_sid ==SECSID_NULL )return 1 ; -if (bad_option (sbsec,FSCONTEXT_MNT , sbsec->sid, sid)) +else if (bad_option (sbsec,FSCONTEXT_MNT , sbsec->sid, + opts->fscontext_sid))return 1 ; }if (opts->context) { - rc =parse_sid (sb, opts->context, &sid,GFP_NOWAIT ); -if (rc) +if (opts->context_sid ==SECSID_NULL )return 1 ; -if (bad_option (sbsec,CONTEXT_MNT , sbsec->mntpoint_sid, sid)) +else if (bad_option (sbsec,CONTEXT_MNT , sbsec->mntpoint_sid, + opts->context_sid))return 1 ; }if (opts->rootcontext) { -struct inode_security_struct *root_isec; - - root_isec =backing_inode_security (sb->s_root); - rc =parse_sid (sb, opts->rootcontext, &sid,GFP_NOWAIT ); -if (rc) -return 1 ; -if (bad_option (sbsec,ROOTCONTEXT_MNT , root_isec->sid, sid)) +if (opts->rootcontext_sid ==SECSID_NULL )return 1 ; +else { +struct inode_security_struct *root_isec; + + root_isec =backing_inode_security (sb->s_root); +if (bad_option (sbsec,ROOTCONTEXT_MNT , root_isec->sid, + opts->rootcontext_sid)) +return 1 ; + } }if (opts->defcontext) { - rc =parse_sid (sb, opts->defcontext, &sid,GFP_NOWAIT ); -if (rc) +if (opts->defcontext_sid ==SECSID_NULL )return 1 ; -if (bad_option (sbsec,DEFCONTEXT_MNT , sbsec->def_sid, sid)) +else if (bad_option (sbsec,DEFCONTEXT_MNT , sbsec->def_sid, + opts->defcontext_sid))return 1 ; }return 0 ;
@@ -2761,14 +2768,14 @@ static int selinux_sb_remount(struct super_block *sb, void *mnt_opts)return 0 ;if (opts->fscontext) { - rc =parse_sid (sb, opts->fscontext, &sid,GFP_KERNEL ); + rc =parse_sid (sb, opts->fscontext, &sid);if (rc)return rc;if (bad_option (sbsec,FSCONTEXT_MNT , sbsec->sid, sid)) goto out_bad_option; }if (opts->context) { - rc =parse_sid (sb, opts->context, &sid,GFP_KERNEL ); + rc =parse_sid (sb, opts->context, &sid);if (rc)return rc;if (bad_option (sbsec,CONTEXT_MNT , sbsec->mntpoint_sid, sid))
@@ -2777,14 +2784,14 @@ static int selinux_sb_remount(struct super_block *sb, void *mnt_opts)if (opts->rootcontext) {struct inode_security_struct *root_isec; root_isec =backing_inode_security (sb->s_root); - rc =parse_sid (sb, opts->rootcontext, &sid,GFP_KERNEL ); + rc =parse_sid (sb, opts->rootcontext, &sid);if (rc)return rc;if (bad_option (sbsec,ROOTCONTEXT_MNT , root_isec->sid, sid)) goto out_bad_option; }if (opts->defcontext) { - rc =parse_sid (sb, opts->defcontext, &sid,GFP_KERNEL ); + rc =parse_sid (sb, opts->defcontext, &sid);if (rc)return rc;if (bad_option (sbsec,DEFCONTEXT_MNT , sbsec->def_sid, sid))
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 199/913 thermal: int340x: Check for NULL after calling kmemdup()
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 38b16d6cfe54c820848bcfc999bc5e8a7da1cefb ]
As the potential failure of the allocation, kmemdup() may return NULL.
Then, 'bin_attr_data_vault.private' will be NULL, but 'bin_attr_data_vault.size' is not 0, which is not consistent.
Therefore, it is better to check the return value of kmemdup() to avoid the confusion.
--- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +5 -0
@@ -469,6 +469,11 @@ static void int3400_setup_gddv(struct int3400_thermal_priv *priv) priv->data_vault =kmemdup (obj->package.elements[0 ].buffer.pointer, obj->package.elements[0 ].buffer.length,GFP_KERNEL ); +if (!priv->data_vault) { +kfree (buffer.pointer); +return ; + } + bin_attr_data_vault.private = priv->data_vault; bin_attr_data_vault.size = obj->package.elements[0 ].buffer.length;kfree (buffer.pointer);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 200/913 crypto: octeontx2 - remove CONFIG_DM_CRYPT check
In reply to Greg Kroah-HartmanFrom: Shijith Thotton <[email protected]>
[ Upstream commit 2d841af23ae8f398c85dd1ff2dc24b5ec8ba4569 ]
No issues were found while using the driver with dm-crypt enabled. So CONFIG_DM_CRYPT check in the driver can be removed.
This also fixes the NULL pointer dereference in driver release if CONFIG_DM_CRYPT is enabled.
...
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 ... Call trace: crypto_unregister_alg+0x68/0xfc crypto_unregister_skciphers+0x44/0x60 otx2_cpt_crypto_exit+0x100/0x1a0 otx2_cptvf_remove+0xf8/0x200 pci_device_remove+0x3c/0xd4 __device_release_driver+0x188/0x234 device_release_driver+0x2c/0x4c
...
--- .../crypto/marvell/octeontx2/otx2_cptvf_algs.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c +7 -10
@@ -1634,16 +1634,13 @@ static inline int cpt_register_algs(void) {int i, err =0 ; -if (!IS_ENABLED (CONFIG_DM_CRYPT )) { -for (i =0 ; i <ARRAY_SIZE (otx2_cpt_skciphers); i++) - otx2_cpt_skciphers[i].base.cra_flags &= - ~CRYPTO_ALG_DEAD ; - - err =crypto_register_skciphers (otx2_cpt_skciphers, -ARRAY_SIZE (otx2_cpt_skciphers)); -if (err) -return err; - } +for (i =0 ; i <ARRAY_SIZE (otx2_cpt_skciphers); i++) + otx2_cpt_skciphers[i].base.cra_flags &= ~CRYPTO_ALG_DEAD ; + + err =crypto_register_skciphers (otx2_cpt_skciphers, +ARRAY_SIZE (otx2_cpt_skciphers)); +if (err) +return err;for (i =0 ; i <ARRAY_SIZE (otx2_cpt_aeads); i++) otx2_cpt_aeads[i].base.cra_flags &= ~CRYPTO_ALG_DEAD ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 201/913 spi: tegra114: Add missing IRQ check in tegra_spi_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 4f92724d4b92c024e721063f520d66e11ca4b54b ]
This func misses checking for platform_get_irq()'s call and may passes the negative error codes to request_threaded_irq(), which takes unsigned IRQ #, causing it to fail with -EINVAL, overriding an original error code. Stop calling request_threaded_irq() with invalid IRQ #s.
--- drivers/spi/spi-tegra114.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/spi/spi-tegra114.c +4 -0
@@ -1352,6 +1352,10 @@ static int tegra_spi_probe(struct platform_device *pdev) tspi->phys = r->start; spi_irq =platform_get_irq (pdev,0 ); +if (spi_irq <0 ) { + ret = spi_irq; + goto exit_free_master; + } tspi->irq = spi_irq; tspi->clk =devm_clk_get (&pdev->dev,"spi" );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 202/913 spi: tegra210-quad: Fix missin IRQ check in tegra_qspi_probe
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 47c3e06ed95aa9b74932dbc6b23b544f644faf84 ]
This func misses checking for platform_get_irq()'s call and may passes the negative error codes to request_threaded_irq(), which takes unsigned IRQ #, causing it to fail with -EINVAL, overriding an original error code. Stop calling request_threaded_irq() with invalid IRQ #s.
--- drivers/spi/spi-tegra210-quad.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/spi/spi-tegra210-quad.c +2 -0
@@ -1249,6 +1249,8 @@ static int tegra_qspi_probe(struct platform_device *pdev) tqspi->phys = r->start; qspi_irq =platform_get_irq (pdev,0 ); +if (qspi_irq <0 ) +return qspi_irq; tqspi->irq = qspi_irq; tqspi->clk =devm_clk_get (&pdev->dev,"qspi" );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 203/913 stack: Constrain and fix stack offset randomization with Clang builds
In reply to Greg Kroah-HartmanFrom: Marco Elver <[email protected]>
[ Upstream commit efa90c11f62e6b7252fb75efe2787056872a627c ]
All supported versions of Clang perform auto-init of __builtin_alloca() when stack auto-init is on (CONFIG_INIT_STACK_ALL_{ZERO,PATTERN}).
add_random_kstack_offset() uses __builtin_alloca() to add a stack offset. This means, when CONFIG_INIT_STACK_ALL_{ZERO,PATTERN} is enabled, add_random_kstack_offset() will auto-init that unused portion of the stack used to add an offset.
There are several problems with this:
1. These offsets can be as large as 1023 bytes. Performing memset() on them isn't exactly cheap, and this is done on every syscall entry.
2. Architectures adding add_random_kstack_offset() to syscall entry implemented in C require them to be 'noinstr' (e.g. see x86 and s390). The potential problem here is that a call to memset may occur, which is not noinstr.
A x86_64 defconfig kernel with Clang 11 and CONFIG_VMLINUX_VALIDATION shows:
| vmlinux.o: warning: objtool: do_syscall_64()+0x9d: call to memset() leaves .noinstr.text section | vmlinux.o: warning: objtool: do_int80_syscall_32()+0xab: call to memset() leaves .noinstr.text section | vmlinux.o: warning: objtool: __do_fast_syscall_32()+0xe2: call to memset() leaves .noinstr.text section | vmlinux.o: warning: objtool: fixup_bad_iret()+0x2f: call to memset() leaves .noinstr.text section
Clang 14 (unreleased) will introduce a way to skip alloca initialization via __builtin_alloca_uninitialized() (https://reviews.llvm.org/D115440).
Constrain RANDOMIZE_KSTACK_OFFSET to only be enabled if no stack auto-init is enabled, the compiler is GCC, or Clang is version 14+. Use __builtin_alloca_uninitialized() if the compiler provides it, as is done by Clang 14.
--- arch/Kconfig | 1 + include/linux/randomize_kstack.h | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-)
arch/Kconfig +1 -0
@@ -1141,6 +1141,7 @@ config HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET config RANDOMIZE_KSTACK_OFFSET_DEFAULT bool "Randomize kernel stack offset on syscall entry" depends on HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET + depends on INIT_STACK_NONE || !CC_IS_CLANG || CLANG_VERSION >= 140000 help The kernel stack offset can be randomized (after pt_regs) by roughly 5 bits of entropy, frustrating memory corruption
include/linux/randomize_kstack.h +14 -2
@@ -16,8 +16,20 @@ DECLARE_PER_CPU(u32, kstack_offset);* alignment. Also, since this use is being explicitly masked to a max of * 10 bits, stack-clash style attacks are unlikely. For more details see * "VLAs" in Documentation/process/deprecated.rst +* +* The normal __builtin_alloca() is initialized with INIT_STACK_ALL (currently +* only with Clang and not GCC). Initializing the unused area on each syscall +* entry is expensive, and generating an implicit call to memset() may also be +* problematic (such as in noinstr functions). Therefore, if the compiler +* supports it (which it should if it initializes allocas), always use the +* "uninitialized" variant of the builtin. */ -void *__builtin_alloca (size_t size); +#if __has_builtin (__builtin_alloca_uninitialized) +#define __kstack_alloca __builtin_alloca_uninitialized +#else +#define __kstack_alloca __builtin_alloca +#endif +/* * Use, at most, 10 bits of entropy. We explicitly cap this to keep the * "VLA" from being unbounded (see above). 10 bits leaves enough room for
@@ -36,7 +48,7 @@ void *__builtin_alloca(size_t size);if (static_branch_maybe (CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT , \ &randomize_kstack_offset)) { \u32 offset =raw_cpu_read (kstack_offset); \ -u8 *ptr =__builtin_alloca (KSTACK_OFFSET_MAX (offset)); \ +u8 *ptr =__kstack_alloca (KSTACK_OFFSET_MAX (offset)); \/* Keep allocation even after "ptr" loses scope. */ \ asmvolatile ("" ::"r" (ptr) :"memory" ); \ } \
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 204/913 arm64/mm: avoid fixmap race condition when create pud mapping
In reply to Greg Kroah-HartmanFrom: Jianyong Wu <[email protected]>
[ Upstream commit ee017ee353506fcec58e481673e4331ff198a80e ]
The 'fixmap' is a global resource and is used recursively by create pud mapping(), leading to a potential race condition in the presence of a concurrent call to alloc_init_pud():
kernel_init thread virtio-mem workqueue thread
================== ===========================
alloc_init_pud(...) alloc_init_pud(...)
pudp = pud_set_fixmap_offset(...) pudp = pud_set_fixmap_offset(...)
READ_ONCE(*pudp)
pud_clear_fixmap(...)
READ_ONCE(*pudp) // CRASH!
As kernel may sleep during creating pud mapping, introduce a mutex lock to serialise use of the fixmap entries by alloc_init_pud(). However, there is no need for locking in early boot stage and it doesn't work well with KASLR enabled when early boot. So, enable lock when system_state doesn't equal to "SYSTEM_BOOTING".
--- arch/arm64/mm/mmu.c | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm64/mm/mmu.c +9 -0
@@ -63,6 +63,7 @@ static pmd_t bm_pmd[PTRS_PER_PMD] __page_aligned_bss __maybe_unused; static pud_t bm_pud[PTRS_PER_PUD] __page_aligned_bss __maybe_unused;static DEFINE_SPINLOCK (swapper_pgdir_lock); +static DEFINE_MUTEX (fixmap_lock);void set_swapper_pgd (pgd_t *pgdp,pgd_t pgd) {
@@ -328,6 +329,12 @@ static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end, }BUG_ON (p4d_bad (p4d)); +/* +* No need for locking during early boot. And it doesn't work as +* expected with KASLR enabled. +*/ +if (system_state !=SYSTEM_BOOTING ) +mutex_lock (&fixmap_lock); pudp =pud_set_fixmap_offset (p4dp, addr); do { pud_t old_pud = READ_ONCE(*pudp);
@@ -358,6 +365,8 @@ static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end, }while (pudp++, addr = next, addr != end);pud_clear_fixmap (); +if (system_state !=SYSTEM_BOOTING ) +mutex_unlock (&fixmap_lock); } static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 205/913 blk-cgroup: set blkg iostat after percpu stat aggregation
In reply to Greg Kroah-HartmanFrom: Chengming Zhou <[email protected]>
[ Upstream commit f122d103b564e5fb7c82de902c6f8f6cbdf50ec9 ]
Don't need to do blkg_iostat_set for top blkg iostat on each CPU, so move it after percpu stat aggregation.
--- block/blk-cgroup.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
block/blk-cgroup.c +5 -5
@@ -855,11 +855,11 @@ static void blkcg_fill_root_iostats(void)blk_queue_root_blkg (bdev->bd_disk->queue);struct blkg_iostat tmp;int cpu; +unsigned long flags;memset (&tmp,0 ,sizeof (tmp));for_each_possible_cpu (cpu) {struct disk_stats *cpu_dkstats; -unsigned long flags; cpu_dkstats =per_cpu_ptr (bdev->bd_stats, cpu); tmp.ios[BLKG_IOSTAT_READ] +=
@@ -875,11 +875,11 @@ static void blkcg_fill_root_iostats(void) cpu_dkstats->sectors[STAT_WRITE ] <<9 ; tmp.bytes[BLKG_IOSTAT_DISCARD ] += cpu_dkstats->sectors[STAT_DISCARD ] <<9 ; - - flags =u64_stats_update_begin_irqsave (&blkg->iostat.sync); -blkg_iostat_set (&blkg->iostat.cur, &tmp); -u64_stats_update_end_irqrestore (&blkg->iostat.sync, flags); } + + flags =u64_stats_update_begin_irqsave (&blkg->iostat.sync); +blkg_iostat_set (&blkg->iostat.cur, &tmp); +u64_stats_update_end_irqrestore (&blkg->iostat.sync, flags); } }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 206/913 selftests/x86: Add validity check and allow field splitting
In reply to Greg Kroah-HartmanFrom: Muhammad Usama Anjum <[email protected]>
[ Upstream commit b06e15ebd5bfb670f93c7f11a29b8299c1178bc6 ]
Add check to test if CC has a string. CC can have multiple sub-strings like "ccache gcc". Erorr pops up if it is treated as single string and double quotes are used around it. This can be fixed by removing the quotes and not treating CC as a single string.
--- tools/testing/selftests/x86/check_cc.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/x86/check_cc.sh +1 -1
@@ -7,7 +7,7 @@ CC="$1" TESTPROG="$2" shift 2 -if "$CC" -o /dev/null "$TESTPROG" -O0 "$@" 2>/dev/null; then +if [ -n "$CC" ] && $CC -o /dev/null "$TESTPROG" -O0 "$@" 2>/dev/null; then echo 1 else echo 0
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 207/913 selftests/sgx: Treat CC as one argument
In reply to Greg Kroah-HartmanFrom: Muhammad Usama Anjum <[email protected]>
[ Upstream commit 6170abb21e2380477080b25145da9747ad467d3d ]
CC can have multiple sub-strings like "ccache gcc". For check_cc.sh, CC needs to be treated like one argument. Put double quotes around it to make CC one string and hence one argument.
--- tools/testing/selftests/sgx/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/sgx/Makefile +1 -1
@@ -4,7 +4,7 @@ include ../lib.mk .PHONY: all clean -CAN_BUILD_X86_64 := $(shell ../x86/check_cc.sh $(CC) \ +CAN_BUILD_X86_64 := $(shell ../x86/check_cc.sh "$(CC)" \ ../x86/trivial_64bit_program.c) ifndef OBJCOPY
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 208/913 crypto: rockchip - ECB does not need IV
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
[ Upstream commit 973d74e93820d99d8ea203882631c76edab699c9 ]
When loading rockchip crypto module, testmgr complains that ivsize of ecb-des3-ede-rk is not the same than generic implementation.
In fact ECB does not use an IV.
--- drivers/crypto/rockchip/rk3288_crypto_skcipher.c | 1 - 1 file changed, 1 deletion(-)
drivers/crypto/rockchip/rk3288_crypto_skcipher.c +0 -1
@@ -506,7 +506,6 @@ struct rk_crypto_tmp rk_ecb_des3_ede_alg = { .exit = rk_ablk_exit_tfm, .min_keysize = DES3_EDE_KEY_SIZE, .max_keysize = DES3_EDE_KEY_SIZE, - .ivsize = DES_BLOCK_SIZE, .setkey = rk_tdes_setkey, .encrypt = rk_des3_ede_ecb_encrypt, .decrypt = rk_des3_ede_ecb_decrypt,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 209/913 audit: log AUDIT_TIME_* records only from rules
In reply to Greg Kroah-HartmanFrom: Richard Guy Briggs <[email protected]>
[ Upstream commit 272ceeaea355214b301530e262a0df8600bfca95 ]
AUDIT_TIME_* events are generated when there are syscall rules present that are not related to time keeping. This will produce noisy log entries that could flood the logs and hide events we really care about.
Rather than immediately produce the AUDIT_TIME_* records, store the data in the context and log it at syscall exit time respecting the filter rules.
Note: This eats the audit_buffer, unlike any others in show_special().
Please see https://bugzilla.redhat.com/show_bug.cgi?id=1991919
--- kernel/audit.h | 4 +++ kernel/auditsc.c | 87 +++++++++++++++++++++++++++++++++++++----------- 2 files changed, 71 insertions(+), 20 deletions(-)
kernel/audit.h +4 -0
@@ -194,6 +194,10 @@ struct audit_context {struct {char *name; } module; +struct { +struct audit_ntp_data ntp_data; +struct timespec64 tk_injoffset; + } time; };int fds[2 ];struct audit_proctitle proctitle;
kernel/auditsc.c +67 -20
110 lines not on this page · raw message
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 210/913 EVM: fix the evm= __setup handler return value
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit f2544f5e6c691679d56bb38637d2f347075b36fa ]
__setup() handlers should return 1 if the parameter is handled. Returning 0 causes the entire string to be added to init's environment strings (limited to 32 strings), unnecessarily polluting it.
Using the documented string "evm=fix" causes an Unknown parameter message:
Unknown kernel command line parameters "BOOT_IMAGE=/boot/bzImage-517rc5 evm=fix", will be passed to user space.
and that string is added to init's environment string space:
Run /sbin/init as init process
with arguments:
/sbin/init
with environment:
HOME=/
TERM=linux
BOOT_IMAGE=/boot/bzImage-517rc5
evm=fixWith this change, using "evm=fix" acts as expected and an invalid option ("evm=evm") causes a warning to be printed:
evm: invalid "evm" mode
but init's environment is not polluted with this string, as expected.
--- security/integrity/evm/evm_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/integrity/evm/evm_main.c +1 -1
@@ -86,7 +86,7 @@ static int __init evm_set_fixmode(char *str)else pr_err ("invalid \"%s\" mode" , str); -return 0 ; +return 1 ; }__setup ("evm=" , evm_set_fixmode);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 211/913 crypto: ccree - dont attempt 0 len DMA mappings
In reply to Greg Kroah-HartmanFrom: Gilad Ben-Yossef <[email protected]>
[ Upstream commit 1fb37b5692c915edcc2448a6b37255738c7c77e0 ]
Refuse to try mapping zero bytes as this may cause a fault on some configurations / platforms and it seems the prev. attempt is not enough and we need to be more explicit.
scatterlists")
--- drivers/crypto/ccree/cc_buffer_mgr.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/crypto/ccree/cc_buffer_mgr.c +7 -0
@@ -258,6 +258,13 @@ static int cc_map_sg(struct device *dev, struct scatterlist *sg, {int ret =0 ; +if (!nbytes) { + *mapped_nents =0 ; + *lbytes =0 ; + *nents =0 ; +return 0 ; + } + *nents =cc_get_sgl_nents (dev, sg, nbytes, lbytes);if (*nents > max_sg_nents) { *nents =0 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 212/913 crypto: hisilicon/sec - fix the aead software fallback for engine
In reply to Greg Kroah-HartmanFrom: Kai Ye <[email protected]>
[ Upstream commit 0a2a464f863187f97e96ebc6384c052cafd4a54c ]
Due to the subreq pointer misuse the private context memory. The aead soft crypto occasionally casues the OS panic as setting the 64K page. Here is fix it.
--- drivers/crypto/hisilicon/sec2/sec_crypto.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/crypto/hisilicon/sec2/sec_crypto.c +13 -3
@@ -2284,9 +2284,10 @@ static int sec_aead_soft_crypto(struct sec_ctx *ctx, struct aead_request *aead_req, bool encrypt) { -struct aead_request *subreq =aead_request_ctx (aead_req);struct sec_auth_ctx *a_ctx = &ctx->a_ctx;struct device *dev = ctx->dev; +struct aead_request *subreq; +int ret;/* Kunpeng920 aead mode not support input 0 size */ if (!a_ctx->fallback_aead_tfm) {
@@ -2294,6 +2295,10 @@ static int sec_aead_soft_crypto(struct sec_ctx *ctx,return -EINVAL ; } + subreq =aead_request_alloc (a_ctx->fallback_aead_tfm,GFP_KERNEL ); +if (!subreq) +return -ENOMEM ; +aead_request_set_tfm (subreq, a_ctx->fallback_aead_tfm);aead_request_set_callback (subreq, aead_req->base.flags, aead_req->base.complete, aead_req->base.data);
@@ -2301,8 +2306,13 @@ static int sec_aead_soft_crypto(struct sec_ctx *ctx, aead_req->cryptlen, aead_req->iv);aead_request_set_ad (subreq, aead_req->assoclen); -return encrypt ?crypto_aead_encrypt (subreq) : -crypto_aead_decrypt (subreq); +if (encrypt) + ret =crypto_aead_encrypt (subreq); +else + ret =crypto_aead_decrypt (subreq); +aead_request_free (subreq); + +return ret; }static int sec_aead_crypto (struct aead_request *a_req,bool encrypt)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 213/913 spi: pxa2xx-pci: Balance reference count for PCI DMA device
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 609d7ffdc42199a0ec949db057e3b4be6745d6c5 ]
The pci_get_slot() increases its reference count, the caller must decrement the reference count by calling pci_dev_put().
--- drivers/spi/spi-pxa2xx-pci.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/spi/spi-pxa2xx-pci.c +16 -1
@@ -76,14 +76,23 @@ static bool lpss_dma_filter(struct dma_chan *chan, void *param)return true; } +static void lpss_dma_put_device (void *dma_dev) +{ +pci_dev_put (dma_dev); +} +static int lpss_spi_setup (struct pci_dev *dev,struct pxa_spi_info *c) {struct pci_dev *dma_dev; +int ret; c->num_chipselect =1 ; c->max_clk_rate =50000000 ; dma_dev =pci_get_slot (dev->bus,PCI_DEVFN (PCI_SLOT (dev->devfn),0 )); + ret =devm_add_action_or_reset (&dev->dev, lpss_dma_put_device, dma_dev); +if (ret) +return ret;if (c->tx_param) {struct dw_dma_slave *slave = c->tx_param;
@@ -107,8 +116,9 @@ static int lpss_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)static int mrfld_spi_setup (struct pci_dev *dev,struct pxa_spi_info *c) { -struct pci_dev *dma_dev =pci_get_slot (dev->bus,PCI_DEVFN (21 ,0 ));struct dw_dma_slave *tx, *rx; +struct pci_dev *dma_dev; +int ret;switch (PCI_FUNC (dev->devfn)) {case 0 :
@@ -133,6 +143,11 @@ static int mrfld_spi_setup(struct pci_dev *dev, struct pxa_spi_info *c)return -ENODEV ; } + dma_dev =pci_get_slot (dev->bus,PCI_DEVFN (21 ,0 )); + ret =devm_add_action_or_reset (&dev->dev, lpss_dma_put_device, dma_dev); +if (ret) +return ret; + tx = c->tx_param; tx->dma_dev = &dma_dev->dev;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 214/913 hwmon: (pmbus) Add mutex to regulator ops
In reply to Greg Kroah-HartmanFrom: Patrick Rudolph <[email protected]>
[ Upstream commit 686d303ee6301261b422ea51e64833d7909a2c36 ]
On PMBUS devices with multiple pages, the regulator ops need to be protected with the update mutex. This prevents accidentally changing the page in a separate thread while operating on the PMBUS_OPERATION register.
Tested on Infineon xdpe11280 while a separate thread polls for sensor data.
--- drivers/hwmon/pmbus/pmbus_core.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +13 -3
@@ -2391,10 +2391,14 @@ static int pmbus_regulator_is_enabled(struct regulator_dev *rdev) {struct device *dev =rdev_get_dev (rdev);struct i2c_client *client =to_i2c_client (dev->parent); +struct pmbus_data *data =i2c_get_clientdata (client);u8 page =rdev_get_id (rdev);int ret; +mutex_lock (&data->update_lock); ret =pmbus_read_byte_data (client, page,PMBUS_OPERATION ); +mutex_unlock (&data->update_lock); +if (ret <0 )return ret;
@@ -2405,11 +2409,17 @@ static int _pmbus_regulator_on_off(struct regulator_dev *rdev, bool enable) {struct device *dev =rdev_get_dev (rdev);struct i2c_client *client =to_i2c_client (dev->parent); +struct pmbus_data *data =i2c_get_clientdata (client);u8 page =rdev_get_id (rdev); +int ret; -return pmbus_update_byte_data (client, page,PMBUS_OPERATION , -PB_OPERATION_CONTROL_ON , - enable ?PB_OPERATION_CONTROL_ON :0 ); +mutex_lock (&data->update_lock); + ret =pmbus_update_byte_data (client, page,PMBUS_OPERATION , +PB_OPERATION_CONTROL_ON , + enable ?PB_OPERATION_CONTROL_ON :0 ); +mutex_unlock (&data->update_lock); + +return ret; }static int pmbus_regulator_enable (struct regulator_dev *rdev)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 215/913 hwmon: (sch56xx-common) Replace WDOG_ACTIVE with WDOG_HW_RUNNING
In reply to Greg Kroah-HartmanFrom: Armin Wolf <[email protected]>
[ Upstream commit 647d6f09bea7dacf4cdb6d4ea7e3051883955297 ]
If the watchdog was already enabled by the BIOS after booting, the watchdog infrastructure needs to regularly send keepalives to prevent a unexpected reset.WDOG_ACTIVE only serves as an status indicator for userspace, we want to use WDOG_HW_RUNNING instead.
Since my Fujitsu Esprimo P720 does not support the watchdog, this change is compile-tested only.
--- drivers/hwmon/sch56xx-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/sch56xx-common.c +1 -1
@@ -422,7 +422,7 @@ void sch56xx_watchdog_register(struct device *parent, u16 addr, u32 revision, data->wddev.max_timeout =255 *60 ;watchdog_set_nowayout (&data->wddev, nowayout);if (output_enable &SCH56XX_WDOG_OUTPUT_ENABLE ) -set_bit (WDOG_ACTIVE , &data->wddev.status); +set_bit (WDOG_HW_RUNNING , &data->wddev.status);/* Since the watchdog uses a downcounter there is no register to read the BIOS set timeout from (if any was set at all) ->
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 216/913 nvme: cleanup __nvme_check_ids
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit fd8099e7918cd2df39ef306dd1d1af7178a15b81 ]
Pass the actual nvme_ns_ids used for the comparison instead of the ns_head that isn't needed and use a more descriptive function name.
--- drivers/nvme/host/core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/nvme/host/core.c +4 -5
@@ -3534,16 +3534,15 @@ static struct nvme_ns_head *nvme_find_ns_head(struct nvme_subsystem *subsys,return NULL ; } -static int __nvme_check_ids (struct nvme_subsystem *subsys, -struct nvme_ns_head *new) +static int nvme_subsys_check_duplicate_ids (struct nvme_subsystem *subsys, +struct nvme_ns_ids *ids) {struct nvme_ns_head *h;lockdep_assert_held (&subsys->lock);list_for_each_entry (h, &subsys->nsheads, entry) { -if (nvme_ns_ids_valid (&new->ids) && -nvme_ns_ids_equal (&new->ids, &h->ids)) +if (nvme_ns_ids_valid (ids) &&nvme_ns_ids_equal (ids, &h->ids))return -EINVAL ; }
@@ -3642,7 +3641,7 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl, head->ids = *ids;kref_init (&head->ref); - ret =__nvme_check_ids (ctrl->subsys, head); + ret =nvme_subsys_check_duplicate_ids (ctrl->subsys, &head->ids);if (ret) {dev_err (ctrl->device,"duplicate IDs for nsid %d\n" , nsid);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 217/913 nvme: fix the check for duplicate unique identifiers
In reply to Greg Kroah-HartmanFrom: Christoph Hellwig <[email protected]>
[ Upstream commit e2724cb9f0c406b8fb66efd3aa9e8b3edfd8d5c8 ]
nvme_subsys_check_duplicate_ids should needs to return an error if any of the identifiers matches, not just if all of them match. But it does not need to and should not look at the CSI value for this sanity check.
Rewrite the logic to be separate from nvme_ns_ids_equal and optimize it by reducing duplicate checks for non-present identifiers.
--- drivers/nvme/host/core.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/nvme/host/core.c +10 -8
@@ -1674,13 +1674,6 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns)blk_queue_max_write_zeroes_sectors (queue,UINT_MAX ); } -static bool nvme_ns_ids_valid (struct nvme_ns_ids *ids) -{ -return !uuid_is_null (&ids->uuid) || -memchr_inv (ids->nguid,0 ,sizeof (ids->nguid)) || -memchr_inv (ids->eui64,0 ,sizeof (ids->eui64)); -} -static bool nvme_ns_ids_equal (struct nvme_ns_ids *a,struct nvme_ns_ids *b) { return uuid_equal(&a->uuid, &b->uuid) &&
@@ -3537,12 +3530,21 @@ static struct nvme_ns_head *nvme_find_ns_head(struct nvme_subsystem *subsys,static int nvme_subsys_check_duplicate_ids (struct nvme_subsystem *subsys,struct nvme_ns_ids *ids) { +bool has_uuid = !uuid_is_null (&ids->uuid); +bool has_nguid =memchr_inv (ids->nguid,0 ,sizeof (ids->nguid)); +bool has_eui64 =memchr_inv (ids->eui64,0 ,sizeof (ids->eui64));struct nvme_ns_head *h;lockdep_assert_held (&subsys->lock);list_for_each_entry (h, &subsys->nsheads, entry) { -if (nvme_ns_ids_valid (ids) &&nvme_ns_ids_equal (ids, &h->ids)) +if (has_uuid &&uuid_equal (&ids->uuid, &h->ids.uuid)) +return -EINVAL ; +if (has_nguid && +memcmp (&ids->nguid, &h->ids.nguid,sizeof (ids->nguid)) ==0 ) +return -EINVAL ; +if (has_eui64 && +memcmp (&ids->eui64, &h->ids.eui64,sizeof (ids->eui64)) ==0 )return -EINVAL ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 218/913 block: dont delete queue kobject before its children
In reply to Greg Kroah-HartmanFrom: Eric Biggers <[email protected]>
[ Upstream commit 0f69288253e9fc7c495047720e523b9f1aba5712 ]
kobjects aren't supposed to be deleted before their child kobjects are deleted. Apparently this is usually benign; however, a WARN will be triggered if one of the child kobjects has a named attribute group:
sysfs group 'modes' not found for kobject 'crypto'
WARNING: CPU: 0 PID: 1 at fs/sysfs/group.c:278 sysfs_remove_group+0x72/0x80
...
Call Trace:
sysfs_remove_groups+0x29/0x40 fs/sysfs/group.c:312
__kobject_del+0x20/0x80 lib/kobject.c:611
kobject_cleanup+0xa4/0x140 lib/kobject.c:696
kobject_release lib/kobject.c:736 [inline]
kref_put include/linux/kref.h:65 [inline]
kobject_put+0x53/0x70 lib/kobject.c:753
blk_crypto_sysfs_unregister+0x10/0x20 block/blk-crypto-sysfs.c:159
blk_unregister_queue+0xb0/0x110 block/blk-sysfs.c:962
del_gendisk+0x117/0x250 block/genhd.c:610Fix this by moving the kobject_del() and the corresponding kobject_uevent() to the correct place.
--- block/blk-sysfs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
block/blk-sysfs.c +5 -3
@@ -954,15 +954,17 @@ void blk_unregister_queue(struct gendisk *disk)*/ if (queue_is_mq (q))blk_mq_unregister_dev (disk_to_dev (disk), q); - -kobject_uevent (&q->kobj,KOBJ_REMOVE ); -kobject_del (&q->kobj);blk_trace_remove_sysfs (disk_to_dev (disk));mutex_lock (&q->sysfs_lock);if (q->elevator)elv_unregister_queue (q);mutex_unlock (&q->sysfs_lock); + +/* Now that we've deleted all child objects, we can delete the queue. */ +kobject_uevent (&q->kobj,KOBJ_REMOVE ); +kobject_del (&q->kobj); +mutex_unlock (&q->sysfs_dir_lock);kobject_put (&disk_to_dev (disk)->kobj);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 219/913 PM: hibernate: fix __setup handler error handling
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit ba7ffcd4c4da374b0f64666354eeeda7d3827131 ]
If an invalid value is used in "resumedelay=<seconds>", it is silently ignored. Add a warning message and then let the __setup handler return 1 to indicate that the kernel command line option has been handled.
--- kernel/power/hibernate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/hibernate.c +1 -1
@@ -1326,7 +1326,7 @@ static int __init resumedelay_setup(char *str)int rc =kstrtouint (str,0 , &resume_delay);if (rc) -return rc; +pr_warn ("resumedelay: bad option string '%s'\n" , str);return 1 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 220/913 PM: suspend: fix return value of __setup handler
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 7a64ca17e4dd50d5f910769167f3553902777844 ]
If an invalid option is given for "test_suspend=<option>", the entire string is added to init's environment, so return 1 instead of 0 from the __setup handler.
Unknown kernel command line parameters "BOOT_IMAGE=/boot/bzImage-517rc5
test_suspend=invalid"
and
Run /sbin/init as init process
with arguments:
/sbin/init
with environment:
HOME=/
TERM=linux
BOOT_IMAGE=/boot/bzImage-517rc5
test_suspend=invalid--- kernel/power/suspend_test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/power/suspend_test.c +4 -4
@@ -157,22 +157,22 @@ static int __init setup_test_suspend(char *value) value++; suspend_type =strsep (&value,"," );if (!suspend_type) -return 0 ; +return 1 ; repeat =strsep (&value,"," );if (repeat) {if (kstrtou32 (repeat,0 , &test_repeat_count_max)) -return 0 ; +return 1 ; }for (i =PM_SUSPEND_MIN ; i <PM_SUSPEND_MAX ; i++)if (!strcmp (pm_labels[i], suspend_type)) { test_state_label = pm_labels[i]; -return 0 ; +return 1 ; }printk (warn_bad_state, suspend_type); -return 0 ; +return 1 ; }__setup ("test_suspend" , setup_test_suspend);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 221/913 spi: spi-zynqmp-gqspi: Handle error for dma_set_mask
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit 13262fc26c1837c51a5131dbbdd67a2387f8bfc7 ]
As the potential failure of the dma_set_mask(),
it should be better to check it and return error
if fails.
--- drivers/spi/spi-zynqmp-gqspi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/spi/spi-zynqmp-gqspi.c +4 -1
@@ -1172,7 +1172,10 @@ static int zynqmp_qspi_probe(struct platform_device *pdev) goto clk_dis_all; } -dma_set_mask (&pdev->dev,DMA_BIT_MASK (44 )); + ret =dma_set_mask (&pdev->dev,DMA_BIT_MASK (44 )); +if (ret) + goto clk_dis_all; + ctlr->bits_per_word_mask =SPI_BPW_MASK (8 ); ctlr->num_chipselect =GQSPI_DEFAULT_NUM_CS ; ctlr->mem_ops = &zynqmp_qspi_mem_ops;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 222/913 hwrng: atmel - disable trng on failure path
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit a223ea9f89ab960eb254ba78429efd42eaf845eb ]
Call atmel_trng_disable() on failure path of probe.
--- drivers/char/hw_random/atmel-rng.c | 1 + 1 file changed, 1 insertion(+)
drivers/char/hw_random/atmel-rng.c +1 -0
@@ -114,6 +114,7 @@ static int atmel_trng_probe(struct platform_device *pdev) err_register:clk_disable_unprepare (trng->clk); +atmel_trng_disable (trng);return ret; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 223/913 crypto: sun8i-ss - call finalize with bh disabled
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
[ Upstream commit b169b3766242b6f3336e24a6c8ee1522978b57a7 ]
Doing ipsec produces a spinlock recursion warning.
This is due to not disabling BH during crypto completion function.
--- drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c | 3 +++ drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c | 3 +++ 2 files changed, 6 insertions(+)
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-cipher.c +3 -0
@@ -11,6 +11,7 @@* You could find a link for the datasheet in Documentation/arm/sunxi.rst */ +#include <linux/bottom_half.h> #include <linux/crypto.h> #include <linux/dma-mapping.h> #include <linux/io.h>
@@ -274,7 +275,9 @@ static int sun8i_ss_handle_cipher_request(struct crypto_engine *engine, void *ar struct skcipher_request *breq = container_of(areq, struct skcipher_request, base); err =sun8i_ss_cipher (breq); +local_bh_disable ();crypto_finalize_skcipher_request (engine, breq, err); +local_bh_enable ();return 0 ; }
drivers/crypto/allwinner/sun8i-ss/sun8i-ss-hash.c +3 -0
@@ -9,6 +9,7 @@* * You could find the datasheet in Documentation/arm/sunxi.rst */ +#include <linux/bottom_half.h> #include <linux/dma-mapping.h> #include <linux/pm_runtime.h> #include <linux/scatterlist.h>
@@ -442,6 +443,8 @@ int sun8i_ss_hash_run(struct crypto_engine *engine, void *breq) theend:kfree (pad);kfree (result); +local_bh_disable ();crypto_finalize_hash_request (engine, breq, err); +local_bh_enable ();return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 224/913 crypto: sun8i-ce - call finalize with bh disabled
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
[ Upstream commit f75a749b6d78aeae2ce90e14fcc4b7b3ba46126d ]
Doing ipsec produces a spinlock recursion warning.
This is due to not disabling BH during crypto completion function.
--- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c | 3 +++ drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c | 3 +++ 2 files changed, 6 insertions(+)
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +3 -0
@@ -11,6 +11,7 @@* You could find a link for the datasheet in Documentation/arm/sunxi.rst */ +#include <linux/bottom_half.h> #include <linux/crypto.h> #include <linux/dma-mapping.h> #include <linux/io.h>
@@ -283,7 +284,9 @@ static int sun8i_ce_cipher_run(struct crypto_engine *engine, void *areq) flow = rctx->flow; err =sun8i_ce_run_task (ce, flow,crypto_tfm_alg_name (breq->base.tfm)); +local_bh_disable ();crypto_finalize_skcipher_request (engine, breq, err); +local_bh_enable ();return 0 ; }
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-hash.c +3 -0
@@ -9,6 +9,7 @@* * You could find the datasheet in Documentation/arm/sunxi.rst */ +#include <linux/bottom_half.h> #include <linux/dma-mapping.h> #include <linux/pm_runtime.h> #include <linux/scatterlist.h>
@@ -414,6 +415,8 @@ int sun8i_ce_hash_run(struct crypto_engine *engine, void *breq) theend:kfree (buf);kfree (result); +local_bh_disable ();crypto_finalize_hash_request (engine, breq, err); +local_bh_enable ();return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 225/913 crypto: amlogic - call finalize with bh disabled
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
[ Upstream commit dba633342994ce47d347bcf5522ba28301247b79 ]
Doing ipsec produces a spinlock recursion warning.
This is due to not disabling BH during crypto completion function.
--- drivers/crypto/amlogic/amlogic-gxl-cipher.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/crypto/amlogic/amlogic-gxl-cipher.c +2 -0
@@ -265,7 +265,9 @@ static int meson_handle_cipher_request(struct crypto_engine *engine, struct skcipher_request *breq = container_of(areq, struct skcipher_request, base); err =meson_cipher (breq); +local_bh_disable ();crypto_finalize_skcipher_request (engine, breq, err); +local_bh_enable ();return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 226/913 crypto: gemini - call finalize with bh disabled
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
[ Upstream commit 7f22421103c5a7f9a1726f0ed125274c38174ddb ]
Doing ipsec produces a spinlock recursion warning.
This is due to not disabling BH during crypto completion function.
--- drivers/crypto/gemini/sl3516-ce-cipher.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/crypto/gemini/sl3516-ce-cipher.c +2 -0
@@ -264,7 +264,9 @@ static int sl3516_ce_handle_cipher_request(struct crypto_engine *engine, void *a struct skcipher_request *breq = container_of(areq, struct skcipher_request, base); err =sl3516_ce_cipher (breq); +local_bh_disable ();crypto_finalize_skcipher_request (engine, breq, err); +local_bh_enable ();return 0 ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 227/913 crypto: vmx - add missing dependencies
In reply to Greg Kroah-HartmanFrom: Petr Vorel <[email protected]>
[ Upstream commit 647d41d3952d726d4ae49e853a9eff68ebad3b3f ]
vmx-crypto module depends on CRYPTO_AES, CRYPTO_CBC, CRYPTO_CTR or CRYPTO_XTS, thus add them.
These dependencies are likely to be enabled, but if CRYPTO_DEV_VMX=y && !CRYPTO_MANAGER_DISABLE_TESTS
and either of CRYPTO_AES, CRYPTO_CBC, CRYPTO_CTR or CRYPTO_XTS is built as module or disabled, alg_test() from crypto/testmgr.c complains during boot about failing to allocate the generic fallback implementations (2 == ENOENT):
[ 0.540953] Failed to allocate xts(aes) fallback: -2 [ 0.541014] alg: skcipher: failed to allocate transform for p8_aes_xts: -2 [ 0.541120] alg: self-tests for p8_aes_xts (xts(aes)) failed (rc=-2) [ 0.544440] Failed to allocate ctr(aes) fallback: -2 [ 0.544497] alg: skcipher: failed to allocate transform for p8_aes_ctr: -2 [ 0.544603] alg: self-tests for p8_aes_ctr (ctr(aes)) failed (rc=-2) [ 0.547992] Failed to allocate cbc(aes) fallback: -2 [ 0.548052] alg: skcipher: failed to allocate transform for p8_aes_cbc: -2 [ 0.548156] alg: self-tests for p8_aes_cbc (cbc(aes)) failed (rc=-2) [ 0.550745] Failed to allocate transformation for 'aes': -2 [ 0.550801] alg: cipher: Failed to load transform for p8_aes: -2 [ 0.550892] alg: self-tests for p8_aes (aes) failed (rc=-2)
--- drivers/crypto/vmx/Kconfig | 4 ++++ 1 file changed, 4 insertions(+)
drivers/crypto/vmx/Kconfig +4 -0
@@ -2,7 +2,11 @@ config CRYPTO_DEV_VMX_ENCRYPT tristate "Encryption acceleration support on P8 CPU" depends on CRYPTO_DEV_VMX + select CRYPTO_AES + select CRYPTO_CBC + select CRYPTO_CTR select CRYPTO_GHASH + select CRYPTO_XTS default m help Support for VMX cryptographic acceleration instructions on Power8 CPU.
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 228/913 clocksource/drivers/timer-ti-dm: Fix regression from errata i940 fix
In reply to Greg Kroah-HartmanFrom: Drew Fustini <[email protected]>
[ Upstream commit bceaae3bac0ce27c549bb050336d8d08abc2ee54 ]
The existing fix for errata i940 causes a conflict for IPU2 which is using timer 3 and 4. From arch/arm/boot/dts/dra7-ipu-dsp-common.dtsi:
&ipu2 {
mboxes = <&mailbox6 &mbox_ipu2_ipc3x>;
ti,timers = <&timer3>;
ti,watchdog-timers = <&timer4>, <&timer9>;
};The conflict was noticed when booting mainline on the BeagleBoard X15 which has a TI AM5728 SoC:
remoteproc remoteproc1: 55020000.ipu is available remoteproc remoteproc1: powering up 55020000.ipu remoteproc remoteproc1: Booting fw image dra7-ipu2-fw.xem4 omap-rproc 55020000.ipu: could not get timer platform device omap-rproc 55020000.ipu: omap_rproc_enable_timers failed: -19 remoteproc remoteproc1: can't start rproc 55020000.ipu: -19
This change modifies the errata fix to instead use timer 15 and 16 which resolves the timer conflict.
It does not appear to introduce any latency regression. Results from cyclictest with original errata fix using dmtimer 3 and 4:
# cyclictest --mlockall --smp --priority=80 --interval=200 --distance=0 policy: fifo: loadavg: 0.02 0.03 0.05
T: 0 ( 1449) P:80 I:200 C: 800368 Min: 0 Act: 32 Avg: 22 Max: 128 T: 1 ( 1450) P:80 I:200 C: 800301 Min: 0 Act: 12 Avg: 23 Max: 70
The results after the change to dmtimer 15 and 16:
# cyclictest --mlockall --smp --priority=80 --interval=200 --distance=0 policy: fifo: loadavg: 0.36 0.19 0.07
T: 0 ( 1711) P:80 I:200 C: 759599 Min: 0 Act: 6 Avg: 22 Max: 108 T: 1 ( 1712) P:80 I:200 C: 759539 Min: 0 Act: 19 Avg: 23 Max: 79
--- arch/arm/boot/dts/dra7-l4.dtsi | 5 ++--- arch/arm/boot/dts/dra7.dtsi | 8 ++++---- drivers/clocksource/timer-ti-dm-systimer.c | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-)
arch/arm/boot/dts/dra7-l4.dtsi +2 -3
@@ -3482,8 +3482,7 @@ ti,timer-pwm; }; }; - - target-module@2c000 { /* 0x4882c000, ap 17 02.0 */ + timer15_target: target-module@2c000 { /* 0x4882c000, ap 17 02.0 */ compatible = "ti,sysc-omap4-timer", "ti,sysc"; reg = <0x2c000 0x4>, <0x2c010 0x4>;
@@ -3511,7 +3510,7 @@ }; }; - target-module@2e000 { /* 0x4882e000, ap 19 14.0 */ + timer16_target: target-module@2e000 { /* 0x4882e000, ap 19 14.0 */ compatible = "ti,sysc-omap4-timer", "ti,sysc"; reg = <0x2e000 0x4>, <0x2e010 0x4>;
arch/arm/boot/dts/dra7.dtsi +4 -4
@@ -1320,20 +1320,20 @@ }; /* Local timers, see ARM architected timer wrap erratum i940 */ -&timer3_target { +&timer15_target { ti,no-reset-on-init; ti,no-idle; timer@0 { - assigned-clocks = <&l4per_clkctrl DRA7_L4PER_TIMER3_CLKCTRL 24>; + assigned-clocks = <&l4per3_clkctrl DRA7_L4PER3_TIMER15_CLKCTRL 24>; assigned-clock-parents = <&timer_sys_clk_div>; }; }; -&timer4_target { +&timer16_target { ti,no-reset-on-init; ti,no-idle; timer@0 { - assigned-clocks = <&l4per_clkctrl DRA7_L4PER_TIMER4_CLKCTRL 24>; + assigned-clocks = <&l4per3_clkctrl DRA7_L4PER3_TIMER16_CLKCTRL 24>; assigned-clock-parents = <&timer_sys_clk_div>; }; };
drivers/clocksource/timer-ti-dm-systimer.c +2 -2
@@ -694,9 +694,9 @@ static int __init dmtimer_percpu_quirk_init(struct device_node *np, u32 pa)return 0 ; } -if (pa ==0x48034000 )/* dra7 dmtimer3 */ +if (pa ==0x4882c000 )/* dra7 dmtimer15 */ return dmtimer_percpu_timer_init (np,0 ); -else if (pa ==0x48036000 )/* dra7 dmtimer4 */ +else if (pa ==0x4882e000 )/* dra7 dmtimer16 */ return dmtimer_percpu_timer_init (np,1 );return 0 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 229/913 clocksource/drivers/exynos_mct: Refactor resources allocation
In reply to Greg Kroah-HartmanFrom: Marek Szyprowski <[email protected]>
[ Upstream commit 7cd925a8823d16de5614d3f0aabea9948747accd ]
Move interrupts allocation from exynos4_timer_resources() into separate function together with the interrupt number parsing code from mct_init_dt(), so the code for managing interrupts is kept together. While touching exynos4_timer_resources() function, move of_iomap() to it. No functional changes.
--- drivers/clocksource/exynos_mct.c | 50 +++++++++++++++++++------------- 1 file changed, 30 insertions(+), 20 deletions(-)
drivers/clocksource/exynos_mct.c +30 -20
@@ -504,11 +504,14 @@ static int exynos4_mct_dying_cpu(unsigned int cpu)return 0 ; } -static int __init exynos4_timer_resources (struct device_node *np,void __iomem *base) +static int __init exynos4_timer_resources (struct device_node *np) { -int err, cpu;struct clk *mct_clk, *tick_clk; + reg_base =of_iomap (np,0 ); +if (!reg_base) +panic ("%s: unable to ioremap mct address space\n" , __func__); + tick_clk =of_clk_get_by_name (np,"fin_pll" );if (IS_ERR (tick_clk))panic ("%s: unable to determine tick clock rate\n" , __func__);
@@ -519,9 +522,27 @@ static int __init exynos4_timer_resources(struct device_node *np, void __iomem *panic ("%s: unable to retrieve mct clock instance\n" , __func__);clk_prepare_enable (mct_clk); - reg_base = base; -if (!reg_base) -panic ("%s: unable to ioremap mct address space\n" , __func__); +return 0 ; +} + +static int __init exynos4_timer_interrupts (struct device_node *np, +unsigned int int_type) +{ +int nr_irqs, i, err, cpu; + + mct_int_type = int_type; + +/* This driver uses only one global timer interrupt */ + mct_irqs[MCT_G0_IRQ ] =irq_of_parse_and_map (np,MCT_G0_IRQ ); + +/* +* Find out the number of local irqs specified. The local +* timer irqs are specified after the four global timer +* irqs are specified. +*/ + nr_irqs =of_irq_count (np); +for (i =MCT_L0_IRQ ; i < nr_irqs; i++) + mct_irqs[i] =irq_of_parse_and_map (np, i);if (mct_int_type ==MCT_INT_PPI ) {
@@ -581,24 +602,13 @@ static int __init exynos4_timer_resources(struct device_node *np, void __iomem *static int __init mct_init_dt (struct device_node *np,unsigned int int_type) { -u32 nr_irqs, i;int ret; - mct_int_type = int_type; - -/* This driver uses only one global timer interrupt */ - mct_irqs[MCT_G0_IRQ ] =irq_of_parse_and_map (np,MCT_G0_IRQ ); - -/* -* Find out the number of local irqs specified. The local -* timer irqs are specified after the four global timer -* irqs are specified. -*/ - nr_irqs =of_irq_count (np); -for (i =MCT_L0_IRQ ; i < nr_irqs; i++) - mct_irqs[i] =irq_of_parse_and_map (np, i); + ret =exynos4_timer_resources (np); +if (ret) +return ret; - ret =exynos4_timer_resources (np,of_iomap (np,0 )); + ret =exynos4_timer_interrupts (np, int_type);if (ret)return ret;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 230/913 clocksource/drivers/exynos_mct: Handle DTS with higher number of interrupts
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit ab8da93dc06d82f464c47ab30e6c75190702f369 ]
The driver statically defines maximum number of interrupts it can handle, however it does not respect that limit when configuring them. When provided with a DTS with more interrupts than assumed, the driver will overwrite static array mct_irqs leading to silent memory corruption.
Validate the interrupts coming from DTS to avoid this. This does not change the fact that such DTS might not boot at all, because it is simply incompatible, however at least some warning will be printed.
--- drivers/clocksource/exynos_mct.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/clocksource/exynos_mct.c +9 -1
@@ -541,6 +541,11 @@ static int __init exynos4_timer_interrupts(struct device_node *np,* irqs are specified. */ nr_irqs =of_irq_count (np); +if (nr_irqs >ARRAY_SIZE (mct_irqs)) { +pr_err ("exynos-mct: too many (%d) interrupts configured in DT\n" , + nr_irqs); + nr_irqs =ARRAY_SIZE (mct_irqs); + }for (i =MCT_L0_IRQ ; i < nr_irqs; i++) mct_irqs[i] =irq_of_parse_and_map (np, i);
@@ -553,11 +558,14 @@ static int __init exynos4_timer_interrupts(struct device_node *np, mct_irqs[MCT_L0_IRQ], err); }else {for_each_possible_cpu (cpu) { -int mct_irq = mct_irqs[MCT_L0_IRQ + cpu]; +int mct_irq;struct mct_clock_event_device *pcpu_mevt =per_cpu_ptr (&percpu_mct_tick, cpu); pcpu_mevt->evt.irq =-1 ; +if (MCT_L0_IRQ + cpu >=ARRAY_SIZE (mct_irqs)) +break ; + mct_irq = mct_irqs[MCT_L0_IRQ + cpu];irq_set_status_flags (mct_irq,IRQ_NOAUTOEN ); if (request_irq(mct_irq,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 231/913 clocksource/drivers/timer-microchip-pit64b: Use notrace
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit ff10ee97cb203262e88d9c8bc87369cbd4004a0c ]
Use notrace for mchp_pit64b_sched_read_clk() to avoid recursive call of prepare_ftrace_return() when issuing:
echo function_graph > /sys/kernel/debug/tracing/current_tracer
--- drivers/clocksource/timer-microchip-pit64b.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/timer-microchip-pit64b.c +1 -1
@@ -165,7 +165,7 @@ static u64 mchp_pit64b_clksrc_read(struct clocksource *cs)return mchp_pit64b_cnt_read (mchp_pit64b_cs_base); } -static u64 mchp_pit64b_sched_read_clk (void ) +static u64 notrace mchp_pit64b_sched_read_clk(void) {return mchp_pit64b_cnt_read (mchp_pit64b_cs_base); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 232/913 clocksource/drivers/timer-of: Check return value of of_iomap in timer_of_base_init()
In reply to Greg Kroah-HartmanFrom: Guillaume Ranquet <[email protected]>
[ Upstream commit 4467b8bad2401794fb89a0268c8c8257180bf60f ]
of_base->base can either be iomapped using of_io_request_and_map() or of_iomap() depending whether or not an of_base->name has been set.
Thus check of_base->base against NULL as of_iomap() does not return a PTR_ERR() in case of error.
--- drivers/clocksource/timer-of.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/clocksource/timer-of.c +3 -3
@@ -157,9 +157,9 @@ static __init int timer_of_base_init(struct device_node *np, of_base->base = of_base->name ?of_io_request_and_map (np, of_base->index, of_base->name) :of_iomap (np, of_base->index); -if (IS_ERR (of_base->base)) { -pr_err ("Failed to iomap (%s)\n" , of_base->name); -return PTR_ERR (of_base->base); +if (IS_ERR_OR_NULL (of_base->base)) { +pr_err ("Failed to iomap (%s:%s)\n" , np->name, of_base->name); +return of_base->base ?PTR_ERR (of_base->base) : -ENOMEM ; }return 0 ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 233/913 arm64: prevent instrumentation of bp hardening callbacks
In reply to Greg Kroah-HartmanFrom: Mark Rutland <[email protected]>
[ Upstream commit 614c0b9fee711dd89b1dd65c88ba83612a373fdc ]
We may call arm64_apply_bp_hardening() early during entry (e.g. in el0_ia()) before it is safe to run instrumented code. Unfortunately this may result in running instrumented code in two cases:
* The hardening callbacks called by arm64_apply_bp_hardening() are not marked as noinstr, and have been observed to be instrumented when compiled with either GCC or LLVM.
* Since arm64_apply_bp_hardening() itself is only marked as inline rather than __always_inline, it is possible that the compiler decides to place it out-of-line, whereupon it may be instrumented.
For example, with defconfig built with clang 13.0.0, call_hvc_arch_workaround_1() is compiled as:
| <call_hvc_arch_workaround_1>: | d503233f paciasp | f81f0ffe str x30, [sp, #-16]! | 320183e0 mov w0, #0x80008000 | d503201f nop | d4000002 hvc #0x0 | f84107fe ldr x30, [sp], #16 | d50323bf autiasp | d65f03c0 ret
... but when CONFIG_FTRACE=y and CONFIG_KCOV=y this is compiled as:
| <call_hvc_arch_workaround_1>: | d503245f bti c | d503201f nop | d503201f nop | d503233f paciasp | a9bf7bfd stp x29, x30, [sp, #-16]! | 910003fd mov x29, sp | 94000000 bl 0 <__sanitizer_cov_trace_pc> | 320183e0 mov w0, #0x80008000 | d503201f nop | d4000002 hvc #0x0 | a8c17bfd ldp x29, x30, [sp], #16 | d50323bf autiasp | d65f03c0 ret
... with a patchable function entry registered with ftrace, and a direct call to __sanitizer_cov_trace_pc(). Neither of these are safe early during entry sequences.
This patch avoids the unsafe instrumentation by marking arm64_apply_bp_hardening() as __always_inline and by marking the hardening functions as noinstr. This avoids the potential for instrumentation, and causes clang to consistently generate the function as with the defconfig sample.
Note: in the defconfig compilation, when CONFIG_SVE=y, x30 is spilled to the stack without being placed in a frame record, which will result in a missing entry if call_hvc_arch_workaround_1() is backtraced. Similar is true of qcom_link_stack_sanitisation(), where inline asm spills the LR to a GPR prior to corrupting it. This is not a significant issue presently as we will only backtrace here if an exception is taken, and in such cases we may omit entries for other reasons today.
The relevant hardening functions were introduced in commits:
ec82b567a74fbdff ("arm64: Implement branch predictor hardening for Falkor") b092201e00206141 ("arm64: Add ARM_SMCCC_ARCH_WORKAROUND_1 BP hardening support")
... and these were subsequently moved in commit:
d4647f0a2ad71110 ("arm64: Rewrite Spectre-v2 mitigation code")
The arm64_apply_bp_hardening() function was introduced in commit:
0f15adbb2861ce6f ("arm64: Add skeleton to harden the branch predictor against aliasing attacks")
... and was subsequently moved and reworked in commit:
6279017e807708a0 ("KVM: arm64: Move BP hardening helpers into spectre.h")
--- arch/arm64/include/asm/spectre.h | 3 ++- arch/arm64/kernel/proton-pack.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-)
arch/arm64/include/asm/spectre.h +2 -1
@@ -67,7 +67,8 @@ struct bp_hardening_data { DECLARE_PER_CPU_READ_MOSTLY(struct bp_hardening_data, bp_hardening_data); -static inline void arm64_apply_bp_hardening (void ) +/* Called during entry so must be __always_inline */ +static __always_inline void arm64_apply_bp_hardening(void) {struct bp_hardening_data *d;
arch/arm64/kernel/proton-pack.c +6 -3
@@ -233,17 +233,20 @@ static void install_bp_hardening_cb(bp_hardening_cb_t fn)__this_cpu_write (bp_hardening_data.slot,HYP_VECTOR_SPECTRE_DIRECT ); } -static void call_smc_arch_workaround_1 (void ) +/* Called during entry so must be noinstr */ +static noinstr void call_smc_arch_workaround_1(void) {arm_smccc_1_1_smc (ARM_SMCCC_ARCH_WORKAROUND_1 ,NULL ); } -static void call_hvc_arch_workaround_1 (void ) +/* Called during entry so must be noinstr */ +static noinstr void call_hvc_arch_workaround_1(void) {arm_smccc_1_1_hvc (ARM_SMCCC_ARCH_WORKAROUND_1 ,NULL ); } -static void qcom_link_stack_sanitisation (void ) +/* Called during entry so must be noinstr */ +static noinstr void qcom_link_stack_sanitisation(void) {u64 tmp;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 234/913 KEYS: trusted: Fix trusted key backends when building as module
In reply to Greg Kroah-HartmanFrom: Andreas Rammhold <[email protected]>
[ Upstream commit 969a26446bcd142faedfe8c6f41cd7668596c1fa ]
Before this commit the kernel could end up with no trusted key sources even though both of the currently supported backends (TPM and TEE) were compiled as modules. This manifested in the trusted key type not being registered at all.
When checking if a CONFIG_… preprocessor variable is defined we only test for the builtin (=y) case and not the module (=m) case. By using the IS_REACHABLE() macro we do test for both cases.
--- security/keys/trusted-keys/trusted_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
security/keys/trusted-keys/trusted_core.c +2 -2
@@ -27,10 +27,10 @@ module_param_named(source, trusted_key_source, charp, 0);MODULE_PARM_DESC (source,"Select trusted keys source (tpm or tee)" );static const struct trusted_key_source trusted_key_sources[] = { -#if defined(CONFIG_TCG_TPM) +#if IS_REACHABLE(CONFIG_TCG_TPM) {"tpm" , &trusted_key_tpm_ops }, #endif -#if defined(CONFIG_TEE) +#if IS_REACHABLE(CONFIG_TEE) {"tee" , &trusted_key_tee_ops }, #endif };
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 235/913 KEYS: trusted: Avoid calling null function trusted_key_exit
In reply to Greg Kroah-HartmanFrom: Dave Kleikamp <[email protected]>
[ Upstream commit c5d1ed846e15090bc90dfdaafc07eac066e070bb ]
If one loads and unloads the trusted module, trusted_key_exit can be NULL. Call it through static_call_cond() to avoid a kernel trap.
--- security/keys/trusted-keys/trusted_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/keys/trusted-keys/trusted_core.c +1 -1
@@ -351,7 +351,7 @@ static int __init init_trusted(void) static void __exit cleanup_trusted(void) { -static_call (trusted_key_exit)(); +static_call_cond (trusted_key_exit)(); }late_initcall (init_trusted);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 236/913 ACPI: APEI: fix return value of __setup handlers
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit f3303ff649dbf7dcdc6a6e1a922235b12b3028f4 ]
__setup() handlers should return 1 to indicate that the boot option has been handled. Returning 0 causes a boot option to be listed in the Unknown kernel command line parameters and also added to init's arg list (if no '=' sign) or environment list (if of the form 'a=b').
Unknown kernel command line parameters "erst_disable
bert_disable hest_disable BOOT_IMAGE=/boot/bzImage-517rc6", will be passed to user space.
Run /sbin/init as init process
with arguments:
/sbin/init
erst_disable
bert_disable
hest_disable
with environment:
HOME=/
TERM=linux
BOOT_IMAGE=/boot/bzImage-517rc6--- drivers/acpi/apei/bert.c | 2 +- drivers/acpi/apei/erst.c | 2 +- drivers/acpi/apei/hest.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/apei/bert.c +1 -1
@@ -77,7 +77,7 @@ static int __init setup_bert_disable(char *str) { bert_disable =1 ; -return 0 ; +return 1 ; }__setup ("bert_disable" , setup_bert_disable);
drivers/acpi/apei/erst.c +1 -1
@@ -891,7 +891,7 @@ EXPORT_SYMBOL_GPL(erst_clear);static int __init setup_erst_disable (char *str) { erst_disable =1 ; -return 0 ; +return 1 ; }__setup ("erst_disable" , setup_erst_disable);
drivers/acpi/apei/hest.c +1 -1
@@ -223,7 +223,7 @@ static int __init hest_ghes_dev_register(unsigned int ghes_count)static int __init setup_hest_disable (char *str) { hest_disable =HEST_DISABLED ; -return 0 ; +return 1 ; }__setup ("hest_disable" , setup_hest_disable);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 237/913 crypto: ccp - ccp_dmaengine_unregister release dma channels
In reply to Greg Kroah-HartmanFrom: Dāvis Mosāns <[email protected]>
[ Upstream commit 54cce8ecb9254f971b40a72911c6da403720a2d2 ]
ccp_dmaengine_register adds dma_chan->device_node to dma_dev->channels list but ccp_dmaengine_unregister didn't remove them.
That can cause crashes in various dmaengine methods that tries to use dma_dev->channels
--- drivers/crypto/ccp/ccp-dmaengine.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/crypto/ccp/ccp-dmaengine.c +16 -0
@@ -632,6 +632,20 @@ static int ccp_terminate_all(struct dma_chan *dma_chan)return 0 ; } +static void ccp_dma_release (struct ccp_device *ccp) +{ +struct ccp_dma_chan *chan; +struct dma_chan *dma_chan; +unsigned int i; + +for (i =0 ; i < ccp->cmd_q_count; i++) { + chan = ccp->ccp_dma_chan + i; + dma_chan = &chan->dma_chan; +tasklet_kill (&chan->cleanup_tasklet); +list_del_rcu (&dma_chan->device_node); + } +} +int ccp_dmaengine_register (struct ccp_device *ccp) {struct ccp_dma_chan *chan;
@@ -736,6 +750,7 @@ int ccp_dmaengine_register(struct ccp_device *ccp)return 0 ; err_reg: +ccp_dma_release (ccp);kmem_cache_destroy (ccp->dma_desc_cache); err_cache:
@@ -752,6 +767,7 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp)return ;dma_async_device_unregister (dma_dev); +ccp_dma_release (ccp);kmem_cache_destroy (ccp->dma_desc_cache);kmem_cache_destroy (ccp->dma_cmd_cache);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 238/913 crypto: ccree - Fix use after free in cc_cipher_exit()
In reply to Greg Kroah-HartmanFrom: Jianglei Nie <[email protected]>
[ Upstream commit 3d950c34074ed74d2713c3856ba01264523289e6 ]
kfree_sensitive(ctx_p->user.key) will free the ctx_p->user.key. But ctx_p->user.key is still used in the next line, which will lead to a use after free.
We can call kfree_sensitive() after dev_dbg() to avoid the uaf.
--- drivers/crypto/ccree/cc_cipher.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/ccree/cc_cipher.c +1 -1
@@ -257,8 +257,8 @@ static void cc_cipher_exit(struct crypto_tfm *tfm) &ctx_p->user.key_dma_addr);/* Free key buffer in context */ -kfree_sensitive (ctx_p->user.key);dev_dbg (dev,"Free key buffer in context. key=@%p\n" , ctx_p->user.key); +kfree_sensitive (ctx_p->user.key); }struct tdes_keys {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 239/913 hwrng: nomadik - Change clk_disable to clk_disable_unprepare
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit 7f0f1f3ef62ed7a40e30aff28115bd94c4211d1d ]
The corresponding API for clk_prepare_enable is clk_disable_unprepare, other than clk_disable_unprepare.
Fix this by changing clk_disable to clk_disable_unprepare.
--- drivers/char/hw_random/nomadik-rng.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/hw_random/nomadik-rng.c +2 -2
@@ -65,14 +65,14 @@ static int nmk_rng_probe(struct amba_device *dev, const struct amba_id *id) out_release:amba_release_regions (dev); out_clk: -clk_disable (rng_clk); +clk_disable_unprepare (rng_clk);return ret; }static void nmk_rng_remove (struct amba_device *dev) {amba_release_regions (dev); -clk_disable (rng_clk); +clk_disable_unprepare (rng_clk); }static const struct amba_id nmk_rng_ids[] = {
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 240/913 hwmon: (pmbus) Add Vin unit off handling
In reply to Greg Kroah-HartmanFrom: Brandon Wyman <[email protected]>
[ Upstream commit a5436af598779219b375c1977555c82def1c35d0 ]
If there is an input undervoltage fault, reported in STATUS_INPUT command response, there is quite likely a "Unit Off For Insufficient Input Voltage" condition as well.
Add a constant for bit 3 of STATUS_INPUT. Update the Vin limit attributes to include both bits in the mask for clearing faults.
If an input undervoltage fault occurs, causing a unit off for insufficient input voltage, but the unit is off bit is not cleared, the STATUS_WORD will not be updated to clear the input fault condition. Including the unit is off bit (bit 3) allows for the input fault condition to completely clear.
--- drivers/hwmon/pmbus/pmbus.h | 1 + drivers/hwmon/pmbus/pmbus_core.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/hwmon/pmbus/pmbus.h +1 -0
@@ -319,6 +319,7 @@ enum pmbus_fan_mode { percent = 0, rpm };/* * STATUS_VOUT, STATUS_INPUT */ +#define PB_VOLTAGE_VIN_OFF BIT(3)#define PB_VOLTAGE_UV_FAULT BIT(4)#define PB_VOLTAGE_UV_WARNING BIT(5)#define PB_VOLTAGE_OV_WARNING BIT(6)
drivers/hwmon/pmbus/pmbus_core.c +1 -1
@@ -1373,7 +1373,7 @@ static const struct pmbus_limit_attr vin_limit_attrs[] = { .reg = PMBUS_VIN_UV_FAULT_LIMIT, .attr = "lcrit", .alarm = "lcrit_alarm", - .sbit = PB_VOLTAGE_UV_FAULT, + .sbit = PB_VOLTAGE_UV_FAULT | PB_VOLTAGE_VIN_OFF, }, { .reg = PMBUS_VIN_OV_WARN_LIMIT, .attr = "max",
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 241/913 clocksource: acpi_pm: fix return value of __setup handler
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 6a861abceecb68497dd82a324fee45a5332dcece ]
__setup() handlers should return 1 to obsolete_checksetup() in init/main.c to indicate that the boot option has been handled. A return of 0 causes the boot option/value to be listed as an Unknown kernel parameter and added to init's (limited) environment strings.
The __setup() handler interface isn't meant to handle negative return values -- they are non-zero, so they mean "handled" (like a return value of 1 does), but that's just a quirk. So return 1 from parse_pmtmr(). Also print a warning message if kstrtouint() returns an error.
--- drivers/clocksource/acpi_pm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/clocksource/acpi_pm.c +4 -2
@@ -229,8 +229,10 @@ static int __init parse_pmtmr(char *arg)int ret; ret =kstrtouint (arg,16 , &base); -if (ret) -return ret; +if (ret) { +pr_warn ("PMTMR: invalid 'pmtmr=' value: '%s'\n" , arg); +return 1 ; + }pr_info ("PMTMR IOPort override: 0x%04x -> 0x%04x\n" , pmtmr_ioport, base);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 242/913 io_uring: dont check unrelated req->open.how in accept request
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
[ Upstream commit adf3a9e9f556613197583a1884f0de40a8bb6fb9 ]
Looks like a victim of too much copy/paste, we should not be looking at req->open.how in accept. The point is to check CLOEXEC and error out, which we don't invalid direct descriptors on exec. Hence any attempt to get a direct descriptor with CLOEXEC is invalid.
No harm is done here, as req->open.how.flags overlaps with req->accept.flags, but it's very confusing and might change if either of those command structs are modified.
--- fs/io_uring.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/io_uring.c +1 -2
@@ -5154,8 +5154,7 @@ static int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) accept->nofile =rlimit (RLIMIT_NOFILE ); accept->file_slot =READ_ONCE (sqe->file_index); -if (accept->file_slot && ((req->open.how.flags &O_CLOEXEC ) || - (accept->flags &SOCK_CLOEXEC ))) +if (accept->file_slot && (accept->flags &SOCK_CLOEXEC ))return -EINVAL ;if (accept->flags & ~(SOCK_CLOEXEC |SOCK_NONBLOCK ))return -EINVAL ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 243/913 io_uring: terminate manual loop iterator loop correctly for non-vecs
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
[ Upstream commit 5e929367468c8f97cd1ffb0417316cecfebef94b ]
The fix for not advancing the iterator if we're using fixed buffers is broken in that it can hit a condition where we don't terminate the loop. This results in io-wq looping forever, asking to read (or write) 0 bytes for every subsequent loop.
--- fs/io_uring.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/io_uring.c +4 -2
@@ -3319,13 +3319,15 @@ static ssize_t loop_rw_iter(int rw, struct io_kiocb *req, struct iov_iter *iter) ret = nr;break ; } + ret += nr;if (!iov_iter_is_bvec (iter)) {iov_iter_advance (iter, nr); }else { - req->rw.len -= nr; req->rw.addr += nr; + req->rw.len -= nr; +if (!req->rw.len) +break ; } - ret += nr;if (nr != iovec.iov_len)break ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 244/913 watch_queue: Fix NULL dereference in error cleanup
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit a635415a064e77bcfbf43da413fd9dfe0bbed9cb ]
In watch_queue_set_size(), the error cleanup code doesn't take account of the fact that __free_page() can't handle a NULL pointer when trying to free up buffer pages that did get allocated.
Fix this by only calling __free_page() on the pages actually allocated.
Without the fix, this can lead to something like the following:
BUG: KASAN: null-ptr-deref in __free_pages+0x1f/0x1b0 mm/page_alloc.c:5473 Read of size 4 at addr 0000000000000034 by task syz-executor168/3599 ... Call Trace: <TASK> __dump_stack lib/dump_stack.c:88 [inline] dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 __kasan_report mm/kasan/report.c:446 [inline] kasan_report.cold+0x66/0xdf mm/kasan/report.c:459 check_region_inline mm/kasan/generic.c:183 [inline] kasan_check_range+0x13d/0x180 mm/kasan/generic.c:189 instrument_atomic_read include/linux/instrumented.h:71 [inline] atomic_read include/linux/atomic/atomic-instrumented.h:27 [inline] page_ref_count include/linux/page_ref.h:67 [inline] put_page_testzero include/linux/mm.h:717 [inline] __free_pages+0x1f/0x1b0 mm/page_alloc.c:5473 watch_queue_set_size+0x499/0x630 kernel/watch_queue.c:275 pipe_ioctl+0xac/0x2b0 fs/pipe.c:632 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:874 [inline] __se_sys_ioctl fs/ioctl.c:860 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:860 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x44/0xae
--- kernel/watch_queue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/watch_queue.c +1 -1
@@ -274,7 +274,7 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)return 0 ; error_p: -for (i =0 ; i < nr_pages; i++) +while (--i >=0 )__free_page (pages[i]);kfree (pages); error:
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 245/913 watch_queue: Actually free the watch
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 3d8dcf278b1ee1eff1e90be848fa2237db4c07a7 ]
free_watch() does everything barring actually freeing the watch object. Fix this by adding the missing kfree.
kmemleak produces a report something like the following. Note that as an address can be seen in the first word, the watch would appear to have gone through call_rcu().
BUG: memory leak
unreferenced object 0xffff88810ce4a200 (size 96):
comm "syz-executor352", pid 3605, jiffies 4294947473 (age 13.720s)
hex dump (first 32 bytes):
e0 82 48 0d 81 88 ff ff 00 00 00 00 00 00 00 00 ..H.............
80 a2 e4 0c 81 88 ff ff 00 00 00 00 00 00 00 00 ................
backtrace:
[<ffffffff8214e6cc>] kmalloc include/linux/slab.h:581 [inline]
[<ffffffff8214e6cc>] kzalloc include/linux/slab.h:714 [inline]
[<ffffffff8214e6cc>] keyctl_watch_key+0xec/0x2e0 security/keys/keyctl.c:1800
[<ffffffff8214ec84>] __do_sys_keyctl+0x3c4/0x490 security/keys/keyctl.c:2016
[<ffffffff84493a25>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
[<ffffffff84493a25>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
[<ffffffff84600068>] entry_SYSCALL_64_after_hwframe+0x44/0xae--- kernel/watch_queue.c | 1 + 1 file changed, 1 insertion(+)
kernel/watch_queue.c +1 -0
@@ -398,6 +398,7 @@ static void free_watch(struct rcu_head *rcu)put_watch_queue (rcu_access_pointer (watch->queue));atomic_dec (&watch->cred->user->nr_watches);put_cred (watch->cred); +kfree (watch); }static void __put_watch (struct kref *kref)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 246/913 f2fs: fix to enable ATGC correctly via gc_idle sysfs interface
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit 7d19e3dab0002e527052b0aaf986e8c32e5537bf ]
It needs to assign sbi->gc_mode with GC_IDLE_AT rather than GC_AT when user tries to enable ATGC via gc_idle sysfs interface, fix it.
--- fs/f2fs/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/sysfs.c +1 -1
@@ -473,7 +473,7 @@ static ssize_t __sbi_store(struct f2fs_attr *a, }else if (t ==GC_IDLE_AT ) {if (!sbi->am.atgc_enabled)return -EINVAL ; - sbi->gc_mode =GC_AT ; + sbi->gc_mode =GC_IDLE_AT ; }else { sbi->gc_mode =GC_NORMAL ; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 247/913 sched/debug: Remove mpol_get/put and task_lock/unlock from sched_show_numa
In reply to Greg Kroah-HartmanFrom: Bharata B Rao <[email protected]>
[ Upstream commit 28c988c3ec29db74a1dda631b18785958d57df4f ]
The older format of /proc/pid/sched printed home node info which required the mempolicy and task lock around mpol_get(). However the format has changed since then and there is no need for sched_show_numa() any more to have mempolicy argument, asssociated mpol_get/put and task_lock/unlock. Remove them.
--- kernel/sched/debug.c | 10 ---------- 1 file changed, 10 deletions(-)
kernel/sched/debug.c +0 -10
@@ -921,25 +921,15 @@ void print_numa_stats(struct seq_file *m, int node, unsigned long tsf,static void sched_show_numa (struct task_struct *p,struct seq_file *m) {#ifdef CONFIG_NUMA_BALANCING -struct mempolicy *pol; -if (p->mm)P (mm->numa_scan_seq); -task_lock (p); - pol = p->mempolicy; -if (pol && !(pol->flags &MPOL_F_MORON )) - pol =NULL ; -mpol_get (pol); -task_unlock (p); -P (numa_pages_migrated);P (numa_preferred_nid);P (total_numa_faults);SEQ_printf (m,"current_node=%d, numa_group_id=%d\n" ,task_node (p),task_numa_group_id (p));show_numa_stats (p, m); -mpol_put (pol);#endif }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 248/913 sched/core: Export pelt_thermal_tp
In reply to Greg Kroah-HartmanFrom: Qais Yousef <[email protected]>
[ Upstream commit 77cf151b7bbdfa3577b3c3f3a5e267a6c60a263b ]
We can't use this tracepoint in modules without having the symbol exported first, fix that.
--- kernel/sched/core.c | 1 + 1 file changed, 1 insertion(+)
kernel/sched/core.c +1 -0
@@ -36,6 +36,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(pelt_rt_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (pelt_dl_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (pelt_irq_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (pelt_se_tp); +EXPORT_TRACEPOINT_SYMBOL_GPL (pelt_thermal_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_cpu_capacity_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_overutilized_tp);EXPORT_TRACEPOINT_SYMBOL_GPL (sched_util_est_cfs_tp);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 249/913 sched/uclamp: Fix iowait boost escaping uclamp restriction
In reply to Greg Kroah-HartmanFrom: Qais Yousef <[email protected]>
[ Upstream commit d37aee9018e68b0d356195caefbb651910e0bbfa ]
iowait_boost signal is applied independently of util and doesn't take into account uclamp settings of the rq. An io heavy task that is capped by uclamp_max could still request higher frequency because sugov_iowait_apply() doesn't clamp the boost via uclamp_rq_util_with() like effective_cpu_util() does.
Make sure that iowait_boost honours uclamp requests by calling uclamp_rq_util_with() when applying the boost.
--- kernel/sched/cpufreq_schedutil.c | 1 + 1 file changed, 1 insertion(+)
kernel/sched/cpufreq_schedutil.c +1 -0
@@ -289,6 +289,7 @@ static void sugov_iowait_apply(struct sugov_cpu *sg_cpu, u64 time)* into the same scale so we can compare. */ boost = (sg_cpu->iowait_boost * sg_cpu->max) >>SCHED_CAPACITY_SHIFT ; + boost =uclamp_rq_util_with (cpu_rq (sg_cpu->cpu), boost,NULL );if (sg_cpu->util < boost) sg_cpu->util = boost; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 250/913 rseq: Remove broken uapi field layout on 32-bit little endian
In reply to Greg Kroah-HartmanFrom: Mathieu Desnoyers <[email protected]>
[ Upstream commit bfdf4e6208051ed7165b2e92035b4bf11f43eb63 ]
The rseq rseq_cs.ptr.{ptr32,padding} uapi endianness handling is entirely wrong on 32-bit little endian: a preprocessor logic mistake wrongly uses the big endian field layout on 32-bit little endian architectures.
Fortunately, those ptr32 accessors were never used within the kernel, and only meant as a convenience for user-space.
Remove those and replace the whole rseq_cs union by a __u64 type, as this is the only thing really needed to express the ABI. Document how 32-bit architectures are meant to interact with this field.
--- include/uapi/linux/rseq.h | 20 ++++---------------- kernel/rseq.c | 8 ++++---- 2 files changed, 8 insertions(+), 20 deletions(-)
include/uapi/linux/rseq.h +4 -16
@@ -105,23 +105,11 @@ struct rseq {* Read and set by the kernel. Set by user-space with single-copy * atomicity semantics. This field should only be updated by the * thread which registered this data structure. Aligned on 64-bit. +* +* 32-bit architectures should update the low order bits of the +* rseq_cs field, leaving the high order bits initialized to 0. */ -union { -__u64 ptr64; -#ifdef __LP64__ -__u64 ptr; -#else -struct { -#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined(__BIG_ENDIAN) -__u32 padding;/* Initialized to zero. */ -__u32 ptr32; -#else /* LITTLE */ -__u32 ptr32; -__u32 padding;/* Initialized to zero. */ -#endif /* ENDIAN */ - } ptr; -#endif - } rseq_cs; +__u64 rseq_cs;/* * Restartable sequences flags field.
kernel/rseq.c +4 -4
@@ -128,10 +128,10 @@ static int rseq_get_rseq_cs(struct task_struct *t, struct rseq_cs *rseq_cs)int ret;#ifdef CONFIG_64BIT -if (get_user (ptr, &t->rseq->rseq_cs.ptr64)) +if (get_user (ptr, &t->rseq->rseq_cs))return -EFAULT ;#else -if (copy_from_user (&ptr, &t->rseq->rseq_cs.ptr64,sizeof (ptr))) +if (copy_from_user (&ptr, &t->rseq->rseq_cs,sizeof (ptr)))return -EFAULT ;#endif if (!ptr) {
@@ -217,9 +217,9 @@ static int clear_rseq_cs(struct task_struct *t)* Set rseq_cs to NULL. */ #ifdef CONFIG_64BIT -return put_user (0UL , &t->rseq->rseq_cs.ptr64); +return put_user (0UL , &t->rseq->rseq_cs);#else -if (clear_user (&t->rseq->rseq_cs.ptr64,sizeof (t->rseq->rseq_cs.ptr64))) +if (clear_user (&t->rseq->rseq_cs,sizeof (t->rseq->rseq_cs)))return -EFAULT ;return 0 ;#endif
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 251/913 perf/core: Fix address filter parser for multiple filters
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
[ Upstream commit d680ff24e9e14444c63945b43a37ede7cd6958f9 ]
Reset appropriate variables in the parser loop between parsing separate filters, so that they do not interfere with parsing the next filter.
--- kernel/events/core.c | 3 +++ 1 file changed, 3 insertions(+)
kernel/events/core.c +3 -0
@@ -10530,8 +10530,11 @@ perf_event_parse_addr_filter(struct perf_event *event, char *fstr, }/* ready to consume more filters */ +kfree (filename); + filename =NULL ; state =IF_STATE_ACTION ; filter =NULL ; + kernel =0 ; } }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 252/913 perf/x86/intel/pt: Fix address filter config for 32-bit kernel
In reply to Greg Kroah-HartmanFrom: Adrian Hunter <[email protected]>
[ Upstream commit e5524bf1047eb3b3f3f33b5f59897ba67b3ade87 ]
Change from shifting 'unsigned long' to 'u64' to prevent the config bits being lost on a 32-bit kernel.
--- arch/x86/events/intel/pt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/pt.c +1 -1
@@ -472,7 +472,7 @@ static u64 pt_config_filters(struct perf_event *event) pt->filters.filter[range].msr_b = filter->msr_b; } - rtit_ctl |= filter->config << pt_address_ranges[range].reg_off; + rtit_ctl |= (u64 )filter->config << pt_address_ranges[range].reg_off; }return rtit_ctl;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 253/913 sched/fair: Improve consistency of allowed NUMA balance calculations
In reply to Greg Kroah-HartmanFrom: Mel Gorman <[email protected]>
[ Upstream commit 2cfb7a1b031b0e816af7a6ee0c6ab83b0acdf05a ]
There are inconsistencies when determining if a NUMA imbalance is allowed that should be corrected.
o allow_numa_imbalance changes types and is not always examining the destination group so both the type should be corrected as well as the naming.
o find_idlest_group uses the sched_domain's weight instead of the group weight which is different to find_busiest_group
o find_busiest_group uses the source group instead of the destination which is different to task_numa_find_cpu
o Both find_idlest_group and find_busiest_group should account for the number of running tasks if a move was allowed to be consistent with task_numa_find_cpu
--- kernel/sched/fair.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
kernel/sched/fair.c +10 -8
@@ -9005,9 +9005,10 @@ static bool update_pick_idlest(struct sched_group *idlest,* This is an approximation as the number of running tasks may not be * related to the number of busy CPUs due to sched_setaffinity. */ -static inline bool allow_numa_imbalance (int dst_running,int dst_weight) +static inline bool +allow_numa_imbalance (unsigned int running,unsigned int weight) { -return (dst_running < (dst_weight >>2 )); +return (running < (weight >>2 )); }/*
@@ -9141,12 +9142,13 @@ find_idlest_group(struct sched_domain *sd, struct task_struct *p, int this_cpu)return idlest;#endif /* -* Otherwise, keep the task on this node to stay close -* its wakeup source and improve locality. If there is -* a real need of migration, periodic load balance will -* take care of it. +* Otherwise, keep the task close to the wakeup source +* and improve locality if the number of running tasks +* would remain below threshold where an imbalance is +* allowed. If there is a real need of migration, +* periodic load balance will take care of it. */ -if (allow_numa_imbalance (local_sgs.sum_nr_running, sd->span_weight)) +if (allow_numa_imbalance (local_sgs.sum_nr_running +1 , local_sgs.group_weight))return NULL ; }
@@ -9352,7 +9354,7 @@ static inline void calculate_imbalance(struct lb_env *env, struct sd_lb_stats *s/* Consider allowing a small imbalance between NUMA groups */ if (env->sd->flags &SD_NUMA ) { env->imbalance =adjust_numa_imbalance (env->imbalance, - busiest->sum_nr_running, busiest->group_weight); + local->sum_nr_running +1 , local->group_weight); }return ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 254/913 f2fs: fix missing free nid in f2fs_handle_failed_inode
In reply to Greg Kroah-HartmanFrom: Jaegeuk Kim <[email protected]>
[ Upstream commit 2fef99b8372c1ae3d8445ab570e888b5a358dbe9 ]
This patch fixes xfstests/generic/475 failure.
[ 293.680694] F2FS-fs (dm-1): May loss orphan inode, run fsck to fix. [ 293.685358] Buffer I/O error on dev dm-1, logical block 8388592, async page read [ 293.691527] Buffer I/O error on dev dm-1, logical block 8388592, async page read [ 293.691764] sh (7615): drop_caches: 3 [ 293.691819] sh (7616): drop_caches: 3 [ 293.694017] Buffer I/O error on dev dm-1, logical block 1, async page read [ 293.695659] sh (7618): drop_caches: 3 [ 293.696979] sh (7617): drop_caches: 3 [ 293.700290] sh (7623): drop_caches: 3 [ 293.708621] sh (7626): drop_caches: 3 [ 293.711386] sh (7628): drop_caches: 3 [ 293.711825] sh (7627): drop_caches: 3 [ 293.716738] sh (7630): drop_caches: 3 [ 293.719613] sh (7632): drop_caches: 3 [ 293.720971] sh (7633): drop_caches: 3 [ 293.727741] sh (7634): drop_caches: 3 [ 293.730783] sh (7636): drop_caches: 3 [ 293.732681] sh (7635): drop_caches: 3 [ 293.732988] sh (7637): drop_caches: 3 [ 293.738836] sh (7639): drop_caches: 3 [ 293.740568] sh (7641): drop_caches: 3 [ 293.743053] sh (7640): drop_caches: 3 [ 293.821889] ------------[ cut here ]------------ [ 293.824654] kernel BUG at fs/f2fs/node.c:3334! [ 293.826226] invalid opcode: 0000 [#1] PREEMPT SMP PTI [ 293.828713] CPU: 0 PID: 7653 Comm: umount Tainted: G OE 5.17.0-rc1-custom #1 [ 293.830946] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 [ 293.832526] RIP: 0010:f2fs_destroy_node_manager+0x33f/0x350 [f2fs] [ 293.833905] Code: e8 d6 3d f9 f9 48 8b 45 d0 65 48 2b 04 25 28 00 00 00 75 1a 48 81 c4 28 03 00 00 5b 41 5c 41 5d 41 5e 41 5f 5d c3 0f 0b [ 293.837783] RSP: 0018:ffffb04ec31e7a20 EFLAGS: 00010202 [ 293.839062] RAX: 0000000000000001 RBX: ffff9df947db2eb8 RCX: 0000000080aa0072 [ 293.840666] RDX: 0000000000000000 RSI: ffffe86c0432a140 RDI: ffffffffc0b72a21 [ 293.842261] RBP: ffffb04ec31e7d70 R08: ffff9df94ca85780 R09: 0000000080aa0072 [ 293.843909] R10: ffff9df94ca85700 R11: ffff9df94e1ccf58 R12: ffff9df947db2e00 [ 293.845594] R13: ffff9df947db2ed0 R14: ffff9df947db2eb8 R15: ffff9df947db2eb8 [ 293.847855] FS: 00007f5a97379800(0000) GS:ffff9dfa77c00000(0000) knlGS:0000000000000000 [ 293.850647] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 293.852940] CR2: 00007f5a97528730 CR3: 000000010bc76005 CR4: 0000000000370ef0 [ 293.854680] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 293.856423] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 293.858380] Call Trace: [ 293.859302] <TASK> [ 293.860311] ? ttwu_do_wakeup+0x1c/0x170 [ 293.861800] ? ttwu_do_activate+0x6d/0xb0 [ 293.863057] ? _raw_spin_unlock_irqrestore+0x29/0x40 [ 293.864411] ? try_to_wake_up+0x9d/0x5e0 [ 293.865618] ? debug_smp_processor_id+0x17/0x20 [ 293.866934] ? debug_smp_processor_id+0x17/0x20 [ 293.868223] ? free_unref_page+0xbf/0x120 [ 293.869470] ? __free_slab+0xcb/0x1c0 [ 293.870614] ? preempt_count_add+0x7a/0xc0 [ 293.871811] ? __slab_free+0xa0/0x2d0 [ 293.872918] ? __wake_up_common_lock+0x8a/0xc0 [ 293.874186] ? __slab_free+0xa0/0x2d0 [ 293.875305] ? free_inode_nonrcu+0x20/0x20 [ 293.876466] ? free_inode_nonrcu+0x20/0x20 [ 293.877650] ? debug_smp_processor_id+0x17/0x20 [ 293.878949] ? call_rcu+0x11a/0x240 [ 293.880060] ? f2fs_destroy_stats+0x59/0x60 [f2fs] [ 293.881437] ? kfree+0x1fe/0x230 [ 293.882674] f2fs_put_super+0x160/0x390 [f2fs] [ 293.883978] generic_shutdown_super+0x7a/0x120 [ 293.885274] kill_block_super+0x27/0x50 [ 293.886496] kill_f2fs_super+0x7f/0x100 [f2fs] [ 293.887806] deactivate_locked_super+0x35/0xa0 [ 293.889271] deactivate_super+0x40/0x50 [ 293.890513] cleanup_mnt+0x139/0x190 [ 293.891689] __cleanup_mnt+0x12/0x20 [ 293.892850] task_work_run+0x64/0xa0 [ 293.894035] exit_to_user_mode_prepare+0x1b7/0x1c0 [ 293.895409] syscall_exit_to_user_mode+0x27/0x50 [ 293.896872] do_syscall_64+0x48/0xc0 [ 293.898090] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 293.899517] RIP: 0033:0x7f5a975cd25b
--- fs/f2fs/inode.c | 1 + 1 file changed, 1 insertion(+)
fs/f2fs/inode.c +1 -0
@@ -876,6 +876,7 @@ void f2fs_handle_failed_inode(struct inode *inode) err =f2fs_get_node_info (sbi, inode->i_ino, &ni);if (err) {set_sbi_flag (sbi,SBI_NEED_FSCK ); +set_inode_flag (inode,FI_FREE_NID );f2fs_warn (sbi,"May loss orphan inode, run fsck to fix." ); goto out; }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 255/913 nfsd: more robust allocation failure handling in nfsd_file_cache_init
In reply to Greg Kroah-HartmanFrom: Amir Goldstein <[email protected]>
[ Upstream commit 4d2eeafecd6c83b4444db3dc0ada201c89b1aa44 ]
The nfsd file cache table can be pretty large and its allocation may require as many as 80 contigious pages.
Employ the same fix that was employed for similar issue that was reported for the reply cache hash table allocation several years ago by commit 8f97514b423a ("nfsd: more robust allocation failure handling in nfsd_reply_cache_init").
--- fs/nfsd/filecache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/nfsd/filecache.c +3 -3
@@ -641,7 +641,7 @@ nfsd_file_cache_init(void)if (!nfsd_filecache_wq) goto out; - nfsd_file_hashtbl =kcalloc (NFSD_FILE_HASH_SIZE , + nfsd_file_hashtbl =kvcalloc (NFSD_FILE_HASH_SIZE ,sizeof (*nfsd_file_hashtbl),GFP_KERNEL );if (!nfsd_file_hashtbl) {pr_err ("nfsd: unable to allocate nfsd_file_hashtbl\n" );
@@ -709,7 +709,7 @@ nfsd_file_cache_init(void) nfsd_file_slab =NULL ;kmem_cache_destroy (nfsd_file_mark_slab); nfsd_file_mark_slab =NULL ; -kfree (nfsd_file_hashtbl); +kvfree (nfsd_file_hashtbl); nfsd_file_hashtbl =NULL ;destroy_workqueue (nfsd_filecache_wq); nfsd_filecache_wq =NULL ;
@@ -855,7 +855,7 @@ nfsd_file_cache_shutdown(void)fsnotify_wait_marks_destroyed ();kmem_cache_destroy (nfsd_file_mark_slab); nfsd_file_mark_slab =NULL ; -kfree (nfsd_file_hashtbl); +kvfree (nfsd_file_hashtbl); nfsd_file_hashtbl =NULL ;destroy_workqueue (nfsd_filecache_wq); nfsd_filecache_wq =NULL ;
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 256/913 sched/cpuacct: Fix charge percpu cpuusage
In reply to Greg Kroah-HartmanFrom: Chengming Zhou <[email protected]>
[ Upstream commit 248cc9993d1cc12b8e9ed716cc3fc09f6c3517dd ]
The cpuacct_account_field() is always called by the current task itself, so it's ok to use __this_cpu_add() to charge the tick time.
But cpuacct_charge() maybe called by update_curr() in load_balance() on a random CPU, different from the CPU on which the task is running. So __this_cpu_add() will charge that cputime to a random incorrect CPU.
--- kernel/sched/cpuacct.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/cpuacct.c +2 -1
@@ -328,12 +328,13 @@ static struct cftype files[] = {*/ void cpuacct_charge (struct task_struct *tsk,u64 cputime) { +unsigned int cpu =task_cpu (tsk);struct cpuacct *ca;rcu_read_lock ();for (ca =task_ca (tsk); ca; ca =parent_ca (ca)) -__this_cpu_add (*ca->cpuusage, cputime); + *per_cpu_ptr (ca->cpuusage, cpu) += cputime;rcu_read_unlock (); }
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 257/913 sched/rt: Plug rt_mutex_setprio() vs push_rt_task() race
In reply to Greg Kroah-HartmanFrom: Valentin Schneider <[email protected]>
[ Upstream commit 49bef33e4b87b743495627a529029156c6e09530 ]
John reported that push_rt_task() can end up invoking find_lowest_rq(rq->curr) when curr is not an RT task (in this case a CFS one), which causes mayhem down convert_prio().
This can happen when current gets demoted to e.g. CFS when releasing an rt_mutex, and the local CPU gets hit with an rto_push_work irqwork before getting the chance to reschedule. Exactly who triggers this work isn't entirely clear to me - switched_from_rt() only invokes rt_queue_pull_task() if there are no RT tasks on the local RQ, which means the local CPU can't be in the rto_mask.
My current suspected sequence is something along the lines of the below, with the demoted task being current.
mark_wakeup_next_waiter()
rt_mutex_adjust_prio()
rt_mutex_setprio() // deboost originally-CFS task
check_class_changed()
switched_from_rt() // Only rt_queue_pull_task() if !rq->rt.rt_nr_running
switched_to_fair() // Sets need_resched
__balance_callbacks() // if pull_rt_task(), tell_cpu_to_push() can't select local CPU per the above
raw_spin_rq_unlock(rq)
// need_resched is set, so task_woken_rt() can't
// invoke push_rt_tasks(). Best I can come up with is
// local CPU has rt_nr_migratory >= 2 after the demotion, so stays
// in the rto_mask, and then:
<some other CPU running rto_push_irq_work_func() queues rto_push_work on this CPU>
push_rt_task()
// breakage follows here as rq->curr is CFSMove an existing check to check rq->curr vs the next pushable task's priority before getting anywhere near find_lowest_rq(). While at it, add an explicit sched_class of rq->curr check prior to invoking find_lowest_rq(rq->curr). Align the DL logic to also reschedule regardless of next_task's migratability.
--- kernel/sched/deadline.c | 12 ++++++------ kernel/sched/rt.c | 32 ++++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 16 deletions(-)
kernel/sched/deadline.c +6 -6
@@ -2145,12 +2145,6 @@ static int push_dl_task(struct rq *rq)return 0 ; retry: -if (is_migration_disabled (next_task)) -return 0 ; - -if (WARN_ON (next_task == rq->curr)) -return 0 ; -/* * If next_task preempts rq->curr, and rq->curr * can move away, it makes sense to just reschedule
@@ -2163,6 +2157,12 @@ static int push_dl_task(struct rq *rq)return 0 ; } +if (is_migration_disabled (next_task)) +return 0 ; + +if (WARN_ON (next_task == rq->curr)) +return 0 ; +/* We might release rq lock */ get_task_struct (next_task);
kernel/sched/rt.c +22 -10
@@ -1900,6 +1900,16 @@ static int push_rt_task(struct rq *rq, bool pull)return 0 ; retry: +/* +* It's possible that the next_task slipped in of +* higher priority than current. If that's the case +* just reschedule current. +*/ +if (unlikely (next_task->prio < rq->curr->prio)) { +resched_curr (rq); +return 0 ; + } +if (is_migration_disabled (next_task)) {struct task_struct *push_task =NULL ;int cpu;
@@ -1907,6 +1917,18 @@ static int push_rt_task(struct rq *rq, bool pull)if (!pull || rq->push_busy)return 0 ; +/* +* Invoking find_lowest_rq() on anything but an RT task doesn't +* make sense. Per the above priority check, curr has to +* be of higher priority than next_task, so no need to +* reschedule when bailing out. +* +* Note that the stoppers are masqueraded as SCHED_FIFO +* (cf. sched_set_stop_task()), so we can't rely on rt_task(). +*/ +if (rq->curr->sched_class != &rt_sched_class) +return 0 ; + cpu =find_lowest_rq (rq->curr);if (cpu ==-1 || cpu == rq->cpu)return 0 ;
@@ -1931,16 +1953,6 @@ static int push_rt_task(struct rq *rq, bool pull)if (WARN_ON (next_task == rq->curr))return 0 ; -/* -* It's possible that the next_task slipped in of -* higher priority than current. If that's the case -* just reschedule current. -*/ -if (unlikely (next_task->prio < rq->curr->prio)) { -resched_curr (rq); -return 0 ; - } -/* We might release rq lock */ get_task_struct (next_task);
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 258/913 f2fs: fix to avoid potential deadlock
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit 344150999b7fc88502a65bbb147a47503eca2033 ]
Quoted from Jing Xia's report, there is a potential deadlock may happen between kworker and checkpoint as below:
[T:writeback] [T:checkpoint]
- wb_writeback
- blk_start_plug
bio contains NodeA was plugged in writeback threads
- do_writepages -- sync write inodeB, inc wb_sync_req[DATA]
- f2fs_write_data_pages
- f2fs_write_single_data_page -- write last dirty page
- f2fs_do_write_data_page
- set_page_writeback -- clear page dirty flag and PAGECACHE_TAG_DIRTY tag in radix tree
- f2fs_outplace_write_data
- f2fs_update_data_blkaddr
- f2fs_wait_on_page_writeback -- wait NodeA to writeback here
- inode_dec_dirty_pages
- writeback_sb_inodes
- writeback_single_inode
- do_writepages
- f2fs_write_data_pages -- skip writepages due to wb_sync_req[DATA]
- wbc->pages_skipped += get_dirty_pages() -- PAGECACHE_TAG_DIRTY is not set but get_dirty_pages() returns one
- requeue_inode -- requeue inode to wb->b_dirty queue due to non-zero.pages_skipped
- blk_finish_plug
Let's try to avoid deadlock condition by forcing unplugging previous bio via blk_finish_plug(current->plug) once we'v skipped writeback in writepages() due to valid sbi->wb_sync_req[DATA/NODE].
--- fs/f2fs/data.c | 6 +++++- fs/f2fs/node.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-)
fs/f2fs/data.c +5 -1
@@ -3214,8 +3214,12 @@ static int __f2fs_write_data_pages(struct address_space *mapping,/* to avoid spliting IOs due to mixed WB_SYNC_ALL and WB_SYNC_NONE */ if (wbc->sync_mode ==WB_SYNC_ALL )atomic_inc (&sbi->wb_sync_req[DATA ]); -else if (atomic_read (&sbi->wb_sync_req[DATA ])) +else if (atomic_read (&sbi->wb_sync_req[DATA ])) { +/* to avoid potential deadlock */ +if (current->plug) +blk_finish_plug (current->plug); goto skip_write; + }if (__should_serialize_io (inode, wbc)) {mutex_lock (&sbi->writepages);
fs/f2fs/node.c +5 -1
@@ -2106,8 +2106,12 @@ static int f2fs_write_node_pages(struct address_space *mapping,if (wbc->sync_mode ==WB_SYNC_ALL )atomic_inc (&sbi->wb_sync_req[NODE ]); -else if (atomic_read (&sbi->wb_sync_req[NODE ])) +else if (atomic_read (&sbi->wb_sync_req[NODE ])) { +/* to avoid potential deadlock */ +if (current->plug) +blk_finish_plug (current->plug); goto skip_write; + }trace_f2fs_writepages (mapping->host, wbc,NODE );
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 259/913 btrfs: fix unexpected error path when reflinking an inline extent
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
[ Upstream commit 1f4613cdbe7739ce291554b316bff8e551383389 ]
When reflinking an inline extent, we assert that its file offset is 0 and that its uncompressed length is not greater than the sector size. We then return an error if one of those conditions is not satisfied. However we use a return statement, which results in returning from btrfs_clone() without freeing the path and buffer that were allocated before, as well as not clearing the flag BTRFS_INODE_NO_DELALLOC_FLUSH for the destination inode.
Fix that by jumping to the 'out' label instead, and also add a WARN_ON() for each condition so that in case assertions are disabled, we get to known which of the unexpected conditions triggered the error.
--- fs/btrfs/reflink.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/btrfs/reflink.c +5 -2
@@ -505,8 +505,11 @@ static int btrfs_clone(struct inode *src, struct inode *inode,*/ ASSERT (key.offset ==0 );ASSERT (datal <= fs_info->sectorsize); -if (key.offset !=0 || datal > fs_info->sectorsize) -return -EUCLEAN ; +if (WARN_ON (key.offset !=0 ) || +WARN_ON (datal > fs_info->sectorsize)) { + ret = -EUCLEAN ; + goto out; + } ret = clone_copy_inline_extent(inode, path, &new_key, drop_start, datal, size,
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 260/913 f2fs: fix compressed file start atomic write may cause data corruption
In reply to Greg Kroah-HartmanFrom: Fengnan Chang <[email protected]>
[ Upstream commit 9b56adcf525522e9ffa52471260298d91fc1d395 ]
When compressed file has blocks, f2fs_ioc_start_atomic_write will succeed, but compressed flag will be remained in inode. If write partial compreseed cluster and commit atomic write will cause data corruption.
This is the reproduction process:
Step 1:
create a compressed file ,write 64K data , call fsync(), then the blocks are write as compressed cluster.
Step2:iotcl(F2FS_IOC_START_ATOMIC_WRITE) --- this should be fail, but not. write page 0 and page 3.iotcl(F2FS_IOC_COMMIT_ATOMIC_WRITE) -- page 0 and 3 write as normal file, Step3:
drop cache.
read page 0-4 -- Since page 0 has a valid block address, read as
non-compressed cluster, page 1 and 2 will be filled with compressed data or zero.
The root cause is, after commit 7eab7a696827 ("f2fs: compress: remove unneeded read when rewrite whole cluster"), in step 2, f2fs_write_begin() only set target page dirty, and in f2fs_commit_inmem_pages(), we will write partial raw pages into compressed cluster, result in corrupting compressed cluster layout.
--- fs/f2fs/data.c | 2 +- fs/f2fs/file.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-)
fs/f2fs/data.c +1 -1
@@ -3410,7 +3410,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, *fsdata =NULL ; -if (len ==PAGE_SIZE ) +if (len ==PAGE_SIZE && !(f2fs_is_atomic_file (inode))) goto repeat; ret = f2fs_prepare_compress_overwrite(inode, pagep,
fs/f2fs/file.c +4 -1
@@ -2002,7 +2002,10 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)inode_lock (inode); -f2fs_disable_compressed_file (inode); +if (!f2fs_disable_compressed_file (inode)) { + ret = -EINVAL ; + goto out; + }if (f2fs_is_atomic_file (inode)) {if (is_inode_flag_set (inode,FI_ATOMIC_REVOKE_REQUEST ))
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 261/913 selftests, x86: fix how check_cc.sh is being invoked
In reply to Greg Kroah-HartmanFrom: Guillaume Tucker <[email protected]>
[ Upstream commit ef696f93ed9778d570bd5ac58414421cdd4f1aab ]
The $(CC) variable used in Makefiles could contain several arguments such as "ccache gcc". These need to be passed as a single string to check_cc.sh, otherwise only the first argument will be used as the compiler command. Without quotes, the $(CC) variable is passed as distinct arguments which causes the script to fail to build trivial programs.
Fix this by adding quotes around $(CC) when calling check_cc.sh to pass the whole string as a single argument to the script even if it has several words such as "ccache gcc".
--- tools/testing/selftests/vm/Makefile | 6 +++--- tools/testing/selftests/x86/Makefile | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
tools/testing/selftests/vm/Makefile +3 -3
@@ -50,9 +50,9 @@ TEST_GEN_FILES += split_huge_page_test TEST_GEN_FILES += ksm_tests ifeq ($(MACHINE),x86_64) -CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_32bit_program.c -m32) -CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_64bit_program.c) -CAN_BUILD_WITH_NOPIE := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_program.c -no-pie) +CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_32bit_program.c -m32) +CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_64bit_program.c) +CAN_BUILD_WITH_NOPIE := $(shell ./../x86/check_cc.sh "$(CC)" ../x86/trivial_program.c -no-pie) TARGETS := protection_keys BINARIES_32 := $(TARGETS:%=%_32)
tools/testing/selftests/x86/Makefile +3 -3
@@ -6,9 +6,9 @@ include ../lib.mk .PHONY: all all_32 all_64 warn_32bit_failure clean UNAME_M := $(shell uname -m) -CAN_BUILD_I386 := $(shell ./check_cc.sh $(CC) trivial_32bit_program.c -m32) -CAN_BUILD_X86_64 := $(shell ./check_cc.sh $(CC) trivial_64bit_program.c) -CAN_BUILD_WITH_NOPIE := $(shell ./check_cc.sh $(CC) trivial_program.c -no-pie) +CAN_BUILD_I386 := $(shell ./check_cc.sh "$(CC)" trivial_32bit_program.c -m32) +CAN_BUILD_X86_64 := $(shell ./check_cc.sh "$(CC)" trivial_64bit_program.c) +CAN_BUILD_WITH_NOPIE := $(shell ./check_cc.sh "$(CC)" trivial_program.c -no-pie) TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt test_mremap_vdso \ check_initial_reg_state sigreturn iopl ioperm \
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 262/913 drivers/base/memory: add memory block to memory group after registration succeeded
In reply to Greg Kroah-HartmanFrom: David Hildenbrand <[email protected]>
[ Upstream commit 7ea0d2d79da09d1f7d71c96a9c9bc1b5229360b5 ]
If register_memory() fails, we freed the memory block but already added the memory block to the group list, not good. Let's defer adding the block to the memory group to after registering the memory block device.
We do handle it properly during unregister_memory(), but that's not called when the registration fails.
--- drivers/base/memory.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/base/memory.c +5 -3
@@ -663,14 +663,16 @@ static int init_memory_block(unsigned long block_id, unsigned long state, mem->nr_vmemmap_pages = nr_vmemmap_pages;INIT_LIST_HEAD (&mem->group_next); + ret =register_memory (mem); +if (ret) +return ret; +if (group) { mem->group = group;list_add (&mem->group_next, &group->memory_blocks); } - ret =register_memory (mem); - -return ret; +return 0 ; }static int add_memory_block (unsigned long base_section_nr)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 263/913 kunit: make kunit_test_timeout compatible with comment
In reply to Greg Kroah-HartmanFrom: Peng Liu <[email protected]>
[ Upstream commit bdd015f7b71b92c2e4ecabac689642cc72553e04 ]
In function kunit_test_timeout, it is declared "300 * MSEC_PER_SEC" represent 5min. However, it is wrong when dealing with arm64 whose default HZ = 250, or some other situations. Use msecs_to_jiffies to fix this, and kunit_test_timeout will work as desired.
--- lib/kunit/try-catch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/kunit/try-catch.c +1 -1
@@ -52,7 +52,7 @@ static unsigned long kunit_test_timeout(void)* If tests timeout due to exceeding sysctl_hung_task_timeout_secs, * the task will be killed and an oops generated. */ -return 300 *MSEC_PER_SEC ;/* 5 min */ +return 300 *msecs_to_jiffies (MSEC_PER_SEC );/* 5 min */ }void kunit_try_catch_run (struct kunit_try_catch *try_catch,void *context)
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 264/913 pinctrl: samsung: Remove EINT handler for Exynos850 ALIVE and CMGP gpios
In reply to Greg Kroah-HartmanFrom: Sam Protsenko <[email protected]>
[ Upstream commit 96f79935015cf3d7ca6fabf63cd13b8af45a7713 ]
GPIO_ALIVE and GPIO_CMGP blocks in Exynos850 SoC don't have EINT capabilities (like EINT_SVC register), and there are no corresponding interrupts wired to GIC. Instead those blocks have wake-up interrupts for each pin. The ".eint_gpio_init" callbacks were specified by mistake for these blocks, when porting pinctrl code from downstream kernel. That leads to error messages like this:
samsung-pinctrl 11850000.pinctrl: irq number not available
Remove ".eint_gpio_init" for pinctrl_alive and pinctrl_gpmc to fix this error. This change doesn't affect proper interrupt handling for related pins, as all those pins are handled in ".eint_wkup_init".
--- drivers/pinctrl/samsung/pinctrl-exynos-arm64.c | 2 -- 1 file changed, 2 deletions(-)
drivers/pinctrl/samsung/pinctrl-exynos-arm64.c +0 -2
@@ -504,13 +504,11 @@ static const struct samsung_pin_ctrl exynos850_pin_ctrl[] __initconst = {/* pin-controller instance 0 ALIVE data */ .pin_banks = exynos850_pin_banks0, .nr_banks = ARRAY_SIZE(exynos850_pin_banks0), - .eint_gpio_init = exynos_eint_gpio_init, .eint_wkup_init = exynos_eint_wkup_init, }, {/* pin-controller instance 1 CMGP data */ .pin_banks = exynos850_pin_banks1, .nr_banks = ARRAY_SIZE(exynos850_pin_banks1), - .eint_gpio_init = exynos_eint_gpio_init, .eint_wkup_init = exynos_eint_wkup_init, }, {/* pin-controller instance 2 AUD data */
Signature · 1 line
2.34.1
Greg Kroah-Hartman
maintainerPATCH 265/913 media: staging: media: zoran: fix usage of vb2_dma_contig_set_max_seg_size
In reply to Greg Kroah-HartmanFrom: Corentin Labbe <[email protected]>
[ Upstream commit 241f5b67fb48def58643f279dfb8468bdd54b443 ]
vb2_dma_contig_set_max_seg_size need to have a size in parameter and not a DMA_BIT_MASK().
While fixing this issue, also fix error handling of all DMA size setting.
--- drivers/staging/media/zoran/zoran_card.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/media/zoran/zoran_card.c +4 -2
@@ -1069,8 +1069,10 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (32 ));if (err) -return -ENODEV ; -vb2_dma_contig_set_max_seg_size (&pdev->dev,DMA_BIT_MASK (32 )); +return err; + err =vb2_dma_contig_set_max_seg_size (&pdev->dev,U32_MAX ); +if (err) +return err; nr = zoran_num++;if (nr >=BUZ_MAX ) {
Signature · 1 line
2.34.1