Skip to contentSkip to conversation

aio: add timeout validity check for io_[p]getevents

PATCH Superseded zhangyi (F) 3 participants 7 messages Jul 25, 2019 – Mar 9, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aio: add timeout validity check for io_[p]getevents

io_[p]getevents syscall should return -EINVAL if if timeout is out of range, add this validity check.

---
 fs/aio.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
fs/aio.c +9 -2
index 01e0fb9..dd967a0 100644
@@ -2031,10 +2031,17 @@ static long do_io_getevents(aio_context_t ctx_id,
 		struct io_event __user *events,
 		struct timespec64 *ts)
 {
-	ktime_t until = ts ? timespec64_to_ktime(*ts) : KTIME_MAX;
-	struct kioctx *ioctx = lookup_ioctx(ctx_id);
+	ktime_t until = KTIME_MAX;
+	struct kioctx *ioctx = NULL;
 	long ret = -EINVAL;
 
+	if (ts) {
+		if (!timespec64_valid(ts))
+			return ret;
+		until = timespec64_to_ktime(*ts);
+	}
+
+	ioctx = lookup_ioctx(ctx_id);
 	if (likely(ioctx)) {
 		if (likely(min_nr <= nr && min_nr >= 0))
 			ret = read_events(ioctx, min_nr, nr, events, until);
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · zhangyi (F)

io_[p]getevents syscall should return -EINVAL if if timeout is out of range, add this validity check.

---
 fs/aio.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
fs/aio.c +2 -2
index 01e0fb9..dd967a0 100644
@@ -2031,10 +2031,17 @@ static long do_io_getevents(aio_context_t ctx_id,
 		struct io_event __user *events,
 		struct timespec64 *ts)
 {
-	ktime_t until = ts ? timespec64_to_ktime(*ts) : KTIME_MAX;
-	struct kioctx *ioctx = lookup_ioctx(ctx_id);
+	ktime_t until = KTIME_MAX;
+	struct kioctx *ioctx = NULL;
 	long ret = -EINVAL;
 

fs/aio.c static long do_io_getevents(aio_context_t ctx_id, · line 2047

Quoted 10 lines
fs/aio.c +7 -0
+	if (ts) {
+		if (!timespec64_valid(ts))
+			return ret;
+		until = timespec64_to_ktime(*ts);
+	}
+
+	ioctx = lookup_ioctx(ctx_id);
 	if (likely(ioctx)) {
 		if (likely(min_nr <= nr && min_nr >= 0))
 			ret = read_events(ioctx, min_nr, nr, events, until);

The previous suggestion[1] of fixing the helpers never materialized, so let's just get this fixed, already.

-Jeff

[1] https://marc.info/?l=linux-fsdevel&m=152209450618587&w=2

#2 lore raw

Al, can you take this through your tree?

Thanks,
Jeff

Quoted 49 lines · Jeff Moyer
Quoted 22 lines · zhangyi (F)

io_[p]getevents syscall should return -EINVAL if if timeout is out of range, add this validity check.

---
 fs/aio.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
fs/aio.c +2 -2
index 01e0fb9..dd967a0 100644
@@ -2031,10 +2031,17 @@ static long do_io_getevents(aio_context_t ctx_id,
 		struct io_event __user *events,
 		struct timespec64 *ts)
 {
-	ktime_t until = ts ? timespec64_to_ktime(*ts) : KTIME_MAX;
-	struct kioctx *ioctx = lookup_ioctx(ctx_id);
+	ktime_t until = KTIME_MAX;
+	struct kioctx *ioctx = NULL;
 	long ret = -EINVAL;
 

fs/aio.c static long do_io_getevents(aio_context_t ctx_id, · line 2047

Quoted 10 lines
fs/aio.c +7 -0
+	if (ts) {
+		if (!timespec64_valid(ts))
+			return ret;
+		until = timespec64_to_ktime(*ts);
+	}
+
+	ioctx = lookup_ioctx(ctx_id);
 	if (likely(ioctx)) {
 		if (likely(min_nr <= nr && min_nr >= 0))
 			ret = read_events(ioctx, min_nr, nr, events, until);

The previous suggestion[1] of fixing the helpers never materialized, so let's just get this fixed, already.

-Jeff

[1] https://marc.info/?l=linux-fsdevel&m=152209450618587&w=2

--
To unsubscribe, send a message with 'unsubscribe linux-aio' in the body to [email protected]. For more info on Linux AIO,
see: http://www.kvack.org/aio/
Don't email: <a href=mailto:"[email protected]">[email protected]</a>

maintainer
#3 lore raw
Quoted 1 line · Jeff Moyer

Al, can you take this through your tree?

Umm... Can do, but I had an impression that Arnd and Deepa had a tree for timespec-related work. OTOH, it had been relatively quiet last cycle, so... If they have nothing in the area, I can take it through vfs.git.

#4 lore raw
Quoted 7 lines · Al Viro
Quoted 1 line · Jeff Moyer

Al, can you take this through your tree?

Umm... Can do, but I had an impression that Arnd and Deepa had a tree for timespec-related work. OTOH, it had been relatively quiet last cycle, so... If they have nothing in the area, I can take it through vfs.git.

Hmm, okay. Yi, can you repost the patch, adding my Reviewed-by tag, and CC-ing Arnd and Deepa:

Arnd Bergmann <[email protected]>
Deepa Dinamani <[email protected]>

Thanks!
Jeff

#5 lore raw

On 2019/7/29 23:59, Jeff Moyer Wrote:

Quoted 5 lines
Quoted 3 lines · Al Viro
Quoted 1 line · Jeff Moyer

Al, can you take this through your tree?

Quoted 8 lines
Quoted 4 lines

Umm... Can do, but I had an impression that Arnd and Deepa had a tree for timespec-related work. OTOH, it had been relatively quiet last cycle, so... If they have nothing in the area, I can take it through vfs.git.

Hmm, okay. Yi, can you repost the patch, adding my Reviewed-by tag, and CC-ing Arnd and Deepa:

Yes, will do.

Thanks,
Yi.

#6 lore raw
In reply to Al Viro

Hi, Al, could you please consider applying this patch ?

Thanks,
Yi.

Quoted 10 lines · Al Viro
Quoted 1 line · Jeff Moyer

Al, can you take this through your tree?

Umm... Can do, but I had an impression that Arnd and Deepa had a tree for timespec-related work. OTOH, it had been relatively quiet last cycle, so... If they have nothing in the area, I can take it through vfs.git.

.