bounds-fixes updates for v5.18-rc1
- Various buffer and array bounds related fixes -----BEGIN PGP SIGNATURE----- iQJKBAABCgA0FiEEpcP2jyKd1g9yPm4TiXL039xtwCYFAmI4nPQWHGtlZXNjb29r QGNocm9taXVtLm9yZwAKCRCJcvTf3G3AJi/gD/9UctJGcKAi28EVVcS11oLSxl97 LuIOJ4lWr8WUpCUqHcN65biUoODjshkIJRTx6Vxx9diLm3u6NO58+oJJCveKvE7w LtFjkbXBZ2sTxUoMZiva7qW8A6pYTfpiGq2lyUWVZRLOAMnNlCVuhcIonkzkR7js xdMZ2AmiQ0LJqT8paw4UUtSxGXGpLkcbuEoWHVWbqd3jgUbDwA4WR4xJw3ZUyh9i ONHOsfl/nFCNcLU69ppGJWPlXqNr5hHjjCeRzlcMfnwD/kxA7Qgt5TmpdEeAD4zx csNbvXbaW2Y+5IUWKXHT2Rt0rW1u+Zi5c+mtstTJf7XqK6slvTdLugY5TCtI6oXf x4qOMbqDjPbTr9Gpw3289WlqZYNJs1pGdeD4zL2HiOmwXq75GCNgxe0bv1hjnhNG b/bggAkpN/0n9r5BCQ32FWBg6S26VPOzg7//l6M38EBtQyakBVnS/064SP3aGTx4 8oCKmrNLQXyQz7mdskOA9hwyEkF1+hCX2kJFsoZ9iN0TDYKzzJYP8cBLzZe6bfPE dqsAc36W8FIHATfo7wrbTVABP61wJcHgocSLICRYmGQrSMTqREl9P+nDDEWl/wcc vKd1kyYhnskcz7GVdFtSDnpcHp6W/aiLwJUFCpAkgz2GBzrt1MtGxnFrXl6s8cc4 bSK/JClIBhMvBas4Tw== =gm8R -----END PGP SIGNATURE----- Merge tag 'bounds-fixes-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux Pull bounds fixes from Kees Cook: "These are a handful of buffer and array bounds fixes that I've been carrying in preparation for the coming memcpy improvements and the enabling of '-Warray-bounds' globally. There are additional similar fixes in other maintainer's trees, but these ended up getting carried by me. :)" * tag 'bounds-fixes-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: media: omap3isp: Use struct_group() for memcpy() region tpm: vtpm_proxy: Check length to avoid compiler warning alpha: Silence -Warray-bounds warnings m68k: cmpxchg: Dereference matching size intel_th: msu: Use memset_startat() for clearing hw header KVM: x86: Replace memset() "optimization" with normal per-field writes
This commit is contained in:
commit
8565d64430
|
@ -76,14 +76,14 @@ pgd_alloc(struct mm_struct *mm)
|
||||||
pmd_t *
|
pmd_t *
|
||||||
__bad_pagetable(void)
|
__bad_pagetable(void)
|
||||||
{
|
{
|
||||||
memset((void *) EMPTY_PGT, 0, PAGE_SIZE);
|
memset(absolute_pointer(EMPTY_PGT), 0, PAGE_SIZE);
|
||||||
return (pmd_t *) EMPTY_PGT;
|
return (pmd_t *) EMPTY_PGT;
|
||||||
}
|
}
|
||||||
|
|
||||||
pte_t
|
pte_t
|
||||||
__bad_page(void)
|
__bad_page(void)
|
||||||
{
|
{
|
||||||
memset((void *) EMPTY_PGE, 0, PAGE_SIZE);
|
memset(absolute_pointer(EMPTY_PGE), 0, PAGE_SIZE);
|
||||||
return pte_mkdirty(mk_pte(virt_to_page(EMPTY_PGE), PAGE_SHARED));
|
return pte_mkdirty(mk_pte(virt_to_page(EMPTY_PGE), PAGE_SHARED));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ void __init paging_init(void)
|
||||||
free_area_init(max_zone_pfn);
|
free_area_init(max_zone_pfn);
|
||||||
|
|
||||||
/* Initialize the kernel's ZERO_PGE. */
|
/* Initialize the kernel's ZERO_PGE. */
|
||||||
memset((void *)ZERO_PGE, 0, PAGE_SIZE);
|
memset(absolute_pointer(ZERO_PGE), 0, PAGE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_SRM)
|
#if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_SRM)
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
|
|
||||||
#include <linux/irqflags.h>
|
#include <linux/irqflags.h>
|
||||||
|
|
||||||
struct __xchg_dummy { unsigned long a[100]; };
|
#define __xg(type, x) ((volatile type *)(x))
|
||||||
#define __xg(x) ((volatile struct __xchg_dummy *)(x))
|
|
||||||
|
|
||||||
extern unsigned long __invalid_xchg_size(unsigned long, volatile void *, int);
|
extern unsigned long __invalid_xchg_size(unsigned long, volatile void *, int);
|
||||||
|
|
||||||
|
@ -50,7 +49,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
|
||||||
"1:\n\t"
|
"1:\n\t"
|
||||||
"casb %0,%1,%2\n\t"
|
"casb %0,%1,%2\n\t"
|
||||||
"jne 1b"
|
"jne 1b"
|
||||||
: "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");
|
: "=&d" (x) : "d" (x), "m" (*__xg(u8, ptr)) : "memory");
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
|
@ -58,7 +57,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
|
||||||
"1:\n\t"
|
"1:\n\t"
|
||||||
"casw %0,%1,%2\n\t"
|
"casw %0,%1,%2\n\t"
|
||||||
"jne 1b"
|
"jne 1b"
|
||||||
: "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");
|
: "=&d" (x) : "d" (x), "m" (*__xg(u16, ptr)) : "memory");
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
|
@ -66,7 +65,7 @@ static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int siz
|
||||||
"1:\n\t"
|
"1:\n\t"
|
||||||
"casl %0,%1,%2\n\t"
|
"casl %0,%1,%2\n\t"
|
||||||
"jne 1b"
|
"jne 1b"
|
||||||
: "=&d" (x) : "d" (x), "m" (*__xg(ptr)) : "memory");
|
: "=&d" (x) : "d" (x), "m" (*__xg(u32, ptr)) : "memory");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
x = __invalid_xchg_size(x, ptr, size);
|
x = __invalid_xchg_size(x, ptr, size);
|
||||||
|
|
|
@ -5395,8 +5395,13 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop)
|
||||||
|
|
||||||
void init_decode_cache(struct x86_emulate_ctxt *ctxt)
|
void init_decode_cache(struct x86_emulate_ctxt *ctxt)
|
||||||
{
|
{
|
||||||
memset(&ctxt->rip_relative, 0,
|
/* Clear fields that are set conditionally but read without a guard. */
|
||||||
(void *)&ctxt->modrm - (void *)&ctxt->rip_relative);
|
ctxt->rip_relative = false;
|
||||||
|
ctxt->rex_prefix = 0;
|
||||||
|
ctxt->lock_prefix = 0;
|
||||||
|
ctxt->rep_prefix = 0;
|
||||||
|
ctxt->regs_valid = 0;
|
||||||
|
ctxt->regs_dirty = 0;
|
||||||
|
|
||||||
ctxt->io_read.pos = 0;
|
ctxt->io_read.pos = 0;
|
||||||
ctxt->io_read.end = 0;
|
ctxt->io_read.end = 0;
|
||||||
|
|
|
@ -336,11 +336,7 @@ struct x86_emulate_ctxt {
|
||||||
fastop_t fop;
|
fastop_t fop;
|
||||||
};
|
};
|
||||||
int (*check_perm)(struct x86_emulate_ctxt *ctxt);
|
int (*check_perm)(struct x86_emulate_ctxt *ctxt);
|
||||||
/*
|
|
||||||
* The following six fields are cleared together,
|
|
||||||
* the rest are initialized unconditionally in x86_decode_insn
|
|
||||||
* or elsewhere
|
|
||||||
*/
|
|
||||||
bool rip_relative;
|
bool rip_relative;
|
||||||
u8 rex_prefix;
|
u8 rex_prefix;
|
||||||
u8 lock_prefix;
|
u8 lock_prefix;
|
||||||
|
|
|
@ -91,7 +91,7 @@ static ssize_t vtpm_proxy_fops_read(struct file *filp, char __user *buf,
|
||||||
|
|
||||||
len = proxy_dev->req_len;
|
len = proxy_dev->req_len;
|
||||||
|
|
||||||
if (count < len) {
|
if (count < len || len > sizeof(proxy_dev->buffer)) {
|
||||||
mutex_unlock(&proxy_dev->buf_lock);
|
mutex_unlock(&proxy_dev->buf_lock);
|
||||||
pr_debug("Invalid size in recv: count=%zd, req_len=%zd\n",
|
pr_debug("Invalid size in recv: count=%zd, req_len=%zd\n",
|
||||||
count, len);
|
count, len);
|
||||||
|
|
|
@ -658,13 +658,11 @@ static void msc_buffer_clear_hw_header(struct msc *msc)
|
||||||
|
|
||||||
list_for_each_entry(win, &msc->win_list, entry) {
|
list_for_each_entry(win, &msc->win_list, entry) {
|
||||||
unsigned int blk;
|
unsigned int blk;
|
||||||
size_t hw_sz = sizeof(struct msc_block_desc) -
|
|
||||||
offsetof(struct msc_block_desc, hw_tag);
|
|
||||||
|
|
||||||
for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) {
|
for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) {
|
||||||
struct msc_block_desc *bdesc = sg_virt(sg);
|
struct msc_block_desc *bdesc = sg_virt(sg);
|
||||||
|
|
||||||
memset(&bdesc->hw_tag, 0, hw_sz);
|
memset_startat(bdesc, 0, hw_tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -512,7 +512,7 @@ int omap3isp_stat_request_statistics(struct ispstat *stat,
|
||||||
int omap3isp_stat_request_statistics_time32(struct ispstat *stat,
|
int omap3isp_stat_request_statistics_time32(struct ispstat *stat,
|
||||||
struct omap3isp_stat_data_time32 *data)
|
struct omap3isp_stat_data_time32 *data)
|
||||||
{
|
{
|
||||||
struct omap3isp_stat_data data64;
|
struct omap3isp_stat_data data64 = { };
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = omap3isp_stat_request_statistics(stat, &data64);
|
ret = omap3isp_stat_request_statistics(stat, &data64);
|
||||||
|
@ -521,7 +521,8 @@ int omap3isp_stat_request_statistics_time32(struct ispstat *stat,
|
||||||
|
|
||||||
data->ts.tv_sec = data64.ts.tv_sec;
|
data->ts.tv_sec = data64.ts.tv_sec;
|
||||||
data->ts.tv_usec = data64.ts.tv_usec;
|
data->ts.tv_usec = data64.ts.tv_usec;
|
||||||
memcpy(&data->buf, &data64.buf, sizeof(*data) - sizeof(data->ts));
|
data->buf = (uintptr_t)data64.buf;
|
||||||
|
memcpy(&data->frame, &data64.frame, sizeof(data->frame));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,6 +162,7 @@ struct omap3isp_h3a_aewb_config {
|
||||||
* struct omap3isp_stat_data - Statistic data sent to or received from user
|
* struct omap3isp_stat_data - Statistic data sent to or received from user
|
||||||
* @ts: Timestamp of returned framestats.
|
* @ts: Timestamp of returned framestats.
|
||||||
* @buf: Pointer to pass to user.
|
* @buf: Pointer to pass to user.
|
||||||
|
* @buf_size: Size of buffer.
|
||||||
* @frame_number: Frame number of requested stats.
|
* @frame_number: Frame number of requested stats.
|
||||||
* @cur_frame: Current frame number being processed.
|
* @cur_frame: Current frame number being processed.
|
||||||
* @config_counter: Number of the configuration associated with the data.
|
* @config_counter: Number of the configuration associated with the data.
|
||||||
|
@ -176,10 +177,12 @@ struct omap3isp_stat_data {
|
||||||
struct timeval ts;
|
struct timeval ts;
|
||||||
#endif
|
#endif
|
||||||
void __user *buf;
|
void __user *buf;
|
||||||
__u32 buf_size;
|
__struct_group(/* no tag */, frame, /* no attrs */,
|
||||||
__u16 frame_number;
|
__u32 buf_size;
|
||||||
__u16 cur_frame;
|
__u16 frame_number;
|
||||||
__u16 config_counter;
|
__u16 cur_frame;
|
||||||
|
__u16 config_counter;
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
#ifdef __KERNEL__
|
||||||
|
@ -189,10 +192,12 @@ struct omap3isp_stat_data_time32 {
|
||||||
__s32 tv_usec;
|
__s32 tv_usec;
|
||||||
} ts;
|
} ts;
|
||||||
__u32 buf;
|
__u32 buf;
|
||||||
__u32 buf_size;
|
__struct_group(/* no tag */, frame, /* no attrs */,
|
||||||
__u16 frame_number;
|
__u32 buf_size;
|
||||||
__u16 cur_frame;
|
__u16 frame_number;
|
||||||
__u16 config_counter;
|
__u16 cur_frame;
|
||||||
|
__u16 config_counter;
|
||||||
|
);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue