lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20191215112017.07502383@hermes.lan>
Date:   Sun, 15 Dec 2019 11:20:17 -0800
From:   Stephen Hemminger <stephen@...workplumber.org>
To:     Aditya Pakki <pakki001@....edu>
Cc:     kjlu@....edu, "David S. Miller" <davem@...emloft.net>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Markus Elfring <elfring@...rs.sourceforge.net>,
        Richard Fontana <rfontana@...hat.com>,
        Thomas Gleixner <tglx@...utronix.de>, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] hdlcdrv: replace assertion with recovery code

On Sun, 15 Dec 2019 11:58:41 -0600
Aditya Pakki <pakki001@....edu> wrote:

> In hdlcdrv_register, failure to register the driver causes a crash.
> However, by returning the error to the caller in case ops is NULL
> can avoid the crash. The patch fixes this issue.
> 
> Signed-off-by: Aditya Pakki <pakki001@....edu>
> ---
>  drivers/net/hamradio/hdlcdrv.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
> index df495b5595f5..38e5d1e54800 100644
> --- a/drivers/net/hamradio/hdlcdrv.c
> +++ b/drivers/net/hamradio/hdlcdrv.c
> @@ -687,7 +687,8 @@ struct net_device *hdlcdrv_register(const struct hdlcdrv_ops *ops,
>  	struct hdlcdrv_state *s;h
>  	int err;
>  
> -	BUG_ON(ops == NULL);
> +	if (!ops)
> +		return ERR_PTR(-EINVAL);
>  
>  	if (privsize < sizeof(struct hdlcdrv_state))
>  		privsize = sizeof(struct hdlcdrv_state);

It is good to remove BUG_ON's but this is not a good way to fix it.
The original code was being over paranoid.  There are only 3 places
this function is called in the current kernel and all pass a valid
pointer.  Better just remove the BUG_ON all together; it is not
worth carrying bug checks for "some day somebody might add broken code".

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ