Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1259536ybb; Fri, 20 Mar 2020 16:47:29 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuvO26sRg0mL++aQCFBlt4qUK8KjqwarBMwToC/tPhkdo2QHE761fHqV64ZU+NPFC3qMkZU X-Received: by 2002:a05:6830:10cd:: with SMTP id z13mr8832066oto.210.1584748049233; Fri, 20 Mar 2020 16:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584748049; cv=none; d=google.com; s=arc-20160816; b=aljs17dwbSQQYrEYpfcnGiPUSeuwaF+YJAMGztXw3bamP0niVes5qKzpT7aUYu2WvI zUc71rEO/fiWHVTv4jxwvzf2oPxwB6PLRQ7JKmIuE9kIjVjF1xePiPExlvlU6a21acrs 8gMtazjE3DmoeZs2zl3DIccNXgVIa3ArZCzK0ml0qOcQgGSRa9KiFcwQUUJ4hemEggf5 zaXJRmp086dyBhFKoNvaKgcd/m5Iko8lJLAqM4WwUhDqt6YH7BnGChDPRGt+iYZTRp9Z ju1M4i54d8yTRIgEWX+fQMH4j4Tt+3lAUKWkw8LcK6yW/xej0pOc3MPTYk2tZZzMqBrY 8gZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:cc:to:subject:from; bh=5WIUvihdzptW34gyF9bfLLCLV9ms7FJH8QQF69+8cIc=; b=bVdANVTq7r+fhN+yfRAskPgQAwmaEzl7maxZYl8hzP1hhte0lD2cPLkYfGJ4bjQ0Nk MhOPuT2Hc8aozOkjZtj1haB2JCopCxSKFlm7bHTTJNsoiw6u6RZ1CzufD4FLXoiRfiIH kbLOoiEdU5muO9/tcoGC44axjg6KES2binZEjLbIRS3DfELUZlSovJ3jTUL+Hbc5audA u5rqgaf9Yzv4oBXmCciP5dI5L2ePuqO1SXL/a1KnI6qP9+9zg/u/nGEUeP5AfqpGshwT eA19Krf/mwM9SAYzLdXQazjNrV7pEVk8EeP9fERouLo9QtON4bc6l3h/RWeTBT2zS9Yr zYuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p204si3628739oib.241.2020.03.20.16.47.16; Fri, 20 Mar 2020 16:47:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727190AbgCTXqy (ORCPT + 99 others); Fri, 20 Mar 2020 19:46:54 -0400 Received: from mx2.suse.de ([195.135.220.15]:51402 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726773AbgCTXqx (ORCPT ); Fri, 20 Mar 2020 19:46:53 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id AA3CAB2E9; Fri, 20 Mar 2020 23:46:51 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id E3383E0FD3; Sat, 21 Mar 2020 00:46:50 +0100 (CET) From: Michal Kubecek Subject: [PATCH net v2] netlink: check for null extack in cookie helpers To: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Johannes Berg , linux-kernel@vger.kernel.org Message-Id: <20200320234650.E3383E0FD3@unicorn.suse.cz> Date: Sat, 21 Mar 2020 00:46:50 +0100 (CET) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Unlike NL_SET_ERR_* macros, nl_set_extack_cookie_u64() and nl_set_extack_cookie_u32() helpers do not check extack argument for null and neither do their callers, as syzbot recently discovered for ethnl_parse_header(). Instead of fixing the callers and leaving the trap in place, add check of null extack to both helpers to make them consistent with NL_SET_ERR_* macros. v2: drop incorrect second Fixes tag Fixes: 2363d73a2f3e ("ethtool: reject unrecognized request flags") Reported-by: syzbot+258a9089477493cea67b@syzkaller.appspotmail.com Signed-off-by: Michal Kubecek --- include/linux/netlink.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 4090524c3462..60739d0cbf93 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h @@ -115,6 +115,8 @@ static inline void nl_set_extack_cookie_u64(struct netlink_ext_ack *extack, { u64 __cookie = cookie; + if (!extack) + return; memcpy(extack->cookie, &__cookie, sizeof(__cookie)); extack->cookie_len = sizeof(__cookie); } @@ -124,6 +126,8 @@ static inline void nl_set_extack_cookie_u32(struct netlink_ext_ack *extack, { u32 __cookie = cookie; + if (!extack) + return; memcpy(extack->cookie, &__cookie, sizeof(__cookie)); extack->cookie_len = sizeof(__cookie); } -- 2.25.1