Received: by 2002:a05:7412:d008:b0:f9:6acb:47ec with SMTP id bd8csp209625rdb; Tue, 19 Dec 2023 14:14:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUjRLHlD2zcEHcMMM16AQP95wd67PRSRnZ6W3GgbyYobXtGToWRVYhNq/mnWJW5hty+T0Q X-Received: by 2002:a17:906:5306:b0:a23:6e40:1344 with SMTP id h6-20020a170906530600b00a236e401344mr719083ejo.233.1703024064886; Tue, 19 Dec 2023 14:14:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703024064; cv=none; d=google.com; s=arc-20160816; b=iaL6jTR9ZKKsX9z7Q9YUVgNSB1TqNY21n+QhPjcdLRDSfl8qSm8WOyClJDtyBeSvqE DkjnKFPunTXScN8CVPvi5Pk4SpfRnf23QFdQ5mWCrG/VTNOp7OoiX4BUoNk43lyT65E6 gwkE9p+BEEAez7wcixD3s1QD0eW4uBMz6I121e2tpGKYqeOv1OcieGVFACPzYRR8cCMR E0ACJnz04/bZRBUAgvAQ8nUX9o80mOf3Z/TpLvpGg0sabnCbFKr1yRqzoc2RKJYEox6F UjAB2htY9X2YLmU1LKIUkg/pbqSTVN+wkwaYZZQOdyvNEf5ALLNjP0Ky59YmAuPllgdv zcTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:references:in-reply-to :message-id:cc:to:from:date:dkim-signature; bh=KpQ/R44BfxnaThyybloTKnv0rytzbAxoza/GiXNSIDA=; fh=2jIvfeI6klwNMnjVBThcrfH0WmfXHPOpYsTU6oi+0jk=; b=izoaXaOcSKdjTlR7b+vtihjXE5F8rsM9nnpy30LSgVvwrrUsZTJiaMVyCUWS1EfHkp RGcawyOBB2LA/PXxkgxOGlOaufBbY//hoFv8E3x3wLIiU9vAJcGwhFsibFbraIPXEqc2 4hv9k9y/HbJD3S4KZTpTmG0a+cOyyxXCUUtnpMl0BdxIT/CsALQD2glFTZ7WmWAnUON9 8zvr7LZKdq4tw58w6hxwzWEnUo925K/0qk3pDSRbdgrxZebsu4bucM69dv0kPECd5fdL LRu+nkPP4KBNahHcrpVr0iViGv4IyPlbj6MhfFP5W3QDiTfXn7y44HxAyA6W95bmxiTC GoAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ncNJ6vWg; spf=pass (google.com: domain of linux-kernel+bounces-6031-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6031-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id q5-20020a1709066b0500b00a1e11bc93b2si11330838ejr.473.2023.12.19.14.14.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 14:14:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-6031-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ncNJ6vWg; spf=pass (google.com: domain of linux-kernel+bounces-6031-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-6031-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 79CFE1F26493 for ; Tue, 19 Dec 2023 22:14:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F15733DB8C; Tue, 19 Dec 2023 22:06:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ncNJ6vWg" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4E363D0C1; Tue, 19 Dec 2023 22:06:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1d3aa0321b5so27101305ad.2; Tue, 19 Dec 2023 14:06:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703023569; x=1703628369; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=KpQ/R44BfxnaThyybloTKnv0rytzbAxoza/GiXNSIDA=; b=ncNJ6vWgX9CegEJrw/sDH/cC/sIDn8/b+1y8rqdxZYLJFJgEFD3nbcTUN4gPitUMM6 rDv4V7YhzMzWOWo1JMa0OBxaIV+jWepOSRPZ/xFRks3VXqArOraSIPzLkJV3/D44Tqb1 SuuY6sPeVOg0qYmByojdfYYgiFkO13E6na+96pSQ/G1aUPOhM6T2WPB07w+ogammKqMO MEC00qE0QLtGNYC5mBxLGhVIfHMp9S97duNb8iQ4d6hmq3zugul3aPCrHISWL4vQz+MN v7n8aduHqrzxk0ainxT5phbd7yU9fN3DKXo2pWsIrYNZa7rIJi2SAudfsmERwa8xG+Rf CsCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703023569; x=1703628369; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=KpQ/R44BfxnaThyybloTKnv0rytzbAxoza/GiXNSIDA=; b=EZVaquAW6sh0VHpIVzEUSQ6RupExoSORzXfe+fsjJELmeEdjKn+4VP6yeqHr0OFojU DcVTLmZov1VxEW/19JX2cAMjW0lWhSyjAi7sCaIRTrvO9M5ti7F6Tkgs49WWQks4KpX+ btF/tjxyEw8dIThOFIAk1Jv7Ha/tCj0j5R9Tmt60tfHKFAe/wET8rKpM657jeGSae/UO b90dMa+0qhG5+xoDbX+yPVzqE5oA+j8EIer0/pact39cZLXHJa+BkS8zLM8zgtvG84yU kWqH3rq7CaRsXfFc2KEEkr1ks2DoFAJbMJ0ZC0lNZnQ/ctL+mSZ/JXrZXihcsOxNguO3 RbKw== X-Gm-Message-State: AOJu0YzSS3KdUFPZNc0Y8mnRLB6O6HaWhF9pw8wRi1VLjt6dO6hFlb4F WmAmhZr4jflkh+J1G8etCw4= X-Received: by 2002:a17:902:e88f:b0:1d0:6ffd:e2da with SMTP id w15-20020a170902e88f00b001d06ffde2damr23446902plg.116.1703023569011; Tue, 19 Dec 2023 14:06:09 -0800 (PST) Received: from localhost ([98.97.32.4]) by smtp.gmail.com with ESMTPSA id p17-20020a170903249100b001cfbe348ca5sm21533352plw.187.2023.12.19.14.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Dec 2023 14:06:08 -0800 (PST) Date: Tue, 19 Dec 2023 14:06:07 -0800 From: John Fastabend To: John Fastabend , John Fastabend , Kuniyuki Iwashima , xrivendell7@gmail.com Cc: alexander@mihalicyn.com, bpf@vger.kernel.org, daan.j.demeyer@gmail.com, davem@davemloft.net, dhowells@redhat.com, edumazet@google.com, john.fastabend@gmail.com, kuba@kernel.org, kuniyu@amazon.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, pabeni@redhat.com Message-ID: <658213cf198a3_96d8820886@john.notmuch> In-Reply-To: <6581fd3754b79_95e63208f@john.notmuch> References: <20231219155057.12716-1-kuniyu@amazon.com> <6581f509a56ea_90e25208c7@john.notmuch> <6581fd3754b79_95e63208f@john.notmuch> Subject: Re: memory leak in unix_create1/copy_process/security_prepare_creds Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable John Fastabend wrote: > John Fastabend wrote: > > Kuniyuki Iwashima wrote: > > > From: xingwei lee > > > Date: Tue, 19 Dec 2023 17:12:25 +0800 > > > > Hello I found a bug in net/af_unix in the lastest upstream linux > > > > 6.7.rc5 and comfired in lastest net/net-next/bpf/bpf-next tree. > > > > Titled "TITLE: memory leak in unix_create1=E2=80=9D and I also up= load the > > > > repro.c and repro.txt. > > > > = > > > > If you fix this issue, please add the following tag to the commit= : > > > > Reported-by: xingwei Lee > > > = > > > Thanks for reporting! > > > = > > > It seems 8866730aed510 forgot to add sock_put(). > > > I've confirmed that the diff below silenced kmemleak but will check= > > > more before posting a patch. > > = > > Did it really silence the memleak? > = > Yes reverting the patch fixed the issue for me. The problem is we call proto update twice that bumps the refcnt when adding a the same element to the map in the same slot. I'll fix this on sockmap side so we can keep the current af_unix logic. Should be able to push a fix tomorrow. We probably never noticed for other socket types because its an unusal replace to do same sock/same slot, but af_unix has this side effect of incrementing the refcnt that doesn't exist elsewhere. Thanks, John=