public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: jpoimboe@redhat.com, mbenes@suze.cz,
	linux-kernel@vger.kernel.org, x86@kernel.org
Subject: Re: [PATCH 1/3] objtool: Add --backup
Date: Fri, 26 Feb 2021 12:48:19 +0100	[thread overview]
Message-ID: <20210226114819.GC19284@zn.tnic> (raw)
In-Reply-To: <20210226110004.133170708@infradead.org>

On Fri, Feb 26, 2021 at 11:57:43AM +0100, Peter Zijlstra wrote:
> +static bool objtool_create_backup(const char *_objname)
> +{
> +	int len = strlen(_objname);
> +	char *buf, *base, *name = malloc(len+3);
> +	int s, d, l, t;
> +
> +	if (!name) {
> +		WARN("failed backup name malloc");
> +		return false;
> +	}
> +
> +	strcpy(name, _objname);
> +	strcpy(name + len, "bj");
> +
> +	d = open(name, O_CREAT|O_WRONLY|O_TRUNC);

Yah, as mentioned on IRC and let me paste it here too, you need to
supply mode with O_CREAT:

	d = open(name, O_CREAT|O_RDWR|O_TRUNC,S_IRUSR);

or so. Also you could add perror("open") to those error paths so that it
can say why it failed creating the backup file.

With that, thanks for doing those!

Acked-by: Borislav Petkov <bp@suse.de>

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

  reply	other threads:[~2021-02-26 11:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-26 10:57 [PATCH 0/3] objtool: OBJTOOL_ARGS and --backup Peter Zijlstra
2021-02-26 10:57 ` [PATCH 1/3] objtool: Add --backup Peter Zijlstra
2021-02-26 11:48   ` Borislav Petkov [this message]
2021-03-02 11:58     ` Peter Zijlstra
2021-03-03  8:45       ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2021-03-06 11:48       ` tip-bot2 for Peter Zijlstra
2021-02-26 10:57 ` [PATCH 2/3] objtool: Collate parse_options() users Peter Zijlstra
2021-03-03  8:45   ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2021-03-06 11:48   ` tip-bot2 for Peter Zijlstra
2021-02-26 10:57 ` [PATCH 3/3] objtool: Parse options from OBJTOOL_ARGS Peter Zijlstra
2021-03-03  8:45   ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2021-03-04 14:12     ` Peter Zijlstra
2021-03-06 11:48   ` tip-bot2 for Peter Zijlstra
2021-02-26 12:27 ` [PATCH 0/3] objtool: OBJTOOL_ARGS and --backup Peter Zijlstra
2021-03-03  0:29 ` Josh Poimboeuf

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=20210226114819.GC19284@zn.tnic \
    --to=bp@alien8.de \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbenes@suze.cz \
    --cc=peterz@infradead.org \
    --cc=x86@kernel.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