5.10.275-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 366/1848 media: i2c: tc358743: add missing color-space strings
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit cb37e83f1bbdf0964ed0a9524ce45a0694f98205 ]
VI_STATUS3 S_V_COLOR is four bits, so the index after the shift is 0-15. input_color_space[] only has 14 entries. Add the two reserved values so log_status() cannot walk off the table.
--- drivers/media/i2c/tc358743.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/i2c/tc358743.c +2 -1
@@ -1268,7 +1268,8 @@ static int tc358743_log_status(struct v4l2_subdev *sd)static const char *const input_color_space[] = {"RGB" ,"YCbCr 601" ,"opRGB" ,"YCbCr 709" ,"NA (4)" ,"xvYCC 601" ,"NA(6)" ,"xvYCC 709" ,"NA(8)" ,"sYCC601" , -"NA(10)" ,"NA(11)" ,"NA(12)" ,"opYCC 601" }; +"NA(10)" ,"NA(11)" ,"NA(12)" ,"opYCC 601" ,"NA(14)" , +"NA(15)" };v4l2_info (sd,"-----Chip status-----\n" ); v4l2_info(sd, "Chip ID: 0x%02x\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 367/1848 media: go7007: bound EZ-USB I2C transfers to the usb_buf size
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengzhuo Wei <[email protected]>
[ Upstream commit 816c4628b23e8c3d925978433f4dd1a13620c01b ]
go7007_usb_i2c_master_xfer() copies msgs[i].len bytes into go->usb_buf, a 16-byte buffer embedded in struct go7007, without any length check. The adapter declares no transfer limits, so an SMBus block transfer issued through /dev/i2c-N can write up to 34 bytes into it and corrupt the struct fields that follow the buffer.
Bound the transfer size with i2c_adapter_quirks so the I2C core rejects oversized messages before they reach the driver.
--- drivers/media/usb/go7007/go7007-usb.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/media/usb/go7007/go7007-usb.c +6 -0
@@ -1029,10 +1029,16 @@ static const struct i2c_algorithm go7007_usb_algo = { .functionality = go7007_usb_functionality, }; +static const struct i2c_adapter_quirks go7007_usb_quirks = { + .max_write_len =12 , + .max_read_len =15 , +}; +static struct i2c_adapter go7007_usb_adap_templ = { .owner =THIS_MODULE , .name ="WIS GO7007SB EZ-USB" , .algo = &go7007_usb_algo, + .quirks = &go7007_usb_quirks, };/********************* USB add/remove functions *********************/
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 368/1848 media: saa7146: Initialize interrupt lock before requesting IRQ
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit e07c75a6bc4adf1ed09ede31756261e2c6bdede5 ]
The saa7146 interrupt handler can call SAA7146_IER_DISABLE(), which serializes register access with dev->int_slock. request_irq() allows the shared handler to run before saa7146_init_one() reaches the current lock initialization block.
Initialize dev->int_slock before requesting the interrupt so every handler path sees an initialized lock.
--- drivers/media/common/saa7146/saa7146_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/common/saa7146/saa7146_core.c +2 -1
@@ -352,6 +352,8 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent goto out; } +spin_lock_init (&dev->int_slock); +/* create a nice device name */ sprintf (dev->name,"saa7146 (%d)" , saa7146_num);
@@ -435,7 +437,6 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent dev->ext = ext;mutex_init (&dev->v4l2_lock); -spin_lock_init (&dev->int_slock);spin_lock_init (&dev->slock);mutex_init (&dev->i2c_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 369/1848 media: vim2m: keep transaction buffer count stable while streaming
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Younho Choi <[email protected]>
[ Upstream commit 50f5fed44d8e24081e8feed5154746fe193f11b8 ]
V4L2_CID_TRANS_NUM_BUFS controls how many buffer pairs a vim2m mem2mem job processes before the job is completed. The driver stores the value in ctx->translen and device_work() uses it later to decide whether the current transaction should continue.
Letting userspace change this control while streaming is active can make a queued job observe a different transaction length than the one it started with. That leaves the transaction state inconsistent with the buffers currently queued for the job.
Grab the transaction buffer count control while either queue is streaming, and release it only after both queues have stopped streaming. The V4L2 control framework then rejects changes with -EBUSY while the value is in use, while still allowing userspace to configure the value before streaming starts.
Keep the control handler alive until after v4l2_m2m_ctx_release(), since releasing the mem2mem context can call stop_streaming(), which now ungrabs the control.
--- drivers/media/test-drivers/vim2m.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
drivers/media/test-drivers/vim2m.c +26 -3
@@ -205,6 +205,7 @@ struct vim2m_ctx {struct vim2m_dev *dev;struct v4l2_ctrl_handler hdl; +struct v4l2_ctrl *trans_num_bufs_ctrl;/* Processed buffers in this transaction */ u8 num_processed;
@@ -1073,9 +1074,27 @@ static int vim2m_start_streaming(struct vb2_queue *q, unsigned int count) ctx->aborting =0 ; q_data->sequence =0 ; +v4l2_ctrl_grab (ctx->trans_num_bufs_ctrl, true); +return 0 ; } +static bool vim2m_other_queue_is_streaming (struct vim2m_ctx *ctx, +struct vb2_queue *q) +{ +struct vb2_queue *other_vq; + +if (!ctx->fh.m2m_ctx) +return false; + +if (V4L2_TYPE_IS_OUTPUT (q->type)) + other_vq =v4l2_m2m_get_dst_vq (ctx->fh.m2m_ctx); +else + other_vq =v4l2_m2m_get_src_vq (ctx->fh.m2m_ctx); + +return vb2_is_streaming (other_vq); +} +static void vim2m_stop_streaming (struct vb2_queue *q) {struct vim2m_ctx *ctx =vb2_get_drv_priv (q);
@@ -1089,11 +1108,14 @@ static void vim2m_stop_streaming(struct vb2_queue *q)else vbuf =v4l2_m2m_dst_buf_remove (ctx->fh.m2m_ctx);if (!vbuf) -return ; +break ;v4l2_ctrl_request_complete (vbuf->vb2_buf.req_obj.req, &ctx->hdl);v4l2_m2m_buf_done (vbuf,VB2_BUF_STATE_ERROR ); } + +if (!vim2m_other_queue_is_streaming (ctx, q)) +v4l2_ctrl_grab (ctx->trans_num_bufs_ctrl, false); }static void vim2m_buf_request_complete (struct vb2_buffer *vb)
@@ -1196,7 +1218,8 @@ static int vim2m_open(struct file *file) vim2m_ctrl_trans_time_msec.def = default_transtime;v4l2_ctrl_new_custom (hdl, &vim2m_ctrl_trans_time_msec,NULL ); -v4l2_ctrl_new_custom (hdl, &vim2m_ctrl_trans_num_bufs,NULL ); + ctx->trans_num_bufs_ctrl = +v4l2_ctrl_new_custom (hdl, &vim2m_ctrl_trans_num_bufs,NULL );if (hdl->error) { rc = hdl->error;v4l2_ctrl_handler_free (hdl);
@@ -1250,10 +1273,10 @@ static int vim2m_release(struct file *file)v4l2_fh_del (&ctx->fh);v4l2_fh_exit (&ctx->fh); -v4l2_ctrl_handler_free (&ctx->hdl);mutex_lock (&dev->dev_mutex);v4l2_m2m_ctx_release (ctx->fh.m2m_ctx);mutex_unlock (&dev->dev_mutex); +v4l2_ctrl_handler_free (&ctx->hdl);kfree (ctx);atomic_dec (&dev->num_inst);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 370/1848 media: vicodec: fix out-of-bounds write on under-rounded coded dimensions
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 0183746ebca4c478027e2261b904f844f1443b19 ]
A capture format whose width or height is one more than a multiple of 16 makes the FWHT codec write one 8x8 block row, or column, past the end of the capture plane, and read the same block out of the reference frame for P-coded frames.
vic_round_dim() is documented to round a frame dimension up so that both the luma and the chroma plane end up a multiple of 8, but it only rounds the chroma plane:
round_up((dim) / (div), 8) * (div)
For div == 2 the result is a multiple of 16 in every case but one: when dim % 16 == 1, dim / div is already a multiple of 8 and the macro returns dim - 1. encode_plane() and decode_plane() round the same dimension with round_up(dim, 8), which yields dim + 7 -- one block more than the coded dimension that sized the buffer.
On a KASAN-enabled kernel, a 641x360 YUYV P-frame triggers:
BUG: KASAN: slab-out-of-bounds in add_deltas+0x450/0xcc0 Read of size 1 at addr ffff888009070800 by task trigger_bin/70 Call Trace: add_deltas+0x450/0xcc0 decode_plane+0x1916/0x3390 fwht_decode_frame+0x173/0x620 v4l2_fwht_decode+0x751/0x1120 device_run+0x6bb/0x1850
Round the dimension itself up to a multiple of 8 * div. The rounding changes only for div == 2 and dim % 16 == 1, and MAX_WIDTH and MAX_HEIGHT are both multiples of 16, so the rounded value still fits the advertised limits.
--- drivers/media/test-drivers/vicodec/codec-fwht.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/test-drivers/vicodec/codec-fwht.h +1 -1
@@ -93,7 +93,7 @@* both luma and chroma components resolutions are rounded up to * a multiple of 8 */ -#define vic_round_dim (dim, div) (round_up((dim) / (div), 8) * (div)) +#define vic_round_dim (dim, div) round_up(dim, 8 * (div))struct fwht_cframe_hdr {u32 magic1;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 371/1848 media: vicodec: make encoder CAPTURE dimensions read-only
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 2532e9d2f8ccb330a9c924b1ee34c5629240d352 ]
Setting the encoder's compressed CAPTURE format to a smaller resolution than the raw OUTPUT format makes the encoder write past the end of the CAPTURE buffer.
For a stateful encoder the CAPTURE width and height are not client-settable; Documentation/userspace-api/media/v4l/dev-encoder.rst specifies them as "ignored (read-only)" on VIDIOC_S_FMT. vicodec only implements half of that: vidioc_s_fmt_vid_out() derives the CAPTURE coded size and sizeimage from the OUTPUT format, but S_FMT on the CAPTURE queue overwrites them. The encoder then takes its geometry from the OUTPUT queue alone, and v4l2_fwht_encode() gets no destination length.
Overwrite the requested width and height with the OUTPUT queue's coded dimensions in vidioc_try_fmt_vid_cap(), making them read-only as the interface requires.
--- drivers/media/test-drivers/vicodec/vicodec-core.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/media/test-drivers/vicodec/vicodec-core.c +10 -0
@@ -900,6 +900,8 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, struct v4l2_format *f) {struct vicodec_ctx *ctx =file2ctx (file); +struct vicodec_q_data *q_data_out = +get_q_data (ctx,V4L2_BUF_TYPE_VIDEO_OUTPUT );struct v4l2_pix_format_mplane *pix_mp;struct v4l2_pix_format *pix;
@@ -910,6 +912,10 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, pix = &f->fmt.pix; pix->pixelformat = ctx->is_enc ?V4L2_PIX_FMT_FWHT :find_fmt (f->fmt.pix.pixelformat)->id; +if (ctx->is_enc) { + pix->width = q_data_out->coded_width; + pix->height = q_data_out->coded_height; + } pix->colorspace = ctx->state.colorspace; pix->xfer_func = ctx->state.xfer_func; pix->ycbcr_enc = ctx->state.ycbcr_enc;
@@ -921,6 +927,10 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, pix_mp = &f->fmt.pix_mp; pix_mp->pixelformat = ctx->is_enc ?V4L2_PIX_FMT_FWHT :find_fmt (pix_mp->pixelformat)->id; +if (ctx->is_enc) { + pix_mp->width = q_data_out->coded_width; + pix_mp->height = q_data_out->coded_height; + } pix_mp->colorspace = ctx->state.colorspace; pix_mp->xfer_func = ctx->state.xfer_func; pix_mp->ycbcr_enc = ctx->state.ycbcr_enc;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 372/1848 media: vidtv: fix frontend reference leak on unbind
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Piyush Patle <[email protected]>
[ Upstream commit 6f412f9fe6a1f3ce9694757f50353bbec221d832 ]
dvb_register_frontend() keeps two references to the frontend. One is released by dvb_unregister_frontend(), and the other by dvb_frontend_detach(). vidtv only called dvb_unregister_frontend(), so the second reference was never released. As a result, __dvb_frontend_free() was never called, leaking the frontend private data and its struct dvb_device.
The detach call was removed by commit 63101b756893 ("media: vidtv: fix driver unbind/remove") because it caused an OOPS. The demod .release callback freed vidtv_demod_state, and the I2C remove callbacks then accessed the freed state.
That commit also removed those accesses from the I2C remove callbacks. Restore the detach call, but remove the demod .release callback. vidtv_demod_state is owned by the I2C client and is already freed by vidtv_demod_i2c_remove(), so the frontend detach path should not free it.
Tested with kmemleak and KASAN over 10 bind/unbind cycles. The reported frontend and dvb_device leaks were present before the fix and were gone after it, with no KASAN reports.
--- drivers/media/test-drivers/vidtv/vidtv_bridge.c | 2 ++ drivers/media/test-drivers/vidtv/vidtv_demod.c | 9 --------- 2 files changed, 2 insertions(+), 9 deletions(-)
drivers/media/test-drivers/vidtv/vidtv_bridge.c +2 -0
@@ -471,6 +471,7 @@ static int vidtv_bridge_dvb_init(struct vidtv_dvb *dvb) fail_demod_probe:for (i = i -1 ; i >=0 ; --i) {dvb_unregister_frontend (dvb->fe[i]); +dvb_frontend_detach (dvb->fe[i]); fail_fe:dvb_module_release (dvb->i2c_client_tuner[i]); fail_tuner_probe:
@@ -522,6 +523,7 @@ static int vidtv_bridge_remove(struct platform_device *pdev)for (i =0 ; i <NUM_FE ; ++i) {dvb_unregister_frontend (dvb->fe[i]); +dvb_frontend_detach (dvb->fe[i]);dvb_module_release (dvb->i2c_client_tuner[i]);dvb_module_release (dvb->i2c_client_demod[i]); }
drivers/media/test-drivers/vidtv/vidtv_demod.c +0 -9
@@ -343,13 +343,6 @@ static int vidtv_diseqc_send_burst(struct dvb_frontend *fe,return 0 ; } -static void vidtv_demod_release (struct dvb_frontend *fe) -{ -struct vidtv_demod_state *state = fe->demodulator_priv; - -kfree (state); -} -static const struct dvb_frontend_ops vidtv_demod_ops = { .delsys = {SYS_DVBT ,
@@ -390,8 +383,6 @@ static const struct dvb_frontend_ops vidtv_demod_ops = { FE_CAN_HIERARCHY_AUTO, }, - .release = vidtv_demod_release, - .set_frontend = vidtv_demod_set_frontend, .get_frontend = vidtv_demod_get_frontend,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 373/1848 media: vidtv: fix uaf in vidtv_bridge_on_new_pkts_avail
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeffin Philip <[email protected]>
[ Upstream commit 2af02ccd048b77713695d7817cf645ca50bf349e ]
Attempting to unbind a dvbdevice that is in the process of feeding data causes a UAF as we free the underlying device without stopping the feed first. Fix this by stopping the stream first using vidtv_stop_streaming(). However, our codepath in the reproducer (mentioned in the below reply) does not decrement our users (dmxdev->dvr_dvbdev->users) to 1 after it has been incremented to 2 by our read() in the reproducer, that is only possible on .release. This can cause a task hang as dvb_dmxdev_release() uses wait_event() in the wait_queue unless we use a close(fd)(in the reproducer). Is this a problem? Please advise.
--- drivers/media/test-drivers/vidtv/vidtv_bridge.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/test-drivers/vidtv/vidtv_bridge.c +2 -0
@@ -521,6 +521,8 @@ static int vidtv_bridge_remove(struct platform_device *pdev)mutex_destroy (&dvb->feed_lock); +vidtv_stop_streaming (dvb); +for (i =0 ; i <NUM_FE ; ++i) {dvb_unregister_frontend (dvb->fe[i]);dvb_frontend_detach (dvb->fe[i]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 374/1848 media: marvell-cam: fix unmet dependency for VIDEO_MMP_CAMERA
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Braha <[email protected]>
[ Upstream commit 1179929b3abd4adb6ca7fae91d649c64a7293aca ]
VIDEO_MMP_CAMERA selects I2C_GPIO without ensuring
'GPIOLIB || COMPILE_TEST' is enabled, despite I2C_GPIO depending on it.
Let's add the same dependency to VIDEO_MMP_CAMERA.
This unmet dependency bug was found by kconfirm, a static analysis tool for Kconfig.
--- drivers/media/platform/marvell-ccic/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/marvell-ccic/Kconfig +1 -0
@@ -16,6 +16,7 @@ config VIDEO_MMP_CAMERA tristate "Marvell Armada 610 integrated camera controller support" depends on I2C && VIDEO_V4L2 depends on ARCH_MMP || COMPILE_TEST + depends on GPIOLIB || COMPILE_TEST depends on COMMON_CLK select VIDEO_OV7670 select I2C_GPIO
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 375/1848 staging: media: av7110: fix corrupted BER reporting in sp8870
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Punnay Sharma <[email protected]>
[ Upstream commit 5764f9bd7b7a72c6df49db6c8c00d4f9994a55ba ]
In sp8870_read_ber(), the 14-bit Bit Error Rate (BER) is assembled by reading two I2C registers: 0xC08 (lower 6 bits) and 0xC07 (upper 8 bits).
The current implementation masks the lower bits via tmp = ret & 0x3F; but subsequently overwrites tmp entirely when processing the upper bits using a direct assignment (tmp = ret << 6;). This logical error causes the lower 6 bits of the BER hardware metric to be silently discarded.
Fix this by using a bitwise OR (tmp |= ret << 6;) to correctly merge the MSB and LSB payloads before returning the metric to the DVB core.
--- drivers/media/dvb-frontends/sp8870.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/sp8870.c +1 -1
@@ -384,7 +384,7 @@ static int sp8870_read_ber (struct dvb_frontend* fe, u32 * ber)if (ret <0 )return -EIO ; - tmp = ret <<6 ; + tmp |= ret <<6 ;if (tmp >=0x3FFF0 ) tmp = ~0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 376/1848 media: m2m-deinterlace: fix default capture field
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Rao <[email protected]>
[ Upstream commit 4ee3ebede5d01efdcdd88c94f9df271d2eb237de ]
queue_init() initializes default formats for both the source and capture queues. It first sets the source field to V4L2_FIELD_SEQ_TB, but then stores the capture default, V4L2_FIELD_INTERLACED_TB, in the source queue again while initializing the capture queue.
This overwrites the valid source default and leaves the capture field at its zero-initialized value, V4L2_FIELD_ANY. vidioc_streamon() accepts only V4L2_FIELD_SEQ_TB or V4L2_FIELD_SEQ_BT on the source queue, and requires the capture queue to use a compatible interlaced or NONE field. Userspace that relies on the default formats can therefore get -EINVAL when starting streaming.
Initialize the capture field instead. The bug is usually hidden because mem2mem applications commonly call S_FMT on both queues before streaming; the TRY_FMT paths normalize the fields and S_FMT overwrites q_data[].field.
--- drivers/media/platform/m2m-deinterlace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/m2m-deinterlace.c +1 -1
@@ -830,7 +830,7 @@ static int queue_init(void *priv, struct vb2_queue *src_vq, q_data[V4L2_M2M_DST ].width =640 ; q_data[V4L2_M2M_DST ].height =480 ; q_data[V4L2_M2M_DST ].sizeimage = (640 *480 *3 ) /2 ; - q_data[V4L2_M2M_SRC ].field =V4L2_FIELD_INTERLACED_TB ; + q_data[V4L2_M2M_DST ].field =V4L2_FIELD_INTERLACED_TB ;return vb2_queue_init (dst_vq); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 377/1848 mtd: rawnand: sunxi: reject ECC maximization on small pages
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hilliard <[email protected]>
[ Upstream commit a3c84084a73e170374b7dd493947efdef4ee57bc ]
When nand-ecc-maximize is set, the driver selects a 1024-byte ECC step and divides the available OOB bytes by the resulting number of steps. A NAND with a smaller page therefore produces zero steps and a division by zero.
The older controllers also provide a 512-byte ECC block mode, but the hardware documentation describes that as an ECC block size within NAND pages whose supported sizes start at 1024 bytes. It does not document a 512-byte NAND page mode.
Reject pages smaller than 1024 bytes before deriving the step count. This prevents the division by zero at the point where the incompatible maximized geometry is selected without changing explicitly configured 512-byte ECC block handling.
--- drivers/mtd/nand/raw/sunxi_nand.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mtd/nand/raw/sunxi_nand.c +3 -0
@@ -1620,6 +1620,9 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,if (nanddev->ecc.user_conf.flags &NAND_ECC_MAXIMIZE_STRENGTH ) {int bytes; +if (mtd->writesize <1024 ) +return -EINVAL ; + ecc->size =1024 ; nsectors = mtd->writesize / ecc->size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 378/1848 media: adv7604: avoid negative array index in log_status when cp_read fails
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]>
[ Upstream commit 10d8dfda1c08f6788049aa100685e223d857f901 ]
cp_read() returns the negative errno from regmap_read() on I2C failure. adv76xx_log_status() shifts the result right by 4 and uses it directly to index csc_coeff_sel_rb[16] causing the right shift of a negative number to result in -1, reading a negative place in the array.
Commit 8163419e3e05 ("media: adv7842: Avoid possible out-of-bounds array accesses in adv7842_cp_log_status()") fixed the identical pattern in the adv7842, so do the same thing here.
--- drivers/media/i2c/adv7604.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/i2c/adv7604.c +2 -1
@@ -2605,8 +2605,9 @@ static int adv76xx_log_status(struct v4l2_subdev *sd) "(16-235)" : "(0-255)", (reg_io_0x02 & 0x08) ? "enabled" : "disabled"); } + ret =cp_read (sd, info->cp_csc) >>4 ;v4l2_info (sd,"Color space conversion: %s\n" , - csc_coeff_sel_rb[cp_read (sd, info->cp_csc) >>4 ]); + ret <0 ?"" : csc_coeff_sel_rb[ret]);if (!is_digital_input (sd))return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 379/1848 media: stv090x: bound DiSEqC reply length to msg[] size
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]>
[ Upstream commit bad6ce6e0856f344910ba95b006e6c0ebee2d9c8 ]
The FIFO_BYTENBR_FIELD register field is 4 bits wide, giving a length of 0..15, but reply->msg is __u8[4] in struct dvb_diseqc_slave_reply. A faulty or malicious DiSEqC slave (or i2c bus glitch) reporting more than 4 bytes will the array and clobber the stack.
The stb0899, tda10071, and s5h1420 drivers all properly bound the FIFO count against sizeof(reply->msg) before the read loop, so do the same thing in this driver.
--- drivers/media/dvb-frontends/stv090x.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/dvb-frontends/stv090x.c +2 -0
@@ -3897,6 +3897,8 @@ static int stv090x_recv_slave_reply(struct dvb_frontend *fe, struct dvb_diseqc_sif (rx_end) { reply->msg_len =STV090x_GETFIELD_Px (reg,FIFO_BYTENBR_FIELD ); +if (reply->msg_len >sizeof (reply->msg)) + reply->msg_len =sizeof (reply->msg);for (i =0 ; i < reply->msg_len; i++) reply->msg[i] =STV090x_READ_DEMOD (state,DISRXDATA ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 380/1848 media: stv0900: bound DiSEqC reply length to msg[] size
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]>
[ Upstream commit 6d7e70111b9c80a9e4cb17fe6a6c4f5470847722 ]
The FIFO_BYTENBR field is 4 bits (mask 0x0f), giving a length of 0..15 but reply->msg is __u8[4] in struct dvb_diseqc_slave_reply. A faulty or malicious device reporting more than 4 bytes will the array and clobber the stack.
The stb0899, tda10071, and s5h1420 drivers all properly bound the FIFO count against sizeof(reply->msg) before the read loop, so do the same thing in this driver.
--- drivers/media/dvb-frontends/stv0900_core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/dvb-frontends/stv0900_core.c +2 -0
@@ -1775,6 +1775,8 @@ static int stv0900_recv_slave_reply(struct dvb_frontend *fe,if (stv0900_get_bits (intp,RX_END )) { reply->msg_len =stv0900_get_bits (intp,FIFO_BYTENBR ); +if (reply->msg_len >sizeof (reply->msg)) + reply->msg_len =sizeof (reply->msg);for (i =0 ; i < reply->msg_len; i++) reply->msg[i] =stv0900_read_reg (intp,DISRXDATA );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 381/1848 drm/bridge: analogix_dp: Restore mandatory samsung DP DT properties
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Damon Ding <[email protected]>
[ Upstream commit 02f569dd66c94dd67b2586f776235cf4177409ed ]
Revert the change that made samsung,link-rate and samsung,lane-count optional for Exynos DP. Add error checking to fail probe early if the required DT properties are missing.
If these properties are missing, video_info->max_link_rate and video_info->max_lane_count remain zero, and so do link_train.link_rate and link_train.lane_count used in the subsequent link training flow, resulting in link training failure.
There is no way at all a device can work without these properties. Here is the code flow when either max_link_rate or max_lane_count is 0:
analogix_dp_commit()
-> analogix_dp_full_link_train(dp, max_lanes = 0, max_rate = 0)
analogix_dp_full_link_train(max_lanes, max_rate):
// Read sink capabilities via DPCD and sanitize them
link_rate = read_dpcd(DP_MAX_LINK_RATE); // >= 0x06 after fixup
lane_count = read_dpcd(DP_MAX_LANE_COUNT); // >= 1 after fixup
// Clamp by the limits from DT
if (link_rate > max_rate) // 0x06 > 0, always true
link_rate = max_rate; // link_rate = 0
if (lane_count > max_lanes) // 1 > 0, always true
lane_count = max_lanes; // lane_count = 0
// Configure TX with the zeroed values
set_link_bandwidth(link_rate = 0)
// writel() is only executed for bwtype == 0x06/0x0a,
// so LINK_BW_SET is never written and stays at
// reset value; phy_configure() gets link_rate = 0.
set_lane_count(lane_count = 0)
// writel(0, ANALOGIX_DP_LANE_COUNT_SET) enables 0 lanes;
// phy_configure() is called with lanes = 0.
// Program sink for link training
drm_dp_dpcd_write(DP_LINK_BW_SET, {link_rate = 0/lane_count = 0})
// DP spec requires link rate in {0x06, 0x0a, 0x14} and
// lane count in {1, 2, 4}. Writing zeros is illegal, so
// the sink cannot enter the training state.
// Training loop
for (lane = 0; lane < lane_count /* 0 */; lane++)
// loop body never executes; training_lane[] stays
// uninitialized and no training register is programmedSince the sanitized sink values are always non-zero (link_rate >= 0x06, lane_count >= 1), the clamping with a zero maximum unconditionally forces the training parameters to zero. Clock recovery can never be achieved, so link training fails deterministically.
Consequently, making these properties mandatory again cannot break any existing device: a DT without them could never have worked in the first place. Failing probe early with a clear error message is more helpful than a silent link training failure at runtime.
--- drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +9 -4
@@ -1643,6 +1643,7 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp) {struct device_node *dp_node = dp->dev->of_node;struct video_info *video_info = &dp->video_info; +u32 val;switch (dp->plat_data->dev_type) {case RK3288_DP :
@@ -1659,10 +1660,14 @@ static int analogix_dp_dt_parse_pdata(struct analogix_dp_device *dp)* NOTE: those property parseing code is used for * providing backward compatibility for samsung platform. */ -of_property_read_u32 (dp_node,"samsung,link-rate" , - &video_info->max_link_rate); -of_property_read_u32 (dp_node,"samsung,lane-count" , - &video_info->max_lane_count); +if (of_property_read_u32 (dp_node,"samsung,link-rate" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,link-rate\n" ); + video_info->max_link_rate = val; +if (of_property_read_u32 (dp_node,"samsung,lane-count" , &val)) +return dev_err_probe (dp->dev, -EINVAL , +"Failed to get samsung,lane-count\n" ); + video_info->max_lane_count = val;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 382/1848 dmaengine: altera-msgdma: initialize state before requesting IRQ
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit a5f8e3471fc20567df888267885dec3eb340eb37 ]
msgdma_probe() registers the IRQ before initializing the tasklet, lock, and descriptor lists used by the interrupt handler. A pending interrupt can access incomplete state during probe.
Initialize the handler state before requesting the IRQ so the interrupt path observes ready software state.
--- drivers/dma/altera-msgdma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/dma/altera-msgdma.c +5 -5
@@ -825,11 +825,6 @@ static int msgdma_probe(struct platform_device *pdev)if (mdev->irq <0 )return -ENXIO ; - ret =devm_request_irq (&pdev->dev, mdev->irq, msgdma_irq_handler, -0 ,dev_name (&pdev->dev), mdev); -if (ret) -return ret; -tasklet_setup (&mdev->irq_tasklet, msgdma_tasklet);dma_cookie_init (&mdev->dmachan);
@@ -841,6 +836,11 @@ static int msgdma_probe(struct platform_device *pdev)INIT_LIST_HEAD (&mdev->done_list);INIT_LIST_HEAD (&mdev->free_list); + ret =devm_request_irq (&pdev->dev, mdev->irq, msgdma_irq_handler, +0 ,dev_name (&pdev->dev), mdev); +if (ret) +return ret; + dma_dev = &mdev->dmadev;/* Set DMA capabilities */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 383/1848 iio: imu: inv_icm42600: fix odr change not caught in certain cases
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jean-Baptiste Maneyrol <[email protected]>
[ Upstream commit f670d4d3477386d62017936f0121909f93ac17f8 ]
When using both accel and gyro with different frequencies, the ODR change flag in the FIFO header can be sometime in a packet with invalid data. Since we are ignoring these packets, we miss the ODR change and any further change are blocked until sensor is turned off.
Fix this by moving the packet data validity check after the ODR change flag check.
--- drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c | 8 ++++---- drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/iio/imu/inv_icm42600/inv_icm42600_accel.c +4 -4
@@ -773,15 +773,15 @@ int inv_icm42600_accel_parse_fifo(struct iio_dev *indio_dev)if (size <=0 )return size; -/* skip packet if no accel data or data is invalid */ -if (accel ==NULL || !inv_icm42600_fifo_is_data_valid (accel)) -continue ; -/* update odr */ if (odr &INV_ICM42600_SENSOR_ACCEL )inv_sensors_timestamp_apply_odr (ts, st->fifo.period, st->fifo.nb.total, no); +/* skip packet if no accel data or data is invalid */ +if (accel ==NULL || !inv_icm42600_fifo_is_data_valid (accel)) +continue ; +memcpy (&buffer.accel, accel,sizeof (buffer.accel));/* convert 8 bits FIFO temperature in high resolution format */ buffer.temp = temp ? (*temp *64 ) :0 ;
drivers/iio/imu/inv_icm42600/inv_icm42600_gyro.c +4 -4
@@ -784,15 +784,15 @@ int inv_icm42600_gyro_parse_fifo(struct iio_dev *indio_dev)if (size <=0 )return size; -/* skip packet if no gyro data or data is invalid */ -if (gyro ==NULL || !inv_icm42600_fifo_is_data_valid (gyro)) -continue ; -/* update odr */ if (odr &INV_ICM42600_SENSOR_GYRO )inv_sensors_timestamp_apply_odr (ts, st->fifo.period, st->fifo.nb.total, no); +/* skip packet if no gyro data or data is invalid */ +if (gyro ==NULL || !inv_icm42600_fifo_is_data_valid (gyro)) +continue ; +memcpy (&buffer.gyro, gyro,sizeof (buffer.gyro));/* convert 8 bits FIFO temperature in high resolution format */ buffer.temp = temp ? (*temp *64 ) :0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 384/1848 sched/fair: Reset NUMA fault locality after scan period update
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Kim <[email protected]>
[ Upstream commit e81ee06308379a5f2ededf997bcf17551bce5db7 ]
When updating the task scan period for NUMA locality checks, update_task_scan_period() checks whether there were no faults or failed migration on the last scan window, at which it prolongs the scan period.
However, p->numa_faults_locality, which is used to check for migration failure and number of faults at the previous scan window is not cleared after changing the scan period, which unintentionally increases numa_scan_period up to numa_scan_period_max even when there were no migration failures or no faults at previous scan.
Fix this by jumping to the out label on early exit at this case to ensure p->numa_faults_locality is always cleared before returning.
--- kernel/sched/fair.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
kernel/sched/fair.c +5 -2
@@ -2202,7 +2202,7 @@ static void update_task_scan_period(struct task_struct *p, p->mm->numa_next_scan = jiffies +msecs_to_jiffies (p->numa_scan_period); -return ; + goto out; }/*
@@ -2246,7 +2246,10 @@ static void update_task_scan_period(struct task_struct *p, p->numa_scan_period =clamp (p->numa_scan_period + diff,task_scan_min (p),task_scan_max (p)); -memset (p->numa_faults_locality,0 ,sizeof (p->numa_faults_locality)); + +out: +memset (p->numa_faults_locality,0 , +sizeof (p->numa_faults_locality)); }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 385/1848 media: vivid: round the height down to the vertical subsampling factor
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxim Skokov <[email protected]>
[ Upstream commit a2ec28dd2a88d0721fc4a30242861e2be01d4023 ]
syzbot reports a vmalloc out-of-bounds write in the test pattern generator:
BUG: KASAN: vmalloc-out-of-bounds in tpg_fill_plane_pattern drivers/media/common/v4l2-tpg/v4l2-tpg-core.c:2617 [inline] BUG: KASAN: vmalloc-out-of-bounds in tpg_fill_plane_buffer+0x2063/0x4160 drivers/media/common/v4l2-tpg/v4l2-tpg-core.c:2705 Write of size 720 at addr ffffc900038f9d50 by task vivid-000-vid-c/6017
The reproducer requests a 720x49 NV12 capture format, i.e. an odd height for a format whose chroma plane is vertically subsampled.
The buffer size is derived from the height by a truncating division:
sizes[p] = (tpg_g_line_width(&dev->tpg, p) * h) / dev->fmt_cap->vdownsampling[p] + dev->fmt_cap->data_offset[p];
For a single buffer holding both planes tpg_g_line_width() returns 720 + 720 / 2 = 1080, so 1080 * 49 = 52920 bytes get allocated.
tpg_fill_plane_buffer() however emits one chroma line for every two luma lines, i.e. DIV_ROUND_UP(49, 2) = 25 lines, and thus needs 49 * 720 + 25 * 720 = 53280 bytes. The memcpy() of the last chroma line runs 360 bytes past the end of the buffer.
An odd height is not meaningful for a 4:2:0 format in the first place, since the chroma plane would have to hold half a line. Rather than fixing up each of the ~10 sites that divide the height by vdownsampling[], round the height down to a multiple of the vertical subsampling factor where it enters the driver. Adjusting the format is what TRY_FMT/S_FMT are for, and it keeps every later division exact.
Formats without vertical subsampling are unaffected and keep accepting odd heights.
Tested with the syzbot reproducer, which no longer triggers the splat, and by streaming NV12, NV21, YUV420, YVU420 and YUYV at heights 47, 48, 49, 51, 480, 481 and 1081. v4l2-compliance gives identical results before and after (48 of 50 succeeded on the vivid device in both cases; the two failures are pre-existing and unrelated).
--- drivers/media/test-drivers/vivid/vivid-vid-cap.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/media/test-drivers/vivid/vivid-vid-cap.c +13 -0
@@ -571,6 +571,7 @@ int vivid_try_fmt_vid_cap(struct file *file, void *priv,const struct vivid_fmt *fmt;unsigned bytesperline, max_bpl;unsigned factor =1 ; +unsigned int vdiv =1 ;unsigned w, h;unsigned p;bool user_set_csc = !!(mp->flags &V4L2_PIX_FMT_FLAG_SET_CSC );
@@ -623,6 +624,18 @@ int vivid_try_fmt_vid_cap(struct file *file, void *priv, mp->height = r.height / factor; } +/* +* The chroma planes of vertically subsampled formats hold +* height / vdownsampling lines. If the height is not a multiple of +* the subsampling factor, then the buffer size calculations round +* that number down while the test pattern generator rounds it up, +* so the generator writes one line past the end of the buffer. +* Round the height down to keep both in sync. +*/ +for (p =0 ; p < fmt->planes; p++) + vdiv =max (vdiv, fmt->vdownsampling[p]); + mp->height =rounddown (mp->height, vdiv); +/* This driver supports custom bytesperline values */ mp->num_planes = fmt->buffers;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 386/1848 media: cx231xx: preserve I2C transfer length
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juan Perdomo <[email protected]>
[ Upstream commit a19c9502a69bbd42c18816b09cbefdeb4cb68066 ]
The I2C core stores message lengths in u16, but cx231xx truncates them to u8 when populating cx231xx_i2c_xfer_data. A 0x700-byte read therefore becomes a zero-length request. USB treats zero-length control transfers as OUT regardless of bRequestType, so the IN control pipe trips the usb_submit_urb() direction warning.
Use u16 for buf_size, matching both i2c_msg.len and VENDOR_REQUEST_IN.wLength. Oversized transfers then reach the existing URB_MAX_CTRL_SIZE check and return -EINVAL.
--- drivers/media/usb/cx231xx/cx231xx.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/cx231xx/cx231xx.h +1 -1
@@ -462,7 +462,7 @@ struct cx231xx_i2c_xfer_data {u8 direction;/* 1 - IN, 0 - OUT */ u8 saddr_len;/* sub address len */ u16 saddr_dat;/* sub addr data */ -u8 buf_size;/* buffer size */ +u16 buf_size;/* buffer size */ u8 *p_buffer;/* pointer to the buffer */ };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 387/1848 media: vicodec: zero-initialize stateful decoder heap buffers
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 27953c044974baf7e24dee3e9342fe0103dea80c ]
The stateful decoder leaks uninitialized kernel heap memory to userspace. A process that can open the decoder video node gets it back in the CAPTURE buffers it dequeues.
The reference frame and the compressed frame buffer are allocated with kvmalloc() in vicodec_start_streaming(), and the decoder can read them before they have been written. The first frame is allowed to be a P-frame, in which case it is decoded against a reference frame that was never produced, and the padding rows below the visible area are never written for any frame.
Use kvzalloc() for both allocations.
--- drivers/media/test-drivers/vicodec/vicodec-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/test-drivers/vicodec/vicodec-core.c +2 -2
@@ -1608,9 +1608,9 @@ static int vicodec_start_streaming(struct vb2_queue *q, } state->ref_stride = q_data->coded_width * info->luma_alpha_step; - state->ref_frame.buf =kvmalloc (total_planes_size,GFP_KERNEL ); + state->ref_frame.buf =kvzalloc (total_planes_size,GFP_KERNEL ); state->ref_frame.luma = state->ref_frame.buf; - new_comp_frame =kvmalloc (ctx->comp_max_size,GFP_KERNEL ); + new_comp_frame =kvzalloc (ctx->comp_max_size,GFP_KERNEL );if (!state->ref_frame.luma || !new_comp_frame) {kvfree (state->ref_frame.luma);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 388/1848 crypto: atmel-tdes - zero-initialize device state
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit dbe70508d507acd677e67eaf029040f5e3a3b2b3 ]
Commit c659d07f11a3 ("crypto: atmel-tdes - Switch to managed version of kzalloc") accidentally replaced kzalloc() with devm_kmalloc(), so the device state is no longer zeroed.
atmel_tdes_hw_init() tests dd->flags during probe: a stale TDES_FLAGS_INIT skips the hardware reset, and a stale TDES_FLAGS_BUSY makes atmel_tdes_handle_queue() treat the engine as permanently busy, leaving every request queued and never dispatched.
Seen on a SAM9X75 Curiosity: the first TDES request after boot never completes and the TDES interrupt count stays at zero, while the AES and SHA engines on the same SoC work normally.
Switch to devm_kzalloc(), matching the Atmel AES and SHA drivers.
--- drivers/crypto/atmel-tdes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/atmel-tdes.c +1 -1
@@ -1165,7 +1165,7 @@ static int atmel_tdes_probe(struct platform_device *pdev)struct resource *tdes_res;int err; - tdes_dd =devm_kmalloc (&pdev->dev,sizeof (*tdes_dd),GFP_KERNEL ); + tdes_dd =devm_kzalloc (&pdev->dev,sizeof (*tdes_dd),GFP_KERNEL );if (!tdes_dd)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 389/1848 crypto: atmel-aes - fix AADLENR for standalone GHASH
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 0dd8cded0e6f8c9635fe1d79d60dc7b2599b099b ]
atmel_aes_gcm_ghash_init() writes dd->total, the request's text length, to AES_AADLENR. But the GHASH it runs hashes the dd->datalen bytes passed
in: the 16-byte length block, or the padded IV when the IV is not 96 bits. The data sheet requires AES_AADLENR to hold the length of that input.
With empty plaintext and empty AAD, dd->total is 0 and the tag comes out wrong. Later requests only pass because dd->total still holds the previous request's length.
This is testmgr's first gcm(aes) vector, so CONFIG_CRYPTO_SELFTESTS=y fails at boot:
alg: aead: atmel-gcm-aes encryption test failed (wrong result) on test vector 0, cfg="in-place (one sglist)"
Without selftests the broken atmel-gcm-aes is preferred at priority 300. Seen on a SAM9X75 Curiosity with 6.18 and current mainline.
Write dd->datalen instead.
--- drivers/crypto/atmel-aes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/atmel-aes.c +1 -1
@@ -1434,7 +1434,7 @@ static int atmel_aes_gcm_ghash_init(struct atmel_aes_dev *dd)struct atmel_aes_gcm_ctx *ctx =atmel_aes_gcm_ctx_cast (dd->ctx);/* Set the data length. */ -atmel_aes_write (dd,AES_AADLENR , dd->total); +atmel_aes_write (dd,AES_AADLENR , dd->datalen);atmel_aes_write (dd,AES_CLENR ,0 );/* If needed, overwrite the GCM Intermediate Hash Word Registers */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 390/1848 lib/842: reject output overflows from index and short data
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 38ed7182f3491ec1449ff246551e11ad82adba45 ]
The output length passed to sw842_decompress() is the caller's buffer capacity. Indexed copies write 2, 4 or 8 bytes and short-data templates write up to 7, but neither checks that capacity before writing and decrementing p->olen.
Overwriting an undersized destination then underflows p->olen, which is unsigned, so every later bounds check in the stream passes. Subsequent operations keep writing past the destination, and a matching CRC lets sw842_decompress() return success with an output length larger than the capacity the caller supplied.
This is reachable through zram's compressed writeback path. With 842 selected, targeted corruption of the compressed data on its backing device made a KASAN kernel report vmalloc-out-of-bounds writes in __do_index() and sw842_decompress() when zram read the page back.
Check the remaining output before both operations and return -ENOSPC, matching the other output-producing templates.
--- lib/842/842_decompress.c | 5 +++++ 1 file changed, 5 insertions(+)
lib/842/842_decompress.c +5 -0
@@ -165,6 +165,9 @@ static int __do_index(struct sw842_param *p, u8 size, u8 bits, u64 fsize)u64 index, offset, total =round_down (p->out - p->ostart,8 );int ret; +if (size > p->olen) +return -ENOSPC ; + ret =next_bits (p, &index, bits);if (ret)return ret;
@@ -344,6 +347,8 @@ int sw842_decompress(const u8 *in, unsigned int ilen,if (!bytes || bytes >SHORT_DATA_BITS_MAX )return -EINVAL ; +if (bytes > p.olen) +return -ENOSPC ;while (bytes-- >0 ) { ret =next_bits (&p, &tmp,8 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 391/1848 lib/842: require a complete history block for repeat templates
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit deb631649882bbf43f7c2fc79b5990139fd744ba ]
An 842 repeat template copies the preceding eight-byte output block. The decoder rejects a repeat only when no output has been produced. A short-data operation can produce between one and seven bytes before a repeat.
Such a stream makes the repeat copy read before the start of the output buffer. Depending on the surrounding mapping, this can fault or bring preceding memory into the decompressed data.
This is also reachable through zram's compressed writeback path. With 842 selected, targeted corruption of the compressed data on its backing device to a short-data-then-repeat stream made a KASAN kernel report a vmalloc-out-of-bounds read when zram read the page back.
Require at least one complete output block before accepting a repeat.
--- lib/842/842_decompress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/842/842_decompress.c +1 -1
@@ -309,7 +309,7 @@ int sw842_decompress(const u8 *in, unsigned int ilen,if (ret)return ret; -if (p.out == out)/* no previous bytes */ +if (p.out - p.ostart <8 )/* no complete previous block */ return -EINVAL ;/* copy rep + 1 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 392/1848 PM: CPU: Restore synchronize_rcu() to cpu_pm_unregister_notifier()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bradley Morgan <[email protected]>
[ Upstream commit 61f7eee7d4664079fbce821576891c3ee5ccf597 ]
cpu_pm_notify() walks the notifier chain lockless under only rcu_read_lock(). That only works if a removed notifier block is not freed until every concurrent walker is done with it.
The chain used to be an atomic_notifier, whose unregister ends in synchronize_rcu(). Commit b2f6662ac08d ("PM: cpu: Make notifier chain use a raw_spinlock_t") switched it over to a raw_notifier, and in doing so replaced that with raw_notifier_chain_unregister(), which does not synchronize. The grace period quietly went away, so a driver that frees the memory holding its notifier block right after cpu_pm_unregister_notifier() returns can race with a concurrent walker:
cpu1 (idle exit) cpu2 (driver remove)
---------------- --------------------
cpu_pm_notify(CPU_PM_EXIT)
rcu_read_lock()
nb = rcu_dereference_raw(*nl)
cpu_pm_unregister_notifier(&od->nb)
unlink, no grace period
remove() frees od (devm)
nb->notifier_call(nb, ...)
/* use after free */The rcu_read_lock() on cpu1 does not stop cpu2 from freeing the block, and nothing else does. The read side is the idle exit path, so this can hit on any system where a driver with a cpu_pm notifier gets unbound.
Add the grace period back. It is only needed when a notifier was actually removed, so wait on success and return -ENOENT without waiting otherwise. The kerneldoc gets back the "may sleep" note that the same commit dropped.
--- kernel/cpu_pm.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
kernel/cpu_pm.c +8 -1
@@ -10,6 +10,7 @@#include <linux/cpu_pm.h> #include <linux/module.h> #include <linux/notifier.h> +#include <linux/rcupdate.h> #include <linux/spinlock.h> #include <linux/syscore_ops.h>
@@ -85,7 +86,8 @@ EXPORT_SYMBOL_GPL(cpu_pm_register_notifier);* * Remove a driver from the CPU PM notifier list. * -* This function has the same return conditions as raw_notifier_chain_unregister. +* This function may sleep, and has the same return conditions as +* raw_notifier_chain_unregister. */ int cpu_pm_unregister_notifier (struct notifier_block *nb) {
@@ -95,6 +97,11 @@ int cpu_pm_unregister_notifier(struct notifier_block *nb)raw_spin_lock_irqsave (&cpu_pm_notifier.lock, flags); ret =raw_notifier_chain_unregister (&cpu_pm_notifier.chain, nb);raw_spin_unlock_irqrestore (&cpu_pm_notifier.lock, flags); + +/* Wait for the rcu_read_lock() walkers in cpu_pm_notify(). */ +if (!ret) +synchronize_rcu (); +return ret; }EXPORT_SYMBOL_GPL (cpu_pm_unregister_notifier);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 393/1848 affs: validate blocks before freeing them
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit 78ea2058abf3ee053c0bd9c1b9a77304cb4ae58b ]
affs_free_block() accepts block numbers from on-disk file block tables when truncating or unlinking files. The function currently rejects only block numbers greater than s_partition_size before subtracting s_reserved and using the result to index the in-memory bitmap descriptor array.
That check still accepts reserved blocks and the one-past-end block at s_partition_size. A crafted image can therefore make the subtraction underflow or make the computed bitmap index equal to s_bmap_count, leading to an out-of-bounds access on s_bitmap before the bitmap block is read and updated.
Use the existing AFFS block validity helper so freeing uses the same range as block reads and writes: s_reserved <= block < s_partition_size.
--- fs/affs/bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/affs/bitmap.c +1 -1
@@ -46,7 +46,7 @@ affs_free_block(struct super_block *sb, u32 block)pr_debug ("%s(%u)\n" , __func__, block); -if (block > sbi->s_partition_size) +if (!affs_validblock (sb, block)) goto err_range; blk = block - sbi->s_reserved;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 394/1848 f2fs: compress: fix to handle race between truncate and writeback
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 c0337e331b065074ce20e4258a578e07dd7e4083 ]
fsstress reports a kernel BUG in f2fs_truncate_partial_cluster():
kernel BUG at fs/f2fs/compress.c:1238!
RIP: 0010:f2fs_truncate_partial_cluster+0x292/0x2a0 Call Trace: <TASK> f2fs_truncate+0xf6/0x210 f2fs_setattr+0x6b7/0x770 notify_change+0x33b/0x520 do_truncate+0xc2/0xf0 vfs_truncate+0x153/0x1d0 ksys_truncate+0x78/0xd0 __x64_sys_truncate+0x16/0x20 do_syscall_64+0xbe/0x540
The root cause is that Thread A (truncate) and Thread B (background writeback or fsync) can race as follows:
Thread A Thread B
- f2fs_setattr
- f2fs_truncate
- f2fs_truncate_blocks
- f2fs_truncate_partial_cluster
- f2fs_is_compressed_cluster
return 1
- f2fs_write_cache_pages
- f2fs_write_multi_pages
- f2fs_write_raw_pages
- f2fs_write_single_data_page dn.data_blkaddr != COMPRESS_ADDR (cluster converted to normal)
- f2fs_prepare_compress_overwrite
- f2fs_is_compressed_cluster
return 0
- return 0
- f2fs_bug_on(sbi, err == 0): BUG!
Writeback path does not acquire i_gc_rwsem or filemap_invalidate_lock. When a compressed cluster fails compression during writeback, it is overwritten with raw data blocks. If Thread A checked f2fs_is_compressed_cluster() before the conversion, but calls f2fs_prepare_compress_overwrite() after the conversion, f2fs_prepare_compress_overwrite() returns 0 because the cluster is no longer a compressed cluster.
To fix this, remove the f2fs_bug_on() and retry checking the cluster status when f2fs_prepare_compress_overwrite() returns 0, so that it can fall back to f2fs_do_truncate_blocks() to handle it as a normal cluster.
--- fs/f2fs/compress.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
fs/f2fs/compress.c +5 -5
@@ -1089,6 +1089,7 @@ int f2fs_truncate_partial_cluster(struct inode *inode, u64 from, bool lock) log_cluster_size;int err; +repeat: err =f2fs_is_compressed_cluster (inode, start_idx);if (err <0 )return err;
@@ -1100,12 +1101,11 @@ int f2fs_truncate_partial_cluster(struct inode *inode, u64 from, bool lock)/* truncate compressed cluster */ err =f2fs_prepare_compress_overwrite (inode, &pagep, start_idx, &fsdata); - -/* should not be a normal cluster */ -f2fs_bug_on (F2FS_I_SB (inode), err ==0 ); - -if (err <=0 ) +if (err <0 )return err; +else if (err ==0 ) +/* the cluster became non-compressed one due to race case */ + goto repeat;if (err >0 ) {struct page **rpages = fsdata;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 395/1848 ata: ahci_st: Do not ignore errors when getting the reset controls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit c74ee9230a8d1d2f6fcbceff55f56f7dd9b9cccd ]
st_ahci_probe_resets() treats any error from devm_reset_control_get() as "reset control not defined" and continues with a NULL reset control:
drv_data->pwr = devm_reset_control_get(dev, "pwr-dwn");
if (IS_ERR(drv_data->pwr)) {
dev_info(dev, "power reset control not defined\n");
drv_data->pwr = NULL;
}This also swallows -EPROBE_DEFER, which is returned when the reset controller providing the reset has not been probed yet. probe() then continues as if the device tree did not specify any reset, so the resets of the SATA IP are never deasserted, and st_ahci_configure_oob() and ahci_platform_init_host() access the MMIO of an IP which is still held in reset and powered down, which can result in an external abort.
The resets are optional in the binding, as they are not part of its required properties, so use devm_reset_control_get_optional(), which returns NULL if the reset is not specified in the device tree, and propagate all other errors.
Note that an absent reset is now indicated by a NULL reset control instead of an error, so the "reset control not defined" messages are dropped.
--- drivers/ata/ahci_st.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-)
drivers/ata/ahci_st.c +14 -17
@@ -105,23 +105,20 @@ static int st_ahci_probe_resets(struct ahci_host_priv *hpriv, {struct st_ahci_drv_data *drv_data = hpriv->plat_data; - drv_data->pwr =devm_reset_control_get (dev,"pwr-dwn" ); -if (IS_ERR (drv_data->pwr)) { -dev_info (dev,"power reset control not defined\n" ); - drv_data->pwr =NULL ; - } - - drv_data->sw_rst =devm_reset_control_get (dev,"sw-rst" ); -if (IS_ERR (drv_data->sw_rst)) { -dev_info (dev,"soft reset control not defined\n" ); - drv_data->sw_rst =NULL ; - } - - drv_data->pwr_rst =devm_reset_control_get (dev,"pwr-rst" ); -if (IS_ERR (drv_data->pwr_rst)) { -dev_dbg (dev,"power soft reset control not defined\n" ); - drv_data->pwr_rst =NULL ; - } + drv_data->pwr =devm_reset_control_get_optional (dev,"pwr-dwn" ); +if (IS_ERR (drv_data->pwr)) +return dev_err_probe (dev,PTR_ERR (drv_data->pwr), +"failed to get pwr-dwn reset\n" ); + + drv_data->sw_rst =devm_reset_control_get_optional (dev,"sw-rst" ); +if (IS_ERR (drv_data->sw_rst)) +return dev_err_probe (dev,PTR_ERR (drv_data->sw_rst), +"failed to get sw-rst reset\n" ); + + drv_data->pwr_rst =devm_reset_control_get_optional (dev,"pwr-rst" ); +if (IS_ERR (drv_data->pwr_rst)) +return dev_err_probe (dev,PTR_ERR (drv_data->pwr_rst), +"failed to get pwr-rst reset\n" );return st_ahci_deassert_resets (hpriv, dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 396/1848 ata: ahci_st: Assert the power down reset in the probe() error path
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit 91e0a7452d7a81e924a499b23f30f3bf85fddbd2 ]
st_ahci_probe_resets() deasserts the "pwr-dwn" reset, but the probe() error path of st_ahci_probe() only releases the host resources, so the SATA IP is left powered up when probe() fails after st_ahci_probe_resets() has succeeded, e.g. when ahci_platform_enable_resources() fails.
The reset is asserted by st_ahci_host_stop(), however ->host_stop() is only called through the ata_host_stop() devres action registered by ata_host_start(), so it does not cover any failure happening before the host has been started.
Factor the assert out into st_ahci_assert_pwrdwn() and call it when either ahci_platform_enable_resources() or ahci_platform_init_host() fails. The "pwr-dwn" reset control is an exclusive one, so asserting it once more from st_ahci_host_stop() is harmless.
No functional change intended for ->host_stop() and st_ahci_suspend().
--- drivers/ata/ahci_st.c | 51 +++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 21 deletions(-)
drivers/ata/ahci_st.c +30 -21
@@ -84,18 +84,27 @@ static int st_ahci_deassert_resets(struct ahci_host_priv *hpriv,return 0 ; } -static void st_ahci_host_stop (struct ata_host *host) +static int st_ahci_assert_pwrdwn (struct ahci_host_priv *hpriv, +struct device *dev) { -struct ahci_host_priv *hpriv = host->private_data;struct st_ahci_drv_data *drv_data = hpriv->plat_data; -struct device *dev = host->dev;int err; -if (drv_data->pwr) { - err =reset_control_assert (drv_data->pwr); -if (err) -dev_err (dev,"unable to pwrdwn\n" ); - } +if (!drv_data->pwr) +return 0 ; + + err =reset_control_assert (drv_data->pwr); +if (err) +dev_err (dev,"unable to pwrdwn\n" ); + +return err; +} + +static void st_ahci_host_stop (struct ata_host *host) +{ +struct ahci_host_priv *hpriv = host->private_data; + +st_ahci_assert_pwrdwn (hpriv, host->dev);ahci_platform_disable_resources (hpriv); }
@@ -161,7 +170,7 @@ static int st_ahci_probe(struct platform_device *pdev) err =ahci_platform_enable_resources (hpriv);if (err) -return err; + goto assert_pwrdwn;st_ahci_configure_oob (hpriv->mmio);
@@ -170,12 +179,17 @@ static int st_ahci_probe(struct platform_device *pdev) err =ahci_platform_init_host (pdev, hpriv, &st_ahci_port_info, &ahci_platform_sht); -if (err) { -ahci_platform_disable_resources (hpriv); -return err; - } +if (err) + goto disable_resources;return 0 ; + +disable_resources: +ahci_platform_disable_resources (hpriv); +assert_pwrdwn: +st_ahci_assert_pwrdwn (hpriv, &pdev->dev); + +return err; }#ifdef CONFIG_PM_SLEEP
@@ -183,20 +197,15 @@ static int st_ahci_suspend(struct device *dev) {struct ata_host *host =dev_get_drvdata (dev);struct ahci_host_priv *hpriv = host->private_data; -struct st_ahci_drv_data *drv_data = hpriv->plat_data;int err; err =ahci_platform_suspend_host (dev);if (err)return err; -if (drv_data->pwr) { - err =reset_control_assert (drv_data->pwr); -if (err) { -dev_err (dev,"unable to pwrdwn" ); -return err; - } - } + err =st_ahci_assert_pwrdwn (hpriv, dev); +if (err) +return err;ahci_platform_disable_resources (hpriv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 397/1848 crypto: atmel-tdes - sync output bounce buffer before DMA
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit a38fdcb9c944525ca71e6aaf35e708586d0ae87d ]
The slow path maps its output bounce buffer once at probe time with dma_map_single() and DMA_FROM_DEVICE, then reuses the mapping for every request. After the CPU copies a result from the buffer, dma_sync_single_for_device() must hand the buffer back to the device before the next DMA transfer. The driver omits this call, so cache lines from the previous result can remain valid while the device writes the next one.
This bug was masked by the completion paths calling dma_sync_single_for_device() immediately before the CPU copied the output, where dma_sync_single_for_cpu() was required. For DMA_FROM_DEVICE on ARM926, dma_sync_single_for_device() invokes arm926_dma_map_area(), which invalidates the cache lines. The misplaced call therefore discarded the stale lines before every copy-out.
Commit c8a9a647532f ("crypto: atmel-tdes - fix DMA sync direction") correctly changed the completion paths to call dma_sync_single_for_cpu(). On ARM926, that function invokes arm926_dma_unmap_area(), which is a no-op. The missing pre-DMA dma_sync_single_for_device() was therefore exposed on ARM926-based SAM9X60 and SAM9X7 SoCs.
With CONFIG_CRYPTO_SELFTESTS=y all four DES/TDES algorithms fail on SAM9X75:
alg: skcipher: atmel-ecb-tdes encryption test failed (wrong result) on test vector 2, cfg="unaligned buffer, offset=1"
Call dma_sync_single_for_device() for the output buffer before starting DMA in both atmel_tdes_crypt_pdc() and atmel_tdes_crypt_dma().
--- drivers/crypto/atmel-tdes.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/crypto/atmel-tdes.c +4 -0
@@ -394,6 +394,8 @@ static int atmel_tdes_crypt_pdc(struct atmel_tdes_dev *dd,if (!(dd->flags &TDES_FLAGS_FAST )) {dma_sync_single_for_device (dd->dev, dma_addr_in, length,DMA_TO_DEVICE ); +dma_sync_single_for_device (dd->dev, dma_addr_out, length, +DMA_FROM_DEVICE ); }switch (rctx->mode &TDES_FLAGS_OPMODE_MASK ) {
@@ -439,6 +441,8 @@ static int atmel_tdes_crypt_dma(struct atmel_tdes_dev *dd,if (!(dd->flags &TDES_FLAGS_FAST )) {dma_sync_single_for_device (dd->dev, dma_addr_in, length,DMA_TO_DEVICE ); +dma_sync_single_for_device (dd->dev, dma_addr_out, length, +DMA_FROM_DEVICE ); }switch (rctx->mode &TDES_FLAGS_OPMODE_MASK ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 398/1848 usb: fotg210: validate endpoint index in ep0 handlers
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Chao <[email protected]>
[ Upstream commit bbddb219b00af0792242a0ad1dc7fb3344f38733 ]
fotg210_set_feature(), fotg210_clear_feature() and fotg210_get_status() use wIndex from the USB setup packet to index the fotg210->ep[] array without verifying that the endpoint number falls below FOTG210_MAX_NUM_EP (5). USB_ENDPOINT_NUMBER_MASK is 0x0f, so a malicious host can issue a setup packet with wIndex 5..15, resulting in an out-of-bounds array read. The resulting wild pointer is then dereferenced in fotg210_set_epnstall() or fotg210_is_epnstall(), which compute an MMIO register offset from ep->epnum and perform iowrite32 through it.
fotg210_clear_feature() is especially problematic: the out-of-bounds access occurs at function entry (source-level) regardless of which USB_RECIP_* case is taken, because the ep pointer is computed before the switch statement.
Add upper-bound checks on the endpoint number derived from wIndex in all three functions. Invalid endpoint numbers in clear_feature now trigger fotg210_request_error() (STALL) instead of silently falling through to fotg210_set_cxdone(). Also add the missing le16_to_cpu() conversion for ctrl->wIndex in fotg210_get_status() to fix a sparse endianness warning.
--- drivers/usb/gadget/udc/fotg210-udc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/usb/gadget/udc/fotg210-udc.c +11 -6
@@ -650,7 +650,7 @@ static void fotg210_set_feature(struct fotg210_udc *fotg210,case USB_RECIP_ENDPOINT : {u8 epnum; epnum =le16_to_cpu (ctrl->wIndex) &USB_ENDPOINT_NUMBER_MASK ; -if (epnum) +if (epnum && epnum <FOTG210_MAX_NUM_EP )fotg210_set_epnstall (fotg210->ep[epnum]);else fotg210_set_cxstall (fotg210);
@@ -666,8 +666,8 @@ static void fotg210_set_feature(struct fotg210_udc *fotg210,static void fotg210_clear_feature (struct fotg210_udc *fotg210,struct usb_ctrlrequest *ctrl) { -struct fotg210_ep *ep = - fotg210->ep[ctrl->wIndex &USB_ENDPOINT_NUMBER_MASK ]; +u8 epnum =le16_to_cpu (ctrl->wIndex) &USB_ENDPOINT_NUMBER_MASK ; +struct fotg210_ep *ep;switch (ctrl->bRequestType &USB_RECIP_MASK ) {case USB_RECIP_DEVICE :
@@ -677,7 +677,12 @@ static void fotg210_clear_feature(struct fotg210_udc *fotg210,fotg210_set_cxdone (fotg210);break ;case USB_RECIP_ENDPOINT : -if (ctrl->wIndex &USB_ENDPOINT_NUMBER_MASK ) { +if (epnum >=FOTG210_MAX_NUM_EP ) { +fotg210_request_error (fotg210); +break ; + } +if (epnum) { + ep = fotg210->ep[epnum];if (ep->wedged) {fotg210_set_cxdone (fotg210);break ;
@@ -719,8 +724,8 @@ static void fotg210_get_status(struct fotg210_udc *fotg210, fotg210->ep0_data =cpu_to_le16 (0 );break ;case USB_RECIP_ENDPOINT : - epnum = ctrl->wIndex &USB_ENDPOINT_NUMBER_MASK ; -if (epnum) + epnum =le16_to_cpu (ctrl->wIndex) &USB_ENDPOINT_NUMBER_MASK ; +if (epnum && epnum <FOTG210_MAX_NUM_EP ) fotg210->ep0_data =cpu_to_le16 (fotg210_is_epnstall (fotg210->ep[epnum]) <<USB_ENDPOINT_HALT );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 399/1848 ASoC: wm8994: Fix runtime PM imbalance in wm8994_component_probe()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 480a5528cb6268d626632d45d4a1f29b4c0c11df ]
In wm8994_component_probe(), pm_runtime_get_sync() is invoked before reading the GPIO configuration registers. If either regmap_read() fails, the function jumps to err_irq without calling pm_runtime_put(), leaving the runtime PM usage count incremented and causing a leak.
Add pm_runtime_put() on both GPIO read failure paths before jumping to err_irq.
--- sound/soc/codecs/wm8994.c | 2 ++ 1 file changed, 2 insertions(+)
sound/soc/codecs/wm8994.c +2 -0
@@ -4352,6 +4352,7 @@ static int wm8994_component_probe(struct snd_soc_component *component) ret =regmap_read (control->regmap,WM8994_GPIO_1 , ®);if (ret <0 ) {dev_err (component->dev,"Failed to read GPIO1 state: %d\n" , ret); +pm_runtime_put (component->dev); goto err_irq; }if ((reg &WM8994_GPN_FN_MASK ) !=WM8994_GP_FN_PIN_SPECIFIC ) {
@@ -4364,6 +4365,7 @@ static int wm8994_component_probe(struct snd_soc_component *component) ret =regmap_read (control->regmap,WM8994_GPIO_6 , ®);if (ret <0 ) {dev_err (component->dev,"Failed to read GPIO6 state: %d\n" , ret); +pm_runtime_put (component->dev); goto err_irq; }if ((reg &WM8994_GPN_FN_MASK ) !=WM8994_GP_FN_PIN_SPECIFIC ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 400/1848 ASoC: arizona-jack: Fix runtime PM imbalance in arizona_start_hpdet_acc_id()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit e04dcb895b4622d67164e218a1179785e2c75999 ]
In arizona_start_hpdet_acc_id(), pm_runtime_get_sync() is called to keep the device powered during headphone detection. If setting the HPDET mode or starting the measurement fails and the function jumps to err, pm_runtime_put_autosuspend() was not called while info->hpdet_active was set to false, resulting in a runtime PM usage count leak.
Add pm_runtime_put_autosuspend() in the err error path to keep runtime PM balanced.
--- drivers/extcon/extcon-arizona.c | 1 + 1 file changed, 1 insertion(+)
drivers/extcon/extcon-arizona.c +1 -0
@@ -785,6 +785,7 @@ static void arizona_start_hpdet_acc_id(struct arizona_extcon_info *info)if (ret !=0 )dev_err (arizona->dev,"Failed to report headphone: %d\n" , ret); +pm_runtime_put_autosuspend (arizona->dev); info->hpdet_active = false; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 401/1848 iio: accel: kxcjk-1013: Disable autosuspend on remove
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 1de1206a42741adfb72ca8b37dc71a6bc80cb074 ]
kxcjk1013_probe() enables runtime PM autosuspend with pm_runtime_use_autosuspend(). The probe error path correctly undoes this setting with pm_runtime_dont_use_autosuspend(), but the normal remove path only disables runtime PM.
The runtime PM API requires pm_runtime_use_autosuspend() to be undone with pm_runtime_dont_use_autosuspend() at driver exit unless runtime PM was enabled with devm_pm_runtime_enable(). Leaving the autosuspend flag set therefore leaves the runtime PM state incompletely cleaned up after the driver is unbound.
Add the missing pm_runtime_dont_use_autosuspend() call to the remove path.
This issue was found by manual code inspection.
--- drivers/iio/accel/kxcjk-1013.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/accel/kxcjk-1013.c +1 -0
@@ -1457,6 +1457,7 @@ static int kxcjk1013_remove(struct i2c_client *client)iio_device_unregister (indio_dev); +pm_runtime_dont_use_autosuspend (&client->dev);pm_runtime_disable (&client->dev);pm_runtime_set_suspended (&client->dev);pm_runtime_put_noidle (&client->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 402/1848 iio: accel: mma9551: disable autosuspend on remove
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 8061720f6be1811478914f8b6143778d70f6033f ]
mma9551_probe() enables runtime PM autosuspend with pm_runtime_use_autosuspend(). The probe error path correctly undoes this setting with pm_runtime_dont_use_autosuspend(), but the normal remove path only disables runtime PM.
The runtime PM API requires pm_runtime_use_autosuspend() to be undone with pm_runtime_dont_use_autosuspend() at driver exit unless runtime PM was enabled with devm_pm_runtime_enable(). Leaving the autosuspend flag set therefore leaves the runtime PM state incompletely cleaned up after the driver is unbound.
Add the missing pm_runtime_dont_use_autosuspend() call to the remove path.
This issue was found by manual code inspection.
--- drivers/iio/accel/mma9551.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/accel/mma9551.c +1 -0
@@ -516,6 +516,7 @@ static int mma9551_remove(struct i2c_client *client)iio_device_unregister (indio_dev); +pm_runtime_dont_use_autosuspend (&client->dev);pm_runtime_disable (&client->dev);pm_runtime_set_suspended (&client->dev);pm_runtime_put_noidle (&client->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 403/1848 iio: accel: mma9553: disable autosuspend on remove
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 4dda1f9d25fb889649e81bbf015809daa512a049 ]
mma9553_probe() enables runtime PM autosuspend with pm_runtime_use_autosuspend(). The probe error path correctly undoes this setting with pm_runtime_dont_use_autosuspend(), but the normal remove path only disables runtime PM.
The runtime PM API requires pm_runtime_use_autosuspend() to be undone with pm_runtime_dont_use_autosuspend() at driver exit unless runtime PM was enabled with devm_pm_runtime_enable(). Leaving the autosuspend flag set therefore leaves the runtime PM state incompletely cleaned up after the driver is unbound.
Add the missing pm_runtime_dont_use_autosuspend() call to the remove path.
This issue was found by manual code inspection.
--- drivers/iio/accel/mma9553.c | 1 + 1 file changed, 1 insertion(+)
drivers/iio/accel/mma9553.c +1 -0
@@ -1155,6 +1155,7 @@ static int mma9553_remove(struct i2c_client *client)iio_device_unregister (indio_dev); +pm_runtime_dont_use_autosuspend (&client->dev);pm_runtime_disable (&client->dev);pm_runtime_set_suspended (&client->dev);pm_runtime_put_noidle (&client->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 404/1848 md/raid5: track disks array size to fix extra_page leak on error paths
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cao Guanghui <[email protected]>
[ Upstream commit 5028ceee173bfcf844469cfb0d1c151d3f6d0296 ]
free_conf() iterates conf->pool_size entries to free extra_page allocations, but pool_size may not reflect the actual size of the conf->disks array. Two scenarios cause a mismatch:
1. setup_conf() early abort: pool_size is 0 (not yet set by grow_stripes) but conf->disks has max_disks entries with extra_page allocated. The loop iterates 0 times, leaking all pages.
2. resize_stripes() Step 4 failure: conf->disks was replaced with a newsize-entry array in Step 3, but pool_size is only updated on success. The loop iterates pool_size (old, smaller value) times, leaking (newsize - pool_size) pages.
Add a dedicated disks_cnt field to track the actual number of entries in conf->disks. Set it immediately after each allocation or replacement (in setup_conf and resize_stripes Step 3, where the array is safely stalled with no concurrent access), and use it in free_conf() instead of pool_size.
This leaves pool_size untouched, preserving the check_reshape() retry behavior that depends on pool_size only being updated on full success.
--- drivers/md/raid5.c | 5 +++-- drivers/md/raid5.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/md/raid5.c +3 -2
@@ -2582,6 +2582,7 @@ static int resize_stripes(struct r5conf *conf, int newsize) }else {kfree (conf->disks); conf->disks = ndisks; + conf->disks_cnt = newsize; } }else err = -ENOMEM ;
@@ -7091,7 +7092,7 @@ static void free_conf(struct r5conf *conf)free_thread_groups (conf);shrink_stripes (conf);raid5_free_percpu (conf); -for (i =0 ; i < conf->pool_size; i++) +for (i =0 ; i < conf->disks_cnt; i++)if (conf->disks[i].extra_page)put_page (conf->disks[i].extra_page);kfree (conf->disks);
@@ -7273,7 +7274,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)if (!conf->disks) goto abort; - + conf->disks_cnt = max_disks;for (i =0 ; i < max_disks; i++) { conf->disks[i].extra_page =alloc_page (GFP_KERNEL );if (!conf->disks[i].extra_page)
drivers/md/raid5.h +1 -0
@@ -667,6 +667,7 @@ struct r5conf {unsigned long cache_state;struct shrinker shrinker;int pool_size;/* number of disks in stripeheads in pool */ +int disks_cnt;/* number of entries in disks[] array */ spinlock_t device_lock;struct disk_info *disks;struct bio_set bio_split;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 405/1848 md/raid5: fix NULL pointer dereference in raid5_free_percpu
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cao Guanghui <[email protected]>
[ Upstream commit 41742e35268d6a45161b187f51f42bc2ade14d0d ]
If cpuhp_state_add_instance() fails in raid5_alloc_percpu() (e.g., the startup callback raid456_cpu_up_prepare fails due to an allocation failure), conf->node is never added to the cpuhp instance list and its pprev remains NULL (from kzalloc initialization).
When setup_conf() then jumps to abort, free_conf() calls raid5_free_percpu(), which checks conf->percpu (non-NULL, since it was allocated before the cpuhp failure) and proceeds to call cpuhp_state_remove_instance(). This calls hlist_del() on the unhashed node, which dereferences node->pprev (NULL), causing a kernel panic.
Guard the removal with hlist_unhashed_lockless() so that the cpuhp instance is only removed if it was actually added. The lockless variant uses READ_ONCE() for the pprev read, which is safe here because the actual removal is synchronized by cpuhp_state_mutex inside cpuhp_state_remove_instance().
--- drivers/md/raid5.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/raid5.c +2 -1
@@ -7078,7 +7078,8 @@ static void raid5_free_percpu(struct r5conf *conf)if (!conf->percpu)return ; -cpuhp_state_remove_instance (CPUHP_MD_RAID5_PREPARE , &conf->node); +if (!hlist_unhashed_lockless (&conf->node)) +cpuhp_state_remove_instance (CPUHP_MD_RAID5_PREPARE , &conf->node);free_percpu (conf->percpu); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 406/1848 md/raid5: validate payload size before calculating payload_len
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Wilck <[email protected]>
[ Upstream commit 38c795105992bbaa3418dd39cbff7348ad17537c ]
Commit b0cc3ae97e89 ("md/raid5: validate payload size before accessing journal metadata") introduced a bounds check to verify that a given payload fits into the current metadata block. In order to calculate the payload size, it has to access the members payload->header.type and payload->size, the offset of which may already be past the end of the metadata block, because the loop condition only checks that the first byte of the payload is inside, and the payload entries have variable sizes. Later on, payload->checksum[0] and payload->checksum[1] are accessed without verifying that payload->size is large enough.
Add another check to make sure that payload->size can be safely accessed, and make sure that the checksum fields are accessible.
This issue has been found by AI (gemma4, Gemini) during a backport review.
--- drivers/md/raid5-cache.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-)
drivers/md/raid5-cache.c +26 -8
@@ -2016,27 +2016,36 @@ r5l_recovery_verify_data_checksum_for_mb(struct r5l_log *log,if (!page)return -ENOMEM ; -while (mb_offset <le32_to_cpu (mb->meta_size)) { +while (mb_offset +sizeof (struct r5l_payload_header ) <=le32_to_cpu (mb->meta_size)) { +u32 payload_size;sector_t payload_len; payload = (void *)mb + mb_offset; payload_flush = (void *)mb + mb_offset;if (le16_to_cpu (payload->header.type) ==R5LOG_PAYLOAD_DATA ) { +if (mb_offset +sizeof (struct r5l_payload_data_parity ) + >le32_to_cpu (mb->meta_size)) + goto mismatch; + payload_size =le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 ); payload_len =sizeof (struct r5l_payload_data_parity ) + - (sector_t )sizeof (__le32) * - (le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 )); -if (mb_offset + payload_len >le32_to_cpu (mb->meta_size)) + (sector_t )sizeof (__le32) * payload_size; +if (mb_offset + payload_len >le32_to_cpu (mb->meta_size) || + payload_size <1 ) goto mismatch;if (r5l_recovery_verify_data_checksum ( log, ctx, page, log_offset, payload->checksum[0 ]) <0 ) goto mismatch; }else if (le16_to_cpu (payload->header.type) ==R5LOG_PAYLOAD_PARITY ) { +if (mb_offset +sizeof (struct r5l_payload_data_parity ) + >le32_to_cpu (mb->meta_size)) + goto mismatch; + payload_size =le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 ); payload_len =sizeof (struct r5l_payload_data_parity ) + - (sector_t )sizeof (__le32) * - (le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 )); -if (mb_offset + payload_len >le32_to_cpu (mb->meta_size)) + (sector_t )sizeof (__le32) * payload_size; +if (mb_offset + payload_len >le32_to_cpu (mb->meta_size) || + payload_size < conf->max_degraded) goto mismatch; if (r5l_recovery_verify_data_checksum( log, ctx, page, log_offset,
@@ -2050,6 +2059,9 @@ r5l_recovery_verify_data_checksum_for_mb(struct r5l_log *log, payload->checksum[1]) < 0) goto mismatch; }else if (le16_to_cpu (payload->header.type) ==R5LOG_PAYLOAD_FLUSH ) { +if (mb_offset +sizeof (struct r5l_payload_flush ) + >le32_to_cpu (mb->meta_size)) + goto mismatch; payload_len =sizeof (struct r5l_payload_flush ) + (sector_t )le32_to_cpu (payload_flush->size);if (mb_offset + payload_len >le32_to_cpu (mb->meta_size))
@@ -2111,7 +2123,7 @@ r5c_recovery_analyze_meta_block(struct r5l_log *log, mb_offset =sizeof (struct r5l_meta_block ); log_offset =r5l_ring_add (log, ctx->pos,BLOCK_SECTORS ); -while (mb_offset <le32_to_cpu (mb->meta_size)) { +while (mb_offset +sizeof (struct r5l_payload_header ) <le32_to_cpu (mb->meta_size)) {sector_t payload_len;int dd;
@@ -2121,6 +2133,9 @@ r5c_recovery_analyze_meta_block(struct r5l_log *log,if (le16_to_cpu (payload->header.type) ==R5LOG_PAYLOAD_FLUSH ) {int i, count; +if (mb_offset +sizeof (struct r5l_payload_flush ) > +le32_to_cpu (mb->meta_size)) +return -EINVAL ; payload_len =sizeof (struct r5l_payload_flush ) + (sector_t )le32_to_cpu (payload_flush->size); if (mb_offset + payload_len >
@@ -2145,6 +2160,9 @@ r5c_recovery_analyze_meta_block(struct r5l_log *log, }/* DATA or PARITY payload */ +if (mb_offset +sizeof (struct r5l_payload_data_parity ) > +le32_to_cpu (mb->meta_size)) +return -EINVAL ; payload_len =sizeof (struct r5l_payload_data_parity ) + (sector_t )sizeof (__le32) * (le32_to_cpu (payload->size) >> (PAGE_SHIFT -9 ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 407/1848 cpufreq: conservative: Restrict deferred downscaling to low load
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengming Hu <[email protected]>
[ Upstream commit 0fa55c5539173bceaeb400c69b1974aaa0cdb8dc ]
For a shared cpufreq policy, dbs_update() derives the load used for the frequency decision from the maximum load among its CPUs, but it may also record deferred idle periods accumulated by an idle CPU in the policy.
Consequently, a single update can contain both a high decision load from one CPU and multiple deferred idle periods from another CPU. The conservative governor applies the deferred down steps before evaluating the decision load. If that load subsequently triggers an up step, the deferred down steps can outweigh the single up step and produce a net frequency reduction.
This was observed on a policy shared by CPUs 2 and 3. A CPU-bound SCHED_EXT task kept CPU 2 fully utilized while CPU 3 remained idle. On this system, SCHED_EXT generated update-util callbacks less frequently than CFS, resulting in sparse DBS updates such as:
load=100 idle_periods=7 interval=59 ms
load=100 idle_periods=4 interval=39 ms
load=100 idle_periods=2 interval=19 ms
load=100 idle_periods=7 interval=59 ms
With the default 5% frequency step and a 2.6 GHz policy maximum, seven deferred periods reduce the requested frequency by seven 130 MHz steps before the high decision load adds only one step. Repeated updates therefore keep the policy near 530 MHz even though CPU 2 is fully utilized.
There are two load values relevant to this behavior:
* sample_load is calculated from the busy and elapsed time of the current sample.
* decision_load is returned by dbs_update() for the governor's frequency decision. After a long idle interval, it may reuse prev_load to improve the response to a waking task and can therefore differ from sample_load.
The problem is that idle_periods is derived from accumulated idle time and is applied independently of whether the current sample load is in the conservative governor's downscaling region. A high sample load and multiple deferred idle periods can therefore coexist, particularly when updates are sparse.
As suggested by Zhongqiu Han, calculate the sample load separately from the decision load. If no time has elapsed, use prev_load for the sample load as the existing load calculation does, since no load can be calculated for that interval.
Record the maximum sample load for the policy and apply deferred down steps only when it is below down_threshold. This makes deferred downscaling follow the same threshold that the conservative governor normally uses to determine whether the policy load is low enough to reduce the frequency.
The existing code applies deferred down steps whenever idle_periods is valid, regardless of the sample load. When the decision load is in the hold region, the locally adjusted frequency is not submitted unless another frequency-update branch is taken. Thus, when the sample and decision loads are the same and both are in the hold region, this change does not alter the requested frequency.
The difference becomes visible when the decision load causes a frequency update. In particular, if it exceeds up_threshold, the governor applies a single up step after the deferred down steps and submits the resulting request. Multiple deferred down steps can then outweigh that up step and cause a frequency reduction even when the sample load is above down_threshold.
With this change, deferred down steps are skipped whenever the maximum sample load is at or above down_threshold, keeping deferred downscaling consistent with the conservative governor's threshold semantics. The requested frequency may therefore be higher than with the existing behavior when deferred idle periods are present and the decision load causes a frequency update. This is intentional, because the lower request previously resulted from applying deferred downscaling while the sampled policy load was outside the governor's downscaling region. Accelerated deferred downscaling remains available when the policy sample load is below down_threshold, including after a workload has completed and the policy has become idle.
--- drivers/cpufreq/cpufreq_conservative.c | 8 ++++--- drivers/cpufreq/cpufreq_governor.c | 29 +++++++++++++++++++------- drivers/cpufreq/cpufreq_governor.h | 2 ++ 3 files changed, 29 insertions(+), 10 deletions(-)
drivers/cpufreq/cpufreq_conservative.c +5 -3
@@ -85,10 +85,12 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy) freq_step =get_freq_step (cs_tuners, policy);/* -* Decrease requested_freq one freq_step for each idle period that -* we didn't update the frequency. +* Apply deferred down steps only when the policy sample load is +* below down_threshold. Otherwise, multiple deferred down steps may +* cause a net frequency decrease outside the downscaling region. */ -if (policy_dbs->idle_periods <UINT_MAX ) { +if (policy_dbs->max_sample_load < cs_tuners->down_threshold && + policy_dbs->idle_periods <UINT_MAX ) {unsigned int freq_steps = policy_dbs->idle_periods * freq_step;if (requested_freq > policy->min + freq_steps)
drivers/cpufreq/cpufreq_governor.c +22 -7
@@ -116,7 +116,8 @@ unsigned int dbs_update(struct cpufreq_policy *policy)struct policy_dbs_info *policy_dbs = policy->governor_data;struct dbs_data *dbs_data = policy_dbs->dbs_data;unsigned int ignore_nice = dbs_data->ignore_nice_load; -unsigned int max_load =0 , idle_periods =UINT_MAX ; +unsigned int max_load =0 , max_sample_load =0 ; +unsigned int idle_periods =UINT_MAX ;unsigned int sampling_rate, io_busy, j;/*
@@ -138,7 +139,7 @@ unsigned int dbs_update(struct cpufreq_policy *policy)struct cpu_dbs_info *j_cdbs = &per_cpu (cpu_dbs, j);u64 update_time, cur_idle_time;unsigned int idle_time, time_elapsed; -unsigned int load; +unsigned int load, sample_load; cur_idle_time =get_cpu_idle_time (j, &update_time, io_busy);
@@ -171,6 +172,20 @@ unsigned int dbs_update(struct cpufreq_policy *policy) j_cdbs->prev_cpu_nice = cur_nice; } +/* +* Compute the sample load separately from the prev_load value +* that may be reused after a long idle interval. The conservative +* governor uses it to decide whether to apply deferred down steps. +* If no time has elapsed, retain the existing behavior and use +* prev_load. +*/ +if (unlikely (!time_elapsed)) + sample_load = j_cdbs->prev_load; +else if (time_elapsed > idle_time) + sample_load =100 * (time_elapsed - idle_time) / time_elapsed; +else + sample_load =0 ; +if (unlikely (!time_elapsed)) {/* * That can only happen when this function is called
@@ -205,11 +220,7 @@ unsigned int dbs_update(struct cpufreq_policy *policy) load = j_cdbs->prev_load; j_cdbs->prev_load =0 ; }else { -if (time_elapsed > idle_time) - load =100 * (time_elapsed - idle_time) / time_elapsed; -else - load =0 ; - + load = sample_load; j_cdbs->prev_load = load; }
@@ -222,9 +233,13 @@ unsigned int dbs_update(struct cpufreq_policy *policy)if (load > max_load) max_load = load; + +if (sample_load > max_sample_load) + max_sample_load = sample_load; } policy_dbs->idle_periods = idle_periods; + policy_dbs->max_sample_load = max_sample_load;return max_load; }
drivers/cpufreq/cpufreq_governor.h +2 -0
@@ -95,6 +95,8 @@ struct policy_dbs_info {/* Multiplier for increasing sample delay temporarily. */ unsigned int rate_mult;unsigned int idle_periods;/* For conservative */ +/* Maximum load from the current policy sample. */ +unsigned int max_sample_load;/* Status indicators */ bool is_shared;/* This object is used by multiple CPUs */ bool work_in_progress;/* Work is being queued up or in progress */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 408/1848 regulator: core: Fix c_rdev reference leak in regulator_resolve_coupling()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit c41b69e9f76fd9632662714c1d37860468e8d773 ]
of_parse_coupled_regulator() returns the coupled regulator with its device reference incremented, but regulator_resolve_coupling() returns without dropping it when the coupled regulator belongs to a different coupler, leaking the reference.
--- drivers/regulator/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/regulator/core.c +1 -0
@@ -5166,6 +5166,7 @@ static void regulator_resolve_coupling(struct regulator_dev *rdev)if (c_rdev->coupling_desc.coupler != coupler) {rdev_err (rdev,"coupler mismatch with %s\n" ,rdev_get_name (c_rdev)); +put_device (&c_rdev->dev);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 409/1848 regulator: core: Fix rdev reference leak in regulator_resolve_supply()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 195bbe5e1c29aa1349655a6162958149c1176034 ]
regulator_resolve_supply() takes a reference on the looked-up regulator with regulator_dev_lookup(), but when the supply resolves to the regulator itself that reference is never dropped: it leaks on the early return and is lost as well when r is replaced with the dummy regulator.
Release the reference before handling the self-referent case.
--- drivers/regulator/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/regulator/core.c +1 -0
@@ -1966,6 +1966,7 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)if (r == rdev) {dev_err (dev,"Supply for %s (%s) resolved to itself\n" , rdev->desc->name, rdev->supply_name); +put_device (&rdev->dev);if (!have_full_constraints ()) { ret = -EINVAL ; goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 410/1848 ASoC: codecs: wm8994: Fix runtime PM leak in wm8994_mic_detect()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit b2c0e5bf750e33b0e1dcdfbb2df8103a06c7caab ]
wm8994_mic_detect() resumes the component before configuring the MICBIAS pins, but the default case of the micbias switch returns -EINVAL right after taking that reference, skipping the pm_runtime_put() on the success path. This leaks a runtime PM reference on every call with an invalid micbias.
Release the reference before returning -EINVAL.
--- sound/soc/codecs/wm8994.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/codecs/wm8994.c +1 -0
@@ -3533,6 +3533,7 @@ int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *break ;default :dev_warn (component->dev,"Invalid MICBIAS %d\n" , micbias); +pm_runtime_put (component->dev);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 411/1848 fpga: Fix of_fpga_mgr_get() reference in fpga_mgr_lock() docs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit ac02245b0ca28388ba16273f2fa683c90da2e5dc ]
The fpga_mgr_lock() comment lists of_fpga_mgr_put() as a source of a manager pointer. The helper which obtains that pointer is of_fpga_mgr_get(). Correct the reference.
--- drivers/fpga/fpga-mgr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/fpga-mgr.c +1 -1
@@ -517,7 +517,7 @@ EXPORT_SYMBOL_GPL(fpga_mgr_put);* @mgr: fpga manager * * Given a pointer to FPGA Manager (from fpga_mgr_get() or -* of_fpga_mgr_put()) attempt to get the mutex. The user should call +* of_fpga_mgr_get()) attempt to get the mutex. The user should call * fpga_mgr_lock() and verify that it returns 0 before attempting to * program the FPGA. Likewise, the user should call fpga_mgr_unlock * when done programming the FPGA.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 412/1848 iio: accel: adis16201: fix channel order for buffer mode
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shehryar Ahmad <[email protected]>
[ Upstream commit a4b9f1137b76faab6891ce0bd3f5c02dda7c392d ]
Reshuffle adis16201_channels to ascending scan_index order to avoid data corruption during IIO core demultiplexing since the ADIS driver builds the buffer in channel array order, while the IIO core demultiplexes it in scan_index order.
This changes the raw buffer byte layout for existing adis16201 users reading buffered data directly.
--- drivers/iio/accel/adis16201.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/iio/accel/adis16201.c +5 -5
@@ -205,19 +205,19 @@ static int adis16201_write_raw(struct iio_dev *indio_dev, }static const struct iio_chan_spec adis16201_channels[] = { -ADIS_SUPPLY_CHAN (ADIS16201_SUPPLY_OUT_REG ,ADIS16201_SCAN_SUPPLY ,0 , -12 ), -ADIS_TEMP_CHAN (ADIS16201_TEMP_OUT_REG ,ADIS16201_SCAN_TEMP ,0 ,12 ),ADIS_ACCEL_CHAN (X ,ADIS16201_XACCL_OUT_REG ,ADIS16201_SCAN_ACC_X ,BIT (IIO_CHAN_INFO_CALIBBIAS ),0 ,14 ),ADIS_ACCEL_CHAN (Y ,ADIS16201_YACCL_OUT_REG ,ADIS16201_SCAN_ACC_Y ,BIT (IIO_CHAN_INFO_CALIBBIAS ),0 ,14 ), -ADIS_AUX_ADC_CHAN (ADIS16201_AUX_ADC_REG ,ADIS16201_SCAN_AUX_ADC ,0 ,12 ),ADIS_INCLI_CHAN (X ,ADIS16201_XINCL_OUT_REG ,ADIS16201_SCAN_INCLI_X ,BIT (IIO_CHAN_INFO_CALIBBIAS ),0 ,12 ),ADIS_INCLI_CHAN (Y ,ADIS16201_YINCL_OUT_REG ,ADIS16201_SCAN_INCLI_Y ,BIT (IIO_CHAN_INFO_CALIBBIAS ),0 ,12 ), -IIO_CHAN_SOFT_TIMESTAMP (7 ) +ADIS_SUPPLY_CHAN (ADIS16201_SUPPLY_OUT_REG ,ADIS16201_SCAN_SUPPLY ,0 , +12 ), +ADIS_AUX_ADC_CHAN (ADIS16201_AUX_ADC_REG ,ADIS16201_SCAN_AUX_ADC ,0 ,12 ), +ADIS_TEMP_CHAN (ADIS16201_TEMP_OUT_REG ,ADIS16201_SCAN_TEMP ,0 ,12 ), +IIO_CHAN_SOFT_TIMESTAMP (7 ), };static const struct iio_info adis16201_info = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 413/1848 ata: libata-scsi: abort multi-sector pass-through commands when multi_count is 0
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Peng <[email protected]>
[ Upstream commit 3bab8c7e0c6ba187a47163a1f71477213a278c48 ]
When an ATA_12, ATA_16, or ATA_32 pass-through command with a multi-sector PIO command opcode (ATA_CMD_READ_MULTI, ATA_CMD_WRITE_MULTI, ATA_CMD_READ_MULTI_EXT, ATA_CMD_WRITE_MULTI_EXT, or ATA_CMD_WRITE_MULTI_FUA_EXT) is submitted via SG_IO on a device where multiple-sector mode is not configured (dev->multi_count == 0), ata_scsi_pass_thru() currently logs a warning and still dispatches the taskfile. When the DRQ interrupt fires, ata_pio_sectors() triggers WARN_ON_ONCE(qc->dev->multi_count == 0) and computes
nsect = min((qc->nbytes - qc->curbytes) / qc->sect_size, 0) = 0, failing to transfer any sectors:
ata1.00: invalid multi_count 1 ignored
WARNING: drivers/ata/libata-sff.c:666 at ata_pio_sectors+0x27d/0x300 Call Trace: <IRQ> ata_sff_hsm_move+0x211/0x22e0 __ata_sff_port_intr+0x1c8/0x520 ata_bmdma_port_intr+0xa1/0x5b0 ata_bmdma_interrupt+0x1f5/0x550
Per ACS-3 section 7.12.7.21, if IDENTIFY DEVICE word 59 bit 8 is cleared to zero (multi_count == 0) and a READ MULTIPLE or WRITE MULTIPLE command is received without a preceding successful SET MULTIPLE MODE command, the device returns command aborted (ABRT). Per the SAT specification, an ABRT error translates to the ABORTED COMMAND sense key with NO ADDITIONAL SENSE INFORMATION (0x00, 0x00).
Fail multi-sector taskfile commands in ata_scsi_pass_thru() with ata_scsi_set_sense(dev, scmd, ABORTED_COMMAND, 0, 0) when dev->multi_count == 0.
--- drivers/ata/libata-scsi.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/ata/libata-scsi.c +5 -0
@@ -3077,6 +3077,11 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)if (is_multi_taskfile (tf)) {unsigned int multi_count =1 << (cdb[1 ] >>5 ); +if (!dev->multi_count) { +ata_scsi_set_sense (dev, scmd,ABORTED_COMMAND ,0 ,0 ); +return 1 ; + } +/* compare the passed through multi_count * with the cached multi_count of libata */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 414/1848 PCI: pciehp: Make pciehp_poll_mode parameter read-only
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 5ab17178fca6026d329cb6ced33c30f3b7d3e50a ]
pciehp_request_irq() and pciehp_free_irq() select different resources based on the global pciehp_poll_mode parameter. The parameter is currently writable through sysfs, so changing it while a controller is active can make teardown try to stop a nonexistent polling thread or call free_irq() for an IRQ that was not requested.
Keep the parameter available for boot and module configuration, but prevent runtime changes to the registration mode.
Reproducer:
Boot an x86_64 guest in QEMU with a native PCIe hotplug root port and an e1000 device, using these device options:
-device pcie-root-port,id=rp1,chassis=1,slot=1 -device e1000,bus=rp1
Pass "pcie_ports=native pciehp.pciehp_poll_mode=1" to the guest kernel. As root in the guest, replace the device name below with a bound pciehp service device and run:
# dev=0000:00:1c.0:pcie004
# driver=/sys/bus/pci_express/drivers/pciehp
# echo 0 > /sys/module/pciehp/parameters/poll_mode # echo "$dev" > "$driver/unbind" # dmesg | grep 'Trying to free already-free IRQ'
The unfixed kernel accepts the runtime mode change and reports the warning when the service device is removed. The fixed kernel rejects the write and removes the device without the warning. The mode change is a deliberate privileged test action and is not expected during ordinary operation.
--- drivers/pci/hotplug/pciehp_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/hotplug/pciehp_core.c +1 -1
@@ -37,7 +37,7 @@ int pciehp_poll_time;* not really modular, but the easiest way to keep compat with existing * bootargs behaviour is to continue using module_param here. */ -module_param (pciehp_poll_mode, bool,0644 ); +module_param (pciehp_poll_mode, bool,0444 );module_param (pciehp_poll_time, int,0644 );MODULE_PARM_DESC (pciehp_poll_mode,"Using polling mechanism for hot-plug events or not" );MODULE_PARM_DESC (pciehp_poll_time,"Polling mechanism frequency, in seconds" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 415/1848 staging: media: imx: csc-scaler: fix ipu_image_convert_run leak on queue error
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Nguyen <[email protected]>
[ Upstream commit 07643be7b1eff94f7a49e142c1e92a1029d3db21 ]
device_run() allocates an ipu_image_convert_run object and, on the success path, hands it to the IPU image conversion core via ipu_image_convert_queue(); the run object is then freed asynchronously by the completion callback ipu_ic_pp_complete().
However, if ipu_image_convert_queue() fails, the core never takes ownership of the run object and the completion callback is never invoked. The "err" label finishes the mem2mem job and reports the buffers as errored, but never frees the run object that was just allocated, leaking it on every queue failure.
Free the run object in the error path. There is no risk of a double
free: the completion callback only runs after the object was successfully queued, which is mutually exclusive with reaching the error path. It is also safe for the earlier "goto err" on allocation failure, since run is NULL there and kfree(NULL) is a no-op.
--- drivers/staging/media/imx/imx-media-csc-scaler.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/media/imx/imx-media-csc-scaler.c +1 -0
@@ -144,6 +144,7 @@ static void device_run(void *_ctx)v4l2_m2m_buf_done (src_buf,VB2_BUF_STATE_ERROR );v4l2_m2m_buf_done (dst_buf,VB2_BUF_STATE_ERROR );v4l2_m2m_job_finish (priv->m2m_dev, ctx->fh.m2m_ctx); +kfree (run); }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 416/1848 ASoC: ti: davinci-mcasp: Fix runtime PM imbalance in __davinci_mcasp_set_clkdiv()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit ba593d662183de74d2b733b4c6e8cd26f04f0a65 ]
In __davinci_mcasp_set_clkdiv(), pm_runtime_get_sync() is called at the entry of the function. If an invalid div_id is provided, the function hits the default switch case and directly returns -EINVAL without calling pm_runtime_put(), resulting in a runtime PM reference leak.
Add pm_runtime_put() in the default case before returning -EINVAL.
--- sound/soc/ti/davinci-mcasp.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/ti/davinci-mcasp.c +1 -0
@@ -644,6 +644,7 @@ static int __davinci_mcasp_set_clkdiv(struct davinci_mcasp *mcasp, int div_id,break ;default : +pm_runtime_put (mcasp->dev);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 417/1848 drm/mali-dp: Fix runtime PM leak in malidp_crtc_atomic_enable()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 73ef663c75688168e31dbe9c585b939be410a945 ]
malidp_crtc_atomic_enable() resumes the device with pm_runtime_get_sync() and returns early when the resume fails. The runtime PM usage count is incremented by pm_runtime_get_sync() even when the resume fails, so returning without dropping the reference leaks it and, once the error has been hit, prevents the device from ever suspending again.
Drop the runtime PM reference with pm_runtime_put_noidle() on the resume failure path before returning.
--- drivers/gpu/drm/arm/malidp_crtc.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/arm/malidp_crtc.c +1 -0
@@ -55,6 +55,7 @@ static void malidp_crtc_atomic_enable(struct drm_crtc *crtc,if (err <0 ) {DRM_DEBUG_DRIVER ("Failed to enable runtime power management: %d\n" , err); +pm_runtime_put_noidle (crtc->dev->dev);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 418/1848 nilfs2: fix checkpoint root lifetime on sysfs errors
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aldo Ariel Panzardo <[email protected]>
[ Upstream commit 2cb947450e0e5a88bb6bb5fca6dbfda1910e74b0 ]
nilfs_find_or_create_root() links a new checkpoint root into the checkpoint tree and drops ns_cptree_lock before creating the root's sysfs group. If nilfs_sysfs_create_snapshot_group() then fails, the root is freed while it is still reachable from ns_cptree, so a concurrent nilfs_lookup_root() can dereference freed memory.
nilfs_sysfs_create_snapshot_group() allocates memory and creates sysfs nodes and may sleep, so it cannot run under the ns_cptree_lock spinlock. Reorder the creation path so that the sysfs group is set up before the root is published: initialize the root, create its sysfs group outside the lock, and only then take ns_cptree_lock to link it into the tree. On sysfs failure the root was never visible and is freed directly; in the unlikely case a root with the same checkpoint number is already present, the sysfs group of the new root is removed before it is freed. Concurrent insertions are already serialized by ns_snapshot_mount_mutex, so only the race against nilfs_lookup_root() needs to be closed.
Because kobject_put() does not guarantee that the embedded kobject's release callback has run by the time it returns (CONFIG_DEBUG_KOBJECT_RELEASE defers it), the container must not be freed until the release completes. Keep that wait_for_completion() of snapshot_kobj_unregister inside the sysfs helpers, so both the creation error path and nilfs_sysfs_delete_snapshot_group() wait for the release before their callers free the root.
--- fs/nilfs2/sysfs.c | 5 ++++- fs/nilfs2/the_nilfs.c | 34 +++++++++++++++++++++------------- 2 files changed, 25 insertions(+), 14 deletions(-)
fs/nilfs2/sysfs.c +4 -1
@@ -207,8 +207,10 @@ int nilfs_sysfs_create_snapshot_group(struct nilfs_root *root) "%llu", root->cno); } -if (err) +if (err) {kobject_put (&root->snapshot_kobj); +wait_for_completion (&root->snapshot_kobj_unregister); + }return err; }
@@ -216,6 +218,7 @@ int nilfs_sysfs_create_snapshot_group(struct nilfs_root *root)void nilfs_sysfs_delete_snapshot_group (struct nilfs_root *root) {kobject_put (&root->snapshot_kobj); +wait_for_completion (&root->snapshot_kobj_unregister); }/************************************************************************
fs/nilfs2/the_nilfs.c +21 -13
@@ -869,6 +869,26 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno)if (!new)return NULL ; + new->cno = cno; + new->ifile =NULL ; + new->nilfs = nilfs; +refcount_set (&new->count,1 ); +atomic64_set (&new->inodes_count,0 ); +atomic64_set (&new->blocks_count,0 ); + +/* +* Register the sysfs group before publishing the root in the +* checkpoint tree. nilfs_sysfs_create_snapshot_group() can sleep, +* so it must run outside ns_cptree_lock; creating it first also +* ensures a concurrent nilfs_lookup_root() can never observe a root +* whose sysfs registration later fails and gets freed. +*/ + err =nilfs_sysfs_create_snapshot_group (new); +if (err) { +kfree (new); +return NULL ; + } +spin_lock (&nilfs->ns_cptree_lock); p = &nilfs->ns_cptree.rb_node;
@@ -885,29 +905,17 @@ nilfs_find_or_create_root(struct the_nilfs *nilfs, __u64 cno) }else {refcount_inc (&root->count);spin_unlock (&nilfs->ns_cptree_lock); +nilfs_sysfs_delete_snapshot_group (new);kfree (new);return root; } } - new->cno = cno; - new->ifile =NULL ; - new->nilfs = nilfs; -refcount_set (&new->count,1 ); -atomic64_set (&new->inodes_count,0 ); -atomic64_set (&new->blocks_count,0 ); -rb_link_node (&new->rb_node, parent, p);rb_insert_color (&new->rb_node, &nilfs->ns_cptree);spin_unlock (&nilfs->ns_cptree_lock); - err =nilfs_sysfs_create_snapshot_group (new); -if (err) { -kfree (new); - new =NULL ; - } -return new; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 419/1848 md: validate bblog_size when loading v1.x badblocks metadata
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuchao Zhang <[email protected]>
[ Upstream commit ae5f89b23cb88667cfa1273b42d6a551db9c651e ]
In super_1_load(), when the on-disk feature_map does not have MD_FEATURE_BAD_BLOCKS set but sb->bblog_offset is non-zero, rdev->badblocks.shift is initialized to 0 without validating sb->bblog_size. The same field is validated in the MD_FEATURE_BAD_BLOCKS branch ("sectors > (PAGE_SIZE / 512)"), but this branch bypasses that check.
A forged on-disk superblock (malicious storage device or crafted image) can therefore carry an oversized sb->bblog_size. When bad blocks are later recorded, super_1_sync() sets bb->size from sb->bblog_size and md_write_metadata() issues a bio larger than the single rdev->bb_page, reading beyond the page and leaking kernel memory contents to disk.
sb->bblog_size is never modified by the kernel between load and sync, and the MD_FEATURE_BAD_BLOCKS branch already validates it, so checking it in this branch is sufficient to cover both paths.
Fix this by rejecting an oversized sb->bblog_size with -EINVAL, matching the existing check in the MD_FEATURE_BAD_BLOCKS branch.
--- drivers/md/md.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/md/md.c +4 -1
@@ -1782,8 +1782,11 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_if (badblocks_set (&rdev->badblocks, sector, count,1 ))return -EINVAL ; } - }else if (sb->bblog_offset !=0 ) + }else if (sb->bblog_offset !=0 ) { +if (le16_to_cpu (sb->bblog_size) > (PAGE_SIZE /512 )) +return -EINVAL ; rdev->badblocks.shift =0 ; + }if ((le32_to_cpu (sb->feature_map) & (MD_FEATURE_PPL |MD_FEATURE_MULTIPLE_PPLS ))) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 420/1848 crypto: amlogic - Fix IRQ handler return value and fallthrough logic
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mohamad Raizudeen <[email protected]>
[ Upstream commit 4b8ae2732070c5669adee2d5d3bb97b14af53a63 ]
In meson_irq_handler(), when an interrupt matches a flow but the status register is empty, the driver prints an error but doesn't return. It falls through the loop and incorrectly prints an unknown irq message.
Fix this by returning immediately. For empty status registers, return IRQ_NONE instead of IRQ_HANDLED to avoid masking spurious interrupts and allow the kernel to detect interrupt storms. Also use dev_err_ratelimited() to prevent console lockups during an interrupt storm.
Additionally, the handler returned IRQ_HANDLED for genuinely unknown interrupts. Return IRQ_NONE instead for unhandled interrupts.
--- drivers/crypto/amlogic/amlogic-gxl-core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/crypto/amlogic/amlogic-gxl-core.c +4 -3
@@ -35,12 +35,13 @@ static irqreturn_t meson_irq_handler(int irq, void *data)complete (&mc->chanlist[flow].complete);return IRQ_HANDLED ; } -dev_err (mc->dev,"%s %d Got irq for flow %d but ctrl is empty\n" , __func__, irq, flow); +dev_err_ratelimited (mc->dev,"%s %d Got irq for flow %d but ctrl is empty\n" , __func__, irq, flow); +return IRQ_NONE ; } } -dev_err (mc->dev,"%s %d from unknown irq\n" , __func__, irq); -return IRQ_HANDLED ; +dev_err_ratelimited (mc->dev,"%s %d from unknown irq\n" , __func__, irq); +return IRQ_NONE ; }static struct meson_alg_template mc_algs[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 421/1848 crypto: hisilicon/hpre - fix pointer dereference before length check
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weili Qian <[email protected]>
[ Upstream commit 9770bb7d335f8f8db01e99168bbdd9ce2cb6238c ]
In hpre_rsa_drop_leading_zeros(), the loop condition dereferences *ptr before checking *len, causing an out-of-bounds read when *len is zero.
Swap to while (*len && !**ptr) to test length first.
--- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/crypto/hisilicon/hpre/hpre_crypto.c +1 -1
@@ -687,7 +687,7 @@ static void hpre_dh_exit_tfm(struct crypto_kpp *tfm)static void hpre_rsa_drop_leading_zeros (const char **ptr,size_t *len) { -while (!**ptr && *len) { +while (*len && !**ptr) { (*ptr)++; (*len)--; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 422/1848 media: marvell: manage the MMP camera clock provider
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 9887716132d6c3c58cc67841dfb441c5a4a0d209 ]
mmpcam_probe() registers an OF clock provider before requesting the IRQ. Neither a later probe failure nor driver removal unregisters that provider, although the underlying clock is registered with devm_clk_register(). This leaves the provider referring to a clock whose lifetime has ended.
Use devm_of_clk_add_hw_provider() with the existing mclk_hw so the provider is unregistered before the managed clock and camera storage are released.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/media/platform/marvell-ccic/mmp-driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/platform/marvell-ccic/mmp-driver.c +3 -2
@@ -25,6 +25,7 @@#include <linux/list.h> #include <linux/pm.h> #include <linux/clk.h> +#include <linux/clk-provider.h> #include "mcam-core.h"
@@ -253,8 +254,8 @@ static int mmpcam_probe(struct platform_device *pdev)/* * Add OF clock provider. */ - ret =of_clk_add_provider (pdev->dev.of_node, of_clk_src_simple_get, - mcam->mclk); + ret =devm_of_clk_add_hw_provider (&pdev->dev, of_clk_hw_simple_get, + &mcam->mclk_hw);if (ret) {dev_err (&pdev->dev,"can't add DT clock provider\n" ); goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 423/1848 media: go7007: unregister the I2C adapter on USB probe failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 14165cd16fa7c233aec6a407b56b304e7a283911 ]
USB probe failures after I2C adapter registration free the backing go7007 structure without unregistering the adapter.
If i2c_adapter_online is set, unregister the adapter before releasing USB resources so that I2C client removal can still use its callbacks.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/media/usb/go7007/go7007-usb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/usb/go7007/go7007-usb.c +2 -0
@@ -1326,6 +1326,8 @@ static int go7007_usb_probe(struct usb_interface *intf,return 0 ; allocfail: +if (go->i2c_adapter_online) +i2c_del_adapter (&go->i2c_adapter);go7007_usb_release (go);kfree (go);return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 424/1848 media: cx18: Disable PCI device on probe failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 2aefbc29765641e1e1a26b96cee194ac7d34ff49 ]
cx18_setup_pci() enables the PCI device but does not disable it when DMA mask setup or the memory-region reservation fails. Later probe failure paths release the region without balancing the enable either.
Unwind the enable inside cx18_setup_pci() when that helper fails after enabling the device. Once setup succeeds, disable it in the probe cleanup after releasing the memory region. Setup failures skip that cleanup, so each successful enable is balanced exactly once.
Keep the existing error codes and normal removal path unchanged.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/media/pci/cx18/cx18-driver.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/media/pci/cx18/cx18-driver.c +7 -2
@@ -807,12 +807,12 @@ static int cx18_setup_pci(struct cx18 *cx, struct pci_dev *pci_dev, }if (pci_set_dma_mask (pci_dev,DMA_BIT_MASK (32 ))) {CX18_ERR ("No suitable DMA available, card %d\n" , cx->instance); -return -EIO ; + goto err_disable_device; }if (!request_mem_region (cx->base_addr,CX18_MEM_SIZE ,"cx18 encoder" )) {CX18_ERR ("Cannot request encoder memory region, card %d\n" , cx->instance); -return -EIO ; + goto err_disable_device; }/* Enable bus mastering and memory mapped IO for the CX23418 */
@@ -836,6 +836,10 @@ static int cx18_setup_pci(struct cx18 *cx, struct pci_dev *pci_dev, cx->pci_dev->irq, pci_latency, (u64)cx->base_addr);return 0 ; + +err_disable_device: +pci_disable_device (pci_dev); +return -EIO ; }static void cx18_init_subdevs (struct cx18 *cx)
@@ -1122,6 +1126,7 @@ static int cx18_probe(struct pci_dev *pci_dev,cx18_iounmap (cx); free_mem:release_mem_region (cx->base_addr,CX18_MEM_SIZE ); +pci_disable_device (pci_dev); free_workqueues:destroy_workqueue (cx->in_work_queue); err:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 425/1848 media: tw68: balance PCI enable on cleanup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit fc02261fdca3ea95e4dcb6b38ab77f0f197c3750 ]
tw68_initdev() leaves the PCI device enabled after a later probe failure or tw68_finidev(). Use pcim_enable_device() to balance the enable reference when the driver is detached or probe fails.
The managed disable runs after the managed IRQ has been released.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/media/pci/tw68/tw68-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/pci/tw68/tw68-core.c +1 -1
@@ -228,7 +228,7 @@ static int tw68_initdev(struct pci_dev *pci_dev,/* pci init */ dev->pci = pci_dev; -if (pci_enable_device (pci_dev)) { +if (pcim_enable_device (pci_dev)) { err = -EIO ; goto fail1; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 426/1848 media: adv7180: Initialize mutex before ancillary clients
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 9d46d17a65e86010b1f5604e5cf61ce1e197f77a ]
The VPP ancillary-client error path unregisters the CSI client before destroying state->mutex. For I2P variants, the failure can occur before mutex_init(), so cleanup destroys an uninitialized mutex.
Initialize the mutex immediately after allocating the driver state, before creating any ancillary clients. This keeps every cleanup path matched with a completed mutex initialization.
A QEMU x86_64 test using an i2c-stub bus instantiated an ADV7280 client at address 0x21 and occupied its VPP ancillary address 0x42. This forced i2c_new_ancillary_device() to return -EBUSY. An instrumentation oracle observed an uninitialized mutex on the buggy kernel and an initialized mutex on the fixed kernel. The failure was deliberately injected to exercise the error path; no natural crash was observed.
--- drivers/media/i2c/adv7180.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/adv7180.c +1 -1
@@ -1333,6 +1333,7 @@ static int adv7180_probe(struct i2c_client *client,if (state ==NULL )return -ENOMEM ; +mutex_init (&state->mutex); state->client = client; state->field =V4L2_FIELD_ALTERNATE ; state->chip_info = (struct adv7180_chip_info *)id->driver_data;
@@ -1362,7 +1363,6 @@ static int adv7180_probe(struct i2c_client *client, } state->irq = client->irq; -mutex_init (&state->mutex); state->curr_norm =V4L2_STD_NTSC ;if (state->chip_info->flags &ADV7180_FLAG_RESET_POWERED ) state->powered = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 427/1848 media: au0828: Fix media device leak in au0828_usb_probe()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 7b7a69c91c0537d48150942d9707614a4fdd3766 ]
au0828_media_device_init() takes a reference to a media device with media_device_usb_allocate(). When au0828_v4l2_device_register() fails right after, the error path only unregisters the entities and frees au0828_dev, so that reference is never released.
Release it with media_device_delete() on that path.
--- drivers/media/usb/au0828/au0828-core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/usb/au0828/au0828-core.c +4 -0
@@ -702,6 +702,10 @@ static int au0828_usb_probe(struct usb_interface *interface, retval =au0828_v4l2_device_register (interface, dev);if (retval) {au0828_usb_v4l2_media_release (dev); +#ifdef CONFIG_MEDIA_CONTROLLER +media_device_delete (dev->media_dev,KBUILD_MODNAME , +THIS_MODULE ); +#endif mutex_unlock (&dev->lock);kfree (dev);return retval;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 428/1848 media: vpif_display: Fix i2c adapter reference leak in vpif_probe()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit f5863ea3f99265e5e297e3dcf0f47432fee2b8ac ]
vpif_probe() takes a reference to the i2c adapter with i2c_get_adapter() and passes it to v4l2_i2c_new_subdev_board(), which does not consume it, but the reference is never released, so it is leaked both when the probe succeeds and when it fails after the adapter has been acquired.
Release the reference with i2c_put_adapter() on the success path and in the probe_subdev_out cleanup.
--- drivers/media/platform/davinci/vpif_display.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/davinci/vpif_display.c +3 -0
@@ -1336,11 +1336,14 @@ static __init int vpif_probe(struct platform_device *pdev) } } +i2c_put_adapter (i2c_adap); +return 0 ; probe_cleanup:v4l2_async_notifier_cleanup (&vpif_obj.notifier); probe_subdev_out: +i2c_put_adapter (i2c_adap);kfree (vpif_obj.sd); vpif_unregister:v4l2_device_unregister (&vpif_obj.v4l2_dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 429/1848 mfd: wcd934x: Fix NULL pointer dereference on IRQ probe deferral
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Heidelberg <[email protected]>
[ Upstream commit dcf0e640b553d33512fbcaedb909c32ba9636a64 ]
ddata->dev is only assigned at the end of wcd934x_slim_probe(), but the of_irq_get() error path has passed it to the error print since the driver was added, while it is still NULL.
This used to be harmless with dev_err(), which copes with a NULL device and was skipped on -EPROBE_DEFER. Since the switch to dev_err_probe(), a deferred IRQ reaches device_set_deferred_probe_reason() -> dev_driver_string(), which dereferences the NULL pointer and crashes during probe. Use dev, which is already valid at this point.
--- drivers/mfd/wcd934x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/wcd934x.c +1 -1
@@ -220,7 +220,7 @@ static int wcd934x_slim_probe(struct slim_device *sdev) ddata->irq =of_irq_get (np,0 );if (ddata->irq <0 ) -return dev_err_probe (ddata->dev, ddata->irq, +return dev_err_probe (dev, ddata->irq,"Failed to get IRQ\n" ); reset_gpio =of_get_named_gpio (np,"reset-gpios" ,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 430/1848 nilfs2: fix deadlock between nilfs_evict_inode() and find_inode()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit ff1227f70eead8704ecfec69259fb4c041f92cda ]
Syzbot reported a deadlock between nilfs_evict_inode(), executed via an asynchronous workqueue (kworker) as:
process_one_work()
process_scheduled_works()
nilfs_iput_work_func()
nilfs_dispose_list()
iput()
iput_final()
evict()
s_op->evict_inode()
nilfs_evict_inode()and find_inode(), called via
nilfs_mkdir()
nilfs_new_inode()
nilfs_insert_inode_locked()
insert_inode_locked4()
inode_insert5()
find_inode()When an inode is deleted (i_nlink == 0), nilfs_evict_inode() clears its ifile bitmap entry and then synchronously triggers the log writer via nilfs_transaction_commit() if IS_SYNC(inode) is true.
If a concurrent directory creation via nilfs_new_inode() attempts to allocate the same newly freed inode number, however, find_inode() called just before inserting it into the inode hash, blocks waiting for the old inode's evict() to complete.
Meanwhile, the synchronous log writer invoked from nilfs_evict_inode() tries to acquire a write lock on 'ns_segctor_sem' which is read locked by the caller of nilfs_new_inode() (in this case, nilfs_mkdir()), resulting in a deadlock.
The synchronous log writer invocation from nilfs_evict_inode() is a legacy artifact; it is no longer necessary because the call itself (triggered by iput()) is now handled asynchronously with a kworker if i_nlink == 0. It merely increases the risk of deadlock.
Fix this deadlock by removing the synchronous log writer trigger from nilfs_evict_inode().
--- fs/nilfs2/inode.c | 6 ------ 1 file changed, 6 deletions(-)
fs/nilfs2/inode.c +0 -6
@@ -975,13 +975,7 @@ void nilfs_evict_inode(struct inode *inode)nilfs_clear_inode (inode); -if (IS_SYNC (inode)) -nilfs_set_transaction_flag (NILFS_TI_SYNC );nilfs_transaction_commit (sb); -/* -* May construct a logical segment and may fail in sync mode. -* But delete_inode has no return value. -*/ }int nilfs_setattr (struct dentry *dentry,struct iattr *iattr)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 431/1848 kobject: fix out-of-bounds access in kobject_action_type()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiacheng Xu <[email protected]>
[ Upstream commit d516455c940555566642b975d1835c67f08136b3 ]
kobject_action_type() compares the input against each known action using strncmp() and then indexes the action string using count_first to check for an exact-length match.
An embedded NUL can make strncmp() return zero even when count_first exceeds the length of the action string. For example, the five-byte input "add\0X" makes the parser access kobject_actions[KOBJ_ADD][5], which is beyond the end of the "add" string.
Check the action string length with strlen() instead of indexing it with the input-derived offset. This rejects malformed action strings containing embedded NUL bytes with -EINVAL instead of invoking undefined behavior.
--- lib/kobject_uevent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/kobject_uevent.c +1 -1
@@ -84,7 +84,7 @@ static int kobject_action_type(const char *buf, size_t count,for (action =0 ; action <ARRAY_SIZE (kobject_actions); action++) {if (strncmp (kobject_actions[action], buf, count_first) !=0 )continue ; -if (kobject_actions[action][count_first] !='\0' ) +if (strlen (kobject_actions[action]) != count_first)continue ;if (args) *args = args_start;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 432/1848 ASoC: Intel: atom: Fix platform 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: Guangshuo Li <[email protected]>
[ Upstream commit dcc36d766dc82bc57cd730915d484119befcfca8 ]
sst_acpi_probe() registers platform devices for the SST platform and machine board using platform_device_register_data(), but does not unregister them when later probe steps fail.
--- sound/soc/intel/atom/sst/sst_acpi.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
sound/soc/intel/atom/sst/sst_acpi.c +13 -1
@@ -231,6 +231,11 @@ static int sst_platform_get_resources(struct intel_sst_drv *ctx)return 0 ; } +static void sst_unregister_platform_device (void *data) +{ +platform_device_unregister (data); +} +static int sst_acpi_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;
@@ -289,7 +294,10 @@ static int sst_acpi_probe(struct platform_device *pdev) pdata->platform);return PTR_ERR (plat_dev); } - + ret =devm_add_action_or_reset (dev, sst_unregister_platform_device, + plat_dev); +if (ret) +return ret;/* * Create platform device for sst machine driver, * pass machine info as pdata
@@ -302,6 +310,10 @@ static int sst_acpi_probe(struct platform_device *pdev)return PTR_ERR (mdev); } + ret =devm_add_action_or_reset (dev, sst_unregister_platform_device, + mdev); +if (ret) +return ret;/* Fill sst platform data */ ctx->pdata = pdata;strcpy (ctx->firmware_name, mach->fw_filename);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 433/1848 regulator: core: Fix coupled regulators reference leak on removal
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit b9205f0837ca91a0bbe6aa9002207656840c1406 ]
of_parse_coupled_regulator() returns the coupled regulator with its device reference incremented and regulator_resolve_coupling() stores it in coupling_desc.coupled_rdevs[]. regulator_remove_coupling() clears those pointers without dropping the references, so they are leaked when the couple is torn down.
Release the reference of each coupled regulator while removing the coupling.
--- drivers/regulator/core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/regulator/core.c +2 -0
@@ -5214,6 +5214,8 @@ static void regulator_remove_coupling(struct regulator_dev *rdev) c_desc->coupled_rdevs[i] =NULL ; c_desc->n_resolved--; + +put_device (&c_rdev->dev); }if (coupler && coupler->detach_regulator) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 434/1848 hwmon: (lm95245) Fix negative temperature conversion
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ridham Khurana <[email protected]>
[ Upstream commit f58c16056f8585ebafb0f1f5d90c23085443a4b9 ]
temp_from_reg_signed() uses only the high byte when the sign bit is set and drops the fractional bits in the low byte. Writing -500 to temp2_offset stores 0xff80 (-0.5 degrees C) in the offset registers, but reading temp2_offset back returns -1000.
Negative temp1_input and temp2_input values are rounded down to the next whole degree the same way. The chip reports -0.125 degrees C as 0xffe0, which the driver returns as -1000.
Treat the register pair as a single 16-bit two's complement value.
--- drivers/hwmon/lm95245.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hwmon/lm95245.c +3 -3
@@ -98,9 +98,9 @@ static int temp_from_reg_unsigned(u8 val_h, u8 val_l)static int temp_from_reg_signed (u8 val_h,u8 val_l) { -if (val_h &0x80 ) -return (val_h -0x100 ) *1000 ; -return temp_from_reg_unsigned (val_h, val_l); +s16 val_hl = (val_h <<8 ) | val_l; + +return val_hl *1000 /256 ; }static int lm95245_read_conversion_rate (struct lm95245_data *data)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 435/1848 mtd: rawnand: atmel: Fix MCK clock leak in atmel_nand_controller_init()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 94edcda45d888c3bb1310de11e10e4537c166f00 ]
atmel_nand_controller_init() takes a reference to the MCK clock with of_clk_get() and keeps it in nc->mck for the lifetime of the controller. If the "atmel,smc" phandle is missing or the SMC regmap cannot be obtained afterwards, the error path jumps to out_release_dma which only releases the DMA channel, so the clock reference is leaked. The callers return the error directly and never run atmel_nand_controller_cleanup(), where the clock is normally put.
Release the reference on those error paths. The path on which of_clk_get() itself fails keeps jumping to out_release_dma, as nc->mck only holds an error pointer there.
--- drivers/mtd/nand/raw/atmel/nand-controller.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mtd/nand/raw/atmel/nand-controller.c +4 -2
@@ -2076,7 +2076,7 @@ static int atmel_nand_controller_init(struct atmel_nand_controller *nc,if (!np) {dev_err (dev,"Missing or invalid atmel,smc property\n" ); ret = -EINVAL ; - goto out_release_dma; + goto out_put_mck; } nc->smc =syscon_node_to_regmap (np);
@@ -2084,11 +2084,13 @@ static int atmel_nand_controller_init(struct atmel_nand_controller *nc,if (IS_ERR (nc->smc)) { ret =PTR_ERR (nc->smc);dev_err (dev,"Could not get SMC regmap (err = %d)\n" , ret); - goto out_release_dma; + goto out_put_mck; }return 0 ; +out_put_mck: +clk_put (nc->mck); out_release_dma:if (nc->dmac)dma_release_channel (nc->dmac);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 436/1848 mtd: maps: pci: balance PCI enable on cleanup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 3be16e5d4990bf96309ac5ba35cb369c6015bce7 ]
mtd_pci_probe() leaves the PCI device enabled on later probe failure and mtd_pci_remove() does not disable it either. Use pcim_enable_device() to release the enable reference after the existing map and region cleanup.
The imbalance is already present in the initial Git import.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/mtd/maps/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/maps/pci.c +1 -1
@@ -256,7 +256,7 @@ static int mtd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)struct mtd_info *mtd =NULL ;int err; - err =pci_enable_device (dev); + err =pcim_enable_device (dev);if (err) goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 437/1848 mtd: cfi_cmdset_0002: cap the write-buffer chunk at 256 bytes on an x8 device
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Orgad Shaneh <[email protected]>
[ Upstream commit cfc5ebc9540e29f8f96db88bbfa261139e5afedb ]
The Write to Buffer command takes the number of words to program minus one, and do_write_buffer() sends that count as a single bus word:
map_write(map, CMD(words - 1), cmd_adr);
CMD() replicates the value into every device lane, so each device reads the count off its own data lines - eight of them on an x8 part. A count that does not fit in eight bits is truncated there, which limits one Write to Buffer to 256 words on an x8 device, however large a buffer the chip advertises in its CFI query.
The M29EW on a Cavium Octeon CN6335 board (an x16 part strapped to x8) advertises MaxBufWriteSize = 512 bytes, so cfi_amdstd_write_buffers() split the data into 512-byte chunks and do_write_buffer() sent a count of
511. The chip saw 511 & 0xff = 255, expected 256 bytes, and aborted the program when the 257th arrived. Chunks below 256 bytes - the leading partial chunk of a write - completed normally, so only the full-size ones failed:
MTD do_write_buffer_wait(): software timeout, address:0x03278bff.
jffs2: Write of 4164 bytes at 0x02c789b4 failed. returned -5, retlen 68
jffs2: No space for garbage collection. Aborting GC thread
Clamp MaxBufWriteSize for x8 devices in the write-buffer fixup, and recompute mtd->writebufsize, which cfi_cmdset_0002_setup() derives from MaxBufWriteSize before the fixups run.
The clamp deliberately keys off the device width rather than the part, even though the driver already recognises this one in is_m29ew(): the ceiling comes from the width of a device's data bus, not from the chip, so any x8 device advertising a larger buffer is told a count it cannot receive. The M29EW is only where it was found.
--- drivers/mtd/chips/cfi_cmdset_0002.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/mtd/chips/cfi_cmdset_0002.c +15 -0
@@ -280,6 +280,21 @@ static void fixup_use_write_buffers(struct mtd_info *mtd)pr_debug ("Using buffer write method\n" ); mtd->_write = cfi_amdstd_write_buffers; } + +/* +* The word count of the Write to Buffer command is a single bus +* word per device, so an x8 device can be told to program at most +* 256 bytes however large a buffer it advertises - including when +* several of them are interleaved on a wider bus, where CMD() +* replicates the count into each device's lane and it is truncated +* there. +*/ +if (cfi->device_type ==CFI_DEVICETYPE_X8 && + cfi->cfiq->MaxBufWriteSize >8 ) { + cfi->cfiq->MaxBufWriteSize =8 ; + mtd->writebufsize =cfi_interleave (cfi) << + cfi->cfiq->MaxBufWriteSize; + } }#endif /* !FORCE_WORD_WRITE */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 438/1848 mtd: amd76xrom: Fix PCI device reference leak in amd76xrom_init_one()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 1a122f5fecbabd47b81b1be3f0934f57b78aad42 ]
init_amd76xrom() obtains the PCI device with pci_get_device() and hands the reference over to amd76xrom_init_one(), which stores it in window->pdev. When reserving the ROM window fails, that function returns -EBUSY directly instead of going through amd76xrom_cleanup(), so the reference is neither released nor cleared.
Drop the reference and clear window->pdev on that path.
--- drivers/mtd/maps/amd76xrom.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/mtd/maps/amd76xrom.c +2 -0
@@ -152,6 +152,8 @@ static int amd76xrom_init_one(struct pci_dev *pdev, printk(KERN_ERR MOD_NAME" %s(): Unable to register resource %pR - kernel bug?\n" , __func__, &window->rsrc); +pci_dev_put (window->pdev); + window->pdev =NULL ;return -EBUSY ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 439/1848 mtd: maps: l440gx: Fix double put of the ISA bridge in init_l440gx()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 521ad948e04934b2d70ae899bc016bbb38802e90 ]
init_l440gx() takes a single reference on the PIIX4 ISA bridge with pci_get_device() and drops it again right after the lookups, before the flash window is set up. The pci_assign_resource() failure path then calls pci_dev_put() on the same device a second time, releasing a reference that is no longer owned and underflowing the reference count.
Remove the extra pci_dev_put().
--- drivers/mtd/maps/l440gx.c | 1 - 1 file changed, 1 deletion(-)
drivers/mtd/maps/l440gx.c +0 -1
@@ -110,7 +110,6 @@ static int __init init_l440gx(void)/* Allocate the resource region */ if (pci_assign_resource (pm_dev,PIIXE_IOBASE_RESOURCE ) !=0 ) { -pci_dev_put (dev);pci_dev_put (pm_dev);printk (KERN_WARNING "Could not allocate pm iobase resource\n" );iounmap (l440gx_map.virt);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 440/1848 mtd: maps: l440gx: Fix double put of the PM device in init_l440gx()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit e6ca524ee5b2705be30ea19ce2e55122d9f9ed8f ]
The PIIX4 PM device reference taken with pci_get_device() is dropped again before the iobase resource is allocated. If pci_assign_resource() fails, the error path calls pci_dev_put() on pm_dev a second time, releasing a reference that is no longer owned and underflowing the reference count.
Remove the extra pci_dev_put().
--- drivers/mtd/maps/l440gx.c | 1 - 1 file changed, 1 deletion(-)
drivers/mtd/maps/l440gx.c +0 -1
@@ -110,7 +110,6 @@ static int __init init_l440gx(void)/* Allocate the resource region */ if (pci_assign_resource (pm_dev,PIIXE_IOBASE_RESOURCE ) !=0 ) { -pci_dev_put (pm_dev);printk (KERN_WARNING "Could not allocate pm iobase resource\n" );iounmap (l440gx_map.virt);return -ENXIO ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 441/1848 mtd: Call get_wunit() on the master partition
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Weinberger <[email protected]>
[ Upstream commit 904f18430e8cce829cb9130eab7a93020e33fc89 ]
The code checks whether master has get_wunit() but still calls it on the child. Fix this.
--- drivers/mtd/mtdcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/mtdcore.c +1 -1
@@ -488,7 +488,7 @@ int mtd_pairing_info_to_wunit(struct mtd_info *mtd,return -EINVAL ;if (master->pairing && master->pairing->get_wunit) -return mtd->pairing->get_wunit (master, info); +return master->pairing->get_wunit (master, info);return info->pair; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 442/1848 ASoC: wcd9335: Fix device reference leak in wcd9335_slim_status()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
[ Upstream commit f0cc352be29ba616e0682f66f551d3f3029886fd ]
wcd9335_slim_status() obtains the SLIM interface device with of_slim_get_device(), which uses device_find_child() internally and returns the device with a reference held. As the device_find_child() documentation says: you will need to drop the reference with put_device() after use. The reference is stored in wcd->slim_ifc_dev and never dropped, so the SLIM interface device cannot be released. Fix it by using devm_add_action_or_reset() or put_device() respectively.
Found by code review.
--- sound/soc/codecs/wcd9335.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
sound/soc/codecs/wcd9335.c +12 -0
@@ -5172,6 +5172,13 @@ static int wcd9335_slim_probe(struct slim_device *slim)return 0 ; } +static void wcd9335_put_device_action (void *data) +{ +struct device *dev = data; + +put_device (dev); +} +static int wcd9335_slim_status (struct slim_device *sdev,enum slim_device_status status) {
@@ -5196,6 +5203,11 @@ static int wcd9335_slim_status(struct slim_device *sdev,return -EINVAL ; } + ret =devm_add_action_or_reset (dev, wcd9335_put_device_action, + &wcd->slim_ifc_dev->dev); +if (ret) +return ret; +slim_get_logical_addr (wcd->slim_ifc_dev); wcd->regmap =regmap_init_slimbus (sdev, &wcd9335_regmap_config);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 443/1848 MIPS: mm: do not write a huge TLB entry when the probe misses
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Orgad Shaneh <[email protected]>
[ Upstream commit 0cb17268887e1df5c425ea052f5146b42d126323 ]
__update_tlb() probes for the 8K pair at the address it is given and, for a huge pmd, writes the huge entry with tlbwi at the probed index or with tlbwr when the probe misses. That works only if the caller passes the faulting address, so that the probe finds the 4K entry the refill handler loaded for the faulting page and the huge entry replaces it.
update_mmu_cache_pmd() is not called that way. do_set_pmd() has always passed the huge-aligned address, and since commit ebcfc63d6bca ("mm:
abstract THP allocation") the anonymous THP fault path does too (map_anon_folio_pmd()). The probe then misses the stale 4K entry, which sits at the faulting page somewhere else in the 2 MB range, tlbwr adds a huge entry next to it, and the TLB holds two entries matching the faulting address. Octeon raises "Machine Check exception - caused by multiple matching entries in the TLB" on the next refill of that page; a process on a CN63XX board died this way within a second of start, on the first anonymous THP of its bss.
Skip the write when the probe misses. The refill and TLBL/TLBS handlers probe the faulting address themselves and rewrite the stale entry with the huge one (they also set the software young bit), so the entry is installed on the next access at the cost of one exception.
--- arch/mips/mm/tlb-r4k.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
arch/mips/mm/tlb-r4k.c +17 -4
@@ -332,6 +332,19 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)/* this could be a huge page */ if (pmd_huge (*pmdp)) {unsigned long lo; + +/* +* The probe above only covers the 8K pair at @address, and +* a huge mapping is installed with the huge-aligned address +* while the refill that started the fault left a 4K entry +* for the faulting page elsewhere in the range. Writing the +* huge entry to a random index would leave two entries +* matching the faulting address; leave it to the refill and +* TLBL/TLBS handlers, which probe the faulting address. +*/ +if (idx <0 ) + goto out; +write_c0_pagemask (PM_HUGE_MASK ); ptep = (pte_t *)pmdp; lo =pte_to_entrylo (pte_val (*ptep));
@@ -339,10 +352,7 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)write_c0_entrylo1 (lo + (HPAGE_SIZE >>7 ));mtc0_tlbw_hazard (); -if (idx <0 ) -tlb_write_random (); -else -tlb_write_indexed (); +tlb_write_indexed ();tlbw_use_hazard ();write_c0_pagemask (PM_DEFAULT_MASK ); }else
@@ -375,6 +385,9 @@ void __update_tlb(struct vm_area_struct * vma, unsigned long address, pte_t pte)tlb_write_indexed (); }tlbw_use_hazard (); +#ifdef CONFIG_MIPS_HUGE_TLB_SUPPORT +out: +#endif htw_start ();flush_micro_tlb_vm (vma);local_irq_restore (flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 444/1848 netfilter: ctnetlink: fix inverted IPv6 address match in dump filter
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Piotr Kubik <[email protected]>
[ Upstream commit 1ae2d094b0200f687923298c0e42579273558988 ]
ctnetlink_filter_match_tuple() rejects an entry when !ipv6_addr_cmp(filter, entry) is true. ipv6_addr_cmp() is a memcmp() and returns 0 for equal addresses, so the condition is true exactly when the addresses match: a CTA_FILTER dump with an IPv6 CTA_IP_SRC or CTA_IP_DST skips every entry that matches the requested address and returns all the others. The IPv4 branch compares with != and behaves correctly.
Observed with libnetfilter_conntrack NFCT_FILTER_DUMP_TUPLE: a dump filtered on src 2001:db8::10 returned only the unrelated entries, and a dump filtered on ::1 returned every entry except the ::1 ones. conntrack-tools does not use the tuple filter for -L, which is why this went unnoticed.
Use ipv6_addr_equal() so the IPv6 branch mirrors the IPv4 one.
--- net/netfilter/nf_conntrack_netlink.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/netfilter/nf_conntrack_netlink.c +4 -4
@@ -1010,13 +1010,13 @@ static int ctnetlink_filter_match_tuple(struct nf_conntrack_tuple *filter_tuple,break ;case NFPROTO_IPV6 :if ((flags &CTA_FILTER_FLAG (CTA_IP_SRC )) && - !ipv6_addr_cmp (&filter_tuple->src.u3.in6, - &ct_tuple->src.u3.in6)) + !ipv6_addr_equal (&filter_tuple->src.u3.in6, + &ct_tuple->src.u3.in6))return 0 ;if ((flags &CTA_FILTER_FLAG (CTA_IP_DST )) && - !ipv6_addr_cmp (&filter_tuple->dst.u3.in6, - &ct_tuple->dst.u3.in6)) + !ipv6_addr_equal (&filter_tuple->dst.u3.in6, + &ct_tuple->dst.u3.in6))return 0 ;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 445/1848 arm64: dts: qcom: sdm845-xiaomi-beryllium: Extend the xbl_mem region
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Heidelberg <[email protected]>
[ Upstream commit 511c4fea32708a065e03503c0e4d44f48990c530 ]
Xiaomi's Oreo-era tree still had the CAF 1 MiB region, the 2 MiB version arrived with the Pie import. This isn't a board-layout quirk, it tracks the firmware. The later XBL wants one extra MiB below the old region.
--- arch/arm64/boot/dts/qcom/sdm845-xiaomi-beryllium.dts | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/qcom/sdm845-xiaomi-beryllium.dts +6 -0
@@ -23,6 +23,7 @@ /delete-node/ &slpi_mem; /delete-node/ &spss_mem; /delete-node/ &rmtfs_mem; +/delete-node/ &xbl_mem; / { model = "Xiaomi Pocophone F1";
@@ -52,6 +53,11 @@ vol-up { /* Reserved memory changes from downstream */ reserved-memory { + xbl-mem@85d00000 { + reg = <0 0x85d00000 0 0x200000>; + no-map; + }; + tz_mem: memory@86200000 { reg = <0 0x86200000 0 0x4900000>; no-map;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 446/1848 ALSA: sgio2audio: Only free successfully requested IRQs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit af3d225b639c6f9fb8fd5e1e27f11672d56724b6 ]
snd_sgio2audio_create() calls snd_sgio2audio_free() when an IRQ request fails. The cleanup helper currently walks the complete IRQ table, including entries whose request_irq() calls have not been attempted yet. free_irq() then receives an IRQ and dev_id pair that was never registered.
Pass the number of successfully requested IRQs to the cleanup helper on the request failure path, while retaining the full-table cleanup for teardown after all requests have succeeded.
--- sound/mips/sgio2audio.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
sound/mips/sgio2audio.c +7 -6
@@ -752,7 +752,8 @@ static struct {/* ALSA driver */ -static int snd_sgio2audio_free (struct snd_sgio2audio *chip) +static int snd_sgio2audio_free (struct snd_sgio2audio *chip, +unsigned int irq_count) {int i;
@@ -762,7 +763,7 @@ static int snd_sgio2audio_free(struct snd_sgio2audio *chip)writeq (0 , &mace->perif.audio.control);/* release IRQ's */ -for (i =0 ; i <ARRAY_SIZE (snd_sgio2_isr_table); i++) +for (i =0 ; i < irq_count; i++)free_irq (snd_sgio2_isr_table[i].irq, &chip->channel[snd_sgio2_isr_table[i].idx]);
@@ -778,7 +779,7 @@ static int snd_sgio2audio_dev_free(struct snd_device *device) {struct snd_sgio2audio *chip = device->device_data; -return snd_sgio2audio_free (chip); +return snd_sgio2audio_free (chip,ARRAY_SIZE (snd_sgio2_isr_table)); }static const struct snd_device_ops ops = {
@@ -829,7 +830,7 @@ static int snd_sgio2audio_create(struct snd_card *card, 0, snd_sgio2_isr_table[i].desc, &chip->channel[snd_sgio2_isr_table[i].idx])) { -snd_sgio2audio_free (chip); +snd_sgio2audio_free (chip, i);printk (KERN_ERR "sgio2audio: cannot allocate irq %d\n" , snd_sgio2_isr_table[i].irq);return -EBUSY ;
@@ -853,13 +854,13 @@ static int snd_sgio2audio_create(struct snd_card *card,/* initialize the AD1843 codec */ err =ad1843_init (&chip->ad1843);if (err <0 ) { -snd_sgio2audio_free (chip); +snd_sgio2audio_free (chip,ARRAY_SIZE (snd_sgio2_isr_table));return err; } err =snd_device_new (card,SNDRV_DEV_LOWLEVEL , chip, &ops);if (err <0 ) { -snd_sgio2audio_free (chip); +snd_sgio2audio_free (chip,ARRAY_SIZE (snd_sgio2_isr_table));return err; } *rchip = chip;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 447/1848 m68k: dmasound: Keep the Q40 IRQ handler registered
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit fa2e77ac5bf81a60864e71fc72196227692d7162 ]
Q40PlayNextFrame() re-registers the sample IRQ after stopping it. This function can be called with dmasound.lock held and from the sample IRQ handler, so free_irq() and request_irq() can sleep or deadlock. A failed re-registration can also leave playback without an IRQ.
Register one handler for the lifetime of the driver and select mono or stereo sample handling inside that handler. Call the frame completion path after releasing dmasound.lock so it can refill the queue safely.
--- sound/oss/dmasound/dmasound_q40.c | 65 ++++++++++++++----------------- 1 file changed, 29 insertions(+), 36 deletions(-)
sound/oss/dmasound/dmasound_q40.c +29 -36
@@ -49,9 +49,8 @@ static int Q40SetFormat(int format);static int Q40SetVolume (int volume);static void Q40PlayNextFrame (int index);static void Q40Play (void ); -static irqreturn_t Q40StereoInterrupt (int irq,void *dummy); -static irqreturn_t Q40MonoInterrupt (int irq,void *dummy); -static void Q40Interrupt (void ); +static irqreturn_t q40_audio_interrupt (int irq,void *dummy); +static void q40_frame_done (void );/*** Mid level stuff *********************************************************/
@@ -372,8 +371,8 @@ static void Q40Free(void *ptr, unsigned int size)static int __init Q40IrqInit (void ) {/* Register interrupt handler. */ -if (request_irq (Q40_IRQ_SAMPLE , Q40StereoInterrupt,0 , -"DMA sound" , Q40Interrupt)) +if (request_irq (Q40_IRQ_SAMPLE , q40_audio_interrupt,0 , +"DMA sound" , q40_frame_done))return 0 ;return (1 );
@@ -384,7 +383,7 @@ static int __init Q40IrqInit(void)static void Q40IrqCleanUp (void ) {master_outb (0 ,SAMPLE_ENABLE_REG ); -free_irq (Q40_IRQ_SAMPLE , Q40Interrupt); +free_irq (Q40_IRQ_SAMPLE , q40_frame_done); }#endif /* MODULE */
@@ -403,7 +402,6 @@ static void Q40PlayNextFrame(int index)u_char *start;u_long size;u_char speed; -int error;/* used by Q40Play() if all doubts whether there really is something * to be played are already wiped out.
@@ -420,15 +418,6 @@ static void Q40PlayNextFrame(int index) speed=(dmasound.hard.speed==10000 ?0 :1 );master_outb (0 ,SAMPLE_ENABLE_REG ); -free_irq (Q40_IRQ_SAMPLE , Q40Interrupt); -if (dmasound.soft.stereo) - error =request_irq (Q40_IRQ_SAMPLE , Q40StereoInterrupt,0 , -"Q40 sound" , Q40Interrupt); -else - error =request_irq (Q40_IRQ_SAMPLE , Q40MonoInterrupt,0 , -"Q40 sound" , Q40Interrupt); -if (error &&printk_ratelimit ()) -pr_err ("Couldn't register sound interrupt\n" );master_outb ( speed,SAMPLE_RATE_REG );master_outb (1 ,SAMPLE_CLEAR_REG );
@@ -456,31 +445,35 @@ static void Q40Play(void)spin_unlock_irqrestore (&dmasound.lock, flags); } -static irqreturn_t Q40StereoInterrupt (int irq,void *dummy) -{ -spin_lock (&dmasound.lock); -if (q40_sc>1 ){ - *DAC_LEFT =*q40_pp++; - *DAC_RIGHT =*q40_pp++; - q40_sc -=2 ; -master_outb (1 ,SAMPLE_CLEAR_REG ); - }else Q40Interrupt (); -spin_unlock (&dmasound.lock); -return IRQ_HANDLED ; -} -static irqreturn_t Q40MonoInterrupt (int irq,void *dummy) +static irqreturn_t q40_audio_interrupt (int irq,void *dummy) { +bool frame_done = false; +spin_lock (&dmasound.lock); -if (q40_sc>0 ){ - *DAC_LEFT =*q40_pp; - *DAC_RIGHT =*q40_pp++; - q40_sc --; -master_outb (1 ,SAMPLE_CLEAR_REG ); - }else Q40Interrupt (); +if (dmasound.hard.stereo) { +if (q40_sc >1 ) { + *DAC_LEFT = *q40_pp++; + *DAC_RIGHT = *q40_pp++; + q40_sc -=2 ; +master_outb (1 ,SAMPLE_CLEAR_REG ); + }else { + frame_done = true; + } + }else if (q40_sc >0 ) { + *DAC_LEFT = *q40_pp; + *DAC_RIGHT = *q40_pp++; + q40_sc--; +master_outb (1 ,SAMPLE_CLEAR_REG ); + }else { + frame_done = true; + }spin_unlock (&dmasound.lock); +if (frame_done) +q40_frame_done ();return IRQ_HANDLED ; } -static void Q40Interrupt (void ) + +static void q40_frame_done (void ) {if (!write_sq.active) {/* playing was interrupted and sq_reset() has already cleared
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 448/1848 drm/msm/hdmi_bridge: Correct poweroff/audio cleanup order in post_disable
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 0499f0576e4442d67c164119f9d7f75d3cc945e7 ]
Turning off the power in msm_hdmi_bridge_atomic_post_disable() should follow reverse order of powering up, not only because it is logical, but also because msm_hdmi_audio_update() accesses registers thus block should still be powered on.
Depending on specific timing, existing code could have accesses to MMIO of powered off block.
Patchwork: https://patchwork.freedesktop.org/patch/752655/
--- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +1 -1
@@ -189,10 +189,10 @@ static void msm_hdmi_bridge_post_disable(struct drm_bridge *bridge)msm_hdmi_phy_powerdown (phy);if (hdmi->power_on) { -power_off (bridge); hdmi->power_on = false;if (hdmi->hdmi_mode)msm_hdmi_audio_update (hdmi); +power_off (bridge);msm_hdmi_phy_resource_disable (phy); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 449/1848 staging: greybus: uart: fix racy TIOCMIWAIT implementation
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 e94cda6551d4716b17353fc458baa9e85ddea9ff ]
Check the wakeup condition after adding the task to the waitqueue and updating the task state to avoid missing a racing modem status update or disconnect.
Store the old icount on entry and do not update it in the completion handler to avoid missing events or reporting spurious ones (due to modem status changes before TIOCMIWAIT was called).
--- drivers/staging/greybus/uart.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-)
drivers/staging/greybus/uart.c +18 -12
@@ -53,7 +53,6 @@ struct gb_tty {spinlock_t read_lock;spinlock_t write_lock;struct async_icount iocount; -struct async_icount oldcount;wait_queue_head_t wioctl;struct mutex mutex;u8 ctrlin;/* input control lines */
@@ -656,11 +655,16 @@ static int wait_serial_change(struct gb_tty *gb_tty, unsigned long arg)if (!(arg & (TIOCM_DSR |TIOCM_RI |TIOCM_CD )))return -EINVAL ; - do { +spin_lock_irq (&gb_tty->read_lock); + old = gb_tty->iocount; +spin_unlock_irq (&gb_tty->read_lock); + +add_wait_queue (&gb_tty->wioctl, &wait); +for (;;) { +set_current_state (TASK_INTERRUPTIBLE ); +spin_lock_irq (&gb_tty->read_lock); - old = gb_tty->oldcount; new = gb_tty->iocount; - gb_tty->oldcount = new;spin_unlock_irq (&gb_tty->read_lock);if ((arg &TIOCM_DSR ) && (old.dsr != new.dsr))
@@ -670,18 +674,20 @@ static int wait_serial_change(struct gb_tty *gb_tty, unsigned long arg)if ((arg &TIOCM_RI ) && (old.rng != new.rng))break ; -add_wait_queue (&gb_tty->wioctl, &wait); -set_current_state (TASK_INTERRUPTIBLE ); -schedule (); -remove_wait_queue (&gb_tty->wioctl, &wait);if (gb_tty->disconnected) { -if (arg &TIOCM_CD ) -break ; retval = -ENODEV ; - }else if (signal_pending (current)) { +break ; + } + +schedule (); + +if (signal_pending (current)) { retval = -ERESTARTSYS ; +break ; } - }while (!retval); + } +__set_current_state (TASK_RUNNING ); +remove_wait_queue (&gb_tty->wioctl, &wait);return retval; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 450/1848 staging: rtl8723bs: fix RX buffer OOB write from device-reported length
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianchu Chen <[email protected]>
[ Upstream commit c52929073fccbc149267a2fd7458626a7e9abcfc ]
sd_recv_rxfifo() trusts the device-reported RX0_REQ_LEN value (hal->SdioRxFIFOSize, a u16 read from the card via CMD52) as the size of the next RX packet and passes it to sdio_read_port(), which copies that many bytes into the recvbuf skb whose data area is only MAX_RECVBUF_SZ (10240) bytes. A bogus device on SDIO can report up to 65535 bytes, causing a heap overflow of up to ~55KB past the skb buffer.
Bail out when the RX0_REQ_LEN exceeds MAX_RECVBUF_SZ. This is expected to keep behavior unchanged on normal devices.
Discovered by Atuin - Automated Vulnerability Discovery Engine.
--- drivers/staging/rtl8723bs/hal/sdio_ops.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/staging/rtl8723bs/hal/sdio_ops.c +7 -0
@@ -857,6 +857,13 @@ static struct recv_buf *sd_recv_rxfifo(struct adapter *adapter, u32 size)struct recv_priv *recv_priv;struct recv_buf *recvbuf; +/* RX0_REQ_LEN is device-reported; the skb buffer is only +* MAX_RECVBUF_SZ bytes, reject bogus lengths instead of +* overflowing past it. +*/ +if (size >MAX_RECVBUF_SZ ) +return NULL ; +/* Patch for some SDIO Host 4 bytes issue */ /* ex. RK3188 */ readsize =round_up (size,4 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 451/1848 media: tw686x: fix V4L2 device lifetime on probe failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit ce6c6dd632b3b4a2c2bfc9efd8f656f4d2137dbd ]
tw686x_video_init() registers the V4L2 device, which initializes its reference count. Successfully registered video devices take additional references to the V4L2 device as well.
The probe failure paths currently tear down the PCI resources and then free the channel arrays and the tw686x device directly. This bypasses the V4L2 device reference count and the tw686x_dev_release() callback.
If a video device still holds a reference, its eventual release will drop a reference to the already freed V4L2 device. Even when no extra references remain, directly freeing the device bypasses the lifetime management established by v4l2_device_register().
After cleaning up the PCI resources, check whether the V4L2 device was registered. If so, mark the hardware unavailable and drop the driver's V4L2 device reference, letting tw686x_dev_release() free the backing objects when the final reference is released. Keep the existing direct free path for failures that occur before V4L2 device registration.
This issue was found by manual code inspection.
--- drivers/media/pci/tw686x/tw686x-core.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/media/pci/tw686x/tw686x-core.c +10 -0
@@ -241,6 +241,7 @@ static int tw686x_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_id) {struct tw686x_dev *dev; +unsigned long flags;int err; dev =kzalloc (sizeof (*dev),GFP_KERNEL );
@@ -349,6 +350,15 @@ static int tw686x_probe(struct pci_dev *pci_dev,pci_release_regions (pci_dev); disable_pci:pci_disable_device (pci_dev); +if (dev->v4l2_dev.dev) { +spin_lock_irqsave (&dev->lock, flags); + dev->pci_dev =NULL ; +spin_unlock_irqrestore (&dev->lock, flags); + +v4l2_device_put (&dev->v4l2_dev); +return err; + } + free_audio:kfree (dev->audio_channels); free_video:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 452/1848 media: pvrusb2: Fix USB parent device leak in class_dev_create()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 02421d7278e4a62c3daf37ad6c45d4af96ee4252 ]
class_dev_create() stores a reference to the USB device obtained with get_device() in class_dev->parent, which class_dev_destroy() releases. When device_register() fails the function only drops class_dev, so the reference to the USB parent device is never released.
Drop the parent reference on the failure path as well.
--- drivers/media/usb/pvrusb2/pvrusb2-sysfs.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/usb/pvrusb2/pvrusb2-sysfs.c +1 -0
@@ -641,6 +641,7 @@ static void class_dev_create(struct pvr2_sysfs *sfp,if (ret) {pvr2_trace (PVR2_TRACE_ERROR_LEGS ,"device_register failed" ); +put_device (class_dev->parent);put_device (class_dev);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 453/1848 media: rtl28xxu: fix SDR platform device leak
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 083a92996598a5080965f1baa84175082e14a45b ]
rtl2832u_tuner_attach() registers an rtl2832_sdr platform device, but does not unregister it if no driver is bound. It also does not take a reference on the bound driver module.
Unregister the platform device when no driver is bound or the module reference cannot be acquired. Drop the module reference in rtl28xxu_tuner_detach() before unregistering the device.
The issue was identified by a static analysis tool I developed and confirmed by manual review.
--- drivers/media/usb/dvb-usb-v2/rtl28xxu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/media/usb/dvb-usb-v2/rtl28xxu.c +12 -2
@@ -1400,8 +1400,16 @@ static int rtl2832u_tuner_attach(struct dvb_usb_adapter *adap)"rtl2832_sdr" ,PLATFORM_DEVID_AUTO , &pdata, sizeof(pdata)); -if (IS_ERR (pdev) || pdev->dev.driver ==NULL ) +if (IS_ERR (pdev))break ; +if (!pdev->dev.driver) { +platform_device_unregister (pdev); +break ; + } +if (!try_module_get (pdev->dev.driver->owner)) { +platform_device_unregister (pdev); +break ; + } dev->platform_device_sdr = pdev;break ;default :
@@ -1435,8 +1443,10 @@ static int rtl28xxu_tuner_detach(struct dvb_usb_adapter *adap)/* remove platform SDR */ pdev = dev->platform_device_sdr; -if (pdev) +if (pdev) { +module_put (pdev->dev.driver->owner);platform_device_unregister (pdev); + }/* remove I2C tuner */ client = dev->i2c_client_tuner;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 454/1848 media: exynos4-is: Fix a race between s_stream(0) and the interrupt handler
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ginger Li <[email protected]>
[ Upstream commit c65eb69f8170975802ddbede84420553eb681d62 ]
fimc_lite_subdev_s_stream(on = 0) sets ST_FLITE_OFF outside of the fimc->slock protected region, and only then stops the capture in the hardware. flite_irq_handler() runs under fimc->slock and clears ST_FLITE_OFF, so an interrupt can be handled in between: the handler finds ST_FLITE_OFF already set, clears it and wakes up fimc->irq_queue before the capture has actually been stopped. The wait_event_timeout() right after it then returns immediately and the driver continues as if the capture had stopped.
Set ST_FLITE_OFF in the same critical section that stops the capture, as fimc_lite_stop_capture() already does.
--- drivers/media/platform/exynos4-is/fimc-lite.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/media/platform/exynos4-is/fimc-lite.c +1 -2
@@ -1212,9 +1212,8 @@ static int fimc_lite_subdev_s_stream(struct v4l2_subdev *sd, int on)spin_unlock_irqrestore (&fimc->slock, flags); } }else { -set_bit (ST_FLITE_OFF , &fimc->state); -spin_lock_irqsave (&fimc->slock, flags); +set_bit (ST_FLITE_OFF , &fimc->state);flite_hw_capture_stop (fimc);spin_unlock_irqrestore (&fimc->slock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 455/1848 media: em28xx: fix double free in em28xx_alloc_urbs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kaho Jiang <[email protected]>
[ Upstream commit fd427b8adae437cac78a2332241a03cac56e95c2 ]
When allocation of usb_bufs->buf[i] fails, em28xx_alloc_urbs() explicitly frees all items within usb_bufs->buf before calling em28xx_uninit_usb_xfer(), which also frees these items, causing them to be freed twice.
BUG: KASAN: double-free in usb_free_urb.part.0 (drivers/usb/core/urb.c:25 ./include/linux/kref.h:65 drivers/usb/core/urb.c:96) Free of addr ffff88802fd37c00 by task kworker/1:2/1182 Workqueue: events request_module_async Call Trace: kasan_report_invalid_free (mm/kasan/report.c:557) check_slab_allocation (mm/kasan/common.c:235) kfree (./include/linux/kasan.h:199 (discriminator 1) mm/slub.c:2693 (discriminator 1) mm/slub.c:6508 (discriminator 1) mm/slub.c:6801 (discriminator 1)) usb_free_urb.part.0 (drivers/usb/core/urb.c:25 ./include/linux/kref.h:65 drivers/usb/core/urb.c:96) usb_free_urb (drivers/usb/core/urb.c:95) em28xx_uninit_usb_xfer (drivers/media/usb/em28xx/em28xx-core.c:964) em28xx_alloc_urbs (drivers/media/usb/em28xx/em28xx-core.c:1076) em28xx_dvb_init (drivers/media/usb/em28xx/em28xx-dvb.c:1734 drivers/media/usb/em28xx/em28xx-dvb.c:1698) em28xx_init_extension (drivers/media/usb/em28xx/em28xx-core.c:1248) request_module_async (drivers/media/usb/em28xx/em28xx-cards.c:3685) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) Allocated by task 1182: kasan_save_stack (mm/kasan/common.c:57) kasan_save_track (mm/kasan/common.c:78) __kasan_kmalloc (mm/kasan/common.c:398 mm/kasan/common.c:415) __kmalloc_noprof (./include/linux/kasan.h:263 mm/slub.c:5414 mm/slub.c:5439) em28xx_alloc_urbs (./include/linux/slab.h:995 ./include/linux/slab.h:1312 drivers/media/usb/em28xx/em28xx-core.c:1081) em28xx_dvb_init (drivers/media/usb/em28xx/em28xx-dvb.c:1734 drivers/media/usb/em28xx/em28xx-dvb.c:1698) em28xx_init_extension (drivers/media/usb/em28xx/em28xx-core.c:1248) request_module_async (drivers/media/usb/em28xx/em28xx-cards.c:3685) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) Freed by task 1182: kasan_save_stack (mm/kasan/common.c:57) kasan_save_track (mm/kasan/common.c:78) kasan_save_free_info (mm/kasan/generic.c:584) __kasan_slab_free (mm/kasan/common.c:253 mm/kasan/common.c:285) kfree (./include/linux/kasan.h:235 mm/slub.c:2748 mm/slub.c:6508 mm/slub.c:6801) em28xx_alloc_urbs (drivers/media/usb/em28xx/em28xx-core.c:1084) em28xx_dvb_init (drivers/media/usb/em28xx/em28xx-dvb.c:1734 drivers/media/usb/em28xx/em28xx-dvb.c:1698) em28xx_init_extension (drivers/media/usb/em28xx/em28xx-core.c:1248) request_module_async (drivers/media/usb/em28xx/em28xx-cards.c:3685) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245)
Remove the explicit cleanup loop and let em28xx_uninit_usb_xfer() handle the cleanup.
--- drivers/media/usb/em28xx/em28xx-core.c | 3 --- 1 file changed, 3 deletions(-)
drivers/media/usb/em28xx/em28xx-core.c +0 -3
@@ -956,9 +956,6 @@ int em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk, usb_bufs->buf[i] =kzalloc (sb_size,GFP_KERNEL );if (!usb_bufs->buf[i]) { -for (i--; i >=0 ; i--) -kfree (usb_bufs->buf[i]); -em28xx_uninit_usb_xfer (dev, mode);return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 456/1848 dm-writecache: fix a crash if we attempt to use non-dax device
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit b15dc73f60ebf02410bc7014ce34fb7fd1040045 ]
If we specify a non-DAX device as a cache device in the 'P' mode, dm-writecache crashes on NULL pointer dereference inside dax_synchronous.
Note that this is not a security bug because only root can trigger it.
--- drivers/md/dm-writecache.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/md/dm-writecache.c +5 -0
@@ -2335,6 +2335,11 @@ static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv) }if (WC_MODE_PMEM (wc)) { +if (!wc->ssd_dev->dax_dev) { + r = -EOPNOTSUPP ; + ti->error ="Cache device is not a DAX device" ; + goto bad; + }if (!dax_synchronous (wc->ssd_dev->dax_dev)) { r = -EOPNOTSUPP ; ti->error ="Asynchronous persistent memory not supported as pmem cache" ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 457/1848 dm-writecache: fix uncommitted_blocks underflow
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit 8a0cc5f3446a324b13f62020eeddb32d6ba1c2db ]
Revert the commit 39495b12ef1cf602e6abd350dce2ef4199906531
writecache_bio_copy_ssd sets wc->uncommitted_blocks = 0; and then queues the flush work: queue_work(wc->writeback_wq, &wc->flush_work);
It may be possible that discard is dispatched in this window, and the discard would decrement wc->uncommitted_blocks to -1U.
Note that this bug is benign - wc->uncommitted_blocks is only used to trigged autocommit, so decrementing it to -1U will trigger a spurious autocommit, but won't cause any data corruption.
--- drivers/md/dm-writecache.c | 2 -- 1 file changed, 2 deletions(-)
drivers/md/dm-writecache.c +0 -2
@@ -874,8 +874,6 @@ static void writecache_discard(struct dm_writecache *wc, sector_t start, sector_ } discarded_something = true; } -if (!writecache_entry_is_committed (wc, e)) - wc->uncommitted_blocks--;writecache_free_entry (wc, e); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 458/1848 PCI: Disable MSI for ULi M1575 EHCI controller
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Imre Kaloz <[email protected]>
[ Upstream commit 5f30217ec296fb5742f6fd306586dbca5b81b4eb ]
With MSI, the ULi M1575 EHCI controller (10b9:5239) intermittently stops executing its asynchronous schedule. Control transfers time out ("device not accepting address", "device descriptor read/64"), the port is handed to the companion OHCI controller, and the device ends up at full speed. On a configured hub the stall shows up as hub descriptor and status read failures. Only re-initializing the controller recovers it.
On a Sun Ultra 45, 65 of 800 controller initializations stalled with MSI and none of 200 with INTx. Each initialization is an unbind and bind of ehci-pci on the EHCI function, with MSI or INTx selected through its msi_bus attribute; with this quirk, 0 of 100 cycles of the same loop stalled. The stall reproduces on a kernel that already contains commit 0b60557230ad ("usb: ehci: Prevent missed ehci interrupts with edge-triggered MSI").
The OHCI functions (10b9:5237) keep MSI. They showed no stall, and the hub enumerated through them on MSI during the EHCI failures, so only the EHCI function is quirked.
The illumos EHCI driver also disables MSI on this chip, in ehci_register_intrs_and_init_mutex() in usr/src/uts/common/io/usb/hcd/ehci/ehci_util.c.
Until USB HCDs started trying MSI first in v5.9, the controller always used INTx. Disable MSI so it uses INTx again on this chipset.
--- drivers/pci/quirks.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/quirks.c +2 -0
@@ -1833,6 +1833,8 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x4388, quirk_no_msi);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_ATI ,0x4389 , quirk_no_msi);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_ATI ,0x438a , quirk_no_msi);DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_ATI ,0x438b , quirk_no_msi); +/* ULi M1575 EHCI (10b9:5239): MSI stalls the async schedule */ +DECLARE_PCI_FIXUP_FINAL (PCI_VENDOR_ID_AL ,0x5239 , quirk_no_msi);static void quirk_pcie_mch (struct pci_dev *pdev) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 459/1848 media: uvcvideo: Fix NULL deref on events for uninitialized controls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Jie Law <[email protected]>
[ Upstream commit daa379e2b74d6c10ba4e3b56eeca5aa8c8704fca ]
A null-ptr-deref exists in v6.12.105 and upstream. KASAN crash log:
KASAN: null-ptr-deref in range [0x0000000000000080-0x0000000000000087] Workqueue: events uvc_ctrl_status_event_work RIP: 0010:uvc_ctrl_status_event+0x105/0x280 uvc_ctrl_status_event_work+0x82/0x240 process_one_work+0x66f/0x10b0
XU controls are initialized lazily, on the first UVCIOC_CTRL_MAP or UVCIOC_CTRL_QUERY. Until then ctrl->info is all zeroes, so info.mappings is not a valid list head, list_empty() returns false, and uvc_ctrl_status_event() walks it from a NULL next pointer.
--- drivers/media/usb/uvc/uvc_ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/uvc/uvc_ctrl.c +1 -1
@@ -1402,7 +1402,7 @@ bool uvc_ctrl_status_event_async(struct urb *urb, struct uvc_video_chain *chain,struct uvc_device *dev = chain->dev;struct uvc_ctrl_work *w = &dev->async_ctrl; -if (list_empty (&ctrl->info.mappings)) +if (!ctrl->initialized ||list_empty (&ctrl->info.mappings))return false; w->data = data;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 460/1848 crypto: caam - fix double-free in caam_rsa_set_priv_key_form()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: ZhaoJinming <[email protected]>
[ Upstream commit a91d9346a70b68f77884cba9d9ec3b70f96bf9d2 ]
caam_rsa_set_priv_key_form() frees the partially allocated key components (p, q, tmp1, tmp2, dp, dq) with kfree_sensitive() on its error path, but does not set those pointers to NULL afterward.
When the function returns an error, caam_rsa_set_priv_key() jumps to its err label and calls caam_rsa_free_key(), which frees all of those same pointers again, resulting in a double-free.
This is reachable when the allocation of q, tmp1, tmp2, dp, dq or qinv fails, e.g. under memory pressure, or for a malformed key whose CRT members decode to zero length and make caam_read_rsa_crt() return NULL.
Set each pointer to NULL right after freeing it so that the subsequent caam_rsa_free_key() call becomes a no-op for the already-freed fields.
--- drivers/crypto/caam/caampkc.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/crypto/caam/caampkc.c +6 -0
@@ -1021,16 +1021,22 @@ static int caam_rsa_set_priv_key_form(struct caam_rsa_ctx *ctx, free_dq:kfree_sensitive (rsa_key->dq); + rsa_key->dq =NULL ; free_dp:kfree_sensitive (rsa_key->dp); + rsa_key->dp =NULL ; free_tmp2:kfree_sensitive (rsa_key->tmp2); + rsa_key->tmp2 =NULL ; free_tmp1:kfree_sensitive (rsa_key->tmp1); + rsa_key->tmp1 =NULL ; free_q:kfree_sensitive (rsa_key->q); + rsa_key->q =NULL ; free_p:kfree_sensitive (rsa_key->p); + rsa_key->p =NULL ;return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 461/1848 hwrng: amd - report partial reads in non-blocking mode
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit e7f5ce911efb2017381f28bbedb6243a74a9c285 ]
amd_rng_read() returns 0 if no more data is available, even if some data was already copied to the output buffer. Return the number of copied bytes instead.
--- drivers/char/hw_random/amd-rng.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/hw_random/amd-rng.c +1 -1
@@ -79,7 +79,7 @@ static int amd_rng_read(struct hwrng *rng, void *buf, size_t max, bool wait)if (timeout-- ==0 )return read; }else { -return 0 ; +return read; } }else { *data =ioread32 (priv->iobase +RNGDATA );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 462/1848 hwrng: ba431 - fix reported byte count
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 7e638679883ceff5b6e7b6dcad09c21a105e941f ]
Use the size of the buffer element instead of the pointer size to report the number of bytes read. Since data is a u32 pointer and sizeof(data) is 8 bytes on 64-bit systems, using the pointer size reports twice the number of bytes actually read.
--- drivers/char/hw_random/ba431-rng.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/hw_random/ba431-rng.c +1 -1
@@ -148,7 +148,7 @@ static int ba431_trng_read(struct hwrng *rng, void *buf, size_t max, bool wait) } } - n *=sizeof (data); + n *=sizeof (*data);return (n || !wait) ? n : -EIO ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 463/1848 hwrng: core - reject unknown RNG names
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 7e7be8815143751c20260f80cb4e7fe14dd24b74 ]
In rng_current_store(), err is 0 after successfully locking rng_mutex, and if the requested RNG name cannot be found, the function reports success even though the current RNG was not changed.
Set err = -ENODEV before searching the RNG list to reject unknown names.
--- drivers/char/hw_random/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/char/hw_random/core.c +1 -0
@@ -343,6 +343,7 @@ static ssize_t hwrng_attr_current_store(struct device *dev,if (sysfs_streq (buf,"" )) { err =enable_best_rng (); }else { + err = -ENODEV ;list_for_each_entry (rng, &rng_list, list) {if (sysfs_streq (rng->name, buf)) { cur_rng_set_by_user =1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 464/1848 crypto: nx - validate ignore before subtracting in decompress
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aldo Ariel Panzardo <[email protected]>
[ Upstream commit b5c2df42977390a71f1940def5be9bd5c69ac2e0 ]
The decompress() function subtracts the header-supplied ignore value (a u16 from the compressed stream) from dlen (the number of bytes produced by the decompressor) without checking that ignore <= dlen.
If a caller decompresses a crafted buffer where hdr->ignore exceeds the actual decompressed length, the subtraction wraps around to a near-UINT_MAX value. The subsequent memcpy() then copies gigabytes of data past the destination buffer, causing an out-of-bounds kernel write.
Add a bounds check before the subtraction and return -EINVAL if the value is inconsistent.
--- drivers/crypto/nx/nx-842.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/crypto/nx/nx-842.c +2 -0
@@ -416,6 +416,8 @@ static int decompress(struct nx842_crypto_ctx *ctx, slen -= spadding; +if (ignore > dlen) +return -EINVAL ; dlen -= ignore;if (ignore)pr_debug ("ignoring last %x bytes\n" , ignore);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 465/1848 media: meson: vdec: size capture planes from the aligned canvas
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Freidkin <[email protected]>
[ Upstream commit b3a805dd5a83ba8c85e2085d3411eb9975e0aea4 ]
The decoder writes a whole canvas of ALIGN(width, 32) x ALIGN(height, 32) (amvdec_set_canvases()) and reports bytesperline = ALIGN(width, 32), but get_output_size() derives sizeimage from the raw width x height.
When the width is not a multiple of 32 the planes are too small for the advertised stride: for 720x360 NV12M the luma plane is 262144 bytes while 736 * 360 = 264960 are needed (282624 for the canvas the firmware fills). The decoder writes past the buffer, and importing the capture dma-buf into DRM fails: drmModeAddFB2() returns -EINVAL, so e.g. Kodi plays the sound over a black screen. 1280x720 and 1920x1080 are not affected.
Size the planes from the aligned canvas the hardware actually uses.
Tested on an S905X (GXL p212) board with LibreELEC 12 (6.16.0-rc3):
720x360 and 1920x1080 H.264 play through V4L2 m2m + DRM PRIME with no AddFB2 errors.
--- drivers/staging/media/meson/vdec/vdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/meson/vdec/vdec.c +1 -1
@@ -34,7 +34,7 @@ struct dummy_buf {static u32 get_output_size (u32 width,u32 height) { -return ALIGN (width * height,SZ_64K ); +return ALIGN (ALIGN (width,32 ) *ALIGN (height,32 ),SZ_64K ); }u32 amvdec_get_output_size (struct amvdec_session *sess)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 466/1848 media: mediatek: vpu: release reserved memory on remove
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 8af0e2bdd9791848d9caf3761825ac51a67c2b9c ]
mtk_vpu_probe() may assign a reserved memory region to the VPU device with of_reserved_mem_device_init(). The probe failure path releases the assignment with of_reserved_mem_device_release(), but the normal remove path does not perform the corresponding cleanup.
As a result, removing the VPU driver after a successful probe can leave the reserved memory assignment associated with the device after its lifetime has ended.
Release the reserved memory assignment after freeing the VPU external firmware memory, matching the cleanup performed by the probe failure path.
This issue was found by manual code inspection.
--- drivers/media/platform/mtk-vpu/mtk_vpu.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/mtk-vpu/mtk_vpu.c +1 -0
@@ -944,6 +944,7 @@ static int mtk_vpu_remove(struct platform_device *pdev) }vpu_free_ext_mem (vpu,P_FW );vpu_free_ext_mem (vpu,D_FW ); +of_reserved_mem_device_release (&pdev->dev);mutex_destroy (&vpu->vpu_mutex);clk_unprepare (vpu->clk);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 467/1848 media: vicodec: fix NULL deref on oversized frame
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 c657eb609197e289b054bc2c4e86a0fc32dd7ebe ]
job_ready() only honours the is_header_valid() verdict when ctx->comp_has_frame is set, and comp_has_frame is only set once comp_size reaches the full frame size. Since the copy is clamped to ctx->comp_max_size, a header advertising a larger size leaves comp_size stuck at comp_max_size, so comp_has_frame stays false and the failed validation is discarded.
Control then falls into the resolution change branch, which calls update_capture_data_from_header(). That function re-derives info via info_from_header(), assigns it to q_dst->info and dereferences it as q_dst->info->sizeimage_mult, with no NULL check of its own. is_header_valid() does check that same info_from_header() result -- if (!info) return false which is precisely the false verdict job_ready() discarded above. info_from_header() returns NULL whenever the header flags resolve to no supported pixel format.
Drop the comp_has_frame conjunct so an invalid header always bails out. The resolution change path is unaffected, as it is entered with a valid header. Oversized frames are then rejected by device_process(), which already returns -EINVAL when comp_frame_size exceeds comp_max_size.
--- drivers/media/test-drivers/vicodec/vicodec-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/test-drivers/vicodec/vicodec-core.c +1 -1
@@ -654,7 +654,7 @@ static int job_ready(void *priv)* if the header is invalid the device_run will just drop the frame * with an error */ -if (!is_header_valid (&ctx->state.header) && ctx->comp_has_frame) +if (!is_header_valid (&ctx->state.header))return 1 ; flags =ntohl (ctx->state.header.flags); hdr_width_div = (flags &FWHT_FL_CHROMA_FULL_WIDTH ) ?1 :2 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 468/1848 power: supply: ab8500_fg: Report sub-percent charge changes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 4d40dba1815d46c6ef9019ed80e3b998b0fc443d ]
The fuel gauge updates bat_cap.mah from the coulomb counter but exposes bat_cap.prev_mah through CHARGE_NOW and ENERGY_NOW. It only refreshes prev_mah when the rounded integer capacity percentage changes, making the momentary properties appear frozen between percentage steps.
Refresh prev_mah and notify userspace whenever the new charge remains within the currently accepted percentage. If a discharge estimate tries to cross upward into a higher percentage, the existing rejection still leaves both the reported percentage and charge unchanged.
The AB8500 fuel-gauge implementations in the Samsung-GT-I8160-Codina, Samsung-GT-I8160_HD-Codina, Samsung-GT-I8530-Gavini, Samsung-GT-S7710-Skomer, Samsung-SGH-I407-Kyle and Samsung-SGH-T599-Codina-TMO product trees retain the same percentage-gated prev_mah update and contain no finer-grained reporting workaround.
--- drivers/power/supply/ab8500_fg.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/power/supply/ab8500_fg.c +7 -0
@@ -1372,6 +1372,13 @@ static void ab8500_fg_check_capacity_limits(struct ab8500_fg *di, bool init) } } +/* Keep the charge properties current between percentage changes. */ +if (di->bat_cap.prev_percent == percent && + di->bat_cap.prev_mah != di->bat_cap.mah) { + di->bat_cap.prev_mah = di->bat_cap.mah; + changed = true; + } +if (changed) {if (di->bm->capacity_scaling) { di->bat_cap.cap_scale.scaled_cap =
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 469/1848 perf: xgene: initialize lock before requesting IRQ
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit d4b7b0c77142b3bc535192fa65130474a129c487 ]
xgene_pmu_probe() requests the PMU IRQ before initializing xgene_pmu->lock. request_irq() enables IRQ handling before it returns, so xgene_pmu_isr() can run in this window and acquire the uninitialized raw spinlock.
Initialize the lock before requesting the IRQ so the handler always sees a valid lock.
--- drivers/perf/xgene_pmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/perf/xgene_pmu.c +2 -2
@@ -1900,6 +1900,8 @@ static int xgene_pmu_probe(struct platform_device *pdev)if (irq <0 )return -EINVAL ; +raw_spin_lock_init (&xgene_pmu->lock); + rc =devm_request_irq (&pdev->dev, irq, xgene_pmu_isr,IRQF_NOBALANCING |IRQF_NO_THREAD ,dev_name (&pdev->dev), xgene_pmu);
@@ -1910,8 +1912,6 @@ static int xgene_pmu_probe(struct platform_device *pdev) xgene_pmu->irq = irq; -raw_spin_lock_init (&xgene_pmu->lock); -/* Check for active MCBs and MCUs */ rc =xgene_pmu_probe_active_mcb_mcu_l3c (xgene_pmu, pdev);if (rc) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 470/1848 svcrdma: Grant credits from the clamped sc_max_requests
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 b7037e5da3fb81abcd6309daecb112f1d5926760 ]
svc_rdma_accept() computes sc_fc_credits from sc_max_requests before the Receive Queue depth is checked against the device's max_qp_wr. When that check lowers sc_max_requests, the credit grant keeps the original value, so the server advertises more credits than it has Receives posted. A client that uses the full grant overruns the Receive Queue, and the connection is lost with an RNR error.
Set sc_fc_credits after the clamp so the grant matches the number of Receives the server posts.
--- net/sunrpc/xprtrdma/svc_rdma_transport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/sunrpc/xprtrdma/svc_rdma_transport.c +2 -1
@@ -397,7 +397,6 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) newxprt->sc_max_requests = svcrdma_max_requests; newxprt->sc_max_bc_requests = svcrdma_max_bc_requests; newxprt->sc_recv_batch =RPCRDMA_MAX_RECV_BATCH ; - newxprt->sc_fc_credits =cpu_to_be32 (newxprt->sc_max_requests);/* Qualify the transport's resource defaults with the * capabilities of this particular device.
@@ -418,6 +417,8 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt) newxprt->sc_max_bc_requests =2 ; } + newxprt->sc_fc_credits =cpu_to_be32 (newxprt->sc_max_requests); +/* Estimate the needed number of rdma_rw contexts. The maximum * Read and Write chunks have one segment each. Each request * can involve one Read chunk and either a Write chunk or Reply
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 471/1848 floppy: dont store a stack buffer in timeout_message
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Efremov (Oracle) <[email protected]>
[ Upstream commit 66be62ee5d64b6ad1285978644798d8611add931 ]
request_done() formats "request done %d" into a buffer on its stack and passes it to reschedule_timeout(), which keeps the pointer in timeout_message. show_floppy() prints timeout_message long after request_done() has returned, e.g. from result() in the interrupt handler, and reads a dead stack frame:
BUG: KASAN: stack-out-of-bounds in string+0x39c/0x3d0 lib/vsprintf.c:720 Read of size 1 at addr ffffc900003cfc70 by task swapper/3/0 Call Trace: <IRQ> ... show_floppy+0xb1/0x45f drivers/block/floppy.c:1838 result.cold+0x2b/0x30 drivers/block/floppy.c:1183 floppy_interrupt+0x191/0x340 drivers/block/floppy.c:1755 floppy_hardint+0x1a7/0x200 arch/x86/include/asm/floppy.h:66
uptodate is either 0 or 1, so pass one of two string literals instead.
--- drivers/block/floppy.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/block/floppy.c +2 -3
@@ -2276,11 +2276,10 @@ static void request_done(int uptodate) {struct request *req = current_req;int block; -char msg[sizeof ("request done " ) +sizeof (int ) *3 ]; probing =0 ; -snprintf (msg,sizeof (msg),"request done %d" , uptodate); -reschedule_timeout (MAXTIMEOUT , msg); +reschedule_timeout (MAXTIMEOUT , + uptodate ?"request done 1" :"request done 0" );if (!req) {pr_info ("floppy.c: no request in request_done\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 472/1848 floppy: return the drive state flags from the 32-bit FDGETDRVSTAT
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Efremov (Oracle) <[email protected]>
[ Upstream commit bb38473f1bcb287567f2fa7980e483a778092504 ]
compat_getdrvstat() copies every field of the drive state to a 32-bit caller except ->flags, which stays zero. 32-bit FDGETDRVSTAT and FDPOLLDRVSTAT therefore never report FD_DISK_WRITABLE, FD_DISK_CHANGED or FD_VERIFY: i386 fdutils (floppycontrol -P, fdmount), and other 32-bit users see every disk as write-protected and never see a disk change. The compat code in block/compat_ioctl.c copied the field; it was lost when that code moved into floppy.c
Also declare the field as compat_ulong_t: the 32-bit struct floppy_drive_struct starts with an unsigned long, and a signed char at offset 0 only lines up with its low byte on little-endian machines. The size and offsets of the compat structure, and so FDGETDRVSTAT32, do not change.
--- drivers/block/floppy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/floppy.c +2 -1
@@ -3693,7 +3693,7 @@ struct compat_floppy_drive_params { };struct compat_floppy_drive_struct { -signed char flags; +compat_ulong_t flags;compat_ulong_t spinup_date;compat_ulong_t select_date;compat_ulong_t first_read_date;
@@ -3877,6 +3877,7 @@ static int compat_getdrvstat(int drive, bool poll, goto Eintr;process_fd_request (); } + v.flags = drive_state[drive].flags; v.spinup_date = drive_state[drive].spinup_date; v.select_date = drive_state[drive].select_date; v.first_read_date = drive_state[drive].first_read_date;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 473/1848 wifi: brcmsmac: Adjust txpwrindex value in nphy_ipa_rxcal_gaintbl_2GHz
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
[ Upstream commit f7463a9c99a506b3308a852f9aaaf2a26b659e95 ]
After a recent change in clang to warn on signed char conversions within array initializers [1], there is a warning (or error with CONFIG_WERROR=y / W=e) from nphy_ipa_rxcal_gaintbl_2GHz:
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c:224:18: error: implicit conversion from 'int' to 's8' (aka 'signed char') changes value from 128 to -128 [-Werror,-Wconstant-conversion]
224 | {0, 0, 0, 0, 0, 128},
| ~ ^~~1 error generated.
This value was introduced in the original staging merge of brcmsmac in commit a9533e7ea3c4 ("Staging: Add initial release of brcm80211 - Broadcom 802.11n wireless LAN driver.") and it is the same in the proprietary driver [2]. Presumably it is correct since there have been no reported issues, so update the value to '-128' to be type correct and clear up the warning.
--- drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c +1 -1
@@ -221,7 +221,7 @@ static const struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_5GHz[] = { };static const struct nphy_ipa_txrxgain nphy_ipa_rxcal_gaintbl_2GHz[] = { - {0 ,0 ,0 ,0 ,0 ,128 }, + {0 ,0 ,0 ,0 ,0 ,-128 }, {0 ,0 ,0 ,0 ,0 ,70 }, {0 ,0 ,0 ,0 ,0 ,20 }, {0 ,0 ,0 ,3 ,0 ,20 },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 474/1848 resource: fix lost wakeup when waiting for a muxed region
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: DAI RENJIE <[email protected]>
[ Upstream commit 405c00e43a9c72a0b9b318cc2d2e298386ffb58e ]
A task waiting for a muxed region can sleep forever in TASK_UNINTERRUPTIBLE even though the region it waits for is already free. __request_region_locked() queues itself on muxed_resource_wait and drops resource_lock before setting TASK_UNINTERRUPTIBLE, while __release_region() wakes the queue after dropping the same lock. A wakeup landing in between finds TASK_RUNNING, does not match TASK_NORMAL and is discarded; callers hold a muxed region only across a bounded transaction, so no further release is coming. The task is unkillable and its caller never returns.
The window is one store wide, but an interrupt is enough to hold the waiter in it, and the machine this was seen on runs PREEMPT_DYNAMIC in its voluntary default. Since v6.11 spd5118 exports the DDR5 sensors of AMD boards through i2c-piix4, which takes a muxed region per SMBus transaction; a third of the in-tree users of request_muxed_region() are hwmon drivers, so reading a world-readable attribute is all an unprivileged user needs to drive the contention. The blocked task sleeps holding the i2c adapter bus lock, and 27 more piled up behind it.
Reproduced by building a kernel with the two orderings selectable at runtime and a 2ms delay inside the window. Switching only that knob, a two-thread barriered reproducer loses the wakeup 200 times out of 200 before the fix and 0 out of 200 after it; without the delay it goes 20000 times through the wait path and loses none.
Fix it by setting the task state before dropping resource_lock, as prepare_to_wait() does: the releasing side needs resource_lock to unlink the resource, so it cannot reach the wakeup before the state is published.
--- kernel/resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/resource.c +1 -1
@@ -1184,8 +1184,8 @@ struct resource * __request_region(struct resource *parent, }if (conflict->flags & flags &IORESOURCE_MUXED ) {add_wait_queue (&muxed_resource_wait, &wait); -write_unlock (&resource_lock);set_current_state (TASK_UNINTERRUPTIBLE ); +write_unlock (&resource_lock);schedule ();remove_wait_queue (&muxed_resource_wait, &wait);write_lock (&resource_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 475/1848 fat: fix fat_ent_write() for reverting the value
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: OGAWA Hirofumi <[email protected]>
[ Upstream commit 63c4b67ee163b2a67a7561314bf2106d6c79c53c ]
commit 64d9183203ee ("fat: restore original value when fat_ent_write failed") try to revert the fatent value to old value when got the error on mirror FAT.
However it didn't work if the error is when writing the fatent bh. In that case, the bh is cleared the uptodate flag, so reuse bh is invalid.
Fix this by reverting the fatent only if got the error on mirror FAT.
--- fs/fat/fat.h | 2 +- fs/fat/fatent.c | 21 ++++++++++++++++++--- fs/fat/file.c | 3 ++- fs/fat/misc.c | 6 ++---- 4 files changed, 23 insertions(+), 9 deletions(-)
fs/fat/fat.h +1 -1
@@ -385,7 +385,7 @@ extern void fat_ent_access_init(struct super_block *sb);extern int fat_ent_read (struct inode *inode,struct fat_entry *fatent,int entry);extern int fat_ent_write (struct inode *inode,struct fat_entry *fatent, -int new,int wait); +int new,int old,int wait);extern int fat_alloc_clusters (struct inode *inode,int *cluster,int nr_cluster);extern int fat_free_clusters (struct inode *inode,int cluster);
fs/fat/fatent.c +18 -3
@@ -407,7 +407,7 @@ static int fat_mirror_bhs(struct super_block *sb, struct buffer_head **bhs, }int fat_ent_write (struct inode *inode,struct fat_entry *fatent, -int new,int wait) +int new,int old,int wait) {struct super_block *sb = inode->i_sb;const struct fatent_operations *ops =MSDOS_SB (sb)->fatent_ops;
@@ -416,10 +416,25 @@ int fat_ent_write(struct inode *inode, struct fat_entry *fatent, ops->ent_put (fatent, new);if (wait) { err =fat_sync_bhs (fatent->bhs, fatent->nr_bhs); -if (err) +if (err) { +/* +* bhs are not uptodate after I/O error. So we +* can't simply re-dirty to revert. And it +* would not have value to write again on I/O +* error. +*/ return err; + } } -return fat_mirror_bhs (sb, fatent->bhs, fatent->nr_bhs); + + err =fat_mirror_bhs (sb, fatent->bhs, fatent->nr_bhs); +if (err) { +/* Try to revert if got the error on mirror FAT */ + ops->ent_put (fatent, old); +if (wait) +fat_sync_bhs (fatent->bhs, fatent->nr_bhs); + } +return err; } static inline int fat_ent_next(struct msdos_sb_info *sbi,
fs/fat/file.c +2 -1
@@ -359,7 +359,8 @@ static int fat_free(struct inode *inode, int skip) __func__, MSDOS_I(inode)->i_pos); ret = -EIO ; }else if (ret >0 ) { - err =fat_ent_write (inode, &fatent,FAT_ENT_EOF , wait); + err =fat_ent_write (inode, &fatent,FAT_ENT_EOF , ret, + wait);if (err) ret = err; }
fs/fat/misc.c +2 -4
@@ -127,11 +127,9 @@ int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster) ret =fat_ent_read (inode, &fatent, last);if (ret >=0 ) {int wait =inode_needs_sync (inode); -int old = ret; - ret =fat_ent_write (inode, &fatent, new_dclus, wait); -if (ret <0 ) -fat_ent_write (inode, &fatent, old, wait); + ret =fat_ent_write (inode, &fatent, new_dclus, ret, + wait);fatent_brelse (&fatent); }if (ret <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 476/1848 fault-inject: fix dentry leak
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Liang <[email protected]>
[ Upstream commit ceb43516a9aae0d969a4ec5ab40d45bd09e64229 ]
fault_create_debugfs_attr() has always taken an extra dentry reference on the created directory (attr->dname = dget(dir)) so that fail_dump() could print the name via %pd from any context. Nothing anywhere in the tree ever calls dput() on attr->dname.
For callers with a matching teardown, that unmatched reference causes one dentry plus its attached inode to leak per fault_create_debugfs_attr / debugfs_remove_recursive cycle. simple_recursive_removal() drops debugfs's own +1 ref on the child dentry, but the dget()'d ref keeps its refcount at 1: the dentry ends up unhashed but pinned, and its inode is never freed.
Boot-once callers (mm/failslab, block/blk-core, etc.) leak exactly once at init and never destroy the tree, so the impact there is bounded. But per-lifecycle callers (drivers/nvme, drivers/infiniband/hw/hfi1, drivers/mmc, drivers/iommu/iommufd, drivers/media, drivers/misc, drivers/gpu/drm/msm, drivers/crypto, net/sunrpc) leak on every create/destroy cycle.
We observed this in production: an NVMe/RDMA host repeatedly reconnecting to a target that rejected the CRTO Property Get went through ~50 nvme controller create/destroy cycles per second, and dentry and inode_cache grew by ~13k pinned objects per 240 s -- unrecoverable through drop_caches. Byte math matched a per-cycle 1-dentry / 1-inode leak from the "fault_inject" directory dentry.
Fix this by not holding any external reference in fault_attr. Embed the directory name as a fixed-size char array (FAULT_ATTR_DNAME_LEN, 64 bytes) inside struct fault_attr, copied by strscpy() at fault_create_debugfs_attr() time. fail_dump() prints it via %s.
Advantages of an embedded array over kstrdup() + kfree() paired with a new destroy API:
- Zero API footprint. No new export and no caller changes required:
callers already own their fault_attr's memory and free it when they are done, and now that suffices.
- No allocation on the create path.
- fault_create_debugfs_attr() cannot fail from the name-copy step.
- No lifetime coupling between attr->dname and debugfs; the string is valid for exactly as long as the containing struct.
The 64-byte length accommodates every in-tree caller with generous headroom (the longest current name is "fail_dma_array_full", 19 chars).
The user-visible fail_dump() format changes from "name %pd" to "name %s", but the printed content is identical -- %pd on the created directory renders the same string that was passed in as @name.
drivers/infiniband/hw/hfi1/fault.c drops a now-invalid "attr.dname = NULL" statement; the surrounding kzalloc() already zero-initialises the array.
--- drivers/infiniband/hw/hfi1/fault.c | 1 - include/linux/fault-inject.h | 10 ++++++++-- lib/fault-inject.c | 7 +++++-- 3 files changed, 13 insertions(+), 5 deletions(-)
drivers/infiniband/hw/hfi1/fault.c +0 -1
@@ -268,7 +268,6 @@ int hfi1_fault_init_debugfs(struct hfi1_ibdev *ibd) ibd->fault->attr.interval =1 ; ibd->fault->attr.require_end =ULONG_MAX ; ibd->fault->attr.stacktrace_depth =32 ; - ibd->fault->attr.dname =NULL ; ibd->fault->attr.verbose =0 ; ibd->fault->enable = false; ibd->fault->opcode = false;
include/linux/fault-inject.h +8 -2
@@ -9,6 +9,13 @@#include <linux/ratelimit.h> #include <linux/atomic.h> +/* +* Length of the debugfs directory name embedded in struct fault_attr. +* Chosen to accommodate every in-tree caller of fault_create_debugfs_attr() +* (the longest is "fail_dma_array_full", 19 chars) with generous headroom. +*/ +#define FAULT_ATTR_DNAME_LEN 64 +/* * For explanation of the elements of this struct, see * Documentation/fault-injection/fault-injection.rst
@@ -28,7 +35,7 @@ struct fault_attr {unsigned long count;struct ratelimit_state ratelimit_state; -struct dentry *dname; +char dname[FAULT_ATTR_DNAME_LEN ]; };#define FAULT_ATTR_INITIALIZER { \
@@ -38,7 +45,6 @@ struct fault_attr { .stacktrace_depth = 32, \ .ratelimit_state = RATELIMIT_STATE_INIT_DISABLED, \ .verbose = 2, \ - .dname = NULL, \ }#define DECLARE_FAULT_ATTR (name) struct fault_attr name = FAULT_ATTR_INITIALIZER
lib/fault-inject.c +5 -2
@@ -4,6 +4,7 @@#include <linux/random.h> #include <linux/sched.h> #include <linux/stat.h> +#include <linux/string.h> #include <linux/types.h> #include <linux/fs.h> #include <linux/export.h>
@@ -43,7 +44,7 @@ static void fail_dump(struct fault_attr *attr) {if (attr->verbose >0 &&__ratelimit (&attr->ratelimit_state)) { printk(KERN_NOTICE "FAULT_INJECTION: forcing a failure.\n" - "name %pd, interval %lu, probability %lu, " + "name %s, interval %lu, probability %lu, " "space %d, times %d\n", attr->dname, attr->interval, attr->probability, atomic_read(&attr->space),
@@ -226,7 +227,9 @@ struct dentry *fault_create_debugfs_attr(const char *name,debugfs_create_ul ("reject-end" , mode, dir, &attr->reject_end);#endif /* CONFIG_FAULT_INJECTION_STACKTRACE_FILTER */ - attr->dname =dget (dir); +if (strscpy (attr->dname, name,sizeof (attr->dname)) == -E2BIG ) +pr_warn ("FAULT_INJECTION: name '%s' truncated to '%s'\n" , + name, attr->dname);return dir; }EXPORT_SYMBOL_GPL (fault_create_debugfs_attr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 477/1848 USB: gadgetfs: do not WARN about excessively large memory allocations
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zi Yan <[email protected]>
[ Upstream commit a156148976eac47bee7210097afbb609cafe88b6 ]
GadgetFS passes an excessively large user input len to kmalloc and kmalloc gives a WARN (see below for details). Suppress it by passing __GFP_NOWARN to kmalloc used by both ep_write_iter() and ep_read_iter(). Follow the same method as commit 4f2629ea67e72 ("USB: usbfs: Don't WARN about excessively large memory allocations").
kmalloc is used to allocate physically contiguous memory for kernel allocations. For requests larger than KMALLOC_MAX_CACHE_SIZE, kmalloc uses the page allocator and can only support up to KMALLOC_MAX_SIZE. For request sizes bigger than KMALLOC_MAX_SIZE, the page allocator can emit a WARN because kmalloc allocates an order greater than MAX_PAGE_ORDER.
--- drivers/usb/gadget/legacy/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/legacy/inode.c +2 -2
@@ -610,7 +610,7 @@ ep_read_iter(struct kiocb *iocb, struct iov_iter *to)return -EBADMSG ; } - buf =kmalloc (len,GFP_KERNEL ); + buf =kmalloc (len,GFP_KERNEL | __GFP_NOWARN);if (unlikely (!buf)) {mutex_unlock (&epdata->lock);return -ENOMEM ;
@@ -672,7 +672,7 @@ ep_write_iter(struct kiocb *iocb, struct iov_iter *from)return -EBADMSG ; } - buf =kmalloc (len,GFP_KERNEL ); + buf =kmalloc (len,GFP_KERNEL | __GFP_NOWARN);if (unlikely (!buf)) {mutex_unlock (&epdata->lock);return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 478/1848 ocfs2: exit recovery thread on mount error path
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 6163a859649e9432e9c79c541f36dbf3bba9172f ]
When a mount fails after the cluster connection has been established, e.g. in ocfs2_mount_volume(), ocfs2_fill_super() unwinds via out_debugfs/out_super and frees the osb without disabling recovery.
A node failure event can concurrently launch the recovery thread, which blocks in __ocfs2_wait_on_mount() waiting for the volume state to become VOLUME_MOUNTED or VOLUME_DISABLED. As the mount error path neither sets VOLUME_DISABLED nor wakes osb_mount_event, the thread can never make
progress: the kthread leaks and stays blocked on the wait queue embedded in the freed osb, which may then be accessed as freed memory.
Fix it by setting VOLUME_DISABLED and waking osb_mount_event on this path so the thread bails out, and replace the plain kfree(osb->recovery_map) with ocfs2_recovery_exit(), which waits for a running recovery thread to exit before the recovery map is freed.
--- fs/ocfs2/super.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
fs/ocfs2/super.c +10 -1
@@ -1174,8 +1174,17 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) out_debugfs:debugfs_remove_recursive (osb->osb_debug_root); out_super: +/* +* A recovery thread launched by a node failure event may still be +* waiting for the volume to be mounted. Set VOLUME_DISABLED and +* wake it up, then wait for it to exit before osb is freed, +* otherwise the kthread would leak and stay blocked on the wait +* queue embedded in the freed osb. +*/ +atomic_set (&osb->vol_state,VOLUME_DISABLED ); +wake_up (&osb->osb_mount_event);ocfs2_release_system_inodes (osb); -kfree (osb->recovery_map); +ocfs2_recovery_exit (osb);ocfs2_delete_osb (osb);kfree (osb); out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 479/1848 ocfs2: free replay slots in ocfs2_recovery_exit()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 1ddadc6d41c1a29fd8fad1891bdcd2956e08b7f0 ]
Commit ce2fcf1516d6 ("ocfs2: fix memory leak in ocfs2_mount_volume()") added ocfs2_free_replay_slots() calls to the mount error paths out_dismount and out_check_volume to fix a leak of osb->replay_map. However these calls are unlocked while the bail path of the recovery thread, which is woken up by out_dismount right before the call, also frees the replay slots under osb->recovery_lock. Both sides can thus observe a non-NULL osb->replay_map and trigger a double free.
Fix this by moving ocfs2_free_replay_slots() into ocfs2_recovery_exit() after ocfs2_recovery_disable(), which waits for a running recovery thread to exit under osb->recovery_lock, and drop the unlocked call sites. Both ocfs2_dismount_volume() and the out_super path of ocfs2_fill_super() call ocfs2_recovery_exit(), so the replay slots are freed on every path. Since super.c no longer references it, make ocfs2_free_replay_slots() static again.
--- fs/ocfs2/journal.c | 3 ++- fs/ocfs2/journal.h | 1 - fs/ocfs2/super.c | 5 +---- 3 files changed, 3 insertions(+), 6 deletions(-)
fs/ocfs2/journal.c +2 -1
@@ -159,7 +159,7 @@ static void ocfs2_queue_replay_slots(struct ocfs2_super *osb, replay_map->rm_state =REPLAY_DONE ; } -void ocfs2_free_replay_slots (struct ocfs2_super *osb) +static void ocfs2_free_replay_slots (struct ocfs2_super *osb) {struct ocfs2_replay_map *replay_map = osb->replay_map;
@@ -250,6 +250,7 @@ void ocfs2_recovery_exit(struct ocfs2_super *osb)/* XXX: Should we bug if there are dirty entries? */ kfree (rm); +ocfs2_free_replay_slots (osb); } static int __ocfs2_recovery_map_test(struct ocfs2_super *osb,
fs/ocfs2/journal.h +0 -1
@@ -153,7 +153,6 @@ void ocfs2_recovery_exit(struct ocfs2_super *osb);void ocfs2_recovery_disable_quota (struct ocfs2_super *osb);int ocfs2_compute_replay_slots (struct ocfs2_super *osb); -void ocfs2_free_replay_slots (struct ocfs2_super *osb);/* * Journal Control: * Initialize, Load, Shutdown, Wipe a journal.
fs/ocfs2/super.c +1 -4
@@ -1167,7 +1167,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) out_dismount:atomic_set (&osb->vol_state,VOLUME_DISABLED );wake_up (&osb->osb_mount_event); -ocfs2_free_replay_slots (osb);ocfs2_dismount_volume (sb,1 ); goto out;
@@ -1842,14 +1841,12 @@ static int ocfs2_mount_volume(struct super_block *sb) status =ocfs2_truncate_log_init (osb);if (status <0 ) {mlog_errno (status); - goto out_check_volume; + goto out_system_inodes; }ocfs2_super_unlock (osb,1 );return 0 ; -out_check_volume: -ocfs2_free_replay_slots (osb); out_system_inodes:if (osb->local_alloc_state ==OCFS2_LA_ENABLED )ocfs2_shutdown_local_alloc (osb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 480/1848 ocfs2: skip uninitialized lockres in ocfs2_mark_lockres_freeing()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 6a3ed6b290513859bd27d9fcb67739347d6315fa ]
A hard readonly mount skips ocfs2_dlm_init(), so the per-osb lock resources are never initialized and osb->cconn stays NULL. Before commit 550842cc60987 ("ocfs2: fix freeing uninitialized resource on ocfs2_dlm_shutdown") ocfs2_dismount_volume() only called ocfs2_dlm_shutdown() when osb->cconn was set. It now calls it unconditionally, so unmounting a hard readonly mount drops the osb locks and takes the never initialized l_lock in ocfs2_mark_lockres_freeing(). With lockdep enabled this triggers:
INFO: trying to register non-static key. The code is fine but needs lockdep annotation, or maybe you didn't initialize this object before use? turning off the locking correctness validator.
ocfs2_drop_lock() and ocfs2_lock_res_free() already skip lock resources without OCFS2_LOCK_INITIALIZED. Add the same check to ocfs2_mark_lockres_freeing(), which is reachable before them through ocfs2_simple_drop_lockres(), so an uninitialized lockres is never touched.
--- fs/ocfs2/dlmglue.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ocfs2/dlmglue.c +4 -0
@@ -3522,6 +3522,10 @@ void ocfs2_mark_lockres_freeing(struct ocfs2_super *osb,struct ocfs2_mask_waiter mw;unsigned long flags, flags2; +/* We didn't get anywhere near actually using this lockres. */ +if (!(lockres->l_flags &OCFS2_LOCK_INITIALIZED )) +return ; +ocfs2_init_mask_waiter (&mw);spin_lock_irqsave (&lockres->l_lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 481/1848 wifi: mt76: mt76x02: validate TX-status rate index before mac80211 handoff
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Anthony Agarro <[email protected]>
[ Upstream commit fbd12e8dabc8a9d2e81f427906749b4cff85d641 ]
mt76x02_mac_process_tx_rate() extracts the rate index straight from the hardware's raw TX-status word with no bounds check for the HT/HT_GF/VHT cases, and mt76x02_mac_fill_tx_status() ignores its return value. A stale or corrupt hardware index reaches mac80211's minstrel_ht rate control, whose per-group rate array is a fixed 10 entries (MCS_GROUP_RATES), causing an out-of-bounds write.
Validate the index in mt76x02_mac_process_tx_rate() (HT: 0-31,
VHT: MCS nibble 0-9) and have mt76x02_mac_fill_tx_status() bail out cleanly on failure instead of passing an invalid index through.
--- .../net/wireless/mediatek/mt76/mt76x02_mac.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +13 -6
@@ -302,10 +302,14 @@ mt76x02_mac_process_tx_rate(struct ieee80211_tx_rate *txrate, u16 rate, txrate->flags |=IEEE80211_TX_RC_GREEN_FIELD ; fallthrough;case MT_PHY_TYPE_HT : +if (idx >31 ) +return -EINVAL ; txrate->flags |=IEEE80211_TX_RC_MCS ; txrate->idx = idx;break ;case MT_PHY_TYPE_VHT : +if ((idx &0xf ) >9 ) +return -EINVAL ; txrate->flags |=IEEE80211_TX_RC_VHT_MCS ; txrate->idx = idx;break ;
@@ -493,18 +497,21 @@ mt76x02_mac_fill_tx_status(struct mt76x02_dev *dev, struct mt76x02_sta *msta, first_rate = st->rate & ~MT_PKTID_RATE ; first_rate |= st->pktid &MT_PKTID_RATE ; -mt76x02_mac_process_tx_rate (&rate[0 ], first_rate, - dev->mphy.chandef.chan->band); +if (mt76x02_mac_process_tx_rate (&rate[0 ], first_rate, + dev->mphy.chandef.chan->band)) +return ; }else if (rate[0 ].idx <0 ) {if (!msta)return ; -mt76x02_mac_process_tx_rate (&rate[0 ], msta->wcid.tx_info, - dev->mphy.chandef.chan->band); +if (mt76x02_mac_process_tx_rate (&rate[0 ], msta->wcid.tx_info, + dev->mphy.chandef.chan->band)) +return ; } -mt76x02_mac_process_tx_rate (&last_rate, st->rate, - dev->mphy.chandef.chan->band); +if (mt76x02_mac_process_tx_rate (&last_rate, st->rate, + dev->mphy.chandef.chan->band)) +return ;for (i =0 ; i <ARRAY_SIZE (info->status.rates); i++) { retry--;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 482/1848 wifi: mt76: mt7615: cancel reset work during unregister
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 5b779c63fb1e20e6729d3241b78be7502759296d ]
The MCU error interrupt handler queues reset_work on the device workqueue. Device removal can reach mt76_unregister_device() while that work is still pending, since the workqueue is not destroyed until mt76_free_device().
If reset_work runs in this window, it operates on an unregistered hw and can requeue mac_work after ieee80211_unregister_hw() has torn the device down. Cancel it before unregistering the device so it cannot outlive the registered hw.
--- drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/mediatek/mt76/mt7615/pci_init.c +1 -0
@@ -158,6 +158,7 @@ void mt7615_unregister_device(struct mt7615_dev *dev) mcu_running =mt7615_wait_for_mcu_init (dev);mt7615_unregister_ext_phy (dev); +cancel_work_sync (&dev->reset_work);mt76_unregister_device (&dev->mt76);if (mcu_running)mt7615_mcu_exit (dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 483/1848 clocksource/drivers/fttmr010: Fix clk reference leak in error paths
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 277e5657237a92e279ee28da2f5c07902cc6aa0b ]
fttmr010_common_init() obtains the PCLK reference with of_clk_get_by_name() but never calls clk_put(). If clk_prepare_enable() fails the reference is leaked directly, and every error path that jumps to out_disable_clock only calls clk_disable_unprepare(), which releases the prepare/enable state but not the reference obtained from of_clk_get_by_name().
Add clk_put() to the clk_prepare_enable() failure path and to the out_disable_clock label so the clock reference is no longer leaked. The success path keeps PCLK enabled for the lifetime of the timer and is left untouched.
--- drivers/clocksource/timer-fttmr010.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clocksource/timer-fttmr010.c +2 -0
@@ -294,6 +294,7 @@ static int __init fttmr010_common_init(struct device_node *np, ret =clk_prepare_enable (clk);if (ret) {pr_err ("failed to enable PCLK\n" ); +clk_put (clk);return ret; }
@@ -426,6 +427,7 @@ static int __init fttmr010_common_init(struct device_node *np,kfree (fttmr010); out_disable_clock:clk_disable_unprepare (clk); +clk_put (clk);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 484/1848 clocksource/drivers/digicolor: Fix clk reference leak on request_irq failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 9cc2e18b32f12d26ae6729c62a03640423956b17 ]
digicolor_timer_init() obtains the timer clock with of_clk_get() and enables it, but the request_irq() failure path returns without releasing the clock reference, leaking both the enable/prepare state and the reference itself.
Disable and put the clock before returning on the request_irq() failure path. The success path keeps the clock enabled for the lifetime of the timer and is left untouched.
--- drivers/clocksource/timer-digicolor.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clocksource/timer-digicolor.c +2 -0
@@ -193,6 +193,8 @@ static int __init digicolor_timer_init(struct device_node *node) &dc_timer_dev.ce);if (ret) {pr_warn ("request of timer irq %d failed (%d)\n" , irq, ret); +clk_disable_unprepare (clk); +clk_put (clk);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 485/1848 aoe: pull in the headers each received packet type reads
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 e1274a6bc40a4618f6fbaebbdc51cca865d51bed ]
aoenet_rcv() only pulls the AoE and ATA headers into the skb head when the packet is long enough to hold both. A shorter packet goes through unpulled, and aoenet_rcv() reads the AoE header from it anyway. CFG responses go on to aoecmd_cfg_rsp(), which reads the config header after it, and ATA responses get queued for ktiocomplete(), which skb_pull()s both headers. Ethernet pads frames to 60 bytes, so this mostly takes a virtual link, but nothing stops a short frame from getting here.
Pull the AoE header up front and drop the packet if it isn't there, then pull the ATA or config header in the switch arm that hands the packet on, so each path gets the headers it reads. This also replaces the open-coded __pskb_pull_tail() with pskb_may_pull().
--- drivers/block/aoe/aoenet.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/block/aoe/aoenet.c +6 -8
@@ -132,9 +132,7 @@ static int aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt, struct net_device *orig_dev) { struct aoe_hdr *h; -struct aoe_atahdr *ah;u32 n; -int sn;if (dev_net (ifp) != &init_net) goto exit;
@@ -145,12 +143,8 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,if (!is_aoe_netif (ifp)) goto exit;skb_push (skb,ETH_HLEN );/* (1) */ - sn =sizeof (*h) +sizeof (*ah); -if (skb->len >= sn) { - sn -=skb_headlen (skb); -if (sn >0 && !__pskb_pull_tail (skb, sn)) - goto exit; - } +if (!pskb_may_pull (skb,sizeof (*h))) + goto exit; h = (struct aoe_hdr *) skb->data; n =get_unaligned_be32 (&h->tag);if ((h->verfl &AOEFL_RSP ) ==0 || (n &1 <<31 ))
@@ -172,10 +166,14 @@ aoenet_rcv(struct sk_buff *skb, struct net_device *ifp, struct packet_type *pt,switch (h->cmd) {case AOECMD_ATA : +if (!pskb_may_pull (skb,sizeof (*h) +sizeof (struct aoe_atahdr ))) + goto exit;/* ata_rsp may keep skb for later processing or give it back */ skb =aoecmd_ata_rsp (skb);break ;case AOECMD_CFG : +if (!pskb_may_pull (skb,sizeof (*h) +sizeof (struct aoe_cfghdr ))) + goto exit;aoecmd_cfg_rsp (skb);break ;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 486/1848 PCI/sysfs: Pass the device name length in UTF-16 code units
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Wilczyński <[email protected]>
[ Upstream commit af5ca2d75147bf283239e8ef0fbf6e5e0488ca91 ]
Currently, dsm_label_utf16s_to_utf8s() passes the ACPI buffer length to utf16s_to_utf8s() unchanged. The Device Name _DSM may return the device name as a buffer holding a UTF-16 string, and the ACPI length counts bytes while the converter counts wchar_t elements. The converter therefore receives a count twice the number of code units the buffer holds, and that count is its only bound on the input.
A NUL code unit ends the conversion early, so a name that carries one is converted correctly and the error stays hidden. ACPICA zeroes the entire result allocation, and the padding placed after the buffer supplies that NUL for most lengths. Lengths that leave no padding, or a single byte of it, do not, and the conversion then runs up to its own length in bytes past the end of the allocation. The bytes beyond the allocation are decoded into the "label" attribute, which is world readable.
Divide the buffer length by the size of wchar_t so that the converter receives a count of code units. The division truncates, so the converter is never told to read more bytes than the buffer holds, including for an odd length.
Reaching the out of bounds read needs firmware that returns the name as a buffer and omits the terminator.
--- drivers/pci/pci-label.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci-label.c +1 -1
@@ -158,7 +158,7 @@ static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf) {int len; len =utf16s_to_utf8s ((const wchar_t *)obj->buffer.pointer, - obj->buffer.length, + obj->buffer.length /sizeof (wchar_t),UTF16_LITTLE_ENDIAN , buf,PAGE_SIZE -1 ); buf[len] ='\n' ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 487/1848 fanotify: report names longer than NAME_MAX
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthias Goergens <[email protected]>
[ Upstream commit ff05910cb1b77c2b229c5e6e260c6173a17b579b ]
fanotify keeps the length of a reported name in a u8, so it drops any name longer than NAME_MAX and warns:
WARNING: fs/notify/fanotify/fanotify.h:217 at fanotify_handle_event+0x2e82/0x39f0
Such names are legitimate on some filesystems. vfat mounted with utf8 takes up to 255 UTF-16 characters, which are up to 765 bytes of UTF-8, and FUSE accepts names up to PATH_MAX - 1. readdir() and inotify report them in full. fanotify sends the event without the name, and for FAN_RENAME it trips a second warning in copy_fid_info_to_user(), after which read() fails with EFAULT and the event is lost.
When syzbot hit this, Jan suggested accommodating names up to PATH_MAX [1], the limit readdir() already applies to a name (verify_dirent_name()). Store the name lengths as u16, which keeps struct fanotify_info at 8 bytes, and drop without a warning only names of PATH_MAX bytes or more, which no path can refer to. An event with such a name can exceed a page, so allocate name events with kvmalloc(), as Jan also suggested. Names up to NAME_MAX are reported exactly as before, and the record format is unchanged: an event with a long name is just longer.
--- fs/notify/fanotify/fanotify.c | 7 +++++-- fs/notify/fanotify/fanotify.h | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-)
fs/notify/fanotify/fanotify.c +5 -2
@@ -610,6 +610,9 @@ static struct fanotify_event *fanotify_alloc_name_event(struct inode *dir,unsigned long name2_len = name2 ? name2->len :0 ;unsigned int len, size; +if (WARN_ON_ONCE (name_len >=PATH_MAX || name2_len >=PATH_MAX )) +return NULL ; +/* Reserve terminating null byte even for empty name */ size =sizeof (*fne) + name_len + name2_len +2 ;if (dir_fh_len)
@@ -618,7 +621,7 @@ static struct fanotify_event *fanotify_alloc_name_event(struct inode *dir, size +=FANOTIFY_FH_HDR_LEN + dir2_fh_len;if (child_fh_len) size +=FANOTIFY_FH_HDR_LEN + child_fh_len; - fne =kmalloc (size, gfp); + fne =kvmalloc (size, gfp);if (!fne)return NULL ;
@@ -1013,7 +1016,7 @@ static void fanotify_free_fid_event(struct fanotify_event *event)static void fanotify_free_name_event (struct fanotify_event *event) { -kfree (FANOTIFY_NE (event)); +kvfree (FANOTIFY_NE (event)); } static void fanotify_free_error_event(struct fsnotify_group *group,
fs/notify/fanotify/fanotify.h +12 -9
@@ -42,9 +42,16 @@ struct fanotify_info {u8 dir_fh_totlen;u8 dir2_fh_totlen;u8 file_fh_totlen; -u8 name_len; -u8 name2_len; -u8 pad[3 ]; +u8 pad; +/* +* Deliberately not limited to NAME_MAX: some filesystems return longer +* names (vfat up to 255 UTF-16 characters, as Windows allows, which is +* up to 765 bytes of UTF-8; FUSE up to PATH_MAX - 1), and readdir() and +* inotify report them in full. Only names of PATH_MAX bytes or more, +* which no path can refer to, are dropped. +*/ +u16 name_len; +u16 name2_len;unsigned char buf[];/* * (struct fanotify_fh) dir_fh starts at buf[0]
@@ -167,7 +174,7 @@ static inline char *fanotify_info_name2(struct fanotify_info *info)static inline void fanotify_info_init (struct fanotify_info *info) {BUILD_BUG_ON (FANOTIFY_FH_HDR_LEN +MAX_HANDLE_SZ >U8_MAX ); -BUILD_BUG_ON (NAME_MAX >U8_MAX ); +BUILD_BUG_ON (PATH_MAX >U16_MAX ); info->dir_fh_totlen =0 ; info->dir2_fh_totlen =0 ;
@@ -213,8 +220,7 @@ static inline void fanotify_info_set_file_fh(struct fanotify_info *info,static inline void fanotify_info_copy_name (struct fanotify_info *info,const struct qstr *name) { -if (WARN_ON_ONCE (name->len >NAME_MAX ) || -WARN_ON_ONCE (info->name2_len >0 )) +if (WARN_ON_ONCE (info->name2_len >0 ))return ; info->name_len = name->len;
@@ -224,9 +230,6 @@ static inline void fanotify_info_copy_name(struct fanotify_info *info,static inline void fanotify_info_copy_name2 (struct fanotify_info *info,const struct qstr *name) { -if (WARN_ON_ONCE (name->len >NAME_MAX )) -return ; - info->name2_len = name->len;strcpy (fanotify_info_name2 (info), name->name); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 488/1848 ext4: skip extra isize expansion while unmounting
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hemanth Selam <[email protected]>
[ Upstream commit 418adcde99032194416248168df810535a1a93f9 ]
syzbot reports a WARN from ext4_xattr_inode_create() reached through the unmount path:
EXT4-fs warning (device loop0): ext4_xattr_inode_create:1485: refuse to create EA inode when umounting
WARNING: fs/ext4/xattr.c:1486 at ext4_xattr_inode_lookup_create ext4_xattr_block_set ext4_expand_extra_isize_ea __ext4_expand_extra_isize __ext4_mark_inode_dirty ext4_dirty_inode __mark_inode_dirty sync_lazytime iput dentry_kill shrink_dentry_list shrink_dcache_for_umount generic_shutdown_super kill_block_super ext4_kill_sb
shrink_dcache_for_umount() clears s_root before generic_shutdown_super() clears SB_ACTIVE, so during the dcache shrink the last iput() of a lazytime inode still redirties it and reaches the isize expansion. The expansion can move xattrs out to a block, and creating the EA inode for them needs s_root, which ext4_xattr_inode_create() refuses without.
ext4_try_to_expand_extra_isize() already declines to expand when the superblock is not active, but that test does not cover this window. Decline while s_root is gone as well. The expansion is best effort and __ext4_mark_inode_dirty() ignores its return value, so nothing else changes; the inode can be expanded on a later mount.
Running the syzbot reproducer for 60 seconds produced 3583 splats before this change and none after it, with the same number of mount cycles.
--- fs/ext4/inode.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/ext4/inode.c +7 -1
@@ -6024,8 +6024,14 @@ static int ext4_try_to_expand_extra_isize(struct inode *inode,* When !SB_ACTIVE, iput triggers write_inode_now() which acquires * s_writepages_rwsem, causing a deadlock with the caller's active * jbd2 handle (lock order: s_writepages_rwsem -> jbd2_handle). +* +* Skip it while unmounting as well. shrink_dcache_for_umount() +* clears s_root before generic_shutdown_super() clears SB_ACTIVE, and +* the last iput() of a lazytime inode in that window redirties it and +* lands here. Moving xattrs out to a block then needs a new EA inode, +* which ext4_xattr_inode_create() refuses without s_root. */ -if (unlikely (!(inode->i_sb->s_flags &SB_ACTIVE ))) +if (unlikely (!(inode->i_sb->s_flags &SB_ACTIVE ) || !inode->i_sb->s_root))return -EBUSY ;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 489/1848 ext4: dont report delalloc data as a hole on indirect-mapped inodes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daejun Park <[email protected]>
[ Upstream commit aed43f47e1edeee1454eea86006a8c09480e5ed3 ]
When a plain lookup finds no block, ext4_ind_map_blocks() sizes the hole it reports by counting the empty subtrees under 'partial' in the on-disk indirect tree. That count knows nothing about delayed allocation, so a range holding delalloc data that has not been written back yet is reported as a plain hole. The extent-mapped path does not have this
problem: it trims the hole it found at the first delayed extent before returning it.
ext4_map_blocks() consults the extent status tree before it calls into the mapping layer, so a query that starts exactly on the delayed block still finds it. A query that starts earlier does not, because the hole reported for the earlier block already spans the delayed one. On a 4k-block filesystem, lseek(SEEK_DATA) from offset 0 on a file whose only data block is at logical block N and is still dirty returns:
N = 0..11 direct blocks N << 12 N = 12 first single-indirect block N << 12 N = 13..1035 inside that indirect block -1 ENXIO N = 1036 first double-indirect block N << 12
Blocks 12 and 1036 survive because the query lands on the delayed block itself. Blocks 13..1035 are swallowed by the 1024-block hole reported for block 12. fiemap loses the same data for the same reason.
An ext3 filesystem mounted as ext4 hits this during ordinary use: ext3 inodes stay indirect mapped, while mount -t ext4 turns on delayed allocation even though mounting ext3 with -o delalloc is explicitly rejected. install(1) from coreutils uses SEEK_DATA to locate data in its source file, so installing a sparse file that has not been written back silently produces a destination of the right size holding none of the data:
truncate -s 1G img && mkfs.ext3 -F img && mount -t ext4 img mnt echo | dd of=mnt/src bs=1 count=1 seek=64K install mnt/src mnt/dst cmp mnt/src mnt/dst # differ: char 65537
Reconciling a hole with the extent status tree does not depend on how the hole was found, so instead of open coding it a second time, split the delalloc handling out of ext4_ext_determine_insert_hole() into ext4_determine_insert_hole(), which takes the hole the caller located, and call that from ext4_ind_map_blocks() as well. All the special cases and the comments explaining them stay in one place.
Two things change for indirect-mapped inodes. They now cache the holes they report, as the extent-mapped path already does: ext4_punch_hole() already puts EXTENT_STATUS_HOLE on such inodes, ext4_map_blocks() and ext4_da_map_blocks() already handle a cached hole, the latter by replacing it with the delayed extent, and consecutive hole entries merge, so the tree does not grow with the length of a scan. And when a delayed extent covers the queried block itself - a race, since ext4_map_blocks() found nothing in the tree just before - the hole is now reported only up to the end of that extent instead of in full.
The indirect path passes hole_start == lblk, so the "delalloc extent in front of the queried range" case cannot be reached there:__es_tree_search() never returns an extent ending before the block it was searched for.
With this the sweep above returns N << 12 for every N, while the nodelalloc and extent-mapped controls are unchanged. generic/225, generic/285, generic/448 and generic/490 pass on ext4 made both with and without the extent feature. generic/286 and generic/436 pass on extent-mapped ext4 and are skipped without it, since they need fallocate.
--- fs/ext4/ext4.h | 3 +++ fs/ext4/extents.c | 26 +++++++++++++------------- fs/ext4/indirect.c | 17 +++++++++++++++++ 3 files changed, 33 insertions(+), 13 deletions(-)
fs/ext4/ext4.h +3 -0
@@ -3559,6 +3559,9 @@ extern void ext4_ext_tree_init(handle_t *handle, struct inode *inode);extern int ext4_ext_index_trans_blocks (struct inode *inode,int extents);extern int ext4_ext_map_blocks (handle_t *handle,struct inode *inode,struct ext4_map_blocks *map,int flags); +ext4_lblk_t ext4_determine_insert_hole (struct inode *inode,ext4_lblk_t lblk, +ext4_lblk_t hole_start, +ext4_lblk_t hole_len);extern int ext4_ext_truncate (handle_t *,struct inode *);extern int ext4_ext_remove_space (struct inode *inode,ext4_lblk_t start,ext4_lblk_t end);
fs/ext4/extents.c +13 -13
@@ -4090,21 +4090,19 @@ static int get_implied_cluster_alloc(struct super_block *sb, }/* -* Determine hole length around the given logical block, first try to -* locate and expand the hole from the given @path, and then adjust it -* if it's partially or completely converted to delayed extents, insert -* it into the extent cache tree if it's indeed a hole, finally return -* the length of the determined extent. +* Adjust the hole [@hole_start, @hole_start + @hole_len) the caller found +* around the queried block @lblk if it's partially or completely converted +* to delayed extents, insert it into the extent cache tree if it's indeed a +* hole, finally return the length of the determined extent starting at +* @lblk. @hole_start must not be behind @lblk. */ -static ext4_lblk_t ext4_ext_determine_insert_hole (struct inode *inode, -struct ext4_ext_path *path, -ext4_lblk_t lblk) +ext4_lblk_t ext4_determine_insert_hole (struct inode *inode,ext4_lblk_t lblk, +ext4_lblk_t hole_start, +ext4_lblk_t hole_len) { -ext4_lblk_t hole_start, len; +ext4_lblk_t len = hole_len;struct extent_status es; - hole_start = lblk; - len =ext4_ext_find_hole (inode, path, &hole_start); again:ext4_es_find_extent_range (inode, &ext4_es_is_delayed, hole_start, hole_start + len -1 , &es);
@@ -4269,9 +4267,11 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,* we couldn't try to create block if create flag is zero */ if ((flags &EXT4_GET_BLOCKS_CREATE ) ==0 ) { -ext4_lblk_t len; +ext4_lblk_t hole_start = map->m_lblk, len; - len =ext4_ext_determine_insert_hole (inode, path, map->m_lblk); + len =ext4_ext_find_hole (inode, path, &hole_start); + len =ext4_determine_insert_hole (inode, map->m_lblk, + hole_start, len); map->m_pblk =0 ; map->m_len = min_t(unsigned int, map->m_len, len);
fs/ext4/indirect.c +17 -0
@@ -584,6 +584,23 @@ int ext4_ind_map_blocks(handle_t *handle, struct inode *inode,for (i = partial - chain +1 ; i < depth; i++) count = count * epb + (epb - offsets[i] -1 ); count++; + +/* +* The count knows nothing about delayed allocation, so let +* the common helper reconcile it with the extent status +* tree. Only when the lookup really did find a hole: +* ext4_get_branch() also returns a non-NULL partial when it +* failed, and caching a hole for a range it could not read +* would answer every later read from that cache instead of +* retrying. Clamp the count first, a subtree can be bigger +* than the logical block space when the block size is large. +*/ +if (!err) { + count =umin (count,EXT_MAX_BLOCKS - map->m_lblk); + count =ext4_determine_insert_hole (inode, map->m_lblk, + map->m_lblk, count); + } +/* Fill in size of a hole we found */ map->m_pblk =0 ; map->m_len =umin (map->m_len, count);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 490/1848 ext4: fix out-of-bounds read in ext4_get_group_info()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinjie Ruan <[email protected]>
[ Upstream commit b067d3c1f90b536e9aa9f48b19580475a0b34f0f ]
A plain read of s_groups_count in ext4_get_group_info() allows CPU load-load reordering. On weak memory models, speculative prefetch of s_group_info prior to the boundary check could lead to an out-of-bounds read if a concurrent online resize expands the array and increments s_groups_count.
The data race occurs between the ioctl configuration path (holding the resize lock via ext4_resize_begin) and the lockless metadata lookup path:
CPU 0 (Writer, Resize Lock) CPU 1 (Reader, Lockless)
--------------------------- ------------------------
ext4_ioctl()
[EXT4_IOC_GROUP_ADD]
ext4_ioctl_group_add()
ext4_resize_begin() // Takes lock
ext4_group_add()
ext4_mb_alloc_groupinfo()
// Publishes expanded array via RCU
rcu_assign_pointer(s_group_info, ...)
ext4_flex_group_add()
ext4_update_super()
ext4_get_group_info()
// Speculative / out-of-order read
[Loads old/smaller s_group_info pointer]
[Plain C store / smp_wmb()]
sbi->s_groups_count += ...;
// Reads new s_groups_count,
// boundary check passes
if (group >= s_groups_count)
// Out-of-bounds array access!
sbi_array_rcu_deref(..., s_group_info)Fix this by using ext4_get_groups_count() to enforce acquire semantics.
--- fs/ext4/balloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/balloc.c +1 -1
@@ -325,7 +325,7 @@ struct ext4_group_info *ext4_get_group_info(struct super_block *sb,struct ext4_group_info **grp_info;long indexv, indexh; -if (unlikely (group >=EXT4_SB (sb)->s_groups_count)) +if (unlikely (group >=ext4_get_groups_count (sb)))return NULL ;if (unlikely (!EXT4_SB (sb)->s_group_info))return NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 491/1848 mm/nommu: reject wrapping ranges in access_remote_vm()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anastasios Papagiannis <[email protected]>
[ Upstream commit 51a8de81fd2edbf87d8046e352060329bb216fad ]
The NOMMU implementation of access_process_vm() rejects address ranges whose end wraps around, but access_remote_vm() bypasses this check even though both functions delegate to __access_remote_vm().
Move the wraparound check into __access_remote_vm() so it applies to both entry points.
This is originally reported in [1].
--- mm/nommu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
mm/nommu.c +3 -3
@@ -1680,6 +1680,9 @@ int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,struct vm_area_struct *vma;int write = gup_flags &FOLL_WRITE ; +if (addr + len < addr) +return 0 ; +if (mmap_read_lock_killable (mm))return 0 ;
@@ -1733,9 +1736,6 @@ int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, in {struct mm_struct *mm; -if (addr + len < addr) -return 0 ; - mm =get_task_mm (tsk);if (!mm)return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 492/1848 clk: imx: Fix clock reference leak in imx_get_clk_hw_by_name()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 8e177ca735761a1f03e1dedffd7ab00d6d0540ae ]
imx_get_clk_hw_by_name() obtains a consumer clock with of_clk_get_by_name(), extracts the hardware pointer with __clk_get_hw() and returns it without ever calling clk_put(), leaking the consumer reference on both return paths.
Extract the hardware pointer first and drop the clock reference with clk_put() before returning.
--- drivers/clk/imx/clk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/clk/imx/clk.c +5 -1
@@ -111,12 +111,16 @@ struct clk_hw * imx_obtain_fixed_clk_hw(struct device_node *np, const char *name) {struct clk *clk; +struct clk_hw *hw; clk =of_clk_get_by_name (np, name);if (IS_ERR (clk))return ERR_PTR (-ENOENT ); -return __clk_get_hw (clk); + hw =__clk_get_hw (clk); +clk_put (clk); + +return hw; }EXPORT_SYMBOL_GPL (imx_obtain_fixed_clk_hw);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 493/1848 clk: imx: Fix clock reference leak in imx_obtain_fixed_clock_hw()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 52d4d1b26a5bc64de95099d0a3dd8b90dba1f3a3 ]
imx_obtain_fixed_clock_hw() obtains the clock through imx_obtain_fixed_clock_from_dt(), which creates a consumer reference via of_clk_get_from_provider(). The reference is discarded right after __clk_get_hw() returns the hardware pointer, leaking it.
Keep the imx_clk_fixed() fallback unchanged and drop the DT-obtained consumer reference with clk_put() once the hardware pointer has been extracted.
--- drivers/clk/imx/clk.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/clk/imx/clk.c +7 -2
@@ -100,11 +100,16 @@ struct clk_hw *imx_obtain_fixed_clock_hw( const char *name, unsigned long rate) { struct clk *clk; +struct clk_hw *hw; clk =imx_obtain_fixed_clock_from_dt (name);if (IS_ERR (clk)) - clk =imx_clk_fixed (name, rate); -return __clk_get_hw (clk); +return __clk_get_hw (imx_clk_fixed (name, rate)); + + hw =__clk_get_hw (clk); +clk_put (clk); + +return hw; } struct clk_hw * imx_obtain_fixed_clk_hw(struct device_node *np,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 494/1848 soc: fsl: dpio: Fix cleanup on IRQ registration failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 45ecea8c55521d424513178fb612cefffb09a9f5 ]
IRQ registration happens after dpaa2_io_create(), but its failure path only releases the IRQ resources and the MC portal. The I/O object stays allocated and published in the service list and per-CPU lookup table, while devres unmaps its portal registers after probe fails.
Call dpaa2_io_down() on IRQ registration failure to remove the object from those lookup structures and free it. Reorder the error labels so that a failed dpaa2_io_create() still skips this cleanup.
Remove unregister_dpio_irq_handlers() from the probe error path, since no IRQ handler or affinity hint has been installed when registration fails.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/soc/fsl/dpio/dpio-driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soc/fsl/dpio/dpio-driver.c +2 -2
@@ -248,9 +248,9 @@ static int dpaa2_dpio_probe(struct fsl_mc_device *dpio_dev)return 0 ; -err_dpaa2_io_create: -unregister_dpio_irq_handlers (dpio_dev); err_register_dpio_irq: +dpaa2_io_down (priv->io); +err_dpaa2_io_create:fsl_mc_free_irqs (dpio_dev); err_allocate_irqs:dpio_disable (dpio_dev->mc_io,0 , dpio_dev->mc_handle);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 495/1848 USB: cdc-acm: fix urb leak on disconnect
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 648b08aa37c1b24a61662ad78964f2bca659ca26 ]
Make sure to drop the reference taken by usb_anchor_urb() when removing URBs from the delayed URB anchor to prevent them from leaking when the device is later disconnected.
--- drivers/usb/class/cdc-acm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/class/cdc-acm.c +2 -1
@@ -773,6 +773,7 @@ static void acm_port_shutdown(struct tty_port *port) urb =usb_get_from_anchor (&acm->delayed);if (!urb)break ; +usb_put_urb (urb); wb = urb->context; wb->use = false;usb_autopm_put_interface_async (acm->control);
@@ -1674,7 +1675,7 @@ static int acm_resume(struct usb_interface *intf) urb =usb_get_from_anchor (&acm->delayed);if (!urb)break ; - +usb_put_urb (urb);acm_start_wb (acm, urb->context); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 496/1848 USB: serial: option: add Rolling Wireless RN947R
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Reinhard Speyerer <[email protected]>
[ Upstream commit 931aad81f3f2d26276fff6b7bda6793267a65725 ]
Add Rolling Wireless RN947R 0x9300 compositions:
Standard mode: DIAG + ADB + NMEA + MODEM + RMNET + QDSS + ADPL
T: Bus=01 Lev=01 Prnt=01 Port=02 Cnt=02 Dev#= 6 Spd=480 MxCh= 0 D: Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=33f8 ProdID=9300 Rev= 0.00 S: Manufacturer=Rolling Wireless S: Product=RN947R S: SerialNumber=xxxxxxxxxxx C:* #Ifs= 7 Cfg#= 1 Atr=a0 MxPwr=500mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=30 Driver=option E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=usbfs E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=84(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=40 Driver=option E: Ad=86(I) Atr=03(Int.) MxPS= 10 Ivl=32ms E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms I:* If#= 8 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=50 Driver=qmi_wwan E: Ad=88(I) Atr=03(Int.) MxPS= 8 Ivl=32ms E: Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#=21 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=70 Driver=(none)
E: Ad=89(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
I:* If#=22 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=ff Prot=80 Driver=(none)
E: Ad=8a(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
QDL mode:
T: Bus=01 Lev=01 Prnt=01 Port=02 Cnt=02 Dev#= 12 Spd=480 MxCh= 0 D: Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=33f8 ProdID=9300 Rev= 0.00 S: Manufacturer=Rolling Wireless S: Product=RN947R S: SerialNumber=xxxxxxxxxxx C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr= 2mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=10 Driver=option E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
--- drivers/usb/serial/option.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/usb/serial/option.c +4 -0
@@ -2511,6 +2511,10 @@ static const struct usb_device_id option_ids[] = { .driver_info = RSVD(5) }, { USB_DEVICE_INTERFACE_CLASS(0x33f8, 0x1003, 0xff), /* Rolling RW135R-GL (laptop MBIM) */ .driver_info = RSVD(5) }, + { USB_DEVICE_AND_INTERFACE_INFO(0x33f8, 0x9300, 0xff, 0xff, 0x30) }, /* Rolling RN947R */ + { USB_DEVICE_AND_INTERFACE_INFO(0x33f8, 0x9300, 0xff, 0xff, 0x40) }, + { USB_DEVICE_AND_INTERFACE_INFO(0x33f8, 0x9300, 0xff, 0xff, 0x10), + .driver_info = ZLP }, { USB_DEVICE_INTERFACE_CLASS(0x3466, 0x3301, 0xff) }, /* TDTECH MT5710-CN */ { USB_DEVICE_AND_INTERFACE_INFO(0x3731, 0x0100, 0xff, 0xff, 0x30) }, /* NetPrisma LCUK54-WWD for Global */ { USB_DEVICE_AND_INTERFACE_INFO(0x3731, 0x0100, 0xff, 0x00, 0x40) },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 497/1848 USB: serial: option: add support for ASR 1286:4e3c modem
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Wyraz <[email protected]>
[ Upstream commit 87c56085bcdfec305f5c350fe1c58a62a7f65843 ]
The ASR modem used in the Tuoshi LT22M exposes an RNDIS function on interfaces 0 and 1, a diagnostic port on interface 2, and AT ports on interfaces 3 and 4. Match only the vendor-specific serial interfaces so option does not bind to the RNDIS function.
--- drivers/usb/serial/option.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/serial/option.c +1 -0
@@ -2444,6 +2444,7 @@ static const struct usb_device_id option_ids[] = { { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x30) }, /* Compal EXM-G1x */ { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x40) }, { USB_DEVICE_AND_INTERFACE_INFO(0x04b7, 0x8217, 0xff, 0xff, 0x60) }, + { USB_DEVICE_INTERFACE_CLASS(0x1286, 0x4e3c, 0xff) }, /* ASR modem */ { USB_DEVICE(0x1508, 0x1001), /* Fibocom NL668 (IOT version) */ .driver_info = RSVD(4) | RSVD(5) | RSVD(6) }, { USB_DEVICE(0x1782, 0x4d10) }, /* Fibocom L610 (AT mode) */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 498/1848 USB: serial: usb_wwan: fix urb leak on disconnect
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 c78dd373b5c56a5a02da591b583c6b48d0d62954 ]
Make sure to drop the reference taken by usb_anchor_urb() when removing URBs from the delayed URB anchor to prevent them from leaking when the device is later disconnected.
--- drivers/usb/serial/usb_wwan.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/serial/usb_wwan.c +3 -0
@@ -445,6 +445,7 @@ void usb_wwan_close(struct usb_serial_port *port) urb =usb_get_from_anchor (&portdata->delayed);if (!urb)break ; +usb_put_urb (urb);unbusy_queued_urb (urb, portdata);usb_autopm_put_interface_async (serial->interface); }
@@ -624,6 +625,8 @@ static int usb_wwan_submit_delayed_urbs(struct usb_serial_port *port)if (!urb)break ; +usb_put_urb (urb); + err =usb_submit_urb (urb,GFP_ATOMIC );if (err) { dev_err(&port->dev, "%s: submit urb failed: %d\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 499/1848 slimbus: messaging: fix leaked PM vote on tid allocation failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zongmin Zhou <[email protected]>
[ Upstream commit c26cc979e28f5193310e4379e14aa6417375c565 ]
In slim_do_transfer(), when a transaction needs a tid and slim_alloc_txn_tid() fails, the function returns directly instead of jumping to slim_xfer_err. The runtime PM vote taken earlier with pm_runtime_get_sync() is then never released, leaving the controller permanently powered up.
As txn->tid is still 0 at that point, jumping to slim_xfer_err drops the vote exactly like it is done for other failed transactions.
--- drivers/slimbus/messaging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/slimbus/messaging.c +1 -1
@@ -138,7 +138,7 @@ int slim_do_transfer(struct slim_controller *ctrl, struct slim_msg_txn *txn)if (need_tid) { ret =slim_alloc_txn_tid (ctrl, txn);if (ret) -return ret; + goto slim_xfer_err;if (!txn->msg->comp) txn->comp = &done;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 500/1848 USB: cdc-acm: add VeriFone VX820 device ID
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Drobyshev Vladimir <[email protected]>
[ Upstream commit ddbddee6592ecf6cf6c24d888780f9ad45a3e30b ]
Add USB ID 11ca:0219 for the VeriFone VX820 to the cdc-acm device table and apply the SINGLE_RX_URB quirk.
--- drivers/usb/class/cdc-acm.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/class/cdc-acm.c +3 -0
@@ -1783,6 +1783,9 @@ static const struct usb_device_id acm_ids[] = { { USB_DEVICE(0x11ca, 0x0201), /* VeriFone Mx870 Gadget Serial */ .driver_info =SINGLE_RX_URB , }, + { USB_DEVICE(0x11ca, 0x0219), /* VeriFone Vx820 Gadget Serial */ + .driver_info = SINGLE_RX_URB, + }, { USB_DEVICE(0x1901, 0x0006), /* GE Healthcare Patient Monitor UI Controller */ .driver_info = DISABLE_ECHO, /* DISABLE ECHO in termios flag */ },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 501/1848 usb: typec: ucsi_ccg: Add retry mechanism in ccg_read
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wayne Chang <[email protected]>
[ Upstream commit bbf6b99a57b2479bf51c3c8ad0946f4b8c33ed69 ]
CCG4 firmware occasionally fails to respond to I2C read requests, especially when reading cci and intr_reg from the ISR path. In these cases, i2c_transfer() returns -EREMOTEIO.
The CCG4 is EOL, and Infineon no longer supports firmware updates, so a software workaround is necessary.
Attempt the read up to CCG_READ_MAX_RETRIES (4) times in total when -EREMOTEIO is returned, sleeping ~1 ms via fsleep() between attempts. This allows recovery from transient I2C failures without affecting other error paths.
The sleep is safe because ccg_read() is called both from process context and from ccg_irq_handler(), which runs in threaded IRQ context (registered via request_threaded_irq() with a NULL hard-IRQ handler), so sleeping is allowed in both cases.
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi_ccg.c +14 -1
@@ -129,6 +129,8 @@ struct version_format {#define NVIDIA_FTB_DP_OFFSET (2)#define NVIDIA_FTB_DBG_OFFSET (3) +#define CCG_READ_MAX_RETRIES 4 +struct version_info {struct version_format base;struct version_format app;
@@ -239,6 +241,7 @@ static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len) };u32 rlen, rem_len = len, max_read_len = len;int status; +int retry_count;/* check any max_read_len limitation on i2c adapter */ if (quirks && quirks->max_read_len)
@@ -250,7 +253,17 @@ static int ccg_read(struct ucsi_ccg *uc, u16 rab, u8 *data, u32 len) rlen =min_t (u16, rem_len, max_read_len); msgs[1 ].len = rlen;put_unaligned_le16 (rab, buf); - status =i2c_transfer (client->adapter, msgs,ARRAY_SIZE (msgs)); + +for (retry_count =0 ; retry_count <CCG_READ_MAX_RETRIES ; retry_count++) { + status =i2c_transfer (client->adapter, msgs,ARRAY_SIZE (msgs)); + +/* Only retry on -EREMOTEIO, and not after the last attempt */ +if (status != -EREMOTEIO || retry_count ==CCG_READ_MAX_RETRIES -1 ) +break ; + +fsleep (1000 ); + } +if (status <0 ) {dev_err (uc->dev,"i2c_transfer failed %d\n" , status);pm_runtime_put_sync (uc->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 502/1848 mailbox: qcom-ipcc: Guard against NULL con_priv in send_data()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anup Vishwakarma <[email protected]>
[ Upstream commit 7b3cc361b5942ac600f38e5dff7aed009be34964 ]
qcom_ipcc_mbox_shutdown() clears chan->con_priv with no locking. qcom_ipcc_mbox_send_data() dereferences the same field without checking for NULL first, so a send racing a concurrent shutdown can crash:
mchan = chan->con_priv; ... hwirq = qcom_ipcc_get_hwirq(mchan->client_id, mchan->signal_id);
Add the same NULL guard mbox_send_message() already uses for chan->cl, and bail out before dereferencing a cleared con_priv.
To close the remaining race where send_data() reads con_priv a moment before a concurrent shutdown clears it, acquire the spinlock in qcom_ipcc_mbox_shutdown() using the modern guard(spinlock_irqsave) primitive before setting con_priv to NULL.
--- drivers/mailbox/qcom-ipcc.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/mailbox/qcom-ipcc.c +6 -0
@@ -10,6 +10,7 @@#include <linux/mailbox_controller.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/spinlock.h> #include <dt-bindings/mailbox/qcom-ipcc.h>
@@ -149,6 +150,9 @@ static int qcom_ipcc_mbox_send_data(struct mbox_chan *chan, void *data)struct qcom_ipcc_chan_info *mchan = chan->con_priv;u32 hwirq; +if (!mchan) +return -EINVAL ; + hwirq =qcom_ipcc_get_hwirq (mchan->client_id, mchan->signal_id);writel (hwirq, ipcc->base +IPCC_REG_SEND_ID );
@@ -157,6 +161,8 @@ static int qcom_ipcc_mbox_send_data(struct mbox_chan *chan, void *data)static void qcom_ipcc_mbox_shutdown (struct mbox_chan *chan) { +guard (spinlock_irqsave)(&chan->lock); + chan->con_priv =NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 503/1848 USB: serial: sierra: fix urb leak on write completion
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 e7daa54802c566ed3f22e81513f84c8c9197c5d1 ]
Make sure to drop the reference taken by usb_anchor_urb() also on successful submission of delayed write URBs during runtime resume to prevent them from leaking on completion.
--- drivers/usb/serial/sierra.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/usb/serial/sierra.c +2 -1
@@ -976,12 +976,13 @@ static int sierra_submit_delayed_urbs(struct usb_serial_port *port) intfdata->in_flight--;usb_unanchor_urb (urb);kfree (urb->transfer_buffer); -usb_free_urb (urb);spin_lock (&portdata->lock); portdata->outstanding_urbs--;spin_unlock (&portdata->lock); } + +usb_put_urb (urb); }if (ec)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 504/1848 dm-snapshot: fix crash if dm_io_client_create fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit 829c4d21148a205eca864429e06530319e1f92d5 ]
If dm_io_client_create() fails, it stores error into the ps->io_client variable. The code would try to free it later with dm_io_client_destroy(ps->io_client), causing an invalid pointer dereference. Fix this by setting ps->io_client = NULL.
--- drivers/md/dm-snap-persistent.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/md/dm-snap-persistent.c +5 -2
@@ -322,8 +322,11 @@ static int read_header(struct pstore *ps, int *new_snapshot) } ps->io_client =dm_io_client_create (); -if (IS_ERR (ps->io_client)) -return PTR_ERR (ps->io_client); +if (IS_ERR (ps->io_client)) { + r =PTR_ERR (ps->io_client); + ps->io_client =NULL ; +return r; + } r =alloc_area (ps);if (r)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 505/1848 arm64/efi: Clear PTE_WRITE when applying EFI_MEMORY_RO
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
[ Upstream commit 215d7b6622733603751f546b9faf9b84b0c281d4 ]
set_permissions() sets PTE_RDONLY for regions that the Memory Attributes Table describes as read-only, but leaves PTE_WRITE set. PTE_WRITE is the DBM bit, so when hardware dirty state management is enabled (TCR_EL1.HD), such a descriptor is writable-clean rather than read-only, and a write by the firmware will be permitted by the hardware (which marks the entry dirty) instead of faulting.
Clear PTE_WRITE as well, as pte_wrprotect() does.
--- arch/arm64/kernel/efi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/arm64/kernel/efi.c +7 -1
@@ -100,8 +100,14 @@ static int __init set_permissions(pte_t *ptep, unsigned long addr, void *data)efi_memory_desc_t *md = data;pte_t pte =READ_ONCE (*ptep); +/* +* Clear PTE_WRITE as well: it doubles as the DBM bit, and leaving it +* set would permit the hardware to make the mapping writable again +* when TCR_EL1.HD is set. +*/ if (md->attribute &EFI_MEMORY_RO ) - pte =set_pte_bit (pte,__pgprot (PTE_RDONLY )); + pte =set_pte_bit (clear_pte_bit (pte,__pgprot (PTE_WRITE )), +__pgprot (PTE_RDONLY ));if (md->attribute &EFI_MEMORY_XP ) pte =set_pte_bit (pte,__pgprot (PTE_PXN ));set_pte (ptep, pte);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 506/1848 xprtrdma: trim head iovec when the payload arrives via a Write chunk
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongjian Mu <[email protected]>
[ Upstream commit 9ee534a75912361308b1f956bc3e7895a082a422 ]
The upper layer sets rq_rcv_buf.head[0].iov_len from its estimate of the reply header size. For RPCSEC_GSS that estimate includes auth->au_ralign, which gss_create_new() initializes to GSS_VERF_SLACK >> 2 (25 XDR words, or 100 bytes) and which is corrected to the real verifier size only after the first reply on that rpc_auth has been unwrapped. In this case, the krb5 MIC verifier is 36 bytes, so every request encoded before the first reply completes has a head that is 64 bytes too long.
On TCP this is harmless: xdr_realign_pages() moves the excess head bytes, which are genuine reply data, into the page list. With RPC-over-RDMA and a Write chunk (sec=krb5, i.e. RPC_GSS_SVC_NONE, where DDP is allowed), the payload has already been placed directly into the page list, and the receive buffer holds only the inline part of the reply. rpcrdma_inline_fixup() clamps its local copy of the head length to the inline length but leaves head.iov_len untouched, so xdr_realign_pages() still sees iov_len > cur and shifts whatever lies past the inline reply in the receive buffer into the front of the directly-placed payload:
rpc_xdr_recvfrom: head=[...,196] page=524288 tail=[...,64]
rpc_xdr_alignment: nfsv4 READ offset=132 copied=64
The first 64 bytes returned by each such READ are incorrect (zeroed, or shifted right by 64 bytes depending on the kernel's xdr_shrink_bufhead() implementation). This is readily hit with pNFS flexfiles over RDMA and sec=krb5: the per-DS rpc_clnt gets a fresh rpc_auth whose first RPC is a large READ. Reads following the first completed reply return the expected data.
Commit cb0ae1fbb2f5 ("xprtrdma: Do not update {head, tail}.iov_len in rpcrdma_inline_fixup()") removed the head-length correction while fixing the handling of pure-inline krb5p replies.
When a Write chunk conveyed the payload, trim head.iov_len (in both rq_rcv_buf and rq_private_buf, which call_decode() expects to match) to the inline length actually received so that the XDR layer does not realign the page list. These READ replies have no trailing inline fields, and the payload is already in the page list, so the upper layer's head estimate can be safely reduced. Reduce buflen by the same amount to avoid treating unused head capacity as additional tail capacity. Pure inline replies and Reply chunk replies are unchanged.
Tested on Linux 6.8.0 and 7.3-rc4 with NFSv4.1 pNFS flexfiles over RPC/RDMA and sec=krb5.
--- net/sunrpc/xprtrdma/rpc_rdma.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
net/sunrpc/xprtrdma/rpc_rdma.c +23 -4
@@ -1039,12 +1039,16 @@ void rpcrdma_reset_cwnd(struct rpcrdma_xprt *r_xprt)* @rqst: controlling RPC request * @srcp: points to RPC message payload in receive buffer * @copy_len: remaining length of receive buffer content -* @pad: Write chunk pad bytes needed (zero for pure inline) +* @writelist: bytes conveyed by the Write chunk (zero for pure inline) * * The upper layer has set the maximum number of bytes it can * receive in each component of rq_rcv_buf. These values are set in * the head.iov_len, page_len, tail.iov_len, and buflen fields. * +* For READ replies with a Write chunk, the payload is already in +* the page list. An overestimated head length and buflen can be +* reduced without moving reply data. +* * Unlike the TCP equivalent (xdr_partial_copy_from_skb), in * many cases this function simply updates iov_base pointers in * rq_rcv_buf to point directly to the received reply data, to
@@ -1053,13 +1057,16 @@ void rpcrdma_reset_cwnd(struct rpcrdma_xprt *r_xprt)* Returns the count of bytes which had to be memcopied. */ static unsigned long -rpcrdma_inline_fixup (struct rpc_rqst *rqst,char *srcp,int copy_len,int pad) +rpcrdma_inline_fixup (struct rpc_rqst *rqst,char *srcp,int copy_len, +u32 writelist) {unsigned long fixup_copy_count;int i, npages, curlen;char *destp;struct page **ppages;int page_base; +int pad = writelist &3 ; +unsigned int delta;/* The head iovec is redirected to the RPC reply message * in the receive buffer, to avoid a memcopy.
@@ -1071,8 +1078,20 @@ rpcrdma_inline_fixup(struct rpc_rqst *rqst, char *srcp, int copy_len, int pad)* head.iov_len bytes are copied into the page list. */ curlen = rqst->rq_rcv_buf.head[0 ].iov_len; -if (curlen > copy_len) +if (curlen > copy_len) { +/* These READ replies have no inline fields after the payload. +* Trim the head without moving the directly-placed data. +*/ +if (writelist) { + delta = curlen - copy_len; + + rqst->rq_rcv_buf.head[0 ].iov_len = copy_len; + rqst->rq_private_buf.head[0 ].iov_len = copy_len; + rqst->rq_rcv_buf.buflen -= delta; + rqst->rq_private_buf.buflen -= delta; + } curlen = copy_len; + } srcp += curlen; copy_len -= curlen;
@@ -1302,7 +1321,7 @@ rpcrdma_decode_msg(struct rpcrdma_xprt *r_xprt, struct rpcrdma_rep *rep, base = (char *)xdr_inline_decode (xdr,0 ); rpclen =xdr_stream_remaining (xdr); r_xprt->rx_stats.fixup_copy_count += -rpcrdma_inline_fixup (rqst, base, rpclen, writelist &3 ); +rpcrdma_inline_fixup (rqst, base, rpclen, writelist); r_xprt->rx_stats.total_rdma_reply += writelist;return rpclen +xdr_align_size (writelist);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 507/1848 mm/page_alloc: do not boost watermarks in kdump capture kernels
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuanhe Shu <[email protected]>
[ Upstream commit 331f94007d79b3c02d3098eea469a92aea3efc2c ]
A watermark boost is not confined to one watermark: wmark_pages() adds it to min, low and high alike, so every watermark check sees it, including should_reclaim_retry() and the last ditch ALLOC_WMARK_HIGH attempt in __alloc_pages_may_oom(). Once the boost exceeds the memory still free the allocator gives up and invokes the OOM killer, and a capture kernel that is still booting has nothing to kill: the boot panics and the vmcore is lost.
Seen on an arm64 machine with 64K pages, CONFIG_PAGE_BLOCK_MAX_ORDER=10 (pageblock = 64M) and crashkernel=512M, running a distribution kernel based on 7.0.14. A high order UNMOVABLE allocation fell back to a MOVABLE pageblock while the capture kernel was still in do_initcalls():
Node 0 DMA free:68096kB boost:65536kB min:68160kB low:68800kB high:69440kB managed:479168kB Out of memory and no killable processes...
Kernel panic - not syncing: System is deadlocked on memory
The zone was not short of memory. Subtracting the boost gives min:2624kB low:3264kB high:3904kB, so the 68096kB still free sat 17 times above the high watermark and the allocator would not even have entered its slow path. The boost supplied 65536kB of the 68160kB min and by itself put the zone 64kB under water. It is that large because boost_watermark() clamps it with max(pageblock_nr_pages, max_boost); watermark_boost_factor alone would have allowed 5824kB.
Commit 14f69140ff9c ("mm: limit boost_watermark on small zones") already tried to protect capture kernels, but it infers them from the zone size and skips the boost only below four pageblocks. arm64 64K pageblocks were 512M then, so the guard reached zones up to 2G; CONFIG_PAGE_BLOCK_MAX_ORDER can cap them at 64M, which shrinks the guard to zones under 256M and lets this 468M zone through.
kdump is a property of the kernel, not of the zone, so test for it directly. A capture kernel exits within seconds and never uses the fragmentation avoidance the boost buys. Normal kernels are unaffected:
the size based check still covers their genuinely tiny zones.
Passing sysctl.vm.watermark_boost_factor=0 to the capture kernel does not cover this window: sysctl.* parameters are written through procfs by do_sysctl_args(), which runs after do_initcalls() where the panic above happened, and watermark_boost_factor has no early_param of its own.
--- mm/page_alloc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
mm/page_alloc.c +10 -2
@@ -53,6 +53,7 @@#include <linux/debugobjects.h> #include <linux/kmemleak.h> #include <linux/compaction.h> +#include <linux/crash_dump.h> #include <trace/events/kmem.h> #include <trace/events/oom.h> #include <linux/prefetch.h>
@@ -2478,10 +2479,17 @@ static inline bool boost_watermark(struct zone *zone)if (!watermark_boost_factor)return false; + +/* +* A kdump capture kernel exits before a boost can pay off, while +* the raised watermark can exceed the memory left for the dump. +*/ +if (is_kdump_kernel ()) +return false; +/* * Don't bother in zones that are unlikely to produce results. -* On small machines, including kdump capture kernels running -* in a small area, boosting the watermark can cause an out of +* On small machines, boosting the watermark can cause an out of * memory situation immediately. */ if ((pageblock_nr_pages *4 ) >zone_managed_pages (zone))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 508/1848 speakup: Fix NULL pointer dereference on VT switch + selection
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Thibault <[email protected]>
[ Upstream commit e1301ab8a8411fccc7effe0711fc09939a94953c ]
When selecting/pasting very quickly after VT switch, the tty is not set yet, leading to a NULL dereference. We can just abort the operation.
--- drivers/accessibility/speakup/selection.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/accessibility/speakup/selection.c +6 -0
@@ -61,6 +61,9 @@ static struct speakup_selection_work speakup_sel_work = {int speakup_set_selection (struct tty_struct *tty) { +if (!tty) +return -ENODEV ; +/* we get kref here first in order to avoid a subtle race when * cancelling selection work. getting kref first establishes the * invariant that if speakup_sel_work.tty is not NULL when
@@ -120,6 +123,9 @@ static struct speakup_selection_work speakup_paste_work = {int speakup_paste_selection (struct tty_struct *tty) { +if (!tty) +return -ENODEV ; +tty_kref_get (tty);if (cmpxchg (&speakup_paste_work.tty,NULL , tty)) {tty_kref_put (tty);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 509/1848 nvme-rdma: dont complete a request after a bogus remote invalidation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit 909307cea08aff4e486cdb7491de5c76a2c31341 ]
When a remote invalidation names an rkey that is not the one we handed out for this request, nvme_rdma_process_nvme_rsp() logs and schedules error recovery, then falls through to nvme_rdma_end_request(). The request is completed with req->mr never invalidated, and nvme_rdma_unmap_data() hands it back with ib_mr_pool_put(), which only puts it on a list. The rkey stays valid and still maps the pages the completed read filled, so a controller that sent the bogus invalidation can write into those pages after pread() has returned.
Return instead, the way the local invalidation path below already does, and leave the request for error recovery to cancel.
--- drivers/nvme/host/rdma.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvme/host/rdma.c +1 -0
@@ -1773,6 +1773,7 @@ static void nvme_rdma_process_nvme_rsp(struct nvme_rdma_queue *queue,"Bogus remote invalidation for rkey %#x\n" , req->mr ? req->mr->rkey : 0);nvme_rdma_error_recovery (queue->ctrl); +return ; } }else if (req->mr) {int ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 510/1848 nvmet: free the bvec on file namespace range errors
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 9d820d55b3cb4859c7cf42a74dc78f6154f97398 ]
nvmet_file_execute_rw() allocates the bvec before nvmet_file_execute_io() checks whether the request fits in the backing file. If the request extends beyond the file, nvmet_file_execute_io() calls nvmet_req_complete() to return an error. This skips nvmet_file_io_done(), so the allocated memory is never freed. Repeated requests can exhaust memory.
Use nvmet_file_io_done() to free the bvec before returning the range error to the client.
--- drivers/nvme/target/io-cmd-file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/target/io-cmd-file.c +2 -2
@@ -159,8 +159,8 @@ static bool nvmet_file_execute_io(struct nvmet_req *req, int ki_flags) pos =le64_to_cpu (req->cmd->rw.slba) << req->ns->blksize_shift;if (unlikely (pos + req->transfer_len > req->ns->size)) { -nvmet_req_complete (req,errno_to_nvme_status (req, -ENOSPC )); -return true; + ret = -ENOSPC ; + goto complete; }memset (&req->f.iocb,0 ,sizeof (struct kiocb ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 511/1848 sh: intc: Sort the prio and sense lists after filling them
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 94a219eda3b5fb1d1753a5ecf28b171c8f308a27 ]
register_intc_controller() sorts d->prio and d->sense right after allocating them, with hw->nr_prio_regs and hw->nr_sense_regs as the element count. The lists hold hw->nr_vectors entries and are only filled later, by intc_register_irq().
On SH7785, sh7785-irq0123 and sh7785-irq4567 have four vectors but the SoC's eleven priority registers, so sort() swaps 88 bytes in a 32 byte kmalloc object at boot. slub_debug=FZPU reports "Right Redzone overwritten" in kmalloc-32, and v6.5 and v6.6 panic in __kmem_cache_alloc_node() while registering sh7785-irq0123.
Found with a custom QEMU model of the SH7785LCR. On it, v6.4 sh7785lcr_defconfig boots with SLAB, the defconfig default before v6.5, and hangs before the console is up when built with SLUB.
Sort the lists once all vectors are registered, with the number of entries that were added.
--- drivers/sh/intc/core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/sh/intc/core.c +5 -6
@@ -262,9 +262,6 @@ int __init register_intc_controller(struct intc_desc *desc) k +=save_reg (d, k, hw->prio_regs[i].set_reg, smp); k +=save_reg (d, k, hw->prio_regs[i].clr_reg, smp); } - -sort (d->prio, hw->nr_prio_regs,sizeof (*d->prio), - intc_handle_int_cmp,NULL ); }if (hw->sense_regs) {
@@ -275,9 +272,6 @@ int __init register_intc_controller(struct intc_desc *desc)for (i =0 ; i < hw->nr_sense_regs; i++) k +=save_reg (d, k, hw->sense_regs[i].reg,0 ); - -sort (d->sense, hw->nr_sense_regs,sizeof (*d->sense), - intc_handle_int_cmp,NULL ); }if (hw->subgroups)
@@ -371,6 +365,11 @@ int __init register_intc_controller(struct intc_desc *desc) } } +sort (d->prio, d->nr_prio,sizeof (*d->prio), + intc_handle_int_cmp,NULL ); +sort (d->sense, d->nr_sense,sizeof (*d->sense), + intc_handle_int_cmp,NULL ); +intc_subgroup_init (desc, d);/* enable bits matching force_enable after registering irqs */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 512/1848 lib/decompress_bunzip2: fix off-by-one in run-length bounds check
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Turner <[email protected]>
[ Upstream commit 69919be2b93ef3922f646729ff42b4bd9a30846b ]
The run-length path rejects a block when dbufCount+t equals dbufSize, but the loop that follows writes exactly t bytes starting at dbufCount, so a block that fills the buffer exactly is legal. bzip2 allows it too: its decompressor bounds a block at 100000 * blockSize100k and checks that limit per byte appended. Use > instead of >=.
bzip2's encoder stops filling a block 19 bytes early, so nothing it produces ever reaches the limit and the bug stays hidden. Compressors that use the full block size do reach it: an lbzip2 -9 image whose block ends on a run fails to decode, and a self-extracting kernel built that way does not boot.
This code came from busybox, which fixed the same line in 2013 in commit 932e233a491b ("bunzip2: fix off-by-one check").
I ran into this because my system uses lbzip2 as /bin/bzip2 -- a common thing on Gentoo I believe. As far as I can tell, anyone using lbzip2 as their system bzip2 would run into this and it's only because it's very uncommon these days to compress a kernel with bzip2 that no one has noticed. I only noticed because I was adding support for various compression formats on alpha.
--- lib/decompress_bunzip2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/decompress_bunzip2.c +1 -1
@@ -439,7 +439,7 @@ static int INIT get_next_block(struct bunzip_data *bd)array.) */ if (runPos) { runPos =0 ; -if (dbufCount+t >= dbufSize) +if (dbufCount+t > dbufSize)return RETVAL_DATA_ERROR ; uc = symToByte[mtfSymbol[0 ]];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 513/1848 lib: decompress_bunzip2: fix integer overflow in run-length decoding
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aamir Ahmed <[email protected]>
[ Upstream commit b822ad8d702df0be9fe3f24f71caeb0522d72319 ]
The RUNA/RUNB decoder in get_next_block() accumulates a run length into the signed int t with no bound. runPos doubles per symbol, so t grows as at least 2^n-1 and reaches INT_MAX after 31 RUNA symbols. The guard that follows, dbufCount+t >= dbufSize, is itself a signed addition, and as the kernel builds with -fno-strict-overflow it wraps negative once dbufCount is nonzero, so the guard is skipped. while (t--) dbuf[dbufCount++] = uc then writes INT_MAX entries into a buffer holding at most 900000. One literal symbol ahead of the run is enough to make dbufCount nonzero.
Bound t to the block size as it is accumulated. t only grows within a run, so the value tested never exceeds the final run length; any stream that decodes today satisfies dbufCount+t < dbufSize at the flush, hence t < dbufSize throughout, and no such stream is rejected. Because t grows as at least 2^n-1 the bound trips by the 20th symbol, leaving runPos at most 2^19, so the following runPos <<= 1 cannot overflow either.
--- lib/decompress_bunzip2.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/decompress_bunzip2.c +4 -0
@@ -428,6 +428,10 @@ static int INIT get_next_block(struct bunzip_data *bd) t += (runPos << nextSym);/* +runPos if RUNA; +2*runPos if RUNB */ +/* Bound the run so t and runPos cannot overflow. */ +if (t >= dbufSize) +return RETVAL_DATA_ERROR ; + runPos <<=1 ;continue ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 514/1848 ALSA: cs46xx: fix unit mismatch in DSP code area bounds check
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis Arefev <[email protected]>
[ Upstream commit fd65108f5001ffb416dc9bd37ec1893f55cff24a ]
ins->code.offset and code->size are measured in 32-bit words, while DSP_CODE_BYTE_SIZE is the size of the DSP code area in bytes. The check ins->code.offset + code->size > DSP_CODE_BYTE_SIZE in cs46xx_dsp_load_module() therefore allowed up to four times more code than the code area can hold.
The shadow buffer ins->code.data is allocated with kmalloc(DSP_CODE_BYTE_SIZE), i.e. it holds DSP_CODE_BYTE_SIZE/4 words. A firmware file with a code segment larger than DSP_CODE_BYTE_SIZE/4 words (28 KiB) passed the check and caused an out-of-bounds write in shadow_and_reallocate_code() and an out-of-bounds read in snd_cs46xx_download().
Compare the sum in words against DSP_CODE_BYTE_SIZE/4 and cast it to u64 so that the sum cannot wrap for large code->size values.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- sound/pci/cs46xx/dsp_spos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/cs46xx/dsp_spos.c +1 -1
@@ -396,7 +396,7 @@ int cs46xx_dsp_load_module (struct snd_cs46xx * chip, struct dsp_module_desc * mdev_dbg (chip->card->dev,"dsp_spos: module got no code segment\n" ); }else { -if (ins->code.offset + code->size >DSP_CODE_BYTE_SIZE ) { +if ((u64 )ins->code.offset + code->size >DSP_CODE_BYTE_SIZE /4 ) {dev_err (chip->card->dev,"dsp_spos: no space available in DSP\n" );return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 515/1848 serial: 8250_lpss: do not touch uninitialized line in ehl_serial_exit()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Slaby (SUSE) <[email protected]>
[ Upstream commit 3e3ae95a3d84a6028f37a07ab7ad78bb14689f2e ]
lpss8250_probe() calls lpss->board->exit() on its error path. For the EHL board, that is ehl_serial_exit() and it does:
serial8250_get_port(lpss->data.line)->dma = NULL;
But when lpss8250_dma_setup() or serial8250_register_8250_port() fails, lpss->data.line was never assigned. As lpss is kzalloc()ed, line is 0 and ehl_serial_exit() clears the dma pointer of an unrelated port -- serial8250_ports[0], i.e. ttyS0, which is often the console.
Initialize lpss->data.line to -1 in probe and skip the clearing in ehl_serial_exit() if no port was registered.
--- drivers/tty/serial/8250/8250_lpss.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/tty/serial/8250/8250_lpss.c +4 -3
@@ -172,9 +172,8 @@ static int ehl_serial_setup(struct lpss8250 *lpss, struct uart_port *port)static void ehl_serial_exit (struct lpss8250 *lpss) { -struct uart_8250_port *up =serial8250_get_port (lpss->data.line); - - up->dma =NULL ; +if (lpss->data.line >=0 ) +serial8250_get_port (lpss->data.line)->dma =NULL ; }#ifdef CONFIG_SERIAL_8250_DMA
@@ -321,6 +320,8 @@ static int lpss8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)return ret; lpss->board = (struct lpss8250_board *)id->driver_data; +/* for tests in lpss->board->exit() */ + lpss->data.line =-1 ;memset (&uart,0 ,sizeof (struct uart_8250_port ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 516/1848 serial: pmac_zilog: push received data to the port that received it
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tim Douglas <[email protected]>
[ Upstream commit f3dc727da3af64abc12b625bbf1eb68d55d882cc ]
pmz_interrupt() drains both channels but, since commit 2e124b4a390c ("TTY: switch tty_flip_buffer_push"), pushes the flip buffer of the port whose handler is running rather than the port that was drained. With both ports open, data received on the other port can be left in its flip buffer until something else pushes it, so its reader may not see it.
--- drivers/tty/serial/pmac_zilog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/pmac_zilog.c +2 -2
@@ -455,7 +455,7 @@ static irqreturn_t pmz_interrupt(int irq, void *dev_id) skip_a:spin_unlock (&uap_a->port.lock);if (push) -tty_flip_buffer_push (&uap->port.state->port); +tty_flip_buffer_push (&uap_a->port.state->port);if (!uap_b) goto out;
@@ -480,7 +480,7 @@ static irqreturn_t pmz_interrupt(int irq, void *dev_id) skip_b:spin_unlock (&uap_b->port.lock);if (push) -tty_flip_buffer_push (&uap->port.state->port); +tty_flip_buffer_push (&uap_b->port.state->port); out:return rc;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 517/1848 ARM: 9491/1: alignment: restore uaccess state on emulation fault
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 80dafbcb705cead6d25cb821cf29c47da8860c8c ]
The alignment handlers enable access to user memory while emulating unaligned instructions. If a checked access faults, its exception table fixup jumps to the handler's fault label and bypasses uaccess_restore(). This leaves DOMAIN_USER as DOMAIN_CLIENT with SW domain PAN, or leaves TTBR0 page table walks enabled with TTBR0 PAN, while the fault is handled.
An ARM926 QEMU test using LDMIA across an unmapped page boundary reports DOMAIN_USER=1 at TYPE_FAULT before this change and DOMAIN_USER=0 after it. SW domain PAN is the default on ARMv5, ARMv6, and non-LPAE ARMv7 builds.
Keep the saved uaccess state at function scope and track whether it was saved. Restore it at the fault label only when needed. Paths that did not enable user access continue to skip the restore.
--- arch/arm/mm/alignment.c | 51 ++++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 14 deletions(-)
arch/arm/mm/alignment.c +37 -14
@@ -341,6 +341,8 @@ static int do_alignment_ldrhstrh(unsigned long addr, u32 instr, struct pt_regs *regs) {unsigned int rd =RD_BITS (instr); +unsigned int ua_flags; +bool ua_saved = false; ai_half +=1 ;
@@ -364,10 +366,11 @@ do_alignment_ldrhstrh(unsigned long addr, u32 instr, struct pt_regs *regs) user:if (LDST_L_BIT (instr)) {unsigned long val; -unsigned int __ua_flags =uaccess_save_and_enable (); + ua_flags =uaccess_save_and_enable (); + ua_saved = true;get16t_unaligned_check (val, addr); -uaccess_restore (__ua_flags); +uaccess_restore (ua_flags);/* signed half-word? */ if (instr &0x40 )
@@ -375,14 +378,17 @@ do_alignment_ldrhstrh(unsigned long addr, u32 instr, struct pt_regs *regs) regs->uregs[rd] = val; }else { -unsigned int __ua_flags =uaccess_save_and_enable (); + ua_flags =uaccess_save_and_enable (); + ua_saved = true;put16t_unaligned_check (regs->uregs[rd], addr); -uaccess_restore (__ua_flags); +uaccess_restore (ua_flags); }return TYPE_LDST ; fault: +if (ua_saved) +uaccess_restore (ua_flags);return TYPE_FAULT ; }
@@ -391,6 +397,8 @@ do_alignment_ldrdstrd(unsigned long addr, u32 instr, struct pt_regs *regs) {unsigned int rd =RD_BITS (instr);unsigned int rd2; +unsigned int ua_flags; +bool ua_saved = false;int load;if ((instr &0xfe000000 ) ==0xe8000000 ) {
@@ -425,26 +433,30 @@ do_alignment_ldrdstrd(unsigned long addr, u32 instr, struct pt_regs *regs) user:if (load) {unsigned long val, val2; -unsigned int __ua_flags =uaccess_save_and_enable (); + ua_flags =uaccess_save_and_enable (); + ua_saved = true;get32t_unaligned_check (val, addr);get32t_unaligned_check (val2, addr +4 ); -uaccess_restore (__ua_flags); +uaccess_restore (ua_flags); regs->uregs[rd] = val; regs->uregs[rd2] = val2; }else { -unsigned int __ua_flags =uaccess_save_and_enable (); + ua_flags =uaccess_save_and_enable (); + ua_saved = true;put32t_unaligned_check (regs->uregs[rd], addr);put32t_unaligned_check (regs->uregs[rd2], addr +4 ); -uaccess_restore (__ua_flags); +uaccess_restore (ua_flags); }return TYPE_LDST ; bad:return TYPE_ERROR ; fault: +if (ua_saved) +uaccess_restore (ua_flags);return TYPE_FAULT ; }
@@ -452,6 +464,8 @@ static int do_alignment_ldrstr(unsigned long addr, u32 instr, struct pt_regs *regs) {unsigned int rd =RD_BITS (instr); +unsigned int ua_flags; +bool ua_saved = false; ai_word +=1 ;
@@ -469,18 +483,22 @@ do_alignment_ldrstr(unsigned long addr, u32 instr, struct pt_regs *regs) trans:if (LDST_L_BIT (instr)) {unsigned int val; -unsigned int __ua_flags =uaccess_save_and_enable (); + ua_flags =uaccess_save_and_enable (); + ua_saved = true;get32t_unaligned_check (val, addr); -uaccess_restore (__ua_flags); +uaccess_restore (ua_flags); regs->uregs[rd] = val; }else { -unsigned int __ua_flags =uaccess_save_and_enable (); + ua_flags =uaccess_save_and_enable (); + ua_saved = true;put32t_unaligned_check (regs->uregs[rd], addr); -uaccess_restore (__ua_flags); +uaccess_restore (ua_flags); }return TYPE_LDST ; fault: +if (ua_saved) +uaccess_restore (ua_flags);return TYPE_FAULT ; }
@@ -502,6 +520,8 @@ do_alignment_ldmstm(unsigned long addr, u32 instr, struct pt_regs *regs) {unsigned int rd, rn, correction, nr_regs, regbits;unsigned long eaddr, newaddr; +unsigned int ua_flags; +bool ua_saved = false;if (LDM_S_BIT (instr)) goto bad;
@@ -547,7 +567,8 @@ do_alignment_ldmstm(unsigned long addr, u32 instr, struct pt_regs *regs)#endif if (user_mode (regs)) { -unsigned int __ua_flags =uaccess_save_and_enable (); + ua_flags =uaccess_save_and_enable (); + ua_saved = true;for (regbits =REGMASK_BITS (instr), rd =0 ; regbits; regbits >>=1 , rd +=1 )if (regbits &1 ) {
@@ -559,7 +580,7 @@ do_alignment_ldmstm(unsigned long addr, u32 instr, struct pt_regs *regs)put32t_unaligned_check (regs->uregs[rd], eaddr); eaddr +=4 ; } -uaccess_restore (__ua_flags); +uaccess_restore (ua_flags); }else {for (regbits =REGMASK_BITS (instr), rd =0 ; regbits; regbits >>=1 , rd +=1 )
@@ -581,6 +602,8 @@ do_alignment_ldmstm(unsigned long addr, u32 instr, struct pt_regs *regs)return TYPE_DONE ; fault: +if (ua_saved) +uaccess_restore (ua_flags); regs->ARM_pc -= correction;return TYPE_FAULT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 518/1848 Bluetooth: 6lowpan: Pin module for 6lowpan_control debugfs file
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bui Viet Dung <[email protected]>
[ Upstream commit 8368f0c2cde48c09ed70644059f24172b0c59f52 ]
An open debugfs file retains lowpan_control_fops in the debugfs proxy state. However, lowpan_control_fops has no .owner set to THIS_MODULE. As a result, full_proxy_open_regular() calls fops_get() which succeeds without taking a reference to the bluetooth_6lowpan module.
With CONFIG_BT_6LOWPAN=m, a userspace process can keep the debugfs file descriptor for 6lowpan_control open across module unload (delete_module / rmmod bluetooth_6lowpan). When the process subsequently closes the file descriptor, full_proxy_release() accesses the already freed and unmapped lowpan_control_fops table, causing a kernel page fault or oops.
The issue was discovered via manual code audit ofnet/bluetooth/6lowpan.c.
Set .owner = THIS_MODULE on lowpan_control_fops so that debugfs pins the module until all open file descriptors have finished.
--- net/bluetooth/6lowpan.c | 1 + 1 file changed, 1 insertion(+)
net/bluetooth/6lowpan.c +1 -0
@@ -1264,6 +1264,7 @@ static int lowpan_control_open(struct inode *inode, struct file *file) }static const struct file_operations lowpan_control_fops = { + .owner =THIS_MODULE , .open = lowpan_control_open, .read = seq_read, .write = lowpan_control_write,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 519/1848 Bluetooth: L2CAP: Reject mode changes on connected channels
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siwei Zhang <[email protected]>
[ Upstream commit c1398cf11b31a94c27ed810ba69515e0df5ce379 ]
A peer can send a configuration response with an RFC option for another mode to a connected channel, for example to switch it from Streaming to ERTM mode. l2cap_parse_conf_rsp() then changes chan->mode, but l2cap_ertm_init() is not called again, so the ERTM sequence lists are never allocated. The next out-of-sequence I-frame makes l2cap_seq_list_clear() write through the NULL srej_list.list.
Refuse the channel when a response tries to change the mode of a connected channel.
--- net/bluetooth/l2cap_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +5 -1
@@ -3967,7 +3967,11 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, } } -if (chan->mode ==L2CAP_MODE_BASIC && chan->mode != rfc.mode) +/* A connected channel cannot change its mode, as the new mode would +* not be initialized. +*/ +if (chan->mode != rfc.mode && + (chan->mode ==L2CAP_MODE_BASIC || chan->state ==BT_CONNECTED ))return -ECONNREFUSED ; chan->mode = rfc.mode;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 520/1848 Bluetooth: L2CAP: Reject invalid TxWindow in configuration requests
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siwei Zhang <[email protected]>
[ Upstream commit c5ebb0245fe927cf5fa33510a9cb2799c4a2dd01 ]
A peer can send an ERTM RFC option with a TxWindow of zero, which is out of spec. It is stored in remote_tx_win unchanged and later passed to l2cap_seq_list_init(), where roundup_pow_of_two(0) is undefined. On some architectures this results in a ZERO_SIZE_PTR list and a remote kernel oops.
A TxWindow above 63 is out of spec as well. With 6-bit sequence numbers we would then send more unacknowledged frames than the sequence space can tell apart.
Reply with L2CAP_CONF_UNACCEPT and propose the default TxWindow instead of accepting the value, so remote_tx_win always stays within 1 to 63. Keep the parameters of an earlier request then, and do not treat the request as done because an earlier one was.
Also refuse a zero size in l2cap_seq_list_init(), so any other path that reaches it with a zero TxWindow fails the channel instead of the kernel.
--- net/bluetooth/l2cap_core.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-)
net/bluetooth/l2cap_core.c +27 -8
@@ -347,6 +347,10 @@ static int l2cap_seq_list_init(struct l2cap_seq_list *seq_list, u16 size) {size_t alloc_size, i; +/* roundup_pow_of_two(0) is undefined */ +if (!size) +return -EINVAL ; +/* Allocated size is a power of 2 to map sequence numbers * (which may be up to 14 bits) in to a smaller array that is * sized for the negotiated ERTM transmit windows.
@@ -3814,18 +3818,33 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data, size_t databreak ;case L2CAP_MODE_ERTM : -if (!test_bit (CONF_EWS_RECV , &chan->conf_state)) - chan->remote_tx_win = rfc.txwin_size; -else - rfc.txwin_size =L2CAP_DEFAULT_TX_WINDOW ; - - chan->remote_max_tx = rfc.max_transmit; - size =min_t (u16,le16_to_cpu (rfc.max_pdu_size), chan->conn->mtu -L2CAP_EXT_HDR_SIZE -L2CAP_SDULEN_SIZE -L2CAP_FCS_SIZE ); rfc.max_pdu_size =cpu_to_le16 (size); - chan->remote_mps = size; + +/* The TxWindow must be within 1 to 63, otherwise +* propose the default one and keep the parameters of +* an earlier request. This overrides a PENDING result +* from the EFS check above, so the request is no +* longer pending, nor done if an earlier one was. +*/ +if (!rfc.txwin_size || + rfc.txwin_size >L2CAP_DEFAULT_TX_WINDOW ) { + result =L2CAP_CONF_UNACCEPT ; +clear_bit (CONF_LOC_CONF_PEND , &chan->conf_state); +clear_bit (CONF_OUTPUT_DONE , &chan->conf_state); + rfc.txwin_size =L2CAP_DEFAULT_TX_WINDOW ; + remote_efs =0 ; + }else { +if (!test_bit (CONF_EWS_RECV , &chan->conf_state)) + chan->remote_tx_win = rfc.txwin_size; +else + rfc.txwin_size =L2CAP_DEFAULT_TX_WINDOW ; + + chan->remote_max_tx = rfc.max_transmit; + chan->remote_mps = size; + }__l2cap_set_ertm_timeouts (chan, &rfc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 521/1848 Bluetooth: L2CAP: Use default TxWindow for zero socket option
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siwei Zhang <[email protected]>
[ Upstream commit 226fa3b676cbf2236f803bccd347462433ffc2c8 ]
L2CAP_OPTIONS accepts a txwin_size of zero and
stores it in tx_win. The zero is then sent to the
peer in our configuration request, and if the
channel ends up in ERTM mode it is passed tol2cap_seq_list_init().
Use the default TxWindow instead, as the mode can
still be changed to ERTM during configuration.
--- net/bluetooth/l2cap_sock.c | 4 ++++ 1 file changed, 4 insertions(+)
net/bluetooth/l2cap_sock.c +4 -0
@@ -801,6 +801,10 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,break ; } +/* A zero TxWindow is invalid, use the default instead */ +if (!opts.txwin_size) + opts.txwin_size =L2CAP_DEFAULT_TX_WINDOW ; +if (!l2cap_valid_mtu (chan, opts.imtu)) { err = -EINVAL ;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 522/1848 cpufreq: schedutil: Serialize sugov_start() against rate limit updates
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Su <[email protected]>
[ Upstream commit ce390caf5541c493c9061e7a2d98a463e66b736a ]
The current value of sg_policy->tunables->rate_limit_us is used in sugov_start() without locking to update sg_policy->freq_update_delay_ns, so if rate_limit_us_store() runs in parallel with it, the rate limit update may go unnoticed and the new freq_update_delay_ns value may be stale until the rate limit is updated again.
To avoid that, acquire the update_lock mutex of the rate limit sysfs attribute, that is held by rate_limit_us_store() during rate limit updates, around the freq_update_delay_ns in sugov_start().
--- kernel/sched/cpufreq_schedutil.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
kernel/sched/cpufreq_schedutil.c +13 -1
@@ -78,6 +78,18 @@ static void sugov_update_rate_limit_us(struct sugov_policy *sg_policy) (s64 )sg_policy->tunables->rate_limit_us *NSEC_PER_USEC ; } +static void sugov_update_rate_limit_us_sync (struct sugov_policy *sg_policy) +{ +/* +* Serialize with rate_limit_us_store() to prevent this path from using +* a stale rate limit tunable value to set the limit for the given +* policy. +*/ +guard (mutex)(&sg_policy->tunables->attr_set.update_lock); + +sugov_update_rate_limit_us (sg_policy); +} +static bool sugov_should_update_freq (struct sugov_policy *sg_policy,u64 time) {s64 delta_ns;
@@ -857,7 +869,7 @@ static int sugov_start(struct cpufreq_policy *policy)struct sugov_policy *sg_policy = policy->governor_data;unsigned int cpu; -sugov_update_rate_limit_us (sg_policy); +sugov_update_rate_limit_us_sync (sg_policy); sg_policy->last_freq_update_time =0 ; sg_policy->next_freq =0 ; sg_policy->work_in_progress = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 523/1848 irqchip/gic-v3-its: Dont clamp nvecs to zero when id_bits is 32
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fuad Tabba <[email protected]>
[ Upstream commit 5a9d62555e7164ec79a5fe70153d79cf1fdfd614 ]
GITS_TYPER_IDBITS is five bits, so id_bits reaches 32 and min_t(unsigned int, ...) truncates BIT(32) to 0. nvecs becomes 0, its_lpi_alloc() rejects that, and its_msi_prepare() returns -ENOMEM. On 32-bit ARM the shift is undefined instead.
The clamp is correct for every value below the maximum, so only that one value is affected.
--- drivers/irqchip/irq-gic-v3-its.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +1 -1
@@ -3398,7 +3398,7 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,* Also honor the ITS's own EID limit. */ id_bits =FIELD_GET (GITS_TYPER_IDBITS , its->typer) +1 ; - nvecs = min_t(unsigned int, nvecs, BIT(id_bits)); + nvecs =min_t (u64, nvecs,BIT_ULL (id_bits)); nr_ites =max (2 , nvecs); sz = nr_ites * (FIELD_GET (GITS_TYPER_ITT_ENTRY_SIZE , its->typer) +1 ); sz =max (sz,ITS_ITT_ALIGN ) +ITS_ITT_ALIGN -1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 524/1848 efi/libstub: Dont replace an existing LINUX_EFI_MEMRESERVE table
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
[ Upstream commit aaf3ed0f46298e18ec8bc477cf0a37478e41f2ea ]
The LINUX_EFI_MEMRESERVE table is the root of a linked list of memory reservations that need to persist across kexec, such as the GICv3 LPI pending and property tables, which cannot be moved once the redistributors have been enabled. Each kernel adds its own reservations to the list that it finds via the EFI configuration table, and honours the ones made by its predecessors.
The EFI stub installs a new, empty table unconditionally, replacing any existing one. This is fine on a cold boot, but not if the stub is being executed by a loader that passes on the configuration tables of an earlier kernel, e.g., a kexec loader that runs the incoming kernel's EFI stub, as the reservations made by earlier kernels would be lost.
So leave an existing table in place, and only install a new one if none exists yet.
--- drivers/firmware/efi/libstub/efi-stub.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/firmware/efi/libstub/efi-stub.c +8 -0
@@ -79,6 +79,14 @@ static void install_memreserve_table(void)efi_guid_t memreserve_table_guid =LINUX_EFI_MEMRESERVE_TABLE_GUID ;efi_status_t status; +/* +* If an earlier boot stage installed a memreserve table already, e.g., +* a kexec loader passing on the persistent reservations made by the +* previous kernel, use it as is: installing a new one would replace it. +*/ +if (get_efi_config_table (memreserve_table_guid)) +return ; + status =efi_bs_call (allocate_pool,EFI_LOADER_DATA ,sizeof (*rsv), (void **)&rsv);if (status !=EFI_SUCCESS ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 525/1848 spi: npcm-fiu: limit UMA data_size to the 16-byte staging buffer
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weibin Liu <[email protected]>
[ Upstream commit f0be928a41384ea93c876364f360779f70359249 ]
npcm_fiu_uma_read() and npcm_fiu_uma_write() use a 16-byte on-stack staging buffer (u32 data_reg[4]) and move data_size bytes to or from it. data_size comes straight from op->data.nbytes, which is supplied by the SPI MEM operation and is not bounded by the driver:npcm_fiu_exec_op() only validates op->addr.nbytes, and no adjust_op_size callback truncates the transfer to the controller FIFO size.
A SPI MEM operation with addr.nbytes == 0 and data.nbytes > 16 therefore overflows data_reg[] on the kernel stack (write path) or reads past it (read path), corrupting the stack.
Reject data_size larger than the staging buffer in both UMA helpers by returning -EOPNOTSUPP, so spi_mem falls back to the generic SPI message path. The chunked path in npcm_fiu_manualwrite() always passes at most CHUNK_SIZE bytes, so it is unaffected.
--- drivers/spi/spi-npcm-fiu.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/spi/spi-npcm-fiu.c +8 -0
@@ -323,6 +323,10 @@ static int npcm_fiu_uma_read(struct spi_mem *mem,u32 val;u32 i; +/* data_reg holds at most 16 bytes */ +if (data_size >sizeof (data_reg)) +return -EOPNOTSUPP ; + regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CTS, NPCM_FIU_UMA_CTS_DEV_NUM, (mem->spi->chip_select <<
@@ -378,6 +382,10 @@ static int npcm_fiu_uma_write(struct spi_mem *mem,u32 val;u32 i; +/* data_reg holds at most 16 bytes */ +if (data_size >sizeof (data_reg)) +return -EOPNOTSUPP ; + regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CTS, NPCM_FIU_UMA_CTS_DEV_NUM, (mem->spi->chip_select <<
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 526/1848 mfd: tps65217: Fix NULL pointer dereference on IRQ init failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Radiy Zhambakiev <[email protected]>
[ Upstream commit 0473a5b0663663b75573bf284beb77459e07c461 ]
tps65217_probe() ignores the return value of tps65217_irq_init(), so when the irq domain creation fails the probe still completes and the driver ends up bound with a NULL tps->irq_domain. Unloading the module then makes tps65217_remove() call irq_domain_remove() on the NULL pointer and oops the kernel. On top of that, irq_find_mapping() may fall back to the default irq domain and dispose of mappings that belong to other interrupt controllers.
Check the return value and abort the probe on failure so the error is reported and no inconsistent state is left for removal.
--- drivers/mfd/tps65217.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mfd/tps65217.c +3 -1
@@ -342,7 +342,9 @@ static int tps65217_probe(struct i2c_client *client) }if (client->irq) { -tps65217_irq_init (tps, client->irq); + ret =tps65217_irq_init (tps, client->irq); +if (ret) +return ret; }else {int i;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 527/1848 mfd: tps65217: Check return value when masking interrupt sources
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Radiy Zhambakiev <[email protected]>
[ Upstream commit 66ed12c1e5a986bee1dc63f9bd9c7f068138a69a ]
tps65217_irq_init() ignores the error returned by tps65217_set_bits() when masking all interrupt sources. A failed register write leaves the driver's software mask out of sync with the hardware and may result in spurious interrupts.
Check the return value and propagate the error to the caller.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/mfd/tps65217.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/mfd/tps65217.c +6 -2
@@ -164,8 +164,12 @@ static int tps65217_irq_init(struct tps65217 *tps, int irq)/* Mask all interrupt sources */ tps->irq_mask =TPS65217_INT_MASK ; -tps65217_set_bits (tps,TPS65217_REG_INT ,TPS65217_INT_MASK , -TPS65217_INT_MASK ,TPS65217_PROTECT_NONE ); + ret =tps65217_set_bits (tps,TPS65217_REG_INT ,TPS65217_INT_MASK , +TPS65217_INT_MASK ,TPS65217_PROTECT_NONE ); +if (ret) { +dev_err (tps->dev,"Failed to mask interrupt sources: %d\n" , ret); +return ret; + } tps->irq_domain =irq_domain_add_linear (tps->dev->of_node,TPS65217_NUM_IRQ , &tps65217_irq_domain_ops, tps);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 528/1848 dax: Return errors from dax_core_init()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jianyun Gao <[email protected]>
[ Upstream commit 4da700e2cadf84a6e858391d5be51d64dcba080f ]
dax_core_init() returns success when either the character device number allocation or DAX bus registration fails, even though the error paths have already released the initialized resources.
For modular DAX, this allows the module to remain loaded despite failed initialization, leaving subsequent users and module removal to access resources that have already been released.
Return the error code from the failed operation so that module loading fails rather than reporting successful initialization after the resources have been released.
--- drivers/dax/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/super.c +1 -1
@@ -748,7 +748,7 @@ static int __init dax_core_init(void)unregister_chrdev_region (dax_devt,MINORMASK +1 ); err_chrdev:dax_fs_exit (); -return 0 ; +return rc; } static void __exit dax_core_exit(void)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 529/1848 ipv6: defrag: orphan skb before queuing
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zixuan Chai <[email protected]>
[ Upstream commit 5dfa91a5ec53cfbf907a1fca095ac3ac7a4e94c9 ]
IPv4 and nf_conntrack fragment queues orphan skbs before returning -EINPROGRESS, but ip6_frag_queue() leaves the socket association intact.
Commit 18685451fc4e ("inet: inet_defrag: prevent sk release while still in use") moved skb_orphan() into ip_frag_queue() and nf_ct_frag6_queue(), but missed ip6_frag_queue().
Without orphaning, inet_frag_reasm_finish() clears fp->sk on frag_list skbs but leaves fp->destructor set to sock_pfree. Freeing the reassembled skb then calls sock_pfree() with a NULL socket. A socket using SOCK_RCU_FREE may also be released while its fragment is queued, leaving a stale socket pointer; this is a second consequence of the same missing orphan.
Orphan the skb before returning -EINPROGRESS so the queued fragment no longer retains the socket association or destructor.
--- net/ipv6/reassembly.c | 1 + 1 file changed, 1 insertion(+)
net/ipv6/reassembly.c +1 -0
@@ -221,6 +221,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, }skb_dst_drop (skb); +skb_orphan (skb);return -EINPROGRESS ; insert_error:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 530/1848 sctp: hold transport reference across connect wait
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seung Min Shin <[email protected]>
[ Upstream commit 5bef8649bb9ac4b2a014bcc227202ebd2df824be ]
sctp_sendmsg_to_asoc() selects a transport before waiting for a new interleaved association to become established. sctp_wait_for_connect() drops the socket lock while sleeping.
While the lock is dropped, backlog processing can handle a COOKIE ACK and an ASCONF DEL-IP that removes the selected transport. sctp_assoc_rm_peer() then marks the transport dead and drops its association-owned reference. The transport can be freed through RCU before the send path resumes.
After the wait, the stale pointer is assigned to newly created DATA or I-DATA chunks and later dereferenced by sctp_outq_select_transport().
Hold a reference to the selected transport across sctp_wait_for_connect(). After the socket lock is reacquired, abort the send if the transport was marked dead. Callers without a selected transport pass NULL and retain their existing behavior.
--- net/sctp/socket.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
net/sctp/socket.c +19 -7
@@ -74,7 +74,8 @@ static int sctp_wait_for_sndbuf(struct sctp_association *asoc,struct sctp_transport *transport, long *timeo_p, size_t msg_len);static int sctp_wait_for_packet (struct sock *sk,int *err,long *timeo_p); -static int sctp_wait_for_connect (struct sctp_association *,long *timeo_p); +static int sctp_wait_for_connect (struct sctp_association *, +struct sctp_transport *,long *timeo_p);static int sctp_wait_for_accept (struct sock *sk,long timeo);static void sctp_wait_for_close (struct sock *sk,long timeo);static void sctp_destruct_sock (struct sock *sk);
@@ -1242,7 +1243,7 @@ static int __sctp_connect(struct sock *sk, struct sockaddr *kaddrs, *assoc_id = asoc->assoc_id; timeo =sock_sndtimeo (sk, flags &O_NONBLOCK ); -return sctp_wait_for_connect (asoc, &timeo); +return sctp_wait_for_connect (asoc,NULL , &timeo); out_free: pr_debug("%s: took out_free path with asoc:%p kaddrs:%p err:%d\n",
@@ -1849,7 +1850,7 @@ static int sctp_sendmsg_to_asoc(struct sctp_association *asoc,if (asoc->ep->intl_enable) { timeo =sock_sndtimeo (sk,0 ); - err =sctp_wait_for_connect (asoc, &timeo); + err =sctp_wait_for_connect (asoc, transport, &timeo);if (err || sk->sk_shutdown &RCV_SHUTDOWN ) { err = -ESRCH ; goto err;
@@ -1892,7 +1893,7 @@ static int sctp_sendmsg_to_asoc(struct sctp_association *asoc,if (unlikely (wait_connect)) { timeo =sock_sndtimeo (sk, msg->msg_flags &MSG_DONTWAIT ); -sctp_wait_for_connect (asoc, &timeo); +sctp_wait_for_connect (asoc,NULL , &timeo); } err = msg_len;
@@ -9119,7 +9120,9 @@ static bool sctp_writeable(const struct sock *sk)/* Wait for an association to go into ESTABLISHED state. If timeout is 0, * returns immediately with EINPROGRESS. */ -static int sctp_wait_for_connect (struct sctp_association *asoc,long *timeo_p) +static int sctp_wait_for_connect (struct sctp_association *asoc, +struct sctp_transport *transport, +long *timeo_p) {struct sock *sk = asoc->base.sk;int err =0 ;
@@ -9128,12 +9131,16 @@ static int sctp_wait_for_connect(struct sctp_association *asoc, long *timeo_p)pr_debug ("%s: asoc:%p, timeo:%ld\n" , __func__, asoc, *timeo_p); -/* Increment the association's refcnt. */ +/* Hold references while the socket lock is dropped. */ +if (transport) +sctp_transport_hold (transport);sctp_association_hold (asoc);for (;;) {prepare_to_wait_exclusive (&asoc->wait, &wait,TASK_INTERRUPTIBLE ); +if (transport && transport->dead) + goto do_transport_dead;if (!*timeo_p) goto do_nonblock;if (sk->sk_shutdown &RCV_SHUTDOWN )
@@ -9162,7 +9169,8 @@ static int sctp_wait_for_connect(struct sctp_association *asoc, long *timeo_p) out:finish_wait (&asoc->wait, &wait); -/* Release the association's refcnt. */ +if (transport) +sctp_transport_put (transport);sctp_association_put (asoc);return err;
@@ -9181,6 +9189,10 @@ static int sctp_wait_for_connect(struct sctp_association *asoc, long *timeo_p) do_nonblock: err = -EINPROGRESS ; goto out; + +do_transport_dead: + err = -EAGAIN ; + goto out; }static int sctp_wait_for_accept (struct sock *sk,long timeo)
Signature · 1 line
2.53.0