Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues flagged by Lintian. #200

Merged
merged 9 commits into from
Jan 28, 2022
Merged

Fix issues flagged by Lintian. #200

merged 9 commits into from
Jan 28, 2022

Conversation

ossama-othman
Copy link
Member

Recent attempts to package mptcpd for Debian triggered several Lintian issues. This set of changes addresses some of them. The list of mptcpd related Lintian warnings and errors may be found here.

@ossama-othman ossama-othman added the bug Something isn't working label Jan 20, 2022
@ossama-othman ossama-othman self-assigned this Jan 20, 2022
@coveralls
Copy link

coveralls commented Jan 20, 2022

Pull Request Test Coverage Report for Build 1752399431

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 53.266%

Totals Coverage Status
Change from base Build 1743047505: 0.0%
Covered Lines: 1060
Relevant Lines: 1990

💛 - Coveralls

@@ -16,4 +16,4 @@ AmbientCapabilities=CAP_NET_ADMIN
LimitNPROC=1

[Install]
WantedBy=sockets.target
WantedBy=multi-user.target
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the systemd bootup diagram for further details.

@ossama-othman
Copy link
Member Author

@matttbe: FYI.

Copy link
Member

@mjmartineau mjmartineau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok, I tried building & running on both Ubuntu 18.04 and Fedora 35. Didn't have things set up to try lintian so can't confirm that tool is happy.

One date to fix.

@@ -1,6 +1,6 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright (c) 2017-2019, Intel Corporation
# Copyright (c) 2017-2019, 2021, Intel Corporation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2022?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! I'll fix that right away.

@matttbe
Copy link
Member

matttbe commented Jan 21, 2022

@ossama-othman thank you for the modifications!

I tried the new version and situation is better!

I still have warnings related to the packaging itself I will need to fix but also one warning linked to autotools and reported by Lintian:

I: mptcpd: hardening-no-fortify-functions usr/bin/mptcpize                                                                                                                                                                                                              
N:                                                                                                                                                                                                                                                                      
I: hardening-no-fortify-functions                                                                                                                                                                                                                                       
N:                                                                                                                                                                                                                                                                      
N:   This package provides an ELF binary that lacks the use of fortified                                                                                                                                                                                                
N:   libc functions. Either there are no potentially unfortified functions                                                                                                                                                                                              
N:   called by any routines, all unfortified calls have already been fully                                                                                                                                                                                              
N:   validated at compile-time, or the package was not built with the                                                                                                                                                                                                   
N:   default Debian compiler flags defined by dpkg-buildflags. If built                                                                                                                                                                                                 
N:   using dpkg-buildflags directly, be sure to import CPPFLAGS.                                                                                                                                                                                                        
N:                                                                                                                                                                                                                                                                      
N:   NB: Due to false-positives, Lintian ignores some unprotected functions                                                                                                                                                                                             
N:   (e.g. memcpy).                                                                                                                                                                                                                                                     
N:                                                                                                                                                                                                                                                                      
N:   Refer to https://wiki.debian.org/Hardening and Bug#673112 for details.                                                                                                                                                                                             
N:                                                                                                                                                                                                                                                                      
N:   Severity: info                                                                                                                                                                                                                                                     
N:                                                                                                                                                                                                                                                                      
N:   Check: binaries                                                                                                                                                                                                                                                    
N:                                                                                                                                                                                                                                                                      
I: mptcpd: hardening-no-fortify-functions usr/lib/x86_64-linux-gnu/mptcpd/libmptcpwrap.so.0.0.1

Here are the logs of the build but I don't see any differences with mptcpd: mptcpd_0.8-1.dev1_amd64.build.gz
Or maybe a conflicting option given to ./configure or an env var?

I can share more to be able to reproduce it on your side if you need to.

Also, regarding package-supports-alternative-init-but-no-init.d-script issue, do you have plan to support a traditional init.d system or should I mark it as wont-fix?

@ossama-othman
Copy link
Member Author

@matttbe I was able to reproduce the fortify function issue by running configure like so:

$ CPPFLAGS=-D_FORTIFY_SOURCE=2 ./configure

This causes the following code in configure.ac to behave differently than expected:

# Fortify source
# Enabling optimization implies _FORTIFY_SOURCE on some platforms.
# Explicitly redefine to _FORTIFY_SOURCE=2 to make sure we have the
# desired fortification level.
AX_APPEND_FLAG([-U_FORTIFY_SOURCE], [CPPFLAGS])
AX_APPEND_FLAG([-D_FORTIFY_SOURCE=2], [CPPFLAGS])

The intent of this code is to make CPPFLAGS have -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 appended in that order. The idea is to address the scenario where a lower _FORTIFY_SOURCE value is defined so that the desired greater value is used instead, e.g.:

CPPLAGS="-D_FORTIFY_SOURCE -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2"

However, AX_APPEND_FLAG will only append a flag if it doesn't already exist in the given flag variable, CPPFLAGS in this case. Since the user already set -D_FORTIFY_SOURCE=2 only -U_FORTIFY_SOURCE is appended, resulting in:

CPPLAGS="-D_FORTIFY_SOURCE=2 -U_FORTIFY_SOURCE"

meaning the user defined _FORTIFY_SOURCE preprocessor symbol ends up being undefined.

I'll revise this code in configure.ac to address this issue.

@matttbe
Copy link
Member

matttbe commented Jan 25, 2022

@ossama-othman for the library-not-linked-against-libc error:

E: mptcpd-plugins: library-not-linked-against-libc usr/lib/x86_64-linux-gnu/mptcpd/addr_adv.so                                                                                                                                                                          
N:                                                                                                                                                                                                                                                                      
E: library-not-linked-against-libc                                                                                                  
N:                                                                                                                                  
N:   The package installs a library which is not dynamically linked against                                                                                                                                                                                             
N:   libc.                                                                                                                                                                                                                                                              
N:                                                                                                                                                                                                                                                                      
N:   It is theoretically possible to have a library which doesn't use any                                                                                                                                                                                               
N:   symbols from libc, but it is far more likely that this is a violation                                                                                                                                                                                              
N:   of the requirement that "shared libraries must be linked against all                                                           
N:   libraries that they use symbols from in the same way that binaries                                                             
N:   are".                                                                                                                                                                                                                                                              
N:                                                                                                                                                                                                                                                                      
N:   Refer to Debian Policy Manual section 10.2 (Libraries) and Bug#698720                                                                                                                                                                                              
N:   for details.                                                                                                                                                                                                                                                       
N:                                                                                                                                  
N:   Severity: error                                                                                                                
N:                                                                                                                                                                                                                                                                      
N:   Check: binaries

It might be a false positive, please see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=896012

On the other hand, it is strange there is no issue with sspi:

$ readelf -WltdVs ./debian/mptcpd-plugins/usr/lib/x86_64-linux-gnu/mptcpd/addr_adv.so | grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libell.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libmptcpd.so.3]

$ readelf -WltdVs ./debian/mptcpd-plugins/usr/lib/x86_64-linux-gnu/mptcpd/sspi.so | grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libell.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libmptcpd.so.3]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

Do you confirm it is a false positive and we should ignore this?

Ossama Othman added 9 commits January 25, 2022 17:59
Hardening linker flags such as "-pie" were missing for the `mptcpize'
program.  Explicitly set mptcpize LDFLAGS accordingly.
Prevent '-fPIE' from beging added to the libmptcpwrap CFLAGS.  '-fPIE'
is meant for executables, not shared libraries.
Lintian complains about the "WantedBy=socket.target" in the mptcpd
`mptcp.service' systemd unit file.  Use "multi-user.target" instead.
The configure script ended up causing _FORTIFY_SOURCE to be undefined
if the user explicitly adds _FORTIFY_SOURCE=2 to the CPPFLAGS.  For
example, running the configure script like so:

    CPPFLAGS=-D_FORTIFY_SOURCE=2 ./configure

ultimately caused CPPFLAGS to contain "-D_FORTIFY_SOURCE=2
-U_FORTIFY_SOURCE" instead of "-D_FORTIFY_SOURCE=2
-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2" due to the AX_APPEND_FLAG()
autoconf archive macro behavior of not appending duplicate flags.

Only append -D_FORTIFY_SOURCE=2 to CPPFLAGS if the user hasn't defined
_FORTIFY_SOURCE rather than attempt to override the user provided
value.  This is more in line with Autoconf conventions as well.
Install the libmptcpwrap library in a ${libdir}/mptcpize instead of
${libdir}/mptcpd to differentiate it from mptcpd plugins.

Closes #202.
@ossama-othman
Copy link
Member Author

Potential init.d script can be found in PR #207.

@ossama-othman ossama-othman marked this pull request as ready for review January 28, 2022 16:06
Copy link
Member

@mjmartineau mjmartineau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Copy link
Member

@matttbe matttbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the modifications!

@ossama-othman ossama-othman merged commit 7c43164 into multipath-tcp:master Jan 28, 2022
@ossama-othman ossama-othman deleted the lintian-fixes branch January 28, 2022 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants