kernel -- ktrace: Fix possible one-word stack leak to userspace.
authorVenkatesh Srinivas <me@endeavour.zapto.org>
Sun, 27 Nov 2011 17:16:45 +0000 (09:16 -0800)
committerVenkatesh Srinivas <me@endeavour.zapto.org>
Sun, 27 Nov 2011 17:16:45 +0000 (09:16 -0800)
From OpenBSD kern_ktrace.c 1.55, via Loganaden Velvindron.

sys/kern/kern_ktrace.c

index 6ccd577..eda9d46 100644 (file)
@@ -128,8 +128,11 @@ ktrsysret(struct lwp *lp, int code, int error, register_t retval)
        kth = ktrgetheader(KTR_SYSRET);
        ktp.ktr_code = code;
        ktp.ktr_error = error;
-       ktp.ktr_retval = retval;                /* what about val2 ? */
-
+       if (error == 0)
+               ktp.ktr_retval = retval;                /* what about val2 ? */
+       else
+               ktp.ktr_retval = 0;
        kth->ktr_buf = (caddr_t)&ktp;
        kth->ktr_len = sizeof(struct ktr_sysret);