All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 9pfs: local: Do not follow symlink in _nofollow
@ 2022-04-27  2:45 Akihiko Odaki
  2022-04-27  8:46 ` Christian Schoenebeck
  0 siblings, 1 reply; 4+ messages in thread
From: Akihiko Odaki @ 2022-04-27  2:45 UTC (permalink / raw)
  Cc: Christian Schoenebeck, qemu-devel, Akihiko Odaki, Greg Kurz

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
---
 hw/9pfs/9p-local.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index d42ce6d8b82..def8afdb4d6 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -365,7 +365,7 @@ static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode)
     if (fd == -1) {
         /* In case the file is writable-only and isn't a directory. */
         if (errno == EACCES) {
-            fd = openat_file(dirfd, name, O_WRONLY, 0);
+            fd = openat_file(dirfd, name, O_WRONLY | O_NOFOLLOW, 0);
         }
         if (fd == -1 && errno == EISDIR) {
             errno = EACCES;
-- 
2.32.0 (Apple Git-132)



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] 9pfs: local: Do not follow symlink in _nofollow
  2022-04-27  2:45 [PATCH] 9pfs: local: Do not follow symlink in _nofollow Akihiko Odaki
@ 2022-04-27  8:46 ` Christian Schoenebeck
  2022-04-27 10:21   ` Greg Kurz
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Schoenebeck @ 2022-04-27  8:46 UTC (permalink / raw)
  To: Akihiko Odaki; +Cc: qemu-devel, Greg Kurz

On Mittwoch, 27. April 2022 04:45:45 CEST Akihiko Odaki wrote:
> Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> ---
>  hw/9pfs/9p-local.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
> index d42ce6d8b82..def8afdb4d6 100644
> --- a/hw/9pfs/9p-local.c
> +++ b/hw/9pfs/9p-local.c
> @@ -365,7 +365,7 @@ static int fchmodat_nofollow(int dirfd, const char
> *name, mode_t mode) if (fd == -1) {
>          /* In case the file is writable-only and isn't a directory. */
>          if (errno == EACCES) {
> -            fd = openat_file(dirfd, name, O_WRONLY, 0);
> +            fd = openat_file(dirfd, name, O_WRONLY | O_NOFOLLOW, 0);

O_NOFOLLOW flag is always added inside openat_file() implementation:

https://github.com/qemu/qemu/blob/master/hw/9pfs/9p-util.h#L60

So this change is not necessary AFAICS.

>          }
>          if (fd == -1 && errno == EISDIR) {
>              errno = EACCES;




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] 9pfs: local: Do not follow symlink in _nofollow
  2022-04-27  8:46 ` Christian Schoenebeck
@ 2022-04-27 10:21   ` Greg Kurz
  2022-04-27 11:18     ` Christian Schoenebeck
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kurz @ 2022-04-27 10:21 UTC (permalink / raw)
  To: Christian Schoenebeck; +Cc: qemu-devel, Akihiko Odaki

On Wed, 27 Apr 2022 10:46:31 +0200
Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:

> On Mittwoch, 27. April 2022 04:45:45 CEST Akihiko Odaki wrote:
> > Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> > ---
> >  hw/9pfs/9p-local.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
> > index d42ce6d8b82..def8afdb4d6 100644
> > --- a/hw/9pfs/9p-local.c
> > +++ b/hw/9pfs/9p-local.c
> > @@ -365,7 +365,7 @@ static int fchmodat_nofollow(int dirfd, const char
> > *name, mode_t mode) if (fd == -1) {
> >          /* In case the file is writable-only and isn't a directory. */
> >          if (errno == EACCES) {
> > -            fd = openat_file(dirfd, name, O_WRONLY, 0);
> > +            fd = openat_file(dirfd, name, O_WRONLY | O_NOFOLLOW, 0);
> 
> O_NOFOLLOW flag is always added inside openat_file() implementation:
> 
> https://github.com/qemu/qemu/blob/master/hw/9pfs/9p-util.h#L60
> 
> So this change is not necessary AFAICS.
> 

Right, and with macOS in mind, maybe fchmodat(AT_SYMLINK_NOFOLLOW) just
works unlike with linux ?

> >          }
> >          if (fd == -1 && errno == EISDIR) {
> >              errno = EACCES;
> 
> 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] 9pfs: local: Do not follow symlink in _nofollow
  2022-04-27 10:21   ` Greg Kurz
@ 2022-04-27 11:18     ` Christian Schoenebeck
  0 siblings, 0 replies; 4+ messages in thread
From: Christian Schoenebeck @ 2022-04-27 11:18 UTC (permalink / raw)
  To: Greg Kurz; +Cc: qemu-devel, Akihiko Odaki

On Mittwoch, 27. April 2022 12:21:51 CEST Greg Kurz wrote:
> On Wed, 27 Apr 2022 10:46:31 +0200
> 
> Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:
> > On Mittwoch, 27. April 2022 04:45:45 CEST Akihiko Odaki wrote:
> > > Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
> > > ---
> > > 
> > >  hw/9pfs/9p-local.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
> > > index d42ce6d8b82..def8afdb4d6 100644
> > > --- a/hw/9pfs/9p-local.c
> > > +++ b/hw/9pfs/9p-local.c
> > > @@ -365,7 +365,7 @@ static int fchmodat_nofollow(int dirfd, const char
> > > *name, mode_t mode) if (fd == -1) {
> > > 
> > >          /* In case the file is writable-only and isn't a directory. */
> > >          if (errno == EACCES) {
> > > 
> > > -            fd = openat_file(dirfd, name, O_WRONLY, 0);
> > > +            fd = openat_file(dirfd, name, O_WRONLY | O_NOFOLLOW, 0);
> > 
> > O_NOFOLLOW flag is always added inside openat_file() implementation:
> > 
> > https://github.com/qemu/qemu/blob/master/hw/9pfs/9p-util.h#L60
> > 
> > So this change is not necessary AFAICS.
> 
> Right, and with macOS in mind, maybe fchmodat(AT_SYMLINK_NOFOLLOW) just
> works unlike with linux ?

Yep, fchmodat(AT_SYMLINK_NOFOLLOW) seems to work on macOS! Like you already 
suggested on the other thread, it would make sense to move current 
implementation of fchmodat_nofollow() to 9p-util-linux.h/.c and let macOS just 
use fchmodat(AT_SYMLINK_NOFOLLOW) instead.

Best regards,
Christian Schoenebeck




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-27 11:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-27  2:45 [PATCH] 9pfs: local: Do not follow symlink in _nofollow Akihiko Odaki
2022-04-27  8:46 ` Christian Schoenebeck
2022-04-27 10:21   ` Greg Kurz
2022-04-27 11:18     ` Christian Schoenebeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.