From nobody Sat Jul 25 20:08:12 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88D1225783C for ; Tue, 14 Jul 2026 03:17:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783999058; cv=none; b=dpcnkn9RaGm6BI3ZfEe9RBeQPgFmkPcNoHCZtw0uAaUuPf98dLTWAKRnMExK204QTESc0TMkQEr6DJSjqta/mrciFp+k16UUhKEgqrf9RN71d2FFkqEvoyRwOF32f4AP9gdJHGfdmnb2uOBPbU/MHHSu21QKlaJSwb3EUsvrOQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783999058; c=relaxed/simple; bh=eP1UMUSEZyLzbAE+dXzHfTz3rRkOfrV8ahNZEKjhR90=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=XlBmnzPUyhenDcQG++XyVZoFrX+XUjgu8pXHkmNy+wOoaKl03tPDOnjvtD/F5xmMzQzKSrCJ/Qg68lA+YEkkDyxKhvziaeGmEKyfDaI2KynLqWGlcAKFLSaNOjMyQ9B31H1lOAgwp4nvwcmkJDfMTnpyvB14hTJqu5IKlhdegRA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 8bffbed47f3211f1aa26b74ffac11d73-20260714 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:e6d5f85c-3468-4fdc-a6da-7a00af6c07c2,IP:0,U RL:0,TC:0,Content:0,EDM:-20,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-20 X-CID-META: VersionHash:e7bac3a,CLOUDID:50a104ecdc504148a3ec16bcd6675b17,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102|850|865|898,TC:nil,Content:0|15|50,E DM:1,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA: 0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 8bffbed47f3211f1aa26b74ffac11d73-20260714 X-User: xieyi@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 1541791786; Tue, 14 Jul 2026 11:17:29 +0800 From: Yi Xie To: akpm@linux-foundation.org, ljs@kernel.org Cc: linux-kernel@vger.kernel.org, Yi Xie Subject: [PATCH] ipc/shm: check shm_lock() in do_shmat cleanup Date: Tue, 14 Jul 2026 11:17:13 +0800 Message-Id: <20260714031713.72859-1-xieyi@kylinos.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" shm_lock() can fail; don't dereference the error pointer. Signed-off-by: Yi Xie --- ipc/shm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ipc/shm.c b/ipc/shm.c index b3e8a58e177d..bdcf1c0f221d 100644 --- a/ipc/shm.c +++ b/ipc/shm.c @@ -1677,6 +1677,10 @@ long do_shmat(int shmid, char __user *shmaddr, int s= hmflg, out_nattch: down_write(&shm_ids(ns).rwsem); shp =3D shm_lock(ns, shmid); + if (IS_ERR(shp)) { + up_write(&shm_ids(ns).rwsem); + return err; + } shp->shm_nattch--; =20 if (shm_may_destroy(shp)) --=20 2.25.1