From a5576d5ad3529d1eb0dcebfb36f0712d645746b8 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Tue, 28 Jul 2020 18:26:01 +0200 Subject: [PATCH] sio: do not follow symlinks --- kernel/mars_sio.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kernel/mars_sio.c b/kernel/mars_sio.c index 8975c7ac..0e5a54ea 100644 --- a/kernel/mars_sio.c +++ b/kernel/mars_sio.c @@ -625,7 +625,7 @@ static int sio_switch(struct sio_brick *brick) int status = 0; if (brick->power.button) { - int flags = O_CREAT | O_RDWR | O_LARGEFILE; + int flags = O_CREAT | O_NOFOLLOW | O_RDWR | O_LARGEFILE; int index; if (brick->power.led_on) @@ -640,8 +640,12 @@ static int sio_switch(struct sio_brick *brick) output->mf = mapfree_get(path, flags); if (unlikely(IS_ERR(output->mf))) { - MARS_ERR("could not open file = '%s' flags = %d\n", path, flags); - status = -ENOENT; + status = PTR_ERR(output->mf); + output->mf = NULL; + MARS_ERR("open '%s' flags=%d status=%d\n", + path, + flags, + status); goto done; }