From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29DCDC07E9D for ; Mon, 26 Sep 2022 06:28:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233118AbiIZG2I (ORCPT ); Mon, 26 Sep 2022 02:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232425AbiIZG2E (ORCPT ); Mon, 26 Sep 2022 02:28:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F29F2A412 for ; Sun, 25 Sep 2022 23:28:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9B9646130C for ; Mon, 26 Sep 2022 06:28:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A321C433C1; Mon, 26 Sep 2022 06:28:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664173681; bh=ptYX6gxJIY6o/kOvZ/NjABrmXfLMiQBEo81RVFYP6GY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=2gXQUcJI2f9juQrMCU9ah5+1fxQkglnQES07bZzvXNpfNPPAjifEvOtFbxBaX5WLK UYScN/r1q9aHBjF1zoJk1JzWw5J+DApHscqFppB2RWActM1i/PG739washyqFxTXnA yeIy8wqHUHLOHuPHpa3TuMzlTBFI8Pnnguh5zyeE= Date: Mon, 26 Sep 2022 08:27:58 +0200 From: Greg KH To: Duoming Zhou Cc: johannes@sipsolutions.net, linux-kernel@vger.kernel.org, rafael@kernel.org Subject: Re: [PATCH V9] devcoredump: add context check in dev_coredumpm Message-ID: References: <20220926061609.44153-1-duoming@zju.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220926061609.44153-1-duoming@zju.edu.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 26, 2022 at 02:16:09PM +0800, Duoming Zhou wrote: > The dev_coredumpm(), dev_coredumpv() and dev_coredumpsg() could not > be used in atomic context, because they call kvasprintf_const() and > kstrdup() with GFP_KERNEL parameter. The process is shown below: > > dev_coredumpv(.., gfp_t gfp) > dev_coredumpm(.., gfp_t gfp) > dev_set_name > kobject_set_name_vargs > kvasprintf_const(GFP_KERNEL, ...); //may sleep > kstrdup(s, GFP_KERNEL); //may sleep > > This patch adds context check in dev_coredumpm() in order to show > dev_coredumpm() and its callers could not be used in atomic context. > > What's more, this change can allow the api to evolve and will not > influence the users that call this api. > > Fixes: 833c95456a70 ("device coredump: add new device coredump class") > Signed-off-by: Duoming Zhou > --- > Changes in v9: > - Add context check in dev_coredumpm(). > > drivers/base/devcoredump.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/base/devcoredump.c b/drivers/base/devcoredump.c > index f4d794d6bb8..806ee872f5f 100644 > --- a/drivers/base/devcoredump.c > +++ b/drivers/base/devcoredump.c > @@ -255,6 +255,9 @@ void dev_coredumpm(struct device *dev, struct module *owner, > struct devcd_entry *devcd; > struct device *existing; > > + if (!gfpflags_normal_context(gfp)) > + goto free; Wait, this just broke things for no good reason if a caller happened to have set a GFP flag that we do not like at the moment. What code now does not work that previously did work with this change? thanks, greg k-h