Skip to contentSkip to conversation

aio: Check for aio_flags

PATCH In review Goldwyn Rodrigues 2 participants 3 messages Feb 8, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aio: Check for aio_flags

From: Goldwyn Rodrigues <[email protected]>

aio_flags are not checked when performing io_submit() and can contain non-conforming values.
Return -EINVAL if they are invalid.

fs/aio.c +5 -0
index 428484f..f2dd175 100644
@@ -1521,6 +1521,11 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
 		return -EINVAL;
 	}
 
+	if (unlikely(iocb->aio_flags & ~IOCB_FLAG_RESFD)) {
+		pr_debug("EINVAL: incorrect flags\n");
+		return -EINVAL;
+	}
+
 	req = aio_get_req(ctx);
 	if (unlikely(!req))
 		return -EAGAIN;
#1 lore raw
Quoted 5 lines · Goldwyn Rodrigues

From: Goldwyn Rodrigues <[email protected]>

aio_flags are not checked when performing io_submit() and can contain non-conforming values.
Return -EINVAL if they are invalid.

while this is what we should have done from the start it could break existing userspace programs now.

#2 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 5 lines · Goldwyn Rodrigues

From: Goldwyn Rodrigues <[email protected]>

aio_flags are not checked when performing io_submit() and can contain non-conforming values.
Return -EINVAL if they are invalid.

while this is what we should have done from the start it could break existing userspace programs now.

Yes, I agree. it would be the one's who are using it incorrectly and have been certified to work. However, I did run it through LTP and it passed the tests (I understand it does not represent all of userspace programs). We would need to correct behavior at some point in time hoping not many depend on it.

Besides, this would also restrict expansion of aio_flags, which I intend to do... (yeah, you see my ulterior motive now ;))

Signature · 1 line
Goldwyn