lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <541BFB6D.3040903@nod.at>
Date:	Fri, 19 Sep 2014 11:46:21 +0200
From:	Richard Weinberger <richard@....at>
To:	dedekind1@...il.com
CC:	dwmw2@...radead.org, computersforpeace@...il.com,
	linux-mtd@...ts.infradead.org, linux-kernel@...r.kernel.org,
	stable@...r.kernel.org
Subject: Re: [PATCH] UBI: Fix possible deadlock in erase_worker()

Am 17.09.2014 11:35, schrieb Artem Bityutskiy:
> On Tue, 2014-09-16 at 09:48 +0200, Richard Weinberger wrote:
>> If sync_erase() failes with EINTR, ENOMEM, EAGAIN or
>> EBUSY erase_worker() re-schedules the failed work.
>> This will lead to a deadlock because erase_worker() is called
>> with work_sem held in read mode. And schedule_erase() will take
>> this lock again.
> 
> There is this code snippet:
> 
>         ubi_err("failed to erase PEB %d, error %d", pnum, err);
>         kfree(wl_wrk);
> 
>         if (err == -EINTR || err == -ENOMEM || err == -EAGAIN ||
>             err == -EBUSY) {
>                 int err1;
> 
>                 /* Re-schedule the LEB for erasure */
>                 err1 = schedule_erase(ubi, e, vol_id, lnum, 0);
>                 if (err1) {
>                         err = err1;
>                         goto out_ro;
>                 }
>                 return err;
>         }
> 
> How about move 'kfree(wl_wrk)' down, and execute
> 
>         __schedule_ubi_work(ubi, wl_wrk)
> 
> inside the 'if' clause instead? The fix would seem to be more elegant
> then.
> 
> Hmm?

Yes, that would work too.
Or we apply "[PATCH 1/2] UBI: Call worker functions without work_sem held". :)

Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ