Skip to content

Commit 26101d7

Browse files
authored
Merge pull request #4624 from chu11/issue4612_broker_crash
job-info: return error on invalid eventlog append
2 parents 99ecf1d + f341232 commit 26101d7

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/modules/job-info/watch.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,24 @@ static void watch_continuation (flux_future_t *f, void *arg)
246246
const char *input;
247247
const char *tok;
248248
size_t toklen;
249+
const char *errmsg = NULL;
249250

250251
if (flux_kvs_lookup_get (f, &s) < 0) {
251252
if (errno != ENOENT && errno != ENODATA && errno != ENOTSUP)
252253
flux_log_error (ctx->h, "%s: flux_kvs_lookup_get", __FUNCTION__);
253254
goto error;
254255
}
255256

257+
/* Issue #4612 - zero length append illegal for an eventlog. This
258+
* most likely occurred through an illegal overwrite of the whole
259+
* eventlog.
260+
*/
261+
if (!s) {
262+
errmsg = "illegal append of zero bytes";
263+
errno = EINVAL;
264+
goto error;
265+
}
266+
256267
if (w->cancel) {
257268
errno = ENODATA;
258269
goto error;
@@ -310,7 +321,7 @@ static void watch_continuation (flux_future_t *f, void *arg)
310321
}
311322

312323
error:
313-
if (flux_respond_error (ctx->h, w->msg, errno, NULL) < 0)
324+
if (flux_respond_error (ctx->h, w->msg, errno, errmsg) < 0)
314325
flux_log_error (ctx->h, "%s: flux_respond_error", __FUNCTION__);
315326

316327
/* flux future destroyed in watch_ctx_destroy, which is called

t/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ dist_check_SCRIPTS = \
312312
issues/t4413-empty-eventlog.sh \
313313
issues/t4465-job-list-use-after-free.sh \
314314
issues/t4482-flush-list-corruption.sh \
315+
issues/t4612-eventlog-overwrite-crash.sh \
315316
python/__init__.py \
316317
python/subflux.py \
317318
python/tap \
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash -e
2+
3+
waitfile=${SHARNESS_TEST_SRCDIR}/scripts/waitfile.lua
4+
5+
jobid=$(flux mini submit --wait-event=start sh -c "echo foo; sleep 300")
6+
7+
kvsdir=$(flux job id --to=kvs $jobid)
8+
9+
# issue a command that will watch / monitor the job's eventlog
10+
flux job attach $jobid > t4612.out &
11+
12+
# ensure backgrounded process has started to monitor eventlog
13+
$waitfile --count=1 --timeout=30 --pattern=foo t4612.out
14+
15+
# now overwrite the eventlog without changing its length
16+
flux kvs get --raw ${kvsdir}.eventlog \
17+
| sed -e s/submit/foobar/ \
18+
| flux kvs put --raw ${kvsdir}.eventlog=-
19+
20+
wait
21+
22+
# if flux broker segfaulted, this won't work
23+
flux mini run hostname

0 commit comments

Comments
 (0)