Input: zinitix - do not report shadow fingers
Subsystems (6)
Sasha Levin
maintainerPATCH 1/5 Input: zinitix - do not report shadow fingers
From: Linus Walleij <[email protected]>
[ Upstream commit e941dc13fd3717122207d74539ab95da07ef797f ]
I observed the following problem with the BT404 touch pad running the Phosh UI:
When e.g. typing on the virtual keyboard pressing "g" would produce "ggg".
After some analysis it turns out the firmware reports that three fingers hit that coordinate at the same time, finger 0, 2 and 4 (of the five available 0,1,2,3,4).
DOWN
Zinitix-TS 3-0020: finger 0 down (246, 395)
Zinitix-TS 3-0020: finger 1 up (0, 0)
Zinitix-TS 3-0020: finger 2 down (246, 395)
Zinitix-TS 3-0020: finger 3 up (0, 0)
Zinitix-TS 3-0020: finger 4 down (246, 395)
UP
Zinitix-TS 3-0020: finger 0 up (246, 395)
Zinitix-TS 3-0020: finger 2 up (246, 395)
Zinitix-TS 3-0020: finger 4 up (246, 395)
This is one touch and release: i.e. this is all reported on touch (down) and release.
There is a field in the struct touch_event called finger_cnt which is actually a bitmask of the fingers active in the event.
Rename this field finger_mask as this matches the use contents better, then use for_each_set_bit() to iterate over just the fingers that are actally active.
Factor out a finger reporting function zinitix_report_fingers() to handle all fingers.
Also be more careful in reporting finger down/up: we were reporting every event with input_mt_report_slot_state(..., true); but this should only be reported on finger down or move, not on finger up, so also add code to check p->sub_status to see what is happening and report correctly.
After this my Zinitix BT404 touchscreen report fingers flawlessly.
The vendor drive I have notably does not use the "finger_cnt" and contains obviously incorrect code like this:
if (touch_dev->touch_info.finger_cnt > MAX_SUPPORTED_FINGER_NUM)
touch_dev->touch_info.finger_cnt = MAX_SUPPORTED_FINGER_NUM;As MAX_SUPPORTED_FINGER_NUM is an ordinal and the field is a bitmask this seems quite confused.
--- drivers/input/touchscreen/zinitix.c | 44 +++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 9 deletions(-)
drivers/input/touchscreen/zinitix.c +35 -9
@@ -135,7 +135,7 @@ struct point_coord {struct touch_event {__le16 status; -u8 finger_cnt; +u8 finger_mask;u8 time_stamp;struct point_coord point_coord[MAX_SUPPORTED_FINGER_NUM ]; };
@@ -311,11 +311,32 @@ static int zinitix_send_power_on_sequence(struct bt541_ts_data *bt541)static void zinitix_report_finger (struct bt541_ts_data *bt541,int slot,const struct point_coord *p) { +u16 x, y; + +if (unlikely (!(p->sub_status & + (SUB_BIT_UP |SUB_BIT_DOWN |SUB_BIT_MOVE )))) { +dev_dbg (&bt541->client->dev,"unknown finger event %#02x\n" , + p->sub_status); +return ; + } + + x =le16_to_cpu (p->x); + y =le16_to_cpu (p->y); +input_mt_slot (bt541->input_dev, slot); -input_mt_report_slot_state (bt541->input_dev,MT_TOOL_FINGER , true); -touchscreen_report_pos (bt541->input_dev, &bt541->prop, -le16_to_cpu (p->x),le16_to_cpu (p->y), true); -input_report_abs (bt541->input_dev,ABS_MT_TOUCH_MAJOR , p->width); +if (input_mt_report_slot_state (bt541->input_dev,MT_TOOL_FINGER , + !(p->sub_status &SUB_BIT_UP ))) { +touchscreen_report_pos (bt541->input_dev, + &bt541->prop, x, y, true); +input_report_abs (bt541->input_dev, +ABS_MT_TOUCH_MAJOR , p->width); +dev_dbg (&bt541->client->dev,"finger %d %s (%u, %u)\n" , + slot, p->sub_status &SUB_BIT_DOWN ?"down" :"move" , + x, y); + }else { +dev_dbg (&bt541->client->dev,"finger %d up (%u, %u)\n" , + slot, x, y); + } }static irqreturn_t zinitix_ts_irq_handler (int irq,void *bt541_handler)
@@ -323,6 +344,7 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler)struct bt541_ts_data *bt541 = bt541_handler;struct i2c_client *client = bt541->client;struct touch_event touch_event; +unsigned long finger_mask;int error;int i;
@@ -335,10 +357,14 @@ static irqreturn_t zinitix_ts_irq_handler(int irq, void *bt541_handler) goto out; } -for (i =0 ; i <MAX_SUPPORTED_FINGER_NUM ; i++) -if (touch_event.point_coord[i].sub_status &SUB_BIT_EXIST ) -zinitix_report_finger (bt541, i, - &touch_event.point_coord[i]); + finger_mask = touch_event.finger_mask; +for_each_set_bit (i, &finger_mask,MAX_SUPPORTED_FINGER_NUM ) { +const struct point_coord *p = &touch_event.point_coord[i]; + +/* Only process contacts that are actually reported */ +if (p->sub_status &SUB_BIT_EXIST ) +zinitix_report_finger (bt541, i, p); + }input_mt_sync_frame (bt541->input_dev);input_sync (bt541->input_dev);
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 2/5 af_key: add __GFP_ZERO flag for compose_sadb_supported in function pfkey_register
From: Haimin Zhang <[email protected]>
[ Upstream commit 9a564bccb78a76740ea9d75a259942df8143d02c ]
Add __GFP_ZERO flag for compose_sadb_supported in function pfkey_register to initialize the buffer of supp_skb to fix a kernel-info-leak issue.
1) Function pfkey_register calls compose_sadb_supported to request a sk_buff. 2) compose_sadb_supported calls alloc_sbk to allocate a sk_buff, but it doesn't zero it. 3) If auth_len is greater 0, then compose_sadb_supported treats the memory as a struct sadb_supported and begins to initialize. But it just initializes the field sadb_supported_len and field sadb_supported_exttype without field sadb_supported_reserved.
--- net/key/af_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/key/af_key.c +1 -1
@@ -1699,7 +1699,7 @@ static int pfkey_register(struct sock *sk, struct sk_buff *skb, const struct sadxfrm_probe_algs (); - supp_skb =compose_sadb_supported (hdr,GFP_KERNEL ); + supp_skb =compose_sadb_supported (hdr,GFP_KERNEL | __GFP_ZERO);if (!supp_skb) {if (hdr->sadb_msg_satype !=SADB_SATYPE_UNSPEC ) pfk->registered &= ~(1 <<hdr->sadb_msg_satype);
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 3/5 net: ipv6: fix skb_over_panic in __ip6_append_data
In reply to Sasha LevinFrom: Tadeusz Struk <[email protected]>
[ Upstream commit 5e34af4142ffe68f01c8a9acae83300f8911e20c ]
Syzbot found a kernel bug in the ipv6 stack:
The reproducer triggers it by sending a crafted message via sendmmsg() call, which triggers skb_over_panic, and crashes the kernel:
skbuff: skb_over_panic: text:ffffffff84647fb4 len:65575 put:65575 head:ffff888109ff0000 data:ffff888109ff0088 tail:0x100af end:0xfec0 dev:<NULL>
Update the check that prevents an invalid packet with MTU equal to the fregment header size to eat up all the space for payload.
The reproducer can be found here:
--- net/ipv6/ip6_output.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/ipv6/ip6_output.c +2 -2
@@ -1476,8 +1476,8 @@ static int __ip6_append_data(struct sock *sk, sizeof(struct frag_hdr) : 0) + rt->rt6i_nfheader_len; -if (mtu < fragheaderlen || - ((mtu - fragheaderlen) & ~7 ) + fragheaderlen <sizeof (struct frag_hdr )) +if (mtu <= fragheaderlen || + ((mtu - fragheaderlen) & ~7 ) + fragheaderlen <=sizeof (struct frag_hdr )) goto emsgsize; maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen -
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 4/5 net: dsa: microchip: add spi_device_id tables
In reply to Sasha LevinFrom: Claudiu Beznea <[email protected]>
[ Upstream commit e981bc74aefc6a177b50c16cfa7023599799cf74 ]
Add spi_device_id tables to avoid logs like "SPI driver ksz9477-switch has no spi_device_id".
--- drivers/net/dsa/microchip/ksz8795_spi.c | 11 +++++++++++ drivers/net/dsa/microchip/ksz9477_spi.c | 12 ++++++++++++ 2 files changed, 23 insertions(+)
drivers/net/dsa/microchip/ksz8795_spi.c +11 -0
@@ -124,12 +124,23 @@ static const struct of_device_id ksz8795_dt_ids[] = { };MODULE_DEVICE_TABLE (of, ksz8795_dt_ids); +static const struct spi_device_id ksz8795_spi_ids[] = { + {"ksz8765" }, + {"ksz8794" }, + {"ksz8795" }, + {"ksz8863" }, + {"ksz8873" }, + { }, +}; +MODULE_DEVICE_TABLE (spi, ksz8795_spi_ids); +static struct spi_driver ksz8795_spi_driver = { .driver = { .name ="ksz8795-switch" , .owner =THIS_MODULE , .of_match_table =of_match_ptr (ksz8795_dt_ids), }, + .id_table = ksz8795_spi_ids, .probe = ksz8795_spi_probe, .remove = ksz8795_spi_remove, .shutdown = ksz8795_spi_shutdown,
drivers/net/dsa/microchip/ksz9477_spi.c +12 -0
@@ -98,12 +98,24 @@ static const struct of_device_id ksz9477_dt_ids[] = { };MODULE_DEVICE_TABLE (of, ksz9477_dt_ids); +static const struct spi_device_id ksz9477_spi_ids[] = { + {"ksz9477" }, + {"ksz9897" }, + {"ksz9893" }, + {"ksz9563" }, + {"ksz8563" }, + {"ksz9567" }, + { }, +}; +MODULE_DEVICE_TABLE (spi, ksz9477_spi_ids); +static struct spi_driver ksz9477_spi_driver = { .driver = { .name ="ksz9477-switch" , .owner =THIS_MODULE , .of_match_table =of_match_ptr (ksz9477_dt_ids), }, + .id_table = ksz9477_spi_ids, .probe = ksz9477_spi_probe, .remove = ksz9477_spi_remove, .shutdown = ksz9477_spi_shutdown,
Signature · 1 line
2.34.1
Sasha Levin
maintainerPATCH 5/5 selftests: vm: fix clang build error multiple output files
In reply to Sasha LevinFrom: Yosry Ahmed <[email protected]>
[ Upstream commit 1c4debc443ef7037dcb7c4f08c33b9caebd21d2e ]
When building the vm selftests using clang, some errors are seen due to having headers in the compilation command:
clang -Wall -I ../../../../usr/include -no-pie gup_test.c ../../../../mm/gup_test.h -lrt -lpthread -o .../tools/testing/selftests/vm/gup_test
clang: error: cannot specify -o when generating multiple output files make[1]: *** [../lib.mk:146: .../tools/testing/selftests/vm/gup_test] Error 1
Rework to add the header files to LOCAL_HDRS before including ../lib.mk, since the dependency is evaluated in '$(OUTPUT)/%:%.c $(LOCAL_HDRS)' in file lib.mk.
--- tools/testing/selftests/vm/Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
tools/testing/selftests/vm/Makefile +2 -4
@@ -1,6 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for vm selftests +LOCAL_HDRS += $(selfdir)/vm/local_config.h $(top_srcdir)/mm/gup_test.h + include local_config.mk uname_M := $(shell uname -m 2>/dev/null || echo not)
@@ -139,10 +141,6 @@ endif $(OUTPUT)/mlock-random-test $(OUTPUT)/memfd_secret: LDLIBS += -lcap -$(OUTPUT)/gup_test: ../../../../mm/gup_test.h - -$(OUTPUT)/hmm-tests: local_config.h - # HMM_EXTRA_LIBS may get set in local_config.mk, or it may be left empty. $(OUTPUT)/hmm-tests: LDLIBS += $(HMM_EXTRA_LIBS)
Signature · 1 line
2.34.1