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] [day] [month] [year] [list]
Message-ID: <20210409100836.GB10447@redhat.com>
Date:   Fri, 9 Apr 2021 12:08:37 +0200
From:   Oleg Nesterov <oleg@...hat.com>
To:     Jens Axboe <axboe@...nel.dk>
Cc:     Peter Zijlstra <peterz@...radead.org>, linux-block@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] block: Fix sys_ioprio_set(.which=IOPRIO_WHO_PGRP) task
 iteration

On 04/08, Jens Axboe wrote:
>
> On 4/8/21 3:46 AM, Peter Zijlstra wrote:
> >
> > do_each_pid_thread() { } while_each_pid_thread() is a double loop and
> > thus break doesn't work as expected. Also, it should be used under
> > tasklist_lock because otherwise we can race against change_pid() for
> > PGID/SID.
>
> Applied, thanks.

Agreed, but can't resist. We can move the "out" label up and avoid the extra
read_unlock(tasklist_lock). IOW, something like below on top of this patch.

Quite possibly this won't change the generated code, gcc is smart enough, but
this makes the code a bit more readable.

Oleg.

--- x/block/ioprio.c~	2021-04-09 12:00:28.066145563 +0200
+++ x/block/ioprio.c	2021-04-09 12:02:01.817849618 +0200
@@ -123,11 +123,10 @@
 			read_lock(&tasklist_lock);
 			do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
 				ret = set_task_ioprio(p, ioprio);
-				if (ret) {
-					read_unlock(&tasklist_lock);
-					goto out;
-				}
+				if (ret)
+					goto out_pgrp;
 			} while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
+out_pgrp:
 			read_unlock(&tasklist_lock);
 
 			break;
@@ -159,7 +158,6 @@
 			ret = -EINVAL;
 	}
 
-out:
 	rcu_read_unlock();
 	return ret;
 }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ