All of lore.kernel.org
 help / color / mirror / Atom feed
* [linux-lvm] [PATCH 0/3] Make udev rules more robust
@ 2022-04-04 21:51 Demi Marie Obenour
  2022-04-04 21:56 ` [linux-lvm] [PATCH 3/3] Disable udev rules if udev flags can't be obtained Demi Marie Obenour
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Demi Marie Obenour @ 2022-04-04 21:51 UTC (permalink / raw)
  To: LVM general discussion and development; +Cc: Marek Marczykowski-Górecki


[-- Attachment #1.1: Type: text/plain, Size: 496 bytes --]

This makes the udev rules more robust against various unsafe error
conditions.

Demi Marie Obenour (3):
  dmsetup: return non-zero on stdio I/O error
  Disable lvm2 udev rules if `dmsetup splitname` fails
  Disable udev rules if udev flags can't be obtained

 libdm/dm-tools/dmsetup.c | 2 ++
 udev/10-dm.rules.in      | 2 +-
 udev/11-dm-lvm.rules.in  | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab

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

[-- Attachment #2: Type: text/plain, Size: 202 bytes --]

_______________________________________________
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

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

* [linux-lvm] [PATCH 3/3] Disable udev rules if udev flags can't be obtained
  2022-04-04 21:51 [linux-lvm] [PATCH 0/3] Make udev rules more robust Demi Marie Obenour
@ 2022-04-04 21:56 ` Demi Marie Obenour
  2022-04-04 21:58 ` [linux-lvm] [PATCH 1/3] dmsetup: return non-zero on stdio I/O error Demi Marie Obenour
  2022-04-04 22:02 ` [linux-lvm] [PATCH 2/3] Disable lvm2 udev rules if `dmsetup splitname` fails Demi Marie Obenour
  2 siblings, 0 replies; 4+ messages in thread
From: Demi Marie Obenour @ 2022-04-04 21:56 UTC (permalink / raw)
  To: LVM general discussion and development; +Cc: Marek Marczykowski-Górecki


[-- Attachment #1.1: Type: text/plain, Size: 918 bytes --]

In this cased the safest option is to disable most udev rules.
---
 udev/10-dm.rules.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/udev/10-dm.rules.in b/udev/10-dm.rules.in
index b4fa52a..9fae8df 100644
--- a/udev/10-dm.rules.in
+++ b/udev/10-dm.rules.in
@@ -50,7 +50,7 @@ ACTION!="add|change", GOTO="dm_end"
 # These flags are encoded in DM_COOKIE variable that was introduced in
 # kernel version 2.6.31. Therefore, we can use this feature with
 # kernels >= 2.6.31 only. Cookie is not decoded for remove event.
-ENV{DM_COOKIE}=="?*", IMPORT{program}="(DM_EXEC)/dmsetup udevflags $env{DM_COOKIE}"
+ENV{DM_COOKIE}=="?*", IMPORT{program}!="(DM_EXEC)/dmsetup udevflags $env{DM_COOKIE}", GOTO="dm_disable"
 
 # Rule out easy-to-detect inappropriate events first.
 ENV{DISK_RO}=="1", GOTO="dm_disable"
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab


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

[-- Attachment #2: Type: text/plain, Size: 202 bytes --]

_______________________________________________
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

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

* [linux-lvm] [PATCH 1/3] dmsetup: return non-zero on stdio I/O error
  2022-04-04 21:51 [linux-lvm] [PATCH 0/3] Make udev rules more robust Demi Marie Obenour
  2022-04-04 21:56 ` [linux-lvm] [PATCH 3/3] Disable udev rules if udev flags can't be obtained Demi Marie Obenour
@ 2022-04-04 21:58 ` Demi Marie Obenour
  2022-04-04 22:02 ` [linux-lvm] [PATCH 2/3] Disable lvm2 udev rules if `dmsetup splitname` fails Demi Marie Obenour
  2 siblings, 0 replies; 4+ messages in thread
From: Demi Marie Obenour @ 2022-04-04 21:58 UTC (permalink / raw)
  To: LVM general discussion and development; +Cc: Marek Marczykowski-Górecki


[-- Attachment #1.1: Type: text/plain, Size: 740 bytes --]

If there is an I/O error on stdout, return a non-zero status so that
udev can avoid trusting the values printed.  Deeper changes to the
log code are out of scope for this patch.
---
 libdm/dm-tools/dmsetup.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index d01b8f2..0449e40 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -7491,5 +7491,7 @@ out:
 	if (_initial_timestamp)
 		dm_timestamp_destroy(_initial_timestamp);
 
+        if (fflush(stdout) || ferror(stdout))
+            return 1;
 	return (_switches[HELP_ARG] || _switches[VERSION_ARG]) ? 0 : ret;
 }
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab

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

[-- Attachment #2: Type: text/plain, Size: 202 bytes --]

_______________________________________________
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

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

* [linux-lvm] [PATCH 2/3] Disable lvm2 udev rules if `dmsetup splitname` fails
  2022-04-04 21:51 [linux-lvm] [PATCH 0/3] Make udev rules more robust Demi Marie Obenour
  2022-04-04 21:56 ` [linux-lvm] [PATCH 3/3] Disable udev rules if udev flags can't be obtained Demi Marie Obenour
  2022-04-04 21:58 ` [linux-lvm] [PATCH 1/3] dmsetup: return non-zero on stdio I/O error Demi Marie Obenour
@ 2022-04-04 22:02 ` Demi Marie Obenour
  2 siblings, 0 replies; 4+ messages in thread
From: Demi Marie Obenour @ 2022-04-04 22:02 UTC (permalink / raw)
  To: LVM general discussion and development; +Cc: Marek Marczykowski-Górecki


[-- Attachment #1.1: Type: text/plain, Size: 967 bytes --]

If the output of `dmsetup splitname` cannot be trusted, the safest
option is to disable all lvm2 rules.
---
 udev/11-dm-lvm.rules.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/udev/11-dm-lvm.rules.in b/udev/11-dm-lvm.rules.in
index 7c58994..f7066b7 100644
--- a/udev/11-dm-lvm.rules.in
+++ b/udev/11-dm-lvm.rules.in
@@ -18,7 +18,7 @@ ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="lvm_end"
 ENV{DM_UUID}!="LVM-?*", GOTO="lvm_end"
 
 # Use DM name and split it up into its VG/LV/layer constituents.
-IMPORT{program}="(DM_EXEC)/dmsetup splitname --nameprefixes --noheadings --rows $env{DM_NAME}"
+IMPORT{program}!="(DM_EXEC)/dmsetup splitname --nameprefixes --noheadings --rows $env{DM_NAME}", GOTO="lvm_disable"
 
 # DM_SUBSYSTEM_UDEV_FLAG0 is the 'NOSCAN' flag for LVM subsystem.
 # This flag is used to temporarily disable selected rules to prevent any
-- 
Sincerely,
Demi Marie Obenour (she/her/hers)
Invisible Things Lab




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

[-- Attachment #2: Type: text/plain, Size: 202 bytes --]

_______________________________________________
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

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

end of thread, other threads:[~2022-04-04 22:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-04 21:51 [linux-lvm] [PATCH 0/3] Make udev rules more robust Demi Marie Obenour
2022-04-04 21:56 ` [linux-lvm] [PATCH 3/3] Disable udev rules if udev flags can't be obtained Demi Marie Obenour
2022-04-04 21:58 ` [linux-lvm] [PATCH 1/3] dmsetup: return non-zero on stdio I/O error Demi Marie Obenour
2022-04-04 22:02 ` [linux-lvm] [PATCH 2/3] Disable lvm2 udev rules if `dmsetup splitname` fails Demi Marie Obenour

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.