lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3b175cb6-fcbe-4521-b6ac-442c8a11c297@moroto.mountain>
Date: Mon, 29 Jan 2024 08:20:26 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Erick Archer <erick.archer@....com>
Cc: Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>,
	Jeffrey Hugo <quic_jhugo@...cinc.com>,
	"Rafael J. Wysocki" <rafael@...nel.org>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	"Gustavo A. R. Silva" <gustavoars@...nel.org>,
	linux-arm-msm@...r.kernel.org, mhi@...ts.linux.dev,
	linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH] bus: mhi: ep: Use kcalloc() instead of kzalloc()

On Sun, Jan 28, 2024 at 11:29:33AM +0100, Erick Archer wrote:
> > It's a bit concerning that ->event_rings is set multiple times, but only
> > allocated one time.  It's either unnecessary or there is a potential
> > memory corruption bug.  If it's really necessary then there should be a
> > check that the new size is <= the size of the original buffer that we
> > allocated.
> 
> The ->event_rings is set twice. In the mhi_ep_mmio_init function and in
> the mhi_ep_mmio_update_ner function.
> 

It's not about the type.

The event_rings struct member is the number of elements in the
mhi_cntrl->mhi_event array.  However, we ->event_rings without
re-allocating mhi_cntrl->mhi_event so those are not in sync any more.
So since we don't know the number of elements in the mhi_cntrl->mhi_event
array leading to memory corruption.

> void mhi_ep_mmio_init(struct mhi_ep_cntrl *mhi_cntrl)
> {
> 	[...]
> 	mhi_cntrl->event_rings = FIELD_GET(MHICFG_NER_MASK, regval);
> 	[...]
> }
> 
> void mhi_ep_mmio_update_ner(struct mhi_ep_cntrl *mhi_cntrl)
> {
> 	[...]
> 	mhi_cntrl->event_rings = FIELD_GET(MHICFG_NER_MASK, regval);
> 	[...]
> }

These ->event_rings assignments look exactly the same.  It depends on
regval.  So possibly one could be deleted.

regards,
dan carpenter


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ