5.10.248-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 300/451 ASoC: qcom: q6adm: the the copp device only during last instance
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit 74cc4f3ea4e99262ba0d619c6a4ee33e2cd47f65 upstream.
A matching Common object post processing instance is normally resused across multiple streams. However currently we close this on DSP even though there is a refcount on this copp object, this can result in below error.
q6routing ab00000.remoteproc:glink-edge:apr:service@8:routing: Found Matching Copp 0x0 qcom-q6adm aprsvc:service:4:8: cmd = 0x10325 return error = 0x2 q6routing ab00000.remoteproc:glink-edge:apr:service@8:routing: DSP returned error[2] q6routing ab00000.remoteproc:glink-edge:apr:service@8:routing: Found Matching Copp 0x0 qcom-q6adm aprsvc:service:4:8: cmd = 0x10325 return error = 0x2 q6routing ab00000.remoteproc:glink-edge:apr:service@8:routing: DSP returned error[2] qcom-q6adm aprsvc:service:4:8: cmd = 0x10327 return error = 0x2 qcom-q6adm aprsvc:service:4:8: DSP returned error[2]
qcom-q6adm aprsvc:service:4:8: Failed to close copp -22
qcom-q6adm aprsvc:service:4:8: cmd = 0x10327 return error = 0x2 qcom-q6adm aprsvc:service:4:8: DSP returned error[2]
qcom-q6adm aprsvc:service:4:8: Failed to close copp -22
Fix this by addressing moving the adm_close to copp_kref destructor callback.
--- sound/soc/qcom/qdsp6/q6adm.c | 146 ++++++++++++++++++++----------------------- 1 file changed, 71 insertions(+), 75 deletions(-)
sound/soc/qcom/qdsp6/q6adm.c +71 -75
@@ -109,11 +109,75 @@ static struct q6copp *q6adm_find_copp(st } +static int q6adm_apr_send_copp_pkt (struct q6adm *adm,struct q6copp *copp, +struct apr_pkt *pkt,uint32_t rsp_opcode) +{ +struct device *dev = adm->dev; +uint32_t opcode = pkt->hdr.opcode; +int ret; + +mutex_lock (&adm->lock); + copp->result.opcode =0 ; + copp->result.status =0 ; + ret =apr_send_pkt (adm->apr, pkt); +if (ret <0 ) { +dev_err (dev,"Failed to send APR packet\n" ); + ret = -EINVAL ; + goto err; + } + +/* Wait for the callback with copp id */ +if (rsp_opcode) + ret =wait_event_timeout (copp->wait, + (copp->result.opcode == opcode) || + (copp->result.opcode == rsp_opcode), +msecs_to_jiffies (TIMEOUT_MS )); +else + ret =wait_event_timeout (copp->wait, + (copp->result.opcode == opcode), +msecs_to_jiffies (TIMEOUT_MS )); + +if (!ret) { +dev_err (dev,"ADM copp cmd timedout\n" ); + ret = -ETIMEDOUT ; + }else if (copp->result.status >0 ) { +dev_err (dev,"DSP returned error[%d]\n" , + copp->result.status); + ret = -EINVAL ; + } + +err: +mutex_unlock (&adm->lock); +return ret; +} + +static int q6adm_device_close (struct q6adm *adm,struct q6copp *copp, +int port_id,int copp_idx) +{ +struct apr_pkt close; + + close.hdr.hdr_field =APR_HDR_FIELD (APR_MSG_TYPE_SEQ_CMD , +APR_HDR_LEN (APR_HDR_SIZE ), +APR_PKT_VER ); + close.hdr.pkt_size =sizeof (close); + close.hdr.src_port = port_id; + close.hdr.dest_port = copp->id; + close.hdr.token = port_id <<16 | copp_idx; + close.hdr.opcode =ADM_CMD_DEVICE_CLOSE_V5 ; + +return q6adm_apr_send_copp_pkt (adm, copp, &close,0 ); +} +static void q6adm_free_copp (struct kref *ref) { struct q6copp *c = container_of(ref, struct q6copp, refcount);struct q6adm *adm = c->adm;unsigned long flags; +int ret; + + ret =q6adm_device_close (adm, c, c->afe_port, c->copp_idx); +if (ret <0 ) +dev_err (adm->dev,"Failed to close copp %d\n" , ret);spin_lock_irqsave (&adm->copps_list_lock, flags);clear_bit (c->copp_idx, &adm->copp_bitmap[c->afe_port]);
@@ -155,13 +219,13 @@ static int q6adm_callback(struct apr_devswitch (result->opcode) {case ADM_CMD_DEVICE_OPEN_V5 :case ADM_CMD_DEVICE_CLOSE_V5 : - copp =q6adm_find_copp (adm, port_idx, copp_idx); -if (!copp) -return 0 ; - - copp->result = *result; -wake_up (&copp->wait); -kref_put (&copp->refcount, q6adm_free_copp); +list_for_each_entry (copp, &adm->copps_list, node) { +if ((port_idx == copp->afe_port) && (copp_idx == copp->copp_idx)) { + copp->result = *result; +wake_up (&copp->wait); +break ; + } + }break ;case ADM_CMD_MATRIX_MAP_ROUTINGS_V5 : adm->result = *result;
@@ -234,65 +298,6 @@ static struct q6copp *q6adm_alloc_copp(sreturn c; } -static int q6adm_apr_send_copp_pkt (struct q6adm *adm,struct q6copp *copp, -struct apr_pkt *pkt,uint32_t rsp_opcode) -{ -struct device *dev = adm->dev; -uint32_t opcode = pkt->hdr.opcode; -int ret; - -mutex_lock (&adm->lock); - copp->result.opcode =0 ; - copp->result.status =0 ; - ret =apr_send_pkt (adm->apr, pkt); -if (ret <0 ) { -dev_err (dev,"Failed to send APR packet\n" ); - ret = -EINVAL ; - goto err; - } - -/* Wait for the callback with copp id */ -if (rsp_opcode) - ret =wait_event_timeout (copp->wait, - (copp->result.opcode == opcode) || - (copp->result.opcode == rsp_opcode), -msecs_to_jiffies (TIMEOUT_MS )); -else - ret =wait_event_timeout (copp->wait, - (copp->result.opcode == opcode), -msecs_to_jiffies (TIMEOUT_MS )); - -if (!ret) { -dev_err (dev,"ADM copp cmd timedout\n" ); - ret = -ETIMEDOUT ; - }else if (copp->result.status >0 ) { -dev_err (dev,"DSP returned error[%d]\n" , - copp->result.status); - ret = -EINVAL ; - } - -err: -mutex_unlock (&adm->lock); -return ret; -} - -static int q6adm_device_close (struct q6adm *adm,struct q6copp *copp, -int port_id,int copp_idx) -{ -struct apr_pkt close; - - close.hdr.hdr_field =APR_HDR_FIELD (APR_MSG_TYPE_SEQ_CMD , -APR_HDR_LEN (APR_HDR_SIZE ), -APR_PKT_VER ); - close.hdr.pkt_size =sizeof (close); - close.hdr.src_port = port_id; - close.hdr.dest_port = copp->id; - close.hdr.token = port_id <<16 | copp_idx; - close.hdr.opcode =ADM_CMD_DEVICE_CLOSE_V5 ; - -return q6adm_apr_send_copp_pkt (adm, copp, &close,0 ); -} - static struct q6copp *q6adm_find_matching_copp(struct q6adm *adm, int port_id, int topology, int mode, int rate,
@@ -567,15 +572,6 @@ EXPORT_SYMBOL_GPL(q6adm_matrix_map);*/ int q6adm_close (struct device *dev,struct q6copp *copp) { -struct q6adm *adm =dev_get_drvdata (dev->parent); -int ret =0 ; - - ret =q6adm_device_close (adm, copp, copp->afe_port, copp->copp_idx); -if (ret <0 ) { -dev_err (adm->dev,"Failed to close copp %d\n" , ret); -return ret; - } -kref_put (&copp->refcount, q6adm_free_copp);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 301/451 ASoC: qcom: qdsp6: q6asm-dai: set 10 ms period and buffer alignment.
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit 81c53b52de21b8d5a3de55ebd06b6bf188bf7efd upstream.
DSP expects the periods to be aligned to fragment sizes, currently setting up to hw constriants on periods bytes is not going to work correctly as we can endup with periods sizes aligned to 32 bytes however not aligned to fragment size.
Update the constriants to use fragment size, and also set at step of 10ms for period size to accommodate DSP requirements of 10ms latency.
--- sound/soc/qcom/qdsp6/q6asm-dai.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/qcom/qdsp6/q6asm-dai.c +2 -2
@@ -413,13 +413,13 @@ static int q6asm_dai_open(struct snd_soc } ret =snd_pcm_hw_constraint_step (runtime,0 , -SNDRV_PCM_HW_PARAM_PERIOD_BYTES ,32 ); +SNDRV_PCM_HW_PARAM_PERIOD_SIZE ,480 );if (ret <0 ) {dev_err (dev,"constraint for period bytes step ret = %d\n" , ret); } ret =snd_pcm_hw_constraint_step (runtime,0 , -SNDRV_PCM_HW_PARAM_BUFFER_BYTES ,32 ); +SNDRV_PCM_HW_PARAM_BUFFER_SIZE ,480 );if (ret <0 ) {dev_err (dev,"constraint for buffer bytes step ret = %d\n" , ret);
Greg Kroah-Hartman
maintainerPATCH 271/451 i40e: fix scheduling in set_rx_mode
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Przemyslaw Korba <[email protected]>
[ Upstream commit be43abc5514167cc129a8d8e9727b89b8e1d9719 ]
Add service task schedule to set_rx_mode.
In some cases there are error messages printed out in PTP application (ptp4l):
ptp4l[13848.762]: port 1 (ens2f3np3): received SYNC without timestamp ptp4l[13848.825]: port 1 (ens2f3np3): received SYNC without timestamp ptp4l[13848.887]: port 1 (ens2f3np3): received SYNC without timestamp
This happens when service task would not run immediately after set_rx_mode, and we need it for setup tasks. This service task checks, if PTP RX packets are hung in firmware, and propagate correct settings such as multicast address for IEEE 1588 Precision Time Protocol. RX timestamping depends on some of these filters set. Bug happens only with high PTP packets frequency incoming, and not every run since sometimes service task is being ran from a different place immediately after starting ptp4l.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/intel/i40e/i40e_main.c +1 -0
@@ -2101,6 +2101,7 @@ static void i40e_set_rx_mode(struct net_device *netdev) vsi->flags |=I40E_VSI_FLAG_FILTER_CHANGED ;set_bit (__I40E_MACVLAN_SYNC_PENDING, vsi->back->state); } +i40e_service_event_schedule (vsi->back); }/**
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 272/451 iavf: fix off-by-one issues in iavf_config_rss_reg()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kohei Enju <[email protected]>
[ Upstream commit 6daa2893f323981c7894c68440823326e93a7d61 ]
There are off-by-one bugs when configuring RSS hash key and lookup table, causing out-of-bounds reads to memory [1] and out-of-bounds writes to device registers.
Before commit 43a3d9ba34c9 ("i40evf: Allow PF driver to configure RSS"), the loop upper bounds were:
i <= I40E_VFQF_{HKEY,HLUT}_MAX_INDEXwhich is safe since the value is the last valid index.
That commit changed the bounds to:
i <= adapter->rss_{key,lut}_size / 4where rss_{key,lut}_size / 4 is the number of dwords, so the last valid index is (rss_{key,lut}_size / 4) - 1. Therefore, using <= accesses one element past the end.
Fix the issues by using < instead of <=, ensuring we do not exceed the bounds.
[1] KASAN splat about rss_key_size off-by-one
BUG: KASAN: slab-out-of-bounds in iavf_config_rss+0x619/0x800
Read of size 4 at addr ffff888102c50134 by task kworker/u8:6/63
CPU: 0 UID: 0 PID: 63 Comm: kworker/u8:6 Not tainted 6.18.0-rc2-enjuk-tnguy-00378-g3005f5b77652-dirty #156 PREEMPT(voluntary)
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Workqueue: iavf iavf_watchdog_task
Call Trace:
<TASK>
dump_stack_lvl+0x6f/0xb0
print_report+0x170/0x4f3
kasan_report+0xe1/0x1a0
iavf_config_rss+0x619/0x800
iavf_watchdog_task+0x2be7/0x3230
process_one_work+0x7fd/0x1420
worker_thread+0x4d1/0xd40
kthread+0x344/0x660
ret_from_fork+0x249/0x320
ret_from_fork_asm+0x1a/0x30
</TASK>
Allocated by task 63:
kasan_save_stack+0x30/0x50
kasan_save_track+0x14/0x30
__kasan_kmalloc+0x7f/0x90
__kmalloc_noprof+0x246/0x6f0
iavf_watchdog_task+0x28fc/0x3230
process_one_work+0x7fd/0x1420
worker_thread+0x4d1/0xd40
kthread+0x344/0x660
ret_from_fork+0x249/0x320
ret_from_fork_asm+0x1a/0x30
The buggy address belongs to the object at ffff888102c50100
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 0 bytes to the right of
allocated 52-byte region [ffff888102c50100, ffff888102c50134)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x102c50
flags: 0x200000000000000(node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000000 ffff8881000418c0 dead000000000122 0000000000000000
raw: 0000000000000000 0000000080200020 00000000f5000000 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888102c50000: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
ffff888102c50080: 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc fc
>ffff888102c50100: 00 00 00 00 00 00 04 fc fc fc fc fc fc fc fc fc
^
ffff888102c50180: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
ffff888102c50200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc--- drivers/net/ethernet/intel/iavf/iavf_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +2 -2
@@ -1262,11 +1262,11 @@ static int iavf_config_rss_reg(struct iavf_adapter *adapter)u16 i; dw = (u32 *)adapter->rss_key; -for (i =0 ; i <= adapter->rss_key_size /4 ; i++) +for (i =0 ; i < adapter->rss_key_size /4 ; i++)wr32 (hw,IAVF_VFQF_HKEY (i), dw[i]); dw = (u32 *)adapter->rss_lut; -for (i =0 ; i <= adapter->rss_lut_size /4 ; i++) +for (i =0 ; i < adapter->rss_lut_size /4 ; i++)wr32 (hw,IAVF_VFQF_HLUT (i), dw[i]);iavf_flush (hw);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 273/451 crypto: seqiv - Do not use req->iv after crypto_aead_encrypt
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 50fdb78b7c0bcc550910ef69c0984e751cac72fa ]
As soon as crypto_aead_encrypt is called, the underlying request may be freed by an asynchronous completion. Thus dereferencing req->iv after it returns is invalid.
Instead of checking req->iv against info, create a new variable unaligned_info and use it for that purpose instead.
--- crypto/seqiv.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
crypto/seqiv.c +5 -3
@@ -51,6 +51,7 @@ static int seqiv_aead_encrypt(struct aead_request *req)struct aead_geniv_ctx *ctx =crypto_aead_ctx (geniv);struct aead_request *subreq =aead_request_ctx (req);crypto_completion_t compl; +bool unaligned_info;void *data;u8 *info;unsigned int ivsize =8 ;
@@ -80,8 +81,9 @@ static int seqiv_aead_encrypt(struct aead_request *req)return err; } -if (unlikely (!IS_ALIGNED ((unsigned long )info, -crypto_aead_alignmask (geniv) +1 ))) { + unaligned_info = !IS_ALIGNED ((unsigned long )info, +crypto_aead_alignmask (geniv) +1 ); +if (unlikely (unaligned_info)) { info =kmemdup (req->iv, ivsize, req->base.flags &CRYPTO_TFM_REQ_MAY_SLEEP ?GFP_KERNEL :GFP_ATOMIC );
@@ -101,7 +103,7 @@ static int seqiv_aead_encrypt(struct aead_request *req)scatterwalk_map_and_copy (info, req->dst, req->assoclen, ivsize,1 ); err =crypto_aead_encrypt (subreq); -if (unlikely (info != req->iv)) +if (unlikely (unaligned_info))seqiv_aead_encrypt_complete2 (req, err);return err; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 274/451 net: mdio: aspeed: move reg accessing part into separate functions
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Potin Lai <[email protected]>
[ Upstream commit 737ca352569e744bf753b4522a6f91b120a734f1 ]
Add aspeed_mdio_op() and aseed_mdio_get_data() for register accessing.
aspeed_mdio_op() handles operations, write command to control register, then check and wait operations is finished (bit 31 is cleared).
aseed_mdio_get_data() fetchs the result value of operation from data register.
Stable-dep-of: d1a1a4bade4b ("net: mdio: aspeed: add dummy read to avoid read-after-write issue")
--- drivers/net/mdio/mdio-aspeed.c | 70 ++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 32 deletions(-)
drivers/net/mdio/mdio-aspeed.c +38 -32
@@ -39,34 +39,35 @@ struct aspeed_mdio {void __iomem *base; }; -static int aspeed_mdio_read (struct mii_bus *bus,int addr,int regnum) +static int aspeed_mdio_op (struct mii_bus *bus,u8 st,u8 op,u8 phyad,u8 regad, +u16 data) {struct aspeed_mdio *ctx = bus->priv;u32 ctrl; -u32 data; -int rc; -dev_dbg (&bus->dev,"%s: addr: %d, regnum: %d\n" , __func__, addr, - regnum); - -/* Just clause 22 for the moment */ -if (regnum &MII_ADDR_C45 ) -return -EOPNOTSUPP ; +dev_dbg (&bus->dev,"%s: st: %u op: %u, phyad: %u, regad: %u, data: %u\n" , + __func__, st, op, phyad, regad, data); ctrl =ASPEED_MDIO_CTRL_FIRE - |FIELD_PREP (ASPEED_MDIO_CTRL_ST ,ASPEED_MDIO_CTRL_ST_C22 ) - |FIELD_PREP (ASPEED_MDIO_CTRL_OP ,MDIO_C22_OP_READ ) - |FIELD_PREP (ASPEED_MDIO_CTRL_PHYAD , addr) - |FIELD_PREP (ASPEED_MDIO_CTRL_REGAD , regnum); + |FIELD_PREP (ASPEED_MDIO_CTRL_ST , st) + |FIELD_PREP (ASPEED_MDIO_CTRL_OP , op) + |FIELD_PREP (ASPEED_MDIO_CTRL_PHYAD , phyad) + |FIELD_PREP (ASPEED_MDIO_CTRL_REGAD , regad) + |FIELD_PREP (ASPEED_MDIO_DATA_MIIRDATA , data);iowrite32 (ctrl, ctx->base +ASPEED_MDIO_CTRL ); - rc =readl_poll_timeout (ctx->base +ASPEED_MDIO_CTRL , ctrl, +return readl_poll_timeout (ctx->base +ASPEED_MDIO_CTRL , ctrl, !(ctrl &ASPEED_MDIO_CTRL_FIRE ),ASPEED_MDIO_INTERVAL_US ,ASPEED_MDIO_TIMEOUT_US ); -if (rc <0 ) -return rc; +} + +static int aspeed_mdio_get_data (struct mii_bus *bus) +{ +struct aspeed_mdio *ctx = bus->priv; +int rc; +u32 data; rc = readl_poll_timeout(ctx->base + ASPEED_MDIO_DATA, data, data & ASPEED_MDIO_DATA_IDLE,
@@ -78,31 +79,36 @@ static int aspeed_mdio_read(struct mii_bus *bus, int addr, int regnum)return FIELD_GET (ASPEED_MDIO_DATA_MIIRDATA , data); } -static int aspeed_mdio_write (struct mii_bus *bus,int addr,int regnum,u16 val) +static int aspeed_mdio_read (struct mii_bus *bus,int addr,int regnum) { -struct aspeed_mdio *ctx = bus->priv; -u32 ctrl; +int rc; -dev_dbg (&bus->dev,"%s: addr: %d, regnum: %d, val: 0x%x\n" , - __func__, addr, regnum, val); +dev_dbg (&bus->dev,"%s: addr: %d, regnum: %d\n" , __func__, addr, + regnum);/* Just clause 22 for the moment */ if (regnum &MII_ADDR_C45 )return -EOPNOTSUPP ; - ctrl =ASPEED_MDIO_CTRL_FIRE - |FIELD_PREP (ASPEED_MDIO_CTRL_ST ,ASPEED_MDIO_CTRL_ST_C22 ) - |FIELD_PREP (ASPEED_MDIO_CTRL_OP ,MDIO_C22_OP_WRITE ) - |FIELD_PREP (ASPEED_MDIO_CTRL_PHYAD , addr) - |FIELD_PREP (ASPEED_MDIO_CTRL_REGAD , regnum) - |FIELD_PREP (ASPEED_MDIO_CTRL_MIIWDATA , val); + rc =aspeed_mdio_op (bus,ASPEED_MDIO_CTRL_ST_C22 ,MDIO_C22_OP_READ , + addr, regnum,0 ); +if (rc <0 ) +return rc; -iowrite32 (ctrl, ctx->base +ASPEED_MDIO_CTRL ); +return aspeed_mdio_get_data (bus); +} -return readl_poll_timeout (ctx->base +ASPEED_MDIO_CTRL , ctrl, - !(ctrl &ASPEED_MDIO_CTRL_FIRE ), -ASPEED_MDIO_INTERVAL_US , -ASPEED_MDIO_TIMEOUT_US ); +static int aspeed_mdio_write (struct mii_bus *bus,int addr,int regnum,u16 val) +{ +dev_dbg (&bus->dev,"%s: addr: %d, regnum: %d, val: 0x%x\n" , + __func__, addr, regnum, val); + +/* Just clause 22 for the moment */ +if (regnum &MII_ADDR_C45 ) +return -EOPNOTSUPP ; + +return aspeed_mdio_op (bus,ASPEED_MDIO_CTRL_ST_C22 ,MDIO_C22_OP_WRITE , + addr, regnum, val); }static int aspeed_mdio_probe (struct platform_device *pdev)
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 275/451 net: mdio: aspeed: add dummy read to avoid read-after-write issue
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacky Chou <[email protected]>
[ Upstream commit d1a1a4bade4b20c0858d0b2f81d2611de055f675 ]
The Aspeed MDIO controller may return incorrect data when a read operation follows immediately after a write. Due to a controller bug, the subsequent read can latch stale data, causing the polling logic to terminate earlier than expected.
To work around this hardware issue, insert a dummy read after each write operation. This ensures that the next actual read returns the correct data and prevents premature polling exit.
This workaround has been verified to stabilize MDIO transactions on affected Aspeed platforms.
--- drivers/net/mdio/mdio-aspeed.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/mdio/mdio-aspeed.c +7 -0
@@ -57,6 +57,13 @@ static int aspeed_mdio_op(struct mii_bus *bus, u8 st, u8 op, u8 phyad, u8 regad,iowrite32 (ctrl, ctx->base +ASPEED_MDIO_CTRL ); +/* Workaround for read-after-write issue. +* The controller may return stale data if a read follows immediately +* after a write. A dummy read forces the hardware to update its +* internal state, ensuring that the next real read returns correct data. +*/ +ioread32 (ctx->base +ASPEED_MDIO_CTRL ); + return readl_poll_timeout(ctx->base + ASPEED_MDIO_CTRL, ctrl, !(ctrl & ASPEED_MDIO_CTRL_FIRE), ASPEED_MDIO_INTERVAL_US,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 276/451 net: openvswitch: Avoid needlessly taking the RTNL on vport destroy
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Toke Høiland-Jørgensen <[email protected]>
[ Upstream commit 5498227676303e3ffa9a3a46214af96bc3e81314 ]
The openvswitch teardown code will immediately call ovs_netdev_detach_dev() in response to a NETDEV_UNREGISTER notification. It will then start the dp_notify_work workqueue, which will later end up calling the vport destroy() callback. This callback takes the RTNL to do another ovs_netdev_detach_port(), which in this case is unnecessary. This causes extra pressure on the RTNL, in some cases leading to "unregister_netdevice: waiting for XX to become free" warnings on teardown.
We can straight-forwardly avoid the extra RTNL lock acquisition by checking the device flags before taking the lock, and skip the locking altogether if the IFF_OVS_DATAPATH flag has already been unset.
--- net/openvswitch/vport-netdev.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
net/openvswitch/vport-netdev.c +13 -4
@@ -155,10 +155,19 @@ void ovs_netdev_detach_dev(struct vport *vport)static void netdev_destroy (struct vport *vport) { -rtnl_lock (); -if (netif_is_ovs_port (vport->dev)) -ovs_netdev_detach_dev (vport); -rtnl_unlock (); +/* When called from ovs_db_notify_wq() after a dp_device_event(), the +* port has already been detached, so we can avoid taking the RTNL by +* checking this first. +*/ +if (netif_is_ovs_port (vport->dev)) { +rtnl_lock (); +/* Check again while holding the lock to ensure we don't race +* with the netdev notifier and detach twice. +*/ +if (netif_is_ovs_port (vport->dev)) +ovs_netdev_detach_dev (vport); +rtnl_unlock (); + }call_rcu (&vport->rcu, vport_netdev_free); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 267/451 rpmsg: glink: fix rpmsg device leak
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Kandagatla <[email protected]>
commit a53e356df548f6b0e82529ef3cc6070f42622189 upstream.
While testing rpmsg-char interface it was noticed that duplicate sysfs entries are getting created and below warning is noticed.
Reason for this is that we are leaking rpmsg device pointer, setting it null without actually unregistering device.
Any further attempts to unregister fail because rpdev is NULL, resulting in a leak.
Fix this by unregistering rpmsg device before removing its reference from rpmsg channel.
sysfs: cannot create duplicate filename '/devices/platform/soc@0/3700000.remot eproc/remoteproc/remoteproc1/3700000.remoteproc:glink-edge/3700000.remoteproc:
glink-edge.adsp_apps.-1.-1'
[ 114.115347] CPU: 0 UID: 0 PID: 9 Comm: kworker/0:0 Not tainted 6.16.0-rc4 #7 PREEMPT [ 114.115355] Hardware name: Qualcomm Technologies, Inc. Robotics RB3gen2 (DT) [ 114.115358] Workqueue: events qcom_glink_work [ 114.115371] Call trace:8 [ 114.115374] show_stack+0x18/0x24 (C) [ 114.115382] dump_stack_lvl+0x60/0x80 [ 114.115388] dump_stack+0x18/0x24 [ 114.115393] sysfs_warn_dup+0x64/0x80 [ 114.115402] sysfs_create_dir_ns+0xf4/0x120 [ 114.115409] kobject_add_internal+0x98/0x260 [ 114.115416] kobject_add+0x9c/0x108 [ 114.115421] device_add+0xc4/0x7a0 [ 114.115429] rpmsg_register_device+0x5c/0xb0 [ 114.115434] qcom_glink_work+0x4bc/0x820 [ 114.115438] process_one_work+0x148/0x284 [ 114.115446] worker_thread+0x2c4/0x3e0 [ 114.115452] kthread+0x12c/0x204 [ 114.115457] ret_from_fork+0x10/0x20 [ 114.115464] kobject: kobject_add_internal failed for 3700000.remoteproc: glink-edge.adsp_apps.-1.-1 with -EEXIST, don't try to register things with the same name in the same directory. [ 114.250045] rpmsg 3700000.remoteproc:glink-edge.adsp_apps.-1.-1:
device_add failed: -17
--- drivers/rpmsg/qcom_glink_native.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/rpmsg/qcom_glink_native.c +8 -0
@@ -1244,6 +1244,7 @@ static void qcom_glink_destroy_ept(struc {struct glink_channel *channel =to_glink_channel (ept);struct qcom_glink *glink = channel->glink; +struct rpmsg_channel_info chinfo;unsigned long flags;spin_lock_irqsave (&channel->recv_lock, flags);
@@ -1251,6 +1252,13 @@ static void qcom_glink_destroy_ept(strucspin_unlock_irqrestore (&channel->recv_lock, flags);/* Decouple the potential rpdev from the channel */ +if (channel->rpdev) { +strscpy_pad (chinfo.name, channel->name,sizeof (chinfo.name)); + chinfo.src =RPMSG_ADDR_ANY ; + chinfo.dst =RPMSG_ADDR_ANY ; + +rpmsg_unregister_device (glink->dev, &chinfo); + } channel->rpdev =NULL ;qcom_glink_send_close_req (glink, channel);
Greg Kroah-Hartman
maintainerPATCH 303/451 iommu/ipmmu-vmsa: fix device leak on of_xlate()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 80aa518452c4aceb9459f9a8e3184db657d1b441 upstream.
Make sure to drop the reference taken to the iommu platform device when looking up its driver data during of_xlate().
--- drivers/iommu/ipmmu-vmsa.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iommu/ipmmu-vmsa.c +2 -0
@@ -732,6 +732,8 @@ static int ipmmu_init_platform_device(stdev_iommu_priv_set (dev,platform_get_drvdata (ipmmu_pdev)); +put_device (&ipmmu_pdev->dev); +return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 312/451 mfd: altera-sysmgr: Fix device leak on sysmgr regmap lookup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit ccb7cd3218e48665f3c7e19eede0da5f069c323d upstream.
Make sure to drop the reference taken to the sysmgr platform device when retrieving its driver data.
Note that holding a reference to a device does not prevent its driver data from going away.
--- drivers/mfd/altera-sysmgr.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mfd/altera-sysmgr.c +2 -0
@@ -118,6 +118,8 @@ struct regmap *altr_sysmgr_regmap_lookup sysmgr =dev_get_drvdata (dev); +put_device (dev); +return sysmgr->regmap; }EXPORT_SYMBOL_GPL (altr_sysmgr_regmap_lookup_by_phandle);
Greg Kroah-Hartman
maintainerPATCH 313/451 mfd: max77620: Fix potential IRQ chip conflict when probing two devices
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
commit 2bac49bad1f3553cc3b3bfb22cc194e9bd9e8427 upstream.
MAX77620 is most likely always a single device on the board, however nothing stops board designers to have two of them, thus same device driver could probe twice. Or user could manually try to probing second time.
Device driver is not ready for that case, because it allocates statically 'struct regmap_irq_chip' as non-const and stores during probe in 'irq_drv_data' member a pointer to per-probe state container ('struct max77620_chip'). devm_regmap_add_irq_chip() does not make a copy of 'struct regmap_irq_chip' but store the pointer.
Second probe - either successful or failure - would overwrite the 'irq_drv_data' from previous device probe, so interrupts would be executed in a wrong context.
--- drivers/mfd/max77620.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/mfd/max77620.c +11 -4
@@ -254,7 +254,7 @@ static int max77620_irq_global_unmask(voreturn ret; } -static struct regmap_irq_chip max77620_top_irq_chip = { +static const struct regmap_irq_chip max77620_top_irq_chip = { .name ="max77620-top" , .irqs = max77620_top_irqs, .num_irqs =ARRAY_SIZE (max77620_top_irqs),
@@ -499,6 +499,7 @@ static int max77620_probe(struct i2c_cli {const struct regmap_config *rmap_config;struct max77620_chip *chip; +struct regmap_irq_chip *chip_desc;const struct mfd_cell *mfd_cells;int n_mfd_cells;bool pm_off;
@@ -509,6 +510,14 @@ static int max77620_probe(struct i2c_clireturn -ENOMEM ;i2c_set_clientdata (client, chip); + + chip_desc =devm_kmemdup (&client->dev, &max77620_top_irq_chip, +sizeof (max77620_top_irq_chip), +GFP_KERNEL ); +if (!chip_desc) +return -ENOMEM ; + chip_desc->irq_drv_data = chip; + chip->dev = &client->dev; chip->chip_irq = client->irq; chip->chip_id = (enum max77620_chip_id )id->driver_data;
@@ -545,11 +554,9 @@ static int max77620_probe(struct i2c_cliif (ret <0 )return ret; - max77620_top_irq_chip.irq_drv_data = chip; ret =devm_regmap_add_irq_chip (chip->dev, chip->rmap, client->irq,IRQF_ONESHOT |IRQF_SHARED ,0 , - &max77620_top_irq_chip, - &chip->top_irq_data); + chip_desc, &chip->top_irq_data);if (ret <0 ) {dev_err (chip->dev,"Failed to add regmap irq: %d\n" , ret);return ret;
Greg Kroah-Hartman
maintainerPATCH 314/451 media: rc: st_rc: Fix reset control resource leak
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
commit 1240abf4b71f632f0117b056e22488e4d9808938 upstream.
The driver calls reset_control_get_optional_exclusive() but never calls reset_control_put() in error paths or in the remove function. This causes a resource leak when probe fails after successfully acquiring the reset control, or when the driver is unloaded.
Switch to devm_reset_control_get_optional_exclusive() to automatically manage the reset control resource.
--- drivers/media/rc/st_rc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/rc/st_rc.c +1 -1
@@ -279,7 +279,7 @@ static int st_rc_probe(struct platform_delse rc_dev->rx_base = rc_dev->base; - rc_dev->rstc =reset_control_get_optional_exclusive (dev,NULL ); + rc_dev->rstc =devm_reset_control_get_optional_exclusive (dev,NULL );if (IS_ERR (rc_dev->rstc)) { ret =PTR_ERR (rc_dev->rstc); goto err;
Greg Kroah-Hartman
maintainerPATCH 315/451 parisc: entry.S: fix space adjustment on interruption for 64-bit userspace
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Schnelle <[email protected]>
commit 1aa4524c0c1b54842c4c0a370171d11b12d0709b upstream.
In wide mode, the IASQ contain the upper part of the GVA during interruption. This needs to be reversed before the space is used - otherwise it contains parts of IAOQ. See Page 2-13 "Processing Resources / Interruption Instruction Address Queues" in the Parisc 2.0 Architecture Manual page 2-13 for an explanation.
The IAOQ/IASQ space_adjust was skipped for other interruptions than itlb misses. However, the code in handle_interruption() checks whether iasq[0] contains a valid space. Due to the not masked out bits this match failed and the process was killed.
Also add space_adjust for IAOQ1/IASQ1 so ptregs contains sane values.
--- arch/parisc/kernel/entry.S | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/parisc/kernel/entry.S +8 -3
@@ -1072,8 +1072,6 @@ ENTRY_CFI(intr_save) /* for os_hpmc */ STREG %r17, PT_IOR(%r29) #if defined(CONFIG_64BIT) - b,n intr_save2 - skip_save_ior: /* We have a itlb miss, and when executing code above 4 Gb on ILP64, we * need to adjust iasq/iaoq here in the same way we adjusted isr/ior
@@ -1082,10 +1080,17 @@ skip_save_ior: bb,COND(>=),n %r8,PSW_W_BIT,intr_save2 LDREG PT_IASQ0(%r29), %r16 LDREG PT_IAOQ0(%r29), %r17 - /* adjust iasq/iaoq */ + /* adjust iasq0/iaoq0 */ space_adjust %r16,%r17,%r1 STREG %r16, PT_IASQ0(%r29) STREG %r17, PT_IAOQ0(%r29) + + LDREG PT_IASQ1(%r29), %r16 + LDREG PT_IAOQ1(%r29), %r17 + /* adjust iasq1/iaoq1 */ + space_adjust %r16,%r17,%r1 + STREG %r16, PT_IASQ1(%r29) + STREG %r17, PT_IAOQ1(%r29) #else skip_save_ior: #endif
Greg Kroah-Hartman
maintainerPATCH 316/451 parisc: entry: set W bit for !compat tasks in syscall_restore_rfi()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Schnelle <[email protected]>
commit 5fb1d3ce3e74a4530042795e1e065422295f1371 upstream.
When the kernel leaves to userspace via syscall_restore_rfi(), the W bit is not set in the new PSW. This doesn't cause any problems because there's no 64 bit userspace for parisc. Simple static binaries are usually loaded at addresses way below the 32 bit limit so the W bit doesn't matter.
Fix this by setting the W bit when TIF_32BIT is not set.
--- arch/parisc/kernel/asm-offsets.c | 2 ++ arch/parisc/kernel/entry.S | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-)
arch/parisc/kernel/asm-offsets.c +2 -0
@@ -262,6 +262,8 @@ int main(void)BLANK ();DEFINE (TIF_BLOCKSTEP_PA_BIT ,31 -TIF_BLOCKSTEP );DEFINE (TIF_SINGLESTEP_PA_BIT ,31 -TIF_SINGLESTEP ); +DEFINE (TIF_32BIT_PA_BIT ,31 -TIF_32BIT ); +BLANK ();DEFINE (ASM_PMD_SHIFT ,PMD_SHIFT );DEFINE (ASM_PGDIR_SHIFT ,PGDIR_SHIFT );
arch/parisc/kernel/entry.S +4 -1
@@ -1913,6 +1913,10 @@ syscall_restore_rfi: extru,= %r19,TIF_BLOCKSTEP_PA_BIT,1,%r0 depi -1,7,1,%r20 /* T bit */ +#ifdef CONFIG_64BIT + extru,<> %r19,TIF_32BIT_PA_BIT,1,%r0 + depi -1,4,1,%r20 /* W bit */ +#endif STREG %r20,TASK_PT_PSW(%r1) /* Always store space registers, since sr3 can be changed (e.g. fork) */
@@ -1926,7 +1930,6 @@ syscall_restore_rfi: STREG %r25,TASK_PT_IASQ0(%r1) STREG %r25,TASK_PT_IASQ1(%r1) - /* XXX W bit??? */ /* Now if old D bit is clear, it means we didn't save all registers * on syscall entry, so do that now. This only happens on TRACEME * calls, or if someone attached to us while we were on a syscall.
Greg Kroah-Hartman
maintainerPATCH 317/451 media: adv7842: Avoid possible out-of-bounds array accesses in adv7842_cp_log_status()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Abramov <[email protected]>
commit 8163419e3e05d71dcfa8fb49c8fdf8d76908fe51 upstream.
It's possible for cp_read() and hdmi_read() to return -EIO. Those values are further used as indexes for accessing arrays.
Fix that by checking return values where it's needed.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/media/i2c/adv7842.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/media/i2c/adv7842.c +5 -2
@@ -2671,6 +2671,7 @@ static int adv7842_cp_log_status(struct/* CP block */ struct adv7842_state *state =to_state (sd);struct v4l2_dv_timings timings; +int temp;u8 reg_io_0x02 =io_read (sd,0x02 );u8 reg_io_0x21 =io_read (sd,0x21 );u8 reg_rep_0x77 =rep_read (sd,0x77 );
@@ -2793,8 +2794,9 @@ static int adv7842_cp_log_status(struct (((reg_io_0x02 >>2 ) &0x01 ) ^ (reg_io_0x02 &0x01 )) ?"(16-235)" :"(0-255)" , (reg_io_0x02 & 0x08) ? "enabled" : "disabled"); + temp =cp_read (sd,0xf4 ) >>4 ;v4l2_info (sd,"Color space conversion: %s\n" , - csc_coeff_sel_rb[cp_read (sd,0xf4 ) >>4 ]); + temp <0 ?"" : csc_coeff_sel_rb[temp]);if (!is_digital_input (sd))return 0 ;
@@ -2824,8 +2826,9 @@ static int adv7842_cp_log_status(struct hdmi_read(sd, 0x5f));v4l2_info (sd,"AV Mute: %s\n" , (hdmi_read (sd,0x04 ) &0x40 ) ?"on" :"off" ); + temp =hdmi_read (sd,0x0b ) >>6 ;v4l2_info (sd,"Deep color mode: %s\n" , - deep_color_mode_txt[hdmi_read (sd,0x0b ) >>6 ]); + temp <0 ?"" : deep_color_mode_txt[temp]);adv7842_log_infoframes (sd);
Greg Kroah-Hartman
maintainerPATCH 318/451 dm-ebs: Mark full buffer dirty even on partial write
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uladzislau Rezki (Sony) <[email protected]>
commit 7fa3e7d114abc9cc71cc35d768e116641074ddb4 upstream.
When performing a read-modify-write(RMW) operation, any modification to a buffered block must cause the entire buffer to be marked dirty.
Marking only a subrange as dirty is incorrect because the underlying device block size(ubs) defines the minimum read/write granularity. A lower device can perform I/O only on regions which are fully aligned and sized to ubs.
This change ensures that write-back operations always occur in full ubs-sized chunks, matching the intended emulation semantics of the EBS target.
As for user space visible impact, submitting sub-ubs and misaligned I/O for devices which are tuned to ubs sizes only, will reject such requests, therefore it can lead to losing data. Example:
1) Create a 8K nvme device in qemu by adding
-device nvme,drive=drv0,serial=foo,logical_block_size=8192,physical_block_size=8192
2) Setup dm-ebs to emulate 512B to 8K mapping
urezki@pc638:~/bin$ cat dmsetup.sh
lower=/dev/nvme0n1
len=$(blockdev --getsz "$lower")
echo "0 $len ebs $lower 0 1 16" | dmsetup create nvme-8k urezki@pc638:~/bin$
offset 0, ebs=1 and ubs=16(in sectors).
3) Create an ext4 filesystem(default 4K block size)
urezki@pc638:~/bin$ sudo mkfs.ext4 -F /dev/dm-0
mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done
Creating filesystem with 2072576 4k blocks and 518144 inodes
Filesystem UUID: bd0b6ca6-0506-4e31-86da-8d22c9d50b63
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: mkfs.ext4: Input/output error while writing out and closing file system
urezki@pc638:~/bin$ dmesg
<snip>
[ 1618.875449] buffer_io_error: 1028 callbacks suppressed [ 1618.875456] Buffer I/O error on dev dm-0, logical block 0, lost async page write [ 1618.875527] Buffer I/O error on dev dm-0, logical block 1, lost async page write [ 1618.875602] Buffer I/O error on dev dm-0, logical block 2, lost async page write [ 1618.875620] Buffer I/O error on dev dm-0, logical block 3, lost async page write [ 1618.875639] Buffer I/O error on dev dm-0, logical block 4, lost async page write [ 1618.894316] Buffer I/O error on dev dm-0, logical block 5, lost async page write [ 1618.894358] Buffer I/O error on dev dm-0, logical block 6, lost async page write [ 1618.894380] Buffer I/O error on dev dm-0, logical block 7, lost async page write [ 1618.894405] Buffer I/O error on dev dm-0, logical block 8, lost async page write [ 1618.894427] Buffer I/O error on dev dm-0, logical block 9, lost async page write
<snip>
Many I/O errors because the lower 8K device rejects sub-ubs/misaligned requests.
with a patch:
urezki@pc638:~/bin$ sudo mkfs.ext4 -F /dev/dm-0
mke2fs 1.47.0 (5-Feb-2023)
Discarding device blocks: done
Creating filesystem with 2072576 4k blocks and 518144 inodes
Filesystem UUID: 9b54f44f-ef55-4bd4-9e40-c8b775a616ac
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
urezki@pc638:~/bin$ sudo mount /dev/dm-0 /mnt/ urezki@pc638:~/bin$ ls -al /mnt/ total 24 drwxr-xr-x 3 root root 4096 Oct 17 15:13 . drwxr-xr-x 19 root root 4096 Jul 10 19:42 .. drwx------ 2 root root 16384 Oct 17 15:13 lost+found urezki@pc638:~/bin$
After this change: mkfs completes; mount succeeds.
--- drivers/md/dm-ebs-target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-ebs-target.c +1 -1
@@ -101,7 +101,7 @@ static int __ebs_rw_bvec(struct ebs_c *e }else {flush_dcache_page (bv->bv_page);memcpy (ba, pa, cur_len); -dm_bufio_mark_partial_buffer_dirty (b, buf_off, buf_off + cur_len); +dm_bufio_mark_buffer_dirty (b); }dm_bufio_release (b);
Greg Kroah-Hartman
maintainerPATCH 319/451 fbdev: gbefb: fix to use physical address instead of dma address
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rene Rebe <[email protected]>
commit e3f44742bbb10537fe53d83d20dea2a7c167674d upstream.
While debuggigng why X would not start on mips64 Sgi/O2 I found the phys adress being off. Turns out the gbefb passed the internal dma_addr as phys. May be broken pre git history. Fix by converting dma_to_phys.
--- drivers/video/fbdev/gbefb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/video/fbdev/gbefb.c +3 -2
@@ -12,6 +12,7 @@#include <linux/delay.h> #include <linux/platform_device.h> #include <linux/dma-mapping.h> +#include <linux/dma-direct.h> #include <linux/errno.h> #include <linux/gfp.h> #include <linux/fb.h>
@@ -65,7 +66,7 @@ struct gbefb_par {static unsigned int gbe_mem_size =CONFIG_FB_GBE_MEM *1024 *1024 ;static void *gbe_mem;static dma_addr_t gbe_dma_addr; -static unsigned long gbe_mem_phys; +static phys_addr_t gbe_mem_phys; static struct { uint16_t *cpu;
@@ -1189,7 +1190,7 @@ static int gbefb_probe(struct platform_d goto out_release_mem_region; } - gbe_mem_phys = (unsigned long ) gbe_dma_addr; + gbe_mem_phys =dma_to_phys (&p_dev->dev, gbe_dma_addr); } par = info->par;
Greg Kroah-Hartman
maintainerPATCH 320/451 fbdev: pxafb: Fix multiple clamped values in pxafb_adjust_timing
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
commit 0155e868cbc111846cc2809c1546ea53810a56ae upstream.
The variables were never clamped because the return value of clamp_val() was not used. Fix this by assigning the clamped values, and use clamp() instead of clamp_val().
--- drivers/video/fbdev/pxafb.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/video/fbdev/pxafb.c +6 -6
@@ -418,12 +418,12 @@ static int pxafb_adjust_timing(struct px var->yres =max_t (int, var->yres,MIN_YRES );if (!(fbi->lccr0 &LCCR0_LCDT )) { -clamp_val (var->hsync_len,1 ,64 ); -clamp_val (var->vsync_len,1 ,64 ); -clamp_val (var->left_margin,1 ,255 ); -clamp_val (var->right_margin,1 ,255 ); -clamp_val (var->upper_margin,1 ,255 ); -clamp_val (var->lower_margin,1 ,255 ); + var->hsync_len =clamp (var->hsync_len,1 ,64 ); + var->vsync_len =clamp (var->vsync_len,1 ,64 ); + var->left_margin =clamp (var->left_margin,1 ,255 ); + var->right_margin =clamp (var->right_margin,1 ,255 ); + var->upper_margin =clamp (var->upper_margin,1 ,255 ); + var->lower_margin =clamp (var->lower_margin,1 ,255 ); }/* make sure each line is aligned on word boundary */
Greg Kroah-Hartman
maintainerPATCH 321/451 fbdev: tcx.c fix mem_map to correct smem_start offset
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: René Rebe <[email protected]>
commit 35fa2b4bf96415b88d7edaa5cf8af5185d9ce76e upstream.
403ae52ac047 ("sparc: fix drivers/video/tcx.c warning") changed the physbase initializing breaking the user-space mmap, e.g. for Xorg entirely.
Fix fbdev mmap table so the sbus mmap helper work correctly, and not try to map vastly (physbase) offset memory.
--- drivers/video/fbdev/tcx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/video/fbdev/tcx.c +1 -1
@@ -436,7 +436,7 @@ static int tcx_probe(struct platform_dev j = i;break ; } - par->mmap_map[i].poff = op->resource[j].start; + par->mmap_map[i].poff = op->resource[j].start - info->fix.smem_start; } info->flags =FBINFO_DEFAULT ;
Greg Kroah-Hartman
maintainerPATCH 304/451 iommu/mediatek-v1: fix device leak on probe_device()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit c77ad28bfee0df9cbc719eb5adc9864462cfb65b upstream.
Make sure to drop the reference taken to the iommu platform device when looking up its driver data during probe_device().
--- drivers/iommu/mtk_iommu_v1.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iommu/mtk_iommu_v1.c +2 -0
@@ -393,6 +393,8 @@ static int mtk_iommu_create_mapping(strureturn -EINVAL ;dev_iommu_priv_set (dev,platform_get_drvdata (m4updev)); + +put_device (&m4updev->dev); } ret =iommu_fwspec_add_ids (dev, args->args,1 );
Greg Kroah-Hartman
maintainerPATCH 322/451 media: cec: Fix debugfs leak on bus_register() failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
commit c43bcd2b2aa3c2ca9d2433c3990ecbc2c47d10eb upstream.
In cec_devnode_init(), the debugfs directory created with debugfs_create_dir() is not removed if bus_register() fails. This leaves a stale "cec" entry in debugfs and prevents proper module reloading.
Fix this by removing the debugfs directory in the error path.
--- drivers/media/cec/core/cec-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/cec/core/cec-core.c +1 -0
@@ -433,6 +433,7 @@ static int __init cec_devnode_init(void) ret =bus_register (&cec_bus_type);if (ret <0 ) { +debugfs_remove_recursive (top_cec_dir);unregister_chrdev_region (cec_dev_t,CEC_NUM_DEVICES );pr_warn ("cec: bus_register failed\n" );return -EIO ;
Greg Kroah-Hartman
maintainerPATCH 323/451 media: msp3400: Avoid possible out-of-bounds array accesses in msp3400c_thread()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Abramov <[email protected]>
commit d2bceb2e20e783d57e739c71e4e50b4b9f4a3953 upstream.
It's possible for max1 to remain -1 if msp_read() always fail. This variable is further used as index for accessing arrays.
Fix that by checking max1 prior to array accesses.
It seems that restart is the preferable action in case of out-of-bounds value.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/media/i2c/msp3400-kthreads.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/i2c/msp3400-kthreads.c +2 -0
@@ -592,6 +592,8 @@ restart: "carrier2 val: %5d / %s\n", val, cd[i].name); } +if (max1 <0 || max1 >3 ) + goto restart;/* program the msp3400 according to the results */ state->main = msp3400c_carrier_detect_main[max1].cdo;switch (max1) {
Greg Kroah-Hartman
maintainerPATCH 324/451 media: TDA1997x: Remove redundant cancel_delayed_work in probe
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit 29de195ca39fc2ac0af6fd45522994df9f431f80 upstream.
The delayed_work delayed_work_enable_hpd is initialized with INIT_DELAYED_WORK(), but it is never scheduled in tda1997x_probe().
Calling cancel_delayed_work() on a work that has never been scheduled is redundant and unnecessary, as there is no pending work to cancel.
Remove the redundant cancel_delayed_work() from error handling path in tda1997x_probe() to avoid potential confusion.
--- drivers/media/i2c/tda1997x.c | 1 - 1 file changed, 1 deletion(-)
drivers/media/i2c/tda1997x.c +0 -1
@@ -2779,7 +2779,6 @@ err_free_media: err_free_handler:v4l2_ctrl_handler_free (&state->hdl); err_free_mutex: -cancel_delayed_work (&state->delayed_work_enable_hpd);mutex_destroy (&state->page_lock);mutex_destroy (&state->lock); err_free_state:
Greg Kroah-Hartman
maintainerPATCH 325/451 media: i2c: ADV7604: Remove redundant cancel_delayed_work in probe
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit 8f34f24355a607b98ecd9924837aab13c676eeca upstream.
The delayed_work delayed_work_enable_hotplug is initialized with INIT_DELAYED_WORK() in adv76xx_probe(), but it is never scheduled anywhere in the probe function.
Calling cancel_delayed_work() on a work that has never been scheduled is redundant and unnecessary, as there is no pending work to cancel.
Remove the redundant cancel_delayed_work() from error handling path and adjust the goto label accordingly to simplify the code and avoid potential confusion.
--- drivers/media/i2c/adv7604.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/i2c/adv7604.c +1 -3
@@ -3561,7 +3561,7 @@ static int adv76xx_probe(struct i2c_clie err =media_entity_pads_init (&sd->entity, state->source_pad +1 , state->pads);if (err) - goto err_work_queues; + goto err_i2c;/* Configure regmaps */ err =configure_regmaps (state);
@@ -3602,8 +3602,6 @@ static int adv76xx_probe(struct i2c_clie err_entity:media_entity_cleanup (&sd->entity); -err_work_queues: -cancel_delayed_work (&state->delayed_work_enable_hotplug); err_i2c:adv76xx_unregister_clients (state); err_hdl:
Greg Kroah-Hartman
maintainerPATCH 326/451 media: i2c: adv7842: Remove redundant cancel_delayed_work in probe
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit e66a5cc606c58e72f18f9cdd868a3672e918f9f8 upstream.
The delayed_work delayed_work_enable_hotplug is initialized with INIT_DELAYED_WORK() in adv7842_probe(), but it is never scheduled anywhere in the probe function.
Calling cancel_delayed_work() on a work that has never been scheduled is redundant and unnecessary, as there is no pending work to cancel.
Remove the redundant cancel_delayed_work() from error handling path and adjust the goto label accordingly to simplify the code and avoid potential confusion.
--- drivers/media/i2c/adv7842.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/i2c/adv7842.c +1 -3
@@ -3552,7 +3552,7 @@ static int adv7842_probe(struct i2c_clie state->pad.flags =MEDIA_PAD_FL_SOURCE ; err =media_entity_pads_init (&sd->entity,1 , &state->pad);if (err) - goto err_work_queues; + goto err_i2c; err =adv7842_core_init (sd);if (err)
@@ -3573,8 +3573,6 @@ static int adv7842_probe(struct i2c_clie err_entity:media_entity_cleanup (&sd->entity); -err_work_queues: -cancel_delayed_work (&state->delayed_work_enable_hotplug); err_i2c:adv7842_unregister_clients (sd); err_hdl:
Greg Kroah-Hartman
maintainerPATCH 327/451 idr: fix idr_alloc() returning an ID out of range
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
commit c6e8e595a0798ad67da0f7bebaf69c31ef70dfff upstream.
If you use an IDR with a non-zero base, and specify a range that lies entirely below the base, 'max - base' becomes very large and idr_get_free() can return an ID that lies outside of the requested range.
--- lib/idr.c | 2 ++ tools/testing/radix-tree/idr-test.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+)
lib/idr.c +2 -0
@@ -40,6 +40,8 @@ int idr_alloc_u32(struct idr *idr, voidif (WARN_ON_ONCE (!(idr->idr_rt.xa_flags &ROOT_IS_IDR ))) idr->idr_rt.xa_flags |=IDR_RT_MARKER ; +if (max < base) +return -ENOSPC ; id = (id < base) ?0 : id - base;radix_tree_iter_init (&iter, id);
tools/testing/radix-tree/idr-test.c +21 -0
@@ -57,6 +57,26 @@ void idr_alloc_test(void)idr_destroy (&idr); } +void idr_alloc2_test (void ) +{ +int id; +struct idr idr =IDR_INIT_BASE (idr,1 ); + + id =idr_alloc (&idr, idr_alloc2_test,0 ,1 ,GFP_KERNEL ); +assert (id == -ENOSPC ); + + id =idr_alloc (&idr, idr_alloc2_test,1 ,2 ,GFP_KERNEL ); +assert (id ==1 ); + + id =idr_alloc (&idr, idr_alloc2_test,0 ,1 ,GFP_KERNEL ); +assert (id == -ENOSPC ); + + id =idr_alloc (&idr, idr_alloc2_test,0 ,2 ,GFP_KERNEL ); +assert (id == -ENOSPC ); + +idr_destroy (&idr); +} +void idr_replace_test (void ) {DEFINE_IDR (idr);
@@ -400,6 +420,7 @@ void idr_checks(void)idr_replace_test ();idr_alloc_test (); +idr_alloc2_test ();idr_null_test ();idr_nowait_test ();idr_get_next_test (0 );
Greg Kroah-Hartman
maintainerPATCH 328/451 RDMA/core: Check for the presence of LS_NLA_TYPE_DGID correctly
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
commit a7b8e876e0ef0232b8076972c57ce9a7286b47ca upstream.
The netlink response for RDMA_NL_LS_OP_IP_RESOLVE should always have a LS_NLA_TYPE_DGID attribute, it is invalid if it does not.
Use the nl parsing logic properly and call nla_parse_deprecated() to fill the nlattrs array and then directly index that array to get the data for the DGID. Just fail if it is NULL.
Remove the for loop searching for the nla, and squash the validation and parsing into one function.
Fixes an uninitialized read from the stack triggered by userspace if it does not provide the DGID to a kernel initiated RDMA_NL_LS_OP_IP_RESOLVE query.
BUG: KMSAN: uninit-value in hex_byte_pack include/linux/hex.h:13 [inline]
BUG: KMSAN: uninit-value in ip6_string+0xef4/0x13a0 lib/vsprintf.c:1490
hex_byte_pack include/linux/hex.h:13 [inline]
ip6_string+0xef4/0x13a0 lib/vsprintf.c:1490
ip6_addr_string+0x18a/0x3e0 lib/vsprintf.c:1509
ip_addr_string+0x245/0xee0 lib/vsprintf.c:1633
pointer+0xc09/0x1bd0 lib/vsprintf.c:2542
vsnprintf+0xf8a/0x1bd0 lib/vsprintf.c:2930
vprintk_store+0x3ae/0x1530 kernel/printk/printk.c:2279
vprintk_emit+0x307/0xcd0 kernel/printk/printk.c:2426
vprintk_default+0x3f/0x50 kernel/printk/printk.c:2465
vprintk+0x36/0x50 kernel/printk/printk_safe.c:82
_printk+0x17e/0x1b0 kernel/printk/printk.c:2475
ib_nl_process_good_ip_rsep drivers/infiniband/core/addr.c:128 [inline]
ib_nl_handle_ip_res_resp+0x963/0x9d0 drivers/infiniband/core/addr.c:141
rdma_nl_rcv_msg drivers/infiniband/core/netlink.c:-1 [inline]
rdma_nl_rcv_skb drivers/infiniband/core/netlink.c:239 [inline]
rdma_nl_rcv+0xefa/0x11c0 drivers/infiniband/core/netlink.c:259
netlink_unicast_kernel net/netlink/af_netlink.c:1320 [inline]
netlink_unicast+0xf04/0x12b0 net/netlink/af_netlink.c:1346
netlink_sendmsg+0x10b3/0x1250 net/netlink/af_netlink.c:1896
sock_sendmsg_nosec net/socket.c:714 [inline]
__sock_sendmsg+0x333/0x3d0 net/socket.c:729
____sys_sendmsg+0x7e0/0xd80 net/socket.c:2617
___sys_sendmsg+0x271/0x3b0 net/socket.c:2671
__sys_sendmsg+0x1aa/0x300 net/socket.c:2703
__compat_sys_sendmsg net/compat.c:346 [inline]
__do_compat_sys_sendmsg net/compat.c:353 [inline]
__se_compat_sys_sendmsg net/compat.c:350 [inline]
__ia32_compat_sys_sendmsg+0xa4/0x100 net/compat.c:350
ia32_sys_call+0x3f6c/0x4310 arch/x86/include/generated/asm/syscalls_32.h:371
do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:83 [inline]
__do_fast_syscall_32+0xb0/0x150 arch/x86/entry/syscall_32.c:306
do_fast_syscall_32+0x38/0x80 arch/x86/entry/syscall_32.c:331
do_SYSENTER_32+0x1f/0x30 arch/x86/entry/syscall_32.c:3--- drivers/infiniband/core/addr.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-)
drivers/infiniband/core/addr.c +10 -23
@@ -81,37 +81,25 @@ static const struct nla_policy ib_nl_add .min = sizeof(struct rdma_nla_ls_gid)}, }; -static inline bool ib_nl_is_good_ip_resp (const struct nlmsghdr *nlh) +static void ib_nl_process_ip_rsep (const struct nlmsghdr *nlh) {struct nlattr *tb[LS_NLA_TYPE_MAX ] = {}; +union ib_gid gid; +struct addr_req *req; +int found =0 ;int ret;if (nlh->nlmsg_flags &RDMA_NL_LS_F_ERR ) -return false; +return ; ret =nla_parse_deprecated (tb,LS_NLA_TYPE_MAX -1 ,nlmsg_data (nlh),nlmsg_len (nlh), ib_nl_addr_policy,NULL );if (ret) -return false; - -return true; -} - -static void ib_nl_process_good_ip_rsep (const struct nlmsghdr *nlh) -{ -const struct nlattr *head, *curr; -union ib_gid gid; -struct addr_req *req; -int len, rem; -int found =0 ; - - head = (const struct nlattr *)nlmsg_data (nlh); - len =nlmsg_len (nlh); +return ; -nla_for_each_attr (curr, head, len, rem) { -if (curr->nla_type ==LS_NLA_TYPE_DGID ) -memcpy (&gid,nla_data (curr),nla_len (curr)); - } +if (!tb[LS_NLA_TYPE_DGID ]) +return ; +memcpy (&gid,nla_data (tb[LS_NLA_TYPE_DGID ]),sizeof (gid));spin_lock_bh (&lock);list_for_each_entry (req, &req_list, list) {
@@ -138,8 +126,7 @@ int ib_nl_handle_ip_res_resp(struct sk_b !(NETLINK_CB(skb).sk))return -EPERM ; -if (ib_nl_is_good_ip_resp (nlh)) -ib_nl_process_good_ip_rsep (nlh); +ib_nl_process_ip_rsep (nlh);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 329/451 RDMA/cm: Fix leaking the multicast GID table reference
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
commit 57f3cb6c84159d12ba343574df2115fb18dd83ca upstream.
If the CM ID is destroyed while the CM event for multicast creating is still queued the cancel_work_sync() will prevent the work from running which also prevents destroying the ah_attr. This leaks a refcount and triggers a WARN:
GID entry ref leak for dev syz1 index 2 ref=573
WARNING: CPU: 1 PID: 655 at drivers/infiniband/core/cache.c:809 release_gid_table drivers/infiniband/core/cache.c:806 [inline] WARNING: CPU: 1 PID: 655 at drivers/infiniband/core/cache.c:809 gid_table_release_one+0x284/0x3cc drivers/infiniband/core/cache.c:886
Destroy the ah_attr after canceling the work, it is safe to call this twice.
--- drivers/infiniband/core/cma.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/core/cma.c +3 -0
@@ -1840,6 +1840,7 @@ static void destroy_mc(struct rdma_id_prib_sa_free_multicast (mc->sa_mc);if (rdma_protocol_roce (id_priv->id.device, id_priv->id.port_num)) { +struct rdma_cm_event *event = &mc->iboe_join.event;struct rdma_dev_addr *dev_addr = &id_priv->id.route.addr.dev_addr;struct net_device *ndev =NULL ;
@@ -1862,6 +1863,8 @@ static void destroy_mc(struct rdma_id_prdev_put (ndev);cancel_work_sync (&mc->iboe_join.work); +if (event->event ==RDMA_CM_EVENT_MULTICAST_JOIN ) +rdma_destroy_ah_attr (&event->param.ud.ah_attr); }kfree (mc); }
Greg Kroah-Hartman
maintainerPATCH 330/451 e1000: fix OOB in e1000_tbi_should_accept()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
commit 9c72a5182ed92904d01057f208c390a303f00a0f upstream.
In e1000_tbi_should_accept() we read the last byte of the frame via 'data[length - 1]' to evaluate the TBI workaround. If the descriptor- reported length is zero or larger than the actual RX buffer size, this read goes out of bounds and can hit unrelated slab objects. The issue is observed from the NAPI receive path (e1000_clean_rx_irq):
==================================================================
BUG: KASAN: slab-out-of-bounds in e1000_tbi_should_accept+0x610/0x790 Read of size 1 at addr ffff888014114e54 by task sshd/363 CPU: 0 PID: 363 Comm: sshd Not tainted 5.18.0-rc1 #1 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014 Call Trace: <IRQ> dump_stack_lvl+0x5a/0x74 print_address_description+0x7b/0x440 print_report+0x101/0x200 kasan_report+0xc1/0xf0 e1000_tbi_should_accept+0x610/0x790 e1000_clean_rx_irq+0xa8c/0x1110 e1000_clean+0xde2/0x3c10 __napi_poll+0x98/0x380 net_rx_action+0x491/0xa20 __do_softirq+0x2c9/0x61d do_softirq+0xd1/0x120 </IRQ> <TASK> __local_bh_enable_ip+0xfe/0x130 ip_finish_output2+0x7d5/0xb00 __ip_queue_xmit+0xe24/0x1ab0 __tcp_transmit_skb+0x1bcb/0x3340 tcp_write_xmit+0x175d/0x6bd0 __tcp_push_pending_frames+0x7b/0x280 tcp_sendmsg_locked+0x2e4f/0x32d0 tcp_sendmsg+0x24/0x40 sock_write_iter+0x322/0x430 vfs_write+0x56c/0xa60 ksys_write+0xd1/0x190 do_syscall_64+0x43/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x7f511b476b10 Code: 73 01 c3 48 8b 0d 88 d3 2b 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d f9 2b 2c 00 00 75 10 b8 01 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 8e 9b 01 00 48 89 04 24 RSP: 002b:00007ffc9211d4e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 0000000000004024 RCX: 00007f511b476b10 RDX: 0000000000004024 RSI: 0000559a9385962c RDI: 0000000000000003 RBP: 0000559a9383a400 R08: fffffffffffffff0 R09: 0000000000004f00 R10: 0000000000000070 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffc9211d57f R14: 0000559a9347bde7 R15: 0000000000000003 </TASK> Allocated by task 1: __kasan_krealloc+0x131/0x1c0 krealloc+0x90/0xc0 add_sysfs_param+0xcb/0x8a0 kernel_add_sysfs_param+0x81/0xd4 param_sysfs_builtin+0x138/0x1a6 param_sysfs_init+0x57/0x5b do_one_initcall+0x104/0x250 do_initcall_level+0x102/0x132 do_initcalls+0x46/0x74 kernel_init_freeable+0x28f/0x393 kernel_init+0x14/0x1a0 ret_from_fork+0x22/0x30 The buggy address belongs to the object at ffff888014114000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 1620 bytes to the right of 2048-byte region [ffff888014114000, ffff888014114800] The buggy address belongs to the physical page: page:ffffea0000504400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x14110 head:ffffea0000504400 order:3 compound_mapcount:0 compound_pincount:0 flags: 0x100000000010200(slab|head|node=0|zone=1) raw: 0100000000010200 0000000000000000 dead000000000001 ffff888013442000 raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000 page dumped because: kasan: bad access detected ==================================================================
This happens because the TBI check unconditionally dereferences the last byte without validating the reported length first:
u8 last_byte = *(data + length - 1);
Fix by rejecting the frame early if the length is zero, or if it exceeds adapter->rx_buffer_len. This preserves the TBI workaround semantics for valid frames and prevents touching memory beyond the RX buffer.
--- drivers/net/ethernet/intel/e1000/e1000_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/e1000/e1000_main.c +9 -1
@@ -4090,7 +4090,15 @@ static bool e1000_tbi_should_accept(stru u32 length, const u8 *data) { struct e1000_hw *hw = &adapter->hw; -u8 last_byte = *(data + length -1 ); +u8 last_byte; + +/* Guard against OOB on data[length - 1] */ +if (unlikely (!length)) +return false; +/* Upper bound: length must not exceed rx_buffer_len */ +if (unlikely (length > adapter->rx_buffer_len)) +return false; + last_byte = *(data + length -1 );if (TBI_ACCEPT (hw, status, errors, length, last_byte)) {unsigned long irq_flags;
Greg Kroah-Hartman
maintainerPATCH 331/451 fjes: Add missing iounmap in fjes_hw_init()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit 15ef641a0c6728d25a400df73922e80ab2cf029c upstream.
In error paths, add fjes_hw_iounmap() to release the resource acquired by fjes_hw_iomap(). Add a goto label to do so.
--- drivers/net/fjes/fjes_hw.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/fjes/fjes_hw.c +9 -3
@@ -333,7 +333,7 @@ int fjes_hw_init(struct fjes_hw *hw) ret =fjes_hw_reset (hw);if (ret) -return ret; + goto err_iounmap;fjes_hw_set_irqmask (hw,REG_ICTL_MASK_ALL , true);
@@ -346,8 +346,10 @@ int fjes_hw_init(struct fjes_hw *hw) hw->max_epid =fjes_hw_get_max_epid (hw); hw->my_epid =fjes_hw_get_my_epid (hw); -if ((hw->max_epid ==0 ) || (hw->my_epid >= hw->max_epid)) -return -ENXIO ; +if ((hw->max_epid ==0 ) || (hw->my_epid >= hw->max_epid)) { + ret = -ENXIO ; + goto err_iounmap; + } ret =fjes_hw_setup (hw);
@@ -355,6 +357,10 @@ int fjes_hw_init(struct fjes_hw *hw) hw->hw_info.trace_size =FJES_DEBUG_BUFFER_SIZE ;return ret; + +err_iounmap: +fjes_hw_iounmap (hw); +return ret; }void fjes_hw_exit (struct fjes_hw *hw)
Greg Kroah-Hartman
maintainerPATCH 305/451 iommu/mediatek: fix device leak on of_xlate()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit b3f1ee18280363ef17f82b564fc379ceba9ec86f upstream.
Make sure to drop the reference taken to the iommu platform device when looking up its driver data during of_xlate().
--- drivers/iommu/mtk_iommu.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iommu/mtk_iommu.c +2 -0
@@ -526,6 +526,8 @@ static int mtk_iommu_of_xlate(struct devreturn -EINVAL ;dev_iommu_priv_set (dev,platform_get_drvdata (m4updev)); + +put_device (&m4updev->dev); }return iommu_fwspec_add_ids (dev, args->args,1 );
Greg Kroah-Hartman
maintainerPATCH 332/451 nfsd: Drop the client reference in client_states_open()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
commit 1f941b2c23fd34c6f3b76d36f9d0a2528fa92b8f upstream.
In error path, call drop_client() to drop the reference obtained by get_nfsdfs_clp().
--- fs/nfsd/nfs4state.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/nfsd/nfs4state.c +3 -1
@@ -2802,8 +2802,10 @@ static int client_states_open(struct inoreturn -ENXIO ; ret =seq_open (file, &states_seq_ops); -if (ret) +if (ret) { +drop_client (clp);return ret; + } s = file->private_data; s->private = clp;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 333/451 net: usb: sr9700: fix incorrect command used to write single register
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ethan Nelson-Moore <[email protected]>
commit fa0b198be1c6775bc7804731a43be5d899d19e7a upstream.
This fixes the device failing to initialize with "error reading MAC address" for me, probably because the incorrect write of NCR_RST to SR_NCR is not actually resetting the device.
--- drivers/net/usb/sr9700.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/usb/sr9700.c +2 -2
@@ -52,7 +52,7 @@ static int sr_read_reg(struct usbnet *destatic int sr_write_reg (struct usbnet *dev,u8 reg,u8 value) { -return usbnet_write_cmd (dev,SR_WR_REGS ,SR_REQ_WR_REG , +return usbnet_write_cmd (dev,SR_WR_REG ,SR_REQ_WR_REG , value, reg,NULL ,0 ); }
@@ -64,7 +64,7 @@ static void sr_write_async(struct usbnetstatic void sr_write_reg_async (struct usbnet *dev,u8 reg,u8 value) { -usbnet_write_cmd_async (dev,SR_WR_REGS ,SR_REQ_WR_REG , +usbnet_write_cmd_async (dev,SR_WR_REG ,SR_REQ_WR_REG , value, reg,NULL ,0 ); }
Greg Kroah-Hartman
maintainerPATCH 334/451 net: nfc: fix deadlock between nfc_unregister_device and rfkill_fop_write
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Deepanshu Kartikey <[email protected]>
commit 1ab526d97a57e44d26fadcc0e9adeb9c0c0182f5 upstream.
A deadlock can occur between nfc_unregister_device() and rfkill_fop_write() due to lock ordering inversion between device_lock and rfkill_global_mutex.
The problematic lock order is:
Thread A (rfkill_fop_write):
rfkill_fop_write()
mutex_lock(&rfkill_global_mutex)
rfkill_set_block()
nfc_rfkill_set_block()
nfc_dev_down()
device_lock(&dev->dev) <- waits for device_lockThread B (nfc_unregister_device):
nfc_unregister_device()
device_lock(&dev->dev)
rfkill_unregister()
mutex_lock(&rfkill_global_mutex) <- waits for rfkill_global_mutex
This creates a classic ABBA deadlock scenario.
Fix this by moving rfkill_unregister() and rfkill_destroy() outside the device_lock critical section. Store the rfkill pointer in a local variable before releasing the lock, then call rfkill_unregister() after releasing device_lock.
This change is safe because rfkill_fop_write() holds rfkill_global_mutex while calling the rfkill callbacks, and rfkill_unregister() also acquires rfkill_global_mutex before cleanup. Therefore, rfkill_unregister() will wait for any ongoing callback to complete before proceeding, and device_del() is only called after rfkill_unregister() returns, preventing any use-after-free.
The similar lock ordering in nfc_register_device() (device_lock -> rfkill_global_mutex via rfkill_register) is safe because during registration the device is not yet in rfkill_list, so no concurrent rfkill operations can occur on this device.
--- net/nfc/core.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/nfc/core.c +7 -2
@@ -1146,6 +1146,7 @@ EXPORT_SYMBOL(nfc_register_device);void nfc_unregister_device (struct nfc_dev *dev) {int rc; +struct rfkill *rfk =NULL ;pr_debug ("dev_name=%s\n" ,dev_name (&dev->dev));
@@ -1156,13 +1157,17 @@ void nfc_unregister_device(struct nfc_dedevice_lock (&dev->dev);if (dev->rfkill) { -rfkill_unregister (dev->rfkill); -rfkill_destroy (dev->rfkill); + rfk = dev->rfkill; dev->rfkill =NULL ; } dev->shutting_down = true;device_unlock (&dev->dev); +if (rfk) { +rfkill_unregister (rfk); +rfkill_destroy (rfk); + } +if (dev->ops->check_presence) {del_timer_sync (&dev->check_pres_timer);cancel_work_sync (&dev->check_pres_work);
Greg Kroah-Hartman
maintainerPATCH 335/451 net: macb: Relocate mog_init_rings() callback from macb_mac_link_up() to macb_open()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiaolei Wang <[email protected]>
commit 99537d5c476cada9cf75aef9fa75579a31faadb9 upstream.
In the non-RT kernel, local_bh_disable() merely disables preemption, whereas it maps to an actual spin lock in the RT kernel. Consequently, when attempting to refill RX buffers via netdev_alloc_skb() in macb_mac_link_up(), a deadlock scenario arises as follows:
WARNING: possible circular locking dependency detected 6.18.0-08691-g2061f18ad76e #39 Not tainted
------------------------------------------------------
kworker/0:0/8 is trying to acquire lock:
ffff00080369bbe0 (&bp->lock){+.+.}-{3:3}, at: macb_start_xmit+0x808/0xb7c
but task is already holding lock:
ffff000803698e58 (&queue->tx_ptr_lock){+...}-{3:3}, at: macb_start_xmit +0x148/0xb7c
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #3 (&queue->tx_ptr_lock){+...}-{3:3}:
rt_spin_lock+0x50/0x1f0
macb_start_xmit+0x148/0xb7c
dev_hard_start_xmit+0x94/0x284
sch_direct_xmit+0x8c/0x37c
__dev_queue_xmit+0x708/0x1120
neigh_resolve_output+0x148/0x28c
ip6_finish_output2+0x2c0/0xb2c
__ip6_finish_output+0x114/0x308
ip6_output+0xc4/0x4a4
mld_sendpack+0x220/0x68c
mld_ifc_work+0x2a8/0x4f4
process_one_work+0x20c/0x5f8
worker_thread+0x1b0/0x35c
kthread+0x144/0x200
ret_from_fork+0x10/0x20-> #2 (_xmit_ETHER#2){+...}-{3:3}:
rt_spin_lock+0x50/0x1f0
sch_direct_xmit+0x11c/0x37c
__dev_queue_xmit+0x708/0x1120
neigh_resolve_output+0x148/0x28c
ip6_finish_output2+0x2c0/0xb2c
__ip6_finish_output+0x114/0x308
ip6_output+0xc4/0x4a4
mld_sendpack+0x220/0x68c
mld_ifc_work+0x2a8/0x4f4
process_one_work+0x20c/0x5f8
worker_thread+0x1b0/0x35c
kthread+0x144/0x200
ret_from_fork+0x10/0x20-> #1 ((softirq_ctrl.lock)){+.+.}-{3:3}:
lock_release+0x250/0x348
__local_bh_enable_ip+0x7c/0x240
__netdev_alloc_skb+0x1b4/0x1d8
gem_rx_refill+0xdc/0x240
gem_init_rings+0xb4/0x108
macb_mac_link_up+0x9c/0x2b4
phylink_resolve+0x170/0x614
process_one_work+0x20c/0x5f8
worker_thread+0x1b0/0x35c
kthread+0x144/0x200
ret_from_fork+0x10/0x20-> #0 (&bp->lock){+.+.}-{3:3}:
__lock_acquire+0x15a8/0x2084
lock_acquire+0x1cc/0x350
rt_spin_lock+0x50/0x1f0
macb_start_xmit+0x808/0xb7c
dev_hard_start_xmit+0x94/0x284
sch_direct_xmit+0x8c/0x37c
__dev_queue_xmit+0x708/0x1120
neigh_resolve_output+0x148/0x28c
ip6_finish_output2+0x2c0/0xb2c
__ip6_finish_output+0x114/0x308
ip6_output+0xc4/0x4a4
mld_sendpack+0x220/0x68c
mld_ifc_work+0x2a8/0x4f4
process_one_work+0x20c/0x5f8
worker_thread+0x1b0/0x35c
kthread+0x144/0x200
ret_from_fork+0x10/0x20other info that might help us debug this:
Chain exists of:
&bp->lock --> _xmit_ETHER#2 --> &queue->tx_ptr_lock
Possible unsafe locking scenario: CPU0 CPU1
---- ----
lock(&queue->tx_ptr_lock);
lock(_xmit_ETHER#2);
lock(&queue->tx_ptr_lock);
lock(&bp->lock);
*** DEADLOCK *** Call trace:
show_stack+0x18/0x24 (C)
dump_stack_lvl+0xa0/0xf0
dump_stack+0x18/0x24
print_circular_bug+0x28c/0x370
check_noncircular+0x198/0x1ac
__lock_acquire+0x15a8/0x2084
lock_acquire+0x1cc/0x350
rt_spin_lock+0x50/0x1f0
macb_start_xmit+0x808/0xb7c
dev_hard_start_xmit+0x94/0x284
sch_direct_xmit+0x8c/0x37c
__dev_queue_xmit+0x708/0x1120
neigh_resolve_output+0x148/0x28c
ip6_finish_output2+0x2c0/0xb2c
__ip6_finish_output+0x114/0x308
ip6_output+0xc4/0x4a4
mld_sendpack+0x220/0x68c
mld_ifc_work+0x2a8/0x4f4
process_one_work+0x20c/0x5f8
worker_thread+0x1b0/0x35c
kthread+0x144/0x200
ret_from_fork+0x10/0x20Notably, invoking the mog_init_rings() callback upon link establishment is unnecessary. Instead, we can exclusively call mog_init_rings() within the ndo_open() callback. This adjustment resolves the deadlock issue. Furthermore, since MACB_CAPS_MACB_IS_EMAC cases do not use mog_init_rings() when opening the network interface via at91ether_open(), moving mog_init_rings() to macb_open() also eliminates the MACB_CAPS_MACB_IS_EMAC check.
--- drivers/net/ethernet/cadence/macb_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/cadence/macb_main.c +2 -1
@@ -654,7 +654,6 @@ static void macb_mac_link_up(struct phyl/* Initialize rings & buffers as clearing MACB_BIT(TE) in link down * cleared the pipeline and control registers. */ - bp->macbgem_ops.mog_init_rings (bp);macb_init_buffers (bp);for (q =0 , queue = bp->queues; q < bp->num_queues; ++q, ++queue)
@@ -2287,6 +2286,8 @@ static void gem_init_rings(struct macb *unsigned int q;int i; + bp->macbgem_ops.mog_init_rings (bp); +for (q =0 , queue = bp->queues; q < bp->num_queues; ++q, ++queue) {for (i =0 ; i < bp->tx_ring_size; i++) { desc =macb_tx_desc (queue, i);
Greg Kroah-Hartman
maintainerPATCH 336/451 drm/msm/a6xx: Fix out of bound IO access in a6xx_get_gmu_registers
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Akhil P Oommen <[email protected]>
commit 779b68a5bf2764c8ed3aa800e41ba0d5d007e1e7 upstream.
REG_A6XX_GMU_AO_AHB_FENCE_CTRL register falls under GMU's register range. So, use gmu_write() routines to write to this register.
Patchwork: https://patchwork.freedesktop.org/patch/688993/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c +1 -1
@@ -794,7 +794,7 @@ static void a6xx_get_gmu_registers(strucreturn ;/* Set the fence to ALLOW mode so we can access the registers */ -gpu_write (gpu,REG_A6XX_GMU_AO_AHB_FENCE_CTRL ,0 ); +gmu_write (&a6xx_gpu->gmu,REG_A6XX_GMU_AO_AHB_FENCE_CTRL ,0 );_a6xx_get_gmu_registers (gpu, a6xx_state, &a6xx_gmu_reglist[2 ], &a6xx_state->gmu_registers[2 ], false);
Greg Kroah-Hartman
maintainerPATCH 337/451 drm/nouveau/dispnv50: Dont call drm_atomic_get_crtc_state() in prepare_fb
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lyude Paul <[email protected]>
commit 560271e10b2c86e95ea35afa9e79822e4847f07a upstream.
Since we recently started warning about uses of this function after the atomic check phase completes, we've started getting warnings about this in nouveau. It appears a misplaced drm_atomic_get_crtc_state() call has been hiding in our .prepare_fb callback for a while.
So, fix this by adding a new nv50_head_atom_get_new() function and use that in our .prepare_fb callback instead.
--- drivers/gpu/drm/nouveau/dispnv50/atom.h | 13 +++++++++++++ drivers/gpu/drm/nouveau/dispnv50/wndw.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/drm/nouveau/dispnv50/atom.h +13 -0
@@ -152,8 +152,21 @@ static inline struct nv50_head_atom * nv50_head_atom_get(struct drm_atomic_state *state, struct drm_crtc *crtc) { struct drm_crtc_state *statec = drm_atomic_get_crtc_state(state, crtc); +if (IS_ERR (statec))return (void *)statec; + +return nv50_head_atom (statec); +} + +static inline struct nv50_head_atom * +nv50_head_atom_get_new (struct drm_atomic_state *state,struct drm_crtc *crtc) +{ +struct drm_crtc_state *statec =drm_atomic_get_new_crtc_state (state, crtc); + +if (!statec) +return NULL ; +return nv50_head_atom (statec); }
drivers/gpu/drm/nouveau/dispnv50/wndw.c +1 -1
@@ -561,7 +561,7 @@ nv50_wndw_prepare_fb(struct drm_plane *p asyw->image.offset[0 ] = nvbo->offset;if (wndw->func->prepare) { - asyh =nv50_head_atom_get (asyw->state.state, asyw->state.crtc); + asyh =nv50_head_atom_get_new (asyw->state.state, asyw->state.crtc);if (IS_ERR (asyh))return PTR_ERR (asyh);
Greg Kroah-Hartman
maintainerPATCH 306/451 iommu/omap: fix device leaks on probe_device()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit b5870691065e6bbe6ba0650c0412636c6a239c5a upstream.
Make sure to drop the references taken to the iommu platform devices when looking up their driver data during probe_device().
Note that the arch data device pointer added by commit 604629bcb505 ("iommu/omap: add support for late attachment of iommu devices") has never been used. Remove it to underline that the references are not needed.
--- drivers/iommu/omap-iommu.c | 2 +- drivers/iommu/omap-iommu.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/iommu/omap-iommu.c +1 -1
@@ -1686,6 +1686,7 @@ static struct iommu_device *omap_iommu_p } oiommu =platform_get_drvdata (pdev); +put_device (&pdev->dev);if (!oiommu) {of_node_put (np);kfree (arch_data);
@@ -1693,7 +1694,6 @@ static struct iommu_device *omap_iommu_p } tmp->iommu_dev = oiommu; - tmp->dev = &pdev->dev;of_node_put (np); }
drivers/iommu/omap-iommu.h +0 -2
@@ -88,7 +88,6 @@ struct omap_iommu {/** * struct omap_iommu_arch_data - omap iommu private data * @iommu_dev: handle of the OMAP iommu device -* @dev: handle of the iommu device * * This is an omap iommu private data object, which binds an iommu user * to its iommu device. This object should be placed at the iommu user's
@@ -97,7 +96,6 @@ struct omap_iommu {*/ struct omap_iommu_arch_data {struct omap_iommu *iommu_dev; -struct device *dev; };struct cr_regs {
Greg Kroah-Hartman
maintainerPATCH 307/451 iommu/sun50i: fix device leak on of_xlate()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit f916109bf53864605d10bf6f4215afa023a80406 upstream.
Make sure to drop the reference taken to the iommu platform device when looking up its driver data during of_xlate().
--- drivers/iommu/sun50i-iommu.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iommu/sun50i-iommu.c +2 -0
@@ -767,6 +767,8 @@ static int sun50i_iommu_of_xlate(structdev_iommu_priv_set (dev,platform_get_drvdata (iommu_pdev)); +put_device (&iommu_pdev->dev); +return iommu_fwspec_add_ids (dev, &id,1 ); }
Greg Kroah-Hartman
maintainerPATCH 308/451 HID: logitech-dj: Remove duplicate error logging
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit ca389a55d8b2d86a817433bf82e0602b68c4d541 upstream.
logi_dj_recv_query_paired_devices() and logi_dj_recv_switch_to_dj_mode() both have 2 callers which all log an error if the function fails. Move the error logging to inside these 2 functions to remove the duplicated error logging in the callers.
While at it also move the logi_dj_recv_send_report() call error handling in logi_dj_recv_switch_to_dj_mode() to directly after the call. That call only fails if the report cannot be found and in that case it does nothing, so the msleep() is not necessary on failures.
--- drivers/hid/hid-logitech-dj.c | 56 +++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 33 deletions(-)
drivers/hid/hid-logitech-dj.c +23 -33
@@ -755,7 +755,6 @@ static void delayedwork_callback(structstruct dj_workitem workitem;unsigned long flags;int count; -int retval;dbg_hid ("%s\n" , __func__);
@@ -792,11 +791,7 @@ static void delayedwork_callback(structlogi_dj_recv_destroy_djhid_device (djrcv_dev, &workitem);break ;case WORKITEM_TYPE_UNKNOWN : - retval =logi_dj_recv_query_paired_devices (djrcv_dev); -if (retval) { -hid_err (djrcv_dev->hidpp,"%s: logi_dj_recv_query_paired_devices error: %d\n" , - __func__, retval); - } +logi_dj_recv_query_paired_devices (djrcv_dev);break ;case WORKITEM_TYPE_EMPTY :dbg_hid ("%s: device list is empty\n" , __func__);
@@ -1173,8 +1168,10 @@ static int logi_dj_recv_query_paired_dev djrcv_dev->last_query = jiffies; -if (djrcv_dev->type != recvr_type_dj) -return logi_dj_recv_query_hidpp_devices (djrcv_dev); +if (djrcv_dev->type != recvr_type_dj) { + retval =logi_dj_recv_query_hidpp_devices (djrcv_dev); + goto out; + } dj_report =kzalloc (sizeof (struct dj_report ),GFP_KERNEL );if (!dj_report)
@@ -1184,6 +1181,10 @@ static int logi_dj_recv_query_paired_dev dj_report->report_type =REPORT_TYPE_CMD_GET_PAIRED_DEVICES ; retval =logi_dj_recv_send_report (djrcv_dev, dj_report);kfree (dj_report); +out: +if (retval <0 ) +hid_err (djrcv_dev->hidpp,"%s error:%d\n" , __func__, retval); +return retval; }
@@ -1209,6 +1210,8 @@ static int logi_dj_recv_switch_to_dj_mod (u8 )timeout; retval =logi_dj_recv_send_report (djrcv_dev, dj_report); +if (retval) + goto out;/* * Ugly sleep to work around a USB 3.0 bug when the receiver is
@@ -1217,11 +1220,6 @@ static int logi_dj_recv_switch_to_dj_mod* 50 msec should gives enough time to the receiver to be ready. */ msleep (50 ); - -if (retval) { -kfree (dj_report); -return retval; - } }/*
@@ -1247,7 +1245,12 @@ static int logi_dj_recv_switch_to_dj_modHIDPP_REPORT_SHORT_LENGTH ,HID_OUTPUT_REPORT , HID_REQ_SET_REPORT); +out:kfree (dj_report); + +if (retval <0 ) +hid_err (hdev,"%s error:%d\n" , __func__, retval); +return retval; }
@@ -1753,11 +1756,8 @@ static int logi_dj_probe(struct hid_deviif (has_hidpp) { retval =logi_dj_recv_switch_to_dj_mode (djrcv_dev,0 ); -if (retval <0 ) { -hid_err (hdev,"%s: logi_dj_recv_switch_to_dj_mode returned error:%d\n" , - __func__, retval); +if (retval <0 ) goto switch_to_dj_mode_fail; - } }/* This is enabling the polling urb on the IN endpoint */
@@ -1775,15 +1775,11 @@ static int logi_dj_probe(struct hid_devispin_lock_irqsave (&djrcv_dev->lock, flags); djrcv_dev->ready = true;spin_unlock_irqrestore (&djrcv_dev->lock, flags); - retval =logi_dj_recv_query_paired_devices (djrcv_dev); -if (retval <0 ) { -hid_err (hdev,"%s: logi_dj_recv_query_paired_devices error:%d\n" , - __func__, retval); -/* -* This can happen with a KVM, let the probe succeed, -* logi_dj_recv_queue_unknown_work will retry later. -*/ - } +/* +* This can fail with a KVM. Ignore errors to let the probe +* succeed, logi_dj_recv_queue_unknown_work will retry later. +*/ +logi_dj_recv_query_paired_devices (djrcv_dev); }return 0 ;
@@ -1800,18 +1796,12 @@ hid_hw_start_fail:#ifdef CONFIG_PM static int logi_dj_reset_resume (struct hid_device *hdev) { -int retval;struct dj_receiver_dev *djrcv_dev =hid_get_drvdata (hdev);if (!djrcv_dev || djrcv_dev->hidpp != hdev)return 0 ; - retval =logi_dj_recv_switch_to_dj_mode (djrcv_dev,0 ); -if (retval <0 ) { -hid_err (hdev,"%s: logi_dj_recv_switch_to_dj_mode returned error:%d\n" , - __func__, retval); - } - +logi_dj_recv_switch_to_dj_mode (djrcv_dev,0 );return 0 ; }#endif
Greg Kroah-Hartman
maintainerPATCH 309/451 PCI/PM: Reinstate clearing state_saved in legacy and !PM codepaths
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lukas Wunner <[email protected]>
commit 894f475f88e06c0f352c829849560790dbdedbe5 upstream.
When a PCI device is suspended, it is normally the PCI core's job to save Config Space and put the device into a low power state. However drivers are allowed to assume these responsibilities. When they do, the PCI core can tell by looking at the state_saved flag in struct pci_dev: The flag is cleared before commencing the suspend sequence and it is set when pci_save_state() is called. If the PCI core finds the flag set late in the suspend sequence, it refrains from calling pci_save_state() itself.
But there are two corner cases where the PCI core neglects to clear the flag before commencing the suspend sequence:
* If a driver has legacy PCI PM callbacks, pci_legacy_suspend() neglects to clear the flag. The (stale) flag is subsequently queried by pci_legacy_suspend() itself and pci_legacy_suspend_late().
* If a device has no driver or its driver has no PCI PM callbacks, pci_pm_freeze() neglects to clear the flag. The (stale) flag is subsequently queried by pci_pm_freeze_noirq().
The flag may be set prior to suspend if the device went through error
recovery: Drivers commonly invoke pci_restore_state() + pci_save_state() to restore Config Space after reset.
The flag may also be set if drivers call pci_save_state() on probe to allow for recovery from subsequent errors.
The result is that pci_legacy_suspend_late() and pci_pm_freeze_noirq() don't call pci_save_state() and so the state that will be restored on resume is the one recorded on last error recovery or on probe, not the one that the device had on suspend. If the two states happen to be identical, there's no problem.
Reinstate clearing the flag in pci_legacy_suspend() and pci_pm_freeze(). The two functions used to do that until commit 4b77b0a2ba27 ("PCI: Clear saved_state after the state has been restored") deemed it unnecessary because it assumed that it's sufficient to clear the flag on resume in pci_restore_state(). The commit seemingly did not take into account that pci_save_state() and pci_restore_state() are not only used by power management code, but also for error recovery.
Devices without driver or whose driver has no PCI PM callbacks may be in runtime suspend when pci_pm_freeze() is called. Their state has already been saved, so don't clear the flag to skip a pointless pci_save_state() in pci_pm_freeze_noirq().
None of the drivers with legacy PCI PM callbacks seem to use runtime PM, so clear the flag unconditionally in their case.
--- drivers/pci/pci-driver.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/pci/pci-driver.c +4 -0
@@ -584,6 +584,8 @@ static int pci_legacy_suspend(struct devstruct pci_dev *pci_dev =to_pci_dev (dev);struct pci_driver *drv = pci_dev->driver; + pci_dev->state_saved = false; +if (drv && drv->suspend) {pci_power_t prev = pci_dev->current_state;int error;
@@ -985,6 +987,8 @@ static int pci_pm_freeze(struct device *if (!pm) {pci_pm_default_suspend (pci_dev); +if (!pm_runtime_suspended (dev)) + pci_dev->state_saved = false;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 310/451 leds: leds-lp50xx: Allow LED 0 to be added to module bank
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Hitz <[email protected]>
commit 26fe74d598c32e7bc6f150edfc4aa43e1bee55db upstream.
led_banks contains LED module number(s) that should be grouped into the module bank. led_banks is 0-initialized.
By checking the led_banks entries for 0, un-set entries are detected. But a 0-entry also indicates that LED module 0 should be grouped into the module bank.
By only iterating over the available entries no check for unused entries is required and LED module 0 can be added to bank.
--- drivers/leds/leds-lp50xx.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/leds/leds-lp50xx.c +4 -6
@@ -348,17 +348,15 @@ out:return ret; } -static int lp50xx_set_banks (struct lp50xx *priv,u32 led_banks[]) +static int lp50xx_set_banks (struct lp50xx *priv,u32 led_banks[],int num_leds) {u8 led_config_lo, led_config_hi;u32 bank_enable_mask =0 ;int ret;int i; -for (i =0 ; i < priv->chip_info->max_modules; i++) { -if (led_banks[i]) - bank_enable_mask |= (1 << led_banks[i]); - } +for (i =0 ; i < num_leds; i++) + bank_enable_mask |= (1 << led_banks[i]); led_config_lo = (u8)(bank_enable_mask &0xff ); led_config_hi = (u8)(bank_enable_mask >>8 ) &0xff ;
@@ -416,7 +414,7 @@ static int lp50xx_probe_leds(struct fwnoreturn ret; } - ret =lp50xx_set_banks (priv, led_banks); + ret =lp50xx_set_banks (priv, led_banks, num_leds);if (ret) {dev_err (&priv->client->dev,"Cannot setup banked LEDs\n" );return ret;
Greg Kroah-Hartman
maintainerPATCH 311/451 leds: leds-lp50xx: LP5009 supports 3 modules for a total of 9 LEDs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Hitz <[email protected]>
commit 5246e3673eeeccb4f5bf4f42375dd495d465ac15 upstream.
LP5009 supports 9 LED outputs that are grouped into 3 modules.
--- drivers/leds/leds-lp50xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/leds/leds-lp50xx.c +1 -1
@@ -57,7 +57,7 @@/* There are 3 LED outputs per bank */ #define LP50XX_LEDS_PER_MODULE 3 -#define LP5009_MAX_LED_MODULES 2 +#define LP5009_MAX_LED_MODULES 3#define LP5012_MAX_LED_MODULES 4#define LP5018_MAX_LED_MODULES 6#define LP5024_MAX_LED_MODULES 8
Greg Kroah-Hartman
maintainerPATCH 302/451 iommu/exynos: fix device leak on of_xlate()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 05913cc43cb122f9afecdbe775115c058b906e1b upstream.
Make sure to drop the reference taken to the iommu platform device when looking up its driver data during of_xlate().
Note that commit 1a26044954a6 ("iommu/exynos: add missing put_device() call in exynos_iommu_of_xlate()") fixed the leak in a couple of error paths, but the reference is still leaking on success.
--- drivers/iommu/exynos-iommu.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/iommu/exynos-iommu.c +3 -6
@@ -1299,17 +1299,14 @@ static int exynos_iommu_of_xlate(structreturn -ENODEV ; data =platform_get_drvdata (sysmmu); -if (!data) { -put_device (&sysmmu->dev); +put_device (&sysmmu->dev); +if (!data)return -ENODEV ; - }if (!owner) { owner =kzalloc (sizeof (*owner),GFP_KERNEL ); -if (!owner) { -put_device (&sysmmu->dev); +if (!owner)return -ENOMEM ; - }INIT_LIST_HEAD (&owner->controllers);mutex_init (&owner->rpm_lock);
Greg Kroah-Hartman
maintainerPATCH 339/451 virtio_console: fix order of fields cols and rows
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maximilian Immanuel Brandtner <[email protected]>
commit 5326ab737a47278dbd16ed3ee7380b26c7056ddd upstream.
According to section 5.3.6.2 (Multiport Device Operation) of the virtio spec(version 1.2) a control buffer with the event VIRTIO_CONSOLE_RESIZE is followed by a virtio_console_resize struct containing cols then rows. The kernel implements this the wrong way around (rows then cols) resulting in the two values being swapped.
Message-Id: <[email protected]>
--- drivers/char/virtio_console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/virtio_console.c +1 -1
@@ -1617,8 +1617,8 @@ static void handle_control_message(strucbreak ;case VIRTIO_CONSOLE_RESIZE : {struct { -__virtio16 rows;__virtio16 cols; +__virtio16 rows; } size;if (!is_console_port (port))
Greg Kroah-Hartman
maintainerPATCH 348/451 ipv6: Fix potential uninit-value access in __ip6_make_skb()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shigeru Yoshida <[email protected]>
commit 4e13d3a9c25b7080f8a619f961e943fe08c2672c upstream.
As it was done in commit fc1092f51567 ("ipv4: Fix uninit-value access in __ip_make_skb()") for IPv4, check FLOWI_FLAG_KNOWN_NH on fl6->flowi6_flags instead of testing HDRINCL on the socket to avoid a race condition which causes uninit-value access.
[ Referred stable v6.1.y version of the patch to generate this one
v6.1 link: https://github.com/gregkh/linux/commit/a05c1ede50e9656f0752e523c7b54f3a3489e9a8 ]
--- net/ipv6/ip6_output.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv6/ip6_output.c +2 -1
@@ -1917,7 +1917,8 @@ struct sk_buff *__ip6_make_skb(struct sostruct inet6_dev *idev =ip6_dst_idev (skb_dst (skb));u8 icmp6_type; -if (sk->sk_socket->type ==SOCK_RAW && !inet_sk (sk)->hdrincl) +if (sk->sk_socket->type ==SOCK_RAW && + !(fl6->flowi6_flags &FLOWI_FLAG_KNOWN_NH )) icmp6_type = fl6->fl6_icmp_type;else icmp6_type =icmp6_hdr (skb)->icmp6_type;
Greg Kroah-Hartman
maintainerPATCH 349/451 ipv4: Fix uninit-value access in __ip_make_skb()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shigeru Yoshida <[email protected]>
commit fc1092f51567277509563800a3c56732070b6aa4 upstream.
KMSAN reported uninit-value access in __ip_make_skb() [1]. __ip_make_skb() tests HDRINCL to know if the skb has icmphdr. However, HDRINCL can cause a race condition. If calling setsockopt(2) with IP_HDRINCL changes HDRINCL while __ip_make_skb() is running, the function will access icmphdr in the skb even if it is not included. This causes the issue reported by KMSAN.
Check FLOWI_FLAG_KNOWN_NH on fl4->flowi4_flags instead of testing HDRINCL on the socket.
Also, fl4->fl4_icmp_type and fl4->fl4_icmp_code are not initialized. These are union in struct flowi4 and are implicitly initialized by flowi4_init_output(), but we should not rely on specific union layout.
Initialize these explicitly in raw_sendmsg().
[1]
BUG: KMSAN: uninit-value in __ip_make_skb+0x2b74/0x2d20 net/ipv4/ip_output.c:1481 __ip_make_skb+0x2b74/0x2d20 net/ipv4/ip_output.c:1481 ip_finish_skb include/net/ip.h:243 [inline] ip_push_pending_frames+0x4c/0x5c0 net/ipv4/ip_output.c:1508 raw_sendmsg+0x2381/0x2690 net/ipv4/raw.c:654 inet_sendmsg+0x27b/0x2a0 net/ipv4/af_inet.c:851 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x274/0x3c0 net/socket.c:745 __sys_sendto+0x62c/0x7b0 net/socket.c:2191 __do_sys_sendto net/socket.c:2203 [inline] __se_sys_sendto net/socket.c:2199 [inline] __x64_sys_sendto+0x130/0x200 net/socket.c:2199 do_syscall_64+0xd8/0x1f0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x6d/0x75
Uninit was created at:
slab_post_alloc_hook mm/slub.c:3804 [inline] slab_alloc_node mm/slub.c:3845 [inline] kmem_cache_alloc_node+0x5f6/0xc50 mm/slub.c:3888 kmalloc_reserve+0x13c/0x4a0 net/core/skbuff.c:577 __alloc_skb+0x35a/0x7c0 net/core/skbuff.c:668 alloc_skb include/linux/skbuff.h:1318 [inline] __ip_append_data+0x49ab/0x68c0 net/ipv4/ip_output.c:1128 ip_append_data+0x1e7/0x260 net/ipv4/ip_output.c:1365 raw_sendmsg+0x22b1/0x2690 net/ipv4/raw.c:648 inet_sendmsg+0x27b/0x2a0 net/ipv4/af_inet.c:851 sock_sendmsg_nosec net/socket.c:730 [inline] __sock_sendmsg+0x274/0x3c0 net/socket.c:745 __sys_sendto+0x62c/0x7b0 net/socket.c:2191 __do_sys_sendto net/socket.c:2203 [inline] __se_sys_sendto net/socket.c:2199 [inline] __x64_sys_sendto+0x130/0x200 net/socket.c:2199 do_syscall_64+0xd8/0x1f0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x6d/0x75 CPU: 1 PID: 15709 Comm: syz-executor.7 Not tainted 6.8.0-11567-gb3603fcb79b1 #25 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-1.fc39 04/01/2014
[ Referred stable v6.1.y version of the patch to generate this one
v6.1 link: https://github.com/gregkh/linux/commit/55bf541e018b76b3750cb6c6ea18c46e1ac5562e ]
--- net/ipv4/ip_output.c | 3 ++- net/ipv4/raw.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-)
net/ipv4/ip_output.c +2 -1
@@ -1572,7 +1572,8 @@ struct sk_buff *__ip_make_skb(struct soc* so icmphdr does not in skb linear region and can not get icmp_type * by icmp_hdr(skb)->type. */ -if (sk->sk_type ==SOCK_RAW && !inet_sk (sk)->hdrincl) +if (sk->sk_type ==SOCK_RAW && + !(fl4->flowi4_flags &FLOWI_FLAG_KNOWN_NH )) icmp_type = fl4->fl4_icmp_type;else icmp_type =icmp_hdr (skb)->type;
net/ipv4/raw.c +3 -0
@@ -634,6 +634,9 @@ static int raw_sendmsg(struct sock *sk, (hdrincl ?FLOWI_FLAG_KNOWN_NH :0 ), daddr, saddr, 0, 0, sk->sk_uid); + fl4.fl4_icmp_type =0 ; + fl4.fl4_icmp_code =0 ; +if (!hdrincl) { rfv.msg = msg; rfv.hlen =0 ;
Greg Kroah-Hartman
maintainerPATCH 350/451 HID: core: Harden s32ton() against conversion to 0 bits
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alan Stern <[email protected]>
[ Upstream commit a6b87bfc2ab5bccb7ad953693c85d9062aef3fdd ]
Testing by the syzbot fuzzer showed that the HID core gets a shift-out-of-bounds exception when it tries to convert a 32-bit quantity to a 0-bit quantity. Ideally this should never occur, but there are buggy devices and some might have a report field with size set to zero; we shouldn't reject the report or the device just because of that.
Instead, harden the s32ton() routine so that it returns a reasonable result instead of crashing when it is called with the number of bits set to 0 -- the same as what snto32() does.
[ s32ton() was moved by c653ffc28340 ("HID: stop exporting hid_snto32()").
Minor context change fixed. ]
--- drivers/hid/hid-core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/hid/hid-core.c +6 -1
@@ -1349,7 +1349,12 @@ EXPORT_SYMBOL_GPL(hid_snto32);static u32 s32ton (__s32 value,unsigned n) { -s32 a = value >> (n -1 ); +s32 a; + +if (!value || !n) +return 0 ; + + a = value >> (n -1 );if (a && a !=-1 )return value <0 ?1 << (n -1 ) : (1 << (n -1 )) -1 ;return value & ((1 << n) -1 );
Greg Kroah-Hartman
maintainerPATCH 351/451 xhci: dbgtty: fix device unregister
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Łukasz Bartosik <[email protected]>
[ Upstream commit 1f73b8b56cf35de29a433aee7bfff26cea98be3f ]
When DbC is disconnected then xhci_dbc_tty_unregister_device() is called. However if there is any user space process blocked on write to DbC terminal device then it will never be signalled and thus stay blocked indifinitely.
This fix adds a tty_vhangup() call in xhci_dbc_tty_unregister_device(). The tty_vhangup() wakes up any blocked writers and causes subsequent write attempts to DbC terminal device to fail.
--- drivers/usb/host/xhci-dbgtty.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/host/xhci-dbgtty.c +6 -0
@@ -468,6 +468,12 @@ static void xhci_dbc_tty_unregister_deviif (!port->registered)return ; +/* +* Hang up the TTY. This wakes up any blocked +* writers and causes subsequent writes to fail. +*/ +tty_vhangup (port->port.tty); +tty_unregister_device (dbc_tty_driver,0 );xhci_dbc_tty_exit_port (port); port->registered = false;
Greg Kroah-Hartman
maintainerPATCH 352/451 usb: gadget: udc: fix use-after-free in usb_gadget_state_work
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jimmy Hu <[email protected]>
[ Upstream commit baeb66fbd4201d1c4325074e78b1f557dff89b5b ]
A race condition during gadget teardown can lead to a use-after-free in usb_gadget_state_work(), as reported by KASAN:
BUG: KASAN: invalid-access in sysfs_notify+0x2c/0xd0 Workqueue: events usb_gadget_state_work
The fundamental race occurs because a concurrent event (e.g., an interrupt) can call usb_gadget_set_state() and schedule gadget->work at any time during the cleanup process in usb_del_gadget().
Commit 399a45e5237c ("usb: gadget: core: flush gadget workqueue after device removal") attempted to fix this by moving flush_work() to after device_del(). However, this does not fully solve the race, as a new work item can still be scheduled *after* flush_work() completes but before the gadget's memory is freed, leading to the same use-after-free.
This patch fixes the race condition robustly by introducing a 'teardown' flag and a 'state_lock' spinlock to the usb_gadget struct. The flag is set during cleanup in usb_del_gadget() *before* calling flush_work() to prevent any new work from being scheduled once cleanup has commenced. The scheduling site, usb_gadget_set_state(), now checks this flag under the lock before queueing the work, thus safely closing the race window.
--- drivers/usb/gadget/udc/core.c | 17 ++++++++++++++++- include/linux/usb/gadget.h | 5 +++++ 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/usb/gadget/udc/core.c +16 -1
@@ -1037,8 +1037,13 @@ static void usb_gadget_state_work(structvoid usb_gadget_set_state (struct usb_gadget *gadget,enum usb_device_state state) { +unsigned long flags; + +spin_lock_irqsave (&gadget->state_lock, flags); gadget->state = state; -schedule_work (&gadget->work); +if (!gadget->teardown) +schedule_work (&gadget->work); +spin_unlock_irqrestore (&gadget->state_lock, flags); }EXPORT_SYMBOL_GPL (usb_gadget_set_state);
@@ -1199,6 +1204,8 @@ void usb_initialize_gadget(struct device void (*release)(struct device *dev)) {dev_set_name (&gadget->dev,"gadget" ); +spin_lock_init (&gadget->state_lock); + gadget->teardown = false;INIT_WORK (&gadget->work, usb_gadget_state_work); gadget->dev.parent = parent;
@@ -1376,6 +1383,7 @@ static void usb_gadget_remove_driver(strvoid usb_del_gadget (struct usb_gadget *gadget) {struct usb_udc *udc = gadget->udc; +unsigned long flags;if (!udc)return ;
@@ -1394,6 +1402,13 @@ void usb_del_gadget(struct usb_gadget *gmutex_unlock (&udc_lock);kobject_uevent (&udc->dev.kobj,KOBJ_REMOVE ); +/* +* Set the teardown flag before flushing the work to prevent new work +* from being scheduled while we are cleaning up. +*/ +spin_lock_irqsave (&gadget->state_lock, flags); + gadget->teardown = true; +spin_unlock_irqrestore (&gadget->state_lock, flags);flush_work (&gadget->work);device_unregister (&udc->dev);device_del (&gadget->dev);
include/linux/usb/gadget.h +5 -0
@@ -341,6 +341,9 @@ struct usb_gadget_ops {* @max_speed: Maximal speed the UDC can handle. UDC must support this * and all slower speeds. * @state: the state we are now (attached, suspended, configured, etc) +* @state_lock: Spinlock protecting the `state` and `teardown` members. +* @teardown: True if the device is undergoing teardown, used to prevent +* new work from being scheduled during cleanup. * @name: Identifies the controller hardware type. Used in diagnostics * and sometimes configuration. * @dev: Driver model state for this abstract device.
@@ -408,6 +411,8 @@ struct usb_gadget {enum usb_device_speed speed;enum usb_device_speed max_speed;enum usb_device_state state; +spinlock_t state_lock; +bool teardown;const char *name;struct device dev;unsigned isoch_delay;
Greg Kroah-Hartman
maintainerPATCH 353/451 net/mlx5e: Avoid field-overflowing memcpy()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit ad5185735f7dab342fdd0dd41044da4c9ccfef67 upstream.
In preparation for FORTIFY_SOURCE performing compile-time and run-time field bounds checking for memcpy(), memmove(), and memset(), avoid intentionally writing across neighboring fields.
Use flexible arrays instead of zero-element arrays (which look like they are always overflowing) and split the cross-field memcpy() into two halves that can be appropriately bounds-checked by the compiler.
We were doing:
#define ETH_HLEN 14
#define VLAN_HLEN 4
...
#define MLX5E_XDP_MIN_INLINE (ETH_HLEN + VLAN_HLEN)
...
struct mlx5e_tx_wqe *wqe = mlx5_wq_cyc_get_wqe(wq, pi);
...
struct mlx5_wqe_eth_seg *eseg = &wqe->eth;
struct mlx5_wqe_data_seg *dseg = wqe->data;
...
memcpy(eseg->inline_hdr.start, xdptxd->data, MLX5E_XDP_MIN_INLINE);target is wqe->eth.inline_hdr.start (which the compiler sees as being 2 bytes in size), but copying 18, intending to write across start (really vlan_tci, 2 bytes). The remaining 16 bytes get written into wqe->data[0], covering byte_count (4 bytes), lkey (4 bytes), and addr (8 bytes).
struct mlx5e_tx_wqe {
struct mlx5_wqe_ctrl_seg ctrl; /* 0 16 */
struct mlx5_wqe_eth_seg eth; /* 16 16 */
struct mlx5_wqe_data_seg data[]; /* 32 0 */
/* size: 32, cachelines: 1, members: 3 */
/* last cacheline: 32 bytes */
};struct mlx5_wqe_eth_seg {
u8 swp_outer_l4_offset; /* 0 1 */
u8 swp_outer_l3_offset; /* 1 1 */
u8 swp_inner_l4_offset; /* 2 1 */
u8 swp_inner_l3_offset; /* 3 1 */
u8 cs_flags; /* 4 1 */
u8 swp_flags; /* 5 1 */
__be16 mss; /* 6 2 */
__be32 flow_table_metadata; /* 8 4 */
union {
struct {
__be16 sz; /* 12 2 */
u8 start[2]; /* 14 2 */
} inline_hdr; /* 12 4 */
struct {
__be16 type; /* 12 2 */
__be16 vlan_tci; /* 14 2 */
} insert; /* 12 4 */
__be32 trailer; /* 12 4 */
}; /* 12 4 */
/* size: 16, cachelines: 1, members: 9 */
/* last cacheline: 16 bytes */
};struct mlx5_wqe_data_seg {
__be32 byte_count; /* 0 4 */
__be32 lkey; /* 4 4 */
__be64 addr; /* 8 8 */ /* size: 16, cachelines: 1, members: 3 */
/* last cacheline: 16 bytes */
};So, split the memcpy() so the compiler can reason about the buffer sizes.
"pahole" shows no size nor member offset changes to struct mlx5e_tx_wqe nor struct mlx5e_umr_wqe. "objdump -d" shows no meaningful object code changes (i.e. only source line number induced differences and optimizations).
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 4 ++-- drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +2 -2
@@ -199,7 +199,7 @@ static inline int mlx5e_get_max_num_chanstruct mlx5e_tx_wqe {struct mlx5_wqe_ctrl_seg ctrl;struct mlx5_wqe_eth_seg eth; -struct mlx5_wqe_data_seg data[0 ]; +struct mlx5_wqe_data_seg data[]; };struct mlx5e_rx_wqe_ll {
@@ -215,7 +215,7 @@ struct mlx5e_umr_wqe {struct mlx5_wqe_ctrl_seg ctrl;struct mlx5_wqe_umr_ctrl_seg uctrl;struct mlx5_mkey_seg mkc; -struct mlx5_mtt inline_mtts[0 ]; +struct mlx5_mtt inline_mtts[]; };extern const char mlx5e_self_tests[][ETH_GSTRING_LEN ];
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c +3 -1
@@ -341,8 +341,10 @@ mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq/* copy the inline part if required */ if (sq->min_inline_mode !=MLX5_INLINE_MODE_NONE ) { -memcpy (eseg->inline_hdr.start, xdptxd->data,MLX5E_XDP_MIN_INLINE ); +memcpy (eseg->inline_hdr.start, xdptxd->data,sizeof (eseg->inline_hdr.start)); eseg->inline_hdr.sz =cpu_to_be16 (MLX5E_XDP_MIN_INLINE ); +memcpy (dseg, xdptxd->data +sizeof (eseg->inline_hdr.start), +MLX5E_XDP_MIN_INLINE -sizeof (eseg->inline_hdr.start)); dma_len -=MLX5E_XDP_MIN_INLINE ; dma_addr +=MLX5E_XDP_MIN_INLINE ; dseg++;
Greg Kroah-Hartman
maintainerPATCH 354/451 ALSA: wavefront: Clear substream pointers on close
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
[ Upstream commit e11c5c13ce0ab2325d38fe63500be1dd88b81e38 ]
Clear substream pointers in close functions to avoid leaving dangling pointers, helping to improve code safety and
prevents potential issues.
--- sound/isa/wavefront/wavefront_midi.c | 2 ++ 1 file changed, 2 insertions(+)
sound/isa/wavefront/wavefront_midi.c +2 -0
@@ -291,6 +291,7 @@ static int snd_wavefront_midi_input_closreturn -EIO ;spin_lock_irqsave (&midi->open, flags); + midi->substream_input[mpu] =NULL ; midi->mode[mpu] &= ~MPU401_MODE_INPUT ;spin_unlock_irqrestore (&midi->open, flags);
@@ -314,6 +315,7 @@ static int snd_wavefront_midi_output_cloreturn -EIO ;spin_lock_irqsave (&midi->open, flags); + midi->substream_output[mpu] =NULL ; midi->mode[mpu] &= ~MPU401_MODE_OUTPUT ;spin_unlock_irqrestore (&midi->open, flags);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 355/451 ALSA: wavefront: Fix integer overflow in sample size validation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junrui Luo <[email protected]>
[ Upstream commit 0c4a13ba88594fd4a27292853e736c6b4349823d ]
The wavefront_send_sample() function has an integer overflow issue when validating sample size. The header->size field is u32 but gets cast to int for comparison with dev->freemem
Fix by using unsigned comparison to avoid integer overflow.
--- sound/isa/wavefront/wavefront_synth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/isa/wavefront/wavefront_synth.c +2 -2
@@ -944,9 +944,9 @@ wavefront_send_sample (snd_wavefront_t *if (header->size) { dev->freemem =wavefront_freemem (dev); -if (dev->freemem < (int )header->size) { +if (dev->freemem <0 || dev->freemem < header->size) {snd_printk ("insufficient memory to " -"load %d byte sample.\n" , +"load %u byte sample.\n" , header->size);return -ENOMEM ; }
Greg Kroah-Hartman
maintainerPATCH 356/451 ext4: fix string copying in parse_apply_sb_mount_options()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
[ Upstream commit ee5a977b4e771cc181f39d504426dbd31ed701cc ]
strscpy_pad() can't be used to copy a non-NUL-term string into a NUL-term string of possibly bigger size. Commit 0efc5990bca5 ("string.h: Introduce memtostr() and memtostr_pad()") provides additional information in that regard. So if this happens, the following warning is observed:
strnlen: detected buffer overflow: 65 byte read of buffer size 64
WARNING: CPU: 0 PID: 28655 at lib/string_helpers.c:1032 __fortify_report+0x96/0xc0 lib/string_helpers.c:1032 Modules linked in: CPU: 0 UID: 0 PID: 28655 Comm: syz-executor.3 Not tainted 6.12.54-syzkaller-00144-g5f0270f1ba00 #0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:__fortify_report+0x96/0xc0 lib/string_helpers.c:1032 Call Trace: <TASK> __fortify_panic+0x1f/0x30 lib/string_helpers.c:1039 strnlen include/linux/fortify-string.h:235 [inline] sized_strscpy include/linux/fortify-string.h:309 [inline] parse_apply_sb_mount_options fs/ext4/super.c:2504 [inline] __ext4_fill_super fs/ext4/super.c:5261 [inline] ext4_fill_super+0x3c35/0xad00 fs/ext4/super.c:5706 get_tree_bdev_flags+0x387/0x620 fs/super.c:1636 vfs_get_tree+0x93/0x380 fs/super.c:1814 do_new_mount fs/namespace.c:3553 [inline] path_mount+0x6ae/0x1f70 fs/namespace.c:3880 do_mount fs/namespace.c:3893 [inline] __do_sys_mount fs/namespace.c:4103 [inline] __se_sys_mount fs/namespace.c:4080 [inline] __x64_sys_mount+0x280/0x300 fs/namespace.c:4080 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x64/0x140 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x76/0x7e
Since userspace is expected to provide s_mount_opts field to be at most 63 characters long with the ending byte being NUL-term, use a 64-byte buffer which matches the size of s_mount_opts, so that strscpy_pad() does its job properly. Return with error if the user still managed to provide a non-NUL-term string here.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
Message-ID: <[email protected]>
--- fs/ext4/super.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
fs/ext4/super.c +4 -3
@@ -4282,10 +4282,11 @@ static int ext4_fill_super(struct super_ }if (sbi->s_es->s_mount_opts[0 ]) { -char s_mount_opts[65 ]; +char s_mount_opts[64 ]; -strscpy_pad (s_mount_opts, sbi->s_es->s_mount_opts, -sizeof (s_mount_opts)); +if (strscpy_pad (s_mount_opts, sbi->s_es->s_mount_opts, +sizeof (s_mount_opts)) <0 ) + goto failed_mount;if (!parse_options (s_mount_opts, sb, &journal_devnum, &journal_ioprio,0 )) { ext4_msg(sb, KERN_WARNING,
Greg Kroah-Hartman
maintainerPATCH 357/451 btrfs: dont rewrite ret from inode_permission
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 0185c2292c600993199bc6b1f342ad47a9e8c678 ]
In our user safe ino resolve ioctl we'll just turn any ret into -EACCES from inode_permission(). This is redundant, and could potentially be wrong if we had an ENOMEM in the security layer or some such other error, so simply return the actual return value.
Note: The patch was taken from v5 of fscrypt patchset
(https://lore.kernel.org/linux-btrfs/[email protected]/)
which was handled over time by various people: Omar Sandoval, Sweet Tea Dorminy, Josef Bacik.
--- fs/btrfs/ioctl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/btrfs/ioctl.c +1 -3
@@ -2573,10 +2573,8 @@ static int btrfs_search_path_in_tree_use } ret =inode_permission (temp_inode,MAY_READ |MAY_EXEC );iput (temp_inode); -if (ret) { - ret = -EACCES ; +if (ret) goto out_put; - }if (key.offset == upper_limit.objectid)break ;
Greg Kroah-Hartman
maintainerPATCH 340/451 console: Delete unused con_font_copy() callback implementations
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peilin Ye <[email protected]>
commit 7a089ec7d77fe7d50f6bb7b178fa25eec9fd822b upstream.
Recently in commit 3c4e0dff2095 ("vt: Disable KD_FONT_OP_COPY") we disabled the KD_FONT_OP_COPY ioctl() option. Delete all the con_font_copy() callbacks, since we no longer use them.
Mark KD_FONT_OP_COPY as "obsolete" in include/uapi/linux/kd.h, just like what we have done for PPPIOCDETACH in commit af8d3c7c001a ("ppp: remove the PPPIOCDETACH ioctl").
--- drivers/usb/misc/sisusbvga/sisusb_con.c | 6 ------ drivers/video/console/dummycon.c | 6 ------ drivers/video/fbdev/core/fbcon.c | 11 ----------- include/linux/console.h | 1 - include/uapi/linux/kd.h | 2 +- 5 files changed, 1 insertion(+), 25 deletions(-)
drivers/usb/misc/sisusbvga/sisusb_con.c +0 -6
@@ -1358,11 +1358,6 @@ static int sisusbdummycon_font_default(sreturn 0 ; } -static int sisusbdummycon_font_copy (struct vc_data *vc,int con) -{ -return 0 ; -} -static const struct consw sisusb_dummy_con = { .owner =THIS_MODULE , .con_startup = sisusbdummycon_startup,
@@ -1377,7 +1372,6 @@ static const struct consw sisusb_dummy_c .con_blank = sisusbdummycon_blank, .con_font_set = sisusbdummycon_font_set, .con_font_default = sisusbdummycon_font_default, - .con_font_copy = sisusbdummycon_font_copy, };int
drivers/video/console/dummycon.c +0 -6
@@ -136,11 +136,6 @@ static int dummycon_font_default(structreturn 0 ; } -static int dummycon_font_copy (struct vc_data *vc,int con) -{ -return 0 ; -} -/* * The console `switch' structure for the dummy console *
@@ -161,6 +156,5 @@ const struct consw dummy_con = { .con_blank = dummycon_blank, .con_font_set = dummycon_font_set, .con_font_default = dummycon_font_default, - .con_font_copy = dummycon_font_copy, };EXPORT_SYMBOL_GPL (dummy_con);
drivers/video/fbdev/core/fbcon.c +0 -11
@@ -2471,16 +2471,6 @@ static int fbcon_do_set_font(struct vc_dreturn 0 ; } -static int fbcon_copy_font (struct vc_data *vc,int con) -{ -struct fbcon_display *od = &fb_display[con]; -struct console_font *f = &vc->vc_font; - -if (od->fontdata == f->data) -return 0 ;/* already the same font... */ -return fbcon_do_set_font (vc, f->width, f->height, od->fontdata, od->userfont); -} -/* * User asked to set font; we are guaranteed that * a) width and height are in range 1..32
@@ -3174,7 +3164,6 @@ static const struct consw fb_con = { .con_font_set = fbcon_set_font, .con_font_get = fbcon_get_font, .con_font_default = fbcon_set_def_font, - .con_font_copy = fbcon_copy_font, .con_set_palette = fbcon_set_palette, .con_invert_region = fbcon_invert_region, .con_screen_pos = fbcon_screen_pos,
include/linux/console.h +0 -1
@@ -62,7 +62,6 @@ struct consw {int (*con_font_get)(struct vc_data *vc,struct console_font *font);int (*con_font_default)(struct vc_data *vc,struct console_font *font,char *name); -int (*con_font_copy)(struct vc_data *vc,int con);int (*con_resize)(struct vc_data *vc,unsigned int width,unsigned int height,unsigned int user); void (*con_set_palette)(struct vc_data *vc,
include/uapi/linux/kd.h +1 -1
@@ -173,7 +173,7 @@ struct console_font {#define KD_FONT_OP_SET 0/* Set font */ #define KD_FONT_OP_GET 1/* Get font */ #define KD_FONT_OP_SET_DEFAULT 2/* Set font to default, data points to name / NULL */ -#define KD_FONT_OP_COPY 3/* Copy from another console */ +#define KD_FONT_OP_COPY 3/* Obsolete, do not use */ #define KD_FONT_FLAG_DONT_RECALC 1/* Don't recalculate hw charcell size [compat] */
Greg Kroah-Hartman
maintainerPATCH 358/451 xfs: fix a memory leak in xfs_buf_item_init()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
[ Upstream commit fc40459de82543b565ebc839dca8f7987f16f62e ]
xfs_buf_item_get_format() may allocate memory for bip->bli_formats, free the memory in the error path.
--- fs/xfs/xfs_buf_item.c | 1 + 1 file changed, 1 insertion(+)
fs/xfs/xfs_buf_item.c +1 -0
@@ -744,6 +744,7 @@ xfs_buf_item_init( map_size =DIV_ROUND_UP (chunks,NBWORD );if (map_size >XFS_BLF_DATAMAP_SIZE ) { +xfs_buf_item_free_format (bip);kmem_cache_free (xfs_buf_item_zone, bip); xfs_err(mp, "buffer item dirty bitmap (%u uints) too small to reflect %u bytes!",
Greg Kroah-Hartman
maintainerPATCH 359/451 f2fs: use global inline_xattr_slab instead of per-sb slab cache
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 1f27ef42bb0b7c0740c5616ec577ec188b8a1d05 ]
As Hong Yun reported in mailing list:
loop7: detected capacity change from 0 to 131072
------------[ cut here ]------------ kmem_cache of name 'f2fs_xattr_entry-7:7' already exists WARNING: CPU: 0 PID: 24426 at mm/slab_common.c:110 kmem_cache_sanity_check mm/slab_common.c:109 [inline] WARNING: CPU: 0 PID: 24426 at mm/slab_common.c:110 __kmem_cache_create_args+0xa6/0x320 mm/slab_common.c:307 CPU: 0 UID: 0 PID: 24426 Comm: syz.7.1370 Not tainted 6.17.0-rc4 #1 PREEMPT(full) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 RIP: 0010:kmem_cache_sanity_check mm/slab_common.c:109 [inline] RIP: 0010:__kmem_cache_create_args+0xa6/0x320 mm/slab_common.c:307 Call Trace: __kmem_cache_create include/linux/slab.h:353 [inline] f2fs_kmem_cache_create fs/f2fs/f2fs.h:2943 [inline] f2fs_init_xattr_caches+0xa5/0xe0 fs/f2fs/xattr.c:843 f2fs_fill_super+0x1645/0x2620 fs/f2fs/super.c:4918 get_tree_bdev_flags+0x1fb/0x260 fs/super.c:1692 vfs_get_tree+0x43/0x140 fs/super.c:1815 do_new_mount+0x201/0x550 fs/namespace.c:3808 do_mount fs/namespace.c:4136 [inline] __do_sys_mount fs/namespace.c:4347 [inline] __se_sys_mount+0x298/0x2f0 fs/namespace.c:4324 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0x8e/0x3a0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x76/0x7e
The bug can be reproduced w/ below scripts:
- mount /dev/vdb /mnt1
- mount /dev/vdc /mnt2
- umount /mnt1
- mounnt /dev/vdb /mnt1
The reason is if we created two slab caches, named f2fs_xattr_entry-7:3 and f2fs_xattr_entry-7:7, and they have the same slab size. Actually, slab system will only create one slab cache core structure which has slab name of "f2fs_xattr_entry-7:3", and two slab caches share the same structure and cache address.
So, if we destroy f2fs_xattr_entry-7:3 cache w/ cache address, it will decrease reference count of slab cache, rather than release slab cache entirely, since there is one more user has referenced the cache.
Then, if we try to create slab cache w/ name "f2fs_xattr_entry-7:3" again, slab system will find that there is existed cache which has the same name and trigger the warning.
Let's changes to use global inline_xattr_slab instead of per-sb slab cache for fixing.
--- fs/f2fs/f2fs.h | 3 --- fs/f2fs/super.c | 15 +++++++-------- fs/f2fs/xattr.c | 32 +++++++++++--------------------- fs/f2fs/xattr.h | 10 ++++++---- 4 files changed, 24 insertions(+), 36 deletions(-)
fs/f2fs/f2fs.h +0 -3
@@ -1573,9 +1573,6 @@ struct f2fs_sb_info {struct workqueue_struct *post_read_wq;/* post read workqueue */ -struct kmem_cache *inline_xattr_slab;/* inline xattr entry */ -unsigned int inline_xattr_slab_size;/* default inline xattr slab size */ -#ifdef CONFIG_F2FS_FS_COMPRESSION struct kmem_cache *page_array_slab;/* page array entry */ unsigned int page_array_slab_size;/* default page array slab size */
fs/f2fs/super.c +7 -8
@@ -1351,7 +1351,6 @@ static void f2fs_put_super(struct super_destroy_device_list (sbi);f2fs_destroy_page_array_cache (sbi); -f2fs_destroy_xattr_caches (sbi);mempool_destroy (sbi->write_io_dummy);#ifdef CONFIG_QUOTA for (i =0 ; i <MAXQUOTAS ; i++)
@@ -3722,13 +3721,9 @@ try_onemore: } } -/* init per sbi slab cache */ - err =f2fs_init_xattr_caches (sbi); -if (err) - goto free_io_dummy; err =f2fs_init_page_array_cache (sbi);if (err) - goto free_xattr_cache; + goto free_io_dummy;/* get an inode for meta space */ sbi->meta_inode =f2fs_iget (sb,F2FS_META_INO (sbi));
@@ -4021,8 +4016,6 @@ free_meta_inode: sbi->meta_inode =NULL ; free_page_array_cache:f2fs_destroy_page_array_cache (sbi); -free_xattr_cache: -f2fs_destroy_xattr_caches (sbi); free_io_dummy:mempool_destroy (sbi->write_io_dummy); free_percpu:
@@ -4174,7 +4167,12 @@ static int __init init_f2fs_fs(void) err =f2fs_init_compress_cache ();if (err) goto free_compress_mempool; + err =f2fs_init_xattr_cache (); +if (err) + goto free_compress_cache;return 0 ; +free_compress_cache: +f2fs_destroy_compress_cache (); free_compress_mempool:f2fs_destroy_compress_mempool (); free_bioset:
@@ -4210,6 +4208,7 @@ fail: static void __exit exit_f2fs_fs(void) { +f2fs_destroy_xattr_cache ();f2fs_destroy_compress_cache ();f2fs_destroy_compress_mempool ();f2fs_destroy_bioset ();
fs/f2fs/xattr.c +11 -21
@@ -23,11 +23,12 @@#include "xattr.h" #include "segment.h" +static struct kmem_cache *inline_xattr_slab;static void *xattr_alloc (struct f2fs_sb_info *sbi,int size,bool *is_inline) { -if (likely (size == sbi->inline_xattr_slab_size)) { +if (likely (size ==DEFAULT_XATTR_SLAB_SIZE )) { *is_inline = true; -return kmem_cache_zalloc (sbi->inline_xattr_slab,GFP_NOFS ); +return kmem_cache_zalloc (inline_xattr_slab,GFP_NOFS ); } *is_inline = false;return f2fs_kzalloc (sbi, size,GFP_NOFS );
@@ -37,7 +38,7 @@ static void xattr_free(struct f2fs_sb_in bool is_inline) {if (is_inline) -kmem_cache_free (sbi->inline_xattr_slab, xattr_addr); +kmem_cache_free (inline_xattr_slab, xattr_addr);else kfree (xattr_addr); }
@@ -814,25 +815,14 @@ int f2fs_setxattr(struct inode *inode, ireturn err; } -int f2fs_init_xattr_caches (struct f2fs_sb_info *sbi) +int __init f2fs_init_xattr_cache (void ) { -dev_t dev = sbi->sb->s_bdev->bd_dev; -char slab_name[32 ]; - -sprintf (slab_name,"f2fs_xattr_entry-%u:%u" ,MAJOR (dev),MINOR (dev)); - - sbi->inline_xattr_slab_size =F2FS_OPTION (sbi).inline_xattr_size * -sizeof (__le32) +XATTR_PADDING_SIZE ; - - sbi->inline_xattr_slab =f2fs_kmem_cache_create (slab_name, - sbi->inline_xattr_slab_size); -if (!sbi->inline_xattr_slab) -return -ENOMEM ; - -return 0 ; + inline_xattr_slab =f2fs_kmem_cache_create ("f2fs_xattr_entry" , +DEFAULT_XATTR_SLAB_SIZE ); +return inline_xattr_slab ?0 : -ENOMEM ; } -void f2fs_destroy_xattr_caches (struct f2fs_sb_info *sbi) +void f2fs_destroy_xattr_cache (void ) { -kmem_cache_destroy (sbi->inline_xattr_slab); -} +kmem_cache_destroy (inline_xattr_slab); +}
fs/f2fs/xattr.h +6 -4
@@ -88,6 +88,8 @@ struct f2fs_xattr_entry { F2FS_TOTAL_EXTRA_ATTR_SIZE / sizeof(__le32) - \ DEF_INLINE_RESERVED_SIZE - \ MIN_INLINE_DENTRY_SIZE / sizeof(__le32)) +#define DEFAULT_XATTR_SLAB_SIZE (DEFAULT_INLINE_XATTR_ADDRS * \ + sizeof(__le32) + XATTR_PADDING_SIZE)/* * On-disk structure of f2fs_xattr
@@ -131,8 +133,8 @@ extern int f2fs_setxattr(struct inode *,extern int f2fs_getxattr (struct inode *,int ,const char *,void *,size_t ,struct page *);extern ssize_t f2fs_listxattr (struct dentry *,char *,size_t ); -extern int f2fs_init_xattr_caches (struct f2fs_sb_info *); -extern void f2fs_destroy_xattr_caches (struct f2fs_sb_info *); +extern int __init f2fs_init_xattr_cache (void ); +extern void f2fs_destroy_xattr_cache (void );#else #define f2fs_xattr_handlers NULL
@@ -149,8 +151,8 @@ static inline int f2fs_getxattr(struct i {return -EOPNOTSUPP ; } -static inline int f2fs_init_xattr_caches (struct f2fs_sb_info *sbi) {return 0 ; } -static inline void f2fs_destroy_xattr_caches (struct f2fs_sb_info *sbi) { } +static inline int __init f2fs_init_xattr_cache (void ) {return 0 ; } +static inline void f2fs_destroy_xattr_cache (void ) { }#endif #ifdef CONFIG_F2FS_FS_SECURITY
Greg Kroah-Hartman
maintainerPATCH 360/451 f2fs: fix to detect recoverable inode during dryrun of find_fsync_dnodes()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 68d05693f8c031257a0822464366e1c2a239a512 ]
mkfs.f2fs -f /dev/vdd
mount /dev/vdd /mnt/f2fs
touch /mnt/f2fs/foo
sync # avoid CP_UMOUNT_FLAG in last f2fs_checkpoint.ckpt_flags
touch /mnt/f2fs/barf2fs_io fsync /mnt/f2fs/barf2fs_io shutdown 2 /mnt/f2fs
umount /mnt/f2fs
blockdev --setro /dev/vdd
mount /dev/vdd /mnt/f2fs
mount: /mnt/f2fs: WARNING: source write-protected, mounted read-only.
For the case if we create and fsync a new inode before sudden power-cut, without norecovery or disable_roll_forward mount option, the following mount will succeed w/o recovering last fsynced inode.
The problem here is that we only check inode_list list after find_fsync_dnodes() in f2fs_recover_fsync_data() to find out whether there is recoverable data in the iamge, but there is a missed case, if last fsynced inode is not existing in last checkpoint, then, we will fail to get its inode due to nat of inode node is not existing in last checkpoint, so the inode won't be linked in inode_list.
Let's detect such case in dyrun mode to fix this issue.
After this change, mount will fail as expected below:
mount: /mnt/f2fs: cannot mount /dev/vdd read-only.
dmesg(1) may have more information after failed mount system call.
demsg:
F2FS-fs (vdd): Need to recover fsync data, but write access unavailable, please try mount w/ disable_roll_forward or norecovery
--- fs/f2fs/recovery.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
fs/f2fs/recovery.c +6 -3
@@ -328,7 +328,7 @@ static int recover_inode(struct inode *i }static int find_fsync_dnodes (struct f2fs_sb_info *sbi,struct list_head *head, -bool check_only) +bool check_only,bool *new_inode) {struct curseg_info *curseg;struct page *page =NULL ;
@@ -385,6 +385,8 @@ static int find_fsync_dnodes(struct f2fsif (IS_ERR (entry)) { err =PTR_ERR (entry);if (err == -ENOENT ) { +if (check_only) + *new_inode = true; err =0 ; goto next; }
@@ -789,6 +791,7 @@ int f2fs_recover_fsync_data(struct f2fs_unsigned long s_flags = sbi->sb->s_flags;bool need_writecp = false;bool fix_curseg_write_pointer = false; +bool new_inode = false;#ifdef CONFIG_QUOTA int quota_enabled;#endif
@@ -813,8 +816,8 @@ int f2fs_recover_fsync_data(struct f2fs_mutex_lock (&sbi->cp_mutex);/* step #1: find fsynced inode numbers */ - err =find_fsync_dnodes (sbi, &inode_list, check_only); -if (err ||list_empty (&inode_list)) + err =find_fsync_dnodes (sbi, &inode_list, check_only, &new_inode); +if (err <0 || (list_empty (&inode_list) && (!check_only || !new_inode))) goto skip;if (check_only) {
Greg Kroah-Hartman
maintainerPATCH 361/451 f2fs: fix to propagate error from f2fs_enable_checkpoint()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit be112e7449a6e1b54aa9feac618825d154b3a5c7 ]
In order to let userspace detect such error rather than suffering silent failure.
--- fs/f2fs/super.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
fs/f2fs/super.c +15 -9
@@ -1836,9 +1836,10 @@ restore_flag:return err; } -static void f2fs_enable_checkpoint (struct f2fs_sb_info *sbi) +static int f2fs_enable_checkpoint (struct f2fs_sb_info *sbi) {int retry =DEFAULT_RETRY_IO_COUNT ; +int ret;/* we should flush all the data to keep data consistency */ do {
@@ -1857,7 +1858,11 @@ static void f2fs_enable_checkpoint(strucset_sbi_flag (sbi,SBI_IS_DIRTY );up_write (&sbi->gc_lock); -f2fs_sync_fs (sbi->sb,1 ); + ret =f2fs_sync_fs (sbi->sb,1 ); +if (ret) +f2fs_err (sbi,"%s sync_fs failed, ret: %d" , __func__, ret); + +return ret; }static int f2fs_remount (struct super_block *sb,int *flags,char *data)
@@ -2005,7 +2010,9 @@ static int f2fs_remount(struct super_bloif (err) goto restore_gc; }else { -f2fs_enable_checkpoint (sbi); + err =f2fs_enable_checkpoint (sbi); +if (err) + goto restore_gc; } }
@@ -3933,13 +3940,12 @@ reset_checkpoint:/* f2fs_recover_fsync_data() cleared this already */ clear_sbi_flag (sbi,SBI_POR_DOING ); -if (test_opt (sbi,DISABLE_CHECKPOINT )) { +if (test_opt (sbi,DISABLE_CHECKPOINT )) err =f2fs_disable_checkpoint (sbi); -if (err) - goto sync_free_meta; - }else if (is_set_ckpt_flags (sbi,CP_DISABLED_FLAG )) { -f2fs_enable_checkpoint (sbi); - } +else if (is_set_ckpt_flags (sbi,CP_DISABLED_FLAG )) + err =f2fs_enable_checkpoint (sbi); +if (err) + goto sync_free_meta;/* * If filesystem is not mounted as read-only then
Greg Kroah-Hartman
maintainerPATCH 362/451 f2fs: fix to avoid updating zero-sized extent in extent cache
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit 7c37c79510329cd951a4dedf3f7bf7e2b18dccec ]
As syzbot reported:
F2FS-fs (loop0): __update_extent_tree_range: extent len is zero, type: 0, extent [0, 0, 0], age [0, 0]
------------[ cut here ]------------ kernel BUG at fs/f2fs/extent_cache.c:678! Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI CPU: 0 UID: 0 PID: 5336 Comm: syz.0.0 Not tainted syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 RIP: 0010:__update_extent_tree_range+0x13bc/0x1500 fs/f2fs/extent_cache.c:678 Call Trace: <TASK> f2fs_update_read_extent_cache_range+0x192/0x3e0 fs/f2fs/extent_cache.c:1085 f2fs_do_zero_range fs/f2fs/file.c:1657 [inline] f2fs_zero_range+0x10c1/0x1580 fs/f2fs/file.c:1737 f2fs_fallocate+0x583/0x990 fs/f2fs/file.c:2030 vfs_fallocate+0x669/0x7e0 fs/open.c:342 ioctl_preallocate fs/ioctl.c:289 [inline] file_ioctl+0x611/0x780 fs/ioctl.c:-1 do_vfs_ioctl+0xb33/0x1430 fs/ioctl.c:576 __do_sys_ioctl fs/ioctl.c:595 [inline] __se_sys_ioctl+0x82/0x170 fs/ioctl.c:583 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0x3b0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f07bc58eec9
In error path of f2fs_zero_range(), it may add a zero-sized extent into extent cache, it should be avoided.
--- fs/f2fs/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/file.c +2 -1
@@ -1458,7 +1458,8 @@ static int f2fs_do_zero_range(struct dnof2fs_set_data_blkaddr (dn); } -f2fs_update_extent_cache_range (dn, start,0 , index - start); +if (index > start) +f2fs_update_extent_cache_range (dn, start,0 , index - start);return ret; }
Greg Kroah-Hartman
maintainerPATCH 363/451 usb: dwc3: keep susphy enabled during exit to avoid controller faults
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Udipto Goswami <[email protected]>
[ Upstream commit e1003aa7ec9eccdde4c926bd64ef42816ad55f25 ]
On some platforms, switching USB roles from host to device can trigger controller faults due to premature PHY power-down. This occurs when the PHY is disabled too early during teardown, causing synchronization issues between the PHY and controller.
Keep susphy enabled during dwc3_host_exit() and dwc3_gadget_exit() ensures the PHY remains in a low-power state capable of handling required commands during role switch.
--- drivers/usb/dwc3/gadget.c | 2 +- drivers/usb/dwc3/host.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/usb/dwc3/gadget.c +1 -1
@@ -4109,7 +4109,7 @@ void dwc3_gadget_exit(struct dwc3 *dwc)if (!dwc->gadget)return ; -dwc3_enable_susphy (dwc, false); +dwc3_enable_susphy (dwc, true);usb_del_gadget (dwc->gadget);dwc3_gadget_free_endpoints (dwc);usb_put_gadget (dwc->gadget);
drivers/usb/dwc3/host.c +1 -1
@@ -155,7 +155,7 @@ err:void dwc3_host_exit (struct dwc3 *dwc) { -dwc3_enable_susphy (dwc, false); +dwc3_enable_susphy (dwc, true);platform_device_unregister (dwc->xhci); dwc->xhci =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 364/451 mptcp: pm: ignore unknown endpoint flags
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Matthieu Baerts (NGI0)" <[email protected]>
[ Upstream commit 0ace3297a7301911e52d8195cb1006414897c859 ]
Before this patch, the kernel was saving any flags set by the userspace, even unknown ones. This doesn't cause critical issues because the kernel is only looking at specific ones. But on the other hand, endpoints dumps could tell the userspace some recent flags seem to be supported on older kernel versions.
Instead, ignore all unknown flags when parsing them. By doing that, the userspace can continue to set unsupported flags, but it has a way to verify what is supported by the kernel.
Note that it sounds better to continue accepting unsupported flags not to change the behaviour, but also that eases things on the userspace side by adding "optional" endpoint types only supported by newer kernel versions without having to deal with the different kernel versions.
A note for the backports: there will be conflicts in mptcp.h on older versions not having the mentioned flags, the new line should still be added last, and the '5' needs to be adapted to have the same value as the last entry.
--- include/uapi/linux/mptcp.h | 1 + net/mptcp/pm_netlink.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
include/uapi/linux/mptcp.h +1 -0
@@ -72,6 +72,7 @@ enum {#define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0)#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1)#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2) +#define MPTCP_PM_ADDR_FLAGS_MASK GENMASK(2, 0)enum {MPTCP_PM_CMD_UNSPEC ,
net/mptcp/pm_netlink.c +2 -1
@@ -721,7 +721,8 @@ skip_family: entry->addr.id =nla_get_u8 (tb[MPTCP_PM_ADDR_ATTR_ID ]);if (tb[MPTCP_PM_ADDR_ATTR_FLAGS ]) - entry->addr.flags =nla_get_u32 (tb[MPTCP_PM_ADDR_ATTR_FLAGS ]); + entry->addr.flags =nla_get_u32 (tb[MPTCP_PM_ADDR_ATTR_FLAGS ]) & +MPTCP_PM_ADDR_FLAGS_MASK ;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 365/451 usb: ohci-nxp: Use helper function devm_clk_get_enabled()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Zekun <[email protected]>
[ Upstream commit c146ede472717f352b7283a525bd9a1a2b15e2cf ]
devm_clk_get() and clk_prepare_enable() can be replaced by helper function devm_clk_get_enabled(). Let's use devm_clk_get_enabled() to simplify code and avoid calling clk_disable_unprepare().
Stable-dep-of: b4c61e542faf ("usb: ohci-nxp: fix device leak on probe failure")
--- drivers/usb/host/ohci-nxp.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-)
drivers/usb/host/ohci-nxp.c +4 -14
@@ -51,8 +51,6 @@ static struct hc_driver __read_mostly ohstatic struct i2c_client *isp1301_i2c_client; -static struct clk *usb_host_clk; -static void isp1301_configure_lpc32xx (void ) {/* LPC32XX only supports DAT_SE0 USB mode */
@@ -155,6 +153,7 @@ static int ohci_hcd_nxp_probe(struct plastruct resource *res;int ret =0 , irq;struct device_node *isp1301_node; +struct clk *usb_host_clk;if (pdev->dev.of_node) { isp1301_node = of_parse_phandle(pdev->dev.of_node,
@@ -180,26 +179,20 @@ static int ohci_hcd_nxp_probe(struct pla }/* Enable USB host clock */ - usb_host_clk =devm_clk_get (&pdev->dev,NULL ); + usb_host_clk =devm_clk_get_enabled (&pdev->dev,NULL );if (IS_ERR (usb_host_clk)) { -dev_err (&pdev->dev,"failed to acquire USB OHCI clock\n" ); +dev_err (&pdev->dev,"failed to acquire and start USB OHCI clock\n" ); ret =PTR_ERR (usb_host_clk); goto fail_disable; } - ret =clk_prepare_enable (usb_host_clk); -if (ret <0 ) { -dev_err (&pdev->dev,"failed to start USB OHCI clock\n" ); - goto fail_disable; - } -isp1301_configure (); hcd =usb_create_hcd (driver, &pdev->dev,dev_name (&pdev->dev));if (!hcd) {dev_err (&pdev->dev,"Failed to allocate HC buffer\n" ); ret = -ENOMEM ; - goto fail_hcd; + goto fail_disable; } res =platform_get_resource (pdev,IORESOURCE_MEM ,0 );
@@ -230,8 +223,6 @@ static int ohci_hcd_nxp_probe(struct plaohci_nxp_stop_hc (); fail_resource:usb_put_hcd (hcd); -fail_hcd: -clk_disable_unprepare (usb_host_clk); fail_disable: isp1301_i2c_client =NULL ;return ret;
@@ -244,7 +235,6 @@ static int ohci_hcd_nxp_remove(struct plusb_remove_hcd (hcd);ohci_nxp_stop_hc ();usb_put_hcd (hcd); -clk_disable_unprepare (usb_host_clk); isp1301_i2c_client =NULL ;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 366/451 usb: ohci-nxp: fix device leak on probe failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit b4c61e542faf8c9131d69ecfc3ad6de96d1b2ab8 ]
Make sure to drop the reference taken when looking up the PHY I2C device during probe on probe failure (e.g. probe deferral) and on driver unbind.
--- drivers/usb/host/ohci-nxp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/host/ohci-nxp.c +2 -0
@@ -224,6 +224,7 @@ static int ohci_hcd_nxp_probe(struct pla fail_resource:usb_put_hcd (hcd); fail_disable: +put_device (&isp1301_i2c_client->dev); isp1301_i2c_client =NULL ;return ret; }
@@ -235,6 +236,7 @@ static int ohci_hcd_nxp_remove(struct plusb_remove_hcd (hcd);ohci_nxp_stop_hc ();usb_put_hcd (hcd); +put_device (&isp1301_i2c_client->dev); isp1301_i2c_client =NULL ;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 367/451 jbd2: fix the inconsistency between checksum and data in memory for journal sb
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Bin <[email protected]>
[ Upstream commit 6abfe107894af7e8ce3a2e120c619d81ee764ad5 ]
Copying the file system while it is mounted as read-only results in a mount failure:
[~]# mkfs.ext4 -F /dev/sdc
[~]# mount /dev/sdc -o ro /mnt/test
[~]# dd if=/dev/sdc of=/dev/sda bs=1M
[~]# mount /dev/sda /mnt/test1
[ 1094.849826] JBD2: journal checksum error [ 1094.850927] EXT4-fs (sda): Could not load journal inode
mount: mount /dev/sda on /mnt/test1 failed: Bad message
The process described above is just an abstracted way I came up with to reproduce the issue. In the actual scenario, the file system was mounted read-only and then copied while it was still mounted. It was found that the mount operation failed. The user intended to verify the data or use it as a backup, and this action was performed during a version upgrade. Above issue may happen as follows:ext4_fill_super
set_journal_csum_feature_set(sb)
if (ext4_has_metadata_csum(sb))
incompat = JBD2_FEATURE_INCOMPAT_CSUM_V3;
if (test_opt(sb, JOURNAL_CHECKSUM)
jbd2_journal_set_features(sbi->s_journal, compat, 0, incompat);
lock_buffer(journal->j_sb_buffer);
sb->s_feature_incompat |= cpu_to_be32(incompat);
//The data in the journal sb was modified, but the checksum was not
updated, so the data remaining in memory has a mismatch between the
data and the checksum.
unlock_buffer(journal->j_sb_buffer);In this case, the journal sb copied over is in a state where the checksum and data are inconsistent, so mounting fails.
To solve the above issue, update the checksum in memory after modifying the journal sb.
Message-ID: <[email protected]>
--- fs/jbd2/journal.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/jbd2/journal.c +14 -0
@@ -2224,6 +2224,12 @@ int jbd2_journal_set_features(journal_t sb->s_feature_compat |=cpu_to_be32 (compat); sb->s_feature_ro_compat |=cpu_to_be32 (ro); sb->s_feature_incompat |=cpu_to_be32 (incompat); +/* +* Update the checksum now so that it is valid even for read-only +* filesystems where jbd2_write_superblock() doesn't get called. +*/ +if (jbd2_journal_has_csum_v2or3 (journal)) + sb->s_checksum =jbd2_superblock_csum (journal, sb);unlock_buffer (journal->j_sb_buffer); journal->j_revoke_records_per_block =journal_revoke_records_per_block (journal);
@@ -2254,9 +2260,17 @@ void jbd2_journal_clear_features(journal sb = journal->j_superblock; +lock_buffer (journal->j_sb_buffer); sb->s_feature_compat &= ~cpu_to_be32 (compat); sb->s_feature_ro_compat &= ~cpu_to_be32 (ro); sb->s_feature_incompat &= ~cpu_to_be32 (incompat); +/* +* Update the checksum now so that it is valid even for read-only +* filesystems where jbd2_write_superblock() doesn't get called. +*/ +if (jbd2_journal_has_csum_v2or3 (journal)) + sb->s_checksum =jbd2_superblock_csum (journal, sb); +unlock_buffer (journal->j_sb_buffer); journal->j_revoke_records_per_block =journal_revoke_records_per_block (journal); }
Greg Kroah-Hartman
maintainerPATCH 341/451 console: Delete dummy con_font_set() and con_font_default() callback implementations
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peilin Ye <[email protected]>
commit 259a252c1f4e19045b06660f81014fb51e17f3f6 upstream.
.con_font_set and .con_font_default callbacks should not pass struct console_font * as a parameter, since struct console_font is a UAPI structure.
We are trying to let them use our new kernel font descriptor, struct font_desc instead. To make that work slightly easier, first delete all of their no-op implementations used by dummy consoles.
This will make KD_FONT_OP_SET and KD_FONT_OP_SET_DEFAULT ioctl() requests on dummy consoles start to fail and return -ENOSYS, which is intended, since no user should ever expect such operations to succeed on dummy consoles.
--- drivers/usb/misc/sisusbvga/sisusb_con.c | 15 --------------- drivers/video/console/dummycon.c | 14 -------------- 2 files changed, 29 deletions(-)
drivers/usb/misc/sisusbvga/sisusb_con.c +0 -15
@@ -1345,19 +1345,6 @@ static int sisusbdummycon_blank(struct vreturn 0 ; } -static int sisusbdummycon_font_set (struct vc_data *vc, -struct console_font *font, -unsigned int flags) -{ -return 0 ; -} - -static int sisusbdummycon_font_default (struct vc_data *vc, -struct console_font *font,char *name) -{ -return 0 ; -} -static const struct consw sisusb_dummy_con = { .owner =THIS_MODULE , .con_startup = sisusbdummycon_startup,
@@ -1370,8 +1357,6 @@ static const struct consw sisusb_dummy_c .con_scroll = sisusbdummycon_scroll, .con_switch = sisusbdummycon_switch, .con_blank = sisusbdummycon_blank, - .con_font_set = sisusbdummycon_font_set, - .con_font_default = sisusbdummycon_font_default, };int
drivers/video/console/dummycon.c +0 -14
@@ -124,18 +124,6 @@ static int dummycon_switch(struct vc_datreturn 0 ; } -static int dummycon_font_set (struct vc_data *vc,struct console_font *font, -unsigned int flags) -{ -return 0 ; -} - -static int dummycon_font_default (struct vc_data *vc, -struct console_font *font,char *name) -{ -return 0 ; -} -/* * The console `switch' structure for the dummy console *
@@ -154,7 +142,5 @@ const struct consw dummy_con = { .con_scroll = dummycon_scroll, .con_switch = dummycon_switch, .con_blank = dummycon_blank, - .con_font_set = dummycon_font_set, - .con_font_default = dummycon_font_default, };EXPORT_SYMBOL_GPL (dummy_con);
Greg Kroah-Hartman
maintainerPATCH 368/451 tpm: Cap the number of PCR banks
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Sakkinen <[email protected]>
[ Upstream commit faf07e611dfa464b201223a7253e9dc5ee0f3c9e ]
tpm2_get_pcr_allocation() does not cap any upper limit for the number of banks. Cap the limit to eight banks so that out of bounds values coming from external I/O cause on only limited harm.
--- drivers/char/tpm/tpm-chip.c | 1 - drivers/char/tpm/tpm1-cmd.c | 5 ----- drivers/char/tpm/tpm2-cmd.c | 8 +++----- include/linux/tpm.h | 9 ++++++--- 4 files changed, 9 insertions(+), 14 deletions(-)
drivers/char/tpm/tpm-chip.c +0 -1
@@ -269,7 +269,6 @@ static void tpm_dev_release(struct devickfree (chip->work_space.context_buf);kfree (chip->work_space.session_buf); -kfree (chip->allocated_banks);kfree (chip); }
drivers/char/tpm/tpm1-cmd.c +0 -5
@@ -794,11 +794,6 @@ int tpm1_pm_suspend(struct tpm_chip *chi*/ int tpm1_get_pcr_allocation (struct tpm_chip *chip) { - chip->allocated_banks =kcalloc (1 ,sizeof (*chip->allocated_banks), -GFP_KERNEL ); -if (!chip->allocated_banks) -return -ENOMEM ; - chip->allocated_banks[0 ].alg_id =TPM_ALG_SHA1 ; chip->allocated_banks[0 ].digest_size = hash_digest_size[HASH_ALGO_SHA1 ]; chip->allocated_banks[0 ].crypto_id =HASH_ALGO_SHA1 ;
drivers/char/tpm/tpm2-cmd.c +3 -5
@@ -574,11 +574,9 @@ ssize_t tpm2_get_pcr_allocation(struct t nr_possible_banks =be32_to_cpup ( (__be32 *)&buf.data[TPM_HEADER_SIZE +5 ]); - - chip->allocated_banks =kcalloc (nr_possible_banks, -sizeof (*chip->allocated_banks), -GFP_KERNEL ); -if (!chip->allocated_banks) { +if (nr_possible_banks >TPM2_MAX_PCR_BANKS ) { +pr_err ("tpm: out of bank capacity: %u > %u\n" , + nr_possible_banks,TPM2_MAX_PCR_BANKS ); rc = -ENOMEM ; goto out; }
include/linux/tpm.h +6 -3
@@ -25,7 +25,10 @@#include <crypto/hash_info.h> #define TPM_DIGEST_SIZE 20/* Max TPM v1.2 PCR size */ -#define TPM_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE + +#define TPM2_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE +#define TPM2_MAX_PCR_BANKS 8 +#define TPM_MAX_DIGEST_SIZE TPM2_MAX_DIGEST_SIZEstruct tpm_chip ;struct trusted_key_payload ;
@@ -44,7 +47,7 @@ enum tpm_algorithms {struct tpm_digest {u16 alg_id; -u8 digest[TPM_MAX_DIGEST_SIZE ]; +u8 digest[TPM2_MAX_DIGEST_SIZE ]; } __packed;struct tpm_bank_info {
@@ -150,7 +153,7 @@ struct tpm_chip {unsigned int groups_cnt;u32 nr_allocated_banks; -struct tpm_bank_info *allocated_banks; +struct tpm_bank_info allocated_banks[TPM2_MAX_PCR_BANKS ];#ifdef CONFIG_ACPI acpi_handle acpi_dev_handle;char ppi_version[TPM_PPI_VERSION_LEN +1 ];
Greg Kroah-Hartman
maintainerPATCH 369/451 NFSD: Clear SECLABEL in the suppattr_exclcreat bitmap
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 27d17641cacfedd816789b75d342430f6b912bd2 ]
Quoted 1 line
Quoted 1 line
From RFC 8881:
5.8.1.14. Attribute 75: suppattr_exclcreat
Quoted 4 lines
The bit vector that would set all REQUIRED and RECOMMENDED attributes that are supported by the
EXCLUSIVE4_1method of file creation via the OPEN operation. The scope of this attribute applies to all objects with a matching fsid.
There's nothing in RFC 8881 that states that suppattr_exclcreat is or is not allowed to contain bits for attributes that are clear in the reported supported_attrs bitmask. But it doesn't make sense for an NFS server to indicate that it /doesn't/ implement an attribute, but then also indicate that clients /are/ allowed to set that attribute using OPEN(create) with EXCLUSIVE4_1.
Ensure that the SECURITY_LABEL and ACL bits are not set in the suppattr_exclcreat bitmask when they are also not set in the supported_attrs bitmask.
--- fs/nfsd/nfs4xdr.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/nfsd/nfs4xdr.c +5 -0
@@ -3408,6 +3408,11 @@ out_acl:u32 supp[3 ];memcpy (supp, nfsd_suppattrs[minorversion],sizeof (supp)); +if (!IS_POSIXACL (d_inode (dentry))) + supp[0 ] &= ~FATTR4_WORD0_ACL ; +if (!contextsupport) + supp[2 ] &= ~FATTR4_WORD2_SECURITY_LABEL ; + supp[0 ] &=NFSD_SUPPATTR_EXCLCREAT_WORD0 ; supp[1 ] &=NFSD_SUPPATTR_EXCLCREAT_WORD1 ; supp[2 ] &=NFSD_SUPPATTR_EXCLCREAT_WORD2 ;
Greg Kroah-Hartman
maintainerPATCH 370/451 SUNRPC: svcauth_gss: avoid NULL deref on zero length gss_token in gss_read_proxy_verf
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joshua Rogers <[email protected]>
[ Upstream commit d4b69a6186b215d2dc1ebcab965ed88e8d41768d ]
A zero length gss_token results in pages == 0 and in_token->pages[0] is NULL. The code unconditionally evaluates page_address(in_token->pages[0]) for the initial memcpy, which can dereference NULL even when the copy length is 0. Guard the first memcpy so it only runs when length > 0.
--- net/sunrpc/auth_gss/svcauth_gss.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sunrpc/auth_gss/svcauth_gss.c +2 -1
@@ -1177,7 +1177,8 @@ static int gss_read_proxy_verf(struct sv } length = min_t(unsigned int, inlen, argv->iov_len); -memcpy (page_address (in_token->pages[0 ]), argv->iov_base, length); +if (length) +memcpy (page_address (in_token->pages[0 ]), argv->iov_base, length); inlen -= length; to_offs = length;
Greg Kroah-Hartman
maintainerPATCH 371/451 hwmon: replace snprintf in show functions with sysfs_emit
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guenter Roeck <[email protected]>
[ Upstream commit 1f4d4af4d7a1c794a4f003f75fcfd38fafb5dff3 ]
coccicheck complains about the use of snprintf() in sysfs show functions.
drivers/hwmon/ina3221.c:701:8-16: WARNING: use scnprintf or sprintf
This results in a large number of patch submissions. Fix it all in one go using the following coccinelle rules. Use sysfs_emit instead of scnprintf or sprintf since that makes more sense.
@depends on patch@
identifier show, dev, attr, buf;
@@
ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
return
- snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \),
+ sysfs_emit(buf,
...);
...>
}@depends on patch@
identifier show, dev, attr, buf, rc;
@@
ssize_t show(struct device *dev, struct device_attribute *attr, char *buf)
{
<...
rc =
- snprintf(buf, \( PAGE_SIZE \| PAGE_SIZE - 1 \),
+ sysfs_emit(buf,
...);
...>
}While at it, remove unnecessary braces and as well as unnecessary else after return statements to address checkpatch warnings in the resulting patch.
Stable-dep-of: b8d5acdcf525 ("hwmon: (max16065) Use local variable to avoid TOCTOU")
--- drivers/hwmon/applesmc.c | 34 +++++++++--------- drivers/hwmon/ina209.c | 6 +-- drivers/hwmon/ina2xx.c | 2 - drivers/hwmon/ina3221.c | 2 - drivers/hwmon/lineage-pem.c | 8 ++-- drivers/hwmon/ltc2945.c | 4 +- drivers/hwmon/ltc2990.c | 2 - drivers/hwmon/ltc4151.c | 2 - drivers/hwmon/ltc4215.c | 8 ++-- drivers/hwmon/ltc4222.c | 4 +- drivers/hwmon/ltc4260.c | 4 +- drivers/hwmon/ltc4261.c | 4 +- drivers/hwmon/max16065.c | 14 +++---- drivers/hwmon/occ/common.c | 69 ++++++++++++++++++------------------- drivers/hwmon/occ/sysfs.c | 4 +- drivers/hwmon/pmbus/inspur-ipsps.c | 28 +++++++-------- drivers/hwmon/pmbus/pmbus_core.c | 8 ++-- drivers/hwmon/s3c-hwmon.c | 4 +- drivers/hwmon/sch5627.c | 24 ++++++------ drivers/hwmon/sch5636.c | 20 +++++----- drivers/hwmon/smm665.c | 4 +- drivers/hwmon/stts751.c | 20 +++++----- drivers/hwmon/vexpress-hwmon.c | 12 +++--- drivers/hwmon/xgene-hwmon.c | 14 +++---- 24 files changed, 151 insertions(+), 150 deletions(-)
drivers/hwmon/applesmc.c +17 -17
@@ -741,7 +741,7 @@ static void applesmc_idev_poll(struct instatic ssize_t applesmc_name_show (struct device *dev,struct device_attribute *attr,char *buf) { -return snprintf (buf,PAGE_SIZE ,"applesmc\n" ); +return sysfs_emit (buf,"applesmc\n" ); } static ssize_t applesmc_position_show(struct device *dev,
@@ -763,8 +763,8 @@ static ssize_t applesmc_position_show(st out:if (ret)return ret; -else -return snprintf (buf,PAGE_SIZE ,"(%d,%d,%d)\n" , x, y, z); + +return sysfs_emit (buf,"(%d,%d,%d)\n" , x, y, z); } static ssize_t applesmc_light_show(struct device *dev,
@@ -804,8 +804,8 @@ static ssize_t applesmc_light_show(struc out:if (ret)return ret; -else -return snprintf (sysfsbuf,PAGE_SIZE ,"(%d,%d)\n" , left, right); + +return sysfs_emit (sysfsbuf,"(%d,%d)\n" , left, right); }/* Displays sensor key as label */
@@ -814,7 +814,7 @@ static ssize_t applesmc_show_sensor_labe {const char *key = smcreg.index[to_index (devattr)]; -return snprintf (sysfsbuf,PAGE_SIZE ,"%s\n" , key); +return sysfs_emit (sysfsbuf,"%s\n" , key); }/* Displays degree Celsius * 1000 */
@@ -832,7 +832,7 @@ static ssize_t applesmc_show_temperature temp =250 * (value >>6 ); -return snprintf (sysfsbuf,PAGE_SIZE ,"%d\n" , temp); +return sysfs_emit (sysfsbuf,"%d\n" , temp); } static ssize_t applesmc_show_fan_speed(struct device *dev,
@@ -851,7 +851,7 @@ static ssize_t applesmc_show_fan_speed(sreturn ret; speed = ((buffer[0 ] <<8 | buffer[1 ]) >>2 ); -return snprintf (sysfsbuf,PAGE_SIZE ,"%u\n" , speed); +return sysfs_emit (sysfsbuf,"%u\n" , speed); } static ssize_t applesmc_store_fan_speed(struct device *dev,
@@ -891,7 +891,7 @@ static ssize_t applesmc_show_fan_manual(return ret; manual = ((buffer[0 ] <<8 | buffer[1 ]) >>to_index (attr)) &0x01 ; -return snprintf (sysfsbuf,PAGE_SIZE ,"%d\n" , manual); +return sysfs_emit (sysfsbuf,"%d\n" , manual); } static ssize_t applesmc_store_fan_manual(struct device *dev,
@@ -943,14 +943,14 @@ static ssize_t applesmc_show_fan_positioif (ret)return ret; -else -return snprintf (sysfsbuf,PAGE_SIZE ,"%s\n" , buffer+4 ); + +return sysfs_emit (sysfsbuf,"%s\n" , buffer +4 ); }static ssize_t applesmc_calibrate_show (struct device *dev,struct device_attribute *attr,char *sysfsbuf) { -return snprintf (sysfsbuf,PAGE_SIZE ,"(%d,%d)\n" , rest_x, rest_y); +return sysfs_emit (sysfsbuf,"(%d,%d)\n" , rest_x, rest_y); } static ssize_t applesmc_calibrate_store(struct device *dev,
@@ -992,7 +992,7 @@ static ssize_t applesmc_key_count_show(s count = ((u32 )buffer[0 ]<<24 ) + ((u32 )buffer[1 ]<<16 ) + ((u32 )buffer[2 ]<<8 ) + buffer[3 ]; -return snprintf (sysfsbuf,PAGE_SIZE ,"%d\n" , count); +return sysfs_emit (sysfsbuf,"%d\n" , count); } static ssize_t applesmc_key_at_index_read_show(struct device *dev,
@@ -1020,7 +1020,7 @@ static ssize_t applesmc_key_at_index_datif (IS_ERR (entry))return PTR_ERR (entry); -return snprintf (sysfsbuf,PAGE_SIZE ,"%d\n" , entry->len); +return sysfs_emit (sysfsbuf,"%d\n" , entry->len); } static ssize_t applesmc_key_at_index_type_show(struct device *dev,
@@ -1032,7 +1032,7 @@ static ssize_t applesmc_key_at_index_typif (IS_ERR (entry))return PTR_ERR (entry); -return snprintf (sysfsbuf,PAGE_SIZE ,"%s\n" , entry->type); +return sysfs_emit (sysfsbuf,"%s\n" , entry->type); } static ssize_t applesmc_key_at_index_name_show(struct device *dev,
@@ -1044,13 +1044,13 @@ static ssize_t applesmc_key_at_index_namif (IS_ERR (entry))return PTR_ERR (entry); -return snprintf (sysfsbuf,PAGE_SIZE ,"%s\n" , entry->key); +return sysfs_emit (sysfsbuf,"%s\n" , entry->key); }static ssize_t applesmc_key_at_index_show (struct device *dev,struct device_attribute *attr,char *sysfsbuf) { -return snprintf (sysfsbuf,PAGE_SIZE ,"%d\n" , key_at_index); +return sysfs_emit (sysfsbuf,"%d\n" , key_at_index); } static ssize_t applesmc_key_at_index_store(struct device *dev,
drivers/hwmon/ina209.c +3 -3
@@ -259,7 +259,7 @@ static ssize_t ina209_interval_show(stru {struct ina209_data *data =dev_get_drvdata (dev); -return snprintf (buf,PAGE_SIZE ,"%d\n" , data->update_interval); +return sysfs_emit (buf,"%d\n" , data->update_interval); }/*
@@ -343,7 +343,7 @@ static ssize_t ina209_value_show(structreturn PTR_ERR (data); val =ina209_from_reg (attr->index, data->regs[attr->index]); -return snprintf (buf,PAGE_SIZE ,"%ld\n" , val); +return sysfs_emit (buf,"%ld\n" , val); } static ssize_t ina209_alarm_show(struct device *dev,
@@ -363,7 +363,7 @@ static ssize_t ina209_alarm_show(struct* All alarms are in the INA209_STATUS register. To avoid a long * switch statement, the mask is passed in attr->index */ -return snprintf (buf,PAGE_SIZE ,"%u\n" , !!(status & mask)); +return sysfs_emit (buf,"%u\n" , !!(status & mask)); }/* Shunt voltage, history, limits, alarms */
drivers/hwmon/ina2xx.c +1 -1
@@ -386,7 +386,7 @@ static ssize_t ina226_alert_show(struct val =ina226_reg_to_alert (data, attr->index, regval); } - ret =snprintf (buf,PAGE_SIZE ,"%d\n" , val); + ret =sysfs_emit (buf,"%d\n" , val); abort:mutex_unlock (&data->config_lock);return ret;
drivers/hwmon/ina3221.c +1 -1
@@ -698,7 +698,7 @@ static ssize_t ina3221_shunt_show(structunsigned int channel = sd_attr->index;struct ina3221_input *input = &ina->inputs[channel]; -return snprintf (buf,PAGE_SIZE ,"%d\n" , input->shunt_resistor); +return sysfs_emit (buf,"%d\n" , input->shunt_resistor); } static ssize_t ina3221_shunt_store(struct device *dev,
drivers/hwmon/lineage-pem.c +4 -4
@@ -280,7 +280,7 @@ static ssize_t pem_bool_show(struct devireturn PTR_ERR (data); status = data->data_string[attr->nr] & attr->index; -return snprintf (buf,PAGE_SIZE ,"%d\n" , !!status); +return sysfs_emit (buf,"%d\n" , !!status); } static ssize_t pem_data_show(struct device *dev, struct device_attribute *da,
@@ -296,7 +296,7 @@ static ssize_t pem_data_show(struct devi value =pem_get_data (data->data_string,sizeof (data->data_string), attr->index); -return snprintf (buf,PAGE_SIZE ,"%ld\n" , value); +return sysfs_emit (buf,"%ld\n" , value); } static ssize_t pem_input_show(struct device *dev, struct device_attribute *da,
@@ -312,7 +312,7 @@ static ssize_t pem_input_show(struct dev value =pem_get_input (data->input_string,sizeof (data->input_string), attr->index); -return snprintf (buf,PAGE_SIZE ,"%ld\n" , value); +return sysfs_emit (buf,"%ld\n" , value); } static ssize_t pem_fan_show(struct device *dev, struct device_attribute *da,
@@ -328,7 +328,7 @@ static ssize_t pem_fan_show(struct devic value =pem_get_fan (data->fan_speed,sizeof (data->fan_speed), attr->index); -return snprintf (buf,PAGE_SIZE ,"%ld\n" , value); +return sysfs_emit (buf,"%ld\n" , value); }/* Voltages */
drivers/hwmon/ltc2945.c +2 -2
@@ -226,7 +226,7 @@ static ssize_t ltc2945_value_show(struct value =ltc2945_reg_to_val (dev, attr->index);if (value <0 )return value; -return snprintf (buf,PAGE_SIZE ,"%lld\n" , value); +return sysfs_emit (buf,"%lld\n" , value); } static ssize_t ltc2945_value_store(struct device *dev,
@@ -335,7 +335,7 @@ static ssize_t ltc2945_bool_show(structif (fault)/* Clear reported faults in chip register */ regmap_update_bits (regmap,LTC2945_FAULT , attr->index,0 ); -return snprintf (buf,PAGE_SIZE ,"%d\n" , !!fault); +return sysfs_emit (buf,"%d\n" , !!fault); }/* Input voltages */
drivers/hwmon/ltc2990.c +1 -1
@@ -147,7 +147,7 @@ static ssize_t ltc2990_value_show(structif (unlikely (ret <0 ))return ret; -return snprintf (buf,PAGE_SIZE ,"%d\n" , value); +return sysfs_emit (buf,"%d\n" , value); } static umode_t ltc2990_attrs_visible(struct kobject *kobj,
drivers/hwmon/ltc4151.c +1 -1
@@ -128,7 +128,7 @@ static ssize_t ltc4151_value_show(structreturn PTR_ERR (data); value =ltc4151_get_value (data, attr->index); -return snprintf (buf,PAGE_SIZE ,"%d\n" , value); +return sysfs_emit (buf,"%d\n" , value); }/*
drivers/hwmon/ltc4215.c +4 -4
@@ -139,7 +139,7 @@ static ssize_t ltc4215_voltage_show(strustruct sensor_device_attribute *attr =to_sensor_dev_attr (da);const int voltage =ltc4215_get_voltage (dev, attr->index); -return snprintf (buf,PAGE_SIZE ,"%d\n" , voltage); +return sysfs_emit (buf,"%d\n" , voltage); } static ssize_t ltc4215_current_show(struct device *dev,
@@ -147,7 +147,7 @@ static ssize_t ltc4215_current_show(stru {const unsigned int curr =ltc4215_get_current (dev); -return snprintf (buf,PAGE_SIZE ,"%u\n" , curr); +return sysfs_emit (buf,"%u\n" , curr); } static ssize_t ltc4215_power_show(struct device *dev,
@@ -159,7 +159,7 @@ static ssize_t ltc4215_power_show(struct/* current in mA * voltage in mV == power in uW */ const unsigned int power =abs (output_voltage * curr); -return snprintf (buf,PAGE_SIZE ,"%u\n" , power); +return sysfs_emit (buf,"%u\n" , power); } static ssize_t ltc4215_alarm_show(struct device *dev,
@@ -170,7 +170,7 @@ static ssize_t ltc4215_alarm_show(structconst u8 reg = data->regs[LTC4215_STATUS ];const u32 mask = attr->index; -return snprintf (buf,PAGE_SIZE ,"%u\n" , !!(reg & mask)); +return sysfs_emit (buf,"%u\n" , !!(reg & mask)); }/*
drivers/hwmon/ltc4222.c +2 -2
@@ -94,7 +94,7 @@ static ssize_t ltc4222_value_show(struct value =ltc4222_get_value (dev, attr->index);if (value <0 )return value; -return snprintf (buf,PAGE_SIZE ,"%d\n" , value); +return sysfs_emit (buf,"%d\n" , value); } static ssize_t ltc4222_bool_show(struct device *dev,
@@ -112,7 +112,7 @@ static ssize_t ltc4222_bool_show(structif (fault)/* Clear reported faults in chip register */ regmap_update_bits (regmap, attr->nr, attr->index,0 ); -return snprintf (buf,PAGE_SIZE ,"%d\n" , !!fault); +return sysfs_emit (buf,"%d\n" , !!fault); }/* Voltages */
drivers/hwmon/ltc4260.c +2 -2
@@ -79,7 +79,7 @@ static ssize_t ltc4260_value_show(struct value =ltc4260_get_value (dev, attr->index);if (value <0 )return value; -return snprintf (buf,PAGE_SIZE ,"%d\n" , value); +return sysfs_emit (buf,"%d\n" , value); } static ssize_t ltc4260_bool_show(struct device *dev,
@@ -98,7 +98,7 @@ static ssize_t ltc4260_bool_show(structif (fault)/* Clear reported faults in chip register */ regmap_update_bits (regmap,LTC4260_FAULT , attr->index,0 ); -return snprintf (buf,PAGE_SIZE ,"%d\n" , !!fault); +return sysfs_emit (buf,"%d\n" , !!fault); }/* Voltages */
drivers/hwmon/ltc4261.c +2 -2
@@ -130,7 +130,7 @@ static ssize_t ltc4261_value_show(structreturn PTR_ERR (data); value =ltc4261_get_value (data, attr->index); -return snprintf (buf,PAGE_SIZE ,"%d\n" , value); +return sysfs_emit (buf,"%d\n" , value); } static ssize_t ltc4261_bool_show(struct device *dev,
@@ -147,7 +147,7 @@ static ssize_t ltc4261_bool_show(structif (fault)/* Clear reported faults in chip register */ i2c_smbus_write_byte_data (data->client,LTC4261_FAULT , ~fault); -return snprintf (buf,PAGE_SIZE ,"%d\n" , fault ?1 :0 ); +return sysfs_emit (buf,"%d\n" , fault ?1 :0 ); }/*
drivers/hwmon/max16065.c +7 -7
@@ -195,7 +195,7 @@ static ssize_t max16065_alarm_show(struci2c_smbus_write_byte_data (data->client,MAX16065_FAULT (attr2->nr), val); -return snprintf (buf,PAGE_SIZE ,"%d\n" , !!val); +return sysfs_emit (buf,"%d\n" , !!val); } static ssize_t max16065_input_show(struct device *dev,
@@ -208,8 +208,8 @@ static ssize_t max16065_input_show(strucif (unlikely (adc <0 ))return adc; -return snprintf (buf,PAGE_SIZE ,"%d\n" , -ADC_TO_MV (adc, data->range[attr->index])); +return sysfs_emit (buf,"%d\n" , +ADC_TO_MV (adc, data->range[attr->index])); } static ssize_t max16065_current_show(struct device *dev,
@@ -220,8 +220,8 @@ static ssize_t max16065_current_show(strif (unlikely (data->curr_sense <0 ))return data->curr_sense; -return snprintf (buf,PAGE_SIZE ,"%d\n" , -ADC_TO_CURR (data->curr_sense, data->curr_gain)); +return sysfs_emit (buf,"%d\n" , +ADC_TO_CURR (data->curr_sense, data->curr_gain)); } static ssize_t max16065_limit_store(struct device *dev,
@@ -257,8 +257,8 @@ static ssize_t max16065_limit_show(strucstruct sensor_device_attribute_2 *attr2 =to_sensor_dev_attr_2 (da);struct max16065_data *data =dev_get_drvdata (dev); -return snprintf (buf,PAGE_SIZE ,"%d\n" , - data->limit[attr2->nr][attr2->index]); +return sysfs_emit (buf,"%d\n" , + data->limit[attr2->nr][attr2->index]); }/* Construct a sensor_device_attribute structure for each register */
drivers/hwmon/occ/common.c +35 -34
181 lines not on this page · raw message
drivers/hwmon/occ/sysfs.c +2 -2
@@ -67,7 +67,7 @@ static ssize_t occ_sysfs_show(struct devreturn -EINVAL ; } -return snprintf (buf,PAGE_SIZE -1 ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t occ_error_show(struct device *dev,
@@ -77,7 +77,7 @@ static ssize_t occ_error_show(struct devocc_update_response (occ); -return snprintf (buf,PAGE_SIZE -1 ,"%d\n" , occ->error); +return sysfs_emit (buf,"%d\n" , occ->error); } static SENSOR_DEVICE_ATTR(occ_master, 0444, occ_sysfs_show, NULL, 0);
drivers/hwmon/pmbus/inspur-ipsps.c +14 -14
@@ -70,7 +70,7 @@ static ssize_t ipsps_string_show(struct p =memscan (data,'#' , rc); *p ='\0' ; -return snprintf (buf,PAGE_SIZE ,"%s\n" , data); +return sysfs_emit (buf,"%s\n" , data); } static ssize_t ipsps_fw_version_show(struct device *dev,
@@ -91,9 +91,9 @@ static ssize_t ipsps_fw_version_show(strif (rc !=6 )return -EPROTO ; -return snprintf (buf,PAGE_SIZE ,"%u.%02u%u-%u.%02u\n" , - data[1 ], data[2 ]/* < 100 */ , data[3 ]/*< 10*/ , - data[4 ], data[5 ]/* < 100 */ ); +return sysfs_emit (buf,"%u.%02u%u-%u.%02u\n" , + data[1 ], data[2 ]/* < 100 */ , data[3 ]/*< 10*/ , + data[4 ], data[5 ]/* < 100 */ ); } static ssize_t ipsps_mode_show(struct device *dev,
@@ -111,19 +111,19 @@ static ssize_t ipsps_mode_show(struct deswitch (rc) {case MODE_ACTIVE : -return snprintf (buf,PAGE_SIZE ,"[%s] %s %s\n" , -MODE_ACTIVE_STRING , -MODE_STANDBY_STRING ,MODE_REDUNDANCY_STRING ); +return sysfs_emit (buf,"[%s] %s %s\n" , +MODE_ACTIVE_STRING , +MODE_STANDBY_STRING ,MODE_REDUNDANCY_STRING );case MODE_STANDBY : -return snprintf (buf,PAGE_SIZE ,"%s [%s] %s\n" , -MODE_ACTIVE_STRING , -MODE_STANDBY_STRING ,MODE_REDUNDANCY_STRING ); +return sysfs_emit (buf,"%s [%s] %s\n" , +MODE_ACTIVE_STRING , +MODE_STANDBY_STRING ,MODE_REDUNDANCY_STRING );case MODE_REDUNDANCY : -return snprintf (buf,PAGE_SIZE ,"%s %s [%s]\n" , -MODE_ACTIVE_STRING , -MODE_STANDBY_STRING ,MODE_REDUNDANCY_STRING ); +return sysfs_emit (buf,"%s %s [%s]\n" , +MODE_ACTIVE_STRING , +MODE_STANDBY_STRING ,MODE_REDUNDANCY_STRING );default : -return snprintf (buf,PAGE_SIZE ,"unspecified\n" ); +return sysfs_emit (buf,"unspecified\n" ); } }
drivers/hwmon/pmbus/pmbus_core.c +4 -4
@@ -962,7 +962,7 @@ static ssize_t pmbus_show_boolean(struct val =pmbus_get_boolean (client, boolean, attr->index);if (val <0 )return val; -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t pmbus_show_sensor(struct device *dev,
@@ -978,7 +978,7 @@ static ssize_t pmbus_show_sensor(structif (sensor->data <0 ) ret = sensor->data;else - ret =snprintf (buf,PAGE_SIZE ,"%lld\n" ,pmbus_reg2data (data, sensor)); + ret =sysfs_emit (buf,"%lld\n" ,pmbus_reg2data (data, sensor));mutex_unlock (&data->update_lock);return ret; }
@@ -1014,7 +1014,7 @@ static ssize_t pmbus_show_label(struct d {struct pmbus_label *label =to_pmbus_label (da); -return snprintf (buf,PAGE_SIZE ,"%s\n" , label->label); +return sysfs_emit (buf,"%s\n" , label->label); }static int pmbus_add_attribute (struct pmbus_data *data,struct attribute *attr)
@@ -2054,7 +2054,7 @@ static ssize_t pmbus_show_samples(structif (val <0 )return val; -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t pmbus_set_samples(struct device *dev,
drivers/hwmon/s3c-hwmon.c +2 -2
@@ -166,7 +166,7 @@ static ssize_t s3c_hwmon_ch_show(struct ret *= cfg->mult; ret =DIV_ROUND_CLOSEST (ret, cfg->div); -return snprintf (buf,PAGE_SIZE ,"%d\n" , ret); +return sysfs_emit (buf,"%d\n" , ret); }/**
@@ -187,7 +187,7 @@ static ssize_t s3c_hwmon_label_show(stru cfg = pdata->in[sen_attr->index]; -return snprintf (buf,PAGE_SIZE ,"%s\n" , cfg->name); +return sysfs_emit (buf,"%s\n" , cfg->name); }/**
drivers/hwmon/sch5627.c +12 -12
@@ -195,7 +195,7 @@ static int reg_to_rpm(u16 reg)static ssize_t name_show (struct device *dev,struct device_attribute *devattr,char *buf) { -return snprintf (buf,PAGE_SIZE ,"%s\n" ,DEVNAME ); +return sysfs_emit (buf,"%s\n" ,DEVNAME ); } static ssize_t temp_show(struct device *dev, struct device_attribute *devattr,
@@ -209,7 +209,7 @@ static ssize_t temp_show(struct device *return PTR_ERR (data); val =reg_to_temp (data->temp[attr->index]); -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t temp_fault_show(struct device *dev,
@@ -221,7 +221,7 @@ static ssize_t temp_fault_show(struct deif (IS_ERR (data))return PTR_ERR (data); -return snprintf (buf,PAGE_SIZE ,"%d\n" , data->temp[attr->index] ==0 ); +return sysfs_emit (buf,"%d\n" , data->temp[attr->index] ==0 ); } static ssize_t temp_max_show(struct device *dev,
@@ -232,7 +232,7 @@ static ssize_t temp_max_show(struct deviint val; val =reg_to_temp_limit (data->temp_max[attr->index]); -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t temp_crit_show(struct device *dev,
@@ -243,7 +243,7 @@ static ssize_t temp_crit_show(struct devint val; val =reg_to_temp_limit (data->temp_crit[attr->index]); -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t fan_show(struct device *dev, struct device_attribute *devattr,
@@ -260,7 +260,7 @@ static ssize_t fan_show(struct device *dif (val <0 )return val; -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t fan_fault_show(struct device *dev,
@@ -272,8 +272,8 @@ static ssize_t fan_fault_show(struct devif (IS_ERR (data))return PTR_ERR (data); -return snprintf (buf,PAGE_SIZE ,"%d\n" , - data->fan[attr->index] ==0xffff ); +return sysfs_emit (buf,"%d\n" , + data->fan[attr->index] ==0xffff ); } static ssize_t fan_min_show(struct device *dev,
@@ -285,7 +285,7 @@ static ssize_t fan_min_show(struct devicif (val <0 )return val; -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t in_show(struct device *dev, struct device_attribute *devattr,
@@ -301,7 +301,7 @@ static ssize_t in_show(struct device *de val =DIV_ROUND_CLOSEST ( data->in[attr->index] *SCH5627_REG_IN_FACTOR [attr->index],10000 ); -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t in_label_show(struct device *dev,
@@ -309,8 +309,8 @@ static ssize_t in_label_show(struct devi {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr); -return snprintf (buf,PAGE_SIZE ,"%s\n" , -SCH5627_IN_LABELS [attr->index]); +return sysfs_emit (buf,"%s\n" , +SCH5627_IN_LABELS [attr->index]); }static DEVICE_ATTR_RO (name);
drivers/hwmon/sch5636.c +10 -10
@@ -160,7 +160,7 @@ static int reg_to_rpm(u16 reg)static ssize_t name_show (struct device *dev,struct device_attribute *devattr,char *buf) { -return snprintf (buf,PAGE_SIZE ,"%s\n" ,DEVNAME ); +return sysfs_emit (buf,"%s\n" ,DEVNAME ); } static ssize_t in_value_show(struct device *dev,
@@ -176,7 +176,7 @@ static ssize_t in_value_show(struct devi val =DIV_ROUND_CLOSEST ( data->in[attr->index] *SCH5636_REG_IN_FACTORS [attr->index],255 ); -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t in_label_show(struct device *dev,
@@ -184,8 +184,8 @@ static ssize_t in_label_show(struct devi {struct sensor_device_attribute *attr =to_sensor_dev_attr (devattr); -return snprintf (buf,PAGE_SIZE ,"%s\n" , -SCH5636_IN_LABELS [attr->index]); +return sysfs_emit (buf,"%s\n" , +SCH5636_IN_LABELS [attr->index]); } static ssize_t temp_value_show(struct device *dev,
@@ -199,7 +199,7 @@ static ssize_t temp_value_show(struct dereturn PTR_ERR (data); val = (data->temp_val[attr->index] -64 ) *1000 ; -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t temp_fault_show(struct device *dev,
@@ -213,7 +213,7 @@ static ssize_t temp_fault_show(struct dereturn PTR_ERR (data); val = (data->temp_ctrl[attr->index] &SCH5636_TEMP_WORKING ) ?0 :1 ; -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t temp_alarm_show(struct device *dev,
@@ -227,7 +227,7 @@ static ssize_t temp_alarm_show(struct dereturn PTR_ERR (data); val = (data->temp_ctrl[attr->index] &SCH5636_TEMP_ALARM ) ?1 :0 ; -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t fan_value_show(struct device *dev,
@@ -244,7 +244,7 @@ static ssize_t fan_value_show(struct devif (val <0 )return val; -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t fan_fault_show(struct device *dev,
@@ -258,7 +258,7 @@ static ssize_t fan_fault_show(struct devreturn PTR_ERR (data); val = (data->fan_ctrl[attr->index] &SCH5636_FAN_NOT_PRESENT ) ?1 :0 ; -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t fan_alarm_show(struct device *dev,
@@ -272,7 +272,7 @@ static ssize_t fan_alarm_show(struct devreturn PTR_ERR (data); val = (data->fan_ctrl[attr->index] &SCH5636_FAN_ALARM ) ?1 :0 ; -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); }static struct sensor_device_attribute sch5636_attr[] = {
drivers/hwmon/smm665.c +2 -2
@@ -351,7 +351,7 @@ static ssize_t smm665_show_crit_alarm(stif (data->faults & (1 << attr->index)) val =1 ; -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); } static ssize_t smm665_show_input(struct device *dev,
@@ -366,7 +366,7 @@ static ssize_t smm665_show_input(structreturn PTR_ERR (data); val =smm665_convert (data->adc[adc], adc); -return snprintf (buf,PAGE_SIZE ,"%d\n" , val); +return sysfs_emit (buf,"%d\n" , val); }#define SMM665_SHOW (what) \
drivers/hwmon/stts751.c +10 -10
@@ -387,7 +387,7 @@ static ssize_t max_alarm_show(struct devif (ret <0 )return ret; -return snprintf (buf,PAGE_SIZE ,"%d\n" , priv->max_alert); +return sysfs_emit (buf,"%d\n" , priv->max_alert); } static ssize_t min_alarm_show(struct device *dev,
@@ -404,7 +404,7 @@ static ssize_t min_alarm_show(struct devif (ret <0 )return ret; -return snprintf (buf,PAGE_SIZE ,"%d\n" , priv->min_alert); +return sysfs_emit (buf,"%d\n" , priv->min_alert); } static ssize_t input_show(struct device *dev, struct device_attribute *attr,
@@ -419,7 +419,7 @@ static ssize_t input_show(struct deviceif (ret <0 )return ret; -return snprintf (buf,PAGE_SIZE ,"%d\n" , priv->temp); +return sysfs_emit (buf,"%d\n" , priv->temp); } static ssize_t therm_show(struct device *dev, struct device_attribute *attr,
@@ -427,7 +427,7 @@ static ssize_t therm_show(struct device {struct stts751_priv *priv =dev_get_drvdata (dev); -return snprintf (buf,PAGE_SIZE ,"%d\n" , priv->therm); +return sysfs_emit (buf,"%d\n" , priv->therm); } static ssize_t therm_store(struct device *dev, struct device_attribute *attr,
@@ -469,7 +469,7 @@ static ssize_t hyst_show(struct device * {struct stts751_priv *priv =dev_get_drvdata (dev); -return snprintf (buf,PAGE_SIZE ,"%d\n" , priv->hyst); +return sysfs_emit (buf,"%d\n" , priv->hyst); } static ssize_t hyst_store(struct device *dev, struct device_attribute *attr,
@@ -509,7 +509,7 @@ static ssize_t therm_trip_show(struct deif (ret <0 )return ret; -return snprintf (buf,PAGE_SIZE ,"%d\n" , priv->therm_trip); +return sysfs_emit (buf,"%d\n" , priv->therm_trip); } static ssize_t max_show(struct device *dev, struct device_attribute *attr,
@@ -517,7 +517,7 @@ static ssize_t max_show(struct device *d {struct stts751_priv *priv =dev_get_drvdata (dev); -return snprintf (buf,PAGE_SIZE ,"%d\n" , priv->event_max); +return sysfs_emit (buf,"%d\n" , priv->event_max); } static ssize_t max_store(struct device *dev, struct device_attribute *attr,
@@ -551,7 +551,7 @@ static ssize_t min_show(struct device *d {struct stts751_priv *priv =dev_get_drvdata (dev); -return snprintf (buf,PAGE_SIZE ,"%d\n" , priv->event_min); +return sysfs_emit (buf,"%d\n" , priv->event_min); } static ssize_t min_store(struct device *dev, struct device_attribute *attr,
@@ -585,8 +585,8 @@ static ssize_t interval_show(struct devi {struct stts751_priv *priv =dev_get_drvdata (dev); -return snprintf (buf,PAGE_SIZE ,"%d\n" , - stts751_intervals[priv->interval]); +return sysfs_emit (buf,"%d\n" , + stts751_intervals[priv->interval]); } static ssize_t interval_store(struct device *dev,
drivers/hwmon/vexpress-hwmon.c +6 -6
@@ -27,7 +27,7 @@ static ssize_t vexpress_hwmon_label_show {const char *label =of_get_property (dev->of_node,"label" ,NULL ); -return snprintf (buffer,PAGE_SIZE ,"%s\n" , label); +return sysfs_emit (buffer,"%s\n" , label); } static ssize_t vexpress_hwmon_u32_show(struct device *dev,
@@ -41,8 +41,8 @@ static ssize_t vexpress_hwmon_u32_show(sif (err)return err; -return snprintf (buffer,PAGE_SIZE ,"%u\n" , value / -to_sensor_dev_attr (dev_attr)->index); +return sysfs_emit (buffer,"%u\n" , value / +to_sensor_dev_attr (dev_attr)->index); } static ssize_t vexpress_hwmon_u64_show(struct device *dev,
@@ -60,9 +60,9 @@ static ssize_t vexpress_hwmon_u64_show(sif (err)return err; -return snprintf (buffer,PAGE_SIZE ,"%llu\n" , -div_u64 (((u64 )value_hi <<32 ) | value_lo, -to_sensor_dev_attr (dev_attr)->index)); +return sysfs_emit (buffer,"%llu\n" , +div_u64 (((u64 )value_hi <<32 ) | value_lo, +to_sensor_dev_attr (dev_attr)->index)); } static umode_t vexpress_hwmon_attr_is_visible(struct kobject *kobj,
drivers/hwmon/xgene-hwmon.c +7 -7
@@ -329,14 +329,14 @@ static ssize_t temp1_input_show(struct d temp =sign_extend32 (val,TEMP_NEGATIVE_BIT ); -return snprintf (buf,PAGE_SIZE ,"%d\n" ,CELSIUS_TO_mCELSIUS (temp)); +return sysfs_emit (buf,"%d\n" ,CELSIUS_TO_mCELSIUS (temp)); }static ssize_t temp1_label_show (struct device *dev,struct device_attribute *attr,char *buf) { -return snprintf (buf,PAGE_SIZE ,"SoC Temperature\n" ); +return sysfs_emit (buf,"SoC Temperature\n" ); } static ssize_t temp1_critical_alarm_show(struct device *dev,
@@ -345,21 +345,21 @@ static ssize_t temp1_critical_alarm_show {struct xgene_hwmon_dev *ctx =dev_get_drvdata (dev); -return snprintf (buf,PAGE_SIZE ,"%d\n" , ctx->temp_critical_alarm); +return sysfs_emit (buf,"%d\n" , ctx->temp_critical_alarm); }static ssize_t power1_label_show (struct device *dev,struct device_attribute *attr,char *buf) { -return snprintf (buf,PAGE_SIZE ,"CPU power\n" ); +return sysfs_emit (buf,"CPU power\n" ); }static ssize_t power2_label_show (struct device *dev,struct device_attribute *attr,char *buf) { -return snprintf (buf,PAGE_SIZE ,"IO power\n" ); +return sysfs_emit (buf,"IO power\n" ); } static ssize_t power1_input_show(struct device *dev,
@@ -374,7 +374,7 @@ static ssize_t power1_input_show(structif (rc <0 )return rc; -return snprintf (buf,PAGE_SIZE ,"%u\n" ,mWATT_TO_uWATT (val)); +return sysfs_emit (buf,"%u\n" ,mWATT_TO_uWATT (val)); } static ssize_t power2_input_show(struct device *dev,
@@ -389,7 +389,7 @@ static ssize_t power2_input_show(structif (rc <0 )return rc; -return snprintf (buf,PAGE_SIZE ,"%u\n" ,mWATT_TO_uWATT (val)); +return sysfs_emit (buf,"%u\n" ,mWATT_TO_uWATT (val)); }static DEVICE_ATTR_RO (temp1_label);
Greg Kroah-Hartman
maintainerPATCH 372/451 hwmon: (max16065) Use local variable to avoid TOCTOU
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gui-Dong Han <[email protected]>
[ Upstream commit b8d5acdcf525f44e521ca4ef51dce4dac403dab4 ]
In max16065_current_show, data->curr_sense is read twice: once for the error check and again for the calculation. Since i2c_smbus_read_byte_data returns negative error codes on failure, if the data changes to an error code between the check and the use, ADC_TO_CURR results in an incorrect calculation.
Read data->curr_sense into a local variable to ensure consistency. Note that data->curr_gain is constant and safe to access directly.
This aligns max16065_current_show with max16065_input_show, which already uses a local variable for the same reason.
--- drivers/hwmon/max16065.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/hwmon/max16065.c +4 -3
@@ -216,12 +216,13 @@ static ssize_t max16065_current_show(str struct device_attribute *da, char *buf) { struct max16065_data *data = max16065_update_device(dev); +int curr_sense = data->curr_sense; -if (unlikely (data->curr_sense <0 )) -return data->curr_sense; +if (unlikely (curr_sense <0 )) +return curr_sense;return sysfs_emit (buf,"%d\n" , -ADC_TO_CURR (data->curr_sense, data->curr_gain)); +ADC_TO_CURR (curr_sense, data->curr_gain)); } static ssize_t max16065_limit_store(struct device *dev,
Greg Kroah-Hartman
maintainerPATCH 373/451 crypto: af_alg - zero initialize memory allocated via sock_kmalloc
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shivani Agarwal <[email protected]>
[ Upstream commit 6f6e309328d53a10c0fe1f77dec2db73373179b6 ]
Several crypto user API contexts and requests allocated with sock_kmalloc() were left uninitialized, relying on callers to set fields explicitly. This resulted in the use of uninitialized data in certain error paths or when new fields are added in the future.
The ACVP patches also contain two user-space interface files:algif_kpp.c and algif_akcipher.c. These too rely on proper initialization of their context structures.
A particular issue has been observed with the newly added 'inflight' variable introduced in af_alg_ctx by commit:
67b164a871af ("crypto: af_alg - Disallow multiple in-flight AIO requests")
Because the context is not memset to zero after allocation, the inflight variable has contained garbage values. As a result, af_alg_alloc_areq() has incorrectly returned -EBUSY randomly when the garbage value was interpreted as true:
https://github.com/gregkh/linux/blame/master/crypto/af_alg.c#L1209
The check directly tests ctx->inflight without explicitly comparing against true/false. Since inflight is only ever set to true or false later, an uninitialized value has triggered -EBUSY failures. Zero-initializing memory allocated with sock_kmalloc() ensures inflight and other fields start in a known state, removing random issues caused by uninitialized data.
--- crypto/af_alg.c | 5 ++--- crypto/algif_hash.c | 3 +-- crypto/algif_rng.c | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-)
crypto/af_alg.c +2 -3
@@ -1127,14 +1127,13 @@ struct af_alg_async_req *af_alg_alloc_arif (unlikely (!areq))return ERR_PTR (-ENOMEM ); +memset (areq,0 , areqlen); + ctx->inflight = true; areq->areqlen = areqlen; areq->sk = sk; - areq->last_rsgl =NULL ;INIT_LIST_HEAD (&areq->rsgl_list); - areq->tsgl =NULL ; - areq->tsgl_entries =0 ;return areq; }
crypto/algif_hash.c +1 -2
@@ -423,9 +423,8 @@ static int hash_accept_parent_nokey(voidif (!ctx)return -ENOMEM ; - ctx->result =NULL ; +memset (ctx,0 , len); ctx->len = len; - ctx->more = false;crypto_init_wait (&ctx->wait); ask->private = ctx;
crypto/algif_rng.c +1 -2
@@ -250,9 +250,8 @@ static int rng_accept_parent(void *privaif (!ctx)return -ENOMEM ; +memset (ctx,0 , len); ctx->len = len; - ctx->addtl =NULL ; - ctx->addtl_len =0 ;/* * No seeding done at that point -- if multiple accepts are
Greg Kroah-Hartman
maintainerPATCH 342/451 Fonts: Add charcount field to font_desc
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peilin Ye <[email protected]>
commit 4ee573086bd88ff3060dda07873bf755d332e9ba upstream.
Subsystems are hard-coding the number of characters of our built-in fonts as 256. Include that information in our kernel font descriptor, struct font_desc.
--- include/linux/font.h | 1 + lib/fonts/font_10x18.c | 1 + lib/fonts/font_6x10.c | 1 + lib/fonts/font_6x11.c | 1 + lib/fonts/font_6x8.c | 1 + lib/fonts/font_7x14.c | 1 + lib/fonts/font_8x16.c | 1 + lib/fonts/font_8x8.c | 1 + lib/fonts/font_acorn_8x8.c | 1 + lib/fonts/font_mini_4x6.c | 1 + lib/fonts/font_pearl_8x8.c | 1 + lib/fonts/font_sun12x22.c | 1 + lib/fonts/font_sun8x16.c | 1 + lib/fonts/font_ter16x32.c | 1 + 14 files changed, 14 insertions(+)
include/linux/font.h +1 -0
@@ -17,6 +17,7 @@ struct font_desc {int idx;const char *name;unsigned int width, height; +unsigned int charcount;const void *data;int pref; };
lib/fonts/font_10x18.c +1 -0
@@ -5137,6 +5137,7 @@ const struct font_desc font_10x18 = { .name = "10x18", .width = 10, .height = 18, + .charcount = 256, .data = fontdata_10x18.data, #ifdef __sparc__ .pref = 5,
lib/fonts/font_6x10.c +1 -0
@@ -3083,6 +3083,7 @@ const struct font_desc font_6x10 = { .name = "6x10", .width = 6, .height = 10, + .charcount = 256, .data = fontdata_6x10.data, .pref = 0, };
lib/fonts/font_6x11.c +1 -0
@@ -3346,6 +3346,7 @@ const struct font_desc font_vga_6x11 = { .name = "ProFont6x11", .width = 6, .height = 11, + .charcount = 256, .data = fontdata_6x11.data,/* Try avoiding this font if possible unless on MAC */ .pref = -2000,
lib/fonts/font_6x8.c +1 -0
@@ -2571,6 +2571,7 @@ const struct font_desc font_6x8 = { .name = "6x8", .width = 6, .height = 8, + .charcount = 256, .data = fontdata_6x8.data, .pref = 0, };
lib/fonts/font_7x14.c +1 -0
@@ -4113,6 +4113,7 @@ const struct font_desc font_7x14 = { .name = "7x14", .width = 7, .height = 14, + .charcount = 256, .data = fontdata_7x14.data, .pref = 0, };
lib/fonts/font_8x16.c +1 -0
@@ -4627,6 +4627,7 @@ const struct font_desc font_vga_8x16 = { .name = "VGA8x16", .width = 8, .height = 16, + .charcount = 256, .data = fontdata_8x16.data, .pref = 0, };
lib/fonts/font_8x8.c +1 -0
@@ -2578,6 +2578,7 @@ const struct font_desc font_vga_8x8 = { .name = "VGA8x8", .width = 8, .height = 8, + .charcount = 256, .data = fontdata_8x8.data, .pref = 0, };
lib/fonts/font_acorn_8x8.c +1 -0
@@ -270,6 +270,7 @@ const struct font_desc font_acorn_8x8 = .name = "Acorn8x8", .width = 8, .height = 8, + .charcount = 256, .data = acorndata_8x8.data, #ifdef CONFIG_ARCH_ACORN .pref = 20,
lib/fonts/font_mini_4x6.c +1 -0
@@ -2152,6 +2152,7 @@ const struct font_desc font_mini_4x6 = { .name = "MINI4x6", .width = 4, .height = 6, + .charcount = 256, .data = fontdata_mini_4x6.data, .pref = 3, };
lib/fonts/font_pearl_8x8.c +1 -0
@@ -2582,6 +2582,7 @@ const struct font_desc font_pearl_8x8 = .name = "PEARL8x8", .width = 8, .height = 8, + .charcount = 256, .data = fontdata_pearl8x8.data, .pref = 2, };
lib/fonts/font_sun12x22.c +1 -0
@@ -6156,6 +6156,7 @@ const struct font_desc font_sun_12x22 = .name = "SUN12x22", .width = 12, .height = 22, + .charcount = 256, .data = fontdata_sun12x22.data, #ifdef __sparc__ .pref = 5,
lib/fonts/font_sun8x16.c +1 -0
@@ -268,6 +268,7 @@ const struct font_desc font_sun_8x16 = { .name = "SUN8x16", .width = 8, .height = 16, + .charcount = 256, .data = fontdata_sun8x16.data, #ifdef __sparc__ .pref = 10,
lib/fonts/font_ter16x32.c +1 -0
@@ -2062,6 +2062,7 @@ const struct font_desc font_ter_16x32 = .name = "TER16x32", .width = 16, .height = 32, + .charcount = 256, .data = fontdata_ter16x32.data, #ifdef __sparc__ .pref = 5,
Greg Kroah-Hartman
maintainerPATCH 343/451 parisc/sticore: Avoid hard-coding built-in font charcount
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peilin Ye <[email protected]>
commit 4497364e5f61f9e8d4a6252bc6deb9597d68bbac upstream.
sti_select_fbfont() and sti_cook_fonts() are hard-coding the number of characters of our built-in fonts as 256. Recently, we included that information in our kernel font descriptor struct font_desc, so use fbfont->charcount instead of hard-coded values.
Depends on patch "Fonts: Add charcount field to font_desc".
--- drivers/video/console/sticore.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/video/console/sticore.c +4 -4
@@ -507,7 +507,7 @@ sti_select_fbfont(struct sti_cooked_rom fbfont->width, fbfont->height, fbfont->name); bpc = ((fbfont->width+7 )/8 ) * fbfont->height; - size = bpc *256 ; + size = bpc * fbfont->charcount; size +=sizeof (struct sti_rom_font ); nf =kzalloc (size,STI_LOWMEM );
@@ -515,7 +515,7 @@ sti_select_fbfont(struct sti_cooked_romreturn NULL ; nf->first_char =0 ; - nf->last_char =255 ; + nf->last_char = fbfont->charcount -1 ; nf->width = fbfont->width; nf->height = fbfont->height; nf->font_type =STI_FONT_HPROMAN8 ;
@@ -526,7 +526,7 @@ sti_select_fbfont(struct sti_cooked_rom dest = nf; dest +=sizeof (struct sti_rom_font ); -memcpy (dest, fbfont->data, bpc*256 ); +memcpy (dest, fbfont->data, bpc * fbfont->charcount); cooked_font =kzalloc (sizeof (*cooked_font),GFP_KERNEL );if (!cooked_font) {
@@ -661,7 +661,7 @@ static int sti_cook_fonts(struct sti_coovoid sti_font_convert_bytemode (struct sti_struct *sti,struct sti_cooked_font *f) {unsigned char *n, *p, *q; -int size = f->raw->bytes_per_char *256 +sizeof (struct sti_rom_font ); +int size = f->raw->bytes_per_char * (f->raw->last_char +1 ) +sizeof (struct sti_rom_font );struct sti_rom_font *old_font;if (sti->wordmode)
Greg Kroah-Hartman
maintainerPATCH 344/451 fbcon: Avoid using FNTCHARCNT() and hard-coded built-in font charcount
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peilin Ye <[email protected]>
commit a1ac250a82a5e97db71f14101ff7468291a6aaef upstream.
For user-provided fonts, the framebuffer layer is using a magic negative-indexing macro, FNTCHARCNT(), to keep track of their number of characters:
#define FNTCHARCNT(fd) (((int *)(fd))[-3])
For built-in fonts, it is using hard-coded values (256). This results in something like the following:
map.length = (ops->p->userfont) ? FNTCHARCNT(ops->p->fontdata) : 256;
This is unsatisfactory. In fact, there is already a charcount field in our virtual console descriptor (see struct console_font inside struct vc_data), let us use it:
map.length = vc->vc_font.charcount;
Recently we added a charcount field to struct font_desc. Use it to set vc->vc_font.charcount properly. The idea is:
- We only use FNTCHARCNT() on vc->vc_font.data and p->fontdata.
Assume FNTCHARCNT() is working as intended;
- Whenever `vc->vc_font.data` is set, also set `vc->vc_font.charcount`
properly;
- We can now replace `FNTCHARCNT(vc->vc_font.data)` with
`vc->vc_font.charcount`;
- Since `p->fontdata` always point to the same font data buffer with
`vc->vc_font.data`, we can also replace `FNTCHARCNT(p->fontdata)` with
`vc->vc_font.charcount`.In conclusion, set vc->vc_font.charcount properly in fbcon_startup(), fbcon_init(), fbcon_set_disp() and fbcon_do_set_font(), then replace FNTCHARCNT() with vc->vc_font.charcount. No more if-else between negative-indexing macros and hard-coded values.
Do not include <linux/font.h> in fbcon_rotate.c and tileblit.c, since they no longer need it.
Depends on patch "Fonts: Add charcount field to font_desc".
--- drivers/video/fbdev/core/fbcon.c | 57 +++++++++++--------------------- drivers/video/fbdev/core/fbcon_rotate.c | 3 - drivers/video/fbdev/core/tileblit.c | 4 -- 3 files changed, 23 insertions(+), 41 deletions(-)
drivers/video/fbdev/core/fbcon.c +21 -36
@@ -1006,7 +1006,7 @@ static const char *fbcon_startup(void) vc->vc_font.width = font->width; vc->vc_font.height = font->height; vc->vc_font.data = (void *)(p->fontdata = font->data); - vc->vc_font.charcount =256 ;/* FIXME Need to support more fonts */ + vc->vc_font.charcount = font->charcount; }else { p->fontdata = vc->vc_font.data; }
@@ -1034,7 +1034,7 @@ static void fbcon_init(struct vc_data *vstruct vc_data **default_mode = vc->vc_display_fg;struct vc_data *svc = *default_mode;struct fbcon_display *t, *p = &fb_display[vc->vc_num]; -int logo =1 , new_rows, new_cols, rows, cols, charcnt =256 ; +int logo =1 , new_rows, new_cols, rows, cols;int cap, ret;if (WARN_ON (info_idx ==-1 ))
@@ -1070,6 +1070,7 @@ static void fbcon_init(struct vc_data *v fvc->vc_font.data); vc->vc_font.width = fvc->vc_font.width; vc->vc_font.height = fvc->vc_font.height; + vc->vc_font.charcount = fvc->vc_font.charcount; p->userfont = t->userfont;if (p->userfont)
@@ -1085,17 +1086,13 @@ static void fbcon_init(struct vc_data *v vc->vc_font.width = font->width; vc->vc_font.height = font->height; vc->vc_font.data = (void *)(p->fontdata = font->data); - vc->vc_font.charcount =256 ;/* FIXME Need to -support more fonts */ + vc->vc_font.charcount = font->charcount; } } -if (p->userfont) - charcnt =FNTCHARCNT (p->fontdata); - vc->vc_can_do_color = (fb_get_color_depth (&info->var, &info->fix)!=1 ); vc->vc_complement_mask = vc->vc_can_do_color ?0x7700 :0x0800 ; -if (charcnt ==256 ) { +if (vc->vc_font.charcount ==256 ) { vc->vc_hi_font_mask =0 ; }else { vc->vc_hi_font_mask =0x100 ;
@@ -1367,7 +1364,7 @@ static void fbcon_set_disp(struct fb_infstruct vc_data **default_mode, *vc;struct vc_data *svc;struct fbcon_ops *ops = info->fbcon_par; -int rows, cols, charcnt =256 ; +int rows, cols; p = &fb_display[unit];
@@ -1387,12 +1384,11 @@ static void fbcon_set_disp(struct fb_inf vc->vc_font.data = (void *)(p->fontdata = t->fontdata); vc->vc_font.width = (*default_mode)->vc_font.width; vc->vc_font.height = (*default_mode)->vc_font.height; + vc->vc_font.charcount = (*default_mode)->vc_font.charcount; p->userfont = t->userfont;if (p->userfont)REFCOUNT (p->fontdata)++; } -if (p->userfont) - charcnt =FNTCHARCNT (p->fontdata); var->activate =FB_ACTIVATE_NOW ; info->var.activate = var->activate;
@@ -1402,7 +1398,7 @@ static void fbcon_set_disp(struct fb_inf ops->var = info->var; vc->vc_can_do_color = (fb_get_color_depth (&info->var, &info->fix)!=1 ); vc->vc_complement_mask = vc->vc_can_do_color ?0x7700 :0x0800 ; -if (charcnt ==256 ) { +if (vc->vc_font.charcount ==256 ) { vc->vc_hi_font_mask =0 ; }else { vc->vc_hi_font_mask =0x100 ;
@@ -2047,7 +2043,7 @@ static int fbcon_resize(struct vc_data **/ if (pitch <=0 )return -EINVAL ; - size =CALC_FONTSZ (vc->vc_font.height, pitch,FNTCHARCNT (vc->vc_font.data)); + size =CALC_FONTSZ (vc->vc_font.height, pitch, vc->vc_font.charcount);if (size >FNTSIZE (vc->vc_font.data))return -EINVAL ; }
@@ -2095,7 +2091,7 @@ static int fbcon_switch(struct vc_data *struct fbcon_ops *ops;struct fbcon_display *p = &fb_display[vc->vc_num];struct fb_var_screeninfo var; -int i, ret, prev_console, charcnt =256 ; +int i, ret, prev_console; info = registered_fb[con2fb_map[vc->vc_num]]; ops = info->fbcon_par;
@@ -2172,10 +2168,7 @@ static int fbcon_switch(struct vc_data * vc->vc_can_do_color = (fb_get_color_depth (&info->var, &info->fix)!=1 ); vc->vc_complement_mask = vc->vc_can_do_color ?0x7700 :0x0800 ; -if (p->userfont) - charcnt =FNTCHARCNT (vc->vc_font.data); - -if (charcnt >256 ) +if (vc->vc_font.charcount >256 ) vc->vc_complement_mask <<=1 ;updatescrollmode (p, info, vc);
@@ -2425,31 +2418,27 @@ static void set_vc_hi_font(struct vc_dat } } -static int fbcon_do_set_font (struct vc_data *vc,int w,int h, +static int fbcon_do_set_font (struct vc_data *vc,int w,int h,int charcount,const u8 * data,int userfont) {struct fb_info *info = registered_fb[con2fb_map[vc->vc_num]];struct fbcon_ops *ops = info->fbcon_par;struct fbcon_display *p = &fb_display[vc->vc_num];int resize; -int cnt;char *old_data =NULL ; resize = (w != vc->vc_font.width) || (h != vc->vc_font.height);if (p->userfont) old_data = vc->vc_font.data; -if (userfont) - cnt =FNTCHARCNT (data); -else - cnt =256 ; vc->vc_font.data = (void *)(p->fontdata = data);if ((p->userfont = userfont))REFCOUNT (data)++; vc->vc_font.width = w; vc->vc_font.height = h; -if (vc->vc_hi_font_mask && cnt ==256 ) + vc->vc_font.charcount = charcount; +if (vc->vc_hi_font_mask && charcount ==256 )set_vc_hi_font (vc, false); -else if (!vc->vc_hi_font_mask && cnt ==512 ) +else if (!vc->vc_hi_font_mask && charcount ==512 )set_vc_hi_font (vc, true);if (resize) {
@@ -2531,9 +2520,10 @@ static int fbcon_set_font(struct vc_dataif (!new_data)return -ENOMEM ; +memset (new_data,0 ,FONT_EXTRA_WORDS *sizeof (int )); + new_data +=FONT_EXTRA_WORDS *sizeof (int );FNTSIZE (new_data) = size; -FNTCHARCNT (new_data) = charcount;REFCOUNT (new_data) =0 ;/* usage counter */ for (i=0 ; i< charcount; i++) {memcpy (new_data + i*h*pitch, data + i*32 *pitch, h*pitch);
@@ -2559,7 +2549,7 @@ static int fbcon_set_font(struct vc_databreak ; } } -return fbcon_do_set_font (vc, font->width, font->height, new_data,1 ); +return fbcon_do_set_font (vc, font->width, font->height, charcount, new_data,1 ); }static int fbcon_set_def_font (struct vc_data *vc,struct console_font *font,char *name)
@@ -2575,7 +2565,7 @@ static int fbcon_set_def_font(struct vc_ font->width = f->width; font->height = f->height; -return fbcon_do_set_font (vc, f->width, f->height, f->data,0 ); +return fbcon_do_set_font (vc, f->width, f->height, f->charcount, f->data,0 ); }static u16 palette_red[16 ];
@@ -3072,7 +3062,6 @@ void fbcon_get_requirement(struct fb_inf struct fb_blit_caps *caps) {struct vc_data *vc; -struct fbcon_display *p;if (caps->flags) {int i, charcnt;
@@ -3081,11 +3070,9 @@ void fbcon_get_requirement(struct fb_inf vc = vc_cons[i].d;if (vc && vc->vc_mode ==KD_TEXT && info->node == con2fb_map[i]) { - p = &fb_display[i]; caps->x |=1 << (vc->vc_font.width -1 ); caps->y |=1 << (vc->vc_font.height -1 ); - charcnt = (p->userfont) ? -FNTCHARCNT (p->fontdata) :256 ; + charcnt = vc->vc_font.charcount;if (caps->len < charcnt) caps->len = charcnt; }
@@ -3095,11 +3082,9 @@ void fbcon_get_requirement(struct fb_infif (vc && vc->vc_mode ==KD_TEXT && info->node == con2fb_map[fg_console]) { - p = &fb_display[fg_console]; caps->x =1 << (vc->vc_font.width -1 ); caps->y =1 << (vc->vc_font.height -1 ); - caps->len = (p->userfont) ? -FNTCHARCNT (p->fontdata) :256 ; + caps->len = vc->vc_font.charcount; } } }
drivers/video/fbdev/core/fbcon_rotate.c +1 -2
@@ -14,7 +14,6 @@#include <linux/fb.h> #include <linux/vt_kern.h> #include <linux/console.h> -#include <linux/font.h> #include <asm/types.h> #include "fbcon.h" #include "fbcon_rotate.h"
@@ -33,7 +32,7 @@ static int fbcon_rotate_font(struct fb_i src = ops->fontdata = vc->vc_font.data; ops->cur_rotate = ops->p->con_rotate; - len = (!ops->p->userfont) ?256 :FNTCHARCNT (src); + len = vc->vc_font.charcount; s_cellsize = ((vc->vc_font.width +7 )/8 ) * vc->vc_font.height; d_cellsize = s_cellsize;
drivers/video/fbdev/core/tileblit.c +1 -3
@@ -13,7 +13,6 @@#include <linux/fb.h> #include <linux/vt_kern.h> #include <linux/console.h> -#include <linux/font.h> #include <asm/types.h> #include "fbcon.h"
@@ -178,8 +177,7 @@ void fbcon_set_tileops(struct vc_data *v map.width = vc->vc_font.width; map.height = vc->vc_font.height; map.depth =1 ; - map.length = (ops->p->userfont) ? -FNTCHARCNT (ops->p->fontdata) :256 ; + map.length = vc->vc_font.charcount; map.data = ops->p->fontdata; info->tileops->fb_settile (info, &map); }
Greg Kroah-Hartman
maintainerPATCH 345/451 drm/vmwgfx: Fix a null-ptr access in the cursor snooper
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zack Rusin <[email protected]>
[ Upstream commit 5ac2c0279053a2c5265d46903432fb26ae2d0da2 ]
Check that the resource which is converted to a surface exists before trying to use the cursor snooper on it.
vmw_cmd_res_check allows explicit invalid (SVGA3D_INVALID_ID) identifiers because some svga commands accept SVGA3D_INVALID_ID to mean "no surface", unfortunately functions that accept the actual surfaces as objects might (and in case of the cursor snooper, do not) be able to handle null objects. Make sure that we validate not only the identifier (via the vmw_cmd_res_check) but also check that the actual resource exists before trying to do something with it.
Fixes unchecked null-ptr reference in the snooping code.
--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +12 -5
@@ -1520,6 +1520,7 @@ static int vmw_cmd_dma(struct vmw_privat SVGA3dCmdHeader *header) {struct vmw_buffer_object *vmw_bo =NULL ; +struct vmw_resource *res;struct vmw_surface *srf =NULL ;VMW_DECLARE_CMD_VAR (*cmd, SVGA3dCmdSurfaceDMA);int ret;
@@ -1555,18 +1556,24 @@ static int vmw_cmd_dma(struct vmw_privat dirty = (cmd->body.transfer ==SVGA3D_WRITE_HOST_VRAM ) ?VMW_RES_DIRTY_SET :0 ; - ret =vmw_cmd_res_check (dev_priv, sw_context, vmw_res_surface, - dirty, user_surface_converter, - &cmd->body.host.sid,NULL ); + ret =vmw_cmd_res_check (dev_priv, sw_context, vmw_res_surface, dirty, + user_surface_converter, &cmd->body.host.sid, +NULL );if (unlikely (ret !=0 )) {if (unlikely (ret != -ERESTARTSYS ))VMW_DEBUG_USER ("could not find surface for DMA.\n" );return ret; } - srf =vmw_res_to_srf (sw_context->res_cache[vmw_res_surface].res); + res = sw_context->res_cache[vmw_res_surface].res; +if (!res) { +VMW_DEBUG_USER ("Invalid DMA surface.\n" ); +return -EINVAL ; + } -vmw_kms_cursor_snoop (srf, sw_context->fp->tfile, &vmw_bo->base, header); + srf =vmw_res_to_srf (res); +vmw_kms_cursor_snoop (srf, sw_context->fp->tfile, &vmw_bo->base, + header);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 346/451 usb: xhci: move link chain bit quirk checks into one helper function.
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Neronin <[email protected]>
commit 7476a2215c07703db5e95efaa3fc5b9f957b9417 upstream.
Older 0.95 xHCI hosts and some other specific newer hosts require the chain bit to be set for Link TRBs even if the link TRB is not in the middle of a transfer descriptor (TD).
move the checks for all those cases into one xhci_link_chain_quirk() function to clean up and avoid code duplication.
No functional changes.
[skip renaming chain_links flag, reword commit message -Mathias]
--- drivers/usb/host/xhci-mem.c | 10 ++-------- drivers/usb/host/xhci-ring.c | 8 ++------ drivers/usb/host/xhci.h | 7 +++++-- 3 files changed, 9 insertions(+), 16 deletions(-)
drivers/usb/host/xhci-mem.c +2 -8
@@ -133,10 +133,7 @@ static void xhci_link_rings(struct xhci_if (!ring || !first || !last)return ; -/* Set chain bit for 0.95 hosts, and for isoc rings on AMD 0.96 host */ - chain_links = !!(xhci_link_trb_quirk (xhci) || - (ring->type ==TYPE_ISOC && - (xhci->quirks & XHCI_AMD_0x96_HOST))); + chain_links =xhci_link_chain_quirk (xhci, ring->type); next = ring->enq_seg->next;xhci_link_segments (ring->enq_seg, first, ring->type, chain_links);
@@ -326,10 +323,7 @@ static int xhci_alloc_segments_for_ring(struct xhci_segment *prev;bool chain_links; -/* Set chain bit for 0.95 hosts, and for isoc rings on AMD 0.96 host */ - chain_links = !!(xhci_link_trb_quirk (xhci) || - (type ==TYPE_ISOC && - (xhci->quirks & XHCI_AMD_0x96_HOST))); + chain_links =xhci_link_chain_quirk (xhci, type); prev =xhci_segment_alloc (xhci, cycle_state, max_packet, flags);if (!prev)
drivers/usb/host/xhci-ring.c +2 -6
@@ -230,9 +230,7 @@ static void inc_enq(struct xhci_hcd *xhc* AMD 0.96 host, carry over the chain bit of the previous TRB * (which may mean the chain bit is cleared). */ -if (!(ring->type ==TYPE_ISOC && - (xhci->quirks & XHCI_AMD_0x96_HOST)) && - !xhci_link_trb_quirk (xhci)) { +if (!xhci_link_chain_quirk (xhci, ring->type)) { next->link.control &=cpu_to_le32 (~TRB_CHAIN ); next->link.control |=cpu_to_le32 (chain); }
@@ -3138,9 +3136,7 @@ static int prepare_ring(struct xhci_hcd/* If we're not dealing with 0.95 hardware or isoc rings * on AMD 0.96 host, clear the chain bit. */ -if (!xhci_link_trb_quirk (xhci) && - !(ep_ring->type ==TYPE_ISOC && - (xhci->quirks & XHCI_AMD_0x96_HOST))) +if (!xhci_link_chain_quirk (xhci, ep_ring->type)) ep_ring->enqueue->link.control &=cpu_to_le32 (~TRB_CHAIN );else
drivers/usb/host/xhci.h +5 -2
@@ -1998,9 +1998,12 @@ static inline void xhci_write_64(structlo_hi_writeq (val, regs); } -static inline int xhci_link_trb_quirk (struct xhci_hcd *xhci) + +/* Link TRB chain should always be set on 0.95 hosts, and AMD 0.96 ISOC rings */ +static inline bool xhci_link_chain_quirk (struct xhci_hcd *xhci,enum xhci_ring_type type) { -return xhci->quirks &XHCI_LINK_TRB_QUIRK ; +return (xhci->quirks &XHCI_LINK_TRB_QUIRK ) || + (type ==TYPE_ISOC && (xhci->quirks & XHCI_AMD_0x96_HOST)); }/* xHCI debugging */
Greg Kroah-Hartman
maintainerPATCH 347/451 usb: xhci: Apply the link chain quirk on NEC isoc endpoints
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Pecio <[email protected]>
commit bb0ba4cb1065e87f9cc75db1fa454e56d0894d01 upstream.
Two clearly different specimens of NEC uPD720200 (one with start/stop bug, one without) were seen to cause IOMMU faults after some Missed Service Errors. Faulting address is immediately after a transfer ring segment and patched dynamic debug messages revealed that the MSE was received when waiting for a TD near the end of that segment:
[ 1.041954] xhci_hcd: Miss service interval error for slot 1 ep 2 expected TD DMA ffa08fe0 [ 1.042120] xhci_hcd: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0005 address=0xffa09000 flags=0x0000] [ 1.042146] xhci_hcd: AMD-Vi: Event logged [IO_PAGE_FAULT domain=0x0005 address=0xffa09040 flags=0x0000]
It gets even funnier if the next page is a ring segment accessible to the HC. Below, it reports MSE in segment at ff1e8000, plows through a zero-filled page at ff1e9000 and starts reporting events for TRBs in page at ff1ea000 every microframe, instead of jumping to seg ff1e6000.
[ 7.041671] xhci_hcd: Miss service interval error for slot 1 ep 2 expected TD DMA ff1e8fe0 [ 7.041999] xhci_hcd: Miss service interval error for slot 1 ep 2 expected TD DMA ff1e8fe0 [ 7.042011] xhci_hcd: WARN: buffer overrun event for slot 1 ep 2 on endpoint [ 7.042028] xhci_hcd: All TDs skipped for slot 1 ep 2. Clear skip flag. [ 7.042134] xhci_hcd: WARN: buffer overrun event for slot 1 ep 2 on endpoint [ 7.042138] xhci_hcd: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 2 comp_code 31 [ 7.042144] xhci_hcd: Looking for event-dma 00000000ff1ea040 trb-start 00000000ff1e6820 trb-end 00000000ff1e6820 [ 7.042259] xhci_hcd: WARN: buffer overrun event for slot 1 ep 2 on endpoint [ 7.042262] xhci_hcd: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 2 comp_code 31 [ 7.042266] xhci_hcd: Looking for event-dma 00000000ff1ea050 trb-start 00000000ff1e6820 trb-end 00000000ff1e6820
At some point completion events change from Isoch Buffer Overrun to Short Packet and the HC finally finds cycle bit mismatch in ff1ec000.
[ 7.098130] xhci_hcd: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 2 comp_code 13 [ 7.098132] xhci_hcd: Looking for event-dma 00000000ff1ecc50 trb-start 00000000ff1e6820 trb-end 00000000ff1e6820 [ 7.098254] xhci_hcd: ERROR Transfer event TRB DMA ptr not part of current TD ep_index 2 comp_code 13 [ 7.098256] xhci_hcd: Looking for event-dma 00000000ff1ecc60 trb-start 00000000ff1e6820 trb-end 00000000ff1e6820 [ 7.098379] xhci_hcd: Overrun event on slot 1 ep 2
It's possible that data from the isochronous device were written to random buffers of pending TDs on other endpoints (either IN or OUT), other devices or even other HCs in the same IOMMU domain.
Lastly, an error from a different USB device on another HC. Was it caused by the above? I don't know, but it may have been. The disk was working without any other issues and generated PCIe traffic to starve the NEC of upstream BW and trigger those MSEs. The two HCs shared one x1 slot by means of a commercial "PCIe splitter" board.
[ 7.162604] usb 10-2: reset SuperSpeed USB device number 3 using xhci_hcd [ 7.178990] sd 9:0:0:0: [sdb] tag#0 UNKNOWN(0x2003) Result: hostbyte=0x07 driverbyte=DRIVER_OK cmd_age=0s [ 7.179001] sd 9:0:0:0: [sdb] tag#0 CDB: opcode=0x28 28 00 04 02 ae 00 00 02 00 00 [ 7.179004] I/O error, dev sdb, sector 67284480 op 0x0:(READ) flags 0x80700 phys_seg 5 prio class 0
Fortunately, it appears that this ridiculous bug is avoided by setting the chain bit of Link TRBs on isochronous rings. Other ancient HCs are known which also expect the bit to be set and they ignore Link TRBs if it's not. Reportedly, 0.95 spec guaranteed that the bit is set.
The bandwidth-starved NEC HC running a 32KB/uframe UVC endpoint reports tens of MSEs per second and runs into the bug within seconds. Chaining Link TRBs allows the same workload to run for many minutes, many times.
No negative side effects seen in UVC recording and UAC playback with a few devices at full speed, high speed and SuperSpeed.
The problem doesn't reproduce on the newer Renesas uPD720201/uPD720202 and on old Etron EJ168 and VIA VL805 (but the VL805 has other bug).
[shorten line length of log snippets in commit messge -Mathias]
--- drivers/usb/host/xhci.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/usb/host/xhci.h +11 -2
@@ -1999,11 +1999,20 @@ static inline void xhci_write_64(struct } -/* Link TRB chain should always be set on 0.95 hosts, and AMD 0.96 ISOC rings */ +/* +* Reportedly, some chapters of v0.95 spec said that Link TRB always has its chain bit set. +* Other chapters and later specs say that it should only be set if the link is inside a TD +* which continues from the end of one segment to the next segment. +* +* Some 0.95 hardware was found to misbehave if any link TRB doesn't have the chain bit set. +* +* 0.96 hardware from AMD and NEC was found to ignore unchained isochronous link TRBs when +* "resynchronizing the pipe" after a Missed Service Error. +*/ static inline bool xhci_link_chain_quirk (struct xhci_hcd *xhci,enum xhci_ring_type type) {return (xhci->quirks &XHCI_LINK_TRB_QUIRK ) || - (type ==TYPE_ISOC && (xhci->quirks & XHCI_AMD_0x96_HOST)); + (type ==TYPE_ISOC && (xhci->quirks & (XHCI_AMD_0x96_HOST |XHCI_NEC_HOST ))); }/* xHCI debugging */
Greg Kroah-Hartman
maintainerPATCH 338/451 RDMA/core: Fix "KASAN: slab-use-after-free Read in ib_register_device" problem
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhu Yanjun <[email protected]>
commit d0706bfd3ee40923c001c6827b786a309e2a8713 upstream.
Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:408 [inline] print_report+0xc3/0x670 mm/kasan/report.c:521 kasan_report+0xe0/0x110 mm/kasan/report.c:634 strlen+0x93/0xa0 lib/string.c:420 __fortify_strlen include/linux/fortify-string.h:268 [inline] get_kobj_path_length lib/kobject.c:118 [inline] kobject_get_path+0x3f/0x2a0 lib/kobject.c:158 kobject_uevent_env+0x289/0x1870 lib/kobject_uevent.c:545 ib_register_device drivers/infiniband/core/device.c:1472 [inline] ib_register_device+0x8cf/0xe00 drivers/infiniband/core/device.c:1393 rxe_register_device+0x275/0x320 drivers/infiniband/sw/rxe/rxe_verbs.c:1552 rxe_net_add+0x8e/0xe0 drivers/infiniband/sw/rxe/rxe_net.c:550 rxe_newlink+0x70/0x190 drivers/infiniband/sw/rxe/rxe.c:225 nldev_newlink+0x3a3/0x680 drivers/infiniband/core/nldev.c:1796 rdma_nl_rcv_msg+0x387/0x6e0 drivers/infiniband/core/netlink.c:195 rdma_nl_rcv_skb.constprop.0.isra.0+0x2e5/0x450 netlink_unicast_kernel net/netlink/af_netlink.c:1313 [inline] netlink_unicast+0x53a/0x7f0 net/netlink/af_netlink.c:1339 netlink_sendmsg+0x8d1/0xdd0 net/netlink/af_netlink.c:1883 sock_sendmsg_nosec net/socket.c:712 [inline] __sock_sendmsg net/socket.c:727 [inline] ____sys_sendmsg+0xa95/0xc70 net/socket.c:2566 ___sys_sendmsg+0x134/0x1d0 net/socket.c:2620 __sys_sendmsg+0x16d/0x220 net/socket.c:2652 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xcd/0x260 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
This problem is similar to the problem that the
commit 1d6a9e7449e2 ("RDMA/core: Fix use-after-free when rename device name") fixes.
The root cause is: the function ib_device_rename() renames the name with lock. But in the function kobject_uevent(), this name is accessed without lock protection at the same time.
The solution is to add the lock protection when this name is accessed in the function kobject_uevent().
[ Ajay: Modified to apply on v5.10.y-v6.6.y
ib_device_notify_register() not present in v5.10.y-v6.6.y, so directly added lock for kobject_uevent() ]
--- drivers/infiniband/core/device.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/infiniband/core/device.c +5 -0
@@ -1396,8 +1396,13 @@ int ib_register_device(struct ib_devicereturn ret; }dev_set_uevent_suppress (&device->dev, false); + +down_read (&devices_rwsem); +/* Mark for userspace that device is ready */ kobject_uevent (&device->dev.kobj,KOBJ_ADD ); + +up_read (&devices_rwsem);ib_device_put (device);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 375/451 iommu/qcom: fix device leak on of_xlate()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 6a3908ce56e6879920b44ef136252b2f0c954194 ]
Make sure to drop the reference taken to the iommu platform device when looking up its driver data during of_xlate().
Note that commit e2eae09939a8 ("iommu/qcom: add missing put_device() call in qcom_iommu_of_xlate()") fixed the leak in a couple of error paths, but the reference is still leaking on success and late failures.
--- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/iommu/arm/arm-smmu/qcom_iommu.c +4 -6
@@ -586,15 +586,15 @@ static int qcom_iommu_of_xlate(struct de qcom_iommu =platform_get_drvdata (iommu_pdev); +put_device (&iommu_pdev->dev); +/* make sure the asid specified in dt is valid, so we don't have * to sanity check this elsewhere, since 'asid - 1' is used to * index into qcom_iommu->ctxs: */ if (WARN_ON (asid <1 ) || -WARN_ON (asid > qcom_iommu->num_ctxs)) { -put_device (&iommu_pdev->dev); +WARN_ON (asid > qcom_iommu->num_ctxs))return -EINVAL ; - }if (!dev_iommu_priv_get (dev)) {dev_iommu_priv_set (dev, qcom_iommu);
@@ -603,10 +603,8 @@ static int qcom_iommu_of_xlate(struct de* multiple different iommu devices. Multiple context * banks are ok, but multiple devices are not: */ -if (WARN_ON (qcom_iommu !=dev_iommu_priv_get (dev))) { -put_device (&iommu_pdev->dev); +if (WARN_ON (qcom_iommu !=dev_iommu_priv_get (dev)))return -EINVAL ; - } }return iommu_fwspec_add_ids (dev, &asid,1 );
Greg Kroah-Hartman
maintainerPATCH 384/451 mm/balloon_compaction: we cannot have isolated pages in the balloon list
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
[ Upstream commit fb05f992b6bbb4702307d96f00703ee637b24dbf ]
Patch series "mm/migration: rework movable_ops page migration (part 1)", v2.
In the future, as we decouple "struct page" from "struct folio", pages that support "non-lru page migration" -- movable_ops page migration such as memory balloons and zsmalloc -- will no longer be folios. They will not have ->mapping, ->lru, and likely no refcount and no page lock. But they will have a type and flags 🙂
This is the first part (other parts not written yet) of decoupling movable_ops page migration from folio migration.
In this series, we get rid of the ->mapping usage, and start cleaning up the code + separating it from folio migration.
Migration core will have to be further reworked to not treat movable_ops pages like folios. This is the first step into that direction.
This patch (of 29):
The core will set PG_isolated only after mops->isolate_page() was called. In case of the balloon, that is where we will remove it from the balloon list. So we cannot have isolated pages in the balloon list.
Let's drop this unnecessary check.
Stable-dep-of: 0da2ba35c0d5 ("powerpc/pseries/cmm: adjust BALLOON_MIGRATE when migrating pages")
--- mm/balloon_compaction.c | 6 ------ 1 file changed, 6 deletions(-)
mm/balloon_compaction.c +0 -6
@@ -93,12 +93,6 @@ size_t balloon_page_list_dequeue(structif (!trylock_page (page))continue ; -if (IS_ENABLED (CONFIG_BALLOON_COMPACTION ) && -PageIsolated (page)) { -/* raced with isolation */ -unlock_page (page); -continue ; - }balloon_page_delete (page);__count_vm_event (BALLOON_DEFLATE );list_add (&page->lru, pages);
Greg Kroah-Hartman
maintainerPATCH 385/451 mm/balloon_compaction: convert balloon_page_delete() to balloon_page_finalize()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
[ Upstream commit 15504b1163007bbfbd9a63460d5c14737c16e96d ]
Let's move the removal of the page from the balloon list into the single caller, to remove the dependency on the PG_isolated flag and clarify locking requirements.
Note that for now, balloon_page_delete() was used on two paths:
(1) Removing a page from the balloon for deflation through balloon_page_list_dequeue()
(2) Removing an isolated page from the balloon for migration in the per-driver migration handlers. Isolated pages were already removed from the balloon list during isolation.
So instead of relying on the flag, we can just distinguish both cases directly and handle it accordingly in the caller.
We'll shuffle the operations a bit such that they logically make more sense (e.g., remove from the list before clearing flags).
In balloon migration functions we can now move the balloon_page_finalize() out of the balloon lock and perform the finalization just before dropping the balloon reference.
Document that the page lock is currently required when modifying the movability aspects of a page; hopefully we can soon decouple this from the page lock.
Stable-dep-of: 0da2ba35c0d5 ("powerpc/pseries/cmm: adjust BALLOON_MIGRATE when migrating pages")
--- arch/powerpc/platforms/pseries/cmm.c | 2 - drivers/misc/vmw_balloon.c | 3 -- drivers/virtio/virtio_balloon.c | 4 --- include/linux/balloon_compaction.h | 43 +++++++++++++---------------------- mm/balloon_compaction.c | 3 +- 5 files changed, 21 insertions(+), 34 deletions(-)
arch/powerpc/platforms/pseries/cmm.c +1 -1
@@ -550,7 +550,6 @@ static int cmm_migratepage(struct balloospin_lock_irqsave (&b_dev_info->pages_lock, flags);balloon_page_insert (b_dev_info, newpage); -balloon_page_delete (page); b_dev_info->isolated_pages--;spin_unlock_irqrestore (&b_dev_info->pages_lock, flags);
@@ -560,6 +559,7 @@ static int cmm_migratepage(struct balloo*/ plpar_page_set_active (page); +balloon_page_finalize (page);/* balloon page list reference */ put_page (page);
drivers/misc/vmw_balloon.c +1 -2
@@ -1810,8 +1810,7 @@ static int vmballoon_migratepage(struct* @pages_lock . We keep holding @comm_lock since we will need it in a * second. */ -balloon_page_delete (page); - +balloon_page_finalize (page);put_page (page);/* Inflate */
drivers/virtio/virtio_balloon.c +1 -3
@@ -796,15 +796,13 @@ static int virtballoon_migratepage(structell_host (vb, vb->inflate_vq);/* balloon's page migration 2nd step -- deflate "page" */ -spin_lock_irqsave (&vb_dev_info->pages_lock, flags); -balloon_page_delete (page); -spin_unlock_irqrestore (&vb_dev_info->pages_lock, flags); vb->num_pfns =VIRTIO_BALLOON_PAGES_PER_PAGE ;set_page_pfns (vb, vb->pfns, page);tell_host (vb, vb->deflate_vq);mutex_unlock (&vb->balloon_lock); +balloon_page_finalize (page);put_page (page);/* balloon reference */ return MIGRATEPAGE_SUCCESS ;
include/linux/balloon_compaction.h +16 -27
61 lines not on this page · raw message
mm/balloon_compaction.c +2 -1
@@ -93,7 +93,8 @@ size_t balloon_page_list_dequeue(structif (!trylock_page (page))continue ; -balloon_page_delete (page); +list_del (&page->lru); +balloon_page_finalize (page);__count_vm_event (BALLOON_DEFLATE );list_add (&page->lru, pages);unlock_page (page);
Greg Kroah-Hartman
maintainerPATCH 386/451 powerpc/pseries/cmm: adjust BALLOON_MIGRATE when migrating pages
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
[ Upstream commit 0da2ba35c0d532ca0fe7af698b17d74c4d084b9a ]
Let's properly adjust BALLOON_MIGRATE like the other drivers.
Note that the INFLATE/DEFLATE events are triggered from the core when enqueueing/dequeueing pages.
This was found by code inspection.
--- arch/powerpc/platforms/pseries/cmm.c | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/platforms/pseries/cmm.c +1 -0
@@ -550,6 +550,7 @@ static int cmm_migratepage(struct balloospin_lock_irqsave (&b_dev_info->pages_lock, flags);balloon_page_insert (b_dev_info, newpage); +__count_vm_event (BALLOON_MIGRATE ); b_dev_info->isolated_pages--;spin_unlock_irqrestore (&b_dev_info->pages_lock, flags);
Greg Kroah-Hartman
maintainerPATCH 387/451 media: mediatek: vcodec: Fix a reference leak in mtk_vcodec_fw_vpu_init()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
[ Upstream commit cdd0f118ef87db8a664fb5ea366fd1766d2df1cd ]
vpu_get_plat_device() increases the reference count of the returned platform device. However, when devm_kzalloc() fails, the reference is not released, causing a reference leak.
Fix this by calling put_device() on fw_pdev->dev before returning on the error path.
--- drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_vpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/media/platform/mtk-vcodec/mtk_vcodec_fw_vpu.c +3 -1
@@ -94,8 +94,10 @@ struct mtk_vcodec_fw *mtk_vcodec_fw_vpu_vpu_wdt_reg_handler (fw_pdev, mtk_vcodec_vpu_reset_handler, dev, rst_id); fw =devm_kzalloc (&dev->plat_dev->dev,sizeof (*fw),GFP_KERNEL ); -if (!fw) +if (!fw) { +put_device (&fw_pdev->dev);return ERR_PTR (-ENOMEM ); + } fw->type =VPU ; fw->ops = &mtk_vcodec_vpu_msg; fw->pdev = fw_pdev;
Greg Kroah-Hartman
maintainerPATCH 388/451 media: vpif_capture: fix section mismatch
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 0ef841113724166c3c484d0e9ae6db1eb5634fde ]
Platform drivers can be probed after their init sections have been discarded (e.g. on probe deferral or manual rebind through sysfs) so the probe function must not live in init.
Note that commit ffa1b391c61b ("V4L/DVB: vpif_cap/disp: Removed section mismatch warning") incorrectly suppressed the modpost warning.
--- drivers/media/platform/davinci/vpif_capture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/davinci/vpif_capture.c +2 -2
@@ -1614,7 +1614,7 @@ err_cleanup:* This creates device entries by register itself to the V4L2 driver and * initializes fields of each channel objects */ -static __init int vpif_probe (struct platform_device *pdev) +static int vpif_probe (struct platform_device *pdev) {struct vpif_subdev_info *subdevdata;struct i2c_adapter *i2c_adap;
@@ -1817,7 +1817,7 @@ static int vpif_resume(struct device *de static SIMPLE_DEV_PM_OPS(vpif_pm_ops, vpif_suspend, vpif_resume); -static __refdata struct platform_driver vpif_driver = { +static struct platform_driver vpif_driver = { .driver = { .name =VPIF_DRIVER_NAME , .pm = &vpif_pm_ops,
Greg Kroah-Hartman
maintainerPATCH 389/451 media: samsung: exynos4-is: fix potential ABBA deadlock on init
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Szyprowski <[email protected]>
[ Upstream commit 17dc8ccd6dd5ffe30aa9b0d36e2af1389344ce2b ]
v4l2_device_register_subdev_nodes() must called without taking media_dev->graph_mutex to avoid potential AB-BA deadlock on further subdevice driver initialization.
--- drivers/media/platform/exynos4-is/media-dev.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/media/platform/exynos4-is/media-dev.c +6 -4
@@ -1409,12 +1409,14 @@ static int subdev_notifier_complete(strumutex_lock (&fmd->media_dev.graph_mutex); ret =fimc_md_create_links (fmd); -if (ret <0 ) - goto unlock; +if (ret <0 ) { +mutex_unlock (&fmd->media_dev.graph_mutex); +return ret; + } - ret =v4l2_device_register_subdev_nodes (&fmd->v4l2_dev); -unlock:mutex_unlock (&fmd->media_dev.graph_mutex); + + ret =v4l2_device_register_subdev_nodes (&fmd->v4l2_dev);if (ret <0 )return ret;
Greg Kroah-Hartman
maintainerPATCH 390/451 lockd: fix vfs_test_lock() calls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
[ Upstream commit a49a2a1baa0c553c3548a1c414b6a3c005a8deba ]
Usage of vfs_test_lock() is somewhat confused. Documentation suggests it is given a "lock" but this is not the case. It is given a struct file_lock which contains some details of the sort of lock it should be looking for.
In particular passing a "file_lock" containing fl_lmops or fl_ops is meaningless and possibly confusing.
This is particularly problematic in lockd. nlmsvc_testlock() receives an initialised "file_lock" from xdr-decode, including manager ops and an owner. It then mistakenly passes this to vfs_test_lock() which might replace the owner and the ops. This can lead to confusion when freeing the lock.
The primary role of the 'struct file_lock' passed to vfs_test_lock() is to report a conflicting lock that was found, so it makes more sense for nlmsvc_testlock() to pass "conflock", which it uses for returning the conflicting lock.
With this change, freeing of the lock is not confused and code in __nlm4svc_proc_test() and __nlmsvc_proc_test() can be simplified.
Documentation for vfs_test_lock() is improved to reflect its real purpose, and a WARN_ON_ONCE() is added to avoid a similar problem in the future.
--- fs/lockd/svc4proc.c | 4 +--- fs/lockd/svclock.c | 21 ++++++++++++--------- fs/lockd/svcproc.c | 5 +---- fs/locks.c | 13 +++++++++++-- 4 files changed, 25 insertions(+), 18 deletions(-)
fs/lockd/svc4proc.c +1 -3
@@ -96,7 +96,6 @@ __nlm4svc_proc_test(struct svc_rqst *rqsstruct nlm_args *argp = rqstp->rq_argp;struct nlm_host *host;struct nlm_file *file; -struct nlm_lockowner *test_owner;__be32 rc = rpc_success;dprintk ("lockd: TEST4 called\n" );
@@ -106,7 +105,6 @@ __nlm4svc_proc_test(struct svc_rqst *rqsif ((resp->status =nlm4svc_retrieve_args (rqstp, argp, &host, &file)))return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; - test_owner = argp->lock.fl.fl_owner;/* Now check for conflicting locks */ resp->status =nlmsvc_testlock (rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie);if (resp->status == nlm_drop_reply)
@@ -114,7 +112,7 @@ __nlm4svc_proc_test(struct svc_rqst *rqselse dprintk ("lockd: TEST4 status %d\n" ,ntohl (resp->status)); -nlmsvc_put_lockowner (test_owner); +nlmsvc_release_lockowner (&argp->lock);nlmsvc_release_host (host);nlm_release_file (file);return rc;
fs/lockd/svclock.c +12 -9
@@ -604,7 +604,13 @@ nlmsvc_testlock(struct svc_rqst *rqstp, } mode =lock_to_openmode (&lock->fl); - error =vfs_test_lock (file->f_file[mode], &lock->fl); +locks_init_lock (&conflock->fl); +/* vfs_test_lock only uses start, end, and owner, but tests fl_file */ + conflock->fl.fl_file = lock->fl.fl_file; + conflock->fl.fl_start = lock->fl.fl_start; + conflock->fl.fl_end = lock->fl.fl_end; + conflock->fl.fl_owner = lock->fl.fl_owner; + error =vfs_test_lock (file->f_file[mode], &conflock->fl);if (error) {/* We can't currently deal with deferred test requests */ if (error ==FILE_LOCK_DEFERRED )
@@ -614,22 +620,19 @@ nlmsvc_testlock(struct svc_rqst *rqstp, goto out; } -if (lock->fl.fl_type ==F_UNLCK ) { +if (conflock->fl.fl_type ==F_UNLCK ) { ret = nlm_granted; goto out; }dprintk ("lockd: conflicting lock(ty=%d, %Ld-%Ld)\n" , - lock->fl.fl_type, (long long )lock->fl.fl_start, - (long long )lock->fl.fl_end); + conflock->fl.fl_type, (long long )conflock->fl.fl_start, + (long long )conflock->fl.fl_end); conflock->caller ="somehost" ;/* FIXME */ conflock->len =strlen (conflock->caller); conflock->oh.len =0 ;/* don't return OH info */ - conflock->svid = lock->fl.fl_pid; - conflock->fl.fl_type = lock->fl.fl_type; - conflock->fl.fl_start = lock->fl.fl_start; - conflock->fl.fl_end = lock->fl.fl_end; -locks_release_private (&lock->fl); + conflock->svid = conflock->fl.fl_pid; +locks_release_private (&conflock->fl); ret = nlm_lck_denied; out:
fs/lockd/svcproc.c +1 -4
@@ -117,7 +117,6 @@ __nlmsvc_proc_test(struct svc_rqst *rqststruct nlm_args *argp = rqstp->rq_argp;struct nlm_host *host;struct nlm_file *file; -struct nlm_lockowner *test_owner;__be32 rc = rpc_success;dprintk ("lockd: TEST called\n" );
@@ -127,8 +126,6 @@ __nlmsvc_proc_test(struct svc_rqst *rqstif ((resp->status =nlmsvc_retrieve_args (rqstp, argp, &host, &file)))return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; - test_owner = argp->lock.fl.fl_owner; -/* Now check for conflicting locks */ resp->status =cast_status (nlmsvc_testlock (rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie));if (resp->status == nlm_drop_reply)
@@ -137,7 +134,7 @@ __nlmsvc_proc_test(struct svc_rqst *rqstdprintk ("lockd: TEST status %d vers %d\n" ,ntohl (resp->status), rqstp->rq_vers); -nlmsvc_put_lockowner (test_owner); +nlmsvc_release_lockowner (&argp->lock);nlmsvc_release_host (host);nlm_release_file (file);return rc;
fs/locks.c +11 -2
@@ -2325,13 +2325,22 @@ SYSCALL_DEFINE2(flock, unsigned int, fd,/** * vfs_test_lock - test file byte range lock * @filp: The file to test lock for -* @fl: The lock to test; also used to hold result +* @fl: The byte-range in the file to test; also used to hold result * +* On entry, @fl does not contain a lock, but identifies a range (fl_start, fl_end) +* in the file (c.flc_file), and an owner (c.flc_owner) for whom existing locks +* should be ignored. c.flc_type and c.flc_flags are ignored. +* Both fl_lmops and fl_ops in @fl must be NULL. * Returns -ERRNO on failure. Indicates presence of conflicting lock by -* setting conf->fl_type to something other than F_UNLCK. +* setting fl->fl_type to something other than F_UNLCK. +* +* If vfs_test_lock() does find a lock and return it, the caller must +* use locks_free_lock() or locks_release_private() on the returned lock. */ int vfs_test_lock (struct file *filp,struct file_lock *fl) { +WARN_ON_ONCE (fl->fl_ops || fl->fl_lmops); +WARN_ON_ONCE (filp != fl->fl_file);if (filp->f_op->lock)return filp->f_op->lock (filp,F_GETLK , fl);posix_test_lock (filp, fl);
Greg Kroah-Hartman
maintainerPATCH 391/451 drm/gma500: Remove unused helper psb_fbdev_fb_setcolreg()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
[ Upstream commit be729f9de6c64240645dc80a24162ac4d3fe00a8 ]
Remove psb_fbdev_fb_setcolreg(), which hasn't been called in almost a decade.
Gma500 commit 4d8d096e9ae8 ("gma500: introduce the framebuffer support code") added the helper psb_fbdev_fb_setcolreg() for setting the fbdev palette via fbdev's fb_setcolreg callback. Later
commit 3da6c2f3b730 ("drm/gma500: use DRM_FB_HELPER_DEFAULT_OPS for fb_ops") set several default helpers for fbdev emulation, including fb_setcmap.
The fbdev subsystem always prefers fb_setcmap over fb_setcolreg. [1] Hence, the gma500 code is no longer in use and gma500 has been using drm_fb_helper_setcmap() for several years without issues.
--- drivers/gpu/drm/gma500/framebuffer.c | 44 ----------------------------------- 1 file changed, 44 deletions(-)
drivers/gpu/drm/gma500/framebuffer.c +0 -44
@@ -34,47 +34,6 @@ static const struct drm_framebuffer_func .create_handle = drm_gem_fb_create_handle, }; -#define CMAP_TOHW (_val, _width) ((((_val) << (_width)) + 0x7FFF - (_val)) >> 16) - -static int psbfb_setcolreg (unsigned regno,unsigned red,unsigned green, -unsigned blue,unsigned transp, -struct fb_info *info) -{ -struct drm_fb_helper *fb_helper = info->par; -struct drm_framebuffer *fb = fb_helper->fb; -uint32_t v; - -if (!fb) -return -ENOMEM ; - -if (regno >255 ) -return 1 ; - - red =CMAP_TOHW (red, info->var.red.length); - blue =CMAP_TOHW (blue, info->var.blue.length); - green =CMAP_TOHW (green, info->var.green.length); - transp =CMAP_TOHW (transp, info->var.transp.length); - - v = (red << info->var.red.offset) | - (green << info->var.green.offset) | - (blue << info->var.blue.offset) | - (transp << info->var.transp.offset); - -if (regno <16 ) { -switch (fb->format->cpp[0 ] *8 ) { -case 16 : - ((uint32_t *) info->pseudo_palette)[regno] = v; -break ; -case 24 : -case 32 : - ((uint32_t *) info->pseudo_palette)[regno] = v; -break ; - } - } - -return 0 ; -} -static int psbfb_pan (struct fb_var_screeninfo *var,struct fb_info *info) {struct drm_fb_helper *fb_helper = info->par;
@@ -167,7 +126,6 @@ static int psbfb_mmap(struct fb_info *instatic const struct fb_ops psbfb_ops = { .owner =THIS_MODULE ,DRM_FB_HELPER_DEFAULT_OPS , - .fb_setcolreg = psbfb_setcolreg, .fb_fillrect = drm_fb_helper_cfb_fillrect, .fb_copyarea = psbfb_copyarea, .fb_imageblit = drm_fb_helper_cfb_imageblit,
@@ -178,7 +136,6 @@ static const struct fb_ops psbfb_ops = {static const struct fb_ops psbfb_roll_ops = { .owner =THIS_MODULE ,DRM_FB_HELPER_DEFAULT_OPS , - .fb_setcolreg = psbfb_setcolreg, .fb_fillrect = drm_fb_helper_cfb_fillrect, .fb_copyarea = drm_fb_helper_cfb_copyarea, .fb_imageblit = drm_fb_helper_cfb_imageblit,
@@ -189,7 +146,6 @@ static const struct fb_ops psbfb_roll_opstatic const struct fb_ops psbfb_unaccel_ops = { .owner =THIS_MODULE ,DRM_FB_HELPER_DEFAULT_OPS , - .fb_setcolreg = psbfb_setcolreg, .fb_fillrect = drm_fb_helper_cfb_fillrect, .fb_copyarea = drm_fb_helper_cfb_copyarea, .fb_imageblit = drm_fb_helper_cfb_imageblit,
Greg Kroah-Hartman
maintainerPATCH 392/451 wifi: mac80211: Discard Beacon frames to non-broadcast address
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jouni Malinen <[email protected]>
[ Upstream commit 193d18f60588e95d62e0f82b6a53893e5f2f19f8 ]
Beacon frames are required to be sent to the broadcast address, see IEEE Std 802.11-2020, 11.1.3.1 ("The Address 1 field of the Beacon .. frame shall be set to the broadcast address"). A unicast Beacon frame might be used as a targeted attack to get one of the associated STAs to do something (e.g., using CSA to move it to another channel). As such, it is better have strict filtering for this on the received side and discard all Beacon frames that are sent to an unexpected address.
This is even more important for cases where beacon protection is used. The current implementation in mac80211 is correctly discarding unicast Beacon frames if the Protected Frame bit in the Frame Control field is set to 0. However, if that bit is set to 1, the logic used for checking for configured BIGTK(s) does not actually work. If the driver does not have logic for dropping unicast Beacon frames with Protected Frame bit 1, these frames would be accepted in mac80211 processing as valid Beacon frames even though they are not protected. This would allow beacon protection to be bypassed. While the logic for checking beacon protection could be extended to cover this corner case, a more generic check for discard all Beacon frames based on A1=unicast address covers this without needing additional changes.
Address all these issues by dropping received Beacon frames if they are sent to a non-broadcast address.
--- net/mac80211/rx.c | 5 +++++ 1 file changed, 5 insertions(+)
net/mac80211/rx.c +5 -0
@@ -3189,6 +3189,11 @@ ieee80211_rx_h_mgmt_check(struct ieee802if (!ieee80211_is_mgmt (mgmt->frame_control))return RX_DROP_MONITOR ; +/* Drop non-broadcast Beacon frames */ +if (ieee80211_is_beacon (mgmt->frame_control) && + !is_broadcast_ether_addr (mgmt->da)) +return RX_DROP_MONITOR ; +if (rx->sdata->vif.type ==NL80211_IFTYPE_AP &&ieee80211_is_beacon (mgmt->frame_control) && !(rx->flags &IEEE80211_RX_BEACON_REPORTED )) {
Greg Kroah-Hartman
maintainerPATCH 393/451 NFSD: NFSv4 file creation neglects setting ACL
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 913f7cf77bf14c13cfea70e89bcb6d0b22239562 ]
An NFSv4 client that sets an ACL with a named principal during file creation retrieves the ACL afterwards, and finds that it is only a default ACL (based on the mode bits) and not the ACL that was requested during file creation. This violates RFC 8881 section 6.4.1.3: "the ACL attribute is set as given".
The issue occurs in nfsd_create_setattr(). On 6.1.y, the check to determine whether nfsd_setattr() should be called is simply "iap->ia_valid", which only accounts for iattr changes. When only an ACL is present (and no iattr fields are set), nfsd_setattr() is skipped and the POSIX ACL is never applied to the inode.
Subsequently, when the client retrieves the ACL, the server finds no POSIX ACL on the inode and returns one generated from the file's mode bits rather than returning the originally-specified ACL.
--- fs/nfsd/vfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/vfs.c +1 -1
@@ -1335,7 +1335,7 @@ nfsd_create_setattr(struct svc_rqst *rqs* Callers expect new file metadata to be committed even * if the attributes have not changed. */ -if (iap->ia_valid) +if (iap->ia_valid || attrs->na_pacl || attrs->na_dpacl) status =nfsd_setattr (rqstp, resfhp, attrs,0 , (time64_t )0 );else status =nfserrno (commit_metadata (resfhp));
Greg Kroah-Hartman
maintainerPATCH 376/451 powerpc/64s/slb: Fix SLB multihit issue during SLB preload
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Donet Tom <[email protected]>
[ Upstream commit 00312419f0863964625d6dcda8183f96849412c6 ]
On systems using the hash MMU, there is a software SLB preload cache that mirrors the entries loaded into the hardware SLB buffer. This preload cache is subject to periodic eviction — typically after every 256 context switches — to remove old entry.
To optimize performance, the kernel skips switch_mmu_context() in switch_mm_irqs_off() when the prev and next mm_struct are the same. However, on hash MMU systems, this can lead to inconsistencies between the hardware SLB and the software preload cache.
If an SLB entry for a process is evicted from the software cache on one CPU, and the same process later runs on another CPU without executing switch_mmu_context(), the hardware SLB may retain stale entries. If the kernel then attempts to reload that entry, it can trigger an SLB multi-hit error.
The following timeline shows how stale SLB entries are created and can cause a multi-hit error when a process moves between CPUs without a MMU context switch.
CPU 0 CPU 1
----- -----
Process P
exec swapper/1
load_elf_binary
begin_new_exc
activate_mm
switch_mm_irqs_off
switch_mmu_context
switch_slb
/*
* This invalidates all
* the entries in the HW
* and setup the new HW
* SLB entries as per the
* preload cache.
*/context_switchsched_migrate_task migrates process P to cpu-1
Process swapper/0 context switch (to process P)
(uses mm_struct of Process P) switch_mm_irqs_off()
switch_slb
load_slb++
/*
* load_slb becomes 0 here
* and we evict an entry from
* the preload cache with
* preload_age(). We still
* keep HW SLB and preload
* cache in sync, that is
* because all HW SLB entries
* anyways gets evicted in
* switch_slb during SLBIA.
* We then only add those
* entries back in HW SLB,
* which are currently
* present in preload_cache
* (after eviction). */
load_elf_binary continues...
setup_new_exec()
slb_setup_new_exec()
sched_switch event sched_migrate_task migrates process P to cpu-0
context_switch from swapper/0 to Process P
switch_mm_irqs_off()
/*
* Since both prev and next mm struct are same we don't call
* switch_mmu_context(). This will cause the HW SLB and SW preload
* cache to go out of sync in preload_new_slb_context. Because there
* was an SLB entry which was evicted from both HW and preload cache
* on cpu-1. Now later in preload_new_slb_context(), when we will try
* to add the same preload entry again, we will add this to the SW
* preload cache and then will add it to the HW SLB. Since on cpu-0
* this entry was never invalidated, hence adding this entry to the HW
* SLB will cause a SLB multi-hit error.
*/load_elf_binary continues...
START_THREAD
start_thread
preload_new_slb_context
/*
* This tries to add a new EA to preload cache which was earlier
* evicted from both cpu-1 HW SLB and preload cache. This caused the
* HW SLB of cpu-0 to go out of sync with the SW preload cache. The
* reason for this was, that when we context switched back on CPU-0,
* we should have ideally called switch_mmu_context() which will
* bring the HW SLB entries on CPU-0 in sync with SW preload cache
* entries by setting up the mmu context properly. But we didn't do
* that since the prev mm_struct running on cpu-0 was same as the
* next mm_struct (which is true for swapper / kernel threads). So
* now when we try to add this new entry into the HW SLB of cpu-0,
* we hit a SLB multi-hit error.
*/
WARNING: CPU: 0 PID: 1810970 at arch/powerpc/mm/book3s64/slb.c:62 assert_slb_presence+0x2c/0x50(48 results) 02:47:29 [20157/42149] Modules linked in: CPU: 0 UID: 0 PID: 1810970 Comm: dd Not tainted 6.16.0-rc3-dirty #12 VOLUNTARY Hardware name: IBM pSeries (emulated by qemu) POWER8 (architected) 0x4d0200 0xf000004 of:SLOF,HEAD hv:linux,kvm pSeries NIP: c00000000015426c LR: c0000000001543b4 CTR: 0000000000000000 REGS: c0000000497c77e0 TRAP: 0700 Not tainted (6.16.0-rc3-dirty) MSR: 8000000002823033 <SF,VEC,VSX,FP,ME,IR,DR,RI,LE> CR: 28888482 XER: 00000000 CFAR: c0000000001543b0 IRQMASK: 3 <...> NIP [c00000000015426c] assert_slb_presence+0x2c/0x50 LR [c0000000001543b4] slb_insert_entry+0x124/0x390 Call Trace: 0x7fffceb5ffff (unreliable) preload_new_slb_context+0x100/0x1a0 start_thread+0x26c/0x420 load_elf_binary+0x1b04/0x1c40 bprm_execve+0x358/0x680 do_execveat_common+0x1f8/0x240 sys_execve+0x58/0x70 system_call_exception+0x114/0x300 system_call_common+0x160/0x2c4
Quoted 1 line
Quoted 1 line
From the above analysis, during early exec the hardware SLB is cleared,
and entries from the software preload cache are reloaded into hardware by switch_slb. However, preload_new_slb_context and slb_setup_new_exec also attempt to load some of the same entries, which can trigger a multi-hit. In most cases, these additional preloads simply hit existing entries and add nothing new. Removing these functions avoids redundant preloads and eliminates the multi-hit issue. This patch removes these two functions.
We tested process switching performance using the context_switch benchmark on POWER9/hash, and observed no regression.
Without this patch: 129041 ops/sec With this patch: 129341 ops/sec
We also measured SLB faults during boot, and the counts are essentially the same with and without this patch.
SLB faults without this patch: 19727 SLB faults with this patch: 19786
--- arch/powerpc/kernel/process.c | 5 - arch/powerpc/mm/book3s64/internal.h | 1 arch/powerpc/mm/book3s64/mmu_context.c | 2 arch/powerpc/mm/book3s64/slb.c | 88 --------------------------------- 4 files changed, 96 deletions(-)
arch/powerpc/kernel/process.c +0 -5
@@ -1767,8 +1767,6 @@ int copy_thread(unsigned long clone_flagreturn 0 ; } -void preload_new_slb_context (unsigned long start,unsigned long sp); -/* * Set up a thread for executing a new program */
@@ -1776,9 +1774,6 @@ void start_thread(struct pt_regs *regs, {#ifdef CONFIG_PPC64 unsigned long load_addr = regs->gpr[2 ];/* saved by ELF_PLAT_INIT */ - -if (IS_ENABLED (CONFIG_PPC_BOOK3S_64 ) && !radix_enabled ()) -preload_new_slb_context (start, sp);#endif /*
arch/powerpc/mm/book3s64/internal.h +0 -1
@@ -13,6 +13,5 @@ static inline bool stress_slb(void) return static_branch_unlikely(&stress_slb_key); } -void slb_setup_new_exec (void );#endif /* ARCH_POWERPC_MM_BOOK3S64_INTERNAL_H */
arch/powerpc/mm/book3s64/mmu_context.c +0 -2
@@ -147,8 +147,6 @@ static int hash__init_new_context(structvoid hash__setup_new_exec (void ) {slice_setup_new_exec (); - -slb_setup_new_exec (); }static int radix__init_new_context (struct mm_struct *mm)
arch/powerpc/mm/book3s64/slb.c +0 -88
94 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 394/451 mm/mprotect: use long for page accountings and retval
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Xu <[email protected]>
commit a79390f5d6a78647fd70856bd42b22d994de0ba2 upstream.
Switch to use type "long" for page accountings and retval across the whole procedure of change_protection().
The change should have shrinked the possible maximum page number to be half comparing to previous (ULONG_MAX / 2), but it shouldn't overflow on any system either because the maximum possible pages touched by change protection should be ULONG_MAX / PAGE_SIZE.
Two reasons to switch from "unsigned long" to "long":
1. It suites better on count_vm_numa_events(), whose 2nd parameter takes a long type.
2. It paves way for returning negative (error) values in the future.
Currently the only caller that consumes this retval is change_prot_numa(), where the unsigned long was converted to an int. Since at it, touching up the numa code to also take a long, so it'll avoid any possible overflow too during the int-size convertion.
--- include/linux/hugetlb.h | 4 ++-- include/linux/mm.h | 2 +- mm/hugetlb.c | 4 ++-- mm/mempolicy.c | 2 +- mm/mprotect.c | 34 +++++++++++++++++----------------- 5 files changed, 23 insertions(+), 23 deletions(-)
include/linux/hugetlb.h +2 -2
@@ -184,7 +184,7 @@ struct page *follow_huge_pgd(struct mm_sint pmd_huge (pmd_t pmd);int pud_huge (pud_t pud); -unsigned long hugetlb_change_protection (struct vm_area_struct *vma, +long hugetlb_change_protection (struct vm_area_struct *vma,unsigned long address,unsigned long end,pgprot_t newprot);bool is_hugetlb_entry_migration (pte_t pte);
@@ -342,7 +342,7 @@ static inline void move_hugetlb_state(st { } -static inline unsigned long hugetlb_change_protection ( +static inline long hugetlb_change_protection (struct vm_area_struct *vma,unsigned long address,unsigned long end,pgprot_t newprot) {
include/linux/mm.h +1 -1
@@ -1876,7 +1876,7 @@ extern unsigned long move_page_tables(st#define MM_CP_UFFD_WP_ALL (MM_CP_UFFD_WP | \ MM_CP_UFFD_WP_RESOLVE) -extern unsigned long change_protection (struct vm_area_struct *vma,unsigned long start, +extern long change_protection (struct vm_area_struct *vma,unsigned long start,unsigned long end,pgprot_t newprot,unsigned long cp_flags); extern int mprotect_fixup(struct vm_area_struct *vma,
mm/hugetlb.c +2 -2
@@ -5051,7 +5051,7 @@ same_page:#define flush_hugetlb_tlb_range (vma, addr, end) flush_tlb_range(vma, addr, end)#endif -unsigned long hugetlb_change_protection (struct vm_area_struct *vma, +long hugetlb_change_protection (struct vm_area_struct *vma,unsigned long address,unsigned long end,pgprot_t newprot) {struct mm_struct *mm = vma->vm_mm;
@@ -5059,7 +5059,7 @@ unsigned long hugetlb_change_protection(pte_t *ptep;pte_t pte;struct hstate *h =hstate_vma (vma); -unsigned long pages =0 ; +long pages =0 ;bool shared_pmd = false;struct mmu_notifier_range range;
mm/mempolicy.c +1 -1
@@ -653,7 +653,7 @@ unlock:unsigned long change_prot_numa (struct vm_area_struct *vma,unsigned long addr,unsigned long end) { -int nr_updated; +long nr_updated; nr_updated =change_protection (vma, addr, end,PAGE_NONE ,MM_CP_PROT_NUMA );if (nr_updated)
mm/mprotect.c +17 -17
@@ -35,13 +35,13 @@#include "internal.h" -static unsigned long change_pte_range (struct vm_area_struct *vma,pmd_t *pmd, +static long change_pte_range (struct vm_area_struct *vma,pmd_t *pmd,unsigned long addr,unsigned long end,pgprot_t newprot,unsigned long cp_flags) {pte_t *pte, oldpte;spinlock_t *ptl; -unsigned long pages =0 ; +long pages =0 ;int target_node =NUMA_NO_NODE ;bool dirty_accountable = cp_flags &MM_CP_DIRTY_ACCT ;bool prot_numa = cp_flags &MM_CP_PROT_NUMA ;
@@ -209,13 +209,13 @@ static inline int pmd_none_or_clear_bad_return 0 ; } -static inline unsigned long change_pmd_range (struct vm_area_struct *vma, +static inline long change_pmd_range (struct vm_area_struct *vma,pud_t *pud,unsigned long addr,unsigned long end,pgprot_t newprot,unsigned long cp_flags) {pmd_t *pmd;unsigned long next; -unsigned long pages =0 ; +long pages =0 ;unsigned long nr_huge_updates =0 ;struct mmu_notifier_range range;
@@ -223,7 +223,7 @@ static inline unsigned long change_pmd_r pmd =pmd_offset (pud, addr); do { - unsigned long this_pages; + long this_pages; next = pmd_addr_end(addr, end);
@@ -281,13 +281,13 @@ next:return pages; } -static inline unsigned long change_pud_range (struct vm_area_struct *vma, -p4d_t *p4d,unsigned long addr,unsigned long end, -pgprot_t newprot,unsigned long cp_flags) +static inline long change_pud_range (struct vm_area_struct *vma,p4d_t *p4d, +unsigned long addr,unsigned long end,pgprot_t newprot, +unsigned long cp_flags) {pud_t *pud;unsigned long next; -unsigned long pages =0 ; +long pages =0 ; pud =pud_offset (p4d, addr); do {
@@ -301,13 +301,13 @@ static inline unsigned long change_pud_rreturn pages; } -static inline unsigned long change_p4d_range (struct vm_area_struct *vma, -pgd_t *pgd,unsigned long addr,unsigned long end, -pgprot_t newprot,unsigned long cp_flags) +static inline long change_p4d_range (struct vm_area_struct *vma,pgd_t *pgd, +unsigned long addr,unsigned long end,pgprot_t newprot, +unsigned long cp_flags) {p4d_t *p4d;unsigned long next; -unsigned long pages =0 ; +long pages =0 ; p4d =p4d_offset (pgd, addr); do {
@@ -321,7 +321,7 @@ static inline unsigned long change_p4d_rreturn pages; } -static unsigned long change_protection_range (struct vm_area_struct *vma, +static long change_protection_range (struct vm_area_struct *vma,unsigned long addr,unsigned long end,pgprot_t newprot,unsigned long cp_flags) {
@@ -329,7 +329,7 @@ static unsigned long change_protection_rpgd_t *pgd;unsigned long next;unsigned long start = addr; -unsigned long pages =0 ; +long pages =0 ;BUG_ON (addr >= end); pgd =pgd_offset (mm, addr);
@@ -351,11 +351,11 @@ static unsigned long change_protection_rreturn pages; } -unsigned long change_protection (struct vm_area_struct *vma,unsigned long start, +long change_protection (struct vm_area_struct *vma,unsigned long start,unsigned long end,pgprot_t newprot,unsigned long cp_flags) { -unsigned long pages; +long pages;BUG_ON ((cp_flags &MM_CP_UFFD_WP_ALL ) ==MM_CP_UFFD_WP_ALL );
Greg Kroah-Hartman
maintainerPATCH 395/451 scsi: iscsi: Move pool freeing
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Christie <[email protected]>
[ Upstream commit a1f3486b3b095ed2259d7a1fc021a8b6e72a5365 ]
This doesn't fix any bugs, but it makes more sense to free the pool after we have removed the session. At that time we know nothing is touching any of the session fields, because all devices have been removed and scans are stopped.
--- drivers/scsi/libiscsi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/libiscsi.c +1 -2
@@ -2902,10 +2902,9 @@ void iscsi_session_teardown(struct iscsistruct module *owner = cls_session->transport->owner;struct Scsi_Host *shost = session->host; -iscsi_pool_free (&session->cmdpool); -iscsi_remove_session (cls_session); +iscsi_pool_free (&session->cmdpool);kfree (session->password);kfree (session->password_in);kfree (session->username);
Greg Kroah-Hartman
maintainerPATCH 396/451 scsi: iscsi_tcp: Fix UAF during logout when accessing the shost ipaddress
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Christie <[email protected]>
[ Upstream commit 6f1d64b13097e85abda0f91b5638000afc5f9a06 ]
Bug report and analysis from Ding Hui.
During iSCSI session logout, if another task accesses the shost ipaddress attr, we can get a KASAN UAF report like this:
[ 276.942144] BUG: KASAN: use-after-free in _raw_spin_lock_bh+0x78/0xe0 [ 276.942535] Write of size 4 at addr ffff8881053b45b8 by task cat/4088 [ 276.943511] CPU: 2 PID: 4088 Comm: cat Tainted: G E 6.1.0-rc8+ #3 [ 276.943997] Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 11/12/2020 [ 276.944470] Call Trace: [ 276.944943] <TASK> [ 276.945397] dump_stack_lvl+0x34/0x48 [ 276.945887] print_address_description.constprop.0+0x86/0x1e7 [ 276.946421] print_report+0x36/0x4f [ 276.947358] kasan_report+0xad/0x130 [ 276.948234] kasan_check_range+0x35/0x1c0 [ 276.948674] _raw_spin_lock_bh+0x78/0xe0 [ 276.949989] iscsi_sw_tcp_host_get_param+0xad/0x2e0 [iscsi_tcp] [ 276.951765] show_host_param_ISCSI_HOST_PARAM_IPADDRESS+0xe9/0x130 [scsi_transport_iscsi] [ 276.952185] dev_attr_show+0x3f/0x80 [ 276.953005] sysfs_kf_seq_show+0x1fb/0x3e0 [ 276.953401] seq_read_iter+0x402/0x1020 [ 276.954260] vfs_read+0x532/0x7b0 [ 276.955113] ksys_read+0xed/0x1c0 [ 276.955952] do_syscall_64+0x38/0x90 [ 276.956347] entry_SYSCALL_64_after_hwframe+0x63/0xcd [ 276.956769] RIP: 0033:0x7f5d3a679222 [ 276.957161] Code: c0 e9 b2 fe ff ff 50 48 8d 3d 32 c0 0b 00 e8 a5 fe 01 00 0f 1f 44 00 00 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 0f 05 <48> 3d 00 f0 ff ff 77 56 c3 0f 1f 44 00 00 48 83 ec 28 48 89 54 24 [ 276.958009] RSP: 002b:00007ffc864d16a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 [ 276.958431] RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007f5d3a679222 [ 276.958857] RDX: 0000000000020000 RSI: 00007f5d3a4fe000 RDI: 0000000000000003 [ 276.959281] RBP: 00007f5d3a4fe000 R08: 00000000ffffffff R09: 0000000000000000 [ 276.959682] R10: 0000000000000022 R11: 0000000000000246 R12: 0000000000020000 [ 276.960126] R13: 0000000000000003 R14: 0000000000000000 R15: 0000557a26dada58 [ 276.960536] </TASK> [ 276.961357] Allocated by task 2209: [ 276.961756] kasan_save_stack+0x1e/0x40 [ 276.962170] kasan_set_track+0x21/0x30 [ 276.962557] __kasan_kmalloc+0x7e/0x90 [ 276.962923] __kmalloc+0x5b/0x140 [ 276.963308] iscsi_alloc_session+0x28/0x840 [scsi_transport_iscsi] [ 276.963712] iscsi_session_setup+0xda/0xba0 [libiscsi] [ 276.964078] iscsi_sw_tcp_session_create+0x1fd/0x330 [iscsi_tcp] [ 276.964431] iscsi_if_create_session.isra.0+0x50/0x260 [scsi_transport_iscsi] [ 276.964793] iscsi_if_recv_msg+0xc5a/0x2660 [scsi_transport_iscsi] [ 276.965153] iscsi_if_rx+0x198/0x4b0 [scsi_transport_iscsi] [ 276.965546] netlink_unicast+0x4d5/0x7b0 [ 276.965905] netlink_sendmsg+0x78d/0xc30 [ 276.966236] sock_sendmsg+0xe5/0x120 [ 276.966576] ____sys_sendmsg+0x5fe/0x860 [ 276.966923] ___sys_sendmsg+0xe0/0x170 [ 276.967300] __sys_sendmsg+0xc8/0x170 [ 276.967666] do_syscall_64+0x38/0x90 [ 276.968028] entry_SYSCALL_64_after_hwframe+0x63/0xcd [ 276.968773] Freed by task 2209: [ 276.969111] kasan_save_stack+0x1e/0x40 [ 276.969449] kasan_set_track+0x21/0x30 [ 276.969789] kasan_save_free_info+0x2a/0x50 [ 276.970146] __kasan_slab_free+0x106/0x190 [ 276.970470] __kmem_cache_free+0x133/0x270 [ 276.970816] device_release+0x98/0x210 [ 276.971145] kobject_cleanup+0x101/0x360 [ 276.971462] iscsi_session_teardown+0x3fb/0x530 [libiscsi] [ 276.971775] iscsi_sw_tcp_session_destroy+0xd8/0x130 [iscsi_tcp] [ 276.972143] iscsi_if_recv_msg+0x1bf1/0x2660 [scsi_transport_iscsi] [ 276.972485] iscsi_if_rx+0x198/0x4b0 [scsi_transport_iscsi] [ 276.972808] netlink_unicast+0x4d5/0x7b0 [ 276.973201] netlink_sendmsg+0x78d/0xc30 [ 276.973544] sock_sendmsg+0xe5/0x120 [ 276.973864] ____sys_sendmsg+0x5fe/0x860 [ 276.974248] ___sys_sendmsg+0xe0/0x170 [ 276.974583] __sys_sendmsg+0xc8/0x170 [ 276.974891] do_syscall_64+0x38/0x90 [ 276.975216] entry_SYSCALL_64_after_hwframe+0x63/0xcd
We can easily reproduce by two tasks:
1. while :; do iscsiadm -m node --login; iscsiadm -m node --logout; done
2. while :; do cat \/sys/devices/platform/host*/iscsi_host/host*/ipaddress; done
iscsid | cat
--------------------------------+---------------------------------------
|- iscsi_sw_tcp_session_destroy |
|- iscsi_session_teardown |
|- device_release |
|- iscsi_session_release ||- dev_attr_show
|- kfree | |- show_host_param_
| ISCSI_HOST_PARAM_IPADDRESS
| |- iscsi_sw_tcp_host_get_param
| |- r/w tcp_sw_host->session (UAF)
|- iscsi_host_remove |
|- iscsi_host_free |Fix the above bug by splitting the session removal into 2 parts:
1. removal from iSCSI class which includes sysfs and removal from host tracking.
2. freeing of session.
During iscsi_tcp host and session removal we can remove the session from sysfs then remove the host from sysfs. At this point we know userspace is not accessing the kernel via sysfs so we can free the session and host.
[Shivani: The false parameter was not passed to iscsi_host_remove() because,
in Linux 5.10.y, the default behavior of iscsi_host_remove() already assumes false.]
--- drivers/scsi/iscsi_tcp.c | 11 +++++++++-- drivers/scsi/libiscsi.c | 38 +++++++++++++++++++++++++++++++------- include/scsi/libiscsi.h | 2 ++ 3 files changed, 42 insertions(+), 9 deletions(-)
drivers/scsi/iscsi_tcp.c +9 -2
@@ -933,10 +933,17 @@ static void iscsi_sw_tcp_session_destroyif (WARN_ON_ONCE (session->leadconn))return ; +iscsi_session_remove (cls_session); +/* +* Our get_host_param needs to access the session, so remove the +* host from sysfs before freeing the session to make sure userspace +* is no longer accessing the callout. +*/ +iscsi_host_remove (shost); +iscsi_tcp_r2tpool_free (cls_session->dd_data); -iscsi_session_teardown (cls_session); -iscsi_host_remove (shost); +iscsi_session_free (cls_session);iscsi_host_free (shost); }
drivers/scsi/libiscsi.c +31 -7
@@ -2892,17 +2892,32 @@ dec_session_count: }EXPORT_SYMBOL_GPL (iscsi_session_setup); -/** -* iscsi_session_teardown - destroy session, host, and cls_session -* @cls_session: iscsi session +/* +* issi_session_remove - Remove session from iSCSI class. */ -void iscsi_session_teardown (struct iscsi_cls_session *cls_session) +void iscsi_session_remove (struct iscsi_cls_session *cls_session) {struct iscsi_session *session = cls_session->dd_data; -struct module *owner = cls_session->transport->owner;struct Scsi_Host *shost = session->host;iscsi_remove_session (cls_session); +/* +* host removal only has to wait for its children to be removed from +* sysfs, and iscsi_tcp needs to do iscsi_host_remove before freeing +* the session, so drop the session count here. +*/ +iscsi_host_dec_session_cnt (shost); +} +EXPORT_SYMBOL_GPL (iscsi_session_remove); + +/** +* iscsi_session_free - Free iscsi session and it's resources +* @cls_session: iscsi session +*/ +void iscsi_session_free (struct iscsi_cls_session *cls_session) +{ +struct iscsi_session *session = cls_session->dd_data; +struct module *owner = cls_session->transport->owner;iscsi_pool_free (&session->cmdpool);kfree (session->password);
@@ -2920,10 +2935,19 @@ void iscsi_session_teardown(struct iscsikfree (session->discovery_parent_type);iscsi_free_session (cls_session); - -iscsi_host_dec_session_cnt (shost);module_put (owner); } +EXPORT_SYMBOL_GPL (iscsi_session_free); + +/** +* iscsi_session_teardown - destroy session and cls_session +* @cls_session: iscsi session +*/ +void iscsi_session_teardown (struct iscsi_cls_session *cls_session) +{ +iscsi_session_remove (cls_session); +iscsi_session_free (cls_session); +}EXPORT_SYMBOL_GPL (iscsi_session_teardown);/**
include/scsi/libiscsi.h +2 -0
@@ -401,6 +401,8 @@ extern int iscsi_target_alloc(struct scsextern struct iscsi_cls_session *iscsi_session_setup (struct iscsi_transport *,struct Scsi_Host *shost,uint16_t ,int ,int ,uint32_t ,unsigned int ); +void iscsi_session_remove (struct iscsi_cls_session *cls_session); +void iscsi_session_free (struct iscsi_cls_session *cls_session);extern void iscsi_session_teardown (struct iscsi_cls_session *);extern void iscsi_session_recovery_timedout (struct iscsi_cls_session *); extern int iscsi_set_param(struct iscsi_cls_conn *cls_conn,
Greg Kroah-Hartman
maintainerPATCH 397/451 cpufreq: scmi: Fix null-ptr-deref in scmi_cpufreq_get_rate()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
[ Upstream commit 484d3f15cc6cbaa52541d6259778e715b2c83c54 ]
cpufreq_cpu_get_raw() can return NULL when the target CPU is not present in the policy->cpus mask. scmi_cpufreq_get_rate() does not check for this case, which results in a NULL pointer dereference.
Add NULL check after cpufreq_cpu_get_raw() to prevent this issue.
--- drivers/cpufreq/scmi-cpufreq.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/cpufreq/scmi-cpufreq.c +8 -2
@@ -29,12 +29,18 @@ static const struct scmi_handle *handle;static unsigned int scmi_cpufreq_get_rate (unsigned int cpu) { -struct cpufreq_policy *policy =cpufreq_cpu_get_raw (cpu); +struct cpufreq_policy *policy; +struct scmi_data *priv;const struct scmi_perf_ops *perf_ops = handle->perf_ops; -struct scmi_data *priv = policy->driver_data;unsigned long rate;int ret; + policy =cpufreq_cpu_get_raw (cpu); +if (unlikely (!policy)) +return 0 ; + + priv = policy->driver_data; + ret = perf_ops->freq_get (handle, priv->domain_id, &rate, false);if (ret)return 0 ;
Greg Kroah-Hartman
maintainerPATCH 398/451 ovl: Use "buf" flexible array for memcpy() destination
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit cf8aa9bf97cadf85745506c6a3e244b22c268d63 upstream.
The "buf" flexible array needs to be the memcpy() destination to avoid false positive run-time warning from the recent FORTIFY_SOURCE hardening:
memcpy: detected field-spanning write (size 93) of single field "&fh->fb" at fs/overlayfs/export.c:799 (size 21)
--- fs/overlayfs/export.c | 2 +- fs/overlayfs/overlayfs.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/overlayfs/export.c +1 -1
@@ -788,7 +788,7 @@ static struct ovl_fh *ovl_fid_to_fh(strureturn ERR_PTR (-ENOMEM );/* Copy unaligned inner fh into aligned buffer */ -memcpy (&fh->fb, fid, buflen -OVL_FH_WIRE_OFFSET ); +memcpy (fh->buf, fid, buflen -OVL_FH_WIRE_OFFSET );return fh; }
fs/overlayfs/overlayfs.h +1 -1
@@ -104,7 +104,7 @@ struct ovl_fh {u8 padding[3 ];/* make sure fb.fid is 32bit aligned */ union {struct ovl_fb fb; -u8 buf[0 ]; + DECLARE_FLEX_ARRAY(u8, buf); }; } __packed;
Greg Kroah-Hartman
maintainerPATCH 399/451 btrfs: do not clean up repair bio if submit fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 8cbc3001a3264d998d6b6db3e23f935c158abd4d ]
The submit helper will always run bio_endio() on the bio if it fails to submit, so cleaning up the bio just leads to a variety of use-after-free and NULL pointer dereference bugs because we race with the endio function that is cleaning up the bio. Instead just return BLK_STS_OK as the repair function has to continue to process the rest of the pages, and the endio for the repair bio will do the appropriate cleanup for the page that it was given.
--- fs/btrfs/extent_io.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
fs/btrfs/extent_io.c +7 -8
@@ -2655,7 +2655,6 @@ blk_status_t btrfs_submit_read_repair(stbool need_validation;struct bio *repair_bio;struct btrfs_io_bio *repair_io_bio; -blk_status_t status;btrfs_debug (fs_info,"repair read error: read error at %llu" , start);
@@ -2699,13 +2698,13 @@ blk_status_t btrfs_submit_read_repair(st"repair read error: submitting new read to mirror %d, in_validation=%d" , failrec->this_mirror, failrec->in_validation); - status =submit_bio_hook (inode, repair_bio, failrec->this_mirror, - failrec->bio_flags); -if (status) { -free_io_failure (failure_tree, tree, failrec); -bio_put (repair_bio); - } -return status; +/* +* At this point we have a bio, so any errors from submit_bio_hook() +* will be handled by the endio on the repair_bio, so we can't return an +* error here. +*/ +submit_bio_hook (inode, repair_bio, failrec->this_mirror, failrec->bio_flags); +return BLK_STS_OK ; }/* lots and lots of room for performance fixes in the end_bio funcs */
Greg Kroah-Hartman
maintainerPATCH 400/451 bus: fsl-mc-bus: fix KASAN use-after-free in fsl_mc_bus_remove()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shin'ichiro Kawasaki <[email protected]>
commit 928ea98252ad75118950941683893cf904541da9 upstream.
In fsl_mc_bus_remove(), mc->root_mc_bus_dev->mc_io is passed to fsl_destroy_mc_io(). However, mc->root_mc_bus_dev is already freed in fsl_mc_device_remove(). Then reference to mc->root_mc_bus_dev->mc_io triggers KASAN use-after-free. To avoid the use-after-free, keep the reference to mc->root_mc_bus_dev->mc_io in a local variable and pass to fsl_destroy_mc_io().
This patch needs rework to apply to kernels older than v5.15.
--- drivers/bus/fsl-mc/fsl-mc-bus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/bus/fsl-mc/fsl-mc-bus.c +3 -3
@@ -1085,14 +1085,14 @@ error_cleanup_mc_io:static int fsl_mc_bus_remove (struct platform_device *pdev) {struct fsl_mc *mc =platform_get_drvdata (pdev); +struct fsl_mc_io *mc_io;if (!fsl_mc_is_root_dprc (&mc->root_mc_bus_dev->dev))return -EINVAL ; + mc_io = mc->root_mc_bus_dev->mc_io;fsl_mc_device_remove (mc->root_mc_bus_dev); - -fsl_destroy_mc_io (mc->root_mc_bus_dev->mc_io); - mc->root_mc_bus_dev->mc_io =NULL ; +fsl_destroy_mc_io (mc_io);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 401/451 leds: lp50xx: Reduce level of dereferences
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit 556f15fe023ec1d9f9cd2781ba6cd14bda650d22 ]
The priv->dev is effectively the same as &priv->client->dev. So, drop the latter for the former.
Stable-dep-of: 434959618c47 ("leds: leds-lp50xx: Enable chip before any communication")
--- drivers/leds/leds-lp50xx.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
drivers/leds/leds-lp50xx.c +12 -14
@@ -322,7 +322,7 @@ static int lp50xx_brightness_set(struct ret =regmap_write (led->priv->regmap, reg_val, brightness);if (ret) { -dev_err (&led->priv->client->dev, +dev_err (led->priv->dev,"Cannot write brightness value %d\n" , ret); goto out; }
@@ -338,7 +338,7 @@ static int lp50xx_brightness_set(struct ret =regmap_write (led->priv->regmap, reg_val, mc_dev->subled_info[i].intensity);if (ret) { -dev_err (&led->priv->client->dev, +dev_err (led->priv->dev,"Cannot write intensity value %d\n" , ret); goto out; }
@@ -402,7 +402,7 @@ static int lp50xx_probe_leds(struct fwnoif (num_leds >1 ) {if (num_leds > priv->chip_info->max_modules) { -dev_err (&priv->client->dev,"reg property is invalid\n" ); +dev_err (priv->dev,"reg property is invalid\n" );return -EINVAL ; }
@@ -410,13 +410,13 @@ static int lp50xx_probe_leds(struct fwno ret =fwnode_property_read_u32_array (child,"reg" , led_banks, num_leds);if (ret) { -dev_err (&priv->client->dev,"reg property is missing\n" ); +dev_err (priv->dev,"reg property is missing\n" );return ret; } ret =lp50xx_set_banks (priv, led_banks, num_leds);if (ret) { -dev_err (&priv->client->dev,"Cannot setup banked LEDs\n" ); +dev_err (priv->dev,"Cannot setup banked LEDs\n" );return ret; }
@@ -424,12 +424,12 @@ static int lp50xx_probe_leds(struct fwno }else { ret =fwnode_property_read_u32 (child,"reg" , &led_number);if (ret) { -dev_err (&priv->client->dev,"led reg property missing\n" ); +dev_err (priv->dev,"led reg property missing\n" );return ret; }if (led_number > priv->chip_info->num_leds) { -dev_err (&priv->client->dev,"led-sources property is invalid\n" ); +dev_err (priv->dev,"led-sources property is invalid\n" );return -EINVAL ; }
@@ -468,7 +468,7 @@ static int lp50xx_probe_dt(struct lp50xx led = &priv->leds[i]; ret =fwnode_property_count_u32 (child,"reg" );if (ret <0 ) { -dev_err (&priv->client->dev,"reg property is invalid\n" ); +dev_err (priv->dev,"reg property is invalid\n" ); goto child_out; }
@@ -518,12 +518,11 @@ static int lp50xx_probe_dt(struct lp50xx led_cdev = &led->mc_cdev.led_cdev; led_cdev->brightness_set_blocking = lp50xx_brightness_set; - ret =devm_led_classdev_multicolor_register_ext (&priv->client->dev, + ret =devm_led_classdev_multicolor_register_ext (priv->dev, &led->mc_cdev, &init_data);if (ret) { -dev_err (&priv->client->dev,"led register err: %d\n" , - ret); +dev_err (priv->dev,"led register err: %d\n" , ret); goto child_out; } i++;
@@ -586,15 +585,14 @@ static int lp50xx_remove(struct i2c_clie ret =lp50xx_enable_disable (led,0 );if (ret) { -dev_err (&led->client->dev,"Failed to disable chip\n" ); +dev_err (led->dev,"Failed to disable chip\n" );return ret; }if (led->regulator) { ret =regulator_disable (led->regulator);if (ret) -dev_err (&led->client->dev, -"Failed to disable regulator\n" ); +dev_err (led->dev,"Failed to disable regulator\n" ); }mutex_destroy (&led->lock);
Greg Kroah-Hartman
maintainerPATCH 402/451 leds: lp50xx: Get rid of redundant check in lp50xx_enable_disable()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit 5d2bfb3fb95b2d448c0fbcaa2c58b215b2fa87fc ]
Since GPIO is optional the API is NULL aware and will check descriptor anyway. Remove duplicate redundant check in lp50xx_enable_disable().
Stable-dep-of: 434959618c47 ("leds: leds-lp50xx: Enable chip before any communication")
--- drivers/leds/leds-lp50xx.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/leds/leds-lp50xx.c +3 -5
@@ -380,11 +380,9 @@ static int lp50xx_enable_disable(struct {int ret; -if (priv->enable_gpio) { - ret =gpiod_direction_output (priv->enable_gpio, enable_disable); -if (ret) -return ret; - } + ret =gpiod_direction_output (priv->enable_gpio, enable_disable); +if (ret) +return ret;if (enable_disable)return regmap_write (priv->regmap,LP50XX_DEV_CFG0 ,LP50XX_CHIP_EN );
Greg Kroah-Hartman
maintainerPATCH 403/451 leds: lp50xx: Remove duplicated error reporting in .remove()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 73bce575ed90c752eaa4b2b9a70860481d58d240 ]
Returning an error value from an i2c remove callback results in an error message being emitted by the i2c core, but otherwise it doesn't make a difference. The device goes away anyhow and the devm cleanups are called.
As stk3310_set_state() already emits an error message on failure and the additional error message by the i2c core doesn't add any useful information, don't pass the error value up the stack. Instead continue to clean up and return 0.
This patch is a preparation for making i2c remove callbacks return void.
Stable-dep-of: 434959618c47 ("leds: leds-lp50xx: Enable chip before any communication")
--- drivers/leds/leds-lp50xx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/leds/leds-lp50xx.c +1 -3
@@ -582,10 +582,8 @@ static int lp50xx_remove(struct i2c_clieint ret; ret =lp50xx_enable_disable (led,0 ); -if (ret) { +if (ret)dev_err (led->dev,"Failed to disable chip\n" ); -return ret; - }if (led->regulator) { ret =regulator_disable (led->regulator);
Greg Kroah-Hartman
maintainerPATCH 377/451 PCI: brcmstb: Fix disabling L0s capability
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jim Quinlan <[email protected]>
[ Upstream commit 9583f9d22991d2cfb5cc59a2552040c4ae98d998 ]
caab002d5069 ("PCI: brcmstb: Disable L0s component of ASPM if requested") set PCI_EXP_LNKCAP_ASPM_L1 and (optionally) PCI_EXP_LNKCAP_ASPM_L0S in PCI_EXP_LNKCAP (aka PCIE_RC_CFG_PRIV1_LINK_CAPABILITY in brcmstb).
But instead of using PCI_EXP_LNKCAP_ASPM_L1 and PCI_EXP_LNKCAP_ASPM_L0S directly, it used PCIE_LINK_STATE_L1 and PCIE_LINK_STATE_L0S, which are Linux-created values that only coincidentally matched the PCIe spec. b478e162f227 ("PCI/ASPM: Consolidate link state defines") later changed them so they no longer matched the PCIe spec, so the bits ended up in the wrong place in PCI_EXP_LNKCAP.
Use PCI_EXP_LNKCAP_ASPM_L0S to clear L0s support when there's an 'aspm-no-l0s' property. Rely on brcmstb hardware to advertise L0s and/or L1 support otherwise.
--- drivers/pci/controller/pcie-brcmstb.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/pci/controller/pcie-brcmstb.c +3 -7
@@ -43,7 +43,6 @@#define PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK 0xffffff#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY 0x04dc -#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK 0xc00#define PCIE_RC_DL_MDIO_ADDR 0x1100#define PCIE_RC_DL_MDIO_WR_DATA 0x1104
@@ -865,7 +864,7 @@ static int brcm_pcie_setup(struct brcm_pint num_out_wins =0 ;u16 nlw, cls, lnksta;int i, ret, memc; -u32 tmp, burst, aspm_support; +u32 tmp, burst;/* Reset the bridge */ pcie->bridge_sw_init_set (pcie,1 );
@@ -987,12 +986,9 @@ static int brcm_pcie_setup(struct brcm_p }/* Don't advertise L0s capability if 'aspm-no-l0s' */ - aspm_support =PCIE_LINK_STATE_L1 ; -if (!of_property_read_bool (pcie->np,"aspm-no-l0s" )) - aspm_support |=PCIE_LINK_STATE_L0S ; tmp =readl (base +PCIE_RC_CFG_PRIV1_LINK_CAPABILITY ); -u32p_replace_bits (&tmp, aspm_support, -PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK ); +if (of_property_read_bool (pcie->np,"aspm-no-l0s" )) + tmp &= ~PCI_EXP_LNKCAP_ASPM_L0S ;writel (tmp, base +PCIE_RC_CFG_PRIV1_LINK_CAPABILITY );/*
Greg Kroah-Hartman
maintainerPATCH 404/451 leds: leds-lp50xx: Enable chip before any communication
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Hitz <[email protected]>
[ Upstream commit 434959618c47efe9e5f2e20f4a850caac4f6b823 ]
If a GPIO is used to control the chip's enable pin, it needs to be pulled high before any i2c communication is attempted.
Currently, the enable GPIO handling is not correct.
Assume the enable GPIO is low when the probe function is entered. In this case the device is in SHUTDOWN mode and does not react to i2c commands.
During probe the following sequence happens:
1. The call to lp50xx_reset() on line 548 has no effect as i2c is not possible yet.
2. Then - on line 552 - lp50xx_enable_disable() is called. As "priv->enable_gpio“ has not yet been initialized, setting the GPIO has no effect. Also the i2c enable command is not executed as the device is still in SHUTDOWN.
3. On line 556 the call to lp50xx_probe_dt() finally parses the rest of
the DT and the configured priv->enable_gpio is set up.
As a result the device is still in SHUTDOWN mode and not ready for operation.
Split lp50xx_enable_disable() into distinct enable and disable functions to enforce correct ordering between enable_gpio manipulations and i2c commands.
Read enable_gpio configuration from DT before attempting to manipulate enable_gpio.
Add delays to observe correct wait timing after manipulating enable_gpio and before any i2c communication.
--- drivers/leds/leds-lp50xx.c | 55 ++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 15 deletions(-)
drivers/leds/leds-lp50xx.c +40 -15
@@ -53,6 +53,12 @@#define LP50XX_SW_RESET 0xff#define LP50XX_CHIP_EN BIT(6) +#define LP50XX_CHIP_DISABLE 0x00 +#define LP50XX_START_TIME_US 500 +#define LP50XX_RESET_TIME_US 3 + +#define LP50XX_EN_GPIO_LOW 0 +#define LP50XX_EN_GPIO_HIGH 1/* There are 3 LED outputs per bank */ #define LP50XX_LEDS_PER_MODULE 3
@@ -376,19 +382,42 @@ static int lp50xx_reset(struct lp50xx *preturn regmap_write (priv->regmap, priv->chip_info->reset_reg,LP50XX_SW_RESET ); } -static int lp50xx_enable_disable (struct lp50xx *priv,int enable_disable) +static int lp50xx_enable (struct lp50xx *priv) {int ret; - ret =gpiod_direction_output (priv->enable_gpio, enable_disable); +if (priv->enable_gpio) { + ret =gpiod_direction_output (priv->enable_gpio,LP50XX_EN_GPIO_HIGH ); +if (ret) +return ret; + +udelay (LP50XX_START_TIME_US ); + } + + ret =lp50xx_reset (priv);if (ret)return ret; -if (enable_disable) -return regmap_write (priv->regmap,LP50XX_DEV_CFG0 ,LP50XX_CHIP_EN ); -else -return regmap_write (priv->regmap,LP50XX_DEV_CFG0 ,0 ); +return regmap_write (priv->regmap,LP50XX_DEV_CFG0 ,LP50XX_CHIP_EN ); +} +static int lp50xx_disable (struct lp50xx *priv) +{ +int ret; + + ret =regmap_write (priv->regmap,LP50XX_DEV_CFG0 ,LP50XX_CHIP_DISABLE ); +if (ret) +return ret; + +if (priv->enable_gpio) { + ret =gpiod_direction_output (priv->enable_gpio,LP50XX_EN_GPIO_LOW ); +if (ret) +return ret; + +udelay (LP50XX_RESET_TIME_US ); + } + +return 0 ; } static int lp50xx_probe_leds(struct fwnode_handle *child, struct lp50xx *priv,
@@ -458,6 +487,10 @@ static int lp50xx_probe_dt(struct lp50xxreturn ret; } + ret =lp50xx_enable (priv); +if (ret) +return ret; + priv->regulator =devm_regulator_get (priv->dev,"vled" );if (IS_ERR (priv->regulator)) priv->regulator =NULL ;
@@ -565,14 +598,6 @@ static int lp50xx_probe(struct i2c_clienreturn ret; } - ret =lp50xx_reset (led); -if (ret) -return ret; - - ret =lp50xx_enable_disable (led,1 ); -if (ret) -return ret; -return lp50xx_probe_dt (led); }
@@ -581,7 +606,7 @@ static int lp50xx_remove(struct i2c_cliestruct lp50xx *led =i2c_get_clientdata (client);int ret; - ret =lp50xx_enable_disable (led,0 ); + ret =lp50xx_disable (led);if (ret)dev_err (led->dev,"Failed to disable chip\n" );
Greg Kroah-Hartman
maintainerPATCH 405/451 pwm: stm32: Always program polarity
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Nyekjaer <[email protected]>
Commit 7346e7a058a2 ("pwm: stm32: Always do lazy disabling") triggered a regression where PWM polarity changes could be ignored.
stm32_pwm_set_polarity() was skipped due to a mismatch between the cached pwm->state.polarity and the actual hardware state, leaving the hardware polarity unchanged.
--- drivers/pwm/pwm-stm32.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/pwm/pwm-stm32.c +1 -2
@@ -458,8 +458,7 @@ static int stm32_pwm_apply(struct pwm_chreturn 0 ; } -if (state->polarity != pwm->state.polarity) -stm32_pwm_set_polarity (priv, pwm->hwpwm, state->polarity); +stm32_pwm_set_polarity (priv, pwm->hwpwm, state->polarity); ret =stm32_pwm_config (priv, pwm->hwpwm, state->duty_cycle, state->period);
Greg Kroah-Hartman
maintainerPATCH 406/451 Revert "iommu/amd: Skip enabling command/event buffers for kdump"
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
This reverts commit 30e91eeb0bc9b3daf402b26176d1d52c29ab53e4 which is commit 9be15fbfc6c5c89c22cf6e209f66ea43ee0e58bb upstream.
This causes problems in older kernel trees as SNP host kdump is not supported in them, so drop it from the stable branches.
--- drivers/iommu/amd/init.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
drivers/iommu/amd/init.c +9 -19
@@ -697,16 +697,11 @@ static void iommu_enable_command_buffer(BUG_ON (iommu->cmd_buf ==NULL ); -if (!is_kdump_kernel ()) { -/* -* Command buffer is re-used for kdump kernel and setting -* of MMIO register is not required. -*/ - entry =iommu_virt_to_phys (iommu->cmd_buf); - entry |=MMIO_CMD_SIZE_512 ; -memcpy_toio (iommu->mmio_base +MMIO_CMD_BUF_OFFSET , - &entry,sizeof (entry)); - } + entry =iommu_virt_to_phys (iommu->cmd_buf); + entry |=MMIO_CMD_SIZE_512 ; + +memcpy_toio (iommu->mmio_base +MMIO_CMD_BUF_OFFSET , + &entry,sizeof (entry));amd_iommu_reset_cmd_buffer (iommu); }
@@ -755,15 +750,10 @@ static void iommu_enable_event_buffer(stBUG_ON (iommu->evt_buf ==NULL ); -if (!is_kdump_kernel ()) { -/* -* Event buffer is re-used for kdump kernel and setting -* of MMIO register is not required. -*/ - entry =iommu_virt_to_phys (iommu->evt_buf) |EVT_LEN_MASK ; -memcpy_toio (iommu->mmio_base +MMIO_EVT_BUF_OFFSET , - &entry,sizeof (entry)); - } + entry =iommu_virt_to_phys (iommu->evt_buf) |EVT_LEN_MASK ; + +memcpy_toio (iommu->mmio_base +MMIO_EVT_BUF_OFFSET , + &entry,sizeof (entry));/* set head and tail to zero manually */ writel (0x00 , iommu->mmio_base +MMIO_EVT_HEAD_OFFSET );
Greg Kroah-Hartman
maintainerPATCH 407/451 scsi: core: ufs: Fix a hang in the error handler
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanjeev Yadav <[email protected]>
commit 8a3514d348de87a9d5e2ac00fbac4faae0b97996 upstream.
ufshcd_err_handling_prepare() calls ufshcd_rpm_get_sync(). The latter function can only succeed if UFSHCD_EH_IN_PROGRESS is not set because resuming involves submitting a SCSI command and ufshcd_queuecommand() returns SCSI_MLQUEUE_HOST_BUSY if UFSHCD_EH_IN_PROGRESS is set. Fix this hang by setting UFSHCD_EH_IN_PROGRESS after ufshcd_rpm_get_sync() has been called instead of before.
Backtrace: __switch_to+0x174/0x338 __schedule+0x600/0x9e4 schedule+0x7c/0xe8 schedule_timeout+0xa4/0x1c8 io_schedule_timeout+0x48/0x70 wait_for_common_io+0xa8/0x160 //waiting on START_STOP wait_for_completion_io_timeout+0x10/0x20 blk_execute_rq+0xe4/0x1e4 scsi_execute_cmd+0x108/0x244 ufshcd_set_dev_pwr_mode+0xe8/0x250 __ufshcd_wl_resume+0x94/0x354 ufshcd_wl_runtime_resume+0x3c/0x174 scsi_runtime_resume+0x64/0xa4 rpm_resume+0x15c/0xa1c __pm_runtime_resume+0x4c/0x90 // Runtime resume ongoing ufshcd_err_handler+0x1a0/0xd08 process_one_work+0x174/0x808 worker_thread+0x15c/0x490 kthread+0xf4/0x1ec ret_from_fork+0x10/0x20
--- drivers/scsi/ufs/ufshcd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +3 -1
@@ -5766,10 +5766,12 @@ static void ufshcd_err_handler(struct wospin_unlock_irqrestore (hba->host->host_lock, flags);return ; } -ufshcd_set_eh_in_progress (hba);spin_unlock_irqrestore (hba->host->host_lock, flags); +ufshcd_err_handling_prepare (hba); +spin_lock_irqsave (hba->host->host_lock, flags); +ufshcd_set_eh_in_progress (hba);ufshcd_scsi_block_requests (hba);/* * A full reset and restore might have happened after preparation
Greg Kroah-Hartman
maintainerPATCH 408/451 net: ethtool: fix the error condition in ethtool_get_phy_stats_ethtool()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Su Hui <[email protected]>
commit 0dcc53abf58d572d34c5313de85f607cd33fc691 upstream.
Clang static checker (scan-build) warning:
net/ethtool/ioctl.c:line 2233, column 2 Called function pointer is null (null dereference).
Return '-EOPNOTSUPP' when 'ops->get_ethtool_phy_stats' is NULL to fix this typo error.
--- net/ethtool/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ethtool/ioctl.c +1 -1
@@ -2089,7 +2089,7 @@ static int ethtool_get_phy_stats_ethtoolconst struct ethtool_ops *ops = dev->ethtool_ops;int n_stats, ret; -if (!ops || !ops->get_sset_count || ops->get_ethtool_phy_stats) +if (!ops || !ops->get_sset_count || !ops->get_ethtool_phy_stats)return -EOPNOTSUPP ; n_stats = ops->get_sset_count (dev,ETH_SS_PHY_STATS );
Greg Kroah-Hartman
maintainerPATCH 378/451 powerpc/pseries/cmm: call balloon_devinfo_init() also without CONFIG_BALLOON_COMPACTION
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
[ Upstream commit fc6bcf9ac4de76f5e7bcd020b3c0a86faff3f2d5 ]
Patch series "powerpc/pseries/cmm: two smaller fixes".
Two smaller fixes identified while doing a bigger rework.
This patch (of 2):
We always have to initialize the balloon_dev_info, even when compaction is not configured in: otherwise the containing list and the lock are left uninitialized.
Likely not many such configs exist in practice, but let's CC stable to be sure.
This was found by code inspection.
--- arch/powerpc/platforms/pseries/cmm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/platforms/pseries/cmm.c +1 -1
@@ -570,7 +570,6 @@ static int cmm_balloon_compaction_init(v {int rc; -balloon_devinfo_init (&b_dev_info); b_dev_info.migratepage = cmm_migratepage; balloon_mnt =kern_mount (&balloon_fs);
@@ -624,6 +623,7 @@ static int cmm_init(void)if (!firmware_has_feature (FW_FEATURE_CMO ) && !simulate)return -EOPNOTSUPP ; +balloon_devinfo_init (&b_dev_info); rc =cmm_balloon_compaction_init ();if (rc)return rc;
Greg Kroah-Hartman
maintainerPATCH 379/451 media: renesas: rcar_drif: fix device node reference leak in rcar_drif_bond_enabled
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miaoqian Lin <[email protected]>
[ Upstream commit 445e1658894fd74eab7e53071fa16233887574ed ]
The function calls of_parse_phandle() which returns
a device node with an incremented reference count. When the bonded device is not available, the function
returns NULL without releasing the reference, causing a reference leak.
Add of_node_put(np) to release the device node reference. The of_node_put function handles NULL pointers.
Found through static analysis by reviewing the doc of of_parse_phandle() and cross-checking its usage patterns across the codebase.
--- drivers/media/platform/rcar_drif.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/rcar_drif.c +1 -0
@@ -1253,6 +1253,7 @@ static struct device_node *rcar_drif_bonif (np &&of_device_is_available (np))return np; +of_node_put (np);return NULL ; }
Greg Kroah-Hartman
maintainerPATCH 380/451 ASoC: stm: Use dev_err_probe() helper
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuninori Morimoto <[email protected]>
[ Upstream commit efc162cbd480f1fb47d439c193ec9731bcc6c749 ]
Use the dev_err_probe() helper, instead of open-coding the same operation.
Stable-dep-of: 312ec2f0d9d1 ("ASoC: stm32: sai: fix clk prepare imbalance on probe failure")
--- sound/soc/stm/stm32_i2s.c | 62 ++++++++++++++---------------------------- sound/soc/stm/stm32_sai.c | 37 ++++++++----------------- sound/soc/stm/stm32_sai_sub.c | 25 +++++----------- sound/soc/stm/stm32_spdifrx.c | 44 ++++++++++------------------- 4 files changed, 57 insertions(+), 111 deletions(-)
sound/soc/stm/stm32_i2s.c +21 -41
@@ -830,36 +830,24 @@ static int stm32_i2s_parse_dt(struct pla/* Get clocks */ i2s->pclk =devm_clk_get (&pdev->dev,"pclk" ); -if (IS_ERR (i2s->pclk)) { -if (PTR_ERR (i2s->pclk) != -EPROBE_DEFER ) -dev_err (&pdev->dev,"Could not get pclk: %ld\n" , -PTR_ERR (i2s->pclk)); -return PTR_ERR (i2s->pclk); - } +if (IS_ERR (i2s->pclk)) +return dev_err_probe (&pdev->dev,PTR_ERR (i2s->pclk), +"Could not get pclk\n" ); i2s->i2sclk =devm_clk_get (&pdev->dev,"i2sclk" ); -if (IS_ERR (i2s->i2sclk)) { -if (PTR_ERR (i2s->i2sclk) != -EPROBE_DEFER ) -dev_err (&pdev->dev,"Could not get i2sclk: %ld\n" , -PTR_ERR (i2s->i2sclk)); -return PTR_ERR (i2s->i2sclk); - } +if (IS_ERR (i2s->i2sclk)) +return dev_err_probe (&pdev->dev,PTR_ERR (i2s->i2sclk), +"Could not get i2sclk\n" ); i2s->x8kclk =devm_clk_get (&pdev->dev,"x8k" ); -if (IS_ERR (i2s->x8kclk)) { -if (PTR_ERR (i2s->x8kclk) != -EPROBE_DEFER ) -dev_err (&pdev->dev,"Could not get x8k parent clock: %ld\n" , -PTR_ERR (i2s->x8kclk)); -return PTR_ERR (i2s->x8kclk); - } +if (IS_ERR (i2s->x8kclk)) +return dev_err_probe (&pdev->dev,PTR_ERR (i2s->x8kclk), +"Could not get x8k parent clock\n" ); i2s->x11kclk =devm_clk_get (&pdev->dev,"x11k" ); -if (IS_ERR (i2s->x11kclk)) { -if (PTR_ERR (i2s->x11kclk) != -EPROBE_DEFER ) -dev_err (&pdev->dev,"Could not get x11k parent clock: %ld\n" , -PTR_ERR (i2s->x11kclk)); -return PTR_ERR (i2s->x11kclk); - } +if (IS_ERR (i2s->x11kclk)) +return dev_err_probe (&pdev->dev,PTR_ERR (i2s->x11kclk), +"Could not get x11k parent clock\n" );/* Get irqs */ irq =platform_get_irq (pdev,0 );
@@ -875,12 +863,10 @@ static int stm32_i2s_parse_dt(struct pla/* Reset */ rst =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL ); -if (IS_ERR (rst)) { -if (PTR_ERR (rst) != -EPROBE_DEFER ) -dev_err (&pdev->dev,"Reset controller error %ld\n" , -PTR_ERR (rst)); -return PTR_ERR (rst); - } +if (IS_ERR (rst)) +return dev_err_probe (&pdev->dev,PTR_ERR (rst), +"Reset controller error\n" ); +reset_control_assert (rst);udelay (2 );reset_control_deassert (rst);
@@ -922,19 +908,13 @@ static int stm32_i2s_probe(struct platfo i2s->regmap =devm_regmap_init_mmio_clk (&pdev->dev,"pclk" , i2s->base, i2s->regmap_conf); -if (IS_ERR (i2s->regmap)) { -if (PTR_ERR (i2s->regmap) != -EPROBE_DEFER ) -dev_err (&pdev->dev,"Regmap init error %ld\n" , -PTR_ERR (i2s->regmap)); -return PTR_ERR (i2s->regmap); - } +if (IS_ERR (i2s->regmap)) +return dev_err_probe (&pdev->dev,PTR_ERR (i2s->regmap), +"Regmap init error\n" ); ret =snd_dmaengine_pcm_register (&pdev->dev, &stm32_i2s_pcm_config,0 ); -if (ret) { -if (ret != -EPROBE_DEFER ) -dev_err (&pdev->dev,"PCM DMA register error %d\n" , ret); -return ret; - } +if (ret) +return dev_err_probe (&pdev->dev, ret,"PCM DMA register error\n" ); ret =snd_soc_register_component (&pdev->dev, &stm32_i2s_component, i2s->dai_drv,1 );
sound/soc/stm/stm32_sai.c +13 -24
@@ -173,29 +173,20 @@ static int stm32_sai_probe(struct platfoif (!STM_SAI_IS_F4 (sai)) { sai->pclk =devm_clk_get (&pdev->dev,"pclk" ); -if (IS_ERR (sai->pclk)) { -if (PTR_ERR (sai->pclk) != -EPROBE_DEFER ) -dev_err (&pdev->dev,"missing bus clock pclk: %ld\n" , -PTR_ERR (sai->pclk)); -return PTR_ERR (sai->pclk); - } +if (IS_ERR (sai->pclk)) +return dev_err_probe (&pdev->dev,PTR_ERR (sai->pclk), +"missing bus clock pclk\n" ); } sai->clk_x8k =devm_clk_get (&pdev->dev,"x8k" ); -if (IS_ERR (sai->clk_x8k)) { -if (PTR_ERR (sai->clk_x8k) != -EPROBE_DEFER ) -dev_err (&pdev->dev,"missing x8k parent clock: %ld\n" , -PTR_ERR (sai->clk_x8k)); -return PTR_ERR (sai->clk_x8k); - } +if (IS_ERR (sai->clk_x8k)) +return dev_err_probe (&pdev->dev,PTR_ERR (sai->clk_x8k), +"missing x8k parent clock\n" ); sai->clk_x11k =devm_clk_get (&pdev->dev,"x11k" ); -if (IS_ERR (sai->clk_x11k)) { -if (PTR_ERR (sai->clk_x11k) != -EPROBE_DEFER ) -dev_err (&pdev->dev,"missing x11k parent clock: %ld\n" , -PTR_ERR (sai->clk_x11k)); -return PTR_ERR (sai->clk_x11k); - } +if (IS_ERR (sai->clk_x11k)) +return dev_err_probe (&pdev->dev,PTR_ERR (sai->clk_x11k), +"missing x11k parent clock\n" );/* init irqs */ sai->irq =platform_get_irq (pdev,0 );
@@ -204,12 +195,10 @@ static int stm32_sai_probe(struct platfo/* reset */ rst =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL ); -if (IS_ERR (rst)) { -if (PTR_ERR (rst) != -EPROBE_DEFER ) -dev_err (&pdev->dev,"Reset controller error %ld\n" , -PTR_ERR (rst)); -return PTR_ERR (rst); - } +if (IS_ERR (rst)) +return dev_err_probe (&pdev->dev,PTR_ERR (rst), +"Reset controller error\n" ); +reset_control_assert (rst);udelay (2 );reset_control_deassert (rst);
sound/soc/stm/stm32_sai_sub.c +8 -17
@@ -1380,12 +1380,9 @@ static int stm32_sai_sub_parse_of(struct*/ sai->regmap =devm_regmap_init_mmio (&pdev->dev, base, sai->regmap_config); -if (IS_ERR (sai->regmap)) { -if (PTR_ERR (sai->regmap) != -EPROBE_DEFER ) -dev_err (&pdev->dev,"Regmap init error %ld\n" , -PTR_ERR (sai->regmap)); -return PTR_ERR (sai->regmap); - } +if (IS_ERR (sai->regmap)) +return dev_err_probe (&pdev->dev,PTR_ERR (sai->regmap), +"Regmap init error\n" );/* Get direction property */ if (of_property_match_string (np,"dma-names" ,"tx" ) >=0 ) {
@@ -1473,12 +1470,9 @@ static int stm32_sai_sub_parse_of(structof_node_put (args.np); sai->sai_ck =devm_clk_get (&pdev->dev,"sai_ck" ); -if (IS_ERR (sai->sai_ck)) { -if (PTR_ERR (sai->sai_ck) != -EPROBE_DEFER ) -dev_err (&pdev->dev,"Missing kernel clock sai_ck: %ld\n" , -PTR_ERR (sai->sai_ck)); -return PTR_ERR (sai->sai_ck); - } +if (IS_ERR (sai->sai_ck)) +return dev_err_probe (&pdev->dev,PTR_ERR (sai->sai_ck), +"Missing kernel clock sai_ck\n" ); ret =clk_prepare (sai->pdata->pclk);if (ret <0 )
@@ -1552,11 +1546,8 @@ static int stm32_sai_sub_probe(struct pl conf = &stm32_sai_pcm_config_spdif; ret =snd_dmaengine_pcm_register (&pdev->dev, conf,0 ); -if (ret) { -if (ret != -EPROBE_DEFER ) -dev_err (&pdev->dev,"Could not register pcm dma\n" ); -return ret; - } +if (ret) +return dev_err_probe (&pdev->dev, ret,"Could not register pcm dma\n" ); ret =snd_soc_register_component (&pdev->dev, &stm32_component, &sai->cpu_dai_drv,1 );
sound/soc/stm/stm32_spdifrx.c +15 -29
74 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 381/451 ASoC: stm32: sai: Use the devm_clk_get_optional() helper
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit 374628fb668e50b42fe81f2a63af616182415bcd ]
Use devm_clk_get_optional() instead of hand writing it. This saves some LoC and improves the semantic.
Stable-dep-of: 312ec2f0d9d1 ("ASoC: stm32: sai: fix clk prepare imbalance on probe failure")
--- sound/soc/stm/stm32_sai_sub.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
sound/soc/stm/stm32_sai_sub.c +3 -6
@@ -1487,12 +1487,9 @@ static int stm32_sai_sub_parse_of(structif (ret <0 )return ret; }else { - sai->sai_mclk =devm_clk_get (&pdev->dev,"MCLK" ); -if (IS_ERR (sai->sai_mclk)) { -if (PTR_ERR (sai->sai_mclk) != -ENOENT ) -return PTR_ERR (sai->sai_mclk); - sai->sai_mclk =NULL ; - } + sai->sai_mclk =devm_clk_get_optional (&pdev->dev,"MCLK" ); +if (IS_ERR (sai->sai_mclk)) +return PTR_ERR (sai->sai_mclk); }return 0 ;
Greg Kroah-Hartman
maintainerPATCH 382/451 ASoC: stm32: sai: fix clk prepare imbalance on probe failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
[ Upstream commit 312ec2f0d9d1a5656f76d770bbf1d967e9289aa7 ]
Make sure to unprepare the parent clock also on probe failures (e.g. probe deferral).
--- sound/soc/stm/stm32_sai_sub.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-)
sound/soc/stm/stm32_sai_sub.c +21 -7
@@ -1485,14 +1485,21 @@ static int stm32_sai_sub_parse_of(structif (of_find_property (np,"#clock-cells" ,NULL )) { ret =stm32_sai_add_mclk_provider (sai);if (ret <0 ) -return ret; + goto err_unprepare_pclk; }else { sai->sai_mclk =devm_clk_get_optional (&pdev->dev,"MCLK" ); -if (IS_ERR (sai->sai_mclk)) -return PTR_ERR (sai->sai_mclk); +if (IS_ERR (sai->sai_mclk)) { + ret =PTR_ERR (sai->sai_mclk); + goto err_unprepare_pclk; + } }return 0 ; + +err_unprepare_pclk: +clk_unprepare (sai->pdata->pclk); + +return ret; }static int stm32_sai_sub_probe (struct platform_device *pdev)
@@ -1536,26 +1543,33 @@ static int stm32_sai_sub_probe(struct pl IRQF_SHARED, dev_name(&pdev->dev), sai);if (ret) {dev_err (&pdev->dev,"IRQ request returned %d\n" , ret); -return ret; + goto err_unprepare_pclk; }if (STM_SAI_PROTOCOL_IS_SPDIF (sai)) conf = &stm32_sai_pcm_config_spdif; ret =snd_dmaengine_pcm_register (&pdev->dev, conf,0 ); -if (ret) -return dev_err_probe (&pdev->dev, ret,"Could not register pcm dma\n" ); +if (ret) { + ret =dev_err_probe (&pdev->dev, ret,"Could not register pcm dma\n" ); + goto err_unprepare_pclk; + } ret =snd_soc_register_component (&pdev->dev, &stm32_component, &sai->cpu_dai_drv,1 );if (ret) {snd_dmaengine_pcm_unregister (&pdev->dev); -return ret; + goto err_unprepare_pclk; }pm_runtime_enable (&pdev->dev);return 0 ; + +err_unprepare_pclk: +clk_unprepare (sai->pdata->pclk); + +return ret; }static int stm32_sai_sub_remove (struct platform_device *pdev)
Greg Kroah-Hartman
maintainerPATCH 383/451 mm/balloon_compaction: make balloon page compaction callbacks static
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miaohe Lin <[email protected]>
[ Upstream commit 504c1cabe325df65c18ef38365ddd1a41c6b591b ]
Since commit b1123ea6d3b3 ("mm: balloon: use general non-lru movable page feature"), these functions are called via balloon_aops callbacks. They're not called directly outside this file. So make them static and clean up the relevant code.
Stable-dep-of: 0da2ba35c0d5 ("powerpc/pseries/cmm: adjust BALLOON_MIGRATE when migrating pages")
--- include/linux/balloon_compaction.h | 22 ---------------------- mm/balloon_compaction.c | 6 +++--- 2 files changed, 3 insertions(+), 25 deletions(-)
include/linux/balloon_compaction.h +0 -22
@@ -80,12 +80,6 @@ static inline void balloon_devinfo_init(#ifdef CONFIG_BALLOON_COMPACTION extern const struct address_space_operations balloon_aops; -extern bool balloon_page_isolate (struct page *page, -isolate_mode_t mode); -extern void balloon_page_putback (struct page *page); -extern int balloon_page_migrate (struct address_space *mapping, -struct page *newpage, -struct page *page,enum migrate_mode mode);/* * balloon_page_insert - insert a page into the balloon's page list and make
@@ -155,22 +149,6 @@ static inline void balloon_page_delete(slist_del (&page->lru); } -static inline bool balloon_page_isolate (struct page *page) -{ -return false; -} - -static inline void balloon_page_putback (struct page *page) -{ -return ; -} - -static inline int balloon_page_migrate (struct page *newpage, -struct page *page,enum migrate_mode mode) -{ -return 0 ; -} -static inline gfp_t balloon_mapping_gfp_mask (void ) {return GFP_HIGHUSER ;
mm/balloon_compaction.c +3 -3
@@ -203,7 +203,7 @@ EXPORT_SYMBOL_GPL(balloon_page_dequeue);#ifdef CONFIG_BALLOON_COMPACTION -bool balloon_page_isolate (struct page *page,isolate_mode_t mode) +static bool balloon_page_isolate (struct page *page,isolate_mode_t mode) {struct balloon_dev_info *b_dev_info =balloon_page_device (page);
@@ -217,7 +217,7 @@ bool balloon_page_isolate(struct page *preturn true; } -void balloon_page_putback (struct page *page) +static void balloon_page_putback (struct page *page) {struct balloon_dev_info *b_dev_info =balloon_page_device (page);unsigned long flags;
@@ -230,7 +230,7 @@ void balloon_page_putback(struct page *p/* move_to_new_page() counterpart for a ballooned page */ -int balloon_page_migrate (struct address_space *mapping, +static int balloon_page_migrate (struct address_space *mapping,struct page *newpage,struct page *page,enum migrate_mode mode) {
Greg Kroah-Hartman
maintainerPATCH 374/451 ARM: dts: microchip: sama5d2: fix spi flexcom fifo size to 32
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Ferre <[email protected]>
[ Upstream commit 7d5864dc5d5ea6a35983dd05295fb17f2f2f44ce ]
Unlike standalone spi peripherals, on sama5d2, the flexcom spi have fifo size of 32 data. Fix flexcom/spi nodes where this property is wrong.
--- arch/arm/boot/dts/sama5d2.dtsi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm/boot/dts/sama5d2.dtsi +5 -5
@@ -555,7 +555,7 @@ AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(12))>; dma-names = "tx", "rx"; - atmel,fifo-size = <16>; + atmel,fifo-size = <32>; status = "disabled"; };
@@ -625,7 +625,7 @@ AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(14))>; dma-names = "tx", "rx"; - atmel,fifo-size = <16>; + atmel,fifo-size = <32>; status = "disabled"; };
@@ -835,7 +835,7 @@ AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(16))>; dma-names = "tx", "rx"; - atmel,fifo-size = <16>; + atmel,fifo-size = <32>; status = "disabled"; };
@@ -925,7 +925,7 @@ AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(18))>; dma-names = "tx", "rx"; - atmel,fifo-size = <16>; + atmel,fifo-size = <32>; status = "disabled"; };
@@ -976,7 +976,7 @@ AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(20))>; dma-names = "tx", "rx"; - atmel,fifo-size = <16>; + atmel,fifo-size = <32>; status = "disabled"; };
Greg Kroah-Hartman
maintainerPATCH 410/451 atm: Fix dma_free_coherent() size
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
commit 4d984b0574ff708e66152763fbfdef24ea40933f upstream.
The size of the buffer is not the same when alloc'd with dma_alloc_coherent() in he_init_tpdrq() and freed.
--- drivers/atm/he.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/atm/he.c +2 -1
@@ -1590,7 +1590,8 @@ he_stop(struct he_dev *he_dev) he_dev->tbrq_base, he_dev->tbrq_phys);if (he_dev->tpdrq_base) -dma_free_coherent (&he_dev->pci_dev->dev,CONFIG_TBRQ_SIZE *sizeof (struct he_tbrq ), +dma_free_coherent (&he_dev->pci_dev->dev, +CONFIG_TPDRQ_SIZE *sizeof (struct he_tpdrq ), he_dev->tpdrq_base, he_dev->tpdrq_phys);dma_pool_destroy (he_dev->tpd_pool);
Greg Kroah-Hartman
maintainerPATCH 419/451 ext4: introduce ITAIL helper
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Bin <[email protected]>
[ Upstream commit 69f3a3039b0d0003de008659cafd5a1eaaa0a7a4 ]
Introduce ITAIL helper to get the bound of xattr in inode.
--- fs/ext4/xattr.c | 10 +++++----- fs/ext4/xattr.h | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-)
fs/ext4/xattr.c +5 -5
@@ -599,7 +599,7 @@ ext4_xattr_ibody_get(struct inode *inodereturn error; raw_inode =ext4_raw_inode (&iloc); header =IHDR (inode, raw_inode); - end = (void *)raw_inode +EXT4_SB (inode->i_sb)->s_inode_size; + end =ITAIL (inode, raw_inode); error =xattr_check_inode (inode, header, end);if (error) goto cleanup;
@@ -744,7 +744,7 @@ ext4_xattr_ibody_list(struct dentry *denreturn error; raw_inode =ext4_raw_inode (&iloc); header =IHDR (inode, raw_inode); - end = (void *)raw_inode +EXT4_SB (inode->i_sb)->s_inode_size; + end =ITAIL (inode, raw_inode); error =xattr_check_inode (inode, header, end);if (error) goto cleanup;
@@ -826,7 +826,7 @@ int ext4_get_inode_usage(struct inode *i goto out; raw_inode =ext4_raw_inode (&iloc); header =IHDR (inode, raw_inode); - end = (void *)raw_inode +EXT4_SB (inode->i_sb)->s_inode_size; + end =ITAIL (inode, raw_inode); ret =xattr_check_inode (inode, header, end);if (ret) goto out;
@@ -2219,7 +2219,7 @@ int ext4_xattr_ibody_find(struct inode * header =IHDR (inode, raw_inode); is->s.base = is->s.first =IFIRST (header); is->s.here = is->s.first; - is->s.end = (void *)raw_inode +EXT4_SB (inode->i_sb)->s_inode_size; + is->s.end =ITAIL (inode, raw_inode);if (ext4_test_inode_state (inode,EXT4_STATE_XATTR )) { error =xattr_check_inode (inode, header, is->s.end);if (error)
@@ -2743,7 +2743,7 @@ retry:*/ base =IFIRST (header); - end = (void *)raw_inode +EXT4_SB (inode->i_sb)->s_inode_size; + end =ITAIL (inode, raw_inode); min_offs = end - base; total_ino =sizeof (struct ext4_xattr_ibody_header ) +sizeof (u32);
fs/ext4/xattr.h +3 -0
@@ -68,6 +68,9 @@ struct ext4_xattr_entry { ((void *)raw_inode + \ EXT4_GOOD_OLD_INODE_SIZE + \ EXT4_I(inode)->i_extra_isize)) +#define ITAIL (inode, raw_inode) \ + ((void *)(raw_inode) + \ + EXT4_SB((inode)->i_sb)->s_inode_size)#define IFIRST (hdr) ((struct ext4_xattr_entry *)((hdr)+1))/*
Greg Kroah-Hartman
maintainerPATCH 420/451 ext4: fix out-of-bound read in ext4_xattr_inode_dec_ref_all()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Bin <[email protected]>
[ Upstream commit 5701875f9609b000d91351eaa6bfd97fe2f157f4 ]
There's issue as follows:
BUG: KASAN: use-after-free in ext4_xattr_inode_dec_ref_all+0x6ff/0x790
Read of size 4 at addr ffff88807b003000 by task syz-executor.0/15172
CPU: 3 PID: 15172 Comm: syz-executor.0
Call Trace:
__dump_stack lib/dump_stack.c:82 [inline]
dump_stack+0xbe/0xfd lib/dump_stack.c:123
print_address_description.constprop.0+0x1e/0x280 mm/kasan/report.c:400
__kasan_report.cold+0x6c/0x84 mm/kasan/report.c:560
kasan_report+0x3a/0x50 mm/kasan/report.c:585
ext4_xattr_inode_dec_ref_all+0x6ff/0x790 fs/ext4/xattr.c:1137
ext4_xattr_delete_inode+0x4c7/0xda0 fs/ext4/xattr.c:2896
ext4_evict_inode+0xb3b/0x1670 fs/ext4/inode.c:323
evict+0x39f/0x880 fs/inode.c:622
iput_final fs/inode.c:1746 [inline]
iput fs/inode.c:1772 [inline]
iput+0x525/0x6c0 fs/inode.c:1758
ext4_orphan_cleanup fs/ext4/super.c:3298 [inline]
ext4_fill_super+0x8c57/0xba40 fs/ext4/super.c:5300
mount_bdev+0x355/0x410 fs/super.c:1446
legacy_get_tree+0xfe/0x220 fs/fs_context.c:611
vfs_get_tree+0x8d/0x2f0 fs/super.c:1576
do_new_mount fs/namespace.c:2983 [inline]
path_mount+0x119a/0x1ad0 fs/namespace.c:3316
do_mount+0xfc/0x110 fs/namespace.c:3329
__do_sys_mount fs/namespace.c:3540 [inline]
__se_sys_mount+0x219/0x2e0 fs/namespace.c:3514
do_syscall_64+0x33/0x40 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x67/0xd1
Memory state around the buggy address:
ffff88807b002f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ffff88807b002f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>ffff88807b003000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
^
ffff88807b003080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
ffff88807b003100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ffAbove issue happens as ext4_xattr_delete_inode() isn't check xattr is valid if xattr is in inode.
To solve above issue call xattr_check_inode() check if xattr if valid in inode. In fact, we can directly verify in ext4_iget_extra_inode(), so that there is no divergent verification.
--- fs/ext4/inode.c | 5 +++++ fs/ext4/xattr.c | 26 +------------------------- fs/ext4/xattr.h | 7 +++++++ 3 files changed, 13 insertions(+), 25 deletions(-)
fs/ext4/inode.c +5 -0
@@ -4650,6 +4650,11 @@ static inline int ext4_iget_extra_inode( *magic == cpu_to_le32(EXT4_XATTR_MAGIC)) {int err; + err =xattr_check_inode (inode,IHDR (inode, raw_inode), +ITAIL (inode, raw_inode)); +if (err) +return err; +ext4_set_inode_state (inode,EXT4_STATE_XATTR ); err =ext4_find_inline_data_nolock (inode);if (!err &&ext4_has_inline_data (inode))
fs/ext4/xattr.c +1 -25
@@ -263,7 +263,7 @@ errout: __ext4_xattr_check_block((inode), (bh), __func__, __LINE__) -static int +int __xattr_check_inode (struct inode *inode,struct ext4_xattr_ibody_header *header,void *end,const char *function,unsigned int line) {
@@ -280,9 +280,6 @@ errout:return error; } -#define xattr_check_inode (inode, header, end) \ - __xattr_check_inode((inode), (header), (end), __func__, __LINE__) -static int xattr_find_entry (struct inode *inode,struct ext4_xattr_entry **pentry,void *end,int name_index,const char *name,int sorted)
@@ -600,9 +597,6 @@ ext4_xattr_ibody_get(struct inode *inode raw_inode =ext4_raw_inode (&iloc); header =IHDR (inode, raw_inode); end =ITAIL (inode, raw_inode); - error =xattr_check_inode (inode, header, end); -if (error) - goto cleanup; entry =IFIRST (header); error =xattr_find_entry (inode, &entry, end, name_index, name,0 );if (error)
@@ -734,7 +728,6 @@ ext4_xattr_ibody_list(struct dentry *denstruct ext4_xattr_ibody_header *header;struct ext4_inode *raw_inode;struct ext4_iloc iloc; -void *end;int error;if (!ext4_test_inode_state (inode,EXT4_STATE_XATTR ))
@@ -744,14 +737,9 @@ ext4_xattr_ibody_list(struct dentry *denreturn error; raw_inode =ext4_raw_inode (&iloc); header =IHDR (inode, raw_inode); - end =ITAIL (inode, raw_inode); - error =xattr_check_inode (inode, header, end); -if (error) - goto cleanup; error =ext4_xattr_list_entries (dentry,IFIRST (header), buffer, buffer_size); -cleanup:brelse (iloc.bh);return error; }
@@ -815,7 +803,6 @@ int ext4_get_inode_usage(struct inode *istruct ext4_xattr_ibody_header *header;struct ext4_xattr_entry *entry;qsize_t ea_inode_refs =0 ; -void *end;int ret;lockdep_assert_held_read (&EXT4_I (inode)->xattr_sem);
@@ -826,10 +813,6 @@ int ext4_get_inode_usage(struct inode *i goto out; raw_inode =ext4_raw_inode (&iloc); header =IHDR (inode, raw_inode); - end =ITAIL (inode, raw_inode); - ret =xattr_check_inode (inode, header, end); -if (ret) - goto out;for (entry =IFIRST (header); !IS_LAST_ENTRY (entry); entry =EXT4_XATTR_NEXT (entry))
@@ -2221,9 +2204,6 @@ int ext4_xattr_ibody_find(struct inode * is->s.here = is->s.first; is->s.end =ITAIL (inode, raw_inode);if (ext4_test_inode_state (inode,EXT4_STATE_XATTR )) { - error =xattr_check_inode (inode, header, is->s.end); -if (error) -return error;/* Find the named attribute. */ error =xattr_find_entry (inode, &is->s.here, is->s.end, i->name_index, i->name,0 );
@@ -2747,10 +2727,6 @@ retry: min_offs = end - base; total_ino =sizeof (struct ext4_xattr_ibody_header ) +sizeof (u32); - error =xattr_check_inode (inode, header, end); -if (error) - goto cleanup; - ifree =ext4_xattr_free_space (base, &min_offs, base, &total_ino);if (ifree >= isize_diff) goto shift;
fs/ext4/xattr.h +7 -0
@@ -210,6 +210,13 @@ extern int ext4_xattr_ibody_set(handle_textern struct mb_cache *ext4_xattr_create_cache (void );extern void ext4_xattr_destroy_cache (struct mb_cache *); +extern int +__xattr_check_inode (struct inode *inode,struct ext4_xattr_ibody_header *header, +void *end,const char *function,unsigned int line); + +#define xattr_check_inode (inode, header, end) \ + __xattr_check_inode((inode), (header), (end), __func__, __LINE__) +#ifdef CONFIG_EXT4_FS_SECURITY extern int ext4_init_security (handle_t *handle,struct inode *inode,struct inode *dir,const struct qstr *qstr);
Greg Kroah-Hartman
maintainerPATCH 421/451 net: Add locking to protect skb->dev access in ip_output
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sharath Chandra Vurukala <[email protected]>
[ Upstream commit 1dbf1d590d10a6d1978e8184f8dfe20af22d680a]
In ip_output() skb->dev is updated from the skb_dst(skb)->dev this can become invalid when the interface is unregistered and freed,
Introduced new skb_dst_dev_rcu() function to be used instead of skb_dst_dev() within rcu_locks in ip_output.This will ensure that all the skb's associated with the dev being deregistered will be transnmitted out first, before freeing the dev.
Given that ip_output() is called within an rcu_read_lock() critical section or from a bottom-half context, it is safe to introduce an RCU read-side critical section within it.
Multiple panic call stacks were observed when UL traffic was run in concurrency with device deregistration from different functions, pasting one sample for reference.
[496733.627565][T13385] Call trace: [496733.627570][T13385] bpf_prog_ce7c9180c3b128ea_cgroupskb_egres+0x24c/0x7f0 [496733.627581][T13385] __cgroup_bpf_run_filter_skb+0x128/0x498 [496733.627595][T13385] ip_finish_output+0xa4/0xf4 [496733.627605][T13385] ip_output+0x100/0x1a0 [496733.627613][T13385] ip_send_skb+0x68/0x100 [496733.627618][T13385] udp_send_skb+0x1c4/0x384 [496733.627625][T13385] udp_sendmsg+0x7b0/0x898 [496733.627631][T13385] inet_sendmsg+0x5c/0x7c [496733.627639][T13385] __sys_sendto+0x174/0x1e4 [496733.627647][T13385] __arm64_sys_sendto+0x28/0x3c [496733.627653][T13385] invoke_syscall+0x58/0x11c [496733.627662][T13385] el0_svc_common+0x88/0xf4 [496733.627669][T13385] do_el0_svc+0x2c/0xb0 [496733.627676][T13385] el0_svc+0x2c/0xa4 [496733.627683][T13385] el0t_64_sync_handler+0x68/0xb4 [496733.627689][T13385] el0t_64_sync+0x1a4/0x1a8
Changes in v3:
- Replaced WARN_ON() with WARN_ON_ONCE(), as suggested by Willem de Bruijn.
- Dropped legacy lines mistakenly pulled in from an outdated branch.
Changes in v2:
- Addressed review comments from Eric Dumazet
- Used READ_ONCE() to prevent potential load/store tearing
- Added skb_dst_dev_rcu() and used along with rcu_read_lock() in ip_output
--- include/net/dst.h | 12 ++++++++++++ net/ipv4/ip_output.c | 16 +++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-)
include/net/dst.h +12 -0
@@ -547,6 +547,18 @@ static inline void skb_dst_update_pmtu_n dst->ops->update_pmtu (dst,NULL , skb, mtu, false); } +static inline struct net_device *dst_dev_rcu (const struct dst_entry *dst) +{ +/* In the future, use rcu_dereference(dst->dev) */ +WARN_ON_ONCE (!rcu_read_lock_held ()); +return READ_ONCE (dst->dev); +} + +static inline struct net_device *skb_dst_dev_rcu (const struct sk_buff *skb) +{ +return dst_dev_rcu (skb_dst (skb)); +} +struct dst_entry *dst_blackhole_check (struct dst_entry *dst,u32 cookie);void dst_blackhole_update_pmtu (struct dst_entry *dst,struct sock *sk,struct sk_buff *skb,u32 mtu,bool confirm_neigh);
net/ipv4/ip_output.c +11 -5
@@ -429,17 +429,23 @@ int ip_mc_output(struct net *net, structint ip_output (struct net *net,struct sock *sk,struct sk_buff *skb) { -struct net_device *dev =skb_dst (skb)->dev, *indev = skb->dev; +struct net_device *dev, *indev = skb->dev; +int ret_val; + +rcu_read_lock (); + dev =skb_dst_dev_rcu (skb);IP_UPD_PO_STATS (net,IPSTATS_MIB_OUT , skb->len); skb->dev = dev; skb->protocol =htons (ETH_P_IP ); -return NF_HOOK_COND (NFPROTO_IPV4 ,NF_INET_POST_ROUTING , - net, sk, skb, indev, dev, - ip_finish_output, - !(IPCB (skb)->flags &IPSKB_REROUTED )); + ret_val =NF_HOOK_COND (NFPROTO_IPV4 ,NF_INET_POST_ROUTING , + net, sk, skb, indev, dev, + ip_finish_output, + !(IPCB (skb)->flags &IPSKB_REROUTED )); +rcu_read_unlock (); +return ret_val; }EXPORT_SYMBOL (ip_output);
Greg Kroah-Hartman
maintainerPATCH 422/451 net: netdevice: Add operation ndo_sk_get_lower_dev
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tariq Toukan <[email protected]>
[ Upstream commit 719a402cf60311b1cdff3f6320abaecdcc5e46b7]
ndo_sk_get_lower_dev returns the lower netdev that corresponds to a given socket.
Additionally, we implement a helper netdev_sk_get_lowest_dev() to get the lowest one in chain.
--- include/linux/netdevice.h | 4 ++++ net/core/dev.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+)
include/linux/netdevice.h +4 -0
@@ -1435,6 +1435,8 @@ struct net_device_ops {struct net_device * (*ndo_get_xmit_slave)(struct net_device *dev,struct sk_buff *skb,bool all_slaves); +struct net_device * (*ndo_sk_get_lower_dev)(struct net_device *dev, +struct sock *sk);netdev_features_t (*ndo_fix_features)(struct net_device *dev,netdev_features_t features); int (*ndo_set_features)(struct net_device *dev,
@@ -2914,6 +2916,8 @@ int init_dummy_netdev(struct net_devicestruct net_device *netdev_get_xmit_slave (struct net_device *dev,struct sk_buff *skb,bool all_slaves); +struct net_device *netdev_sk_get_lowest_dev (struct net_device *dev, +struct sock *sk);struct net_device *dev_get_by_index (struct net *net,int ifindex);struct net_device *__dev_get_by_index (struct net *net,int ifindex);struct net_device *dev_get_by_index_rcu (struct net *net,int ifindex);
net/core/dev.c +33 -0
@@ -8169,6 +8169,39 @@ struct net_device *netdev_get_xmit_slave }EXPORT_SYMBOL (netdev_get_xmit_slave); +static struct net_device *netdev_sk_get_lower_dev (struct net_device *dev, +struct sock *sk) +{ +const struct net_device_ops *ops = dev->netdev_ops; + +if (!ops->ndo_sk_get_lower_dev) +return NULL ; +return ops->ndo_sk_get_lower_dev (dev, sk); +} + +/** +* netdev_sk_get_lowest_dev - Get the lowest device in chain given device and socket +* @dev: device +* @sk: the socket +* +* %NULL is returned if no lower device is found. +*/ + +struct net_device *netdev_sk_get_lowest_dev (struct net_device *dev, +struct sock *sk) +{ +struct net_device *lower; + + lower =netdev_sk_get_lower_dev (dev, sk); +while (lower) { + dev = lower; + lower =netdev_sk_get_lower_dev (dev, sk); + } + +return dev; +} +EXPORT_SYMBOL (netdev_sk_get_lowest_dev); +static void netdev_adjacent_add_links (struct net_device *dev) {struct netdev_adjacent *iter;
Greg Kroah-Hartman
maintainerPATCH 423/451 tls: Use __sk_dst_get() and dst_dev_rcu() in get_netdev_for_sock().
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit c65f27b9c3be2269918e1cbad6d8884741f835c5 ]
get_netdev_for_sock() is called during setsockopt(), so not under RCU.
Using sk_dst_get(sk)->dev could trigger UAF.
Let's use __sk_dst_get() and dst_dev_rcu().
Note that the only ->ndo_sk_get_lower_dev() user is bond_sk_get_lower_dev(), which uses RCU.
--- net/tls/tls_device.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
net/tls/tls_device.c +10 -8
@@ -113,17 +113,19 @@ unlock:/* We assume that the socket is already connected */ static struct net_device *get_netdev_for_sock (struct sock *sk) { -struct dst_entry *dst =sk_dst_get (sk); -struct net_device *netdev =NULL ; +struct net_device *dev, *lowest_dev =NULL ; +struct dst_entry *dst; -if (likely (dst)) { - netdev = dst->dev; -dev_hold (netdev); +rcu_read_lock (); + dst =__sk_dst_get (sk); + dev = dst ?dst_dev_rcu (dst) :NULL ; +if (likely (dev)) { + lowest_dev =netdev_sk_get_lowest_dev (dev, sk); +dev_hold (lowest_dev); } +rcu_read_unlock (); -dst_release (dst); - -return netdev; +return lowest_dev; }static void destroy_record (struct tls_record_info *record)
Greg Kroah-Hartman
maintainerPATCH 424/451 bpf, sockmap: Dont let sock_map_{close,destroy,unhash} call itself
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakub Sitnicki <[email protected]>
commit 5b4a79ba65a1ab479903fff2e604865d229b70a9 upstream.
sock_map proto callbacks should never call themselves by design. Protect against bugs like [1] and break out of the recursive loop to avoid a stack overflow in favor of a resource leak.
[1] https://lore.kernel.org/all/[email protected]/
--- net/core/sock_map.c | 53 +++++++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 23 deletions(-)
net/core/sock_map.c +30 -23
@@ -1558,15 +1558,16 @@ void sock_map_unhash(struct sock *sk) psock =sk_psock (sk);if (unlikely (!psock)) {rcu_read_unlock (); -if (sk->sk_prot->unhash) - sk->sk_prot->unhash (sk); -return ; + saved_unhash =READ_ONCE (sk->sk_prot)->unhash; + }else { + saved_unhash = psock->saved_unhash; +sock_map_remove_links (sk, psock); +rcu_read_unlock (); } - - saved_unhash = psock->saved_unhash; -sock_map_remove_links (sk, psock); -rcu_read_unlock (); -saved_unhash (sk); +if (WARN_ON_ONCE (saved_unhash == sock_map_unhash)) +return ; +if (saved_unhash) +saved_unhash (sk); }void sock_map_destroy (struct sock *sk)
@@ -1578,16 +1579,17 @@ void sock_map_destroy(struct sock *sk) psock =sk_psock_get (sk);if (unlikely (!psock)) {rcu_read_unlock (); -if (sk->sk_prot->destroy) - sk->sk_prot->destroy (sk); -return ; + saved_destroy =READ_ONCE (sk->sk_prot)->destroy; + }else { + saved_destroy = psock->saved_destroy; +sock_map_remove_links (sk, psock); +rcu_read_unlock (); +sk_psock_put (sk, psock); } - - saved_destroy = psock->saved_destroy; -sock_map_remove_links (sk, psock); -rcu_read_unlock (); -sk_psock_put (sk, psock); -saved_destroy (sk); +if (WARN_ON_ONCE (saved_destroy == sock_map_destroy)) +return ; +if (saved_destroy) +saved_destroy (sk); }EXPORT_SYMBOL_GPL (sock_map_destroy);
@@ -1602,13 +1604,18 @@ void sock_map_close(struct sock *sk, lonif (unlikely (!psock)) {rcu_read_unlock ();release_sock (sk); -return sk->sk_prot->close (sk, timeout); + saved_close =READ_ONCE (sk->sk_prot)->close; + }else { + saved_close = psock->saved_close; +sock_map_remove_links (sk, psock); +rcu_read_unlock (); +release_sock (sk); } - - saved_close = psock->saved_close; -sock_map_remove_links (sk, psock); -rcu_read_unlock (); -release_sock (sk); +/* Make sure we do not recurse. This is a bug. +* Leak the socket instead of crashing on a stack overflow. +*/ +if (WARN_ON_ONCE (saved_close == sock_map_close)) +return ;saved_close (sk, timeout); }
Greg Kroah-Hartman
maintainerPATCH 425/451 ARM: 9461/1: Disable HIGHPTE on PREEMPT_RT kernels
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <[email protected]>
[ Upstream commit fedadc4137234c3d00c4785eeed3e747fe9036ae ]
gup_pgd_range() is invoked with disabled interrupts and invokes __kmap_local_page_prot() via pte_offset_map(), gup_p4d_range(). With HIGHPTE enabled, __kmap_local_page_prot() invokes kmap_high_get() which uses a spinlock_t via lock_kmap_any(). This leads to an sleeping-while-atomic error on PREEMPT_RT because spinlock_t becomes a sleeping lock and must not be acquired in atomic context.
The loop in map_new_virtual() uses wait_queue_head_t for wake up which also is using a spinlock_t.
Since HIGHPTE is rarely needed at all, turn it off for PREEMPT_RT to allow the use of get_user_pages_fast().
[arnd: rework patch to turn off HIGHPTE instead of HAVE_PAST_GUP]
--- arch/arm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/Kconfig +1 -1
@@ -1513,7 +1513,7 @@ config HIGHMEM config HIGHPTE bool "Allocate 2nd-level pagetables from highmem" if EXPERT - depends on HIGHMEM + depends on HIGHMEM && !PREEMPT_RT default y help The VM uses one page of physical memory for each page table.
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 426/451 alpha: dont reference obsolete termio struct for TC* constants
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sam James <[email protected]>
[ Upstream commit 9aeed9041929812a10a6d693af050846942a1d16 ]
Similar in nature to ab107276607af90b13a5994997e19b7b9731e251. glibc-2.42 drops the legacy termio struct, but the ioctls.h header still defines some TC* constants in terms of termio (via sizeof). Hardcode the values instead.
This fixes building Python for example, which falls over like:
./Modules/termios.c:1119:16: error: invalid application of 'sizeof' to incomplete type 'struct termio'
--- arch/alpha/include/uapi/asm/ioctls.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/alpha/include/uapi/asm/ioctls.h +4 -4
@@ -23,10 +23,10 @@#define TCSETSW _IOW('t', 21, struct termios)#define TCSETSF _IOW('t', 22, struct termios) -#define TCGETA _IOR('t', 23, struct termio) -#define TCSETA _IOW('t', 24, struct termio) -#define TCSETAW _IOW('t', 25, struct termio) -#define TCSETAF _IOW('t', 28, struct termio) +#define TCGETA 0x40127417 +#define TCSETA 0x80127418 +#define TCSETAW 0x80127419 +#define TCSETAF 0x8012741c#define TCSBRK _IO('t', 29)#define TCXONC _IO('t', 30)
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 427/451 NFSv4: ensure the open stateid seqid doesnt go backwards
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Scott Mayhew <[email protected]>
[ Upstream commit 2e47c3cc64b44b0b06cd68c2801db92ff143f2b2 ]
We have observed an NFSv4 client receiving a LOCK reply with a status of NFS4ERR_OLD_STATEID and subsequently retrying the LOCK request with an earlier seqid value in the stateid. As this was for a new lockowner, that would imply that nfs_set_open_stateid_locked() had updated the open stateid seqid with an earlier value.
Looking at nfs_set_open_stateid_locked(), if the incoming seqid is out of sequence, the task will sleep on the state->waitq for up to 5 seconds. If the task waits for the full 5 seconds, then after finishing the wait it'll update the open stateid seqid with whatever value the incoming seqid has. If there are multiple waiters in this scenario, then the last one to perform said update may not be the one with the highest seqid.
Add a check to ensure that the seqid can only be incremented, and add a tracepoint to indicate when old seqids are skipped.
--- fs/nfs/nfs4proc.c | 13 +++++++++++-- fs/nfs/nfs4trace.h | 1 + 2 files changed, 12 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +11 -2
@@ -1688,8 +1688,17 @@ static void nfs_set_open_stateid_locked(struct nfs4_state *state,if (nfs_stateid_is_sequential (state, stateid))break ; -if (status) -break ; +if (status) { +if (nfs4_stateid_match_other (stateid, &state->open_stateid) && + !nfs4_stateid_is_newer (stateid, &state->open_stateid)) { +trace_nfs4_open_stateid_update_skip (state->inode, + stateid, status); +return ; + }else { +break ; + } + } +/* Rely on seqids for serialisation with NFSv4.0 */ if (!nfs4_has_session (NFS_SERVER (state->inode)->nfs_client))break ;
fs/nfs/nfs4trace.h +1 -0
@@ -1513,6 +1513,7 @@ DEFINE_NFS4_INODE_STATEID_EVENT(nfs4_setattr);DEFINE_NFS4_INODE_STATEID_EVENT (nfs4_delegreturn);DEFINE_NFS4_INODE_STATEID_EVENT (nfs4_open_stateid_update);DEFINE_NFS4_INODE_STATEID_EVENT (nfs4_open_stateid_update_wait); +DEFINE_NFS4_INODE_STATEID_EVENT (nfs4_open_stateid_update_skip);DEFINE_NFS4_INODE_STATEID_EVENT (nfs4_close_stateid_update_wait); DECLARE_EVENT_CLASS(nfs4_getattr_event,
Signature · 1 line
2.51.0