[lvc-project] [PATCH 6.1] efivars: Fix "BUG: corrupted list in efivar_entry_remove"

Fedor Pchelkin pchelkin at ispras.ru
Mon Feb 3 23:04:08 MSK 2025


On Mon, 03. Feb 15:03, Alexey Nepomnyashih wrote:
> Prevent list corruption in efivar_entry_remove() and efivar_entry_list_del_unlock() 
> by verifying that an entry is still in the list (list_empty() == false) before calling 
> list_del(). Also reset the list pointers with INIT_LIST_HEAD() to avoid potential double-removal issues. 
> Ensure robust handling of entries and prevent the kernel BUG observed when list_del() was called on an 
> already-removed entry.

Невероятно длинные строки выше. Дублировать фрагменты кода в описании
*не нужно*. Описание в основном нужно, чтобы понятным языком представить
исходную проблему и показать, зачем её требуется править патчем.

> Fix https://syzkaller.appspot.com/bug?extid=246ea4feed277471958a

Для этого существуют теги Reported-by и Closes.
https://www.kernel.org/doc/html/latest/process/submitting-patches.html#using-reported-by-tested-by-reviewed-by-suggested-by-and-fixes

> Reported-by: syzbot+75dc11... at syzkaller.appspotmail.com

Адрес выше неполный, если что.

> @@ -490,7 +490,10 @@ void __efivar_entry_add(struct efivar_entry *entry, struct list_head *head)
>   */
>  void efivar_entry_remove(struct efivar_entry *entry)
>  {
> -	list_del(&entry->list);
> +	if (!list_empty(&entry->list)) {
> +        list_del(&entry->list);
> +        INIT_LIST_HEAD(&entry->list);
> +	}
>  }
>  

Что-то поехало с извечными tabs/spaces.

Алексей, просьба предварительно отправлять патчи (в том числе бэкпорты)
только в список рассылки lvc-patches at linuxtesting.org. Не первый раз
одни и те же ошибки в подготовке патчей встречаются, к сожалению.

Из вывода scripts/checkpatch.pl, который рекомендуется прогонять поверх
патча перед отправкой:

WARNING: suspect code indent for conditional statements (8, 8)
#62: FILE: fs/efivarfs/vars.c:493:
+	if (!list_empty(&entry->list)) {
+        list_del(&entry->list);

ERROR: code indent should use tabs where possible
#63: FILE: fs/efivarfs/vars.c:494:
+        list_del(&entry->list);$

WARNING: please, no spaces at the start of a line
#63: FILE: fs/efivarfs/vars.c:494:
+        list_del(&entry->list);$

ERROR: code indent should use tabs where possible
#64: FILE: fs/efivarfs/vars.c:495:
+        INIT_LIST_HEAD(&entry->list);$

WARNING: please, no spaces at the start of a line
#64: FILE: fs/efivarfs/vars.c:495:
+        INIT_LIST_HEAD(&entry->list);$

WARNING: suspect code indent for conditional statements (8, 8)
#74: FILE: fs/efivarfs/vars.c:512:
+	if (!list_empty(&entry->list)) {
+        list_del(&entry->list);

ERROR: code indent should use tabs where possible
#75: FILE: fs/efivarfs/vars.c:513:
+        list_del(&entry->list);$

WARNING: please, no spaces at the start of a line
#75: FILE: fs/efivarfs/vars.c:513:
+        list_del(&entry->list);$

ERROR: code indent should use tabs where possible
#76: FILE: fs/efivarfs/vars.c:514:
+        INIT_LIST_HEAD(&entry->list);$

WARNING: please, no spaces at the start of a line
#76: FILE: fs/efivarfs/vars.c:514:
+        INIT_LIST_HEAD(&entry->list);$

WARNING: please, no spaces at the start of a line
#77: FILE: fs/efivarfs/vars.c:515:
+    }$

total: 4 errors, 7 warnings, 0 checks, 22 lines checked



More information about the lvc-project mailing list