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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080814102719.GB8046@google.com>
Date:	Thu, 14 Aug 2008 12:27:19 +0200
From:	juliusv@...gle.com (Julius Volz)
To:	Sven Wegener <sven.wegener@...aler.net>
Cc:	netdev@...r.kernel.org, lvs-devel@...r.kernel.org,
	horms@...ge.net.au, kaber@...sh.net, davem@...emloft.net,
	tgraf@...g.ch, vbusam@...gle.com
Subject: Re: [PATCHv3 2/2] IPVS: Add genetlink interface implementation

On Thu, Aug 14, 2008 at 12:04:50PM +0200, Sven Wegener wrote:
> On Thu, 14 Aug 2008, Julius Volz wrote:
> 
> > On Wed, Aug 13, 2008 at 11:51:06PM +0200, Sven Wegener wrote:
> > > On Fri, 8 Aug 2008, Julius Volz wrote:
> > > > +static int ip_vs_genl_get_cmd(struct sk_buff *skb, struct genl_info *info)
> > > > +{
> > > > +	struct sk_buff *msg;
> > > > +	void *reply;
> > > > +	int ret, cmd, reply_cmd;
> > > > +
> > > > +	mutex_lock(&__ip_vs_mutex);
> > > > +
> > > > +	cmd = info->genlhdr->cmd;
> > > > +
> > > > +	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
> > > > +	if (!msg) {
> > > > +		ret = -ENOMEM;
> > > > +		goto out_err;
> > > 
> > > Here you want out...
> > > 
> > > > +	}
> > > > +
> > > > +	if (cmd == IPVS_CMD_GET_SERVICE)
> > > > +		reply_cmd = IPVS_CMD_NEW_SERVICE;
> > > > +	else if (cmd == IPVS_CMD_GET_INFO)
> > > > +		reply_cmd = IPVS_CMD_SET_INFO;
> > > > +	else if (cmd == IPVS_CMD_GET_CONFIG)
> > > > +		reply_cmd = IPVS_CMD_SET_CONFIG;
> > > > +	else {
> > > > +		IP_VS_ERR("unknown Generic Netlink command\n");
> > > > +		ret = -EINVAL;
> > > > +		goto out;
> > > 
> > > ..and here you want out_error, to not leak msg.
> > 
> > Ouch, thanks! Fixed this and locked the mutex later. I also removed the
> > "if (msg)" from out_err, as it becomes unneeded now. Here's the updated
> > patch:
> 
> You missed the static on the register and unregister functions down at the 
> bottom. :) Also see my comments to your change regarding the above issue 
> down here.

Hrm, yes!

> > +static int ip_vs_genl_get_cmd(struct sk_buff *skb, struct genl_info *info)
> > +{
> > +	struct sk_buff *msg;
> > +	void *reply;
> > +	int ret, cmd, reply_cmd;
> > +
> > +	cmd = info->genlhdr->cmd;
> > +
> > +	if (cmd == IPVS_CMD_GET_SERVICE)
> > +		reply_cmd = IPVS_CMD_NEW_SERVICE;
> > +	else if (cmd == IPVS_CMD_GET_INFO)
> > +		reply_cmd = IPVS_CMD_SET_INFO;
> > +	else if (cmd == IPVS_CMD_GET_CONFIG)
> > +		reply_cmd = IPVS_CMD_SET_CONFIG;
> > +	else {
> > +		IP_VS_ERR("unknown Generic Netlink command\n");
> > +		ret = -EINVAL;
> > +		goto out;
> > +	}
> > +
> > +	msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
> > +	if (!msg) {
> > +		ret = -ENOMEM;
> > +		goto out;
> > +	}
> > +
> > +	reply = genlmsg_put_reply(msg, info, &ip_vs_genl_family, 0, reply_cmd);
> > +	if (reply == NULL)
> > +		goto nla_put_failure;
> 
> These gotos now unlock a not locked mutex down in the error path.

What did they put into my water supply :-/ Thanks!

> 
> > +
> > +	mutex_lock(&__ip_vs_mutex);
> 
> Is there a reason not using mutex_lock_interruptible() like the sockopt 
> interface does? I wondered in your earlier patch, but didn't really 
> bother.

Not an expert here. I saw mutex_lock_interruptible() being used in the
old sockopt interface, but returning -ERESTARTSYS on interruption. Can I
do something similar to this from a genetlink function or what is the
right way? I was unsure, so I stuck to mutex_lock()...

Julius
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ