mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Tejun Heo <tj@kernel.org>, Lai Jiangshan <jiangshanlai@gmail.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] workqueue: fix null-ptr-deref on __alloc_workqueue() error
Date: Thu, 15 Aug 2024 15:56:39 +0000	[thread overview]
Message-ID: <Zr4lN63t25Og5/0G@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <20240815072427.GC12106@google.com>

On Thu, Aug 15, 2024 at 04:24:27PM +0900, Sergey Senozhatsky wrote:
> On (24/08/15 16:09), Sergey Senozhatsky wrote:
> > On (24/08/15 16:02), Sergey Senozhatsky wrote:
> > Oh, okay, so this is related to [1]
> > 
> > 	workqueue: Split alloc_workqueue into internal function and lockdep init
> > 
> > Cc-ing Matthew on this.
> > 
> > [1] https://lore.kernel.org/all/20240809222827.3211998-2-matthew.brost@intel.com/
> 
> Matthew, did you mean to do something like below instead?
> Otherwise it breaks boot for me.
> 

Yikes, my bad. My change worked locally and in Intel's CI for Xe [2]. So
I did not realize this was an issue the way I had it coded. 

I believe you when you say this is an issue.

With that, the way I coded alloc_ordered_workqueue_lockdep_map could
also be dangerous. Thinking that also should also be changed back to a
macro too.

Let's see what Tejon thinks?

Matt

[2] https://patchwork.freedesktop.org/series/136701/ 

> ---
> 
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 7a2f4cbbe8b2..55e0e69ee604 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -5615,12 +5615,11 @@ static void wq_adjust_max_active(struct workqueue_struct *wq)
>  	} while (activated);
>  }
>  
> -__printf(1, 4)
>  static struct workqueue_struct *__alloc_workqueue(const char *fmt,
>  						  unsigned int flags,
> -						  int max_active, ...)
> +						  int max_active,
> +						  va_list args)
>  {
> -	va_list args;
>  	struct workqueue_struct *wq;
>  	size_t wq_size;
>  	int name_len;
> @@ -5652,9 +5651,7 @@ static struct workqueue_struct *__alloc_workqueue(const char *fmt,
>  			goto err_free_wq;
>  	}
>  
> -	va_start(args, max_active);
>  	name_len = vsnprintf(wq->name, sizeof(wq->name), fmt, args);
> -	va_end(args);
>  
>  	if (name_len >= WQ_NAME_LEN)
>  		pr_warn_once("workqueue: name exceeds WQ_NAME_LEN. Truncating to: %s\n",

  reply	other threads:[~2024-08-15 15:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-15  7:02 Sergey Senozhatsky
2024-08-15  7:09 ` Sergey Senozhatsky
2024-08-15  7:24   ` Sergey Senozhatsky
2024-08-15 15:56     ` Matthew Brost [this message]
2024-08-15 16:24       ` Matthew Brost
2024-08-16  2:38         ` Sergey Senozhatsky
2024-08-16  2:45           ` Matthew Brost
2024-08-16  2:52             ` Sergey Senozhatsky
2024-08-19 21:15             ` Tejun Heo
2024-08-19 23:57               ` Matthew Brost
2024-08-20 23:54               ` Sergey Senozhatsky
2024-08-20 23:56                 ` Matthew Brost
2024-08-21  0:07                   ` Sergey Senozhatsky
2024-08-21  0:04                 ` Tejun Heo
2024-08-21  0:09                   ` Sergey Senozhatsky
2024-08-21 16:14 ` Tejun Heo

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=Zr4lN63t25Og5/0G@DUT025-TGLU.fm.intel.com \
    --to=matthew.brost@intel.com \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=senozhatsky@chromium.org \
    --cc=tj@kernel.org \
    /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

all inboxes | Powered by JetHome®