From owner-freebsd-bugs@freebsd.org Wed Jul 3 19:12:50 2019 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EBE7C15DDE3E for ; Wed, 3 Jul 2019 19:12:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 7C1F08B645 for ; Wed, 3 Jul 2019 19:12:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id 3D83F15DDE3D; Wed, 3 Jul 2019 19:12:49 +0000 (UTC) Delivered-To: bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1A0F015DDE3C for ; Wed, 3 Jul 2019 19:12:49 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 99E938B642 for ; Wed, 3 Jul 2019 19:12:48 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id BB436D960 for ; Wed, 3 Jul 2019 19:12:47 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id x63JClC5060750 for ; Wed, 3 Jul 2019 19:12:47 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id x63JCl2T060748 for bugs@FreeBSD.org; Wed, 3 Jul 2019 19:12:47 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 238971] patch(1) modifies the wrong file Date: Wed, 03 Jul 2019 19:12:47 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 12.0-STABLE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: vangyzen@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jul 2019 19:12:50 -0000 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 |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 # # $FreeBSD$ # --=20 You are receiving this mail because: You are the assignee for the bug.=