diff mbox

aio: Check for aio_flags

Message ID 20170208023323.8962-1-rgoldwyn@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Goldwyn Rodrigues Feb. 8, 2017, 2:33 a.m. UTC
From: Goldwyn Rodrigues <rgoldwyn@suse.com>

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

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>

Comments

Christoph Hellwig Feb. 8, 2017, 7:59 a.m. UTC | #1
On Tue, Feb 07, 2017 at 08:33:23PM -0600, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> 
> 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.
Goldwyn Rodrigues Feb. 8, 2017, 11:19 a.m. UTC | #2
On 02/08/2017 01:59 AM, Christoph Hellwig wrote:
> On Tue, Feb 07, 2017 at 08:33:23PM -0600, Goldwyn Rodrigues wrote:
>> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
>>
>> 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 ;))
diff mbox

Patch

diff --git a/fs/aio.c b/fs/aio.c
index 428484f..f2dd175 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -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;