linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek-IBi9RG/b67k@public.gmane.org>
To: Jessica Yu <jeyu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Josh Poimboeuf <jpoimboe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>,
	Seth Jennings <sjenning-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Jiri Kosina <jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Vojtech Pavlik <vojtech-IBi9RG/b67k@public.gmane.org>,
	Jonathan Corbet <corbet-T1hC0tSOHrs@public.gmane.org>,
	Miroslav Benes <mbenes-AlSwsSmVLrQ@public.gmane.org>,
	linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	live-patching-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: livepatch: reuse module loader code to write relocations
Date: Thu, 17 Dec 2015 16:45:01 +0100	[thread overview]
Message-ID: <20151217154500.GG3729@pathway.suse.cz> (raw)
In-Reply-To: <20151216054048.GA28258-N0bYjD2NfQ6k4hzjq3hgyGTy53QMssKEsp+A89P3RPuQWHG76I6BsA@public.gmane.org>

On Wed 2015-12-16 00:40:48, Jessica Yu wrote:
> Turns out the string parsing stuff, even with the help of lib/string.c, doesn't
> look very pretty. As I'm working on v3, I'm starting to think having
> klp_write_object_relocations() loop simply through all the elf sections might
> not be a good idea. Let me explain.
> 
> I don't like the amount of string manipulation code that would potentially come
> with this change. Even with a string as simple as ".klp.rela.objname", we'll
> end up with a bunch of kstrdup's/kmalloc's and kfree's (unless we modify and
> chop the section name string in place, which I don't think we should do) that
> are going to be required at every iteration of the loop, all just to be able to
> call strcmp() and see if we're dealing with a klp rela section that belongs to
> the object in question. This also leads to more complicated error handling.

I do not think that we need to allocate and free buffers every time
we compare a substring.

One possibility is to find the position of the substring using
strchr(). Then you could compare it using strncmp() and pass there
the pointer where the substring begins.

Alternatively we could use a static buffer or allocate a big enough
one at the beginning. IMHO, we could assume that function name must
fit into 80 characters, otherwise, that code would be unmanageable
(won't deserve patching). If we use a buffer size 256 bytes,
we should be definitely on the safe side.

Just 2 my cents,
Petr

  parent reply	other threads:[~2015-12-17 15:45 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-01  4:21 [RFC PATCH v2 0/6] (mostly) Arch-independent livepatch Jessica Yu
2015-12-01  4:21 ` [RFC PATCH v2 1/6] Elf: add livepatch-specific Elf constants Jessica Yu
2015-12-01  4:21 ` [RFC PATCH v2 2/6] module: preserve Elf information for livepatch modules Jessica Yu
     [not found]   ` <1448943679-3412-3-git-send-email-jeyu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-12-01  8:48     ` Jessica Yu
2015-12-01 21:06   ` Jessica Yu
2015-12-08 18:32   ` [RFC PATCH v2 2/6] " Josh Poimboeuf
     [not found]     ` <20151208183212.GB14846-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2015-12-09 20:05       ` Jessica Yu
2015-12-10 14:38         ` Josh Poimboeuf
     [not found]           ` <20151210143817.GB29872-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2015-12-16 10:46             ` Miroslav Benes
2015-12-17 16:28     ` [RFC PATCH v2 2/6] " Petr Mladek
2015-12-16 10:58   ` Miroslav Benes
2015-12-17  0:40     ` Jessica Yu
2015-12-17 16:26   ` [RFC PATCH v2 2/6] " Petr Mladek
2015-12-21  5:44     ` Jessica Yu
2015-12-01  4:21 ` [RFC PATCH v2 3/6] module: s390: keep mod_arch_specific " Jessica Yu
2015-12-16 12:02   ` Miroslav Benes
     [not found]     ` <alpine.LNX.2.00.1512161257170.25787-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2015-12-16 23:48       ` Jessica Yu
2015-12-17 11:39         ` Miroslav Benes
2015-12-01  4:21 ` [RFC PATCH v2 4/6] livepatch: reuse module loader code to write relocations Jessica Yu
     [not found]   ` <1448943679-3412-5-git-send-email-jeyu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-12-01  8:43     ` Jessica Yu
2015-12-10 14:20     ` [RFC PATCH v2 4/6] " Minfei Huang
     [not found]       ` <20151210142032.GA2399-4afrMIaGpRkhWf4U84eJi3gqWNq4x99MuOMsETyM3/Q@public.gmane.org>
2015-12-10 19:56         ` Jiri Kosina
     [not found]           ` <alpine.LNX.2.00.1512102055180.9922-YHPUNQjx9ReKbouaWp301Q@public.gmane.org>
2015-12-10 21:12             ` Josh Poimboeuf
2015-12-08 18:38   ` Josh Poimboeuf
     [not found]     ` <20151208183844.GC14846-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2015-12-09 19:10       ` Jessica Yu
     [not found]         ` <20151209191013.GA25387-N0bYjD2NfQ6k4hzjq3hgyGTy53QMssKEsp+A89P3RPuQWHG76I6BsA@public.gmane.org>
2015-12-10 14:28           ` Josh Poimboeuf
2015-12-10 21:33             ` Jessica Yu
     [not found]               ` <20151210213328.GA6553-N0bYjD2NfQ6k4hzjq3hgyGTy53QMssKEsp+A89P3RPuQWHG76I6BsA@public.gmane.org>
2015-12-10 21:41                 ` Josh Poimboeuf
     [not found]                   ` <20151210214115.GD4934-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2015-12-10 22:07                     ` Jessica Yu
2015-12-16  5:40           ` Jessica Yu
2015-12-16 12:59             ` Miroslav Benes
2015-12-16 19:14               ` Jessica Yu
     [not found]             ` <20151216054048.GA28258-N0bYjD2NfQ6k4hzjq3hgyGTy53QMssKEsp+A89P3RPuQWHG76I6BsA@public.gmane.org>
2015-12-17 15:45               ` Petr Mladek [this message]
2015-12-21  5:57                 ` Jessica Yu
2015-12-01  4:21 ` [RFC PATCH v2 5/6] samples: livepatch: init reloc section array and mark as klp module Jessica Yu
2015-12-08 18:41   ` Josh Poimboeuf
2015-12-01  4:21 ` [RFC PATCH v2 6/6] Documentation: livepatch: outline the Elf format of a livepatch module Jessica Yu
  -- strict thread matches above, loose matches on Subject: below --
2016-03-16 19:47 [PATCH v5 0/6] (mostly) Arch-independent livepatch Jessica Yu
2016-03-16 19:47 ` [PATCH v5 4/6] livepatch: reuse module loader code to write relocations Jessica Yu
2016-03-21 13:55   ` Miroslav Benes
2016-03-21 19:18     ` Jessica Yu
2016-03-21 19:24       ` Josh Poimboeuf
2016-03-21 21:16       ` Jiri Kosina
2016-03-21 21:34         ` Josh Poimboeuf
     [not found]           ` <20160321213445.e64jic2uoc7tdtbl-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2016-03-21 22:02             ` Jiri Kosina
2016-03-22 19:00               ` Jessica Yu
2016-03-21 16:31   ` [PATCH v5 4/6] " Petr Mladek
2016-03-21 16:46     ` Josh Poimboeuf
2016-03-21 17:36       ` Josh Poimboeuf
2016-03-21 18:07         ` Jessica Yu
2016-02-04  1:11 [RFC PATCH v4 0/6] (mostly) Arch-independent livepatch Jessica Yu
2016-02-04  1:11 ` [RFC PATCH v4 4/6] livepatch: reuse module loader code to write relocations Jessica Yu
2016-02-08 20:26   ` Josh Poimboeuf
     [not found]     ` <20160208202606.GD23106-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2016-02-10  0:56       ` Jessica Yu
2016-02-09 14:01   ` [RFC PATCH v4 4/6] " Petr Mladek
2016-02-10  1:21     ` Jessica Yu
2016-01-08 19:28 [RFC PATCH v3 0/6] (mostly) Arch-independent livepatch Jessica Yu
2016-01-08 19:28 ` [RFC PATCH v3 4/6] livepatch: reuse module loader code to write relocations Jessica Yu
2016-01-11 21:33   ` Josh Poimboeuf
     [not found]     ` <20160111213349.GB17874-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2016-01-11 22:35       ` Jessica Yu
     [not found]         ` <20160111223513.GA10796-N0bYjD2NfQ6k4hzjq3hgyGTy53QMssKEsp+A89P3RPuQWHG76I6BsA@public.gmane.org>
2016-01-12  3:05           ` Josh Poimboeuf
     [not found]             ` <20160112030552.GC17874-8wJ5/zUtDR0XGNroddHbYwC/G2K4zDHf@public.gmane.org>
2016-01-12  9:12               ` Petr Mladek
2016-01-14  5:07               ` Jessica Yu
2016-01-12 16:40   ` [RFC PATCH v3 4/6] " Miroslav Benes
2016-01-14  3:49     ` Jessica Yu
2016-01-14  9:04       ` Miroslav Benes
2016-01-13  9:19   ` [RFC PATCH v3 4/6] " Miroslav Benes
     [not found]     ` <alpine.LNX.2.00.1601131012340.10011-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2016-01-13 18:39       ` Jessica Yu
2016-01-14  9:10         ` Miroslav Benes
2015-11-10  4:45 [RFC PATCH 0/5] Arch-independent livepatch Jessica Yu
2015-11-10  4:45 ` [RFC PATCH 3/5] livepatch: reuse module loader code to write relocations Jessica Yu
2015-11-11 14:30   ` Miroslav Benes
     [not found]     ` <alpine.LNX.2.00.1511111519250.12467-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2015-11-11 20:07       ` Jessica Yu
     [not found]         ` <20151111200732.GB30025-N0bYjD2NfQ6k4hzjq3hgyGTy53QMssKEsp+A89P3RPuQWHG76I6BsA@public.gmane.org>
2015-11-12 15:27           ` Miroslav Benes
2015-11-12 17:40             ` Josh Poimboeuf
     [not found]               ` <20151112174032.GG4038-M1RQNqTfbHcHO9+bouH2LOBSVt8DKT+lrE5yTffgRl4@public.gmane.org>
2015-11-12 20:22                 ` Jessica Yu
     [not found]                   ` <20151112202243.GC5841-N0bYjD2NfQ6k4hzjq3hgyGTy53QMssKEsp+A89P3RPuQWHG76I6BsA@public.gmane.org>
2015-11-12 20:32                     ` Josh Poimboeuf
     [not found]                       ` <20151112203221.GM4038-M1RQNqTfbHcHO9+bouH2LOBSVt8DKT+lrE5yTffgRl4@public.gmane.org>
2015-11-13  7:15                         ` Jessica Yu
2015-11-13 13:51                       ` Miroslav Benes
     [not found]             ` <alpine.LNX.2.00.1511121601370.9440-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2015-11-12 19:14               ` Jessica Yu
     [not found]                 ` <20151112191458.GB5841-N0bYjD2NfQ6k4hzjq3hgyGTy53QMssKEsp+A89P3RPuQWHG76I6BsA@public.gmane.org>
2015-11-12 20:35                   ` Jessica Yu
2015-11-11 15:22   ` [RFC PATCH 3/5] " Petr Mladek
     [not found]     ` <20151111152256.GP2599-KsEp0d+Q8qECVLCxKZUutA@public.gmane.org>
2015-11-11 18:27       ` Jessica Yu
     [not found]         ` <20151111182718.GA30025-N0bYjD2NfQ6k4hzjq3hgyGTy53QMssKEsp+A89P3RPuQWHG76I6BsA@public.gmane.org>
2015-11-12  9:16           ` Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151217154500.GG3729@pathway.suse.cz \
    --to=pmladek-ibi9rg/b67k@public.gmane.org \
    --cc=corbet-T1hC0tSOHrs@public.gmane.org \
    --cc=jeyu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=jikos-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=jpoimboe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-s390-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=live-patching-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mbenes-AlSwsSmVLrQ@public.gmane.org \
    --cc=rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org \
    --cc=sjenning-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=vojtech-IBi9RG/b67k@public.gmane.org \
    --cc=x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).