crypto: mxs-dcp - Use sg_mapping_iter to copy data
Subsystems (22)
Sasha Levin
maintainerPATCH 1/35 crypto: mxs-dcp - Use sg_mapping_iter to copy data
From: Sean Anderson <[email protected]>
[ Upstream commit 2e6d793e1bf07fe5e20cfbbdcec9e1af7e5097eb ]
This uses the sg_pcopy_from_buffer to copy data, instead of doing it ourselves.
In addition to reducing code size, this fixes the following oops resulting from failing to kmap the page:
[ 68.896381] Unable to handle kernel NULL pointer dereference at virtual address 00000ab8 [ 68.904539] pgd = 3561adb3 [ 68.907475] [00000ab8] *pgd=00000000 [ 68.911153] Internal error: Oops: 805 [#1] ARM [ 68.915618] Modules linked in: cfg80211 rfkill des_generic libdes arc4 libarc4 cbc ecb algif_skcipher sha256_generic libsha256 sha1_generic hmac aes_generic libaes cmac sha512_generic md5 md4 algif_hash af_alg i2c_imx i2c_core ci_hdrc_imx ci_hdrc mxs_dcp ulpi roles udc_core imx_sdma usbmisc_imx usb_common firmware_class virt_dma phy_mxs_usb nf_tables nfnetlink ip_tables x_tables ipv6 autofs4 [ 68.950741] CPU: 0 PID: 139 Comm: mxs_dcp_chan/ae Not tainted 5.10.34 #296 [ 68.958501] Hardware name: Freescale i.MX6 Ultralite (Device Tree) [ 68.964710] PC is at memcpy+0xa8/0x330 [ 68.968479] LR is at 0xd7b2bc9d [ 68.971638] pc : [<c053e7c8>] lr : [<d7b2bc9d>] psr: 000f0013 [ 68.977920] sp : c2cbbee4 ip : 00000010 fp : 00000010 [ 68.983159] r10: 00000000 r9 : c3283a40 r8 : 1a5a6f08 [ 68.988402] r7 : 4bfe0ecc r6 : 76d8a220 r5 : c32f9050 r4 : 00000001 [ 68.994945] r3 : 00000ab8 r2 : fffffff0 r1 : c32f9050 r0 : 00000ab8 [ 69.001492] Flags: nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none [ 69.008646] Control: 10c53c7d Table: 83664059 DAC: 00000051 [ 69.014414] Process mxs_dcp_chan/ae (pid: 139, stack limit = 0x667b57ab) [ 69.021133] Stack: (0xc2cbbee4 to 0xc2cbc000) [ 69.025519] bee0: c32f9050 c3235408 00000010 00000010 00000ab8 00000001 bf10406c [ 69.033720] bf00: 00000000 00000000 00000010 00000000 c32355d0 832fb080 00000000 c13de2fc [ 69.041921] bf20: c3628010 00000010 c33d5780 00000ab8 bf1067e8 00000002 c21e5010 c2cba000 [ 69.050125] bf40: c32f8040 00000000 bf106a40 c32f9040 c3283a80 00000001 bf105240 c3234040 [ 69.058327] bf60: ffffe000 c3204100 c2c69800 c2cba000 00000000 bf103b84 00000000 c2eddc54 [ 69.066530] bf80: c3204144 c0140d1c c2cba000 c2c69800 c0140be8 00000000 00000000 00000000 [ 69.074730] bfa0: 00000000 00000000 00000000 c0100114 00000000 00000000 00000000 00000000 [ 69.082932] bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 69.091131] bfe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000 [ 69.099364] [<c053e7c8>] (memcpy) from [<bf10406c>] (dcp_chan_thread_aes+0x4e8/0x840 [mxs_dcp]) [ 69.108117] [<bf10406c>] (dcp_chan_thread_aes [mxs_dcp]) from [<c0140d1c>] (kthread+0x134/0x160) [ 69.116941] [<c0140d1c>] (kthread) from [<c0100114>] (ret_from_fork+0x14/0x20) [ 69.124178] Exception stack(0xc2cbbfb0 to 0xc2cbbff8) [ 69.129250] bfa0: 00000000 00000000 00000000 00000000 [ 69.137450] bfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 69.145648] bfe0: 00000000 00000000 00000000 00000000 00000013 00000000 [ 69.152289] Code: e320f000 e4803004 e4804004 e4805004 (e4806004)
--- drivers/crypto/mxs-dcp.c | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-)
drivers/crypto/mxs-dcp.c +9 -27
@@ -280,21 +280,20 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)struct scatterlist *dst = req->dst;struct scatterlist *src = req->src; -const int nents =sg_nents (req->src); +int dst_nents =sg_nents (dst);const int out_off =DCP_BUF_SZ ;uint8_t *in_buf = sdcp->coh->aes_in_buf;uint8_t *out_buf = sdcp->coh->aes_out_buf; -uint8_t *out_tmp, *src_buf, *dst_buf =NULL ;uint32_t dst_off =0 ; +uint8_t *src_buf =NULL ;uint32_t last_out_len =0 ;uint8_t *key = sdcp->coh->aes_key;int ret =0 ; -int split =0 ; -unsigned int i, len, clen, rem =0 , tlen =0 ; +unsigned int i, len, clen, tlen =0 ;int init =0 ;bool limit_hit = false;
@@ -312,7 +311,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, nents, i) { +for_each_sg (req->src, src,sg_nents (src), i) { src_buf =sg_virt (src); len =sg_dma_len (src); tlen += len;
@@ -337,34 +336,17 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)* submit the buffer. */ if (actx->fill == out_off ||sg_is_last (src) || - limit_hit) { + limit_hit) { ret =mxs_dcp_run_aes (actx, req, init);if (ret)return ret; init =0 ; - out_tmp = out_buf; +sg_pcopy_from_buffer (dst, dst_nents, out_buf, + actx->fill, dst_off); + dst_off += actx->fill; last_out_len = actx->fill; -while (dst && actx->fill) { -if (!split) { - dst_buf =sg_virt (dst); - dst_off =0 ; - } - rem =min (sg_dma_len (dst) - dst_off, - actx->fill); - -memcpy (dst_buf + dst_off, out_tmp, rem); - out_tmp += rem; - dst_off += rem; - actx->fill -= rem; - -if (dst_off ==sg_dma_len (dst)) { - dst =sg_next (dst); - split =0 ; - }else { - split =1 ; - } - } + actx->fill =0 ; } }while (len);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 2/35 PCI: Use pci_update_current_state() in pci_enable_device_flags()
From: "Rafael J. Wysocki" <[email protected]>
[ Upstream commit 14858dcc3b3587f4bb5c48e130ee7d68fc2b0a29 ]
Updating the current_state field of struct pci_dev the way it is done in pci_enable_device_flags() before calling do_pci_enable_device() may not work. For example, if the given PCI device depends on an ACPI power resource whose _STA method initially returns 0 ("off"), but the config space of the PCI device is accessible and the power state retrieved from the PCI_PM_CTRL register is D0, the current_state field in the struct pci_dev representing that device will get out of sync with the power.state of its ACPI companion object and that will lead to power management issues going forward.
To avoid such issues, make pci_enable_device_flags() call pci_update_current_state() which takes ACPI device power management into account, if present, to retrieve the current power state of the device.
--- drivers/pci/pci.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/pci/pci.c +1 -5
@@ -1334,11 +1334,7 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)* so that things like MSI message writing will behave as expected * (e.g. if the device really is in D0 at enable time). */ -if (dev->pm_cap) { -u16 pmcsr; -pci_read_config_word (dev, dev->pm_cap +PCI_PM_CTRL , &pmcsr); - dev->current_state = (pmcsr &PCI_PM_CTRL_STATE_MASK ); - } +pci_update_current_state (dev, dev->current_state);if (atomic_inc_return (&dev->enable_cnt) >1 )return 0 ;/* already enabled */
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 3/35 iio: dac: ad5624r: Fix incorrect handling of an optional regulator.
In reply to Sasha LevinFrom: Jonathan Cameron <[email protected]>
[ Upstream commit 97683c851f9cdbd3ea55697cbe2dcb6af4287bbd ]
The naming of the regulator is problematic. VCC is usually a supply voltage whereas these devices have a separate VREF pin.
Secondly, the regulator core might have provided a stub regulator if a real regulator wasn't provided. That would in turn have failed to provide a voltage when queried. So reality was that there was no way to use the internal reference.
In order to avoid breaking any dts out in the wild, make sure to fallback to the original vcc naming if vref is not available.
--- drivers/iio/dac/ad5624r_spi.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/iio/dac/ad5624r_spi.c +17 -1
@@ -231,7 +231,7 @@ static int ad5624r_probe(struct spi_device *spi)if (!indio_dev)return -ENOMEM ; st =iio_priv (indio_dev); - st->reg =devm_regulator_get (&spi->dev,"vcc" ); + st->reg =devm_regulator_get_optional (&spi->dev,"vref" );if (!IS_ERR (st->reg)) { ret =regulator_enable (st->reg);if (ret)
@@ -242,6 +242,22 @@ static int ad5624r_probe(struct spi_device *spi) goto error_disable_reg; voltage_uv = ret; + }else { +if (PTR_ERR (st->reg) != -ENODEV ) +return PTR_ERR (st->reg); +/* Backwards compatibility. This naming is not correct */ + st->reg =devm_regulator_get_optional (&spi->dev,"vcc" ); +if (!IS_ERR (st->reg)) { + ret =regulator_enable (st->reg); +if (ret) +return ret; + + ret =regulator_get_voltage (st->reg); +if (ret <0 ) + goto error_disable_reg; + + voltage_uv = ret; + } }spi_set_drvdata (spi, indio_dev);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 4/35 video: fbdev: kyro: fix a DoS bug by restricting user input
In reply to Sasha LevinFrom: Zheyu Ma <[email protected]>
[ Upstream commit 98a65439172dc69cb16834e62e852afc2adb83ed ]
The user can pass in any value to the driver through the 'ioctl' interface. The driver dost not check, which may cause DoS bugs.
The following log reveals it:
divide error: 0000 [#1] PREEMPT SMP KASAN PTI
RIP: 0010:SetOverlayViewPort+0x133/0x5f0 drivers/video/fbdev/kyro/STG4000OverlayDevice.c:476 Call Trace: kyro_dev_overlay_viewport_set drivers/video/fbdev/kyro/fbdev.c:378 [inline] kyrofb_ioctl+0x2eb/0x330 drivers/video/fbdev/kyro/fbdev.c:603 do_fb_ioctl+0x1f3/0x700 drivers/video/fbdev/core/fbmem.c:1171 fb_ioctl+0xeb/0x130 drivers/video/fbdev/core/fbmem.c:1185 vfs_ioctl fs/ioctl.c:48 [inline] __do_sys_ioctl fs/ioctl.c:753 [inline] __se_sys_ioctl fs/ioctl.c:739 [inline] __x64_sys_ioctl+0x19b/0x220 fs/ioctl.c:739 do_syscall_64+0x32/0x80 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xae
--- drivers/video/fbdev/kyro/fbdev.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/video/fbdev/kyro/fbdev.c +5 -0
@@ -372,6 +372,11 @@ static int kyro_dev_overlay_viewport_set(u32 x, u32 y, u32 ulWidth, u32 ulHeight/* probably haven't called CreateOverlay yet */ return -EINVAL ; +if (ulWidth ==0 || ulWidth ==0xffffffff || + ulHeight ==0 || ulHeight ==0xffffffff || + (x <2 && ulWidth +2 ==0 )) +return -EINVAL ; +/* Stop Ramdac Output */ DisableRamdacOutput (deviceInfo.pSTGReg);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 5/35 netlink: Deal with ESRCH error in nlmsg_notify()
In reply to Sasha LevinFrom: Yajun Deng <[email protected]>
[ Upstream commit fef773fc8110d8124c73a5e6610f89e52814637d ]
Yonghong Song report:
The bpf selftest tc_bpf failed with latest bpf-next. The following is the command to run and the result:
$ ./test_progs -n 132 [ 40.947571] bpf_testmod: loading out-of-tree module taints kernel. test_tc_bpf:PASS:test_tc_bpf__open_and_load 0 nsec test_tc_bpf:PASS:bpf_tc_hook_create(BPF_TC_INGRESS) 0 nsec test_tc_bpf:PASS:bpf_tc_hook_create invalid hook.attach_point 0 nsec test_tc_bpf_basic:PASS:bpf_obj_get_info_by_fd 0 nsec test_tc_bpf_basic:PASS:bpf_tc_attach 0 nsec test_tc_bpf_basic:PASS:handle set 0 nsec test_tc_bpf_basic:PASS:priority set 0 nsec test_tc_bpf_basic:PASS:prog_id set 0 nsec test_tc_bpf_basic:PASS:bpf_tc_attach replace mode 0 nsec test_tc_bpf_basic:PASS:bpf_tc_query 0 nsec test_tc_bpf_basic:PASS:handle set 0 nsec test_tc_bpf_basic:PASS:priority set 0 nsec test_tc_bpf_basic:PASS:prog_id set 0 nsec libbpf: Kernel error message: Failed to send filter delete notification test_tc_bpf_basic:FAIL:bpf_tc_detach unexpected error: -3 (errno 3) test_tc_bpf:FAIL:test_tc_internal ingress unexpected error: -3 (errno 3)
The failure seems due to the commit
cfdf0d9ae75b ("rtnetlink: use nlmsg_notify() in rtnetlink_send()")
Deal with ESRCH error in nlmsg_notify() even the report variable is zero.
--- net/netlink/af_netlink.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/netlink/af_netlink.c +3 -1
@@ -2405,13 +2405,15 @@ int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 portid,/* errors reported via destination sk->sk_err, but propagate * delivery errors if NETLINK_BROADCAST_ERROR flag is set */ err =nlmsg_multicast (sk, skb, exclude_portid, group, flags); +if (err == -ESRCH ) + err =0 ; }if (report) {int err2; err2 =nlmsg_unicast (sk, skb, portid); -if (!err || err == -ESRCH ) +if (!err) err = err2; }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 6/35 Smack: Fix wrong semantics in smk_access_entry()
In reply to Sasha LevinFrom: Tianjia Zhang <[email protected]>
[ Upstream commit 6d14f5c7028eea70760df284057fe198ce7778dd ]
In the smk_access_entry() function, if no matching rule is found in the rust_list, a negative error code will be used to perform bit operations with the MAY_ enumeration value. This is semantically wrong. This patch fixes this issue.
--- security/smack/smack_access.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
security/smack/smack_access.c +8 -9
@@ -90,23 +90,22 @@ int log_policy = SMACK_AUDIT_DENIED;int smk_access_entry (char *subject_label,char *object_label,struct list_head *rule_list) { -int may = -ENOENT ;struct smack_rule *srp;list_for_each_entry_rcu (srp, rule_list, list) {if (srp->smk_object->smk_known == object_label && srp->smk_subject->smk_known == subject_label) { - may = srp->smk_access; -break ; +int may = srp->smk_access; +/* +* MAY_WRITE implies MAY_LOCK. +*/ +if ((may &MAY_WRITE ) ==MAY_WRITE ) + may |=MAY_LOCK ; +return may; } } -/* -* MAY_WRITE implies MAY_LOCK. -*/ -if ((may &MAY_WRITE ) ==MAY_WRITE ) - may |=MAY_LOCK ; -return may; +return -ENOENT ; }/**
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 7/35 usb: host: fotg210: fix the actual_length of an iso packet
In reply to Sasha LevinFrom: Kelly Devilliv <[email protected]>
[ Upstream commit 091cb2f782f32ab68c6f5f326d7868683d3d4875 ]
We should acquire the actual_length of an iso packet from the iTD directly using FOTG210_ITD_LENGTH() macro.
--- drivers/usb/host/fotg210-hcd.c | 5 ++--- drivers/usb/host/fotg210.h | 5 ----- 2 files changed, 2 insertions(+), 8 deletions(-)
drivers/usb/host/fotg210-hcd.c +2 -3
@@ -4495,13 +4495,12 @@ static bool itd_complete(struct fotg210_hcd *fotg210, struct fotg210_itd *itd)/* HC need not update length with this error */ if (!(t &FOTG210_ISOC_BABBLE )) { - desc->actual_length = -fotg210_itdlen (urb, desc, t); + desc->actual_length =FOTG210_ITD_LENGTH (t); urb->actual_length += desc->actual_length; } }else if (likely ((t &FOTG210_ISOC_ACTIVE ) ==0 )) { desc->status =0 ; - desc->actual_length =fotg210_itdlen (urb, desc, t); + desc->actual_length =FOTG210_ITD_LENGTH (t); urb->actual_length += desc->actual_length; }else {/* URB was too late */
drivers/usb/host/fotg210.h +0 -5
@@ -682,11 +682,6 @@ static inline unsigned fotg210_read_frame_index(struct fotg210_hcd *fotg210) return fotg210_readl(fotg210, &fotg210->regs->frame_index); } -#define fotg210_itdlen (urb, desc, t) ({ \ - usb_pipein((urb)->pipe) ? \ - (desc)->length - FOTG210_ITD_LENGTH(t) : \ - FOTG210_ITD_LENGTH(t); \ -})/*-------------------------------------------------------------------------*/ #endif /* __LINUX_FOTG210_H */
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 8/35 usb: gadget: u_ether: fix a potential null pointer dereference
In reply to Sasha LevinFrom: Maciej Żenczykowski <[email protected]>
[ Upstream commit 8ae01239609b29ec2eff55967c8e0fe3650cfa09 ]
f_ncm tx timeout can call us with null skb to flush a pending frame. In this case skb is NULL to begin with but ceases to be null after dev->wrap() completes.
In such a case in->maxpacket will be read, even though we've failed to check that 'in' is not NULL.
Though I've never observed this fail in practice, however the 'flush operation' simply does not make sense with a null usb IN endpoint - there's nowhere to flush to... (note that we're the gadget/device, and IN is from the point
of view of the host, so here IN actually means outbound...)
--- drivers/usb/gadget/function/u_ether.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/gadget/function/u_ether.c +3 -2
@@ -507,8 +507,9 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb, }spin_unlock_irqrestore (&dev->lock, flags); -if (skb && !in) { -dev_kfree_skb_any (skb); +if (!in) { +if (skb) +dev_kfree_skb_any (skb);return NETDEV_TX_OK ; }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 9/35 tty: serial: jsm: hold port lock when reporting modem line changes
In reply to Sasha LevinFrom: Zheyu Ma <[email protected]>
[ Upstream commit 240e126c28df084222f0b661321e8e3ecb0d232e ]
uart_handle_dcd_change() requires a port lock to be held and will emit a warning when lockdep is enabled.
Held corresponding lock to fix the following warnings.
[ 132.528648] WARNING: CPU: 5 PID: 11600 at drivers/tty/serial/serial_core.c:3046 uart_handle_dcd_change+0xf4/0x120 [ 132.530482] Modules linked in: [ 132.531050] CPU: 5 PID: 11600 Comm: jsm Not tainted 5.14.0-rc1-00003-g7fef2edf7cc7-dirty #31 [ 132.535268] RIP: 0010:uart_handle_dcd_change+0xf4/0x120 [ 132.557100] Call Trace: [ 132.557562] ? __free_pages+0x83/0xb0 [ 132.558213] neo_parse_modem+0x156/0x220 [ 132.558897] neo_param+0x399/0x840 [ 132.559495] jsm_tty_open+0x12f/0x2d0 [ 132.560131] uart_startup.part.18+0x153/0x340 [ 132.560888] ? lock_is_held_type+0xe9/0x140 [ 132.561660] uart_port_activate+0x7f/0xe0 [ 132.562351] ? uart_startup.part.18+0x340/0x340 [ 132.563003] tty_port_open+0x8d/0xf0 [ 132.563523] ? uart_set_options+0x1e0/0x1e0 [ 132.564125] uart_open+0x24/0x40 [ 132.564604] tty_open+0x15c/0x630
--- drivers/tty/serial/jsm/jsm_neo.c | 2 ++ drivers/tty/serial/jsm/jsm_tty.c | 3 +++ 2 files changed, 5 insertions(+)
drivers/tty/serial/jsm/jsm_neo.c +2 -0
@@ -827,7 +827,9 @@ static inline void neo_parse_isr(struct jsm_board *brd, u32 port)/* Parse any modem signal changes */ jsm_dbg (INTR , &ch->ch_bd->pci_dev,"MOD_STAT: sending to parse_modem_sigs\n" ); +spin_lock_irqsave (&ch->uart_port.lock, lock_flags);neo_parse_modem (ch,readb (&ch->ch_neo_uart->msr)); +spin_unlock_irqrestore (&ch->uart_port.lock, lock_flags); } }
drivers/tty/serial/jsm/jsm_tty.c +3 -0
@@ -195,6 +195,7 @@ static void jsm_tty_break(struct uart_port *port, int break_state)static int jsm_tty_open (struct uart_port *port) { +unsigned long lock_flags;struct jsm_board *brd;struct jsm_channel *channel = container_of(port, struct jsm_channel, uart_port);
@@ -248,6 +249,7 @@ static int jsm_tty_open(struct uart_port *port) channel->ch_cached_lsr =0 ; channel->ch_stops_sent =0 ; +spin_lock_irqsave (&port->lock, lock_flags); termios = &port->state->port.tty->termios; channel->ch_c_cflag = termios->c_cflag; channel->ch_c_iflag = termios->c_iflag;
@@ -267,6 +269,7 @@ static int jsm_tty_open(struct uart_port *port)jsm_carrier (channel); channel->ch_open_count++; +spin_unlock_irqrestore (&port->lock, lock_flags);jsm_dbg (OPEN , &channel->ch_bd->pci_dev,"finish\n" );return 0 ;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 10/35 bpf/tests: Fix copy-and-paste error in double word test
In reply to Sasha LevinFrom: Johan Almbladh <[email protected]>
[ Upstream commit ae7f47041d928b1a2f28717d095b4153c63cbf6a ]
This test now operates on DW as stated instead of W, which was already covered by another test.
--- lib/test_bpf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/test_bpf.c +2 -2
@@ -3983,8 +3983,8 @@ static struct bpf_test tests[] = { .u.insns_int = {BPF_LD_IMM64 (R0 ,0 ),BPF_LD_IMM64 (R1 ,0xffffffffffffffffLL ), -BPF_STX_MEM (BPF_W ,R10 ,R1 ,-40 ), -BPF_LDX_MEM (BPF_W ,R0 ,R10 ,-40 ), +BPF_STX_MEM (BPF_DW ,R10 ,R1 ,-40 ), +BPF_LDX_MEM (BPF_DW ,R0 ,R10 ,-40 ),BPF_EXIT_INSN (), }, INTERNAL,
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 11/35 bpf/tests: Do not PASS tests without actually testing the result
In reply to Sasha LevinFrom: Johan Almbladh <[email protected]>
[ Upstream commit 2b7e9f25e590726cca76700ebdb10e92a7a72ca1 ]
Each test case can have a set of sub-tests, where each sub-test can run the cBPF/eBPF test snippet with its own data_size and expected result. Before, the end of the sub-test array was indicated by both data_size and result being zero. However, most or all of the internal eBPF tests has a data_size of zero already. When such a test also had an expected value of zero, the test was never run but reported as PASS anyway.
Now the test runner always runs the first sub-test, regardless of the data_size and result values. The sub-test array zero-termination only applies for any additional sub-tests.
There are other ways fix it of course, but this solution at least removes the surprise of eBPF tests with a zero result always succeeding.
--- lib/test_bpf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
lib/test_bpf.c +8 -1
@@ -5399,7 +5399,14 @@ static int run_one(const struct bpf_prog *fp, struct bpf_test *test)u64 duration;u32 ret; -if (test->test[i].data_size ==0 && +/* +* NOTE: Several sub-tests may be present, in which case +* a zero {data_size, result} tuple indicates the end of +* the sub-test array. The first test is always run, +* even if both data_size and result happen to be zero. +*/ +if (i >0 && + test->test[i].data_size ==0 && test->test[i].result ==0 )break ;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 12/35 video: fbdev: asiliantfb: Error out if 'pixclock' equals zero
In reply to Sasha LevinFrom: Zheyu Ma <[email protected]>
[ Upstream commit b36b242d4b8ea178f7fd038965e3cac7f30c3f09 ]
The userspace program could pass any values to the driver through ioctl() interface. If the driver doesn't check the value of 'pixclock', it may cause divide error.
Fix this by checking whether 'pixclock' is zero first.
The following log reveals it:
[ 43.861711] divide error: 0000 [#1] PREEMPT SMP KASAN PTI [ 43.861737] CPU: 2 PID: 11764 Comm: i740 Not tainted 5.14.0-rc2-00513-gac532c9bbcfb-dirty #224 [ 43.861756] RIP: 0010:asiliantfb_check_var+0x4e/0x730 [ 43.861843] Call Trace: [ 43.861848] ? asiliantfb_remove+0x190/0x190 [ 43.861858] fb_set_var+0x2e4/0xeb0 [ 43.861866] ? fb_blank+0x1a0/0x1a0 [ 43.861873] ? lock_acquire+0x1ef/0x530 [ 43.861884] ? lock_release+0x810/0x810 [ 43.861892] ? lock_is_held_type+0x100/0x140 [ 43.861903] ? ___might_sleep+0x1ee/0x2d0 [ 43.861914] ? __mutex_lock+0x620/0x1190 [ 43.861921] ? do_fb_ioctl+0x313/0x700 [ 43.861929] ? mutex_lock_io_nested+0xfa0/0xfa0 [ 43.861936] ? __this_cpu_preempt_check+0x1d/0x30 [ 43.861944] ? _raw_spin_unlock_irqrestore+0x46/0x60 [ 43.861952] ? lockdep_hardirqs_on+0x59/0x100 [ 43.861959] ? _raw_spin_unlock_irqrestore+0x46/0x60 [ 43.861967] ? trace_hardirqs_on+0x6a/0x1c0 [ 43.861978] do_fb_ioctl+0x31e/0x700
--- drivers/video/fbdev/asiliantfb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/video/fbdev/asiliantfb.c +3 -0
@@ -227,6 +227,9 @@ static int asiliantfb_check_var(struct fb_var_screeninfo *var, {unsigned long Ftarget, ratio, remainder; +if (!var->pixclock) +return -EINVAL ; + ratio =1000000 / var->pixclock; remainder =1000000 % var->pixclock; Ftarget =1000000 * ratio + (1000000 * remainder) / var->pixclock;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 13/35 video: fbdev: kyro: Error out if 'pixclock' equals zero
In reply to Sasha LevinFrom: Zheyu Ma <[email protected]>
[ Upstream commit 1520b4b7ba964f8eec2e7dd14c571d50de3e5191 ]
The userspace program could pass any values to the driver through ioctl() interface. if the driver doesn't check the value of 'pixclock', it may cause divide error because the value of 'lineclock' and 'frameclock' will be zero.
Fix this by checking whether 'pixclock' is zero in kyrofb_check_var().
The following log reveals it:
[ 103.073930] divide error: 0000 [#1] PREEMPT SMP KASAN PTI [ 103.073942] CPU: 4 PID: 12483 Comm: syz-executor Not tainted 5.14.0-rc2-00478-g2734d6c1b1a0-dirty #118 [ 103.073959] RIP: 0010:kyrofb_set_par+0x316/0xc80 [ 103.074045] Call Trace: [ 103.074048] ? ___might_sleep+0x1ee/0x2d0 [ 103.074060] ? kyrofb_ioctl+0x330/0x330 [ 103.074069] fb_set_var+0x5bf/0xeb0 [ 103.074078] ? fb_blank+0x1a0/0x1a0 [ 103.074085] ? lock_acquire+0x3bd/0x530 [ 103.074094] ? lock_release+0x810/0x810 [ 103.074103] ? ___might_sleep+0x1ee/0x2d0 [ 103.074114] ? __mutex_lock+0x620/0x1190 [ 103.074126] ? trace_hardirqs_on+0x6a/0x1c0 [ 103.074137] do_fb_ioctl+0x31e/0x700 [ 103.074144] ? fb_getput_cmap+0x280/0x280 [ 103.074152] ? rcu_read_lock_sched_held+0x11/0x80 [ 103.074162] ? rcu_read_lock_sched_held+0x11/0x80 [ 103.074171] ? __sanitizer_cov_trace_switch+0x67/0xf0 [ 103.074181] ? __sanitizer_cov_trace_const_cmp2+0x20/0x80 [ 103.074191] ? do_vfs_ioctl+0x14b/0x16c0 [ 103.074199] ? vfs_fileattr_set+0xb60/0xb60 [ 103.074207] ? rcu_read_lock_sched_held+0x11/0x80 [ 103.074216] ? lock_release+0x483/0x810 [ 103.074224] ? __fget_files+0x217/0x3d0 [ 103.074234] ? __fget_files+0x239/0x3d0 [ 103.074243] ? do_fb_ioctl+0x700/0x700 [ 103.074250] fb_ioctl+0xe6/0x130
--- drivers/video/fbdev/kyro/fbdev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/video/fbdev/kyro/fbdev.c +3 -0
@@ -399,6 +399,9 @@ static int kyrofb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) {struct kyrofb_info *par = info->par; +if (!var->pixclock) +return -EINVAL ; +if (var->bits_per_pixel !=16 && var->bits_per_pixel !=32 ) {printk (KERN_WARNING "kyrofb: depth not supported: %u\n" , var->bits_per_pixel);return -EINVAL ;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 14/35 video: fbdev: riva: Error out if 'pixclock' equals zero
In reply to Sasha LevinFrom: Zheyu Ma <[email protected]>
[ Upstream commit f92763cb0feba247e0939ed137b495601fd072a5 ]
The userspace program could pass any values to the driver through ioctl() interface. If the driver doesn't check the value of 'pixclock', it may cause divide error.
Fix this by checking whether 'pixclock' is zero first.
The following log reveals it:
[ 33.396850] divide error: 0000 [#1] PREEMPT SMP KASAN PTI [ 33.396864] CPU: 5 PID: 11754 Comm: i740 Not tainted 5.14.0-rc2-00513-gac532c9bbcfb-dirty #222 [ 33.396883] RIP: 0010:riva_load_video_mode+0x417/0xf70 [ 33.396969] Call Trace: [ 33.396973] ? debug_smp_processor_id+0x1c/0x20 [ 33.396984] ? tick_nohz_tick_stopped+0x1a/0x90 [ 33.396996] ? rivafb_copyarea+0x3c0/0x3c0 [ 33.397003] ? wake_up_klogd.part.0+0x99/0xd0 [ 33.397014] ? vprintk_emit+0x110/0x4b0 [ 33.397024] ? vprintk_default+0x26/0x30 [ 33.397033] ? vprintk+0x9c/0x1f0 [ 33.397041] ? printk+0xba/0xed [ 33.397054] ? record_print_text.cold+0x16/0x16 [ 33.397063] ? __kasan_check_read+0x11/0x20 [ 33.397074] ? profile_tick+0xc0/0x100 [ 33.397084] ? __sanitizer_cov_trace_const_cmp4+0x24/0x80 [ 33.397094] ? riva_set_rop_solid+0x2a0/0x2a0 [ 33.397102] rivafb_set_par+0xbe/0x610 [ 33.397111] ? riva_set_rop_solid+0x2a0/0x2a0 [ 33.397119] fb_set_var+0x5bf/0xeb0 [ 33.397127] ? fb_blank+0x1a0/0x1a0 [ 33.397134] ? lock_acquire+0x1ef/0x530 [ 33.397143] ? lock_release+0x810/0x810 [ 33.397151] ? lock_is_held_type+0x100/0x140 [ 33.397159] ? ___might_sleep+0x1ee/0x2d0 [ 33.397170] ? __mutex_lock+0x620/0x1190 [ 33.397180] ? trace_hardirqs_on+0x6a/0x1c0 [ 33.397190] do_fb_ioctl+0x31e/0x700
--- drivers/video/fbdev/riva/fbdev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/video/fbdev/riva/fbdev.c +3 -0
@@ -1088,6 +1088,9 @@ static int rivafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)int mode_valid =0 ;NVTRACE_ENTER (); +if (!var->pixclock) +return -EINVAL ; +switch (var->bits_per_pixel) { case 1 ... 8: var->red.offset = var->green.offset = var->blue.offset =0 ;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 15/35 ipv4: ip_output.c: Fix out-of-bounds warning in ip_copy_addrs()
In reply to Sasha LevinFrom: "Gustavo A. R. Silva" <[email protected]>
[ Upstream commit 6321c7acb82872ef6576c520b0e178eaad3a25c0 ]
Fix the following out-of-bounds warning:
In function 'ip_copy_addrs',
inlined from '__ip_queue_xmit' at net/ipv4/ip_output.c:517:2:net/ipv4/ip_output.c:449:2: warning: 'memcpy' offset [40, 43] from the object at 'fl' is out of the bounds of referenced subobject 'saddr' with type 'unsigned int' at offset 36 [-Warray-bounds]
449 | memcpy(&iph->saddr, &fl4->saddr,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
450 | sizeof(fl4->saddr) + sizeof(fl4->daddr));
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~The problem is that the original code is trying to copy data into a couple of struct members adjacent to each other in a single call to memcpy(). This causes a legitimate compiler warning because memcpy() overruns the length of &iph->saddr and &fl4->saddr. As these are just a couple of struct members, fix this by using direct assignments, instead of memcpy().
This helps with the ongoing efforts to globally enable -Warray-bounds and get us closer to being able to tighten the FORTIFY_SOURCE routines on memcpy().
--- net/ipv4/ip_output.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/ipv4/ip_output.c +3 -2
@@ -376,8 +376,9 @@ static void ip_copy_addrs(struct iphdr *iph, const struct flowi4 *fl4) { BUILD_BUG_ON(offsetof(typeof(*fl4), daddr) != offsetof(typeof(*fl4), saddr) + sizeof(fl4->saddr)); -memcpy (&iph->saddr, &fl4->saddr, -sizeof (fl4->saddr) +sizeof (fl4->daddr)); + + iph->saddr = fl4->saddr; + iph->daddr = fl4->daddr; }/* Note: skb->sk can be different from sk, in case of tunnels */
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 16/35 s390/jump_label: print real address in a case of a jump label bug
In reply to Sasha LevinFrom: Heiko Carstens <[email protected]>
[ Upstream commit 5492886c14744d239e87f1b0b774b5a341e755cc ]
In case of a jump label print the real address of the piece of code where a mismatch was detected. This is right before the system panics, so there is nothing revealed.
--- arch/s390/kernel/jump_label.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/jump_label.c +1 -1
@@ -43,7 +43,7 @@ static void jump_label_bug(struct jump_entry *entry, struct insn *expected,unsigned char *ipe = (unsigned char *)expected;unsigned char *ipn = (unsigned char *)new; -pr_emerg ("Jump label code mismatch at %pS [%p]\n" , ipc, ipc); +pr_emerg ("Jump label code mismatch at %pS [%px]\n" , ipc, ipc);pr_emerg ("Found: %6ph\n" , ipc);pr_emerg ("Expected: %6ph\n" , ipe);pr_emerg ("New: %6ph\n" , ipn);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 17/35 serial: 8250: Define RX trigger levels for OxSemi 950 devices
In reply to Sasha LevinFrom: "Maciej W. Rozycki" <[email protected]>
[ Upstream commit d7aff291d069c4418285f3c8ee27b0ff67ce5998 ]
Oxford Semiconductor 950 serial port devices have a 128-byte FIFO and in the enhanced (650) mode, which we select in `autoconfig_has_efr' with the ECB bit set in the EFR register, they support the receive interrupt trigger level selectable with FCR bits 7:6 from the set of 16, 32, 112,
120. This applies to the original OX16C950 discrete UART[1] as well as 950 cores embedded into more complex devices.
For these devices we set the default to 112, which sets an excessively high level of 112 or 7/8 of the FIFO capacity, unlike with other port types where we choose at most 1/2 of their respective FIFO capacities. Additionally we don't make the trigger level configurable. Consequently frequent input overruns happen with high bit rates where hardware flow control cannot be used (e.g. terminal applications) even with otherwise highly-performant systems.
Lower the default receive interrupt trigger level to 32 then, and make it configurable. Document the trigger levels along with other port types, including the set of 16, 32, 64, 112 for the transmit interrupt as well[2].
References:
[1] "OX16C950 rev B High Performance UART with 128 byte FIFOs", Oxford Semiconductor, Inc., DS-0031, Sep 05, Table 10: "Receiver Trigger Levels", p. 22
[2] same, Table 9: "Transmit Interrupt Trigger Levels", p. 22
--- drivers/tty/serial/8250/8250_port.c | 3 ++- include/uapi/linux/serial_reg.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_port.c +2 -1
@@ -124,7 +124,8 @@ static const struct serial8250_config uart_config[] = { .name = "16C950/954", .fifo_size = 128, .tx_loadsz = 128, - .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10, + .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_01, + .rxtrig_bytes = {16, 32, 112, 120},/* UART_CAP_EFR breaks billionon CF bluetooth card. */ .flags = UART_CAP_FIFO | UART_CAP_SLEEP, },
include/uapi/linux/serial_reg.h +1 -0
@@ -61,6 +61,7 @@* ST16C654: 8 16 56 60 8 16 32 56 PORT_16654 * TI16C750: 1 16 32 56 xx xx xx xx PORT_16750 * TI16C752: 8 16 56 60 8 16 32 56 +* OX16C950: 16 32 112 120 16 32 64 112 PORT_16C950 * Tegra: 1 4 8 14 16 8 4 1 PORT_TEGRA */ #define UART_FCR_R_TRIG_00 0x00
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 18/35 xtensa: ISS: don't panic in rs_init
In reply to Sasha LevinFrom: Jiri Slaby <[email protected]>
[ Upstream commit 23411c720052ad860b3e579ee4873511e367130a ]
While alloc_tty_driver failure in rs_init would mean we have much bigger problem, there is no reason to panic when tty_register_driver fails there. It can fail for various reasons.
So handle the failure gracefully. Actually handle them both while at it. This will make at least the console functional as it was enabled earlier by console_initcall in iss_console_init. Instead of shooting down the whole system.
We move tty_port_init() after alloc_tty_driver(), so that we don't need to destroy the port in case the latter function fails.
--- arch/xtensa/platforms/iss/console.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
arch/xtensa/platforms/iss/console.c +14 -3
@@ -186,9 +186,13 @@ static const struct tty_operations serial_ops = {int __init rs_init (void ) { -tty_port_init (&serial_port); +int ret; serial_driver =alloc_tty_driver (SERIAL_MAX_NUM_LINES ); +if (!serial_driver) +return -ENOMEM ; + +tty_port_init (&serial_port);printk ("%s %s\n" , serial_name, serial_version);
@@ -208,8 +212,15 @@ int __init rs_init(void)tty_set_operations (serial_driver, &serial_ops);tty_port_link_device (&serial_port, serial_driver,0 ); -if (tty_register_driver (serial_driver)) -panic ("Couldn't register serial driver\n" ); + ret =tty_register_driver (serial_driver); +if (ret) { +pr_err ("Couldn't register serial driver\n" ); +tty_driver_kref_put (serial_driver); +tty_port_destroy (&serial_port); + +return ret; + } +return 0 ; }
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 19/35 hvsi: don't panic on tty_register_driver failure
In reply to Sasha LevinFrom: Jiri Slaby <[email protected]>
[ Upstream commit 7ccbdcc4d08a6d7041e4849219bbb12ffa45db4c ]
The alloc_tty_driver failure is handled gracefully in hvsi_init. But tty_register_driver is not. panic is called if that one fails.
So handle the failure of tty_register_driver gracefully too. This will keep at least the console functional as it was enabled earlier by console_initcall in hvsi_console_init. Instead of shooting down the whole system.
This means, we disable interrupts and restore hvsi_wait back to poll_for_state().
--- drivers/tty/hvc/hvsi.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/tty/hvc/hvsi.c +16 -3
@@ -1051,7 +1051,7 @@ static const struct tty_operations hvsi_ops = {static int __init hvsi_init (void ) { -int i; +int i, ret; hvsi_driver =alloc_tty_driver (hvsi_count);if (!hvsi_driver)
@@ -1082,12 +1082,25 @@ static int __init hvsi_init(void) } hvsi_wait = wait_for_state;/* irqs active now */ -if (tty_register_driver (hvsi_driver)) -panic ("Couldn't register hvsi console driver\n" ); + ret =tty_register_driver (hvsi_driver); +if (ret) { +pr_err ("Couldn't register hvsi console driver\n" ); + goto err_free_irq; + }printk (KERN_DEBUG "HVSI: registered %i devices\n" , hvsi_count);return 0 ; +err_free_irq: + hvsi_wait = poll_for_state; +for (i =0 ; i < hvsi_count; i++) { +struct hvsi_struct *hp = &hvsi_ports[i]; + +free_irq (hp->virq, hp); + } +tty_driver_kref_put (hvsi_driver); + +return ret; }device_initcall (hvsi_init);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 20/35 serial: 8250_pci: make setup_port() parameters explicitly unsigned
In reply to Sasha LevinFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 3a96e97ab4e835078e6f27b7e1c0947814df3841 ]
The bar and offset parameters to setup_port() are used in pointer math, and while it would be very difficult to get them to wrap as a negative number, just be "safe" and make them unsigned so that static checkers do not trip over them unintentionally.
--- drivers/tty/serial/8250/8250_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/8250/8250_pci.c +1 -1
@@ -78,7 +78,7 @@ static void moan_device(const char *str, struct pci_dev *dev)static int setup_port (struct serial_private *priv,struct uart_8250_port *port, -int bar,int offset,int regshift) +u8 bar,unsigned int offset,int regshift) {struct pci_dev *dev = priv->dev;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 21/35 Bluetooth: skip invalid hci_sync_conn_complete_evt
In reply to Sasha LevinFrom: Desmond Cheong Zhi Xi <[email protected]>
[ Upstream commit 92fe24a7db751b80925214ede43f8d2be792ea7b ]
Syzbot reported a corrupted list in kobject_add_internal [1]. This happens when multiple HCI_EV_SYNC_CONN_COMPLETE event packets with status 0 are sent for the same HCI connection. This causes us to register the device more than once which corrupts the kset list.
As this is forbidden behavior, we add a check for whether we're trying to process the same HCI_EV_SYNC_CONN_COMPLETE event multiple times for one connection. If that's the case, the event is invalid, so we report an error that the device is misbehaving, and ignore the packet.
--- net/bluetooth/hci_event.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
net/bluetooth/hci_event.c +15 -0
@@ -3747,6 +3747,21 @@ static void hci_sync_conn_complete_evt(struct hci_dev *hdev,switch (ev->status) {case 0x00 : +/* The synchronous connection complete event should only be +* sent once per new connection. Receiving a successful +* complete event when the connection status is already +* BT_CONNECTED means that the device is misbehaving and sent +* multiple complete event packets for the same new connection. +* +* Registering the device more than once can corrupt kernel +* memory, hence upon detecting this invalid event, we report +* an error and ignore the packet. +*/ +if (conn->state ==BT_CONNECTED ) { +bt_dev_err (hdev,"Ignoring connect complete event for existing connection" ); + goto unlock; + } + conn->handle =__le16_to_cpu (ev->handle); conn->state =BT_CONNECTED ; conn->type = ev->link_type;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 22/35 gpu: drm: amd: amdgpu: amdgpu_i2c: fix possible uninitialized-variable access in amdgpu_i2c_router_select_ddc_port()
In reply to Sasha LevinFrom: Tuo Li <[email protected]>
[ Upstream commit a211260c34cfadc6068fece8c9e99e0fe1e2a2b6 ]
The variable val is declared without initialization, and its address is passed to amdgpu_i2c_get_byte(). In this function, the value of val is accessed in:
DRM_DEBUG("i2c 0x%02x 0x%02x read failed\n",
addr, *val);
Also, when amdgpu_i2c_get_byte() returns, val may remain uninitialized, but it is accessed in:
val &= ~amdgpu_connector->router.ddc_mux_control_pin;
To fix this possible uninitialized-variable access, initialize val to 0 in amdgpu_i2c_router_select_ddc_port().
--- drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c +1 -1
@@ -340,7 +340,7 @@ static void amdgpu_i2c_put_byte(struct amdgpu_i2c_chan *i2c_bus,void amdgpu_i2c_router_select_ddc_port (struct amdgpu_connector *amdgpu_connector) { -u8 val; +u8 val =0 ;if (!amdgpu_connector->router.ddc_valid)return ;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 23/35 ARM: tegra: tamonten: Fix UART pad setting
In reply to Sasha LevinFrom: Andreas Obergschwandtner <[email protected]>
[ Upstream commit 2270ad2f4e123336af685ecedd1618701cb4ca1e ]
This patch fixes the tristate and pullup configuration for UART 1 to 3 on the Tamonten SOM.
--- arch/arm/boot/dts/tegra20-tamonten.dtsi | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
arch/arm/boot/dts/tegra20-tamonten.dtsi +7 -7
@@ -180,8 +180,9 @@ conf_ata { nvidia,pins = "ata", "atb", "atc", "atd", "ate", "cdev1", "cdev2", "dap1", "dtb", "gma", "gmb", "gmc", "gmd", "gme", "gpu7", - "gpv", "i2cp", "pta", "rm", "slxa", - "slxk", "spia", "spib", "uac"; + "gpv", "i2cp", "irrx", "irtx", "pta", + "rm", "slxa", "slxk", "spia", "spib", + "uac"; nvidia,pull = <TEGRA_PIN_PULL_NONE>; nvidia,tristate = <TEGRA_PIN_DISABLE>; };
@@ -206,7 +207,7 @@ conf_crtp { conf_ddc { nvidia,pins = "ddc", "dta", "dtd", "kbca", "kbcb", "kbcc", "kbcd", "kbce", "kbcf", - "sdc"; + "sdc", "uad", "uca"; nvidia,pull = <TEGRA_PIN_PULL_UP>; nvidia,tristate = <TEGRA_PIN_DISABLE>; };
@@ -216,10 +217,9 @@ conf_hdint { "lvp0", "owc", "sdb"; nvidia,tristate = <TEGRA_PIN_ENABLE>; }; - conf_irrx { - nvidia,pins = "irrx", "irtx", "sdd", "spic", - "spie", "spih", "uaa", "uab", "uad", - "uca", "ucb"; + conf_sdd { + nvidia,pins = "sdd", "spic", "spie", "spih", + "uaa", "uab", "ucb"; nvidia,pull = <TEGRA_PIN_PULL_UP>; nvidia,tristate = <TEGRA_PIN_ENABLE>; };
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 24/35 ACPICA: iASL: Fix for WPBT table with no command-line arguments
In reply to Sasha LevinFrom: Bob Moore <[email protected]>
[ Upstream commit 87b8ec5846cb81747088d1729acaf55a1155a267 ]
Handle the case where the Command-line Arguments table field does not exist.
ACPICA commit d6487164497fda170a1b1453c5d58f2be7c873d6
--- include/acpi/actbl3.h | 4 ++++ 1 file changed, 4 insertions(+)
include/acpi/actbl3.h +4 -0
@@ -738,6 +738,10 @@ struct acpi_table_wpbt {u16 arguments_length; }; +struct acpi_wpbt_unicode { +u16 *unicode_string; +}; +/******************************************************************************* * * XENV - Xen Environment Table (ACPI 6.0)
Signature · 1 line
2.30.2
Re: [PATCH AUTOSEL 4.4 24/35] ACPICA: iASL: Fix for WPBT table with no command-line arguments
Hi!
Quoted 4 lines
Handle the case where the Command-line Arguments table field does not exist.
ACPICA commit
d6487164497fda170a1b1453c5d58f2be7c873d6
I'm not sure what is going on here, but adding unused definition will not make any difference for 4.4 users, so we don't need this in -stable...?
Best regards,
Pavel
Quoted 12 lines
+++
b/include/acpi/actbl3.hinclude/acpi/actbl3.h +4
-0@@ -738,6 +738,10 @@ struct acpi_table_wpbt {u16 arguments_length; }; +struct acpi_wpbt_unicode { +u16 *unicode_string; +}; +/******************************************************************************* * * XENV - Xen Environment Table (ACPI 6.0)
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Sasha Levin
maintainerRe: [PATCH AUTOSEL 4.4 24/35] ACPICA: iASL: Fix for WPBT table with no command-line arguments
Quoted 10 lines · Pavel Machek
Hi!
Quoted 4 lines
Handle the case where the Command-line Arguments table field does not exist.
ACPICA commit
d6487164497fda170a1b1453c5d58f2be7c873d6I'm not sure what is going on here, but adding unused definition will not make any difference for 4.4 users, so we don't need this in -stable...?
Ugh, dropped, thanks!
I wonder what this patch actually does upstream.
Signature · 2 lines
Thanks, Sasha
Rafael J. Wysocki
maintainerRe: [PATCH AUTOSEL 4.4 24/35] ACPICA: iASL: Fix for WPBT table with no command-line arguments
Quoted 9 lines · Sasha Levin
Quoted 7 lines · Pavel Machek
Hi!
Quoted 4 lines
Handle the case where the Command-line Arguments table field does not exist.
ACPICA commit
d6487164497fda170a1b1453c5d58f2be7c873d6
Quoted 7 lines
Quoted 3 lines
I'm not sure what is going on here, but adding unused definition will not make any difference for 4.4 users, so we don't need this in -stable...?
Ugh, dropped, thanks!
I wonder what this patch actually does upstream.
There are AML compiler changes in it, but the compiler is not included into the Linux kernel.
RE: [PATCH AUTOSEL 4.4 24/35] ACPICA: iASL: Fix for WPBT table with no command-line arguments
In reply to Pavel MachekThis structure is used by the iASL data table disassembler. Bob
-----Original Message-----
From: Pavel Machek <pavel(a)denx.de>
Sent: Friday, September 10, 2021 12:46 AM
To: Sasha Levin <sashal(a)kernel.org>
Cc: linux-kernel(a)vger.kernel.org; stable(a)vger.kernel.org; Moore, Robert <robert.moore(a)intel.com>; Wysocki, Rafael J <rafael.j.wysocki(a)intel.com>; linux-acpi(a)vger.kernel.org; devel(a)acpica.org
Subject: Re: [PATCH AUTOSEL 4.4 24/35] ACPICA: iASL: Fix for WPBT table with no command-line arguments
Hi!
Quoted 4 lines
Handle the case where the Command-line Arguments table field does not exist.
ACPICA commit
d6487164497fda170a1b1453c5d58f2be7c873d6
I'm not sure what is going on here, but adding unused definition will not make any difference for 4.4 users, so we don't need this in -stable...?
Best regards,
Pavel
Quoted 12 lines
+++
b/include/acpi/actbl3.hinclude/acpi/actbl3.h +4
-0@@ -738,6 +738,10 @@ struct acpi_table_wpbt {u16 arguments_length; }; +struct acpi_wpbt_unicode { +u16 *unicode_string; +}; +/******************************************************************************* * * XENV - Xen Environment Table (ACPI 6.0)
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Sasha Levin
maintainerPATCH 25/35 rpc: fix gss_svc_init cleanup on failure
In reply to Sasha LevinFrom: "J. Bruce Fields" <[email protected]>
[ Upstream commit 5a4753446253a427c0ff1e433b9c4933e5af207c ]
The failure case here should be rare, but it's obviously wrong.
--- net/sunrpc/auth_gss/svcauth_gss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/auth_gss/svcauth_gss.c +1 -1
@@ -1845,7 +1845,7 @@ gss_svc_init_net(struct net *net) goto out2;return 0 ; out2: -destroy_use_gss_proxy_proc_entry (net); +rsi_cache_destroy_net (net); out1:rsc_cache_destroy_net (net);return rv;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 26/35 gfs2: Don't call dlm after protocol is unmounted
In reply to Sasha LevinFrom: Bob Peterson <[email protected]>
[ Upstream commit d1340f80f0b8066321b499a376780da00560e857 ]
In the gfs2 withdraw sequence, the dlm protocol is unmounted with a call to lm_unmount. After a withdraw, users are allowed to unmount the withdrawn file system. But at that point we may still have glocks left over that we need to free via unmount's call to gfs2_gl_hash_clear. These glocks may have never been completed because of whatever problem caused the withdraw (IO errors or whatever).
Before this patch, function gdlm_put_lock would still try to call into dlm to unlock these leftover glocks, which resulted in dlm returning -EINVAL because the lock space was abandoned. These glocks were never freed because there was no mechanism after that to free them.
This patch adds a check to gdlm_put_lock to see if the locking protocol was inactive (DFL_UNMOUNT flag) and if so, free the glock and not make the invalid call into dlm.
I could have combined this "if" with the one that follows, related to leftover glock LVBs, but I felt the code was more readable with its own if clause.
--- fs/gfs2/lock_dlm.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/gfs2/lock_dlm.c +5 -0
@@ -296,6 +296,11 @@ static void gdlm_put_lock(struct gfs2_glock *gl)gfs2_sbstats_inc (gl,GFS2_LKS_DCOUNT );gfs2_update_request_times (gl); +/* don't want to call dlm if we've unmounted the lock protocol */ +if (test_bit (DFL_UNMOUNT , &ls->ls_recover_flags)) { +gfs2_glock_free (gl); +return ; + }/* don't want to skip dlm_unlock writing the lvb when lock has one */ if (test_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags) &&
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 27/35 btrfs: subpage: check if there are compressed extents inside one page
In reply to Sasha LevinFrom: Qu Wenruo <[email protected]>
[ Upstream commit 3670e6451bc9c39ab3a46f1da19360219e4319f3 ]
[BUG]
When testing experimental subpage compressed write support, it hits a NULL pointer dereference inside read path:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000018 pc : __pi_memcmp+0x28/0x1ec lr : check_data_csum+0xd0/0x274 [btrfs] Call trace: __pi_memcmp+0x28/0x1ec btrfs_verify_data_csum+0xf4/0x244 [btrfs] end_bio_extent_readpage+0x1d0/0x6b0 [btrfs] bio_endio+0x15c/0x1dc end_workqueue_fn+0x44/0x64 [btrfs] btrfs_work_helper+0x74/0x250 [btrfs] process_one_work+0x1d4/0x47c worker_thread+0x180/0x400 kthread+0x11c/0x120 ret_from_fork+0x10/0x30 Code: 54000261 d100044c d343fd8c f8408403 (f8408424) ---[ end trace 9e2c59f33ea40866 ]---
[CAUSE]
When reading two compressed extents inside the same page, like the following layout, we trigger above crash:
0 32K 64K |-------|\\\\\\\| | \- Compressed extent (A) \--------- Compressed extent (B)
For compressed read, we don't need to populate its io_bio->csum, as we rely on compressed_bio->csum to verify the compressed data, and then copy the decompressed to inode pages.
Normally btrfs_verify_data_csum() skip such page by checking and clearing its PageChecked flag
But since that flag is still for the full page, when endio for inode page range [0, 32K) gets executed, it clears PageChecked flag for the full page.
Then when endio for inode page range [32K, 64K) gets executed, since the page no longer has PageChecked flag, it just continues checking, even though io_bio->csum is NULL.
[FIX]
Thankfully there are only two users of PageChecked bit:
- Cow fixup
Since subpage has its own way to trace page dirty (dirty_bitmap) and ordered bit (ordered_bitmap), it should never trigger cow fixup.
- Compressed read
We can distinguish such read by just checking io_bio->csum.
So just check io_bio->csum before doing the verification to avoid such NULL pointer dereference.
--- fs/btrfs/inode.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/btrfs/inode.c +14 -0
@@ -3146,6 +3146,20 @@ static int btrfs_readpage_end_io_hook(struct btrfs_io_bio *io_bio,return 0 ; } +/* +* For subpage case, above PageChecked is not safe as it's not subpage +* compatible. +* But for now only cow fixup and compressed read utilize PageChecked +* flag, while in this context we can easily use io_bio->csum to +* determine if we really need to do csum verification. +* +* So for now, just exit if io_bio->csum is NULL, as it means it's +* compressed read, and its compressed data csum has already been +* verified. +*/ +if (io_bio->csum ==NULL ) +return 0 ; +if (BTRFS_I (inode)->flags &BTRFS_INODE_NODATASUM )return 0 ;
Signature · 1 line
2.30.2
Re: [PATCH AUTOSEL 4.4 27/35] btrfs: subpage: check if there are compressed extents inside one page
Quoted 3 lines · Sasha Levin
From: Qu Wenruo <[email protected]>
[ Upstream commit
3670e6451bc9c39ab3a46f1da19360219e4319f3]
Please drop this patch from stable queue, thanks.
Sasha Levin
maintainerPATCH 28/35 btrfs: subpage: fix race between prepare_pages() and btrfs_releasepage()
In reply to Sasha LevinFrom: Qu Wenruo <[email protected]>
[ Upstream commit e0467866198f7f536806f39e5d0d91ae8018de08 ]
[BUG]
When running generic/095, there is a high chance to crash with subpage data RW support:
assertion failed: PagePrivate(page) && page->private
------------[ cut here ]------------ kernel BUG at fs/btrfs/ctree.h:3403! Internal error: Oops - BUG: 0 [#1] SMP CPU: 1 PID: 3567 Comm: fio Tainted: 5.12.0-rc7-custom+ #17 Hardware name: Khadas VIM3 (DT) Call trace: assertfail.constprop.0+0x28/0x2c [btrfs] btrfs_subpage_assert+0x80/0xa0 [btrfs] btrfs_subpage_set_uptodate+0x34/0xec [btrfs] btrfs_page_clamp_set_uptodate+0x74/0xa4 [btrfs] btrfs_dirty_pages+0x160/0x270 [btrfs] btrfs_buffered_write+0x444/0x630 [btrfs] btrfs_direct_write+0x1cc/0x2d0 [btrfs] btrfs_file_write_iter+0xc0/0x160 [btrfs] new_sync_write+0xe8/0x180 vfs_write+0x1b4/0x210 ksys_pwrite64+0x7c/0xc0 __arm64_sys_pwrite64+0x24/0x30 el0_svc_common.constprop.0+0x70/0x140 do_el0_svc+0x28/0x90 el0_svc+0x2c/0x54 el0_sync_handler+0x1a8/0x1ac el0_sync+0x170/0x180 Code: f0000160 913be042 913c4000 955444bc (d4210000) ---[ end trace 3fdd39f4cccedd68 ]---
[CAUSE]
Although prepare_pages() calls find_or_create_page(), which returns the page locked, but in later prepare_uptodate_page() calls, we may call btrfs_readpage() which will unlock the page before it returns.
This leaves a window where btrfs_releasepage() can sneak in and release the page, clearing page->private and causing above ASSERT().
[FIX]
In prepare_uptodate_page(), we should not only check page->mapping, but also PagePrivate() to ensure we are still holding the correct page which has proper fs context setup.
--- fs/btrfs/file.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
fs/btrfs/file.c +12 -1
@@ -1307,7 +1307,18 @@ static int prepare_uptodate_page(struct inode *inode,unlock_page (page);return -EIO ; } -if (page->mapping != inode->i_mapping) { + +/* +* Since btrfs_readpage() will unlock the page before it +* returns, there is a window where btrfs_releasepage() can +* be called to release the page. +* Here we check both inode mapping and PagePrivate() to +* make sure the page was not released. +* +* The private flag check is essential for subpage as we need +* to store extra bitmap using page->private. +*/ +if (page->mapping != inode->i_mapping || !PagePrivate (page)) {unlock_page (page);return -EAGAIN ; }
Signature · 1 line
2.30.2
Re: [PATCH AUTOSEL 4.4 28/35] btrfs: subpage: fix race between prepare_pages() and btrfs_releasepage()
Quoted 3 lines · Sasha Levin
From: Qu Wenruo <[email protected]>
[ Upstream commit
e0467866198f7f536806f39e5d0d91ae8018de08]
Please drop this patch from stable queue, thanks.
Sasha Levin
maintainerPATCH 29/35 ASoC: intel: atom: Revert PCM buffer address setup workaround again
In reply to Sasha LevinFrom: Takashi Iwai <[email protected]>
[ Upstream commit e28ac04a705e946eddc5e7d2fc712dea3f20fe9e ]
We worked around the breakage of PCM buffer setup by the commit 65ca89c2b12c ("ASoC: intel: atom: Fix breakage for PCM buffer address setup"), but this isn't necessary since the CONTINUOUS buffer type also sets runtime->dma_addr since commit f84ba106a018 ("ALSA:
memalloc: Store snd_dma_buffer.addr for continuous pages, too"). Let's revert the change again.
--- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/atom/sst-mfld-platform-pcm.c +1 -1
@@ -134,7 +134,7 @@ static void sst_fill_alloc_params(struct snd_pcm_substream *substream,snd_pcm_uframes_t period_size;ssize_t periodbytes;ssize_t buffer_bytes =snd_pcm_lib_buffer_bytes (substream); -u32 buffer_addr =virt_to_phys (substream->runtime->dma_area); +u32 buffer_addr = substream->runtime->dma_addr; channels = substream->runtime->channels; period_size = substream->runtime->period_size;
Signature · 1 line
2.30.2
Re: [PATCH AUTOSEL 4.4 29/35] ASoC: intel: atom: Revert PCM buffer address setup workaround again
Quoted 12 lines · Sasha Levin
From: Takashi Iwai <[email protected]>
[ Upstream commit
e28ac04a705e946eddc5e7d2fc712dea3f20fe9e]We worked around the breakage of PCM buffer setup by the commit
65ca89c2b12c("ASoC: intel: atom: Fix breakage for PCM buffer address setup"), but this isn't necessary since the CONTINUOUS buffer type also setsruntime->dma_addrsince commitf84ba106a018("ALSA:
memalloc: Store snd_dma_buffer.addr for continuous pages, too"). Let's revert the change again.
Quoted 3 lines
Signed-off-by Takashi Iwai <[email protected]>Signed-off-by Sasha Levin <[email protected]>
Please drop this.
Takashi
Sasha Levin
maintainerRe: [PATCH AUTOSEL 4.4 29/35] ASoC: intel: atom: Revert PCM buffer address setup workaround again
Quoted 14 lines · Takashi Iwai
Quoted 12 lines · Sasha Levin
From: Takashi Iwai <[email protected]>
[ Upstream commit
e28ac04a705e946eddc5e7d2fc712dea3f20fe9e]We worked around the breakage of PCM buffer setup by the commit
65ca89c2b12c("ASoC: intel: atom: Fix breakage for PCM buffer address setup"), but this isn't necessary since the CONTINUOUS buffer type also setsruntime->dma_addrsince commitf84ba106a018("ALSA:
memalloc: Store snd_dma_buffer.addr for continuous pages, too"). Let's revert the change again.
Quoted 5 lines
Quoted 3 lines
Signed-off-by Takashi Iwai <[email protected]>Signed-off-by Sasha Levin <[email protected]>Please drop this.
Will do, thanks!
Signature · 2 lines
Thanks, Sasha
Sasha Levin
maintainerPATCH 30/35 mmc: rtsx_pci: Fix long reads when clock is prescaled
In reply to Sasha LevinFrom: Thomas Hebb <[email protected]>
[ Upstream commit 3ac5e45291f3f0d699a721357380d4593bc2dcb3 ]
For unexplained reasons, the prescaler register for this device needs to be cleared (set to 1) while performing a data read or else the command will hang. This does not appear to affect the real clock rate sent out on the bus, so I assume it's purely to work around a hardware bug.
During normal operation, the prescaler is already set to 1, so nothing needs to be done. However, in "initial mode" (which is used for sub-MHz clock speeds, like the core sets while enumerating cards), it's set to 128 and so we need to reset it during data reads. We currently fail to do this for long reads.
This has no functional affect on the driver's operation currently written, as the MMC core always sets a clock above 1MHz before attempting any long reads. However, the core could conceivably set any clock speed at any time and the driver should still work, so I think this fix is worthwhile.
I personally encountered this issue while performing data recovery on an external chip. My connections had poor signal integrity, so I modified the core code to reduce the clock speed. Without this change, I saw the card enumerate but was unable to actually read any data.
Writes don't seem to work in the situation described above even with this change (and even if the workaround is extended to encompass data write commands). I was not able to find a way to get them working.
--- drivers/mmc/host/rtsx_pci_sdmmc.c | 36 ++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-)
drivers/mmc/host/rtsx_pci_sdmmc.c +23 -13
@@ -553,9 +553,22 @@ static int sd_write_long_data(struct realtek_pci_sdmmc *host,return 0 ; } +static inline void sd_enable_initial_mode (struct realtek_pci_sdmmc *host) +{ +rtsx_pci_write_register (host->pcr,SD_CFG1 , +SD_CLK_DIVIDE_MASK ,SD_CLK_DIVIDE_128 ); +} + +static inline void sd_disable_initial_mode (struct realtek_pci_sdmmc *host) +{ +rtsx_pci_write_register (host->pcr,SD_CFG1 , +SD_CLK_DIVIDE_MASK ,SD_CLK_DIVIDE_0 ); +} +static int sd_rw_multi (struct realtek_pci_sdmmc *host,struct mmc_request *mrq) {struct mmc_data *data = mrq->data; +int err;if (host->sg_count <0 ) { data->error = host->sg_count;
@@ -564,22 +577,19 @@ static int sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq)return data->error; } -if (data->flags &MMC_DATA_READ ) -return sd_read_long_data (host, mrq); +if (data->flags &MMC_DATA_READ ) { +if (host->initial_mode) +sd_disable_initial_mode (host); -return sd_write_long_data (host, mrq); -} + err =sd_read_long_data (host, mrq); -static inline void sd_enable_initial_mode (struct realtek_pci_sdmmc *host) -{ -rtsx_pci_write_register (host->pcr,SD_CFG1 , -SD_CLK_DIVIDE_MASK ,SD_CLK_DIVIDE_128 ); -} +if (host->initial_mode) +sd_enable_initial_mode (host); -static inline void sd_disable_initial_mode (struct realtek_pci_sdmmc *host) -{ -rtsx_pci_write_register (host->pcr,SD_CFG1 , -SD_CLK_DIVIDE_MASK ,SD_CLK_DIVIDE_0 ); +return err; + } + +return sd_write_long_data (host, mrq); } static void sd_normal_rw(struct realtek_pci_sdmmc *host,
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 31/35 cifs: fix wrong release in sess_alloc_buffer() failed path
In reply to Sasha LevinFrom: Ding Hui <[email protected]>
[ Upstream commit d72c74197b70bc3c95152f351a568007bffa3e11 ]
smb_buf is allocated by small_smb_init_no_tc(), and buf type is CIFS_SMALL_BUFFER, so we should use cifs_small_buf_release() to release it in failed path.
--- fs/cifs/sess.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/sess.c +1 -1
@@ -602,7 +602,7 @@ sess_alloc_buffer(struct sess_data *sess_data, int wct)return 0 ; out_free_smb_buf: -kfree (smb_buf); +cifs_small_buf_release (smb_buf); sess_data->iov[0 ].iov_base =NULL ; sess_data->iov[0 ].iov_len =0 ; sess_data->buf0_type =CIFS_NO_BUFFER ;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 32/35 Revert "USB: xhci: fix U1/U2 handling for hardware with XHCI_INTEL_HOST quirk set"
In reply to Sasha LevinFrom: Mathias Nyman <[email protected]>
[ Upstream commit 2847c46c61486fd8bca9136a6e27177212e78c69 ]
This reverts commit 5d5323a6f3625f101dbfa94ba3ef7706cce38760.
That commit effectively disabled Intel host initiated U1/U2 lpm for devices with periodic endpoints.
Before that commit we disabled host initiated U1/U2 lpm if the exit latency was larger than any periodic endpoint service interval, this is according to xhci spec xhci 1.1 specification section 4.23.5.2
After that commit we incorrectly checked that service interval was smaller than U1/U2 inactivity timeout. This is not relevant, and can't happen for Intel hosts as previously set U1/U2 timeout = 105% * service interval.
Patch claimed it solved cases where devices can't be enumerated because of bandwidth issues. This might be true but it's a side effect of accidentally turning off lpm.
exit latency calculations have been revised since then
--- drivers/usb/host/xhci.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
drivers/usb/host/xhci.c +12 -12
@@ -4438,19 +4438,19 @@ static u16 xhci_calculate_u1_timeout(struct xhci_hcd *xhci, {unsigned long long timeout_ns; -if (xhci->quirks &XHCI_INTEL_HOST ) - timeout_ns =xhci_calculate_intel_u1_timeout (udev, desc); -else - timeout_ns = udev->u1_params.sel; -/* Prevent U1 if service interval is shorter than U1 exit latency */ if (usb_endpoint_xfer_int (desc) ||usb_endpoint_xfer_isoc (desc)) { -if (xhci_service_interval_to_ns (desc) <= timeout_ns) { +if (xhci_service_interval_to_ns (desc) <= udev->u1_params.mel) {dev_dbg (&udev->dev,"Disable U1, ESIT shorter than exit latency\n" );return USB3_LPM_DISABLED ; } } +if (xhci->quirks &XHCI_INTEL_HOST ) + timeout_ns =xhci_calculate_intel_u1_timeout (udev, desc); +else + timeout_ns = udev->u1_params.sel; +/* The U1 timeout is encoded in 1us intervals. * Don't return a timeout of zero, because that's USB3_LPM_DISABLED. */
@@ -4502,19 +4502,19 @@ static u16 xhci_calculate_u2_timeout(struct xhci_hcd *xhci, {unsigned long long timeout_ns; -if (xhci->quirks &XHCI_INTEL_HOST ) - timeout_ns =xhci_calculate_intel_u2_timeout (udev, desc); -else - timeout_ns = udev->u2_params.sel; -/* Prevent U2 if service interval is shorter than U2 exit latency */ if (usb_endpoint_xfer_int (desc) ||usb_endpoint_xfer_isoc (desc)) { -if (xhci_service_interval_to_ns (desc) <= timeout_ns) { +if (xhci_service_interval_to_ns (desc) <= udev->u2_params.mel) {dev_dbg (&udev->dev,"Disable U2, ESIT shorter than exit latency\n" );return USB3_LPM_DISABLED ; } } +if (xhci->quirks &XHCI_INTEL_HOST ) + timeout_ns =xhci_calculate_intel_u2_timeout (udev, desc); +else + timeout_ns = udev->u2_params.sel; +/* The U2 timeout is encoded in 256us intervals */ timeout_ns =DIV_ROUND_UP_ULL (timeout_ns,256 *1000 );/* If the necessary timeout value is bigger than what we can set in the
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 33/35 parport: remove non-zero check on count
In reply to Sasha LevinFrom: Colin Ian King <[email protected]>
[ Upstream commit 0be883a0d795d9146f5325de582584147dd0dcdc ]
The check for count appears to be incorrect since a non-zero count check occurs a couple of statements earlier. Currently the check is always false and the dev->port->irq != PARPORT_IRQ_NONE part of the check is never tested and the if statement is dead-code. Fix this by removing the check on count.
Note that this code is pre-git history, so I can't find a sha for it.
Addresses-Coverity: ("Logically dead code")
--- drivers/parport/ieee1284_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/parport/ieee1284_ops.c +1 -1
@@ -534,7 +534,7 @@ size_t parport_ieee1284_ecp_read_data (struct parport *port, goto out;/* Yield the port for a while. */ -if (count && dev->port->irq !=PARPORT_IRQ_NONE ) { +if (dev->port->irq !=PARPORT_IRQ_NONE ) {parport_release (dev);schedule_timeout_interruptible (msecs_to_jiffies (40 ));parport_claim_or_block (dev);
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 34/35 ath9k: fix OOB read ar9300_eeprom_restore_internal
In reply to Sasha LevinFrom: Zekun Shen <[email protected]>
[ Upstream commit 23151b9ae79e3bc4f6a0c4cd3a7f355f68dad128 ]
Bad header can have large length field which can cause OOB. cptr is the last bytes for read, and the eeprom is parsed from high to low address. The OOB, triggered by the condition length > cptr could cause memory error with a read on negative index.
There are some sanity check around length, but it is not compared with cptr (the remaining bytes). Here, the corrupted/bad EEPROM can cause panic.
I was able to reproduce the crash, but I cannot find the log and the reproducer now. After I applied the patch, the bug is no longer reproducible.
--- drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +2 -1
@@ -3345,7 +3345,8 @@ static int ar9300_eeprom_restore_internal(struct ath_hw *ah,"Found block at %x: code=%d ref=%d length=%d major=%d minor=%d\n" , cptr, code, reference, length, major, minor);if ((!AR_SREV_9485 (ah) && length >=1024 ) || - (AR_SREV_9485 (ah) && length >EEPROM_DATA_LEN_9485 )) { + (AR_SREV_9485 (ah) && length >EEPROM_DATA_LEN_9485 ) || + (length > cptr)) {ath_dbg (common,EEPROM ,"Skipping bad header\n" ); cptr -=COMP_HDR_LEN ;continue ;
Signature · 1 line
2.30.2
Sasha Levin
maintainerPATCH 35/35 net: fix NULL pointer reference in cipso_v4_doi_free
In reply to Sasha LevinFrom: 王贇 <[email protected]>
[ Upstream commit 733c99ee8be9a1410287cdbb943887365e83b2d6 ]
In netlbl_cipsov4_add_std() when 'doi_def->map.std' alloc failed, we sometime observe panic:
BUG: kernel NULL pointer dereference, address: ... RIP: 0010:cipso_v4_doi_free+0x3a/0x80 ... Call Trace: netlbl_cipsov4_add_std+0xf4/0x8c0 netlbl_cipsov4_add+0x13f/0x1b0 genl_family_rcv_msg_doit.isra.15+0x132/0x170 genl_rcv_msg+0x125/0x240
This is because in cipso_v4_doi_free() there is no check on 'doi_def->map.std' when 'doi_def->type' equal 1, which is possibe, since netlbl_cipsov4_add_std() haven't initialize it before alloc 'doi_def->map.std'.
This patch just add the check to prevent panic happen for similar cases.
--- net/netlabel/netlabel_cipso_v4.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netlabel/netlabel_cipso_v4.c +2 -2
@@ -163,8 +163,8 @@ static int netlbl_cipsov4_add_std(struct genl_info *info,return -ENOMEM ; doi_def->map.std =kzalloc (sizeof (*doi_def->map.std),GFP_KERNEL );if (doi_def->map.std ==NULL ) { - ret_val = -ENOMEM ; - goto add_std_failure; +kfree (doi_def); +return -ENOMEM ; } doi_def->type =CIPSO_V4_MAP_TRANS ;
Signature · 1 line
2.30.2