]> git.baikalelectronics.ru Git - kernel.git/commit
Revert "Revert "ipv4: fix memory leaks in ip_cmsg_send() callers""
authorEric Dumazet <edumazet@google.com>
Tue, 14 Sep 2021 05:18:51 +0000 (22:18 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 14 Sep 2021 13:24:31 +0000 (14:24 +0100)
commit1f8945190a6c07fc6a527089a8904f808dba3325
tree7650f671289f847a7a157ce5c4d346bcf20d7cfd
parentbe4f0c5c751f936e5c189d444e26069a375b1b66
Revert "Revert "ipv4: fix memory leaks in ip_cmsg_send() callers""

This reverts commit 731bdb5c5f2f219a077ca983f77efbeef2f5e70a.

As mentioned in https://lkml.org/lkml/2021/9/13/1819
5 years old commit 5915988f2f58 ("ipv4: fix memory leaks in ip_cmsg_send() callers")
was a correct fix.

  ip_cmsg_send() can loop over multiple cmsghdr()

  If IP_RETOPTS has been successful, but following cmsghdr generates an error,
  we do not free ipc.ok

  If IP_RETOPTS is not successful, we have freed the allocated temporary space,
  not the one currently in ipc.opt.

Sure, code could be refactored, but let's not bring back old bugs.

Fixes: 731bdb5c5f2f ("Revert "ipv4: fix memory leaks in ip_cmsg_send() callers"")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Yajun Deng <yajun.deng@linux.dev>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/ip_sockglue.c
net/ipv4/ping.c
net/ipv4/raw.c
net/ipv4/udp.c