CVS commit: src/sys/compat/linux/common

2024-05-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 12 19:54:48 UTC 2024

Modified Files:
src/sys/compat/linux/common: linux_misc.h

Log Message:
Add forward decl for procfs include.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/compat/linux/common/linux_misc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_misc.h
diff -u src/sys/compat/linux/common/linux_misc.h:1.31 src/sys/compat/linux/common/linux_misc.h:1.32
--- src/sys/compat/linux/common/linux_misc.h:1.31	Sun May 12 15:50:42 2024
+++ src/sys/compat/linux/common/linux_misc.h	Sun May 12 15:54:48 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_misc.h,v 1.31 2024/05/12 19:50:42 christos Exp $	*/
+/*	$NetBSD: linux_misc.h,v 1.32 2024/05/12 19:54:48 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -174,6 +174,7 @@ __packed
 
 #ifdef _KERNEL
 __BEGIN_DECLS
+struct linux_timeval;
 int bsd_to_linux_wstat(int);
 int linux_select1(struct lwp *, register_t *, int, fd_set *, fd_set *,
 		   fd_set *, struct linux_timeval *);



CVS commit: src/sys/compat/linux/common

2024-05-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 12 19:54:48 UTC 2024

Modified Files:
src/sys/compat/linux/common: linux_misc.h

Log Message:
Add forward decl for procfs include.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/compat/linux/common/linux_misc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2024-05-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 12 19:50:42 UTC 2024

Modified Files:
src/sys/compat/linux/common: linux_misc.h

Log Message:
fix whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/compat/linux/common/linux_misc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_misc.h
diff -u src/sys/compat/linux/common/linux_misc.h:1.30 src/sys/compat/linux/common/linux_misc.h:1.31
--- src/sys/compat/linux/common/linux_misc.h:1.30	Sun May 12 13:23:10 2024
+++ src/sys/compat/linux/common/linux_misc.h	Sun May 12 15:50:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_misc.h,v 1.30 2024/05/12 17:23:10 christos Exp $	*/
+/*	$NetBSD: linux_misc.h,v 1.31 2024/05/12 19:50:42 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -94,11 +94,11 @@ struct linux_sysinfo {
 #define	LINUX_RLIMIT_MEMLOCK	8
 #define	LINUX_RLIMIT_AS		9
 #define	LINUX_RLIMIT_LOCKS	10
-#define LINUX_RLIMIT_SIGPENDING	11
-#define LINUX_RLIMIT_MSGQUEUE	12
-#define LINUX_RLIMIT_NICE	13
-#define LINUX_RLIMIT_RTPRIO	14
-#define LINUX_RLIMIT_RTTIME	15
+#define	LINUX_RLIMIT_SIGPENDING	11
+#define	LINUX_RLIMIT_MSGQUEUE	12
+#define	LINUX_RLIMIT_NICE	13
+#define	LINUX_RLIMIT_RTPRIO	14
+#define	LINUX_RLIMIT_RTTIME	15
 #ifdef __mips__  /* XXX only mips32. On mips64, it's ~0ul */
 #define	LINUX_RLIM_INFINITY	0x7fffUL
 #define	LINUX32_RLIM_INFINITY	0x7fffU



CVS commit: src/sys/compat/linux/common

2024-05-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 12 19:50:42 UTC 2024

Modified Files:
src/sys/compat/linux/common: linux_misc.h

Log Message:
fix whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/compat/linux/common/linux_misc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2024-05-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 12 17:23:10 UTC 2024

Modified Files:
src/sys/compat/linux/common: linux_limit.h linux_misc.h

Log Message:
PR/58240: Ricardo Branco: Add missing limits


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/compat/linux/common/linux_limit.h
cvs rdiff -u -r1.29 -r1.30 src/sys/compat/linux/common/linux_misc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_limit.h
diff -u src/sys/compat/linux/common/linux_limit.h:1.8 src/sys/compat/linux/common/linux_limit.h:1.9
--- src/sys/compat/linux/common/linux_limit.h:1.8	Wed Dec  1 23:29:48 2021
+++ src/sys/compat/linux/common/linux_limit.h	Sun May 12 13:23:10 2024
@@ -1,4 +1,4 @@
-/* 	$NetBSD: linux_limit.h,v 1.8 2021/12/02 04:29:48 ryo Exp $ */
+/* 	$NetBSD: linux_limit.h,v 1.9 2024/05/12 17:23:10 christos Exp $ */
 
 /*-
  * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@@ -94,6 +94,11 @@ linux_to_bsd_limit(int lim)
 	case LINUX_RLIMIT_AS:
 		return RLIMIT_AS;
 	case LINUX_RLIMIT_LOCKS:
+	case LINUX_RLIMIT_SIGPENDING:
+	case LINUX_RLIMIT_MSGQUEUE:
+	case LINUX_RLIMIT_NICE:
+	case LINUX_RLIMIT_RTPRIO:
+	case LINUX_RLIMIT_RTTIME:
 		return -EOPNOTSUPP;
 	default:
 		return -EINVAL;

Index: src/sys/compat/linux/common/linux_misc.h
diff -u src/sys/compat/linux/common/linux_misc.h:1.29 src/sys/compat/linux/common/linux_misc.h:1.30
--- src/sys/compat/linux/common/linux_misc.h:1.29	Fri Aug 18 15:41:19 2023
+++ src/sys/compat/linux/common/linux_misc.h	Sun May 12 13:23:10 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_misc.h,v 1.29 2023/08/18 19:41:19 christos Exp $	*/
+/*	$NetBSD: linux_misc.h,v 1.30 2024/05/12 17:23:10 christos Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -94,6 +94,11 @@ struct linux_sysinfo {
 #define	LINUX_RLIMIT_MEMLOCK	8
 #define	LINUX_RLIMIT_AS		9
 #define	LINUX_RLIMIT_LOCKS	10
+#define LINUX_RLIMIT_SIGPENDING	11
+#define LINUX_RLIMIT_MSGQUEUE	12
+#define LINUX_RLIMIT_NICE	13
+#define LINUX_RLIMIT_RTPRIO	14
+#define LINUX_RLIMIT_RTTIME	15
 #ifdef __mips__  /* XXX only mips32. On mips64, it's ~0ul */
 #define	LINUX_RLIM_INFINITY	0x7fffUL
 #define	LINUX32_RLIM_INFINITY	0x7fffU



CVS commit: src/sys/compat/linux/common

2024-05-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May 12 17:23:10 UTC 2024

Modified Files:
src/sys/compat/linux/common: linux_limit.h linux_misc.h

Log Message:
PR/58240: Ricardo Branco: Add missing limits


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/compat/linux/common/linux_limit.h
cvs rdiff -u -r1.29 -r1.30 src/sys/compat/linux/common/linux_misc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/sys/compat/linux/common

2023-08-25 Thread Theodore Preduta
On 2023-08-25 13:30, Taylor R Campbell wrote:
> Since VOP_READDIR requires vp to be locked, I can infer that the
> handle_write caller must already hold vp locked.  But that means that
> we have ifd_lock -> vnode lock in one path, and vnode lock -> ifd_lock
> in another path, which is forbidden (unless there's some reason we can
> prove these paths never happen concurrently).

Hmm... I did not realize this, so I don't think NOTE_WRITE
disambiguation is (or has ever been) safe.

The real pain here is that we inherit a held vp_interlock and vnode lock
in the needs_lock=false case from the kevent callback.  So this may
require a pretty substantial locking revision(?)

Anyways, I'll take a closer look later this weekend.

> I'm also suspicious of logic like this:
> 
> mutex_enter(>f_lock);
> uio.uio_offset = fp->f_offset;
> mutex_exit(>f_lock);
> ...
> mutex_enter(>f_lock);
> fp->f_offset = uio.uio_offset;
> mutex_exit(>f_lock);
> 
> If fp->f_offset can change concurrently while f_lock is released, this
> looks like a problem.  But if it can't, why do we need the lock at
> all?  I suspect this really does need a lock over the whole
> transaction (maybe fp->f_lock, maybe something else), which is not
> released while I/O is happening -- possibly not with mutex(9) but
> something interruptible instead.

I think you're right about needing a lock for the whole transaction.
Since this is called from get_inotify_dir_entries(), perhaps it would be
better for get_inotify_dir_entries() to keep track of the offset and
pass it in instead?

Theo(dore)



Re: CVS commit: src/sys/compat/linux/common

2023-08-25 Thread Taylor R Campbell
> Date: Fri, 25 Aug 2023 13:38:02 -0400
> From: Theodore Preduta 
> 
> On 2023-08-25 13:13, Taylor R Campbell wrote:
> > This can't be right, and it's a little unsettling that the problem
> > isn't caught by any automatic tests.
> > 
> > As I understand it, the `ie_name' member is supposed to provide
> > storage for the `ie_event.name' array.
> > 
> > So this looks like this change is going to lead either to a buffer
> > overrun -- reading someone else's heap memory, or scribbling all over
> > someone else's heap memory -- or to uninitialized or zero-filled
> > memory being published to userland where there should be a pathname.
> 
> I don't think so.  Notice that in inotify_read() two calls to uiomove()
> are made, one on ie_event and one on ie_name... and in general this code
> never accesses ie_event.name directly.
> 
> The reason I separated the fields in the first place was to make
> allocation/deallocation simpler, not to use ie_name as storage for
> ie_event.name.

Got it!  So that would explain why automatic tests didn't catch
anything.  Thanks!  Maybe we should have a comment about this to
clarify for future readers.

Side note: I realize there's a KASSERT protecting one of the strcpy
calls, and the other one is limited to copying from values of struct
dirent::d_name created by VOP_READDIR which should be limited to
NAME_MAX (plus NUL terminator).  But I'd be a little more comfortable
if we didn't use strcpy at all -- strlcpy is probably the right choice
here.  Might prefer to set buf->ie_event.len to MIN(strlen(name) + 1,
sizeof(buf->ie_name)) too, so that non-DIAGNOSTIC builds will truncate
the data rather than overrun the buffer.


Re: CVS commit: src/sys/compat/linux/common

2023-08-25 Thread Theodore Preduta
On 2023-08-25 13:13, Taylor R Campbell wrote:
>> Module Name:src
>> Committed By:   christos
>> Date:   Wed Aug 23 19:17:59 UTC 2023
>>
>> Modified Files:
>> src/sys/compat/linux/common: linux_inotify.c
>>
>> Log Message:
>> put variable length structure at the end, so that clang does not complain.
>>
>>  struct inotify_entry {
>> TAILQ_ENTRY(inotify_entry)  ie_entries;
>> +   charie_name[NAME_MAX + 1];
>> struct linux_inotify_event  ie_event;
>> -   charie_name[NAME_MAX+1];
>>  };
> 
> This can't be right, and it's a little unsettling that the problem
> isn't caught by any automatic tests.
> 
> As I understand it, the `ie_name' member is supposed to provide
> storage for the `ie_event.name' array.
> 
> So this looks like this change is going to lead either to a buffer
> overrun -- reading someone else's heap memory, or scribbling all over
> someone else's heap memory -- or to uninitialized or zero-filled
> memory being published to userland where there should be a pathname.

I don't think so.  Notice that in inotify_read() two calls to uiomove()
are made, one on ie_event and one on ie_name... and in general this code
never accesses ie_event.name directly.

The reason I separated the fields in the first place was to make
allocation/deallocation simpler, not to use ie_name as storage for
ie_event.name.

Theo(dore)



Re: CVS commit: src/sys/compat/linux/common

2023-08-25 Thread Taylor R Campbell
> Module Name:src
> Committed By:   christos
> Date:   Thu Aug 24 19:51:24 UTC 2023
> 
> Modified Files:
> src/sys/compat/linux/common: linux_inotify.c
> 
> Log Message:
> fix a locking bug (Theodore Preduta)
> 
> if (needs_lock)
> vn_lock(vp, LK_SHARED | LK_RETRY);
> +   else
> +   /*
> +* XXX We need to temprarily drop v_interlock because
> +* it may be temporarily acquired by biowait().
> +*/
> +   mutex_exit(vp->v_interlock);
> +   KASSERT(!mutex_owned(vp->v_interlock));
> error = VOP_READDIR(vp, , fp->f_cred, , NULL, NULL);
> if (needs_lock)
> VOP_UNLOCK(vp);
> +   else
> +   mutex_enter(vp->v_interlock);

This looks questionable.

1. Why is v_interlock held in the first place?

2. Why is it safe to release v_interlock here, if the caller holds it?

3. What is the lock order for all the locks involved?

I see that inotify_readdir via get_inotify_dir_entries has two call
sites, leading to the following lock orders:

- linux_sys_inotify_add_watch
  -> mutex_enter(>ifd_lock)
  -> get_inotify_dir_entries(..., needs_lock=true)
 -> inotify_readdir(..., needs_lock=true)
-> vn_lock(vp)
-> VOP_READDIR(vp)

- handle_write
  -> mutex_enter(>ifd_lock)
  -> get_inotify_dir_entries(..., needs_lock=false)
 -> inotify_readdir(..., needs_lock=true)
-> mutex_exit(vp->v_interlock)
-> VOP_READDIR(vp)

Since VOP_READDIR requires vp to be locked, I can infer that the
handle_write caller must already hold vp locked.  But that means that
we have ifd_lock -> vnode lock in one path, and vnode lock -> ifd_lock
in another path, which is forbidden (unless there's some reason we can
prove these paths never happen concurrently).

I'm also suspicious of logic like this:

mutex_enter(>f_lock);
uio.uio_offset = fp->f_offset;
mutex_exit(>f_lock);
...
mutex_enter(>f_lock);
fp->f_offset = uio.uio_offset;
mutex_exit(>f_lock);

If fp->f_offset can change concurrently while f_lock is released, this
looks like a problem.  But if it can't, why do we need the lock at
all?  I suspect this really does need a lock over the whole
transaction (maybe fp->f_lock, maybe something else), which is not
released while I/O is happening -- possibly not with mutex(9) but
something interruptible instead.


Re: CVS commit: src/sys/compat/linux/common

2023-08-25 Thread Taylor R Campbell
> Module Name:src
> Committed By:   christos
> Date:   Wed Aug 23 19:17:59 UTC 2023
> 
> Modified Files:
> src/sys/compat/linux/common: linux_inotify.c
> 
> Log Message:
> put variable length structure at the end, so that clang does not complain.
> 
>  struct inotify_entry {
> TAILQ_ENTRY(inotify_entry)  ie_entries;
> +   charie_name[NAME_MAX + 1];
> struct linux_inotify_event  ie_event;
> -   charie_name[NAME_MAX+1];
>  };

This can't be right, and it's a little unsettling that the problem
isn't caught by any automatic tests.

As I understand it, the `ie_name' member is supposed to provide
storage for the `ie_event.name' array.

So this looks like this change is going to lead either to a buffer
overrun -- reading someone else's heap memory, or scribbling all over
someone else's heap memory -- or to uninitialized or zero-filled
memory being published to userland where there should be a pathname.

We need to do this in a different way.  (It's annoying that C doesn't
formally allow the original code, since in principle it is sensible.)
Perhaps we can delete the struct inotify_entry::ie_name member, and
instead of using

struct inotify_event *ie = kmem_zalloc(sizeof(*ie), ...);

do

struct inotify_event *ie = kmem_zalloc(
offsetof(struct inotify_event, ie_event.name[NAME_MAX + 1]),
...);

and similarly for kmem_free.


CVS commit: src/sys/compat/linux/common

2023-08-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Aug 24 19:51:24 UTC 2023

Modified Files:
src/sys/compat/linux/common: linux_inotify.c

Log Message:
fix a locking bug (Theodore Preduta)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/compat/linux/common/linux_inotify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2023-08-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Aug 24 19:51:24 UTC 2023

Modified Files:
src/sys/compat/linux/common: linux_inotify.c

Log Message:
fix a locking bug (Theodore Preduta)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/compat/linux/common/linux_inotify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_inotify.c
diff -u src/sys/compat/linux/common/linux_inotify.c:1.4 src/sys/compat/linux/common/linux_inotify.c:1.5
--- src/sys/compat/linux/common/linux_inotify.c:1.4	Wed Aug 23 15:17:59 2023
+++ src/sys/compat/linux/common/linux_inotify.c	Thu Aug 24 15:51:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_inotify.c,v 1.4 2023/08/23 19:17:59 christos Exp $	*/
+/*	$NetBSD: linux_inotify.c,v 1.5 2023/08/24 19:51:24 christos Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_inotify.c,v 1.4 2023/08/23 19:17:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_inotify.c,v 1.5 2023/08/24 19:51:24 christos Exp $");
 
 #include 
 #include 
@@ -790,9 +790,18 @@ inotify_readdir(file_t *fp, struct diren
 	/* XXX: should pass whether to lock or not */
 	if (needs_lock)
 		vn_lock(vp, LK_SHARED | LK_RETRY);
+	else
+		/*
+		 * XXX We need to temprarily drop v_interlock because
+		 * it may be temporarily acquired by biowait().
+		 */
+		mutex_exit(vp->v_interlock);
+	KASSERT(!mutex_owned(vp->v_interlock));
 	error = VOP_READDIR(vp, , fp->f_cred, , NULL, NULL);
 	if (needs_lock)
 		VOP_UNLOCK(vp);
+	else
+		mutex_enter(vp->v_interlock);
 
 	mutex_enter(>f_lock);
 	fp->f_offset = uio.uio_offset;
@@ -1107,7 +1116,7 @@ inotify_filt_event(struct knote *kn, lon
 		cv_signal(>ifd_qcv);
 
 		mutex_enter(>ifd_lock);
-		selnotify(>ifd_sel, 0, 0);
+		selnotify(>ifd_sel, 0, NOTE_LOWAT);
 		mutex_exit(>ifd_lock);
 	} else
 		DPRINTF(("%s: hint=%lx resulted in 0 inotify events\n",
@@ -1295,14 +1304,17 @@ inotify_read_filt_detach(struct knote *k
 static int
 inotify_read_filt_event(struct knote *kn, long hint)
 {
-	int rv;
 	struct inotifyfd *ifd = ((file_t *)kn->kn_obj)->f_data;
 
-	mutex_enter(>ifd_qlock);
-	rv = (ifd->ifd_qcount > 0);
-	mutex_exit(>ifd_qlock);
+	if (hint != 0) {
+		KASSERT(mutex_owned(>ifd_lock));
+		KASSERT(mutex_owned(>ifd_qlock));
+		KASSERT(hint == NOTE_LOWAT);
+
+		kn->kn_data = ifd->ifd_qcount;
+	}
 
-	return rv;
+	return kn->kn_data > 0;
 }
 
 /*



CVS commit: src/sys/compat/linux/common

2023-08-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 23 19:17:59 UTC 2023

Modified Files:
src/sys/compat/linux/common: linux_inotify.c

Log Message:
put variable length structure at the end, so that clang does not complain.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/compat/linux/common/linux_inotify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_inotify.c
diff -u src/sys/compat/linux/common/linux_inotify.c:1.3 src/sys/compat/linux/common/linux_inotify.c:1.4
--- src/sys/compat/linux/common/linux_inotify.c:1.3	Tue Aug 22 08:02:34 2023
+++ src/sys/compat/linux/common/linux_inotify.c	Wed Aug 23 15:17:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_inotify.c,v 1.3 2023/08/22 12:02:34 christos Exp $	*/
+/*	$NetBSD: linux_inotify.c,v 1.4 2023/08/23 19:17:59 christos Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_inotify.c,v 1.3 2023/08/22 12:02:34 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_inotify.c,v 1.4 2023/08/23 19:17:59 christos Exp $");
 
 #include 
 #include 
@@ -84,8 +84,8 @@ __KERNEL_RCSID(0, "$NetBSD: linux_inotif
 
 struct inotify_entry {
 	TAILQ_ENTRY(inotify_entry)	ie_entries;
+	charie_name[NAME_MAX + 1];
 	struct linux_inotify_event	ie_event;
-	charie_name[NAME_MAX+1];
 };
 
 struct inotify_dir_entries {



CVS commit: src/sys/compat/linux/common

2023-08-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 23 19:17:59 UTC 2023

Modified Files:
src/sys/compat/linux/common: linux_inotify.c

Log Message:
put variable length structure at the end, so that clang does not complain.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/compat/linux/common/linux_inotify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2023-08-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 22 12:02:34 UTC 2023

Modified Files:
src/sys/compat/linux/common: linux_inotify.c

Log Message:
aarch64 does not have sys_inotify_init()...


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/compat/linux/common/linux_inotify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_inotify.c
diff -u src/sys/compat/linux/common/linux_inotify.c:1.2 src/sys/compat/linux/common/linux_inotify.c:1.3
--- src/sys/compat/linux/common/linux_inotify.c:1.2	Sun Aug 20 14:09:25 2023
+++ src/sys/compat/linux/common/linux_inotify.c	Tue Aug 22 08:02:34 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_inotify.c,v 1.2 2023/08/20 18:09:25 christos Exp $	*/
+/*	$NetBSD: linux_inotify.c,v 1.3 2023/08/22 12:02:34 christos Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_inotify.c,v 1.2 2023/08/20 18:09:25 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_inotify.c,v 1.3 2023/08/22 12:02:34 christos Exp $");
 
 #include 
 #include 
@@ -331,6 +331,7 @@ leave0:
 	return error;
 }
 
+#ifndef __aarch64__
 /*
  * inotify_init(2).  Initialize a new inotify fd with flags=0.
  */
@@ -339,6 +340,7 @@ linux_sys_inotify_init(struct lwp *l, co
 {
 	return do_inotify_init(l, retval, 0);
 }
+#endif
 
 /*
  * inotify_init(2).  Initialize a new inotify fd with the given flags.



CVS commit: src/sys/compat/linux/common

2023-08-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 22 12:02:34 UTC 2023

Modified Files:
src/sys/compat/linux/common: linux_inotify.c

Log Message:
aarch64 does not have sys_inotify_init()...


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/compat/linux/common/linux_inotify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2023-08-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 20 18:09:25 UTC 2023

Modified Files:
src/sys/compat/linux/common: linux_inotify.c

Log Message:
fix locking: eliminate using mutex_owned() (Theodore Preduta)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/compat/linux/common/linux_inotify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_inotify.c
diff -u src/sys/compat/linux/common/linux_inotify.c:1.1 src/sys/compat/linux/common/linux_inotify.c:1.2
--- src/sys/compat/linux/common/linux_inotify.c:1.1	Sat Aug 19 13:57:54 2023
+++ src/sys/compat/linux/common/linux_inotify.c	Sun Aug 20 14:09:25 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_inotify.c,v 1.1 2023/08/19 17:57:54 christos Exp $	*/
+/*	$NetBSD: linux_inotify.c,v 1.2 2023/08/20 18:09:25 christos Exp $	*/
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_inotify.c,v 1.1 2023/08/19 17:57:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_inotify.c,v 1.2 2023/08/20 18:09:25 christos Exp $");
 
 #include 
 #include 
@@ -135,8 +135,8 @@ static void	do_kevent_to_inotify(int32_t
 struct inotify_entry *, size_t *, char *);
 static int	kevent_to_inotify(struct inotifyfd *, int, enum vtype, uint32_t,
 uint32_t, struct inotify_entry *, size_t *);
-static int	inotify_readdir(file_t *, struct dirent *, int *);
-static struct inotify_dir_entries *get_inotify_dir_entries(int);
+static int	inotify_readdir(file_t *, struct dirent *, int *, bool);
+static struct inotify_dir_entries *get_inotify_dir_entries(int, bool);
 
 static int	inotify_filt_attach(struct knote *);
 static void	inotify_filt_detach(struct knote *);
@@ -417,15 +417,15 @@ linux_sys_inotify_add_watch(struct lwp *
 		syscallarg(const char *) pathname;
 		syscallarg(uint32_t) mask;
 	} */
-	int wd, dup_of_wd, i, error = 0;
+	int wd, i, error = 0;
 	file_t *fp, *wp, *cur_fp;
-	struct stat wst, cur_st;
 	struct inotifyfd *ifd;
 	struct inotify_dir_entries **new_wds;
 	struct knote *kn, *tmpkn;
 	struct sys_open_args oa;
 	struct kevent kev;
-	enum vtype wtype;
+	struct vnode *wvp;
+	namei_simple_flags_t sflags;
 	struct kevent_ops k_ops = {
 		.keo_private = NULL,
 		.keo_fetch_timeout = NULL,
@@ -452,38 +452,16 @@ linux_sys_inotify_add_watch(struct lwp *
 
 	mutex_enter(>ifd_lock);
 
-	/* open a new file descriptor for the watch descriptor */
-	SCARG(, path) = SCARG(uap, pathname);
-	SCARG(, mode) = 0;
-	SCARG(, flags) = O_RDONLY;
 	if (mask & LINUX_IN_DONT_FOLLOW)
-		SCARG(, flags) |= O_NOFOLLOW;
-	if (mask & LINUX_IN_ONLYDIR)
-		SCARG(, flags) |= O_DIRECTORY;
-
-	error = sys_open(l, , retval);
+		sflags = NSM_NOFOLLOW_TRYEMULROOT;
+	else
+		sflags = NSM_FOLLOW_TRYEMULROOT;
+	error = namei_simple_user(SCARG(uap, pathname), sflags, );
 	if (error != 0)
 		goto leave1;
-	wd = *retval;
-
-	wp = fd_getfile(wd);
-	KASSERT(wp != NULL);
-	wtype = wp->f_vnode->v_type;
-	error = vn_stat(wp->f_vnode, );
-	fd_putfile(wd);
-	if (error != 0)
-		goto leave1;
-
-	/* translate the flags */
-	memset(, 0, sizeof(kev));
-	EV_SET(, wd, inotify_filtid, EV_ADD|EV_ENABLE,
-	NOTE_DELETE|NOTE_REVOKE, 0, ifd);
-	if (mask & LINUX_IN_ONESHOT)
-		kev.flags |= EV_ONESHOT;
-	kev.fflags |= inotify_mask_to_kevent_fflags(mask, wtype);
 
 	/* Check to see if we already have a descriptor to wd's file. */
-dup_of_wd = -1;
+wd = -1;
 	for (i = 0; i < ifd->ifd_nwds; i++) {
 		if (ifd->ifd_wds[i] != NULL) {
 			cur_fp = fd_getfile(i);
@@ -498,24 +476,47 @@ linux_sys_inotify_add_watch(struct lwp *
 "with a non-vnode\n", __func__, i));
 error = EBADF;
 			}
-			if (error == 0)
-error = vn_stat(cur_fp->f_vnode, _st);
+			if (error == 0 && cur_fp->f_vnode == wvp)
+wd = i;
 			fd_putfile(i);
 			if (error != 0)
 goto leave1;
 
-			if (wst.st_ino == cur_st.st_ino) {
-			dup_of_wd = i;
+			if (wd != -1)
 break;
-			}
 		}
 	}
 
-	if (dup_of_wd != -1) {
+	if (wd == -1) {
 		/*
-		 * If we do not have a descriptor to wd's file, we need to add
-		 * a knote.
+		 * If we do not have a descriptor to wd's file, we
+		 * need to open the watch descriptor.
 		 */
+		SCARG(, path) = SCARG(uap, pathname);
+		SCARG(, mode) = 0;
+		SCARG(, flags) = O_RDONLY;
+		if (mask & LINUX_IN_DONT_FOLLOW)
+			SCARG(, flags) |= O_NOFOLLOW;
+		if (mask & LINUX_IN_ONLYDIR)
+			SCARG(, flags) |= O_DIRECTORY;
+
+		error = sys_open(l, , retval);
+		if (error != 0)
+			goto leave1;
+		wd = *retval;
+		wp = fd_getfile(wd);
+	KASSERT(wp != NULL);
+		KASSERT(wp->f_type == DTYPE_VNODE);
+
+		/* translate the flags */
+		memset(, 0, sizeof(kev));
+		EV_SET(, wd, inotify_filtid, EV_ADD|EV_ENABLE,
+		NOTE_DELETE|NOTE_REVOKE, 0, ifd);
+		if (mask & LINUX_IN_ONESHOT)
+			kev.flags |= EV_ONESHOT;
+		kev.fflags |= 

CVS commit: src/sys/compat/linux/common

2023-08-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 20 18:09:25 UTC 2023

Modified Files:
src/sys/compat/linux/common: linux_inotify.c

Log Message:
fix locking: eliminate using mutex_owned() (Theodore Preduta)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/compat/linux/common/linux_inotify.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2023-08-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 19 17:57:55 UTC 2023

Modified Files:
src/sys/compat/linux/common: linux_fcntl.h linux_mod.c
Added Files:
src/sys/compat/linux/common: linux_inotify.c linux_inotify.h

Log Message:
new inotify support GSoC 2023 (Theodore Preduta)


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/compat/linux/common/linux_fcntl.h
cvs rdiff -u -r0 -r1.1 src/sys/compat/linux/common/linux_inotify.c \
src/sys/compat/linux/common/linux_inotify.h
cvs rdiff -u -r1.14 -r1.15 src/sys/compat/linux/common/linux_mod.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2023-08-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 19 17:57:55 UTC 2023

Modified Files:
src/sys/compat/linux/common: linux_fcntl.h linux_mod.c
Added Files:
src/sys/compat/linux/common: linux_inotify.c linux_inotify.h

Log Message:
new inotify support GSoC 2023 (Theodore Preduta)


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/compat/linux/common/linux_fcntl.h
cvs rdiff -u -r0 -r1.1 src/sys/compat/linux/common/linux_inotify.c \
src/sys/compat/linux/common/linux_inotify.h
cvs rdiff -u -r1.14 -r1.15 src/sys/compat/linux/common/linux_mod.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_fcntl.h
diff -u src/sys/compat/linux/common/linux_fcntl.h:1.21 src/sys/compat/linux/common/linux_fcntl.h:1.22
--- src/sys/compat/linux/common/linux_fcntl.h:1.21	Sun Jul  9 22:31:55 2023
+++ src/sys/compat/linux/common/linux_fcntl.h	Sat Aug 19 13:57:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_fcntl.h,v 1.21 2023/07/10 02:31:55 christos Exp $	*/
+/*	$NetBSD: linux_fcntl.h,v 1.22 2023/08/19 17:57:54 christos Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -32,6 +32,11 @@
 #ifndef _LINUX_FCNTL_H
 #define _LINUX_FCNTL_H
 
+#ifdef _KERNEL
+#include  /* For linux_off_t */
+struct stat;
+#endif
+
 /*
  * The arguments in the flock structure have a different order from the
  * BSD structure.
@@ -50,6 +55,7 @@
 #define LINUX_AT_NO_AUTOMOUNT		0x0800
 #define LINUX_AT_EMPTY_PATH		0x1000
 
+#ifdef _KERNEL
 int linux_to_bsd_ioflags(int);
 int linux_to_bsd_atflags(int);
 int bsd_to_linux_statx(struct stat *, struct linux_statx *, unsigned int);
@@ -70,6 +76,7 @@ struct linux_flock64 {
 	off_t	l_len;
 	linux_pid_t l_pid;
 };
+#endif /* _KERNEL */
 
 #if defined(__i386__)
 #include 
@@ -103,6 +110,7 @@ struct linux_flock64 {
 #define	LINUX_F_ADD_SEALS	(LINUX_F_SPECIFIC_BASE + 9)
 #define	LINUX_F_GET_SEALS	(LINUX_F_SPECIFIC_BASE + 10)
 
+#ifdef _KERNEL
 /*
  * We have to have 4 copies of the code that converts linux fcntl() file
  * locking to native form because there are 4 layouts for the structures.
@@ -171,6 +179,6 @@ LINUX##_to_bsd_##FLOCK(struct flock *bfp
 	LINUX##_to_bsd_##FLOCK(, ); \
 	return do_fcntl_lock(fd, cmd == setlk ? F_SETLK : F_SETLKW, ); \
 } while (0)
-
+#endif /* _KERNEL */
 
 #endif /* !_LINUX_FCNTL_H */

Index: src/sys/compat/linux/common/linux_mod.c
diff -u src/sys/compat/linux/common/linux_mod.c:1.14 src/sys/compat/linux/common/linux_mod.c:1.15
--- src/sys/compat/linux/common/linux_mod.c:1.14	Sun Apr 26 14:53:33 2020
+++ src/sys/compat/linux/common/linux_mod.c	Sat Aug 19 13:57:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_mod.c,v 1.14 2020/04/26 18:53:33 thorpej Exp $	*/
+/*	$NetBSD: linux_mod.c,v 1.15 2023/08/19 17:57:54 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_mod.c,v 1.14 2020/04/26 18:53:33 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_mod.c,v 1.15 2023/08/19 17:57:54 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_execfmt.h"
@@ -46,6 +46,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_mod.c,
 #include 
 #include 
 
+#include 
 #include 
 #include 
 
@@ -162,7 +163,12 @@ compat_linux_modcmd(modcmd_t cmd, void *
 
 	switch (cmd) {
 	case MODULE_CMD_INIT:
+		error = linux_inotify_init();
+		if (error != 0)
+			return error;
 		error = exec_add(linux_execsw, __arraycount(linux_execsw));
+		if (error)
+			linux_inotify_fini();
 		return error;
 
 	case MODULE_CMD_FINI:
@@ -170,6 +176,7 @@ compat_linux_modcmd(modcmd_t cmd, void *
 		if (error)
 			return error;
 		linux_sysctl_fini();
+		linux_inotify_fini();
 		return 0;
 
 	default:

Added files:

Index: src/sys/compat/linux/common/linux_inotify.c
diff -u /dev/null src/sys/compat/linux/common/linux_inotify.c:1.1
--- /dev/null	Sat Aug 19 13:57:55 2023
+++ src/sys/compat/linux/common/linux_inotify.c	Sat Aug 19 13:57:54 2023
@@ -0,0 +1,1317 @@
+/*	$NetBSD: linux_inotify.c,v 1.1 2023/08/19 17:57:54 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2023 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Theodore Preduta.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 

CVS commit: src/sys/compat/linux/common

2023-07-29 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Jul 29 12:58:51 UTC 2023

Modified Files:
src/sys/compat/linux/common: linux_misc.h

Log Message:
Add comment on packed attribution for struct linux_epoll_event on amd64.
NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/compat/linux/common/linux_misc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_misc.h
diff -u src/sys/compat/linux/common/linux_misc.h:1.27 src/sys/compat/linux/common/linux_misc.h:1.28
--- src/sys/compat/linux/common/linux_misc.h:1.27	Fri Jul 28 18:19:01 2023
+++ src/sys/compat/linux/common/linux_misc.h	Sat Jul 29 12:58:51 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_misc.h,v 1.27 2023/07/28 18:19:01 christos Exp $	*/
+/*	$NetBSD: linux_misc.h,v 1.28 2023/07/29 12:58:51 rin Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -146,6 +146,7 @@ struct linux_epoll_event {
 	uint64_t	data;
 }
 #if defined(__amd64__)
+/* Only for x86_64. See include/uapi/linux/eventpoll.h. */
 __packed
 #endif
 ;



CVS commit: src/sys/compat/linux/common

2023-07-29 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Jul 29 12:58:51 UTC 2023

Modified Files:
src/sys/compat/linux/common: linux_misc.h

Log Message:
Add comment on packed attribution for struct linux_epoll_event on amd64.
NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/compat/linux/common/linux_misc.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2023-07-29 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Jul 29 07:00:00 UTC 2023

Modified Files:
src/sys/compat/linux/common: linux_misc.c

Log Message:
compat/linux: aarch64 does not have epoll_create(2) nor epoll_wait(2)

Note that for Linux, new architectures like arm64 use MI system call
table in include/uapi/asm-generic/unistd.h, instead of MD syscall.tbl.

XXX
Too many ifdef's like this. We should be smarter...


To generate a diff of this commit:
cvs rdiff -u -r1.258 -r1.259 src/sys/compat/linux/common/linux_misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_misc.c
diff -u src/sys/compat/linux/common/linux_misc.c:1.258 src/sys/compat/linux/common/linux_misc.c:1.259
--- src/sys/compat/linux/common/linux_misc.c:1.258	Fri Jul 28 18:19:01 2023
+++ src/sys/compat/linux/common/linux_misc.c	Sat Jul 29 07:00:00 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_misc.c,v 1.258 2023/07/28 18:19:01 christos Exp $	*/
+/*	$NetBSD: linux_misc.c,v 1.259 2023/07/29 07:00:00 rin Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.258 2023/07/28 18:19:01 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.259 2023/07/29 07:00:00 rin Exp $");
 
 #include 
 #include 
@@ -1683,6 +1683,7 @@ linux_sys_eventfd2(struct lwp *l, const 
  retval);
 }
 
+#ifndef __aarch64__
 /*
  * epoll_create(2).  Check size and call sys_epoll_create1.
  */
@@ -1705,6 +1706,7 @@ linux_sys_epoll_create(struct lwp *l,
 	SCARG(, flags) = 0;
 	return sys_epoll_create1(l, , retval);
 }
+#endif /* !__aarch64__ */
 
 /*
  * epoll_create1(2).  Translate the flags and call sys_epoll_create1.
@@ -1768,6 +1770,7 @@ linux_sys_epoll_ctl(struct lwp *l, const
 	SCARG(uap, fd), eep);
 }
 
+#ifndef __aarch64__
 /*
  * epoll_wait(2).  Call sys_epoll_pwait().
  */
@@ -1791,6 +1794,7 @@ linux_sys_epoll_wait(struct lwp *l,
 
 	return linux_sys_epoll_pwait(l, , retval);
 }
+#endif /* !__aarch64__ */
 
 /*
  * Main body of epoll_pwait2(2).  Translate timeout and sigmask and



CVS commit: src/sys/compat/linux/common

2023-07-29 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Jul 29 07:00:00 UTC 2023

Modified Files:
src/sys/compat/linux/common: linux_misc.c

Log Message:
compat/linux: aarch64 does not have epoll_create(2) nor epoll_wait(2)

Note that for Linux, new architectures like arm64 use MI system call
table in include/uapi/asm-generic/unistd.h, instead of MD syscall.tbl.

XXX
Too many ifdef's like this. We should be smarter...


To generate a diff of this commit:
cvs rdiff -u -r1.258 -r1.259 src/sys/compat/linux/common/linux_misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2021-11-24 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Nov 25 02:09:23 UTC 2021

Modified Files:
src/sys/compat/linux/common: linux_file64.c

Log Message:
rename bsd_to_linux_stat() to bsd_to_linux_stat64() to avoid confusion.
There is a static function with the same name in linux/common/linux_file.c.

NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.66 src/sys/compat/linux/common/linux_file64.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_file64.c
diff -u src/sys/compat/linux/common/linux_file64.c:1.64 src/sys/compat/linux/common/linux_file64.c:1.66
--- src/sys/compat/linux/common/linux_file64.c:1.64	Thu Sep 23 06:56:27 2021
+++ src/sys/compat/linux/common/linux_file64.c	Thu Nov 25 02:09:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_file64.c,v 1.64 2021/09/23 06:56:27 ryo Exp $	*/
+/*	$NetBSD: linux_file64.c,v 1.66 2021/11/25 02:09:23 ryo Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.64 2021/09/23 06:56:27 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.66 2021/11/25 02:09:23 ryo Exp $");
 
 #include 
 #include 
@@ -67,7 +67,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_file64
 
 #include 
 
-static void bsd_to_linux_stat(struct stat *, struct linux_stat64 *);
+static void bsd_to_linux_stat64(struct stat *, struct linux_stat64 *);
 
 /*
  * Convert a NetBSD stat structure to a Linux stat structure.
@@ -78,7 +78,7 @@ static void bsd_to_linux_stat(struct sta
  * things against constant major device numbers? sigh)
  */
 static void
-bsd_to_linux_stat(struct stat *bsp, struct linux_stat64 *lsp)
+bsd_to_linux_stat64(struct stat *bsp, struct linux_stat64 *lsp)
 {
 	memset(lsp, 0, sizeof(*lsp));
 	lsp->lst_dev = linux_fakedev(bsp->st_dev, 0);
@@ -126,7 +126,7 @@ linux_sys_fstat64(struct lwp *l, const s
 	if (error != 0)
 		return error;
 
-	bsd_to_linux_stat(, );
+	bsd_to_linux_stat64(, );
 
 	return copyout(, SCARG(uap, sp), sizeof tmplst);
 }
@@ -143,7 +143,7 @@ linux_do_stat64(struct lwp *l, const str
 	if (error != 0)
 		return error;
 
-	bsd_to_linux_stat(, );
+	bsd_to_linux_stat64(, );
 
 	return copyout(, SCARG(uap, sp), sizeof tmplst);
 }
@@ -225,7 +225,7 @@ linux_sys_fstatat64(struct lwp *l, const
 		return error;
 
 done:
-	bsd_to_linux_stat(, );
+	bsd_to_linux_stat64(, );
 
 	return copyout(, SCARG(uap, sp), sizeof tmplst);
 }



CVS commit: src/sys/compat/linux/common

2021-11-24 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Nov 25 02:09:23 UTC 2021

Modified Files:
src/sys/compat/linux/common: linux_file64.c

Log Message:
rename bsd_to_linux_stat() to bsd_to_linux_stat64() to avoid confusion.
There is a static function with the same name in linux/common/linux_file.c.

NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.66 src/sys/compat/linux/common/linux_file64.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2021-11-24 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Nov 25 02:08:55 UTC 2021

Modified Files:
src/sys/compat/linux/common: linux_file64.c

Log Message:
rename bsd_to_linux_stat() to bsd_to_linux_stat64() to avoid confusion.
There is a static function with the same name in linux/common/linux_file.c.

NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/compat/linux/common/linux_file64.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_file64.c
diff -u src/sys/compat/linux/common/linux_file64.c:1.64 src/sys/compat/linux/common/linux_file64.c:1.65
--- src/sys/compat/linux/common/linux_file64.c:1.64	Thu Sep 23 06:56:27 2021
+++ src/sys/compat/linux/common/linux_file64.c	Thu Nov 25 02:08:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_file64.c,v 1.64 2021/09/23 06:56:27 ryo Exp $	*/
+/*	$NetBSD: linux_file64.c,v 1.65 2021/11/25 02:08:55 ryo Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.64 2021/09/23 06:56:27 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.65 2021/11/25 02:08:55 ryo Exp $");
 
 #include 
 #include 
@@ -67,7 +67,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux_file64
 
 #include 
 
-static void bsd_to_linux_stat(struct stat *, struct linux_stat64 *);
+static void bsd_to_linux_stat64(struct stat *, struct linux_stat64 *);
 
 /*
  * Convert a NetBSD stat structure to a Linux stat structure.
@@ -78,7 +78,7 @@ static void bsd_to_linux_stat(struct sta
  * things against constant major device numbers? sigh)
  */
 static void
-bsd_to_linux_stat(struct stat *bsp, struct linux_stat64 *lsp)
+bsd_to_linux_stat64(struct stat *bsp, struct linux_stat64 *lsp)
 {
 	memset(lsp, 0, sizeof(*lsp));
 	lsp->lst_dev = linux_fakedev(bsp->st_dev, 0);
@@ -126,7 +126,7 @@ linux_sys_fstat64(struct lwp *l, const s
 	if (error != 0)
 		return error;
 
-	bsd_to_linux_stat(, );
+	bsd_to_linux_stat64(, );
 
 	return copyout(, SCARG(uap, sp), sizeof tmplst);
 }
@@ -143,7 +143,7 @@ linux_do_stat64(struct lwp *l, const str
 	if (error != 0)
 		return error;
 
-	bsd_to_linux_stat(, );
+	bsd_to_linux_stat64(, );
 
 	return copyout(, SCARG(uap, sp), sizeof tmplst);
 }
@@ -225,7 +225,7 @@ linux_sys_fstatat64(struct lwp *l, const
 		return error;
 
 done:
-	bsd_to_linux_stat(, );
+	bsd_to_linux_stat64(, );
 
 	return copyout(, SCARG(uap, sp), sizeof tmplst);
 }



CVS commit: src/sys/compat/linux/common

2021-11-24 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Thu Nov 25 02:08:55 UTC 2021

Modified Files:
src/sys/compat/linux/common: linux_file64.c

Log Message:
rename bsd_to_linux_stat() to bsd_to_linux_stat64() to avoid confusion.
There is a static function with the same name in linux/common/linux_file.c.

NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/compat/linux/common/linux_file64.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2021-11-23 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Tue Nov 23 17:54:08 UTC 2021

Modified Files:
src/sys/compat/linux/common: linux_termios.c

Log Message:
Make LINUX_FIOCLEX and LINUX_FIONCLEX work

These ioctls were declared in linux_termios.h but were not actually
handled.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/compat/linux/common/linux_termios.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2021-11-23 Thread Masatake Daimon
Module Name:src
Committed By:   pho
Date:   Tue Nov 23 17:54:08 UTC 2021

Modified Files:
src/sys/compat/linux/common: linux_termios.c

Log Message:
Make LINUX_FIOCLEX and LINUX_FIONCLEX work

These ioctls were declared in linux_termios.h but were not actually
handled.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/compat/linux/common/linux_termios.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_termios.c
diff -u src/sys/compat/linux/common/linux_termios.c:1.38 src/sys/compat/linux/common/linux_termios.c:1.39
--- src/sys/compat/linux/common/linux_termios.c:1.38	Fri Aug 23 12:09:17 2019
+++ src/sys/compat/linux/common/linux_termios.c	Tue Nov 23 17:54:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_termios.c,v 1.38 2019/08/23 12:09:17 maxv Exp $	*/
+/*	$NetBSD: linux_termios.c,v 1.39 2021/11/23 17:54:08 pho Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_termios.c,v 1.38 2019/08/23 12:09:17 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_termios.c,v 1.39 2021/11/23 17:54:08 pho Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_ptm.h"
@@ -276,6 +276,12 @@ linux_ioctl_termios(struct lwp *l, const
 	case LINUX_TIOCSPGRP:
 		SCARG(, com) = TIOCSPGRP;
 		break;
+	case LINUX_FIOCLEX:
+		SCARG(, com) = FIOCLEX;
+		break;
+	case LINUX_FIONCLEX:
+		SCARG(, com) = FIONCLEX;
+		break;
 	case LINUX_FIONREAD:
 		SCARG(, com) = FIONREAD;
 		break;



CVS commit: src/sys/compat/linux/common

2021-09-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep 23 11:28:47 UTC 2021

Modified Files:
src/sys/compat/linux/common: linux_misc_notalpha.c

Log Message:
remove stray char.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 \
src/sys/compat/linux/common/linux_misc_notalpha.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_misc_notalpha.c
diff -u src/sys/compat/linux/common/linux_misc_notalpha.c:1.112 src/sys/compat/linux/common/linux_misc_notalpha.c:1.113
--- src/sys/compat/linux/common/linux_misc_notalpha.c:1.112	Thu Sep 23 02:56:27 2021
+++ src/sys/compat/linux/common/linux_misc_notalpha.c	Thu Sep 23 07:28:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_misc_notalpha.c,v 1.112 2021/09/23 06:56:27 ryo Exp $	*/
+/*	$NetBSD: linux_misc_notalpha.c,v 1.113 2021/09/23 11:28:47 christos Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008, 2020 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.112 2021/09/23 06:56:27 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc_notalpha.c,v 1.113 2021/09/23 11:28:47 christos Exp $");
 
 /*
  * Note that we must NOT include "opt_compat_linux32.h" here,
@@ -165,7 +165,7 @@ linux_sys_readdir(struct lwp *l, const s
 	} */
 	int error;
 	struct linux_sys_getdents_args da;
-v
+
 	SCARG(, fd) = SCARG(uap, fd);
 	SCARG(, dent) = SCARG(uap, dent);
 	SCARG(, count) = 1;



CVS commit: src/sys/compat/linux/common

2021-09-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Sep 23 11:28:47 UTC 2021

Modified Files:
src/sys/compat/linux/common: linux_misc_notalpha.c

Log Message:
remove stray char.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 \
src/sys/compat/linux/common/linux_misc_notalpha.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2021-09-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Sep 21 09:24:15 UTC 2021

Modified Files:
src/sys/compat/linux/common: linux_file64.c

Log Message:
linux_sys_fstatat64: Add support for AT_EMPTY_PATH flag.

This is required for rtld shipped with glibc 2.33.

Now, userland of Fedora 34 is working fine on NetBSD/amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/compat/linux/common/linux_file64.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_file64.c
diff -u src/sys/compat/linux/common/linux_file64.c:1.62 src/sys/compat/linux/common/linux_file64.c:1.63
--- src/sys/compat/linux/common/linux_file64.c:1.62	Fri Aug 23 07:53:36 2019
+++ src/sys/compat/linux/common/linux_file64.c	Tue Sep 21 09:24:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_file64.c,v 1.62 2019/08/23 07:53:36 maxv Exp $	*/
+/*	$NetBSD: linux_file64.c,v 1.63 2021/09/21 09:24:15 rin Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.62 2019/08/23 07:53:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.63 2021/09/21 09:24:15 rin Exp $");
 
 #include 
 #include 
@@ -180,7 +180,38 @@ linux_sys_fstatat64(struct lwp *l, const
 	} */
 	struct linux_stat64 tmplst;
 	struct stat tmpst;
-	int error, nd_flag;
+	struct vnode *vp;
+	int error, nd_flag, fd;
+	uint8_t c;
+
+	if (SCARG(uap, flag) & LINUX_AT_EMPTY_PATH) {
+		/*
+		 * If path is null string:
+		 */
+		error = ufetch_8(SCARG(uap, path), );
+		if (error != 0)
+			return error;
+		if (c == '\0') {
+			fd = SCARG(uap, fd);
+			if (fd == AT_FDCWD) {
+/*
+ * operate on current directory
+ */
+vp = l->l_proc->p_cwdi->cwdi_cdir;
+vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+error = vn_stat(vp, );
+VOP_UNLOCK(vp);
+			} else {
+/*
+ * operate on fd
+ */
+error = do_sys_fstat(fd, );
+			}
+			if (error != 0)
+return error;
+			goto done;
+		}
+	}
 
 	if (SCARG(uap, flag) & LINUX_AT_SYMLINK_NOFOLLOW)
 		nd_flag = NOFOLLOW;
@@ -191,6 +222,7 @@ linux_sys_fstatat64(struct lwp *l, const
 	if (error != 0)
 		return error;
 
+done:
 	bsd_to_linux_stat(, );
 
 	return copyout(, SCARG(uap, sp), sizeof tmplst);



CVS commit: src/sys/compat/linux/common

2021-09-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Sep 21 09:24:15 UTC 2021

Modified Files:
src/sys/compat/linux/common: linux_file64.c

Log Message:
linux_sys_fstatat64: Add support for AT_EMPTY_PATH flag.

This is required for rtld shipped with glibc 2.33.

Now, userland of Fedora 34 is working fine on NetBSD/amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/compat/linux/common/linux_file64.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2021-09-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 19 17:33:39 UTC 2021

Modified Files:
src/sys/compat/linux/common: linux_sigevent.h linux_signal.c

Log Message:
- LINUX_SIGEV_PAD is incorrect for 64-bit systems, because sigval_t
  contains a pointer.  Correct this.
- Add routines to convert from Linux to native sigevent_t.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/compat/linux/common/linux_sigevent.h
cvs rdiff -u -r1.84 -r1.85 src/sys/compat/linux/common/linux_signal.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_sigevent.h
diff -u src/sys/compat/linux/common/linux_sigevent.h:1.2 src/sys/compat/linux/common/linux_sigevent.h:1.3
--- src/sys/compat/linux/common/linux_sigevent.h:1.2	Mon Apr 28 20:23:44 2008
+++ src/sys/compat/linux/common/linux_sigevent.h	Sun Sep 19 17:33:39 2021
@@ -37,13 +37,16 @@
 
 #define LINUX_SIGEV_MAX  64
 #ifndef LINUX_SIGEV_PAD
-#define LINUX_SIGEV_PAD  ((LINUX_SIGEV_MAX/sizeof(int)) - 3)
+#define LINUX_SIGEV_PAD  ((LINUX_SIGEV_MAX -\
+			   (sizeof(sigval_t) + (sizeof(int) * 2))) /	\
+			  sizeof(int))
 #endif
 
 typedef struct linux_sigevent {
-	sigval_t sigev_value;
+	sigval_t sigev_value;		/* sizeof(pointer) */
 	int sigev_signo;
 	int sigev_notify;
+	/* guaranteed to have natural pointer alignment */
 	union {
 		int pad[LINUX_SIGEV_PAD];
 		int tid;
@@ -54,4 +57,8 @@ typedef struct linux_sigevent {
 	} _sigev_un;
 } linux_sigevent_t;
 
+int	linux_to_native_sigevent(struct sigevent *,
+	const struct linux_sigevent *);
+int	linux_sigevent_copyin(const void *, void *, size_t);
+
 #endif /* _LINUX_SIGEVENT_H */

Index: src/sys/compat/linux/common/linux_signal.c
diff -u src/sys/compat/linux/common/linux_signal.c:1.84 src/sys/compat/linux/common/linux_signal.c:1.85
--- src/sys/compat/linux/common/linux_signal.c:1.84	Tue Sep  7 11:43:04 2021
+++ src/sys/compat/linux/common/linux_signal.c	Sun Sep 19 17:33:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_signal.c,v 1.84 2021/09/07 11:43:04 riastradh Exp $	*/
+/*	$NetBSD: linux_signal.c,v 1.85 2021/09/19 17:33:39 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.84 2021/09/07 11:43:04 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_signal.c,v 1.85 2021/09/19 17:33:39 thorpej Exp $");
 
 #define COMPAT_LINUX 1
 
@@ -852,3 +852,50 @@ native_to_linux_si_status(int code, int 
 
 	return sts;
 }
+
+int
+linux_to_native_sigevent(struct sigevent *nsep,
+const struct linux_sigevent *lsep)
+{
+	memset(nsep, 0, sizeof(*nsep));
+
+	switch (lsep->sigev_notify) {
+	case LINUX_SIGEV_SIGNAL:
+		nsep->sigev_notify = SIGEV_SIGNAL;
+		break;
+
+	case LINUX_SIGEV_NONE:
+		nsep->sigev_notify = SIGEV_NONE;
+		break;
+
+	case LINUX_SIGEV_THREAD:
+	case LINUX_SIGEV_THREAD_ID:
+	default:
+		return ENOTSUP;
+	}
+
+	nsep->sigev_value = lsep->sigev_value;
+	if (lsep->sigev_signo < 0 || lsep->sigev_signo >= LINUX__NSIG) {
+		return EINVAL;
+	}
+	nsep->sigev_signo = linux_to_native_signo[lsep->sigev_signo];
+
+	return 0;
+}
+
+int
+linux_sigevent_copyin(const void *src, void *dst, size_t size)
+{
+	struct linux_sigevent lse;
+	struct sigevent *sep = dst;
+	int error;
+
+	KASSERT(size == sizeof(*sep));
+
+	error = copyin(src, , sizeof(lse));
+	if (error) {
+		return error;
+	}
+
+	return linux_to_native_sigevent(sep, );
+}



CVS commit: src/sys/compat/linux/common

2021-09-19 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sun Sep 19 17:33:39 UTC 2021

Modified Files:
src/sys/compat/linux/common: linux_sigevent.h linux_signal.c

Log Message:
- LINUX_SIGEV_PAD is incorrect for 64-bit systems, because sigval_t
  contains a pointer.  Correct this.
- Add routines to convert from Linux to native sigevent_t.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/compat/linux/common/linux_sigevent.h
cvs rdiff -u -r1.84 -r1.85 src/sys/compat/linux/common/linux_signal.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2019-09-08 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Sep  8 18:46:32 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_socket.c

Log Message:
Hum, remove incorrect assignment. Userland could have passed a smaller
namelen, and the uninitialized bytes from sb_data were being used later in
the network stack.


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/sys/compat/linux/common/linux_socket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.148 src/sys/compat/linux/common/linux_socket.c:1.149
--- src/sys/compat/linux/common/linux_socket.c:1.148	Sat Aug 24 14:18:43 2019
+++ src/sys/compat/linux/common/linux_socket.c	Sun Sep  8 18:46:32 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.148 2019/08/24 14:18:43 maxv Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.149 2019/09/08 18:46:32 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.148 2019/08/24 14:18:43 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.149 2019/09/08 18:46:32 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1609,9 +1609,6 @@ linux_get_sa(struct lwp *l, int s, struc
 		sin6->sin6_scope_id = 0;
 	}
 
-	if (bdom == AF_INET)
-		namelen = sizeof(struct sockaddr_in);
-
 	sb->sb_family = bdom;
 	sb->sb_len = namelen;
 	ktrkuser("mbsoname", sb, namelen);



CVS commit: src/sys/compat/linux/common

2019-09-08 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Sep  8 18:46:32 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_socket.c

Log Message:
Hum, remove incorrect assignment. Userland could have passed a smaller
namelen, and the uninitialized bytes from sb_data were being used later in
the network stack.


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.149 src/sys/compat/linux/common/linux_socket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 14:21:13 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_misc.c

Log Message:
I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.244 src/sys/compat/linux/common/linux_misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_misc.c
diff -u src/sys/compat/linux/common/linux_misc.c:1.243 src/sys/compat/linux/common/linux_misc.c:1.244
--- src/sys/compat/linux/common/linux_misc.c:1.243	Fri Aug 23 08:01:42 2019
+++ src/sys/compat/linux/common/linux_misc.c	Sat Aug 24 14:21:13 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_misc.c,v 1.243 2019/08/23 08:01:42 maxv Exp $	*/
+/*	$NetBSD: linux_misc.c,v 1.244 2019/08/24 14:21:13 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 1999, 2008 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.243 2019/08/23 08:01:42 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_misc.c,v 1.244 2019/08/24 14:21:13 maxv Exp $");
 
 #include 
 #include 
@@ -240,7 +240,7 @@ linux_sys_wait4(struct lwp *l, const str
 # ifdef DIAGNOSTIC
 	if (linux_options & LINUX_WAIT4_WNOTHREAD)
 		printf("WARNING: %s: linux process %d.%d called "
-		   "waitpid with __WNOTHREAD set!",
+		   "waitpid with __WNOTHREAD set!\n",
 		   __FILE__, l->l_proc->p_pid, l->l_lid);
 
 # endif



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 14:21:13 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_misc.c

Log Message:
I don't see the point in having this useless printf, but add a '\n' to it,
so that it at least displays useless stuff correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.243 -r1.244 src/sys/compat/linux/common/linux_misc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 14:18:43 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_socket.c

Log Message:
Fix memory leak.


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/sys/compat/linux/common/linux_socket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.147 src/sys/compat/linux/common/linux_socket.c:1.148
--- src/sys/compat/linux/common/linux_socket.c:1.147	Sat Aug 24 14:08:35 2019
+++ src/sys/compat/linux/common/linux_socket.c	Sat Aug 24 14:18:43 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.147 2019/08/24 14:08:35 maxv Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.148 2019/08/24 14:18:43 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.147 2019/08/24 14:08:35 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.148 2019/08/24 14:18:43 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -546,6 +546,8 @@ linux_sys_sendmsg(struct lwp *l, const s
 
 case LINUX_SCM_CREDENTIALS:
 	/* no native equivalent, just drop it */
+	if (control != mtod(ctl_mbuf, void *))
+		free(control, M_MBUF);
 	m_free(ctl_mbuf);
 	ctl_mbuf = NULL;
 	msg.msg_control = NULL;



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 14:18:43 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_socket.c

Log Message:
Fix memory leak.


To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/sys/compat/linux/common/linux_socket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 14:08:35 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_socket.c

Log Message:
Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/compat/linux/common/linux_socket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.146 src/sys/compat/linux/common/linux_socket.c:1.147
--- src/sys/compat/linux/common/linux_socket.c:1.146	Sat Aug 24 12:33:25 2019
+++ src/sys/compat/linux/common/linux_socket.c	Sat Aug 24 14:08:35 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.146 2019/08/24 12:33:25 maxv Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.147 2019/08/24 14:08:35 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.146 2019/08/24 12:33:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.147 2019/08/24 14:08:35 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -568,14 +568,15 @@ linux_sys_sendmsg(struct lwp *l, const s
 			/* Check the buffer is big enough */
 			if (__predict_false(cidx + cspace > clen)) {
 u_int8_t *nc;
+size_t nclen;
 
-clen = cidx + cspace;
-if (clen >= PAGE_SIZE) {
+nclen = cidx + cspace;
+if (nclen >= PAGE_SIZE) {
 	error = EINVAL;
 	goto done;
 }
 nc = realloc(clen <= MLEN ? NULL : control,
-		clen, M_TEMP, M_WAITOK);
+		nclen, M_TEMP, M_WAITOK);
 if (!nc) {
 	error = ENOMEM;
 	goto done;
@@ -584,6 +585,7 @@ linux_sys_sendmsg(struct lwp *l, const s
 	/* Old buffer was in mbuf... */
 	memcpy(nc, control, cidx);
 control = nc;
+clen = nclen;
 			}
 
 			/* Copy header */



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 14:08:35 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_socket.c

Log Message:
Hum, don't pass an mbuf to realloc(). Inspired from copyin32_msg_control().


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/compat/linux/common/linux_socket.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 12:33:25 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_socket.c linux_socket.h

Log Message:
Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?


To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.23 -r1.24 src/sys/compat/linux/common/linux_socket.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_socket.c
diff -u src/sys/compat/linux/common/linux_socket.c:1.145 src/sys/compat/linux/common/linux_socket.c:1.146
--- src/sys/compat/linux/common/linux_socket.c:1.145	Thu Apr 18 17:45:12 2019
+++ src/sys/compat/linux/common/linux_socket.c	Sat Aug 24 12:33:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.c,v 1.145 2019/04/18 17:45:12 christos Exp $	*/
+/*	$NetBSD: linux_socket.c,v 1.146 2019/08/24 12:33:25 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.145 2019/04/18 17:45:12 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_socket.c,v 1.146 2019/08/24 12:33:25 maxv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -605,7 +605,7 @@ linux_sys_sendmsg(struct lwp *l, const s
 
 			resid -= LINUX_CMSG_ALIGN(l_cmsg.cmsg_len);
 			cidx += cspace;
-		} while ((l_cc = LINUX_CMSG_NXTHDR(, l_cc)) && resid > 0);
+		} while ((l_cc = LINUX_CMSG_NXTHDR(, l_cc, _cmsg)) && resid > 0);
 
 		/* If we allocated a buffer, attach to mbuf */
 		if (cidx > MLEN) {

Index: src/sys/compat/linux/common/linux_socket.h
diff -u src/sys/compat/linux/common/linux_socket.h:1.23 src/sys/compat/linux/common/linux_socket.h:1.24
--- src/sys/compat/linux/common/linux_socket.h:1.23	Fri Feb  3 16:57:39 2017
+++ src/sys/compat/linux/common/linux_socket.h	Sat Aug 24 12:33:25 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_socket.h,v 1.23 2017/02/03 16:57:39 christos Exp $	*/
+/*	$NetBSD: linux_socket.h,v 1.24 2019/08/24 12:33:25 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -186,13 +186,13 @@ struct linux_cmsghdr {
 /* Linux either uses this, or  &((cmsg)->__cmsg_data) */
 #define LINUX_CMSG_DATA(cmsg)	\
 	((u_char *)((struct linux_cmsghdr *)(cmsg) + 1))
-#define	LINUX_CMSG_NXTHDR(mhdr, cmsg)	\
-	char *)(cmsg) + LINUX_CMSG_ALIGN((cmsg)->cmsg_len) + \
-			sizeof(*(cmsg))) > \
+#define LINUX_CMSG_NXTHDR(mhdr, ucmsg, kcmsg)	\
+	char *)(ucmsg) + LINUX_CMSG_ALIGN((kcmsg)->cmsg_len) + \
+			sizeof(*(ucmsg))) > \
 	(((char *)(mhdr)->msg_control) + (mhdr)->msg_controllen)) ? \
 	(struct linux_cmsghdr *)NULL : \
-	(struct linux_cmsghdr *)((char *)(cmsg) + \
-	LINUX_CMSG_ALIGN((cmsg)->cmsg_len)))
+	(struct linux_cmsghdr *)((char *)(ucmsg) + \
+	LINUX_CMSG_ALIGN((kcmsg)->cmsg_len)))
 /* This the number of bytes removed from each item (excl. final padding) */
 #define LINUX_CMSG_ALIGN_DELTA	\
 	(CMSG_ALIGN(sizeof(struct cmsghdr)) - sizeof(struct linux_cmsghdr))



CVS commit: src/sys/compat/linux/common

2019-08-24 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Aug 24 12:33:25 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_socket.c linux_socket.h

Log Message:
Don't read data from userland directly. This simply does not work on any
recent x86 CPU (thanks to SMAP) and all architectures that forbid direct
access to userland from the kernel. But I guess no one noticed because no
one ever uses compat_linux, right?


To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/sys/compat/linux/common/linux_socket.c
cvs rdiff -u -r1.23 -r1.24 src/sys/compat/linux/common/linux_socket.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2019-08-23 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Aug 23 13:36:45 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_statfs.h

Log Message:
Fix info leaks.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/compat/linux/common/linux_statfs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_statfs.h
diff -u src/sys/compat/linux/common/linux_statfs.h:1.6 src/sys/compat/linux/common/linux_statfs.h:1.7
--- src/sys/compat/linux/common/linux_statfs.h:1.6	Thu Sep 13 13:59:33 2012
+++ src/sys/compat/linux/common/linux_statfs.h	Fri Aug 23 13:36:45 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_statfs.h,v 1.6 2012/09/13 13:59:33 pooka Exp $	*/
+/*	$NetBSD: linux_statfs.h,v 1.7 2019/08/23 13:36:45 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@@ -48,6 +48,8 @@ bsd_to_linux_statfs(const struct statvfs
 {
 	int i;
 
+	memset(lsp, 0, sizeof(*lsp));
+
 	for (i = 0; i < linux_fstypes_cnt; i++) {
 		if (strcmp(bsp->f_fstypename, linux_fstypes[i].mty_bsd) == 0) {
 			lsp->l_ftype = linux_fstypes[i].mty_linux;
@@ -82,7 +84,6 @@ bsd_to_linux_statfs(const struct statvfs
 	lsp->l_ffsid.val[0] = bsp->f_fsidx.__fsid_val[0];
 	lsp->l_ffsid.val[1] = bsp->f_fsidx.__fsid_val[1];
 	lsp->l_fnamelen = bsp->f_namemax;
-	(void)memset(lsp->l_fspare, 0, sizeof(lsp->l_fspare));
 }
 
 /*
@@ -96,6 +97,8 @@ bsd_to_linux_statfs64(const struct statv
 {
 	int i, div;
 
+	memset(lsp, 0, sizeof(*lsp));
+
 	for (i = 0; i < linux_fstypes_cnt; i++) {
 		if (strcmp(bsp->f_fstypename, linux_fstypes[i].mty_bsd) == 0) {
 			lsp->l_ftype = linux_fstypes[i].mty_linux;
@@ -121,7 +124,6 @@ bsd_to_linux_statfs64(const struct statv
 	lsp->l_ffsid.val[0] = bsp->f_fsidx.__fsid_val[0];
 	lsp->l_ffsid.val[1] = bsp->f_fsidx.__fsid_val[1];
 	lsp->l_fnamelen = bsp->f_namemax;
-	(void)memset(lsp->l_fspare, 0, sizeof(lsp->l_fspare));
 }
 
 #endif /* !_LINUX_STATFS_H */



CVS commit: src/sys/compat/linux/common

2019-08-23 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Aug 23 13:36:45 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_statfs.h

Log Message:
Fix info leaks.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/compat/linux/common/linux_statfs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2019-08-23 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Aug 23 11:19:39 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_fcntl.h

Log Message:
When dealing with an unknown value, set -1, to prevent (harmless)
uninitialized accesses later.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/compat/linux/common/linux_fcntl.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2019-08-23 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Aug 23 11:19:39 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_fcntl.h

Log Message:
When dealing with an unknown value, set -1, to prevent (harmless)
uninitialized accesses later.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/compat/linux/common/linux_fcntl.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_fcntl.h
diff -u src/sys/compat/linux/common/linux_fcntl.h:1.17 src/sys/compat/linux/common/linux_fcntl.h:1.18
--- src/sys/compat/linux/common/linux_fcntl.h:1.17	Sun Mar  1 13:19:39 2015
+++ src/sys/compat/linux/common/linux_fcntl.h	Fri Aug 23 11:19:39 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_fcntl.h,v 1.17 2015/03/01 13:19:39 njoly Exp $	*/
+/*	$NetBSD: linux_fcntl.h,v 1.18 2019/08/23 11:19:39 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -132,6 +132,9 @@ LINUX##_to_bsd_##FLOCK(struct flock *bfp
 	case src_f##_WRLCK: \
 		dst->l_type = dst_f##_WRLCK; \
 		break; \
+	default: \
+		dst->l_type = -1; \
+		break; \
 	} \
 }
 



CVS commit: src/sys/compat/linux/common

2019-08-23 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Aug 23 06:59:52 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_termios.h

Log Message:
Fix info leaks.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/compat/linux/common/linux_termios.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_termios.h
diff -u src/sys/compat/linux/common/linux_termios.h:1.21 src/sys/compat/linux/common/linux_termios.h:1.22
--- src/sys/compat/linux/common/linux_termios.h:1.21	Sun Sep 25 13:40:07 2011
+++ src/sys/compat/linux/common/linux_termios.h	Fri Aug 23 06:59:52 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_termios.h,v 1.21 2011/09/25 13:40:07 chs Exp $	*/
+/*	$NetBSD: linux_termios.h,v 1.22 2019/08/23 06:59:52 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -279,6 +279,7 @@ bsd_termios_to_linux_termio(struct termi
 {
 	int i, mask;
 
+	memset(lt, 0, sizeof(*lt));
 	lt->c_iflag = 0;
 	lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNBRK, LINUX_IGNBRK);
 	lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, BRKINT, LINUX_BRKINT);
@@ -466,6 +467,7 @@ bsd_termios_to_linux_termios(struct term
 {
 	int i, mask;
 
+	memset(lts, 0, sizeof(*lts));
 	lts->c_iflag = 0;
 	lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNBRK, LINUX_IGNBRK);
 	lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, BRKINT, LINUX_BRKINT);



CVS commit: src/sys/compat/linux/common

2019-08-23 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Aug 23 06:59:52 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_termios.h

Log Message:
Fix info leaks.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/compat/linux/common/linux_termios.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/compat/linux/common

2019-08-23 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Aug 23 06:54:54 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_file64.c

Log Message:
Fix info leak.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/compat/linux/common/linux_file64.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/compat/linux/common/linux_file64.c
diff -u src/sys/compat/linux/common/linux_file64.c:1.60 src/sys/compat/linux/common/linux_file64.c:1.61
--- src/sys/compat/linux/common/linux_file64.c:1.60	Mon Sep  3 16:29:29 2018
+++ src/sys/compat/linux/common/linux_file64.c	Fri Aug 23 06:54:54 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_file64.c,v 1.60 2018/09/03 16:29:29 riastradh Exp $	*/
+/*	$NetBSD: linux_file64.c,v 1.61 2019/08/23 06:54:54 maxv Exp $	*/
 
 /*-
  * Copyright (c) 1995, 1998, 2000, 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.60 2018/09/03 16:29:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file64.c,v 1.61 2019/08/23 06:54:54 maxv Exp $");
 
 #include 
 #include 
@@ -80,6 +80,7 @@ static void bsd_to_linux_stat(struct sta
 static void
 bsd_to_linux_stat(struct stat *bsp, struct linux_stat64 *lsp)
 {
+	memset(lsp, 0, sizeof(*lsp));
 	lsp->lst_dev = linux_fakedev(bsp->st_dev, 0);
 	lsp->lst_ino = bsp->st_ino;
 	lsp->lst_mode= (linux_mode_t)bsp->st_mode;



CVS commit: src/sys/compat/linux/common

2019-08-23 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Fri Aug 23 06:54:54 UTC 2019

Modified Files:
src/sys/compat/linux/common: linux_file64.c

Log Message:
Fix info leak.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/compat/linux/common/linux_file64.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



re: CVS commit: src/sys/compat/linux/common

2018-01-08 Thread Christos Zoulas
On Jan 9, 12:33pm, m...@eterna.com.au (matthew green) wrote:
-- Subject: re: CVS commit: src/sys/compat/linux/common

| Christos Zoulas writes:
| > On Jan 9, 12:44am, m...@netbsd.org (m...@netbsd.org) wrote:
| > -- Subject: Re: CVS commit: src/sys/compat/linux/common
| > 
| > | Why not add a signal?
| > 
| > It is complicated to do so. It will even change the sigmask size.
| 
| it will?  don't we have support for upto 128 signals there?
| 
| 1.2  (thorpej  18-Jan-03): typedef struct {
| 1.2  (thorpej  18-Jan-03):  __uint32_t  __bits[4];
| 1.2  (thorpej  18-Jan-03): } sigset_t;
| 
| there might be some issues, but i was fairly sure when we went
| beyond the old 32 signals we made it upto 128.
| 
| we should be able to make it work in the kernel, at least.

You need to look at the compat code for linux... Ours is fine I think.
We use the NSIG linux macro to compute the words. Yes, it can be done,
but it requires more changes.

christos


re: CVS commit: src/sys/compat/linux/common

2018-01-08 Thread matthew green
Christos Zoulas writes:
> On Jan 9, 12:44am, m...@netbsd.org (m...@netbsd.org) wrote:
> -- Subject: Re: CVS commit: src/sys/compat/linux/common
> 
> | Why not add a signal?
> 
> It is complicated to do so. It will even change the sigmask size.

it will?  don't we have support for upto 128 signals there?

1.2  (thorpej  18-Jan-03): typedef struct {
1.2  (thorpej  18-Jan-03):  __uint32_t  __bits[4];
1.2  (thorpej  18-Jan-03): } sigset_t;

there might be some issues, but i was fairly sure when we went
beyond the old 32 signals we made it upto 128.

we should be able to make it work in the kernel, at least.


.mrg.