Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 03 Jul 2019 19:12:47 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 238971] patch(1) modifies the wrong file
Message-ID:  <bug-238971-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D238971

            Bug ID: 238971
           Summary: patch(1) modifies the wrong file
           Product: Base System
           Version: 12.0-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: vangyzen@FreeBSD.org

Created attachment 205503
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D205503&action=
=3Dedit
patch that adds a new Makefile

I'm running 12.0-STABLE r348455.  I used patch(1) to apply the attached pat=
ch
file to a head tree at r349671.  The patch adds a new Makefile under a new
directory under tools/, but patch(1) applied the change to the top-level
Makefile.  It also added the new .c file to the top-level directory, althou=
gh
that should have gone in the new directory.

Here is the patch output:

$ patch < ~/0001-Save-the-last-callout-function-executed-on-each-CPU.patch=
=20
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|From ee77139c3ce21bac8665411c9d5e7c945afcf981 Mon Sep 17 00:00:00 2001
|From: Eric van Gyzen <eric@vangyzen.net>
|Date: Fri, 28 Jun 2019 05:16:27 -0500
|Subject: [PATCH 1/2] Save the last callout function executed on each CPU
|
|Save the last callout function pointer (and its argument) executed
|on each CPU for inspection by a debugger.  Add a ddb `show callout_last`
|command to show these pointers.  Add a kernel module that I used
|for testing that command.
|
|Relocate `ce_migration_cpu` to reduce padding and therefore preserve
|the size of `struct callout_cpu` (320 bytes on amd64) despite the
|added members.
|
|This should help diagnose reference-after-free bugs where the
|callout's mutex has already been freed when `softclock_call_cc`
|tries to unlock it.
|
|You might hope that the pointer would still be available, but it
|isn't.  The argument to that function is on the stack (because
|`softclock_call_cc` uses it later), and that might be enough in
|some cases, but even then, it's very laborious.  A pointer to the
|callout is saved right before these newly added fields, but that
|callout might have been freed.  We still have the pointer to its
|associated mutex, and the name within might be enough, but it might
|also have been freed.
|---
| sys/kern/kern_timeout.c                | 39 +++++++++++-
| tools/test/callout_free/Makefile       |  4 ++
| tools/test/callout_free/callout_free.c | 87 ++++++++++++++++++++++++++
| 3 files changed, 129 insertions(+), 1 deletion(-)
| create mode 100644 tools/test/callout_free/Makefile
| create mode 100644 tools/test/callout_free/callout_free.c
|
|diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c
|index 81b4a14ecf08..73f3904d1837 100644
|--- a/sys/kern/kern_timeout.c
|+++ b/sys/kern/kern_timeout.c
--------------------------
Patching file sys/kern/kern_timeout.c using Plan A...
Hunk #1 succeeded at 65.
Hunk #2 succeeded at 144.
Hunk #3 succeeded at 180.
Hunk #4 succeeded at 691.
Hunk #5 succeeded at 1677.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/tools/test/callout_free/Makefile
b/tools/test/callout_free/Makefile
|new file mode 100644
|index 000000000000..6421c072c5b9
|--- /dev/null
|+++ b/tools/test/callout_free/Makefile
--------------------------
Patching file Makefile using Plan A...
Empty context always matches.
Hunk #1 succeeded at 1.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/tools/test/callout_free/callout_free.c
b/tools/test/callout_free/callout_free.c
|new file mode 100644
|index 000000000000..4556687e06f6
|--- /dev/null
|+++ b/tools/test/callout_free/callout_free.c
--------------------------
(Creating file callout_free.c...)
Patching file callout_free.c using Plan A...
Empty context always matches.
Hunk #1 succeeded at 1.
Hmm...  Ignoring the trailing garbage.
done

$ svn st
M       Makefile
?       Makefile.orig
?       callout_free.c
?       callout_free.c.orig
M       sys/kern/kern_timeout.c
?       sys/kern/kern_timeout.c.orig

$ svn diff Makefile
Index: Makefile
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- Makefile    (revision 349673)
+++ Makefile    (working copy)
@@ -1,3 +1,7 @@
+KMOD=3D  callout_free
+SRCS=3D  callout_free.c
+
+.include <bsd.kmod.mk>
 #
 # $FreeBSD$
 #

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-238971-227>