printk: Fix signed integer overflow when defining LOG_BUF_LEN_MAX
Subsystems (2)
Sasha Levin
maintainerPATCH 1/3 printk: Fix signed integer overflow when defining LOG_BUF_LEN_MAX
From: Kuan-Wei Chiu <[email protected]>
[ Upstream commit 3d6f83df8ff2d5de84b50377e4f0d45e25311c7a ]
Shifting 1 << 31 on a 32-bit int causes signed integer overflow, which leads to undefined behavior. To prevent this, cast 1 to u32 before performing the shift, ensuring well-defined behavior.
This change explicitly avoids any potential overflow by ensuring that the shift occurs on an unsigned 32-bit integer.
--- kernel/printk/printk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/printk/printk.c +1 -1
@@ -420,7 +420,7 @@ static u64 clear_seq;/* record buffer */ #define LOG_ALIGN __alignof__(unsigned long)#define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT) -#define LOG_BUF_LEN_MAX (u32)(1 << 31) +#define LOG_BUF_LEN_MAX ((u32)1 << 31)static char __log_buf[__LOG_BUF_LEN]__aligned(LOG_ALIGN) ;static char *log_buf = __log_buf;static u32 log_buf_len = __LOG_BUF_LEN;
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 2/3 drm/sti: hdmi: use eld_mutex to protect access to connector->eld
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit e99c0b517bcd53cf61f998a3c4291333401cb391 ]
Reading access to connector->eld can happen at the same time the drm_edid_to_eld() updates the data. Take the newly added eld_mutex in order to protect connector->eld from concurrent access.
--- drivers/gpu/drm/sti/sti_hdmi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/sti/sti_hdmi.c +2 -0
@@ -1213,7 +1213,9 @@ static int hdmi_audio_get_eld(struct device *dev, void *data, uint8_t *buf, sizestruct drm_connector *connector = hdmi->drm_connector;DRM_DEBUG_DRIVER ("\n" ); +mutex_lock (&connector->eld_mutex);memcpy (buf, connector->eld,min (sizeof (connector->eld), len)); +mutex_unlock (&connector->eld_mutex);return 0 ; }
Signature · 1 line
2.39.5
Sasha Levin
maintainerPATCH 3/3 safesetid: check size of policy writes
In reply to Sasha LevinFrom: Leo Stone <[email protected]>
[ Upstream commit f09ff307c7299392f1c88f763299e24bc99811c7 ]
syzbot attempts to write a buffer with a large size to a sysfs entry with writes handled by handle_policy_update(), triggering a warning in kmalloc.
Check the size specified for write buffers before allocating.
--- security/safesetid/securityfs.c | 3 +++ 1 file changed, 3 insertions(+)
security/safesetid/securityfs.c +3 -0
@@ -143,6 +143,9 @@ static ssize_t handle_policy_update(struct file *file,char *buf, *p, *end;int err; +if (len >=KMALLOC_MAX_SIZE ) +return -EINVAL ; + pol =kmalloc (sizeof (struct setid_ruleset ),GFP_KERNEL );if (!pol)return -ENOMEM ;
Signature · 1 line
2.39.5