Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 232084 - net-misc/dhcdbd-3.0 - open with O_CREAT in second argument needs 3 arguments in dhcdbd
Summary: net-misc/dhcdbd-3.0 - open with O_CREAT in second argument needs 3 arguments ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] GCC Porting (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Steev Klimaszewski (RETIRED)
URL:
Whiteboard:
Keywords:
: 257139 257342 (view as bug list)
Depends on:
Blocks: fortify-source
  Show dependency tree
 
Reported: 2008-07-17 16:02 UTC by Magnus Granberg
Modified: 2009-02-25 20:55 UTC (History)
12 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Fix O_CREAT bug in dhcdbd (dhcdbd-open_missing_mode.patch,721 bytes, patch)
2008-07-17 16:07 UTC, Magnus Granberg
Details | Diff
fix_open_missing_mode (dhcdbd_fix_open_missing_mode.diff,639 bytes, patch)
2009-02-10 07:55 UTC, Gabriel Máculus
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus Granberg gentoo-dev 2008-07-17 16:02:59 UTC
-DDBUS_API_SUBJECT_TO_CHANGE -D_GNU_SOURCE -I../include -c main.c 
In function ‘open’, 
inlined from ‘dhcdbd_run’ at dhcdbd.c:2816: 
/usr/include/bits/fcntl2.h:51: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT in second argument needs 3 arguments 
make[1]: *** [dhcdbd.o] Error 1 
make[1]: Leaving directory `/var/tmp/portage/net-misc/dhcdbd-3.0/work/dhcdbd-3.0/src' 
make: *** [dhcdbd] Error 2 
O_CRAET bug in dhcdbd-3.0
Gcc 4.3.1 whit fortify_source=2
https://hardened.gentooexperimental.org/secure/ticket/29
Comment 1 Magnus Granberg gentoo-dev 2008-07-17 16:07:21 UTC
Created attachment 160646 [details, diff]
Fix O_CREAT bug in dhcdbd
Comment 2 Mark Loeser (RETIRED) gentoo-dev 2008-11-23 19:51:53 UTC
This only seems to happen because of -DFORTIFY_SOURCE=2, so this shouldn't block our gcc-4.3 tracker.
Comment 3 David Carlos Manuelda 2009-01-28 08:24:46 UTC
I can confirm here using gcc 4.3.3 and same erros (O_CREATE related) without a hardened profile (and possibly without fortify_source).
Comment 4 Xake 2009-01-28 10:13:01 UTC
(In reply to comment #3)
> I can confirm here using gcc 4.3.3 and same erros (O_CREATE related) without a
> hardened profile (and possibly without fortify_source).
> 

gcc-4.3.2-r3 and probably gcc-4.3.3 in portage enable fotify per default [1]
So this is probably a fortify problem.

[1] http://marc.info/?l=gentoo-dev&m=123162258513047&w=2
Comment 5 David Carlos Manuelda 2009-01-28 16:22:49 UTC
Oh, I didn't know that, anyway, I downgraded to gcc-4.3.2-r3 and it builds fine now, so it seems only to fail with the new 4.3.3
Comment 6 Reginald Tiangha 2009-02-01 05:56:14 UTC
Yeah, dhcdbd no longer compiles with the default gcc 4.3.3 (I'm running x86_64, glibc 2.8).

Temporarily adding -U_FORTIFY_SOURCE to my CFLAGS and compiling dhcdbd with that allowed it to compile successfully.
Comment 7 Gabriel Máculus 2009-02-10 07:55:48 UTC
Created attachment 181515 [details, diff]
fix_open_missing_mode
Comment 8 Magnus Granberg gentoo-dev 2009-02-10 14:10:26 UTC
(In reply to comment #7)
> Created an attachment (id=181515) [edit]
> fix_open_missing_mode
> 

Will not work and you still don't have mode for O_CREAT
man open:
mode specifies the permissions to use in case a new file is created.  This argument must be supplied when O_CREAT is specified in flags......
Comment 9 Gabriel Máculus 2009-02-11 23:25:31 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > Created an attachment (id=181515) [edit]
> > fix_open_missing_mode
> > 
> 
> Will not work and you still don't have mode for O_CREAT
> man open:
> mode specifies the permissions to use in case a new file is created.  This
> argument must be supplied when O_CREAT is specified in flags......
> 
yes, is my type error. sorry, i´m reviewing this...
Comment 10 Martin Väth 2009-02-17 09:01:02 UTC
*** Bug 257342 has been marked as a duplicate of this bug. ***
Comment 11 Peter Alfredsen (RETIRED) gentoo-dev 2009-02-17 23:26:34 UTC
*** Bug 257139 has been marked as a duplicate of this bug. ***
Comment 12 Tom Voss 2009-02-18 00:17:44 UTC
The issue is caused by dhcdbd-3.0-daemon.patch which for some reason when moving the following line:
"if ((fd = open (DHCDBD_PID_FILE, O_WRONLY | O_CREAT, 0644)) == -1)"
drops the ", 0644".  It compiles fine without the daemon patch for me, and also if I add ", 0644" back into the daemon patch.

Magnus, your patch looks good other than "0644" is equivalent to "S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH", so you're dropping read access for group and other from the original code.  (Note: This may be preferred, I really haven't dug into what the code is doing I'm just noting that it's different than the unpatched code before the dhcdbd-3.0-daemon.patch.)
Comment 13 Magnus Granberg gentoo-dev 2009-02-18 01:23:15 UTC
(In reply to comment #12)
> The issue is caused by dhcdbd-3.0-daemon.patch which for some reason when
> moving the following line:
> "if ((fd = open (DHCDBD_PID_FILE, O_WRONLY | O_CREAT, 0644)) == -1)"
> drops the ", 0644".  It compiles fine without the daemon patch for me, and also
> if I add ", 0644" back into the daemon patch.
> 
> Magnus, your patch looks good other than "0644" is equivalent to "S_IRUSR |
> S_IWUSR | S_IRGRP | S_IROTH", so you're dropping read access for group and
> other from the original code.  (Note: This may be preferred, I really haven't
> dug into what the code is doing I'm just noting that it's different than the
> unpatched code before the dhcdbd-3.0-daemon.patch.)
> 
We have uset that patch on the hardened overlay for gcc 4 with no error so far. But if we need read access for grup to so add it. The caode should be fixed upstream.
Comment 14 SpanKY gentoo-dev 2009-02-24 07:23:52 UTC
Comment on attachment 181515 [details, diff]
fix_open_missing_mode

this change is clearly wrong
Comment 15 Rémi Cardona (RETIRED) gentoo-dev 2009-02-24 19:53:37 UTC
Steev,

do you mind if I commit this? I just got bit by this on a fresh ~amd64 stage3.

Thanks
Comment 16 Robert Buchholz (RETIRED) gentoo-dev 2009-02-25 20:55:38 UTC
committed, thanks for the patch.