From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 498C73264CA for ; Mon, 4 May 2026 08:22:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777882950; cv=none; b=Ii/gYo96Mzcp6/5iDMLzOneuBqol90ukiOGUNTe2HN1XKxBCQ6MdZ4L4M+V5jHmPVHqeaeOtzD/BpU+Lg3wwTjQk1bk1krIXw0g4kD3fHEH7/6Okxk14r8e/+mEtVQ+frmvQtPHZC4iHmuKqz7WNGKii04HY0CwyrixKAu9Wx5A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777882950; c=relaxed/simple; bh=ZIQDkX/cvyL0xNjSSic8qAT8zD4NaIC2T3Yp1s4yTic=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dkwTIn+v7sklCVx3uMVV1Exj2rxuckXzf6Qj4VAAIVi+ml/oFLotobhgu1ckv9OYV5ocDgy7xd8uwZka7/+NguP46wyox6jKa3+smUXnJzJVNQsPLSEKRwKQ0hORJ8yzdK1ID7rxBY+aT5lg8ia/XtV0Px+5hFGCAGOjFISSEoY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=TI84OB9a; arc=none smtp.client-ip=192.198.163.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="TI84OB9a" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1777882949; x=1809418949; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=ZIQDkX/cvyL0xNjSSic8qAT8zD4NaIC2T3Yp1s4yTic=; b=TI84OB9aTg+BfEoKpPCi9/j3Zy5YE8Yzg6VH9yg/SIHKZwm+jspU/y8Z xIMNYUeEWc9SIueF04gtFasrVfxhu5INKjkWaD7jdyu/YWSqQ8livZdW6 Y2RM1wILFWpA/po8a+LGtYf8rvRHJQzgzrYCUK8M+xF4EmR27FXKL0krH 2TXPVdrIXKi4VVFG+ZdW0dGqxFr5CP6KvPEj1Phh4K/19Dmy4XZe9C6RZ DMPvmZ9QLErqDnG8wtN4iwfNKOAYg3fw9H7csHUMfy1z/EEpceqENuF11 zfBZ6Xm6Z01S6i/1IpmUhwY39dnCKymYdEJyNCtVifj7u9TLygZlXy1v4 g==; X-CSE-ConnectionGUID: Z1QtbYVzSpKqYdiT3lRXGw== X-CSE-MsgGUID: XJVzYvsOQ+io+u4fhRQf1w== X-IronPort-AV: E=McAfee;i="6800,10657,11775"; a="66267912" X-IronPort-AV: E=Sophos;i="6.23,215,1770624000"; d="scan'208";a="66267912" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2026 01:22:28 -0700 X-CSE-ConnectionGUID: IeblzqfFSCaWSKGT56oHgA== X-CSE-MsgGUID: wp0kBrMXSH+Yc1eYFiHnRg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,215,1770624000"; d="scan'208";a="235515020" Received: from fpallare-mobl4.ger.corp.intel.com (HELO kekkonen.fi.intel.com) ([10.245.245.114]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2026 01:22:25 -0700 Received: from kekkonen.localdomain (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with SMTP id 23E5F121CC4; Mon, 04 May 2026 11:22:24 +0300 (EEST) Date: Mon, 4 May 2026 11:22:24 +0300 Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo From: Sakari Ailus To: Ricardo Ribalda Cc: Mauro Carvalho Chehab , Laurent Pinchart , Hans Verkuil , Nas Chung , Jackson Lee , Bingbu Cao , Tianshu Qiu , Greg Kroah-Hartman , Keke Li , Yong Zhi , Jacopo Mondi , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Mauro Carvalho Chehab , stable@vger.kernel.org Subject: Re: [PATCH v2 5/6] media: staging: ipu3-imgu: Add range check for imgu_css_cfg_acc_stripe Message-ID: References: <20260501-smatch-7-1-v2-0-a2fcfb2531ac@chromium.org> <20260501-smatch-7-1-v2-5-a2fcfb2531ac@chromium.org> Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260501-smatch-7-1-v2-5-a2fcfb2531ac@chromium.org> Hi Ricardo, On Fri, May 01, 2026 at 11:32:50AM +0000, Ricardo Ribalda wrote: > If the driver's stripe information is invalid it can result in an integer > overflow. Add a range check with a WARN_ON to expose this kind of > error. This would be an underflow, not overflow. There's also no longer a WARN_ON() here. I presume this might not be the only such issue in the driver. > > This patch fixes the following smatch error: > drivers/staging/media/ipu3/ipu3-css-params.c:1792 imgu_css_cfg_acc_stripe() warn: 'acc->stripe.bds_out_stripes[0]->width - 2 * f' 4294967168 can't fit into 65535 'acc->stripe.bds_out_stripes[1]->offset' > > Cc: stable@vger.kernel.org > Fixes: e11110a5b744 ("media: staging/intel-ipu3: css: Compute and program ccs") > Signed-off-by: Ricardo Ribalda > --- > drivers/staging/media/ipu3/ipu3-css-params.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/staging/media/ipu3/ipu3-css-params.c b/drivers/staging/media/ipu3/ipu3-css-params.c > index 2c48d57a3180..92cce31e35c5 100644 > --- a/drivers/staging/media/ipu3/ipu3-css-params.c > +++ b/drivers/staging/media/ipu3/ipu3-css-params.c > @@ -1770,6 +1770,8 @@ static int imgu_css_cfg_acc_stripe(struct imgu_css *css, unsigned int pipe, > acc->stripe.bds_out_stripes[0].width = > ALIGN(css_pipe->rect[IPU3_CSS_RECT_BDS].width, f); > } else { > + u32 offset; > + > /* Image processing is divided into two stripes */ > acc->stripe.bds_out_stripes[0].width = > acc->stripe.bds_out_stripes[1].width = > @@ -1788,8 +1790,10 @@ static int imgu_css_cfg_acc_stripe(struct imgu_css *css, unsigned int pipe, > acc->stripe.bds_out_stripes[1].width += f; > } > /* Overlap between stripes is IPU3_UAPI_ISP_VEC_ELEMS * 4 */ > - acc->stripe.bds_out_stripes[1].offset = > - acc->stripe.bds_out_stripes[0].width - 2 * f; > + offset = acc->stripe.bds_out_stripes[0].width - 2 * f; > + if (offset > 65535) > + return -EINVAL; > + acc->stripe.bds_out_stripes[1].offset = offset; > } > > acc->stripe.effective_stripes[0].height = > -- Regards, Sakari Ailus