From: Jiri Pirko <jiri@resnulli.us>
To: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Cc: netdev@vger.kernel.org, vadim.fedorenko@linux.dev,
michal.michalik@intel.com, milena.olech@intel.com,
pabeni@redhat.com, kuba@kernel.org,
Jan Glaza <jan.glaza@intel.com>
Subject: Re: [PATCH net v2 4/4] dpll: hide "zombie" pins for userspace
Date: Thu, 4 Jan 2024 16:04:30 +0100 [thread overview]
Message-ID: <ZZbI_gsQuugrJ7X9@nanopsycho> (raw)
In-Reply-To: <20240104111132.42730-5-arkadiusz.kubalewski@intel.com>
Thu, Jan 04, 2024 at 12:11:32PM CET, arkadiusz.kubalewski@intel.com wrote:
>If parent pin was unregistered but child pin was not, the userspace
>would see the "zombie" pins - the ones that were registered with
>parent pin (pins_pin_on_pin_register(..)).
>Technically those are not available - as there is no dpll device in the
>system. Do not dump those pins and prevent userspace from any
>interaction with them.
Ah, here it is :)
>
>Fixes: 9431063ad323 ("dpll: core: Add DPLL framework base functions")
>Fixes: 9d71b54b65b1 ("dpll: netlink: Add DPLL framework base functions")
>Reviewed-by: Jan Glaza <jan.glaza@intel.com>
>Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
>---
> drivers/dpll/dpll_netlink.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
>
>diff --git a/drivers/dpll/dpll_netlink.c b/drivers/dpll/dpll_netlink.c
>index f266db8da2f0..495dfc43c0be 100644
>--- a/drivers/dpll/dpll_netlink.c
>+++ b/drivers/dpll/dpll_netlink.c
>@@ -949,6 +949,19 @@ dpll_pin_parent_pin_set(struct dpll_pin *pin, struct nlattr *parent_nest,
> return 0;
> }
>
>+static bool dpll_pin_parents_registered(struct dpll_pin *pin)
>+{
>+ struct dpll_pin_ref *par_ref;
>+ struct dpll_pin *p;
>+ unsigned long i, j;
>+
>+ xa_for_each(&pin->parent_refs, i, par_ref)
>+ xa_for_each_marked(&dpll_pin_xa, j, p, DPLL_REGISTERED)
>+ if (par_ref->pin == p)
>+ return true;
if (xa_get_mark(..))
return true;
?
>+ return false;
As I wrote in the reply to the other patch, could you unify the "hide"
behaviour for unregistered parent pin/device?
>+}
>+
> static int
> dpll_pin_set_from_nlattr(struct dpll_pin *pin, struct genl_info *info)
> {
>@@ -1153,6 +1166,9 @@ int dpll_nl_pin_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
>
> xa_for_each_marked_start(&dpll_pin_xa, i, pin, DPLL_REGISTERED,
> ctx->idx) {
>+ if (!xa_empty(&pin->parent_refs) &&
This empty check is redundant, remove it.
>+ !dpll_pin_parents_registered(pin))
>+ continue;
> hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid,
> cb->nlh->nlmsg_seq,
> &dpll_nl_family, NLM_F_MULTI,
>@@ -1179,6 +1195,10 @@ int dpll_nl_pin_set_doit(struct sk_buff *skb, struct genl_info *info)
> {
> struct dpll_pin *pin = info->user_ptr[0];
>
>+ if (!xa_empty(&pin->parent_refs) &&
This empty check is redundant, remove it.
>+ !dpll_pin_parents_registered(pin))
>+ return -ENODEV;
>+
> return dpll_pin_set_from_nlattr(pin, info);
> }
>
>--
>2.38.1
>
next prev parent reply other threads:[~2024-01-04 15:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-04 11:11 [PATCH net v2 0/4] dpll: fix unordered unbind/bind registerer issues Arkadiusz Kubalewski
2024-01-04 11:11 ` [PATCH net v2 1/4] dpll: fix pin dump crash after module unbind Arkadiusz Kubalewski
2024-01-04 15:08 ` Jiri Pirko
2024-01-11 9:06 ` Kubalewski, Arkadiusz
2024-01-04 11:11 ` [PATCH net v2 2/4] dpll: fix pin dump crash for rebound module Arkadiusz Kubalewski
2024-01-04 15:40 ` Jiri Pirko
2024-01-11 9:07 ` Kubalewski, Arkadiusz
2024-01-04 11:11 ` [PATCH net v2 3/4] dpll: fix register pin with unregistered parent pin Arkadiusz Kubalewski
2024-01-04 14:48 ` Jiri Pirko
2024-01-11 9:06 ` Kubalewski, Arkadiusz
2024-01-04 11:11 ` [PATCH net v2 4/4] dpll: hide "zombie" pins for userspace Arkadiusz Kubalewski
2024-01-04 15:04 ` Jiri Pirko [this message]
2024-01-11 9:16 ` Kubalewski, Arkadiusz
2024-01-04 15:07 ` Jiri Pirko
2024-01-11 9:16 ` Kubalewski, Arkadiusz
2024-01-04 15:09 ` Jiri Pirko
2024-01-11 9:16 ` Kubalewski, Arkadiusz
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=ZZbI_gsQuugrJ7X9@nanopsycho \
--to=jiri@resnulli.us \
--cc=arkadiusz.kubalewski@intel.com \
--cc=jan.glaza@intel.com \
--cc=kuba@kernel.org \
--cc=michal.michalik@intel.com \
--cc=milena.olech@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=vadim.fedorenko@linux.dev \
/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;
as well as URLs for NNTP newsgroup(s).