public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Tvrtko Ursulin <tursulin@ursulin.net>
Cc: "Jani Nikula" <jani.nikula@linux.intel.com>,
	"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
	"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Matt Roper" <matthew.d.roper@intel.com>,
	"Gustavo Sousa" <gustavo.sousa@intel.com>,
	"Andi Shyti" <andi.shyti@linux.intel.com>,
	"Lucas De Marchi" <lucas.demarchi@intel.com>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	"Gnattu OC" <gnattuoc@me.com>,
	"Nitin Gote" <nitin.r.gote@intel.com>,
	"Ranu Maurya" <ranu.maurya@intel.com>,
	"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
	"Angus Chen" <angus.chen@intel.com>,
	"Juha-Pekka Heikkila" <juhapekka.heikkila@gmail.com>,
	"Yu Jiaoliang" <yujiaoliang@vivo.com>,
	"Dnyaneshwar Bhadane" <dnyaneshwar.bhadane@intel.com>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] drm/i915/gt: Remove const from struct i915_wa list allocation
Date: Wed, 30 Apr 2025 13:56:04 -0700	[thread overview]
Message-ID: <202504301345.659CB6B@keescook> (raw)
In-Reply-To: <7f1ad610-5a37-4f74-8eee-5f37556d9576@ursulin.net>

On Mon, Apr 28, 2025 at 01:09:46PM +0100, Tvrtko Ursulin wrote:
> 
> On 26/04/2025 07:13, Kees Cook wrote:
> > In preparation for making the kmalloc family of allocators type aware,
> > we need to make sure that the returned type from the allocation matches
> > the type of the variable being assigned. (Before, the allocator would
> > always return "void *", which can be implicitly cast to any pointer type.)
> > 
> > The assigned type is "struct i915_wa *". The returned type, while
> > technically matching, will be const qualified. As there is no general
> > way to remove const qualifiers, adjust the allocation type to match
> > the assignment.
> > 
> > Signed-off-by: Kees Cook <kees@kernel.org>
> > ---
> > Cc: Jani Nikula <jani.nikula@linux.intel.com>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > Cc: Tvrtko Ursulin <tursulin@ursulin.net>
> > Cc: David Airlie <airlied@gmail.com>
> > Cc: Simona Vetter <simona@ffwll.ch>
> > Cc: Matt Roper <matthew.d.roper@intel.com>
> > Cc: Gustavo Sousa <gustavo.sousa@intel.com>
> > Cc: Andi Shyti <andi.shyti@linux.intel.com>
> > Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> > Cc: <intel-gfx@lists.freedesktop.org>
> > Cc: <dri-devel@lists.freedesktop.org>
> > ---
> >   drivers/gpu/drm/i915/gt/intel_workarounds.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c b/drivers/gpu/drm/i915/gt/intel_workarounds.c
> > index 116683ebe074..b37e400f74e5 100644
> > --- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
> > +++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
> > @@ -156,7 +156,7 @@ static void _wa_add(struct i915_wa_list *wal, const struct i915_wa *wa)
> >   	if (IS_ALIGNED(wal->count, grow)) { /* Either uninitialized or full. */
> >   		struct i915_wa *list;
> > -		list = kmalloc_array(ALIGN(wal->count + 1, grow), sizeof(*wa),
> > +		list = kmalloc_array(ALIGN(wal->count + 1, grow), sizeof(*list),
> 
> Will the sizeof stay, and if so, how will kmalloc be able to distinguish the
> type? Or we expect one more churn on the same line?

It is expected that when (if?) this happens, there will be a pre-rc1
treewide change to convert kmalloc to kmalloc_obj[1]. (So, yes, this
call would change, but it'll happen separately.)

-Kees

[1] Here's what v4 looked like:
    https://lore.kernel.org/lkml/20250315025852.it.568-kees@kernel.org/
    v5 is still under development, but will look like this:
    https://web.git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/log/?h=dev/v6.15-rc3%2b/alloc_obj/v5

-- 
Kees Cook

  reply	other threads:[~2025-04-30 20:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-26  6:13 [PATCH] drm/i915/gt: Remove const from struct i915_wa list allocation Kees Cook
2025-04-28 11:40 ` Jani Nikula
2025-04-30 20:56   ` Kees Cook
2025-05-07 13:05     ` Andi Shyti
2025-04-28 12:09 ` Tvrtko Ursulin
2025-04-30 20:56   ` Kees Cook [this message]
2025-05-07 15:50 ` Andi Shyti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202504301345.659CB6B@keescook \
    --to=kees@kernel.org \
    --cc=airlied@gmail.com \
    --cc=andi.shyti@linux.intel.com \
    --cc=angus.chen@intel.com \
    --cc=dnyaneshwar.bhadane@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gnattuoc@me.com \
    --cc=gustavo.sousa@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=juhapekka.heikkila@gmail.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.demarchi@intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=nitin.r.gote@intel.com \
    --cc=ranu.maurya@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=simona@ffwll.ch \
    --cc=tursulin@ursulin.net \
    --cc=ville.syrjala@linux.intel.com \
    --cc=yujiaoliang@vivo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox