From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Carpenter Date: Tue, 25 Aug 2020 18:53:24 +0000 Subject: Re: [PATCH 1/3] drm/amdgpu/si: Fix buffer overflow in si_get_register_value() Message-Id: <20200825185324.GW5493@kadam> List-Id: References: <20200825111843.GA285523@mwanda> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Alex Deucher Cc: Alex Jivin , Frederick Lawler , David Airlie , kernel-janitors@vger.kernel.org, amd-gfx list , Sonny Jiang , Bjorn Helgaas , Daniel Vetter , Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , Monk Liu , Hawking Zhang On Tue, Aug 25, 2020 at 11:53:25AM -0400, Alex Deucher wrote: > On Tue, Aug 25, 2020 at 7:21 AM Dan Carpenter wrote: > > > > The values for "se_num" and "sh_num" come from the user in the ioctl. > > They can be in the 0-255 range but if they're more than > > AMDGPU_GFX_MAX_SE (4) or AMDGPU_GFX_MAX_SH_PER_SE (2) then it results in > > an out of bounds read. > > > > I split this function into to two to make the error handling simpler. > > > > Fixes: dd5dfa61b4ff ("drm/amdgpu: refine si_read_register") > > Signed-off-by: Dan Carpenter > > Good catch. This is more defensive, but It's a much simpler check to > validate these in the caller. See the attached patch. > That works too. Acked-by: Dan Carpenter regards, dan carpenter