All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] watchdog: HACK: disable bind attributes with NOWAYOUT
@ 2018-08-28 10:29 Wolfram Sang
  2018-08-28 14:03 ` Guenter Roeck
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2018-08-28 10:29 UTC (permalink / raw)
  To: linux-watchdog; +Cc: linux-renesas-soc, Wolfram Sang, Wolfram Sang

With NOWAYOUT, prevent bind/unbind possibilities in SYSFS.
Proof-of-concept, not for upstream yet.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

So, this is really an RFC to check if something like this is considered useful
or not. If so, we probably need to do it differently because modifying the
parent's driver is likely a layering violation. We could add the driver to
modify as an optional parameter to watchdog_set_nowayout(). I wouldn't favor
another seperate function to configure this, but am open for discussion.

Thanks,

   Wolfram

 include/linux/watchdog.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
index 44985c4a1e86..241de0fa0010 100644
--- a/include/linux/watchdog.h
+++ b/include/linux/watchdog.h
@@ -143,8 +143,10 @@ static inline bool watchdog_hw_running(struct watchdog_device *wdd)
 /* Use the following function to set the nowayout feature */
 static inline void watchdog_set_nowayout(struct watchdog_device *wdd, bool nowayout)
 {
-	if (nowayout)
+	if (nowayout) {
 		set_bit(WDOG_NO_WAY_OUT, &wdd->status);
+		wdd->parent->driver->suppress_bind_attrs = true;
+	}
 }
 
 /* Use the following function to stop the watchdog on reboot */
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] watchdog: HACK: disable bind attributes with NOWAYOUT
  2018-08-28 10:29 [RFC PATCH] watchdog: HACK: disable bind attributes with NOWAYOUT Wolfram Sang
@ 2018-08-28 14:03 ` Guenter Roeck
  2018-08-28 14:18   ` Wolfram Sang
  0 siblings, 1 reply; 4+ messages in thread
From: Guenter Roeck @ 2018-08-28 14:03 UTC (permalink / raw)
  To: Wolfram Sang, linux-watchdog; +Cc: linux-renesas-soc, Wolfram Sang

On 08/28/2018 03:29 AM, Wolfram Sang wrote:
> With NOWAYOUT, prevent bind/unbind possibilities in SYSFS.
> Proof-of-concept, not for upstream yet.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> 
> So, this is really an RFC to check if something like this is considered useful
> or not. If so, we probably need to do it differently because modifying the
> parent's driver is likely a layering violation. We could add the driver to
> modify as an optional parameter to watchdog_set_nowayout(). I wouldn't favor
> another seperate function to configure this, but am open for discussion.
> 
> Thanks,
> 
>     Wolfram
> 
>   include/linux/watchdog.h | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
> index 44985c4a1e86..241de0fa0010 100644
> --- a/include/linux/watchdog.h
> +++ b/include/linux/watchdog.h
> @@ -143,8 +143,10 @@ static inline bool watchdog_hw_running(struct watchdog_device *wdd)
>   /* Use the following function to set the nowayout feature */
>   static inline void watchdog_set_nowayout(struct watchdog_device *wdd, bool nowayout)
>   {
> -	if (nowayout)
> +	if (nowayout) {
>   		set_bit(WDOG_NO_WAY_OUT, &wdd->status);
> +		wdd->parent->driver->suppress_bind_attrs = true;

That makes sense to me. We can not assume that wdd->parent is set, so it won't work as-is.
Not sure what a "correct" solution might be. Passing "parent" as argument doesn't really
solve any layering argument - stating that it violates layering if parent is pulled from
wdd but not if it is passed as argument seems to be a bit ridiculous.

Did you ensure that the attributes are not already created by the time
suppress_bind_attrs is set ?

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] watchdog: HACK: disable bind attributes with NOWAYOUT
  2018-08-28 14:03 ` Guenter Roeck
@ 2018-08-28 14:18   ` Wolfram Sang
  2018-08-28 16:37     ` Wolfram Sang
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2018-08-28 14:18 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: linux-watchdog, linux-renesas-soc, Wolfram Sang

[-- Attachment #1: Type: text/plain, Size: 887 bytes --]

Hi Guenter,

> > -	if (nowayout)
> > +	if (nowayout) {
> >   		set_bit(WDOG_NO_WAY_OUT, &wdd->status);
> > +		wdd->parent->driver->suppress_bind_attrs = true;
> 
> That makes sense to me. We can not assume that wdd->parent is set, so it won't work as-is.

Good point!

> Not sure what a "correct" solution might be. Passing "parent" as argument doesn't really
> solve any layering argument

I totally agree. I opted for passing a pointer to the driver to modify:

void watchdog_set_nowayout(struct watchdog_device *wdd, struct driver
			   *drv, bool nowayout)

I'd think this would work from a layering perspective.

> Did you ensure that the attributes are not already created by the time
> suppress_bind_attrs is set ?

Not yet. I first wanted to make sure if it makes sense, at all. But will
do for later versions.

Thanks for the review,

   Wolfram


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC PATCH] watchdog: HACK: disable bind attributes with NOWAYOUT
  2018-08-28 14:18   ` Wolfram Sang
@ 2018-08-28 16:37     ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2018-08-28 16:37 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: linux-watchdog, linux-renesas-soc, Wolfram Sang

[-- Attachment #1: Type: text/plain, Size: 312 bytes --]


> void watchdog_set_nowayout(struct watchdog_device *wdd, struct driver
> 			   *drv, bool nowayout)
> 
> I'd think this would work from a layering perspective.

No, this is also bogus. probe() works per device, and
.suppress_bind_attrs works per driver. We need to tackle this in the
init callback.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-28 17:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-28 10:29 [RFC PATCH] watchdog: HACK: disable bind attributes with NOWAYOUT Wolfram Sang
2018-08-28 14:03 ` Guenter Roeck
2018-08-28 14:18   ` Wolfram Sang
2018-08-28 16:37     ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.