From nobody Wed Dec 17 11:52:14 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 505FAC77B73 for ; Thu, 20 Apr 2023 12:06:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234121AbjDTMGS (ORCPT ); Thu, 20 Apr 2023 08:06:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234081AbjDTMGO (ORCPT ); Thu, 20 Apr 2023 08:06:14 -0400 X-Greylist: delayed 105 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 20 Apr 2023 05:06:11 PDT Received: from forwardcorp1b.mail.yandex.net (forwardcorp1b.mail.yandex.net [IPv6:2a02:6b8:c02:900:1:45:d181:df01]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DD0A19AF; Thu, 20 Apr 2023 05:06:10 -0700 (PDT) Received: from mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:7f29:0:640:9a2b:0]) by forwardcorp1b.mail.yandex.net (Yandex) with ESMTP id 4AFA56082B; Thu, 20 Apr 2023 15:04:23 +0300 (MSK) Received: from vsementsov-nix.yandex.net (unknown [2a02:6b8:b081:b58f::1:1d]) by mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id C4dVdH1Or4Y0-LN2mPFV8; Thu, 20 Apr 2023 15:04:22 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1681992262; bh=+Up1ucyvwcaXiWbgdfd9BwoNS2gW3y73aYKQDaLXdUM=; h=Message-Id:Date:Cc:Subject:To:From; b=sSrVGXUTVayl51clBd2Sjz72jObckMVdj0XrzZxAuNIxFN6h0cThC+qs0g85A/PMk N12Mam6BMTYc8avDLPkibyYQtcKyNHYfo07zAjY+eUa5qs2d75K2At7XDU6I/DNSLi Pv0bKfWdZ7LH+QmO9nOOVQS6A6R5CakFMPZ5Rrn0= Authentication-Results: mail-nwsmtp-smtp-corp-main-44.iva.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: Alexander Viro , Christian Brauner Cc: vsementsov@yandex-team.ru, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fs/coredump: open coredump file in O_WRONLY instead of O_RDWR Date: Thu, 20 Apr 2023 15:04:09 +0300 Message-Id: <20230420120409.602576-1-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This makes it possible to make stricter apparmor profile and don't allow the program to read any coredump in the system. Signed-off-by: Vladimir Sementsov-Ogievskiy --- fs/coredump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/coredump.c b/fs/coredump.c index 5df1e6e1eb2b..8f263a389175 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -646,7 +646,7 @@ void do_coredump(const kernel_siginfo_t *siginfo) } else { struct mnt_idmap *idmap; struct inode *inode; - int open_flags =3D O_CREAT | O_RDWR | O_NOFOLLOW | + int open_flags =3D O_CREAT | O_WRONLY | O_NOFOLLOW | O_LARGEFILE | O_EXCL; =20 if (cprm.limit < binfmt->min_coredump) --=20 2.34.1